Main.js 41 KB

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