View.js 76 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848
  1. MWF.xApplication = MWF.xApplication || {};
  2. MWF.xApplication.query = MWF.xApplication.query || {};
  3. MWF.xApplication.query.ViewDesigner = MWF.xApplication.query.ViewDesigner || {};
  4. MWF.APPDVD = MWF.xApplication.query.ViewDesigner;
  5. MWF.require("MWF.widget.Common", null, false);
  6. MWF.require("MWF.xScript.Macro", null, false);
  7. MWF.xDesktop.requireApp("query.ViewDesigner", "lp."+MWF.language, null, false);
  8. MWF.xDesktop.requireApp("query.ViewDesigner", "Property", null, false);
  9. MWF.xApplication.query.ViewDesigner.View = new Class({
  10. Extends: MWF.widget.Common,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "isView": false,
  15. "showTab": true,
  16. "propertyPath": "/x_component_query_ViewDesigner/$View/view.html"
  17. },
  18. initialize: function(designer, data, options){
  19. this.setOptions(options);
  20. this.path = "/x_component_query_ViewDesigner/$View/";
  21. this.cssPath = "/x_component_query_ViewDesigner/$View/"+this.options.style+"/css.wcss";
  22. this._loadCss();
  23. this.designer = designer;
  24. this.data = data;
  25. if (!this.data.data) this.data.data = {};
  26. this.parseData();
  27. this.node = this.designer.designNode;
  28. //this.tab = this.designer.tab;
  29. this.areaNode = new Element("div", {"styles": {"height": "100%", "overflow": "auto"}});
  30. //MWF.require("MWF.widget.ScrollBar", function(){
  31. // new MWF.widget.ScrollBar(this.areaNode, {"distance": 100});
  32. //}.bind(this));
  33. this.propertyListNode = this.designer.propertyDomArea;
  34. //this.propertyNode = this.designer.propertyContentArea;
  35. if(this.designer.application) this.data.applicationName = this.designer.application.name;
  36. if(this.designer.application) this.data.application = this.designer.application.id;
  37. this.isNewView = (this.data.id) ? false : true;
  38. this.items = [];
  39. this.view = this;
  40. this.autoSave();
  41. this.designer.addEvent("queryClose", function(){
  42. if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
  43. }.bind(this));
  44. },
  45. autoSave: function(){
  46. this.autoSaveTimerID = window.setInterval(function(){
  47. if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFDictionaryAutoSaveCheck");
  48. if (this.autoSaveCheckNode){
  49. if (this.autoSaveCheckNode.get("checked")){
  50. this.save();
  51. }
  52. }
  53. }.bind(this), 60000);
  54. },
  55. parseData: function(){
  56. this.json = this.data;
  57. if( !this.json.data.events ){
  58. var url = "/x_component_query_ViewDesigner/$View/view.json";
  59. MWF.getJSON(url, {
  60. "onSuccess": function(obj){
  61. this.json.data.events = obj.data.events;
  62. }.bind(this),
  63. "onerror": function(text){
  64. this.notice(text, "error");
  65. }.bind(this),
  66. "onRequestFailure": function(xhr){
  67. this.notice(xhr.responseText, "error");
  68. }.bind(this)
  69. },false);
  70. }
  71. },
  72. showProperty: function(){
  73. if (!this.property){
  74. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.designer.propertyContentArea, this.designer, {
  75. "path": this.options.propertyPath,
  76. "onPostLoad": function(){
  77. this.property.show();
  78. }.bind(this)
  79. });
  80. this.property.load();
  81. }else{
  82. this.property.show();
  83. }
  84. },
  85. hideProperty: function(){
  86. if (this.property) this.property.hide();
  87. },
  88. load : function(){
  89. this.setAreaNodeSize();
  90. this.designer.addEvent("resize", this.setAreaNodeSize.bind(this));
  91. this.areaNode.inject(this.node);
  92. this.designer.viewListAreaNode.getChildren().each(function(node){
  93. var view = node.retrieve("view");
  94. if (view.id==this.data.id){
  95. if (this.designer.currentListViewItem){
  96. this.designer.currentListViewItem.setStyles(this.designer.css.listViewItem);
  97. }
  98. node.setStyles(this.designer.css.listViewItem_current);
  99. this.designer.currentListViewItem = node;
  100. this.lisNode = node;
  101. }
  102. }.bind(this));
  103. this.domListNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.designer.propertyDomArea);
  104. this.loadTemplateStyle( function () {
  105. this.loadActionbar();
  106. this.loadView();
  107. this.selected();
  108. this.setEvent();
  109. //if (this.options.showTab) this.page.showTabIm();
  110. this.setViewWidth();
  111. this.designer.addEvent("resize", this.setViewWidth.bind(this));
  112. }.bind(this))
  113. },
  114. setEvent: function(){
  115. this.areaNode.addEvent("click", this.selected.bind(this));
  116. this.refreshNode.addEvent("click", function(e){
  117. this.loadViewData();
  118. e.stopPropagation();
  119. }.bind(this));
  120. this.addColumnNode.addEvent("click", function(e){
  121. this.addColumn();
  122. e.stopPropagation();
  123. }.bind(this));
  124. },
  125. loadViewData: function(){
  126. if (this.data.id){
  127. this.saveSilence(function(){
  128. this.viewContentBodyNode.empty();
  129. this.viewContentTableNode = new Element("table", {
  130. "styles": this.css.viewContentTableNode,
  131. "border": "0px",
  132. "cellPadding": "0",
  133. "cellSpacing": "0"
  134. }).inject(this.viewContentBodyNode);
  135. this.designer.actions.loadView(this.data.id, null,function(json){
  136. var entries = {};
  137. json.data.selectList.each(function(entry){entries[entry.column] = entry;}.bind(this));
  138. if (this.json.data.group.column){
  139. if (json.data.groupGrid.length){
  140. var groupColumn = null;
  141. for (var c = 0; c<json.data.selectList.length; c++){
  142. if (json.data.selectList[c].column === json.data.group.column){
  143. groupColumn = json.data.selectList[c];
  144. break;
  145. }
  146. }
  147. json.data.groupGrid.each(function(line, idx){
  148. var groupTr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  149. var colSpan = this.items.length ;
  150. var td = new Element("td", {"styles": this.css.viewContentGroupTdNode, "colSpan": colSpan}).inject(groupTr);
  151. var groupAreaNode = new Element("div", {"styles": this.css.viewContentTdGroupNode}).inject(td);
  152. var groupIconNode = new Element("div", {"styles": this.css.viewContentTdGroupIconNode}).inject(groupAreaNode);
  153. var groupTextNode = new Element("div", {"styles": this.css.viewContentTdGroupTextNode}).inject(groupAreaNode);
  154. if (groupColumn){
  155. //groupTextNode.set("text", (groupColumn.code) ? MWF.Macro.exec(groupColumn.code, {"value": line.group, "gridData": json.data.groupGrid, "data": json.data, "entry": line}) : line.group);
  156. groupTextNode.set("text", line.group);
  157. }else{
  158. groupTextNode.set("text", line.group);
  159. }
  160. var subtrs = [];
  161. line.list.each(function(entry){
  162. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  163. tr.setStyle("display", "none");
  164. //this.createViewCheckboxTd( tr );
  165. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  166. Object.each(entries, function(c, k){
  167. var d = entry.data[k];
  168. if (d!=undefined){
  169. if (k!=this.json.data.group.column){
  170. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  171. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  172. if (c.isHtml){
  173. td.set("html", d);
  174. }else{
  175. td.set("text", d);
  176. }
  177. }
  178. }
  179. }.bind(this));
  180. // Object.each(entry.data, function(d, k){
  181. // if (k!=this.json.data.group.column){
  182. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  183. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.groupGrid, "data": json.data, "entry": entry}) : d);
  184. // }
  185. // }.bind(this));
  186. subtrs.push(tr)
  187. }.bind(this));
  188. groupAreaNode.store("subtrs", subtrs);
  189. var _self = this;
  190. groupAreaNode.addEvent("click", function(){
  191. var subtrs = this.retrieve("subtrs");
  192. var iconNode = groupAreaNode.getFirst("div");
  193. if (subtrs[0]){
  194. if (subtrs[0].getStyle("display")=="none"){
  195. subtrs.each(function(subtr){ subtr.setStyle("display", "table-row"); });
  196. iconNode.setStyle("background", "url("+"/x_component_process_ViewDesigner/$View/default/icon/down.png) center center no-repeat");
  197. }else{
  198. subtrs.each(function(subtr){ subtr.setStyle("display", "none"); });
  199. iconNode.setStyle("background", "url("+"/x_component_process_ViewDesigner/$View/default/icon/right.png) center center no-repeat");
  200. }
  201. }
  202. _self.setContentHeight();
  203. });
  204. }.bind(this));
  205. this.setContentColumnWidth();
  206. this.setContentHeight();
  207. }
  208. }else{
  209. if (json.data.grid.length){
  210. json.data.grid.each(function(line, idx){
  211. var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  212. //this.createViewCheckboxTd( tr );
  213. Object.each(entries, function(c, k){
  214. var d = line.data[k];
  215. if (d!=undefined){
  216. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  217. //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  218. if (c.isHtml){
  219. td.set("html", d);
  220. }else{
  221. td.set("text", d);
  222. }
  223. //td.set("text", d);
  224. }
  225. }.bind(this));
  226. // Object.each(line.data, function(d, k){
  227. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  228. // td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d);
  229. // }.bind(this));
  230. }.bind(this));
  231. this.setContentColumnWidth();
  232. this.setContentHeight();
  233. }
  234. }
  235. }.bind(this));
  236. //this.getLookupAction(function(){
  237. // this.lookupAction.invoke({"name": "lookup","async": true, "parameter": {"id": this.data.id},"success": function(json){
  238. // if (json.data.length){
  239. // json.data.each(function(line, idx){
  240. // var tr = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.viewContentTableNode);
  241. // line.each(function(cell, i){
  242. // var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr);
  243. // td.set("text", cell);
  244. // }.bind(this));
  245. // }.bind(this));
  246. // this.setContentColumnWidth();
  247. // this.setContentHeight();
  248. // }
  249. // }.bind(this)});
  250. //}.bind(this));
  251. }.bind(this));
  252. }
  253. },
  254. setContentColumnWidth: function(){
  255. var titleTds = this.viewTitleTrNode.getElements("td");
  256. var widthList = [];
  257. titleTds.each(function(td){widthList.push(td.getSize().x);});
  258. var flag = false;
  259. if (this.viewContentTableNode){
  260. trs = this.viewContentTableNode.getElements("tr");
  261. for (var i=0; i<trs.length; i++){
  262. var tr = trs[i];
  263. var tds = tr.getElements("td");
  264. tds.each(function(contentTd, i){
  265. if (contentTd.get("colSpan")==1){
  266. contentTd.setStyle("width", ""+widthList[i]+"px");
  267. flag = true;
  268. }
  269. });
  270. if (flag) break;
  271. }
  272. //var tr = this.viewContentTableNode.getFirst("tr");
  273. //if (tr){
  274. // var tds = tr.getElements("td");
  275. // tds.each(function(contentTd, i){
  276. // if (!contentTd.get("colSpan")){
  277. // contentTd.setStyle("width", ""+widthList[i]+"px");
  278. // }
  279. // });
  280. //}
  281. }
  282. },
  283. //getLookupAction: function(callback){
  284. // if (!this.lookupAction){
  285. // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  286. // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface_lookup", "");
  287. // this.lookupAction.getActions = function(actionCallback){
  288. //
  289. // this.actions = {"lookup": {"uri": "/jaxrs/view/{id}"}};
  290. // if (actionCallback) actionCallback();
  291. // }
  292. // if (callback) callback();
  293. // }.bind(this));
  294. // }else{
  295. // if (callback) callback();
  296. // }
  297. //},
  298. addColumn: function(){
  299. MWF.require("MWF.widget.UUID", function(){
  300. var id = (new MWF.widget.UUID).id;
  301. var json = {
  302. "id": id,
  303. "column": id,
  304. "displayName": this.designer.lp.unnamed,
  305. "orderType": "original"
  306. };
  307. if (!this.json.data.selectList) this.json.data.selectList = [];
  308. this.json.data.selectList.push(json);
  309. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this);
  310. this.items.push(column);
  311. column.selected();
  312. if (this.viewContentTableNode){
  313. var trs = this.viewContentTableNode.getElements("tr");
  314. trs.each(function(tr){
  315. new Element("td", {"styles": this.css.viewContentTdNode}).inject(tr)
  316. }.bind(this));
  317. //this.setContentColumnWidth();
  318. }
  319. this.setViewWidth();
  320. this.addColumnNode.scrollIntoView(true);
  321. }.bind(this));
  322. //new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 0}).toRight();
  323. },
  324. selected: function(){
  325. if (this.currentSelectedModule){
  326. if (this.currentSelectedModule==this){
  327. return true;
  328. }else{
  329. this.currentSelectedModule.unSelected();
  330. }
  331. }
  332. this.currentSelectedModule = this;
  333. this.showProperty();
  334. },
  335. unSelected: function(){
  336. this.currentSelectedModule = null;
  337. this.hideProperty();
  338. },
  339. loadViewNodes: function(){
  340. this.viewAreaNode = new Element("div#viewAreaNode", {"styles": this.css.viewAreaNode}).inject(this.areaNode);
  341. this.viewTitleNode = new Element("div#viewTitleNode", {"styles": this.css.viewTitleNode}).inject(this.viewAreaNode);
  342. this.refreshNode = new Element("div", {"styles": this.css.refreshNode}).inject(this.viewTitleNode);
  343. this.addColumnNode = new Element("div", {"styles": this.css.addColumnNode}).inject(this.viewTitleNode);
  344. this.viewTitleContentNode = new Element("div", {"styles": this.css.viewTitleContentNode}).inject(this.viewTitleNode);
  345. this.viewTitleTableNode = new Element("table", {
  346. "styles": this.css.viewTitleTableNode,
  347. "border": "0px",
  348. "cellPadding": "0",
  349. "cellSpacing": "0"
  350. }).inject(this.viewTitleContentNode);
  351. this.viewTitleTrNode = new Element("tr", {"styles": this.css.viewTitleTrNode}).inject(this.viewTitleTableNode);
  352. this.viewContentScrollNode = new Element("div", {"styles": this.css.viewContentScrollNode}).inject(this.viewAreaNode);
  353. this.viewContentNode = new Element("div", {"styles": this.css.viewContentNode}).inject(this.viewContentScrollNode);
  354. MWF.require("MWF.widget.ScrollBar", function(){
  355. new MWF.widget.ScrollBar(this.viewContentScrollNode, {"style": "view", "distance": 100, "indent": false});
  356. }.bind(this));
  357. this.contentLeftNode = new Element("div", {"styles": this.css.contentLeftNode}).inject(this.viewContentNode);
  358. this.contentRightNode = new Element("div", {"styles": this.css.contentRightNode}).inject(this.viewContentNode);
  359. this.viewContentBodyNode = new Element("div", {"styles": this.css.viewContentBodyNode}).inject(this.viewContentNode);
  360. this.viewContentTableNode = new Element("table", {
  361. "styles": this.css.viewContentTableNode,
  362. "border": "0px",
  363. "cellPadding": "0",
  364. "cellSpacing": "0"
  365. }).inject(this.viewContentBodyNode);
  366. },
  367. setContentHeight: function(){
  368. var size = this.areaNode.getSize();
  369. var titleSize = this.viewTitleNode.getSize();
  370. var actionbarSize = this.actionbarNode ? this.actionbarNode.getSize() : {x:0, y:0};
  371. var height = size.y-titleSize.y-actionbarSize.y-2;
  372. this.viewContentScrollNode.setStyle("height", height);
  373. var contentSize = this.viewContentBodyNode.getSize();
  374. if (height<contentSize.y) height = contentSize.y+10;
  375. this.viewContentNode.setStyle("height", height);
  376. this.contentLeftNode.setStyle("height", height);
  377. this.contentRightNode.setStyle("height", height);
  378. //this.viewContentBodyNode.setStyle("min-height", height);
  379. },
  380. loadViewColumns: function(){
  381. // for (var i=0; i<10; i++){
  382. if (this.json.data.selectList) {
  383. this.json.data.selectList.each(function (json) {
  384. this.items.push(new MWF.xApplication.query.ViewDesigner.View.Column(json, this));
  385. }.bind(this));
  386. }
  387. // }
  388. },
  389. loadViewSelectAllNode : function(){
  390. var _self = this;
  391. var td = new Element("td.viewTitleCheckboxTd",{ "styles": this.css.viewTitleColumnAreaNode }).inject( this.viewTitleTrNode );
  392. td.setStyles({
  393. "width":"30px", "text-align" : "center",
  394. "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
  395. });
  396. new Element("input",{
  397. "type" : "checkbox",
  398. "events" : {
  399. "change" : function(){
  400. _self.viewContentTableNode.getElements(".viewContentCheckbox").set("checked", this.checked )
  401. }
  402. }
  403. }).inject(td);
  404. },
  405. createViewCheckboxTd : function( tr ){
  406. var td = new Element("td.viewContentCheckboxTd", {"styles": this.css.viewContentTdNode}).inject(tr, "top");
  407. td.setStyles({
  408. "width":"30px", "text-align" : "center",
  409. "display" : this.json.data.selectAllEnable ? "table-cell" : "none"
  410. });
  411. new Element("input.viewContentCheckbox",{
  412. "type" : "checkbox"
  413. }).inject(td);
  414. },
  415. loadView: function(){
  416. this.loadViewNodes();
  417. //this.loadViewSelectAllNode();
  418. this.loadViewColumns();
  419. // this.addTopItemNode.addEvent("click", this.addTopItem.bind(this));
  420. },
  421. loadActionbar: function(){
  422. this.actionbarNode = new Element("div#actionbarNode", {"styles": this.css.actionbarNode}).inject(this.areaNode);
  423. this.actionbarList = [];
  424. if( !this.json.data.actionbarHidden ){
  425. this.showActionbar( true );
  426. }
  427. },
  428. hideActionbar : function(){
  429. this.actionbarNode.hide();
  430. this.setContentHeight();
  431. },
  432. showActionbar : function( noSetHeight ){
  433. this.actionbarNode.show();
  434. if( !this.json.data.actionbarList )this.json.data.actionbarList = [];
  435. if( !this.actionbarList || this.actionbarList.length == 0 ){
  436. if( this.json.data.actionbarList.length ){
  437. this.json.data.actionbarList.each( function(json){
  438. this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( json, this.json.data.actionbarList, this) )
  439. }.bind(this));
  440. }else{
  441. this.actionbarList.push( new MWF.xApplication.query.ViewDesigner.View.Actionbar( null, this.json.data.actionbarList, this) )
  442. }
  443. }
  444. if( !noSetHeight )this.setContentHeight();
  445. },
  446. setViewWidth: function(){
  447. this.viewAreaNode.setStyle("width", "auto");
  448. this.viewTitleNode.setStyle("width", "auto");
  449. var s1 = this.viewTitleTableNode.getSize();
  450. var s2 = this.refreshNode.getSize();
  451. var s3 = this.addColumnNode.getSize();
  452. var width = s1.x+s2.x+s2.x;
  453. var size = this.areaNode.getSize();
  454. if (width>size.x){
  455. this.viewTitleNode.setStyle("width", ""+width+"px");
  456. this.viewAreaNode.setStyle("width", ""+width+"px");
  457. }else{
  458. this.viewTitleNode.setStyle("width", ""+size.x+"px");
  459. this.viewAreaNode.setStyle("width", ""+size.x+"px");
  460. }
  461. this.setContentColumnWidth();
  462. this.setContentHeight();
  463. },
  464. //setPropertyContent: function(){
  465. // this.designer.propertyIdNode.set("text", this.data.id);
  466. // this.designer.propertyNameNode.set("value", this.data.name);
  467. // this.designer.propertyAliasNode.set("value", this.data.alias);
  468. // this.designer.propertyDescriptionNode.set("value", this.data.description);
  469. //
  470. // this.designer.jsonDomNode.empty();
  471. // MWF.require("MWF.widget.JsonParse", function(){
  472. // this.jsonParse = new MWF.widget.JsonParse(this.data.data, this.designer.jsonDomNode, this.designer.jsonTextAreaNode);
  473. // window.setTimeout(function(){
  474. // this.jsonParse.load();
  475. // }.bind(this), 1);
  476. // }.bind(this));
  477. //},
  478. setAreaNodeSize: function(){
  479. //var size = this.node.getSize();
  480. ////var tabSize = this.tab.tabNodeContainer.getSize();
  481. //var tabSize = this.node.getSize();
  482. //var y = size.y - tabSize.y;
  483. //this.areaNode.setStyle("height", ""+y+"px");
  484. //if (this.editor) if (this.editor.editor) this.editor.editor.resize();
  485. },
  486. // createRootItem: function() {
  487. // this.items.push(new MWF.xApplication.process.DictionaryDesigner.Dictionary.item("ROOT", this.data.data, null, 0, this, true));
  488. // },
  489. saveSilence: function(callback){
  490. if (!this.data.name){
  491. this.designer.notice(this.designer.lp.notice.inputName, "error");
  492. return false;
  493. }
  494. this.designer.actions.saveView(this.data, function(json){
  495. this.data.id = json.data.id;
  496. //this.page.textNode.set("text", this.data.name);
  497. if (this.lisNode) {
  498. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  499. }
  500. if (callback) callback();
  501. }.bind(this));
  502. },
  503. save: function(callback){
  504. //if (this.designer.tab.showPage==this.page){
  505. if (!this.data.name){
  506. this.designer.notice(this.designer.lp.notice.inputName, "error");
  507. return false;
  508. }
  509. //}
  510. this.designer.actions.saveView(this.data, function(json){
  511. this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
  512. this.data.id = json.data.id;
  513. //this.page.textNode.set("text", this.data.name);
  514. if (this.lisNode) {
  515. this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
  516. }
  517. if (callback) callback();
  518. }.bind(this));
  519. },
  520. explode: function(){},
  521. implode: function(){},
  522. _setEditStyle: function(name, input, oldValue){
  523. if (name=="type"){
  524. this.items.each(function(item){
  525. if (item.property){
  526. var processDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedProcessArea");
  527. var cmsDiv = item.property.propertyContent.getElements("#"+item.json.id+"dataPathSelectedCMSArea");
  528. if (this.json[name]=="cms"){
  529. cmsDiv.setStyle("display", "block");
  530. processDiv.setStyle("display", "none");
  531. }else{
  532. cmsDiv.setStyle("display", "none");
  533. processDiv.setStyle("display", "block");
  534. }
  535. }
  536. }.bind(this));
  537. }
  538. if( name=="data.actionbarHidden" ){
  539. if( this.json.data.actionbarHidden ){
  540. this.hideActionbar()
  541. }else{
  542. this.showActionbar()
  543. }
  544. }
  545. if( name=="data.selectAllEnable" ){
  546. if( this.json.data.selectAllEnable ){
  547. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","table-cell");
  548. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","table-cell");
  549. }else{
  550. this.viewTitleTrNode.getElement(".viewTitleCheckboxTd").setStyle("display","none");
  551. this.viewContentTableNode.getElements(".viewContentCheckboxTd").setStyle("display","none");
  552. }
  553. }
  554. if (name=="data.viewStyleType"){
  555. var file = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].file : null;
  556. var extendFile = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType].extendFile : null;
  557. this.loadTemplateStyles( file, extendFile, function( templateStyles ){
  558. this.templateStyles = templateStyles;
  559. var oldFile, oldExtendFile;
  560. if( oldValue && this.stylesList[oldValue] ){
  561. oldFile = this.stylesList[oldValue].file;
  562. oldExtendFile = this.stylesList[oldValue].extendFile;
  563. }
  564. this.loadTemplateStyles( oldFile, oldExtendFile, function( oldTemplateStyles ){
  565. this.json.data.styleConfig = (this.stylesList && this.json.data.viewStyleType) ? this.stylesList[this.json.data.viewStyleType] : null;
  566. if (oldTemplateStyles["form"]) this.clearTemplateStyles(oldTemplateStyles["form"]);
  567. if (this.templateStyles["form"]) this.setTemplateStyles(this.templateStyles["form"]);
  568. // this.setAllStyles();
  569. // this.moduleList.each(function(module){
  570. // if (oldTemplateStyles[module.moduleName]){
  571. // module.clearTemplateStyles(oldTemplateStyles[module.moduleName]);
  572. // }
  573. // module.setStyleTemplate();
  574. // module.setAllStyles();
  575. // }.bind(this));
  576. }.bind(this))
  577. }.bind(this))
  578. }
  579. },
  580. saveAs: function(){
  581. var form = new MWF.xApplication.query.ViewDesigner.View.NewNameForm(this, {
  582. name : this.data.name + "_" + MWF.xApplication.query.ViewDesigner.LP.copy,
  583. query : this.data.query || this.data.application,
  584. queryName : this.data.queryName || this.data.applicationName
  585. }, {
  586. onSave : function( data, callback ){
  587. this._saveAs( data, callback );
  588. }.bind(this)
  589. }, {
  590. app: this.designer
  591. });
  592. form.edit()
  593. },
  594. cloneObject : function( obj ){
  595. if (null == obj || "object" != typeof obj) return obj;
  596. if ( typeof obj.length==='number'){ //数组
  597. //print( "array" );
  598. var copy = [];
  599. for (var i = 0, len = obj.length; i < len; ++i) {
  600. copy[i] = this.cloneObject(obj[i]);
  601. }
  602. return copy;
  603. }else{
  604. var copy = {};
  605. for (var attr in obj) {
  606. copy[attr] = this.cloneObject(obj[attr]);
  607. }
  608. return copy;
  609. }
  610. },
  611. _saveAs : function( data , callback){
  612. var _self = this;
  613. var d = this.cloneObject( this.data );
  614. d.isNewView = true;
  615. d.id = this.designer.actions.getUUID();
  616. d.name = data.name;
  617. d.alias = "";
  618. d.query = data.query;
  619. d.queryName = data.queryName;
  620. d.application = data.query;
  621. d.applicationName = data.queryName;
  622. d.pid = d.id + d.id;
  623. delete d[this.data.id+"viewFilterType"];
  624. d[d.id+"viewFilterType"]="custom";
  625. d.data.selectList.each( function( entry ){
  626. entry.id = (new MWF.widget.UUID).id;
  627. }.bind(this));
  628. this.designer.actions.saveView(d, function(json){
  629. this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
  630. if (callback) callback();
  631. }.bind(this));
  632. },
  633. loadTemplateStyle : function( callback ){
  634. this.loadStylesList(function(){
  635. var oldStyleValue = "";
  636. if ((!this.json.data.viewStyleType) || !this.stylesList[this.json.data.viewStyleType]) this.json.data.viewStyleType="default";
  637. // if (this.options.mode=="Mobile"){
  638. // if (this.json.viewStyleType != "defaultMobile"){
  639. // var styles = this.stylesList[this.json.viewStyleType];
  640. // if( !styles || typeOf(styles.mode)!=="array" || !styles.mode.contains( "mobile" ) ){
  641. // oldStyleValue = this.json.viewStyleType;
  642. // this.json.viewStyleType = "defaultMobile";
  643. // }
  644. // }
  645. // }
  646. this.loadTemplateStyles( this.stylesList[this.json.data.viewStyleType].file, this.stylesList[this.json.data.viewStyleType].extendFile,
  647. function( templateStyles ){
  648. this.templateStyles = templateStyles;
  649. // this.loadDomModules();
  650. if (this.json.data.viewStyleType && this.templateStyles && this.templateStyles["form"]){
  651. this.setTemplateStyles(this.templateStyles["form"]);
  652. }
  653. // this.setCustomStyles();
  654. this.node.setProperties(this.json.data.properties);
  655. if(callback)callback();
  656. // this.setNodeEvents();
  657. // if (this.options.mode=="Mobile"){
  658. // if (oldStyleValue) this._setEditStyle("viewStyleType", null, oldStyleValue);
  659. // }
  660. }.bind(this)
  661. );
  662. }.bind(this));
  663. },
  664. removeStyles: function(from, to){
  665. if (this.json.data[to]){
  666. Object.each(from, function(style, key){
  667. if (this.json.data[to][key] && this.json.data[to][key]==style){
  668. delete this.json.data[to][key];
  669. }
  670. }.bind(this));
  671. }
  672. },
  673. copyStyles: function(from, to){
  674. if (!this.json.data[to]) this.json.data[to] = {};
  675. Object.each(from, function(style, key){
  676. if (!this.json.data[to][key]) this.json.data[to][key] = style;
  677. }.bind(this));
  678. },
  679. clearTemplateStyles: function(styles){
  680. if (styles){
  681. if (styles.styles) this.removeStyles(styles.styles, "styles");
  682. if (styles.properties) this.removeStyles(styles.properties, "properties");
  683. }
  684. },
  685. setTemplateStyles: function(styles){
  686. if (styles.styles) this.copyStyles(styles.styles, "styles");
  687. if (styles.properties) this.copyStyles(styles.properties, "properties");
  688. },
  689. loadTemplateStyles : function( file, extendFile, callback ){
  690. if( !file ){
  691. if (callback) callback({});
  692. return;
  693. }
  694. this.templateStylesList = this.templateStylesList || {};
  695. if( this.templateStylesList[file] ){
  696. if (callback) callback(this.templateStylesList[file]);
  697. return;
  698. }
  699. this.loadTemplateStyleFile( file, function( json_file ){
  700. this.loadTemplateExtendStyleFile( extendFile, function( json_extend ){
  701. this.templateStylesList[file] = Object.merge( json_file, json_extend );
  702. if (callback) callback(this.templateStylesList[file]);
  703. }.bind(this))
  704. }.bind(this))
  705. },
  706. loadTemplateStyleFile : function(file, callback ){
  707. if( !file ){
  708. if (callback) callback({});
  709. return;
  710. }
  711. var stylesUrl = "/x_component_query_ViewDesigner/$View/skin/"+file;
  712. MWF.getJSON(stylesUrl,{
  713. "onSuccess": function(responseJSON){
  714. //this.templateStylesList[file] = responseJSON;
  715. if (callback) callback(responseJSON);
  716. }.bind(this),
  717. "onRequestFailure": function(){
  718. if (callback) callback({});
  719. }.bind(this),
  720. "onError": function(){
  721. if (callback) callback({});
  722. }.bind(this)
  723. }
  724. );
  725. },
  726. loadTemplateExtendStyleFile : function(extendFile, callback ){
  727. if( !extendFile ){
  728. if (callback) callback({});
  729. return;
  730. }
  731. var stylesUrl = "/x_component_query_ViewDesigner/$View/skin/"+extendFile;
  732. MWF.getJSON(stylesUrl,{
  733. "onSuccess": function(responseJSON){
  734. //this.templateStylesList[file] = responseJSON;
  735. if (callback) callback(responseJSON);
  736. }.bind(this),
  737. "onRequestFailure": function(){
  738. if (callback) callback({});
  739. }.bind(this),
  740. "onError": function(){
  741. if (callback) callback({});
  742. }.bind(this)
  743. }
  744. );
  745. },
  746. loadStylesList: function(callback){
  747. var configUrl = "/x_component_query_ViewDesigner/$View/skin/config.json";
  748. MWF.getJSON(configUrl,{
  749. "onSuccess": function(responseJSON){
  750. this.stylesList = responseJSON;
  751. if (callback) callback(this.stylesList);
  752. }.bind(this),
  753. "onRequestFailure": function(){
  754. this.stylesList = {};
  755. if (callback) callback(this.stylesList);
  756. }.bind(this),
  757. "onError": function(){
  758. this.stylesList = {};
  759. if (callback) callback(this.stylesList);
  760. }.bind(this)
  761. }
  762. );
  763. }
  764. });
  765. MWF.xApplication.query.ViewDesigner.View.Column = new Class({
  766. initialize: function(json, view, next){
  767. this.propertyPath = "/x_component_query_ViewDesigner/$View/column.html";
  768. this.view = view;
  769. this.json = json;
  770. this.next = next;
  771. this.css = this.view.css;
  772. this.content = this.view.viewTitleTrNode;
  773. this.domListNode = this.view.domListNode;
  774. this.load();
  775. },
  776. load: function(){
  777. this.areaNode = new Element("td", {"styles": this.css.viewTitleColumnAreaNode});
  778. this.areaNode.store("column", this);
  779. if (this.next){
  780. this.areaNode.inject(this.next.areaNode, "before");
  781. }else{
  782. this.areaNode.inject(this.content);
  783. }
  784. this.node = new Element("div", {
  785. "styles": this.css.viewTitleColumnNode
  786. }).inject(this.areaNode);
  787. this.textNode = new Element("div", {
  788. "styles": this.css.viewTitleColumnTextNode,
  789. "text": this.json.displayName
  790. }).inject(this.node);
  791. this.createDomListItem();
  792. this._createIconAction();
  793. //if (!this.json.export) this.hideMode();
  794. this.setEvent();
  795. },
  796. createDomListItem: function(){
  797. this.listNode = new Element("div", {"styles": this.css.cloumnListNode});
  798. if (this.next){
  799. this.listNode.inject(this.next.listNode, "before");
  800. }else{
  801. this.listNode.inject(this.domListNode);
  802. }
  803. var listIconNode = new Element("div", {"styles": this.css.cloumnListIconNode}).inject(this.listNode);
  804. var listTextNode = new Element("div", {"styles": this.css.cloumnListTextNode}).inject(this.listNode);
  805. this.resetTextNode();
  806. },
  807. setEvent: function(){
  808. this.node.addEvents({
  809. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  810. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.viewTitleColumnNode_over)}.bind(this),
  811. "mouseout": function(){if (!this.isSelected) if (this.isError){
  812. this.node.setStyles(this.css.viewTitleColumnNode_error)
  813. }else{
  814. this.node.setStyles(this.css.viewTitleColumnNode)
  815. }}.bind(this)
  816. });
  817. this.listNode.addEvents({
  818. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  819. "mouseover": function(){debugger; if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode_over)}.bind(this),
  820. "mouseout": function(){if (!this.isSelected) this.listNode.setStyles(this.css.cloumnListNode)}.bind(this)
  821. });
  822. },
  823. _createIconAction: function(){
  824. if (!this.actionArea){
  825. this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.view.areaNode, "after");
  826. this._createAction({
  827. "name": "move",
  828. "icon": "move1.png",
  829. "event": "mousedown",
  830. "action": "move",
  831. "title": MWF.APPDVD.LP.action.move
  832. });
  833. this._createAction({
  834. "name": "add",
  835. "icon": "add.png",
  836. "event": "click",
  837. "action": "addColumn",
  838. "title": MWF.APPDVD.LP.action.add
  839. });
  840. this._createAction({
  841. "name": "delete",
  842. "icon": "delete1.png",
  843. "event": "click",
  844. "action": "delete",
  845. "title": MWF.APPDVD.LP.action["delete"]
  846. });
  847. }
  848. },
  849. _createAction: function(action){
  850. var actionNode = new Element("div", {
  851. "styles": this.css.actionNodeStyles,
  852. "title": action.title
  853. }).inject(this.actionArea);
  854. actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
  855. actionNode.addEvent(action.event, function(e){
  856. this[action.action](e);
  857. }.bind(this));
  858. actionNode.addEvents({
  859. "mouseover": function(e){
  860. e.target.setStyle("border", "1px solid #999");
  861. }.bind(this),
  862. "mouseout": function(e){
  863. e.target.setStyle("border", "1px solid #F1F1F1");
  864. }.bind(this)
  865. });
  866. },
  867. _setActionAreaPosition: function(){
  868. var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
  869. var y = p.y-25;
  870. var x = p.x;
  871. this.actionArea.setPosition({"x": x, "y": y});
  872. },
  873. _showActions: function(){
  874. if (this.actionArea){
  875. this._setActionAreaPosition();
  876. this.actionArea.setStyle("display", "block");
  877. }
  878. },
  879. _hideActions: function(){
  880. if (this.actionArea) this.actionArea.setStyle("display", "none");
  881. },
  882. selected: function(){
  883. if (this.view.currentSelectedModule){
  884. if (this.view.currentSelectedModule==this){
  885. return true;
  886. }else{
  887. this.view.currentSelectedModule.unSelected();
  888. }
  889. }
  890. this.node.setStyles(this.css.viewTitleColumnNode_selected);
  891. this.listNode.setStyles(this.css.cloumnListNode_selected);
  892. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  893. new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  894. this.view.currentSelectedModule = this;
  895. this.isSelected = true;
  896. this._showActions();
  897. this.showProperty();
  898. },
  899. unSelected: function(){
  900. this.view.currentSelectedModule = null;
  901. //this.node.setStyles(this.css.viewTitleColumnNode);
  902. if (this.isError){
  903. this.node.setStyles(this.css.viewTitleColumnNode_error)
  904. }else{
  905. this.node.setStyles(this.css.viewTitleColumnNode)
  906. }
  907. this.listNode.setStyles(this.css.cloumnListNode);
  908. this.isSelected = false;
  909. this._hideActions();
  910. this.hideProperty();
  911. },
  912. showProperty: function(){
  913. if (!this.property){
  914. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  915. "path": this.propertyPath,
  916. "onPostLoad": function(){
  917. this.property.show();
  918. var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
  919. var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
  920. if (this.view.json.type=="cms"){
  921. processDiv.setStyle("display", "none");
  922. cmsDiv.setStyle("display", "block");
  923. }else{
  924. processDiv.setStyle("display", "block");
  925. cmsDiv.setStyle("display", "none");
  926. }
  927. }.bind(this)
  928. });
  929. this.property.load();
  930. }else{
  931. this.property.show();
  932. }
  933. },
  934. hideProperty: function(){
  935. if (this.property) this.property.hide();
  936. },
  937. _setEditStyle: function(name, input, oldValue){
  938. if (name=="displayName") this.resetTextNode();
  939. if (name=="selectType") this.resetTextNode();
  940. if (name=="attribute") this.resetTextNode();
  941. if (name=="path") this.resetTextNode();
  942. if (name=="column"){
  943. this.view.json.data.orderList.each(function(order){
  944. if (order.column==oldValue) order.column = this.json.column
  945. }.bind(this));
  946. if (this.view.json.data.group.column == oldValue) this.view.json.data.group.column = this.json.column;
  947. }
  948. },
  949. resetTextNode: function(){
  950. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  951. if (!listText) listText = "unnamed";
  952. this.textNode.set("text", this.json.displayName);
  953. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  954. },
  955. "delete": function(e){
  956. var _self = this;
  957. if (!e) e = this.node;
  958. this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
  959. _self.destroy();
  960. this.close();
  961. }, function(){
  962. this.close();
  963. }, null);
  964. },
  965. destroy: function(){
  966. if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
  967. if (this.actionArea) this.actionArea.destroy();
  968. if (this.listNode) this.listNode.destroy();
  969. if (this.property) this.property.propertyContent.destroy();
  970. var idx = this.view.items.indexOf(this);
  971. if (this.view.viewContentTableNode){
  972. var trs = this.view.viewContentTableNode.getElements("tr");
  973. trs.each(function(tr){
  974. tr.deleteCell(idx);
  975. }.bind(this));
  976. }
  977. if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
  978. if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
  979. this.view.items.erase(this);
  980. if (this.view.property) this.view.property.loadStatColumnSelect();
  981. this.areaNode.destroy();
  982. this.view.selected();
  983. this.view.setViewWidth();
  984. MWF.release(this);
  985. delete this;
  986. },
  987. addColumn: function(e, data){
  988. MWF.require("MWF.widget.UUID", function(){
  989. var json;
  990. if (data){
  991. json = Object.clone(data);
  992. json.id = (new MWF.widget.UUID).id;
  993. json.column = (new MWF.widget.UUID).id;
  994. }else{
  995. var id = (new MWF.widget.UUID).id;
  996. json = {
  997. "id": id,
  998. "column": id,
  999. "displayName": this.view.designer.lp.unnamed,
  1000. "orderType": "original"
  1001. };
  1002. }
  1003. var idx = this.view.json.data.selectList.indexOf(this.json);
  1004. this.view.json.data.selectList.splice(idx, 0, json);
  1005. var column = new MWF.xApplication.query.ViewDesigner.View.Column(json, this.view, this);
  1006. this.view.items.splice(idx, 0, column);
  1007. column.selected();
  1008. if (this.view.viewContentTableNode){
  1009. var trs = this.view.viewContentTableNode.getElements("tr");
  1010. trs.each(function(tr){
  1011. var td = tr.insertCell(idx);
  1012. td.setStyles(this.css.viewContentTdNode);
  1013. }.bind(this));
  1014. }
  1015. this.view.setViewWidth();
  1016. }.bind(this));
  1017. },
  1018. move: function(e){
  1019. var columnNodes = [];
  1020. this.view.items.each(function(item){
  1021. if (item!=this){
  1022. columnNodes.push(item.areaNode);
  1023. }
  1024. }.bind(this));
  1025. this._createMoveNode();
  1026. this._setNodeMove(columnNodes, e);
  1027. },
  1028. _createMoveNode: function(){
  1029. this.moveNode = new Element("div", {"text": this.node.get("text")});
  1030. this.moveNode.inject(this.view.designer.content);
  1031. this.moveNode.setStyles({
  1032. "border": "2px dashed #ffa200",
  1033. "opacity": 0.7,
  1034. "height": "30px",
  1035. "line-height": "30px",
  1036. "padding": "0px 10px",
  1037. "position": "absolute"
  1038. });
  1039. },
  1040. _setMoveNodePosition: function(e){
  1041. var x = e.page.x+2;
  1042. var y = e.page.y+2;
  1043. this.moveNode.positionTo(x, y);
  1044. },
  1045. createMoveFlagNode: function(){
  1046. this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
  1047. },
  1048. _setNodeMove: function(droppables, e){
  1049. this._setMoveNodePosition(e);
  1050. var movePosition = this.moveNode.getPosition();
  1051. var moveSize = this.moveNode.getSize();
  1052. var contentPosition = this.content.getPosition();
  1053. var contentSize = this.content.getSize();
  1054. var nodeDrag = new Drag.Move(this.moveNode, {
  1055. "droppables": droppables,
  1056. "limit": {
  1057. "x": [contentPosition.x, contentPosition.x+contentSize.x],
  1058. "y": [movePosition.y, movePosition.y+moveSize.y]
  1059. },
  1060. "onEnter": function(dragging, inObj){
  1061. if (!this.moveFlagNode) this.createMoveFlagNode();
  1062. this.moveFlagNode.inject(inObj, "before");
  1063. }.bind(this),
  1064. "onLeave": function(dragging, inObj){
  1065. if (this.moveFlagNode){
  1066. this.moveFlagNode.dispose();
  1067. }
  1068. }.bind(this),
  1069. "onDrop": function(dragging, inObj){
  1070. if (inObj){
  1071. this.areaNode.inject(inObj, "before");
  1072. var column = inObj.retrieve("column");
  1073. this.listNode.inject(column.listNode, "before");
  1074. var idx = this.view.json.data.selectList.indexOf(column.json);
  1075. this.view.json.data.selectList.erase(this.json);
  1076. this.view.items.erase(this);
  1077. this.view.json.data.selectList.splice(idx, 0, this.json);
  1078. this.view.items.splice(idx, 0, this);
  1079. if (this.moveNode) this.moveNode.destroy();
  1080. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1081. this._setActionAreaPosition();
  1082. }else{
  1083. if (this.moveNode) this.moveNode.destroy();
  1084. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1085. }
  1086. }.bind(this),
  1087. "onCancel": function(dragging){
  1088. if (this.moveNode) this.moveNode.destroy();
  1089. if (this.moveFlagNode) this.moveFlagNode.destroy();
  1090. }.bind(this)
  1091. });
  1092. nodeDrag.start(e);
  1093. }
  1094. //hideMode: function(){
  1095. // if (!this.columnHideFlagNode){
  1096. // this.columnHideFlagNode = new Element("div", {"styles": this.view.css.columnHideFlagNode}).inject(this.node);
  1097. // }
  1098. //},
  1099. //showMode: function(){
  1100. // if (this.columnHideFlagNode) this.columnHideFlagNode.destroy();
  1101. // this.columnHideFlagNode = null;
  1102. //}
  1103. });
  1104. MWF.require("MWF.widget.Toolbar", null, false);
  1105. MWF.xApplication.query.ViewDesigner.View.Actionbar = new Class({
  1106. Implements: [Options, Events],
  1107. options : {
  1108. "style" : "default",
  1109. "customImageStyle" : "default"
  1110. },
  1111. initialize: function(json, jsonList, view, options){
  1112. this.setOptions( options );
  1113. this.propertyPath = "/x_component_query_ViewDesigner/$View/actionbar.html";
  1114. this.path = "/x_component_query_ViewDesigner/$View/";
  1115. this.imagePath_default = "/x_component_query_ViewDesigner/$View/";
  1116. this.imagePath_custom = "/x_component_process_FormDesigner/Module/Actionbar/";
  1117. this.cssPath = "/x_component_query_ViewDesigner/$View/"+this.options.style+"/actionbar.wcss";
  1118. this.view = view;
  1119. this.json = json;
  1120. this.jsonList = jsonList;
  1121. this.css = this.view.css;
  1122. this.container = this.view.actionbarNode;
  1123. this.load();
  1124. },
  1125. load: function(){
  1126. this.systemTools = [];
  1127. this.customTools = [];
  1128. if( !this.json ){
  1129. this.loadDefaultJson(function(){
  1130. this._load()
  1131. }.bind(this));
  1132. }else{
  1133. this._load()
  1134. }
  1135. },
  1136. _load : function(){
  1137. this._createNode();
  1138. //this._createIconAction();
  1139. //if (!this.json.export) this.hideMode();
  1140. this.setEvent();
  1141. },
  1142. loadDefaultJson: function(callback){
  1143. var url = this.path+"actionbar.json";
  1144. MWF.getJSON(url, {
  1145. "onSuccess": function(obj){
  1146. this.view.designer.actions.getUUID(function(id){
  1147. obj.id=id;
  1148. //obj.isNewView = true;
  1149. //obj.application = this.view.designer.application.id;
  1150. this.json = obj;
  1151. this.jsonList.push( this.json );
  1152. if (callback) callback(obj);
  1153. }.bind(this));
  1154. }.bind(this),
  1155. "onerror": function(text){
  1156. this.view.designer.notice(text, "error");
  1157. }.bind(this),
  1158. "onRequestFailure": function(xhr){
  1159. this.view.designer.notice(xhr.responseText, "error");
  1160. }.bind(this)
  1161. });
  1162. },
  1163. setEvent: function(){
  1164. this.node.addEvents({
  1165. "click": function(e){this.selected(); e.stopPropagation();}.bind(this),
  1166. "mouseover": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode_over)}.bind(this),
  1167. "mouseout": function(){if (!this.isSelected) this.node.setStyles(this.css.toolbarWarpNode) }.bind(this)
  1168. });
  1169. },
  1170. //_createIconAction: function(){
  1171. // if (!this.actionArea){
  1172. // this.actionArea = new Element("div", {"styles": this.css.actionAreaNode}).inject(this.container, "after");
  1173. //
  1174. // //this._createAction({
  1175. // // "name": "move",
  1176. // // "icon": "move1.png",
  1177. // // "event": "mousedown",
  1178. // // "action": "move",
  1179. // // "title": MWF.APPDVD.LP.action.move
  1180. // //});
  1181. // //this._createAction({
  1182. // // "name": "add",
  1183. // // "icon": "add.png",
  1184. // // "event": "click",
  1185. // // "action": "addColumn",
  1186. // // "title": MWF.APPDVD.LP.action.add
  1187. // //});
  1188. // this._createAction({
  1189. // "name": "delete",
  1190. // "icon": "delete1.png",
  1191. // "event": "click",
  1192. // "action": "delete",
  1193. // "title": MWF.APPDVD.LP.action["delete"]
  1194. // });
  1195. // }
  1196. //},
  1197. //_createAction: function(action){
  1198. // var actionNode = new Element("div", {
  1199. // "styles": this.css.actionNodeStyles,
  1200. // "title": action.title
  1201. // }).inject(this.actionArea);
  1202. // actionNode.setStyle("background", "url("+this.view.path+this.view.options.style+"/action/"+action.icon+") no-repeat left center");
  1203. // actionNode.addEvent(action.event, function(e){
  1204. // this[action.action](e);
  1205. // }.bind(this));
  1206. // actionNode.addEvents({
  1207. // "mouseover": function(e){
  1208. // e.target.setStyle("border", "1px solid #999");
  1209. // }.bind(this),
  1210. // "mouseout": function(e){
  1211. // e.target.setStyle("border", "1px solid #F1F1F1");
  1212. // }.bind(this)
  1213. // });
  1214. //},
  1215. //_setActionAreaPosition: function(){
  1216. // var p = this.node.getPosition(this.view.areaNode.getOffsetParent());
  1217. // var y = p.y-25;
  1218. // var x = p.x;
  1219. // this.actionArea.setPosition({"x": x, "y": y});
  1220. //},
  1221. //_showActions: function(){
  1222. // if (this.actionArea){
  1223. // this._setActionAreaPosition();
  1224. // this.actionArea.setStyle("display", "block");
  1225. // }
  1226. //},
  1227. //_hideActions: function(){
  1228. // if (this.actionArea) this.actionArea.setStyle("display", "none");
  1229. //},
  1230. selected: function(){
  1231. if (this.view.currentSelectedModule){
  1232. if (this.view.currentSelectedModule==this){
  1233. return true;
  1234. }else{
  1235. this.view.currentSelectedModule.unSelected();
  1236. }
  1237. }
  1238. this.node.setStyles(this.css.toolbarWarpNode_selected);
  1239. //this.listNode.setStyles(this.css.cloumnListNode_selected);
  1240. new Fx.Scroll(this.view.areaNode, {"wheelStops": false, "duration": 100}).toElementEdge(this.node);
  1241. //new Fx.Scroll(this.view.designer.propertyDomArea, {"wheelStops": false, "duration": 100}).toElement(this.listNode);
  1242. this.view.currentSelectedModule = this;
  1243. this.isSelected = true;
  1244. //this._showActions();
  1245. this.showProperty();
  1246. },
  1247. unSelected: function(){
  1248. this.view.currentSelectedModule = null;
  1249. this.node.setStyles(this.css.toolbarWarpNode)
  1250. //this.listNode.setStyles(this.css.cloumnListNode);
  1251. this.isSelected = false;
  1252. //this._hideActions();
  1253. this.hideProperty();
  1254. },
  1255. showProperty: function(){
  1256. if (!this.property){
  1257. this.property = new MWF.xApplication.query.ViewDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
  1258. "path": this.propertyPath,
  1259. "onPostLoad": function(){
  1260. this.property.show();
  1261. //var processDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedProcessArea");
  1262. //var cmsDiv = this.property.propertyContent.getElements("#"+this.json.id+"dataPathSelectedCMSArea");
  1263. //
  1264. //if (this.view.json.type=="cms"){
  1265. // processDiv.setStyle("display", "none");
  1266. // cmsDiv.setStyle("display", "block");
  1267. //}else{
  1268. // processDiv.setStyle("display", "block");
  1269. // cmsDiv.setStyle("display", "none");
  1270. //}
  1271. }.bind(this)
  1272. });
  1273. this.property.load();
  1274. }else{
  1275. this.property.show();
  1276. }
  1277. },
  1278. hideProperty: function(){
  1279. if (this.property) this.property.hide();
  1280. },
  1281. resetTextNode: function(){
  1282. var listText = (this.json.selectType=="attribute") ? (this.json.attribute || "") : (this.json.path || "");
  1283. if (!listText) listText = "unnamed";
  1284. this.textNode.set("text", this.json.displayName);
  1285. this.listNode.getLast().set("text", this.json.displayName+"("+listText+")");
  1286. },
  1287. //"delete": function(e){
  1288. // var _self = this;
  1289. // if (!e) e = this.node;
  1290. // this.view.designer.confirm("warn", e, MWF.APPDVD.LP.notice.deleteColumnTitle, MWF.APPDVD.LP.notice.deleteColumn, 300, 120, function(){
  1291. // _self.destroy();
  1292. //
  1293. // this.close();
  1294. // }, function(){
  1295. // this.close();
  1296. // }, null);
  1297. //},
  1298. //destroy: function(){
  1299. // if (this.view.currentSelectedModule==this) this.view.currentSelectedModule = null;
  1300. // if (this.actionArea) this.actionArea.destroy();
  1301. // if (this.listNode) this.listNode.destroy();
  1302. // if (this.property) this.property.propertyContent.destroy();
  1303. //
  1304. // var idx = this.view.items.indexOf(this);
  1305. //
  1306. // if (this.view.viewContentTableNode){
  1307. // var trs = this.view.viewContentTableNode.getElements("tr");
  1308. // trs.each(function(tr){
  1309. // tr.deleteCell(idx);
  1310. // }.bind(this));
  1311. // }
  1312. //
  1313. // if (this.view.json.data.selectList) this.view.json.data.selectList.erase(this.json);
  1314. // if (this.view.json.data.calculate) if (this.view.json.data.calculate.calculateList) this.view.json.data.calculate.calculateList.erase(this.json);
  1315. // this.view.items.erase(this);
  1316. // if (this.view.property) this.view.property.loadStatColumnSelect();
  1317. //
  1318. // this.areaNode.destroy();
  1319. // this.view.selected();
  1320. //
  1321. // this.view.setViewWidth();
  1322. //
  1323. // MWF.release(this);
  1324. // delete this;
  1325. //},
  1326. //move: function(e){
  1327. // this._createMoveNode();
  1328. //
  1329. // //this._setNodeMove(columnNodes, e);
  1330. //},
  1331. //_createMoveNode: function(){
  1332. // this.moveNode = new Element("div", {"text": this.node.get("text")});
  1333. // this.moveNode.inject(this.view.designer.content);
  1334. // this.moveNode.setStyles({
  1335. // "border": "2px dashed #ffa200",
  1336. // "opacity": 0.7,
  1337. // "height": "30px",
  1338. // "line-height": "30px",
  1339. // "padding": "0px 10px",
  1340. // "position": "absolute"
  1341. // });
  1342. //},
  1343. //_setMoveNodePosition: function(e){
  1344. // var x = e.page.x+2;
  1345. // var y = e.page.y+2;
  1346. // this.moveNode.positionTo(x, y);
  1347. //},
  1348. //createMoveFlagNode: function(){
  1349. // this.moveFlagNode = new Element("td", {"styles": this.css.moveFlagNode});
  1350. //},
  1351. //_setNodeMove: function(droppables, e){
  1352. // this._setMoveNodePosition(e);
  1353. // var movePosition = this.moveNode.getPosition();
  1354. // var moveSize = this.moveNode.getSize();
  1355. // var contentPosition = this.content.getPosition();
  1356. // var contentSize = this.content.getSize();
  1357. //
  1358. // var nodeDrag = new Drag.Move(this.moveNode, {
  1359. // "droppables": droppables,
  1360. // "limit": {
  1361. // "x": [contentPosition.x, contentPosition.x+contentSize.x],
  1362. // "y": [movePosition.y, movePosition.y+moveSize.y]
  1363. // },
  1364. // "onEnter": function(dragging, inObj){
  1365. // if (!this.moveFlagNode) this.createMoveFlagNode();
  1366. // this.moveFlagNode.inject(inObj, "before");
  1367. // }.bind(this),
  1368. // "onLeave": function(dragging, inObj){
  1369. // if (this.moveFlagNode){
  1370. // this.moveFlagNode.dispose();
  1371. // }
  1372. // }.bind(this),
  1373. // "onDrop": function(dragging, inObj){
  1374. // if (inObj){
  1375. // this.areaNode.inject(inObj, "before");
  1376. // var column = inObj.retrieve("column");
  1377. // this.listNode.inject(column.listNode, "before");
  1378. // var idx = this.view.json.data.selectList.indexOf(column.json);
  1379. //
  1380. // this.view.json.data.selectList.erase(this.json);
  1381. // this.view.items.erase(this);
  1382. //
  1383. // this.view.json.data.selectList.splice(idx, 0, this.json);
  1384. // this.view.items.splice(idx, 0, this);
  1385. //
  1386. // if (this.moveNode) this.moveNode.destroy();
  1387. // if (this.moveFlagNode) this.moveFlagNode.destroy();
  1388. // this._setActionAreaPosition();
  1389. // }else{
  1390. // if (this.moveNode) this.moveNode.destroy();
  1391. // if (this.moveFlagNode) this.moveFlagNode.destroy();
  1392. // }
  1393. // }.bind(this),
  1394. // "onCancel": function(dragging){
  1395. // if (this.moveNode) this.moveNode.destroy();
  1396. // if (this.moveFlagNode) this.moveFlagNode.destroy();
  1397. // }.bind(this)
  1398. // });
  1399. // nodeDrag.start(e);
  1400. //},
  1401. deletePropertiesOrStyles: function(name, key){
  1402. if (name=="properties"){
  1403. try{
  1404. this.node.removeProperty(key);
  1405. }catch(e){}
  1406. }
  1407. },
  1408. setPropertiesOrStyles: function(name){
  1409. if (name=="styles"){
  1410. try{
  1411. this.setCustomStyles();
  1412. }catch(e){}
  1413. }
  1414. if (name=="properties"){
  1415. try{
  1416. this.node.setProperties(this.json.properties);
  1417. }catch(e){}
  1418. }
  1419. },
  1420. setCustomNodeStyles: function(node, styles){
  1421. var border = node.getStyle("border");
  1422. node.clearStyles();
  1423. //node.setStyles(styles);
  1424. node.setStyle("border", border);
  1425. Object.each(styles, function(value, key){
  1426. var reg = /^border\w*/ig;
  1427. if (!key.test(reg)){
  1428. node.setStyle(key, value);
  1429. }
  1430. }.bind(this));
  1431. },
  1432. setCustomStyles: function(){
  1433. var border = this.node.getStyle("border");
  1434. this.node.clearStyles();
  1435. this.node.setStyles(this.css.moduleNode);
  1436. if (this.initialStyles) this.node.setStyles(this.initialStyles);
  1437. this.node.setStyle("border", border);
  1438. if (this.json.styles) Object.each(this.json.styles, function(value, key){
  1439. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1)){
  1440. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  1441. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  1442. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  1443. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1444. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  1445. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  1446. }
  1447. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  1448. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1449. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  1450. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  1451. }
  1452. }
  1453. var reg = /^border\w*/ig;
  1454. if (!key.test(reg)){
  1455. if (key){
  1456. if (key.toString().toLowerCase()==="display"){
  1457. if (value.toString().toLowerCase()==="none"){
  1458. this.node.setStyle("opacity", 0.3);
  1459. }else{
  1460. this.node.setStyle("opacity", 1);
  1461. this.node.setStyle(key, value);
  1462. }
  1463. }else{
  1464. this.node.setStyle(key, value);
  1465. }
  1466. }
  1467. }
  1468. //this.node.setStyle(key, value);
  1469. }.bind(this));
  1470. },
  1471. _setEditStyle: function(name, obj, oldValue){
  1472. var title = "";
  1473. var text = "";
  1474. if (name==="name"){
  1475. title = this.json.name || this.json.id;
  1476. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1477. this.treeNode.setText("<"+text+"> "+title);
  1478. }
  1479. if (name==="id"){
  1480. title = this.json.name || this.json.id;
  1481. if (!this.json.name){
  1482. text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  1483. this.treeNode.setText("<"+text+"> "+this.json.id);
  1484. }
  1485. this.treeNode.setTitle(this.json.id);
  1486. this.node.set("id", this.json.id);
  1487. }
  1488. this._setEditStyle_custom(name, obj, oldValue);
  1489. },
  1490. reloadMaplist: function(){
  1491. if (this.property) Object.each(this.property.maplists, function(map, name){ map.reload(this.json[name]);}.bind(this));
  1492. },
  1493. getHtml: function(){
  1494. var copy = this.node.clone(true, true);
  1495. copy.clearStyles(true);
  1496. var html = copy.outerHTML;
  1497. copy.destroy();
  1498. return html;
  1499. },
  1500. getJson: function(){
  1501. var json = Object.clone(this.json);
  1502. var o = {};
  1503. o[json.id] = json;
  1504. return o;
  1505. },
  1506. _createNode: function(callback){
  1507. this.node = new Element("div", {
  1508. "id": this.json.id,
  1509. "MWFType": "actionbar",
  1510. "styles": this.css.toolbarWarpNode,
  1511. "events": {
  1512. "selectstart": function(e){
  1513. e.preventDefault();
  1514. }
  1515. }
  1516. }).inject(this.container );
  1517. this.toolbarNode = new Element("div").inject(this.node);
  1518. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1519. if (!this.json.actionStyles){
  1520. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1521. }
  1522. //MWF.getJSON(this.path+"toolbars.json", function(json){
  1523. // this.json.defaultTools = json;
  1524. // this.setToolbars(json, this.toolbarNode);
  1525. // debugger;
  1526. // this.toolbarWidget.load();
  1527. //}.bind(this), false);
  1528. if (this.json.defaultTools){
  1529. var json = Array.clone(this.json.defaultTools);
  1530. //if (this.json.tools) json.append(this.json.tools);
  1531. this.setToolbars(json, this.toolbarNode);
  1532. if (this.json.tools){
  1533. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1534. }
  1535. this.toolbarWidget.load();
  1536. this._setEditStyle_custom("hideSystemTools");
  1537. //json = null;
  1538. }else{
  1539. MWF.getJSON(this.path+"toolbars.json", function(json){
  1540. this.json.defaultTools = json;
  1541. var json = Array.clone(this.json.defaultTools);
  1542. //if (this.json.tools) json.append(this.json.tools);
  1543. this.setToolbars(json, this.toolbarNode);
  1544. if (this.json.tools){
  1545. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1546. }
  1547. this.toolbarWidget.load();
  1548. this._setEditStyle_custom("hideSystemTools");
  1549. //json = null;
  1550. }.bind(this), false);
  1551. }
  1552. },
  1553. _refreshActionbar: function(){
  1554. //if (this.form.options.mode == "Mobile"){
  1555. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1556. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1557. //}else{
  1558. this.toolbarNode = this.node.getFirst("div");
  1559. this.toolbarNode.empty();
  1560. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1561. if (!this.json.actionStyles) this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1562. this.toolbarWidget.css = this.json.actionStyles;
  1563. if (this.json.defaultTools){
  1564. var json = Array.clone(this.json.defaultTools);
  1565. //if (this.json.tools) json.append(this.json.tools);
  1566. this.setToolbars(json, this.toolbarNode);
  1567. if (this.json.tools){
  1568. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1569. }
  1570. this.toolbarWidget.load();
  1571. //json = null;
  1572. }else{
  1573. MWF.getJSON(this.path+"toolbars.json", function(json){
  1574. this.json.defaultTools = json;
  1575. var json = Array.clone(this.json.defaultTools);
  1576. //if (this.json.tools) json.append(this.json.tools);
  1577. this.setToolbars(json, this.toolbarNode);
  1578. if (this.json.tools){
  1579. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1580. }
  1581. this.toolbarWidget.load();
  1582. //json = null;
  1583. }.bind(this), false);
  1584. }
  1585. //}
  1586. },
  1587. _resetActionbar: function(){
  1588. //if (this.form.options.mode == "Mobile"){
  1589. // this.node.set("text", MWF.APPFD.LP.notice.notUseModuleInMobile+"("+this.moduleName+")");
  1590. // this.node.setStyles({"height": "24px", "line-height": "24px", "background-color": "#999"});
  1591. //}else{
  1592. this.toolbarNode = this.node.getFirst("div");
  1593. this.toolbarNode.empty();
  1594. this.toolbarWidget = new MWF.widget.Toolbar(this.toolbarNode, {"style": this.json.style}, this);
  1595. if (!this.json.actionStyles){
  1596. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1597. }else{
  1598. this.toolbarWidget.css = Object.merge( Object.clone(this.json.actionStyles), this.toolbarWidget.css );
  1599. this.json.actionStyles = Object.clone(this.toolbarWidget.css);
  1600. }
  1601. if (this.json.defaultTools){
  1602. var json = Array.clone(this.json.defaultTools);
  1603. //if (this.json.tools) json.append(this.json.tools);
  1604. this.setToolbars(json, this.toolbarNode);
  1605. if (this.json.tools){
  1606. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1607. }
  1608. this.toolbarWidget.load();
  1609. //json = null;
  1610. }else{
  1611. MWF.getJSON(this.path+"toolbars.json", function(json){
  1612. this.json.defaultTools = json;
  1613. var json = Array.clone(this.json.defaultTools);
  1614. //if (this.json.tools) json.append(this.json.tools);
  1615. this.setToolbars(json, this.toolbarNode);
  1616. if (this.json.tools){
  1617. this.setCustomToolbars(Array.clone(this.json.tools), this.toolbarNode);
  1618. }
  1619. this.toolbarWidget.load();
  1620. //json = null;
  1621. }.bind(this), false);
  1622. }
  1623. //}
  1624. },
  1625. setToolbars: function(tools, node){
  1626. tools.each(function(tool){
  1627. var actionNode = new Element("div", {
  1628. "MWFnodetype": tool.type,
  1629. "MWFButtonImage": this.imagePath_default+""+this.options.style+"/actionbar/"+tool.img,
  1630. "title": tool.title,
  1631. "MWFButtonAction": tool.action,
  1632. "MWFButtonText": tool.text
  1633. }).inject(node);
  1634. if( this.json.iconOverStyle ){
  1635. actionNode.set("MWFButtonImageOver" , this.imagePath_default+""+this.options.style+"/actionbar/"+this.json.iconOverStyle+"/"+tool.img );
  1636. }
  1637. this.systemTools.push(actionNode);
  1638. if (tool.sub){
  1639. var subNode = node.getLast();
  1640. this.setToolbars(tool.sub, subNode);
  1641. }
  1642. }.bind(this));
  1643. },
  1644. setCustomToolbars: function(tools, node){
  1645. //var style = (this.json.style || "default").indexOf("red") > -1 ? "red" : "blue";
  1646. var path = "";
  1647. if( this.json.customIconStyle ){
  1648. path = this.json.customIconStyle+ "/";
  1649. }
  1650. tools.each(function(tool){
  1651. var actionNode = new Element("div", {
  1652. "MWFnodetype": tool.type,
  1653. "MWFButtonImage": this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+path+tool.img,
  1654. "title": tool.title,
  1655. "MWFButtonAction": tool.action,
  1656. "MWFButtonText": tool.text
  1657. }).inject(node);
  1658. if( this.json.customIconOverStyle ){
  1659. actionNode.set("MWFButtonImageOver" , this.imagePath_custom+""+this.options.customImageStyle +"/custom/"+this.json.customIconOverStyle+ "/" +tool.img );
  1660. }
  1661. this.customTools.push(actionNode);
  1662. if (tool.sub){
  1663. var subNode = node.getLast();
  1664. this.setToolbars(tool.sub, subNode);
  1665. }
  1666. }.bind(this));
  1667. },
  1668. _setEditStyle_custom: function(name){
  1669. if (name=="hideSystemTools"){
  1670. if (this.json.hideSystemTools){
  1671. this.systemTools.each(function(tool){
  1672. tool.setStyle("display", "none");
  1673. });
  1674. }else{
  1675. this.systemTools.each(function(tool){
  1676. tool.setStyle("display", "block");
  1677. });
  1678. }
  1679. }
  1680. if (name=="defaultTools" || name=="tools" || name==="actionStyles"){
  1681. this._refreshActionbar();
  1682. }
  1683. }
  1684. });