Explorer.js 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  1. MWF.xApplication.Template = MWF.xApplication.Template || {};
  2. MWF.xApplication.Template.Explorer = MWF.xApplication.Template.Explorer || {};
  3. MWF.require("MWF.widget.O2Identity", null, false);
  4. //MWF.xDesktop.requireApp("Template", "lp." + MWF.language, null, false);
  5. String.implement({
  6. toDOM: function( container, callback ){
  7. var wrapper = this.test('^<the|^<tf|^<tb|^<colg|^<ca') && ['<table>', '</table>', 1] ||
  8. this.test('^<col') && ['<table><colgroup>', '</colgroup><tbody></tbody></table>',2] ||
  9. this.test('^<tr') && ['<table><tbody>', '</tbody></table>', 2] ||
  10. this.test('^<th|^<td') && ['<table><tbody><tr>', '</tr></tbody></table>', 3] ||
  11. this.test('^<li') && ['<ul>', '</ul>', 1] ||
  12. this.test('^<dt|^<dd') && ['<dl>', '</dl>', 1] ||
  13. this.test('^<le') && ['<fieldset>', '</fieldset>', 1] ||
  14. this.test('^<opt') && ['<select multiple="multiple">', '</select>', 1] ||
  15. ['', '', 0];
  16. if( container ){
  17. var el = new Element('div', {html: wrapper[0] + this + wrapper[1]}).getChildren();
  18. while(wrapper[2]--) el = el[0].getChildren();
  19. el.inject( container );
  20. if( callback )callback( container );
  21. return el;
  22. }else{
  23. var div = new Element('div', {html: wrapper[0] + this + wrapper[1]});
  24. div.setStyle("display","none").inject( $(document.body) );
  25. if( callback )callback( div );
  26. var el = div.getChildren();
  27. while(wrapper[2]--) el = el[0].getChildren();
  28. div.dispose();
  29. return el;
  30. }
  31. }
  32. });
  33. MWF.xApplication.Template.Explorer.ComplexView = new Class({
  34. Implements: [Options, Events],
  35. options: {
  36. "style": "default",
  37. "templateUrl": "",
  38. "scrollEnable" : false,
  39. "scrollType" : "xApp_TaskList",
  40. "checkboxEnable" : true,
  41. "pagingEnable" : false,
  42. "documentSortable" : false, //item可以拖动排序,和 onSortCompleted 结合使用
  43. "documentKeyWord" : null,
  44. "pagingPar" : {
  45. position : [ "top" , "bottom" ], //分页条,上下
  46. countPerPage : 0,
  47. visiblePages : 10,
  48. currentPage : 1,
  49. currentItem : null,
  50. hasPagingBar : true,
  51. hasTruningBar : true,
  52. hasNextPage : true,
  53. hasPrevPage : false,
  54. hasJumper : true,
  55. hasReturn : true,
  56. hiddenWithInvalid : true,
  57. text : {
  58. prePage : "",
  59. nextPage : "",
  60. firstPage : "",
  61. lastPage : ""
  62. }
  63. }
  64. },
  65. initialize: function (container, app, explorer, options, para) {
  66. this.container = container;
  67. this.explorer = explorer;
  68. if( para ){
  69. this.app = app || para.app || this.explorer.app;
  70. this.lp = para.lp || this.explorer.lp || this.app.lp;
  71. this.css = para.css || this.explorer.css || this.app.css;
  72. this.actions = para.actions || this.explorer.actions || this.app.actions || this.app.restActions;
  73. }else{
  74. this.app = app || this.explorer.app;
  75. this.lp = this.explorer.lp || this.app.lp;
  76. this.css = this.explorer.css || this.app.css;
  77. this.actions = this.explorer.actions || this.app.actions || this.app.restActions;
  78. }
  79. if (!options.templateUrl) {
  80. options.templateUrl = this.explorer.path + "listItem.json"
  81. } else if (options.templateUrl.indexOf("/") == -1) {
  82. options.templateUrl = this.explorer.path + options.templateUrl;
  83. }
  84. this.setOptions(options);
  85. },
  86. initData: function () {
  87. this.items = [];
  88. this.documents = {};
  89. this.isItemsLoaded = false;
  90. this.isItemLoadding = false;
  91. this.loadItemQueue = 0;
  92. this.count = 0;
  93. //this.controllers =[];
  94. },
  95. load: function () {
  96. this.fireEvent("queryLoad");
  97. this._queryLoad( );
  98. this.initData();
  99. this.ayalyseTemplate();
  100. this.node = new Element("div", {
  101. "styles": this.css.viewContentListNode
  102. }).inject(this.container);
  103. if( this.options.scrollEnable ){
  104. this.setScroll();
  105. }
  106. this.getContentTemplateNode();
  107. this.createViewNode();
  108. this.initSortData(); //点击列排序
  109. this.createViewHead();
  110. this.createViewBody();
  111. this._postLoad();
  112. this.fireEvent("postLoad");
  113. },
  114. reload: function () {
  115. this.clear();
  116. this.node = new Element("div", {
  117. "styles": this.css.viewContentListNode
  118. }).inject(this.container);
  119. this.createViewNode();
  120. this.createViewHead();
  121. this.createViewBody();
  122. },
  123. initSortData: function () {
  124. this.sortField = null;
  125. this.sortType = null;
  126. this.sortFieldDefault = null;
  127. this.sortTypeDefault = null;
  128. },
  129. destroy: function(){
  130. if(this.documentNodeTemplate){
  131. delete this.documentNodeTemplate;
  132. }
  133. if(this.template)delete this.template;
  134. if( this.scrollBar || this.scrollContainerFun ){
  135. this.destroyScroll()
  136. }
  137. if(this.pagingContainerTop ){
  138. if( this.pagingContainerTopCreated ){
  139. this.pagingContainerTop.destroy();
  140. }else{
  141. this.pagingContainerTop.empty();
  142. }
  143. }
  144. if( this.pagingContainerBottom ){
  145. if( this.pagingContainerBottomCreated ){
  146. this.pagingContainerBottom.destroy();
  147. }else{
  148. this.pagingContainerBottom.empty();
  149. }
  150. }
  151. if( this.paging )this.paging.destroy();
  152. this.clear();
  153. //delete this;
  154. },
  155. clear: function () {
  156. if( this.documentDragSort ){
  157. this.documentDragSort.removeLists( this.viewBodyNode || this.viewNode );
  158. this.documentDragSort.detach();
  159. this.documentDragSort = null;
  160. }
  161. this.documents = null;
  162. MWF.release(this.items);
  163. this.items = [];
  164. this.documents = {};
  165. this.node.destroy();
  166. this.container.empty();
  167. this.isItemsLoaded = false;
  168. this.isItemLoadding = false;
  169. this.loadItemQueue = 0;
  170. },
  171. clearBody : function(){
  172. this.items.each( function(item,i){
  173. item.destroy();
  174. });
  175. this.documents = null;
  176. MWF.release(this.items);
  177. this.items = [];
  178. this.documents = {};
  179. },
  180. resort: function (el) {
  181. this.sortField = el.retrieve("sortField");
  182. var sortType = el.retrieve("sortType");
  183. if (sortType == "") {
  184. this.sortType = "asc";
  185. } else if (this.sortType == "asc") {
  186. this.sortType = "desc";
  187. } else {
  188. this.sortField = null;
  189. this.sortType = null;
  190. }
  191. this.reload();
  192. },
  193. destroyScroll: function(){
  194. if( this.options.scrollType == "window" ){
  195. if( this.scrollContainerFun ){
  196. this.container.removeEvent("scroll", this.scrollContainerFun );
  197. this.scrollContainerFun = null;
  198. }
  199. }else{
  200. if(this.scrollBar.scrollVAreaNode){
  201. this.scrollBar.scrollVAreaNode.destroy();
  202. }
  203. delete this.scrollBar;
  204. }
  205. },
  206. setScroll: function(){
  207. if( this.options.scrollType == "window" ){
  208. this.container.setStyle("overflow","auto");
  209. this.scrollContainerFun = function(){
  210. if( !this.options.pagingEnable ){
  211. var scrollSize = this.container.getScrollSize();
  212. var clientSize = this.container.getSize();
  213. var scrollHeight = scrollSize.y - clientSize.y;
  214. if (this.container.scrollTop + 150 > scrollHeight ) {
  215. if (! this.isItemsLoaded) this.loadElementList();
  216. }
  217. }
  218. }.bind(this);
  219. this.container.addEvent("scroll", this.scrollContainerFun )
  220. }else{
  221. MWF.require("MWF.widget.ScrollBar", function () {
  222. this.scrollBar = new MWF.widget.ScrollBar(this.container, {
  223. "indent": false,
  224. "style": this.options.scrollType,
  225. "where": "before",
  226. "distance": 60,
  227. "friction": 4,
  228. "axis": {"x": false, "y": true},
  229. "onScroll": function (y) {
  230. if( !this.options.pagingEnable ){
  231. var scrollSize = this.container.getScrollSize();
  232. var clientSize = this.container.getSize();
  233. var scrollHeight = scrollSize.y - clientSize.y;
  234. if (y + 200 > scrollHeight ) {
  235. if (! this.isItemsLoaded) this.loadElementList();
  236. }
  237. }
  238. }.bind(this)
  239. });
  240. }.bind(this));
  241. }
  242. },
  243. ayalyseTemplate: function () {
  244. MWF.getJSON(this.options.templateUrl, function (json) {
  245. this.template = json;
  246. }.bind(this), false)
  247. },
  248. formatElement: function (container, setting, clear ) {
  249. //container.appendHTML(setting.html);
  250. var el = setting.html.toDOM( container, function( c , el ){
  251. this.formatStyles(c);
  252. this.formatLable(c);
  253. if(container)this.setEventStyle(c, setting);
  254. }.bind(this) )[0];
  255. if( setting.width ){
  256. el.set("width",setting.width )
  257. }
  258. if( clear && container ){
  259. container.empty();
  260. }
  261. return el;
  262. },
  263. formatStyles: function ( container ) {
  264. container.getElements("[class]").each(function (el) {
  265. var className = el.get("class");
  266. if (className && this.css[className]) {
  267. el.setStyles(this.css[className])
  268. }
  269. }.bind(this));
  270. container.getElements("[styles]").each(function (el) {
  271. var styles = el.get("styles");
  272. if (styles && this.css[styles]) {
  273. el.setStyles(this.css[styles])
  274. }
  275. }.bind(this));
  276. },
  277. formatLable: function (container) {
  278. container.getElements("[lable]").each(function (el) {
  279. var lable = el.get("lable");
  280. if (lable && this.lp[lable]) {
  281. el.set("text", this.lp[lable] + (el.get("colon") ? ":" : "") )
  282. }
  283. }.bind(this))
  284. },
  285. createViewNode: function () {
  286. this.fireEvent("queryCreateViewNode");
  287. this._queryCreateViewNode( );
  288. this.viewNode = this.formatElement(this.node, this.template.viewSetting);
  289. this._postCreateViewNode( this.viewNode );
  290. this.fireEvent("postCreateViewNode");
  291. if (!this.viewNode)return;
  292. },
  293. getContentTemplateNode: function(){
  294. this.documentNodeTemplate = this.formatElement(null, this.template.documentSetting);
  295. this.template.items.each(function (item) {
  296. item.nodeTemplate = this.formatElement(null, item.content);
  297. }.bind(this))
  298. },
  299. createViewHead: function () {
  300. this.fireEvent("queryCreateViewHead");
  301. this._queryCreateViewHead( );
  302. if (this.template) {
  303. if (!this.template.headSetting || this.template.headSetting.disable || !this.template.headSetting.html) {
  304. return;
  305. }
  306. }
  307. var _self = this;
  308. var viewHeadNode;
  309. if( this.template.viewHeadSetting ){
  310. viewHeadNode = this.viewHeadNode = this.formatElement(this.viewNode, this.template.viewHeadSetting);
  311. }
  312. var headNode = this.headNode = this.formatElement( viewHeadNode || this.viewNode, this.template.headSetting);
  313. this.headItemNodes = {};
  314. this.template.items.each(function (item) {
  315. if( !item.head )return;
  316. ////如果设置了权限,那么options里需要有 对应的设置项才会展现
  317. // 比如 item.access == isAdmin 那么 this.options.isAdmin要为true才展现
  318. if (item.access && !this.options[item.access])return;
  319. if (item.head.access && !this.options[item.head.access])return;
  320. if( item.name == "$checkbox" && !this.options.checkboxEnable )return;
  321. var headItemNode = this.formatElement(headNode, item.head);
  322. if( item.name ){
  323. this.headItemNodes[item.name] = headItemNode;
  324. }
  325. if (item.name == "$checkbox" && this.options.checkboxEnable ) {
  326. this.checkboxElement = new Element("input", {
  327. "type": "checkbox"
  328. }).inject(headItemNode);
  329. this.checkboxElement.addEvent("click", function () {
  330. this.selectAllCheckbox()
  331. }.bind(this))
  332. }
  333. if (item.defaultSort && item.defaultSort != "") {
  334. this.sortFieldDefault = item.name;
  335. this.sortTypeDefault = item.defaultSort;
  336. }
  337. }.bind(this));
  338. this.template.items.each( function(item){
  339. if (item.name && item.sort && item.sort != "") {
  340. var headItemNode = this.headItemNodes[item.name];
  341. headItemNode.store("sortField", item.name);
  342. if (this.sortField == item.name && this.sortType != "") {
  343. headItemNode.store("sortType", this.sortType);
  344. this.sortIconNode = new Element("div", {
  345. "styles": this.sortType == "asc" ? this.css.sortIconNode_asc : this.css.sortIconNode_desc
  346. }).inject(headItemNode, "bottom");
  347. } else {
  348. headItemNode.store("sortType", "");
  349. this.sortIconNode = new Element("div.sortIconNode", {"styles": this.css.sortIconNode}).inject(headItemNode, "bottom");
  350. }
  351. headItemNode.setStyle("cursor", "pointer");
  352. headItemNode.addEvent("click", function () {
  353. _self.resort(this);
  354. })
  355. }
  356. }.bind(this));
  357. this.fireEvent("postCreateViewHead");
  358. this._postCreateViewHead( headNode )
  359. },
  360. setEventStyle: function (node, setting, bingObj, data) {
  361. var _self = this;
  362. var styles, overStyles, downStyles;
  363. var styleStr = setting.styles;
  364. if (typeOf(styleStr) == "string"){
  365. if (styleStr && styleStr.substr(0, "function".length) == "function") {
  366. eval("var fun = " + styleStr );
  367. styles = fun.call(bingObj, data);
  368. }else{
  369. styles = this.css[styleStr];
  370. }
  371. }else if (typeOf(styleStr) == "object"){
  372. styles = styleStr;
  373. }else if (typeOf(styleStr) == "function"){
  374. eval("var fun = " + styleStr );
  375. styles = fun.call(bingObj, data);
  376. }
  377. if (!styles) {
  378. var s = node.get("styles");
  379. if (!s)node.get("class");
  380. if (s)styles = this.css[s]
  381. }
  382. if (setting.icon) {
  383. if (!styles)styles = {};
  384. styles["background-image"] = "url(" + this.explorer.path + "/" + this.explorer.options.style + "/icon/" + setting.icon + ")";
  385. }
  386. if (typeOf(setting.mouseoverStyles) == "string")overStyles = this.css[setting.mouseoverStyles];
  387. if (typeOf(setting.mouseoverStyles) == "object") overStyles = setting.mouseoverStyles;
  388. if (setting.mouseoverIcon) {
  389. if (!overStyles)overStyles = {};
  390. overStyles["background-image"] = "url(" + this.explorer.path + "/" + this.explorer.options.style + "/icon/" + setting.mouseoverIcon + ")"
  391. }
  392. if (typeOf(setting.mousedownStyles) == "string")downStyles = this.css[setting.mousedownStyles];
  393. if (typeOf(setting.mousedownStyles) == "object") downStyles = setting.mousedownStyles;
  394. if (setting.mousedownIcon) {
  395. if (!downStyles)downStyles = {};
  396. downStyles["background-image"] = "url(" + this.explorer.path + "/" + this.explorer.options.style + "/icon/" + setting.mousedownIcon + ")"
  397. }
  398. if (styles)node.setStyles(styles);
  399. if (overStyles && styles) {
  400. node.addEvent("mouseover", function (ev) {
  401. if( !_self.lockNodeStyle )this.node.setStyles(this.styles);
  402. }.bind({"styles": overStyles, "node":node }));
  403. node.addEvent("mouseout", function (ev) {
  404. if( !_self.lockNodeStyle )this.node.setStyles(this.styles);
  405. }.bind({"styles": styles, "node":node}));
  406. }
  407. if (downStyles && ( overStyles || styles)) {
  408. node.addEvent("mousedown", function (ev) {
  409. if( !_self.lockNodeStyle )this.node.setStyles(this.styles);
  410. }.bind({"styles": downStyles, "node":node}));
  411. node.addEvent("mouseup", function (ev) {
  412. if( !_self.lockNodeStyle )this.node.setStyles(this.styles);
  413. }.bind({"styles": overStyles || styles, "node":node}))
  414. }
  415. },
  416. selectAllCheckbox: function () {
  417. var flag = this.checkboxElement.get("checked");
  418. this.items.each(function (it) {
  419. if (it.checkboxElement)it.checkboxElement.set("checked", flag)
  420. }.bind(this))
  421. },
  422. getCheckedItems : function(){
  423. var checkedItems = [];
  424. this.items.each(function (it) {
  425. if (it.checkboxElement.get("checked")) {
  426. checkedItems.push( it )
  427. }
  428. }.bind(this));
  429. return checkedItems;
  430. },
  431. createViewBody : function(){
  432. if( this.template.viewBodySetting ){
  433. this.viewBodyNode = this.formatElement(this.viewNode, this.template.viewBodySetting);
  434. }
  435. this.loadElementList();
  436. },
  437. loadElementList: function () {
  438. if( this.options.pagingEnable ){
  439. var currentItem = this.options.pagingPar.currentItem;
  440. var countPerPage = this.options.pagingPar.countPerPage;
  441. if( currentItem ){
  442. var pageNum = Math.ceil( currentItem / countPerPage );
  443. var itemNum = currentItem % countPerPage;
  444. this.loadPagingElementList( countPerPage , pageNum, currentItem );
  445. }else{
  446. this.loadPagingElementList( countPerPage , this.options.pagingPar.currentPage ); //使用分页的方式
  447. }
  448. }else{
  449. countPerPage = this.options.pagingPar.countPerPage;
  450. this.loadScrollElementList( countPerPage ); //滚动条下拉取下一页
  451. }
  452. },
  453. loadScrollElementList : function( count ){
  454. if (!this.isItemsLoaded) {
  455. if (!this.isItemLoadding) {
  456. this.isItemLoadding = true;
  457. this._getCurrentPageData(function (json) {
  458. var itemList = [];
  459. this.fireEvent("queryCreateViewBody");
  460. this._queryCreateViewBody( );
  461. var length = this.dataCount = json.count; //|| json.data.length;
  462. if (length <= this.items.length) {
  463. this.isItemsLoaded = true;
  464. }
  465. if( json.data && typeOf( json.data )=="array" ){
  466. json.data.each(function (data ) {
  467. var key = data[ this.options.documentKeyWord || "id" ];
  468. if (!this.documents[key]) {
  469. var item = this._createDocument(data, this.items.length);
  470. this.items.push(item);
  471. if(item)itemList.push( item.node );
  472. this.documents[key] = item;
  473. }
  474. }.bind(this));
  475. }
  476. this.isItemLoadding = false;
  477. if( this.options.documentSortable && itemList.length){
  478. if( this.documentDragSort ){
  479. this.documentDragSort.addItems( itemList );
  480. }else{
  481. this.makeSortable();
  482. }
  483. }
  484. this.fireEvent("postCreateViewBody");
  485. this._postCreateViewBody( this.viewBodyNode || this.viewNode );
  486. if (this.loadItemQueue > 0) {
  487. this.loadItemQueue--;
  488. this.loadElementList();
  489. }
  490. }.bind(this), count);
  491. } else {
  492. this.loadItemQueue++;
  493. }
  494. }
  495. },
  496. loadPagingElementList : function( count, pageNum, itemNum ){
  497. this.currentPage = pageNum || 1;
  498. this._getCurrentPageData(function (json) {
  499. this.items = [];
  500. this.documents = {};
  501. this.fireEvent("queryCreateViewBody");
  502. this._queryCreateViewBody( );
  503. if( this.documentDragSort ){
  504. this.documentDragSort.removeLists( this.viewBodyNode || this.viewNode );
  505. }
  506. this.dataCount = json.count;
  507. this.createPaging( json.count, this.currentPage );
  508. json.data.each(function (data ) {
  509. var item = this._createDocument(data, this.items.length);
  510. this.items.push( item );
  511. var key = data[ this.options.documentKeyWord || "id" ];
  512. this.documents[key] = item;
  513. }.bind(this));
  514. if( this.options.documentSortable && this.items.length){
  515. this.makeSortable();
  516. }
  517. var top;
  518. if( itemNum ){
  519. if( this.options.documentKeyWord ){
  520. top = this.documents[ itemNum ].node.getTop();
  521. }else{
  522. top = this.items[itemNum-1].node.getTop();
  523. }
  524. this.fireEvent( "gotoItem", top );
  525. }
  526. this.fireEvent("postCreateViewBody");
  527. this._postCreateViewBody( this.viewBodyNode || this.viewNode );
  528. }.bind(this), count, pageNum );
  529. },
  530. createPaging : function( itemSize, pageNum ){
  531. if( !this.options.pagingEnable || this.paging )return;
  532. if( this.options.pagingPar.position.indexOf("top") > -1 ){
  533. if( !this.pagingContainerTop ){
  534. this.pagingContainerTopCreated = true;
  535. this.pagingContainerTop = new Element("div", {"styles":this.css.pagingContainer}).inject( this.viewNode, "before" );
  536. }
  537. }
  538. if( this.options.pagingPar.position.indexOf("bottom") > -1 ){
  539. if( !this.pagingContainerBottom ){
  540. this.pagingContainerBottomCreated = true;
  541. this.pagingContainerBottom = new Element("div", {"styles":this.css.pagingContainer}).inject( this.viewNode, "after" );
  542. }
  543. }
  544. var par = Object.merge( this.options.pagingPar, {
  545. itemSize : itemSize,
  546. onJumpingPage : function( par ){
  547. this.loadPagingElementList( this.options.pagingPar.countPerPage, par.pageNum, par.itemNum );
  548. }.bind(this)
  549. });
  550. if( pageNum )par.currentPage = pageNum;
  551. if( this.options.pagingPar.hasPagingBar ){
  552. this.paging = new MWF.xApplication.Template.Explorer.Paging(this.pagingContainerTop, this.pagingContainerBottom, par, this.css);
  553. this.paging.load();
  554. }
  555. },
  556. _getCurrentPageData: function (callback, count, page) {
  557. if( this.options.pagingEnable ){
  558. this.actions.listDetailFilter(page, count, filter, function (json) {
  559. if (callback)callback(json);
  560. }.bind(this))
  561. }else{
  562. if (!count)count = 20;
  563. var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  564. var filter = this.filterData || {};
  565. this.actions.listDetailFilterNext(id, count, filter, function (json) {
  566. if (callback)callback(json);
  567. }.bind(this))
  568. }
  569. },
  570. getCurrentPageNum: function(){
  571. return this.paging.options.currentPage;
  572. },
  573. getPageSize: function(){
  574. return this.paging.options.pageSize;
  575. },
  576. gotoPage : function( page ){
  577. this.paging.gotoPage( page );
  578. },
  579. makeSortable:function(){
  580. this.documentDragSort = new Sortables( this.viewBodyNode || this.viewNode,
  581. {
  582. clone:true,
  583. opacity:0.3,
  584. onStart : function (element, clone) {
  585. if(this.css.itemSortCloneNode)clone.setStyles( this.css.itemSortCloneNode );
  586. this.fireEvent( "documentSortStart", [ element, clone ] );
  587. this._documentSortStart(element, clone);
  588. }.bind(this),
  589. onSort : function (element, clone) {
  590. this.fireEvent( "documentSort", [ element, clone ] );
  591. this._documentSort(element, clone);
  592. }.bind(this),
  593. onComplete : function (element) {
  594. var serial = this.documentDragSort.serialize();
  595. this.fireEvent( "documentSortComplete", [ element, serial ] );
  596. this._documentSortComplete(element, serial);
  597. //var id = element.get("id");
  598. //var idStr = dragSort.serialize();
  599. //var submitData = {
  600. // "ordersymbol":this.filter.ordersymbol,
  601. // "ids":idStr
  602. //};
  603. //this.actions.changeKeyWorkPosition(submitData,function(json){
  604. // this.createViewContent();
  605. //}.bind(this));
  606. }.bind(this)
  607. }
  608. )
  609. },
  610. _createDocument: function (data, index) {
  611. return new MWF.xApplication.Template.Explorer.ComplexDocument(this.viewBodyNode || this.viewNode, data, this.explorer, this, null,index);
  612. },
  613. _openDocument: function (documentData) {
  614. },
  615. _removeDocument: function (documentData, all) {
  616. //var id = document.data.id;
  617. //this.actions.removeDocument(id, function(json){
  618. // //json.data.each(function(item){
  619. // this.items.erase(this.documents[id]);
  620. // this.documents[id].destroy();
  621. // MWF.release(this.documents[id]);
  622. // delete this.documents[id];
  623. // this.app.notice(this.app.lp.deleteDocumentOK, "success");
  624. // // }.bind(this));
  625. //}.bind(this));
  626. },
  627. _create: function () {
  628. MWF.xDesktop.requireApp("Template", "MPopupForm", function(){
  629. this.from = new MPopupForm(this.explorer);
  630. this.from.create();
  631. }.bind(this), false);
  632. },
  633. _queryLoad: function(){
  634. },
  635. _postLoad: function(){
  636. },
  637. _queryCreateViewNode: function(){
  638. },
  639. _postCreateViewNode: function( viewNode ){
  640. },
  641. _queryCreateViewHead:function(){
  642. },
  643. _postCreateViewHead: function( headNode ){
  644. },
  645. _queryCreateViewBody:function(){
  646. },
  647. _postCreateViewBody: function( bodyNode ){
  648. },
  649. _documentSortStart: function( element, clone ){
  650. },
  651. _documentSort: function( element, clone ){
  652. },
  653. _documentSortComplete: function( element, serial ){
  654. }
  655. });
  656. MWF.xApplication.Template.Explorer.ComplexDocument = new Class({
  657. Implements: [Options, Events],
  658. initialize: function (container, data, explorer, view, para, index) {
  659. this.explorer = explorer;
  660. this.data = data;
  661. this.container = container;
  662. this.view = view;
  663. this.index = index;
  664. if( para ){
  665. this.app = para.app || this.view.app || this.explorer.app;
  666. this.lp = para.lp || this.view.lp || this.explorer.lp || this.app.lp;
  667. this.css = para.css || this.view.css || this.explorer.css || this.app.css;
  668. this.actions = para.actions || this.view.actions || this.explorer.actions || this.app.actions || this.app.restActions;
  669. }else{
  670. this.app = this.view.app || this.explorer.app;
  671. this.lp = this.view.lp || this.explorer.lp || this.app.lp;
  672. this.css = this.view.css || this.explorer.css || this.app.css;
  673. this.actions = this.view.actions || this.explorer.actions || this.app.actions || this.app.restActions;
  674. }
  675. this.load();
  676. },
  677. load: function () {
  678. this.fireEvent("queryCreateDocumentNode");
  679. this._queryCreateDocumentNode( this.data );
  680. var _self = this;
  681. this.node = this.view.documentNodeTemplate.clone().inject(this.container);
  682. //this.documentAreaNode = new Element("td", {"styles": this.css.documentNode}).inject(this.node);
  683. this.view.template.items.each(function (item) {
  684. if( item.access && this._getItemAccess(item) ){
  685. this.loadItem(item.name, item.content, item.nodeTemplate)
  686. }else{
  687. this.loadItem(item.name, item.content, item.nodeTemplate)
  688. }
  689. }.bind(this));
  690. var setting = this.view.template.documentSetting;
  691. if( setting.styles || setting.mouseoverStyles || setting.mousedownStyles || setting.icon || setting.mouseoverIcon || setting.mousedownIcon ){
  692. this.view.setEventStyle( this.node, setting, this, this.data );
  693. }
  694. var available = this.getConditionResult(setting.condition);
  695. if( setting.action && this[setting.action] ){
  696. if ( available ){
  697. this.node.addEvent("click", function (ev) {
  698. this.fun.call(_self, this.node, ev);
  699. ev.stopPropagation();
  700. }.bind({fun: this[setting.action], node : this.node}))
  701. }
  702. }
  703. if( setting.event && available ){
  704. this.bindEvent( this.node, setting.event );
  705. }
  706. this.fireEvent("postCreateDocumentNode");
  707. this._postCreateDocumentNode( this.node, this.data )
  708. },
  709. loadItem: function (name, item, nodeTemplate ) {
  710. var itemNode = this[name] = nodeTemplate.clone();
  711. if( this.format(itemNode, name, item) ){
  712. itemNode.inject(this.node);
  713. }
  714. if (item.items) {
  715. var elements = itemNode.getElements("[item]");
  716. if( itemNode.get("item") )elements.push(itemNode);
  717. elements.each(function (el) {
  718. var key = el.get("item");
  719. var sub = item.items[key];
  720. if( sub ){
  721. if( !sub.value && sub.value!="" )sub.value = key;
  722. if( !this.format(el, name, sub) ){
  723. el.dispose()
  724. }
  725. }
  726. }.bind(this))
  727. }
  728. },
  729. format: function (itemNode, name, item) {
  730. var _self = this;
  731. if( name == "$checkbox" && !this.view.options.checkboxEnable )return false;
  732. if (item.access) {
  733. if (!this._getItemAccess(item))return false;
  734. }
  735. var available = this.getConditionResult(item.condition);
  736. if ( item.action && !available) {
  737. return false;
  738. }
  739. //if (item.condition) {
  740. // if (!this.getConditionResult(item.condition))return false;
  741. //}
  742. var show = this.getConditionResult( item.show );
  743. if( !show )itemNode.setStyle("display","none");
  744. if (item.text) {
  745. var text = this.getExecuteResult( item.text );
  746. //var text = item.text;
  747. itemNode.set("text", this.view.lp && this.view.lp[text] ? this.view.lp[text] : text);
  748. }
  749. if (item.title) {
  750. var title = this.getExecuteResult( item.title );
  751. //var title = item.title;
  752. itemNode.set("title", this.view.lp && this.view.lp[title] ? this.view.lp[title] : title);
  753. }
  754. if ( !item.text && item.value && item.value != "") {
  755. if( item.type == "html" ){
  756. itemNode.set("html", this.getValue(item.value));
  757. }else{
  758. itemNode.set("text", this.getValue(item.value));
  759. }
  760. }
  761. if( item.styles || item.mouseoverStyles || item.mousedownStyles || item.icon || item.mouseoverIcon || item.mousedownIcon ){
  762. this.view.setEventStyle( itemNode, item, this, this.data );
  763. }
  764. var action = item.action && this[item.action];
  765. if ( action ) {
  766. if ( available ){
  767. itemNode.addEvent("click", function (ev) {
  768. this.fun.call(_self, this.node, ev);
  769. ev.stopPropagation();
  770. }.bind({fun: action, node : itemNode}))
  771. }else{
  772. return false;
  773. }
  774. }
  775. if( item.event && available ){
  776. this.bindEvent( itemNode, item.event );
  777. }
  778. if( item.attr ){
  779. this.setAttr( itemNode, item.attr );
  780. }
  781. if ( name == "$checkbox" && this.view.options.checkboxEnable ) {
  782. if ( available ){
  783. this.checkboxElement = new Element("input", {
  784. "type": "checkbox"
  785. }).inject(itemNode);
  786. if( item.event ){
  787. this.bindEvent( this.checkboxElement, item.event );
  788. }
  789. if( !item.event || !item.event.contains( "click" ) ){
  790. this.checkboxElement.addEvent("click", function (ev) {
  791. ev.stopPropagation();
  792. }.bind(this));
  793. }
  794. itemNode.addEvent("click", function (ev) {
  795. this.checkboxElement.set("checked", !this.checkboxElement.get("checked"));
  796. ev.stopPropagation();
  797. }.bind(this))
  798. }else{
  799. //return false;
  800. }
  801. }
  802. return true;
  803. },
  804. getExecuteResult : function( str ){
  805. var result = str;
  806. if (str && str.substr(0, 8) == "function") { //"function".length
  807. eval("var fun = " + str);
  808. result = fun.call(this, this.data);
  809. }
  810. return result;
  811. },
  812. getValue: function (str) {
  813. if (str.substr(0, 8 ) == "function") { //"function".length
  814. eval("var fun = " + str);
  815. return fun.call(this, this.data);
  816. } else if (typeOf(this.data[str]) == "number") {
  817. return this.data[str];
  818. } else {
  819. return this.data[str] ? this.data[str] : "";
  820. }
  821. },
  822. getConditionResult: function (str) {
  823. var flag = true;
  824. if (str && str.substr(0, 8) == "function") { //"function".length
  825. eval("var fun = " + str);
  826. flag = fun.call(this, this.data);
  827. }
  828. return flag;
  829. },
  830. setAttr: function(item, attr){
  831. if( !attr || attr == "" || attr == "$none" )return;
  832. if( typeof attr == "string" ){
  833. if( attr.indexOf("^^") > -1 ){
  834. var attrsArr = attr.split("##");
  835. if( attrsArr[0].split("^^").length != 2 )return;
  836. attrs = {};
  837. for(var i=0;i<attrsArr.length;i++){
  838. var aname = attrsArr[i].split("^^")[0];
  839. var afunction = attrsArr[i].split("^^")[1];
  840. if( afunction.substr(0, "function".length) == "function" ){
  841. eval("var fun = " + afunction );
  842. attrs[ aname ] = fun.call(this, this.data); //字符串变对象或function,方法1
  843. }else{
  844. attrs[ aname ] = afunction;
  845. }
  846. }
  847. }else{
  848. //字符串变对象或function,方法2
  849. eval( "var attrs = " + attr );
  850. }
  851. }
  852. if( typeOf(attrs) == "object" ){
  853. for( var a in attrs ){
  854. item.set( a, attrs[a] );
  855. }
  856. }
  857. },
  858. bindEvent: function(item,events){
  859. if( !events || events == "" || events == "$none" )return;
  860. if( typeof events == "string" ){
  861. if( events.indexOf("^^") > -1 ){
  862. var eventsArr = events.split("##");
  863. if( eventsArr[0].split("^^").length != 2 )return;
  864. events = {};
  865. for(var i=0;i<eventsArr.length;i++){
  866. var ename = eventsArr[i].split("^^")[0];
  867. var efunction = eventsArr[i].split("^^")[1];
  868. events[ ename ] = eval( "(function(){ return "+ efunction +" })()" ); //字符串变对象或function,方法1
  869. }
  870. }else{
  871. //字符串变对象或function,方法2
  872. eval( "var events = " + events );
  873. }
  874. }
  875. if( typeOf(events) == "object" ){
  876. for( var e in events ){
  877. item.addEvent( e, function(ev){
  878. this.fun.call( this.bingObj, this.target, ev );
  879. ev.stopPropagation();
  880. }.bind({bingObj : this, target: item, fun : events[e]}));
  881. }
  882. }
  883. },
  884. _getItemAccess: function (item) {
  885. if (item.access && !this.explorer.options[item.access]) {
  886. return false;
  887. } else {
  888. return true;
  889. }
  890. },
  891. _getActionAccess: function (actionData) {
  892. return true;
  893. },
  894. open: function (e) {
  895. //var options = {"documentId": this.data.id }//this.explorer.app.options.application.allowControl};
  896. //this.explorer.app.desktop.openApplication(e, "cms.Document", options);
  897. this.view._openDocument(this.data);
  898. },
  899. remove: function (e) {
  900. var lp = this.app.lp;
  901. var text = lp.deleteDocument.replace(/{title}/g, this.data.title);
  902. var _self = this;
  903. this.node.setStyles(this.css.documentNode_remove);
  904. this.readyRemove = true;
  905. this.view.lockNodeStyle = true;
  906. //this.explorer.app.confirm("warn", e, lp.deleteDocumentTitle, text, 350, 120, function () {
  907. this.app.confirm("warn", e, lp.deleteDocumentTitle, text, 350, 120, function () {
  908. //var inputs = this.content.getElements("input");
  909. //var flag = "";
  910. //for (var i=0; i<inputs.length; i++){
  911. // if (inputs[i].checked){
  912. // flag = inputs[i].get("value");
  913. // break;
  914. // }
  915. //}
  916. //if (flag){
  917. //if (flag=="all"){
  918. //_self.explorer.removeDocument(_self, true);
  919. //}else{
  920. _self.view._removeDocument(_self.data, false);
  921. _self.view.lockNodeStyle = false;
  922. //}
  923. this.close();
  924. //}else{
  925. // this.content.getElement("#deleteDocument_checkInfor").set("text", lp.deleteAllDocumentCheck).setStyle("color", "red");
  926. //}
  927. }, function () {
  928. _self.node.setStyles(_self.css.documentNode);
  929. _self.readyRemove = false;
  930. _self.view.lockNodeStyle = false;
  931. this.close();
  932. });
  933. },
  934. destroy: function () {
  935. this.node.destroy();
  936. //delete this;
  937. },
  938. _queryCreateDocumentNode:function( itemData ){
  939. },
  940. _postCreateDocumentNode: function( itemNode, itemData ){
  941. }
  942. });
  943. MWF.xApplication.Template.Explorer.Paging = new Class({
  944. Implements: [Options, Events],
  945. options : {
  946. position : ["top","bottom"],
  947. countPerPage : 20,
  948. visiblePages : 10,
  949. currentPage : 1,
  950. itemSize : 0,
  951. pageSize : 0,
  952. hasNextPage : true,
  953. hasPrevPage : false,
  954. hasTruningBar : true,
  955. hasJumper : true,
  956. hasReturn : true,
  957. returnText : "返回首页",
  958. hiddenWithDisable: true,
  959. text : {
  960. prePage : "",
  961. nextPage : "",
  962. firstPage : "",
  963. lastPage : ""
  964. }
  965. },
  966. initialize: function (topContainer, bottomContainer, options, css) {
  967. this.setOptions( options || {});
  968. this.topContainer = topContainer;
  969. this.bottomContainer = bottomContainer;
  970. this.css = css;
  971. },
  972. load : function(){
  973. this.fireEvent( "queryLoad", this);
  974. this.options.pageSize = Math.ceil(this.options.itemSize/this.options.countPerPage);
  975. if( ( (this.options.pageSize == 1 || this.options.pageSize == 0) && this.options.hiddenWithDisable ) && !this.options.hasReturn )return;
  976. if( this.topContainer ){
  977. this.topContainer.empty();
  978. if( this.options.hasTruningBar && this.options.position.indexOf("top") > -1 ){
  979. this.createNode( this.topContainer );
  980. }
  981. }
  982. if( this.bottomContainer ){
  983. this.bottomContainer.empty();
  984. if( this.options.hasPrevPage ){
  985. this.createPrevPageNode( this.bottomContainer );
  986. }
  987. if( this.options.hasNextPage ){
  988. this.createNextPageNode( this.bottomContainer );
  989. }
  990. if( this.options.hasTruningBar && this.options.position.indexOf("bottom") > -1 ){
  991. this.createNode( this.bottomContainer );
  992. }
  993. }
  994. this.fireEvent( "postLoad", this);
  995. },
  996. createNode : function( container ){
  997. var _self = this;
  998. var visiblePages = this.options.visiblePages;
  999. var pageSize = this.options.pageSize;
  1000. var currentPage = this.options.currentPage;
  1001. var halfCount = Math.floor( visiblePages / 2);
  1002. var i, max, min;
  1003. if( pageSize <= visiblePages ){
  1004. min = 1;
  1005. max = pageSize;
  1006. }else if( currentPage + halfCount > pageSize ){
  1007. min = pageSize - visiblePages;
  1008. max = pageSize;
  1009. }else if( currentPage - halfCount < 1 ){
  1010. min = 1;
  1011. max = visiblePages;
  1012. }else{
  1013. min = currentPage - halfCount;
  1014. max = currentPage + halfCount;
  1015. }
  1016. var node = this.node = new Element("div.pagingBar", { styles : this.css.pagingBar } ).inject( container );
  1017. if( this.options.hasReturn ){
  1018. var pageReturn = this.pageReturn = new Element( "div.pageReturn" , { styles : this.css.pageReturn , "text" : this.options.returnText } ).inject(node);
  1019. pageReturn.addEvents( {
  1020. "mouseover" : function( ev ){ ev.target.setStyles( this.css.pageReturn_over ) }.bind(this),
  1021. "mouseout" : function( ev ){ ev.target.setStyles( this.css.pageReturn ) }.bind(this),
  1022. "click" : function(){ this.fireEvent( "pageReturn" , this ) }.bind(this)
  1023. })
  1024. }
  1025. if( (pageSize != 1 && pageSize != 0) || !this.options.hiddenWithDisable ){
  1026. if( min > 1 || !this.options.hiddenWithDisable){
  1027. var firstPage = this.firstPage = new Element( "div.firstPage" , { styles : this.css.firstPage, text : "1..." }).inject(node);
  1028. if( this.options.text.firstPage )firstPage.set( "text", this.options.text.firstPage );
  1029. firstPage.addEvents( {
  1030. "mouseover" : function( ev ){ ev.target.setStyles( this.css.firstPage_over ) }.bind(this),
  1031. "mouseout" : function( ev ){ ev.target.setStyles( this.css.firstPage ) }.bind(this),
  1032. "click" : function(){ this.gotoPage(1) }.bind(this)
  1033. } )
  1034. }
  1035. if( currentPage != 1 || !this.options.hiddenWithDisable){
  1036. var prePage = this.prePage = new Element( "div.prePage" , { styles : this.css.prePage } ).inject(node);
  1037. if( this.options.text.prePage )prePage.set( "text", this.options.text.prePage );
  1038. prePage.addEvents( {
  1039. "mouseover" : function( ev ){ ev.target.setStyles( this.css.prePage_over ) }.bind(this),
  1040. "mouseout" : function( ev ){ ev.target.setStyles( this.css.prePage ) }.bind(this),
  1041. "click" : function(){ this.gotoPage( currentPage-1 ) }.bind(this)
  1042. } )
  1043. }
  1044. this.pageTurnNodes = [];
  1045. for( i=min; i<=max; i++ ){
  1046. if( currentPage == i ){
  1047. this.currentPage = new Element("div.currentPage", {"styles" : this.css.currentPage, "text" : i }).inject(node);
  1048. }else{
  1049. var pageTurnNode = new Element("div.pageItem", {"styles" : this.css.pageItem, "text" : i }).inject(node);
  1050. pageTurnNode.addEvents( {
  1051. "mouseover" : function( ev ){ ev.target.setStyles( this.css.pageItem_over ) }.bind(this),
  1052. "mouseout" : function( ev ){ ev.target.setStyles( this.css.pageItem ) }.bind(this),
  1053. "click" : function(){ this.obj.gotoPage( this.num ) }.bind({ obj : this, num : i })
  1054. });
  1055. this.pageTurnNodes.push( pageTurnNode );
  1056. }
  1057. }
  1058. if( this.options.hasJumper ){
  1059. var pageJumper = this.pageJumper = new Element("input.pageJumper", {"styles" : this.css.pageJumper , "title" : "输入页码,按回车跳转"}).inject( node );
  1060. new Element( "div.pageText", {"styles" : this.css.pageText , "text" : "/" + pageSize }).inject( node );
  1061. pageJumper.addEvents( {
  1062. "focus" : function( ev ){ ev.target.setStyles( this.css.pageJumper_over ) }.bind(this),
  1063. "blur" : function( ev ){ ev.target.setStyles( this.css.pageJumper ) }.bind(this),
  1064. "keyup" : function(e){
  1065. this.value=this.value.replace(/[^0-9_]/g,'')
  1066. },
  1067. "keydown" : function(e){
  1068. if(e.code==13 && this.value!="" ){
  1069. _self.gotoPage( this.value );
  1070. e.stopPropagation();
  1071. //e.preventDefault();
  1072. }
  1073. }
  1074. });
  1075. }
  1076. if( currentPage != pageSize || !this.options.hiddenWithDisable){
  1077. var nextPage = this.nextPage = new Element( "div.nextPage" , { styles : this.css.nextPage } ).inject(node);
  1078. if( this.options.text.nextPage )nextPage.set( "text", this.options.text.nextPage );
  1079. nextPage.addEvents( {
  1080. "mouseover" : function( ev ){ ev.target.setStyles( this.css.nextPage_over ) }.bind(this),
  1081. "mouseout" : function( ev ){ ev.target.setStyles( this.css.nextPage ) }.bind(this),
  1082. "click" : function(){ this.gotoPage( currentPage+1 ) }.bind(this)
  1083. } )
  1084. }
  1085. if( max < pageSize || !this.options.hiddenWithDisable){
  1086. var lastPage = this.lastPage = new Element( "div.lastPage" , { styles : this.css.lastPage, text : "..." + pageSize }).inject(node);
  1087. if( this.options.text.lastPage )lastPage.set( "text", this.options.text.lastPage );
  1088. lastPage.addEvents( {
  1089. "mouseover" : function( ev ){ ev.target.setStyles( this.css.lastPage_over ) }.bind(this),
  1090. "mouseout" : function( ev ){ ev.target.setStyles( this.css.lastPage ) }.bind(this),
  1091. "click" : function(){ this.gotoPage( pageSize ) }.bind(this)
  1092. } )
  1093. }
  1094. }
  1095. },
  1096. createNextPageNode : function( container ){
  1097. if( this.nextPageNode ){
  1098. this.nextPageNode.destroy();
  1099. delete this.nextPageNode;
  1100. }
  1101. var pageSize = this.options.pageSize;
  1102. if( this.options.currentPage != pageSize && pageSize != 1 && pageSize != 0 ){
  1103. this.nextPageNode = new Element("div.nextPageNode", {
  1104. "styles" : this.css.nextPageNode,
  1105. "text" : "下一页"
  1106. }).inject(container);
  1107. this.nextPageNode.addEvents( {
  1108. "mouseover" : function( ev ){ ev.target.setStyles( this.css.nextPageNode_over ) }.bind(this),
  1109. "mouseout" : function( ev ){ ev.target.setStyles( this.css.nextPageNode ) }.bind(this),
  1110. "click" : function(){ this.gotoPage( this.options.currentPage+1 ) }.bind(this)
  1111. })
  1112. }
  1113. },
  1114. createPrevPageNode : function( container ){
  1115. if( this.prevPageNode ){
  1116. this.prevPageNode.destroy();
  1117. delete this.prevPageNode;
  1118. }
  1119. var pageSize = this.options.pageSize;
  1120. if( this.options.currentPage != 1 && pageSize != 1 && pageSize != 0 ){
  1121. this.prevPageNode = new Element("div.prevPageNode", {
  1122. "styles" : this.css.prevPageNode,
  1123. "text" : "上一页"
  1124. }).inject(container);
  1125. this.prevPageNode.addEvents( {
  1126. "mouseover" : function( ev ){ ev.target.setStyles( this.css.prevPageNode_over ) }.bind(this),
  1127. "mouseout" : function( ev ){ ev.target.setStyles( this.css.prevPageNode ) }.bind(this),
  1128. "click" : function(){ this.gotoPage( this.options.currentPage-1 ) }.bind(this)
  1129. })
  1130. }
  1131. },
  1132. gotoPage : function( num ){
  1133. if( num < 1 || num > this.options.pageSize )return;
  1134. this.fireEvent( "jumpingPage", { pageNum : num } );
  1135. this.options.currentPage = num;
  1136. this.load();
  1137. },
  1138. gotoItem : function( itemNum ){
  1139. var pageNum = Math.ceil( itemNum / this.options.countPerPage );
  1140. var index = itemNum % this.options.countPerPage;
  1141. this.fireEvent( "jumpingPage", { pageNum : pageNum, itemNum : itemNum, index : index } );
  1142. this.options.currentPage = pageNum;
  1143. this.load();
  1144. },
  1145. destroy : function(){
  1146. if( this.nextPageNode )this.nextPageNode.destroy();
  1147. //delete this;
  1148. }
  1149. });
  1150. //MWF.xApplication.Template.Explorer.PopupForm = new Class({
  1151. // Extends: MPopupForm
  1152. //});