Main.js 49 KB

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