CMSCategory.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Identity", null, false);
  3. MWF.xApplication.Selector.CMSCategory = new Class({
  4. Extends: MWF.xApplication.Selector.Identity,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectCMSCategory,
  9. "values": [],
  10. "names": [],
  11. "expand": false
  12. },
  13. loadSelectItems: function(addToNext){
  14. this.cmsAction.listCMSApplication(function(json){
  15. if (json.data.length){
  16. json.data.each(function(data){
  17. data.name = data.appName;
  18. var category = this._newItemCategory(data, this, this.itemAreaNode);
  19. }.bind(this));
  20. }
  21. }.bind(this));
  22. },
  23. _scrollEvent: function(y){
  24. return true;
  25. },
  26. _getChildrenItemIds: function(){
  27. return null;
  28. },
  29. _newItemCategory: function(data, selector, item, level){
  30. return new MWF.xApplication.Selector.CMSCategory.ItemCategory(data, selector, item, level)
  31. },
  32. _listItemByKey: function(callback, failure, key){
  33. return false;
  34. },
  35. _getItem: function(callback, failure, id, async){
  36. //this.action.getDepartment(function(json){
  37. // if (callback) callback.apply(this, [json]);
  38. //}.bind(this), failure, id, async);
  39. },
  40. _newItemSelected: function(data, selector, item){
  41. return new MWF.xApplication.Selector.CMSCategory.ItemSelected(data, selector, item)
  42. },
  43. _listItemByPinyin: function(callback, failure, key){
  44. return false;
  45. },
  46. _newItem: function(data, selector, container, level){
  47. return new MWF.xApplication.Selector.CMSCategory.Item(data, selector, container, level);
  48. }
  49. });
  50. MWF.xApplication.Selector.CMSCategory.Item = new Class({
  51. Extends: MWF.xApplication.Selector.Identity.Item,
  52. _getShowName: function(){
  53. return this.data.name;
  54. },
  55. _setIcon: function(){
  56. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  57. },
  58. loadSubItem: function(){
  59. return false;
  60. // this.children = new Element("div", {
  61. // "styles": this.selector.css.selectorItemCategoryChildrenNode
  62. // }).inject(this.node, "after");
  63. // this.children.setStyle("display", "block");
  64. //// if (!this.selector.options.expand) this.children.setStyle("display", "none");
  65. //
  66. // this.selector.action.listProcess(function(subJson){
  67. // subJson.data.each(function(subData){
  68. // var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  69. // }.bind(this));
  70. // }.bind(this), null, this.data.id);
  71. },
  72. getData: function(callback){
  73. if (callback) callback();
  74. },
  75. checkSelectedSingle: function(){
  76. var selectedItem = this.selector.options.values.filter(function(item, index){
  77. if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
  78. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  79. return false;
  80. }.bind(this));
  81. if (selectedItem.length){
  82. this.selectedSingle();
  83. }
  84. },
  85. checkSelected: function(){
  86. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  87. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  88. }.bind(this));
  89. if (selectedItem.length){
  90. //selectedItem[0].item = this;
  91. selectedItem[0].addItem(this);
  92. this.selectedItem = selectedItem[0];
  93. this.setSelected();
  94. }
  95. }
  96. });
  97. MWF.xApplication.Selector.CMSCategory.ItemSelected = new Class({
  98. Extends: MWF.xApplication.Selector.Identity.ItemSelected,
  99. getData: function(callback){
  100. if (callback) callback();
  101. },
  102. _getShowName: function(){
  103. return this.data.name;
  104. },
  105. _setIcon: function(){
  106. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/processicon.png)");
  107. }
  108. });
  109. MWF.xApplication.Selector.CMSCategory.ItemCategory = new Class({
  110. Extends: MWF.xApplication.Selector.Identity.ItemCategory,
  111. _setIcon: function(){
  112. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  113. },
  114. loadSub: function(callback){
  115. if (!this.loaded){
  116. this.selector.cmsAction.listCMSCategory(function(subJson){
  117. subJson.data.each(function(subData){
  118. subData.name = subData.categoryName;
  119. subData.applicationName = this.data.name;
  120. subData.application = this.data.id;
  121. var category = this.selector._newItem(subData, this.selector, this.children, this.level+1);
  122. }.bind(this));
  123. this.loaded = true;
  124. if (callback) callback();
  125. }.bind(this), null, this.data.id);
  126. }else{
  127. if (callback) callback();
  128. }
  129. },
  130. _hasChild: function(){
  131. return (this.data.wrapOutCategoryList && this.data.wrapOutCategoryList.length);
  132. },
  133. check: function(){}
  134. });