Main_bak.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819
  1. MWF.xApplication.cms = MWF.xApplication.cms || {};
  2. //MWF.xApplication.cms.Column = MWF.xApplication.cms.Column || {};
  3. MWF.xDesktop.requireApp("cms.Column", "Actions.RestActions", null, false);
  4. MWF.xApplication.cms.Column.Main = new Class({
  5. Extends: MWF.xApplication.Common.Main,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "name": "cms.Column",
  10. "icon": "icon.png",
  11. "width": "1000",
  12. "height": "600",
  13. "isResize": false,
  14. "isMax": true,
  15. "title": MWF.xApplication.cms.Column.LP.title,
  16. "tooltip" : {
  17. "description" : MWF.xApplication.cms.Column.LP.description,
  18. "column" : {
  19. "title" : MWF.xApplication.cms.Column.LP.column.title,
  20. "create" : MWF.xApplication.cms.Column.LP.column.create,
  21. "nameLabel" : MWF.xApplication.cms.Column.LP.column.nameLabel,
  22. "aliasLabel": MWF.xApplication.cms.Column.LP.column.aliasLabel,
  23. "descriptionLabel": MWF.xApplication.cms.Column.LP.column.descriptionLabel,
  24. "sortLabel": MWF.xApplication.cms.Column.LP.column.sortLabel,
  25. "iconLabel": MWF.xApplication.cms.Column.LP.column.iconLabel,
  26. "cancel": MWF.xApplication.cms.Column.LP.column.cancel,
  27. "ok": MWF.xApplication.cms.Column.LP.column.ok,
  28. "inputName" : MWF.xApplication.cms.Column.LP.column.inputName,
  29. "create_cancel_title" : MWF.xApplication.cms.Column.LP.column.create_cancel_title,
  30. "create_cancel" : MWF.xApplication.cms.Column.LP.column.create_cancel,
  31. "noDescription" : MWF.xApplication.cms.Column.LP.column.noDescription,
  32. "delete" : MWF.xApplication.cms.Column.LP.column.delete,
  33. "edit" : MWF.xApplication.cms.Column.LP.column.edit
  34. },
  35. "category" : {
  36. "title": MWF.xApplication.cms.Column.LP.category.title,
  37. "create" : MWF.xApplication.cms.Column.LP.category.create,
  38. "nameLabel" : MWF.xApplication.cms.Column.LP.category.nameLabel,
  39. "aliasLabel": MWF.xApplication.cms.Column.LP.category.aliasLabel,
  40. "descriptionLabel": MWF.xApplication.cms.Column.LP.category.descriptionLabel,
  41. "sortLabel": MWF.xApplication.cms.Column.LP.category.sortLabel,
  42. "iconLabel": MWF.xApplication.cms.Column.LP.category.iconLabel,
  43. "columnLabel": MWF.xApplication.cms.Column.LP.category.columnLabel,
  44. "cancel": MWF.xApplication.cms.Column.LP.category.cancel,
  45. "ok": MWF.xApplication.cms.Column.LP.category.ok,
  46. "inputName" : MWF.xApplication.cms.Column.LP.category.inputName,
  47. "create_cancel_title" : MWF.xApplication.cms.Column.LP.category.create_cancel_title,
  48. "create_cancel" : MWF.xApplication.cms.Column.LP.category.create_cancel,
  49. "noDescription" : MWF.xApplication.cms.Column.LP.category.noDescription,
  50. "edit" : MWF.xApplication.cms.Column.LP.category.edit
  51. }
  52. }
  53. },
  54. onQueryLoad: function(){
  55. this.lp = MWF.xApplication.cms.Column.LP;
  56. this.defaultColumnIcon = "/x_component_cms_Column/$Main/"+this.options.style+"/icon/column.png";
  57. this.defaultCategoryIcon = "/x_component_cms_Column/$Main/"+this.options.style+"/icon/category2.png";
  58. },
  59. loadApplication: function(callback){
  60. if (!this.restActions) this.restActions = new MWF.xApplication.cms.Column.Actions.RestActions();
  61. this.columns = [];
  62. this.categorys = [];
  63. this.deleteElements = [];
  64. this.createNode();
  65. this.loadApplicationContent();
  66. if (callback) callback();
  67. },
  68. loadApplicationContent: function(){
  69. this.loadToolbar();
  70. this.loadColumnArea();
  71. this.loadCategoryArea();
  72. },
  73. createNode: function(){
  74. this.content.setStyle("overflow", "hidden");
  75. this.node = new Element("div", {
  76. "styles": {"width": "100%", "height": "100%", "overflow": "hidden"}
  77. }).inject(this.content);
  78. },
  79. loadToolbar: function(){
  80. this.toolbarAreaNode = new Element("div", {
  81. "styles": this.css.toolbarAreaNode,
  82. "text" : this.options.tooltip.description
  83. }).inject(this.node);
  84. //this.createCreateAction();
  85. //this.createSearchAction();
  86. },
  87. createCreateAction: function(){
  88. //if (MWF.AC.isProcessPlatformCreator()){
  89. this.createCategoryNode = new Element("div", {
  90. "styles": this.css.createCategoryNode,
  91. "title": this.options.tooltip.category.create
  92. }).inject(this.toolbarAreaNode);
  93. this.createCategoryNode.addEvent("click", function(){
  94. this.createCategory();
  95. }.bind(this));
  96. //}
  97. },
  98. loadColumnArea: function(){
  99. this.columnAreaNode = new Element("div",{
  100. "styles" : this.css.columnAreaNode
  101. }).inject(this.node);
  102. this.columnToolbarAreaNode = new Element("div",{
  103. "styles" : this.css.columnToolbarAreaNode
  104. }).inject(this.columnAreaNode);
  105. if (MWF.AC.isProcessPlatformCreator()) {
  106. if ( MWF.AC.isAdministrator()) {
  107. this.createColumnNode = new Element("button", {
  108. "styles": this.css.createColumnNode,
  109. "text": this.options.tooltip.column.create
  110. }).inject(this.columnToolbarAreaNode);
  111. this.createColumnNode.addEvent("click", function () {
  112. this.createColumn();
  113. }.bind(this));
  114. }
  115. }
  116. this.columnToolbarTextNode = new Element("div",{
  117. "styles" : this.css.columnToolbarTextNode,
  118. "text" : this.options.tooltip.column.title
  119. }).inject(this.columnToolbarAreaNode);
  120. this.loadColumnContentArea();
  121. },
  122. loadColumnContentArea: function(){
  123. this.columnContentAreaNode = new Element("div",{
  124. "styles" : this.css.columnContentAreaNode
  125. }).inject(this.columnAreaNode);
  126. this.createColumnNodes();
  127. },
  128. createColumnNodes: function(){
  129. this.restActions.listColumn(function(json){
  130. var emptyColumn = null;
  131. json.data.each(function(column){
  132. var column = new MWF.xApplication.cms.Column.Column(this, column);
  133. column.load();
  134. this.columns.push(column);
  135. }.bind(this));
  136. // if (emptyColumn) this.createColumnItemNode()
  137. }.bind(this));
  138. },
  139. createColumn: function(text, alias, memo, icon, creator){
  140. var column = new MWF.xApplication.cms.Column.Column(this);
  141. column.createColumn( this.node );
  142. },
  143. /*
  144. createLoadding: function(){
  145. this.loaddingNode = new Element("div", {
  146. "styles": this.css.noApplicationNode,
  147. "text": this.options.tooltip.loadding
  148. }).inject(this.applicationContentNode);
  149. },
  150. removeLoadding: function(){
  151. if (this.loaddingNode) this.loaddingNode.destroy();
  152. },
  153. */
  154. loadCategoryArea: function(){
  155. this.categoryAreaNode = new Element("div",{
  156. "styles" : this.css.categoryAreaNode
  157. }).inject(this.node);
  158. this.categoryToolbarAreaNode = new Element("div",{
  159. "styles" : this.css.categoryToolbarAreaNode
  160. }).inject(this.categoryAreaNode);
  161. this.createCategoryNode = new Element("button",{
  162. "styles" : this.css.createCategoryNode,
  163. "text" : this.options.tooltip.category.create
  164. }).inject(this.categoryToolbarAreaNode);
  165. this.createCategoryNode.addEvent("click", function(){
  166. this.createCategory();
  167. }.bind(this));
  168. this.categoryToolbarTextNode = new Element("div",{
  169. "styles" : this.css.categoryToolbarTextNode,
  170. "text" : this.options.tooltip.category.title
  171. }).inject(this.categoryToolbarAreaNode);
  172. this.categoryContentAreaNode = new Element("div",{
  173. "styles" : this.css.categoryContentAreaNode
  174. }).inject(this.categoryAreaNode);
  175. },
  176. createCategory: function(){
  177. var category = new MWF.xApplication.cms.Column.Category( this );
  178. category.createCategory();
  179. }
  180. });
  181. MWF.xApplication.cms.Column.Category = new Class({
  182. Implements: [Options, Events],
  183. options: {
  184. "bgColor": ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"]
  185. },
  186. initialize: function (app, data, options) {
  187. this.setOptions(options);
  188. this.app = app;
  189. //this.container = this.app.categoryContentAreaNode;
  190. this.data = data;
  191. this.isNew = false;
  192. },
  193. load: function () {
  194. var name = this.data.cms_catagory_name;
  195. var alias = this.data.cms_catagory_alias;
  196. var memo = this.data.cms_catagory_description;
  197. var order = this.data.cms_catagory_order;
  198. var creator =this.data.creator_uid;
  199. var column = this.data.cms_catagory_app_id;
  200. var form = this.data.cms_catagory_form_id;
  201. var icon = this.data.cms_app_icon;
  202. if( !icon || icon == "")icon = this.app.defaultCategoryIcon;
  203. var itemNode = this.itemNode = new Element("div.categoryItem", {
  204. "styles": this.app.css.categoryItemNode
  205. }).inject(this.container);
  206. itemNode.store("name", name);
  207. itemNode.setStyle("background-color", this.options.bgColor[(Math.random()*10).toInt()]);
  208. var iconNode = new Element("div",{
  209. "styles" : this.app.css.categoryItemIconNode
  210. }).inject(itemNode);
  211. iconNode.setStyles({
  212. "background-image" : "url("+icon+")"
  213. });
  214. var textNode = new Element("div",{
  215. "styles" : this.app.css.categoryItemTextNode
  216. }).inject(itemNode)
  217. var titleNode = new Element("div",{
  218. "styles" : this.app.css.categoryItemTitleNode,
  219. "text" : name,
  220. "title": (alias) ? name+" ("+alias+") " : name
  221. }).inject(textNode)
  222. var description = ( memo && memo!="") ? memo : this.app.options.tooltip.category.noDescription;
  223. var descriptionNode = new Element("div",{
  224. "styles" : this.app.css.categoryItemDescriptionNode,
  225. "text" : description,
  226. "title" : description
  227. }).inject(textNode)
  228. var _self = this;
  229. itemNode.addEvents({
  230. "mouseover": function(){if (!_self.selected) this.setStyles(_self.app.css.categoryItemNode_over);},
  231. "mouseout": function(){if (!_self.selected) this.setStyles(_self.app.css.categoryItemNode);},
  232. "click": function(){_self.clickNode(_self,this)}
  233. });
  234. if (MWF.AC.isProcessPlatformCreator()){
  235. if ((creator==layout.desktop.session.user.name) || MWF.AC.isAdministrator()){
  236. this.delAdctionNode = new Element("div.delNode", {
  237. "styles": this.app.css.categoryItemDelActionNode,
  238. "title" : this.app.options.tooltip.category.delete
  239. }).inject(itemNode );
  240. itemNode.addEvents({
  241. "mouseover": function(){ this.delAdctionNode.fade("in"); }.bind(this),
  242. "mouseout": function(){ this.delAdctionNode.fade("out"); }.bind(this)
  243. });
  244. this.delAdctionNode.addEvent("click", function(e){
  245. this.checkDeleteColumn(e);
  246. e.stopPropagation();
  247. }.bind(this));
  248. }
  249. }
  250. if (MWF.AC.isProcessPlatformCreator()){
  251. if ((creator==layout.desktop.session.user.name) || MWF.AC.isAdministrator()){
  252. this.editAdctionNode = new Element("div.editNode", {
  253. "styles": this.app.css.categoryItemEditActionNode,
  254. "title" : this.app.options.tooltip.category.edit
  255. }).inject(itemNode );
  256. itemNode.addEvents({
  257. "mouseover": function(){ this.editAdctionNode.fade("in"); }.bind(this),
  258. "mouseout": function(){ this.editAdctionNode.fade("out"); }.bind(this)
  259. });
  260. this.editAdctionNode.addEvent("click", function(e){
  261. this.edit(e);
  262. e.stopPropagation();
  263. }.bind(this));
  264. }
  265. }
  266. },
  267. clickNode : function(_self, el ){
  268. },
  269. createCategory: function(){
  270. this.createCategoryCreateMarkNode();
  271. this.createCategoryCreateAreaNode();
  272. this.createCategoryCreateNode();
  273. this.categoryCreateAreaNode.inject(this.categoryCreateMarkNode, "after");
  274. this.categoryCreateAreaNode.fade("in");
  275. $("createCategoryName").focus();
  276. this.setCategoryCreateNodeSize();
  277. this.setCategoryCreateNodeSizeFun = this.setCategoryCreateNodeSize.bind(this);
  278. this.addEvent("resize", this.setCategoryCreateNodeSizeFun);
  279. },
  280. createCategoryCreateMarkNode: function(){
  281. this.categoryCreateMarkNode = new Element("div", {
  282. "styles": this.app.css.categoryCreateMarkNode,
  283. "events": {
  284. "mouseover": function(e){e.stopPropagation();},
  285. "mouseout": function(e){e.stopPropagation();}
  286. }
  287. }).inject(this.app.node, "after");
  288. },
  289. createCategoryCreateAreaNode: function(){
  290. this.categoryCreateAreaNode = new Element("div", {
  291. "styles": this.app.css.categoryCreateAreaNode
  292. });
  293. },
  294. createCategoryCreateNode: function(){
  295. this.categoryCreateNode = new Element("div", {
  296. "styles": this.app.css.categoryCreateNode
  297. }).inject(this.categoryCreateAreaNode);
  298. this.categoryCreateNewNode = new Element("div", {
  299. "styles": this.app.css.categoryCreateNewNode
  300. }).inject(this.categoryCreateNode);
  301. this.categoryCreateFormNode = new Element("div", {
  302. "styles": this.app.css.categoryCreateFormNode
  303. }).inject(this.categoryCreateNode);
  304. var html = "<table width=\"100%\" height=\"80%\" border=\"0\" cellPadding=\"0\" cellSpacing=\"0\">" +
  305. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left; min-width: 80px; width:25%\">" +
  306. this.app.options.tooltip.category.nameLabel+":</td>" +
  307. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createCategoryName\" " +
  308. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  309. "height: 26px;\"/></td></tr>" +
  310. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.app.options.tooltip.category.aliasLabel+":</td>" +
  311. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createCategoryAlias\" " +
  312. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  313. "height: 26px;\"/></td></tr>" +
  314. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.app.options.tooltip.category.descriptionLabel+":</td>" +
  315. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createCategoryDescription\" " +
  316. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  317. "height: 26px;\"/></td></tr>" +
  318. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.app.options.tooltip.category.sortLabel+":</td>" +
  319. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createCategorySort\" " +
  320. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  321. "height: 26px;\"/></td></tr>" +
  322. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.app.options.tooltip.category.columnLabel+":</td>" +
  323. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createCategoryColumn\" " +
  324. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  325. "height: 26px;\"/></td></tr>" +
  326. //"<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.options.tooltip.iconLabel+":</td>" +
  327. //"<td style=\"; text-align: right;\"><input type=\"text\" id=\"createCategoryType\" " +
  328. //"style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  329. //"height: 26px;\"/></td></tr>" +
  330. "</table>";
  331. this.categoryCreateFormNode.set("html", html);
  332. this.categoryCancelActionNode = new Element("div", {
  333. "styles": this.app.css.categoryCreateCancelActionNode,
  334. "text": this.app.options.tooltip.category.cancel
  335. }).inject(this.categoryCreateFormNode);
  336. this.categoryCreateOkActionNode = new Element("div", {
  337. "styles": this.app.css.categoryCreateOkActionNode,
  338. "text": this.app.options.tooltip.category.ok
  339. }).inject(this.categoryCreateFormNode);
  340. this.categoryCancelActionNode.addEvent("click", function(e){
  341. this.cancelCreateCategory(e);
  342. }.bind(this));
  343. this.categoryCreateOkActionNode.addEvent("click", function(e){
  344. this.okCreateCategory(e);
  345. }.bind(this));
  346. },
  347. setCategoryCreateNodeSize: function(){
  348. var size = this.app.node.getSize();
  349. var allSize = this.app.content.getSize();
  350. this.categoryCreateMarkNode.setStyles({
  351. "width": ""+allSize.x+"px",
  352. "height": ""+allSize.y+"px"
  353. });
  354. this.categoryCreateAreaNode.setStyles({
  355. "width": ""+size.x+"px",
  356. "height": ""+size.y+"px"
  357. });
  358. var hY = size.y*0.8;
  359. var mY = size.y*0.2/2;
  360. this.categoryCreateNode.setStyles({
  361. "height": ""+hY+"px",
  362. "margin-top": ""+mY+"px"
  363. });
  364. var iconSize = this.categoryCreateNewNode.getSize();
  365. var formHeight = hY*0.7;
  366. if (formHeight>250) formHeight = 250;
  367. var formMargin = hY*0.3/2-iconSize.y;
  368. this.categoryCreateFormNode.setStyles({
  369. "height": ""+formHeight+"px",
  370. "margin-top": ""+formMargin+"px"
  371. });
  372. },
  373. cancelCreateCategory: function(e){
  374. var _self = this;
  375. if ($("createCategoryName").get("value") || $("createCategoryAlias").get("value") || $("createCategoryDescription").get("value")){
  376. this.confirm("warn", e,
  377. this.app.options.tooltip.category.create_cancel_title,
  378. this.app.options.tooltip.category.create_cancel, "320px", "100px",
  379. function(){
  380. _self.categoryCreateMarkNode.destroy();
  381. _self.categoryCreateAreaNode.destroy();
  382. this.close();
  383. },function(){
  384. this.close();
  385. }
  386. );
  387. }else{
  388. this.categoryCreateMarkNode.destroy();
  389. this.categoryCreateAreaNode.destroy();
  390. }
  391. },
  392. okCreateCategory: function(e){
  393. var data = {
  394. "name": $("createCategoryName").get("value"),
  395. "alias": $("createCategoryAlias").get("value"),
  396. "description": $("createCategoryDescription").get("value"),
  397. "createCategorySort": $("createCategorySort").get("value"),
  398. "createCategoryColumn":$("createCategoryColumn").get("value")
  399. };
  400. if (data.name){
  401. this.restActions.saveCategory(data, function(json){
  402. this.categoryCreateMarkNode.destroy();
  403. this.categoryCreateAreaNode.destroy();
  404. this.restActions.getCategory(json.data.id, function(json){
  405. json.data.processList = [];
  406. json.data.formList = [];
  407. var category = new MWF.xCategory.process.CategoryColumn.Category(this, json.data, {"where": "top"});
  408. category.load();
  409. this.categorys.push(category);
  410. }.bind(this));
  411. if( this.app.noElementNode ){
  412. }
  413. this.notice(this.options.tooltip.createCategorySuccess, "success");
  414. // this.app.processConfig();
  415. }.bind(this));
  416. }else{
  417. $("createCategoryName").setStyle("border-color", "red");
  418. $("createCategoryName").focus();
  419. this.notice(this.options.tooltip.category.inputName, "error");
  420. }
  421. },
  422. checkDeleteCategory: function(){
  423. if (this.deleteElements.length){
  424. if (!this.deleteElementsNode){
  425. this.deleteElementsNode = new Element("div", {
  426. "styles": this.app.css.deleteElementsNode,
  427. "text": this.app.lp.category.deleteElements
  428. }).inject(this.node);
  429. this.deleteElementsNode.position({
  430. relativeTo: this.app.categoryContentNode,
  431. position: "centerTop",
  432. edge: "centerbottom"
  433. });
  434. this.deleteElementsNode.addEvent("click", function(e){
  435. this.deleteSelectedElements(e);
  436. }.bind(this));
  437. }
  438. }else{
  439. if (this.deleteElementsNode){
  440. this.deleteElementsNode.destroy();
  441. this.deleteElementsNode = null;
  442. delete this.deleteElementsNode;
  443. }
  444. }
  445. }
  446. })
  447. MWF.xApplication.cms.Column.Column = new Class({
  448. Implements: [Options, Events],
  449. options: {
  450. "bgColor": ["#30afdc", "#e9573e", "#8dc153", "#9d4a9c", "#ab8465", "#959801", "#434343", "#ffb400", "#9e7698", "#00a489"]
  451. },
  452. initialize: function (app, data, options) {
  453. this.setOptions(options);
  454. this.app = app;
  455. this.container = this.app.columnContentAreaNode;
  456. this.data = data;
  457. this.isNew = false;
  458. },
  459. load: function () {
  460. var columnName = this.data.cms_app;
  461. var alias = this.data.cms_app_alias;
  462. var memo = this.data.cms_app_memo;
  463. var creator =this.data.creator_uid;
  464. var icon = this.data.cms_app_icon;
  465. if( !icon || icon == "")icon = this.app.defaultColumnIcon;
  466. var itemNode = this.itemNode = new Element("div.columnItem", {
  467. "styles": this.app.css.columnItemNode
  468. }).inject(this.container);
  469. itemNode.store("columnName", columnName);
  470. //itemNode.setStyle("background-color", this.options.bgColor[(Math.random()*10).toInt()]);
  471. var iconNode = new Element("div",{
  472. "styles" : this.app.css.columnItemIconNode
  473. }).inject(itemNode);
  474. iconNode.setStyles({
  475. "background-image" : "url("+icon+")"
  476. });
  477. var textNode = new Element("div",{
  478. "styles" : this.app.css.columnItemTextNode
  479. }).inject(itemNode)
  480. var titleNode = new Element("div",{
  481. "styles" : this.app.css.columnItemTitleNode,
  482. "text" : columnName,
  483. "title": (alias) ? columnName+" ("+alias+") " : columnName
  484. }).inject(textNode)
  485. var description = ( memo && memo!="") ? memo : this.app.options.tooltip.column.noDescription;
  486. var descriptionNode = new Element("div",{
  487. "styles" : this.app.css.columnItemDescriptionNode,
  488. "text" : description,
  489. "title" : description
  490. }).inject(textNode)
  491. var _self = this;
  492. itemNode.addEvents({
  493. "mouseover": function(){if (!_self.selected) this.setStyles(_self.app.css.columnItemNode_over);},
  494. "mouseout": function(){if (!_self.selected) this.setStyles(_self.app.css.columnItemNode);},
  495. "click": function(){_self.clickColumnNode(_self,this)}
  496. });
  497. if (MWF.AC.isProcessPlatformCreator()){
  498. if ((creator==layout.desktop.session.user.name) || MWF.AC.isAdministrator()){
  499. this.delAdctionNode = new Element("div.delNode", {
  500. "styles": this.app.css.columnItemDelActionNode,
  501. "title" : this.app.options.tooltip.column.delete
  502. }).inject(itemNode );
  503. itemNode.addEvents({
  504. "mouseover": function(){ this.delAdctionNode.fade("in"); }.bind(this),
  505. "mouseout": function(){ this.delAdctionNode.fade("out"); }.bind(this)
  506. });
  507. this.delAdctionNode.addEvent("click", function(e){
  508. this.checkDeleteColumn(e);
  509. e.stopPropagation();
  510. }.bind(this));
  511. }
  512. }
  513. if (MWF.AC.isProcessPlatformCreator()){
  514. if ((creator==layout.desktop.session.user.name) || MWF.AC.isAdministrator()){
  515. this.editAdctionNode = new Element("div.editNode", {
  516. "styles": this.app.css.columnItemEditActionNode,
  517. "title" : this.app.options.tooltip.column.edit
  518. }).inject(itemNode );
  519. itemNode.addEvents({
  520. "mouseover": function(){ this.editAdctionNode.fade("in"); }.bind(this),
  521. "mouseout": function(){ this.editAdctionNode.fade("out"); }.bind(this)
  522. });
  523. this.editAdctionNode.addEvent("click", function(e){
  524. this.edit(e);
  525. e.stopPropagation();
  526. }.bind(this));
  527. }
  528. }
  529. },
  530. clickColumnNode : function(_self, el ){
  531. _self.app.columns.each(function( column ){
  532. if( column.selected ){
  533. column.itemNode.setStyles( _self.app.css.columnItemNode );
  534. }
  535. })
  536. this.selected = true;
  537. el.setStyles( _self.app.css.columnItemNode_select );
  538. },
  539. checkDeleteColumn: function(){
  540. if (this.deleteElements.length){
  541. if (!this.deleteElementsNode){
  542. this.deleteElementsNode = new Element("div", {
  543. "styles": this.app.css.deleteElementsNode,
  544. "text": this.app.lp.column.deleteElements
  545. }).inject(this.node);
  546. this.deleteElementsNode.position({
  547. relativeTo: this.container,
  548. position: "centerTop",
  549. edge: "centerbottom"
  550. });
  551. this.deleteElementsNode.addEvent("click", function(e){
  552. this.deleteSelectedElements(e);
  553. }.bind(this));
  554. }
  555. }else{
  556. if (this.deleteElementsNode){
  557. this.deleteElementsNode.destroy();
  558. this.deleteElementsNode = null;
  559. delete this.deleteElementsNode;
  560. }
  561. }
  562. },
  563. edit : function(){
  564. this.isNew = false;
  565. this.createContainer = this.app.node;
  566. this.createColumnCreateMarkNode();
  567. this.createColumnCreateAreaNode();
  568. this.createColumnCreateNode();
  569. this.columnCreateAreaNode.inject(this.columnCreateMarkNode, "after");
  570. this.columnCreateAreaNode.fade("in");
  571. $("createColumnName").focus();
  572. this.setColumnCreateNodeSize();
  573. this.setColumnCreateNodeSizeFun = this.setColumnCreateNodeSize.bind(this);
  574. this.addEvent("resize", this.setColumnCreateNodeSizeFun);
  575. },
  576. createColumn: function( container ){
  577. this.isNew = true;
  578. this.createContainer = container;
  579. this.createColumnCreateMarkNode();
  580. this.createColumnCreateAreaNode();
  581. this.createColumnCreateNode();
  582. this.columnCreateAreaNode.inject(this.columnCreateMarkNode, "after");
  583. this.columnCreateAreaNode.fade("in");
  584. $("createColumnName").focus();
  585. this.setColumnCreateNodeSize();
  586. this.setColumnCreateNodeSizeFun = this.setColumnCreateNodeSize.bind(this);
  587. this.addEvent("resize", this.setColumnCreateNodeSizeFun);
  588. },
  589. createColumnCreateMarkNode: function(){
  590. this.columnCreateMarkNode = new Element("div", {
  591. "styles": this.app.css.columnCreateMarkNode,
  592. "events": {
  593. "mouseover": function(e){e.stopPropagation();},
  594. "mouseout": function(e){e.stopPropagation();}
  595. }
  596. }).inject(this.createContainer, "after");
  597. },
  598. createColumnCreateAreaNode: function(){
  599. this.columnCreateAreaNode = new Element("div", {
  600. "styles": this.app.css.columnCreateAreaNode
  601. });
  602. },
  603. createColumnCreateNode: function(){
  604. if(!this.isNew){
  605. var columnName = this.data.cms_app;
  606. var alias = this.data.cms_app_alias;
  607. var memo = this.data.cms_app_memo;
  608. var creator =this.data.creator_uid;
  609. var order = this.data.cms_app_order;
  610. var icon = this.data.cms_app_icon;
  611. if( !icon || icon == "")icon = this.app.defaultColumnIcon;
  612. }else{
  613. var columnName = "";
  614. var alias = "";
  615. var memo = "";
  616. var order = "";
  617. var creator ="";
  618. var icon = "";
  619. }
  620. this.columnCreateNode = new Element("div", {
  621. "styles": this.app.css.columnCreateNode
  622. }).inject(this.columnCreateAreaNode);
  623. this.columnCreateNewNode = new Element("div", {
  624. "styles": ( this.isNew ? this.app.css.columnCreateNewNode : this.app.css.columnCreateEditNode )
  625. }).inject(this.columnCreateNode);
  626. this.columnCreateFormNode = new Element("div", {
  627. "styles": this.app.css.columnCreateFormNode
  628. }).inject(this.columnCreateNode);
  629. var html = "<table width=\"100%\" height=\"80%\" border=\"0\" cellPadding=\"0\" cellSpacing=\"0\">" +
  630. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left; min-width: 80px; width:25%\">" +
  631. this.app.options.tooltip.column.nameLabel+":</td>" +
  632. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createColumnName\" " +
  633. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  634. "height: 26px;\" value=\""+columnName+"\"/></td></tr>" +
  635. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.app.options.tooltip.column.aliasLabel+":</td>" +
  636. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createColumnAlias\" " +
  637. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  638. "height: 26px;\" value=\""+alias+"\"/></td></tr>" +
  639. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.app.options.tooltip.column.descriptionLabel+":</td>" +
  640. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createColumnDescription\" " +
  641. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  642. "height: 26px;\" value=\""+memo+"\"/></td></tr>" +
  643. "<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.app.options.tooltip.column.sortLabel+":</td>" +
  644. "<td style=\"; text-align: right;\"><input type=\"text\" id=\"createColumnSort\" " +
  645. "style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  646. "height: 26px;\" value=\""+order+"\"/></td></tr>"+
  647. //"<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.options.tooltip.column.iconLabel+":</td>" +
  648. //"<td style=\"; text-align: right;\"><div " +
  649. //"style=\"height:72px; width:72px;background:url(/x_component_cms_Column/$Main/default/icon/column.png) center center no-repeat \"></div></td></tr>" +
  650. //"<tr><td style=\"height: 30px; line-height: 30px; text-align: left\">"+this.options.tooltip.iconLabel+":</td>" +
  651. //"<td style=\"; text-align: right;\"><input type=\"text\" id=\"createColumnType\" " +
  652. //"style=\"width: 99%; border:1px solid #999; background-color:#FFF; border-radius: 3px; box-shadow: 0px 0px 6px #CCC; " +
  653. //"height: 26px;\"/></td></tr>" +
  654. "</table>";
  655. this.columnCreateFormNode.set("html", html);
  656. this.columnCancelActionNode = new Element("div", {
  657. "styles": this.app.css.columnCreateCancelActionNode,
  658. "text": this.app.options.tooltip.column.cancel
  659. }).inject(this.columnCreateFormNode);
  660. this.columnCreateOkActionNode = new Element("div", {
  661. "styles": this.app.css.columnCreateOkActionNode,
  662. "text": this.app.options.tooltip.column.ok
  663. }).inject(this.columnCreateFormNode);
  664. this.columnCancelActionNode.addEvent("click", function(e){
  665. this.cancelCreateColumn(e);
  666. }.bind(this));
  667. this.columnCreateOkActionNode.addEvent("click", function(e){
  668. this.okCreateColumn(e);
  669. }.bind(this));
  670. },
  671. setColumnCreateNodeSize: function(){
  672. var size = this.createContainer.getSize();
  673. var allSize = this.app.content.getSize();
  674. this.columnCreateMarkNode.setStyles({
  675. "width": ""+allSize.x+"px",
  676. "height": ""+allSize.y+"px"
  677. });
  678. this.columnCreateAreaNode.setStyles({
  679. "width": ""+size.x+"px",
  680. "height": ""+size.y+"px"
  681. });
  682. var hY = size.y*0.8;
  683. var mY = size.y*0.2/2;
  684. this.columnCreateNode.setStyles({
  685. "height": ""+hY+"px",
  686. "margin-top": ""+mY+"px"
  687. });
  688. var iconSize = this.columnCreateNewNode.getSize();
  689. var formHeight = hY*0.7;
  690. if (formHeight>250) formHeight = 250;
  691. var formMargin = hY*0.3/2-iconSize.y;
  692. this.columnCreateFormNode.setStyles({
  693. "height": ""+formHeight+"px",
  694. "margin-top": ""+formMargin+"px"
  695. });
  696. },
  697. cancelCreateColumn: function(e){
  698. if(this.isNew){
  699. this.cancelNewColumn(e)
  700. }else{
  701. this.cancelEditColumn(e)
  702. }
  703. },
  704. cancelNewColumn: function(e){
  705. var _self = this;
  706. if ($("createColumnName").get("value") || $("createColumnAlias").get("value") || $("createColumnDescription").get("value")){
  707. this.app.confirm("warn", e, this.app.options.tooltip.column.create_cancel_title,
  708. this.app.options.tooltip.column.create_cancel, "320px", "100px", function(){
  709. _self.columnCreateMarkNode.destroy();
  710. _self.columnCreateAreaNode.destroy();
  711. this.close();
  712. },function(){
  713. this.close();
  714. });
  715. }else{
  716. this.columnCreateMarkNode.destroy();
  717. this.columnCreateAreaNode.destroy();
  718. }
  719. },
  720. cancelEditColumn : function(e){
  721. this.columnCreateMarkNode.destroy();
  722. this.columnCreateAreaNode.destroy();
  723. },
  724. okCreateColumn: function(e){
  725. var data = {
  726. "name": $("createColumnName").get("value"),
  727. "alias": $("createColumnAlias").get("value"),
  728. "description": $("createColumnDescription").get("value"),
  729. "createColumnSort": $("createColumnSort").get("value")
  730. };
  731. if (data.name){
  732. this.restActions.saveColumn(data, function(json){
  733. this.columnCreateMarkNode.destroy();
  734. this.columnCreateAreaNode.destroy();
  735. this.restActions.getColumn(json.data.id, function(json){
  736. json.data.processList = [];
  737. json.data.formList = [];
  738. var column = new MWF.xColumn.process.ColumnColumn.Column(this, json.data, {"where": "top"});
  739. column.load();
  740. this.app.columns.push(column);
  741. }.bind(this));
  742. this.app.notice(this.options.tooltip.createColumnSuccess, "success");
  743. // this.app.processConfig();
  744. }.bind(this));
  745. }else{
  746. $("createColumnName").setStyle("border-color", "red");
  747. $("createColumnName").focus();
  748. this.app.notice(this.app.options.tooltip.column.inputName, "error");
  749. }
  750. }
  751. })