Portal.js 3.9 KB

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