SectionSelector.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Forum.SectionSelector = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Forum.LP.selectList,
  9. "values": [],
  10. "appId" : "",
  11. "formId": "",
  12. "expand": false
  13. },
  14. initialize: function(container, options){
  15. this.setOptions(options);
  16. this.path = "../x_component_Selector/$Selector/";
  17. this.cssPath = "../x_component_Selector/$Selector/"+this.options.style+"/css.wcss";
  18. this._loadCss(true);
  19. this.container = $(container);
  20. this.action = MWF.Actions.get("x_bbs_assemble_control"); //new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  21. this.lastPeople = "";
  22. this.pageCount = "13";
  23. this.selectedItems = [];
  24. this.items = [];
  25. },
  26. loadSelectItems: function(addToNext){
  27. this.action.listCategoryAll(function(json){
  28. (json.data || []).each(function(d){
  29. if(d.forumStatus != MWF.xApplication.Forum.LP.disable ){
  30. this.action.listSection(d.id , function (js) {
  31. d.name = d.forumName;
  32. d.sectionList = ( js.data || [] );
  33. var category = this._newItemCategory(d , this, this.itemAreaNode);
  34. d.sectionList.each( function( sectiondata ){
  35. sectiondata.name = sectiondata.sectionName;
  36. var item = this._newItem(sectiondata, this, category.children);
  37. this.items.push(item);
  38. }.bind(this))
  39. }.bind(this));
  40. }
  41. }.bind(this));
  42. }.bind(this));
  43. },
  44. _scrollEvent: function(y){
  45. return true;
  46. },
  47. _getChildrenItemIds: function(data){
  48. return data.sectionList || [];
  49. },
  50. _newItemCategory: function(data, selector, item, level){
  51. return new MWF.xApplication.Forum.SectionSelector.ItemCategory(data, selector, item, level)
  52. },
  53. _listItemByKey: function(callback, failure, key){
  54. return false;
  55. },
  56. _getItem: function(callback, failure, id, async){
  57. //this.action.getProcess(function(json){
  58. // if (callback) callback.apply(this, [json]);
  59. //}.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
  60. },
  61. _newItemSelected: function(data, selector, item){
  62. return new MWF.xApplication.Forum.SectionSelector.ItemSelected(data, selector, item)
  63. },
  64. _listItemByPinyin: function(callback, failure, key){
  65. return false;
  66. },
  67. _newItem: function(data, selector, container, level){
  68. return new MWF.xApplication.Forum.SectionSelector.Item(data, selector, container, level);
  69. }
  70. });
  71. MWF.xApplication.Forum.SectionSelector.Item = new Class({
  72. Extends: MWF.xApplication.Selector.Person.Item,
  73. _getShowName: function(){
  74. return this.data.name;
  75. },
  76. _setIcon: function(){
  77. //this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/processicon.png)");
  78. },
  79. loadSubItem: function(){
  80. return false;
  81. },
  82. checkSelectedSingle: function(){
  83. var selectedItem = this.selector.options.values.filter(function(item, index){
  84. if (typeOf(item)==="object") return (this.data.id === item.id) || (this.data.name === item.name) ;
  85. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  86. return false;
  87. }.bind(this));
  88. if (selectedItem.length){
  89. this.selectedSingle();
  90. }
  91. },
  92. checkSelected: function(){
  93. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  94. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  95. }.bind(this));
  96. if (selectedItem.length){
  97. //selectedItem[0].item = this;
  98. selectedItem[0].addItem(this);
  99. this.selectedItem = selectedItem[0];
  100. this.setSelected();
  101. }
  102. }
  103. });
  104. MWF.xApplication.Forum.SectionSelector.ItemSelected = new Class({
  105. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  106. _getShowName: function(){
  107. return this.data.name;
  108. },
  109. _setIcon: function(){
  110. //this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/processicon.png)");
  111. },
  112. check: function(){
  113. if (this.selector.items.length){
  114. var items = this.selector.items.filter(function(item, index){
  115. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  116. }.bind(this));
  117. this.items = items;
  118. if (items.length){
  119. items.each(function(item){
  120. item.selectedItem = this;
  121. item.setSelected();
  122. }.bind(this));
  123. }
  124. }
  125. }
  126. });
  127. MWF.xApplication.Forum.SectionSelector.ItemCategory = new Class({
  128. Extends: MWF.xApplication.Selector.Person.ItemCategory,
  129. _getShowName: function(){
  130. return this.data.name;
  131. },
  132. createNode: function(){
  133. this.node = new Element("div", {
  134. "styles": this.selector.css.selectorItemCategory_department
  135. }).inject(this.container);
  136. },
  137. _setIcon: function(){
  138. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/default/icon/applicationicon.png)");
  139. },
  140. _hasChild: function(){
  141. return (this.data.sectionList && this.data.sectionList.length);
  142. },
  143. check: function(){}
  144. });