jquery.parser.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /**
  2. * EasyUI for jQuery 1.9.4
  3. *
  4. * Copyright (c) 2009-2020 www.jeasyui.com. All rights reserved.
  5. *
  6. * Licensed under the freeware license: http://www.jeasyui.com/license_freeware.php
  7. * To use it on other terms please contact us: info@jeasyui.com
  8. *
  9. */
  10. (function($){
  11. $.easyui={indexOfArray:function(a,o,id){
  12. for(var i=0,_1=a.length;i<_1;i++){
  13. if(id==undefined){
  14. if(a[i]==o){
  15. return i;
  16. }
  17. }else{
  18. if(a[i][o]==id){
  19. return i;
  20. }
  21. }
  22. }
  23. return -1;
  24. },removeArrayItem:function(a,o,id){
  25. if(typeof o=="string"){
  26. for(var i=0,_2=a.length;i<_2;i++){
  27. if(a[i][o]==id){
  28. a.splice(i,1);
  29. return;
  30. }
  31. }
  32. }else{
  33. var _3=this.indexOfArray(a,o);
  34. if(_3!=-1){
  35. a.splice(_3,1);
  36. }
  37. }
  38. },addArrayItem:function(a,o,r){
  39. var _4=this.indexOfArray(a,o,r?r[o]:undefined);
  40. if(_4==-1){
  41. a.push(r?r:o);
  42. }else{
  43. a[_4]=r?r:o;
  44. }
  45. },getArrayItem:function(a,o,id){
  46. var _5=this.indexOfArray(a,o,id);
  47. return _5==-1?null:a[_5];
  48. },forEach:function(_6,_7,_8){
  49. var _9=[];
  50. for(var i=0;i<_6.length;i++){
  51. _9.push(_6[i]);
  52. }
  53. while(_9.length){
  54. var _a=_9.shift();
  55. if(_8(_a)==false){
  56. return;
  57. }
  58. if(_7&&_a.children){
  59. for(var i=_a.children.length-1;i>=0;i--){
  60. _9.unshift(_a.children[i]);
  61. }
  62. }
  63. }
  64. }};
  65. $.parser={auto:true,emptyFn:function(){
  66. },onComplete:function(_b){
  67. },plugins:["draggable","droppable","resizable","pagination","tooltip","linkbutton","menu","sidemenu","menubutton","splitbutton","switchbutton","progressbar","radiobutton","checkbox","tree","textbox","passwordbox","maskedbox","filebox","combo","combobox","combotree","combogrid","combotreegrid","tagbox","numberbox","validatebox","searchbox","spinner","numberspinner","timespinner","datetimespinner","calendar","datebox","datetimebox","timepicker","slider","layout","panel","datagrid","propertygrid","treegrid","datalist","tabs","accordion","window","dialog","form"],parse:function(_c){
  68. var aa=[];
  69. for(var i=0;i<$.parser.plugins.length;i++){
  70. var _d=$.parser.plugins[i];
  71. var r=$(".easyui-"+_d,_c);
  72. if(r.length){
  73. if(r[_d]){
  74. r.each(function(){
  75. $(this)[_d]($.data(this,"options")||{});
  76. });
  77. }else{
  78. aa.push({name:_d,jq:r});
  79. }
  80. }
  81. }
  82. if(aa.length&&window.easyloader){
  83. var _e=[];
  84. for(var i=0;i<aa.length;i++){
  85. _e.push(aa[i].name);
  86. }
  87. easyloader.load(_e,function(){
  88. for(var i=0;i<aa.length;i++){
  89. var _f=aa[i].name;
  90. var jq=aa[i].jq;
  91. jq.each(function(){
  92. $(this)[_f]($.data(this,"options")||{});
  93. });
  94. }
  95. $.parser.onComplete.call($.parser,_c);
  96. });
  97. }else{
  98. $.parser.onComplete.call($.parser,_c);
  99. }
  100. },parseValue:function(_10,_11,_12,_13){
  101. _13=_13||0;
  102. var v=$.trim(String(_11||""));
  103. var _14=v.substr(v.length-1,1);
  104. if(_14=="%"){
  105. v=parseFloat(v.substr(0,v.length-1));
  106. if(_10.toLowerCase().indexOf("width")>=0){
  107. _13+=_12[0].offsetWidth-_12[0].clientWidth;
  108. v=Math.floor((_12.width()-_13)*v/100);
  109. }else{
  110. _13+=_12[0].offsetHeight-_12[0].clientHeight;
  111. v=Math.floor((_12.height()-_13)*v/100);
  112. }
  113. }else{
  114. v=parseInt(v)||undefined;
  115. }
  116. return v;
  117. },parseOptions:function(_15,_16){
  118. var t=$(_15);
  119. var _17={};
  120. var s=$.trim(t.attr("data-options"));
  121. if(s){
  122. if(s.substring(0,1)!="{"){
  123. s="{"+s+"}";
  124. }
  125. _17=(new Function("return "+s))();
  126. }
  127. $.map(["width","height","left","top","minWidth","maxWidth","minHeight","maxHeight"],function(p){
  128. var pv=$.trim(_15.style[p]||"");
  129. if(pv){
  130. if(pv.indexOf("%")==-1){
  131. pv=parseInt(pv);
  132. if(isNaN(pv)){
  133. pv=undefined;
  134. }
  135. }
  136. _17[p]=pv;
  137. }
  138. });
  139. if(_16){
  140. var _18={};
  141. for(var i=0;i<_16.length;i++){
  142. var pp=_16[i];
  143. if(typeof pp=="string"){
  144. _18[pp]=t.attr(pp);
  145. }else{
  146. for(var _19 in pp){
  147. var _1a=pp[_19];
  148. if(_1a=="boolean"){
  149. _18[_19]=t.attr(_19)?(t.attr(_19)=="true"):undefined;
  150. }else{
  151. if(_1a=="number"){
  152. _18[_19]=t.attr(_19)=="0"?0:parseFloat(t.attr(_19))||undefined;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. $.extend(_17,_18);
  159. }
  160. return _17;
  161. },parseVars:function(){
  162. var d=$("<div style=\"position:absolute;top:-1000px;width:100px;height:100px;padding:5px\"></div>").appendTo("body");
  163. $._boxModel=d.outerWidth()!=100;
  164. d.remove();
  165. d=$("<div style=\"position:fixed\"></div>").appendTo("body");
  166. $._positionFixed=(d.css("position")=="fixed");
  167. d.remove();
  168. }};
  169. $(function(){
  170. $.parser.parseVars();
  171. if(!window.easyloader&&$.parser.auto){
  172. $.parser.parse();
  173. }
  174. });
  175. $.fn._outerWidth=function(_1b){
  176. if(_1b==undefined){
  177. if(this[0]==window){
  178. return this.width()||document.body.clientWidth;
  179. }
  180. return this.outerWidth()||0;
  181. }
  182. return this._size("width",_1b);
  183. };
  184. $.fn._outerHeight=function(_1c){
  185. if(_1c==undefined){
  186. if(this[0]==window){
  187. return this.height()||document.body.clientHeight;
  188. }
  189. return this.outerHeight()||0;
  190. }
  191. return this._size("height",_1c);
  192. };
  193. $.fn._scrollLeft=function(_1d){
  194. if(_1d==undefined){
  195. return this.scrollLeft();
  196. }else{
  197. return this.each(function(){
  198. $(this).scrollLeft(_1d);
  199. });
  200. }
  201. };
  202. $.fn._propAttr=$.fn.prop||$.fn.attr;
  203. $.fn._bind=$.fn.on;
  204. $.fn._unbind=$.fn.off;
  205. $.fn._size=function(_1e,_1f){
  206. if(typeof _1e=="string"){
  207. if(_1e=="clear"){
  208. return this.each(function(){
  209. $(this).css({width:"",minWidth:"",maxWidth:"",height:"",minHeight:"",maxHeight:""});
  210. });
  211. }else{
  212. if(_1e=="fit"){
  213. return this.each(function(){
  214. _20(this,this.tagName=="BODY"?$("body"):$(this).parent(),true);
  215. });
  216. }else{
  217. if(_1e=="unfit"){
  218. return this.each(function(){
  219. _20(this,$(this).parent(),false);
  220. });
  221. }else{
  222. if(_1f==undefined){
  223. return _21(this[0],_1e);
  224. }else{
  225. return this.each(function(){
  226. _21(this,_1e,_1f);
  227. });
  228. }
  229. }
  230. }
  231. }
  232. }else{
  233. return this.each(function(){
  234. _1f=_1f||$(this).parent();
  235. $.extend(_1e,_20(this,_1f,_1e.fit)||{});
  236. var r1=_22(this,"width",_1f,_1e);
  237. var r2=_22(this,"height",_1f,_1e);
  238. if(r1||r2){
  239. $(this).addClass("easyui-fluid");
  240. }else{
  241. $(this).removeClass("easyui-fluid");
  242. }
  243. });
  244. }
  245. function _20(_23,_24,fit){
  246. if(!_24.length){
  247. return false;
  248. }
  249. var t=$(_23)[0];
  250. var p=_24[0];
  251. var _25=p.fcount||0;
  252. if(fit){
  253. if(!t.fitted){
  254. t.fitted=true;
  255. p.fcount=_25+1;
  256. $(p).addClass("panel-noscroll");
  257. if(p.tagName=="BODY"){
  258. $("html").addClass("panel-fit");
  259. }
  260. }
  261. return {width:($(p).width()||1),height:($(p).height()||1)};
  262. }else{
  263. if(t.fitted){
  264. t.fitted=false;
  265. p.fcount=_25-1;
  266. if(p.fcount==0){
  267. $(p).removeClass("panel-noscroll");
  268. if(p.tagName=="BODY"){
  269. $("html").removeClass("panel-fit");
  270. }
  271. }
  272. }
  273. return false;
  274. }
  275. };
  276. function _22(_26,_27,_28,_29){
  277. var t=$(_26);
  278. var p=_27;
  279. var p1=p.substr(0,1).toUpperCase()+p.substr(1);
  280. var min=$.parser.parseValue("min"+p1,_29["min"+p1],_28);
  281. var max=$.parser.parseValue("max"+p1,_29["max"+p1],_28);
  282. var val=$.parser.parseValue(p,_29[p],_28);
  283. var _2a=(String(_29[p]||"").indexOf("%")>=0?true:false);
  284. if(!isNaN(val)){
  285. var v=Math.min(Math.max(val,min||0),max||99999);
  286. if(!_2a){
  287. _29[p]=v;
  288. }
  289. t._size("min"+p1,"");
  290. t._size("max"+p1,"");
  291. t._size(p,v);
  292. }else{
  293. t._size(p,"");
  294. t._size("min"+p1,min);
  295. t._size("max"+p1,max);
  296. }
  297. return _2a||_29.fit;
  298. };
  299. function _21(_2b,_2c,_2d){
  300. var t=$(_2b);
  301. if(_2d==undefined){
  302. _2d=parseInt(_2b.style[_2c]);
  303. if(isNaN(_2d)){
  304. return undefined;
  305. }
  306. if($._boxModel){
  307. _2d+=_2e();
  308. }
  309. return _2d;
  310. }else{
  311. if(_2d===""){
  312. t.css(_2c,"");
  313. }else{
  314. if($._boxModel){
  315. _2d-=_2e();
  316. if(_2d<0){
  317. _2d=0;
  318. }
  319. }
  320. t.css(_2c,_2d+"px");
  321. }
  322. }
  323. function _2e(){
  324. if(_2c.toLowerCase().indexOf("width")>=0){
  325. return t.outerWidth()-t.width();
  326. }else{
  327. return t.outerHeight()-t.height();
  328. }
  329. };
  330. };
  331. };
  332. })(jQuery);
  333. (function($){
  334. var _2f=null;
  335. var _30=null;
  336. var _31=false;
  337. function _32(e){
  338. if(e.touches.length!=1){
  339. return;
  340. }
  341. if(!_31){
  342. _31=true;
  343. dblClickTimer=setTimeout(function(){
  344. _31=false;
  345. },500);
  346. }else{
  347. clearTimeout(dblClickTimer);
  348. _31=false;
  349. _33(e,"dblclick");
  350. }
  351. _2f=setTimeout(function(){
  352. _33(e,"contextmenu",3);
  353. },1000);
  354. _33(e,"mousedown");
  355. if($.fn.draggable.isDragging||$.fn.resizable.isResizing){
  356. e.preventDefault();
  357. }
  358. };
  359. function _34(e){
  360. if(e.touches.length!=1){
  361. return;
  362. }
  363. if(_2f){
  364. clearTimeout(_2f);
  365. }
  366. _33(e,"mousemove");
  367. if($.fn.draggable.isDragging||$.fn.resizable.isResizing){
  368. e.preventDefault();
  369. }
  370. };
  371. function _35(e){
  372. if(_2f){
  373. clearTimeout(_2f);
  374. }
  375. _33(e,"mouseup");
  376. if($.fn.draggable.isDragging||$.fn.resizable.isResizing){
  377. e.preventDefault();
  378. }
  379. };
  380. function _33(e,_36,_37){
  381. var _38=new $.Event(_36);
  382. _38.pageX=e.changedTouches[0].pageX;
  383. _38.pageY=e.changedTouches[0].pageY;
  384. _38.which=_37||1;
  385. $(e.target).trigger(_38);
  386. };
  387. if(document.addEventListener){
  388. document.addEventListener("touchstart",_32,true);
  389. document.addEventListener("touchmove",_34,true);
  390. document.addEventListener("touchend",_35,true);
  391. }
  392. })(jQuery);