Viewer.js 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084
  1. MWF.xApplication.query = MWF.xApplication.query || {};
  2. MWF.xApplication.query.Query = MWF.xApplication.query.Query || {};
  3. MWF.require("MWF.widget.Common", null, false);
  4. MWF.require("MWF.xScript.Macro", null, false);
  5. MWF.xDesktop.requireApp("query.Query", "lp.zh-cn", null, false);
  6. MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
  7. Implements: [Options, Events],
  8. Extends: MWF.widget.Common,
  9. options: {
  10. "style": "default",
  11. "resizeNode": true,
  12. "paging" : "scroll",
  13. "perPageCount" : 50,
  14. "isload": "true"
  15. // "actions": {
  16. // "lookup": {"uri": "/jaxrs/view/flag/{view}/query/{application}/execute", "method":"PUT"},
  17. // "getView": {"uri": "/jaxrs/view/flag/{view}/query/{application}"}
  18. //
  19. // },
  20. // "actionRoot": "x_query_assemble_surface"
  21. },
  22. initialize: function(container, json, options){
  23. this.setOptions(options);
  24. this.path = "/x_component_query_Query/$Viewer/";
  25. this.cssPath = "/x_component_query_Query/$Viewer/"+this.options.style+"/css.wcss";
  26. this._loadCss();
  27. this.lp = MWF.xApplication.query.Query.LP;
  28. this.container = $(container);
  29. this.json = json;
  30. this.viewJson = null;
  31. this.filterItems = [];
  32. this.searchStatus = "none"; //none, custom, default
  33. this.items = [];
  34. this.selectedItems = [];
  35. this.hideColumns = [];
  36. this.openColumns = [];
  37. this.gridJson = null;
  38. if (this.options.isload){
  39. this.init(function(){
  40. this.load();
  41. }.bind(this));
  42. }
  43. },
  44. loadView: function(){
  45. if (this.viewJson){
  46. this.reload();
  47. }else{
  48. this.init(function(){
  49. this.load();
  50. }.bind(this));
  51. }
  52. },
  53. init: function(callback){
  54. debugger;
  55. if (this.json.data){
  56. this.viewJson = JSON.decode(this.json.data);
  57. if (callback) callback();
  58. }else{
  59. this.getView(callback);
  60. }
  61. },
  62. load: function(){
  63. this.loadLayout();
  64. this.createSearchNode();
  65. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  66. if (this.options.resizeNode){
  67. this.setContentHeightFun = this.setContentHeight.bind(this);
  68. this.container.addEvent("resize", this.setContentHeightFun);
  69. this.setContentHeightFun();
  70. }
  71. },
  72. loadLayout: function(){
  73. this.node = new Element("div", {"styles": this.css.node}).inject(this.container);
  74. this.searchAreaNode = new Element("div", {"styles": this.css.searchAreaNode}).inject(this.node);
  75. this.viewAreaNode = new Element("div", {"styles": this.css.viewAreaNode}).inject(this.node);
  76. },
  77. createSearchNode: function(){
  78. if (this.viewJson.customFilterList && this.viewJson.customFilterList.length){
  79. this.searchStatus = "default";
  80. this.loadFilterSearch();
  81. }else{
  82. this.loadSimpleSearch();
  83. }
  84. },
  85. loadSimpleSearch: function(){
  86. this.searchSimpleNode = new Element("div", {"styles": this.css.searchSimpleNode}).inject(this.searchAreaNode);
  87. this.searchSimpleButtonNode = new Element("div", {"styles": this.css.searchSimpleButtonNode}).inject(this.searchSimpleNode);
  88. this.searchSimpleInputNode = new Element("input", {"type":"text", "styles": this.css.searchSimpleInputNode, "value": this.lp.searchKeywork}).inject(this.searchSimpleNode);
  89. this.searchSimpleButtonNode.addEvent("click", function(){
  90. this.search();
  91. }.bind(this));
  92. this.searchSimpleInputNode.addEvents({
  93. "focus": function(){
  94. if (this.searchSimpleInputNode.get("value")===this.lp.searchKeywork) this.searchSimpleInputNode.set("value", "");
  95. }.bind(this),
  96. "blur": function(){if (!this.searchSimpleInputNode.get("value")) this.searchSimpleInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  97. "keydown": function(e){
  98. if (e.code===13) this.search();
  99. }.bind(this)
  100. });
  101. },
  102. search: function(){
  103. if (this.gridJson){
  104. var key = this.searchSimpleInputNode.get("value");
  105. var rows = this.viewTable.rows;
  106. var first = (this.json.isTitle!=="no") ? 1 : 0;
  107. for (var i = first; i<rows.length; i++){
  108. var tr = rows[i];
  109. if (!key || key==this.lp.searchKeywork){
  110. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  111. }else{
  112. if (tr.get("text").indexOf(key)!==-1){
  113. if (tr.getStyle("display")==="none") tr.setStyle("display", "table-row");
  114. }else{
  115. if (tr.getStyle("display")!=="none") tr.setStyle("display", "none");
  116. }
  117. }
  118. }
  119. }
  120. },
  121. loadFilterSearch: function(){
  122. this.viewSearchCustomActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomActionNode, "text": this.lp.customSearch}).inject(this.searchAreaNode);
  123. this.viewSearchInputAreaNode = new Element("div", {"styles": this.css.viewFilterSearchInputAreaNode}).inject(this.searchAreaNode);
  124. this.viewSearchIconNode = new Element("div", {"styles": this.css.viewFilterSearchIconNode}).inject(this.viewSearchInputAreaNode);
  125. this.viewSearchInputBoxNode = new Element("div", {"styles": this.css.viewFilterSearchInputBoxNode}).inject(this.viewSearchInputAreaNode);
  126. this.viewSearchInputNode = new Element("input", {"styles": this.css.viewFilterSearchInputNode, "value": this.lp.searchKeywork}).inject(this.viewSearchInputBoxNode);
  127. this.viewSearchInputNode.addEvents({
  128. "focus": function(){
  129. if (this.viewSearchInputNode.get("value")===this.lp.searchKeywork) this.viewSearchInputNode.set("value", "");
  130. }.bind(this),
  131. "blur": function(){if (!this.viewSearchInputNode.get("value")) this.viewSearchInputNode.set("value", this.lp.searchKeywork);}.bind(this),
  132. "keydown": function(e){
  133. if (e.code===13) this.searchView();
  134. }.bind(this)
  135. });
  136. this.viewSearchIconNode.addEvents({
  137. "click": function(){this.searchView();}.bind(this)
  138. });
  139. this.viewSearchCustomActionNode.addEvents({
  140. "click": function(){this.loadCustomSearch();}.bind(this)
  141. });
  142. },
  143. searchView: function(){
  144. if (this.viewJson.customFilterList){
  145. var key = this.viewSearchInputNode.get("value");
  146. if (key && key!==this.lp.searchKeywork){
  147. var filterData = this.json.filter ? this.json.filter : [];
  148. this.viewJson.customFilterList.each(function(entry){
  149. if (entry.formatType==="textValue"){
  150. var d = {
  151. "path": entry.path,
  152. "value": key,
  153. "formatType": entry.formatType,
  154. "logic": "or",
  155. "comparison": "like"
  156. };
  157. filterData.push(d);
  158. }
  159. if (entry.formatType==="numberValue"){
  160. var v = key.toFloat();
  161. if (!isNaN(v)){
  162. var d = {
  163. "path": entry.path,
  164. "value": v,
  165. "formatType": entry.formatType,
  166. "logic": "or",
  167. "comparison": "like"
  168. };
  169. filterData.push(d);
  170. }
  171. }
  172. }.bind(this));
  173. this.createViewNode({"filterList": filterData});
  174. }
  175. }
  176. },
  177. searchCustomView: function(){
  178. if (this.filterItems.length){
  179. var filterData = this.json.filter ? this.json.filter.clone() : [];
  180. this.filterItems.each(function(filter){
  181. filterData.push(filter.data);
  182. }.bind(this));
  183. this.createViewNode({"filterList": filterData});
  184. }else{
  185. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  186. }
  187. },
  188. loadCustomSearch: function(){
  189. this.viewSearchIconNode.setStyle("display", "none");
  190. this.viewSearchInputBoxNode.setStyle("display", "none");
  191. this.viewSearchCustomActionNode.setStyle("display", "none");
  192. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  193. var x = this.viewSearchInputAreaNode.getParent().getSize().x-2-20;
  194. this.css.viewFilterSearchInputAreaNode_custom.width = ""+x+"px";
  195. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  196. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  197. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode_custom).chain(function(){
  198. this.searchStatus = "custom";
  199. this.css.viewFilterSearchInputAreaNode_custom.width = "auto";
  200. this.viewSearchInputAreaNode.setStyle("width", "auto");
  201. if (this.viewSearchCustomContentNode){
  202. this.viewSearchCustomCloseActionNode.setStyle("display", "block");
  203. this.viewSearchCustomContentNode.setStyle("display", "block");
  204. }else{
  205. this.loadCustomSearchContent();
  206. }
  207. this.setContentHeightFun();
  208. }.bind(this));
  209. this.searchCustomView();
  210. },
  211. loadCustomSearchContent: function(){
  212. this.viewSearchCustomCloseActionNode = new Element("div", {"styles": this.css.viewFilterSearchCustomCloseActionNode}).inject(this.viewSearchInputAreaNode);
  213. this.viewSearchCustomContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomContentNode}).inject(this.viewSearchInputAreaNode);
  214. this.viewSearchCustomPathContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomPathContentNode}).inject(this.viewSearchCustomContentNode);
  215. this.viewSearchCustomComparisonContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomComparisonContentNode}).inject(this.viewSearchCustomContentNode);
  216. this.viewSearchCustomValueContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomValueContentNode}).inject(this.viewSearchCustomContentNode);
  217. this.viewSearchCustomAddContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddContentNode}).inject(this.viewSearchCustomContentNode);
  218. this.viewSearchCustomAddIconNode = new Element("div", {"styles": this.css.viewFilterSearchCustomAddIconNode}).inject(this.viewSearchCustomAddContentNode);
  219. this.viewSearchCustomFilterContentNode = new Element("div", {"styles": this.css.viewFilterSearchCustomFilterContentNode}).inject(this.viewSearchCustomContentNode);
  220. this.loadViewSearchCustomList();
  221. this.viewSearchCustomCloseActionNode.addEvents({
  222. "click": function(){this.closeCustomSearch();}.bind(this)
  223. });
  224. this.viewSearchCustomAddIconNode.addEvents({
  225. "click": function(){this.viewSearchCustomAddToFilter();}.bind(this)
  226. });
  227. },
  228. loadViewSearchCustomList: function(){
  229. this.viewSearchCustomPathListNode = new Element("select", {
  230. "styles": this.css.viewFilterSearchCustomPathListNode,
  231. "multiple": true
  232. }).inject(this.viewSearchCustomPathContentNode);
  233. this.viewSearchCustomComparisonListNode = new Element("select", {
  234. "styles": this.css.viewFilterSearchCustomComparisonListNode,
  235. "multiple": true
  236. }).inject(this.viewSearchCustomComparisonContentNode);
  237. this.viewJson.customFilterList.each(function(entry){
  238. var option = new Element("option", {
  239. "style": this.css.viewFilterSearchOptionNode,
  240. "value": entry.path,
  241. "text": entry.title
  242. }).inject(this.viewSearchCustomPathListNode);
  243. option.store("entry", entry);
  244. }.bind(this));
  245. this.viewSearchCustomPathListNode.addEvent("change", function(){
  246. this.loadViewSearchCustomComparisonList();
  247. }.bind(this));
  248. },
  249. loadViewSearchCustomComparisonList: function(){
  250. var idx = this.viewSearchCustomPathListNode.selectedIndex;
  251. var option = this.viewSearchCustomPathListNode.options[idx];
  252. var entry = option.retrieve("entry");
  253. if (entry){
  254. switch (entry.formatType){
  255. case "numberValue":
  256. this.loadComparisonSelect(this.lp.numberFilter);
  257. this.loadViewSearchCustomValueNumberInput();
  258. break;
  259. case "dateTimeValue":
  260. this.loadComparisonSelect(this.lp.dateFilter);
  261. this.loadViewSearchCustomValueDateInput();
  262. break;
  263. case "booleanValue":
  264. this.loadComparisonSelect(this.lp.booleanFilter);
  265. this.loadViewSearchCustomValueBooleanInput();
  266. break;
  267. default:
  268. this.loadComparisonSelect(this.lp.textFilter);
  269. this.loadViewSearchCustomValueTextInput();
  270. }
  271. }
  272. },
  273. loadViewSearchCustomValueNumberInput: function(){
  274. this.viewSearchCustomValueContentNode.empty();
  275. this.viewSearchCustomValueNode = new Element("input", {
  276. "styles": this.css.viewFilterSearchCustomValueNode,
  277. "type": "number"
  278. }).inject(this.viewSearchCustomValueContentNode);
  279. },
  280. loadViewSearchCustomValueDateInput: function(){
  281. this.viewSearchCustomValueContentNode.empty();
  282. this.viewSearchCustomValueNode = new Element("input", {
  283. "styles": this.css.viewFilterSearchCustomValueNode,
  284. "type": "text",
  285. "readonly": true
  286. }).inject(this.viewSearchCustomValueContentNode);
  287. MWF.require("MWF.widget.Calendar", function(){
  288. this.calendar = new MWF.widget.Calendar(this.viewSearchCustomValueNode, {
  289. "style": "xform",
  290. "isTime": true,
  291. "target": this.container,
  292. "format": "db"
  293. });
  294. }.bind(this));
  295. },
  296. loadViewSearchCustomValueBooleanInput: function(){
  297. this.viewSearchCustomValueContentNode.empty();
  298. this.viewSearchCustomValueNode = new Element("select", {
  299. "styles": this.css.viewFilterSearchCustomValueSelectNode,
  300. "multiple": true
  301. }).inject(this.viewSearchCustomValueContentNode);
  302. new Element("option", {"value": "true","text": this.lp.yes}).inject(this.viewSearchCustomValueNode);
  303. new Element("option", {"value": "false","text": this.lp.no}).inject(this.viewSearchCustomValueNode);
  304. },
  305. loadViewSearchCustomValueTextInput: function(){
  306. this.viewSearchCustomValueContentNode.empty();
  307. this.viewSearchCustomValueNode = new Element("textarea", {
  308. "styles": this.css.viewFilterSearchCustomValueNode
  309. }).inject(this.viewSearchCustomValueContentNode);
  310. },
  311. loadComparisonSelect:function(obj){
  312. this.viewSearchCustomComparisonListNode.empty();
  313. Object.each(obj, function(v, k){
  314. var option = new Element("option", {"value": k,"text": v}).inject(this.viewSearchCustomComparisonListNode);
  315. }.bind(this));
  316. },
  317. closeCustomSearch: function(){
  318. if (this.viewSearchCustomContentNode && this.viewSearchCustomContentNode.getStyle("display")==="block"){
  319. this.viewSearchCustomCloseActionNode.setStyle("display", "none");
  320. this.viewSearchCustomContentNode.setStyle("display", "none");
  321. var x = this.viewSearchInputAreaNode.getParent().getSize().x;
  322. x1 = x-2-10-90;
  323. this.css.viewFilterSearchInputAreaNode.width = ""+x1+"px";
  324. var x1 = this.viewSearchInputAreaNode.getSize().x-2;
  325. this.viewSearchInputAreaNode.setStyle("width", ""+x1+"px");
  326. if (!this.searchMorph) this.searchMorph = new Fx.Morph(this.viewSearchInputAreaNode);
  327. this.searchMorph.start(this.css.viewFilterSearchInputAreaNode).chain(function(){
  328. this.searchStatus = "default";
  329. this.css.viewFilterSearchInputAreaNode.width = "auto";
  330. this.viewSearchInputAreaNode.setStyle("margin-right", "90px");
  331. this.viewSearchIconNode.setStyle("display", "block");
  332. this.viewSearchInputBoxNode.setStyle("display", "block");
  333. this.viewSearchCustomActionNode.setStyle("display", "block");
  334. this.setContentHeightFun();
  335. }.bind(this));
  336. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  337. }
  338. },
  339. viewSearchCustomAddToFilter: function(){
  340. var pathIdx = this.viewSearchCustomPathListNode.selectedIndex;
  341. var comparisonIdx = this.viewSearchCustomComparisonListNode.selectedIndex;
  342. if (pathIdx===-1){
  343. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorTitle, this.viewSearchCustomPathListNode, {"x": 0, "y": 85});
  344. return false;
  345. }
  346. if (comparisonIdx===-1){
  347. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorComparison, this.viewSearchCustomComparisonListNode, {"x": 0, "y": 85});
  348. return false;
  349. }
  350. var pathOption = this.viewSearchCustomPathListNode.options[pathIdx];
  351. var entry = pathOption.retrieve("entry");
  352. if (entry){
  353. var pathTitle = entry.title;
  354. var path = entry.path;
  355. var comparison = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("value");
  356. var comparisonTitle = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("text");
  357. var value = "";
  358. switch (entry.formatType){
  359. case "numberValue":
  360. value = this.viewSearchCustomValueNode.get("value");
  361. break;
  362. case "dateTimeValue":
  363. value = this.viewSearchCustomValueNode.get("value");
  364. break;
  365. case "booleanValue":
  366. var idx = this.viewSearchCustomValueNode.selectedIndex;
  367. if (idx!==-1){
  368. var v = this.viewSearchCustomValueNode.options[idx].get("value");
  369. value = (v==="true");
  370. }
  371. break;
  372. default:
  373. value = this.viewSearchCustomValueNode.get("value");
  374. }
  375. if (value===""){
  376. MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85});
  377. return false;
  378. }
  379. this.filterItems.push(new MWF.xApplication.query.Query.Viewer.Filter(this, {
  380. "logic": "and",
  381. "path": path,
  382. "title": pathTitle,
  383. "comparison": comparison,
  384. "comparisonTitle": comparisonTitle,
  385. "value": value,
  386. "formatType": entry.formatType
  387. }, this.viewSearchCustomFilterContentNode));
  388. this.searchCustomView();
  389. }
  390. },
  391. searchViewRemoveFilter: function(filter){
  392. debugger;
  393. this.filterItems.erase(filter);
  394. filter.destroy();
  395. this.searchCustomView()
  396. },
  397. setContentHeight: function(){
  398. var size = this.node.getSize();
  399. var searchSize = this.searchAreaNode.getSize();
  400. var h = size.y-searchSize.y;
  401. this.viewAreaNode.setStyle("height", ""+h+"px");
  402. },
  403. createLoadding: function(){
  404. this.loadingAreaNode = new Element("div", {"styles": this.css.viewLoadingAreaNode}).inject(this.contentAreaNode);
  405. new Element("div", {"styles": {"height": "5px"}}).inject(this.loadingAreaNode);
  406. var loadingNode = new Element("div", {"styles": this.css.viewLoadingNode}).inject(this.loadingAreaNode);
  407. new Element("div", {"styles": this.css.viewLoadingIconNode}).inject(loadingNode);
  408. var loadingTextNode = new Element("div", {"styles": this.css.viewLoadingTextNode}).inject(loadingNode);
  409. loadingTextNode.set("text", "loading...");
  410. },
  411. createViewNode: function(data){
  412. this.viewAreaNode.empty();
  413. this.contentAreaNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.viewAreaNode);
  414. this.viewTable = new Element("table", {
  415. "styles": this.css.viewTitleTableNode,
  416. "border": "0px",
  417. "cellPadding": "0",
  418. "cellSpacing": "0"
  419. }).inject(this.contentAreaNode);
  420. this.createLoadding();
  421. if (this.json.isTitle!=="no"){
  422. this.viewTitleLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
  423. //if (this.json.select==="single" || this.json.select==="multi") {
  424. this.selectTitleCell = new Element("td", {
  425. "styles": this.css.viewTitleCellNode
  426. }).inject(this.viewTitleLine);
  427. this.selectTitleCell.setStyle("width", "10px");
  428. if (this.json.titleStyles) this.selectTitleCell.setStyles(this.json.titleStyles);
  429. //}
  430. this.entries = {};
  431. this.viewJson.selectList.each(function(column){
  432. this.entries[column.column] = column;
  433. if (!column.hideColumn){
  434. var viewCell = new Element("td", {
  435. "styles": this.css.viewTitleCellNode,
  436. "text": column.displayName
  437. }).inject(this.viewTitleLine);
  438. var size = MWF.getTextSize(column.displayName, this.css.viewTitleCellNode);
  439. viewCell.setStyle("min-width", ""+size.x+"px");
  440. if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
  441. }else{
  442. this.hideColumns.push(column.column);
  443. }
  444. if (column.allowOpen) this.openColumns.push(column.column);
  445. }.bind(this));
  446. this.lookup(data);
  447. }else{
  448. this.viewJson.selectList.each(function(column){
  449. if (column.hideColumn) this.hideColumns.push(column.column);
  450. if (!column.allowOpen) this.openColumns.push(column.column);
  451. }.bind(this));
  452. this.lookup(data);
  453. }
  454. },
  455. lookup: function(data){
  456. this.getLookupAction(function(){
  457. if (this.json.application){
  458. this.lookupAction.loadView(this.json.name, this.json.application, (data || null), function(json){
  459. this.viewData = json.data;
  460. if (this.viewJson.group.column){
  461. this.gridJson = json.data.groupGrid;
  462. this.loadGroupData();
  463. }else{
  464. this.gridJson = json.data.grid;
  465. this.loadData();
  466. }
  467. if (this.loadingAreaNode){
  468. this.loadingAreaNode.destroy();
  469. this.loadingAreaNode = null;
  470. }
  471. }.bind(this));
  472. // this.lookupAction.invoke({"name": "lookup","async": true, "data": (data || null), "parameter": {"view": this.json.name, "application": this.json.application},"success": function(json){
  473. // this.viewData = json.data;
  474. // if (this.viewJson.group.column){
  475. // this.gridJson = json.data.groupGrid;
  476. // this.loadGroupData();
  477. // }else{
  478. // this.gridJson = json.data.grid;
  479. // this.loadData();
  480. // }
  481. // if (this.loadingAreaNode){
  482. // this.loadingAreaNode.destroy();
  483. // this.loadingAreaNode = null;
  484. // }
  485. // }.bind(this)});
  486. }
  487. }.bind(this));
  488. },
  489. loadData: function(){
  490. if (this.gridJson.length){
  491. if( !this.options.paging ){
  492. this.gridJson.each(function(line, i){
  493. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, line, null, i));
  494. }.bind(this));
  495. }else{
  496. this.loadPaging();
  497. }
  498. }
  499. },
  500. loadPaging : function(){
  501. this.isItemsLoading = false;
  502. this.pageNumber = 0;
  503. this.isItemsLoaded = false;
  504. this.isSetedScroll = false;
  505. this.setScroll();
  506. this.loadDataByPaging()
  507. },
  508. setScroll : function(){
  509. if( this.options.paging && !this.isSetedScroll ){
  510. this.contentAreaNode.setStyle("overflow","auto");
  511. this.scrollContainerFun = function(){
  512. var scrollSize = this.contentAreaNode.getScrollSize();
  513. var clientSize = this.contentAreaNode.getSize();
  514. var scrollHeight = scrollSize.y - clientSize.y;
  515. //alert( "clientSize.y=" + clientSize.y + " scrollSize.y="+scrollSize.y + " this.contentAreaNode.scrollTop="+this.contentAreaNode.scrollTop);
  516. if (this.contentAreaNode.scrollTop + 150 > scrollHeight ) {
  517. if (!this.isItemsLoaded) this.loadDataByPaging();
  518. }
  519. }.bind(this);
  520. this.isSetedScroll = true;
  521. this.contentAreaNode.addEvent("scroll", this.scrollContainerFun )
  522. }
  523. },
  524. loadDataByPaging : function(){
  525. if( this.isItemsLoading )return;
  526. if( !this.isItemsLoaded ){
  527. var from = Math.min( this.pageNumber * this.options.perPageCount , this.gridJson.length);
  528. var to = Math.min( ( this.pageNumber + 1 ) * this.options.perPageCount + 1 , this.gridJson.length);
  529. this.isItemsLoading = true;
  530. for( var i = from; i<to; i++ ){
  531. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this, this.gridJson[i], null, i));
  532. }
  533. this.isItemsLoading = false;
  534. this.pageNumber ++;
  535. if( to == this.gridJson.length )this.isItemsLoaded = true;
  536. }
  537. },
  538. loadGroupData: function(){
  539. if (this.selectTitleCell){
  540. this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
  541. this.selectTitleCell.setStyle("cursor", "pointer");
  542. this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
  543. }
  544. if (this.gridJson.length){
  545. this.gridJson.each(function(data){
  546. this.items.push(new MWF.xApplication.query.Query.Viewer.ItemCategory(this, data));
  547. }.bind(this));
  548. if (this.json.isExpand=="yes") this.expandOrCollapseAll();
  549. }
  550. },
  551. expandOrCollapseAll: function(){
  552. var icon = this.selectTitleCell.getElement("span");
  553. if (icon.get("html").indexOf("expand.png")===-1){
  554. this.items.each(function(item){
  555. item.collapse();
  556. icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
  557. }.bind(this));
  558. }else{
  559. this.items.each(function(item, i){
  560. window.setTimeout(function(){
  561. item.expand();
  562. }.bind(this), 10*i+5);
  563. icon.set("html", "<img src='/x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
  564. }.bind(this));
  565. }
  566. },
  567. getView: function(callback){
  568. this.getLookupAction(function(){
  569. if (this.json.application){
  570. this.lookupAction.getView(this.json.viewName, this.json.application, function(json){
  571. this.viewJson = JSON.decode(json.data.data);
  572. this.json = Object.merge(this.json, json.data);
  573. if (callback) callback();
  574. }.bind(this));
  575. // this.lookupAction.invoke({"name": "getView","async": true, "parameter": {"view": this.json.viewName, "application": this.json.application},"success": function(json){
  576. // this.viewJson = JSON.decode(json.data.data);
  577. // this.json = Object.merge(this.json, json.data);
  578. // //var viewData = JSON.decode(json.data.data);
  579. // if (callback) callback();
  580. // }.bind(this)});
  581. }
  582. }.bind(this));
  583. },
  584. getLookupAction: function(callback){
  585. if (!this.lookupAction){
  586. this.lookupAction = MWF.Actions.get("x_query_assemble_surface");
  587. if (callback) callback();
  588. // var _self = this;
  589. // MWF.require("MWF.xDesktop.Actions.RestActions", function(){
  590. // this.lookupAction = new MWF.xDesktop.Actions.RestActions("", this.options.actionRoot, "");
  591. // this.lookupAction.getActions = function(actionCallback){
  592. // this.actions = _self.options.actions;
  593. // if (actionCallback) actionCallback();
  594. // };
  595. // if (callback) callback();
  596. // }.bind(this));
  597. }else{
  598. if (callback) callback();
  599. }
  600. },
  601. hide: function(){
  602. this.node.setStyle("display", "none");
  603. },
  604. reload: function(){
  605. this.node.setStyle("display", "block");
  606. if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
  607. this.filterItems.each(function(filter){
  608. filter.destroy();
  609. }.bind(this));
  610. this.filterItems = [];
  611. if (this.viewSearchInputNode) this.viewSearchInputNode.set("text", this.lp.searchKeywork);
  612. this.closeCustomSearch();
  613. this.viewAreaNode.empty();
  614. this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
  615. },
  616. getFilter: function(){
  617. debugger;
  618. var filterData = [];
  619. if (this.searchStatus==="custom"){
  620. if (this.filterItems.length){
  621. this.filterItems.each(function(filter){
  622. filterData.push(filter.data);
  623. }.bind(this));
  624. }
  625. }
  626. if (this.searchStatus==="default"){
  627. var key = this.viewSearchInputNode.get("value");
  628. if (key && key!==this.lp.searchKeywork){
  629. this.viewJson.customFilterList.each(function(entry){
  630. if (entry.formatType==="textValue"){
  631. var d = {
  632. "path": entry.path,
  633. "value": key,
  634. "formatType": entry.formatType,
  635. "logic": "or",
  636. "comparison": "like"
  637. };
  638. filterData.push(d);
  639. }
  640. if (entry.formatType==="numberValue"){
  641. var v = key.toFloat();
  642. if (!isNaN(v)){
  643. var d = {
  644. "path": entry.path,
  645. "value": v,
  646. "formatType": entry.formatType,
  647. "logic": "or",
  648. "comparison": "like"
  649. };
  650. filterData.push(d);
  651. }
  652. }
  653. }.bind(this));
  654. }
  655. }
  656. return (filterData.length) ? filterData : null;
  657. },
  658. getData: function(){
  659. if (this.selectedItems.length){
  660. var arr = [];
  661. this.selectedItems.each(function(item){
  662. arr.push(item.data);
  663. });
  664. return arr;
  665. }else{
  666. return [];
  667. }
  668. }
  669. });
  670. MWF.xApplication.query.Query.Viewer.Item = new Class({
  671. initialize: function(view, data, prev, i){
  672. this.view = view;
  673. this.data = data;
  674. this.css = this.view.css;
  675. this.isSelected = false;
  676. this.prev = prev;
  677. this.load();
  678. },
  679. load: function(){
  680. this.node = new Element("tr", {"styles": this.css.viewContentTrNode});
  681. if (this.prev){
  682. this.node.inject(this.prev.node, "after");
  683. }else{
  684. this.node.inject(this.view.viewTable);
  685. }
  686. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  687. this.selectTd = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  688. this.selectTd.setStyles({"cursor": "pointer"});
  689. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  690. //}
  691. Object.each(this.data.data, function(cell, k){
  692. if (this.view.hideColumns.indexOf(k)===-1){
  693. var td = new Element("td", {"styles": this.css.viewContentTdNode}).inject(this.node);
  694. if (k!== this.view.viewJson.group.column){
  695. var v = (this.view.entries[k].code) ? MWF.Macro.exec(this.view.entries[k].code, {"value": cell, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : cell;
  696. td.set("text", v);
  697. }
  698. if (this.view.openColumns.indexOf(k)!==-1){
  699. this.setOpenWork(td)
  700. }
  701. if (this.view.json.itemStyles) td.setStyles(this.view.json.itemStyles);
  702. }
  703. }.bind(this));
  704. this.setEvent();
  705. },
  706. setOpenWork: function(td){
  707. td.setStyle("cursor", "pointer");
  708. td.addEvent("click", this.openWorkAndCompleted.bind(this));
  709. },
  710. openWorkAndCompleted: function(e){
  711. debugger;
  712. MWF.Actions.get("x_processplatform_assemble_surface").listWorkByJob(this.data.bundle, function(json){
  713. var workCompletedCount = json.data.workCompletedList.length;
  714. var workCount = json.data.workList.length;
  715. var count = workCount+workCompletedCount;
  716. if (count===1){
  717. if (workCompletedCount) {
  718. this.openWorkCompleted(json.data.workCompletedList[0].id, e);
  719. }else{
  720. this.openWork(json.data.workList[0].id, e);
  721. }
  722. }else if (count>1){
  723. var worksAreaNode = this.createWorksArea();
  724. json.data.workCompletedList.each(function(work){
  725. this.createWorkCompletedNode(work, worksAreaNode);
  726. }.bind(this));
  727. json.data.workList.each(function(work){
  728. this.createWorkNode(work, worksAreaNode);
  729. }.bind(this));
  730. this.showWorksArea(worksAreaNode, e);
  731. }else{
  732. }
  733. }.bind(this));
  734. },
  735. createWorkNode: function(work, worksAreaNode){
  736. var worksAreaContentNode = worksAreaNode.getLast();
  737. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  738. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  739. actionNode.store("workId", work.id);
  740. actionNode.addEvent("click", function(e){
  741. this.openWork(e.target.retrieve("workId"), e);
  742. this.mask.hide();
  743. worksAreaNode.destroy();
  744. }.bind(this));
  745. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  746. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  747. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  748. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  749. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": work.activityName}).inject(contentNode);
  750. var taskUsers = [];
  751. MWF.Actions.get("x_processplatform_assemble_surface").listTaskByWork(work.id, function(json){
  752. json.data.taskList.each(function(task){
  753. taskUsers.push(MWF.name.cn(task.person));
  754. }.bind(this));
  755. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.taskPeople+": "}).inject(contentNode);
  756. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": taskUsers.join(", ")}).inject(contentNode);
  757. }.bind(this));
  758. },
  759. createWorkCompletedNode: function(work, worksAreaNode){
  760. var worksAreaContentNode = worksAreaNode.getLast();
  761. var node = new Element("div", {"styles": this.css.workAreaNode}).inject(worksAreaContentNode);
  762. var actionNode = new Element("div", {"styles": this.css.workAreaActionNode, "text": this.view.lp.open}).inject(node);
  763. actionNode.store("workId", work.id);
  764. actionNode.addEvent("click", function(e){
  765. this.mask.hide();
  766. worksAreaNode.destroy();
  767. this.openWorkCompleted(e.target.retrieve("workId"), e)
  768. }.bind(this));
  769. var areaNode = new Element("div", {"styles": this.css.workAreaLeftNode}).inject(node);
  770. var titleNode = new Element("div", {"styles": this.css.workAreaTitleNode, "text": work.title}).inject(areaNode);
  771. var contentNode = new Element("div", {"styles": this.css.workAreaContentNode}).inject(areaNode);
  772. new Element("div", {"styles": this.css.workAreaContentTitleNode, "text": this.view.lp.activity+": "}).inject(contentNode);
  773. new Element("div", {"styles": this.css.workAreaContentTextNode, "text": this.view.lp.processCompleted}).inject(contentNode);
  774. },
  775. createWorksArea: function(){
  776. var worksAreaNode = new Element("div", {"styles": this.css.worksAreaNode});
  777. var worksAreaTitleNode = new Element("div", {"styles": this.css.worksAreaTitleNode}).inject(worksAreaNode);
  778. var worksAreaTitleCloseNode = new Element("div", {"styles": this.css.worksAreaTitleCloseNode}).inject(worksAreaTitleNode);
  779. worksAreaTitleCloseNode.addEvent("click", function(e){
  780. this.mask.hide();
  781. e.target.getParent().getParent().destroy();
  782. }.bind(this));
  783. var worksAreaContentNode = new Element("div", {"styles": this.css.worksAreaContentNode}).inject(worksAreaNode);
  784. return worksAreaNode;
  785. },
  786. showWorksArea: function(node, e){
  787. this.mask = new MWF.widget.Mask({"style": "desktop", "loading": false});
  788. this.mask.loadNode(this.view.container);
  789. node.inject(this.view.node);
  790. this.setWorksAreaPosition(node, e.target);
  791. },
  792. setWorksAreaPosition: function(node, td){
  793. var p = td.getPosition(this.view.container);
  794. var containerS = this.view.container.getSize();
  795. var containerP = this.view.container.getPosition(this.view.container.getOffsetParent());
  796. var s = node.getSize();
  797. var offX = p.x+s.x-containerS.x;
  798. offX = (offX>0) ? offX+20 : 0;
  799. var offY = p.y+s.y-containerS.y;
  800. offY = (offY>0) ? offY+5 : 0;
  801. node.position({
  802. "relativeTo": td,
  803. "position": "lefttop",
  804. "edge": "lefttop",
  805. "offset": {
  806. "x": 0-offX,
  807. "y": 0-offY
  808. }
  809. });
  810. },
  811. openWork: function(id, e){
  812. var options = {"workId": id};
  813. this.view.fireEvent("openDocument", [options, this]);
  814. layout.desktop.openApplication(e, "process.Work", options);
  815. },
  816. openWorkCompleted: function(id, e){
  817. var options = {"workCompletedId": id};
  818. this.view.fireEvent("openDocument", [options, this]);
  819. layout.desktop.openApplication(e, "process.Work", options);
  820. },
  821. setEvent: function(){
  822. if (this.view.json.select==="single" || this.view.json.select==="multi"){
  823. this.node.addEvents({
  824. "mouseover": function(){
  825. if (!this.isSelected){
  826. var iconName = "checkbox";
  827. if (this.view.json.select==="single") iconName = "radiobox";
  828. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/"+iconName+".png) center center no-repeat"});
  829. }
  830. }.bind(this),
  831. "mouseout": function(){
  832. if (!this.isSelected) this.selectTd.setStyles({"background": "transparent"});
  833. }.bind(this),
  834. "click": function(){this.select();}.bind(this)
  835. });
  836. }
  837. },
  838. select: function(){
  839. if (this.isSelected){
  840. if (this.view.json.select==="single"){
  841. this.unSelectedSingle();
  842. }else{
  843. this.unSelected();
  844. }
  845. }else{
  846. if (this.view.json.select==="single"){
  847. this.selectedSingle();
  848. }else{
  849. this.selected();
  850. }
  851. }
  852. this.view.fireEvent("select");
  853. },
  854. selected: function(){
  855. this.view.selectedItems.push(this);
  856. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/checkbox_checked.png) center center no-repeat"});
  857. this.node.setStyles(this.css.viewContentTrNode_selected);
  858. this.isSelected = true;
  859. },
  860. unSelected: function(){
  861. this.view.selectedItems.erase(this);
  862. this.selectTd.setStyles({"background": "transparent"});
  863. this.node.setStyles(this.css.viewContentTrNode);
  864. this.isSelected = false;
  865. },
  866. selectedSingle: function(){
  867. if (this.view.currentSelectedItem) this.view.currentSelectedItem.unSelectedSingle();
  868. this.view.selectedItems = [this];
  869. this.view.currentSelectedItem = this;
  870. this.selectTd.setStyles({"background": "url("+"/x_component_query_Query/$Viewer/default/icon/radiobox_checked.png) center center no-repeat"});
  871. this.node.setStyles(this.css.viewContentTrNode_selected);
  872. this.isSelected = true;
  873. },
  874. unSelectedSingle: function(){
  875. this.view.selectedItems = [];
  876. this.view.currentSelectedItem = null;
  877. this.selectTd.setStyles({"background": "transparent"});
  878. this.node.setStyles(this.css.viewContentTrNode);
  879. this.isSelected = false;
  880. }
  881. });
  882. MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
  883. initialize: function(view, data){
  884. this.view = view;
  885. this.data = data;
  886. this.css = this.view.css;
  887. this.items = [];
  888. this.loadChild = false;
  889. this.load();
  890. },
  891. load: function(){
  892. this.node = new Element("tr", {"styles": this.css.viewContentTrNode}).inject(this.view.viewTable);
  893. //if (this.view.json.select==="single" || this.view.json.select==="multi"){
  894. this.selectTd = new Element("td", {"styles": this.css.viewContentCategoryTdNode}).inject(this.node);
  895. if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
  896. //}
  897. this.categoryTd = new Element("td", {
  898. "styles": this.css.viewContentCategoryTdNode,
  899. "colspan": this.view.viewJson.selectList.length
  900. }).inject(this.node);
  901. this.groupColumn = null;
  902. for (var c = 0; c<this.view.viewJson.selectList.length; c++){
  903. if (this.view.viewJson.selectList[c].column === this.view.viewJson.group.column){
  904. this.groupColumn = this.view.viewJson.selectList[c];
  905. break;
  906. }
  907. }
  908. if (this.groupColumn){
  909. var text = (this.groupColumn.code) ? MWF.Macro.exec(this.groupColumn.code, {"value": this.data.group, "gridData": this.view.gridJson, "data": this.view.viewData, "entry": this.data}) : this.data.group;
  910. }else{
  911. var text = this.data.group;
  912. }
  913. this.categoryTd.set("html", "<span style='font-family: Webdings'><img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/></span> "+text);
  914. if (this.view.json.itemStyles) this.categoryTd.setStyles(this.view.json.itemStyles);
  915. this.setEvent();
  916. },
  917. setEvent: function(){
  918. //if (this.selectTd){
  919. this.node.addEvents({
  920. "click": function(){this.expandOrCollapse();}.bind(this)
  921. });
  922. //}
  923. },
  924. expandOrCollapse: function(){
  925. var t = this.node.getElement("span").get("html");
  926. if (t.indexOf("expand.png")===-1){
  927. this.collapse();
  928. }else{
  929. this.expand();
  930. }
  931. },
  932. collapse: function(){
  933. this.items.each(function(item){
  934. item.node.setStyle("display", "none");
  935. }.bind(this));
  936. this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
  937. },
  938. expand: function(){
  939. this.items.each(function(item){
  940. item.node.setStyle("display", "table-row");
  941. }.bind(this));
  942. this.node.getElement("span").set("html", "<img src='/x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/down.png'/>");
  943. if (!this.loadChild){
  944. //window.setTimeout(function(){
  945. this.data.list.each(function(line){
  946. this.items.push(new MWF.xApplication.query.Query.Viewer.Item(this.view, line, this));
  947. }.bind(this));
  948. this.loadChild = true;
  949. //}.bind(this), 10);
  950. }
  951. }
  952. });
  953. MWF.xApplication.query.Query.Viewer.Filter = new Class({
  954. initialize: function(viewer, data, node){
  955. this.viewer = viewer;
  956. this.data = data;
  957. this.css = this.viewer.css;
  958. this.content = node;
  959. this.load();
  960. },
  961. load: function(){
  962. this.node = new Element("div", {"styles": this.css.viewSearchFilterNode}).inject(this.content);
  963. if (this.viewer.filterItems.length){
  964. this.logicNode = new Element("div", {"styles": this.css.viewSearchFilterSelectAreaNode}).inject(this.node);
  965. this.logicSelectNode = new Element("div", {
  966. "styles": this.css.viewSearchFilterSelectNode,
  967. "text": this.viewer.lp.and,
  968. "value": "and"
  969. }).inject(this.logicNode);
  970. this.logicSelectButtonNode = new Element("div", {"styles": this.css.viewSearchFilterSelectButtonNode}).inject(this.logicNode);
  971. this.logicNode.addEvents({
  972. "click": function(){
  973. var v = this.logicSelectNode.get("value");
  974. if (v==="and"){
  975. this.logicSelectButtonNode.setStyle("float", "left");
  976. this.logicSelectNode.setStyle("float", "right");
  977. this.logicSelectNode.set({
  978. "text": this.viewer.lp.or,
  979. "value": "or"
  980. });
  981. this.data.logic = "or";
  982. }else{
  983. this.logicSelectButtonNode.setStyle("float", "right");
  984. this.logicSelectNode.setStyle("float", "left");
  985. this.logicSelectNode.set({
  986. "text": this.viewer.lp.and,
  987. "value": "and"
  988. });
  989. this.data.logic = "and";
  990. }
  991. this.viewer.searchCustomView();
  992. }.bind(this)
  993. });
  994. }
  995. this.titleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.title}).inject(this.node);
  996. this.comparisonTitleNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": this.data.comparisonTitle}).inject(this.node);
  997. this.valueNode = new Element("div", {"styles": this.css.viewSearchFilterTextNode, "text": "\""+this.data.value+"\""}).inject(this.node);
  998. this.deleteNode = new Element("div", {"styles": this.css.viewSearchFilterDeleteNode}).inject(this.node);
  999. this.node.addEvents({
  1000. "mouseover": function(){
  1001. this.node.setStyles(this.css.viewSearchFilterNode_over);
  1002. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode_over);
  1003. }.bind(this),
  1004. "mouseout": function(){
  1005. this.node.setStyles(this.css.viewSearchFilterNode);
  1006. this.deleteNode.setStyles(this.css.viewSearchFilterDeleteNode);
  1007. }.bind(this)
  1008. });
  1009. this.deleteNode.addEvent("click", function(){
  1010. this.viewer.searchViewRemoveFilter(this);
  1011. }.bind(this));
  1012. },
  1013. destroy: function(){
  1014. this.node.destroy();
  1015. MWF.release(this);
  1016. }
  1017. });