Main.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. MWF.xApplication.FindDesigner.options.multitask = false;
  2. MWF.xApplication.FindDesigner.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "default",
  7. "name": "FindDesigner",
  8. "mvcStyle": "style.css",
  9. "icon": "icon.png",
  10. "width": "1200",
  11. "height": "800",
  12. "isResize": true,
  13. "isMax": true,
  14. "layout": {
  15. "type": "leftRight",
  16. "percent": 0.4
  17. },
  18. "title": MWF.xApplication.FindDesigner.LP.title
  19. },
  20. onQueryLoad: function(){
  21. this.lp = MWF.xApplication.FindDesigner.LP;
  22. this.filterOption = {
  23. "keyword": "",
  24. "type": [],
  25. "caseSensitive": false,
  26. "matchWholeWord": false,
  27. "matchRegExp": false,
  28. "moduleList": []
  29. }
  30. debugger;
  31. o2.UD.getDataJson("findDesignerLayout", function(json){
  32. this.setOptions(json);
  33. }.bind(this), false);
  34. },
  35. loadApplication: function(callback){
  36. var url = this.path+this.options.style+"/view.html";
  37. this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){
  38. this.setSizeNode();
  39. if (callback) callback();
  40. }.bind(this));
  41. },
  42. initLayout: function(){
  43. this.listNode.set("style", "");
  44. this.previewNode.set("style", "");
  45. if (this.resizeDrag) this.resizeDrag.detach();
  46. if (this.sizeNodeFun) this.removeEvent("resize", this.sizeNodeFun);
  47. if (this.options.layout.type=="leftRight"){
  48. this.toLeftRight();
  49. }else{
  50. this.toTopBottom();
  51. }
  52. },
  53. setSizeNode: function(){
  54. this.initLayout();
  55. this["sizeNode_"+this.options.layout.type]();
  56. this["setResizeNode_"+this.options.layout.type]();
  57. this.sizeNodeFun = null;
  58. this.sizeNodeFun = this["sizeNode_"+this.options.layout.type].bind(this);
  59. this.addEvent("resize", this.sizeNodeFun);
  60. },
  61. sizeResultNode: function(){
  62. var size = this.content.getSize();
  63. var filterSzie = this.filterNode.getSize();
  64. var keywordSize = this.keywordNode.getSize();
  65. var rangeSize = this.rangeNode.getSize();
  66. var h = size.y-filterSzie.y-keywordSize.y-rangeSize.y;
  67. this.resultNode.setStyle("height", ""+h+"px");
  68. return h;
  69. },
  70. sizeNode_topBottom: function(){
  71. var h = this.sizeResultNode();
  72. var listHeight = h*this.options.layout.percent;
  73. this.listNode.setStyle("height", ""+listHeight+"px");
  74. var previewHeight = h*(1-this.options.layout.percent);
  75. this.previewNode.setStyle("height", ""+previewHeight+"px");
  76. var previewSeparatorSize = this.previewSeparatorNode.getSize();
  77. var previewTitleSize = this.previewTitleNode.getSize();
  78. var previewContentHeight = previewHeight - previewSeparatorSize.y - previewTitleSize.y;
  79. this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
  80. },
  81. sizeNode_leftRight: function(){
  82. var h = this.sizeResultNode();
  83. var w = this.resultNode.getSize().x;
  84. var listWidth = w*this.options.layout.percent;
  85. this.listNode.setStyle("width", ""+listWidth+"px");
  86. this.previewNode.setStyle("margin-left", ""+listWidth+"px");
  87. //var previewSeparatorSize = this.previewSeparatorNode.getSize();
  88. var previewTitleSize = this.previewTitleNode.getSize();
  89. var previewContentHeight = h - previewTitleSize.y;
  90. this.previewContentNode.setStyle("height", ""+previewContentHeight+"px");
  91. },
  92. setResizeNode_topBottom: function(){
  93. if (this.previewSeparatorNode){
  94. this.resizeDrag = new Drag(this.previewSeparatorNode, {
  95. "onStart": function(el, e){
  96. el.store("position", o2.eventPosition(e));
  97. el.store("initialSize", this.listNode.getSize());
  98. }.bind(this),
  99. "onDrag": function(el, e){
  100. var p = o2.eventPosition(e);
  101. var position = el.retrieve("position");
  102. var initialSize = el.retrieve("initialSize");
  103. var dy = position.y.toFloat()-p.y.toFloat();
  104. var height = initialSize.y-dy;
  105. var size = this.resultNode.getSize();
  106. this.options.layout.percent = height/size.y;
  107. if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
  108. if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
  109. this.sizeNode_topBottom();
  110. }.bind(this),
  111. "onComplete": function(){
  112. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  113. }.bind(this)
  114. });
  115. }
  116. },
  117. setResizeNode_leftRight: function(){
  118. if (this.previewSeparatorNode){
  119. this.resizeDrag = new Drag(this.previewSeparatorNode, {
  120. "onStart": function(el, e){
  121. el.store("position", o2.eventPosition(e));
  122. el.store("initialSize", this.listNode.getSize());
  123. }.bind(this),
  124. "onDrag": function(el, e){
  125. var p = o2.eventPosition(e);
  126. var position = el.retrieve("position");
  127. var initialSize = el.retrieve("initialSize");
  128. var dx = position.x.toFloat()-p.x.toFloat();
  129. var width = initialSize.x-dx;
  130. var size = this.resultNode.getSize();
  131. this.options.layout.percent = width/size.x;
  132. if (this.options.layout.percent<0.1) this.options.layout.percent = 0.1;
  133. if (this.options.layout.percent>0.85) this.options.layout.percent = 0.85;
  134. this.sizeNode_leftRight();
  135. }.bind(this),
  136. "onComplete": function(){
  137. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  138. }.bind(this)
  139. });
  140. }
  141. },
  142. checkFilter: function(e){
  143. if (e.target.hasClass("o2_findDesigner_filterNode_item")) e.target.getElement("input").click();
  144. e.stopPropagation();
  145. },
  146. overKeywordOption: function(e){
  147. if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")){
  148. if (!e.target.hasClass("optionItem_over")) e.target.addClass("optionItem_over");
  149. }
  150. },
  151. outKeywordOption: function(e){
  152. if (e.target.hasClass("o2_findDesigner_keywordNode_optionItem")) e.target.removeClass("optionItem_over");
  153. },
  154. setCaseSensitive: function(e){
  155. this.filterOption.caseSensitive = !this.filterOption.caseSensitive;
  156. this.caseSensitiveNode.removeClass("caseSensitiveNode_"+!this.filterOption.caseSensitive);
  157. this.caseSensitiveNode.addClass("caseSensitiveNode_"+this.filterOption.caseSensitive);
  158. },
  159. setMatchWholeWord: function(e){
  160. this.filterOption.matchWholeWord = !this.filterOption.matchWholeWord;
  161. this.matchWholeWordNode.removeClass("matchWholeWordNode_"+!this.filterOption.matchWholeWord);
  162. this.matchWholeWordNode.addClass("matchWholeWordNode_"+this.filterOption.matchWholeWord);
  163. },
  164. setMatchRegExp: function(e){
  165. this.filterOption.matchRegExp = !this.filterOption.matchRegExp;
  166. this.matchRegExpNode.removeClass("matchRegExpNode_"+!this.filterOption.matchRegExp);
  167. this.matchRegExpNode.addClass("matchRegExpNode_"+this.filterOption.matchRegExp);
  168. },
  169. layoutAddClass: function(flag){
  170. flag = flag || "";
  171. this.listNode.addClass("listNode"+flag);
  172. this.previewNode.addClass("previewNode"+flag);
  173. this.previewSeparatorNode.addClass("previewNode_separator"+flag);
  174. this.previewTitleNode.addClass("previewNode_title"+flag);
  175. this.previewTitleActionNode.addClass("previewNode_title_action"+flag);
  176. this.previewContentNode.addClass("previewNode_content"+flag);
  177. },
  178. layoutRemoveClass: function(flag){
  179. flag = flag || "";
  180. this.listNode.removeClass("listNode"+flag);
  181. this.previewNode.removeClass("previewNode"+flag);
  182. this.previewSeparatorNode.removeClass("previewNode_separator"+flag);
  183. this.previewTitleNode.removeClass("previewNode_title"+flag);
  184. this.previewTitleActionNode.removeClass("previewNode_title_action"+flag);
  185. this.previewContentNode.removeClass("previewNode_content"+flag);
  186. },
  187. toLeftRight: function(){
  188. this.layoutAddClass("_lr");
  189. this.layoutRemoveClass();
  190. this.options.layout.type="leftRight";
  191. },
  192. toTopBottom: function(){
  193. this.layoutAddClass();
  194. this.layoutRemoveClass("_lr");
  195. this.options.layout.type="topBottom";
  196. },
  197. changeLayout: function(){
  198. if (this.options.layout.type=="leftRight"){
  199. this.options.layout.type="topBottom";
  200. }else{
  201. this.options.layout.type="leftRight";
  202. }
  203. debugger;
  204. this.setSizeNode();
  205. o2.UD.putData("findDesignerLayout", {"layout": this.options.layout});
  206. }
  207. });