Main.js 50 KB

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