Explorer.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. MWF.xApplication.Attendance = MWF.xApplication.Attendance || {};
  2. MWF.require("MWF.xAction.org.express.RestActions", null,false);
  3. MWF.require("MWF.widget.O2Identity", null,false);
  4. MWF.xDesktop.requireApp("Attendance", "lp."+MWF.language, null, false);
  5. MWF.xApplication.Attendance.Explorer = new Class({
  6. Extends: MWF.widget.Common,
  7. Implements: [Options, Events],
  8. options: {
  9. "style": "default",
  10. "isAdmin": false,
  11. "searchKey" : ""
  12. },
  13. initialize: function(node, app, actions, options){
  14. this.setOptions(options);
  15. this.app = app;
  16. this.path = "../x_component_Attendance/$Explorer/";
  17. this.cssPath = "../x_component_Attendance/$Explorer/"+this.options.style+"/css.wcss";
  18. this._loadCss();
  19. this.actions = actions;
  20. this.node = $(node);
  21. this.initData();
  22. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  23. },
  24. initData: function(){
  25. this.toolItemNodes = [];
  26. },
  27. reload: function(){
  28. this.node.empty();
  29. this.load();
  30. },
  31. load: function(){
  32. this.loadToolbar();
  33. this.loadContentNode();
  34. this.loadView();
  35. this.setNodeScroll();
  36. },
  37. destroy : function(){
  38. this.node.empty();
  39. delete this;
  40. },
  41. loadToolbar: function(){
  42. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode || this.app.css.toolbarNode});
  43. this.toolbarNode.inject(this.node);
  44. var toolbarUrl = this.path+"toolbar.json";
  45. MWF.getJSON(toolbarUrl, function(json){
  46. json.each(function(tool){
  47. this.createToolbarItemNode(tool);
  48. }.bind(this));
  49. }.bind(this));
  50. //this.createSearchElementNode();
  51. },
  52. createToolbarItemNode : function( tool ){
  53. var toolItemStyle;
  54. if(tool.styles && (this.css[tool.styles] || this.app.css[tool.styles])){
  55. toolItemStyle = tool.styles && (this.css[tool.styles] || this.app.css[tool.styles]);
  56. }else{
  57. toolItemStyle = this.css.toolbarItemNode || this.app.css.toolbarItemNode;
  58. }
  59. var toolItemNode = new Element("div", {
  60. "styles": toolItemStyle
  61. });
  62. // var toolItemNode = new Element("div", {
  63. // "styles": (tool.styles && this.css[tool.styles]) ? this.css[tool.styles] : this.css.toolbarItemNode
  64. // });
  65. if( tool.id ){
  66. toolItemNode.set( 'name' , tool.id );
  67. }
  68. toolItemNode.store("toolData", tool );
  69. if( tool.icon ){
  70. var iconNode = new Element("div", {
  71. "styles": this.css.toolbarItemIconNode || this.app.css.toolbarItemIconNode
  72. }).inject(toolItemNode);
  73. // iconNode.setStyle("background-image", "url("+this.path+this.options.style+"/icon/"+tool.icon+")");
  74. iconNode.setStyle("background-image", "url(../x_component_Attendance/$Main/"+this.app.options.style+"/icon/toolbar/"+tool.icon+")");
  75. }
  76. if( tool.title ){
  77. var textNode = new Element("div", {
  78. "styles": this.css.toolbarItemTextNode || this.app.css.toolbarItemTextNode,
  79. "text": tool.title
  80. });
  81. if( tool.text )textNode.set("title", tool.text);
  82. textNode.inject(toolItemNode);
  83. }
  84. toolItemNode.inject(this.toolbarNode);
  85. this.toolItemNodes.push(toolItemNode);
  86. // this.setToolbarItemEvent(toolItemNode);
  87. var _self = this;
  88. if( tool.action ){
  89. toolItemNode.addEvents({
  90. "mouseover": function () {
  91. toolItemNode.setStyles( _self.app.css.toolbarItemNode_over );
  92. toolItemNode.addClass( "mainColor_bg" );
  93. toolItemNode.addClass( "mainColor_border" );
  94. if( tool.icon && iconNode ){
  95. // iconNode.setStyle("background-image", "url("+_self.path+_self.options.style+"/icon/"+tool.icon.split(".")[0]+"_over.png)");
  96. iconNode.setStyle("background-image", "url(../x_component_Attendance/$Main/"+_self.app.options.style+"/icon/toolbar/"+tool.icon.split(".")[0]+"_over.png)");
  97. }
  98. },
  99. "mouseout": function () {
  100. toolItemNode.setStyles( _self.app.css.toolbarItemNode_normal );
  101. toolItemNode.removeClass( "mainColor_bg" );
  102. toolItemNode.removeClass( "mainColor_border" );
  103. if( tool.icon && iconNode ){
  104. // iconNode.setStyle("background-image", "url("+_self.path+_self.options.style+"/icon/"+tool.icon+")");
  105. iconNode.setStyle("background-image", "url(../x_component_Attendance/$Main/"+_self.app.options.style+"/icon/toolbar/"+tool.icon+")");
  106. }
  107. },
  108. "click": function () {
  109. var data = this.retrieve("toolData");
  110. if( _self[data.action] )_self[data.action].apply(_self,[this]);
  111. }
  112. })
  113. }
  114. },
  115. // setToolbarItemEvent:function(toolItemNode){
  116. // var _self = this;
  117. // toolItemNode.addEvents({
  118. // "click": function () {
  119. // var data = this.retrieve("toolData");
  120. // if( _self[data.action] )_self[data.action].apply(_self,[this]);
  121. // }
  122. // })
  123. // },
  124. loadContentNode: function(){
  125. this.elementContentNode = new Element("div.elementContentNode", {
  126. "styles": this.css.elementContentNode || this.app.css.elementContentNode
  127. }).inject(this.node);
  128. this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  129. },
  130. loadView : function(){
  131. this.view = new MWF.xApplication.Attendance.Explorer.View(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
  132. this.view.load();
  133. this.setContentSize();
  134. },
  135. setContentSize: function(){
  136. var toolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : {"x":0,"y":0};
  137. var titlebarSize = this.app.titleBar ? this.app.titleBar.getSize() : {"x":0,"y":0};
  138. var nodeSize = this.node.getSize();
  139. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  140. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  141. //var filterSize = this.filterNode.getSize();
  142. var filterConditionSize = this.filterConditionNode ? this.filterConditionNode.getSize() : {"x":0,"y":0};
  143. var height = nodeSize.y-toolbarSize.y-pt-pb-filterConditionSize.y-titlebarSize.y;
  144. this.elementContentNode.setStyle("height", ""+height+"px");
  145. this.pageCount = (height/30).toInt()+5;
  146. this._setContentSize();
  147. if (this.view && this.view.items.length<this.pageCount){
  148. this.view.loadElementList(this.pageCount-this.view.items.length);
  149. }
  150. },
  151. getOffsetY : function(node){
  152. return (node.getStyle("margin-top").toInt() || 0 ) +
  153. (node.getStyle("margin-bottom").toInt() || 0 ) +
  154. (node.getStyle("padding-top").toInt() || 0 ) +
  155. (node.getStyle("padding-bottom").toInt() || 0 )+
  156. (node.getStyle("border-top-width").toInt() || 0 ) +
  157. (node.getStyle("border-bottom-width").toInt() || 0 );
  158. },
  159. getOffsetX : function(node){
  160. return (node.getStyle("margin-left").toInt() || 0 ) +
  161. (node.getStyle("margin-right").toInt() || 0 ) +
  162. (node.getStyle("padding-left").toInt() || 0 ) +
  163. (node.getStyle("padding-right").toInt() || 0 )+
  164. (node.getStyle("border-left-width").toInt() || 0 ) +
  165. (node.getStyle("border-right-width").toInt() || 0 );
  166. },
  167. _setContentSize: function(){
  168. },
  169. loadFilterStyle: function(callback){
  170. var path = "../x_component_Template/$MForm/attendance/css.wcss";
  171. var key = encodeURIComponent(path);
  172. var css;
  173. if (o2.widget.css[key]){
  174. css = o2.widget.css[key];
  175. if(callback)callback(css);
  176. }else{
  177. path = path+"?v="+o2.version.v;
  178. var r = new Request.JSON({
  179. url: o2.filterUrl(path),
  180. secure: false,
  181. async: true,
  182. method: "get",
  183. noCache: false,
  184. onSuccess: function(responseJSON, responseText){
  185. css = responseJSON;
  186. o2.widget.css[key] = responseJSON;
  187. if(callback)callback(css);
  188. }.bind(this),
  189. onError: function(text, error){
  190. alert(error + text);
  191. }
  192. });
  193. r.send();
  194. }
  195. },
  196. setNodeScroll: function(){
  197. var _self = this;
  198. var container = this.elementContentNode;
  199. container.setStyle("overflow","auto");
  200. this.scrollContainerFun = function(){
  201. var scrollSize = container.getScrollSize();
  202. var clientSize = container.getSize();
  203. var scrollHeight = scrollSize.y - clientSize.y;
  204. if (container.scrollTop + 150 > scrollHeight ) {
  205. if (!this.view.isItemsLoaded) this.view.loadElementList();
  206. }
  207. }.bind(this);
  208. container.addEvent("scroll", this.scrollContainerFun )
  209. // var _self = this;
  210. // MWF.require("MWF.widget.ScrollBar", function(){
  211. // new MWF.widget.ScrollBar(this.elementContentNode, {
  212. // "indent": false,"style":"xApp_TaskList", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
  213. // "onScroll": function(y){
  214. // var scrollSize = _self.elementContentNode.getScrollSize();
  215. // var clientSize = _self.elementContentNode.getSize();
  216. // var scrollHeight = scrollSize.y-clientSize.y;
  217. // if (y+200>scrollHeight) {
  218. // if (!_self.view.isItemsLoaded) _self.view.loadElementList();
  219. // }
  220. // }
  221. // });
  222. // }.bind(this));
  223. }
  224. });
  225. MWF.xApplication.Attendance.Explorer.View = new Class({
  226. initialize: function( container, app, explorer, searchKey, css ){
  227. this.container = container;
  228. this.app = app;
  229. this.explorer = explorer;
  230. this.css = this.explorer.css;
  231. this.actions = explorer.actions;
  232. this.searchKey = searchKey;
  233. this.listItemUrl = this.explorer.path+"listItem.json";
  234. },
  235. initData: function(){
  236. this.items=[];
  237. this.documents = {};
  238. this.isItemsLoaded = false;
  239. this.isItemLoadding = false;
  240. this.loadItemQueue = 0;
  241. this.count = 0;
  242. //this.controllers =[];
  243. },
  244. load : function( onlyShowTitle ){
  245. this.initData();
  246. this.node = new Element("div", {
  247. "styles": this.css.elementContentListNode || this.app.css.elementContentListNode
  248. }).inject(this.container);
  249. this.table = new Element("table",{ "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "class" : "editTable"}).inject(this.node);
  250. this.initSortData();
  251. this.createListHead();
  252. if( onlyShowTitle ){
  253. this.onlyShowTitle = true;
  254. }else{
  255. this.onlyShowTitle = false;
  256. this.loadElementList();
  257. }
  258. },
  259. initSortData : function(){
  260. this.sortField = null;
  261. this.sortType = null;
  262. this.sortFieldDefault = null;
  263. this.sortTypeDefault = null;
  264. },
  265. clear: function(){
  266. this.documents = null;
  267. MWF.release(this.items);
  268. this.items=[];
  269. this.documents = {};
  270. this.container.empty();
  271. this.isItemsLoaded = false;
  272. this.isItemLoadding = false;
  273. this.loadItemQueue = 0;
  274. //this.count = 0;
  275. },
  276. reload: function(){
  277. this.clear();
  278. this.node = new Element("div", {
  279. "styles": this.css.elementContentListNode || this.app.css.elementContentListNode
  280. }).inject(this.container);
  281. this.table = new Element("table",{ "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "class" : "editTable"}).inject(this.node);
  282. this.createListHead();
  283. this.loadElementList();
  284. },
  285. resort : function(th){
  286. this.sortField = th.retrieve("sortField");
  287. var sortType = th.retrieve("sortType");
  288. //th.eliminate(sortType);
  289. if( sortType == "" ){
  290. this.sortType = "asc";
  291. }else if( this.sortType == "asc" ){
  292. this.sortType = "desc";
  293. }else{
  294. this.sortField = null;
  295. this.sortType = null;
  296. }
  297. this.reload();
  298. },
  299. createListHead : function(){
  300. var _self = this;
  301. var headNode = new Element("tr", {"styles": this.css.listHeadNode || this.app.css.listHeadNode}).inject(this.table);
  302. MWF.getJSON( this.listItemUrl, function(json){
  303. this.listItemTemplate = json;
  304. json.each(function(cell){
  305. var isShow = true;
  306. if( cell.access ){
  307. if( cell.access == "admin" && !this.explorer.options.isAdmin ){
  308. isShow = false;
  309. }
  310. }
  311. if(isShow) {
  312. var th = new Element("th", {
  313. "styles": this.css[cell.headStyles] || this.app.css[cell.headStyles],
  314. "text": cell.title,
  315. "width": cell.width
  316. }).inject(headNode);
  317. if( cell.name == "checkbox" ){
  318. this.checkboxElement = new Element("input",{
  319. "type" : "checkbox"
  320. }).inject( th );
  321. this.checkboxElement.addEvent("click",function(){
  322. this.selectAllCheckbox()
  323. }.bind(this))
  324. }
  325. if( cell.defaultSort && cell.defaultSort != "" ){
  326. this.sortFieldDefault = cell.name;
  327. this.sortTypeDefault = cell.defaultSort;
  328. }
  329. if( cell.sort && cell.sort != "" ){
  330. th.store("sortField",cell.name);
  331. if( this.sortField == cell.name && this.sortType!="" ){
  332. th.store("sortType",this.sortType);
  333. this.sortIconNode = new Element("div",{
  334. "styles": this.sortType == "asc" ? (this.css.sortIconNode_asc || this.app.css.sortIconNode_asc) : (this.css.sortIconNode_desc || this.app.css.sortIconNode_desc)
  335. }).inject( th, "top" );
  336. }else{
  337. th.store("sortType","");
  338. this.sortIconNode = new Element("div",{"styles":this.css.sortIconNode || this.app.css.sortIconNode}).inject( th, "top" );
  339. }
  340. th.setStyle("cursor","pointer");
  341. th.addEvent("click",function(){
  342. _self.resort( this );
  343. })
  344. }
  345. }
  346. }.bind(this));
  347. }.bind(this),false);
  348. },
  349. selectAllCheckbox : function(){
  350. var flag = this.checkboxElement.get("checked");
  351. this.items.each( function( it ){
  352. if( it.checkboxElement )it.checkboxElement.set("checked",flag );
  353. }.bind(this))
  354. },
  355. loadElementList: function(count){
  356. if( this.onlyShowTitle )return;
  357. if (!this.isItemsLoaded){
  358. if (!this.isItemLoadding){
  359. this.isItemLoadding = true;
  360. this._getCurrentPageData(function(json){
  361. //if( !json.data )return;
  362. json.data = json.data || [];
  363. var length = json.count; //|| json.data.length;
  364. //if (!this.isCountShow){
  365. // this.filterAllProcessNode.getFirst("span").set("text", "("+this.count+")");
  366. // this.isCountShow = true;
  367. //}
  368. if ( length <=this.items.length){
  369. this.isItemsLoaded = true;
  370. }
  371. json.data.each(function(data){
  372. if (!this.documents[data.id]){
  373. var item = this._createItem(data);
  374. this.items.push(item);
  375. this.documents[data.id] = item;
  376. }
  377. }.bind(this));
  378. this.isItemLoadding = false;
  379. if (this.loadItemQueue>0){
  380. this.loadItemQueue--;
  381. this.loadElementList();
  382. }
  383. }.bind(this), count);
  384. }else{
  385. this.loadItemQueue++;
  386. }
  387. }
  388. },
  389. _createItem: function(data){
  390. return new MWF.xApplication.Attendance.Explorer.Document(this.table, data, this.explorer, this);
  391. },
  392. _getCurrentPageData: function(callback, count){
  393. /* if(!count)count=20;
  394. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  395. var data = {
  396. "catagoryIdList": [
  397. {
  398. "name": "catagoryId",
  399. "value": this.explorer.categoryData.id
  400. }
  401. ],
  402. "statusList": [
  403. {
  404. "name": "docStatus",
  405. "value": this.explorer.options.status
  406. }
  407. ]
  408. }
  409. if( this.searchKey && this.searchKey!="" ){
  410. data.titleList = [{
  411. "name" :"title",
  412. "value" : this.searchKey
  413. }]
  414. }
  415. if (this.filter && this.filter.filter ){
  416. var filterResult = this.filter.getFilterResult();
  417. for(var f in filterResult ){
  418. data[f] = filterResult[f];
  419. }
  420. this.actions.listDocumentFilterNext(id, count || this.pageCount, data, function(json){
  421. if (callback) callback(json);
  422. });
  423. }else{
  424. this.actions.listDocumentFilterNext(id, count || this.pageCount, data, function(json){
  425. if (callback) callback(json);
  426. });
  427. }*/
  428. },
  429. _removeDocument: function(documentData, all){
  430. //var id = document.data.id;
  431. //this.actions.removeDocument(id, function(json){
  432. // //json.data.each(function(item){
  433. // this.items.erase(this.documents[id]);
  434. // this.documents[id].destroy();
  435. // MWF.release(this.documents[id]);
  436. // delete this.documents[id];
  437. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  438. // // }.bind(this));
  439. //}.bind(this));
  440. },
  441. _createDocument: function(){
  442. },
  443. _openDocument: function( documentData ){
  444. }
  445. });
  446. MWF.xApplication.Attendance.Explorer.Document = new Class({
  447. initialize: function(container, data, explorer, view){
  448. this.explorer = explorer;
  449. this.app = explorer.app;
  450. this.data = data;
  451. this.container = container;
  452. this.view = view;
  453. this.css = this.explorer.css;
  454. this.load();
  455. },
  456. load: function(){
  457. this.node = new Element("tr", {"styles": this.css.documentItemNode || this.app.css.documentItemNode});
  458. this.node.inject(this.container);
  459. //this.documentAreaNode = new Element("td", {"styles": this.css.documentItemDocumentNode}).inject(this.node);
  460. this.view.listItemTemplate.each(function(cell){
  461. var isShow = true;
  462. if( cell.access ){
  463. if( cell.access == "admin" && !this.explorer.options.isAdmin ){
  464. isShow = false;
  465. }
  466. }
  467. if(isShow){
  468. var value;
  469. if( cell.item.substr( 0, "function".length ) == "function" ){
  470. eval( "var fun = " + cell.item );
  471. value = fun.call( this, this.data );
  472. }else if( typeOf(this.data[cell.item]) == "number" ){
  473. value = this.data[cell.item];
  474. }else{
  475. value = this.data[cell.item] ? this.data[cell.item] : "";
  476. }
  477. var td = this[cell.name] = new Element("td",{
  478. "styles":this.css[cell.contentStyles] || this.app.css[cell.contentStyles],
  479. "text" : value
  480. }).inject(this.node);
  481. if( cell.name == "actions" && typeOf( cell.sub )=="array"){
  482. this.setActions( this[cell.name], cell.sub );
  483. }
  484. if( cell.name == "checkbox" ){
  485. var showCheckBox = true;
  486. if( cell.condition && cell.condition.substr( 0, "function".length ) == "function" ) {
  487. eval("var fun = " + cell.condition);
  488. showCheckBox = fun.call(this, this.data);
  489. }
  490. if( showCheckBox ){
  491. this.checkboxElement = new Element("input",{
  492. "type" : "checkbox"
  493. }).inject( td );
  494. this.checkboxElement.addEvent("click",function(ev){
  495. ev.stopPropagation();
  496. }.bind(this));
  497. td.addEvent("click",function(ev){
  498. this.checkboxElement.set("checked", !this.checkboxElement.get("checked") );
  499. ev.stopPropagation();
  500. }.bind(this))
  501. }
  502. }
  503. }
  504. }.bind(this));
  505. this.node.addEvents({
  506. "mouseover": function(){if (!this.readyRemove) {
  507. this.node.setStyles(this.css.documentItemDocumentNode_over || this.app.css.documentItemDocumentNode_over);
  508. }}.bind(this),
  509. "mouseout": function(){if (!this.readyRemove){
  510. this.node.setStyles(this.css.documentItemDocumentNode || this.app.css.documentItemDocumentNode);
  511. }}.bind(this),
  512. "click": function(e){
  513. this.openDocument(e);
  514. }.bind(this)
  515. });
  516. },
  517. setActions: function( actionsNode, data ){
  518. var _self = this;
  519. data.each(function( d ){
  520. if( !d.action || !this[d.action])return;
  521. if( d.condition ){
  522. if( d.condition.substr( 0, "function".length ) == "function" ) {
  523. eval("var fun = " + d.condition );
  524. if( ! fun.call(this, this.data) ){
  525. return;
  526. }
  527. }
  528. }
  529. var node = this[d.action+"Node"] = new Element("div", {"title": d.title}).inject(actionsNode);
  530. var styles, overStyles, downStyles;
  531. if( typeOf( d.styles) == "string" ) styles = this.css[d.styles] || this.app.css[d.styles];
  532. if( typeOf(d.styles) == "object" ) styles = d.styles;
  533. if( typeOf( d.overStyles) == "string" ) overStyles = this.css[d.overStyles] || this.app.css[d.overStyles];
  534. if( typeOf(d.overStyles) == "object" ) overStyles = d.overStyles;
  535. if( typeOf( d.downStyles) == "string" ) downStyles = this.css[d.downStyles] || this.app.css[d.downStyles];
  536. if( typeOf(d.downStyles) == "object" ) downStyles = d.downStyles;
  537. if( styles )node.setStyles( styles );
  538. var fonticonNode;
  539. if( d.fonticon ){
  540. fonticonNode = new Element("i."+d.fonticon).inject(node, "top");
  541. }else if(d.icon){
  542. // node.setStyle("background-image", "url("+_self.explorer.path+_self.explorer.options.style+"/icon/"+d.icon+")");
  543. node.setStyle("background-image", "url(../x_component_Attendance/$Main/"+_self.app.options.style+"/icon/action/"+d.icon+")");
  544. }
  545. if( overStyles && styles ){
  546. node.addEvent( "mouseover", function(ev){
  547. ev.target.setStyles( this.styles );
  548. if( d.fonticon ){
  549. fonticonNode.addClass("mainColor_color");
  550. }else if(d.icon){
  551. // ev.target.setStyle("background-image", "url("+_self.explorer.path+_self.explorer.options.style+"/icon/"+d.icon.split(".")[0]+"_blue.png)");
  552. ev.target.setStyle("background-image", "url(../x_component_Attendance/$Main/"+_self.app.options.style+"/icon/action/"+d.icon.split(".")[0]+"_blue.png)");
  553. }
  554. }.bind({"styles" : overStyles }) );
  555. node.addEvent( "mouseout", function(ev){
  556. ev.target.setStyles( this.styles );
  557. if( d.fonticon ){
  558. fonticonNode.removeClass("mainColor_color");
  559. }else if(d.icon){
  560. // ev.target.setStyle("background-image", "url("+_self.explorer.path+_self.explorer.options.style+"/icon/"+d.icon+")");
  561. ev.target.setStyle("background-image", "url(../x_component_Attendance/$Main/"+_self.app.options.style+"/icon/action/"+d.icon+")");
  562. }
  563. }.bind({"styles" : styles}) );
  564. }
  565. if( downStyles && ( overStyles || styles)){
  566. node.addEvent( "mousedown", function(ev){ ev.target.setStyles( this.styles ); }.bind({"styles" : downStyles }) );
  567. node.addEvent( "mouseup", function(ev){ ev.target.setStyles( this.styles ); }.bind({"styles" : overStyles || styles }) )
  568. }
  569. if( this[d.action] ){
  570. node.addEvent("click", function(ev){
  571. this.fun.call( _self, ev );
  572. ev.stopPropagation();
  573. }.bind({fun : this[d.action]}))
  574. }
  575. }.bind(this));
  576. //if( this.actionAreaNode ){
  577. // if( this.explorer.options.isAdmin ){
  578. // this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": this.app.lp.delete}).inject(this.actionAreaNode);
  579. // }
  580. //}
  581. },
  582. openDocument: function(e){
  583. //var options = {"documentId": this.data.id }//this.explorer.app.options.application.allowControl};
  584. //this.explorer.app.desktop.openApplication(e, "cms.Document", options);
  585. this.view._openDocument( this.data );
  586. },
  587. remove: function(e){
  588. var lp = this.app.lp;
  589. var text = lp.deleteDocument.replace(/{title}/g, this.data.title);
  590. var _self = this;
  591. this.node.setStyles(this.css.documentItemDocumentNode_remove || this.app.css.documentItemDocumentNode_remove);
  592. this.readyRemove = true;
  593. this.explorer.app.confirm("warn", e, lp.deleteDocumentTitle, text, 350, 120, function(){
  594. //var inputs = this.content.getElements("input");
  595. //var flag = "";
  596. //for (var i=0; i<inputs.length; i++){
  597. // if (inputs[i].checked){
  598. // flag = inputs[i].get("value");
  599. // break;
  600. // }
  601. //}
  602. //if (flag){
  603. //if (flag=="all"){
  604. //_self.explorer.removeDocument(_self, true);
  605. //}else{
  606. _self.view._removeDocument(_self.data, false);
  607. //}
  608. this.close();
  609. //}else{
  610. // this.content.getElement("#deleteDocument_checkInfor").set("text", lp.deleteAllDocumentCheck).setStyle("color", "red");
  611. //}
  612. }, function(){
  613. _self.node.setStyles(_self.css.documentItemDocumentNode || _self.app.css.documentItemDocumentNode);
  614. _self.readyRemove = false;
  615. this.close();
  616. });
  617. },
  618. destroy: function(){
  619. this.node.destroy();
  620. }
  621. });
  622. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  623. MWF.xApplication.Attendance.Explorer.PopupForm = new Class({
  624. Extends: MPopupForm,
  625. options: {
  626. "style": "attendanceV2",
  627. "okClass": "mainColor_bg",
  628. "hideBottomWhenReading": true,
  629. "closeByClickMaskWhenReading": true,
  630. "width": "500",
  631. "height": "400",
  632. "buttonList": [{ "type":"ok", "text": "" }, { "type":"cancel", "text": "" }]
  633. }
  634. });
  635. // MWF.xApplication.Attendance.Explorer.PopupForm = new Class({
  636. // Extends: MWF.widget.Common,
  637. // Implements: [Options, Events],
  638. // options: {
  639. // "width": "500",
  640. // "height": "400"
  641. // },
  642. // initialize: function( explorer, data,options){
  643. // this.setOptions(options);
  644. // this.explorer = explorer;
  645. // this.app = explorer.app;
  646. // this.data = data || {};
  647. // this.css = this.explorer.css;
  648. //
  649. // this.load();
  650. // },
  651. // load: function(){
  652. //
  653. // },
  654. //
  655. // open: function(e){
  656. // this.isNew = false;
  657. // this.isEdited = false;
  658. // this._open();
  659. // },
  660. // create: function(){
  661. // this.isNew = true;
  662. // this._open();
  663. // },
  664. // edit: function(){
  665. // this.isEdited = true;
  666. // this._open();
  667. // },
  668. // _open : function(){
  669. // this.formMaskNode = new Element("div", {
  670. // "styles": this.css.formMaskNode || this.app.css.formMaskNode,
  671. // "events": {
  672. // "mouseover": function(e){e.stopPropagation();},
  673. // "mouseout": function(e){e.stopPropagation();}
  674. // }
  675. // }).inject(this.app.content, "after");
  676. //
  677. // this.formAreaNode = new Element("div", {
  678. // "styles": this.css.formAreaNode || this.app.css.formAreaNode
  679. // });
  680. //
  681. // this.createFormNode();
  682. //
  683. // this.formAreaNode.inject(this.formMaskNode, "after");
  684. // this.formAreaNode.fade("in");
  685. //
  686. // this.setFormNodeSize();
  687. // this.setFormNodeSizeFun = this.setFormNodeSize.bind(this);
  688. // this.addEvent("resize", this.setFormNodeSizeFun);
  689. // },
  690. // createFormNode: function(){
  691. // var _self = this;
  692. //
  693. // this.formNode = new Element("div", {
  694. // "styles": this.css.formNode || this.app.css.formNode
  695. // }).inject(this.formAreaNode);
  696. //
  697. // this.formIconNode = new Element("div", {
  698. // "styles": this.isNew ? ( this.css.formNewNode || this.app.css.formNewNode) : ( this.css.formIconNode || this.app.css.formIconNode )
  699. // }).inject(this.formNode);
  700. //
  701. //
  702. // this.formFormNode = new Element("div", {
  703. // "styles": this.css.formFormNode || this.app.css.formFormNode
  704. // }).inject(this.formNode);
  705. //
  706. // this.formTableContainer = new Element("div", {
  707. // "styles": this.css.formTableContainer || this.app.css.formTableContainer
  708. // }).inject(this.formFormNode);
  709. //
  710. // this.formTableArea = new Element("div", {
  711. // "styles": this.css.formTableArea || this.app.css.formTableArea
  712. // }).inject(this.formTableContainer);
  713. //
  714. //
  715. // this._createTableContent();
  716. // //formFormNode.set("html", html);
  717. //
  718. // //this.setScrollBar(this.formTableContainer)
  719. //
  720. // this._createAction();
  721. // },
  722. // _createTableContent: function(){
  723. //
  724. // var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  725. // "<tr><td colspan='2' styles='formTableHead'>申诉处理单</td></tr>" +
  726. // "<tr><td styles='formTabelTitle' lable='empName'></td>"+
  727. // " <td styles='formTableValue' item='empName'></td></tr>" +
  728. // "<tr><td styles='formTabelTitle' lable='unitName'></td>"+
  729. // " <td styles='formTableValue' item='unitName'></td></tr>" +
  730. // "<tr><td styles='formTabelTitle' lable='recordDateString'></td>"+
  731. // " <td styles='formTableValue' item='recordDateString'></td></tr>" +
  732. // "<tr><td styles='formTabelTitle' lable='status'></td>"+
  733. // " <td styles='formTableValue' item='status'></td></tr>" +
  734. // "<tr><td styles='formTabelTitle' lable='appealReason'></td>"+
  735. // " <td styles='formTableValue' item='appealReason'></td></tr>" +
  736. // "<tr><td styles='formTabelTitle' lable='appealDescription'></td>"+
  737. // " <td styles='formTableValue' item='appealDescription'></td></tr>" +
  738. // "<tr><td styles='formTabelTitle' lable='opinion1'></td>"+
  739. // " <td styles='formTableValue' item='opinion1'></td></tr>" +
  740. // "</table>";
  741. // this.formTableArea.set("html",html);
  742. //
  743. // MWF.xDesktop.requireApp("Template", "MForm", function(){
  744. // this.form = new MForm( this.formTableArea, {empName:"xadmin"}, {
  745. // isEdited : this.isEdited || this.isNew,
  746. // itemTemplate : {
  747. // empName : { text:"姓名", type : "innertext" },
  748. // unitName : { text:"部门", tType : "unit", notEmpty:true },
  749. // recordDateString : { text:"日期", tType : "date"},
  750. // status : { text:"状态", tType : "number" },
  751. // appealReason : {
  752. // text:"下拉框",
  753. // type : "select",
  754. // selectValue : ["测试1","测试2"]
  755. // },
  756. // appealDescription : { text:"描述", type : "textarea" },
  757. // opinion1 : { text:"测试", type : "button", "value" : "测试" }
  758. // }
  759. // }, this.app);
  760. // this.form.load();
  761. // }.bind(this), true);
  762. // },
  763. // setFormNodeSize: function (width, height, top, left) {
  764. // if (!width)width = this.options && this.options.width ? this.options.width : "50%";
  765. // if (!height)height = this.options && this.options.height ? this.options.height : "50%";
  766. // if (!top) top = this.options && this.options.top ? this.options.top : 0;
  767. // if (!left) left = this.options && this.options.left ? this.options.left : 0;
  768. //
  769. // var allSize = this.app.content.getSize();
  770. // var limitWidth = allSize.x; //window.screen.width
  771. // var limitHeight = allSize.y; //window.screen.height
  772. //
  773. // "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  774. // "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  775. // 300 > width && (width = 300);
  776. // 220 > height && (height = 220);
  777. // top = top || parseInt((limitHeight - height) / 2, 10);
  778. // left = left || parseInt((limitWidth - width) / 2, 10);
  779. //
  780. // this.formAreaNode.setStyles({
  781. // "width": "" + width + "px",
  782. // "height": "" + height + "px",
  783. // "top": "" + top + "px",
  784. // "left": "" + left + "px"
  785. // });
  786. //
  787. // this.formNode.setStyles({
  788. // "width": "" + width + "px",
  789. // "height": "" + height + "px"
  790. // });
  791. //
  792. // var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
  793. // var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  794. // var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  795. //
  796. // var contentHeight = height - iconSize.y - topSize.y - bottomSize.y;
  797. // //var formMargin = formHeight -iconSize.y;
  798. // this.formFormNode.setStyles({
  799. // "height": "" + contentHeight + "px"
  800. // });
  801. // },
  802. // _createAction : function(){
  803. // this.cancelActionNode = new Element("div", {
  804. // "styles": this.css.formCancelActionNode || this.app.css.formCancelActionNode,
  805. // "text": this.app.lp.cancel
  806. // }).inject(this.formFormNode);
  807. //
  808. //
  809. // this.cancelActionNode.addEvent("click", function(e){
  810. // this.cancel(e);
  811. // }.bind(this));
  812. // if( this.isNew || this.isEdited){
  813. //
  814. // this.okActionNode = new Element("div", {
  815. // "styles": this.css.formOkActionNode || this.app.css.formOkActionNode,
  816. // "text": this.app.lp.ok
  817. // }).inject(this.formFormNode);
  818. //
  819. // this.okActionNode.addEvent("click", function(e){
  820. // this.ok(e);
  821. // }.bind(this));
  822. // }
  823. // },
  824. // cancel: function(e){
  825. // this.close();
  826. // },
  827. // close: function(e){
  828. // this.formMaskNode.destroy();
  829. // this.formAreaNode.destroy();
  830. // delete this;
  831. // },
  832. // ok: function(e){
  833. // debugger
  834. // var data = this.form.getResult(false,",",true,false,true);
  835. // if( data ){
  836. // this._ok( data, function( json ){
  837. // if( json.type == "ERROR" ){
  838. // this.app.notice( json.message , "error");
  839. // }else{
  840. // this.formMaskNode.destroy();
  841. // this.formAreaNode.destroy();
  842. // if(this.explorer.view)this.explorer.view.reload();
  843. // this.app.notice( this.isNew ? this.app.lp.createSuccess : this.app.lp.updateSuccess , "success");
  844. // }
  845. // }.bind(this))
  846. // }
  847. // },
  848. // _ok: function( data, callback ){
  849. // //this.app.restActions.saveDocument( this.data.id, data, function(json){
  850. // // if( callback )callback(json);
  851. // //}.bind(this));
  852. // }
  853. // });