Main.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113
  1. MWF.xDesktop.requireApp("cms.ColumnManager", "package", null, false);
  2. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", null, false);
  3. MWF.xDesktop.requireApp("Organization", "Selector.package", null, false);
  4. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  5. MWF.require("MWF.widget.Identity", null,false);
  6. MWF.xApplication.cms.ColumnManager.Main = new Class({
  7. Extends: MWF.xApplication.Common.Main,
  8. Implements: [Options, Events],
  9. options: {
  10. "column": null,
  11. "application" : null,
  12. "style": "default",
  13. "name": "cms.ColumnManager",
  14. "icon": "icon.png",
  15. "width": "1100",
  16. "height": "720",
  17. "title": MWF.xApplication.cms.ColumnManager.LP.title
  18. },
  19. onQueryLoad: function(){
  20. if(this.options.column)this.options.column.icon = this.options.column.appIcon;
  21. if(!this.options.application) this.options.application = this.options.column;
  22. this.lp = MWF.xApplication.cms.ColumnManager.LP;
  23. this.currentContentNode = null;
  24. },
  25. loadApplication: function(callback){
  26. this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  27. //if (this.status){
  28. // if (!this.options.application){
  29. // if (this.status.application){
  30. // this.restActions.getApplication(this.status.application, function(json){
  31. // if (json.data){
  32. // this.options.application = json.data;
  33. // alert("sds"+this.options.application);
  34. // }else{
  35. // this.close();
  36. // }
  37. // }.bind(this), function(){this.close();}.bind(this), false)
  38. // }else{
  39. // this.close();
  40. // }
  41. // }
  42. //}
  43. this.getColumn(function(){
  44. this.setTitle( this.options.column.appName +this.lp.setting );
  45. this.loadController(function(){
  46. if( !this.isAdmin ){
  47. this.notice( MWF.CMSCM.LP.noAdministratorAccess , "error");
  48. this.close();
  49. }else{
  50. this.createNode();
  51. this.loadApplicationContent();
  52. if (callback) callback();
  53. }
  54. }.bind(this))
  55. }.bind(this), function(){
  56. this.close();
  57. }.bind(this));
  58. },
  59. loadController: function(callback){
  60. this.controllers = [];
  61. this.restActions.listColumnController(this.options.column.id, function( json ){
  62. json.data = json.data || [];
  63. json.data.each(function(item){
  64. this.controllers.push(item.adminUid)
  65. }.bind(this));
  66. this.isAdmin = MWF.AC.isAdministrator() || this.controllers.contains(layout.desktop.session.user.name);
  67. if(callback)callback(this.isAdmin);
  68. }.bind(this));
  69. },
  70. getColumn: function(success, failure){
  71. if (!this.options.column){
  72. if (this.status) {
  73. if (this.status.column){
  74. this.restActions.getColumn({"id":this.status.column}, function(json){
  75. if (json.data){
  76. this.options.column = json.data;
  77. this.options.application = json.data;
  78. if (success) success();
  79. }else{
  80. if (failure) failure();
  81. }
  82. }.bind(this), function(){if (failure) failure();}.bind(this), false)
  83. }else{
  84. if (failure) failure();
  85. }
  86. }else{
  87. if (failure) failure();
  88. }
  89. }else{
  90. if (success) success();
  91. }
  92. },
  93. loadApplicationContent: function(){
  94. this.loadStartMenu();
  95. this.loadApplicationLayout();
  96. },
  97. createNode: function(){
  98. this.content.setStyle("overflow", "hidden");
  99. this.node = new Element("div", {
  100. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  101. }).inject(this.content);
  102. },
  103. loadApplicationLayout: function(){
  104. // this.topMenuNode = new Element("div").inject(this.node);
  105. // MWF.require("MWF.widget.Toolbar", function(){
  106. // this.toobar = new MWF.widget.Toolbar(this.topMenuNode);
  107. // this.toobar.load();
  108. // alert("ok")
  109. // }.bind(this));
  110. },
  111. loadStartMenu: function(callback){
  112. this.leftContentNode = new Element("div", {
  113. "styles": this.css.leftContentNode
  114. }).inject(this.node);
  115. this.leftTitleNode = new Element("div", {
  116. "styles": this.css.leftTitleNode
  117. }).inject(this.leftContentNode);
  118. this.leftTitleIconNode = new Element("div", {
  119. "styles": this.css.leftTitleIconNode
  120. }).inject(this.leftTitleNode);
  121. if (this.options.column){
  122. var icon = this.options.column.icon || this.options.column.appIcon;
  123. if (icon){
  124. this.leftTitleIconNode.setStyle("background-image", "url(data:image/png;base64,"+icon+")");
  125. }else{
  126. this.leftTitleIconNode.setStyle("background-image", "url("+"/x_component_cms_Column/$Main/default/icon/column.png)");
  127. }
  128. }
  129. this.leftTitleTextNode = new Element("div", {
  130. "styles": this.css.leftTitleTextNode,
  131. "text" : this.options.column.appName + this.lp.setting
  132. }).inject(this.leftTitleNode);
  133. this.startMenuNode = new Element("div", {
  134. "styles": this.css.normalStartMenuNode
  135. }).inject(this.leftContentNode);
  136. this.menu = new MWF.xApplication.cms.ColumnManager.Menu(this, this.startMenuNode, {
  137. "onPostLoad": function(){
  138. var defaultId = "categoryConfig";
  139. if (this.status){
  140. if (this.status.navi!=null && this.menu.itemObject[this.status.navi]){
  141. this.menu.doAction(this.menu.itemObject[this.status.navi]);
  142. }else{
  143. this.menu.doAction(this.menu.itemObject[defaultId]);
  144. }
  145. }else{
  146. this.menu.doAction(this.menu.startNavis[0]);
  147. }
  148. }.bind(this)
  149. });
  150. //this.addEvent("resize", function(){
  151. // if (this.menu) this.menu.onResize();
  152. //}.bind(this));
  153. },
  154. clearContent: function(){
  155. if (this.categoryConfiguratorContent){
  156. this.categoryConfiguratorContent.setStyle("display","none");
  157. //if (this.categoryConfigurator) delete this.categoryConfigurator;
  158. //this.categoryConfiguratorContent.destroy();
  159. //this.categoryConfiguratorContent = null;
  160. }
  161. if (this.formConfiguratorContent){
  162. if (this.formConfigurator) delete this.formConfigurator;
  163. this.formConfiguratorContent.destroy();
  164. this.formConfiguratorContent = null;
  165. }
  166. if (this.propertyConfiguratorContent){
  167. if (this.property) delete this.property;
  168. this.propertyConfiguratorContent.destroy();
  169. this.propertyConfiguratorContent = null;
  170. }
  171. if (this.dataConfiguratorContent){
  172. if (this.dataConfigurator) delete this.dataConfigurator;
  173. this.dataConfiguratorContent.destroy();
  174. this.dataConfiguratorContent = null;
  175. }
  176. if (this.scriptConfiguratorContent){
  177. if (this.scriptConfigurator) delete this.scriptConfigurator;
  178. this.scriptConfiguratorContent.destroy();
  179. this.scriptConfiguratorContent = null;
  180. }
  181. if (this.viewConfiguratorContent){
  182. if (this.viewConfigurator) delete this.viewConfigurator;
  183. this.viewConfiguratorContent.destroy();
  184. this.viewConfiguratorContent = null;
  185. }
  186. if (this.queryViewConfiguratorContent){
  187. if (this.queryViewConfigurator) delete this.queryViewConfigurator;
  188. this.queryViewConfiguratorContent.destroy();
  189. this.queryViewConfiguratorContent = null;
  190. }
  191. },
  192. applicationProperty: function(){
  193. this.clearContent();
  194. this.propertyConfiguratorContent = new Element("div", {
  195. "styles": this.css.rightContentNode
  196. }).inject(this.node);
  197. this.property = new MWF.xApplication.cms.ColumnManager.ApplicationProperty(this, this.propertyConfiguratorContent);
  198. this.property.load();
  199. },
  200. cagetoryConfig: function(){
  201. this.clearContent();
  202. if( this.categoryConfiguratorContent ) {
  203. this.categoryConfiguratorContent.setStyle("display","");
  204. if( this.menu.itemObject["categoryConfig"] ){
  205. this.menu.expend( this.menu.itemObject["categoryConfig"] );
  206. }
  207. this.categoryConfigurator.refresh();
  208. }else{
  209. this.categoryConfiguratorContent = new Element("div", {
  210. "styles": this.css.rightContentNode
  211. }).inject(this.node);
  212. this.loadCategoryConfig();
  213. }
  214. },
  215. loadCategoryConfig: function(){
  216. MWF.xDesktop.requireApp("cms.ColumnManager", "CategoryExplorer", function(){
  217. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  218. var navi = this.menu.itemObject.categoryConfig;
  219. var subNode = navi.retrieve( "subNode" );
  220. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  221. this.categoryConfigurator = new MWF.xApplication.cms.ColumnManager.CategoryExplorer(this.categoryConfiguratorContent, subNode, this.restActions, {
  222. "onPostLoadCategoryList" : function(){
  223. }.bind(this)
  224. });
  225. this.categoryConfigurator.app = this;
  226. //this.categoryConfigurator.categoryScrollWrapNode = this.menu.naviNode;
  227. //this.categoryConfigurator.categoryScrollContentNode = this.menu.areaNode;
  228. this.categoryConfigurator.load();
  229. }.bind(this));
  230. }.bind(this));
  231. },
  232. createCategory : function(){
  233. this.cagetoryConfig();
  234. if( this.categoryConfigurator ){
  235. this.categoryConfigurator.categoryList.newCategory();
  236. }
  237. },
  238. formConfig: function(){
  239. this.clearContent();
  240. this.formConfiguratorContent = new Element("div", {
  241. "styles": this.css.rightContentNode
  242. }).inject(this.node);
  243. this.loadFormConfig();
  244. },
  245. loadFormConfig: function(){
  246. MWF.xDesktop.requireApp("cms.ColumnManager", "FormExplorer", function(){
  247. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  248. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  249. this.formConfigurator = new MWF.xApplication.cms.ColumnManager.FormExplorer(this.formConfiguratorContent, this.restActions, { "title" : "表单配置" });
  250. this.formConfigurator.app = this;
  251. this.formConfigurator.load();
  252. }.bind(this));
  253. }.bind(this));
  254. },
  255. createForm : function(){
  256. if( this.formConfigurator ){
  257. this.formConfigurator._createElement();
  258. }else{
  259. MWF.xDesktop.requireApp("cms.ColumnManager", "FormExplorer", function(){
  260. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  261. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  262. this.formConfigurator = new MWF.xApplication.cms.ColumnManager.FormExplorer(this.formConfiguratorContent, this.restActions);
  263. this.formConfigurator.app = this;
  264. this.formConfigurator._createElement();
  265. }.bind(this));
  266. }.bind(this));
  267. }
  268. },
  269. dataConfig: function(){
  270. this.clearContent();
  271. this.dataConfiguratorContent = new Element("div", {
  272. "styles": this.css.rightContentNode
  273. }).inject(this.node);
  274. this.loadDataConfig();
  275. },
  276. loadDataConfig: function(){
  277. MWF.xDesktop.requireApp("cms.ColumnManager", "DictionaryExplorer", function(){
  278. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  279. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  280. this.dataConfigurator = new MWF.xApplication.cms.ColumnManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions, { "title" : "数据配置" });
  281. this.dataConfigurator.app = this;
  282. this.dataConfigurator.load();
  283. }.bind(this));
  284. }.bind(this));
  285. },
  286. createDataConfig : function(){
  287. if( this.dataConfigurator ){
  288. this.dataConfigurator._createElement();
  289. }else{
  290. MWF.xDesktop.requireApp("cms.ColumnManager", "DictionaryExplorer", function(){
  291. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  292. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  293. this.dataConfigurator = new MWF.xApplication.cms.ColumnManager.DictionaryExplorer(this.dataConfiguratorContent, this.restActions);
  294. this.dataConfigurator.app = this;
  295. this.dataConfigurator._createElement();
  296. }.bind(this));
  297. }.bind(this));
  298. }
  299. },
  300. scriptConfig: function(){
  301. this.clearContent();
  302. this.scriptConfiguratorContent = new Element("div", {
  303. "styles": this.css.rightContentNode
  304. }).inject(this.node);
  305. this.loadScriptConfig();
  306. },
  307. loadScriptConfig: function(){
  308. MWF.xDesktop.requireApp("cms.ColumnManager", "ScriptExplorer", function(){
  309. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  310. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  311. this.scriptConfigurator = new MWF.xApplication.cms.ColumnManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions, { "title" : "脚本配置" });
  312. this.scriptConfigurator.app = this;
  313. this.scriptConfigurator.load();
  314. }.bind(this));
  315. }.bind(this));
  316. },
  317. createScriptConfig : function(){
  318. if( this.scriptConfigurator ){
  319. this.scriptConfigurator._createElement();
  320. }else{
  321. MWF.xDesktop.requireApp("cms.ColumnManager", "ScriptExplorer", function(){
  322. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  323. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  324. this.scriptConfigurator = new MWF.xApplication.cms.ColumnManager.ScriptExplorer(this.scriptConfiguratorContent, this.restActions);
  325. this.scriptConfigurator.app = this;
  326. this.scriptConfigurator._createElement();
  327. }.bind(this));
  328. }.bind(this));
  329. }
  330. },
  331. viewConfig: function(){
  332. this.clearContent();
  333. this.viewConfiguratorContent = new Element("div", {
  334. "styles": this.css.rightContentNode
  335. }).inject(this.node);
  336. this.loadViewConfig();
  337. },
  338. loadViewConfig: function(){
  339. MWF.xDesktop.requireApp("cms.ColumnManager", "ViewExplorer", function(){
  340. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  341. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  342. this.viewConfigurator = new MWF.xApplication.cms.ColumnManager.ViewExplorer(this.viewConfiguratorContent, this.restActions, { "title" : "列表配置" });
  343. this.viewConfigurator.app = this;
  344. this.viewConfigurator.load();
  345. }.bind(this));
  346. }.bind(this));
  347. },
  348. createView : function(){
  349. if( this.viewConfigurator ){
  350. this.viewConfigurator._createElement();
  351. }else{
  352. MWF.xDesktop.requireApp("cms.ColumnManager", "ViewExplorer", function(){
  353. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  354. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  355. this.viewConfigurator = new MWF.xApplication.cms.ColumnManager.ViewExplorer(this.viewConfiguratorContent, this.restActions);
  356. this.viewConfigurator.app = this;
  357. this.viewConfigurator._createElement();
  358. }.bind(this));
  359. }.bind(this));
  360. }
  361. },
  362. queryViewConfig: function(){
  363. this.clearContent();
  364. this.queryViewConfiguratorContent = new Element("div", {
  365. "styles": this.css.rightContentNode
  366. }).inject(this.node);
  367. this.loadQueryViewConfig();
  368. },
  369. loadQueryViewConfig: function(){
  370. MWF.xDesktop.requireApp("cms.ColumnManager", "QueryViewExplorer", function(){
  371. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  372. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  373. this.queryViewConfigurator = new MWF.xApplication.cms.ColumnManager.QueryViewExplorer(this.queryViewConfiguratorContent, this.restActions, { "title" : "数据视图配置" });
  374. this.queryViewConfigurator.app = this;
  375. this.queryViewConfigurator.load();
  376. }.bind(this));
  377. }.bind(this));
  378. },
  379. createQueryView : function(){
  380. if( this.queryViewConfigurator ){
  381. this.queryViewConfigurator._createElement();
  382. }else{
  383. MWF.xDesktop.requireApp("cms.ColumnManager", "QueryViewExplorer", function(){
  384. MWF.xDesktop.requireApp("cms.ColumnManager", "Actions.RestActions", function(){
  385. if (!this.restActions) this.restActions = new MWF.xApplication.cms.ColumnManager.Actions.RestActions();
  386. this.queryViewConfigurator = new MWF.xApplication.cms.ColumnManager.QueryViewExplorer(this.queryViewConfiguratorContent, this.restActions);
  387. this.queryViewConfigurator.app = this;
  388. this.queryViewConfigurator._createElement();
  389. }.bind(this));
  390. }.bind(this));
  391. }
  392. },
  393. //getCategoryCount: function(){
  394. // var size = this.categoryConfiguratorContent.getSize();
  395. // categoryCount = parseInt(size.x/182)+5;
  396. // return categoryCount;
  397. //},
  398. getCategoryCount: function(){
  399. if (this.categoryConfigurator){
  400. var size = this.categoryConfigurator.categoryNode.getSize();
  401. categoryCount = (parseInt(size.x/401)*parseInt(size.y/101))+10;
  402. return categoryCount;
  403. }
  404. return 20;
  405. },
  406. showContentNode: function(node){
  407. if (this.currentContentNode){
  408. // this.currentContentNode.setStyles({
  409. // "position": "absolute"
  410. // });
  411. this.currentContentNode.fade("hide");
  412. node.fade("show");
  413. node.setStyle("display", "node");
  414. this.currentContentNode = null;
  415. }
  416. node.setStyle("display", "block");
  417. node.fade("show");
  418. this.currentContentNode = node;
  419. },
  420. recordStatus: function(){
  421. var id = null;
  422. if (this.menu.currentNavi){
  423. var naviData = this.menu.currentNavi.retrieve( "naviData" );
  424. id = naviData.id;
  425. }
  426. return {"navi": id, "column": this.options.column.id};
  427. }
  428. // onResize: function(){
  429. // if (this.menu) this.menu.onResize();
  430. // }
  431. });
  432. MWF.xApplication.cms.ColumnManager.Menu = new Class({
  433. Implements: [Options, Events],
  434. initialize: function(app, node, options){
  435. this.setOptions(options);
  436. this.app = app;
  437. this.node = $(node);
  438. this.currentNavi = null;
  439. this.status = "start";
  440. this.startNavis = [];
  441. this.itemObject = {};
  442. //this.
  443. this.load();
  444. },
  445. load: function(){
  446. this.areaNode = new Element("div.startMenuAreaNode", this.app.css.startMenuAreaNode).inject( this.node );
  447. MWF.require("MWF.widget.ScrollBar", function(){
  448. new MWF.widget.ScrollBar(this.node, {
  449. "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
  450. });
  451. }.bind(this));
  452. var menuUrl = this.app.path+"startMenu.json";
  453. MWF.getJSON(menuUrl, function(json){
  454. json.each(function(navi){
  455. var naviNode = new Element("div", {
  456. "styles": this.app.css.startMenuNaviNode
  457. });
  458. naviNode.store("naviData", navi);
  459. var iconNode = new Element("div", {
  460. "styles": this.app.css.startMenuIconNode
  461. }).inject(naviNode);
  462. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  463. naviNode.store("iconNode", iconNode );
  464. var textNode = new Element("div", {
  465. "styles": this.app.css.startMenuTextNode,
  466. "text": navi.title
  467. });
  468. textNode.inject(naviNode);
  469. if( navi.expand ){
  470. var expandNode = new Element("div", {
  471. "styles": this.app.css.startMenuExpandNode
  472. });
  473. expandNode.inject(naviNode);
  474. naviNode.store("expandNode", expandNode );
  475. }
  476. if( navi.create ){
  477. var createNode = new Element("div", {
  478. "styles": this.app.css.startMenuCreateNode,
  479. "title" : "新建"+navi.title
  480. });
  481. createNode.inject(naviNode);
  482. naviNode.store("createNode", createNode );
  483. createNode.addEvents({
  484. "click" : function(ev){
  485. this.obj.app[ this.navi.createAction ]();
  486. ev.stopPropagation();
  487. }.bind( { obj : this, navi : navi } ),
  488. "mouseover" : function(ev){
  489. this.createNode.setStyles( this.obj.app.css.startMenuCreateNode_over )
  490. }.bind({ obj : this, createNode : createNode }),
  491. "mouseout" : function(ev){
  492. this.createNode.setStyles( this.obj.app.css.startMenuCreateNode )
  493. }.bind({ obj : this, createNode : createNode })
  494. })
  495. }
  496. naviNode.inject(this.areaNode);
  497. if( navi.expand ){
  498. var subNode = new Element("div", {
  499. "styles": this.app.css.startMenuSubContentNode
  500. });
  501. subNode.inject(this.areaNode);
  502. naviNode.store("subNode", subNode );
  503. }
  504. this.startNavis.push(naviNode);
  505. this.itemObject[ navi.id ] = naviNode;
  506. this.setStartNaviEvent(naviNode, navi);
  507. //this.setNodeCenter(this.node);
  508. }.bind(this));
  509. //this.setStartMenuWidth();
  510. this.setContentSize();
  511. this.app.addEvent("resize", this.setContentSize.bind(this));
  512. this.fireEvent("postLoad");
  513. }.bind(this));
  514. },
  515. setStartNaviEvent: function(naviNode){
  516. var _self = this;
  517. naviNode.addEvents({
  518. "mouseover": function(){ if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  519. "mouseout": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode);},
  520. "mousedown": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_down);},
  521. "mouseup": function(){if (_self.currentNavi!=this) this.setStyles(_self.app.css.startMenuNaviNode_over);},
  522. "click": function(){
  523. //if (_self.currentNavi!=this) _self.doAction.apply(_self, [this]);
  524. _self.doAction.apply(_self, [this]);
  525. }
  526. });
  527. },
  528. expend : function( naviNode ){
  529. var isExpand = naviNode.retrieve("isExpand");
  530. if( !isExpand ){
  531. var expandNode = naviNode.retrieve("expandNode");
  532. expandNode.setStyles(this.app.css.startMenuCollapseNode);
  533. var subNode = naviNode.retrieve("subNode");
  534. subNode.setStyle( "display" , "" );
  535. naviNode.store("isExpand",true);
  536. }
  537. },
  538. collapse : function( naviNode ){
  539. var isExpand = naviNode.retrieve("isExpand");
  540. if( isExpand ){
  541. var expandNode = naviNode.retrieve("expandNode");
  542. expandNode.setStyles(this.app.css.startMenuExpandNode);
  543. var subNode = naviNode.retrieve("subNode");
  544. subNode.setStyle( "display" , "none" );
  545. naviNode.store("isExpand",false);
  546. }
  547. },
  548. doAction: function(naviNode){
  549. if( this.currentNavi && this.currentNavi == naviNode ){
  550. var navi = this.currentNavi.retrieve("naviData");
  551. if( navi.expand ){
  552. var isExpand = this.currentNavi.retrieve("isExpand");
  553. if( isExpand ){
  554. var expandNode = this.currentNavi.retrieve("expandNode");
  555. expandNode.setStyles(this.app.css.startMenuExpandNode);
  556. var subNode = this.currentNavi.retrieve("subNode");
  557. subNode.setStyle( "display" , "none" );
  558. this.currentNavi.store("isExpand",false);
  559. }else{
  560. var expandNode = this.currentNavi.retrieve("expandNode");
  561. expandNode.setStyles(this.app.css.startMenuCollapseNode);
  562. var subNode = this.currentNavi.retrieve("subNode");
  563. subNode.setStyle( "display" , "" );
  564. this.currentNavi.store("isExpand",true);
  565. }
  566. }
  567. return;
  568. }
  569. if (this.currentNavi){
  570. this.currentNavi.setStyles(this.app.css.startMenuNaviNode);
  571. var iconNode = this.currentNavi.retrieve("iconNode");
  572. var navi = this.currentNavi.retrieve("naviData");
  573. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.icon+")");
  574. if( navi.expand ){
  575. var expandNode = this.currentNavi.retrieve("expandNode");
  576. expandNode.setStyles(this.app.css.startMenuExpandNode);
  577. var subNode = this.currentNavi.retrieve("subNode");
  578. subNode.setStyle( "display" , "none" );
  579. this.currentNavi.store("isExpand",false);
  580. }
  581. }
  582. var navi = naviNode.retrieve("naviData");
  583. var action = navi.action;
  584. naviNode.setStyles(this.app.css.startMenuNaviNode_current);
  585. var iconNode = naviNode.retrieve("iconNode");
  586. iconNode.setStyle("background-image", "url("+this.app.path+this.app.options.style+"/icon/"+navi.selectedIcon+")");
  587. if( navi.expand ){
  588. var expandNode = naviNode.retrieve("expandNode");
  589. expandNode.setStyles(this.app.css.startMenuCollapseNode);
  590. var subNode = naviNode.retrieve("subNode");
  591. subNode.setStyle( "display" , "" );
  592. naviNode.store("isExpand",true);
  593. }
  594. this.currentNavi = naviNode;
  595. if (this.app[action]) this.app[action].apply(this.app);
  596. },
  597. setContentSize : function(){
  598. var size = this.app.content.getSize();
  599. this.node.setStyle("height", size.y - 82);
  600. }
  601. });
  602. MWF.xApplication.cms.ColumnManager.ApplicationProperty = new Class({
  603. initialize: function(app, node){
  604. this.app = app;
  605. this.node = $(node);
  606. this.data = this.app.options.application;
  607. this.controllerData = [];
  608. this.controllerList = [];
  609. },
  610. load: function(){
  611. this.propertyTitleBar = new Element("div", {
  612. "styles": this.app.css.propertyTitleBar,
  613. "text": "栏目属性" //this.data.name || this.data.appName
  614. }).inject(this.node);
  615. this.contentNode = new Element("div", {
  616. "styles": this.app.css.propertyContentNode
  617. }).inject(this.node);
  618. this.contentAreaNode = new Element("div", {
  619. "styles": this.app.css.propertyContentAreaNode
  620. }).inject(this.contentNode);
  621. this.setContentHeight();
  622. this.setContentHeightFun = this.setContentHeight.bind(this);
  623. this.app.addEvent("resize", this.setContentHeightFun);
  624. MWF.require("MWF.widget.ScrollBar", function(){
  625. new MWF.widget.ScrollBar(this.contentNode, {"indent": false});
  626. }.bind(this));
  627. this.baseActionAreaNode = new Element("div", {
  628. "styles": this.app.css.baseActionAreaNode
  629. }).inject(this.contentAreaNode);
  630. this.baseActionNode = new Element("div", {
  631. "styles": this.app.css.propertyInforActionNode
  632. }).inject(this.baseActionAreaNode);
  633. this.baseTextNode = new Element("div", {
  634. "styles": this.app.css.baseTextNode,
  635. "text": this.app.lp.application.property
  636. }).inject(this.baseActionAreaNode);
  637. this.createEditBaseNode();
  638. this.createPropertyContentNode();
  639. this.createIconContentNode();
  640. this.publisherContainer = new Element( "div").inject( this.contentAreaNode );
  641. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.PublisherSetting", null, false);
  642. this.publisherSetting = new MWF.xApplication.cms.ColumnManager.PublisherSetting( this.app,
  643. this.app.lp.application.publisherSetting, this.publisherContainer, {
  644. objectId : this.data.id,
  645. objectType : "APPINFO",
  646. permission : "PUBLISH"
  647. }
  648. );
  649. this.publisherSetting.load();
  650. this.permissionContainer = new Element( "div").inject( this.contentAreaNode );
  651. MWF.xDesktop.requireApp("cms.ColumnManager", "widget.PermissionSetting", null, false);
  652. this.permissionSetting = new MWF.xApplication.cms.ColumnManager.PermissionSetting( this.app,
  653. this.app.lp.application.availableSetting, this.permissionContainer, {
  654. objectId : this.data.id,
  655. objectType : "APPINFO",
  656. permission : "VIEW"
  657. }
  658. );
  659. this.permissionSetting.load();
  660. this.listController( function( ){
  661. this.createControllerListNode();
  662. }.bind(this) );
  663. },
  664. listController : function( callback ){
  665. this.app.restActions.listColumnController(this.data.id, function(json){
  666. json.data = json.data || [];
  667. this.controllerData = json.data;
  668. json.data.each(function( d ){
  669. this.controllerList.push( d.adminName );
  670. }.bind(this))
  671. callback.call( )
  672. }.bind(this), null ,false)
  673. },
  674. setContentHeight: function(){
  675. var size = this.app.content.getSize();
  676. var titleSize = this.propertyTitleBar.getSize();
  677. var y = size.y-titleSize.y;
  678. this.contentNode.setStyle("height", ""+y+"px");
  679. },
  680. createIconContentNode: function(){
  681. this.iconContentTitleNode = new Element("div", {
  682. "styles": this.app.css.iconContentTitleNode,
  683. "text": this.app.lp.application.icon
  684. }).inject(this.contentAreaNode);
  685. this.iconContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  686. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  687. html += "<tr><td class='formTitle'><div id='formIconPreview'></div></td><td id='formChangeIconAction'></td></tr>";
  688. html += "</table>";
  689. this.iconContentNode.set("html", html);
  690. this.iconContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  691. this.iconPreviewNode = this.iconContentNode.getElement("div#formIconPreview");
  692. this.iconActionNode = this.iconContentNode.getElement("td#formChangeIconAction");
  693. this.iconPreviewNode.setStyles({
  694. "height": "72px",
  695. "width": "72px",
  696. "float": "right"
  697. });
  698. var icon = this.data.icon || this.data.appIcon;
  699. if (icon){
  700. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+icon+") center center no-repeat");
  701. }else{
  702. this.iconPreviewNode.setStyle("background", "url("+"/x_component_cms_Column/$Main/default/icon/column.png) center center no-repeat")
  703. }
  704. var changeIconAction = new Element("div", {
  705. "styles": {
  706. "margin-left": "20px",
  707. "float": "left",
  708. "background-color": "#FFF",
  709. "padding": "4px 14px",
  710. "border": "1px solid #999",
  711. "border-radius": "3px",
  712. "margin-top": "10px",
  713. "font-size": "14px",
  714. "color": "#666",
  715. "cursor": "pointer"
  716. },
  717. "text": "更改图标"
  718. }).inject(this.iconActionNode);
  719. changeIconAction.addEvent("click", function(){
  720. this.changeIcon();
  721. }.bind(this));
  722. },
  723. changeIcon: function(){
  724. if (!this.uploadFileAreaNode){
  725. this.uploadFileAreaNode = new Element("div");
  726. var html = "<input name=\"file\" type=\"file\"/>";
  727. this.uploadFileAreaNode.set("html", html);
  728. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  729. this.fileUploadNode.addEvent("change", function(){
  730. var files = fileNode.files;
  731. if (files.length){
  732. for (var i = 0; i < files.length; i++) {
  733. var file = files.item(i);
  734. var formData = new FormData();
  735. formData.append('file', file);
  736. //formData.append('name', file.name);
  737. //formData.append('folder', folderId);
  738. this.app.restActions.updataColumnIcon(this.data.id ,function(){
  739. this.app.restActions.getColumn(this.data, function(json){
  740. if (json.data){
  741. this.data = json.data;
  742. if (this.data.appIcon){
  743. this.iconPreviewNode.setStyle("background", "url(data:image/png;base64,"+this.data.appIcon+") center center no-repeat");
  744. }else{
  745. this.iconPreviewNode.setStyle("background", "url("+"/x_component_cms_Column/$Main/default/icon/category2.png) center center no-repeat")
  746. }
  747. }
  748. }.bind(this), false)
  749. }.bind(this), null, formData, file);
  750. }
  751. }
  752. }.bind(this));
  753. }
  754. var fileNode = this.uploadFileAreaNode.getFirst();
  755. fileNode.click();
  756. },
  757. createPropertyContentNode: function(){
  758. this.propertyContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  759. var html = "<table cellspacing='0' cellpadding='0' border='0' width='95%' align='center' style='margin-top: 20px'>";
  760. html += "<tr><td class='formTitle'>"+this.app.lp.application.name+"</td><td id='formApplicationName'></td></tr>";
  761. html += "<tr><td class='formTitle'>"+this.app.lp.application.alias+"</td><td id='formApplicationAlias'></td></tr>";
  762. html += "<tr><td class='formTitle'>"+this.app.lp.application.description+"</td><td id='formApplicationDescription'></td></tr>";
  763. html += "<tr><td class='formTitle'>"+this.app.lp.application.sort+"</td><td id='formApplicationSort'></td></tr>";
  764. // html += "<tr><td class='formTitle'>"+this.app.lp.application.type+"</td><td id='formApplicationType'></td></tr>";
  765. // html += "<tr><td class='formTitle'>"+this.app.lp.application.icon+"</td><td id='formApplicationIcon'></td></tr>";
  766. html += "</table>";
  767. this.propertyContentNode.set("html", html);
  768. this.propertyContentNode.getElements("td.formTitle").setStyles(this.app.css.propertyBaseContentTdTitle);
  769. this.nameInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationName"), this.data.name, this.app.css.formInput);
  770. this.aliasInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationAlias"), this.data.alias, this.app.css.formInput);
  771. this.descriptionInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationDescription"), this.data.description, this.app.css.formInput);
  772. this.sortInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationSort"), this.data.appInfoSeq, this.app.css.formInput);
  773. //this.typeInput = new MWF.xApplication.cms.ColumnManager.Input(this.propertyContentNode.getElement("#formApplicationType"), this.data.applicationCategory, this.app.css.formInput);
  774. },
  775. createControllerListNode: function(){
  776. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  777. this.controllerListTitleNode = new Element("div", {
  778. "styles": this.app.css.controllerListTitleNode,
  779. "text": this.app.lp.application.controllerList
  780. }).inject(this.contentAreaNode);
  781. this.controllerListContentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.contentAreaNode);
  782. this.administratorsContentNode = new Element("div", {"styles": this.app.css.administratorsContentNode}).inject(this.controllerListContentNode);
  783. var changeAdministrators = new Element("div", {
  784. "styles": {
  785. "margin-left": "40px",
  786. "float": "left",
  787. "background-color": "#FFF",
  788. "padding": "4px 14px",
  789. "border": "1px solid #999",
  790. "border-radius": "3px",
  791. "margin-top": "10px",
  792. "margin-bottom": "20px",
  793. "font-size": "14px",
  794. "color": "#666",
  795. "cursor": "pointer"
  796. },
  797. "text": "设置栏目管理者"
  798. }).inject(this.contentAreaNode);
  799. changeAdministrators.addEvent("click", function(){
  800. this.changeAdministrators();
  801. }.bind(this));
  802. if (this.controllerList){
  803. var explorer = {
  804. "actions": this.personActions,
  805. "app": {
  806. "lp": this.app.lp
  807. }
  808. }
  809. this.controllerList.each(function(name){
  810. if (name) var admin = new MWF.widget.Person({"name": name}, this.administratorsContentNode, explorer, false, null, {"style": "application"});
  811. }.bind(this));
  812. }
  813. },
  814. changeAdministrators: function(){
  815. var explorer = {
  816. "actions": this.personActions,
  817. "app": {
  818. "lp": this.app.lp
  819. }
  820. };
  821. var options = {
  822. "type": "person",
  823. "title": "设置应用管理者",
  824. "names": this.controllerList || [],
  825. "onComplete": function(items){
  826. this.administratorsContentNode.empty();
  827. //var controllerList = [];
  828. //items.each(function(item){
  829. // controllerList.push(item.data.name);
  830. // var admin = new MWF.widget.Person(item.data, this.administratorsContentNode, explorer, false, null, {"style": "application"});
  831. //}.bind(this));
  832. //this.controllerList = controllerList;
  833. //this.app.restActions.saveApplication(this.data, function(json){
  834. //
  835. //}.bind(this));
  836. var controllerList = [];
  837. items.each(function(item){
  838. controllerList.push(item.data.name);
  839. var admin = new MWF.widget.Person(item.data, this.administratorsContentNode, explorer, false, null, {"style": "application"});
  840. }.bind(this));
  841. controllerList.each(function(item){
  842. if( !this.controllerList.contains( item ) ){
  843. var controllerData = {
  844. "objectType": "APPINFO",
  845. "objectId": this.data.id,
  846. "adminUid": item,
  847. "adminName": item,
  848. "adminLevel": "ADMIN"
  849. }
  850. this.app.restActions.saveController(controllerData, function(json){
  851. controllerData.id = json.data.id;
  852. this.controllerData.push( controllerData );
  853. }.bind(this), null, false);
  854. }
  855. }.bind(this))
  856. this.controllerList.each(function(item){
  857. if( !controllerList.contains( item ) ){
  858. var ad = null;
  859. var id = "";
  860. this.controllerData.each(function(data){
  861. if( data.adminName == item ){
  862. ad = data;
  863. id = data.id;
  864. }
  865. }.bind(this));
  866. this.app.restActions.removeController(id, function(json){
  867. this.controllerData.erase( ad )
  868. }.bind(this), null, false);
  869. }
  870. }.bind(this))
  871. this.controllerList = controllerList;
  872. this.app.notice( MWF.CMSCM.LP.setControllerSuccess , "success");
  873. }.bind(this)
  874. };
  875. var selector = new MWF.OrgSelector(this.app.content, options);
  876. },
  877. createEditBaseNode: function(){
  878. this.editBaseNode = new Element("button", {
  879. "styles": this.app.css.editBaseNode,
  880. "text": this.app.lp.edit,
  881. "events": {"click": this.editBaseInfor.bind(this)}
  882. }).inject(this.baseActionNode);
  883. },
  884. createCancelBaseNode: function(){
  885. this.cancelBaseNode = new Element("button", {
  886. "styles": this.app.css.cancelBaseNode,
  887. "text": this.app.lp.cancel,
  888. "events": {"click": this.cancelBaseInfor.bind(this)}
  889. }).inject(this.baseActionNode);
  890. },
  891. createSaveBaseNode: function(){
  892. this.saveBaseNode = new Element("button", {
  893. "styles": this.app.css.saveBaseNode,
  894. "text": this.app.lp.save,
  895. "events": {"click": this.saveBaseInfor.bind(this)}
  896. }).inject(this.baseActionNode);
  897. },
  898. editBaseInfor: function(){
  899. this.baseActionNode.empty();
  900. this.editBaseNode = null;
  901. this.createCancelBaseNode();
  902. this.createSaveBaseNode();
  903. this.editMode();
  904. },
  905. editMode: function(){
  906. this.nameInput.editMode();
  907. this.aliasInput.editMode();
  908. this.descriptionInput.editMode();
  909. this.sortInput.editMode();
  910. //this.typeInput.editMode();
  911. this.isEdit = true;
  912. },
  913. readMode: function(){
  914. this.nameInput.readMode();
  915. this.aliasInput.readMode();
  916. this.descriptionInput.readMode();
  917. this.sortInput.readMode();
  918. //this.typeInput.readMode();
  919. this.isEdit = false;
  920. },
  921. cancelBaseInfor: function(){
  922. if (this.data.name){
  923. this.baseActionNode.empty();
  924. this.cancelBaseNode = null;
  925. this.saveBaseNode = null;
  926. this.createEditBaseNode();
  927. this.readMode();
  928. }else{
  929. this.destroy();
  930. }
  931. },
  932. saveBaseInfor: function(){
  933. if (!this.nameInput.input.get("value")){
  934. this.app.notice(this.app.lp.application.inputApplicationName, "error", this.node);
  935. return false;
  936. }
  937. this.node.mask({
  938. "style": {
  939. "opacity": 0.7,
  940. "background-color": "#999"
  941. }
  942. });
  943. this.save(function(){
  944. this.baseActionNode.empty();
  945. this.cancelBaseNode = null;
  946. this.saveBaseNode = null;
  947. this.createEditBaseNode();
  948. this.readMode();
  949. this.node.unmask();
  950. }.bind(this), function(xhr, text, error){
  951. var errorText = error;
  952. if (xhr) errorText = xhr.responseText;
  953. this.app.notice("request json error: "+errorText, "error");
  954. this.node.unmask();
  955. }.bind(this));
  956. },
  957. save: function(callback, cancel){
  958. this.data.name = this.nameInput.input.get("value");
  959. this.data.appName = this.data.name;
  960. this.data.alias = this.aliasInput.input.get("value");
  961. this.data.appAlias = this.data.alias;
  962. this.data.description = this.descriptionInput.input.get("value");
  963. this.data.appInfoSeq = this.sortInput.input.get("value");
  964. //this.data.applicationCategory = this.typeInput.input.get("value");
  965. this.app.restActions.saveColumn(this.data, function(json){
  966. this.propertyTitleBar.set("text", this.data.name);
  967. this.data.id = json.data.id;
  968. this.nameInput.save();
  969. this.aliasInput.save();
  970. this.descriptionInput.save();
  971. this.sortInput.save();
  972. //this.typeInput.save();
  973. if (callback) callback();
  974. }.bind(this), function(xhr, text, error){
  975. if (cancel) cancel(xhr, text, error);
  976. }.bind(this));
  977. }
  978. });
  979. MWF.xApplication.cms.ColumnManager.Input = new Class({
  980. Implements: [Events],
  981. initialize: function(node, value, style){
  982. this.node = $(node);
  983. this.value = value || "";
  984. this.style = style;
  985. this.load();
  986. },
  987. load: function(){
  988. this.content = new Element("div", {
  989. "styles": this.style.content,
  990. "text": this.value
  991. }).inject(this.node);
  992. },
  993. editMode: function(){
  994. this.content.empty();
  995. this.input = new Element("input",{
  996. "styles": this.style.input,
  997. "value": this.value
  998. }).inject(this.content);
  999. this.input.addEvents({
  1000. "focus": function(){
  1001. this.input.setStyles(this.style.input_focus);
  1002. }.bind(this),
  1003. "blur": function(){
  1004. this.input.setStyles(this.style.input);
  1005. }.bind(this)
  1006. });
  1007. },
  1008. readMode: function(){
  1009. this.content.empty();
  1010. this.input = null;
  1011. this.content.set("text", this.value);
  1012. },
  1013. save: function(){
  1014. if (this.input) this.value = this.input.get("value");
  1015. return this.value;
  1016. }
  1017. });