Explorer.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. MWF.xApplication.cms = MWF.xApplication.cms || {};
  2. MWF.xApplication.cms.ColumnManager = MWF.xApplication.cms.ColumnManager || {};
  3. MWF.xDesktop.requireApp("cms.ColumnManager", "lp."+MWF.language, null, false);
  4. MWF.xDesktop.requireApp("cms.ColumnManager", "package", null, false);
  5. MWF.xApplication.cms.ColumnManager.Explorer = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "title" : "",
  11. "tooltip": {
  12. "create": MWF.CMSCM.LP.category.create,
  13. "search": MWF.CMSCM.LP.category.search,
  14. "searchText": MWF.CMSCM.LP.category.searchText,
  15. "noElement": MWF.CMSCM.LP.category.noCategoryNoticeText
  16. },
  17. "topEnable": true,
  18. "itemStyle": "line",
  19. "sortKeys": ['name', 'alias', 'createTime', 'updateTime'],
  20. "sortKey": '',
  21. "name": 'cms.FormExplorer'
  22. },
  23. initialize: function(node, actions, options){
  24. this.setOptions(options);
  25. this.setTooltip();
  26. this.path = "../x_component_cms_ColumnManager/$Explorer/";
  27. this.cssPath = "../x_component_cms_ColumnManager/$Explorer/"+this.options.style+"/css.wcss";
  28. this._loadCss();
  29. this.actions = actions;
  30. this.node = $(node);
  31. this.initData();
  32. },
  33. setTooltip: function(tooltip){
  34. if (tooltip) this.options.tooltip = Object.merge(this.options.tooltip, tooltip);
  35. },
  36. initData: function(){
  37. //this.categoryLoadFirst = true;
  38. //this.isLoaddingCategory = false;
  39. //this.categoryLoaded = false;
  40. //this.categorys = [];
  41. //this.dragItem = false;
  42. //this.dragCategory = false;
  43. //this.currentCategory = null;
  44. //this.loadCategoryQueue = 0;
  45. this.itemArray = [];
  46. this.itemObject = {};
  47. this.deleteMarkItems = [];
  48. this.selectMarkItems = [];
  49. },
  50. reload: function(){
  51. if( !this.node )return;
  52. if( this.itemArray && this.itemArray.length ){
  53. this.itemArray.each(function (item){
  54. if(item.destroy)item.destroy();
  55. });
  56. }
  57. this.initData();
  58. this.node.empty();
  59. this.load();
  60. },
  61. load: function(){
  62. this.getUd( function (){
  63. this.loadToolbar();
  64. this.loadContentNode();
  65. this.setNodeScroll();
  66. this.loadElementList();
  67. }.bind(this));
  68. },
  69. getUd: function ( callback ){
  70. MWF.UD.getDataJson(this.options.name+ "_" + this.app.options.column.id, function (data){
  71. if( data ){
  72. this.options.itemStyle = data.itemStyle;
  73. this.options.sortKey = data.sortKey;
  74. }
  75. callback();
  76. }.bind(this));
  77. },
  78. setUd: function (){
  79. var data = {
  80. itemStyle: this.options.itemStyle,
  81. sortKey: this.options.sortKey,
  82. };
  83. MWF.UD.putData(this.options.name+ "_" + this.app.options.column.id, data);
  84. },
  85. loadToolbar: function(){
  86. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode});
  87. this.createTitleElementNode();
  88. this.createCreateElementNode();
  89. if(this.options.topEnable){
  90. this.createItemStyleNode();
  91. this.createSortNode();
  92. this.createSearchNode();
  93. }
  94. //this.createSearchElementNode();
  95. this.toolbarNode.inject(this.node);
  96. },
  97. createCreateElementNode: function(){
  98. this.createElementNode = new Element("div", {
  99. "styles": this.css.createElementNode,
  100. "title": this.options.tooltip.create
  101. }).inject(this.toolbarNode);
  102. this.createElementNode.addEvents({
  103. "click": function(e){ this._createElement(e); }.bind(this),
  104. "mouseover" : function(e){
  105. this.createElementNode.setStyles(this.css.createElementNode_over);
  106. }.bind(this),
  107. "mouseout" : function(ev){
  108. this.createElementNode.setStyles(this.css.createElementNode);
  109. }.bind(this)
  110. });
  111. },
  112. createTitleElementNode: function() {
  113. this.titleElementNode = new Element("div", {
  114. "styles": this.css.titleElementNode,
  115. "text": this.options.title
  116. }).inject(this.toolbarNode);
  117. },
  118. createSearchElementNode: function(){
  119. this.searchElementNode = new Element("div", {
  120. "styles": this.css.searchElementNode
  121. }).inject(this.toolbarNode);
  122. //@todo
  123. // return false;
  124. //
  125. // this.searchElementButtonNode = new Element("div", {
  126. // "styles": this.css.searchElementButtonNode,
  127. // "title": this.options.tooltip.search
  128. // }).inject(this.searchElementNode);
  129. //
  130. // this.searchElementInputAreaNode = new Element("div", {
  131. // "styles": this.css.searchElementInputAreaNode
  132. // }).inject(this.searchElementNode);
  133. //
  134. // this.searchElementInputBoxNode = new Element("div", {
  135. // "styles": this.css.searchElementInputBoxNode
  136. // }).inject(this.searchElementInputAreaNode);
  137. //
  138. // this.searchElementInputNode = new Element("input", {
  139. // "type": "text",
  140. // "value": this.options.tooltip.searchText,
  141. // "styles": this.css.searchElementInputNode,
  142. // "x-webkit-speech": "1"
  143. // }).inject(this.searchElementInputBoxNode);
  144. // var _self = this;
  145. // this.searchElementInputNode.addEvents({
  146. // "focus": function(){
  147. // if (this.value==_self.options.tooltip.searchText) this.set("value", "");
  148. // },
  149. // "blur": function(){if (!this.value) this.set("value", _self.options.tooltip.searchText);},
  150. // "keydown": function(e){
  151. // if (e.code==13){
  152. // this.searchElement();
  153. // e.preventDefault();
  154. // }
  155. // }.bind(this),
  156. // "selectstart": function(e){
  157. // e.preventDefault();
  158. // }
  159. // });
  160. // this.searchElementButtonNode.addEvent("click", function(){this.searchElement();}.bind(this));
  161. },
  162. searchElement: function(){
  163. //-----------------------------------------
  164. //-----------------------------------------
  165. //-----search category---------------------
  166. //-----------------------------------------
  167. //-----------------------------------------
  168. //alert("search Element");
  169. },
  170. loadContentNode: function(){
  171. this.elementContentNode = new Element("div", {
  172. "styles": this.css.elementContentNode
  173. }).inject(this.node);
  174. this.elementContentListNode = new Element("div", {
  175. "styles": this.css.elementContentListNode
  176. }).inject(this.elementContentNode);
  177. this.setContentSize();
  178. this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  179. },
  180. setContentSize: function(){
  181. var toolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : { x : 0 , y : 0 };
  182. var nodeSize = this.node.getSize();
  183. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  184. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  185. var height = nodeSize.y-toolbarSize.y-pt-pb;
  186. this.elementContentNode.setStyle("height", ""+height+"px");
  187. var contentSize = this.app.content.getSize();
  188. var menuSize = this.app.leftContentNode.getSize();
  189. var width = contentSize.x - menuSize.x;
  190. this.elementContentNode.setStyle("width", ""+(width-10)+"px");
  191. if (this.options.noCreate) this.createElementNode.destroy();
  192. //var count = (nodeSize.x/282).toInt();
  193. //var x = count*282;
  194. //var m = (nodeSize.x-x)/2-10;
  195. //
  196. //this.elementContentListNode.setStyles({
  197. // "width": ""+x+"px",
  198. // "margin-left": "" + m + "px"
  199. //});
  200. },
  201. setNodeScroll: function(){
  202. MWF.require("MWF.widget.DragScroll", function(){
  203. new MWF.widget.DragScroll(this.elementContentNode);
  204. }.bind(this));
  205. MWF.require("MWF.widget.ScrollBar", function(){
  206. new MWF.widget.ScrollBar(this.elementContentNode, {"indent": false});
  207. }.bind(this));
  208. },
  209. loadElementList: function( callback ){
  210. this._loadItemDataList(function(json){
  211. if (json.data.length){
  212. this.checkSort(json.data);
  213. json.data.each(function(item){
  214. var itemObj = this._getItemObject(item, this.itemArray.length + 1 );
  215. itemObj.load();
  216. this.checkShow(itemObj);
  217. this.itemObject[ item.id ] = itemObj;
  218. this.itemArray.push( itemObj );
  219. }.bind(this));
  220. if( callback )callback();
  221. }else{
  222. var noElementNode = this.noElementNode = new Element("div", {
  223. "styles": this.css.noElementNode,
  224. "text": this.options.tooltip.noElement
  225. }).inject(this.elementContentListNode);
  226. noElementNode.addEvent("click", function(e){
  227. this._createElement(e);
  228. }.bind(this));
  229. }
  230. }.bind(this));
  231. },
  232. checkSort: function (data){
  233. if( !!this.options.sortKey ){
  234. var sortKey = this.options.sortKey.split("-");
  235. var key = sortKey[0], isDesc = sortKey[1] === 'desc';
  236. data.sort(function (a, b){
  237. var av = a[key];
  238. var bv = b[key];
  239. if( typeOf(av) === 'string' && typeOf(bv) === 'string' ){
  240. var isLetterA = /^[a-zA-Z0-9]/.test(av);
  241. var isLetterB = /^[a-zA-Z0-9]/.test(bv);
  242. if (isLetterA && !isLetterB) return isDesc ? 1 : -1; // a是字母,b不是,a排在前面
  243. if (!isLetterA && isLetterB) return isDesc ? -1 : 1; // a不是字母,b是,b排在前面
  244. return isDesc ? bv.localeCompare(av) : av.localeCompare(bv);
  245. }
  246. return isDesc ? (bv - av) : (av - bv);
  247. }.bind(this));
  248. }
  249. },
  250. checkShow: function (i){
  251. if( this.options.searchKey ){
  252. var v = this.options.searchKey;
  253. if( i.data.name.contains(v) || (i.data.alias || "").contains(v) || i.data.id.contains(v) ){
  254. //i.node.setStyle("display", "");
  255. }else{
  256. i.node.setStyle("display", "none");
  257. }
  258. }
  259. },
  260. createItemStyleNode: function (){
  261. this.itemStyleSwitchNode = new Element("div.itemStyleSwitchNode", {
  262. styles: this.css.itemStyleSwitchNode
  263. }).inject(this.toolbarNode);
  264. ['line','card'].each(function(style){
  265. var el = new Element("div", {
  266. styles: this.css.itemStyleSwitchItemNode
  267. }).inject(this.itemStyleSwitchNode);
  268. el.setStyle('background-image',"url('../x_component_process_ProcessManager/$Explorer/default/icon/"+style+".png')");
  269. el.store("sty", style);
  270. el.addEvent("click", function(e){
  271. this.switchItemStyle(el, style);
  272. }.bind(this));
  273. if( style === this.options.itemStyle )el.click();
  274. }.bind(this));
  275. },
  276. createSortNode: function(){
  277. this.itemSortArea = new Element("div.itemStyleSwitchNode", {
  278. styles: this.css.itemSortArea
  279. }).inject(this.toolbarNode);
  280. this.itemSortSelect = new Element('select.itemSortSelect', {
  281. styles: this.css.itemSortSelect,
  282. events: {
  283. change: function(){
  284. this.options.sortKey = this.itemSortSelect[ this.itemSortSelect.selectedIndex ].value;
  285. this.setUd();
  286. this.reload();
  287. }.bind(this)
  288. }
  289. }).inject(this.itemSortArea);
  290. new Element('option',{ 'text': this.app.lp.sorkKeyNote, 'value': "" }).inject(this.itemSortSelect);
  291. this.options.sortKeys.each(function (key){
  292. var opt = new Element('option',{ 'text': this.app.lp[key] + " " + this.app.lp.asc, 'value': key+"-asc" }).inject(this.itemSortSelect);
  293. if( this.options.sortKey === opt.get('value') )opt.set('selected', true);
  294. opt = new Element('option',{ 'text': this.app.lp[key] + " " + this.app.lp.desc, 'value': key+"-desc" }).inject(this.itemSortSelect);
  295. if( this.options.sortKey === opt.get('value') )opt.set('selected', true);
  296. }.bind(this));
  297. },
  298. createSearchNode: function (){
  299. this.searchNode = new Element("div.searchNode", {
  300. "styles": this.css.searchArea
  301. }).inject(this.toolbarNode);
  302. this.searchInput = new Element("input.searchInput", {
  303. "styles": this.css.searchInput,
  304. "placeholder": this.app.lp.searchPlacholder,
  305. "value": this.options.searchKey || ""
  306. }).inject(this.searchNode);
  307. this.searchButton = new Element("i", {
  308. "styles": this.css.searchButton
  309. }).inject(this.searchNode);
  310. this.searchCancelButton = new Element("i", {
  311. "styles": this.css.searchCancelButton
  312. }).inject(this.searchNode);
  313. this.searchInput.addEvents({
  314. focus: function(){
  315. this.searchNode.addClass("mainColor_border");
  316. this.searchButton.addClass("mainColor_color");
  317. }.bind(this),
  318. blur: function () {
  319. this.searchNode.removeClass("mainColor_border");
  320. this.searchButton.removeClass("mainColor_color");
  321. }.bind(this),
  322. keydown: function (e) {
  323. if( (e.keyCode || e.code) === 13 ){
  324. this.search();
  325. }
  326. }.bind(this),
  327. keyup: function (e){
  328. this.searchCancelButton.setStyle('display', this.searchInput.get('value') ? '' : 'none');
  329. }.bind(this)
  330. });
  331. this.searchCancelButton.addEvent("click", function (e) {
  332. this.searchInput.set("value", "");
  333. this.searchCancelButton.hide();
  334. this.search();
  335. }.bind(this));
  336. this.searchButton.addEvent("click", function (e) {
  337. this.search();
  338. }.bind(this));
  339. },
  340. switchItemStyle: function(el){
  341. if( this.currentItemStyleSwitchItemNode ){
  342. var cur = this.currentItemStyleSwitchItemNode;
  343. cur.setStyle('background-image',"url('../x_component_process_ProcessManager/$Explorer/default/icon/"+cur.retrieve('sty')+".png')");
  344. }
  345. this.currentItemStyleSwitchItemNode = el;
  346. el.setStyle('background-image',"url('../x_component_process_ProcessManager/$Explorer/default/icon/"+el.retrieve('sty')+"_active.png')");
  347. if( el.retrieve('sty') !== this.options.itemStyle ){
  348. this.options.itemStyle = el.retrieve('sty');
  349. this.setUd();
  350. this.reload();
  351. }
  352. },
  353. showDeleteAction: function(){
  354. if (!this.deleteItemsAction){
  355. this.deleteItemsAction = new Element("div", {
  356. "styles": this.css.deleteItemsAction,
  357. "text": this.app.lp.deleteItems
  358. }).inject(this.node);
  359. this.deleteItemsAction.fade("in");
  360. this.deleteItemsAction.position({
  361. relativeTo: this.elementContentListNode
  362. });
  363. this.deleteItemsAction.setStyle("top","50%");
  364. this.deleteItemsAction.addEvent("click", function(){
  365. var _self = this;
  366. this.app.confirm("warn", this.deleteItemsAction, MWF.CMSCM.LP.deleteElementTitle, MWF.CMSCM.LP.deleteElement, 300, 120, function(){
  367. _self.deleteItems();
  368. this.close();
  369. }, function(){
  370. this.close();
  371. });
  372. }.bind(this));
  373. }
  374. },
  375. search: function (){
  376. var v = this.searchInput.get("value");
  377. this.options.searchKey = v;
  378. this.itemArray.each(function (i){
  379. if( !v ){
  380. i.node.setStyle("display", "");
  381. }else if( i.data.name.contains(v) || (i.data.alias || "").contains(v) || i.data.id.contains(v) ){
  382. i.node.setStyle("display", "");
  383. }else{
  384. i.node.setStyle("display", "none");
  385. }
  386. }.bind(this));
  387. },
  388. hideDeleteAction: function(){
  389. if (this.deleteItemsAction) this.deleteItemsAction.destroy();
  390. delete this.deleteItemsAction;
  391. },
  392. _createElement: function(e){
  393. },
  394. _loadItemDataList: function(callback){
  395. this.app.restActions.listCategory(this.app.options.column.id,callback);
  396. },
  397. _getItemObject: function(item, index){
  398. return MWF.xApplication.cms.ColumnManager.Explorer.Item(this, item, {index : index })
  399. },
  400. destroy: function(){
  401. if( this.itemArray && this.itemArray.length ){
  402. this.itemArray.each(function (item){
  403. if(item.destroy)item.destroy();
  404. });
  405. }
  406. this.node.destroy();
  407. o2.release(this);
  408. }
  409. });
  410. MWF.xApplication.cms.ColumnManager.Explorer.Item = new Class({
  411. Implements: [Options],
  412. options: {
  413. "where": "bottom",
  414. "index" : 1
  415. },
  416. initialize: function(explorer, item, options ){
  417. this.setOptions(options);
  418. this.explorer = explorer;
  419. this.data = item;
  420. this.container = this.explorer.elementContentListNode;
  421. this.css = this.explorer.css;
  422. this.icon = this._getIcon();
  423. },
  424. load: function(){
  425. if( this.explorer.options.itemStyle === 'card' ){
  426. this.itemNodeCss = this.css.itemNode_card;
  427. }else{
  428. this.itemNodeCss = this.options.index % 2 === 0 ? this.css.itemNode_even : this.css.itemNode;
  429. }
  430. this.node = new Element("div", {
  431. "styles": this.itemNodeCss,
  432. "events": {
  433. "click": function(e){this._open(e);e.stopPropagation();}.bind(this),
  434. "mouseover": function(){
  435. if( !this.isSelected )this.node.setStyles( this.css.itemNode_over );
  436. if(this.deleteActionNode)this.deleteActionNode.fade("in");
  437. if (this.saveasActionNode) this.saveasActionNode.fade("in");
  438. }.bind(this),
  439. "mouseout": function(){
  440. if( !this.isSelected )this.node.setStyles( this.itemNodeCss );
  441. if(this.deleteActionNode)this.deleteActionNode.fade("out");
  442. if (this.saveasActionNode) this.saveasActionNode.fade("out");
  443. }.bind(this)
  444. }
  445. }).inject(this.container,this.options.where);
  446. if (this.data.icon) this.icon = this.data.icon;
  447. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  448. var itemIconNode = new Element("div", {
  449. "styles": this.explorer.options.itemStyle === 'card' ? this.css.itemIconNode_card : this.css.itemIconNode
  450. }).inject(this.node);
  451. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  452. //new Element("img", {
  453. // "src": iconUrl, "border": "0"
  454. //}).inject(itemIconNode);
  455. itemIconNode.makeLnk({
  456. "par": this._getLnkPar()
  457. });
  458. itemIconNode.addEvent("click", function(e){
  459. this.toggleSelected();
  460. e.stopPropagation();
  461. }.bind(this));
  462. this.actionsArea = new Element("div.actionsArea",{
  463. styles : this.explorer.css.actionsArea
  464. }).inject(this.node);
  465. this.saveasActionNode = new Element("div", {
  466. "styles": this.explorer.css.saveasActionNode,
  467. "title": this.explorer.app.lp.copy
  468. }).inject(this.actionsArea);
  469. this.saveasActionNode.addEvent("click", function(e){
  470. this.saveas(e);
  471. e.stopPropagation();
  472. }.bind(this));
  473. // this.saveasActionNode.addEvents({
  474. // "mouseover" : function(ev){
  475. // this.saveasActionNode.setStyles( this.explorer.css.saveasActionNode_over )
  476. // }.bind(this),
  477. // "mouseout" : function(ev){
  478. // this.saveasActionNode.setStyles( this.explorer.css.saveasActionNode )
  479. // }.bind(this)
  480. // });
  481. if (!this.explorer.options.noDelete){
  482. this.deleteActionNode = new Element("div.deleteAction", {
  483. "styles": this.explorer.css.deleteAction
  484. }).inject(this.actionsArea);
  485. this.deleteActionNode.addEvent("click", function(e){
  486. this.deleteItem(e);
  487. e.stopPropagation();
  488. }.bind(this));
  489. // this.deleteActionNode.addEvents({
  490. // "mouseover" : function(ev){
  491. // this.deleteActionNode.setStyles( this.explorer.css.deleteAction_over )
  492. // }.bind(this),
  493. // "mouseout" : function(ev){
  494. // this.deleteActionNode.setStyles( this.explorer.css.deleteAction )
  495. // }.bind(this)
  496. // })
  497. }
  498. this.explorer.options.itemStyle === 'card' ? this.createTextNodes_card() : this.createTextNodes();
  499. this._isNew();
  500. this.createInforNode();
  501. },
  502. createTextNodes_card: function(){
  503. new Element("div", {
  504. "styles": this.css.itemTextTitleNode_card,
  505. "text": this.data.name,
  506. "title": this.data.name,
  507. "events": {
  508. "click": function(e){this._open(e);}.bind(this)
  509. }
  510. }).inject(this.node);
  511. new Element("div", {
  512. "styles": this.css.itemTextDescriptionNode_card,
  513. "text": this.data.description || "",
  514. "title": this.data.description || ""
  515. }).inject(this.node);
  516. new Element("div", {
  517. "styles": this.css.itemTextDateNode_card,
  518. "text": (this.data.updateTime || "")
  519. }).inject(this.node);
  520. },
  521. createTextNodes: function(){
  522. var inforNode = new Element("div.itemInforNode", {
  523. "styles": this.explorer.css.itemInforNode
  524. }).inject(this.node);
  525. var inforBaseNode = new Element("div.itemInforBaseNode", {
  526. "styles": this.explorer.css.itemInforBaseNode
  527. }).inject(inforNode);
  528. new Element("div.itemTextTitleNode", {
  529. "styles": this.explorer.css.itemTextTitleNode,
  530. "text": this.data.name,
  531. "title": this.data.name
  532. }).inject(inforBaseNode);
  533. new Element("div.itemTextAliasNode", {
  534. "styles": this.explorer.css.itemTextAliasNode,
  535. "text": this.data.alias,
  536. "title": this.data.alias
  537. }).inject(inforBaseNode);
  538. new Element("div.itemTextDateNode", {
  539. "styles": this.explorer.css.itemTextDateNode,
  540. "text": (this.data.updateTime || "")
  541. }).inject(inforBaseNode);
  542. new Element("div.itemTextDescriptionNode", {
  543. "styles": this.explorer.css.itemTextDescriptionNode,
  544. "text": this.data.description || "",
  545. "title": this.data.description || ""
  546. }).inject(inforBaseNode);
  547. //new Element("div", {
  548. // "styles": this.explorer.css.itemTextTitleNode,
  549. // "text": this.data.name,
  550. // "title": this.data.name,
  551. // "events": {
  552. // "click": function(e){this._open(e);}.bind(this)
  553. // }
  554. //}).inject(this.node);
  555. //
  556. //new Element("div", {
  557. // "styles": this.explorer.css.itemTextDescriptionNode,
  558. // "text": this.data.description || "",
  559. // "title": this.data.description || ""
  560. //}).inject(this.node);
  561. //
  562. //new Element("div", {
  563. // "styles": this.explorer.css.itemTextDateNode,
  564. // "text": (this.data.updateTime || "")
  565. //}).inject(this.node);
  566. },
  567. deleteItem: function(){
  568. if (!this.deleteMode){
  569. this.deleteMode = true;
  570. this.node.setStyle("background-color", "#ffb7b7");
  571. this.deleteActionNode.setStyle("background-image", "url("+"../x_component_cms_ColumnManager/$Explorer/default/processIcon/deleteProcess_red1.png)");
  572. this.deleteActionNode.removeEvents("mouseover");
  573. this.deleteActionNode.removeEvents("mouseout");
  574. this.node.removeEvents("mouseover");
  575. this.node.removeEvents("mouseout");
  576. this.explorer.deleteMarkItems.push(this);
  577. }else{
  578. this.deleteMode = false;
  579. this.node.setStyle("background", "#FFF");
  580. this.deleteActionNode.setStyles( this.explorer.css.deleteAction );
  581. this.deleteActionNode.addEvents({
  582. "mouseover" : function(ev){
  583. this.deleteActionNode.setStyles( this.explorer.css.deleteAction_over )
  584. }.bind(this),
  585. "mouseout" : function(ev){
  586. this.deleteActionNode.setStyles( this.explorer.css.deleteAction )
  587. }.bind(this)
  588. });
  589. this.node.addEvents({"mouseover": function(){
  590. this.node.setStyles( this.explorer.css.itemNode_over )
  591. }.bind(this),
  592. "mouseout": function(){
  593. this.node.setStyles( this.itemNodeCss )
  594. }.bind(this)
  595. });
  596. this.explorer.deleteMarkItems.erase(this);
  597. }
  598. if (this.explorer.deleteMarkItems.length){
  599. this.explorer.showDeleteAction();
  600. }else{
  601. this.explorer.hideDeleteAction();
  602. }
  603. },
  604. deleteItems: function(){},
  605. _open: function(e){
  606. var _self = this;
  607. var options = {
  608. "onQueryLoad": function(){
  609. this.actions = _self.explorer.actions;
  610. this.category = _self;
  611. this.options.id = _self.data.id;
  612. this.column = _self.explorer.app.options.column;
  613. this.application = _self.explorer.app.options.column;
  614. }
  615. };
  616. this.explorer.app.desktop.openApplication(e, "cms.ProcessDesigner", options);
  617. },
  618. _getIcon: function(){
  619. var x = (Math.random()*33).toInt();
  620. return "process_icon_"+x+".png";
  621. },
  622. _getLnkPar: function(){
  623. return {
  624. "icon": this.explorer.path+this.explorer.options.style+"/processIcon/lnk.png",
  625. "title": this.data.name,
  626. "par": "ProcessDesigner#{\"id\": \""+this.data.id+"\"}"
  627. };
  628. },
  629. _isNew: function(){
  630. if (this.data.updateTime){
  631. var createDate = Date.parse(this.data.updateTime);
  632. var currentDate = new Date();
  633. if (createDate.diff(currentDate, "hour")<12) {
  634. this.newNode = new Element("div", {
  635. "styles": this.explorer.options.itemStyle === 'card' ? this.css.itemNewNode_card : this.css.itemNewNode
  636. }).inject(this.node);
  637. this.newNode.addEvent("click", function(e){
  638. this.toggleSelected();
  639. e.stopPropagation();
  640. }.bind(this));
  641. }
  642. }
  643. },
  644. toggleSelected: function(){
  645. if (this.isSelected){
  646. this.unSelected();
  647. }else{
  648. this.selected();
  649. }
  650. },
  651. checkShowCopyInfor: function(){
  652. if (this.explorer.selectMarkItems.length===1){
  653. this.explorer.app.notice(this.explorer.app.lp.copyInfor, "infor");
  654. }
  655. },
  656. selected: function(){
  657. if (this.deleteMode) this.deleteItem();
  658. this.isSelected = true;
  659. this.node.setStyles(this.explorer.css.itemNode_selected);
  660. this.explorer.selectMarkItems.push(this);
  661. this.checkShowCopyInfor();
  662. },
  663. unSelected: function(){
  664. this.isSelected = false;
  665. this.node.setStyles(this.explorer.css.itemNode);
  666. this.explorer.selectMarkItems.erase(this);
  667. },
  668. saveas: function(){
  669. MWF.xDesktop.requireApp("Selector", "package", function(){
  670. var app = this.explorer.app.options.application;
  671. app.name = app.appName;
  672. var selector = new MWF.O2Selector(this.explorer.app.content, {
  673. "title": this.explorer.app.lp.copyto,
  674. "type": "CMSApplication",
  675. "values": [app],
  676. "onComplete": function(items){
  677. items.each(function(item){
  678. this.saveItemAs(item.data);
  679. }.bind(this));
  680. }.bind(this),
  681. });
  682. }.bind(this));
  683. },
  684. createInforNode: function(callback){
  685. var lp = this.explorer.app.lp;
  686. this.inforNode = new Element("div");
  687. var wrapNode = new Element("div", {
  688. style: 'display: grid; grid-template-columns: 60px auto; line-height:20px;'
  689. }).inject(this.inforNode);
  690. var html = "<div style='grid-column: 1 / -1; font-weight: bold'>"+this.data.name+"</div>";
  691. html += "<div style='font-weight: bold'>"+lp.alias+": </div><div style='margin-left:10px'>"+( this.data.alias || "" )+"</div>";
  692. html += "<div style='font-weight: bold'>"+lp.createTime+": </div><div style='margin-left:10px'>"+(this.data.createTime || "")+"</div>";
  693. html += "<div style='font-weight: bold'>"+lp.updateTime+": </div><div style='float:left; margin-left:10px'>"+(this.data.updateTime||"")+"</div>";
  694. html += "<div style='font-weight: bold'>"+lp.description+": </div><div style='float:left; margin-left:10px'>"+(this.data.description||"")+"</div>";
  695. wrapNode.set("html", html);
  696. this.tooltip = new MWF.xApplication.cms.ColumnManager.Explorer.Item.Tooltip(this.explorer.app.content, this.node, this.explorer.app, {}, {
  697. axis : "y",
  698. hiddenDelay : 300,
  699. displayDelay : 200
  700. });
  701. this.tooltip.inforNode = this.inforNode;
  702. },
  703. });
  704. MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
  705. MWF.xApplication.cms.ColumnManager.Explorer.Item.Tooltip = new Class({
  706. Extends: MTooltips,
  707. options:{
  708. nodeStyles: {
  709. "font-size" : "12px",
  710. "position" : "absolute",
  711. "max-width" : "500px",
  712. "min-width" : "180px",
  713. "z-index" : "1001",
  714. "background-color" : "#fff",
  715. "padding" : "10px",
  716. "border-radius" : "8px",
  717. "box-shadow": "0 0 12px 0 #999999",
  718. "-webkit-user-select": "text",
  719. "-moz-user-select": "text"
  720. },
  721. isFitToContainer : true,
  722. overflow : "scroll"
  723. },
  724. _loadCustom : function( callback ){
  725. if(callback)callback();
  726. },
  727. _customNode : function( node, contentNode ){
  728. this.inforNode.inject(contentNode);
  729. if( this.inforNode.getSize().y > 300 ){
  730. this.inforNode.setStyle("padding-bottom", "15px");
  731. }
  732. this.fireEvent("customContent", [contentNode, node]);
  733. }
  734. });