You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 lines
60 KiB
JavaScript

11 months ago
/*!
* Copyright (c) 2013-Now http://jeesite.com All rights reserved.
*
* 通用公共JavaScript注意项目请不要修改公共CSS样式若需要新增或调整请在common.js中覆盖
* @author ThinkGem
* @version 2019-1-6
*/
if(typeof jQuery==="undefined"){throw new Error("JeeSite's JavaScript requires jQuery")}(function($,window,undefined){$(function(){if($.fn.iCheck!==undefined){$("input[type=checkbox].form-control:not(.noicheck),input[type=radio].form-control:not(.noicheck)").each(function(){$(this).iCheck({checkboxClass:"icheckbox_"+($(this).data("style")||"minimal-grey"),radioClass:"iradio_"+($(this).data("style")||"minimal-grey")}).on("ifChanged",function(){try{$(this).valid()}catch(e){}})})}if($.fn.select2!==undefined){$("select.form-control:not(.noselect2)").each(function(){$(this).select2({minimumResultsForSearch:10}).on("change",function(){try{$(this).valid()}catch(e){}})})}if(js.ie){$("a").bind("focus",function(){if(this.blur){this.blur()}})}$("#inputForm input[type=text]:not([readonly]):not([disabled]):not(.nofocus):eq(0)").focus();$("textarea.autoHeight").textareaAutoHieght();$(document).on("click",".addTabPage",function(e){var $this=$(this),href=$this.data("href"),title=$this.data("title")||$this.attr("title")||$this.text();if(href&&href!=""&&href!="blank"){js.addTabPage($this,$.trim(title||js.text("tabpanel.newTabPage")),href);if($this.parent().hasClass("treeview")){top.window.isMenuClickFlag=true;top.window.location.hash=href.replace("#","")}return false}return true});if(js.ie&&js.ie<=9){setTimeout(function(){$("input[placeholder],textarea[placeholder]").placeholder()},500)}if($("#scroll-up").length>0){var btnScrollTop=$("#scroll-up"),isVisible=false;$(window).on("scroll.btnScrollTop",function(){var scroll=$(document).scrollTop(),h=$(window).height(),sh=document.body.scrollHeight;if(scroll>parseInt(h/4)||(scroll>0&&sh>=h&&h+scroll>=sh-1)){if(!isVisible){btnScrollTop.addClass("display");isVisible=true}}else{if(isVisible){btnScrollTop.removeClass("display");isVisible=false}}}).triggerHandler("scroll.btnScrollTop");btnScrollTop.on("click",function(){$("html,body").animate({scrollTop:0},500);return false})}if(typeof FastClick!="undefined"){FastClick.attach(document.body)}});var js={log:function(msg){if(typeof(console)!=="undefined"){console.log(msg)}},error:function(msg){if(typeof(console)!=="undefined"){console.error(msg)}},encodeUrl:function(url){return encodeURIComponent(url)},decodeUrl:function(url){return decodeURIComponent(url)},ie:function(){var agent=navigator.userAgent.toLowerCase();return(!!window.ActiveXObject||"ActiveXObject" in window)?((agent.match(/msie\s(\d+)/)||[])[1]||(agent.match(/Trident/i)&&agent.match(/rv:(\d+)/)||[])[1]||false):false}(),val:function(jsonObj,attrName){if(jsonObj===undefined){return""}if(attrName===undefined||attrName==""){return typeof jsonObj==="string"?jsonObj:""}var ret=jsonObj[attrName],prm=[],p,i;if(ret===undefined){try{if(typeof attrName==="string"){prm=attrName.split(".")}i=prm.length;if(i){ret=jsonObj;while(ret&&i--){p=prm.shift();ret=ret[p]}}}catch(e){}}if(ret===undefined){return""}return ret},hashCode:function(str,caseSensitive){if(caseSensitive!=true){str=str.toLowerCase()}var hash=1315423911,i,ch;for(i=str.length-1;i>=0;i--){ch=str.charCodeAt(i);hash^=((hash<<5)+ch+(hash>>2))}return(hash&2147483647)},loadFile:function(file,callback,error){callback=callback||function(){};error=error||function(data){js.showMessage(data)};var files=typeof file=="string"?[file]:file;var htmlDoc=document.getElementsByTagName("head")[0],okCounts=0,fileCounts=files.length,i,loadFilePath=null;for(i=0;i<fileCounts;i++){var includeFile=null,att=null,ext,hash;loadFilePath=files[i];hash=js.hashCode(loadFilePath);if(document.getElementById("loadHash_"+hash)){okCounts+=1;if(okCounts==fileCounts){callback();return true}continue}att=loadFilePath.split("?")[0].split(".");ext=att[att.length-1].toLowerCase();switch(ext){case"css":includeFile=document.createElement("link");includeFile.setAttribute("rel","stylesheet");includeFile.setAttribute("type","text/css");includeFile.setAttribute("href",loadFilePath);break;case"js":includeFile=document.createElement("script");includeFile.setAttribute("type","text/javascript");includeFile.setAttribute("src",loadFilePath);break;case"jpg":case"jpeg":case"png":case"gif":includeFil
this.id?F+=this.id:(this.id=M,F+=M);F+='"'});F=L.wrap(F+"/>")[S]("ifCreated").parent().append(p.insert);H=X('<ins class="'+g+'"/>').css(H).appendTo(F);L.data(R,{o:p,s:L.attr("style")}).css(G);p.inheritClass&&F[B](I.className||"");p.inheritID&&J&&F.attr("id",R+"-"+J);"static"==F.css("position")&&F.css("position","relative");C(L,!0,j);if(x.length){x.on("click.i mouseover.i mouseout.i touchbegin.i touchend.i",function(k){var Z=k[T],Y=X(this);if(!I[P]){if("click"==Z){if(X(k.target).is("a")){return}C(L,!1,!0)}else{u&&(/ut|nd/.test(Z)?(F[c](m),Y[c](l)):(F[B](m),Y[B](l)))}if(d){k.stopPropagation()}else{return !1}}})}L.on("click.i focus.i blur.i keyup.i keydown.i keypress.i",function(k){var Y=k[T];k=k.keyCode;if("click"==Y){return !1}if("keydown"==Y&&32==k){return I[T]==K&&I[V]||(I[V]?O(L,V):Q(L,V)),!1}if("keyup"==Y&&I[T]==K){!I[V]&&Q(L,V)}else{if(/us|ur/.test(Y)){F["blur"==Y?c:B](z)}}});H.on("click mousedown mouseup mouseover mouseout touchbegin.i touchend.i",function(k){var Z=k[T],Y=/wn|up/.test(Z)?E:m;if(!I[P]){if("click"==Z){C(L,!1,!0)}else{if(/wn|er|in/.test(Z)){F[B](Y)}else{F[c](Y+" "+E)}if(x.length&&u&&Y==m){x[/ut|nd/.test(Z)?c:B](l)}}if(d){k.stopPropagation()}else{return !1}}})})}})(window.jQuery||window.Zepto);(function(f,d,a){var b,g,c;c="resizeEnd";g={delay:150};b=function(i,h,j){if(typeof h==="function"){j=h;h={}}j=j||null;this.element=i;this.settings=f.extend({},g,h);this._defaults=g;this._name=c;this._timeout=false;this._callback=j;return this.init()};b.prototype={init:function(){var h,i;i=this;h=f(this.element);return h.on("resize",function(){return i.initResize()})},getUTCDate:function(i){var h;i=i||new Date();h=Date.UTC(i.getUTCFullYear(),i.getUTCMonth(),i.getUTCDate(),i.getUTCHours(),i.getUTCMinutes(),i.getUTCSeconds(),i.getUTCMilliseconds());return h},initResize:function(){var h;h=this;h.controlTime=h.getUTCDate();if(h._timeout===false){h._timeout=true;return setTimeout(function(){return h.runCallback(h)},h.settings.delay)}},runCallback:function(i){var h;h=i.getUTCDate();if(h-i.controlTime<i.settings.delay){return setTimeout(function(){return i.runCallback(i)},i.settings.delay)}else{i._timeout=false;return i._callback()}}};return f.fn[c]=function(h,i){return this.each(function(){if(!f.data(this,"plugin_"+c)){return f.data(this,"plugin_"+c,new b(this,h,i))}})}})(jQuery,window,document);!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(e){function t(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).ajaxSubmit(r))}function r(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length){return}r=n[0]}var i=this;if(i.clk=r,"image"==r.type){if(void 0!==t.offsetX){i.clk_x=t.offsetX,i.clk_y=t.offsetY}else{if("function"==typeof e.fn.offset){var o=a.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else{i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop}}}setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function a(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var n={};n.fileapi=void 0!==e("<input type='file'/>").get(0).files,n.formdata=void 0!==window.FormData;var i=!!e.fn.prop;e.fn.attr2=function(){if(!i){return this.attr.apply(this,arguments)}var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t){function r(r){var a,n,i=e.param(r,t.traditional).split("&"),o=i.length,s=[];for(a=0;o>a;a++){i[a]=i[a].replace(/\+/g," "),n=i[a].split("="),s.push([decodeURIComponent(n[0]),decodeURIComponent(n[1])])}return s}function o(a){for(var n=new FormData,i=0;i<a.length;i++){n.append(a[i].name,a[i].value)}if(t.extraData){var o=r(t.extraData);for(i=0;i<o.length;i++){o[i]&&n.append(o[i][0],o[i][1])}}t.data=null;var s=e.extend(!0,{},e.ajaxSettings,t,{contentType:!1,processData:!1,cache:!1,type:u||"POST"});t.uploadProgres
var b="";for(var g=0;g<d.length;g++){var f=d.charCodeAt(g);if(f<128){b+=String.fromCharCode(f)}else{if((f>127)&&(f<2048)){b+=String.fromCharCode((f>>6)|192);b+=String.fromCharCode((f&63)|128)}else{b+=String.fromCharCode((f>>12)|224);b+=String.fromCharCode(((f>>6)&63)|128);b+=String.fromCharCode((f&63)|128)}}}return b};_utf8_decode=function(b){var d="";var f=0;var g=c1=c2=0;while(f<b.length){g=b.charCodeAt(f);if(g<128){d+=String.fromCharCode(g);f++}else{if((g>191)&&(g<224)){c2=b.charCodeAt(f+1);d+=String.fromCharCode(((g&31)<<6)|(c2&63));f+=2}else{c2=b.charCodeAt(f+1);c3=b.charCodeAt(f+2);d+=String.fromCharCode(((g&15)<<12)|((c2&63)<<6)|(c3&63));f+=3}}}return d}}})();