Portal.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.Portal = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectApplication,
  9. "values": [],
  10. "expand": false,
  11. "forceSearchInItem" : true
  12. },
  13. _init : function(){
  14. this.selectType = "portal";
  15. this.className = "Portal";
  16. },
  17. loadSelectItems: function(addToNext){
  18. this.portalDesignerAction.listApplication(function(json){
  19. json.data.each(function(data){
  20. var category = this._newItem(data, this, this.itemAreaNode);
  21. this.items.push( category );
  22. }.bind(this));
  23. }.bind(this));
  24. },
  25. _scrollEvent: function(y){
  26. return true;
  27. },
  28. _getChildrenItemIds: function(){
  29. return null;
  30. },
  31. _listItemByKey: function(callback, failure, key){
  32. return false;
  33. },
  34. _getItem: function(callback, failure, id, async){
  35. this.portalDesignerAction.getApplications(function(json){
  36. if (callback) callback.apply(this, [json]);
  37. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
  38. },
  39. _newItemSelected: function(data, selector, item){
  40. return new MWF.xApplication.Selector.Portal.ItemSelected(data, selector, item)
  41. },
  42. _listItemByPinyin: function(callback, failure, key){
  43. return false;
  44. },
  45. _newItem: function(data, selector, container, level){
  46. return new MWF.xApplication.Selector.Portal.Item(data, selector, container, level);
  47. }
  48. });
  49. MWF.xApplication.Selector.Portal.Item = new Class({
  50. Extends: MWF.xApplication.Selector.Person.Item,
  51. _getShowName: function(){
  52. return this.data.name;
  53. },
  54. _setIcon: function(){
  55. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)");
  56. },
  57. loadSubItem: function(){
  58. return false;
  59. },
  60. checkSelectedSingle: function(){
  61. var selectedItem = this.selector.options.values.filter(function(item, index){
  62. if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
  63. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  64. return false;
  65. }.bind(this));
  66. if (selectedItem.length){
  67. this.selectedSingle();
  68. }
  69. },
  70. checkSelected: function(){
  71. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  72. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  73. }.bind(this));
  74. if (selectedItem.length){
  75. //selectedItem[0].item = this;
  76. selectedItem[0].addItem(this);
  77. this.selectedItem = selectedItem[0];
  78. this.setSelected();
  79. }
  80. }
  81. });
  82. MWF.xApplication.Selector.Portal.ItemSelected = new Class({
  83. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  84. _getShowName: function(){
  85. return this.data.name;
  86. },
  87. _setIcon: function(){
  88. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)");
  89. },
  90. check: function(){
  91. if (this.selector.items.length){
  92. var items = this.selector.items.filter(function(item, index){
  93. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  94. }.bind(this));
  95. this.items = items;
  96. if (items.length){
  97. items.each(function(item){
  98. item.selectedItem = this;
  99. item.setSelected();
  100. }.bind(this));
  101. }
  102. }
  103. }
  104. });