Main.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569
  1. MWF.xApplication.cms = MWF.xApplication.cms || {};
  2. MWF.CMSE = MWF.xApplication.cms.Module = MWF.xApplication.cms.Module ||{};
  3. MWF.require("MWF.widget.O2Identity", null,false);
  4. //MWF.xDesktop.requireApp("cms.Module", "Actions.RestActions", null, false);
  5. MWF.xApplication.cms.Module.options = {
  6. multitask: false,
  7. executable: true
  8. };
  9. MWF.xApplication.cms.Module.Main = new Class({
  10. Extends: MWF.xApplication.Common.Main,
  11. Implements: [Options, Events],
  12. options: {
  13. "style": "default",
  14. "name": "cms.Module",
  15. "icon": "icon.png",
  16. "width": "1200",
  17. "height": "700",
  18. "isResize": true,
  19. "isMax": true,
  20. "isCategory" : false,
  21. "searchKey" : "",
  22. "title": MWF.xApplication.cms.Module.LP.title
  23. },
  24. onQueryLoad: function(){
  25. this.lp = MWF.xApplication.cms.Module.LP;
  26. },
  27. onQueryClose : function(){
  28. if (window.clipboardData){
  29. if (this.keyCopyItemsFun)this.removeEvent("copy", this.keyCopyItemsFun);
  30. if (this.keyPasteItemsFun)this.removeEvent("paste", this.keyPasteItemsFun);
  31. }else{
  32. if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  33. if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun);
  34. }
  35. },
  36. loadApplication: function(callback){
  37. //this.controllers = [];
  38. this.isAdmin = false;
  39. this.restActions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Module.Actions.RestActions();
  40. this.createNode();
  41. this.loadApplicationContent();
  42. },
  43. createNode: function(){
  44. this.content.setStyle("overflow", "hidden");
  45. this.node = new Element("div", {
  46. "styles": this.css.node
  47. }).inject(this.content);
  48. this.naviContainerNode = new Element("div.naviContainerNode", {
  49. "styles": this.css.naviContainerNode
  50. }).inject(this.node);
  51. this.leftTitleNode = new Element("div.leftTitleNode", {
  52. "styles": this.css.leftTitleNode
  53. }).inject(this.naviContainerNode);
  54. this.rightContentNode = new Element("div", {
  55. "styles":this.css.rightContentNode
  56. }).inject(this.node);
  57. this.titleBar = new Element("div", {
  58. "styles": this.css.titleBar
  59. }).inject(this.rightContentNode );
  60. this.titleActionBar = new Element("div", {
  61. "styles": this.css.titleActionBar
  62. }).inject(this.titleBar );
  63. },
  64. loadApplicationContent: function(){
  65. if( this.options.columnData ){
  66. this.setColumnDataConfig();
  67. this.setTitle(this.options.columnData.appName);
  68. this.loadController(function(){
  69. this.loadTitle(function(){
  70. this.loadMenu();
  71. }.bind(this));
  72. }.bind(this))
  73. }else if( (this.status && this.status.columnId) || this.options.columnId ){
  74. var columnId = this.options.columnId || this.status.columnId;
  75. this.loadColumnData( columnId, function(){
  76. this.loadController(function(){
  77. this.loadTitle(function(){
  78. this.loadMenu();
  79. }.bind(this));
  80. }.bind(this))
  81. }.bind(this))
  82. }else if( this.options.columnAlias ){
  83. this.restActions.getColumnByAlias( this.options.columnAlias, function( json ){
  84. this.options.columnData = json.data;
  85. this.setColumnDataConfig();
  86. this.setTitle(this.options.columnData.appName);
  87. this.loadController(function(){
  88. this.loadTitle(function(){
  89. this.loadMenu();
  90. }.bind(this));
  91. }.bind(this))
  92. }.bind(this))
  93. }
  94. },
  95. setColumnDataConfig : function(){
  96. if( !this.options.columnData.config ){
  97. this.options.columnData.config = {};
  98. }else if( typeOf(this.options.columnData.config) === "string" ){
  99. this.options.columnData.config = JSON.parse( this.options.columnData.config || {} );
  100. }
  101. },
  102. loadColumnData : function(columnId, callback){
  103. this.restActions.getColumn( columnId, function( json ){
  104. this.options.columnData = json.data;
  105. this.setTitle(this.options.columnData.appName);
  106. this.setColumnDataConfig();
  107. //MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
  108. //MWF.require("o2.xScript.Macro", null, false);
  109. //var scriptAction = new MWF.xScript.Actions.CMSScriptActions();
  110. //scriptAction.getScriptByName( this.options.columnData.id, "_config", [], function(json){
  111. // if (json.data){
  112. // try{
  113. // this.options.columnData = Object.merge(this.options.columnData,JSON.parse(json.data.text));
  114. // }catch(e){
  115. // }
  116. // }
  117. //}.bind(this), null, false);
  118. if(callback)callback()
  119. }.bind(this))
  120. },
  121. loadController: function(callback){
  122. //this.restActions.listColumnController(this.options.columnData.id, function( json ){
  123. // json.data = json.data || [];
  124. // json.data.each(function(item){
  125. // this.controllers.push(item.adminUid)
  126. // }.bind(this));
  127. // this.isAdmin = MWF.AC.isCMSManager() || this.controllers.contains(layout.desktop.session.user.distinguishedName);
  128. // if(callback)callback(json);
  129. //}.bind(this));
  130. this.restActions.isAppInfoManager( this.options.columnData.id, function( json ){
  131. this.isAdmin = MWF.AC.isCMSManager() || json.data.value;
  132. if(callback)callback(json);
  133. }.bind(this))
  134. },
  135. loadTitle : function(callback){
  136. if( this.isAdmin ){
  137. //this.loadImportActionNode();
  138. //this.loadExportActionNode();
  139. }
  140. this.loadCreateDocumentActionNode(
  141. function(){
  142. this.loadTitleIconNode();
  143. this.loadTitleContentNode();
  144. this.loadBatchAction();
  145. this.loadPastEvent();
  146. this.loadSearchNode();
  147. if(callback)callback();
  148. }.bind(this)
  149. );
  150. },
  151. loadBatchAction: function(){
  152. if( !this.isAdmin )return;
  153. this.batchAction = new Element("div", {
  154. "styles": this.css.batchAction,
  155. "text" : "选择"
  156. }).inject(this.titleActionBar);
  157. this.batchAction.addEvents({
  158. "click": function(e){
  159. if( this.view ){
  160. if( this.view.selectEnable ){
  161. this.selectEnable = false;
  162. this.batchAction.setStyles( this.css.batchAction );
  163. this.batchAction.set("text","选择");
  164. this.view.disableSelectMode();
  165. this.cancelBatchRemoveAction();
  166. this.cancelChangeCategoryAction();
  167. this.cancelCopyActionNode();
  168. }else{
  169. this.selectEnable = true;
  170. this.batchAction.setStyles( this.css.batchAction_over );
  171. this.batchAction.set("text","取消选择");
  172. this.view.selectMode();
  173. this.loadCopyActionNode();
  174. this.loadChangeCategoryAction();
  175. this.loadBatchRemoveAction();
  176. }
  177. }
  178. }.bind(this),
  179. "mouseover" : function(e){
  180. if( this.view.selectEnable )return;
  181. this.batchAction.setStyles( this.css.batchAction_over )
  182. }.bind(this),
  183. "mouseout" : function(e){
  184. if( this.view.selectEnable )return;
  185. this.batchAction.setStyles( this.css.batchAction )
  186. }.bind(this)
  187. });
  188. },
  189. getSearchBarSize : function(){
  190. var x_action = this.titleActionBar.getSize().x;
  191. var x_titlebar = this.titleBar.getSize().x;
  192. return x_titlebar - x_action;
  193. },
  194. loadPastEvent : function(){
  195. if( !this.isAdmin )return;
  196. this.keyPasteItemsFun = this.keyPasteItems.bind(this);
  197. if (window.clipboardData){
  198. this.addEvent("paste", this.keyPasteItemsFun);
  199. }else{
  200. document.addEventListener('paste', this.keyPasteItemsFun);
  201. //this.addEvent("queryClose", function(){
  202. // if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun);
  203. //}.bind(this));
  204. }
  205. },
  206. loadCreateDocumentActionNode: function( callback ){
  207. this.restActions.listCategoryByPublisher( this.options.columnData.id, function( json ){
  208. if( json.data && json.data.length ){
  209. this.createDocumentAction = new Element("div", {
  210. "styles": this.css.createDocumentAction,
  211. "text" : this.lp.start
  212. }).inject(this.titleActionBar);
  213. this.createDocumentAction.addEvents({
  214. "click": function(e){
  215. MWF.xDesktop.requireApp("cms.Index", "Newer", null, false);
  216. //if(this.options.columnData.latest===undefined) this.options.columnData.latest = true;
  217. //if(this.options.columnData.ignoreTitle===undefined) this.options.columnData.ignoreTitle = false;
  218. this.creater = new MWF.xApplication.cms.Index.Newer( this.options.columnData, null, this, this.view, {
  219. restrictToColumn : true
  220. //ignoreTitle : this.options.columnData.ignoreTitle,
  221. //latest : this.options.columnData.latest
  222. });
  223. this.creater.load();
  224. }.bind(this),
  225. "mouseover" : function(e){
  226. this.createDocumentAction.setStyles( this.css.createDocumentAction_over )
  227. }.bind(this),
  228. "mouseout" : function(e){
  229. this.createDocumentAction.setStyles( this.css.createDocumentAction )
  230. }.bind(this)
  231. });
  232. }
  233. if(callback)callback();
  234. }.bind(this));
  235. },
  236. cancelChangeCategoryAction : function(){
  237. if(this.moveAction)this.moveAction.destroy();
  238. this.moveAction = null;
  239. },
  240. loadChangeCategoryAction : function(){
  241. if( !this.isAdmin )return;
  242. this.moveAction = new Element("div", {
  243. "styles": this.css.moveDocumentAction,
  244. "text" : "移动"
  245. }).inject(this.titleActionBar);
  246. this.moveAction.addEvents({
  247. "click": function(e){
  248. var _self = this;
  249. if( this.view ){
  250. var itemIds = this.view.getSelectedIds();
  251. if (!itemIds.length) {
  252. this.notice("请先选择文档","error");
  253. return;
  254. }
  255. this.loadSelectColumnDialog( function( data ){
  256. if( data && data.id ){
  257. var text = "移动后将在本分类删除,确定要移动选中的"+itemIds.length+"个文档到"+data.categoryName+"?";
  258. this.confirm("warn", e, "移动确认", text, 350, 120, function(){
  259. _self.restActions.moveDocumentToCategory({
  260. ids : itemIds,
  261. categoryId : data.id
  262. }, function(){
  263. _self.notice("移动成功", "success");
  264. _self.view.reload();
  265. this.close();
  266. }.bind(this))
  267. }, function(){
  268. this.close();
  269. });
  270. }
  271. }.bind(this))
  272. }
  273. }.bind(this),
  274. "mouseover" : function(e){
  275. this.moveAction.setStyles( this.css.moveDocumentAction_over )
  276. }.bind(this),
  277. "mouseout" : function(e){
  278. this.moveAction.setStyles( this.css.moveDocumentAction )
  279. }.bind(this)
  280. });
  281. },
  282. cancelBatchRemoveAction : function(){
  283. if(this.batchRemoveAction)this.batchRemoveAction.destroy();
  284. this.batchRemoveAction = null;
  285. },
  286. loadBatchRemoveAction : function(){
  287. if( !this.isAdmin )return;
  288. var _self = this;
  289. this.batchRemoveAction = new Element("div", {
  290. "styles": this.css.batchRemoveDocumentAction,
  291. "text" : this.lp.batchRemove
  292. }).inject(this.titleActionBar);
  293. this.batchRemoveAction.addEvents({
  294. "click": function(e){
  295. if( this.view ){
  296. var itemIds = this.view.getSelectedIds();
  297. if (itemIds.length) {
  298. _self.readyRemove = true;
  299. var text = "删除后无法恢复,确定要删除选中的"+itemIds.length+"个文档?";
  300. this.confirm("warn", e, "清除确认", text, 350, 120, function(){
  301. _self.removeDocumentList(itemIds);
  302. this.close();
  303. }, function(){
  304. _self.readyRemove = false;
  305. this.close();
  306. });
  307. }else{
  308. this.notice("请先选择文档","error")
  309. }
  310. }
  311. }.bind(this),
  312. "mouseover" : function(e){
  313. this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction_over )
  314. }.bind(this),
  315. "mouseout" : function(e){
  316. this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction )
  317. }.bind(this)
  318. });
  319. },
  320. //loadBatchRemoveAction : function(){
  321. // if( !this.isAdmin )return;
  322. //
  323. // this.batchRemoveAction = new Element("div", {
  324. // "styles": this.css.batchRemoveDocumentAction,
  325. // "text" : this.lp.batchRemove
  326. // }).inject(this.titleBar);
  327. // this.batchRemoveAction.addEvents({
  328. // "click": function(e){
  329. // if( this.view ){
  330. // if( this.view.selectEnable ){
  331. // this.view.disableSelectMode();
  332. // this.batchRemoveConfirmAction.setStyle("display","none");
  333. // //this.batchRemoveAction.set("text",this.lp.batchRemove);
  334. // }else{
  335. // this.view.selectMode();
  336. // this.batchRemoveConfirmAction.setStyle("display","");
  337. // //this.batchRemoveAction.set("text",this.lp.cancel);
  338. // }
  339. // }
  340. // }.bind(this),
  341. // "mouseover" : function(e){
  342. // this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction_over )
  343. // }.bind(this),
  344. // "mouseout" : function(e){
  345. // this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction )
  346. // }.bind(this)
  347. // });
  348. //
  349. //
  350. // this.batchRemoveConfirmAction = new Element("div", {
  351. // "styles": this.css.batchRemoveConfirmDocumentAction,
  352. // "text" : this.lp.batchRemoveConfirm
  353. // }).inject(this.titleBar);
  354. // var _self = this;
  355. // this.batchRemoveConfirmAction.addEvents({
  356. // "click": function (e) {
  357. // var itemIds = this.view.getSelectedIds();
  358. // if (itemIds.length) {
  359. // _self.readyRemove = true;
  360. // var text = "删除后无法恢复,确定要删除选中的"+itemIds.length+"个文档?";
  361. // this.confirm("warn", e, "清除确认", text, 350, 120, function(){
  362. //
  363. // _self.removeDocumentList(itemIds);
  364. //
  365. // this.close();
  366. //
  367. // }, function(){
  368. // _self.readyRemove = false;
  369. // this.close();
  370. // });
  371. // }else{
  372. // this.notice("请先选择文档","error")
  373. // }
  374. // }.bind(this)
  375. // });
  376. // this.batchRemoveConfirmAction.setStyle("display","none");
  377. //},
  378. removeDocumentList : function( itemIds ){
  379. var count = 0;
  380. itemIds.each( function(id){
  381. this.restActions.removeDocument(id, function(json){
  382. count++;
  383. if( count === itemIds.length ){
  384. this.notice("清除成功", "success");
  385. //this.view.disableSelectMode();
  386. this.view.reload();
  387. }
  388. }.bind(this));
  389. }.bind(this))
  390. },
  391. cancelCopyActionNode : function(){
  392. if (window.clipboardData){
  393. if (this.keyCopyItemsFun)this.removeEvent("copy", this.keyCopyItemsFun);
  394. }else{
  395. if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  396. }
  397. this.keyCopyItemsFun = null;
  398. if(this.copyAction)this.copyAction.destroy();
  399. this.copyAction = null;
  400. },
  401. loadCopyActionNode : function(){
  402. if( !this.isAdmin )return;
  403. this.copyAction = new Element("div", {
  404. "styles": this.css.copyDocumentAction,
  405. "text" : "启用复制"
  406. }).inject(this.titleActionBar);
  407. this.copyAction.addEvents({
  408. "click": function(e){
  409. if( this.view ){
  410. if( this.keyCopyItemsFun )return;
  411. this.keyCopyItemsFun = this.keyCopyItems.bind(this);
  412. if (window.clipboardData){
  413. this.addEvent("copy", this.keyCopyItemsFun);
  414. }else{
  415. document.addEventListener('copy', this.keyCopyItemsFun);
  416. //this.addEvent("queryClose", function(){
  417. // if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  418. //}.bind(this));
  419. }
  420. this.notice( this.lp.copyInfor );
  421. }
  422. }.bind(this),
  423. "mouseover" : function(e){
  424. this.copyAction.setStyles( this.css.copyDocumentAction_over )
  425. }.bind(this),
  426. "mouseout" : function(e){
  427. this.copyAction.setStyles( this.css.copyDocumentAction )
  428. }.bind(this)
  429. });
  430. },
  431. //loadCopyActionNode : function(){
  432. // if( !this.isAdmin )return;
  433. // this.copyAction = new Element("div", {
  434. // "styles": this.css.copyDocumentAction,
  435. // "text" : this.lp.copy
  436. // }).inject(this.titleBar);
  437. // this.copyAction.addEvents({
  438. // "click": function(e){
  439. // if( this.view ){
  440. // if( this.view.selectEnable ){
  441. // this.view.disableSelectMode();
  442. // if (window.clipboardData){
  443. // if (this.keyCopyItemsFun)this.removeEvent("copy", this.keyCopyItemsFun);
  444. // }else{
  445. // if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  446. // }
  447. // this.keyCopyItemsFun = null;
  448. // }else{
  449. // this.view.selectMode();
  450. // this.keyCopyItemsFun = this.keyCopyItems.bind(this);
  451. // if (window.clipboardData){
  452. // this.addEvent("copy", this.keyCopyItemsFun);
  453. // }else{
  454. // document.addEventListener('copy', this.keyCopyItemsFun);
  455. // //this.addEvent("queryClose", function(){
  456. // // if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
  457. // //}.bind(this));
  458. // }
  459. // this.notice( this.lp.copyInfor );
  460. // }
  461. // }
  462. // }.bind(this),
  463. // "mouseover" : function(e){
  464. // this.copyAction.setStyles( this.css.copyDocumentAction_over )
  465. // }.bind(this),
  466. // "mouseout" : function(e){
  467. // this.copyAction.setStyles( this.css.copyDocumentAction )
  468. // }.bind(this)
  469. // });
  470. //},
  471. keyCopyItems: function(e){
  472. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId) {
  473. var itemIds = this.view.getSelectedIds();
  474. if (itemIds.length) {
  475. var items = [];
  476. var i = 0;
  477. var checkItems = function (e) {
  478. if (i >= itemIds.length) {
  479. if (items.length) {
  480. var str = JSON.encode(items);
  481. if (e && e.clipboardData) {
  482. e.clipboardData.setData('text/plain', str);
  483. e.preventDefault();
  484. } else {
  485. window.clipboardData.setData("Text", str);
  486. }
  487. this.notice(this.lp.copyed, "success");
  488. }
  489. }
  490. }.bind(this);
  491. itemIds.each(function (id) {
  492. this.restActions.getDocument(id, function (json) {
  493. json.data.elementType = "cmsDocument";
  494. items.push(json.data);
  495. i++;
  496. checkItems(e);
  497. }.bind(this), null, false)
  498. }.bind(this));
  499. }
  500. }
  501. },
  502. keyPasteItems: function(e){
  503. if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId) {
  504. var dataStr = "";
  505. if (e && e.clipboardData) {
  506. dataStr = e.clipboardData.getData('text/plain');
  507. } else {
  508. dataStr = window.clipboardData.getData("Text");
  509. }
  510. var data = JSON.decode(dataStr);
  511. this.listPublishableCategoryInfo(function(){
  512. this.pasteItem(data, 0);
  513. }.bind(this))
  514. }
  515. },
  516. listPublishableCategoryInfo : function( callback ){
  517. this.publishableCategoryInfoObject_id = {};
  518. this.publishableCategoryInfoObject_alias = {};
  519. this.publishableCategoryInfoObject_name = {};
  520. this.categoryTransformMap = {};
  521. this.categoryRadioHtml = "";
  522. o2.Actions.load("x_cms_assemble_control").CategoryInfoAction.listPublishableCategoryInfo( this.options.columnData.id, function(json){
  523. ( json.data || [] ).each( function(c){
  524. this.publishableCategoryInfoObject_id[c.id] = c;
  525. this.publishableCategoryInfoObject_alias[c.categoryAlias] = c;
  526. this.publishableCategoryInfoObject_name[c.categoryName] = c;
  527. this.categoryRadioHtml += "<div><input type='radio' name='categoryRadio' value='"+ c.id+"'/>" + c.categoryName + "(" + c.categoryAlias +")</div>"
  528. }.bind(this));
  529. this.categoryRadioHtml = "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'>" +
  530. this.categoryRadioHtml + "</div>"
  531. if(callback)callback();
  532. }.bind(this));
  533. },
  534. pasteItem: function(data, i){
  535. if (i<data.length){
  536. var item = data[i];
  537. if (item.elementType==="cmsDocument"){
  538. this.saveItemAs(item, function(){
  539. i++;
  540. this.pasteItem(data, i);
  541. }.bind(this), function(){
  542. i++;
  543. this.pasteItem(data, i);
  544. }.bind(this), function(){
  545. this.view.reload();
  546. }.bind(this));
  547. }else{
  548. i++;
  549. this.pasteItem(data, i);
  550. }
  551. }else{
  552. this.view.reload();
  553. }
  554. },
  555. saveItemAs: function(data, success, failure, cancel){
  556. var lp = this.lp;
  557. var _self = this;
  558. if( this.publishableCategoryInfoObject_id[ data.document.categoryId ] ){
  559. this._saveItemAs(data, success, failure, cancel );
  560. }else if( this.categoryTransformMap[ data.document.categoryId ] ){
  561. this._saveItemAs(data, success, failure, cancel, this.categoryTransformMap[ data.document.categoryId ] );
  562. }else{
  563. var text;
  564. if( this.publishableCategoryInfoObject_alias[ data.document.categoryAlias ] ){
  565. text = lp.copyConfirmCategoryInfor_hasSameAlias + "。<br/>" + lp.copyConfirmCateogyrInfor_withChoice
  566. }else if( this.publishableCategoryInfoObject_name[ data.document.categoryName ] ){
  567. text = lp.copyConfirmCategoryInfor_hasSameName + "。<br/>" + lp.copyConfirmCateogyrInfor_withChoice
  568. }else{
  569. text = lp.copyConfirmCategoryInfor_noCategory + ":"
  570. }
  571. text = text.replace("{alias}", "(<span style='color:red;'>" + data.document.categoryAlias + "</span>)" );
  572. text = text.replace("{name}", "(<span style='color:red;'>" + data.document.categoryName + "</span>)" );
  573. var html = "<div style='overflow-y:auto;height:300px'>";
  574. html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'>";
  575. html += " <div style='clear: both;font-weight: bold; font-size:14px;'>"+lp.copyTarget+" "+data.document.title+"</div>";
  576. html += " <div style='font-size:12px; color: #666666; float: left;'>"+data.document.publishTime+"</div>";
  577. html += " <div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(data.document.creatorPersonShort)+"</div>";
  578. html += "</div>";
  579. html += "<div>" + text + "</div>" + this.categoryRadioHtml;
  580. html += "<div><input type='checkbox' value='true' name='useSameChoice'>"+lp.copyConfirm_SameCategory+"</div>";
  581. html += "</div>";
  582. // html += "<>"
  583. this.dlg("inofr", null, lp.copyConfirmCategoryTitle, {"html": html}, 500, 360, [
  584. {
  585. "text": lp.copy,
  586. "action": function(){
  587. var categoryRadio = this.node.getElements("[name='categoryRadio']");
  588. var checkbox = this.node.getElement("[name='useSameChoice']");
  589. var newCategory;
  590. for( var i=0; i<categoryRadio.length; i++ ){
  591. if( categoryRadio[i].checked ){
  592. newCategory = _self.publishableCategoryInfoObject_id[ categoryRadio[i].get("value") ];
  593. }
  594. }
  595. if( !newCategory ){
  596. if( _self.publishableCategoryInfoObject_alias[ data.document.categoryAlias ] ){
  597. newCategory = _self.publishableCategoryInfoObject_alias[ data.document.categoryAlias ];
  598. }else if( _self.publishableCategoryInfoObject_name[ data.document.categoryName ] ){
  599. newCategory = _self.publishableCategoryInfoObject_name[ data.document.categoryName ];
  600. }
  601. }
  602. if( newCategory ){
  603. if( checkbox.checked )_self.categoryTransformMap[ data.document.categoryId ] = newCategory;
  604. this.close();
  605. _self._saveItemAs(data, success, failure, cancel, newCategory );
  606. }else{
  607. _self.notice( lp.notSelectCategory, "error" )
  608. }
  609. //_self.saveItemAsUpdate(someItem, data, success, failure);
  610. }
  611. },
  612. {
  613. "text": lp.copyConfirm_skip,
  614. "action": function(){/*nothing*/ this.close(); if (success) success();}
  615. },
  616. {
  617. "text": lp.copyConfirm_cancel,
  618. "action": function(){this.close(); if (cancel) cancel();}
  619. }
  620. ]);
  621. }
  622. },
  623. _saveItemAs: function(data, success, failure, cancel, newCategory ){
  624. this.restActions.getDocument(data.document.id, function(dJson){
  625. var someItem = dJson.data;
  626. var flag = false;
  627. if (someItem){
  628. if( newCategory ){
  629. if( newCategory.id !== someItem.document.categoryId ){ //如果已有文档的分类和新分类不一样,直接新建
  630. this.saveItemAsNew(data, success, failure, true, newCategory)
  631. }else{ //如果已有文档的分类和新分类一样,需要询问
  632. flag = true;
  633. }
  634. }else{ //如果使用原有分类,需要询问
  635. flag = true;
  636. }
  637. if( flag ){
  638. var lp = this.lp;
  639. var _self = this;
  640. var d1 = new Date().parse(data.document.publishTime);
  641. var d2 = new Date().parse(someItem.document.publishTime);
  642. var html = "<div>"+lp.copyConfirmInfor+"</div>";
  643. html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='font-weight: bold; font-size:14px;'>"+lp.copySource+" "+someItem.document.title+"</div>";
  644. html += "<div style='font-size:12px; color: #666666; float: left'>"+someItem.document.publishTime+"</div>" +
  645. "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(someItem.document.creatorPersonShort)+"</div>" +
  646. "<div style='color: red; float: right;'>"+((d1>=d2) ? "": lp.copynew)+"</div></div>";
  647. html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='clear: both;font-weight: bold; font-size:14px;'>"+lp.copyTarget+" "+data.document.title+"</div>";
  648. html += "<div style='font-size:12px; color: #666666; float: left;'>"+data.document.publishTime+"</div>" +
  649. "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(data.document.creatorPersonShort)+"</div>" +
  650. "<div style='color: red; float: right;'>"+((d1<=d2) ? "": lp.copynew)+"</div></div>";
  651. // html += "<>"
  652. this.dlg("inofr", null, lp.copyConfirmTitle, {"html": html}, 500, 290, [
  653. {
  654. "text": lp.copyConfirm_overwrite,
  655. "action": function(){_self.saveItemAsUpdate(someItem, data, success, failure);this.close();}
  656. },
  657. {
  658. "text": lp.copyConfirm_new,
  659. "action": function(){_self.saveItemAsNew( data, success, failure, true, newCategory );this.close();}
  660. },
  661. {
  662. "text": lp.copyConfirm_skip,
  663. "action": function(){/*nothing*/ this.close(); if (success) success();}
  664. },
  665. {
  666. "text": lp.copyConfirm_cancel,
  667. "action": function(){this.close(); if (cancel) cancel();}
  668. }
  669. ]);
  670. }
  671. }
  672. }.bind(this), function(){
  673. //if (failure) failure();
  674. this.saveItemAsNew(data, success, failure, false, newCategory)
  675. }.bind(this));
  676. },
  677. saveItemAsUpdate: function(someItem, data, success, failure){
  678. var doc = data.document;
  679. doc.id = someItem.document.id;
  680. doc.isNewDocument = false;
  681. doc.appId = someItem.document.appId;
  682. doc.appName = someItem.document.appName;
  683. doc.categoryId = someItem.document.categoryId;
  684. doc.categoryName = someItem.document.categoryName;
  685. doc.categoryAlias = someItem.document.categoryAlias;
  686. doc.form = someItem.document.form;
  687. doc.formName = someItem.document.formName;
  688. doc.readFormId = someItem.document.readFormId;
  689. doc.readFormName = someItem.document.readFormName;
  690. doc.docData = data.data;
  691. this.restActions.saveDocument(doc, function(){
  692. if (success) success();
  693. }.bind(this), function(){
  694. if (failure) failure();
  695. }.bind(this));
  696. },
  697. saveItemAsNew: function(data, success, failure, clearId, newCategory){
  698. var columnData = this.options.columnData;
  699. var doc = data.document;
  700. if( clearId ){
  701. delete doc.id;
  702. }
  703. delete doc.documentType;
  704. delete doc.appId;
  705. delete doc.appName;
  706. delete doc.appAlias;
  707. delete doc.categoryId;
  708. delete doc.categoryName;
  709. delete doc.categoryAlias;
  710. delete doc.form;
  711. delete doc.formName;
  712. delete doc.readFormId;
  713. delete doc.readFormName;
  714. doc.appId = columnData.id;
  715. doc.docData = data.data;
  716. delete doc.docData.$document;
  717. var callback = function(data){
  718. this.restActions.publishDocumentComplex(data, function(){
  719. if (success) success();
  720. }.bind(this), function(){
  721. if (failure) failure();
  722. }.bind(this));
  723. }.bind(this);
  724. if( newCategory ){
  725. doc.categoryId = newCategory.id;
  726. callback( doc );
  727. }else{
  728. this.restActions.getCategory( data.document.categoryId, function( json ){
  729. if( json.data.appId === columnData.id ){
  730. doc.categoryId = data.document.categoryId;
  731. callback( doc );
  732. }else{
  733. this.loadSelectCategoryDialog( "选择"+ data.document.title + "的分类",function(id){
  734. doc.categoryId = id;
  735. callback( doc );
  736. }.bind(this))
  737. }
  738. }.bind(this), function(){
  739. this.loadSelectCategoryDialog( "选择"+ data.document.title + "的分类",function(id){
  740. doc.categoryId = id;
  741. callback( doc );
  742. }.bind(this))
  743. }.bind(this))
  744. }
  745. },
  746. loadSelectColumnDialog : function( callback){
  747. MWF.xDesktop.requireApp("Selector", "package", null, false);
  748. var options = {
  749. "type": "CMSCategory",
  750. "count": 1,
  751. "onComplete": function(items){
  752. items.each(function(item){
  753. if( callback )callback( item.data );
  754. }.bind(this));
  755. }.bind(this)
  756. };
  757. var selector = new MWF.O2Selector(this.content, options);
  758. },
  759. loadSelectCategoryDialog : function(title, callback){
  760. if( !this.categoryList ){
  761. this.categoryList = [];
  762. this.restActions.listCategory( this.options.columnData.id, function( json ){
  763. json.data.each( function(d){
  764. this.categoryList.push( {
  765. name : d.categoryName,
  766. id : d.id
  767. })
  768. }.bind(this))
  769. }.bind(this), null, false)
  770. }
  771. MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false);
  772. var opt = {
  773. "count": 1,
  774. "title": "选择分类",
  775. "selectableItems" : this.categoryList,
  776. "values": [],
  777. "onComplete": function( array ){
  778. if( !array || array.length == 0 )return;
  779. var id = array[0].data.id;
  780. callback( id )
  781. }.bind(this)
  782. };
  783. var selector = new MWF.xApplication.Template.Selector.Custom(this.content, opt );
  784. selector.load();
  785. },
  786. loadImportActionNode : function(){
  787. this.importAction = new Element("div", {
  788. "styles": this.css.importAction,
  789. "text" : this.lp.import
  790. }).inject(this.titleActionBar);
  791. this.importAction.setStyle("display","none");
  792. this.importAction.addEvents({
  793. "click": function(e){
  794. MWF.xDesktop.requireApp("cms.Module", "ExcelForm", null, false);
  795. var categoryData = this.navi.currentObject.isCategory ? this.navi.currentObject.data : this.navi.currentObject.category.data ;
  796. this.import = new MWF.xApplication.cms.Module.ImportForm( { app : this }, categoryData, {} );
  797. this.import.edit();
  798. }.bind(this),
  799. "mouseover" : function(e){
  800. this.importAction.setStyles( this.css.importAction_over )
  801. }.bind(this),
  802. "mouseout" : function(e){
  803. this.importAction.setStyles( this.css.importAction )
  804. }.bind(this)
  805. });
  806. },
  807. loadExportActionNode : function(){
  808. this.exportAction = new Element("div", {
  809. "styles": this.css.exportAction,
  810. "text" : this.lp.export
  811. }).inject(this.titleActionBar);
  812. this.exportAction.setStyle("display","none");
  813. this.exportAction.addEvents({
  814. "click": function(e){
  815. MWF.xDesktop.requireApp("cms.Module", "ExcelForm", null, false);
  816. var categoryData = this.navi.currentObject.isCategory ? this.navi.currentObject.data : this.navi.currentObject.category.data ;
  817. this.export = new MWF.xApplication.cms.Module.ExportForm ( { app : this }, categoryData, {} );
  818. this.export.edit();
  819. }.bind(this),
  820. "mouseover" : function(e){
  821. this.exportAction.setStyles( this.css.exportAction_over )
  822. }.bind(this),
  823. "mouseout" : function(e){
  824. this.exportAction.setStyles( this.css.exportAction )
  825. }.bind(this)
  826. });
  827. },
  828. loadTitleIconNode : function(){
  829. this.defaultColumnIcon = "/x_component_cms_Index/$Main/"+this.options.style+"/icon/column.png";
  830. var iconAreaNode = this.iconAreaNode = new Element("div",{
  831. "styles" : this.css.titleIconAreaNode
  832. }).inject(this.leftTitleNode);
  833. var iconNode = this.iconNode = new Element("img",{
  834. "styles" : this.css.titleIconNode
  835. }).inject(iconAreaNode);
  836. if (this.options.columnData.appIcon){
  837. this.iconNode.set("src", "data:image/png;base64,"+this.options.columnData.appIcon+"");
  838. }else{
  839. this.iconNode.set("src", this.defaultColumnIcon)
  840. }
  841. iconNode.makeLnk({
  842. "par": this._getLnkPar()
  843. });
  844. },
  845. _getLnkPar: function(){
  846. var lnkIcon = this.defaultColumnIcon;
  847. if (this.options.columnData.appIcon) lnkIcon = "data:image/png;base64,"+this.options.columnData.appIcon;
  848. var appId = "cms.Module"+this.options.columnData.id;
  849. return {
  850. "icon": lnkIcon,
  851. "title": this.options.columnData.appName,
  852. "par": "cms.Module#{\"columnId\": \""+this.options.columnData.id+"\", \"appId\": \""+appId+"\"}"
  853. };
  854. },
  855. loadTitleContentNode: function(){
  856. this.titleContentNode = new Element("div.titleContentNode", {
  857. "styles": this.css.titleContentNode
  858. }).inject(this.leftTitleNode);
  859. this.titleTextNode = new Element("div.titleTextNode", {
  860. "styles": this.css.titleTextNode,
  861. "text": this.options.columnData.appName,
  862. "title": this.options.columnData.appName
  863. }).inject(this.titleContentNode);
  864. this.titleDescriptionNode = new Element("div.titleDescriptionNode", {
  865. "styles": this.css.titleDescriptionNode,
  866. "text": this.options.columnData.description ? this.options.columnData.description : this.lp.noDescription,
  867. "title": this.options.columnData.description ? this.options.columnData.description : this.lp.noDescription
  868. }).inject(this.titleContentNode);
  869. },
  870. loadSearchNode : function(){
  871. this.searchNode = new Element("div").inject( this.titleBar );
  872. },
  873. loadMenu: function(callback){
  874. this.naviNode = new Element("div.naviNode", {
  875. "styles": this.css.naviNode
  876. }).inject(this.naviContainerNode);
  877. //this.setScrollBar(this.naviNode,{"where": "before"});
  878. MWF.require("MWF.widget.ScrollBar", function(){
  879. new MWF.widget.ScrollBar(this.naviContainerNode, {
  880. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  881. });
  882. }.bind(this));
  883. this.addEvent("resize", function(){this.setNaviSize();}.bind(this));
  884. //MWF.require("MWF.widget.ScrollBar", function(){
  885. // new MWF.widget.ScrollBar(this.menuNode, {
  886. // "style":"xApp_CMSModule_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  887. // });
  888. //}.bind(this));
  889. if( this.options.categoryId == "all" ){
  890. this.options.categoryId = "whole";
  891. }
  892. if( this.status && this.status.categoryId ){
  893. this._loadMenu( this.status );
  894. }else if( this.options.categoryId && this.options.categoryId != "" ){
  895. if( this.options.viewId && this.options.viewId!="" ){
  896. this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : this.options.viewId } )
  897. }else{
  898. //this.getCategoryDefaultList(this.options.categoryId , function(viewId){
  899. // if( viewId ){
  900. // this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : viewId, "isCategory" : this.options.isCategory } );
  901. // }else{
  902. // this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : this.options.isCategory, "naviIndex" : (this.options.naviIndex || 0) } );
  903. // }
  904. //}.bind(this))
  905. this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : true, "naviIndex" : (this.options.naviIndex || 0) } ); //this.options.isCategory
  906. }
  907. }else if( this.options.categoryAlias && this.options.categoryAlias != "" ){
  908. this.restActions.getCategoryByAlias( this.options.categoryAlias, function( json ){
  909. this.options.categoryId = json.data.id;
  910. if( this.options.viewId && this.options.viewId!="" ){
  911. this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : this.options.viewId } )
  912. }else{
  913. this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : true, "naviIndex" : (this.options.naviIndex || 0) } ); //this.options.isCategory
  914. }
  915. }.bind(this))
  916. }else{
  917. this._loadMenu( { "categoryId" :"whole" } )
  918. }
  919. },
  920. _loadMenu : function( options ){
  921. this.navi = new MWF.xApplication.cms.Module.Navi(this, this.naviNode, this.options.columnData, options );
  922. this.setNaviSize();
  923. },
  924. clearContent: function(){
  925. //debugger;
  926. if (this.moduleContent){
  927. if (this.view) delete this.view;
  928. this.moduleContent.destroy();
  929. this.searchNode.empty();
  930. this.moduleContent = null;
  931. }
  932. },
  933. openView : function(el, categoryData, revealData, searchKey, navi){
  934. if( revealData && revealData.type == "queryview" ){
  935. this.loadQueryView(el, categoryData, revealData, searchKey, navi);
  936. }else{
  937. this.loadList(el, categoryData, revealData, searchKey, navi);
  938. }
  939. },
  940. loadQueryView : function(el, categoryData, revealData, searchKey, navi){
  941. MWF.xDesktop.requireApp("cms.Module", "ViewExplorer", function(){
  942. this.clearContent();
  943. this.moduleContent = new Element("div", {
  944. "styles": this.css.moduleContent
  945. }).inject(this.rightContentNode);
  946. this.view = new MWF.xApplication.cms.Module.ViewExplorer(
  947. this.moduleContent,
  948. this,
  949. this.options.columnData,
  950. categoryData,
  951. revealData,
  952. {"isAdmin": this.isAdmin, "searchKey" : searchKey },
  953. this.searchNode
  954. );
  955. this.view.selectEnable = this.selectEnable;
  956. this.view.load();
  957. }.bind(this))
  958. },
  959. loadList : function(el, categoryData, revealData, searchKey, navi){
  960. MWF.xDesktop.requireApp("cms.Module", "ListExplorer", function(){
  961. this.clearContent();
  962. this.moduleContent = new Element("div", {
  963. "styles": this.css.moduleContent
  964. }).inject(this.rightContentNode);
  965. if (!this.restActions) this.restActions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Module.Actions.RestActions();
  966. this.view = new MWF.xApplication.cms.Module.ListExplorer(
  967. this.moduleContent,
  968. this.restActions,
  969. this.options.columnData,
  970. categoryData,
  971. revealData,
  972. {"isAdmin": this.isAdmin, "searchKey" : searchKey },
  973. this.searchNode
  974. );
  975. this.view.app = this;
  976. this.view.selectEnable = this.selectEnable;
  977. this.view.load();
  978. }.bind(this));
  979. },
  980. recordStatus: function(){
  981. var currentObject = this.navi.currentObject;
  982. if( currentObject ){
  983. var categoryId = currentObject.getCategoryId();
  984. if (categoryId){
  985. return {
  986. "columnId" : this.options.columnData.id,
  987. "categoryId" :categoryId,
  988. "isCategory" : currentObject.isCategory,
  989. "viewId" : currentObject.data.id
  990. };
  991. }else{
  992. return { "columnId" : this.options.columnData.id , "categoryId" : "whole"}
  993. }
  994. }else{
  995. return { "columnId" : this.options.columnData.id , "categoryId" : "whole" }
  996. }
  997. },
  998. setNaviSize: function(){
  999. //var titlebarSize = this.titleBar ? this.titleBar.getSize() : {"x":0,"y":0};
  1000. var nodeSize = this.node.getSize();
  1001. //var pt = this.naviContainerNode.getStyle("padding-top").toFloat();
  1002. //var pb = this.naviContainerNode.getStyle("padding-bottom").toFloat();
  1003. //var height = nodeSize.y-pt-pb-titlebarSize.y;
  1004. this.naviContainerNode.setStyle("height", ""+nodeSize.y+"px");
  1005. }
  1006. });
  1007. MWF.xApplication.cms.Module.Navi = new Class({
  1008. Implements: [Options, Events],
  1009. options : {
  1010. "categoryId" :"" ,
  1011. "viewId" : "",
  1012. "isCategory" : false,
  1013. "navi" : -1
  1014. },
  1015. initialize: function(app, node, columnData, options){
  1016. this.setOptions(options);
  1017. this.app = app;
  1018. this.node = $(node);
  1019. this.columnData = columnData;
  1020. this.categoryList = [];
  1021. this.css = this.app.css;
  1022. this.load();
  1023. },
  1024. load: function(){
  1025. var self = this;
  1026. var showAll = (typeOf(this.columnData.showAllDocuments) === "boolean" ? this.columnData.showAllDocuments : true).toString();
  1027. if( showAll !== "false" ){
  1028. this.allView = new MWF.xApplication.cms.Module.NaviAllView( this, this.node, {} );
  1029. }
  1030. if( this.columnData.config.latest === false ){
  1031. this.draftView = new MWF.xApplication.cms.Module.NaviDraftView( this, this.node, {} );
  1032. }
  1033. new Element("div",{
  1034. "styles" : this.css.viewNaviBottom
  1035. }).inject(this.node);
  1036. this.app.restActions.listCategory( this.columnData.id, function( json ) {
  1037. json.data.each(function (d, idx) {
  1038. var isCurrent = false;
  1039. var category = new MWF.xApplication.cms.Module.NaviCategory(this, this.node,d, {} );
  1040. this.categoryList.push( category );
  1041. if( showAll == "false" && idx === 0 ){
  1042. category.setCurrent();
  1043. }
  1044. this.fireEvent("postLoad");
  1045. }.bind(this))
  1046. }.bind(this))
  1047. }
  1048. });
  1049. MWF.xApplication.cms.Module.NaviCategory = new Class({
  1050. Implements: [Options, Events],
  1051. options: {
  1052. "style": "default"
  1053. },
  1054. initialize: function ( navi, container, data, options) {
  1055. this.setOptions(options);
  1056. this.navi = navi;
  1057. this.app = navi.app;
  1058. this.container = $(container);
  1059. this.data = data;
  1060. this.css = this.app.css;
  1061. this.load();
  1062. },
  1063. load: function () {
  1064. var _self = this;
  1065. this.isCategory = true;
  1066. this.isCurrent = false;
  1067. this.isExpended = false;
  1068. this.hasSub = false;
  1069. this.naviViewList = [];
  1070. if( this.navi.options.categoryId == this.data.id && this.navi.options.isCategory ){
  1071. this.isCurrent = true;
  1072. }
  1073. this.reveal = this.getRevealData();
  1074. this.node = new Element("div.categoryNaviNode", {
  1075. "styles": this.css.categoryNaviNode
  1076. }).inject(this.container);
  1077. this.expendNode = new Element("div.expendNode").inject(this.node);
  1078. this.setExpendNodeStyle();
  1079. if( this.hasSub ){
  1080. this.expendNode.addEvent( "click" , function(ev){
  1081. this.triggerExpend();
  1082. ev.stopPropagation();
  1083. }.bind(this));
  1084. }
  1085. this.textNode = new Element("div.categoryNaviTextNode",{
  1086. "styles": this.css.categoryNaviTextNode,
  1087. "text": this.data.name //this.defaultRevealData.id == "defaultList" ? this.data.name : this.defaultRevealData.showName
  1088. }).inject(this.node);
  1089. this.node.addEvents({
  1090. "mouseover": function(){ if ( !_self.isCurrent )this.setStyles(_self.app.css.categoryNaviNode_over) },
  1091. "mouseout": function(){ if ( !_self.isCurrent )this.setStyles( _self.app.css.categoryNaviNode ) },
  1092. click : function(){ _self.setCurrent(this);}
  1093. });
  1094. this.listNode = new Element("div.viewNaviListNode",{
  1095. "styles" : this.css.viewNaviListNode
  1096. }).inject(this.container);
  1097. this.loadListContent();
  1098. if( this.isCurrent ){
  1099. this.setCurrent();
  1100. }
  1101. },
  1102. getRevealData: function(){
  1103. var j = this.data.extContent;
  1104. if( j ){
  1105. this.extContent = JSON.parse( j );
  1106. }
  1107. if( !this.extContent || !this.extContent.reveal || this.extContent.reveal.length == 0 ){ //兼容以前的设置
  1108. this.extContent = { reveal : [] };
  1109. this.app.restActions.listViewByCategory( this.data.id, function(json){
  1110. ( json.data || [] ).each( function(d){
  1111. var itemData = {
  1112. "type" : "list",
  1113. "name" : d.name,
  1114. "showName" : d.name,
  1115. "id" : d.id,
  1116. "alias" : d.alias,
  1117. "appId" : d.appId,
  1118. "formId" : d.formId,
  1119. "formName" : d.formName
  1120. };
  1121. this.extContent.reveal.push( itemData );
  1122. }.bind(this));
  1123. }.bind(this), null, false );
  1124. }
  1125. this.extContent.reveal.each( function( r ){
  1126. if(this.data.defaultViewName && r.id == this.data.defaultViewName ){
  1127. this.defaultRevealData = r;
  1128. }else{
  1129. this.isExpended = true;
  1130. this.hasSub = true;
  1131. }
  1132. }.bind(this));
  1133. if( !this.extContent || !this.extContent.reveal || this.extContent.reveal.length == 0 ){
  1134. this.extContent = { reveal : [{
  1135. id : "defaultList",
  1136. showName : "系统列表",
  1137. name : "系统列表"
  1138. }] };
  1139. }
  1140. this.revealData = this.extContent.reveal;
  1141. if( !this.defaultRevealData ){
  1142. this.defaultRevealData = {
  1143. id : "defaultList",
  1144. showName : "系统列表",
  1145. name : "系统列表"
  1146. }
  1147. }
  1148. },
  1149. setExpendNodeStyle : function(){
  1150. var style;
  1151. if( this.hasSub ){
  1152. if( this.isExpended ){
  1153. if( this.isCurrent ){
  1154. style = this.css.categoryExpendNode_selected;
  1155. }else{
  1156. style = this.css.categoryExpendNode;
  1157. }
  1158. }else{
  1159. if( this.isCurrent ){
  1160. style = this.css.categoryCollapseNode_selected;
  1161. }else{
  1162. style = this.css.categoryCollapseNode;
  1163. }
  1164. }
  1165. }else{
  1166. style = this.css.emptyExpendNode;
  1167. }
  1168. this.expendNode.setStyles( style );
  1169. },
  1170. triggerExpend : function(){
  1171. if( this.hasSub ){
  1172. if( this.isExpended ){
  1173. this.isExpended = false;
  1174. this.listNode.setStyle("display","none")
  1175. }else{
  1176. this.isExpended = true;
  1177. this.listNode.setStyle("display","")
  1178. }
  1179. this.setExpendNodeStyle();
  1180. }
  1181. },
  1182. setCurrent : function(){
  1183. if( this.navi.currentObject ){
  1184. this.navi.currentObject.cancelCurrent();
  1185. }
  1186. this.node.setStyles( this.css.categoryNaviNode_selected );
  1187. if( this.hasSub ){
  1188. if( this.isExpended ){
  1189. this.expendNode.setStyles( this.css.categoryExpendNode_selected );
  1190. }else{
  1191. this.expendNode.setStyles( this.css.categoryCollapseNode_selected );
  1192. }
  1193. }
  1194. this.isCurrent = true;
  1195. this.navi.currentObject = this;
  1196. var action = this.app.importAction;
  1197. if( action ){
  1198. action.setStyle("display", (this.data.importViewId && this.app.isAdmin) ? "" : "none");
  1199. }
  1200. action = this.app.exportAction;
  1201. if( action ){
  1202. action.setStyle("display", (this.data.importViewId && this.app.isAdmin) ? "" : "none");
  1203. }
  1204. this.loadView();
  1205. },
  1206. cancelCurrent : function(){
  1207. this.isCurrent = false;
  1208. this.node.setStyles( this.css.categoryNaviNode );
  1209. if( this.hasSub ){
  1210. if( this.isExpended ){
  1211. this.expendNode.setStyles( this.css.categoryExpendNode );
  1212. }else{
  1213. this.expendNode.setStyles( this.css.categoryCollapseNode );
  1214. }
  1215. }
  1216. },
  1217. loadView: function( searchkey ){
  1218. this.app.openView( this, this.data, this.viewData || this.defaultRevealData, searchkey || "", this );
  1219. },
  1220. loadListContent : function(){
  1221. this.revealData.each( function( d , i){
  1222. if( d.id != this.defaultRevealData.id ){
  1223. var naviView = new MWF.xApplication.cms.Module.NaviView(this.navi, this, this.listNode, d, {
  1224. "style": this.options.style,
  1225. "index" : i
  1226. });
  1227. this.naviViewList.push( naviView );
  1228. }
  1229. }.bind(this));
  1230. new Element("div", {
  1231. "styles": this.css.viewNaviSepartorNode
  1232. }).inject( this.listNode );
  1233. },
  1234. getCategoryId : function(){
  1235. return this.data.id;
  1236. }
  1237. });
  1238. MWF.xApplication.cms.Module.NaviView = new Class({
  1239. Implements: [Options, Events],
  1240. options: {
  1241. "style": "default",
  1242. "index" : 0
  1243. },
  1244. initialize: function ( navi, category, container, data, options) {
  1245. this.setOptions(options);
  1246. this.navi = navi;
  1247. this.category = category;
  1248. this.app = navi.app;
  1249. this.data = data;
  1250. this.container = $(container);
  1251. this.css = this.app.css;
  1252. this.load();
  1253. },
  1254. load: function(){
  1255. this.isDefault = this.data.id == "defaultList";
  1256. this.isCurrent = false;
  1257. this.isCategory = false;
  1258. if( this.navi.options.categoryId == this.category.data.id && !this.navi.options.isCategory ){
  1259. if( this.navi.options.viewId == "defaultList" && this.isDefault ){
  1260. this.isCurrent = true;
  1261. }else if( this.navi.options.viewId == this.data.id ){
  1262. this.isCurrent = true;
  1263. }else if( this.navi.options.naviIndex == this.options.index ){
  1264. this.isCurrent = true;
  1265. }
  1266. }
  1267. var _self = this;
  1268. this.node = new Element("div.viewNaviNode", {
  1269. "styles": this.css.viewNaviNode,
  1270. "text" : this.isDefault ? this.app.lp.defaultView : this.data.showName
  1271. }).inject(this.container);
  1272. this.node.addEvents({
  1273. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.viewNaviNode_over) },
  1274. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.viewNaviNode ) },
  1275. "click": function (el) {
  1276. _self.setCurrent();
  1277. }
  1278. });
  1279. if( this.isCurrent ){
  1280. this.setCurrent()
  1281. }
  1282. },
  1283. setCurrent : function(){
  1284. if( this.navi.currentObject ){
  1285. this.navi.currentObject.cancelCurrent();
  1286. }
  1287. this.node.setStyles( this.css.viewNaviNode_selected );
  1288. this.isCurrent = true;
  1289. this.navi.currentObject = this;
  1290. var action = this.app.importAction;
  1291. if( action ){
  1292. action.setStyle("display", (this.category.data.importViewId && this.app.isAdmin) ? "" : "none");
  1293. }
  1294. action = this.app.exportAction;
  1295. if( action ){
  1296. action.setStyle("display", (this.category.data.importViewId && this.app.isAdmin) ? "" : "none");
  1297. }
  1298. this.loadView();
  1299. },
  1300. cancelCurrent : function(){
  1301. this.isCurrent = false;
  1302. this.node.setStyles( this.css.viewNaviNode );
  1303. },
  1304. getCategoryId : function(){
  1305. return this.category.data.id;
  1306. },
  1307. loadView : function( searchKey ){
  1308. this.app.openView( this, this.category.data, this.data, searchKey || "", this );
  1309. }
  1310. });
  1311. MWF.xApplication.cms.Module.NaviAllView = new Class({
  1312. Implements: [Options, Events],
  1313. options: {
  1314. "style": "default"
  1315. },
  1316. initialize: function ( navi, container, options) {
  1317. this.setOptions(options);
  1318. this.navi = navi;
  1319. this.app = navi.app;
  1320. this.container = $(container);
  1321. this.css = this.app.css;
  1322. this.data = {
  1323. "isAll" : true,
  1324. "id" : "defaultList"
  1325. };
  1326. this.load();
  1327. },
  1328. load: function(){
  1329. var _self = this;
  1330. this.isDefault = true;
  1331. this.isAll = true;
  1332. this.isCurrent = false;
  1333. this.isCategory = false;
  1334. if( this.navi.options.categoryId == "whole" ){
  1335. this.isCurrent = true;
  1336. }
  1337. this.listNode = new Element("div.viewNaviListNode_all",{
  1338. "styles" : this.css.viewNaviListNode_all
  1339. }).inject(this.container);
  1340. this.node = new Element("div.viewNaviNode_all", {
  1341. "styles": this.css.viewNaviNode_all,
  1342. "text" : this.app.lp.allDocument
  1343. }).inject(this.listNode);
  1344. this.node.addEvents({
  1345. "mouseover": function(){ if ( !_self.isCurrent )this.setStyles(_self.css.viewNaviNode_all_over) },
  1346. "mouseout": function(){ if ( !_self.isCurrent )this.setStyles( _self.css.viewNaviNode_all ) },
  1347. "click": function (el) {
  1348. _self.setCurrent();
  1349. }
  1350. });
  1351. new Element("div", {
  1352. "styles": this.css.viewNaviSepartorNode
  1353. }).inject(this.listNode);
  1354. if( this.isCurrent ){
  1355. this.setCurrent()
  1356. }
  1357. },
  1358. setCurrent : function(){
  1359. if( this.navi.currentObject ){
  1360. this.navi.currentObject.cancelCurrent();
  1361. }
  1362. this.node.setStyles( this.css.viewNaviNode_all_selected );
  1363. this.isCurrent = true;
  1364. this.navi.currentObject = this;
  1365. var action = this.app.importAction;
  1366. if( action ){
  1367. action.setStyle("display","none");
  1368. }
  1369. var action = this.app.exportAction;
  1370. if( action ){
  1371. action.setStyle("display","none");
  1372. }
  1373. this.loadView();
  1374. },
  1375. cancelCurrent : function(){
  1376. this.isCurrent = false;
  1377. this.node.setStyles( this.css.viewNaviNode_all );
  1378. },
  1379. getCategoryId : function(){
  1380. return null;
  1381. },
  1382. loadView : function( searchKey ){
  1383. this.app.openView( this, null, this.data, searchKey || "", this );
  1384. }
  1385. });
  1386. MWF.xApplication.cms.Module.NaviDraftView = new Class({
  1387. Implements: [Options, Events],
  1388. options: {
  1389. "style": "default"
  1390. },
  1391. initialize: function ( navi, container, options) {
  1392. this.setOptions(options);
  1393. this.navi = navi;
  1394. this.app = navi.app;
  1395. this.container = $(container);
  1396. this.css = this.app.css;
  1397. this.data = {
  1398. "isDraft" : true,
  1399. "id" : "defaultList"
  1400. };
  1401. this.load();
  1402. },
  1403. load: function(){
  1404. var _self = this;
  1405. this.isDefault = true;
  1406. this.isAll = true;
  1407. this.isCurrent = false;
  1408. this.isCategory = false;
  1409. this.listNode = new Element("div.viewNaviListNode_all",{
  1410. "styles" : this.css.viewNaviListNode_all
  1411. }).inject(this.container);
  1412. this.node = new Element("div.viewNaviNode_all", {
  1413. "styles": this.css.viewNaviNode_all,
  1414. "text" : this.app.lp.draftStatus
  1415. }).inject(this.listNode);
  1416. this.node.addEvents({
  1417. "mouseover": function(){ if ( !_self.isCurrent )this.setStyles(_self.css.viewNaviNode_all_over) },
  1418. "mouseout": function(){ if ( !_self.isCurrent )this.setStyles( _self.css.viewNaviNode_all ) },
  1419. "click": function (el) {
  1420. _self.setCurrent();
  1421. }
  1422. });
  1423. new Element("div", {
  1424. "styles": this.css.viewNaviSepartorNode
  1425. }).inject(this.listNode);
  1426. if( this.isCurrent ){
  1427. this.setCurrent()
  1428. }
  1429. },
  1430. setCurrent : function(){
  1431. if( this.navi.currentObject ){
  1432. this.navi.currentObject.cancelCurrent();
  1433. }
  1434. this.node.setStyles( this.css.viewNaviNode_all_selected );
  1435. this.isCurrent = true;
  1436. this.navi.currentObject = this;
  1437. var action = this.app.importAction;
  1438. if( action ){
  1439. action.setStyle("display","none");
  1440. }
  1441. var action = this.app.exportAction;
  1442. if( action ){
  1443. action.setStyle("display","none");
  1444. }
  1445. this.loadView();
  1446. },
  1447. cancelCurrent : function(){
  1448. this.isCurrent = false;
  1449. this.node.setStyles( this.css.viewNaviNode_all );
  1450. },
  1451. getCategoryId : function(){
  1452. return null;
  1453. },
  1454. loadView : function( searchKey ){
  1455. this.app.openView( this, null, this.data, searchKey || "", this );
  1456. }
  1457. });