jquery.parser.js 6.4 KB

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