Main.js 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579
  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. if( newCategory ){
  734. doc.categoryId = newCategory.id;
  735. callback( doc );
  736. }else{
  737. this.restActions.getCategory( data.document.categoryId, function( json ){
  738. if( json.data.appId === columnData.id ){
  739. doc.categoryId = data.document.categoryId;
  740. callback( doc );
  741. }else{
  742. this.loadSelectCategoryDialog( "选择"+ data.document.title + "的分类",function(id){
  743. doc.categoryId = id;
  744. callback( doc );
  745. }.bind(this))
  746. }
  747. }.bind(this), function(){
  748. this.loadSelectCategoryDialog( "选择"+ data.document.title + "的分类",function(id){
  749. doc.categoryId = id;
  750. callback( doc );
  751. }.bind(this))
  752. }.bind(this))
  753. }
  754. },
  755. loadSelectColumnDialog : function( callback){
  756. MWF.xDesktop.requireApp("Selector", "package", null, false);
  757. var options = {
  758. "type": "CMSCategory",
  759. "count": 1,
  760. "onComplete": function(items){
  761. items.each(function(item){
  762. if( callback )callback( item.data );
  763. }.bind(this));
  764. }.bind(this)
  765. };
  766. var selector = new MWF.O2Selector(this.content, options);
  767. },
  768. loadSelectCategoryDialog : function(title, callback){
  769. if( !this.categoryList ){
  770. this.categoryList = [];
  771. this.restActions.listCategory( this.options.columnData.id, function( json ){
  772. json.data.each( function(d){
  773. this.categoryList.push( {
  774. name : d.categoryName,
  775. id : d.id
  776. })
  777. }.bind(this))
  778. }.bind(this), null, false)
  779. }
  780. MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false);
  781. var opt = {
  782. "count": 1,
  783. "title": "选择分类",
  784. "selectableItems" : this.categoryList,
  785. "values": [],
  786. "onComplete": function( array ){
  787. if( !array || array.length == 0 )return;
  788. var id = array[0].data.id;
  789. callback( id )
  790. }.bind(this)
  791. };
  792. var selector = new MWF.xApplication.Template.Selector.Custom(this.content, opt );
  793. selector.load();
  794. },
  795. loadImportActionNode : function(){
  796. this.importAction = new Element("div", {
  797. "styles": this.css.importAction,
  798. "text" : this.lp.import
  799. }).inject(this.titleActionBar);
  800. this.importAction.setStyle("display","none");
  801. this.importAction.addEvents({
  802. "click": function(e){
  803. MWF.xDesktop.requireApp("cms.Module", "ExcelForm", null, false);
  804. var categoryData = this.navi.currentObject.isCategory ? this.navi.currentObject.data : this.navi.currentObject.category.data ;
  805. this.import = new MWF.xApplication.cms.Module.ImportForm( { app : this }, categoryData, {} );
  806. this.import.edit();
  807. }.bind(this),
  808. "mouseover" : function(e){
  809. this.importAction.setStyles( this.css.importAction_over )
  810. }.bind(this),
  811. "mouseout" : function(e){
  812. this.importAction.setStyles( this.css.importAction )
  813. }.bind(this)
  814. });
  815. },
  816. loadExportActionNode : function(){
  817. this.exportAction = new Element("div", {
  818. "styles": this.css.exportAction,
  819. "text" : this.lp.export
  820. }).inject(this.titleActionBar);
  821. this.exportAction.setStyle("display","none");
  822. this.exportAction.addEvents({
  823. "click": function(e){
  824. MWF.xDesktop.requireApp("cms.Module", "ExcelForm", null, false);
  825. var categoryData = this.navi.currentObject.isCategory ? this.navi.currentObject.data : this.navi.currentObject.category.data ;
  826. this.export = new MWF.xApplication.cms.Module.ExportForm ( { app : this }, categoryData, {} );
  827. this.export.edit();
  828. }.bind(this),
  829. "mouseover" : function(e){
  830. this.exportAction.setStyles( this.css.exportAction_over )
  831. }.bind(this),
  832. "mouseout" : function(e){
  833. this.exportAction.setStyles( this.css.exportAction )
  834. }.bind(this)
  835. });
  836. },
  837. loadTitleIconNode : function(){
  838. this.defaultColumnIcon = "/x_component_cms_Index/$Main/"+this.options.style+"/icon/column.png";
  839. var iconAreaNode = this.iconAreaNode = new Element("div",{
  840. "styles" : this.css.titleIconAreaNode
  841. }).inject(this.leftTitleNode);
  842. var iconNode = this.iconNode = new Element("img",{
  843. "styles" : this.css.titleIconNode
  844. }).inject(iconAreaNode);
  845. if (this.options.columnData.appIcon){
  846. this.iconNode.set("src", "data:image/png;base64,"+this.options.columnData.appIcon+"");
  847. }else{
  848. this.iconNode.set("src", this.defaultColumnIcon)
  849. }
  850. iconNode.makeLnk({
  851. "par": this._getLnkPar()
  852. });
  853. },
  854. _getLnkPar: function(){
  855. var lnkIcon = this.defaultColumnIcon;
  856. if (this.options.columnData.appIcon) lnkIcon = "data:image/png;base64,"+this.options.columnData.appIcon;
  857. var appId = "cms.Module"+this.options.columnData.id;
  858. return {
  859. "icon": lnkIcon,
  860. "title": this.options.columnData.appName,
  861. "par": "cms.Module#{\"columnId\": \""+this.options.columnData.id+"\", \"appId\": \""+appId+"\"}"
  862. };
  863. },
  864. loadTitleContentNode: function(){
  865. this.titleContentNode = new Element("div.titleContentNode", {
  866. "styles": this.css.titleContentNode
  867. }).inject(this.leftTitleNode);
  868. this.titleTextNode = new Element("div.titleTextNode", {
  869. "styles": this.css.titleTextNode,
  870. "text": this.options.columnData.appName,
  871. "title": this.options.columnData.appName
  872. }).inject(this.titleContentNode);
  873. this.titleDescriptionNode = new Element("div.titleDescriptionNode", {
  874. "styles": this.css.titleDescriptionNode,
  875. "text": this.options.columnData.description ? this.options.columnData.description : this.lp.noDescription,
  876. "title": this.options.columnData.description ? this.options.columnData.description : this.lp.noDescription
  877. }).inject(this.titleContentNode);
  878. },
  879. loadSearchNode : function(){
  880. this.searchNode = new Element("div").inject( this.titleBar );
  881. },
  882. loadMenu: function(callback){
  883. this.naviNode = new Element("div.naviNode", {
  884. "styles": this.css.naviNode
  885. }).inject(this.naviContainerNode);
  886. //this.setScrollBar(this.naviNode,{"where": "before"});
  887. MWF.require("MWF.widget.ScrollBar", function(){
  888. new MWF.widget.ScrollBar(this.naviContainerNode, {
  889. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  890. });
  891. }.bind(this));
  892. this.addEvent("resize", function(){this.setNaviSize();}.bind(this));
  893. //MWF.require("MWF.widget.ScrollBar", function(){
  894. // new MWF.widget.ScrollBar(this.menuNode, {
  895. // "style":"xApp_CMSModule_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  896. // });
  897. //}.bind(this));
  898. if( this.options.categoryId == "all" ){
  899. this.options.categoryId = "whole";
  900. }
  901. if( this.status && this.status.categoryId ){
  902. this._loadMenu( this.status );
  903. }else if( this.options.categoryId && this.options.categoryId != "" ){
  904. if( this.options.viewId && this.options.viewId!="" ){
  905. this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : this.options.viewId } )
  906. }else{
  907. //this.getCategoryDefaultList(this.options.categoryId , function(viewId){
  908. // if( viewId ){
  909. // this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : viewId, "isCategory" : this.options.isCategory } );
  910. // }else{
  911. // this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : this.options.isCategory, "naviIndex" : (this.options.naviIndex || 0) } );
  912. // }
  913. //}.bind(this))
  914. this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : true, "naviIndex" : (this.options.naviIndex || 0) } ); //this.options.isCategory
  915. }
  916. }else if( this.options.categoryAlias && this.options.categoryAlias != "" ){
  917. this.restActions.getCategoryByAlias( this.options.categoryAlias, function( json ){
  918. this.options.categoryId = json.data.id;
  919. if( this.options.viewId && this.options.viewId!="" ){
  920. this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : this.options.viewId } )
  921. }else{
  922. this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : true, "naviIndex" : (this.options.naviIndex || 0) } ); //this.options.isCategory
  923. }
  924. }.bind(this))
  925. }else{
  926. this._loadMenu( { "categoryId" :"whole" } )
  927. }
  928. },
  929. _loadMenu : function( options ){
  930. this.navi = new MWF.xApplication.cms.Module.Navi(this, this.naviNode, this.options.columnData, options );
  931. this.setNaviSize();
  932. },
  933. clearContent: function(){
  934. //debugger;
  935. if (this.moduleContent){
  936. if (this.view) delete this.view;
  937. this.moduleContent.destroy();
  938. this.searchNode.empty();
  939. this.moduleContent = null;
  940. }
  941. },
  942. openView : function(el, categoryData, revealData, searchKey, navi){
  943. if( revealData && revealData.type == "queryview" ){
  944. this.loadQueryView(el, categoryData, revealData, searchKey, navi);
  945. }else{
  946. this.loadList(el, categoryData, revealData, searchKey, navi);
  947. }
  948. },
  949. loadQueryView : function(el, categoryData, revealData, searchKey, navi){
  950. MWF.xDesktop.requireApp("cms.Module", "ViewExplorer", function(){
  951. this.clearContent();
  952. this.moduleContent = new Element("div", {
  953. "styles": this.css.moduleContent
  954. }).inject(this.rightContentNode);
  955. this.view = new MWF.xApplication.cms.Module.ViewExplorer(
  956. this.moduleContent,
  957. this,
  958. this.options.columnData,
  959. categoryData,
  960. revealData,
  961. {"isAdmin": this.isAdmin, "searchKey" : searchKey },
  962. this.searchNode
  963. );
  964. this.view.selectEnable = this.selectEnable;
  965. this.view.load();
  966. }.bind(this))
  967. },
  968. loadList : function(el, categoryData, revealData, searchKey, navi){
  969. MWF.xDesktop.requireApp("cms.Module", "ListExplorer", function(){
  970. this.clearContent();
  971. this.moduleContent = new Element("div", {
  972. "styles": this.css.moduleContent
  973. }).inject(this.rightContentNode);
  974. if (!this.restActions) this.restActions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Module.Actions.RestActions();
  975. this.view = new MWF.xApplication.cms.Module.ListExplorer(
  976. this.moduleContent,
  977. this.restActions,
  978. this.options.columnData,
  979. categoryData,
  980. revealData,
  981. {"isAdmin": this.isAdmin, "searchKey" : searchKey },
  982. this.searchNode
  983. );
  984. this.view.app = this;
  985. this.view.selectEnable = this.selectEnable;
  986. this.view.load();
  987. }.bind(this));
  988. },
  989. recordStatus: function(){
  990. var currentObject = this.navi.currentObject;
  991. if( currentObject ){
  992. var categoryId = currentObject.getCategoryId();
  993. if (categoryId){
  994. return {
  995. "columnId" : this.options.columnData.id,
  996. "categoryId" :categoryId,
  997. "isCategory" : currentObject.isCategory,
  998. "viewId" : currentObject.data.id
  999. };
  1000. }else{
  1001. return { "columnId" : this.options.columnData.id , "categoryId" : "whole"}
  1002. }
  1003. }else{
  1004. return { "columnId" : this.options.columnData.id , "categoryId" : "whole" }
  1005. }
  1006. },
  1007. setNaviSize: function(){
  1008. //var titlebarSize = this.titleBar ? this.titleBar.getSize() : {"x":0,"y":0};
  1009. var nodeSize = this.node.getSize();
  1010. //var pt = this.naviContainerNode.getStyle("padding-top").toFloat();
  1011. //var pb = this.naviContainerNode.getStyle("padding-bottom").toFloat();
  1012. //var height = nodeSize.y-pt-pb-titlebarSize.y;
  1013. this.naviContainerNode.setStyle("height", ""+nodeSize.y+"px");
  1014. }
  1015. });
  1016. MWF.xApplication.cms.Module.Navi = new Class({
  1017. Implements: [Options, Events],
  1018. options : {
  1019. "categoryId" :"" ,
  1020. "viewId" : "",
  1021. "isCategory" : false,
  1022. "navi" : -1
  1023. },
  1024. initialize: function(app, node, columnData, options){
  1025. this.setOptions(options);
  1026. this.app = app;
  1027. this.node = $(node);
  1028. this.columnData = columnData;
  1029. this.categoryList = [];
  1030. this.css = this.app.css;
  1031. this.load();
  1032. },
  1033. load: function(){
  1034. var self = this;
  1035. var showAll = (typeOf(this.columnData.showAllDocuments) === "boolean" ? this.columnData.showAllDocuments : true).toString();
  1036. if( showAll !== "false" ){
  1037. this.allView = new MWF.xApplication.cms.Module.NaviAllView( this, this.node, {} );
  1038. }
  1039. if( this.columnData.config.latest === false ){
  1040. this.draftView = new MWF.xApplication.cms.Module.NaviDraftView( this, this.node, {} );
  1041. }
  1042. new Element("div",{
  1043. "styles" : this.css.viewNaviBottom
  1044. }).inject(this.node);
  1045. this.app.restActions.listCategory( this.columnData.id, function( json ) {
  1046. json.data.each(function (d, idx) {
  1047. var isCurrent = false;
  1048. var category = new MWF.xApplication.cms.Module.NaviCategory(this, this.node,d, {} );
  1049. this.categoryList.push( category );
  1050. if( showAll == "false" && idx === 0 ){
  1051. category.setCurrent();
  1052. }
  1053. this.fireEvent("postLoad");
  1054. }.bind(this))
  1055. }.bind(this))
  1056. }
  1057. });
  1058. MWF.xApplication.cms.Module.NaviCategory = new Class({
  1059. Implements: [Options, Events],
  1060. options: {
  1061. "style": "default"
  1062. },
  1063. initialize: function ( navi, container, data, options) {
  1064. this.setOptions(options);
  1065. this.navi = navi;
  1066. this.app = navi.app;
  1067. this.container = $(container);
  1068. this.data = data;
  1069. this.css = this.app.css;
  1070. this.load();
  1071. },
  1072. load: function () {
  1073. var _self = this;
  1074. this.isCategory = true;
  1075. this.isCurrent = false;
  1076. this.isExpended = false;
  1077. this.hasSub = false;
  1078. this.naviViewList = [];
  1079. if( this.navi.options.categoryId == this.data.id && this.navi.options.isCategory ){
  1080. this.isCurrent = true;
  1081. }
  1082. this.reveal = this.getRevealData();
  1083. this.node = new Element("div.categoryNaviNode", {
  1084. "styles": this.css.categoryNaviNode
  1085. }).inject(this.container);
  1086. this.expendNode = new Element("div.expendNode").inject(this.node);
  1087. this.setExpendNodeStyle();
  1088. if( this.hasSub ){
  1089. this.expendNode.addEvent( "click" , function(ev){
  1090. this.triggerExpend();
  1091. ev.stopPropagation();
  1092. }.bind(this));
  1093. }
  1094. this.textNode = new Element("div.categoryNaviTextNode",{
  1095. "styles": this.css.categoryNaviTextNode,
  1096. "text": this.data.name //this.defaultRevealData.id == "defaultList" ? this.data.name : this.defaultRevealData.showName
  1097. }).inject(this.node);
  1098. this.node.addEvents({
  1099. "mouseover": function(){ if ( !_self.isCurrent )this.setStyles(_self.app.css.categoryNaviNode_over) },
  1100. "mouseout": function(){ if ( !_self.isCurrent )this.setStyles( _self.app.css.categoryNaviNode ) },
  1101. click : function(){ _self.setCurrent(this);}
  1102. });
  1103. this.listNode = new Element("div.viewNaviListNode",{
  1104. "styles" : this.css.viewNaviListNode
  1105. }).inject(this.container);
  1106. this.loadListContent();
  1107. if( this.isCurrent ){
  1108. this.setCurrent();
  1109. }
  1110. },
  1111. getRevealData: function(){
  1112. debugger;
  1113. var j = this.data.extContent;
  1114. if( j ){
  1115. this.extContent = JSON.parse( j );
  1116. }
  1117. if( !this.extContent || !this.extContent.reveal || this.extContent.reveal.length == 0 ){ //兼容以前的设置
  1118. this.extContent = { reveal : [] };
  1119. this.app.restActions.listViewByCategory( this.data.id, function(json){
  1120. ( json.data || [] ).each( function(d){
  1121. var itemData = {
  1122. "type" : "list",
  1123. "name" : d.name,
  1124. "showName" : d.name,
  1125. "id" : d.id,
  1126. "alias" : d.alias,
  1127. "appId" : d.appId,
  1128. "formId" : d.formId,
  1129. "formName" : d.formName
  1130. };
  1131. this.extContent.reveal.push( itemData );
  1132. }.bind(this));
  1133. }.bind(this), null, false );
  1134. }
  1135. this.extContent.reveal.each( function( r, i ){
  1136. if(this.data.defaultViewName && r.id == this.data.defaultViewName ){
  1137. this.defaultRevealData = r;
  1138. }else if( i>0 ){
  1139. this.isExpended = true;
  1140. this.hasSub = true;
  1141. }
  1142. }.bind(this));
  1143. if( !this.extContent || !this.extContent.reveal || this.extContent.reveal.length == 0 ){
  1144. this.extContent = { reveal : [{
  1145. id : "defaultList",
  1146. showName : "系统列表",
  1147. name : "系统列表"
  1148. }] };
  1149. }
  1150. this.revealData = this.extContent.reveal;
  1151. if( !this.defaultRevealData ){
  1152. this.defaultRevealData = {
  1153. id : "defaultList",
  1154. showName : "系统列表",
  1155. name : "系统列表"
  1156. }
  1157. }
  1158. },
  1159. setExpendNodeStyle : function(){
  1160. var style;
  1161. if( this.hasSub ){
  1162. if( this.isExpended ){
  1163. if( this.isCurrent ){
  1164. style = this.css.categoryExpendNode_selected;
  1165. }else{
  1166. style = this.css.categoryExpendNode;
  1167. }
  1168. }else{
  1169. if( this.isCurrent ){
  1170. style = this.css.categoryCollapseNode_selected;
  1171. }else{
  1172. style = this.css.categoryCollapseNode;
  1173. }
  1174. }
  1175. }else{
  1176. style = this.css.emptyExpendNode;
  1177. }
  1178. this.expendNode.setStyles( style );
  1179. },
  1180. triggerExpend : function(){
  1181. if( this.hasSub ){
  1182. if( this.isExpended ){
  1183. this.isExpended = false;
  1184. this.listNode.setStyle("display","none")
  1185. }else{
  1186. this.isExpended = true;
  1187. this.listNode.setStyle("display","")
  1188. }
  1189. this.setExpendNodeStyle();
  1190. }
  1191. },
  1192. setCurrent : function(){
  1193. if( this.navi.currentObject ){
  1194. this.navi.currentObject.cancelCurrent();
  1195. }
  1196. this.node.setStyles( this.css.categoryNaviNode_selected );
  1197. if( this.hasSub ){
  1198. if( this.isExpended ){
  1199. this.expendNode.setStyles( this.css.categoryExpendNode_selected );
  1200. }else{
  1201. this.expendNode.setStyles( this.css.categoryCollapseNode_selected );
  1202. }
  1203. }
  1204. this.isCurrent = true;
  1205. this.navi.currentObject = this;
  1206. var action = this.app.importAction;
  1207. if( action ){
  1208. action.setStyle("display", (this.data.importViewId && this.app.isAdmin) ? "" : "none");
  1209. }
  1210. action = this.app.exportAction;
  1211. if( action ){
  1212. action.setStyle("display", (this.data.importViewId && this.app.isAdmin) ? "" : "none");
  1213. }
  1214. this.loadView();
  1215. },
  1216. cancelCurrent : function(){
  1217. this.isCurrent = false;
  1218. this.node.setStyles( this.css.categoryNaviNode );
  1219. if( this.hasSub ){
  1220. if( this.isExpended ){
  1221. this.expendNode.setStyles( this.css.categoryExpendNode );
  1222. }else{
  1223. this.expendNode.setStyles( this.css.categoryCollapseNode );
  1224. }
  1225. }
  1226. },
  1227. loadView: function( searchkey ){
  1228. this.app.openView( this, this.data, this.viewData || this.defaultRevealData, searchkey || "", this );
  1229. },
  1230. loadListContent : function(){
  1231. this.revealData.each( function( d , i){
  1232. if( d.id != this.defaultRevealData.id ){
  1233. var naviView = new MWF.xApplication.cms.Module.NaviView(this.navi, this, this.listNode, d, {
  1234. "style": this.options.style,
  1235. "index" : i
  1236. });
  1237. this.naviViewList.push( naviView );
  1238. }
  1239. }.bind(this));
  1240. new Element("div", {
  1241. "styles": this.css.viewNaviSepartorNode
  1242. }).inject( this.listNode );
  1243. },
  1244. getCategoryId : function(){
  1245. return this.data.id;
  1246. }
  1247. });
  1248. MWF.xApplication.cms.Module.NaviView = new Class({
  1249. Implements: [Options, Events],
  1250. options: {
  1251. "style": "default",
  1252. "index" : 0
  1253. },
  1254. initialize: function ( navi, category, container, data, options) {
  1255. this.setOptions(options);
  1256. this.navi = navi;
  1257. this.category = category;
  1258. this.app = navi.app;
  1259. this.data = data;
  1260. this.container = $(container);
  1261. this.css = this.app.css;
  1262. this.load();
  1263. },
  1264. load: function(){
  1265. this.isDefault = this.data.id == "defaultList";
  1266. this.isCurrent = false;
  1267. this.isCategory = false;
  1268. if( this.navi.options.categoryId == this.category.data.id && !this.navi.options.isCategory ){
  1269. if( this.navi.options.viewId == "defaultList" && this.isDefault ){
  1270. this.isCurrent = true;
  1271. }else if( this.navi.options.viewId == this.data.id ){
  1272. this.isCurrent = true;
  1273. }else if( this.navi.options.naviIndex == this.options.index ){
  1274. this.isCurrent = true;
  1275. }
  1276. }
  1277. var _self = this;
  1278. this.node = new Element("div.viewNaviNode", {
  1279. "styles": this.css.viewNaviNode,
  1280. "text" : (this.isDefault && !this.data.showName) ? this.app.lp.defaultView : this.data.showName
  1281. }).inject(this.container);
  1282. this.node.addEvents({
  1283. "mouseover": function(){ if (!_self.isCurrent)this.setStyles(_self.css.viewNaviNode_over) },
  1284. "mouseout": function(){ if (!_self.isCurrent)this.setStyles( _self.css.viewNaviNode ) },
  1285. "click": function (el) {
  1286. _self.setCurrent();
  1287. }
  1288. });
  1289. if( this.isCurrent ){
  1290. this.setCurrent()
  1291. }
  1292. },
  1293. setCurrent : function(){
  1294. if( this.navi.currentObject ){
  1295. this.navi.currentObject.cancelCurrent();
  1296. }
  1297. this.node.setStyles( this.css.viewNaviNode_selected );
  1298. this.isCurrent = true;
  1299. this.navi.currentObject = this;
  1300. var action = this.app.importAction;
  1301. if( action ){
  1302. action.setStyle("display", (this.category.data.importViewId && this.app.isAdmin) ? "" : "none");
  1303. }
  1304. action = this.app.exportAction;
  1305. if( action ){
  1306. action.setStyle("display", (this.category.data.importViewId && this.app.isAdmin) ? "" : "none");
  1307. }
  1308. this.loadView();
  1309. },
  1310. cancelCurrent : function(){
  1311. this.isCurrent = false;
  1312. this.node.setStyles( this.css.viewNaviNode );
  1313. },
  1314. getCategoryId : function(){
  1315. return this.category.data.id;
  1316. },
  1317. loadView : function( searchKey ){
  1318. this.app.openView( this, this.category.data, this.data, searchKey || "", this );
  1319. }
  1320. });
  1321. MWF.xApplication.cms.Module.NaviAllView = new Class({
  1322. Implements: [Options, Events],
  1323. options: {
  1324. "style": "default"
  1325. },
  1326. initialize: function ( navi, container, options) {
  1327. this.setOptions(options);
  1328. this.navi = navi;
  1329. this.app = navi.app;
  1330. this.container = $(container);
  1331. this.css = this.app.css;
  1332. this.data = {
  1333. "isAll" : true,
  1334. "id" : "defaultList"
  1335. };
  1336. this.load();
  1337. },
  1338. load: function(){
  1339. var _self = this;
  1340. this.isDefault = true;
  1341. this.isAll = true;
  1342. this.isCurrent = false;
  1343. this.isCategory = false;
  1344. if( this.navi.options.categoryId == "whole" ){
  1345. this.isCurrent = true;
  1346. }
  1347. this.listNode = new Element("div.viewNaviListNode_all",{
  1348. "styles" : this.css.viewNaviListNode_all
  1349. }).inject(this.container);
  1350. this.node = new Element("div.viewNaviNode_all", {
  1351. "styles": this.css.viewNaviNode_all,
  1352. "text" : this.app.lp.allDocument
  1353. }).inject(this.listNode);
  1354. this.node.addEvents({
  1355. "mouseover": function(){ if ( !_self.isCurrent )this.setStyles(_self.css.viewNaviNode_all_over) },
  1356. "mouseout": function(){ if ( !_self.isCurrent )this.setStyles( _self.css.viewNaviNode_all ) },
  1357. "click": function (el) {
  1358. _self.setCurrent();
  1359. }
  1360. });
  1361. new Element("div", {
  1362. "styles": this.css.viewNaviSepartorNode
  1363. }).inject(this.listNode);
  1364. if( this.isCurrent ){
  1365. this.setCurrent()
  1366. }
  1367. },
  1368. setCurrent : function(){
  1369. if( this.navi.currentObject ){
  1370. this.navi.currentObject.cancelCurrent();
  1371. }
  1372. this.node.setStyles( this.css.viewNaviNode_all_selected );
  1373. this.isCurrent = true;
  1374. this.navi.currentObject = this;
  1375. var action = this.app.importAction;
  1376. if( action ){
  1377. action.setStyle("display","none");
  1378. }
  1379. var action = this.app.exportAction;
  1380. if( action ){
  1381. action.setStyle("display","none");
  1382. }
  1383. this.loadView();
  1384. },
  1385. cancelCurrent : function(){
  1386. this.isCurrent = false;
  1387. this.node.setStyles( this.css.viewNaviNode_all );
  1388. },
  1389. getCategoryId : function(){
  1390. return null;
  1391. },
  1392. loadView : function( searchKey ){
  1393. this.app.openView( this, null, this.data, searchKey || "", this );
  1394. }
  1395. });
  1396. MWF.xApplication.cms.Module.NaviDraftView = new Class({
  1397. Implements: [Options, Events],
  1398. options: {
  1399. "style": "default"
  1400. },
  1401. initialize: function ( navi, container, options) {
  1402. this.setOptions(options);
  1403. this.navi = navi;
  1404. this.app = navi.app;
  1405. this.container = $(container);
  1406. this.css = this.app.css;
  1407. this.data = {
  1408. "isDraft" : true,
  1409. "id" : "defaultList"
  1410. };
  1411. this.load();
  1412. },
  1413. load: function(){
  1414. var _self = this;
  1415. this.isDefault = true;
  1416. this.isAll = true;
  1417. this.isCurrent = false;
  1418. this.isCategory = false;
  1419. this.listNode = new Element("div.viewNaviListNode_all",{
  1420. "styles" : this.css.viewNaviListNode_all
  1421. }).inject(this.container);
  1422. this.node = new Element("div.viewNaviNode_all", {
  1423. "styles": this.css.viewNaviNode_all,
  1424. "text" : this.app.lp.draftStatus
  1425. }).inject(this.listNode);
  1426. this.node.addEvents({
  1427. "mouseover": function(){ if ( !_self.isCurrent )this.setStyles(_self.css.viewNaviNode_all_over) },
  1428. "mouseout": function(){ if ( !_self.isCurrent )this.setStyles( _self.css.viewNaviNode_all ) },
  1429. "click": function (el) {
  1430. _self.setCurrent();
  1431. }
  1432. });
  1433. new Element("div", {
  1434. "styles": this.css.viewNaviSepartorNode
  1435. }).inject(this.listNode);
  1436. if( this.isCurrent ){
  1437. this.setCurrent()
  1438. }
  1439. },
  1440. setCurrent : function(){
  1441. if( this.navi.currentObject ){
  1442. this.navi.currentObject.cancelCurrent();
  1443. }
  1444. this.node.setStyles( this.css.viewNaviNode_all_selected );
  1445. this.isCurrent = true;
  1446. this.navi.currentObject = this;
  1447. var action = this.app.importAction;
  1448. if( action ){
  1449. action.setStyle("display","none");
  1450. }
  1451. var action = this.app.exportAction;
  1452. if( action ){
  1453. action.setStyle("display","none");
  1454. }
  1455. this.loadView();
  1456. },
  1457. cancelCurrent : function(){
  1458. this.isCurrent = false;
  1459. this.node.setStyles( this.css.viewNaviNode_all );
  1460. },
  1461. getCategoryId : function(){
  1462. return null;
  1463. },
  1464. loadView : function( searchKey ){
  1465. this.app.openView( this, null, this.data, searchKey || "", this );
  1466. }
  1467. });