Portal.js 3.7 KB

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