Main.js 42 KB

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