Main.js 50 KB

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