15861 lines
799 KiB
JavaScript
15861 lines
799 KiB
JavaScript
/**
|
|
* @license
|
|
* Lodash lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
|
|
*/
|
|
;(function(){function n(n,t,r){switch(r.length){case 0:return n.call(t);case 1:return n.call(t,r[0]);case 2:return n.call(t,r[0],r[1]);case 3:return n.call(t,r[0],r[1],r[2])}return n.apply(t,r)}function t(n,t,r,e){for(var u=-1,i=null==n?0:n.length;++u<i;){var o=n[u];t(e,o,r(o),n)}return e}function r(n,t){for(var r=-1,e=null==n?0:n.length;++r<e&&false!==t(n[r],r,n););return n}function e(n,t){for(var r=null==n?0:n.length;r--&&false!==t(n[r],r,n););return n}function u(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(!t(n[r],r,n))return false;
|
|
return true}function i(n,t){for(var r=-1,e=null==n?0:n.length,u=0,i=[];++r<e;){var o=n[r];t(o,r,n)&&(i[u++]=o)}return i}function o(n,t){return!(null==n||!n.length)&&-1<v(n,t,0)}function f(n,t,r){for(var e=-1,u=null==n?0:n.length;++e<u;)if(r(t,n[e]))return true;return false}function c(n,t){for(var r=-1,e=null==n?0:n.length,u=Array(e);++r<e;)u[r]=t(n[r],r,n);return u}function a(n,t){for(var r=-1,e=t.length,u=n.length;++r<e;)n[u+r]=t[r];return n}function l(n,t,r,e){var u=-1,i=null==n?0:n.length;for(e&&i&&(r=n[++u]);++u<i;)r=t(r,n[u],u,n);
|
|
return r}function s(n,t,r,e){var u=null==n?0:n.length;for(e&&u&&(r=n[--u]);u--;)r=t(r,n[u],u,n);return r}function h(n,t){for(var r=-1,e=null==n?0:n.length;++r<e;)if(t(n[r],r,n))return true;return false}function p(n,t,r){var e;return r(n,function(n,r,u){if(t(n,r,u))return e=r,false}),e}function _(n,t,r,e){var u=n.length;for(r+=e?1:-1;e?r--:++r<u;)if(t(n[r],r,n))return r;return-1}function v(n,t,r){if(t===t)n:{--r;for(var e=n.length;++r<e;)if(n[r]===t){n=r;break n}n=-1}else n=_(n,d,r);return n}function g(n,t,r,e){
|
|
--r;for(var u=n.length;++r<u;)if(e(n[r],t))return r;return-1}function d(n){return n!==n}function y(n,t){var r=null==n?0:n.length;return r?m(n,t)/r:F}function b(n){return function(t){return null==t?T:t[n]}}function x(n){return function(t){return null==n?T:n[t]}}function j(n,t,r,e,u){return u(n,function(n,u,i){r=e?(e=false,n):t(r,n,u,i)}),r}function w(n,t){var r=n.length;for(n.sort(t);r--;)n[r]=n[r].c;return n}function m(n,t){for(var r,e=-1,u=n.length;++e<u;){var i=t(n[e]);i!==T&&(r=r===T?i:r+i)}return r;
|
|
}function A(n,t){for(var r=-1,e=Array(n);++r<n;)e[r]=t(r);return e}function k(n,t){return c(t,function(t){return[t,n[t]]})}function E(n){return function(t){return n(t)}}function S(n,t){return c(t,function(t){return n[t]})}function O(n,t){return n.has(t)}function I(n,t){for(var r=-1,e=n.length;++r<e&&-1<v(t,n[r],0););return r}function R(n,t){for(var r=n.length;r--&&-1<v(t,n[r],0););return r}function z(n){return"\\"+Ln[n]}function W(n){var t=-1,r=Array(n.size);return n.forEach(function(n,e){r[++t]=[e,n];
|
|
}),r}function U(n,t){return function(r){return n(t(r))}}function B(n,t){for(var r=-1,e=n.length,u=0,i=[];++r<e;){var o=n[r];o!==t&&"__lodash_placeholder__"!==o||(n[r]="__lodash_placeholder__",i[u++]=r)}return i}function L(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=n}),r}function C(n){var t=-1,r=Array(n.size);return n.forEach(function(n){r[++t]=[n,n]}),r}function D(n){if(Rn.test(n)){for(var t=On.lastIndex=0;On.test(n);)++t;n=t}else n=Qn(n);return n}function M(n){return Rn.test(n)?n.match(On)||[]:n.split("");
|
|
}var T,$=1/0,F=NaN,N=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],P=/\b__p\+='';/g,Z=/\b(__p\+=)''\+/g,q=/(__e\(.*?\)|\b__t\))\+'';/g,V=/&(?:amp|lt|gt|quot|#39);/g,K=/[&<>"']/g,G=RegExp(V.source),H=RegExp(K.source),J=/<%-([\s\S]+?)%>/g,Y=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nn=/^\w*$/,tn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rn=/[\\^$.*+?()[\]{}|]/g,en=RegExp(rn.source),un=/^\s+|\s+$/g,on=/^\s+/,fn=/\s+$/,cn=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,an=/\{\n\/\* \[wrapped with (.+)\] \*/,ln=/,? & /,sn=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,hn=/\\(\\)?/g,pn=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,_n=/\w*$/,vn=/^[-+]0x[0-9a-f]+$/i,gn=/^0b[01]+$/i,dn=/^\[object .+?Constructor\]$/,yn=/^0o[0-7]+$/i,bn=/^(?:0|[1-9]\d*)$/,xn=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,jn=/($^)/,wn=/['\n\r\u2028\u2029\\]/g,mn="[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?(?:\\u200d(?:[^\\ud800-\\udfff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])[\\ufe0e\\ufe0f]?(?:[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|\\ud83c[\\udffb-\\udfff])?)*",An="(?:[\\u2700-\\u27bf]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff])"+mn,kn="(?:[^\\ud800-\\udfff][\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]?|[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]|(?:\\ud83c[\\udde6-\\uddff]){2}|[\\ud800-\\udbff][\\udc00-\\udfff]|[\\ud800-\\udfff])",En=RegExp("['\u2019]","g"),Sn=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]","g"),On=RegExp("\\ud83c[\\udffb-\\udfff](?=\\ud83c[\\udffb-\\udfff])|"+kn+mn,"g"),In=RegExp(["[A-Z\\xc0-\\xd6\\xd8-\\xde]?[a-z\\xdf-\\xf6\\xf8-\\xff]+(?:['\u2019](?:d|ll|m|re|s|t|ve))?(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000]|[A-Z\\xc0-\\xd6\\xd8-\\xde]|$)|(?:[A-Z\\xc0-\\xd6\\xd8-\\xde]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['\u2019](?:D|LL|M|RE|S|T|VE))?(?=[\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000]|[A-Z\\xc0-\\xd6\\xd8-\\xde](?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])|$)|[A-Z\\xc0-\\xd6\\xd8-\\xde]?(?:[a-z\\xdf-\\xf6\\xf8-\\xff]|[^\\ud800-\\udfff\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000\\d+\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde])+(?:['\u2019](?:d|ll|m|re|s|t|ve))?|[A-Z\\xc0-\\xd6\\xd8-\\xde]+(?:['\u2019](?:D|LL|M|RE|S|T|VE))?|\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])|\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])|\\d+",An].join("|"),"g"),Rn=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]"),zn=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Wn="Array Buffer DataView Date Error Float32Array Float64Array Function Int8Array Int16Array Int32Array Map Math Object Promise RegExp Set String Symbol TypeError Uint8Array Uint8ClampedArray Uint16Array Uint32Array WeakMap _ clearTimeout isFinite parseInt setTimeout".split(" "),Un={};
|
|
Un["[object Float32Array]"]=Un["[object Float64Array]"]=Un["[object Int8Array]"]=Un["[object Int16Array]"]=Un["[object Int32Array]"]=Un["[object Uint8Array]"]=Un["[object Uint8ClampedArray]"]=Un["[object Uint16Array]"]=Un["[object Uint32Array]"]=true,Un["[object Arguments]"]=Un["[object Array]"]=Un["[object ArrayBuffer]"]=Un["[object Boolean]"]=Un["[object DataView]"]=Un["[object Date]"]=Un["[object Error]"]=Un["[object Function]"]=Un["[object Map]"]=Un["[object Number]"]=Un["[object Object]"]=Un["[object RegExp]"]=Un["[object Set]"]=Un["[object String]"]=Un["[object WeakMap]"]=false;
|
|
var Bn={};Bn["[object Arguments]"]=Bn["[object Array]"]=Bn["[object ArrayBuffer]"]=Bn["[object DataView]"]=Bn["[object Boolean]"]=Bn["[object Date]"]=Bn["[object Float32Array]"]=Bn["[object Float64Array]"]=Bn["[object Int8Array]"]=Bn["[object Int16Array]"]=Bn["[object Int32Array]"]=Bn["[object Map]"]=Bn["[object Number]"]=Bn["[object Object]"]=Bn["[object RegExp]"]=Bn["[object Set]"]=Bn["[object String]"]=Bn["[object Symbol]"]=Bn["[object Uint8Array]"]=Bn["[object Uint8ClampedArray]"]=Bn["[object Uint16Array]"]=Bn["[object Uint32Array]"]=true,
|
|
Bn["[object Error]"]=Bn["[object Function]"]=Bn["[object WeakMap]"]=false;var Ln={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Cn=parseFloat,Dn=parseInt,Mn=typeof global=="object"&&global&&global.Object===Object&&global,Tn=typeof self=="object"&&self&&self.Object===Object&&self,$n=Mn||Tn||Function("return this")(),Fn=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Nn=Fn&&typeof module=="object"&&module&&!module.nodeType&&module,Pn=Nn&&Nn.exports===Fn,Zn=Pn&&Mn.process,qn=function(){
|
|
try{var n=Nn&&Nn.require&&Nn.require("util").types;return n?n:Zn&&Zn.binding&&Zn.binding("util")}catch(n){}}(),Vn=qn&&qn.isArrayBuffer,Kn=qn&&qn.isDate,Gn=qn&&qn.isMap,Hn=qn&&qn.isRegExp,Jn=qn&&qn.isSet,Yn=qn&&qn.isTypedArray,Qn=b("length"),Xn=x({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e",
|
|
"\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a",
|
|
"\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I",
|
|
"\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r",
|
|
"\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ",
|
|
"\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),nt=x({"&":"&","<":"<",">":">",'"':""","'":"'"}),tt=x({"&":"&","<":"<",">":">",""":'"',"'":"'"}),rt=function x(mn){function An(n){if(yu(n)&&!ff(n)&&!(n instanceof Ln)){if(n instanceof On)return n;if(oi.call(n,"__wrapped__"))return Fe(n)}return new On(n)}function kn(){}function On(n,t){this.__wrapped__=n,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=T}function Ln(n){
|
|
this.__wrapped__=n,this.__actions__=[],this.__dir__=1,this.__filtered__=false,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Mn(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}function Tn(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}function Fn(n){var t=-1,r=null==n?0:n.length;for(this.clear();++t<r;){var e=n[t];this.set(e[0],e[1])}}function Nn(n){var t=-1,r=null==n?0:n.length;for(this.__data__=new Fn;++t<r;)this.add(n[t]);
|
|
}function Zn(n){this.size=(this.__data__=new Tn(n)).size}function qn(n,t){var r,e=ff(n),u=!e&&of(n),i=!e&&!u&&af(n),o=!e&&!u&&!i&&_f(n),u=(e=e||u||i||o)?A(n.length,ni):[],f=u.length;for(r in n)!t&&!oi.call(n,r)||e&&("length"==r||i&&("offset"==r||"parent"==r)||o&&("buffer"==r||"byteLength"==r||"byteOffset"==r)||Se(r,f))||u.push(r);return u}function Qn(n){var t=n.length;return t?n[ir(0,t-1)]:T}function et(n,t){return De(Lr(n),pt(t,0,n.length))}function ut(n){return De(Lr(n))}function it(n,t,r){(r===T||lu(n[t],r))&&(r!==T||t in n)||st(n,t,r);
|
|
}function ot(n,t,r){var e=n[t];oi.call(n,t)&&lu(e,r)&&(r!==T||t in n)||st(n,t,r)}function ft(n,t){for(var r=n.length;r--;)if(lu(n[r][0],t))return r;return-1}function ct(n,t,r,e){return uo(n,function(n,u,i){t(e,n,r(n),i)}),e}function at(n,t){return n&&Cr(t,Wu(t),n)}function lt(n,t){return n&&Cr(t,Uu(t),n)}function st(n,t,r){"__proto__"==t&&Ai?Ai(n,t,{configurable:true,enumerable:true,value:r,writable:true}):n[t]=r}function ht(n,t){for(var r=-1,e=t.length,u=Ku(e),i=null==n;++r<e;)u[r]=i?T:Ru(n,t[r]);return u;
|
|
}function pt(n,t,r){return n===n&&(r!==T&&(n=n<=r?n:r),t!==T&&(n=n>=t?n:t)),n}function _t(n,t,e,u,i,o){var f,c=1&t,a=2&t,l=4&t;if(e&&(f=i?e(n,u,i,o):e(n)),f!==T)return f;if(!du(n))return n;if(u=ff(n)){if(f=me(n),!c)return Lr(n,f)}else{var s=vo(n),h="[object Function]"==s||"[object GeneratorFunction]"==s;if(af(n))return Ir(n,c);if("[object Object]"==s||"[object Arguments]"==s||h&&!i){if(f=a||h?{}:Ae(n),!c)return a?Mr(n,lt(f,n)):Dr(n,at(f,n))}else{if(!Bn[s])return i?n:{};f=ke(n,s,c)}}if(o||(o=new Zn),
|
|
i=o.get(n))return i;if(o.set(n,f),pf(n))return n.forEach(function(r){f.add(_t(r,t,e,r,n,o))}),f;if(sf(n))return n.forEach(function(r,u){f.set(u,_t(r,t,e,u,n,o))}),f;var a=l?a?ve:_e:a?Uu:Wu,p=u?T:a(n);return r(p||n,function(r,u){p&&(u=r,r=n[u]),ot(f,u,_t(r,t,e,u,n,o))}),f}function vt(n){var t=Wu(n);return function(r){return gt(r,n,t)}}function gt(n,t,r){var e=r.length;if(null==n)return!e;for(n=Qu(n);e--;){var u=r[e],i=t[u],o=n[u];if(o===T&&!(u in n)||!i(o))return false}return true}function dt(n,t,r){if(typeof n!="function")throw new ti("Expected a function");
|
|
return bo(function(){n.apply(T,r)},t)}function yt(n,t,r,e){var u=-1,i=o,a=true,l=n.length,s=[],h=t.length;if(!l)return s;r&&(t=c(t,E(r))),e?(i=f,a=false):200<=t.length&&(i=O,a=false,t=new Nn(t));n:for(;++u<l;){var p=n[u],_=null==r?p:r(p),p=e||0!==p?p:0;if(a&&_===_){for(var v=h;v--;)if(t[v]===_)continue n;s.push(p)}else i(t,_,e)||s.push(p)}return s}function bt(n,t){var r=true;return uo(n,function(n,e,u){return r=!!t(n,e,u)}),r}function xt(n,t,r){for(var e=-1,u=n.length;++e<u;){var i=n[e],o=t(i);if(null!=o&&(f===T?o===o&&!wu(o):r(o,f)))var f=o,c=i;
|
|
}return c}function jt(n,t){var r=[];return uo(n,function(n,e,u){t(n,e,u)&&r.push(n)}),r}function wt(n,t,r,e,u){var i=-1,o=n.length;for(r||(r=Ee),u||(u=[]);++i<o;){var f=n[i];0<t&&r(f)?1<t?wt(f,t-1,r,e,u):a(u,f):e||(u[u.length]=f)}return u}function mt(n,t){return n&&oo(n,t,Wu)}function At(n,t){return n&&fo(n,t,Wu)}function kt(n,t){return i(t,function(t){return _u(n[t])})}function Et(n,t){t=Sr(t,n);for(var r=0,e=t.length;null!=n&&r<e;)n=n[Me(t[r++])];return r&&r==e?n:T}function St(n,t,r){return t=t(n),
|
|
ff(n)?t:a(t,r(n))}function Ot(n){if(null==n)return n===T?"[object Undefined]":"[object Null]";if(mi&&mi in Qu(n)){var t=oi.call(n,mi),r=n[mi];try{n[mi]=T;var e=true}catch(n){}var u=ai.call(n);e&&(t?n[mi]=r:delete n[mi]),n=u}else n=ai.call(n);return n}function It(n,t){return n>t}function Rt(n,t){return null!=n&&oi.call(n,t)}function zt(n,t){return null!=n&&t in Qu(n)}function Wt(n,t,r){for(var e=r?f:o,u=n[0].length,i=n.length,a=i,l=Ku(i),s=1/0,h=[];a--;){var p=n[a];a&&t&&(p=c(p,E(t))),s=Ci(p.length,s),
|
|
l[a]=!r&&(t||120<=u&&120<=p.length)?new Nn(a&&p):T}var p=n[0],_=-1,v=l[0];n:for(;++_<u&&h.length<s;){var g=p[_],d=t?t(g):g,g=r||0!==g?g:0;if(v?!O(v,d):!e(h,d,r)){for(a=i;--a;){var y=l[a];if(y?!O(y,d):!e(n[a],d,r))continue n}v&&v.push(d),h.push(g)}}return h}function Ut(n,t,r,e){return mt(n,function(n,u,i){t(e,r(n),u,i)}),e}function Bt(t,r,e){return r=Sr(r,t),t=2>r.length?t:Et(t,hr(r,0,-1)),r=null==t?t:t[Me(Ve(r))],null==r?T:n(r,t,e)}function Lt(n){return yu(n)&&"[object Arguments]"==Ot(n)}function Ct(n){
|
|
return yu(n)&&"[object ArrayBuffer]"==Ot(n)}function Dt(n){return yu(n)&&"[object Date]"==Ot(n)}function Mt(n,t,r,e,u){if(n===t)return true;if(null==n||null==t||!yu(n)&&!yu(t))return n!==n&&t!==t;n:{var i=ff(n),o=ff(t),f=i?"[object Array]":vo(n),c=o?"[object Array]":vo(t),f="[object Arguments]"==f?"[object Object]":f,c="[object Arguments]"==c?"[object Object]":c,a="[object Object]"==f,o="[object Object]"==c;if((c=f==c)&&af(n)){if(!af(t)){t=false;break n}i=true,a=false}if(c&&!a)u||(u=new Zn),t=i||_f(n)?se(n,t,r,e,Mt,u):he(n,t,f,r,e,Mt,u);else{
|
|
if(!(1&r)&&(i=a&&oi.call(n,"__wrapped__"),f=o&&oi.call(t,"__wrapped__"),i||f)){n=i?n.value():n,t=f?t.value():t,u||(u=new Zn),t=Mt(n,t,r,e,u);break n}if(c)t:if(u||(u=new Zn),i=1&r,f=_e(n),o=f.length,c=_e(t).length,o==c||i){for(a=o;a--;){var l=f[a];if(!(i?l in t:oi.call(t,l))){t=false;break t}}if((c=u.get(n))&&u.get(t))t=c==t;else{c=true,u.set(n,t),u.set(t,n);for(var s=i;++a<o;){var l=f[a],h=n[l],p=t[l];if(e)var _=i?e(p,h,l,t,n,u):e(h,p,l,n,t,u);if(_===T?h!==p&&!Mt(h,p,r,e,u):!_){c=false;break}s||(s="constructor"==l);
|
|
}c&&!s&&(r=n.constructor,e=t.constructor,r!=e&&"constructor"in n&&"constructor"in t&&!(typeof r=="function"&&r instanceof r&&typeof e=="function"&&e instanceof e)&&(c=false)),u.delete(n),u.delete(t),t=c}}else t=false;else t=false}}return t}function Tt(n){return yu(n)&&"[object Map]"==vo(n)}function $t(n,t,r,e){var u=r.length,i=u,o=!e;if(null==n)return!i;for(n=Qu(n);u--;){var f=r[u];if(o&&f[2]?f[1]!==n[f[0]]:!(f[0]in n))return false}for(;++u<i;){var f=r[u],c=f[0],a=n[c],l=f[1];if(o&&f[2]){if(a===T&&!(c in n))return false;
|
|
}else{if(f=new Zn,e)var s=e(a,l,c,n,t,f);if(s===T?!Mt(l,a,3,e,f):!s)return false}}return true}function Ft(n){return!(!du(n)||ci&&ci in n)&&(_u(n)?hi:dn).test(Te(n))}function Nt(n){return yu(n)&&"[object RegExp]"==Ot(n)}function Pt(n){return yu(n)&&"[object Set]"==vo(n)}function Zt(n){return yu(n)&&gu(n.length)&&!!Un[Ot(n)]}function qt(n){return typeof n=="function"?n:null==n?$u:typeof n=="object"?ff(n)?Jt(n[0],n[1]):Ht(n):Zu(n)}function Vt(n){if(!ze(n))return Bi(n);var t,r=[];for(t in Qu(n))oi.call(n,t)&&"constructor"!=t&&r.push(t);
|
|
return r}function Kt(n,t){return n<t}function Gt(n,t){var r=-1,e=su(n)?Ku(n.length):[];return uo(n,function(n,u,i){e[++r]=t(n,u,i)}),e}function Ht(n){var t=xe(n);return 1==t.length&&t[0][2]?We(t[0][0],t[0][1]):function(r){return r===n||$t(r,n,t)}}function Jt(n,t){return Ie(n)&&t===t&&!du(t)?We(Me(n),t):function(r){var e=Ru(r,n);return e===T&&e===t?zu(r,n):Mt(t,e,3)}}function Yt(n,t,r,e,u){n!==t&&oo(t,function(i,o){if(du(i)){u||(u=new Zn);var f=u,c=Be(n,o),a=Be(t,o),l=f.get(a);if(!l){var l=e?e(c,a,o+"",n,t,f):T,s=l===T;
|
|
if(s){var h=ff(a),p=!h&&af(a),_=!h&&!p&&_f(a),l=a;h||p||_?ff(c)?l=c:hu(c)?l=Lr(c):p?(s=false,l=Ir(a,true)):_?(s=false,l=zr(a,true)):l=[]:xu(a)||of(a)?(l=c,of(c)?l=Ou(c):du(c)&&!_u(c)||(l=Ae(a))):s=false}s&&(f.set(a,l),Yt(l,a,r,e,f),f.delete(a))}it(n,o,l)}else f=e?e(Be(n,o),i,o+"",n,t,u):T,f===T&&(f=i),it(n,o,f)},Uu)}function Qt(n,t){var r=n.length;if(r)return t+=0>t?r:0,Se(t,r)?n[t]:T}function Xt(n,t,r){var e=-1;return t=c(t.length?t:[$u],E(ye())),n=Gt(n,function(n,r,u){return{a:c(t,function(t){return t(n)}),
|
|
b:++e,c:n}}),w(n,function(n,t){var e;n:{e=-1;for(var u=n.a,i=t.a,o=u.length,f=r.length;++e<o;){var c=Wr(u[e],i[e]);if(c){if(e>=f){e=c;break n}e=c*("desc"==r[e]?-1:1);break n}}e=n.b-t.b}return e})}function nr(n,t){return tr(n,t,function(t,r){return zu(n,r)})}function tr(n,t,r){for(var e=-1,u=t.length,i={};++e<u;){var o=t[e],f=Et(n,o);r(f,o)&&lr(i,Sr(o,n),f)}return i}function rr(n){return function(t){return Et(t,n)}}function er(n,t,r,e){var u=e?g:v,i=-1,o=t.length,f=n;for(n===t&&(t=Lr(t)),r&&(f=c(n,E(r)));++i<o;)for(var a=0,l=t[i],l=r?r(l):l;-1<(a=u(f,l,a,e));)f!==n&&xi.call(f,a,1),
|
|
xi.call(n,a,1);return n}function ur(n,t){for(var r=n?t.length:0,e=r-1;r--;){var u=t[r];if(r==e||u!==i){var i=u;Se(u)?xi.call(n,u,1):xr(n,u)}}return n}function ir(n,t){return n+Ii(Ti()*(t-n+1))}function or(n,t){var r="";if(!n||1>t||9007199254740991<t)return r;do t%2&&(r+=n),(t=Ii(t/2))&&(n+=n);while(t);return r}function fr(n,t){return xo(Ue(n,t,$u),n+"")}function cr(n){return Qn(Lu(n))}function ar(n,t){var r=Lu(n);return De(r,pt(t,0,r.length))}function lr(n,t,r,e){if(!du(n))return n;t=Sr(t,n);for(var u=-1,i=t.length,o=i-1,f=n;null!=f&&++u<i;){
|
|
var c=Me(t[u]),a=r;if(u!=o){var l=f[c],a=e?e(l,c,f):T;a===T&&(a=du(l)?l:Se(t[u+1])?[]:{})}ot(f,c,a),f=f[c]}return n}function sr(n){return De(Lu(n))}function hr(n,t,r){var e=-1,u=n.length;for(0>t&&(t=-t>u?0:u+t),r=r>u?u:r,0>r&&(r+=u),u=t>r?0:r-t>>>0,t>>>=0,r=Ku(u);++e<u;)r[e]=n[e+t];return r}function pr(n,t){var r;return uo(n,function(n,e,u){return r=t(n,e,u),!r}),!!r}function _r(n,t,r){var e=0,u=null==n?e:n.length;if(typeof t=="number"&&t===t&&2147483647>=u){for(;e<u;){var i=e+u>>>1,o=n[i];null!==o&&!wu(o)&&(r?o<=t:o<t)?e=i+1:u=i;
|
|
}return u}return vr(n,t,$u,r)}function vr(n,t,r,e){t=r(t);for(var u=0,i=null==n?0:n.length,o=t!==t,f=null===t,c=wu(t),a=t===T;u<i;){var l=Ii((u+i)/2),s=r(n[l]),h=s!==T,p=null===s,_=s===s,v=wu(s);(o?e||_:a?_&&(e||h):f?_&&h&&(e||!p):c?_&&h&&!p&&(e||!v):p||v?0:e?s<=t:s<t)?u=l+1:i=l}return Ci(i,4294967294)}function gr(n,t){for(var r=-1,e=n.length,u=0,i=[];++r<e;){var o=n[r],f=t?t(o):o;if(!r||!lu(f,c)){var c=f;i[u++]=0===o?0:o}}return i}function dr(n){return typeof n=="number"?n:wu(n)?F:+n}function yr(n){
|
|
if(typeof n=="string")return n;if(ff(n))return c(n,yr)+"";if(wu(n))return ro?ro.call(n):"";var t=n+"";return"0"==t&&1/n==-$?"-0":t}function br(n,t,r){var e=-1,u=o,i=n.length,c=true,a=[],l=a;if(r)c=false,u=f;else if(200<=i){if(u=t?null:so(n))return L(u);c=false,u=O,l=new Nn}else l=t?[]:a;n:for(;++e<i;){var s=n[e],h=t?t(s):s,s=r||0!==s?s:0;if(c&&h===h){for(var p=l.length;p--;)if(l[p]===h)continue n;t&&l.push(h),a.push(s)}else u(l,h,r)||(l!==a&&l.push(h),a.push(s))}return a}function xr(n,t){return t=Sr(t,n),
|
|
n=2>t.length?n:Et(n,hr(t,0,-1)),null==n||delete n[Me(Ve(t))]}function jr(n,t,r,e){for(var u=n.length,i=e?u:-1;(e?i--:++i<u)&&t(n[i],i,n););return r?hr(n,e?0:i,e?i+1:u):hr(n,e?i+1:0,e?u:i)}function wr(n,t){var r=n;return r instanceof Ln&&(r=r.value()),l(t,function(n,t){return t.func.apply(t.thisArg,a([n],t.args))},r)}function mr(n,t,r){var e=n.length;if(2>e)return e?br(n[0]):[];for(var u=-1,i=Ku(e);++u<e;)for(var o=n[u],f=-1;++f<e;)f!=u&&(i[u]=yt(i[u]||o,n[f],t,r));return br(wt(i,1),t,r)}function Ar(n,t,r){
|
|
for(var e=-1,u=n.length,i=t.length,o={};++e<u;)r(o,n[e],e<i?t[e]:T);return o}function kr(n){return hu(n)?n:[]}function Er(n){return typeof n=="function"?n:$u}function Sr(n,t){return ff(n)?n:Ie(n,t)?[n]:jo(Iu(n))}function Or(n,t,r){var e=n.length;return r=r===T?e:r,!t&&r>=e?n:hr(n,t,r)}function Ir(n,t){if(t)return n.slice();var r=n.length,r=gi?gi(r):new n.constructor(r);return n.copy(r),r}function Rr(n){var t=new n.constructor(n.byteLength);return new vi(t).set(new vi(n)),t}function zr(n,t){return new n.constructor(t?Rr(n.buffer):n.buffer,n.byteOffset,n.length);
|
|
}function Wr(n,t){if(n!==t){var r=n!==T,e=null===n,u=n===n,i=wu(n),o=t!==T,f=null===t,c=t===t,a=wu(t);if(!f&&!a&&!i&&n>t||i&&o&&c&&!f&&!a||e&&o&&c||!r&&c||!u)return 1;if(!e&&!i&&!a&&n<t||a&&r&&u&&!e&&!i||f&&r&&u||!o&&u||!c)return-1}return 0}function Ur(n,t,r,e){var u=-1,i=n.length,o=r.length,f=-1,c=t.length,a=Li(i-o,0),l=Ku(c+a);for(e=!e;++f<c;)l[f]=t[f];for(;++u<o;)(e||u<i)&&(l[r[u]]=n[u]);for(;a--;)l[f++]=n[u++];return l}function Br(n,t,r,e){var u=-1,i=n.length,o=-1,f=r.length,c=-1,a=t.length,l=Li(i-f,0),s=Ku(l+a);
|
|
for(e=!e;++u<l;)s[u]=n[u];for(l=u;++c<a;)s[l+c]=t[c];for(;++o<f;)(e||u<i)&&(s[l+r[o]]=n[u++]);return s}function Lr(n,t){var r=-1,e=n.length;for(t||(t=Ku(e));++r<e;)t[r]=n[r];return t}function Cr(n,t,r,e){var u=!r;r||(r={});for(var i=-1,o=t.length;++i<o;){var f=t[i],c=e?e(r[f],n[f],f,r,n):T;c===T&&(c=n[f]),u?st(r,f,c):ot(r,f,c)}return r}function Dr(n,t){return Cr(n,po(n),t)}function Mr(n,t){return Cr(n,_o(n),t)}function Tr(n,r){return function(e,u){var i=ff(e)?t:ct,o=r?r():{};return i(e,n,ye(u,2),o);
|
|
}}function $r(n){return fr(function(t,r){var e=-1,u=r.length,i=1<u?r[u-1]:T,o=2<u?r[2]:T,i=3<n.length&&typeof i=="function"?(u--,i):T;for(o&&Oe(r[0],r[1],o)&&(i=3>u?T:i,u=1),t=Qu(t);++e<u;)(o=r[e])&&n(t,o,e,i);return t})}function Fr(n,t){return function(r,e){if(null==r)return r;if(!su(r))return n(r,e);for(var u=r.length,i=t?u:-1,o=Qu(r);(t?i--:++i<u)&&false!==e(o[i],i,o););return r}}function Nr(n){return function(t,r,e){var u=-1,i=Qu(t);e=e(t);for(var o=e.length;o--;){var f=e[n?o:++u];if(false===r(i[f],f,i))break;
|
|
}return t}}function Pr(n,t,r){function e(){return(this&&this!==$n&&this instanceof e?i:n).apply(u?r:this,arguments)}var u=1&t,i=Vr(n);return e}function Zr(n){return function(t){t=Iu(t);var r=Rn.test(t)?M(t):T,e=r?r[0]:t.charAt(0);return t=r?Or(r,1).join(""):t.slice(1),e[n]()+t}}function qr(n){return function(t){return l(Mu(Du(t).replace(En,"")),n,"")}}function Vr(n){return function(){var t=arguments;switch(t.length){case 0:return new n;case 1:return new n(t[0]);case 2:return new n(t[0],t[1]);case 3:
|
|
return new n(t[0],t[1],t[2]);case 4:return new n(t[0],t[1],t[2],t[3]);case 5:return new n(t[0],t[1],t[2],t[3],t[4]);case 6:return new n(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new n(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var r=eo(n.prototype),t=n.apply(r,t);return du(t)?t:r}}function Kr(t,r,e){function u(){for(var o=arguments.length,f=Ku(o),c=o,a=de(u);c--;)f[c]=arguments[c];return c=3>o&&f[0]!==a&&f[o-1]!==a?[]:B(f,a),o-=c.length,o<e?ue(t,r,Jr,u.placeholder,T,f,c,T,T,e-o):n(this&&this!==$n&&this instanceof u?i:t,this,f);
|
|
}var i=Vr(t);return u}function Gr(n){return function(t,r,e){var u=Qu(t);if(!su(t)){var i=ye(r,3);t=Wu(t),r=function(n){return i(u[n],n,u)}}return r=n(t,r,e),-1<r?u[i?t[r]:r]:T}}function Hr(n){return pe(function(t){var r=t.length,e=r,u=On.prototype.thru;for(n&&t.reverse();e--;){var i=t[e];if(typeof i!="function")throw new ti("Expected a function");if(u&&!o&&"wrapper"==ge(i))var o=new On([],true)}for(e=o?e:r;++e<r;)var i=t[e],u=ge(i),f="wrapper"==u?ho(i):T,o=f&&Re(f[0])&&424==f[1]&&!f[4].length&&1==f[9]?o[ge(f[0])].apply(o,f[3]):1==i.length&&Re(i)?o[u]():o.thru(i);
|
|
return function(){var n=arguments,e=n[0];if(o&&1==n.length&&ff(e))return o.plant(e).value();for(var u=0,n=r?t[u].apply(this,n):e;++u<r;)n=t[u].call(this,n);return n}})}function Jr(n,t,r,e,u,i,o,f,c,a){function l(){for(var d=arguments.length,y=Ku(d),b=d;b--;)y[b]=arguments[b];if(_){var x,j=de(l),b=y.length;for(x=0;b--;)y[b]===j&&++x}if(e&&(y=Ur(y,e,u,_)),i&&(y=Br(y,i,o,_)),d-=x,_&&d<a)return j=B(y,j),ue(n,t,Jr,l.placeholder,r,y,j,f,c,a-d);if(j=h?r:this,b=p?j[n]:n,d=y.length,f){x=y.length;for(var w=Ci(f.length,x),m=Lr(y);w--;){
|
|
var A=f[w];y[w]=Se(A,x)?m[A]:T}}else v&&1<d&&y.reverse();return s&&c<d&&(y.length=c),this&&this!==$n&&this instanceof l&&(b=g||Vr(b)),b.apply(j,y)}var s=128&t,h=1&t,p=2&t,_=24&t,v=512&t,g=p?T:Vr(n);return l}function Yr(n,t){return function(r,e){return Ut(r,n,t(e),{})}}function Qr(n,t){return function(r,e){var u;if(r===T&&e===T)return t;if(r!==T&&(u=r),e!==T){if(u===T)return e;typeof r=="string"||typeof e=="string"?(r=yr(r),e=yr(e)):(r=dr(r),e=dr(e)),u=n(r,e)}return u}}function Xr(t){return pe(function(r){
|
|
return r=c(r,E(ye())),fr(function(e){var u=this;return t(r,function(t){return n(t,u,e)})})})}function ne(n,t){t=t===T?" ":yr(t);var r=t.length;return 2>r?r?or(t,n):t:(r=or(t,Oi(n/D(t))),Rn.test(t)?Or(M(r),0,n).join(""):r.slice(0,n))}function te(t,r,e,u){function i(){for(var r=-1,c=arguments.length,a=-1,l=u.length,s=Ku(l+c),h=this&&this!==$n&&this instanceof i?f:t;++a<l;)s[a]=u[a];for(;c--;)s[a++]=arguments[++r];return n(h,o?e:this,s)}var o=1&r,f=Vr(t);return i}function re(n){return function(t,r,e){
|
|
e&&typeof e!="number"&&Oe(t,r,e)&&(r=e=T),t=Au(t),r===T?(r=t,t=0):r=Au(r),e=e===T?t<r?1:-1:Au(e);var u=-1;r=Li(Oi((r-t)/(e||1)),0);for(var i=Ku(r);r--;)i[n?r:++u]=t,t+=e;return i}}function ee(n){return function(t,r){return typeof t=="string"&&typeof r=="string"||(t=Su(t),r=Su(r)),n(t,r)}}function ue(n,t,r,e,u,i,o,f,c,a){var l=8&t,s=l?o:T;o=l?T:o;var h=l?i:T;return i=l?T:i,t=(t|(l?32:64))&~(l?64:32),4&t||(t&=-4),u=[n,t,u,h,s,i,o,f,c,a],r=r.apply(T,u),Re(n)&&yo(r,u),r.placeholder=e,Le(r,n,t)}function ie(n){
|
|
var t=Yu[n];return function(n,r){if(n=Su(n),r=null==r?0:Ci(ku(r),292)){var e=(Iu(n)+"e").split("e"),e=t(e[0]+"e"+(+e[1]+r)),e=(Iu(e)+"e").split("e");return+(e[0]+"e"+(+e[1]-r))}return t(n)}}function oe(n){return function(t){var r=vo(t);return"[object Map]"==r?W(t):"[object Set]"==r?C(t):k(t,n(t))}}function fe(n,t,r,e,u,i,o,f){var c=2&t;if(!c&&typeof n!="function")throw new ti("Expected a function");var a=e?e.length:0;if(a||(t&=-97,e=u=T),o=o===T?o:Li(ku(o),0),f=f===T?f:ku(f),a-=u?u.length:0,64&t){
|
|
var l=e,s=u;e=u=T}var h=c?T:ho(n);return i=[n,t,r,e,u,l,s,i,o,f],h&&(r=i[1],n=h[1],t=r|n,e=128==n&&8==r||128==n&&256==r&&i[7].length<=h[8]||384==n&&h[7].length<=h[8]&&8==r,131>t||e)&&(1&n&&(i[2]=h[2],t|=1&r?0:4),(r=h[3])&&(e=i[3],i[3]=e?Ur(e,r,h[4]):r,i[4]=e?B(i[3],"__lodash_placeholder__"):h[4]),(r=h[5])&&(e=i[5],i[5]=e?Br(e,r,h[6]):r,i[6]=e?B(i[5],"__lodash_placeholder__"):h[6]),(r=h[7])&&(i[7]=r),128&n&&(i[8]=null==i[8]?h[8]:Ci(i[8],h[8])),null==i[9]&&(i[9]=h[9]),i[0]=h[0],i[1]=t),n=i[0],t=i[1],
|
|
r=i[2],e=i[3],u=i[4],f=i[9]=i[9]===T?c?0:n.length:Li(i[9]-a,0),!f&&24&t&&(t&=-25),c=t&&1!=t?8==t||16==t?Kr(n,t,f):32!=t&&33!=t||u.length?Jr.apply(T,i):te(n,t,r,e):Pr(n,t,r),Le((h?co:yo)(c,i),n,t)}function ce(n,t,r,e){return n===T||lu(n,ei[r])&&!oi.call(e,r)?t:n}function ae(n,t,r,e,u,i){return du(n)&&du(t)&&(i.set(t,n),Yt(n,t,T,ae,i),i.delete(t)),n}function le(n){return xu(n)?T:n}function se(n,t,r,e,u,i){var o=1&r,f=n.length,c=t.length;if(f!=c&&!(o&&c>f))return false;if((c=i.get(n))&&i.get(t))return c==t;
|
|
var c=-1,a=true,l=2&r?new Nn:T;for(i.set(n,t),i.set(t,n);++c<f;){var s=n[c],p=t[c];if(e)var _=o?e(p,s,c,t,n,i):e(s,p,c,n,t,i);if(_!==T){if(_)continue;a=false;break}if(l){if(!h(t,function(n,t){if(!O(l,t)&&(s===n||u(s,n,r,e,i)))return l.push(t)})){a=false;break}}else if(s!==p&&!u(s,p,r,e,i)){a=false;break}}return i.delete(n),i.delete(t),a}function he(n,t,r,e,u,i,o){switch(r){case"[object DataView]":if(n.byteLength!=t.byteLength||n.byteOffset!=t.byteOffset)break;n=n.buffer,t=t.buffer;case"[object ArrayBuffer]":
|
|
if(n.byteLength!=t.byteLength||!i(new vi(n),new vi(t)))break;return true;case"[object Boolean]":case"[object Date]":case"[object Number]":return lu(+n,+t);case"[object Error]":return n.name==t.name&&n.message==t.message;case"[object RegExp]":case"[object String]":return n==t+"";case"[object Map]":var f=W;case"[object Set]":if(f||(f=L),n.size!=t.size&&!(1&e))break;return(r=o.get(n))?r==t:(e|=2,o.set(n,t),t=se(f(n),f(t),e,u,i,o),o.delete(n),t);case"[object Symbol]":if(to)return to.call(n)==to.call(t)}
|
|
return false}function pe(n){return xo(Ue(n,T,Ze),n+"")}function _e(n){return St(n,Wu,po)}function ve(n){return St(n,Uu,_o)}function ge(n){for(var t=n.name+"",r=Gi[t],e=oi.call(Gi,t)?r.length:0;e--;){var u=r[e],i=u.func;if(null==i||i==n)return u.name}return t}function de(n){return(oi.call(An,"placeholder")?An:n).placeholder}function ye(){var n=An.iteratee||Fu,n=n===Fu?qt:n;return arguments.length?n(arguments[0],arguments[1]):n}function be(n,t){var r=n.__data__,e=typeof t;return("string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t)?r[typeof t=="string"?"string":"hash"]:r.map;
|
|
}function xe(n){for(var t=Wu(n),r=t.length;r--;){var e=t[r],u=n[e];t[r]=[e,u,u===u&&!du(u)]}return t}function je(n,t){var r=null==n?T:n[t];return Ft(r)?r:T}function we(n,t,r){t=Sr(t,n);for(var e=-1,u=t.length,i=false;++e<u;){var o=Me(t[e]);if(!(i=null!=n&&r(n,o)))break;n=n[o]}return i||++e!=u?i:(u=null==n?0:n.length,!!u&&gu(u)&&Se(o,u)&&(ff(n)||of(n)))}function me(n){var t=n.length,r=new n.constructor(t);return t&&"string"==typeof n[0]&&oi.call(n,"index")&&(r.index=n.index,r.input=n.input),r}function Ae(n){
|
|
return typeof n.constructor!="function"||ze(n)?{}:eo(di(n))}function ke(n,t,r){var e=n.constructor;switch(t){case"[object ArrayBuffer]":return Rr(n);case"[object Boolean]":case"[object Date]":return new e(+n);case"[object DataView]":return t=r?Rr(n.buffer):n.buffer,new n.constructor(t,n.byteOffset,n.byteLength);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":
|
|
case"[object Uint16Array]":case"[object Uint32Array]":return zr(n,r);case"[object Map]":return new e;case"[object Number]":case"[object String]":return new e(n);case"[object RegExp]":return t=new n.constructor(n.source,_n.exec(n)),t.lastIndex=n.lastIndex,t;case"[object Set]":return new e;case"[object Symbol]":return to?Qu(to.call(n)):{}}}function Ee(n){return ff(n)||of(n)||!!(ji&&n&&n[ji])}function Se(n,t){var r=typeof n;return t=null==t?9007199254740991:t,!!t&&("number"==r||"symbol"!=r&&bn.test(n))&&-1<n&&0==n%1&&n<t;
|
|
}function Oe(n,t,r){if(!du(r))return false;var e=typeof t;return!!("number"==e?su(r)&&Se(t,r.length):"string"==e&&t in r)&&lu(r[t],n)}function Ie(n,t){if(ff(n))return false;var r=typeof n;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=n&&!wu(n))||(nn.test(n)||!X.test(n)||null!=t&&n in Qu(t))}function Re(n){var t=ge(n),r=An[t];return typeof r=="function"&&t in Ln.prototype&&(n===r||(t=ho(r),!!t&&n===t[0]))}function ze(n){var t=n&&n.constructor;return n===(typeof t=="function"&&t.prototype||ei)}function We(n,t){
|
|
return function(r){return null!=r&&(r[n]===t&&(t!==T||n in Qu(r)))}}function Ue(t,r,e){return r=Li(r===T?t.length-1:r,0),function(){for(var u=arguments,i=-1,o=Li(u.length-r,0),f=Ku(o);++i<o;)f[i]=u[r+i];for(i=-1,o=Ku(r+1);++i<r;)o[i]=u[i];return o[r]=e(f),n(t,this,o)}}function Be(n,t){if("__proto__"!=t)return n[t]}function Le(n,t,r){var e=t+"";t=xo;var u,i=$e;return u=(u=e.match(an))?u[1].split(ln):[],r=i(u,r),(i=r.length)&&(u=i-1,r[u]=(1<i?"& ":"")+r[u],r=r.join(2<i?", ":" "),e=e.replace(cn,"{\n/* [wrapped with "+r+"] */\n")),
|
|
t(n,e)}function Ce(n){var t=0,r=0;return function(){var e=Di(),u=16-(e-r);if(r=e,0<u){if(800<=++t)return arguments[0]}else t=0;return n.apply(T,arguments)}}function De(n,t){var r=-1,e=n.length,u=e-1;for(t=t===T?e:t;++r<t;){var e=ir(r,u),i=n[e];n[e]=n[r],n[r]=i}return n.length=t,n}function Me(n){if(typeof n=="string"||wu(n))return n;var t=n+"";return"0"==t&&1/n==-$?"-0":t}function Te(n){if(null!=n){try{return ii.call(n)}catch(n){}return n+""}return""}function $e(n,t){return r(N,function(r){var e="_."+r[0];
|
|
t&r[1]&&!o(n,e)&&n.push(e)}),n.sort()}function Fe(n){if(n instanceof Ln)return n.clone();var t=new On(n.__wrapped__,n.__chain__);return t.__actions__=Lr(n.__actions__),t.__index__=n.__index__,t.__values__=n.__values__,t}function Ne(n,t,r){var e=null==n?0:n.length;return e?(r=null==r?0:ku(r),0>r&&(r=Li(e+r,0)),_(n,ye(t,3),r)):-1}function Pe(n,t,r){var e=null==n?0:n.length;if(!e)return-1;var u=e-1;return r!==T&&(u=ku(r),u=0>r?Li(e+u,0):Ci(u,e-1)),_(n,ye(t,3),u,true)}function Ze(n){return(null==n?0:n.length)?wt(n,1):[];
|
|
}function qe(n){return n&&n.length?n[0]:T}function Ve(n){var t=null==n?0:n.length;return t?n[t-1]:T}function Ke(n,t){return n&&n.length&&t&&t.length?er(n,t):n}function Ge(n){return null==n?n:$i.call(n)}function He(n){if(!n||!n.length)return[];var t=0;return n=i(n,function(n){if(hu(n))return t=Li(n.length,t),true}),A(t,function(t){return c(n,b(t))})}function Je(t,r){if(!t||!t.length)return[];var e=He(t);return null==r?e:c(e,function(t){return n(r,T,t)})}function Ye(n){return n=An(n),n.__chain__=true,n;
|
|
}function Qe(n,t){return t(n)}function Xe(){return this}function nu(n,t){return(ff(n)?r:uo)(n,ye(t,3))}function tu(n,t){return(ff(n)?e:io)(n,ye(t,3))}function ru(n,t){return(ff(n)?c:Gt)(n,ye(t,3))}function eu(n,t,r){return t=r?T:t,t=n&&null==t?n.length:t,fe(n,128,T,T,T,T,t)}function uu(n,t){var r;if(typeof t!="function")throw new ti("Expected a function");return n=ku(n),function(){return 0<--n&&(r=t.apply(this,arguments)),1>=n&&(t=T),r}}function iu(n,t,r){return t=r?T:t,n=fe(n,8,T,T,T,T,T,t),n.placeholder=iu.placeholder,
|
|
n}function ou(n,t,r){return t=r?T:t,n=fe(n,16,T,T,T,T,T,t),n.placeholder=ou.placeholder,n}function fu(n,t,r){function e(t){var r=c,e=a;return c=a=T,_=t,s=n.apply(e,r)}function u(n){var r=n-p;return n-=_,p===T||r>=t||0>r||g&&n>=l}function i(){var n=Go();if(u(n))return o(n);var r,e=bo;r=n-_,n=t-(n-p),r=g?Ci(n,l-r):n,h=e(i,r)}function o(n){return h=T,d&&c?e(n):(c=a=T,s)}function f(){var n=Go(),r=u(n);if(c=arguments,a=this,p=n,r){if(h===T)return _=n=p,h=bo(i,t),v?e(n):s;if(g)return h=bo(i,t),e(p)}return h===T&&(h=bo(i,t)),
|
|
s}var c,a,l,s,h,p,_=0,v=false,g=false,d=true;if(typeof n!="function")throw new ti("Expected a function");return t=Su(t)||0,du(r)&&(v=!!r.leading,l=(g="maxWait"in r)?Li(Su(r.maxWait)||0,t):l,d="trailing"in r?!!r.trailing:d),f.cancel=function(){h!==T&&lo(h),_=0,c=p=a=h=T},f.flush=function(){return h===T?s:o(Go())},f}function cu(n,t){if(typeof n!="function"||null!=t&&typeof t!="function")throw new ti("Expected a function");var r=function(){var e=arguments,u=t?t.apply(this,e):e[0],i=r.cache;return i.has(u)?i.get(u):(e=n.apply(this,e),
|
|
r.cache=i.set(u,e)||i,e)};return r.cache=new(cu.Cache||Fn),r}function au(n){if(typeof n!="function")throw new ti("Expected a function");return function(){var t=arguments;switch(t.length){case 0:return!n.call(this);case 1:return!n.call(this,t[0]);case 2:return!n.call(this,t[0],t[1]);case 3:return!n.call(this,t[0],t[1],t[2])}return!n.apply(this,t)}}function lu(n,t){return n===t||n!==n&&t!==t}function su(n){return null!=n&&gu(n.length)&&!_u(n)}function hu(n){return yu(n)&&su(n)}function pu(n){if(!yu(n))return false;
|
|
var t=Ot(n);return"[object Error]"==t||"[object DOMException]"==t||typeof n.message=="string"&&typeof n.name=="string"&&!xu(n)}function _u(n){return!!du(n)&&(n=Ot(n),"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n)}function vu(n){return typeof n=="number"&&n==ku(n)}function gu(n){return typeof n=="number"&&-1<n&&0==n%1&&9007199254740991>=n}function du(n){var t=typeof n;return null!=n&&("object"==t||"function"==t)}function yu(n){return null!=n&&typeof n=="object";
|
|
}function bu(n){return typeof n=="number"||yu(n)&&"[object Number]"==Ot(n)}function xu(n){return!(!yu(n)||"[object Object]"!=Ot(n))&&(n=di(n),null===n||(n=oi.call(n,"constructor")&&n.constructor,typeof n=="function"&&n instanceof n&&ii.call(n)==li))}function ju(n){return typeof n=="string"||!ff(n)&&yu(n)&&"[object String]"==Ot(n)}function wu(n){return typeof n=="symbol"||yu(n)&&"[object Symbol]"==Ot(n)}function mu(n){if(!n)return[];if(su(n))return ju(n)?M(n):Lr(n);if(wi&&n[wi]){n=n[wi]();for(var t,r=[];!(t=n.next()).done;)r.push(t.value);
|
|
return r}return t=vo(n),("[object Map]"==t?W:"[object Set]"==t?L:Lu)(n)}function Au(n){return n?(n=Su(n),n===$||n===-$?1.7976931348623157e308*(0>n?-1:1):n===n?n:0):0===n?n:0}function ku(n){n=Au(n);var t=n%1;return n===n?t?n-t:n:0}function Eu(n){return n?pt(ku(n),0,4294967295):0}function Su(n){if(typeof n=="number")return n;if(wu(n))return F;if(du(n)&&(n=typeof n.valueOf=="function"?n.valueOf():n,n=du(n)?n+"":n),typeof n!="string")return 0===n?n:+n;n=n.replace(un,"");var t=gn.test(n);return t||yn.test(n)?Dn(n.slice(2),t?2:8):vn.test(n)?F:+n;
|
|
}function Ou(n){return Cr(n,Uu(n))}function Iu(n){return null==n?"":yr(n)}function Ru(n,t,r){return n=null==n?T:Et(n,t),n===T?r:n}function zu(n,t){return null!=n&&we(n,t,zt)}function Wu(n){return su(n)?qn(n):Vt(n)}function Uu(n){if(su(n))n=qn(n,true);else if(du(n)){var t,r=ze(n),e=[];for(t in n)("constructor"!=t||!r&&oi.call(n,t))&&e.push(t);n=e}else{if(t=[],null!=n)for(r in Qu(n))t.push(r);n=t}return n}function Bu(n,t){if(null==n)return{};var r=c(ve(n),function(n){return[n]});return t=ye(t),tr(n,r,function(n,r){
|
|
return t(n,r[0])})}function Lu(n){return null==n?[]:S(n,Wu(n))}function Cu(n){return $f(Iu(n).toLowerCase())}function Du(n){return(n=Iu(n))&&n.replace(xn,Xn).replace(Sn,"")}function Mu(n,t,r){return n=Iu(n),t=r?T:t,t===T?zn.test(n)?n.match(In)||[]:n.match(sn)||[]:n.match(t)||[]}function Tu(n){return function(){return n}}function $u(n){return n}function Fu(n){return qt(typeof n=="function"?n:_t(n,1))}function Nu(n,t,e){var u=Wu(t),i=kt(t,u);null!=e||du(t)&&(i.length||!u.length)||(e=t,t=n,n=this,i=kt(t,Wu(t)));
|
|
var o=!(du(e)&&"chain"in e&&!e.chain),f=_u(n);return r(i,function(r){var e=t[r];n[r]=e,f&&(n.prototype[r]=function(){var t=this.__chain__;if(o||t){var r=n(this.__wrapped__);return(r.__actions__=Lr(this.__actions__)).push({func:e,args:arguments,thisArg:n}),r.__chain__=t,r}return e.apply(n,a([this.value()],arguments))})}),n}function Pu(){}function Zu(n){return Ie(n)?b(Me(n)):rr(n)}function qu(){return[]}function Vu(){return false}mn=null==mn?$n:rt.defaults($n.Object(),mn,rt.pick($n,Wn));var Ku=mn.Array,Gu=mn.Date,Hu=mn.Error,Ju=mn.Function,Yu=mn.Math,Qu=mn.Object,Xu=mn.RegExp,ni=mn.String,ti=mn.TypeError,ri=Ku.prototype,ei=Qu.prototype,ui=mn["__core-js_shared__"],ii=Ju.prototype.toString,oi=ei.hasOwnProperty,fi=0,ci=function(){
|
|
var n=/[^.]+$/.exec(ui&&ui.keys&&ui.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}(),ai=ei.toString,li=ii.call(Qu),si=$n._,hi=Xu("^"+ii.call(oi).replace(rn,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pi=Pn?mn.Buffer:T,_i=mn.Symbol,vi=mn.Uint8Array,gi=pi?pi.allocUnsafe:T,di=U(Qu.getPrototypeOf,Qu),yi=Qu.create,bi=ei.propertyIsEnumerable,xi=ri.splice,ji=_i?_i.isConcatSpreadable:T,wi=_i?_i.iterator:T,mi=_i?_i.toStringTag:T,Ai=function(){try{var n=je(Qu,"defineProperty");
|
|
return n({},"",{}),n}catch(n){}}(),ki=mn.clearTimeout!==$n.clearTimeout&&mn.clearTimeout,Ei=Gu&&Gu.now!==$n.Date.now&&Gu.now,Si=mn.setTimeout!==$n.setTimeout&&mn.setTimeout,Oi=Yu.ceil,Ii=Yu.floor,Ri=Qu.getOwnPropertySymbols,zi=pi?pi.isBuffer:T,Wi=mn.isFinite,Ui=ri.join,Bi=U(Qu.keys,Qu),Li=Yu.max,Ci=Yu.min,Di=Gu.now,Mi=mn.parseInt,Ti=Yu.random,$i=ri.reverse,Fi=je(mn,"DataView"),Ni=je(mn,"Map"),Pi=je(mn,"Promise"),Zi=je(mn,"Set"),qi=je(mn,"WeakMap"),Vi=je(Qu,"create"),Ki=qi&&new qi,Gi={},Hi=Te(Fi),Ji=Te(Ni),Yi=Te(Pi),Qi=Te(Zi),Xi=Te(qi),no=_i?_i.prototype:T,to=no?no.valueOf:T,ro=no?no.toString:T,eo=function(){
|
|
function n(){}return function(t){return du(t)?yi?yi(t):(n.prototype=t,t=new n,n.prototype=T,t):{}}}();An.templateSettings={escape:J,evaluate:Y,interpolate:Q,variable:"",imports:{_:An}},An.prototype=kn.prototype,An.prototype.constructor=An,On.prototype=eo(kn.prototype),On.prototype.constructor=On,Ln.prototype=eo(kn.prototype),Ln.prototype.constructor=Ln,Mn.prototype.clear=function(){this.__data__=Vi?Vi(null):{},this.size=0},Mn.prototype.delete=function(n){return n=this.has(n)&&delete this.__data__[n],
|
|
this.size-=n?1:0,n},Mn.prototype.get=function(n){var t=this.__data__;return Vi?(n=t[n],"__lodash_hash_undefined__"===n?T:n):oi.call(t,n)?t[n]:T},Mn.prototype.has=function(n){var t=this.__data__;return Vi?t[n]!==T:oi.call(t,n)},Mn.prototype.set=function(n,t){var r=this.__data__;return this.size+=this.has(n)?0:1,r[n]=Vi&&t===T?"__lodash_hash_undefined__":t,this},Tn.prototype.clear=function(){this.__data__=[],this.size=0},Tn.prototype.delete=function(n){var t=this.__data__;return n=ft(t,n),!(0>n)&&(n==t.length-1?t.pop():xi.call(t,n,1),
|
|
--this.size,true)},Tn.prototype.get=function(n){var t=this.__data__;return n=ft(t,n),0>n?T:t[n][1]},Tn.prototype.has=function(n){return-1<ft(this.__data__,n)},Tn.prototype.set=function(n,t){var r=this.__data__,e=ft(r,n);return 0>e?(++this.size,r.push([n,t])):r[e][1]=t,this},Fn.prototype.clear=function(){this.size=0,this.__data__={hash:new Mn,map:new(Ni||Tn),string:new Mn}},Fn.prototype.delete=function(n){return n=be(this,n).delete(n),this.size-=n?1:0,n},Fn.prototype.get=function(n){return be(this,n).get(n);
|
|
},Fn.prototype.has=function(n){return be(this,n).has(n)},Fn.prototype.set=function(n,t){var r=be(this,n),e=r.size;return r.set(n,t),this.size+=r.size==e?0:1,this},Nn.prototype.add=Nn.prototype.push=function(n){return this.__data__.set(n,"__lodash_hash_undefined__"),this},Nn.prototype.has=function(n){return this.__data__.has(n)},Zn.prototype.clear=function(){this.__data__=new Tn,this.size=0},Zn.prototype.delete=function(n){var t=this.__data__;return n=t.delete(n),this.size=t.size,n},Zn.prototype.get=function(n){
|
|
return this.__data__.get(n)},Zn.prototype.has=function(n){return this.__data__.has(n)},Zn.prototype.set=function(n,t){var r=this.__data__;if(r instanceof Tn){var e=r.__data__;if(!Ni||199>e.length)return e.push([n,t]),this.size=++r.size,this;r=this.__data__=new Fn(e)}return r.set(n,t),this.size=r.size,this};var uo=Fr(mt),io=Fr(At,true),oo=Nr(),fo=Nr(true),co=Ki?function(n,t){return Ki.set(n,t),n}:$u,ao=Ai?function(n,t){return Ai(n,"toString",{configurable:true,enumerable:false,value:Tu(t),writable:true})}:$u,lo=ki||function(n){
|
|
return $n.clearTimeout(n)},so=Zi&&1/L(new Zi([,-0]))[1]==$?function(n){return new Zi(n)}:Pu,ho=Ki?function(n){return Ki.get(n)}:Pu,po=Ri?function(n){return null==n?[]:(n=Qu(n),i(Ri(n),function(t){return bi.call(n,t)}))}:qu,_o=Ri?function(n){for(var t=[];n;)a(t,po(n)),n=di(n);return t}:qu,vo=Ot;(Fi&&"[object DataView]"!=vo(new Fi(new ArrayBuffer(1)))||Ni&&"[object Map]"!=vo(new Ni)||Pi&&"[object Promise]"!=vo(Pi.resolve())||Zi&&"[object Set]"!=vo(new Zi)||qi&&"[object WeakMap]"!=vo(new qi))&&(vo=function(n){
|
|
var t=Ot(n);if(n=(n="[object Object]"==t?n.constructor:T)?Te(n):"")switch(n){case Hi:return"[object DataView]";case Ji:return"[object Map]";case Yi:return"[object Promise]";case Qi:return"[object Set]";case Xi:return"[object WeakMap]"}return t});var go=ui?_u:Vu,yo=Ce(co),bo=Si||function(n,t){return $n.setTimeout(n,t)},xo=Ce(ao),jo=function(n){n=cu(n,function(n){return 500===t.size&&t.clear(),n});var t=n.cache;return n}(function(n){var t=[];return 46===n.charCodeAt(0)&&t.push(""),n.replace(tn,function(n,r,e,u){
|
|
t.push(e?u.replace(hn,"$1"):r||n)}),t}),wo=fr(function(n,t){return hu(n)?yt(n,wt(t,1,hu,true)):[]}),mo=fr(function(n,t){var r=Ve(t);return hu(r)&&(r=T),hu(n)?yt(n,wt(t,1,hu,true),ye(r,2)):[]}),Ao=fr(function(n,t){var r=Ve(t);return hu(r)&&(r=T),hu(n)?yt(n,wt(t,1,hu,true),T,r):[]}),ko=fr(function(n){var t=c(n,kr);return t.length&&t[0]===n[0]?Wt(t):[]}),Eo=fr(function(n){var t=Ve(n),r=c(n,kr);return t===Ve(r)?t=T:r.pop(),r.length&&r[0]===n[0]?Wt(r,ye(t,2)):[]}),So=fr(function(n){var t=Ve(n),r=c(n,kr);return(t=typeof t=="function"?t:T)&&r.pop(),
|
|
r.length&&r[0]===n[0]?Wt(r,T,t):[]}),Oo=fr(Ke),Io=pe(function(n,t){var r=null==n?0:n.length,e=ht(n,t);return ur(n,c(t,function(n){return Se(n,r)?+n:n}).sort(Wr)),e}),Ro=fr(function(n){return br(wt(n,1,hu,true))}),zo=fr(function(n){var t=Ve(n);return hu(t)&&(t=T),br(wt(n,1,hu,true),ye(t,2))}),Wo=fr(function(n){var t=Ve(n),t=typeof t=="function"?t:T;return br(wt(n,1,hu,true),T,t)}),Uo=fr(function(n,t){return hu(n)?yt(n,t):[]}),Bo=fr(function(n){return mr(i(n,hu))}),Lo=fr(function(n){var t=Ve(n);return hu(t)&&(t=T),
|
|
mr(i(n,hu),ye(t,2))}),Co=fr(function(n){var t=Ve(n),t=typeof t=="function"?t:T;return mr(i(n,hu),T,t)}),Do=fr(He),Mo=fr(function(n){var t=n.length,t=1<t?n[t-1]:T,t=typeof t=="function"?(n.pop(),t):T;return Je(n,t)}),To=pe(function(n){var t=n.length,r=t?n[0]:0,e=this.__wrapped__,u=function(t){return ht(t,n)};return!(1<t||this.__actions__.length)&&e instanceof Ln&&Se(r)?(e=e.slice(r,+r+(t?1:0)),e.__actions__.push({func:Qe,args:[u],thisArg:T}),new On(e,this.__chain__).thru(function(n){return t&&!n.length&&n.push(T),
|
|
n})):this.thru(u)}),$o=Tr(function(n,t,r){oi.call(n,r)?++n[r]:st(n,r,1)}),Fo=Gr(Ne),No=Gr(Pe),Po=Tr(function(n,t,r){oi.call(n,r)?n[r].push(t):st(n,r,[t])}),Zo=fr(function(t,r,e){var u=-1,i=typeof r=="function",o=su(t)?Ku(t.length):[];return uo(t,function(t){o[++u]=i?n(r,t,e):Bt(t,r,e)}),o}),qo=Tr(function(n,t,r){st(n,r,t)}),Vo=Tr(function(n,t,r){n[r?0:1].push(t)},function(){return[[],[]]}),Ko=fr(function(n,t){if(null==n)return[];var r=t.length;return 1<r&&Oe(n,t[0],t[1])?t=[]:2<r&&Oe(t[0],t[1],t[2])&&(t=[t[0]]),
|
|
Xt(n,wt(t,1),[])}),Go=Ei||function(){return $n.Date.now()},Ho=fr(function(n,t,r){var e=1;if(r.length)var u=B(r,de(Ho)),e=32|e;return fe(n,e,t,r,u)}),Jo=fr(function(n,t,r){var e=3;if(r.length)var u=B(r,de(Jo)),e=32|e;return fe(t,e,n,r,u)}),Yo=fr(function(n,t){return dt(n,1,t)}),Qo=fr(function(n,t,r){return dt(n,Su(t)||0,r)});cu.Cache=Fn;var Xo=fr(function(t,r){r=1==r.length&&ff(r[0])?c(r[0],E(ye())):c(wt(r,1),E(ye()));var e=r.length;return fr(function(u){for(var i=-1,o=Ci(u.length,e);++i<o;)u[i]=r[i].call(this,u[i]);
|
|
return n(t,this,u)})}),nf=fr(function(n,t){return fe(n,32,T,t,B(t,de(nf)))}),tf=fr(function(n,t){return fe(n,64,T,t,B(t,de(tf)))}),rf=pe(function(n,t){return fe(n,256,T,T,T,t)}),ef=ee(It),uf=ee(function(n,t){return n>=t}),of=Lt(function(){return arguments}())?Lt:function(n){return yu(n)&&oi.call(n,"callee")&&!bi.call(n,"callee")},ff=Ku.isArray,cf=Vn?E(Vn):Ct,af=zi||Vu,lf=Kn?E(Kn):Dt,sf=Gn?E(Gn):Tt,hf=Hn?E(Hn):Nt,pf=Jn?E(Jn):Pt,_f=Yn?E(Yn):Zt,vf=ee(Kt),gf=ee(function(n,t){return n<=t}),df=$r(function(n,t){
|
|
if(ze(t)||su(t))Cr(t,Wu(t),n);else for(var r in t)oi.call(t,r)&&ot(n,r,t[r])}),yf=$r(function(n,t){Cr(t,Uu(t),n)}),bf=$r(function(n,t,r,e){Cr(t,Uu(t),n,e)}),xf=$r(function(n,t,r,e){Cr(t,Wu(t),n,e)}),jf=pe(ht),wf=fr(function(n,t){n=Qu(n);var r=-1,e=t.length,u=2<e?t[2]:T;for(u&&Oe(t[0],t[1],u)&&(e=1);++r<e;)for(var u=t[r],i=Uu(u),o=-1,f=i.length;++o<f;){var c=i[o],a=n[c];(a===T||lu(a,ei[c])&&!oi.call(n,c))&&(n[c]=u[c])}return n}),mf=fr(function(t){return t.push(T,ae),n(Of,T,t)}),Af=Yr(function(n,t,r){
|
|
null!=t&&typeof t.toString!="function"&&(t=ai.call(t)),n[t]=r},Tu($u)),kf=Yr(function(n,t,r){null!=t&&typeof t.toString!="function"&&(t=ai.call(t)),oi.call(n,t)?n[t].push(r):n[t]=[r]},ye),Ef=fr(Bt),Sf=$r(function(n,t,r){Yt(n,t,r)}),Of=$r(function(n,t,r,e){Yt(n,t,r,e)}),If=pe(function(n,t){var r={};if(null==n)return r;var e=false;t=c(t,function(t){return t=Sr(t,n),e||(e=1<t.length),t}),Cr(n,ve(n),r),e&&(r=_t(r,7,le));for(var u=t.length;u--;)xr(r,t[u]);return r}),Rf=pe(function(n,t){return null==n?{}:nr(n,t);
|
|
}),zf=oe(Wu),Wf=oe(Uu),Uf=qr(function(n,t,r){return t=t.toLowerCase(),n+(r?Cu(t):t)}),Bf=qr(function(n,t,r){return n+(r?"-":"")+t.toLowerCase()}),Lf=qr(function(n,t,r){return n+(r?" ":"")+t.toLowerCase()}),Cf=Zr("toLowerCase"),Df=qr(function(n,t,r){return n+(r?"_":"")+t.toLowerCase()}),Mf=qr(function(n,t,r){return n+(r?" ":"")+$f(t)}),Tf=qr(function(n,t,r){return n+(r?" ":"")+t.toUpperCase()}),$f=Zr("toUpperCase"),Ff=fr(function(t,r){try{return n(t,T,r)}catch(n){return pu(n)?n:new Hu(n)}}),Nf=pe(function(n,t){
|
|
return r(t,function(t){t=Me(t),st(n,t,Ho(n[t],n))}),n}),Pf=Hr(),Zf=Hr(true),qf=fr(function(n,t){return function(r){return Bt(r,n,t)}}),Vf=fr(function(n,t){return function(r){return Bt(n,r,t)}}),Kf=Xr(c),Gf=Xr(u),Hf=Xr(h),Jf=re(),Yf=re(true),Qf=Qr(function(n,t){return n+t},0),Xf=ie("ceil"),nc=Qr(function(n,t){return n/t},1),tc=ie("floor"),rc=Qr(function(n,t){return n*t},1),ec=ie("round"),uc=Qr(function(n,t){return n-t},0);return An.after=function(n,t){if(typeof t!="function")throw new ti("Expected a function");
|
|
return n=ku(n),function(){if(1>--n)return t.apply(this,arguments)}},An.ary=eu,An.assign=df,An.assignIn=yf,An.assignInWith=bf,An.assignWith=xf,An.at=jf,An.before=uu,An.bind=Ho,An.bindAll=Nf,An.bindKey=Jo,An.castArray=function(){if(!arguments.length)return[];var n=arguments[0];return ff(n)?n:[n]},An.chain=Ye,An.chunk=function(n,t,r){if(t=(r?Oe(n,t,r):t===T)?1:Li(ku(t),0),r=null==n?0:n.length,!r||1>t)return[];for(var e=0,u=0,i=Ku(Oi(r/t));e<r;)i[u++]=hr(n,e,e+=t);return i},An.compact=function(n){for(var t=-1,r=null==n?0:n.length,e=0,u=[];++t<r;){
|
|
var i=n[t];i&&(u[e++]=i)}return u},An.concat=function(){var n=arguments.length;if(!n)return[];for(var t=Ku(n-1),r=arguments[0];n--;)t[n-1]=arguments[n];return a(ff(r)?Lr(r):[r],wt(t,1))},An.cond=function(t){var r=null==t?0:t.length,e=ye();return t=r?c(t,function(n){if("function"!=typeof n[1])throw new ti("Expected a function");return[e(n[0]),n[1]]}):[],fr(function(e){for(var u=-1;++u<r;){var i=t[u];if(n(i[0],this,e))return n(i[1],this,e)}})},An.conforms=function(n){return vt(_t(n,1))},An.constant=Tu,
|
|
An.countBy=$o,An.create=function(n,t){var r=eo(n);return null==t?r:at(r,t)},An.curry=iu,An.curryRight=ou,An.debounce=fu,An.defaults=wf,An.defaultsDeep=mf,An.defer=Yo,An.delay=Qo,An.difference=wo,An.differenceBy=mo,An.differenceWith=Ao,An.drop=function(n,t,r){var e=null==n?0:n.length;return e?(t=r||t===T?1:ku(t),hr(n,0>t?0:t,e)):[]},An.dropRight=function(n,t,r){var e=null==n?0:n.length;return e?(t=r||t===T?1:ku(t),t=e-t,hr(n,0,0>t?0:t)):[]},An.dropRightWhile=function(n,t){return n&&n.length?jr(n,ye(t,3),true,true):[];
|
|
},An.dropWhile=function(n,t){return n&&n.length?jr(n,ye(t,3),true):[]},An.fill=function(n,t,r,e){var u=null==n?0:n.length;if(!u)return[];for(r&&typeof r!="number"&&Oe(n,t,r)&&(r=0,e=u),u=n.length,r=ku(r),0>r&&(r=-r>u?0:u+r),e=e===T||e>u?u:ku(e),0>e&&(e+=u),e=r>e?0:Eu(e);r<e;)n[r++]=t;return n},An.filter=function(n,t){return(ff(n)?i:jt)(n,ye(t,3))},An.flatMap=function(n,t){return wt(ru(n,t),1)},An.flatMapDeep=function(n,t){return wt(ru(n,t),$)},An.flatMapDepth=function(n,t,r){return r=r===T?1:ku(r),
|
|
wt(ru(n,t),r)},An.flatten=Ze,An.flattenDeep=function(n){return(null==n?0:n.length)?wt(n,$):[]},An.flattenDepth=function(n,t){return null!=n&&n.length?(t=t===T?1:ku(t),wt(n,t)):[]},An.flip=function(n){return fe(n,512)},An.flow=Pf,An.flowRight=Zf,An.fromPairs=function(n){for(var t=-1,r=null==n?0:n.length,e={};++t<r;){var u=n[t];e[u[0]]=u[1]}return e},An.functions=function(n){return null==n?[]:kt(n,Wu(n))},An.functionsIn=function(n){return null==n?[]:kt(n,Uu(n))},An.groupBy=Po,An.initial=function(n){
|
|
return(null==n?0:n.length)?hr(n,0,-1):[]},An.intersection=ko,An.intersectionBy=Eo,An.intersectionWith=So,An.invert=Af,An.invertBy=kf,An.invokeMap=Zo,An.iteratee=Fu,An.keyBy=qo,An.keys=Wu,An.keysIn=Uu,An.map=ru,An.mapKeys=function(n,t){var r={};return t=ye(t,3),mt(n,function(n,e,u){st(r,t(n,e,u),n)}),r},An.mapValues=function(n,t){var r={};return t=ye(t,3),mt(n,function(n,e,u){st(r,e,t(n,e,u))}),r},An.matches=function(n){return Ht(_t(n,1))},An.matchesProperty=function(n,t){return Jt(n,_t(t,1))},An.memoize=cu,
|
|
An.merge=Sf,An.mergeWith=Of,An.method=qf,An.methodOf=Vf,An.mixin=Nu,An.negate=au,An.nthArg=function(n){return n=ku(n),fr(function(t){return Qt(t,n)})},An.omit=If,An.omitBy=function(n,t){return Bu(n,au(ye(t)))},An.once=function(n){return uu(2,n)},An.orderBy=function(n,t,r,e){return null==n?[]:(ff(t)||(t=null==t?[]:[t]),r=e?T:r,ff(r)||(r=null==r?[]:[r]),Xt(n,t,r))},An.over=Kf,An.overArgs=Xo,An.overEvery=Gf,An.overSome=Hf,An.partial=nf,An.partialRight=tf,An.partition=Vo,An.pick=Rf,An.pickBy=Bu,An.property=Zu,
|
|
An.propertyOf=function(n){return function(t){return null==n?T:Et(n,t)}},An.pull=Oo,An.pullAll=Ke,An.pullAllBy=function(n,t,r){return n&&n.length&&t&&t.length?er(n,t,ye(r,2)):n},An.pullAllWith=function(n,t,r){return n&&n.length&&t&&t.length?er(n,t,T,r):n},An.pullAt=Io,An.range=Jf,An.rangeRight=Yf,An.rearg=rf,An.reject=function(n,t){return(ff(n)?i:jt)(n,au(ye(t,3)))},An.remove=function(n,t){var r=[];if(!n||!n.length)return r;var e=-1,u=[],i=n.length;for(t=ye(t,3);++e<i;){var o=n[e];t(o,e,n)&&(r.push(o),
|
|
u.push(e))}return ur(n,u),r},An.rest=function(n,t){if(typeof n!="function")throw new ti("Expected a function");return t=t===T?t:ku(t),fr(n,t)},An.reverse=Ge,An.sampleSize=function(n,t,r){return t=(r?Oe(n,t,r):t===T)?1:ku(t),(ff(n)?et:ar)(n,t)},An.set=function(n,t,r){return null==n?n:lr(n,t,r)},An.setWith=function(n,t,r,e){return e=typeof e=="function"?e:T,null==n?n:lr(n,t,r,e)},An.shuffle=function(n){return(ff(n)?ut:sr)(n)},An.slice=function(n,t,r){var e=null==n?0:n.length;return e?(r&&typeof r!="number"&&Oe(n,t,r)?(t=0,
|
|
r=e):(t=null==t?0:ku(t),r=r===T?e:ku(r)),hr(n,t,r)):[]},An.sortBy=Ko,An.sortedUniq=function(n){return n&&n.length?gr(n):[]},An.sortedUniqBy=function(n,t){return n&&n.length?gr(n,ye(t,2)):[]},An.split=function(n,t,r){return r&&typeof r!="number"&&Oe(n,t,r)&&(t=r=T),r=r===T?4294967295:r>>>0,r?(n=Iu(n))&&(typeof t=="string"||null!=t&&!hf(t))&&(t=yr(t),!t&&Rn.test(n))?Or(M(n),0,r):n.split(t,r):[]},An.spread=function(t,r){if(typeof t!="function")throw new ti("Expected a function");return r=null==r?0:Li(ku(r),0),
|
|
fr(function(e){var u=e[r];return e=Or(e,0,r),u&&a(e,u),n(t,this,e)})},An.tail=function(n){var t=null==n?0:n.length;return t?hr(n,1,t):[]},An.take=function(n,t,r){return n&&n.length?(t=r||t===T?1:ku(t),hr(n,0,0>t?0:t)):[]},An.takeRight=function(n,t,r){var e=null==n?0:n.length;return e?(t=r||t===T?1:ku(t),t=e-t,hr(n,0>t?0:t,e)):[]},An.takeRightWhile=function(n,t){return n&&n.length?jr(n,ye(t,3),false,true):[]},An.takeWhile=function(n,t){return n&&n.length?jr(n,ye(t,3)):[]},An.tap=function(n,t){return t(n),
|
|
n},An.throttle=function(n,t,r){var e=true,u=true;if(typeof n!="function")throw new ti("Expected a function");return du(r)&&(e="leading"in r?!!r.leading:e,u="trailing"in r?!!r.trailing:u),fu(n,t,{leading:e,maxWait:t,trailing:u})},An.thru=Qe,An.toArray=mu,An.toPairs=zf,An.toPairsIn=Wf,An.toPath=function(n){return ff(n)?c(n,Me):wu(n)?[n]:Lr(jo(Iu(n)))},An.toPlainObject=Ou,An.transform=function(n,t,e){var u=ff(n),i=u||af(n)||_f(n);if(t=ye(t,4),null==e){var o=n&&n.constructor;e=i?u?new o:[]:du(n)&&_u(o)?eo(di(n)):{};
|
|
}return(i?r:mt)(n,function(n,r,u){return t(e,n,r,u)}),e},An.unary=function(n){return eu(n,1)},An.union=Ro,An.unionBy=zo,An.unionWith=Wo,An.uniq=function(n){return n&&n.length?br(n):[]},An.uniqBy=function(n,t){return n&&n.length?br(n,ye(t,2)):[]},An.uniqWith=function(n,t){return t=typeof t=="function"?t:T,n&&n.length?br(n,T,t):[]},An.unset=function(n,t){return null==n||xr(n,t)},An.unzip=He,An.unzipWith=Je,An.update=function(n,t,r){return null!=n&&(r=Er(r),n=lr(n,t,r(Et(n,t)),void 0)),n},An.updateWith=function(n,t,r,e){
|
|
return e=typeof e=="function"?e:T,null!=n&&(r=Er(r),n=lr(n,t,r(Et(n,t)),e)),n},An.values=Lu,An.valuesIn=function(n){return null==n?[]:S(n,Uu(n))},An.without=Uo,An.words=Mu,An.wrap=function(n,t){return nf(Er(t),n)},An.xor=Bo,An.xorBy=Lo,An.xorWith=Co,An.zip=Do,An.zipObject=function(n,t){return Ar(n||[],t||[],ot)},An.zipObjectDeep=function(n,t){return Ar(n||[],t||[],lr)},An.zipWith=Mo,An.entries=zf,An.entriesIn=Wf,An.extend=yf,An.extendWith=bf,Nu(An,An),An.add=Qf,An.attempt=Ff,An.camelCase=Uf,An.capitalize=Cu,
|
|
An.ceil=Xf,An.clamp=function(n,t,r){return r===T&&(r=t,t=T),r!==T&&(r=Su(r),r=r===r?r:0),t!==T&&(t=Su(t),t=t===t?t:0),pt(Su(n),t,r)},An.clone=function(n){return _t(n,4)},An.cloneDeep=function(n){return _t(n,5)},An.cloneDeepWith=function(n,t){return t=typeof t=="function"?t:T,_t(n,5,t)},An.cloneWith=function(n,t){return t=typeof t=="function"?t:T,_t(n,4,t)},An.conformsTo=function(n,t){return null==t||gt(n,t,Wu(t))},An.deburr=Du,An.defaultTo=function(n,t){return null==n||n!==n?t:n},An.divide=nc,An.endsWith=function(n,t,r){
|
|
n=Iu(n),t=yr(t);var e=n.length,e=r=r===T?e:pt(ku(r),0,e);return r-=t.length,0<=r&&n.slice(r,e)==t},An.eq=lu,An.escape=function(n){return(n=Iu(n))&&H.test(n)?n.replace(K,nt):n},An.escapeRegExp=function(n){return(n=Iu(n))&&en.test(n)?n.replace(rn,"\\$&"):n},An.every=function(n,t,r){var e=ff(n)?u:bt;return r&&Oe(n,t,r)&&(t=T),e(n,ye(t,3))},An.find=Fo,An.findIndex=Ne,An.findKey=function(n,t){return p(n,ye(t,3),mt)},An.findLast=No,An.findLastIndex=Pe,An.findLastKey=function(n,t){return p(n,ye(t,3),At);
|
|
},An.floor=tc,An.forEach=nu,An.forEachRight=tu,An.forIn=function(n,t){return null==n?n:oo(n,ye(t,3),Uu)},An.forInRight=function(n,t){return null==n?n:fo(n,ye(t,3),Uu)},An.forOwn=function(n,t){return n&&mt(n,ye(t,3))},An.forOwnRight=function(n,t){return n&&At(n,ye(t,3))},An.get=Ru,An.gt=ef,An.gte=uf,An.has=function(n,t){return null!=n&&we(n,t,Rt)},An.hasIn=zu,An.head=qe,An.identity=$u,An.includes=function(n,t,r,e){return n=su(n)?n:Lu(n),r=r&&!e?ku(r):0,e=n.length,0>r&&(r=Li(e+r,0)),ju(n)?r<=e&&-1<n.indexOf(t,r):!!e&&-1<v(n,t,r);
|
|
},An.indexOf=function(n,t,r){var e=null==n?0:n.length;return e?(r=null==r?0:ku(r),0>r&&(r=Li(e+r,0)),v(n,t,r)):-1},An.inRange=function(n,t,r){return t=Au(t),r===T?(r=t,t=0):r=Au(r),n=Su(n),n>=Ci(t,r)&&n<Li(t,r)},An.invoke=Ef,An.isArguments=of,An.isArray=ff,An.isArrayBuffer=cf,An.isArrayLike=su,An.isArrayLikeObject=hu,An.isBoolean=function(n){return true===n||false===n||yu(n)&&"[object Boolean]"==Ot(n)},An.isBuffer=af,An.isDate=lf,An.isElement=function(n){return yu(n)&&1===n.nodeType&&!xu(n)},An.isEmpty=function(n){
|
|
if(null==n)return true;if(su(n)&&(ff(n)||typeof n=="string"||typeof n.splice=="function"||af(n)||_f(n)||of(n)))return!n.length;var t=vo(n);if("[object Map]"==t||"[object Set]"==t)return!n.size;if(ze(n))return!Vt(n).length;for(var r in n)if(oi.call(n,r))return false;return true},An.isEqual=function(n,t){return Mt(n,t)},An.isEqualWith=function(n,t,r){var e=(r=typeof r=="function"?r:T)?r(n,t):T;return e===T?Mt(n,t,T,r):!!e},An.isError=pu,An.isFinite=function(n){return typeof n=="number"&&Wi(n)},An.isFunction=_u,
|
|
An.isInteger=vu,An.isLength=gu,An.isMap=sf,An.isMatch=function(n,t){return n===t||$t(n,t,xe(t))},An.isMatchWith=function(n,t,r){return r=typeof r=="function"?r:T,$t(n,t,xe(t),r)},An.isNaN=function(n){return bu(n)&&n!=+n},An.isNative=function(n){if(go(n))throw new Hu("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Ft(n)},An.isNil=function(n){return null==n},An.isNull=function(n){return null===n},An.isNumber=bu,An.isObject=du,An.isObjectLike=yu,An.isPlainObject=xu,An.isRegExp=hf,
|
|
An.isSafeInteger=function(n){return vu(n)&&-9007199254740991<=n&&9007199254740991>=n},An.isSet=pf,An.isString=ju,An.isSymbol=wu,An.isTypedArray=_f,An.isUndefined=function(n){return n===T},An.isWeakMap=function(n){return yu(n)&&"[object WeakMap]"==vo(n)},An.isWeakSet=function(n){return yu(n)&&"[object WeakSet]"==Ot(n)},An.join=function(n,t){return null==n?"":Ui.call(n,t)},An.kebabCase=Bf,An.last=Ve,An.lastIndexOf=function(n,t,r){var e=null==n?0:n.length;if(!e)return-1;var u=e;if(r!==T&&(u=ku(r),u=0>u?Li(e+u,0):Ci(u,e-1)),
|
|
t===t)n:{for(r=u+1;r--;)if(n[r]===t){n=r;break n}n=r}else n=_(n,d,u,true);return n},An.lowerCase=Lf,An.lowerFirst=Cf,An.lt=vf,An.lte=gf,An.max=function(n){return n&&n.length?xt(n,$u,It):T},An.maxBy=function(n,t){return n&&n.length?xt(n,ye(t,2),It):T},An.mean=function(n){return y(n,$u)},An.meanBy=function(n,t){return y(n,ye(t,2))},An.min=function(n){return n&&n.length?xt(n,$u,Kt):T},An.minBy=function(n,t){return n&&n.length?xt(n,ye(t,2),Kt):T},An.stubArray=qu,An.stubFalse=Vu,An.stubObject=function(){
|
|
return{}},An.stubString=function(){return""},An.stubTrue=function(){return true},An.multiply=rc,An.nth=function(n,t){return n&&n.length?Qt(n,ku(t)):T},An.noConflict=function(){return $n._===this&&($n._=si),this},An.noop=Pu,An.now=Go,An.pad=function(n,t,r){n=Iu(n);var e=(t=ku(t))?D(n):0;return!t||e>=t?n:(t=(t-e)/2,ne(Ii(t),r)+n+ne(Oi(t),r))},An.padEnd=function(n,t,r){n=Iu(n);var e=(t=ku(t))?D(n):0;return t&&e<t?n+ne(t-e,r):n},An.padStart=function(n,t,r){n=Iu(n);var e=(t=ku(t))?D(n):0;return t&&e<t?ne(t-e,r)+n:n;
|
|
},An.parseInt=function(n,t,r){return r||null==t?t=0:t&&(t=+t),Mi(Iu(n).replace(on,""),t||0)},An.random=function(n,t,r){if(r&&typeof r!="boolean"&&Oe(n,t,r)&&(t=r=T),r===T&&(typeof t=="boolean"?(r=t,t=T):typeof n=="boolean"&&(r=n,n=T)),n===T&&t===T?(n=0,t=1):(n=Au(n),t===T?(t=n,n=0):t=Au(t)),n>t){var e=n;n=t,t=e}return r||n%1||t%1?(r=Ti(),Ci(n+r*(t-n+Cn("1e-"+((r+"").length-1))),t)):ir(n,t)},An.reduce=function(n,t,r){var e=ff(n)?l:j,u=3>arguments.length;return e(n,ye(t,4),r,u,uo)},An.reduceRight=function(n,t,r){
|
|
var e=ff(n)?s:j,u=3>arguments.length;return e(n,ye(t,4),r,u,io)},An.repeat=function(n,t,r){return t=(r?Oe(n,t,r):t===T)?1:ku(t),or(Iu(n),t)},An.replace=function(){var n=arguments,t=Iu(n[0]);return 3>n.length?t:t.replace(n[1],n[2])},An.result=function(n,t,r){t=Sr(t,n);var e=-1,u=t.length;for(u||(u=1,n=T);++e<u;){var i=null==n?T:n[Me(t[e])];i===T&&(e=u,i=r),n=_u(i)?i.call(n):i}return n},An.round=ec,An.runInContext=x,An.sample=function(n){return(ff(n)?Qn:cr)(n)},An.size=function(n){if(null==n)return 0;
|
|
if(su(n))return ju(n)?D(n):n.length;var t=vo(n);return"[object Map]"==t||"[object Set]"==t?n.size:Vt(n).length},An.snakeCase=Df,An.some=function(n,t,r){var e=ff(n)?h:pr;return r&&Oe(n,t,r)&&(t=T),e(n,ye(t,3))},An.sortedIndex=function(n,t){return _r(n,t)},An.sortedIndexBy=function(n,t,r){return vr(n,t,ye(r,2))},An.sortedIndexOf=function(n,t){var r=null==n?0:n.length;if(r){var e=_r(n,t);if(e<r&&lu(n[e],t))return e}return-1},An.sortedLastIndex=function(n,t){return _r(n,t,true)},An.sortedLastIndexBy=function(n,t,r){
|
|
return vr(n,t,ye(r,2),true)},An.sortedLastIndexOf=function(n,t){if(null==n?0:n.length){var r=_r(n,t,true)-1;if(lu(n[r],t))return r}return-1},An.startCase=Mf,An.startsWith=function(n,t,r){return n=Iu(n),r=null==r?0:pt(ku(r),0,n.length),t=yr(t),n.slice(r,r+t.length)==t},An.subtract=uc,An.sum=function(n){return n&&n.length?m(n,$u):0},An.sumBy=function(n,t){return n&&n.length?m(n,ye(t,2)):0},An.template=function(n,t,r){var e=An.templateSettings;r&&Oe(n,t,r)&&(t=T),n=Iu(n),t=bf({},t,e,ce),r=bf({},t.imports,e.imports,ce);
|
|
var u,i,o=Wu(r),f=S(r,o),c=0;r=t.interpolate||jn;var a="__p+='";r=Xu((t.escape||jn).source+"|"+r.source+"|"+(r===Q?pn:jn).source+"|"+(t.evaluate||jn).source+"|$","g");var l="sourceURL"in t?"//# sourceURL="+t.sourceURL+"\n":"";if(n.replace(r,function(t,r,e,o,f,l){return e||(e=o),a+=n.slice(c,l).replace(wn,z),r&&(u=true,a+="'+__e("+r+")+'"),f&&(i=true,a+="';"+f+";\n__p+='"),e&&(a+="'+((__t=("+e+"))==null?'':__t)+'"),c=l+t.length,t}),a+="';",(t=t.variable)||(a="with(obj){"+a+"}"),a=(i?a.replace(P,""):a).replace(Z,"$1").replace(q,"$1;"),
|
|
a="function("+(t||"obj")+"){"+(t?"":"obj||(obj={});")+"var __t,__p=''"+(u?",__e=_.escape":"")+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+a+"return __p}",t=Ff(function(){return Ju(o,l+"return "+a).apply(T,f)}),t.source=a,pu(t))throw t;return t},An.times=function(n,t){if(n=ku(n),1>n||9007199254740991<n)return[];var r=4294967295,e=Ci(n,4294967295);for(t=ye(t),n-=4294967295,e=A(e,t);++r<n;)t(r);return e},An.toFinite=Au,An.toInteger=ku,An.toLength=Eu,An.toLower=function(n){
|
|
return Iu(n).toLowerCase()},An.toNumber=Su,An.toSafeInteger=function(n){return n?pt(ku(n),-9007199254740991,9007199254740991):0===n?n:0},An.toString=Iu,An.toUpper=function(n){return Iu(n).toUpperCase()},An.trim=function(n,t,r){return(n=Iu(n))&&(r||t===T)?n.replace(un,""):n&&(t=yr(t))?(n=M(n),r=M(t),t=I(n,r),r=R(n,r)+1,Or(n,t,r).join("")):n},An.trimEnd=function(n,t,r){return(n=Iu(n))&&(r||t===T)?n.replace(fn,""):n&&(t=yr(t))?(n=M(n),t=R(n,M(t))+1,Or(n,0,t).join("")):n},An.trimStart=function(n,t,r){
|
|
return(n=Iu(n))&&(r||t===T)?n.replace(on,""):n&&(t=yr(t))?(n=M(n),t=I(n,M(t)),Or(n,t).join("")):n},An.truncate=function(n,t){var r=30,e="...";if(du(t))var u="separator"in t?t.separator:u,r="length"in t?ku(t.length):r,e="omission"in t?yr(t.omission):e;n=Iu(n);var i=n.length;if(Rn.test(n))var o=M(n),i=o.length;if(r>=i)return n;if(i=r-D(e),1>i)return e;if(r=o?Or(o,0,i).join(""):n.slice(0,i),u===T)return r+e;if(o&&(i+=r.length-i),hf(u)){if(n.slice(i).search(u)){var f=r;for(u.global||(u=Xu(u.source,Iu(_n.exec(u))+"g")),
|
|
u.lastIndex=0;o=u.exec(f);)var c=o.index;r=r.slice(0,c===T?i:c)}}else n.indexOf(yr(u),i)!=i&&(u=r.lastIndexOf(u),-1<u&&(r=r.slice(0,u)));return r+e},An.unescape=function(n){return(n=Iu(n))&&G.test(n)?n.replace(V,tt):n},An.uniqueId=function(n){var t=++fi;return Iu(n)+t},An.upperCase=Tf,An.upperFirst=$f,An.each=nu,An.eachRight=tu,An.first=qe,Nu(An,function(){var n={};return mt(An,function(t,r){oi.call(An.prototype,r)||(n[r]=t)}),n}(),{chain:false}),An.VERSION="4.17.11",r("bind bindKey curry curryRight partial partialRight".split(" "),function(n){
|
|
An[n].placeholder=An}),r(["drop","take"],function(n,t){Ln.prototype[n]=function(r){r=r===T?1:Li(ku(r),0);var e=this.__filtered__&&!t?new Ln(this):this.clone();return e.__filtered__?e.__takeCount__=Ci(r,e.__takeCount__):e.__views__.push({size:Ci(r,4294967295),type:n+(0>e.__dir__?"Right":"")}),e},Ln.prototype[n+"Right"]=function(t){return this.reverse()[n](t).reverse()}}),r(["filter","map","takeWhile"],function(n,t){var r=t+1,e=1==r||3==r;Ln.prototype[n]=function(n){var t=this.clone();return t.__iteratees__.push({
|
|
iteratee:ye(n,3),type:r}),t.__filtered__=t.__filtered__||e,t}}),r(["head","last"],function(n,t){var r="take"+(t?"Right":"");Ln.prototype[n]=function(){return this[r](1).value()[0]}}),r(["initial","tail"],function(n,t){var r="drop"+(t?"":"Right");Ln.prototype[n]=function(){return this.__filtered__?new Ln(this):this[r](1)}}),Ln.prototype.compact=function(){return this.filter($u)},Ln.prototype.find=function(n){return this.filter(n).head()},Ln.prototype.findLast=function(n){return this.reverse().find(n);
|
|
},Ln.prototype.invokeMap=fr(function(n,t){return typeof n=="function"?new Ln(this):this.map(function(r){return Bt(r,n,t)})}),Ln.prototype.reject=function(n){return this.filter(au(ye(n)))},Ln.prototype.slice=function(n,t){n=ku(n);var r=this;return r.__filtered__&&(0<n||0>t)?new Ln(r):(0>n?r=r.takeRight(-n):n&&(r=r.drop(n)),t!==T&&(t=ku(t),r=0>t?r.dropRight(-t):r.take(t-n)),r)},Ln.prototype.takeRightWhile=function(n){return this.reverse().takeWhile(n).reverse()},Ln.prototype.toArray=function(){return this.take(4294967295);
|
|
},mt(Ln.prototype,function(n,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),e=/^(?:head|last)$/.test(t),u=An[e?"take"+("last"==t?"Right":""):t],i=e||/^find/.test(t);u&&(An.prototype[t]=function(){var t=this.__wrapped__,o=e?[1]:arguments,f=t instanceof Ln,c=o[0],l=f||ff(t),s=function(n){return n=u.apply(An,a([n],o)),e&&h?n[0]:n};l&&r&&typeof c=="function"&&1!=c.length&&(f=l=false);var h=this.__chain__,p=!!this.__actions__.length,c=i&&!h,f=f&&!p;return!i&&l?(t=f?t:new Ln(this),t=n.apply(t,o),t.__actions__.push({
|
|
func:Qe,args:[s],thisArg:T}),new On(t,h)):c&&f?n.apply(this,o):(t=this.thru(s),c?e?t.value()[0]:t.value():t)})}),r("pop push shift sort splice unshift".split(" "),function(n){var t=ri[n],r=/^(?:push|sort|unshift)$/.test(n)?"tap":"thru",e=/^(?:pop|shift)$/.test(n);An.prototype[n]=function(){var n=arguments;if(e&&!this.__chain__){var u=this.value();return t.apply(ff(u)?u:[],n)}return this[r](function(r){return t.apply(ff(r)?r:[],n)})}}),mt(Ln.prototype,function(n,t){var r=An[t];if(r){var e=r.name+"";
|
|
(Gi[e]||(Gi[e]=[])).push({name:t,func:r})}}),Gi[Jr(T,2).name]=[{name:"wrapper",func:T}],Ln.prototype.clone=function(){var n=new Ln(this.__wrapped__);return n.__actions__=Lr(this.__actions__),n.__dir__=this.__dir__,n.__filtered__=this.__filtered__,n.__iteratees__=Lr(this.__iteratees__),n.__takeCount__=this.__takeCount__,n.__views__=Lr(this.__views__),n},Ln.prototype.reverse=function(){if(this.__filtered__){var n=new Ln(this);n.__dir__=-1,n.__filtered__=true}else n=this.clone(),n.__dir__*=-1;return n;
|
|
},Ln.prototype.value=function(){var n,t=this.__wrapped__.value(),r=this.__dir__,e=ff(t),u=0>r,i=e?t.length:0;n=0;for(var o=i,f=this.__views__,c=-1,a=f.length;++c<a;){var l=f[c],s=l.size;switch(l.type){case"drop":n+=s;break;case"dropRight":o-=s;break;case"take":o=Ci(o,n+s);break;case"takeRight":n=Li(n,o-s)}}if(n={start:n,end:o},o=n.start,f=n.end,n=f-o,o=u?f:o-1,f=this.__iteratees__,c=f.length,a=0,l=Ci(n,this.__takeCount__),!e||!u&&i==n&&l==n)return wr(t,this.__actions__);e=[];n:for(;n--&&a<l;){for(o+=r,
|
|
u=-1,i=t[o];++u<c;){var h=f[u],s=h.type,h=(0,h.iteratee)(i);if(2==s)i=h;else if(!h){if(1==s)continue n;break n}}e[a++]=i}return e},An.prototype.at=To,An.prototype.chain=function(){return Ye(this)},An.prototype.commit=function(){return new On(this.value(),this.__chain__)},An.prototype.next=function(){this.__values__===T&&(this.__values__=mu(this.value()));var n=this.__index__>=this.__values__.length;return{done:n,value:n?T:this.__values__[this.__index__++]}},An.prototype.plant=function(n){for(var t,r=this;r instanceof kn;){
|
|
var e=Fe(r);e.__index__=0,e.__values__=T,t?u.__wrapped__=e:t=e;var u=e,r=r.__wrapped__}return u.__wrapped__=n,t},An.prototype.reverse=function(){var n=this.__wrapped__;return n instanceof Ln?(this.__actions__.length&&(n=new Ln(this)),n=n.reverse(),n.__actions__.push({func:Qe,args:[Ge],thisArg:T}),new On(n,this.__chain__)):this.thru(Ge)},An.prototype.toJSON=An.prototype.valueOf=An.prototype.value=function(){return wr(this.__wrapped__,this.__actions__)},An.prototype.first=An.prototype.head,wi&&(An.prototype[wi]=Xe),
|
|
An}();typeof define=="function"&&typeof define.amd=="object"&&define.amd?($n._=rt, define(function(){return rt})):Nn?((Nn.exports=rt)._=rt,Fn._=rt):$n._=rt}).call(this);
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.dayjs=e()}(this,function(){"use strict";var t="millisecond",e="second",n="minute",r="hour",i="day",s="week",u="month",a="quarter",o="year",f="date",h=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[^0-9]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")},$=function(t,e,n){var r=String(t);return!r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},l={s:$,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return(e<=0?"+":"-")+$(r,2,"0")+":"+$(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return-t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,u),s=n-i<0,a=e.clone().add(r+(s?-1:1),u);return+(-(r+(n-i)/(s?i-a:a-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(h){return{M:u,y:o,w:s,d:i,D:f,h:r,m:n,s:e,ms:t,Q:a}[h]||String(h||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},y="en",M={};M[y]=d;var m=function(t){return t instanceof S},D=function(t,e,n){var r;if(!t)return y;if("string"==typeof t)M[t]&&(r=t),e&&(M[t]=e,r=t);else{var i=t.name;M[i]=t,r=i}return!n&&r&&(y=r),r||!n&&y},v=function(t,e){if(m(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new S(n)},g=l;g.l=D,g.i=m,g.w=function(t,e){return v(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var S=function(){function d(t){this.$L=D(t.locale,null,!0),this.parse(t)}var $=d.prototype;return $.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(g.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match(h);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.$x=t.x||{},this.init()},$.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},$.$utils=function(){return g},$.isValid=function(){return!("Invalid Date"===this.$d.toString())},$.isSame=function(t,e){var n=v(t);return this.startOf(e)<=n&&n<=this.endOf(e)},$.isAfter=function(t,e){return v(t)<this.startOf(e)},$.isBefore=function(t,e){return this.endOf(e)<v(t)},$.$g=function(t,e,n){return g.u(t)?this[e]:this.set(n,t)},$.unix=function(){return Math.floor(this.valueOf()/1e3)},$.valueOf=function(){return this.$d.getTime()},$.startOf=function(t,a){var h=this,c=!!g.u(a)||a,d=g.p(t),$=function(t,e){var n=g.w(h.$u?Date.UTC(h.$y,e,t):new Date(h.$y,e,t),h);return c?n:n.endOf(i)},l=function(t,e){return g.w(h.toDate()[t].apply(h.toDate("s"),(c?[0,0,0,0]:[23,59,59,999]).slice(e)),h)},y=this.$W,M=this.$M,m=this.$D,D="set"+(this.$u?"UTC":"");switch(d){case o:return c?$(1,0):$(31,11);case u:return c?$(1,M):$(0,M+1);case s:var v=this.$locale().weekStart||0,S=(y<v?y+7:y)-v;return $(c?m-S:m+(6-S),M);case i:case f:return l(D+"Hours",0);case r:return l(D+"Minutes",1);case n:return l(D+"Seconds",2);case e:return l(D+"Milliseconds",3);default:return this.clone()}},$.endOf=function(t){return this.startOf(t,!1)},$.$set=function(s,a){var h,c=g.p(s),d="set"+(this.$u?"UTC":""),$=(h={},h[i]=d+"Date",h[f]=d+"Date",h[u]=d+"Month",h[o]=d+"FullYear",h[r]=d+"Hours",h[n]=d+"Minutes",h[e]=d+"Seconds",h[t]=d+"Milliseconds",h)[c],l=c===i?this.$D+(a-this.$W):a;if(c===u||c===o){var y=this.clone().set(f,1);y.$d[$](l),y.init(),this.$d=y.set(f,Math.min(this.$D,y.daysInMonth())).$d}else $&&this.$d[$](l);return this.init(),this},$.set=function(t,e){return this.clone().$set(t,e)},$.get=function(t){return this[g.p(t)]()},$.add=function(t,a){var f,h=this;t=Number(t);var c=g.p(a),d=function(e){var n=v(h);return g.w(n.date(n.date()+Math.round(e*t)),h)};if(c===u)return this.set(u,this.$M+t);if(c===o)return this.set(o,this.$y+t);if(c===i)return d(1);if(c===s)return d(7);var $=(f={},f[n]=6e4,f[r]=36e5,f[e]=1e3,f)[c]||1,l=this.$d.getTime()+t*$;return g.w(l,this)},$.subtract=function(t,e){return this.add(-1*t,e)},$.format=function(t){var e=this;if(!this.isValid())return"Invalid Date";var n=t||"YYYY-MM-DDTHH:mm:ssZ",r=g.z(this),i=this.$locale(),s=this.$H,u=this.$m,a=this.$M,o=i.weekdays,f=i.months,h=function(t,r,i,s){return t&&(t[r]||t(e,n))||i[r].substr(0,s)},d=function(t){return g.s(s%12||12,t,"0")},$=i.meridiem||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r},l={YY:String(this.$y).slice(-2),YYYY:this.$y,M:a+1,MM:g.s(a+1,2,"0"),MMM:h(i.monthsShort,a,f,3),MMMM:h(f,a),D:this.$D,DD:g.s(this.$D,2,"0"),d:String(this.$W),dd:h(i.weekdaysMin,this.$W,o,2),ddd:h(i.weekdaysShort,this.$W,o,3),dddd:o[this.$W],H:String(s),HH:g.s(s,2,"0"),h:d(1),hh:d(2),a:$(s,u,!0),A:$(s,u,!1),m:String(u),mm:g.s(u,2,"0"),s:String(this.$s),ss:g.s(this.$s,2,"0"),SSS:g.s(this.$ms,3,"0"),Z:r};return n.replace(c,function(t,e){return e||l[t]||r.replace(":","")})},$.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},$.diff=function(t,f,h){var c,d=g.p(f),$=v(t),l=6e4*($.utcOffset()-this.utcOffset()),y=this-$,M=g.m(this,$);return M=(c={},c[o]=M/12,c[u]=M,c[a]=M/3,c[s]=(y-l)/6048e5,c[i]=(y-l)/864e5,c[r]=y/36e5,c[n]=y/6e4,c[e]=y/1e3,c)[d]||y,h?M:g.a(M)},$.daysInMonth=function(){return this.endOf(u).$D},$.$locale=function(){return M[this.$L]},$.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=D(t,e,!0);return r&&(n.$L=r),n},$.clone=function(){return g.w(this.$d,this)},$.toDate=function(){return new Date(this.valueOf())},$.toJSON=function(){return this.isValid()?this.toISOString():null},$.toISOString=function(){return this.$d.toISOString()},$.toString=function(){return this.$d.toUTCString()},d}(),p=S.prototype;return v.prototype=p,[["$ms",t],["$s",e],["$m",n],["$H",r],["$W",i],["$M",u],["$y",o],["$D",f]].forEach(function(t){p[t[1]]=function(e){return this.$g(e,t[0],t[1])}}),v.extend=function(t,e){return t.$i||(t(e,S,v),t.$i=!0),v},v.locale=D,v.isDayjs=m,v.unix=function(t){return v(1e3*t)},v.en=M[y],v.Ls=M,v.p={},v});
|
|
|
|
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.dayjs_plugin_weekday=t()}(this,function(){"use strict";return function(e,t){t.prototype.weekday=function(e){var t=this.$locale().weekStart||0,n=this.$W,i=(n<t?n+7:n)-t;return this.$utils().u(e)?i:this.subtract(i,"day").add(e,"day")}}});
|
|
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.dayjs_plugin_isoWeek=e()}(this,function(){"use strict";var t="day";return function(e,i,s){var a=function(e){return e.add(4-e.isoWeekday(),t)},d=i.prototype;d.isoWeekYear=function(){return a(this).year()},d.isoWeek=function(e){if(!this.$utils().u(e))return this.add(7*(e-this.isoWeek()),t);var i,d,n,r,o=a(this),u=(i=this.isoWeekYear(),d=this.$u,n=(d?s.utc:s)().year(i).startOf("year"),r=4-n.isoWeekday(),n.isoWeekday()>4&&(r+=7),n.add(r,t));return o.diff(u,"week")+1},d.isoWeekday=function(t){return this.$utils().u(t)?this.day()||7:this.day(this.day()%7?t:t-7)};var n=d.startOf;d.startOf=function(t,e){var i=this.$utils(),s=!!i.u(e)||e;return"isoweek"===i.p(t)?s?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):n.bind(this)(t,e)}}});
|
|
|
|
dayjs.extend(dayjs_plugin_weekday);
|
|
dayjs.extend(dayjs_plugin_isoWeek);
|
|
/*!
|
|
* Bootstrap v4.5.2 (https://getbootstrap.com/)
|
|
* Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
*/
|
|
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("jquery")):"function"==typeof define&&define.amd?define(["exports","jquery"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).bootstrap={},t.jQuery)}(this,(function(t,e){"use strict";function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function i(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function o(){return(o=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t}).apply(this,arguments)}e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e;function r(t){var n=this,i=!1;return e(this).one(s.TRANSITION_END,(function(){i=!0})),setTimeout((function(){i||s.triggerTransitionEnd(n)}),t),this}var s={TRANSITION_END:"bsTransitionEnd",getUID:function(t){do{t+=~~(1e6*Math.random())}while(document.getElementById(t));return t},getSelectorFromElement:function(t){var e=t.getAttribute("data-target");if(!e||"#"===e){var n=t.getAttribute("href");e=n&&"#"!==n?n.trim():""}try{return document.querySelector(e)?e:null}catch(t){return null}},getTransitionDurationFromElement:function(t){if(!t)return 0;var n=e(t).css("transition-duration"),i=e(t).css("transition-delay"),o=parseFloat(n),r=parseFloat(i);return o||r?(n=n.split(",")[0],i=i.split(",")[0],1e3*(parseFloat(n)+parseFloat(i))):0},reflow:function(t){return t.offsetHeight},triggerTransitionEnd:function(t){e(t).trigger("transitionend")},supportsTransitionEnd:function(){return Boolean("transitionend")},isElement:function(t){return(t[0]||t).nodeType},typeCheckConfig:function(t,e,n){for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var o=n[i],r=e[i],a=r&&s.isElement(r)?"element":null===(l=r)||"undefined"==typeof l?""+l:{}.toString.call(l).match(/\s([a-z]+)/i)[1].toLowerCase();if(!new RegExp(o).test(a))throw new Error(t.toUpperCase()+': Option "'+i+'" provided type "'+a+'" but expected type "'+o+'".')}var l},findShadowRoot:function(t){if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){var e=t.getRootNode();return e instanceof ShadowRoot?e:null}return t instanceof ShadowRoot?t:t.parentNode?s.findShadowRoot(t.parentNode):null},jQueryDetection:function(){if("undefined"==typeof e)throw new TypeError("Bootstrap's JavaScript requires jQuery. jQuery must be included before Bootstrap's JavaScript.");var t=e.fn.jquery.split(" ")[0].split(".");if(t[0]<2&&t[1]<9||1===t[0]&&9===t[1]&&t[2]<1||t[0]>=4)throw new Error("Bootstrap's JavaScript requires at least jQuery v1.9.1 but less than v4.0.0")}};s.jQueryDetection(),e.fn.emulateTransitionEnd=r,e.event.special[s.TRANSITION_END]={bindType:"transitionend",delegateType:"transitionend",handle:function(t){if(e(t.target).is(this))return t.handleObj.handler.apply(this,arguments)}};var a="alert",l=e.fn[a],c=function(){function t(t){this._element=t}var n=t.prototype;return n.close=function(t){var e=this._element;t&&(e=this._getRootElement(t)),this._triggerCloseEvent(e).isDefaultPrevented()||this._removeElement(e)},n.dispose=function(){e.removeData(this._element,"bs.alert"),this._element=null},n._getRootElement=function(t){var n=s.getSelectorFromElement(t),i=!1;return n&&(i=document.querySelector(n)),i||(i=e(t).closest(".alert")[0]),i},n._triggerCloseEvent=function(t){var n=e.Event("close.bs.alert");return e(t).trigger(n),n},n._removeElement=function(t){var n=this;if(e(t).removeClass("show"),e(t).hasClass("fade")){var i=s.getTransitionDurationFromElement(t);e(t).one(s.TRANSITION_END,(function(e){return n._destroyElement(t,e)})).emulateTransitionEnd(i)}else this._destroyElement(t)},n._destroyElement=function(t){e(t).detach().trigger("closed.bs.alert").remove()},t._jQueryInterface=function(n){return this.each((function(){var i=e(this),o=i.data("bs.alert");o||(o=new t(this),i.data("bs.alert",o)),"close"===n&&o[n](this)}))},t._handleDismiss=function(t){return function(e){e&&e.preventDefault(),t.close(this)}},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}}]),t}();e(document).on("click.bs.alert.data-api",'[data-dismiss="alert"]',c._handleDismiss(new c)),e.fn[a]=c._jQueryInterface,e.fn[a].Constructor=c,e.fn[a].noConflict=function(){return e.fn[a]=l,c._jQueryInterface};var h=e.fn.button,u=function(){function t(t){this._element=t}var n=t.prototype;return n.toggle=function(){var t=!0,n=!0,i=e(this._element).closest('[data-toggle="buttons"]')[0];if(i){var o=this._element.querySelector('input:not([type="hidden"])');if(o){if("radio"===o.type)if(o.checked&&this._element.classList.contains("active"))t=!1;else{var r=i.querySelector(".active");r&&e(r).removeClass("active")}t&&("checkbox"!==o.type&&"radio"!==o.type||(o.checked=!this._element.classList.contains("active")),e(o).trigger("change")),o.focus(),n=!1}}this._element.hasAttribute("disabled")||this._element.classList.contains("disabled")||(n&&this._element.setAttribute("aria-pressed",!this._element.classList.contains("active")),t&&e(this._element).toggleClass("active"))},n.dispose=function(){e.removeData(this._element,"bs.button"),this._element=null},t._jQueryInterface=function(n){return this.each((function(){var i=e(this).data("bs.button");i||(i=new t(this),e(this).data("bs.button",i)),"toggle"===n&&i[n]()}))},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}}]),t}();e(document).on("click.bs.button.data-api",'[data-toggle^="button"]',(function(t){var n=t.target,i=n;if(e(n).hasClass("btn")||(n=e(n).closest(".btn")[0]),!n||n.hasAttribute("disabled")||n.classList.contains("disabled"))t.preventDefault();else{var o=n.querySelector('input:not([type="hidden"])');if(o&&(o.hasAttribute("disabled")||o.classList.contains("disabled")))return void t.preventDefault();("LABEL"!==i.tagName||o&&"checkbox"!==o.type)&&u._jQueryInterface.call(e(n),"toggle")}})).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',(function(t){var n=e(t.target).closest(".btn")[0];e(n).toggleClass("focus",/^focus(in)?$/.test(t.type))})),e(window).on("load.bs.button.data-api",(function(){for(var t=[].slice.call(document.querySelectorAll('[data-toggle="buttons"] .btn')),e=0,n=t.length;e<n;e++){var i=t[e],o=i.querySelector('input:not([type="hidden"])');o.checked||o.hasAttribute("checked")?i.classList.add("active"):i.classList.remove("active")}for(var r=0,s=(t=[].slice.call(document.querySelectorAll('[data-toggle="button"]'))).length;r<s;r++){var a=t[r];"true"===a.getAttribute("aria-pressed")?a.classList.add("active"):a.classList.remove("active")}})),e.fn.button=u._jQueryInterface,e.fn.button.Constructor=u,e.fn.button.noConflict=function(){return e.fn.button=h,u._jQueryInterface};var f="carousel",d=".bs.carousel",p=e.fn[f],m={interval:5e3,keyboard:!0,slide:!1,pause:"hover",wrap:!0,touch:!0},g={interval:"(number|boolean)",keyboard:"boolean",slide:"(boolean|string)",pause:"(string|boolean)",wrap:"boolean",touch:"boolean"},_={TOUCH:"touch",PEN:"pen"},v=function(){function t(t,e){this._items=null,this._interval=null,this._activeElement=null,this._isPaused=!1,this._isSliding=!1,this.touchTimeout=null,this.touchStartX=0,this.touchDeltaX=0,this._config=this._getConfig(e),this._element=t,this._indicatorsElement=this._element.querySelector(".carousel-indicators"),this._touchSupported="ontouchstart"in document.documentElement||navigator.maxTouchPoints>0,this._pointerEvent=Boolean(window.PointerEvent||window.MSPointerEvent),this._addEventListeners()}var n=t.prototype;return n.next=function(){this._isSliding||this._slide("next")},n.nextWhenVisible=function(){!document.hidden&&e(this._element).is(":visible")&&"hidden"!==e(this._element).css("visibility")&&this.next()},n.prev=function(){this._isSliding||this._slide("prev")},n.pause=function(t){t||(this._isPaused=!0),this._element.querySelector(".carousel-item-next, .carousel-item-prev")&&(s.triggerTransitionEnd(this._element),this.cycle(!0)),clearInterval(this._interval),this._interval=null},n.cycle=function(t){t||(this._isPaused=!1),this._interval&&(clearInterval(this._interval),this._interval=null),this._config.interval&&!this._isPaused&&(this._interval=setInterval((document.visibilityState?this.nextWhenVisible:this.next).bind(this),this._config.interval))},n.to=function(t){var n=this;this._activeElement=this._element.querySelector(".active.carousel-item");var i=this._getItemIndex(this._activeElement);if(!(t>this._items.length-1||t<0))if(this._isSliding)e(this._element).one("slid.bs.carousel",(function(){return n.to(t)}));else{if(i===t)return this.pause(),void this.cycle();var o=t>i?"next":"prev";this._slide(o,this._items[t])}},n.dispose=function(){e(this._element).off(d),e.removeData(this._element,"bs.carousel"),this._items=null,this._config=null,this._element=null,this._interval=null,this._isPaused=null,this._isSliding=null,this._activeElement=null,this._indicatorsElement=null},n._getConfig=function(t){return t=o({},m,t),s.typeCheckConfig(f,t,g),t},n._handleSwipe=function(){var t=Math.abs(this.touchDeltaX);if(!(t<=40)){var e=t/this.touchDeltaX;this.touchDeltaX=0,e>0&&this.prev(),e<0&&this.next()}},n._addEventListeners=function(){var t=this;this._config.keyboard&&e(this._element).on("keydown.bs.carousel",(function(e){return t._keydown(e)})),"hover"===this._config.pause&&e(this._element).on("mouseenter.bs.carousel",(function(e){return t.pause(e)})).on("mouseleave.bs.carousel",(function(e){return t.cycle(e)})),this._config.touch&&this._addTouchEventListeners()},n._addTouchEventListeners=function(){var t=this;if(this._touchSupported){var n=function(e){t._pointerEvent&&_[e.originalEvent.pointerType.toUpperCase()]?t.touchStartX=e.originalEvent.clientX:t._pointerEvent||(t.touchStartX=e.originalEvent.touches[0].clientX)},i=function(e){t._pointerEvent&&_[e.originalEvent.pointerType.toUpperCase()]&&(t.touchDeltaX=e.originalEvent.clientX-t.touchStartX),t._handleSwipe(),"hover"===t._config.pause&&(t.pause(),t.touchTimeout&&clearTimeout(t.touchTimeout),t.touchTimeout=setTimeout((function(e){return t.cycle(e)}),500+t._config.interval))};e(this._element.querySelectorAll(".carousel-item img")).on("dragstart.bs.carousel",(function(t){return t.preventDefault()})),this._pointerEvent?(e(this._element).on("pointerdown.bs.carousel",(function(t){return n(t)})),e(this._element).on("pointerup.bs.carousel",(function(t){return i(t)})),this._element.classList.add("pointer-event")):(e(this._element).on("touchstart.bs.carousel",(function(t){return n(t)})),e(this._element).on("touchmove.bs.carousel",(function(e){return function(e){e.originalEvent.touches&&e.originalEvent.touches.length>1?t.touchDeltaX=0:t.touchDeltaX=e.originalEvent.touches[0].clientX-t.touchStartX}(e)})),e(this._element).on("touchend.bs.carousel",(function(t){return i(t)})))}},n._keydown=function(t){if(!/input|textarea/i.test(t.target.tagName))switch(t.which){case 37:t.preventDefault(),this.prev();break;case 39:t.preventDefault(),this.next()}},n._getItemIndex=function(t){return this._items=t&&t.parentNode?[].slice.call(t.parentNode.querySelectorAll(".carousel-item")):[],this._items.indexOf(t)},n._getItemByDirection=function(t,e){var n="next"===t,i="prev"===t,o=this._getItemIndex(e),r=this._items.length-1;if((i&&0===o||n&&o===r)&&!this._config.wrap)return e;var s=(o+("prev"===t?-1:1))%this._items.length;return-1===s?this._items[this._items.length-1]:this._items[s]},n._triggerSlideEvent=function(t,n){var i=this._getItemIndex(t),o=this._getItemIndex(this._element.querySelector(".active.carousel-item")),r=e.Event("slide.bs.carousel",{relatedTarget:t,direction:n,from:o,to:i});return e(this._element).trigger(r),r},n._setActiveIndicatorElement=function(t){if(this._indicatorsElement){var n=[].slice.call(this._indicatorsElement.querySelectorAll(".active"));e(n).removeClass("active");var i=this._indicatorsElement.children[this._getItemIndex(t)];i&&e(i).addClass("active")}},n._slide=function(t,n){var i,o,r,a=this,l=this._element.querySelector(".active.carousel-item"),c=this._getItemIndex(l),h=n||l&&this._getItemByDirection(t,l),u=this._getItemIndex(h),f=Boolean(this._interval);if("next"===t?(i="carousel-item-left",o="carousel-item-next",r="left"):(i="carousel-item-right",o="carousel-item-prev",r="right"),h&&e(h).hasClass("active"))this._isSliding=!1;else if(!this._triggerSlideEvent(h,r).isDefaultPrevented()&&l&&h){this._isSliding=!0,f&&this.pause(),this._setActiveIndicatorElement(h);var d=e.Event("slid.bs.carousel",{relatedTarget:h,direction:r,from:c,to:u});if(e(this._element).hasClass("slide")){e(h).addClass(o),s.reflow(h),e(l).addClass(i),e(h).addClass(i);var p=parseInt(h.getAttribute("data-interval"),10);p?(this._config.defaultInterval=this._config.defaultInterval||this._config.interval,this._config.interval=p):this._config.interval=this._config.defaultInterval||this._config.interval;var m=s.getTransitionDurationFromElement(l);e(l).one(s.TRANSITION_END,(function(){e(h).removeClass(i+" "+o).addClass("active"),e(l).removeClass("active "+o+" "+i),a._isSliding=!1,setTimeout((function(){return e(a._element).trigger(d)}),0)})).emulateTransitionEnd(m)}else e(l).removeClass("active"),e(h).addClass("active"),this._isSliding=!1,e(this._element).trigger(d);f&&this.cycle()}},t._jQueryInterface=function(n){return this.each((function(){var i=e(this).data("bs.carousel"),r=o({},m,e(this).data());"object"==typeof n&&(r=o({},r,n));var s="string"==typeof n?n:r.slide;if(i||(i=new t(this,r),e(this).data("bs.carousel",i)),"number"==typeof n)i.to(n);else if("string"==typeof s){if("undefined"==typeof i[s])throw new TypeError('No method named "'+s+'"');i[s]()}else r.interval&&r.ride&&(i.pause(),i.cycle())}))},t._dataApiClickHandler=function(n){var i=s.getSelectorFromElement(this);if(i){var r=e(i)[0];if(r&&e(r).hasClass("carousel")){var a=o({},e(r).data(),e(this).data()),l=this.getAttribute("data-slide-to");l&&(a.interval=!1),t._jQueryInterface.call(e(r),a),l&&e(r).data("bs.carousel").to(l),n.preventDefault()}}},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"Default",get:function(){return m}}]),t}();e(document).on("click.bs.carousel.data-api","[data-slide], [data-slide-to]",v._dataApiClickHandler),e(window).on("load.bs.carousel.data-api",(function(){for(var t=[].slice.call(document.querySelectorAll('[data-ride="carousel"]')),n=0,i=t.length;n<i;n++){var o=e(t[n]);v._jQueryInterface.call(o,o.data())}})),e.fn[f]=v._jQueryInterface,e.fn[f].Constructor=v,e.fn[f].noConflict=function(){return e.fn[f]=p,v._jQueryInterface};var b="collapse",y=e.fn[b],w={toggle:!0,parent:""},E={toggle:"boolean",parent:"(string|element)"},T=function(){function t(t,e){this._isTransitioning=!1,this._element=t,this._config=this._getConfig(e),this._triggerArray=[].slice.call(document.querySelectorAll('[data-toggle="collapse"][href="#'+t.id+'"],[data-toggle="collapse"][data-target="#'+t.id+'"]'));for(var n=[].slice.call(document.querySelectorAll('[data-toggle="collapse"]')),i=0,o=n.length;i<o;i++){var r=n[i],a=s.getSelectorFromElement(r),l=[].slice.call(document.querySelectorAll(a)).filter((function(e){return e===t}));null!==a&&l.length>0&&(this._selector=a,this._triggerArray.push(r))}this._parent=this._config.parent?this._getParent():null,this._config.parent||this._addAriaAndCollapsedClass(this._element,this._triggerArray),this._config.toggle&&this.toggle()}var n=t.prototype;return n.toggle=function(){e(this._element).hasClass("show")?this.hide():this.show()},n.show=function(){var n,i,o=this;if(!this._isTransitioning&&!e(this._element).hasClass("show")&&(this._parent&&0===(n=[].slice.call(this._parent.querySelectorAll(".show, .collapsing")).filter((function(t){return"string"==typeof o._config.parent?t.getAttribute("data-parent")===o._config.parent:t.classList.contains("collapse")}))).length&&(n=null),!(n&&(i=e(n).not(this._selector).data("bs.collapse"))&&i._isTransitioning))){var r=e.Event("show.bs.collapse");if(e(this._element).trigger(r),!r.isDefaultPrevented()){n&&(t._jQueryInterface.call(e(n).not(this._selector),"hide"),i||e(n).data("bs.collapse",null));var a=this._getDimension();e(this._element).removeClass("collapse").addClass("collapsing"),this._element.style[a]=0,this._triggerArray.length&&e(this._triggerArray).removeClass("collapsed").attr("aria-expanded",!0),this.setTransitioning(!0);var l="scroll"+(a[0].toUpperCase()+a.slice(1)),c=s.getTransitionDurationFromElement(this._element);e(this._element).one(s.TRANSITION_END,(function(){e(o._element).removeClass("collapsing").addClass("collapse show"),o._element.style[a]="",o.setTransitioning(!1),e(o._element).trigger("shown.bs.collapse")})).emulateTransitionEnd(c),this._element.style[a]=this._element[l]+"px"}}},n.hide=function(){var t=this;if(!this._isTransitioning&&e(this._element).hasClass("show")){var n=e.Event("hide.bs.collapse");if(e(this._element).trigger(n),!n.isDefaultPrevented()){var i=this._getDimension();this._element.style[i]=this._element.getBoundingClientRect()[i]+"px",s.reflow(this._element),e(this._element).addClass("collapsing").removeClass("collapse show");var o=this._triggerArray.length;if(o>0)for(var r=0;r<o;r++){var a=this._triggerArray[r],l=s.getSelectorFromElement(a);if(null!==l)e([].slice.call(document.querySelectorAll(l))).hasClass("show")||e(a).addClass("collapsed").attr("aria-expanded",!1)}this.setTransitioning(!0);this._element.style[i]="";var c=s.getTransitionDurationFromElement(this._element);e(this._element).one(s.TRANSITION_END,(function(){t.setTransitioning(!1),e(t._element).removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")})).emulateTransitionEnd(c)}}},n.setTransitioning=function(t){this._isTransitioning=t},n.dispose=function(){e.removeData(this._element,"bs.collapse"),this._config=null,this._parent=null,this._element=null,this._triggerArray=null,this._isTransitioning=null},n._getConfig=function(t){return(t=o({},w,t)).toggle=Boolean(t.toggle),s.typeCheckConfig(b,t,E),t},n._getDimension=function(){return e(this._element).hasClass("width")?"width":"height"},n._getParent=function(){var n,i=this;s.isElement(this._config.parent)?(n=this._config.parent,"undefined"!=typeof this._config.parent.jquery&&(n=this._config.parent[0])):n=document.querySelector(this._config.parent);var o='[data-toggle="collapse"][data-parent="'+this._config.parent+'"]',r=[].slice.call(n.querySelectorAll(o));return e(r).each((function(e,n){i._addAriaAndCollapsedClass(t._getTargetFromElement(n),[n])})),n},n._addAriaAndCollapsedClass=function(t,n){var i=e(t).hasClass("show");n.length&&e(n).toggleClass("collapsed",!i).attr("aria-expanded",i)},t._getTargetFromElement=function(t){var e=s.getSelectorFromElement(t);return e?document.querySelector(e):null},t._jQueryInterface=function(n){return this.each((function(){var i=e(this),r=i.data("bs.collapse"),s=o({},w,i.data(),"object"==typeof n&&n?n:{});if(!r&&s.toggle&&"string"==typeof n&&/show|hide/.test(n)&&(s.toggle=!1),r||(r=new t(this,s),i.data("bs.collapse",r)),"string"==typeof n){if("undefined"==typeof r[n])throw new TypeError('No method named "'+n+'"');r[n]()}}))},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"Default",get:function(){return w}}]),t}();e(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',(function(t){"A"===t.currentTarget.tagName&&t.preventDefault();var n=e(this),i=s.getSelectorFromElement(this),o=[].slice.call(document.querySelectorAll(i));e(o).each((function(){var t=e(this),i=t.data("bs.collapse")?"toggle":n.data();T._jQueryInterface.call(t,i)}))})),e.fn[b]=T._jQueryInterface,e.fn[b].Constructor=T,e.fn[b].noConflict=function(){return e.fn[b]=y,T._jQueryInterface};var C="undefined"!=typeof window&&"undefined"!=typeof document&&"undefined"!=typeof navigator,S=function(){for(var t=["Edge","Trident","Firefox"],e=0;e<t.length;e+=1)if(C&&navigator.userAgent.indexOf(t[e])>=0)return 1;return 0}();var D=C&&window.Promise?function(t){var e=!1;return function(){e||(e=!0,window.Promise.resolve().then((function(){e=!1,t()})))}}:function(t){var e=!1;return function(){e||(e=!0,setTimeout((function(){e=!1,t()}),S))}};function N(t){return t&&"[object Function]"==={}.toString.call(t)}function k(t,e){if(1!==t.nodeType)return[];var n=t.ownerDocument.defaultView.getComputedStyle(t,null);return e?n[e]:n}function A(t){return"HTML"===t.nodeName?t:t.parentNode||t.host}function I(t){if(!t)return document.body;switch(t.nodeName){case"HTML":case"BODY":return t.ownerDocument.body;case"#document":return t.body}var e=k(t),n=e.overflow,i=e.overflowX,o=e.overflowY;return/(auto|scroll|overlay)/.test(n+o+i)?t:I(A(t))}function O(t){return t&&t.referenceNode?t.referenceNode:t}var x=C&&!(!window.MSInputMethodContext||!document.documentMode),j=C&&/MSIE 10/.test(navigator.userAgent);function L(t){return 11===t?x:10===t?j:x||j}function P(t){if(!t)return document.documentElement;for(var e=L(10)?document.body:null,n=t.offsetParent||null;n===e&&t.nextElementSibling;)n=(t=t.nextElementSibling).offsetParent;var i=n&&n.nodeName;return i&&"BODY"!==i&&"HTML"!==i?-1!==["TH","TD","TABLE"].indexOf(n.nodeName)&&"static"===k(n,"position")?P(n):n:t?t.ownerDocument.documentElement:document.documentElement}function F(t){return null!==t.parentNode?F(t.parentNode):t}function R(t,e){if(!(t&&t.nodeType&&e&&e.nodeType))return document.documentElement;var n=t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING,i=n?t:e,o=n?e:t,r=document.createRange();r.setStart(i,0),r.setEnd(o,0);var s,a,l=r.commonAncestorContainer;if(t!==l&&e!==l||i.contains(o))return"BODY"===(a=(s=l).nodeName)||"HTML"!==a&&P(s.firstElementChild)!==s?P(l):l;var c=F(t);return c.host?R(c.host,e):R(t,F(e).host)}function H(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",n="top"===e?"scrollTop":"scrollLeft",i=t.nodeName;if("BODY"===i||"HTML"===i){var o=t.ownerDocument.documentElement,r=t.ownerDocument.scrollingElement||o;return r[n]}return t[n]}function M(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=H(e,"top"),o=H(e,"left"),r=n?-1:1;return t.top+=i*r,t.bottom+=i*r,t.left+=o*r,t.right+=o*r,t}function B(t,e){var n="x"===e?"Left":"Top",i="Left"===n?"Right":"Bottom";return parseFloat(t["border"+n+"Width"])+parseFloat(t["border"+i+"Width"])}function q(t,e,n,i){return Math.max(e["offset"+t],e["scroll"+t],n["client"+t],n["offset"+t],n["scroll"+t],L(10)?parseInt(n["offset"+t])+parseInt(i["margin"+("Height"===t?"Top":"Left")])+parseInt(i["margin"+("Height"===t?"Bottom":"Right")]):0)}function Q(t){var e=t.body,n=t.documentElement,i=L(10)&&getComputedStyle(n);return{height:q("Height",e,n,i),width:q("Width",e,n,i)}}var W=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},U=function(){function t(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(e,n,i){return n&&t(e.prototype,n),i&&t(e,i),e}}(),V=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},Y=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t};function z(t){return Y({},t,{right:t.left+t.width,bottom:t.top+t.height})}function X(t){var e={};try{if(L(10)){e=t.getBoundingClientRect();var n=H(t,"top"),i=H(t,"left");e.top+=n,e.left+=i,e.bottom+=n,e.right+=i}else e=t.getBoundingClientRect()}catch(t){}var o={left:e.left,top:e.top,width:e.right-e.left,height:e.bottom-e.top},r="HTML"===t.nodeName?Q(t.ownerDocument):{},s=r.width||t.clientWidth||o.width,a=r.height||t.clientHeight||o.height,l=t.offsetWidth-s,c=t.offsetHeight-a;if(l||c){var h=k(t);l-=B(h,"x"),c-=B(h,"y"),o.width-=l,o.height-=c}return z(o)}function K(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=L(10),o="HTML"===e.nodeName,r=X(t),s=X(e),a=I(t),l=k(e),c=parseFloat(l.borderTopWidth),h=parseFloat(l.borderLeftWidth);n&&o&&(s.top=Math.max(s.top,0),s.left=Math.max(s.left,0));var u=z({top:r.top-s.top-c,left:r.left-s.left-h,width:r.width,height:r.height});if(u.marginTop=0,u.marginLeft=0,!i&&o){var f=parseFloat(l.marginTop),d=parseFloat(l.marginLeft);u.top-=c-f,u.bottom-=c-f,u.left-=h-d,u.right-=h-d,u.marginTop=f,u.marginLeft=d}return(i&&!n?e.contains(a):e===a&&"BODY"!==a.nodeName)&&(u=M(u,e)),u}function G(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t.ownerDocument.documentElement,i=K(t,n),o=Math.max(n.clientWidth,window.innerWidth||0),r=Math.max(n.clientHeight,window.innerHeight||0),s=e?0:H(n),a=e?0:H(n,"left"),l={top:s-i.top+i.marginTop,left:a-i.left+i.marginLeft,width:o,height:r};return z(l)}function $(t){var e=t.nodeName;if("BODY"===e||"HTML"===e)return!1;if("fixed"===k(t,"position"))return!0;var n=A(t);return!!n&&$(n)}function J(t){if(!t||!t.parentElement||L())return document.documentElement;for(var e=t.parentElement;e&&"none"===k(e,"transform");)e=e.parentElement;return e||document.documentElement}function Z(t,e,n,i){var o=arguments.length>4&&void 0!==arguments[4]&&arguments[4],r={top:0,left:0},s=o?J(t):R(t,O(e));if("viewport"===i)r=G(s,o);else{var a=void 0;"scrollParent"===i?"BODY"===(a=I(A(e))).nodeName&&(a=t.ownerDocument.documentElement):a="window"===i?t.ownerDocument.documentElement:i;var l=K(a,s,o);if("HTML"!==a.nodeName||$(s))r=l;else{var c=Q(t.ownerDocument),h=c.height,u=c.width;r.top+=l.top-l.marginTop,r.bottom=h+l.top,r.left+=l.left-l.marginLeft,r.right=u+l.left}}var f="number"==typeof(n=n||0);return r.left+=f?n:n.left||0,r.top+=f?n:n.top||0,r.right-=f?n:n.right||0,r.bottom-=f?n:n.bottom||0,r}function tt(t){return t.width*t.height}function et(t,e,n,i,o){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;if(-1===t.indexOf("auto"))return t;var s=Z(n,i,r,o),a={top:{width:s.width,height:e.top-s.top},right:{width:s.right-e.right,height:s.height},bottom:{width:s.width,height:s.bottom-e.bottom},left:{width:e.left-s.left,height:s.height}},l=Object.keys(a).map((function(t){return Y({key:t},a[t],{area:tt(a[t])})})).sort((function(t,e){return e.area-t.area})),c=l.filter((function(t){var e=t.width,i=t.height;return e>=n.clientWidth&&i>=n.clientHeight})),h=c.length>0?c[0].key:l[0].key,u=t.split("-")[1];return h+(u?"-"+u:"")}function nt(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=i?J(e):R(e,O(n));return K(n,o,i)}function it(t){var e=t.ownerDocument.defaultView.getComputedStyle(t),n=parseFloat(e.marginTop||0)+parseFloat(e.marginBottom||0),i=parseFloat(e.marginLeft||0)+parseFloat(e.marginRight||0);return{width:t.offsetWidth+i,height:t.offsetHeight+n}}function ot(t){var e={left:"right",right:"left",bottom:"top",top:"bottom"};return t.replace(/left|right|bottom|top/g,(function(t){return e[t]}))}function rt(t,e,n){n=n.split("-")[0];var i=it(t),o={width:i.width,height:i.height},r=-1!==["right","left"].indexOf(n),s=r?"top":"left",a=r?"left":"top",l=r?"height":"width",c=r?"width":"height";return o[s]=e[s]+e[l]/2-i[l]/2,o[a]=n===a?e[a]-i[c]:e[ot(a)],o}function st(t,e){return Array.prototype.find?t.find(e):t.filter(e)[0]}function at(t,e,n){return(void 0===n?t:t.slice(0,function(t,e,n){if(Array.prototype.findIndex)return t.findIndex((function(t){return t[e]===n}));var i=st(t,(function(t){return t[e]===n}));return t.indexOf(i)}(t,"name",n))).forEach((function(t){t.function&&console.warn("`modifier.function` is deprecated, use `modifier.fn`!");var n=t.function||t.fn;t.enabled&&N(n)&&(e.offsets.popper=z(e.offsets.popper),e.offsets.reference=z(e.offsets.reference),e=n(e,t))})),e}function lt(){if(!this.state.isDestroyed){var t={instance:this,styles:{},arrowStyles:{},attributes:{},flipped:!1,offsets:{}};t.offsets.reference=nt(this.state,this.popper,this.reference,this.options.positionFixed),t.placement=et(this.options.placement,t.offsets.reference,this.popper,this.reference,this.options.modifiers.flip.boundariesElement,this.options.modifiers.flip.padding),t.originalPlacement=t.placement,t.positionFixed=this.options.positionFixed,t.offsets.popper=rt(this.popper,t.offsets.reference,t.placement),t.offsets.popper.position=this.options.positionFixed?"fixed":"absolute",t=at(this.modifiers,t),this.state.isCreated?this.options.onUpdate(t):(this.state.isCreated=!0,this.options.onCreate(t))}}function ct(t,e){return t.some((function(t){var n=t.name;return t.enabled&&n===e}))}function ht(t){for(var e=[!1,"ms","Webkit","Moz","O"],n=t.charAt(0).toUpperCase()+t.slice(1),i=0;i<e.length;i++){var o=e[i],r=o?""+o+n:t;if("undefined"!=typeof document.body.style[r])return r}return null}function ut(){return this.state.isDestroyed=!0,ct(this.modifiers,"applyStyle")&&(this.popper.removeAttribute("x-placement"),this.popper.style.position="",this.popper.style.top="",this.popper.style.left="",this.popper.style.right="",this.popper.style.bottom="",this.popper.style.willChange="",this.popper.style[ht("transform")]=""),this.disableEventListeners(),this.options.removeOnDestroy&&this.popper.parentNode.removeChild(this.popper),this}function ft(t){var e=t.ownerDocument;return e?e.defaultView:window}function dt(t,e,n,i){n.updateBound=i,ft(t).addEventListener("resize",n.updateBound,{passive:!0});var o=I(t);return function t(e,n,i,o){var r="BODY"===e.nodeName,s=r?e.ownerDocument.defaultView:e;s.addEventListener(n,i,{passive:!0}),r||t(I(s.parentNode),n,i,o),o.push(s)}(o,"scroll",n.updateBound,n.scrollParents),n.scrollElement=o,n.eventsEnabled=!0,n}function pt(){this.state.eventsEnabled||(this.state=dt(this.reference,this.options,this.state,this.scheduleUpdate))}function mt(){var t,e;this.state.eventsEnabled&&(cancelAnimationFrame(this.scheduleUpdate),this.state=(t=this.reference,e=this.state,ft(t).removeEventListener("resize",e.updateBound),e.scrollParents.forEach((function(t){t.removeEventListener("scroll",e.updateBound)})),e.updateBound=null,e.scrollParents=[],e.scrollElement=null,e.eventsEnabled=!1,e))}function gt(t){return""!==t&&!isNaN(parseFloat(t))&&isFinite(t)}function _t(t,e){Object.keys(e).forEach((function(n){var i="";-1!==["width","height","top","right","bottom","left"].indexOf(n)&>(e[n])&&(i="px"),t.style[n]=e[n]+i}))}var vt=C&&/Firefox/i.test(navigator.userAgent);function bt(t,e,n){var i=st(t,(function(t){return t.name===e})),o=!!i&&t.some((function(t){return t.name===n&&t.enabled&&t.order<i.order}));if(!o){var r="`"+e+"`",s="`"+n+"`";console.warn(s+" modifier is required by "+r+" modifier in order to work, be sure to include it before "+r+"!")}return o}var yt=["auto-start","auto","auto-end","top-start","top","top-end","right-start","right","right-end","bottom-end","bottom","bottom-start","left-end","left","left-start"],wt=yt.slice(3);function Et(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=wt.indexOf(t),i=wt.slice(n+1).concat(wt.slice(0,n));return e?i.reverse():i}var Tt="flip",Ct="clockwise",St="counterclockwise";function Dt(t,e,n,i){var o=[0,0],r=-1!==["right","left"].indexOf(i),s=t.split(/(\+|\-)/).map((function(t){return t.trim()})),a=s.indexOf(st(s,(function(t){return-1!==t.search(/,|\s/)})));s[a]&&-1===s[a].indexOf(",")&&console.warn("Offsets separated by white space(s) are deprecated, use a comma (,) instead.");var l=/\s*,\s*|\s+/,c=-1!==a?[s.slice(0,a).concat([s[a].split(l)[0]]),[s[a].split(l)[1]].concat(s.slice(a+1))]:[s];return(c=c.map((function(t,i){var o=(1===i?!r:r)?"height":"width",s=!1;return t.reduce((function(t,e){return""===t[t.length-1]&&-1!==["+","-"].indexOf(e)?(t[t.length-1]=e,s=!0,t):s?(t[t.length-1]+=e,s=!1,t):t.concat(e)}),[]).map((function(t){return function(t,e,n,i){var o=t.match(/((?:\-|\+)?\d*\.?\d*)(.*)/),r=+o[1],s=o[2];if(!r)return t;if(0===s.indexOf("%")){var a=void 0;switch(s){case"%p":a=n;break;case"%":case"%r":default:a=i}return z(a)[e]/100*r}if("vh"===s||"vw"===s){return("vh"===s?Math.max(document.documentElement.clientHeight,window.innerHeight||0):Math.max(document.documentElement.clientWidth,window.innerWidth||0))/100*r}return r}(t,o,e,n)}))}))).forEach((function(t,e){t.forEach((function(n,i){gt(n)&&(o[e]+=n*("-"===t[i-1]?-1:1))}))})),o}var Nt={placement:"bottom",positionFixed:!1,eventsEnabled:!0,removeOnDestroy:!1,onCreate:function(){},onUpdate:function(){},modifiers:{shift:{order:100,enabled:!0,fn:function(t){var e=t.placement,n=e.split("-")[0],i=e.split("-")[1];if(i){var o=t.offsets,r=o.reference,s=o.popper,a=-1!==["bottom","top"].indexOf(n),l=a?"left":"top",c=a?"width":"height",h={start:V({},l,r[l]),end:V({},l,r[l]+r[c]-s[c])};t.offsets.popper=Y({},s,h[i])}return t}},offset:{order:200,enabled:!0,fn:function(t,e){var n=e.offset,i=t.placement,o=t.offsets,r=o.popper,s=o.reference,a=i.split("-")[0],l=void 0;return l=gt(+n)?[+n,0]:Dt(n,r,s,a),"left"===a?(r.top+=l[0],r.left-=l[1]):"right"===a?(r.top+=l[0],r.left+=l[1]):"top"===a?(r.left+=l[0],r.top-=l[1]):"bottom"===a&&(r.left+=l[0],r.top+=l[1]),t.popper=r,t},offset:0},preventOverflow:{order:300,enabled:!0,fn:function(t,e){var n=e.boundariesElement||P(t.instance.popper);t.instance.reference===n&&(n=P(n));var i=ht("transform"),o=t.instance.popper.style,r=o.top,s=o.left,a=o[i];o.top="",o.left="",o[i]="";var l=Z(t.instance.popper,t.instance.reference,e.padding,n,t.positionFixed);o.top=r,o.left=s,o[i]=a,e.boundaries=l;var c=e.priority,h=t.offsets.popper,u={primary:function(t){var n=h[t];return h[t]<l[t]&&!e.escapeWithReference&&(n=Math.max(h[t],l[t])),V({},t,n)},secondary:function(t){var n="right"===t?"left":"top",i=h[n];return h[t]>l[t]&&!e.escapeWithReference&&(i=Math.min(h[n],l[t]-("right"===t?h.width:h.height))),V({},n,i)}};return c.forEach((function(t){var e=-1!==["left","top"].indexOf(t)?"primary":"secondary";h=Y({},h,u[e](t))})),t.offsets.popper=h,t},priority:["left","right","top","bottom"],padding:5,boundariesElement:"scrollParent"},keepTogether:{order:400,enabled:!0,fn:function(t){var e=t.offsets,n=e.popper,i=e.reference,o=t.placement.split("-")[0],r=Math.floor,s=-1!==["top","bottom"].indexOf(o),a=s?"right":"bottom",l=s?"left":"top",c=s?"width":"height";return n[a]<r(i[l])&&(t.offsets.popper[l]=r(i[l])-n[c]),n[l]>r(i[a])&&(t.offsets.popper[l]=r(i[a])),t}},arrow:{order:500,enabled:!0,fn:function(t,e){var n;if(!bt(t.instance.modifiers,"arrow","keepTogether"))return t;var i=e.element;if("string"==typeof i){if(!(i=t.instance.popper.querySelector(i)))return t}else if(!t.instance.popper.contains(i))return console.warn("WARNING: `arrow.element` must be child of its popper element!"),t;var o=t.placement.split("-")[0],r=t.offsets,s=r.popper,a=r.reference,l=-1!==["left","right"].indexOf(o),c=l?"height":"width",h=l?"Top":"Left",u=h.toLowerCase(),f=l?"left":"top",d=l?"bottom":"right",p=it(i)[c];a[d]-p<s[u]&&(t.offsets.popper[u]-=s[u]-(a[d]-p)),a[u]+p>s[d]&&(t.offsets.popper[u]+=a[u]+p-s[d]),t.offsets.popper=z(t.offsets.popper);var m=a[u]+a[c]/2-p/2,g=k(t.instance.popper),_=parseFloat(g["margin"+h]),v=parseFloat(g["border"+h+"Width"]),b=m-t.offsets.popper[u]-_-v;return b=Math.max(Math.min(s[c]-p,b),0),t.arrowElement=i,t.offsets.arrow=(V(n={},u,Math.round(b)),V(n,f,""),n),t},element:"[x-arrow]"},flip:{order:600,enabled:!0,fn:function(t,e){if(ct(t.instance.modifiers,"inner"))return t;if(t.flipped&&t.placement===t.originalPlacement)return t;var n=Z(t.instance.popper,t.instance.reference,e.padding,e.boundariesElement,t.positionFixed),i=t.placement.split("-")[0],o=ot(i),r=t.placement.split("-")[1]||"",s=[];switch(e.behavior){case Tt:s=[i,o];break;case Ct:s=Et(i);break;case St:s=Et(i,!0);break;default:s=e.behavior}return s.forEach((function(a,l){if(i!==a||s.length===l+1)return t;i=t.placement.split("-")[0],o=ot(i);var c=t.offsets.popper,h=t.offsets.reference,u=Math.floor,f="left"===i&&u(c.right)>u(h.left)||"right"===i&&u(c.left)<u(h.right)||"top"===i&&u(c.bottom)>u(h.top)||"bottom"===i&&u(c.top)<u(h.bottom),d=u(c.left)<u(n.left),p=u(c.right)>u(n.right),m=u(c.top)<u(n.top),g=u(c.bottom)>u(n.bottom),_="left"===i&&d||"right"===i&&p||"top"===i&&m||"bottom"===i&&g,v=-1!==["top","bottom"].indexOf(i),b=!!e.flipVariations&&(v&&"start"===r&&d||v&&"end"===r&&p||!v&&"start"===r&&m||!v&&"end"===r&&g),y=!!e.flipVariationsByContent&&(v&&"start"===r&&p||v&&"end"===r&&d||!v&&"start"===r&&g||!v&&"end"===r&&m),w=b||y;(f||_||w)&&(t.flipped=!0,(f||_)&&(i=s[l+1]),w&&(r=function(t){return"end"===t?"start":"start"===t?"end":t}(r)),t.placement=i+(r?"-"+r:""),t.offsets.popper=Y({},t.offsets.popper,rt(t.instance.popper,t.offsets.reference,t.placement)),t=at(t.instance.modifiers,t,"flip"))})),t},behavior:"flip",padding:5,boundariesElement:"viewport",flipVariations:!1,flipVariationsByContent:!1},inner:{order:700,enabled:!1,fn:function(t){var e=t.placement,n=e.split("-")[0],i=t.offsets,o=i.popper,r=i.reference,s=-1!==["left","right"].indexOf(n),a=-1===["top","left"].indexOf(n);return o[s?"left":"top"]=r[n]-(a?o[s?"width":"height"]:0),t.placement=ot(e),t.offsets.popper=z(o),t}},hide:{order:800,enabled:!0,fn:function(t){if(!bt(t.instance.modifiers,"hide","preventOverflow"))return t;var e=t.offsets.reference,n=st(t.instance.modifiers,(function(t){return"preventOverflow"===t.name})).boundaries;if(e.bottom<n.top||e.left>n.right||e.top>n.bottom||e.right<n.left){if(!0===t.hide)return t;t.hide=!0,t.attributes["x-out-of-boundaries"]=""}else{if(!1===t.hide)return t;t.hide=!1,t.attributes["x-out-of-boundaries"]=!1}return t}},computeStyle:{order:850,enabled:!0,fn:function(t,e){var n=e.x,i=e.y,o=t.offsets.popper,r=st(t.instance.modifiers,(function(t){return"applyStyle"===t.name})).gpuAcceleration;void 0!==r&&console.warn("WARNING: `gpuAcceleration` option moved to `computeStyle` modifier and will not be supported in future versions of Popper.js!");var s=void 0!==r?r:e.gpuAcceleration,a=P(t.instance.popper),l=X(a),c={position:o.position},h=function(t,e){var n=t.offsets,i=n.popper,o=n.reference,r=Math.round,s=Math.floor,a=function(t){return t},l=r(o.width),c=r(i.width),h=-1!==["left","right"].indexOf(t.placement),u=-1!==t.placement.indexOf("-"),f=e?h||u||l%2==c%2?r:s:a,d=e?r:a;return{left:f(l%2==1&&c%2==1&&!u&&e?i.left-1:i.left),top:d(i.top),bottom:d(i.bottom),right:f(i.right)}}(t,window.devicePixelRatio<2||!vt),u="bottom"===n?"top":"bottom",f="right"===i?"left":"right",d=ht("transform"),p=void 0,m=void 0;if(m="bottom"===u?"HTML"===a.nodeName?-a.clientHeight+h.bottom:-l.height+h.bottom:h.top,p="right"===f?"HTML"===a.nodeName?-a.clientWidth+h.right:-l.width+h.right:h.left,s&&d)c[d]="translate3d("+p+"px, "+m+"px, 0)",c[u]=0,c[f]=0,c.willChange="transform";else{var g="bottom"===u?-1:1,_="right"===f?-1:1;c[u]=m*g,c[f]=p*_,c.willChange=u+", "+f}var v={"x-placement":t.placement};return t.attributes=Y({},v,t.attributes),t.styles=Y({},c,t.styles),t.arrowStyles=Y({},t.offsets.arrow,t.arrowStyles),t},gpuAcceleration:!0,x:"bottom",y:"right"},applyStyle:{order:900,enabled:!0,fn:function(t){var e,n;return _t(t.instance.popper,t.styles),e=t.instance.popper,n=t.attributes,Object.keys(n).forEach((function(t){!1!==n[t]?e.setAttribute(t,n[t]):e.removeAttribute(t)})),t.arrowElement&&Object.keys(t.arrowStyles).length&&_t(t.arrowElement,t.arrowStyles),t},onLoad:function(t,e,n,i,o){var r=nt(o,e,t,n.positionFixed),s=et(n.placement,r,e,t,n.modifiers.flip.boundariesElement,n.modifiers.flip.padding);return e.setAttribute("x-placement",s),_t(e,{position:n.positionFixed?"fixed":"absolute"}),n},gpuAcceleration:void 0}}},kt=function(){function t(e,n){var i=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};W(this,t),this.scheduleUpdate=function(){return requestAnimationFrame(i.update)},this.update=D(this.update.bind(this)),this.options=Y({},t.Defaults,o),this.state={isDestroyed:!1,isCreated:!1,scrollParents:[]},this.reference=e&&e.jquery?e[0]:e,this.popper=n&&n.jquery?n[0]:n,this.options.modifiers={},Object.keys(Y({},t.Defaults.modifiers,o.modifiers)).forEach((function(e){i.options.modifiers[e]=Y({},t.Defaults.modifiers[e]||{},o.modifiers?o.modifiers[e]:{})})),this.modifiers=Object.keys(this.options.modifiers).map((function(t){return Y({name:t},i.options.modifiers[t])})).sort((function(t,e){return t.order-e.order})),this.modifiers.forEach((function(t){t.enabled&&N(t.onLoad)&&t.onLoad(i.reference,i.popper,i.options,t,i.state)})),this.update();var r=this.options.eventsEnabled;r&&this.enableEventListeners(),this.state.eventsEnabled=r}return U(t,[{key:"update",value:function(){return lt.call(this)}},{key:"destroy",value:function(){return ut.call(this)}},{key:"enableEventListeners",value:function(){return pt.call(this)}},{key:"disableEventListeners",value:function(){return mt.call(this)}}]),t}();kt.Utils=("undefined"!=typeof window?window:global).PopperUtils,kt.placements=yt,kt.Defaults=Nt;var At="dropdown",It=e.fn[At],Ot=new RegExp("38|40|27"),xt={offset:0,flip:!0,boundary:"scrollParent",reference:"toggle",display:"dynamic",popperConfig:null},jt={offset:"(number|string|function)",flip:"boolean",boundary:"(string|element)",reference:"(string|element)",display:"string",popperConfig:"(null|object)"},Lt=function(){function t(t,e){this._element=t,this._popper=null,this._config=this._getConfig(e),this._menu=this._getMenuElement(),this._inNavbar=this._detectNavbar(),this._addEventListeners()}var n=t.prototype;return n.toggle=function(){if(!this._element.disabled&&!e(this._element).hasClass("disabled")){var n=e(this._menu).hasClass("show");t._clearMenus(),n||this.show(!0)}},n.show=function(n){if(void 0===n&&(n=!1),!(this._element.disabled||e(this._element).hasClass("disabled")||e(this._menu).hasClass("show"))){var i={relatedTarget:this._element},o=e.Event("show.bs.dropdown",i),r=t._getParentFromElement(this._element);if(e(r).trigger(o),!o.isDefaultPrevented()){if(!this._inNavbar&&n){if("undefined"==typeof kt)throw new TypeError("Bootstrap's dropdowns require Popper.js (https://popper.js.org/)");var a=this._element;"parent"===this._config.reference?a=r:s.isElement(this._config.reference)&&(a=this._config.reference,"undefined"!=typeof this._config.reference.jquery&&(a=this._config.reference[0])),"scrollParent"!==this._config.boundary&&e(r).addClass("position-static"),this._popper=new kt(a,this._menu,this._getPopperConfig())}"ontouchstart"in document.documentElement&&0===e(r).closest(".navbar-nav").length&&e(document.body).children().on("mouseover",null,e.noop),this._element.focus(),this._element.setAttribute("aria-expanded",!0),e(this._menu).toggleClass("show"),e(r).toggleClass("show").trigger(e.Event("shown.bs.dropdown",i))}}},n.hide=function(){if(!this._element.disabled&&!e(this._element).hasClass("disabled")&&e(this._menu).hasClass("show")){var n={relatedTarget:this._element},i=e.Event("hide.bs.dropdown",n),o=t._getParentFromElement(this._element);e(o).trigger(i),i.isDefaultPrevented()||(this._popper&&this._popper.destroy(),e(this._menu).toggleClass("show"),e(o).toggleClass("show").trigger(e.Event("hidden.bs.dropdown",n)))}},n.dispose=function(){e.removeData(this._element,"bs.dropdown"),e(this._element).off(".bs.dropdown"),this._element=null,this._menu=null,null!==this._popper&&(this._popper.destroy(),this._popper=null)},n.update=function(){this._inNavbar=this._detectNavbar(),null!==this._popper&&this._popper.scheduleUpdate()},n._addEventListeners=function(){var t=this;e(this._element).on("click.bs.dropdown",(function(e){e.preventDefault(),e.stopPropagation(),t.toggle()}))},n._getConfig=function(t){return t=o({},this.constructor.Default,e(this._element).data(),t),s.typeCheckConfig(At,t,this.constructor.DefaultType),t},n._getMenuElement=function(){if(!this._menu){var e=t._getParentFromElement(this._element);e&&(this._menu=e.querySelector(".dropdown-menu"))}return this._menu},n._getPlacement=function(){var t=e(this._element.parentNode),n="bottom-start";return t.hasClass("dropup")?n=e(this._menu).hasClass("dropdown-menu-right")?"top-end":"top-start":t.hasClass("dropright")?n="right-start":t.hasClass("dropleft")?n="left-start":e(this._menu).hasClass("dropdown-menu-right")&&(n="bottom-end"),n},n._detectNavbar=function(){return e(this._element).closest(".navbar").length>0},n._getOffset=function(){var t=this,e={};return"function"==typeof this._config.offset?e.fn=function(e){return e.offsets=o({},e.offsets,t._config.offset(e.offsets,t._element)||{}),e}:e.offset=this._config.offset,e},n._getPopperConfig=function(){var t={placement:this._getPlacement(),modifiers:{offset:this._getOffset(),flip:{enabled:this._config.flip},preventOverflow:{boundariesElement:this._config.boundary}}};return"static"===this._config.display&&(t.modifiers.applyStyle={enabled:!1}),o({},t,this._config.popperConfig)},t._jQueryInterface=function(n){return this.each((function(){var i=e(this).data("bs.dropdown");if(i||(i=new t(this,"object"==typeof n?n:null),e(this).data("bs.dropdown",i)),"string"==typeof n){if("undefined"==typeof i[n])throw new TypeError('No method named "'+n+'"');i[n]()}}))},t._clearMenus=function(n){if(!n||3!==n.which&&("keyup"!==n.type||9===n.which))for(var i=[].slice.call(document.querySelectorAll('[data-toggle="dropdown"]')),o=0,r=i.length;o<r;o++){var s=t._getParentFromElement(i[o]),a=e(i[o]).data("bs.dropdown"),l={relatedTarget:i[o]};if(n&&"click"===n.type&&(l.clickEvent=n),a){var c=a._menu;if(e(s).hasClass("show")&&!(n&&("click"===n.type&&/input|textarea/i.test(n.target.tagName)||"keyup"===n.type&&9===n.which)&&e.contains(s,n.target))){var h=e.Event("hide.bs.dropdown",l);e(s).trigger(h),h.isDefaultPrevented()||("ontouchstart"in document.documentElement&&e(document.body).children().off("mouseover",null,e.noop),i[o].setAttribute("aria-expanded","false"),a._popper&&a._popper.destroy(),e(c).removeClass("show"),e(s).removeClass("show").trigger(e.Event("hidden.bs.dropdown",l)))}}}},t._getParentFromElement=function(t){var e,n=s.getSelectorFromElement(t);return n&&(e=document.querySelector(n)),e||t.parentNode},t._dataApiKeydownHandler=function(n){if(!(/input|textarea/i.test(n.target.tagName)?32===n.which||27!==n.which&&(40!==n.which&&38!==n.which||e(n.target).closest(".dropdown-menu").length):!Ot.test(n.which))&&!this.disabled&&!e(this).hasClass("disabled")){var i=t._getParentFromElement(this),o=e(i).hasClass("show");if(o||27!==n.which){if(n.preventDefault(),n.stopPropagation(),!o||o&&(27===n.which||32===n.which))return 27===n.which&&e(i.querySelector('[data-toggle="dropdown"]')).trigger("focus"),void e(this).trigger("click");var r=[].slice.call(i.querySelectorAll(".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)")).filter((function(t){return e(t).is(":visible")}));if(0!==r.length){var s=r.indexOf(n.target);38===n.which&&s>0&&s--,40===n.which&&s<r.length-1&&s++,s<0&&(s=0),r[s].focus()}}}},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"Default",get:function(){return xt}},{key:"DefaultType",get:function(){return jt}}]),t}();e(document).on("keydown.bs.dropdown.data-api",'[data-toggle="dropdown"]',Lt._dataApiKeydownHandler).on("keydown.bs.dropdown.data-api",".dropdown-menu",Lt._dataApiKeydownHandler).on("click.bs.dropdown.data-api keyup.bs.dropdown.data-api",Lt._clearMenus).on("click.bs.dropdown.data-api",'[data-toggle="dropdown"]',(function(t){t.preventDefault(),t.stopPropagation(),Lt._jQueryInterface.call(e(this),"toggle")})).on("click.bs.dropdown.data-api",".dropdown form",(function(t){t.stopPropagation()})),e.fn[At]=Lt._jQueryInterface,e.fn[At].Constructor=Lt,e.fn[At].noConflict=function(){return e.fn[At]=It,Lt._jQueryInterface};var Pt=e.fn.modal,Ft={backdrop:!0,keyboard:!0,focus:!0,show:!0},Rt={backdrop:"(boolean|string)",keyboard:"boolean",focus:"boolean",show:"boolean"},Ht=function(){function t(t,e){this._config=this._getConfig(e),this._element=t,this._dialog=t.querySelector(".modal-dialog"),this._backdrop=null,this._isShown=!1,this._isBodyOverflowing=!1,this._ignoreBackdropClick=!1,this._isTransitioning=!1,this._scrollbarWidth=0}var n=t.prototype;return n.toggle=function(t){return this._isShown?this.hide():this.show(t)},n.show=function(t){var n=this;if(!this._isShown&&!this._isTransitioning){e(this._element).hasClass("fade")&&(this._isTransitioning=!0);var i=e.Event("show.bs.modal",{relatedTarget:t});e(this._element).trigger(i),this._isShown||i.isDefaultPrevented()||(this._isShown=!0,this._checkScrollbar(),this._setScrollbar(),this._adjustDialog(),this._setEscapeEvent(),this._setResizeEvent(),e(this._element).on("click.dismiss.bs.modal",'[data-dismiss="modal"]',(function(t){return n.hide(t)})),e(this._dialog).on("mousedown.dismiss.bs.modal",(function(){e(n._element).one("mouseup.dismiss.bs.modal",(function(t){e(t.target).is(n._element)&&(n._ignoreBackdropClick=!0)}))})),this._showBackdrop((function(){return n._showElement(t)})))}},n.hide=function(t){var n=this;if(t&&t.preventDefault(),this._isShown&&!this._isTransitioning){var i=e.Event("hide.bs.modal");if(e(this._element).trigger(i),this._isShown&&!i.isDefaultPrevented()){this._isShown=!1;var o=e(this._element).hasClass("fade");if(o&&(this._isTransitioning=!0),this._setEscapeEvent(),this._setResizeEvent(),e(document).off("focusin.bs.modal"),e(this._element).removeClass("show"),e(this._element).off("click.dismiss.bs.modal"),e(this._dialog).off("mousedown.dismiss.bs.modal"),o){var r=s.getTransitionDurationFromElement(this._element);e(this._element).one(s.TRANSITION_END,(function(t){return n._hideModal(t)})).emulateTransitionEnd(r)}else this._hideModal()}}},n.dispose=function(){[window,this._element,this._dialog].forEach((function(t){return e(t).off(".bs.modal")})),e(document).off("focusin.bs.modal"),e.removeData(this._element,"bs.modal"),this._config=null,this._element=null,this._dialog=null,this._backdrop=null,this._isShown=null,this._isBodyOverflowing=null,this._ignoreBackdropClick=null,this._isTransitioning=null,this._scrollbarWidth=null},n.handleUpdate=function(){this._adjustDialog()},n._getConfig=function(t){return t=o({},Ft,t),s.typeCheckConfig("modal",t,Rt),t},n._triggerBackdropTransition=function(){var t=this;if("static"===this._config.backdrop){var n=e.Event("hidePrevented.bs.modal");if(e(this._element).trigger(n),n.defaultPrevented)return;var i=this._element.scrollHeight>document.documentElement.clientHeight;i||(this._element.style.overflowY="hidden"),this._element.classList.add("modal-static");var o=s.getTransitionDurationFromElement(this._dialog);e(this._element).off(s.TRANSITION_END),e(this._element).one(s.TRANSITION_END,(function(){t._element.classList.remove("modal-static"),i||e(t._element).one(s.TRANSITION_END,(function(){t._element.style.overflowY=""})).emulateTransitionEnd(t._element,o)})).emulateTransitionEnd(o),this._element.focus()}else this.hide()},n._showElement=function(t){var n=this,i=e(this._element).hasClass("fade"),o=this._dialog?this._dialog.querySelector(".modal-body"):null;this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE||document.body.appendChild(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),e(this._dialog).hasClass("modal-dialog-scrollable")&&o?o.scrollTop=0:this._element.scrollTop=0,i&&s.reflow(this._element),e(this._element).addClass("show"),this._config.focus&&this._enforceFocus();var r=e.Event("shown.bs.modal",{relatedTarget:t}),a=function(){n._config.focus&&n._element.focus(),n._isTransitioning=!1,e(n._element).trigger(r)};if(i){var l=s.getTransitionDurationFromElement(this._dialog);e(this._dialog).one(s.TRANSITION_END,a).emulateTransitionEnd(l)}else a()},n._enforceFocus=function(){var t=this;e(document).off("focusin.bs.modal").on("focusin.bs.modal",(function(n){document!==n.target&&t._element!==n.target&&0===e(t._element).has(n.target).length&&t._element.focus()}))},n._setEscapeEvent=function(){var t=this;this._isShown?e(this._element).on("keydown.dismiss.bs.modal",(function(e){t._config.keyboard&&27===e.which?(e.preventDefault(),t.hide()):t._config.keyboard||27!==e.which||t._triggerBackdropTransition()})):this._isShown||e(this._element).off("keydown.dismiss.bs.modal")},n._setResizeEvent=function(){var t=this;this._isShown?e(window).on("resize.bs.modal",(function(e){return t.handleUpdate(e)})):e(window).off("resize.bs.modal")},n._hideModal=function(){var t=this;this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._showBackdrop((function(){e(document.body).removeClass("modal-open"),t._resetAdjustments(),t._resetScrollbar(),e(t._element).trigger("hidden.bs.modal")}))},n._removeBackdrop=function(){this._backdrop&&(e(this._backdrop).remove(),this._backdrop=null)},n._showBackdrop=function(t){var n=this,i=e(this._element).hasClass("fade")?"fade":"";if(this._isShown&&this._config.backdrop){if(this._backdrop=document.createElement("div"),this._backdrop.className="modal-backdrop",i&&this._backdrop.classList.add(i),e(this._backdrop).appendTo(document.body),e(this._element).on("click.dismiss.bs.modal",(function(t){n._ignoreBackdropClick?n._ignoreBackdropClick=!1:t.target===t.currentTarget&&n._triggerBackdropTransition()})),i&&s.reflow(this._backdrop),e(this._backdrop).addClass("show"),!t)return;if(!i)return void t();var o=s.getTransitionDurationFromElement(this._backdrop);e(this._backdrop).one(s.TRANSITION_END,t).emulateTransitionEnd(o)}else if(!this._isShown&&this._backdrop){e(this._backdrop).removeClass("show");var r=function(){n._removeBackdrop(),t&&t()};if(e(this._element).hasClass("fade")){var a=s.getTransitionDurationFromElement(this._backdrop);e(this._backdrop).one(s.TRANSITION_END,r).emulateTransitionEnd(a)}else r()}else t&&t()},n._adjustDialog=function(){var t=this._element.scrollHeight>document.documentElement.clientHeight;!this._isBodyOverflowing&&t&&(this._element.style.paddingLeft=this._scrollbarWidth+"px"),this._isBodyOverflowing&&!t&&(this._element.style.paddingRight=this._scrollbarWidth+"px")},n._resetAdjustments=function(){this._element.style.paddingLeft="",this._element.style.paddingRight=""},n._checkScrollbar=function(){var t=document.body.getBoundingClientRect();this._isBodyOverflowing=Math.round(t.left+t.right)<window.innerWidth,this._scrollbarWidth=this._getScrollbarWidth()},n._setScrollbar=function(){var t=this;if(this._isBodyOverflowing){var n=[].slice.call(document.querySelectorAll(".fixed-top, .fixed-bottom, .is-fixed, .sticky-top")),i=[].slice.call(document.querySelectorAll(".sticky-top"));e(n).each((function(n,i){var o=i.style.paddingRight,r=e(i).css("padding-right");e(i).data("padding-right",o).css("padding-right",parseFloat(r)+t._scrollbarWidth+"px")})),e(i).each((function(n,i){var o=i.style.marginRight,r=e(i).css("margin-right");e(i).data("margin-right",o).css("margin-right",parseFloat(r)-t._scrollbarWidth+"px")}));var o=document.body.style.paddingRight,r=e(document.body).css("padding-right");e(document.body).data("padding-right",o).css("padding-right",parseFloat(r)+this._scrollbarWidth+"px")}e(document.body).addClass("modal-open")},n._resetScrollbar=function(){var t=[].slice.call(document.querySelectorAll(".fixed-top, .fixed-bottom, .is-fixed, .sticky-top"));e(t).each((function(t,n){var i=e(n).data("padding-right");e(n).removeData("padding-right"),n.style.paddingRight=i||""}));var n=[].slice.call(document.querySelectorAll(".sticky-top"));e(n).each((function(t,n){var i=e(n).data("margin-right");"undefined"!=typeof i&&e(n).css("margin-right",i).removeData("margin-right")}));var i=e(document.body).data("padding-right");e(document.body).removeData("padding-right"),document.body.style.paddingRight=i||""},n._getScrollbarWidth=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",document.body.appendChild(t);var e=t.getBoundingClientRect().width-t.clientWidth;return document.body.removeChild(t),e},t._jQueryInterface=function(n,i){return this.each((function(){var r=e(this).data("bs.modal"),s=o({},Ft,e(this).data(),"object"==typeof n&&n?n:{});if(r||(r=new t(this,s),e(this).data("bs.modal",r)),"string"==typeof n){if("undefined"==typeof r[n])throw new TypeError('No method named "'+n+'"');r[n](i)}else s.show&&r.show(i)}))},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"Default",get:function(){return Ft}}]),t}();e(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',(function(t){var n,i=this,r=s.getSelectorFromElement(this);r&&(n=document.querySelector(r));var a=e(n).data("bs.modal")?"toggle":o({},e(n).data(),e(this).data());"A"!==this.tagName&&"AREA"!==this.tagName||t.preventDefault();var l=e(n).one("show.bs.modal",(function(t){t.isDefaultPrevented()||l.one("hidden.bs.modal",(function(){e(i).is(":visible")&&i.focus()}))}));Ht._jQueryInterface.call(e(n),a,this)})),e.fn.modal=Ht._jQueryInterface,e.fn.modal.Constructor=Ht,e.fn.modal.noConflict=function(){return e.fn.modal=Pt,Ht._jQueryInterface};var Mt=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],Bt={"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},qt=/^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/gi,Qt=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i;function Wt(t,e,n){if(0===t.length)return t;if(n&&"function"==typeof n)return n(t);for(var i=(new window.DOMParser).parseFromString(t,"text/html"),o=Object.keys(e),r=[].slice.call(i.body.querySelectorAll("*")),s=function(t,n){var i=r[t],s=i.nodeName.toLowerCase();if(-1===o.indexOf(i.nodeName.toLowerCase()))return i.parentNode.removeChild(i),"continue";var a=[].slice.call(i.attributes),l=[].concat(e["*"]||[],e[s]||[]);a.forEach((function(t){(function(t,e){var n=t.nodeName.toLowerCase();if(-1!==e.indexOf(n))return-1===Mt.indexOf(n)||Boolean(t.nodeValue.match(qt)||t.nodeValue.match(Qt));for(var i=e.filter((function(t){return t instanceof RegExp})),o=0,r=i.length;o<r;o++)if(n.match(i[o]))return!0;return!1})(t,l)||i.removeAttribute(t.nodeName)}))},a=0,l=r.length;a<l;a++)s(a);return i.body.innerHTML}var Ut="tooltip",Vt=e.fn[Ut],Yt=new RegExp("(^|\\s)bs-tooltip\\S+","g"),zt=["sanitize","whiteList","sanitizeFn"],Xt={animation:"boolean",template:"string",title:"(string|element|function)",trigger:"string",delay:"(number|object)",html:"boolean",selector:"(string|boolean)",placement:"(string|function)",offset:"(number|string|function)",container:"(string|element|boolean)",fallbackPlacement:"(string|array)",boundary:"(string|element)",sanitize:"boolean",sanitizeFn:"(null|function)",whiteList:"object",popperConfig:"(null|object)"},Kt={AUTO:"auto",TOP:"top",RIGHT:"right",BOTTOM:"bottom",LEFT:"left"},Gt={animation:!0,template:'<div class="tooltip" role="tooltip"><div class="arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:0,container:!1,fallbackPlacement:"flip",boundary:"scrollParent",sanitize:!0,sanitizeFn:null,whiteList:Bt,popperConfig:null},$t={HIDE:"hide.bs.tooltip",HIDDEN:"hidden.bs.tooltip",SHOW:"show.bs.tooltip",SHOWN:"shown.bs.tooltip",INSERTED:"inserted.bs.tooltip",CLICK:"click.bs.tooltip",FOCUSIN:"focusin.bs.tooltip",FOCUSOUT:"focusout.bs.tooltip",MOUSEENTER:"mouseenter.bs.tooltip",MOUSELEAVE:"mouseleave.bs.tooltip"},Jt=function(){function t(t,e){if("undefined"==typeof kt)throw new TypeError("Bootstrap's tooltips require Popper.js (https://popper.js.org/)");this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this.element=t,this.config=this._getConfig(e),this.tip=null,this._setListeners()}var n=t.prototype;return n.enable=function(){this._isEnabled=!0},n.disable=function(){this._isEnabled=!1},n.toggleEnabled=function(){this._isEnabled=!this._isEnabled},n.toggle=function(t){if(this._isEnabled)if(t){var n=this.constructor.DATA_KEY,i=e(t.currentTarget).data(n);i||(i=new this.constructor(t.currentTarget,this._getDelegateConfig()),e(t.currentTarget).data(n,i)),i._activeTrigger.click=!i._activeTrigger.click,i._isWithActiveTrigger()?i._enter(null,i):i._leave(null,i)}else{if(e(this.getTipElement()).hasClass("show"))return void this._leave(null,this);this._enter(null,this)}},n.dispose=function(){clearTimeout(this._timeout),e.removeData(this.element,this.constructor.DATA_KEY),e(this.element).off(this.constructor.EVENT_KEY),e(this.element).closest(".modal").off("hide.bs.modal",this._hideModalHandler),this.tip&&e(this.tip).remove(),this._isEnabled=null,this._timeout=null,this._hoverState=null,this._activeTrigger=null,this._popper&&this._popper.destroy(),this._popper=null,this.element=null,this.config=null,this.tip=null},n.show=function(){var t=this;if("none"===e(this.element).css("display"))throw new Error("Please use show on visible elements");var n=e.Event(this.constructor.Event.SHOW);if(this.isWithContent()&&this._isEnabled){e(this.element).trigger(n);var i=s.findShadowRoot(this.element),o=e.contains(null!==i?i:this.element.ownerDocument.documentElement,this.element);if(n.isDefaultPrevented()||!o)return;var r=this.getTipElement(),a=s.getUID(this.constructor.NAME);r.setAttribute("id",a),this.element.setAttribute("aria-describedby",a),this.setContent(),this.config.animation&&e(r).addClass("fade");var l="function"==typeof this.config.placement?this.config.placement.call(this,r,this.element):this.config.placement,c=this._getAttachment(l);this.addAttachmentClass(c);var h=this._getContainer();e(r).data(this.constructor.DATA_KEY,this),e.contains(this.element.ownerDocument.documentElement,this.tip)||e(r).appendTo(h),e(this.element).trigger(this.constructor.Event.INSERTED),this._popper=new kt(this.element,r,this._getPopperConfig(c)),e(r).addClass("show"),"ontouchstart"in document.documentElement&&e(document.body).children().on("mouseover",null,e.noop);var u=function(){t.config.animation&&t._fixTransition();var n=t._hoverState;t._hoverState=null,e(t.element).trigger(t.constructor.Event.SHOWN),"out"===n&&t._leave(null,t)};if(e(this.tip).hasClass("fade")){var f=s.getTransitionDurationFromElement(this.tip);e(this.tip).one(s.TRANSITION_END,u).emulateTransitionEnd(f)}else u()}},n.hide=function(t){var n=this,i=this.getTipElement(),o=e.Event(this.constructor.Event.HIDE),r=function(){"show"!==n._hoverState&&i.parentNode&&i.parentNode.removeChild(i),n._cleanTipClass(),n.element.removeAttribute("aria-describedby"),e(n.element).trigger(n.constructor.Event.HIDDEN),null!==n._popper&&n._popper.destroy(),t&&t()};if(e(this.element).trigger(o),!o.isDefaultPrevented()){if(e(i).removeClass("show"),"ontouchstart"in document.documentElement&&e(document.body).children().off("mouseover",null,e.noop),this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1,e(this.tip).hasClass("fade")){var a=s.getTransitionDurationFromElement(i);e(i).one(s.TRANSITION_END,r).emulateTransitionEnd(a)}else r();this._hoverState=""}},n.update=function(){null!==this._popper&&this._popper.scheduleUpdate()},n.isWithContent=function(){return Boolean(this.getTitle())},n.addAttachmentClass=function(t){e(this.getTipElement()).addClass("bs-tooltip-"+t)},n.getTipElement=function(){return this.tip=this.tip||e(this.config.template)[0],this.tip},n.setContent=function(){var t=this.getTipElement();this.setElementContent(e(t.querySelectorAll(".tooltip-inner")),this.getTitle()),e(t).removeClass("fade show")},n.setElementContent=function(t,n){"object"!=typeof n||!n.nodeType&&!n.jquery?this.config.html?(this.config.sanitize&&(n=Wt(n,this.config.whiteList,this.config.sanitizeFn)),t.html(n)):t.text(n):this.config.html?e(n).parent().is(t)||t.empty().append(n):t.text(e(n).text())},n.getTitle=function(){var t=this.element.getAttribute("data-original-title");return t||(t="function"==typeof this.config.title?this.config.title.call(this.element):this.config.title),t},n._getPopperConfig=function(t){var e=this;return o({},{placement:t,modifiers:{offset:this._getOffset(),flip:{behavior:this.config.fallbackPlacement},arrow:{element:".arrow"},preventOverflow:{boundariesElement:this.config.boundary}},onCreate:function(t){t.originalPlacement!==t.placement&&e._handlePopperPlacementChange(t)},onUpdate:function(t){return e._handlePopperPlacementChange(t)}},this.config.popperConfig)},n._getOffset=function(){var t=this,e={};return"function"==typeof this.config.offset?e.fn=function(e){return e.offsets=o({},e.offsets,t.config.offset(e.offsets,t.element)||{}),e}:e.offset=this.config.offset,e},n._getContainer=function(){return!1===this.config.container?document.body:s.isElement(this.config.container)?e(this.config.container):e(document).find(this.config.container)},n._getAttachment=function(t){return Kt[t.toUpperCase()]},n._setListeners=function(){var t=this;this.config.trigger.split(" ").forEach((function(n){if("click"===n)e(t.element).on(t.constructor.Event.CLICK,t.config.selector,(function(e){return t.toggle(e)}));else if("manual"!==n){var i="hover"===n?t.constructor.Event.MOUSEENTER:t.constructor.Event.FOCUSIN,o="hover"===n?t.constructor.Event.MOUSELEAVE:t.constructor.Event.FOCUSOUT;e(t.element).on(i,t.config.selector,(function(e){return t._enter(e)})).on(o,t.config.selector,(function(e){return t._leave(e)}))}})),this._hideModalHandler=function(){t.element&&t.hide()},e(this.element).closest(".modal").on("hide.bs.modal",this._hideModalHandler),this.config.selector?this.config=o({},this.config,{trigger:"manual",selector:""}):this._fixTitle()},n._fixTitle=function(){var t=typeof this.element.getAttribute("data-original-title");(this.element.getAttribute("title")||"string"!==t)&&(this.element.setAttribute("data-original-title",this.element.getAttribute("title")||""),this.element.setAttribute("title",""))},n._enter=function(t,n){var i=this.constructor.DATA_KEY;(n=n||e(t.currentTarget).data(i))||(n=new this.constructor(t.currentTarget,this._getDelegateConfig()),e(t.currentTarget).data(i,n)),t&&(n._activeTrigger["focusin"===t.type?"focus":"hover"]=!0),e(n.getTipElement()).hasClass("show")||"show"===n._hoverState?n._hoverState="show":(clearTimeout(n._timeout),n._hoverState="show",n.config.delay&&n.config.delay.show?n._timeout=setTimeout((function(){"show"===n._hoverState&&n.show()}),n.config.delay.show):n.show())},n._leave=function(t,n){var i=this.constructor.DATA_KEY;(n=n||e(t.currentTarget).data(i))||(n=new this.constructor(t.currentTarget,this._getDelegateConfig()),e(t.currentTarget).data(i,n)),t&&(n._activeTrigger["focusout"===t.type?"focus":"hover"]=!1),n._isWithActiveTrigger()||(clearTimeout(n._timeout),n._hoverState="out",n.config.delay&&n.config.delay.hide?n._timeout=setTimeout((function(){"out"===n._hoverState&&n.hide()}),n.config.delay.hide):n.hide())},n._isWithActiveTrigger=function(){for(var t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1},n._getConfig=function(t){var n=e(this.element).data();return Object.keys(n).forEach((function(t){-1!==zt.indexOf(t)&&delete n[t]})),"number"==typeof(t=o({},this.constructor.Default,n,"object"==typeof t&&t?t:{})).delay&&(t.delay={show:t.delay,hide:t.delay}),"number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),s.typeCheckConfig(Ut,t,this.constructor.DefaultType),t.sanitize&&(t.template=Wt(t.template,t.whiteList,t.sanitizeFn)),t},n._getDelegateConfig=function(){var t={};if(this.config)for(var e in this.config)this.constructor.Default[e]!==this.config[e]&&(t[e]=this.config[e]);return t},n._cleanTipClass=function(){var t=e(this.getTipElement()),n=t.attr("class").match(Yt);null!==n&&n.length&&t.removeClass(n.join(""))},n._handlePopperPlacementChange=function(t){this.tip=t.instance.popper,this._cleanTipClass(),this.addAttachmentClass(this._getAttachment(t.placement))},n._fixTransition=function(){var t=this.getTipElement(),n=this.config.animation;null===t.getAttribute("x-placement")&&(e(t).removeClass("fade"),this.config.animation=!1,this.hide(),this.show(),this.config.animation=n)},t._jQueryInterface=function(n){return this.each((function(){var i=e(this).data("bs.tooltip"),o="object"==typeof n&&n;if((i||!/dispose|hide/.test(n))&&(i||(i=new t(this,o),e(this).data("bs.tooltip",i)),"string"==typeof n)){if("undefined"==typeof i[n])throw new TypeError('No method named "'+n+'"');i[n]()}}))},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"Default",get:function(){return Gt}},{key:"NAME",get:function(){return Ut}},{key:"DATA_KEY",get:function(){return"bs.tooltip"}},{key:"Event",get:function(){return $t}},{key:"EVENT_KEY",get:function(){return".bs.tooltip"}},{key:"DefaultType",get:function(){return Xt}}]),t}();e.fn[Ut]=Jt._jQueryInterface,e.fn[Ut].Constructor=Jt,e.fn[Ut].noConflict=function(){return e.fn[Ut]=Vt,Jt._jQueryInterface};var Zt="popover",te=e.fn[Zt],ee=new RegExp("(^|\\s)bs-popover\\S+","g"),ne=o({},Jt.Default,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'}),ie=o({},Jt.DefaultType,{content:"(string|element|function)"}),oe={HIDE:"hide.bs.popover",HIDDEN:"hidden.bs.popover",SHOW:"show.bs.popover",SHOWN:"shown.bs.popover",INSERTED:"inserted.bs.popover",CLICK:"click.bs.popover",FOCUSIN:"focusin.bs.popover",FOCUSOUT:"focusout.bs.popover",MOUSEENTER:"mouseenter.bs.popover",MOUSELEAVE:"mouseleave.bs.popover"},re=function(t){var n,o;function r(){return t.apply(this,arguments)||this}o=t,(n=r).prototype=Object.create(o.prototype),n.prototype.constructor=n,n.__proto__=o;var s=r.prototype;return s.isWithContent=function(){return this.getTitle()||this._getContent()},s.addAttachmentClass=function(t){e(this.getTipElement()).addClass("bs-popover-"+t)},s.getTipElement=function(){return this.tip=this.tip||e(this.config.template)[0],this.tip},s.setContent=function(){var t=e(this.getTipElement());this.setElementContent(t.find(".popover-header"),this.getTitle());var n=this._getContent();"function"==typeof n&&(n=n.call(this.element)),this.setElementContent(t.find(".popover-body"),n),t.removeClass("fade show")},s._getContent=function(){return this.element.getAttribute("data-content")||this.config.content},s._cleanTipClass=function(){var t=e(this.getTipElement()),n=t.attr("class").match(ee);null!==n&&n.length>0&&t.removeClass(n.join(""))},r._jQueryInterface=function(t){return this.each((function(){var n=e(this).data("bs.popover"),i="object"==typeof t?t:null;if((n||!/dispose|hide/.test(t))&&(n||(n=new r(this,i),e(this).data("bs.popover",n)),"string"==typeof t)){if("undefined"==typeof n[t])throw new TypeError('No method named "'+t+'"');n[t]()}}))},i(r,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"Default",get:function(){return ne}},{key:"NAME",get:function(){return Zt}},{key:"DATA_KEY",get:function(){return"bs.popover"}},{key:"Event",get:function(){return oe}},{key:"EVENT_KEY",get:function(){return".bs.popover"}},{key:"DefaultType",get:function(){return ie}}]),r}(Jt);e.fn[Zt]=re._jQueryInterface,e.fn[Zt].Constructor=re,e.fn[Zt].noConflict=function(){return e.fn[Zt]=te,re._jQueryInterface};var se="scrollspy",ae=e.fn[se],le={offset:10,method:"auto",target:""},ce={offset:"number",method:"string",target:"(string|element)"},he=function(){function t(t,n){var i=this;this._element=t,this._scrollElement="BODY"===t.tagName?window:t,this._config=this._getConfig(n),this._selector=this._config.target+" .nav-link,"+this._config.target+" .list-group-item,"+this._config.target+" .dropdown-item",this._offsets=[],this._targets=[],this._activeTarget=null,this._scrollHeight=0,e(this._scrollElement).on("scroll.bs.scrollspy",(function(t){return i._process(t)})),this.refresh(),this._process()}var n=t.prototype;return n.refresh=function(){var t=this,n=this._scrollElement===this._scrollElement.window?"offset":"position",i="auto"===this._config.method?n:this._config.method,o="position"===i?this._getScrollTop():0;this._offsets=[],this._targets=[],this._scrollHeight=this._getScrollHeight(),[].slice.call(document.querySelectorAll(this._selector)).map((function(t){var n,r=s.getSelectorFromElement(t);if(r&&(n=document.querySelector(r)),n){var a=n.getBoundingClientRect();if(a.width||a.height)return[e(n)[i]().top+o,r]}return null})).filter((function(t){return t})).sort((function(t,e){return t[0]-e[0]})).forEach((function(e){t._offsets.push(e[0]),t._targets.push(e[1])}))},n.dispose=function(){e.removeData(this._element,"bs.scrollspy"),e(this._scrollElement).off(".bs.scrollspy"),this._element=null,this._scrollElement=null,this._config=null,this._selector=null,this._offsets=null,this._targets=null,this._activeTarget=null,this._scrollHeight=null},n._getConfig=function(t){if("string"!=typeof(t=o({},le,"object"==typeof t&&t?t:{})).target&&s.isElement(t.target)){var n=e(t.target).attr("id");n||(n=s.getUID(se),e(t.target).attr("id",n)),t.target="#"+n}return s.typeCheckConfig(se,t,ce),t},n._getScrollTop=function(){return this._scrollElement===window?this._scrollElement.pageYOffset:this._scrollElement.scrollTop},n._getScrollHeight=function(){return this._scrollElement.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)},n._getOffsetHeight=function(){return this._scrollElement===window?window.innerHeight:this._scrollElement.getBoundingClientRect().height},n._process=function(){var t=this._getScrollTop()+this._config.offset,e=this._getScrollHeight(),n=this._config.offset+e-this._getOffsetHeight();if(this._scrollHeight!==e&&this.refresh(),t>=n){var i=this._targets[this._targets.length-1];this._activeTarget!==i&&this._activate(i)}else{if(this._activeTarget&&t<this._offsets[0]&&this._offsets[0]>0)return this._activeTarget=null,void this._clear();for(var o=this._offsets.length;o--;){this._activeTarget!==this._targets[o]&&t>=this._offsets[o]&&("undefined"==typeof this._offsets[o+1]||t<this._offsets[o+1])&&this._activate(this._targets[o])}}},n._activate=function(t){this._activeTarget=t,this._clear();var n=this._selector.split(",").map((function(e){return e+'[data-target="'+t+'"],'+e+'[href="'+t+'"]'})),i=e([].slice.call(document.querySelectorAll(n.join(","))));i.hasClass("dropdown-item")?(i.closest(".dropdown").find(".dropdown-toggle").addClass("active"),i.addClass("active")):(i.addClass("active"),i.parents(".nav, .list-group").prev(".nav-link, .list-group-item").addClass("active"),i.parents(".nav, .list-group").prev(".nav-item").children(".nav-link").addClass("active")),e(this._scrollElement).trigger("activate.bs.scrollspy",{relatedTarget:t})},n._clear=function(){[].slice.call(document.querySelectorAll(this._selector)).filter((function(t){return t.classList.contains("active")})).forEach((function(t){return t.classList.remove("active")}))},t._jQueryInterface=function(n){return this.each((function(){var i=e(this).data("bs.scrollspy");if(i||(i=new t(this,"object"==typeof n&&n),e(this).data("bs.scrollspy",i)),"string"==typeof n){if("undefined"==typeof i[n])throw new TypeError('No method named "'+n+'"');i[n]()}}))},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"Default",get:function(){return le}}]),t}();e(window).on("load.bs.scrollspy.data-api",(function(){for(var t=[].slice.call(document.querySelectorAll('[data-spy="scroll"]')),n=t.length;n--;){var i=e(t[n]);he._jQueryInterface.call(i,i.data())}})),e.fn[se]=he._jQueryInterface,e.fn[se].Constructor=he,e.fn[se].noConflict=function(){return e.fn[se]=ae,he._jQueryInterface};var ue=e.fn.tab,fe=function(){function t(t){this._element=t}var n=t.prototype;return n.show=function(){var t=this;if(!(this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE&&e(this._element).hasClass("active")||e(this._element).hasClass("disabled"))){var n,i,o=e(this._element).closest(".nav, .list-group")[0],r=s.getSelectorFromElement(this._element);if(o){var a="UL"===o.nodeName||"OL"===o.nodeName?"> li > .active":".active";i=(i=e.makeArray(e(o).find(a)))[i.length-1]}var l=e.Event("hide.bs.tab",{relatedTarget:this._element}),c=e.Event("show.bs.tab",{relatedTarget:i});if(i&&e(i).trigger(l),e(this._element).trigger(c),!c.isDefaultPrevented()&&!l.isDefaultPrevented()){r&&(n=document.querySelector(r)),this._activate(this._element,o);var h=function(){var n=e.Event("hidden.bs.tab",{relatedTarget:t._element}),o=e.Event("shown.bs.tab",{relatedTarget:i});e(i).trigger(n),e(t._element).trigger(o)};n?this._activate(n,n.parentNode,h):h()}}},n.dispose=function(){e.removeData(this._element,"bs.tab"),this._element=null},n._activate=function(t,n,i){var o=this,r=(!n||"UL"!==n.nodeName&&"OL"!==n.nodeName?e(n).children(".active"):e(n).find("> li > .active"))[0],a=i&&r&&e(r).hasClass("fade"),l=function(){return o._transitionComplete(t,r,i)};if(r&&a){var c=s.getTransitionDurationFromElement(r);e(r).removeClass("show").one(s.TRANSITION_END,l).emulateTransitionEnd(c)}else l()},n._transitionComplete=function(t,n,i){if(n){e(n).removeClass("active");var o=e(n.parentNode).find("> .dropdown-menu .active")[0];o&&e(o).removeClass("active"),"tab"===n.getAttribute("role")&&n.setAttribute("aria-selected",!1)}if(e(t).addClass("active"),"tab"===t.getAttribute("role")&&t.setAttribute("aria-selected",!0),s.reflow(t),t.classList.contains("fade")&&t.classList.add("show"),t.parentNode&&e(t.parentNode).hasClass("dropdown-menu")){var r=e(t).closest(".dropdown")[0];if(r){var a=[].slice.call(r.querySelectorAll(".dropdown-toggle"));e(a).addClass("active")}t.setAttribute("aria-expanded",!0)}i&&i()},t._jQueryInterface=function(n){return this.each((function(){var i=e(this),o=i.data("bs.tab");if(o||(o=new t(this),i.data("bs.tab",o)),"string"==typeof n){if("undefined"==typeof o[n])throw new TypeError('No method named "'+n+'"');o[n]()}}))},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}}]),t}();e(document).on("click.bs.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"], [data-toggle="list"]',(function(t){t.preventDefault(),fe._jQueryInterface.call(e(this),"show")})),e.fn.tab=fe._jQueryInterface,e.fn.tab.Constructor=fe,e.fn.tab.noConflict=function(){return e.fn.tab=ue,fe._jQueryInterface};var de=e.fn.toast,pe={animation:"boolean",autohide:"boolean",delay:"number"},me={animation:!0,autohide:!0,delay:500},ge=function(){function t(t,e){this._element=t,this._config=this._getConfig(e),this._timeout=null,this._setListeners()}var n=t.prototype;return n.show=function(){var t=this,n=e.Event("show.bs.toast");if(e(this._element).trigger(n),!n.isDefaultPrevented()){this._clearTimeout(),this._config.animation&&this._element.classList.add("fade");var i=function(){t._element.classList.remove("showing"),t._element.classList.add("show"),e(t._element).trigger("shown.bs.toast"),t._config.autohide&&(t._timeout=setTimeout((function(){t.hide()}),t._config.delay))};if(this._element.classList.remove("hide"),s.reflow(this._element),this._element.classList.add("showing"),this._config.animation){var o=s.getTransitionDurationFromElement(this._element);e(this._element).one(s.TRANSITION_END,i).emulateTransitionEnd(o)}else i()}},n.hide=function(){if(this._element.classList.contains("show")){var t=e.Event("hide.bs.toast");e(this._element).trigger(t),t.isDefaultPrevented()||this._close()}},n.dispose=function(){this._clearTimeout(),this._element.classList.contains("show")&&this._element.classList.remove("show"),e(this._element).off("click.dismiss.bs.toast"),e.removeData(this._element,"bs.toast"),this._element=null,this._config=null},n._getConfig=function(t){return t=o({},me,e(this._element).data(),"object"==typeof t&&t?t:{}),s.typeCheckConfig("toast",t,this.constructor.DefaultType),t},n._setListeners=function(){var t=this;e(this._element).on("click.dismiss.bs.toast",'[data-dismiss="toast"]',(function(){return t.hide()}))},n._close=function(){var t=this,n=function(){t._element.classList.add("hide"),e(t._element).trigger("hidden.bs.toast")};if(this._element.classList.remove("show"),this._config.animation){var i=s.getTransitionDurationFromElement(this._element);e(this._element).one(s.TRANSITION_END,n).emulateTransitionEnd(i)}else n()},n._clearTimeout=function(){clearTimeout(this._timeout),this._timeout=null},t._jQueryInterface=function(n){return this.each((function(){var i=e(this),o=i.data("bs.toast");if(o||(o=new t(this,"object"==typeof n&&n),i.data("bs.toast",o)),"string"==typeof n){if("undefined"==typeof o[n])throw new TypeError('No method named "'+n+'"');o[n](this)}}))},i(t,null,[{key:"VERSION",get:function(){return"4.5.2"}},{key:"DefaultType",get:function(){return pe}},{key:"Default",get:function(){return me}}]),t}();e.fn.toast=ge._jQueryInterface,e.fn.toast.Constructor=ge,e.fn.toast.noConflict=function(){return e.fn.toast=de,ge._jQueryInterface},t.Alert=c,t.Button=u,t.Carousel=v,t.Collapse=T,t.Dropdown=Lt,t.Modal=Ht,t.Popover=re,t.Scrollspy=he,t.Tab=fe,t.Toast=ge,t.Tooltip=Jt,t.Util=s,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
//# sourceMappingURL=bootstrap.bundle.min.js.map
|
|
;(function($){
|
|
/**
|
|
* jqGrid Chinese Translation for v4.2
|
|
* henryyan 2011.11.30
|
|
* http://www.wsria.com
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
*
|
|
* update 2011.11.30
|
|
* add double u3000 SPACE for search:odata to fix SEARCH box display err when narrow width from only use of eq/ne/cn/in/lt/gt operator under IE6/7
|
|
**/
|
|
$.jgrid = $.jgrid || {};
|
|
$.extend($.jgrid,{
|
|
defaults : {
|
|
recordtext: "{0} - {1}\u3000共 {2} 条", // 共字前是全角空格
|
|
emptyrecords: "无数据显示",
|
|
loadtext: "读取中...",
|
|
pgtext : " {0} 共 {1} 页"
|
|
},
|
|
search : {
|
|
caption: "搜索...",
|
|
Find: "查找",
|
|
Reset: "重置",
|
|
odata : ['等于\u3000\u3000', '不等\u3000\u3000', '小于\u3000\u3000', '小于等于','大于\u3000\u3000','大于等于',
|
|
'开始于','不开始于','属于\u3000\u3000','不属于','结束于','不结束于','包含\u3000\u3000','不包含','空值于\u3000\u3000','非空值'],
|
|
groupOps: [ { op: "AND", text: "所有" }, { op: "OR", text: "任一" } ],
|
|
matchText: " 匹配",
|
|
rulesText: " 规则"
|
|
},
|
|
edit : {
|
|
addCaption: "添加记录",
|
|
editCaption: "编辑记录",
|
|
bSubmit: "提交",
|
|
bCancel: "取消",
|
|
bClose: "关闭",
|
|
saveData: "数据已改变,是否保存?",
|
|
bYes : "是",
|
|
bNo : "否",
|
|
bExit : "取消",
|
|
msg: {
|
|
required:"此字段必需",
|
|
number:"请输入有效数字",
|
|
minValue:"输值必须大于等于 ",
|
|
maxValue:"输值必须小于等于 ",
|
|
email: "这不是有效的e-mail地址",
|
|
integer: "请输入有效整数",
|
|
date: "请输入有效时间",
|
|
url: "无效网址。前缀必须为 ('http://' 或 'https://')",
|
|
nodefined : " 未定义!",
|
|
novalue : " 需要返回值!",
|
|
customarray : "自定义函数需要返回数组!",
|
|
customfcheck : "Custom function should be present in case of custom checking!"
|
|
|
|
}
|
|
},
|
|
view : {
|
|
caption: "查看记录",
|
|
bClose: "关闭"
|
|
},
|
|
del : {
|
|
caption: "删除",
|
|
msg: "删除所选记录?",
|
|
bSubmit: "删除",
|
|
bCancel: "取消"
|
|
},
|
|
nav : {
|
|
edittext: "",
|
|
edittitle: "编辑所选记录",
|
|
addtext:"",
|
|
addtitle: "添加新记录",
|
|
deltext: "",
|
|
deltitle: "删除所选记录",
|
|
searchtext: "",
|
|
searchtitle: "查找",
|
|
refreshtext: "",
|
|
refreshtitle: "刷新表格",
|
|
alertcap: "注意",
|
|
alerttext: "请选择记录",
|
|
viewtext: "",
|
|
viewtitle: "查看所选记录"
|
|
},
|
|
col : {
|
|
caption: "选择列",
|
|
bSubmit: "确定",
|
|
bCancel: "取消"
|
|
},
|
|
errors : {
|
|
errcap : "错误",
|
|
nourl : "没有设置url",
|
|
norecords: "没有要处理的记录",
|
|
model : "colNames 和 colModel 长度不等!"
|
|
},
|
|
formatter : {
|
|
integer : {thousandsSeparator: ",", defaultValue: '0'},
|
|
number : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00'},
|
|
currency : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
|
|
date : {
|
|
dayNames: [
|
|
"Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat",
|
|
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
|
|
],
|
|
monthNames: [
|
|
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
|
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
|
|
],
|
|
AmPm : ["am","pm","AM","PM"],
|
|
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
|
|
srcformat: 'Y-m-d',
|
|
newformat: 'Y-m-d',
|
|
masks : {
|
|
ISO8601Long:"Y-m-d H:i:s",
|
|
ISO8601Short:"Y-m-d",
|
|
ShortDate: "Y/j/n",
|
|
LongDate: "l, F d, Y",
|
|
FullDateTime: "l, F d, Y g:i:s A",
|
|
MonthDay: "F d",
|
|
ShortTime: "g:i A",
|
|
LongTime: "g:i:s A",
|
|
SortableDateTime: "Y-m-d\\TH:i:s",
|
|
UniversalSortableDateTime: "Y-m-d H:i:sO",
|
|
YearMonth: "F, Y"
|
|
},
|
|
reformatAfterEdit : false
|
|
},
|
|
baseLinkUrl: '',
|
|
showAction: '',
|
|
target: '',
|
|
checkbox : {disabled:true},
|
|
idName : 'id'
|
|
}
|
|
});
|
|
})(jQuery);
|
|
|
|
/*
|
|
* jQuery UI Multiselect
|
|
*
|
|
* Authors:
|
|
* Michael Aufreiter (quasipartikel.at)
|
|
* Yanick Rochon (yanick.rochon[at]gmail[dot]com)
|
|
*
|
|
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
|
* and GPL (GPL-LICENSE.txt) licenses.
|
|
*
|
|
* http://www.quasipartikel.at/multiselect/
|
|
*
|
|
*
|
|
* Depends:
|
|
* ui.core.js
|
|
* ui.sortable.js
|
|
*
|
|
* Optional:
|
|
* localization (http://plugins.jquery.com/project/localisation)
|
|
* scrollTo (http://plugins.jquery.com/project/ScrollTo)
|
|
*
|
|
* Todo:
|
|
* Make batch actions faster
|
|
* Implement dynamic insertion through remote calls
|
|
*/
|
|
|
|
|
|
(function($) {
|
|
|
|
$.widget("ui.multiselect", {
|
|
_init: function() {
|
|
this.element.hide();
|
|
this.id = this.element.attr("id");
|
|
this.container = $('<div class="ui-multiselect ui-helper-clearfix ui-widget"></div>').insertAfter(this.element);
|
|
this.count = 0; // number of currently selected options
|
|
this.selectedContainer = $('<div class="selected"></div>').appendTo(this.container);
|
|
this.availableContainer = $('<div class="available"></div>').appendTo(this.container);
|
|
this.selectedActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><span class="count">0 '+$.ui.multiselect.locale.itemsCount+'</span><a href="#" class="remove-all">'+$.ui.multiselect.locale.removeAll+'</a></div>').appendTo(this.selectedContainer);
|
|
this.availableActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><input type="text" class="search empty ui-widget-content ui-corner-all"/><a href="#" class="add-all">'+$.ui.multiselect.locale.addAll+'</a></div>').appendTo(this.availableContainer);
|
|
this.selectedList = $('<ul class="selected connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.selectedContainer);
|
|
this.availableList = $('<ul class="available connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.availableContainer);
|
|
|
|
var that = this;
|
|
|
|
// set dimensions
|
|
this.container.width(this.element.width()+1);
|
|
this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation));
|
|
this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation)));
|
|
|
|
// fix list height to match <option> depending on their individual header's heights
|
|
this.selectedList.height(Math.max(this.element.height()-this.selectedActions.height(),1));
|
|
this.availableList.height(Math.max(this.element.height()-this.availableActions.height(),1));
|
|
|
|
if ( !this.options.animated ) {
|
|
this.options.show = 'show';
|
|
this.options.hide = 'hide';
|
|
}
|
|
|
|
// init lists
|
|
this._populateLists(this.element.find('option'));
|
|
|
|
// make selection sortable
|
|
if (this.options.sortable) {
|
|
$("ul.selected").sortable({
|
|
placeholder: 'ui-state-highlight',
|
|
axis: 'y',
|
|
update: function(event, ui) {
|
|
// apply the new sort order to the original selectbox
|
|
that.selectedList.find('li').each(function() {
|
|
if ($(this).data('optionLink'))
|
|
$(this).data('optionLink').remove().appendTo(that.element);
|
|
});
|
|
},
|
|
receive: function(event, ui) {
|
|
ui.item.data('optionLink').prop('selected', true);
|
|
// increment count
|
|
that.count += 1;
|
|
that._updateCount();
|
|
// workaround, because there's no way to reference
|
|
// the new element, see http://dev.jqueryui.com/ticket/4303
|
|
that.selectedList.children('.ui-draggable').each(function() {
|
|
$(this).removeClass('ui-draggable');
|
|
$(this).data('optionLink', ui.item.data('optionLink'));
|
|
$(this).data('idx', ui.item.data('idx'));
|
|
that._applyItemState($(this), true);
|
|
});
|
|
|
|
// workaround according to http://dev.jqueryui.com/ticket/4088
|
|
setTimeout(function() { ui.item.remove(); }, 1);
|
|
}
|
|
});
|
|
}
|
|
|
|
// set up livesearch
|
|
if (this.options.searchable) {
|
|
this._registerSearchEvents(this.availableContainer.find('input.search'));
|
|
} else {
|
|
$('.search').hide();
|
|
}
|
|
|
|
// batch actions
|
|
$(".remove-all").click(function() {
|
|
that._populateLists(that.element.find('option').prop('selected', false));
|
|
return false;
|
|
});
|
|
$(".add-all").click(function() {
|
|
that._populateLists(that.element.find('option').prop('selected', true));
|
|
return false;
|
|
});
|
|
},
|
|
destroy: function() {
|
|
this.element.show();
|
|
this.container.remove();
|
|
|
|
$.widget.prototype.destroy.apply(this, arguments);
|
|
},
|
|
_populateLists: function(options) {
|
|
this.selectedList.children('.ui-element').remove();
|
|
this.availableList.children('.ui-element').remove();
|
|
this.count = 0;
|
|
|
|
var that = this;
|
|
var items = $(options.map(function(i) {
|
|
var item = that._getOptionNode(this).appendTo(this.selected ? that.selectedList : that.availableList).show();
|
|
|
|
if (this.selected) that.count += 1;
|
|
that._applyItemState(item, this.selected);
|
|
item.data('idx', i);
|
|
return item[0];
|
|
}));
|
|
|
|
// update count
|
|
this._updateCount();
|
|
},
|
|
_updateCount: function() {
|
|
this.selectedContainer.find('span.count').text(this.count+" "+$.ui.multiselect.locale.itemsCount);
|
|
},
|
|
_getOptionNode: function(option) {
|
|
option = $(option);
|
|
var node = $('<li class="ui-state-default ui-element" title="'+option.text()+'"><span class="ui-icon"/>'+option.text()+'<a href="#" class="action"><span class="ui-corner-all ui-icon"/></a></li>').hide();
|
|
node.data('optionLink', option);
|
|
return node;
|
|
},
|
|
// clones an item with associated data
|
|
// didn't find a smarter away around this
|
|
_cloneWithData: function(clonee) {
|
|
var clone = clonee.clone();
|
|
clone.data('optionLink', clonee.data('optionLink'));
|
|
clone.data('idx', clonee.data('idx'));
|
|
return clone;
|
|
},
|
|
_setSelected: function(item, selected) {
|
|
item.data('optionLink').prop('selected', selected);
|
|
|
|
if (selected) {
|
|
var selectedItem = this._cloneWithData(item);
|
|
item[this.options.hide](this.options.animated, function() { $(this).remove(); });
|
|
selectedItem.appendTo(this.selectedList).hide()[this.options.show](this.options.animated);
|
|
|
|
this._applyItemState(selectedItem, true);
|
|
return selectedItem;
|
|
} else {
|
|
|
|
// look for successor based on initial option index
|
|
var items = this.availableList.find('li'), comparator = this.options.nodeComparator;
|
|
var succ = null, i = item.data('idx'), direction = comparator(item, $(items[i]));
|
|
|
|
// TODO: test needed for dynamic list populating
|
|
if ( direction ) {
|
|
while (i>=0 && i<items.length) {
|
|
direction > 0 ? i++ : i--;
|
|
if ( direction != comparator(item, $(items[i])) ) {
|
|
// going up, go back one item down, otherwise leave as is
|
|
succ = items[direction > 0 ? i : i+1];
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
succ = items[i];
|
|
}
|
|
|
|
var availableItem = this._cloneWithData(item);
|
|
succ ? availableItem.insertBefore($(succ)) : availableItem.appendTo(this.availableList);
|
|
item[this.options.hide](this.options.animated, function() { $(this).remove(); });
|
|
availableItem.hide()[this.options.show](this.options.animated);
|
|
|
|
this._applyItemState(availableItem, false);
|
|
return availableItem;
|
|
}
|
|
},
|
|
_applyItemState: function(item, selected) {
|
|
if (selected) {
|
|
if (this.options.sortable)
|
|
item.children('span').addClass('ui-icon-arrowthick-2-n-s').removeClass('ui-helper-hidden').addClass('ui-icon');
|
|
else
|
|
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
|
|
item.find('a.action span').addClass('ui-icon-minus').removeClass('ui-icon-plus');
|
|
this._registerRemoveEvents(item.find('a.action'));
|
|
|
|
} else {
|
|
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
|
|
item.find('a.action span').addClass('ui-icon-plus').removeClass('ui-icon-minus');
|
|
this._registerAddEvents(item.find('a.action'));
|
|
}
|
|
|
|
this._registerHoverEvents(item);
|
|
},
|
|
// taken from John Resig's liveUpdate script
|
|
_filter: function(list) {
|
|
var input = $(this);
|
|
var rows = list.children('li'),
|
|
cache = rows.map(function(){
|
|
|
|
return $(this).text().toLowerCase();
|
|
});
|
|
|
|
var term = $.trim(input.val().toLowerCase()), scores = [];
|
|
|
|
if (!term) {
|
|
rows.show();
|
|
} else {
|
|
rows.hide();
|
|
|
|
cache.each(function(i) {
|
|
if (this.indexOf(term)>-1) { scores.push(i); }
|
|
});
|
|
|
|
$.each(scores, function() {
|
|
$(rows[this]).show();
|
|
});
|
|
}
|
|
},
|
|
_registerHoverEvents: function(elements) {
|
|
elements.removeClass('ui-state-hover');
|
|
elements.mouseover(function() {
|
|
$(this).addClass('ui-state-hover');
|
|
});
|
|
elements.mouseout(function() {
|
|
$(this).removeClass('ui-state-hover');
|
|
});
|
|
},
|
|
_registerAddEvents: function(elements) {
|
|
var that = this;
|
|
elements.click(function() {
|
|
var item = that._setSelected($(this).parent(), true);
|
|
that.count += 1;
|
|
that._updateCount();
|
|
return false;
|
|
})
|
|
// make draggable
|
|
.each(function() {
|
|
$(this).parent().draggable({
|
|
connectToSortable: 'ul.selected',
|
|
helper: function() {
|
|
var selectedItem = that._cloneWithData($(this)).width($(this).width() - 50);
|
|
selectedItem.width($(this).width());
|
|
return selectedItem;
|
|
},
|
|
appendTo: '.ui-multiselect',
|
|
containment: '.ui-multiselect',
|
|
revert: 'invalid'
|
|
});
|
|
});
|
|
},
|
|
_registerRemoveEvents: function(elements) {
|
|
var that = this;
|
|
elements.click(function() {
|
|
that._setSelected($(this).parent(), false);
|
|
that.count -= 1;
|
|
that._updateCount();
|
|
return false;
|
|
});
|
|
},
|
|
_registerSearchEvents: function(input) {
|
|
var that = this;
|
|
|
|
input.focus(function() {
|
|
$(this).addClass('ui-state-active');
|
|
})
|
|
.blur(function() {
|
|
$(this).removeClass('ui-state-active');
|
|
})
|
|
.keypress(function(e) {
|
|
if (e.keyCode == 13)
|
|
return false;
|
|
})
|
|
.keyup(function() {
|
|
that._filter.apply(this, [that.availableList]);
|
|
});
|
|
}
|
|
});
|
|
|
|
$.extend($.ui.multiselect, {
|
|
defaults: {
|
|
sortable: true,
|
|
searchable: true,
|
|
animated: 'fast',
|
|
show: 'slideDown',
|
|
hide: 'slideUp',
|
|
dividerLocation: 0.6,
|
|
nodeComparator: function(node1,node2) {
|
|
var text1 = node1.text(),
|
|
text2 = node2.text();
|
|
return text1 == text2 ? 0 : (text1 < text2 ? -1 : 1);
|
|
}
|
|
},
|
|
locale: {
|
|
addAll:'Add all',
|
|
removeAll:'Remove all',
|
|
itemsCount:'items selected'
|
|
}
|
|
});
|
|
|
|
})(jQuery);
|
|
|
|
// ==ClosureCompiler==
|
|
// @compilation_level SIMPLE_OPTIMIZATIONS
|
|
|
|
/**
|
|
* @license jqGrid 4.5.4 - jQuery Grid
|
|
* Copyright (c) 2008, Tony Tomov, tony@trirand.com
|
|
* Dual licensed under the MIT and GPL licenses
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
* Date: 2013-10-06
|
|
*/
|
|
//jsHint options
|
|
/*jshint evil:true, eqeqeq:false, eqnull:true, devel:true */
|
|
/*global jQuery */
|
|
|
|
(function ($) {
|
|
"use strict";
|
|
$.jgrid = $.jgrid || {};
|
|
$.extend($.jgrid,{
|
|
version : "4.5.4",
|
|
htmlDecode : function(value){
|
|
if(value && (value===' ' || value===' ' || (value.length===1 && value.charCodeAt(0)===160))) { return "";}
|
|
return !value ? value : String(value).replace(/>/g, ">").replace(/</g, "<").replace(/"/g, '"').replace(/&/g, "&");
|
|
},
|
|
htmlEncode : function (value){
|
|
return !value ? value : String(value).replace(/&/g, "&").replace(/\"/g, """).replace(/</g, "<").replace(/>/g, ">");
|
|
},
|
|
format : function(format){ //jqgformat
|
|
var args = $.makeArray(arguments).slice(1);
|
|
if(format==null) { format = ""; }
|
|
return format.replace(/\{(\d+)\}/g, function(m, i){
|
|
return args[i];
|
|
});
|
|
},
|
|
msie : navigator.appName === 'Microsoft Internet Explorer',
|
|
msiever : function () {
|
|
var rv = -1;
|
|
var ua = navigator.userAgent;
|
|
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
|
|
if (re.exec(ua) != null) {
|
|
rv = parseFloat( RegExp.$1 );
|
|
}
|
|
return rv;
|
|
},
|
|
getCellIndex : function (cell) {
|
|
var c = $(cell);
|
|
if (c.is('tr')) { return -1; }
|
|
c = (!c.is('td') && !c.is('th') ? c.closest("td,th") : c)[0];
|
|
if ($.jgrid.msie) { return $.inArray(c, c.parentNode.cells); }
|
|
return c.cellIndex;
|
|
},
|
|
stripHtml : function(v) {
|
|
v = String(v);
|
|
var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi;
|
|
if (v) {
|
|
v = v.replace(regexp,"");
|
|
return (v && v !== ' ' && v !== ' ') ? v.replace(/\"/g,"'") : "";
|
|
}
|
|
return v;
|
|
},
|
|
stripPref : function (pref, id) {
|
|
var obj = $.type( pref );
|
|
if( obj === "string" || obj === "number") {
|
|
pref = String(pref);
|
|
id = pref !== "" ? String(id).replace(String(pref), "") : id;
|
|
}
|
|
return id;
|
|
},
|
|
parse : function(jsonString) {
|
|
var js = jsonString;
|
|
if (js.substr(0,9) === "while(1);") { js = js.substr(9); }
|
|
if (js.substr(0,2) === "/*") { js = js.substr(2,js.length-4); }
|
|
if(!js) { js = "{}"; }
|
|
return ($.jgrid.useJSON===true && typeof JSON === 'object' && typeof JSON.parse === 'function') ?
|
|
JSON.parse(js) :
|
|
eval('(' + js + ')');
|
|
},
|
|
parseDate : function(format, date, newformat, opts) {
|
|
var token = /\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/g,
|
|
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
|
|
timezoneClip = /[^-+\dA-Z]/g,
|
|
msDateRegExp = new RegExp("^\/Date\\((([-+])?[0-9]+)(([-+])([0-9]{2})([0-9]{2}))?\\)\/$"),
|
|
msMatch = ((typeof date === 'string') ? date.match(msDateRegExp): null),
|
|
pad = function (value, length) {
|
|
value = String(value);
|
|
length = parseInt(length,10) || 2;
|
|
while (value.length < length) { value = '0' + value; }
|
|
return value;
|
|
},
|
|
ts = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0, u:0},
|
|
timestamp=0, dM, k,hl,
|
|
h12to24 = function(ampm, h){
|
|
if (ampm === 0){ if (h === 12) { h = 0;} }
|
|
else { if (h !== 12) { h += 12; } }
|
|
return h;
|
|
};
|
|
if(opts === undefined) {
|
|
opts = $.jgrid.formatter.date;
|
|
}
|
|
// old lang files
|
|
if(opts.parseRe === undefined ) {
|
|
opts.parseRe = /[Tt\\\/:_;.,\t\s-]/;
|
|
}
|
|
if( opts.masks.hasOwnProperty(format) ) { format = opts.masks[format]; }
|
|
if(date && date != null) {
|
|
if( !isNaN( date - 0 ) && String(format).toLowerCase() === "u") {
|
|
//Unix timestamp
|
|
timestamp = new Date( parseFloat(date)*1000 );
|
|
} else if(date.constructor === Date) {
|
|
timestamp = date;
|
|
// Microsoft date format support
|
|
} else if( msMatch !== null ) {
|
|
timestamp = new Date(parseInt(msMatch[1], 10));
|
|
if (msMatch[3]) {
|
|
var offset = Number(msMatch[5]) * 60 + Number(msMatch[6]);
|
|
offset *= ((msMatch[4] === '-') ? 1 : -1);
|
|
offset -= timestamp.getTimezoneOffset();
|
|
timestamp.setTime(Number(Number(timestamp) + (offset * 60 * 1000)));
|
|
}
|
|
} else {
|
|
date = String(date).replace(/\\T/g,"T").replace(/\\t/,"t").split(opts.parseRe);
|
|
format = format.replace(/\\T/g,"T").replace(/\\t/,"t").split(opts.parseRe);
|
|
// parsing for month names
|
|
for(k=0,hl=format.length;k<hl;k++){
|
|
if(format[k] === 'M') {
|
|
dM = $.inArray(date[k],opts.monthNames);
|
|
if(dM !== -1 && dM < 12){date[k] = dM+1; ts.m = date[k];}
|
|
}
|
|
if(format[k] === 'F') {
|
|
dM = $.inArray(date[k],opts.monthNames,12);
|
|
if(dM !== -1 && dM > 11){date[k] = dM+1-12; ts.m = date[k];}
|
|
}
|
|
if(format[k] === 'a') {
|
|
dM = $.inArray(date[k],opts.AmPm);
|
|
if(dM !== -1 && dM < 2 && date[k] === opts.AmPm[dM]){
|
|
date[k] = dM;
|
|
ts.h = h12to24(date[k], ts.h);
|
|
}
|
|
}
|
|
if(format[k] === 'A') {
|
|
dM = $.inArray(date[k],opts.AmPm);
|
|
if(dM !== -1 && dM > 1 && date[k] === opts.AmPm[dM]){
|
|
date[k] = dM-2;
|
|
ts.h = h12to24(date[k], ts.h);
|
|
}
|
|
}
|
|
if (format[k] === 'g') {
|
|
ts.h = parseInt(date[k], 10);
|
|
}
|
|
if(date[k] !== undefined) {
|
|
ts[format[k].toLowerCase()] = parseInt(date[k],10);
|
|
}
|
|
}
|
|
if(ts.f) {ts.m = ts.f;}
|
|
if( ts.m === 0 && ts.y === 0 && ts.d === 0) {
|
|
return " " ;
|
|
}
|
|
ts.m = parseInt(ts.m,10)-1;
|
|
var ty = ts.y;
|
|
if (ty >= 70 && ty <= 99) {ts.y = 1900+ts.y;}
|
|
else if (ty >=0 && ty <=69) {ts.y= 2000+ts.y;}
|
|
timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u);
|
|
}
|
|
} else {
|
|
timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u);
|
|
}
|
|
if( newformat === undefined ) {
|
|
return timestamp;
|
|
}
|
|
if( opts.masks.hasOwnProperty(newformat) ) {
|
|
newformat = opts.masks[newformat];
|
|
} else if ( !newformat ) {
|
|
newformat = 'Y-m-d';
|
|
}
|
|
var
|
|
G = timestamp.getHours(),
|
|
i = timestamp.getMinutes(),
|
|
j = timestamp.getDate(),
|
|
n = timestamp.getMonth() + 1,
|
|
o = timestamp.getTimezoneOffset(),
|
|
s = timestamp.getSeconds(),
|
|
u = timestamp.getMilliseconds(),
|
|
w = timestamp.getDay(),
|
|
Y = timestamp.getFullYear(),
|
|
N = (w + 6) % 7 + 1,
|
|
z = (new Date(Y, n - 1, j) - new Date(Y, 0, 1)) / 86400000,
|
|
flags = {
|
|
// Day
|
|
d: pad(j),
|
|
D: opts.dayNames[w],
|
|
j: j,
|
|
l: opts.dayNames[w + 7],
|
|
N: N,
|
|
S: opts.S(j),
|
|
//j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th',
|
|
w: w,
|
|
z: z,
|
|
// Week
|
|
W: N < 5 ? Math.floor((z + N - 1) / 7) + 1 : Math.floor((z + N - 1) / 7) || ((new Date(Y - 1, 0, 1).getDay() + 6) % 7 < 4 ? 53 : 52),
|
|
// Month
|
|
F: opts.monthNames[n - 1 + 12],
|
|
m: pad(n),
|
|
M: opts.monthNames[n - 1],
|
|
n: n,
|
|
t: '?',
|
|
// Year
|
|
L: '?',
|
|
o: '?',
|
|
Y: Y,
|
|
y: String(Y).substring(2),
|
|
// Time
|
|
a: G < 12 ? opts.AmPm[0] : opts.AmPm[1],
|
|
A: G < 12 ? opts.AmPm[2] : opts.AmPm[3],
|
|
B: '?',
|
|
g: G % 12 || 12,
|
|
G: G,
|
|
h: pad(G % 12 || 12),
|
|
H: pad(G),
|
|
i: pad(i),
|
|
s: pad(s),
|
|
u: u,
|
|
// Timezone
|
|
e: '?',
|
|
I: '?',
|
|
O: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
|
|
P: '?',
|
|
T: (String(timestamp).match(timezone) || [""]).pop().replace(timezoneClip, ""),
|
|
Z: '?',
|
|
// Full Date/Time
|
|
c: '?',
|
|
r: '?',
|
|
U: Math.floor(timestamp / 1000)
|
|
};
|
|
return newformat.replace(token, function ($0) {
|
|
return flags.hasOwnProperty($0) ? flags[$0] : $0.substring(1);
|
|
});
|
|
},
|
|
jqID : function(sid){
|
|
return String(sid).replace(/[!"#$%&'()*+,.\/:; <=>?@\[\\\]\^`{|}~]/g,"\\$&");
|
|
},
|
|
guid : 1,
|
|
uidPref: 'jqg',
|
|
randId : function( prefix ) {
|
|
return (prefix || $.jgrid.uidPref) + ($.jgrid.guid++);
|
|
},
|
|
getAccessor : function(obj, expr) {
|
|
var ret,p,prm = [], i;
|
|
if( typeof expr === 'function') { return expr(obj); }
|
|
ret = obj[expr];
|
|
if(ret===undefined) {
|
|
try {
|
|
if ( typeof expr === 'string' ) {
|
|
prm = expr.split('.');
|
|
}
|
|
i = prm.length;
|
|
if( i ) {
|
|
ret = obj;
|
|
while (ret && i--) {
|
|
p = prm.shift();
|
|
ret = ret[p];
|
|
}
|
|
}
|
|
} catch (e) {}
|
|
}
|
|
return ret;
|
|
},
|
|
getXmlData: function (obj, expr, returnObj) {
|
|
var ret, m = typeof expr === 'string' ? expr.match(/^(.*)\[(\w+)\]$/) : null;
|
|
if (typeof expr === 'function') { return expr(obj); }
|
|
if (m && m[2]) {
|
|
// m[2] is the attribute selector
|
|
// m[1] is an optional element selector
|
|
// examples: "[id]", "rows[page]"
|
|
return m[1] ? $(m[1], obj).attr(m[2]) : $(obj).attr(m[2]);
|
|
}
|
|
ret = $(expr, obj);
|
|
if (returnObj) { return ret; }
|
|
//$(expr, obj).filter(':last'); // we use ':last' to be more compatible with old version of jqGrid
|
|
return ret.length > 0 ? $(ret).text() : undefined;
|
|
},
|
|
cellWidth : function () {
|
|
var $testDiv = $("<div class='ui-jqgrid' style='left:10000px'><table class='ui-jqgrid-btable' style='width:5px;'><tr class='jqgrow'><td style='width:5px;display:block;'></td></tr></table></div>"),
|
|
testCell = $testDiv.appendTo("body")
|
|
.find("td")
|
|
.width();
|
|
$testDiv.remove();
|
|
return Math.abs(testCell-5) > 0.1;
|
|
},
|
|
cell_width : true,
|
|
ajaxOptions: {},
|
|
from : function(source){
|
|
// Original Author Hugo Bonacci
|
|
// License MIT http://jlinq.codeplex.com/license
|
|
var QueryObject=function(d,q){
|
|
if(typeof d==="string"){
|
|
d=$.data(d);
|
|
}
|
|
var self=this,
|
|
_data=d,
|
|
_usecase=true,
|
|
_trim=false,
|
|
_query=q,
|
|
_stripNum = /[\$,%]/g,
|
|
_lastCommand=null,
|
|
_lastField=null,
|
|
_orDepth=0,
|
|
_negate=false,
|
|
_queuedOperator="",
|
|
_sorting=[],
|
|
_useProperties=true;
|
|
if(typeof d==="object"&&d.push) {
|
|
if(d.length>0){
|
|
if(typeof d[0]!=="object"){
|
|
_useProperties=false;
|
|
}else{
|
|
_useProperties=true;
|
|
}
|
|
}
|
|
}else{
|
|
throw "data provides is not an array";
|
|
}
|
|
this._hasData=function(){
|
|
return _data===null?false:_data.length===0?false:true;
|
|
};
|
|
this._getStr=function(s){
|
|
var phrase=[];
|
|
if(_trim){
|
|
phrase.push("jQuery.trim(");
|
|
}
|
|
phrase.push("String("+s+")");
|
|
if(_trim){
|
|
phrase.push(")");
|
|
}
|
|
if(!_usecase){
|
|
phrase.push(".toLowerCase()");
|
|
}
|
|
return phrase.join("");
|
|
};
|
|
this._strComp=function(val){
|
|
if(typeof val==="string"){
|
|
return".toString()";
|
|
}
|
|
return"";
|
|
};
|
|
this._group=function(f,u){
|
|
return({field:f.toString(),unique:u,items:[]});
|
|
};
|
|
this._toStr=function(phrase){
|
|
if(_trim){
|
|
phrase=$.trim(phrase);
|
|
}
|
|
phrase=phrase.toString().replace(/\\/g,'\\\\').replace(/\"/g,'\\"');
|
|
return _usecase ? phrase : phrase.toLowerCase();
|
|
};
|
|
this._funcLoop=function(func){
|
|
var results=[];
|
|
$.each(_data,function(i,v){
|
|
results.push(func(v));
|
|
});
|
|
return results;
|
|
};
|
|
this._append=function(s){
|
|
var i;
|
|
if(_query===null){
|
|
_query="";
|
|
} else {
|
|
_query+=_queuedOperator === "" ? " && " :_queuedOperator;
|
|
}
|
|
for (i=0;i<_orDepth;i++){
|
|
_query+="(";
|
|
}
|
|
if(_negate){
|
|
_query+="!";
|
|
}
|
|
_query+="("+s+")";
|
|
_negate=false;
|
|
_queuedOperator="";
|
|
_orDepth=0;
|
|
};
|
|
this._setCommand=function(f,c){
|
|
_lastCommand=f;
|
|
_lastField=c;
|
|
};
|
|
this._resetNegate=function(){
|
|
_negate=false;
|
|
};
|
|
this._repeatCommand=function(f,v){
|
|
if(_lastCommand===null){
|
|
return self;
|
|
}
|
|
if(f!==null&&v!==null){
|
|
return _lastCommand(f,v);
|
|
}
|
|
if(_lastField===null){
|
|
return _lastCommand(f);
|
|
}
|
|
if(!_useProperties){
|
|
return _lastCommand(f);
|
|
}
|
|
return _lastCommand(_lastField,f);
|
|
};
|
|
this._equals=function(a,b){
|
|
return(self._compare(a,b,1)===0);
|
|
};
|
|
this._compare=function(a,b,d){
|
|
var toString = Object.prototype.toString;
|
|
if( d === undefined) { d = 1; }
|
|
if(a===undefined) { a = null; }
|
|
if(b===undefined) { b = null; }
|
|
if(a===null && b===null){
|
|
return 0;
|
|
}
|
|
if(a===null&&b!==null){
|
|
return 1;
|
|
}
|
|
if(a!==null&&b===null){
|
|
return -1;
|
|
}
|
|
if (toString.call(a) === '[object Date]' && toString.call(b) === '[object Date]') {
|
|
if (a < b) { return -d; }
|
|
if (a > b) { return d; }
|
|
return 0;
|
|
}
|
|
if(!_usecase && typeof a !== "number" && typeof b !== "number" ) {
|
|
a=String(a);
|
|
b=String(b);
|
|
}
|
|
if(a<b){return -d;}
|
|
if(a>b){return d;}
|
|
return 0;
|
|
};
|
|
this._performSort=function(){
|
|
if(_sorting.length===0){return;}
|
|
_data=self._doSort(_data,0);
|
|
};
|
|
this._doSort=function(d,q){
|
|
var by=_sorting[q].by,
|
|
dir=_sorting[q].dir,
|
|
type = _sorting[q].type,
|
|
dfmt = _sorting[q].datefmt;
|
|
if(q===_sorting.length-1){
|
|
return self._getOrder(d, by, dir, type, dfmt);
|
|
}
|
|
q++;
|
|
var values=self._getGroup(d,by,dir,type,dfmt), results=[], i, j, sorted;
|
|
for(i=0;i<values.length;i++){
|
|
sorted=self._doSort(values[i].items,q);
|
|
for(j=0;j<sorted.length;j++){
|
|
results.push(sorted[j]);
|
|
}
|
|
}
|
|
return results;
|
|
};
|
|
this._getOrder=function(data,by,dir,type, dfmt){
|
|
var sortData=[],_sortData=[], newDir = dir==="a" ? 1 : -1, i,ab,j,
|
|
findSortKey;
|
|
|
|
if(type === undefined ) { type = "text"; }
|
|
if (type === 'float' || type=== 'number' || type=== 'currency' || type=== 'numeric') {
|
|
findSortKey = function($cell) {
|
|
var key = parseFloat( String($cell).replace(_stripNum, ''));
|
|
return isNaN(key) ? 0.00 : key;
|
|
};
|
|
} else if (type==='int' || type==='integer') {
|
|
findSortKey = function($cell) {
|
|
return $cell ? parseFloat(String($cell).replace(_stripNum, '')) : 0;
|
|
};
|
|
} else if(type === 'date' || type === 'datetime') {
|
|
findSortKey = function($cell) {
|
|
return $.jgrid.parseDate(dfmt,$cell).getTime();
|
|
};
|
|
} else if($.isFunction(type)) {
|
|
findSortKey = type;
|
|
} else {
|
|
findSortKey = function($cell) {
|
|
$cell = $cell ? $.trim(String($cell)) : "";
|
|
return _usecase ? $cell : $cell.toLowerCase();
|
|
};
|
|
}
|
|
$.each(data,function(i,v){
|
|
ab = by!=="" ? $.jgrid.getAccessor(v,by) : v;
|
|
if(ab === undefined) { ab = ""; }
|
|
ab = findSortKey(ab, v);
|
|
_sortData.push({ 'vSort': ab,'index':i});
|
|
});
|
|
|
|
_sortData.sort(function(a,b){
|
|
a = a.vSort;
|
|
b = b.vSort;
|
|
return self._compare(a,b,newDir);
|
|
});
|
|
j=0;
|
|
var nrec= data.length;
|
|
// overhead, but we do not change the original data.
|
|
while(j<nrec) {
|
|
i = _sortData[j].index;
|
|
sortData.push(data[i]);
|
|
j++;
|
|
}
|
|
return sortData;
|
|
};
|
|
this._getGroup=function(data,by,dir,type, dfmt){
|
|
var results=[],
|
|
group=null,
|
|
last=null, val;
|
|
$.each(self._getOrder(data,by,dir,type, dfmt),function(i,v){
|
|
val = $.jgrid.getAccessor(v, by);
|
|
if(val == null) { val = ""; }
|
|
if(!self._equals(last,val)){
|
|
last=val;
|
|
if(group !== null){
|
|
results.push(group);
|
|
}
|
|
group=self._group(by,val);
|
|
}
|
|
group.items.push(v);
|
|
});
|
|
if(group !== null){
|
|
results.push(group);
|
|
}
|
|
return results;
|
|
};
|
|
this.ignoreCase=function(){
|
|
_usecase=false;
|
|
return self;
|
|
};
|
|
this.useCase=function(){
|
|
_usecase=true;
|
|
return self;
|
|
};
|
|
this.trim=function(){
|
|
_trim=true;
|
|
return self;
|
|
};
|
|
this.noTrim=function(){
|
|
_trim=false;
|
|
return self;
|
|
};
|
|
this.execute=function(){
|
|
var match=_query, results=[];
|
|
if(match === null){
|
|
return self;
|
|
}
|
|
$.each(_data,function(){
|
|
if(eval(match)){results.push(this);}
|
|
});
|
|
_data=results;
|
|
return self;
|
|
};
|
|
this.data=function(){
|
|
return _data;
|
|
};
|
|
this.select=function(f){
|
|
self._performSort();
|
|
if(!self._hasData()){ return[]; }
|
|
self.execute();
|
|
if($.isFunction(f)){
|
|
var results=[];
|
|
$.each(_data,function(i,v){
|
|
results.push(f(v));
|
|
});
|
|
return results;
|
|
}
|
|
return _data;
|
|
};
|
|
this.hasMatch=function(){
|
|
if(!self._hasData()) { return false; }
|
|
self.execute();
|
|
return _data.length>0;
|
|
};
|
|
this.andNot=function(f,v,x){
|
|
_negate=!_negate;
|
|
return self.and(f,v,x);
|
|
};
|
|
this.orNot=function(f,v,x){
|
|
_negate=!_negate;
|
|
return self.or(f,v,x);
|
|
};
|
|
this.not=function(f,v,x){
|
|
return self.andNot(f,v,x);
|
|
};
|
|
this.and=function(f,v,x){
|
|
_queuedOperator=" && ";
|
|
if(f===undefined){
|
|
return self;
|
|
}
|
|
return self._repeatCommand(f,v,x);
|
|
};
|
|
this.or=function(f,v,x){
|
|
_queuedOperator=" || ";
|
|
if(f===undefined) { return self; }
|
|
return self._repeatCommand(f,v,x);
|
|
};
|
|
this.orBegin=function(){
|
|
_orDepth++;
|
|
return self;
|
|
};
|
|
this.orEnd=function(){
|
|
if (_query !== null){
|
|
_query+=")";
|
|
}
|
|
return self;
|
|
};
|
|
this.isNot=function(f){
|
|
_negate=!_negate;
|
|
return self.is(f);
|
|
};
|
|
this.is=function(f){
|
|
self._append('this.'+f);
|
|
self._resetNegate();
|
|
return self;
|
|
};
|
|
this._compareValues=function(func,f,v,how,t){
|
|
var fld;
|
|
if(_useProperties){
|
|
fld='jQuery.jgrid.getAccessor(this,\''+f+'\')';
|
|
}else{
|
|
fld='this';
|
|
}
|
|
if(v===undefined) { v = null; }
|
|
//var val=v===null?f:v,
|
|
var val =v,
|
|
swst = t.stype === undefined ? "text" : t.stype;
|
|
if(v !== null) {
|
|
switch(swst) {
|
|
case 'int':
|
|
case 'integer':
|
|
val = (isNaN(Number(val)) || val==="") ? '0' : val; // To be fixed with more inteligent code
|
|
fld = 'parseInt('+fld+',10)';
|
|
val = 'parseInt('+val+',10)';
|
|
break;
|
|
case 'float':
|
|
case 'number':
|
|
case 'numeric':
|
|
val = String(val).replace(_stripNum, '');
|
|
val = (isNaN(Number(val)) || val==="") ? '0' : val; // To be fixed with more inteligent code
|
|
fld = 'parseFloat('+fld+')';
|
|
val = 'parseFloat('+val+')';
|
|
break;
|
|
case 'date':
|
|
case 'datetime':
|
|
val = String($.jgrid.parseDate(t.newfmt || 'Y-m-d',val).getTime());
|
|
fld = 'jQuery.jgrid.parseDate("'+t.srcfmt+'",'+fld+').getTime()';
|
|
break;
|
|
default :
|
|
fld=self._getStr(fld);
|
|
val=self._getStr('"'+self._toStr(val)+'"');
|
|
}
|
|
}
|
|
self._append(fld+' '+how+' '+val);
|
|
self._setCommand(func,f);
|
|
self._resetNegate();
|
|
return self;
|
|
};
|
|
this.equals=function(f,v,t){
|
|
return self._compareValues(self.equals,f,v,"==",t);
|
|
};
|
|
this.notEquals=function(f,v,t){
|
|
return self._compareValues(self.equals,f,v,"!==",t);
|
|
};
|
|
this.isNull = function(f,v,t){
|
|
return self._compareValues(self.equals,f,null,"===",t);
|
|
};
|
|
this.greater=function(f,v,t){
|
|
return self._compareValues(self.greater,f,v,">",t);
|
|
};
|
|
this.less=function(f,v,t){
|
|
return self._compareValues(self.less,f,v,"<",t);
|
|
};
|
|
this.greaterOrEquals=function(f,v,t){
|
|
return self._compareValues(self.greaterOrEquals,f,v,">=",t);
|
|
};
|
|
this.lessOrEquals=function(f,v,t){
|
|
return self._compareValues(self.lessOrEquals,f,v,"<=",t);
|
|
};
|
|
this.startsWith=function(f,v){
|
|
var val = (v==null) ? f: v,
|
|
length=_trim ? $.trim(val.toString()).length : val.toString().length;
|
|
if(_useProperties){
|
|
self._append(self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.substr(0,'+length+') == '+self._getStr('"'+self._toStr(v)+'"'));
|
|
}else{
|
|
length=_trim?$.trim(v.toString()).length:v.toString().length;
|
|
self._append(self._getStr('this')+'.substr(0,'+length+') == '+self._getStr('"'+self._toStr(f)+'"'));
|
|
}
|
|
self._setCommand(self.startsWith,f);
|
|
self._resetNegate();
|
|
return self;
|
|
};
|
|
this.endsWith=function(f,v){
|
|
var val = (v==null) ? f: v,
|
|
length=_trim ? $.trim(val.toString()).length:val.toString().length;
|
|
if(_useProperties){
|
|
self._append(self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.substr('+self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.length-'+length+','+length+') == "'+self._toStr(v)+'"');
|
|
} else {
|
|
self._append(self._getStr('this')+'.substr('+self._getStr('this')+'.length-"'+self._toStr(f)+'".length,"'+self._toStr(f)+'".length) == "'+self._toStr(f)+'"');
|
|
}
|
|
self._setCommand(self.endsWith,f);self._resetNegate();
|
|
return self;
|
|
};
|
|
this.contains=function(f,v){
|
|
if(_useProperties){
|
|
self._append(self._getStr('jQuery.jgrid.getAccessor(this,\''+f+'\')')+'.indexOf("'+self._toStr(v)+'",0) > -1');
|
|
}else{
|
|
self._append(self._getStr('this')+'.indexOf("'+self._toStr(f)+'",0) > -1');
|
|
}
|
|
self._setCommand(self.contains,f);
|
|
self._resetNegate();
|
|
return self;
|
|
};
|
|
this.groupBy=function(by,dir,type, datefmt){
|
|
if(!self._hasData()){
|
|
return null;
|
|
}
|
|
return self._getGroup(_data,by,dir,type, datefmt);
|
|
};
|
|
this.orderBy=function(by,dir,stype, dfmt){
|
|
dir = dir == null ? "a" :$.trim(dir.toString().toLowerCase());
|
|
if(stype == null) { stype = "text"; }
|
|
if(dfmt == null) { dfmt = "Y-m-d"; }
|
|
if(dir==="desc"||dir==="descending"){dir="d";}
|
|
if(dir==="asc"||dir==="ascending"){dir="a";}
|
|
_sorting.push({by:by,dir:dir,type:stype, datefmt: dfmt});
|
|
return self;
|
|
};
|
|
return self;
|
|
};
|
|
return new QueryObject(source,null);
|
|
},
|
|
getMethod: function (name) {
|
|
return this.getAccessor($.fn.jqGrid, name);
|
|
},
|
|
extend : function(methods) {
|
|
$.extend($.fn.jqGrid,methods);
|
|
if (!this.no_legacy_api) {
|
|
$.fn.extend(methods);
|
|
}
|
|
}
|
|
});
|
|
|
|
$.fn.jqGrid = function( pin ) {
|
|
if (typeof pin === 'string') {
|
|
var fn = $.jgrid.getMethod(pin);
|
|
if (!fn) {
|
|
throw ("jqGrid - No such method: " + pin);
|
|
}
|
|
var args = $.makeArray(arguments).slice(1);
|
|
return fn.apply(this,args);
|
|
}
|
|
return this.each( function() {
|
|
if(this.grid) {return;}
|
|
|
|
var p = $.extend(true,{
|
|
url: "",
|
|
height: 150,
|
|
page: 1,
|
|
rowNum: 20000,
|
|
rowTotal : null,
|
|
records: 0,
|
|
pager: "",
|
|
pgbuttons: true,
|
|
pginput: true,
|
|
colModel: [],
|
|
rowList: [],
|
|
colNames: [],
|
|
sortorder: "asc",
|
|
sortname: "",
|
|
datatype: "xml",
|
|
mtype: "GET",
|
|
altRows: false,
|
|
selarrrow: [],
|
|
savedRow: [],
|
|
shrinkToFit: true,
|
|
xmlReader: {},
|
|
jsonReader: {},
|
|
subGrid: false,
|
|
subGridModel :[],
|
|
reccount: 0,
|
|
lastpage: 0,
|
|
lastsort: 0,
|
|
selrow: null,
|
|
beforeSelectRow: null,
|
|
onSelectRow: null,
|
|
onSortCol: null,
|
|
ondblClickRow: null,
|
|
onRightClickRow: null,
|
|
onPaging: null,
|
|
onSelectAll: null,
|
|
onInitGrid : null,
|
|
loadComplete: null,
|
|
gridComplete: null,
|
|
loadError: null,
|
|
loadBeforeSend: null,
|
|
afterInsertRow: null,
|
|
beforeRequest: null,
|
|
beforeProcessing : null,
|
|
onHeaderClick: null,
|
|
viewrecords: false,
|
|
loadonce: false,
|
|
multiselect: false,
|
|
multikey: false,
|
|
editurl: null,
|
|
search: false,
|
|
caption: "",
|
|
hidegrid: true,
|
|
hiddengrid: false,
|
|
postData: {},
|
|
userData: {},
|
|
treeGrid : false,
|
|
treeGridModel : 'nested',
|
|
treeReader : {},
|
|
treeANode : -1,
|
|
ExpandColumn: null,
|
|
tree_root_level : 0,
|
|
prmNames: {page:"page",rows:"rows", sort: "sidx",order: "sord", search:"_search", nd:"nd", id:"id",oper:"oper",editoper:"edit",addoper:"add",deloper:"del", subgridid:"id", npage: null, totalrows:"totalrows"},
|
|
forceFit : false,
|
|
gridstate : "visible",
|
|
cellEdit: false,
|
|
cellsubmit: "remote",
|
|
nv:0,
|
|
loadui: "enable",
|
|
toolbar: [false,""],
|
|
scroll: false,
|
|
multiboxonly : false,
|
|
deselectAfterSort : true,
|
|
scrollrows : false,
|
|
autowidth: false,
|
|
scrollOffset :18,
|
|
cellLayout: 5,
|
|
subGridWidth: 20,
|
|
multiselectWidth: 20,
|
|
gridview: false,
|
|
rownumWidth: 25,
|
|
rownumbers : false,
|
|
pagerpos: 'center',
|
|
recordpos: 'right',
|
|
footerrow : false,
|
|
userDataOnFooter : false,
|
|
hoverrows : true,
|
|
altclass : 'ui-priority-secondary',
|
|
viewsortcols : [false,'vertical',true],
|
|
resizeclass : '',
|
|
autoencode : false,
|
|
remapColumns : [],
|
|
ajaxGridOptions :{},
|
|
direction : "ltr",
|
|
toppager: false,
|
|
headertitles: false,
|
|
scrollTimeout: 40,
|
|
data : [],
|
|
_index : {},
|
|
grouping : false,
|
|
groupingView : {groupField:[],groupOrder:[], groupText:[],groupColumnShow:[],groupSummary:[], showSummaryOnHide: false, sortitems:[], sortnames:[], summary:[],summaryval:[], plusicon: 'ui-icon-circlesmall-plus', minusicon: 'ui-icon-circlesmall-minus', displayField: []},
|
|
ignoreCase : false,
|
|
cmTemplate : {},
|
|
idPrefix : "",
|
|
multiSort : false
|
|
}, $.jgrid.defaults, pin || {});
|
|
var ts= this, grid={
|
|
headers:[],
|
|
cols:[],
|
|
footers: [],
|
|
dragStart: function (i, x, y) {
|
|
var gridLeftPos = $(this.bDiv).offset().left;
|
|
this.resizing = { idx: i, startX: x.clientX, sOL: x.clientX - gridLeftPos };
|
|
this.hDiv.style.cursor = "col-resize";
|
|
this.curGbox = $("#rs_m" + $.jgrid.jqID(p.id), "#gbox_" + $.jgrid.jqID(p.id));
|
|
this.curGbox.css({ display: "block", left: x.clientX - gridLeftPos, top: y[1], height: y[2] });
|
|
$(ts).triggerHandler("jqGridResizeStart", [x, i]);
|
|
if ($.isFunction(p.resizeStart)) { p.resizeStart.call(ts, x, i); }
|
|
document.onselectstart = function () { return false; };
|
|
|
|
//this.resizing = { idx: i, startX: x.clientX, sOL : x.clientX-6};
|
|
//this.hDiv.style.cursor = "col-resize";
|
|
//this.curGbox = $("#rs_m"+$.jgrid.jqID(p.id),"#gbox_"+$.jgrid.jqID(p.id));
|
|
//this.curGbox.css({display:"block",left:x.clientX-6,top:y[1],height:y[2]});
|
|
//$(ts).triggerHandler("jqGridResizeStart", [x, i]);
|
|
//if($.isFunction(p.resizeStart)) { p.resizeStart.call(ts,x,i); }
|
|
//document.onselectstart=function(){return false;};
|
|
},
|
|
dragMove: function(x) {
|
|
if(this.resizing) {
|
|
var diff = x.clientX-this.resizing.startX,
|
|
h = this.headers[this.resizing.idx],
|
|
newWidth = p.direction === "ltr" ? h.width + diff : h.width - diff, hn, nWn;
|
|
if(newWidth > 33) {
|
|
this.curGbox.css({left:this.resizing.sOL+diff});
|
|
|
|
if(p.forceFit===true ){
|
|
hn = this.headers[this.resizing.idx+p.nv];
|
|
nWn = p.direction === "ltr" ? hn.width - diff : hn.width + diff;
|
|
if(nWn >33) {
|
|
h.newWidth = newWidth;
|
|
hn.newWidth = nWn;
|
|
}
|
|
} else {
|
|
this.newWidth = p.direction === "ltr" ? p.tblwidth+diff : p.tblwidth-diff;
|
|
h.newWidth = newWidth;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
dragEnd: function() {
|
|
this.hDiv.style.cursor = "default";
|
|
if(this.resizing) {
|
|
var idx = this.resizing.idx,
|
|
nw = this.headers[idx].newWidth || this.headers[idx].width;
|
|
nw = parseInt(nw,10);
|
|
this.resizing = false;
|
|
$("#rs_m"+$.jgrid.jqID(p.id)).css("display","none");
|
|
p.colModel[idx].width = nw;
|
|
this.headers[idx].width = nw;
|
|
this.headers[idx].el.style.width = nw + "px";
|
|
this.cols[idx].style.width = nw+"px";
|
|
if(this.footers.length>0) {this.footers[idx].style.width = nw+"px";}
|
|
if(p.forceFit===true){
|
|
nw = this.headers[idx+p.nv].newWidth || this.headers[idx+p.nv].width;
|
|
this.headers[idx+p.nv].width = nw;
|
|
this.headers[idx+p.nv].el.style.width = nw + "px";
|
|
this.cols[idx+p.nv].style.width = nw+"px";
|
|
if(this.footers.length>0) {this.footers[idx+p.nv].style.width = nw+"px";}
|
|
p.colModel[idx+p.nv].width = nw;
|
|
} else {
|
|
p.tblwidth = this.newWidth || p.tblwidth;
|
|
$('table:first',this.bDiv).css("width",p.tblwidth+"px");
|
|
$('table:first',this.hDiv).css("width",p.tblwidth+"px");
|
|
this.hDiv.scrollLeft = this.bDiv.scrollLeft;
|
|
if(p.footerrow) {
|
|
$('table:first',this.sDiv).css("width",p.tblwidth+"px");
|
|
this.sDiv.scrollLeft = this.bDiv.scrollLeft;
|
|
}
|
|
}
|
|
$(ts).triggerHandler("jqGridResizeStop", [nw, idx]);
|
|
if($.isFunction(p.resizeStop)) { p.resizeStop.call(ts,nw,idx); }
|
|
}
|
|
this.curGbox = null;
|
|
document.onselectstart=function(){return true;};
|
|
},
|
|
populateVisible: function() {
|
|
if (grid.timer) { clearTimeout(grid.timer); }
|
|
grid.timer = null;
|
|
var dh = $(grid.bDiv).height();
|
|
if (!dh) { return; }
|
|
var table = $("table:first", grid.bDiv);
|
|
var rows, rh;
|
|
if(table[0].rows.length) {
|
|
try {
|
|
rows = table[0].rows[1];
|
|
rh = rows ? $(rows).outerHeight() || grid.prevRowHeight : grid.prevRowHeight;
|
|
} catch (pv) {
|
|
rh = grid.prevRowHeight;
|
|
}
|
|
}
|
|
if (!rh) { return; }
|
|
grid.prevRowHeight = rh;
|
|
var rn = p.rowNum;
|
|
var scrollTop = grid.scrollTop = grid.bDiv.scrollTop;
|
|
var ttop = Math.round(table.position().top) - scrollTop;
|
|
var tbot = ttop + table.height();
|
|
var div = rh * rn;
|
|
var page, npage, empty;
|
|
if ( tbot < dh && ttop <= 0 &&
|
|
(p.lastpage===undefined||parseInt((tbot + scrollTop + div - 1) / div,10) <= p.lastpage))
|
|
{
|
|
npage = parseInt((dh - tbot + div - 1) / div,10);
|
|
if (tbot >= 0 || npage < 2 || p.scroll === true) {
|
|
page = Math.round((tbot + scrollTop) / div) + 1;
|
|
ttop = -1;
|
|
} else {
|
|
ttop = 1;
|
|
}
|
|
}
|
|
if (ttop > 0) {
|
|
page = parseInt(scrollTop / div,10) + 1;
|
|
npage = parseInt((scrollTop + dh) / div,10) + 2 - page;
|
|
empty = true;
|
|
}
|
|
if (npage) {
|
|
if (p.lastpage && (page > p.lastpage || p.lastpage===1 || (page === p.page && page===p.lastpage)) ) {
|
|
return;
|
|
}
|
|
if (grid.hDiv.loading) {
|
|
grid.timer = setTimeout(grid.populateVisible, p.scrollTimeout);
|
|
} else {
|
|
p.page = page;
|
|
if (empty) {
|
|
grid.selectionPreserver(table[0]);
|
|
grid.emptyRows.call(table[0], false, false);
|
|
}
|
|
grid.populate(npage);
|
|
}
|
|
}
|
|
},
|
|
scrollGrid: function( e ) {
|
|
if(p.scroll) {
|
|
var scrollTop = grid.bDiv.scrollTop;
|
|
if(grid.scrollTop === undefined) { grid.scrollTop = 0; }
|
|
if (scrollTop !== grid.scrollTop) {
|
|
grid.scrollTop = scrollTop;
|
|
if (grid.timer) { clearTimeout(grid.timer); }
|
|
grid.timer = setTimeout(grid.populateVisible, p.scrollTimeout);
|
|
}
|
|
}
|
|
grid.hDiv.scrollLeft = grid.bDiv.scrollLeft;
|
|
if(p.footerrow) {
|
|
grid.sDiv.scrollLeft = grid.bDiv.scrollLeft;
|
|
}
|
|
if( e ) { e.stopPropagation(); }
|
|
},
|
|
selectionPreserver : function(ts) {
|
|
var p = ts.p,
|
|
sr = p.selrow, sra = p.selarrrow ? $.makeArray(p.selarrrow) : null,
|
|
left = ts.grid.bDiv.scrollLeft,
|
|
restoreSelection = function() {
|
|
var i;
|
|
p.selrow = null;
|
|
p.selarrrow = [];
|
|
if(p.multiselect && sra && sra.length>0) {
|
|
for(i=0;i<sra.length;i++){
|
|
if (sra[i] !== sr) {
|
|
$(ts).jqGrid("setSelection",sra[i],false, null);
|
|
}
|
|
}
|
|
}
|
|
if (sr) {
|
|
$(ts).jqGrid("setSelection",sr,false,null);
|
|
}
|
|
ts.grid.bDiv.scrollLeft = left;
|
|
$(ts).unbind('.selectionPreserver', restoreSelection);
|
|
};
|
|
$(ts).bind('jqGridGridComplete.selectionPreserver', restoreSelection);
|
|
}
|
|
};
|
|
if(this.tagName.toUpperCase() !== 'TABLE') {
|
|
alert("Element is not a table");
|
|
return;
|
|
}
|
|
if(document.documentMode !== undefined ) { // IE only
|
|
if(document.documentMode <= 5) {
|
|
alert("Grid can not be used in this ('quirks') mode!");
|
|
return;
|
|
}
|
|
}
|
|
$(this).empty().attr("tabindex","0");
|
|
this.p = p ;
|
|
this.p.useProp = !!$.fn.prop;
|
|
var i, dir;
|
|
if(this.p.colNames.length === 0) {
|
|
for (i=0;i<this.p.colModel.length;i++){
|
|
this.p.colNames[i] = this.p.colModel[i].label || this.p.colModel[i].name;
|
|
}
|
|
}
|
|
if( this.p.colNames.length !== this.p.colModel.length ) {
|
|
alert($.jgrid.errors.model);
|
|
return;
|
|
}
|
|
var gv = $("<div class='ui-jqgrid-view'></div>"),
|
|
isMSIE = $.jgrid.msie;
|
|
ts.p.direction = $.trim(ts.p.direction.toLowerCase());
|
|
if($.inArray(ts.p.direction,["ltr","rtl"]) === -1) { ts.p.direction = "ltr"; }
|
|
dir = ts.p.direction;
|
|
|
|
$(gv).insertBefore(this);
|
|
$(this).removeClass("scroll").appendTo(gv);
|
|
var eg = $("<div class='ui-jqgrid ui-widget ui-widget-content ui-corner-all'></div>");
|
|
$(eg).attr({"id" : "gbox_"+this.id,"dir":dir}).insertBefore(gv);
|
|
$(gv).attr("id","gview_"+this.id).appendTo(eg);
|
|
$("<div class='ui-widget-overlay jqgrid-overlay' id='lui_"+this.id+"'></div>").insertBefore(gv);
|
|
$("<div class='loading ui-state-default ui-state-active' id='load_"+this.id+"'>"+this.p.loadtext+"</div>").insertBefore(gv);
|
|
$(this).attr({cellspacing:"0",cellpadding:"0",border:"0","role":"grid","aria-multiselectable":!!this.p.multiselect,"aria-labelledby":"gbox_"+this.id});
|
|
var sortkeys = ["shiftKey","altKey","ctrlKey"],
|
|
intNum = function(val,defval) {
|
|
val = parseInt(val,10);
|
|
if (isNaN(val)) { return defval || 0;}
|
|
return val;
|
|
},
|
|
formatCol = function (pos, rowInd, tv, rawObject, rowId, rdata){
|
|
var cm = ts.p.colModel[pos],
|
|
ral = cm.align, result="style=\"", clas = cm.classes, nm = cm.name, celp, acp=[];
|
|
if(ral) { result += "text-align:"+ral+";"; }
|
|
if(cm.hidden===true) { result += "display:none;"; }
|
|
if(rowInd===0) {
|
|
result += "width: "+grid.headers[pos].width+"px;";
|
|
} else if (cm.cellattr && $.isFunction(cm.cellattr))
|
|
{
|
|
celp = cm.cellattr.call(ts, rowId, tv, rawObject, cm, rdata);
|
|
if(celp && typeof celp === "string") {
|
|
celp = celp.replace(/style/i,'style').replace(/title/i,'title');
|
|
if(celp.indexOf('title') > -1) { cm.title=false;}
|
|
if(celp.indexOf('class') > -1) { clas = undefined;}
|
|
acp = celp.replace('-style','-sti').split(/style/);
|
|
if(acp.length === 2 ) {
|
|
acp[1] = $.trim(acp[1].replace('-sti','-style').replace("=",""));
|
|
if(acp[1].indexOf("'") === 0 || acp[1].indexOf('"') === 0) {
|
|
acp[1] = acp[1].substring(1);
|
|
}
|
|
result += acp[1].replace(/'/gi,'"');
|
|
} else {
|
|
result += "\"";
|
|
}
|
|
}
|
|
}
|
|
if(!acp.length) { acp[0] = ""; result += "\"";}
|
|
result += (clas !== undefined ? (" class=\""+clas+"\"") :"") + ((cm.title && tv) ? (" title=\""+$.jgrid.stripHtml(tv)+"\"") :"");
|
|
result += " aria-describedby=\""+ts.p.id+"_"+nm+"\"";
|
|
return result + acp[0];
|
|
},
|
|
cellVal = function (val) {
|
|
return val == null || val === "" ? " " : (ts.p.autoencode ? $.jgrid.htmlEncode(val) : String(val));
|
|
},
|
|
formatter = function (rowId, cellval , colpos, rwdat, _act){
|
|
var cm = ts.p.colModel[colpos],v;
|
|
if(cm.formatter !== undefined) {
|
|
rowId = String(ts.p.idPrefix) !== "" ? $.jgrid.stripPref(ts.p.idPrefix, rowId) : rowId;
|
|
var opts= {rowId: rowId, colModel:cm, gid:ts.p.id, pos:colpos };
|
|
if($.isFunction( cm.formatter ) ) {
|
|
v = cm.formatter.call(ts,cellval,opts,rwdat,_act);
|
|
} else if($.fmatter){
|
|
v = $.fn.fmatter.call(ts,cm.formatter,cellval,opts,rwdat,_act);
|
|
} else {
|
|
v = cellVal(cellval);
|
|
}
|
|
} else {
|
|
v = cellVal(cellval);
|
|
}
|
|
return v;
|
|
},
|
|
addCell = function(rowId,cell,pos,irow, srvr, rdata) {
|
|
var v,prp;
|
|
v = formatter(rowId, cell, pos, srvr, 'add');
|
|
if (v == null) v = "";
|
|
prp = formatCol( pos,irow, v, srvr, rowId, rdata);
|
|
return "<td role=\"gridcell\" "+prp+">"+v+"</td>";
|
|
},
|
|
addMulti = function(rowid,pos,irow,checked){
|
|
var v = "<input role=\"checkbox\" type=\"checkbox\""+" id=\"jqg_"+ts.p.id+"_"+rowid+"\" class=\"cbox\" name=\"jqg_"+ts.p.id+"_"+rowid+"\"" + (checked ? "checked=\"checked\"" : "")+"/>",
|
|
prp = formatCol( pos,irow,'',null, rowid, true);
|
|
return "<td role=\"gridcell\" "+prp+">"+v+"</td>";
|
|
},
|
|
addRowNum = function (pos, irow, pG, rN, rowid) {
|
|
var v = (parseInt(pG,10)-1)*parseInt(rN,10)+1+irow,
|
|
prp = formatCol( pos,irow,v, null, irow, true);
|
|
return "<td onClick=\"rowclick('" + rowid + "');\" role=\"gridcell\" class=\"ui-state-default jqgrid-rownum\" " + prp + ">" + v + "</td>";
|
|
},
|
|
reader = function (datatype) {
|
|
var field, f=[], j=0, i;
|
|
for(i =0; i<ts.p.colModel.length; i++){
|
|
field = ts.p.colModel[i];
|
|
if (field.name !== 'cb' && field.name !=='subgrid' && field.name !=='rn') {
|
|
f[j]= datatype === "local" ?
|
|
field.name :
|
|
( (datatype==="xml" || datatype === "xmlstring") ? field.xmlmap || field.name : field.jsonmap || field.name );
|
|
if(ts.p.keyIndex !== false && field.key===true ) {
|
|
ts.p.keyName = f[j];
|
|
}
|
|
j++;
|
|
}
|
|
}
|
|
return f;
|
|
},
|
|
orderedCols = function (offset) {
|
|
var order = ts.p.remapColumns;
|
|
if (!order || !order.length) {
|
|
order = $.map(ts.p.colModel, function(v,i) { return i; });
|
|
}
|
|
if (offset) {
|
|
order = $.map(order, function(v) { return v<offset?null:v-offset; });
|
|
}
|
|
return order;
|
|
},
|
|
emptyRows = function (scroll, locdata) {
|
|
var firstrow;
|
|
if (this.p.deepempty) {
|
|
$(this.rows).slice(1).remove();
|
|
} else {
|
|
firstrow = this.rows.length > 0 ? this.rows[0] : null;
|
|
$(this.firstChild).empty().append(firstrow);
|
|
}
|
|
if (scroll && this.p.scroll) {
|
|
$(this.grid.bDiv.firstChild).css({height: "auto"});
|
|
$(this.grid.bDiv.firstChild.firstChild).css({height: 0, display: "none"});
|
|
if (this.grid.bDiv.scrollTop !== 0) {
|
|
this.grid.bDiv.scrollTop = 0;
|
|
}
|
|
}
|
|
if(locdata === true && this.p.treeGrid) {
|
|
this.p.data = []; this.p._index = {};
|
|
}
|
|
},
|
|
refreshIndex = function() {
|
|
var datalen = ts.p.data.length, idname, i, val,
|
|
ni = ts.p.rownumbers===true ? 1 :0,
|
|
gi = ts.p.multiselect ===true ? 1 :0,
|
|
si = ts.p.subGrid===true ? 1 :0;
|
|
|
|
if(ts.p.keyIndex === false || ts.p.loadonce === true) {
|
|
idname = ts.p.localReader.id;
|
|
} else {
|
|
idname = ts.p.colModel[ts.p.keyIndex+gi+si+ni].name;
|
|
}
|
|
for(i =0;i < datalen; i++) {
|
|
val = $.jgrid.getAccessor(ts.p.data[i],idname);
|
|
if (val === undefined) { val=String(i+1); }
|
|
ts.p._index[val] = i;
|
|
}
|
|
},
|
|
constructTr = function(id, hide, altClass, rd, cur, selected) {
|
|
var tabindex = '-1', restAttr = '', attrName, style = hide ? 'display:none;' : '',
|
|
classes = 'ui-widget-content jqgrow ui-row-' + ts.p.direction + (altClass ? ' ' + altClass : '') + (selected ? ' ui-state-highlight' : ''),
|
|
rowAttrObj = $(ts).triggerHandler("jqGridRowAttr", [rd, cur, id]);
|
|
if( typeof rowAttrObj !== "object" ) {
|
|
rowAttrObj = $.isFunction(ts.p.rowattr) ? ts.p.rowattr.call(ts, rd, cur, id) :{};
|
|
}
|
|
if(!$.isEmptyObject( rowAttrObj )) {
|
|
if (rowAttrObj.hasOwnProperty("id")) {
|
|
id = rowAttrObj.id;
|
|
delete rowAttrObj.id;
|
|
}
|
|
if (rowAttrObj.hasOwnProperty("tabindex")) {
|
|
tabindex = rowAttrObj.tabindex;
|
|
delete rowAttrObj.tabindex;
|
|
}
|
|
if (rowAttrObj.hasOwnProperty("style")) {
|
|
style += rowAttrObj.style;
|
|
delete rowAttrObj.style;
|
|
}
|
|
if (rowAttrObj.hasOwnProperty("class")) {
|
|
classes += ' ' + rowAttrObj['class'];
|
|
delete rowAttrObj['class'];
|
|
}
|
|
// dot't allow to change role attribute
|
|
try { delete rowAttrObj.role; } catch(ra){}
|
|
for (attrName in rowAttrObj) {
|
|
if (rowAttrObj.hasOwnProperty(attrName)) {
|
|
restAttr += ' ' + attrName + '=' + rowAttrObj[attrName];
|
|
}
|
|
}
|
|
}
|
|
return '<tr role="row" id="' + id + '" tabindex="' + tabindex + '" class="' + classes + '"' +
|
|
(style === '' ? '' : ' style="' + style + '"') + restAttr + '>';
|
|
},
|
|
addXmlData = function (xml,t, rcnt, more, adjust) {
|
|
var startReq = new Date(),
|
|
locdata = (ts.p.datatype !== "local" && ts.p.loadonce) || ts.p.datatype === "xmlstring",
|
|
xmlid = "_id_", xmlRd = ts.p.xmlReader,
|
|
frd = ts.p.datatype === "local" ? "local" : "xml";
|
|
if(locdata) {
|
|
ts.p.data = [];
|
|
ts.p._index = {};
|
|
ts.p.localReader.id = xmlid;
|
|
}
|
|
ts.p.reccount = 0;
|
|
if($.isXMLDoc(xml)) {
|
|
if(ts.p.treeANode===-1 && !ts.p.scroll) {
|
|
emptyRows.call(ts, false, true);
|
|
rcnt=1;
|
|
} else { rcnt = rcnt > 1 ? rcnt :1; }
|
|
} else { return; }
|
|
var self= $(ts), i,fpos,ir=0,v,gi=ts.p.multiselect===true?1:0,si=0,addSubGridCell,ni=ts.p.rownumbers===true?1:0,idn, getId,f=[],F,rd ={}, xmlr,rid, rowData=[], cn=(ts.p.altRows === true) ? ts.p.altclass:"",cn1;
|
|
if(ts.p.subGrid===true) {
|
|
si = 1;
|
|
addSubGridCell = $.jgrid.getMethod("addSubGridCell");
|
|
}
|
|
if(!xmlRd.repeatitems) {f = reader(frd);}
|
|
if( ts.p.keyIndex===false) {
|
|
idn = $.isFunction( xmlRd.id ) ? xmlRd.id.call(ts, xml) : xmlRd.id;
|
|
} else {
|
|
idn = ts.p.keyIndex;
|
|
}
|
|
if(f.length>0 && !isNaN(idn)) {
|
|
idn=ts.p.keyName;
|
|
}
|
|
if( String(idn).indexOf("[") === -1 ) {
|
|
if (f.length) {
|
|
getId = function( trow, k) {return $(idn,trow).text() || k;};
|
|
} else {
|
|
getId = function( trow, k) {return $(xmlRd.cell,trow).eq(idn).text() || k;};
|
|
}
|
|
}
|
|
else {
|
|
getId = function( trow, k) {return trow.getAttribute(idn.replace(/[\[\]]/g,"")) || k;};
|
|
}
|
|
ts.p.userData = {};
|
|
ts.p.page = intNum($.jgrid.getXmlData(xml, xmlRd.page), ts.p.page);
|
|
ts.p.lastpage = intNum($.jgrid.getXmlData(xml, xmlRd.total), 1);
|
|
ts.p.records = intNum($.jgrid.getXmlData(xml, xmlRd.records));
|
|
if($.isFunction(xmlRd.userdata)) {
|
|
ts.p.userData = xmlRd.userdata.call(ts, xml) || {};
|
|
} else {
|
|
$.jgrid.getXmlData(xml, xmlRd.userdata, true).each(function() {ts.p.userData[this.getAttribute("name")]= $(this).text();});
|
|
}
|
|
var gxml = $.jgrid.getXmlData( xml, xmlRd.root, true);
|
|
gxml = $.jgrid.getXmlData( gxml, xmlRd.row, true);
|
|
if (!gxml) { gxml = []; }
|
|
var gl = gxml.length, j=0, grpdata=[], rn = parseInt(ts.p.rowNum,10), br=ts.p.scroll?$.jgrid.randId():1, altr;
|
|
if (gl > 0 && ts.p.page <= 0) { ts.p.page = 1; }
|
|
if(gxml && gl){
|
|
if (adjust) { rn *= adjust+1; }
|
|
var afterInsRow = $.isFunction(ts.p.afterInsertRow), hiderow=false, groupingPrepare;
|
|
if(ts.p.grouping) {
|
|
hiderow = ts.p.groupingView.groupCollapse === true;
|
|
groupingPrepare = $.jgrid.getMethod("groupingPrepare");
|
|
}
|
|
while (j<gl) {
|
|
xmlr = gxml[j];
|
|
rid = getId(xmlr,br+j);
|
|
rid = ts.p.idPrefix + rid;
|
|
altr = rcnt === 0 ? 0 : rcnt+1;
|
|
cn1 = (altr+j)%2 === 1 ? cn : '';
|
|
var iStartTrTag = rowData.length;
|
|
rowData.push("");
|
|
if( ni ) {
|
|
rowData.push(addRowNum(0, i, ts.p.page, ts.p.rowNum,rid));
|
|
}
|
|
if( gi ) {
|
|
rowData.push( addMulti(rid,ni,j, false) );
|
|
}
|
|
if( si ) {
|
|
rowData.push( addSubGridCell.call(self,gi+ni,j+rcnt) );
|
|
}
|
|
if(xmlRd.repeatitems){
|
|
if (!F) { F=orderedCols(gi+si+ni); }
|
|
var cells = $.jgrid.getXmlData( xmlr, xmlRd.cell, true);
|
|
$.each(F, function (k) {
|
|
var cell = cells[this];
|
|
if (!cell) { return false; }
|
|
v = cell.textContent || cell.text;
|
|
rd[ts.p.colModel[k+gi+si+ni].name] = v;
|
|
rowData.push( addCell(rid,v,k+gi+si+ni,j+rcnt,xmlr, rd) );
|
|
});
|
|
} else {
|
|
for(i = 0; i < f.length;i++) {
|
|
v = $.jgrid.getXmlData( xmlr, f[i]);
|
|
rd[ts.p.colModel[i+gi+si+ni].name] = v;
|
|
rowData.push( addCell(rid, v, i+gi+si+ni, j+rcnt, xmlr, rd) );
|
|
}
|
|
}
|
|
rowData[iStartTrTag] = constructTr(rid, hiderow, cn1, rd, xmlr, false);
|
|
rowData.push("</tr>");
|
|
if(ts.p.grouping) {
|
|
grpdata = groupingPrepare.call(self,rowData, grpdata, rd, j);
|
|
rowData = [];
|
|
}
|
|
if(locdata || ts.p.treeGrid === true) {
|
|
rd[xmlid] = $.jgrid.stripPref(ts.p.idPrefix, rid);
|
|
ts.p.data.push(rd);
|
|
ts.p._index[rd[xmlid]] = ts.p.data.length-1;
|
|
}
|
|
if(ts.p.gridview === false ) {
|
|
$("tbody:first",t).append(rowData.join(''));
|
|
self.triggerHandler("jqGridAfterInsertRow", [rid, rd, xmlr]);
|
|
if(afterInsRow) {ts.p.afterInsertRow.call(ts,rid,rd,xmlr);}
|
|
rowData=[];
|
|
}
|
|
rd={};
|
|
ir++;
|
|
j++;
|
|
if(ir===rn) {break;}
|
|
}
|
|
}
|
|
if(ts.p.gridview === true) {
|
|
fpos = ts.p.treeANode > -1 ? ts.p.treeANode: 0;
|
|
if(ts.p.grouping) {
|
|
self.jqGrid('groupingRender',grpdata,ts.p.colModel.length);
|
|
grpdata = null;
|
|
} else if(ts.p.treeGrid === true && fpos > 0) {
|
|
$(ts.rows[fpos]).after(rowData.join(''));
|
|
} else {
|
|
$("tbody:first",t).append(rowData.join(''));
|
|
}
|
|
}
|
|
if(ts.p.subGrid === true ) {
|
|
try {self.jqGrid("addSubGrid",gi+ni);} catch (_){}
|
|
}
|
|
ts.p.totaltime = new Date() - startReq;
|
|
if(ir>0) { if(ts.p.records===0) { ts.p.records=gl;} }
|
|
rowData =null;
|
|
if( ts.p.treeGrid === true) {
|
|
try {self.jqGrid("setTreeNode", fpos+1, ir+fpos+1);} catch (e) {}
|
|
}
|
|
if(!ts.p.treeGrid && !ts.p.scroll) {ts.grid.bDiv.scrollTop = 0;}
|
|
ts.p.reccount=ir;
|
|
ts.p.treeANode = -1;
|
|
if(ts.p.userDataOnFooter) { self.jqGrid("footerData","set",ts.p.userData,true); }
|
|
if(locdata) {
|
|
ts.p.records = gl;
|
|
ts.p.lastpage = Math.ceil(gl/ rn);
|
|
}
|
|
if (!more) { ts.updatepager(false,true); }
|
|
if(locdata) {
|
|
while (ir<gl) {
|
|
xmlr = gxml[ir];
|
|
rid = getId(xmlr,ir+br);
|
|
rid = ts.p.idPrefix + rid;
|
|
if(xmlRd.repeatitems){
|
|
if (!F) { F=orderedCols(gi+si+ni); }
|
|
var cells2 = $.jgrid.getXmlData( xmlr, xmlRd.cell, true);
|
|
$.each(F, function (k) {
|
|
var cell = cells2[this];
|
|
if (!cell) { return false; }
|
|
v = cell.textContent || cell.text;
|
|
rd[ts.p.colModel[k+gi+si+ni].name] = v;
|
|
});
|
|
} else {
|
|
for(i = 0; i < f.length;i++) {
|
|
v = $.jgrid.getXmlData( xmlr, f[i]);
|
|
rd[ts.p.colModel[i+gi+si+ni].name] = v;
|
|
}
|
|
}
|
|
rd[xmlid] = $.jgrid.stripPref(ts.p.idPrefix, rid);
|
|
ts.p.data.push(rd);
|
|
ts.p._index[rd[xmlid]] = ts.p.data.length-1;
|
|
rd = {};
|
|
ir++;
|
|
}
|
|
}
|
|
},
|
|
addJSONData = function(data,t, rcnt, more, adjust) {
|
|
var startReq = new Date();
|
|
if(data) {
|
|
if(ts.p.treeANode === -1 && !ts.p.scroll) {
|
|
emptyRows.call(ts, false, true);
|
|
rcnt=1;
|
|
} else { rcnt = rcnt > 1 ? rcnt :1; }
|
|
} else { return; }
|
|
|
|
var dReader, locid = "_id_", frd,
|
|
locdata = (ts.p.datatype !== "local" && ts.p.loadonce) || ts.p.datatype === "jsonstring";
|
|
if(locdata) { ts.p.data = []; ts.p._index = {}; ts.p.localReader.id = locid;}
|
|
ts.p.reccount = 0;
|
|
if(ts.p.datatype === "local") {
|
|
dReader = ts.p.localReader;
|
|
frd= 'local';
|
|
} else {
|
|
dReader = ts.p.jsonReader;
|
|
frd='json';
|
|
}
|
|
var self = $(ts), ir=0,v,i,j,f=[],cur,gi=ts.p.multiselect?1:0,si=ts.p.subGrid===true?1:0,addSubGridCell,ni=ts.p.rownumbers===true?1:0,arrayReader=orderedCols(gi+si+ni),objectReader=reader(frd),rowReader,len,drows,idn,rd={}, fpos, idr,rowData=[],cn=(ts.p.altRows === true) ? ts.p.altclass:"",cn1;
|
|
ts.p.page = intNum($.jgrid.getAccessor(data,dReader.page), ts.p.page);
|
|
ts.p.lastpage = intNum($.jgrid.getAccessor(data,dReader.total), 1);
|
|
ts.p.records = intNum($.jgrid.getAccessor(data,dReader.records));
|
|
ts.p.userData = $.jgrid.getAccessor(data,dReader.userdata) || {};
|
|
if(si) {
|
|
addSubGridCell = $.jgrid.getMethod("addSubGridCell");
|
|
}
|
|
if( ts.p.keyIndex===false ) {
|
|
idn = $.isFunction(dReader.id) ? dReader.id.call(ts, data) : dReader.id;
|
|
} else {
|
|
idn = ts.p.keyIndex;
|
|
}
|
|
if(!dReader.repeatitems) {
|
|
f = objectReader;
|
|
if(f.length>0 && !isNaN(idn)) {
|
|
idn=ts.p.keyName;
|
|
}
|
|
}
|
|
drows = $.jgrid.getAccessor(data,dReader.root);
|
|
if (drows == null && $.isArray(data)) { drows = data; }
|
|
if (!drows) { drows = []; }
|
|
len = drows.length; i=0;
|
|
if (len > 0 && ts.p.page <= 0) { ts.p.page = 1; }
|
|
var rn = parseInt(ts.p.rowNum,10),br=ts.p.scroll?$.jgrid.randId():1, altr, selected=false, selr;
|
|
if (adjust) { rn *= adjust+1; }
|
|
if(ts.p.datatype === "local" && !ts.p.deselectAfterSort) {
|
|
selected = true;
|
|
}
|
|
var afterInsRow = $.isFunction(ts.p.afterInsertRow), grpdata=[],hiderow=false, groupingPrepare;
|
|
if(ts.p.grouping) {
|
|
hiderow = ts.p.groupingView.groupCollapse === true;
|
|
groupingPrepare = $.jgrid.getMethod("groupingPrepare");
|
|
}
|
|
while (i<len) {
|
|
cur = drows[i];
|
|
idr = $.jgrid.getAccessor(cur,idn);
|
|
if(idr === undefined) {
|
|
if (typeof idn === "number" && ts.p.colModel[idn+gi+si+ni] != null) {
|
|
// reread id by name
|
|
idr = $.jgrid.getAccessor(cur,ts.p.colModel[idn+gi+si+ni].name);
|
|
}
|
|
if(idr === undefined) {
|
|
idr = br+i;
|
|
if(f.length===0){
|
|
if(dReader.cell){
|
|
var ccur = $.jgrid.getAccessor(cur,dReader.cell) || cur;
|
|
idr = ccur != null && ccur[idn] !== undefined ? ccur[idn] : idr;
|
|
ccur=null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
idr = ts.p.idPrefix + idr;
|
|
altr = rcnt === 1 ? 0 : rcnt;
|
|
cn1 = (altr+i)%2 === 1 ? cn : '';
|
|
if( selected) {
|
|
if( ts.p.multiselect) {
|
|
selr = ($.inArray(idr, ts.p.selarrrow) !== -1);
|
|
} else {
|
|
selr = (idr === ts.p.selrow);
|
|
}
|
|
}
|
|
var iStartTrTag = rowData.length;
|
|
rowData.push("");
|
|
if( ni ) {
|
|
rowData.push( addRowNum(0,i,ts.p.page,ts.p.rowNum,idr) );
|
|
}
|
|
if( gi ){
|
|
rowData.push( addMulti(idr,ni,i,selr) );
|
|
}
|
|
if( si ) {
|
|
rowData.push( addSubGridCell.call(self,gi+ni,i+rcnt) );
|
|
}
|
|
rowReader=objectReader;
|
|
if (dReader.repeatitems) {
|
|
if(dReader.cell) {cur = $.jgrid.getAccessor(cur,dReader.cell) || cur;}
|
|
if ($.isArray(cur)) { rowReader=arrayReader; }
|
|
}
|
|
for (j=0;j<rowReader.length;j++) {
|
|
v = $.jgrid.getAccessor(cur,rowReader[j]);
|
|
rd[ts.p.colModel[j+gi+si+ni].name] = v;
|
|
rowData.push( addCell(idr,v,j+gi+si+ni,i+rcnt,cur, rd) );
|
|
}
|
|
rowData[iStartTrTag] = constructTr(idr, hiderow, cn1, rd, cur, selr);
|
|
rowData.push( "</tr>" );
|
|
if(ts.p.grouping) {
|
|
grpdata = groupingPrepare.call(self,rowData, grpdata, rd, i);
|
|
rowData = [];
|
|
}
|
|
if(locdata || ts.p.treeGrid===true) {
|
|
rd[locid] = $.jgrid.stripPref(ts.p.idPrefix, idr);
|
|
ts.p.data.push(rd);
|
|
ts.p._index[rd[locid]] = ts.p.data.length-1;
|
|
}
|
|
if(ts.p.gridview === false ) {
|
|
$("#"+$.jgrid.jqID(ts.p.id)+" tbody:first").append(rowData.join(''));
|
|
self.triggerHandler("jqGridAfterInsertRow", [idr, rd, cur]);
|
|
if(afterInsRow) {ts.p.afterInsertRow.call(ts,idr,rd,cur);}
|
|
rowData=[];//ari=0;
|
|
}
|
|
rd={};
|
|
ir++;
|
|
i++;
|
|
if(ir===rn) { break; }
|
|
}
|
|
if(ts.p.gridview === true ) {
|
|
fpos = ts.p.treeANode > -1 ? ts.p.treeANode: 0;
|
|
if(ts.p.grouping) {
|
|
self.jqGrid('groupingRender',grpdata,ts.p.colModel.length);
|
|
grpdata = null;
|
|
} else if(ts.p.treeGrid === true && fpos > 0) {
|
|
$(ts.rows[fpos]).after(rowData.join(''));
|
|
} else {
|
|
$("#"+$.jgrid.jqID(ts.p.id)+" tbody:first").append(rowData.join(''));
|
|
}
|
|
}
|
|
if(ts.p.subGrid === true ) {
|
|
try { self.jqGrid("addSubGrid",gi+ni);} catch (_){}
|
|
}
|
|
ts.p.totaltime = new Date() - startReq;
|
|
if(ir>0) {
|
|
if(ts.p.records===0) { ts.p.records=len; }
|
|
}
|
|
rowData = null;
|
|
if( ts.p.treeGrid === true) {
|
|
try {self.jqGrid("setTreeNode", fpos+1, ir+fpos+1);} catch (e) {}
|
|
}
|
|
if(!ts.p.treeGrid && !ts.p.scroll) {ts.grid.bDiv.scrollTop = 0;}
|
|
ts.p.reccount=ir;
|
|
ts.p.treeANode = -1;
|
|
if(ts.p.userDataOnFooter) { self.jqGrid("footerData","set",ts.p.userData,true); }
|
|
if(locdata) {
|
|
ts.p.records = len;
|
|
ts.p.lastpage = Math.ceil(len/ rn);
|
|
}
|
|
if (!more) { ts.updatepager(false,true); }
|
|
if(locdata) {
|
|
while (ir<len && drows[ir]) {
|
|
cur = drows[ir];
|
|
idr = $.jgrid.getAccessor(cur,idn);
|
|
if(idr === undefined) {
|
|
if (typeof idn === "number" && ts.p.colModel[idn+gi+si+ni] != null) {
|
|
// reread id by name
|
|
idr = $.jgrid.getAccessor(cur,ts.p.colModel[idn+gi+si+ni].name);
|
|
}
|
|
if(idr === undefined) {
|
|
idr = br+ir;
|
|
if(f.length===0){
|
|
if(dReader.cell){
|
|
var ccur2 = $.jgrid.getAccessor(cur,dReader.cell) || cur;
|
|
idr = ccur2 != null && ccur2[idn] !== undefined ? ccur2[idn] : idr;
|
|
ccur2=null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(cur) {
|
|
idr = ts.p.idPrefix + idr;
|
|
rowReader=objectReader;
|
|
if (dReader.repeatitems) {
|
|
if(dReader.cell) {cur = $.jgrid.getAccessor(cur,dReader.cell) || cur;}
|
|
if ($.isArray(cur)) { rowReader=arrayReader; }
|
|
}
|
|
|
|
for (j=0;j<rowReader.length;j++) {
|
|
rd[ts.p.colModel[j+gi+si+ni].name] = $.jgrid.getAccessor(cur,rowReader[j]);
|
|
}
|
|
rd[locid] = $.jgrid.stripPref(ts.p.idPrefix, idr);
|
|
ts.p.data.push(rd);
|
|
ts.p._index[rd[locid]] = ts.p.data.length-1;
|
|
rd = {};
|
|
}
|
|
ir++;
|
|
}
|
|
}
|
|
},
|
|
addLocalData = function() {
|
|
var st = ts.p.multiSort ? [] : "", sto=[], fndsort=false, cmtypes={}, grtypes=[], grindexes=[], srcformat, sorttype, newformat;
|
|
if(!$.isArray(ts.p.data)) {
|
|
return;
|
|
}
|
|
var grpview = ts.p.grouping ? ts.p.groupingView : false, lengrp, gin;
|
|
$.each(ts.p.colModel,function(){
|
|
sorttype = this.sorttype || "text";
|
|
if(sorttype === "date" || sorttype === "datetime") {
|
|
if(this.formatter && typeof this.formatter === 'string' && this.formatter === 'date') {
|
|
if(this.formatoptions && this.formatoptions.srcformat) {
|
|
srcformat = this.formatoptions.srcformat;
|
|
} else {
|
|
srcformat = $.jgrid.formatter.date.srcformat;
|
|
}
|
|
if(this.formatoptions && this.formatoptions.newformat) {
|
|
newformat = this.formatoptions.newformat;
|
|
} else {
|
|
newformat = $.jgrid.formatter.date.newformat;
|
|
}
|
|
} else {
|
|
srcformat = newformat = this.datefmt || "Y-m-d";
|
|
}
|
|
cmtypes[this.name] = {"stype": sorttype, "srcfmt": srcformat,"newfmt":newformat};
|
|
} else {
|
|
cmtypes[this.name] = {"stype": sorttype, "srcfmt":'',"newfmt":''};
|
|
}
|
|
if(ts.p.grouping ) {
|
|
for(gin =0, lengrp = grpview.groupField.length; gin< lengrp; gin++) {
|
|
if( this.name === grpview.groupField[gin]) {
|
|
var grindex = this.name;
|
|
if (this.index) {
|
|
grindex = this.index;
|
|
}
|
|
grtypes[gin] = cmtypes[grindex];
|
|
grindexes[gin]= grindex;
|
|
}
|
|
}
|
|
}
|
|
if(ts.p.multiSort) {
|
|
if(this.lso) {
|
|
st.push(this.name);
|
|
var tmplso= this.lso.split("-");
|
|
sto.push( tmplso[tmplso.length-1] );
|
|
}
|
|
} else {
|
|
if(!fndsort && (this.index === ts.p.sortname || this.name === ts.p.sortname)){
|
|
st = this.name; // ???
|
|
fndsort = true;
|
|
}
|
|
}
|
|
});
|
|
if(ts.p.treeGrid) {
|
|
$(ts).jqGrid("SortTree", st, ts.p.sortorder, cmtypes[st].stype || 'text', cmtypes[st].srcfmt || '');
|
|
return;
|
|
}
|
|
var compareFnMap = {
|
|
'eq':function(queryObj) {return queryObj.equals;},
|
|
'ne':function(queryObj) {return queryObj.notEquals;},
|
|
'lt':function(queryObj) {return queryObj.less;},
|
|
'le':function(queryObj) {return queryObj.lessOrEquals;},
|
|
'gt':function(queryObj) {return queryObj.greater;},
|
|
'ge':function(queryObj) {return queryObj.greaterOrEquals;},
|
|
'cn':function(queryObj) {return queryObj.contains;},
|
|
'nc':function(queryObj,op) {return op === "OR" ? queryObj.orNot().contains : queryObj.andNot().contains;},
|
|
'bw':function(queryObj) {return queryObj.startsWith;},
|
|
'bn':function(queryObj,op) {return op === "OR" ? queryObj.orNot().startsWith : queryObj.andNot().startsWith;},
|
|
'en':function(queryObj,op) {return op === "OR" ? queryObj.orNot().endsWith : queryObj.andNot().endsWith;},
|
|
'ew':function(queryObj) {return queryObj.endsWith;},
|
|
'ni':function(queryObj,op) {return op === "OR" ? queryObj.orNot().equals : queryObj.andNot().equals;},
|
|
'in':function(queryObj) {return queryObj.equals;},
|
|
'nu':function(queryObj) {return queryObj.isNull;},
|
|
'nn':function(queryObj,op) {return op === "OR" ? queryObj.orNot().isNull : queryObj.andNot().isNull;}
|
|
|
|
},
|
|
query = $.jgrid.from(ts.p.data);
|
|
if (ts.p.ignoreCase) { query = query.ignoreCase(); }
|
|
function tojLinq ( group ) {
|
|
var s = 0, index, gor, ror, opr, rule;
|
|
if (group.groups != null) {
|
|
gor = group.groups.length && group.groupOp.toString().toUpperCase() === "OR";
|
|
if (gor) {
|
|
query.orBegin();
|
|
}
|
|
for (index = 0; index < group.groups.length; index++) {
|
|
if (s > 0 && gor) {
|
|
query.or();
|
|
}
|
|
try {
|
|
tojLinq(group.groups[index]);
|
|
} catch (e) {alert(e);}
|
|
s++;
|
|
}
|
|
if (gor) {
|
|
query.orEnd();
|
|
}
|
|
}
|
|
if (group.rules != null) {
|
|
//if(s>0) {
|
|
// var result = query.select();
|
|
// query = $.jgrid.from( result);
|
|
// if (ts.p.ignoreCase) { query = query.ignoreCase(); }
|
|
//}
|
|
try{
|
|
ror = group.rules.length && group.groupOp.toString().toUpperCase() === "OR";
|
|
if (ror) {
|
|
query.orBegin();
|
|
}
|
|
for (index = 0; index < group.rules.length; index++) {
|
|
rule = group.rules[index];
|
|
opr = group.groupOp.toString().toUpperCase();
|
|
if (compareFnMap[rule.op] && rule.field ) {
|
|
if(s > 0 && opr && opr === "OR") {
|
|
query = query.or();
|
|
}
|
|
query = compareFnMap[rule.op](query, opr)(rule.field, rule.data, cmtypes[rule.field]);
|
|
}
|
|
s++;
|
|
}
|
|
if (ror) {
|
|
query.orEnd();
|
|
}
|
|
} catch (g) {alert(g);}
|
|
}
|
|
}
|
|
|
|
if (ts.p.search === true) {
|
|
var srules = ts.p.postData.filters;
|
|
if(srules) {
|
|
if(typeof srules === "string") { srules = $.jgrid.parse(srules);}
|
|
tojLinq( srules );
|
|
} else {
|
|
try {
|
|
query = compareFnMap[ts.p.postData.searchOper](query)(ts.p.postData.searchField, ts.p.postData.searchString,cmtypes[ts.p.postData.searchField]);
|
|
} catch (se){}
|
|
}
|
|
}
|
|
if(ts.p.grouping) {
|
|
for(gin=0; gin<lengrp;gin++) {
|
|
query.orderBy(grindexes[gin],grpview.groupOrder[gin],grtypes[gin].stype, grtypes[gin].srcfmt);
|
|
}
|
|
}
|
|
if(ts.p.multiSort) {
|
|
$.each(st,function(i){
|
|
query.orderBy(this, sto[i], cmtypes[this].stype, cmtypes[this].srcfmt);
|
|
});
|
|
} else {
|
|
if (st && ts.p.sortorder && fndsort) {
|
|
if(ts.p.sortorder.toUpperCase() === "DESC") {
|
|
query.orderBy(ts.p.sortname, "d", cmtypes[st].stype, cmtypes[st].srcfmt);
|
|
} else {
|
|
query.orderBy(ts.p.sortname, "a", cmtypes[st].stype, cmtypes[st].srcfmt);
|
|
}
|
|
}
|
|
}
|
|
var queryResults = query.select(),
|
|
recordsperpage = parseInt(ts.p.rowNum,10),
|
|
total = queryResults.length,
|
|
page = parseInt(ts.p.page,10),
|
|
totalpages = Math.ceil(total / recordsperpage),
|
|
retresult = {};
|
|
queryResults = queryResults.slice( (page-1)*recordsperpage , page*recordsperpage );
|
|
query = null;
|
|
cmtypes = null;
|
|
retresult[ts.p.localReader.total] = totalpages;
|
|
retresult[ts.p.localReader.page] = page;
|
|
retresult[ts.p.localReader.records] = total;
|
|
retresult[ts.p.localReader.root] = queryResults;
|
|
retresult[ts.p.localReader.userdata] = ts.p.userData;
|
|
queryResults = null;
|
|
return retresult;
|
|
},
|
|
updatepager = function(rn, dnd) {
|
|
var cp, last, base, from,to,tot,fmt, pgboxes = "", sppg,
|
|
tspg = ts.p.pager ? "_"+$.jgrid.jqID(ts.p.pager.substr(1)) : "",
|
|
tspg_t = ts.p.toppager ? "_"+ts.p.toppager.substr(1) : "";
|
|
base = parseInt(ts.p.page,10)-1;
|
|
if(base < 0) { base = 0; }
|
|
base = base*parseInt(ts.p.rowNum,10);
|
|
to = base + ts.p.reccount;
|
|
if (ts.p.scroll) {
|
|
var rows = $("tbody:first > tr:gt(0)", ts.grid.bDiv);
|
|
base = to - rows.length;
|
|
ts.p.reccount = rows.length;
|
|
var rh = rows.outerHeight() || ts.grid.prevRowHeight;
|
|
if (rh) {
|
|
var top = base * rh;
|
|
var height = parseInt(ts.p.records,10) * rh;
|
|
$(">div:first",ts.grid.bDiv).css({height : height}).children("div:first").css({height:top,display:top?"":"none"});
|
|
if (ts.grid.bDiv.scrollTop == 0 && ts.p.page > 1) {
|
|
ts.grid.bDiv.scrollTop = ts.p.rowNum * (ts.p.page - 1) * rh;
|
|
}
|
|
}
|
|
ts.grid.bDiv.scrollLeft = ts.grid.hDiv.scrollLeft;
|
|
}
|
|
pgboxes = ts.p.pager || "";
|
|
pgboxes += ts.p.toppager ? (pgboxes ? "," + ts.p.toppager : ts.p.toppager) : "";
|
|
if(pgboxes) {
|
|
fmt = $.jgrid.formatter.integer || {};
|
|
cp = intNum(ts.p.page);
|
|
last = intNum(ts.p.lastpage);
|
|
$(".selbox",pgboxes)[ this.p.useProp ? 'prop' : 'attr' ]("disabled",false);
|
|
if(ts.p.pginput===true) {
|
|
$('.ui-pg-input',pgboxes).val(ts.p.page);
|
|
sppg = ts.p.toppager ? '#sp_1'+tspg+",#sp_1"+tspg_t : '#sp_1'+tspg;
|
|
$(sppg).html($.fmatter ? $.fmatter.util.NumberFormat(ts.p.lastpage,fmt):ts.p.lastpage);
|
|
|
|
}
|
|
if (ts.p.viewrecords){
|
|
if(ts.p.reccount === 0) {
|
|
$(".ui-paging-info",pgboxes).html(ts.p.emptyrecords);
|
|
} else {
|
|
from = base+1;
|
|
tot=ts.p.records;
|
|
if($.fmatter) {
|
|
from = $.fmatter.util.NumberFormat(from,fmt);
|
|
to = $.fmatter.util.NumberFormat(to,fmt);
|
|
tot = $.fmatter.util.NumberFormat(tot,fmt);
|
|
}
|
|
$(".ui-paging-info",pgboxes).html($.jgrid.format(ts.p.recordtext,from,to,tot));
|
|
}
|
|
}
|
|
if(ts.p.pgbuttons===true) {
|
|
if(cp<=0) {cp = last = 0;}
|
|
if(cp===1 || cp === 0) {
|
|
$("#first"+tspg+", #prev"+tspg).addClass('ui-state-disabled').removeClass('ui-state-hover');
|
|
if(ts.p.toppager) { $("#first_t"+tspg_t+", #prev_t"+tspg_t).addClass('ui-state-disabled').removeClass('ui-state-hover'); }
|
|
} else {
|
|
$("#first"+tspg+", #prev"+tspg).removeClass('ui-state-disabled');
|
|
if(ts.p.toppager) { $("#first_t"+tspg_t+", #prev_t"+tspg_t).removeClass('ui-state-disabled'); }
|
|
}
|
|
if(cp===last || cp === 0) {
|
|
$("#next"+tspg+", #last"+tspg).addClass('ui-state-disabled').removeClass('ui-state-hover');
|
|
if(ts.p.toppager) { $("#next_t"+tspg_t+", #last_t"+tspg_t).addClass('ui-state-disabled').removeClass('ui-state-hover'); }
|
|
} else {
|
|
$("#next"+tspg+", #last"+tspg).removeClass('ui-state-disabled');
|
|
if(ts.p.toppager) { $("#next_t"+tspg_t+", #last_t"+tspg_t).removeClass('ui-state-disabled'); }
|
|
}
|
|
}
|
|
}
|
|
if(rn===true && ts.p.rownumbers === true) {
|
|
$(">td.jqgrid-rownum",ts.rows).each(function(i){
|
|
$(this).html(base+1+i);
|
|
});
|
|
}
|
|
if(dnd && ts.p.jqgdnd) { $(ts).jqGrid('gridDnD','updateDnD');}
|
|
$(ts).triggerHandler("jqGridGridComplete");
|
|
if($.isFunction(ts.p.gridComplete)) {ts.p.gridComplete.call(ts);}
|
|
$(ts).triggerHandler("jqGridAfterGridComplete");
|
|
},
|
|
beginReq = function() {
|
|
ts.grid.hDiv.loading = true;
|
|
if(ts.p.hiddengrid) { return;}
|
|
switch(ts.p.loadui) {
|
|
case "disable":
|
|
break;
|
|
case "enable":
|
|
$("#load_"+$.jgrid.jqID(ts.p.id)).show();
|
|
break;
|
|
case "block":
|
|
$("#lui_"+$.jgrid.jqID(ts.p.id)).show();
|
|
$("#load_"+$.jgrid.jqID(ts.p.id)).show();
|
|
break;
|
|
}
|
|
},
|
|
endReq = function() {
|
|
ts.grid.hDiv.loading = false;
|
|
switch(ts.p.loadui) {
|
|
case "disable":
|
|
break;
|
|
case "enable":
|
|
$("#load_"+$.jgrid.jqID(ts.p.id)).hide();
|
|
break;
|
|
case "block":
|
|
$("#lui_"+$.jgrid.jqID(ts.p.id)).hide();
|
|
$("#load_"+$.jgrid.jqID(ts.p.id)).hide();
|
|
break;
|
|
}
|
|
},
|
|
populate = function (npage) {
|
|
if(!ts.grid.hDiv.loading) {
|
|
var pvis = ts.p.scroll && npage === false,
|
|
prm = {}, dt, dstr, pN=ts.p.prmNames;
|
|
if(ts.p.page <=0) { ts.p.page = Math.min(1,ts.p.lastpage); }
|
|
if(pN.search !== null) {prm[pN.search] = ts.p.search;} if(pN.nd !== null) {prm[pN.nd] = new Date().getTime();}
|
|
if(pN.rows !== null) {prm[pN.rows]= ts.p.rowNum;} if(pN.page !== null) {prm[pN.page]= ts.p.page;}
|
|
if(pN.sort !== null) {prm[pN.sort]= ts.p.sortname;} if(pN.order !== null) {prm[pN.order]= ts.p.sortorder;}
|
|
if(ts.p.rowTotal !== null && pN.totalrows !== null) { prm[pN.totalrows]= ts.p.rowTotal; }
|
|
var lcf = $.isFunction(ts.p.loadComplete), lc = lcf ? ts.p.loadComplete : null;
|
|
var adjust = 0;
|
|
npage = npage || 1;
|
|
if (npage > 1) {
|
|
if(pN.npage !== null) {
|
|
prm[pN.npage] = npage;
|
|
adjust = npage - 1;
|
|
npage = 1;
|
|
} else {
|
|
lc = function(req) {
|
|
ts.p.page++;
|
|
ts.grid.hDiv.loading = false;
|
|
if (lcf) {
|
|
ts.p.loadComplete.call(ts,req);
|
|
}
|
|
populate(npage-1);
|
|
};
|
|
}
|
|
} else if (pN.npage !== null) {
|
|
delete ts.p.postData[pN.npage];
|
|
}
|
|
if(ts.p.grouping) {
|
|
$(ts).jqGrid('groupingSetup');
|
|
var grp = ts.p.groupingView, gi, gs="";
|
|
for(gi=0;gi<grp.groupField.length;gi++) {
|
|
var index = grp.groupField[gi];
|
|
$.each(ts.p.colModel, function(cmIndex, cmValue) {
|
|
if (cmValue.name === index && cmValue.index){
|
|
index = cmValue.index;
|
|
}
|
|
} );
|
|
gs += index +" "+grp.groupOrder[gi]+", ";
|
|
}
|
|
prm[pN.sort] = gs + prm[pN.sort];
|
|
}
|
|
$.extend(ts.p.postData,prm);
|
|
var rcnt = !ts.p.scroll ? 1 : ts.rows.length-1;
|
|
var bfr = $(ts).triggerHandler("jqGridBeforeRequest");
|
|
if (bfr === false || bfr === 'stop') { return; }
|
|
if ($.isFunction(ts.p.datatype)) { ts.p.datatype.call(ts,ts.p.postData,"load_"+ts.p.id, rcnt, npage, adjust); return;}
|
|
if ($.isFunction(ts.p.beforeRequest)) {
|
|
bfr = ts.p.beforeRequest.call(ts);
|
|
if(bfr === undefined) { bfr = true; }
|
|
if ( bfr === false ) { return; }
|
|
}
|
|
dt = ts.p.datatype.toLowerCase();
|
|
switch(dt)
|
|
{
|
|
case "json":
|
|
case "jsonp":
|
|
case "xml":
|
|
case "script":
|
|
$.ajax($.extend({
|
|
url:ts.p.url,
|
|
type:ts.p.mtype,
|
|
dataType: dt ,
|
|
data: $.isFunction(ts.p.serializeGridData)? ts.p.serializeGridData.call(ts,ts.p.postData) : ts.p.postData,
|
|
success:function(data,st, xhr) {
|
|
if ($.isFunction(ts.p.beforeProcessing)) {
|
|
if (ts.p.beforeProcessing.call(ts, data, st, xhr) === false) {
|
|
endReq();
|
|
return;
|
|
}
|
|
}
|
|
if(dt === "xml") { addXmlData(data,ts.grid.bDiv,rcnt,npage>1,adjust); }
|
|
else { addJSONData(data,ts.grid.bDiv,rcnt,npage>1,adjust); }
|
|
$(ts).triggerHandler("jqGridLoadComplete", [data]);
|
|
if(lc) { lc.call(ts,data); }
|
|
$(ts).triggerHandler("jqGridAfterLoadComplete", [data]);
|
|
if (pvis) { ts.grid.populateVisible(); }
|
|
if( ts.p.loadonce || ts.p.treeGrid) {ts.p.datatype = "local";}
|
|
data=null;
|
|
if (npage === 1) { endReq(); }
|
|
},
|
|
error:function(xhr,st,err){
|
|
if($.isFunction(ts.p.loadError)) { ts.p.loadError.call(ts,xhr,st,err); }
|
|
if (npage === 1) { endReq(); }
|
|
xhr=null;
|
|
},
|
|
beforeSend: function(xhr, settings ){
|
|
var gotoreq = true;
|
|
if($.isFunction(ts.p.loadBeforeSend)) {
|
|
gotoreq = ts.p.loadBeforeSend.call(ts,xhr, settings);
|
|
}
|
|
if(gotoreq === undefined) { gotoreq = true; }
|
|
if(gotoreq === false) {
|
|
return false;
|
|
}
|
|
beginReq();
|
|
}
|
|
},$.jgrid.ajaxOptions, ts.p.ajaxGridOptions));
|
|
break;
|
|
case "xmlstring":
|
|
beginReq();
|
|
dstr = typeof ts.p.datastr !== 'string' ? ts.p.datastr : $.parseXML(ts.p.datastr);
|
|
addXmlData(dstr,ts.grid.bDiv);
|
|
$(ts).triggerHandler("jqGridLoadComplete", [dstr]);
|
|
if(lcf) {ts.p.loadComplete.call(ts,dstr);}
|
|
$(ts).triggerHandler("jqGridAfterLoadComplete", [dstr]);
|
|
ts.p.datatype = "local";
|
|
ts.p.datastr = null;
|
|
endReq();
|
|
break;
|
|
case "jsonstring":
|
|
beginReq();
|
|
if(typeof ts.p.datastr === 'string') { dstr = $.jgrid.parse(ts.p.datastr); }
|
|
else { dstr = ts.p.datastr; }
|
|
addJSONData(dstr,ts.grid.bDiv);
|
|
$(ts).triggerHandler("jqGridLoadComplete", [dstr]);
|
|
if(lcf) {ts.p.loadComplete.call(ts,dstr);}
|
|
$(ts).triggerHandler("jqGridAfterLoadComplete", [dstr]);
|
|
ts.p.datatype = "local";
|
|
ts.p.datastr = null;
|
|
endReq();
|
|
break;
|
|
case "local":
|
|
case "clientside":
|
|
beginReq();
|
|
ts.p.datatype = "local";
|
|
var req = addLocalData();
|
|
addJSONData(req,ts.grid.bDiv,rcnt,npage>1,adjust);
|
|
$(ts).triggerHandler("jqGridLoadComplete", [req]);
|
|
if(lc) { lc.call(ts,req); }
|
|
$(ts).triggerHandler("jqGridAfterLoadComplete", [req]);
|
|
if (pvis) { ts.grid.populateVisible(); }
|
|
endReq();
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
setHeadCheckBox = function ( checked ) {
|
|
$('#cb_'+$.jgrid.jqID(ts.p.id),ts.grid.hDiv)[ts.p.useProp ? 'prop': 'attr']("checked", checked);
|
|
var fid = ts.p.frozenColumns ? ts.p.id+"_frozen" : "";
|
|
if(fid) {
|
|
$('#cb_'+$.jgrid.jqID(ts.p.id),ts.grid.fhDiv)[ts.p.useProp ? 'prop': 'attr']("checked", checked);
|
|
}
|
|
},
|
|
setPager = function (pgid, tp){
|
|
// TBD - consider escaping pgid with pgid = $.jgrid.jqID(pgid);
|
|
var sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>",
|
|
pginp = "",
|
|
pgl="<table cellspacing='0' cellpadding='0' border='0' style='table-layout:auto;' class='ui-pg-table'><tbody><tr>",
|
|
str="", pgcnt, lft, cent, rgt, twd, tdw, i,
|
|
clearVals = function(onpaging){
|
|
var ret;
|
|
if ($.isFunction(ts.p.onPaging) ) { ret = ts.p.onPaging.call(ts,onpaging); }
|
|
if(ret==='stop') {return false;}
|
|
ts.p.selrow = null;
|
|
if(ts.p.multiselect) {ts.p.selarrrow =[]; setHeadCheckBox( false );}
|
|
ts.p.savedRow = [];
|
|
return true;
|
|
};
|
|
pgid = pgid.substr(1);
|
|
tp += "_" + pgid;
|
|
pgcnt = "pg_"+pgid;
|
|
lft = pgid+"_left"; cent = pgid+"_center"; rgt = pgid+"_right";
|
|
$("#"+$.jgrid.jqID(pgid) )
|
|
.append("<div id='"+pgcnt+"' class='ui-pager-control' role='group'><table cellspacing='0' cellpadding='0' border='0' class='ui-pg-table' style='width:100%;table-layout:fixed;height:100%;' role='row'><tbody><tr><td id='"+lft+"' align='left'></td><td id='"+cent+"' align='center' style='white-space:pre;'></td><td id='"+rgt+"' align='right'></td></tr></tbody></table></div>")
|
|
.attr("dir","ltr"); //explicit setting
|
|
if(ts.p.rowList.length >0){
|
|
str = "<td dir='"+dir+"'>";
|
|
str +="<select class='ui-pg-selbox' role='listbox'>";
|
|
for(i=0;i<ts.p.rowList.length;i++){
|
|
str +="<option role=\"option\" value=\""+ts.p.rowList[i]+"\""+((ts.p.rowNum === ts.p.rowList[i])?" selected=\"selected\"":"")+">"+ts.p.rowList[i]+"</option>";
|
|
}
|
|
str +="</select></td>";
|
|
}
|
|
if(dir==="rtl") { pgl += str; }
|
|
if(ts.p.pginput===true) { pginp= "<td dir='"+dir+"'>"+$.jgrid.format(ts.p.pgtext || "","<input class='ui-pg-input' type='text' size='2' maxlength='7' value='0' role='textbox'/>","<span id='sp_1_"+$.jgrid.jqID(pgid)+"'></span>")+"</td>";}
|
|
if(ts.p.pgbuttons===true) {
|
|
var po=["first"+tp,"prev"+tp, "next"+tp,"last"+tp]; if(dir==="rtl") { po.reverse(); }
|
|
pgl += "<td id='" + po[0] + "' class='ui-pg-button'><span class='fa fa-angle-double-left'></span></td>";
|
|
pgl += "<td id='" + po[1] + "' class='ui-pg-button'><span class='fa fa-angle-left'></span></td>";
|
|
pgl += pginp !== "" ? sep+pginp+sep:"";
|
|
pgl += "<td id='" + po[2] + "' class='ui-pg-button'><span class='fa fa-angle-right'></span></td>";
|
|
pgl += "<td id='" + po[3] + "' class='ui-pg-button'><span class='fa fa-angle-double-right'></span></td>";
|
|
} else if (pginp !== "") { pgl += pginp; }
|
|
if(dir==="ltr") { pgl += str; }
|
|
pgl += "</tr></tbody></table>";
|
|
if(ts.p.viewrecords===true) {$("td#"+pgid+"_"+ts.p.recordpos,"#"+pgcnt).append("<div dir='"+dir+"' style='text-align:"+ts.p.recordpos+"' class='ui-paging-info'></div>");}
|
|
$("td#"+pgid+"_"+ts.p.pagerpos,"#"+pgcnt).append(pgl);
|
|
tdw = $(".ui-jqgrid").css("font-size") || "11px";
|
|
$(document.body).append("<div id='testpg' class='ui-jqgrid ui-widget ui-widget-content' style='font-size:"+tdw+";visibility:hidden;' ></div>");
|
|
twd = $(pgl).clone().appendTo("#testpg").width();
|
|
$("#testpg").remove();
|
|
if(twd > 0) {
|
|
if(pginp !== "") { twd += 50; } //should be param
|
|
$("td#"+pgid+"_"+ts.p.pagerpos,"#"+pgcnt).width(twd);
|
|
}
|
|
ts.p._nvtd = [];
|
|
ts.p._nvtd[0] = twd ? Math.floor((ts.p.width - twd)/2) : Math.floor(ts.p.width/3);
|
|
ts.p._nvtd[1] = 0;
|
|
pgl=null;
|
|
$('.ui-pg-selbox',"#"+pgcnt).bind('change',function() {
|
|
if(!clearVals('records')) { return false; }
|
|
ts.p.page = Math.round(ts.p.rowNum*(ts.p.page-1)/this.value-0.5)+1;
|
|
ts.p.rowNum = this.value;
|
|
if(ts.p.pager) { $('.ui-pg-selbox',ts.p.pager).val(this.value); }
|
|
if(ts.p.toppager) { $('.ui-pg-selbox',ts.p.toppager).val(this.value); }
|
|
populate();
|
|
return false;
|
|
});
|
|
if(ts.p.pgbuttons===true) {
|
|
$(".ui-pg-button","#"+pgcnt).hover(function(){
|
|
if($(this).hasClass('ui-state-disabled')) {
|
|
this.style.cursor='default';
|
|
} else {
|
|
$(this).addClass('ui-state-hover');
|
|
this.style.cursor='pointer';
|
|
}
|
|
},function() {
|
|
if(!$(this).hasClass('ui-state-disabled')) {
|
|
$(this).removeClass('ui-state-hover');
|
|
this.style.cursor= "default";
|
|
}
|
|
});
|
|
$("#first"+$.jgrid.jqID(tp)+", #prev"+$.jgrid.jqID(tp)+", #next"+$.jgrid.jqID(tp)+", #last"+$.jgrid.jqID(tp)).click( function() {
|
|
var cp = intNum(ts.p.page,1),
|
|
last = intNum(ts.p.lastpage,1), selclick = false,
|
|
fp=true, pp=true, np=true,lp=true;
|
|
if(last ===0 || last===1) {fp=false;pp=false;np=false;lp=false; }
|
|
else if( last>1 && cp >=1) {
|
|
if( cp === 1) { fp=false; pp=false; }
|
|
//else if( cp>1 && cp <last){ }
|
|
else if( cp===last){ np=false;lp=false; }
|
|
} else if( last>1 && cp===0 ) { np=false;lp=false; cp=last-1;}
|
|
if(!clearVals(this.id)) { return false; }
|
|
if( this.id === 'first'+tp && fp ) { ts.p.page=1; selclick=true;}
|
|
if( this.id === 'prev'+tp && pp) { ts.p.page=(cp-1); selclick=true;}
|
|
if( this.id === 'next'+tp && np) { ts.p.page=(cp+1); selclick=true;}
|
|
if( this.id === 'last'+tp && lp) { ts.p.page=last; selclick=true;}
|
|
if(selclick) {
|
|
populate();
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
if(ts.p.pginput===true) {
|
|
$('input.ui-pg-input',"#"+pgcnt).keypress( function(e) {
|
|
var key = e.charCode || e.keyCode || 0;
|
|
if (key === 13) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
if(!clearVals('user')) { return false; }
|
|
$(this).val( intNum( $(this).val(), 1));
|
|
ts.p.page = ($(this).val()>0) ? $(this).val():ts.p.page;
|
|
populate();
|
|
return false;
|
|
}
|
|
return this;
|
|
}).on("keydown", function () {
|
|
event.stopPropagation();
|
|
});
|
|
}
|
|
},
|
|
multiSort = function(iCol, obj ) {
|
|
var splas, sort="", cm = ts.p.colModel, fs=false, ls,
|
|
selTh = ts.p.frozenColumns ? obj : ts.grid.headers[iCol].el, so="";
|
|
$("span.ui-grid-ico-sort",selTh).addClass('ui-state-disabled');
|
|
$(selTh).attr("aria-selected","false");
|
|
|
|
if(cm[iCol].lso) {
|
|
if(cm[iCol].lso==="asc") {
|
|
cm[iCol].lso += "-desc";
|
|
so = "desc";
|
|
} else if(cm[iCol].lso==="desc") {
|
|
cm[iCol].lso += "-asc";
|
|
so = "asc";
|
|
} else if(cm[iCol].lso==="asc-desc" || cm[iCol].lso==="desc-asc") {
|
|
cm[iCol].lso="";
|
|
}
|
|
} else {
|
|
cm[iCol].lso = so = cm[iCol].firstsortorder || 'asc';
|
|
}
|
|
if( so ) {
|
|
$("span.s-ico",selTh).show();
|
|
$("span.ui-icon-"+so,selTh).removeClass('ui-state-disabled');
|
|
$(selTh).attr("aria-selected","true");
|
|
} else {
|
|
if(!ts.p.viewsortcols[0]) {
|
|
$("span.s-ico",selTh).hide();
|
|
}
|
|
}
|
|
ts.p.sortorder = "";
|
|
$.each(cm, function(i){
|
|
if(this.lso) {
|
|
if(i>0 && fs) {
|
|
sort += ", ";
|
|
}
|
|
splas = this.lso.split("-");
|
|
sort += cm[i].index || cm[i].name;
|
|
sort += " "+splas[splas.length-1];
|
|
fs = true;
|
|
ts.p.sortorder = splas[splas.length-1];
|
|
}
|
|
});
|
|
ls = sort.lastIndexOf(ts.p.sortorder);
|
|
sort = sort.substring(0, ls);
|
|
ts.p.sortname = sort;
|
|
},
|
|
sortData = function (index, idxcol,reload,sor, obj){
|
|
if(!ts.p.colModel[idxcol].sortable) { return; }
|
|
if(ts.p.savedRow.length > 0) {return;}
|
|
if(!reload) {
|
|
if( ts.p.lastsort === idxcol ) {
|
|
if( ts.p.sortorder === 'asc') {
|
|
ts.p.sortorder = 'desc';
|
|
} else if(ts.p.sortorder === 'desc') { ts.p.sortorder = 'asc';}
|
|
} else { ts.p.sortorder = ts.p.colModel[idxcol].firstsortorder || 'asc'; }
|
|
ts.p.page = 1;
|
|
}
|
|
if(ts.p.multiSort) {
|
|
multiSort( idxcol, obj);
|
|
} else {
|
|
if(sor) {
|
|
if(ts.p.lastsort === idxcol && ts.p.sortorder === sor && !reload) { return; }
|
|
ts.p.sortorder = sor;
|
|
}
|
|
var previousSelectedTh = ts.grid.headers[ts.p.lastsort].el, newSelectedTh = ts.p.frozenColumns ? obj : ts.grid.headers[idxcol].el;
|
|
|
|
$("span.ui-grid-ico-sort",previousSelectedTh).addClass('ui-state-disabled');
|
|
$(previousSelectedTh).attr("aria-selected","false");
|
|
if(ts.p.frozenColumns) {
|
|
ts.grid.fhDiv.find("span.ui-grid-ico-sort").addClass('ui-state-disabled');
|
|
ts.grid.fhDiv.find("th").attr("aria-selected","false");
|
|
}
|
|
$("span.ui-icon-"+ts.p.sortorder,newSelectedTh).removeClass('ui-state-disabled');
|
|
$(newSelectedTh).attr("aria-selected","true");
|
|
if(!ts.p.viewsortcols[0]) {
|
|
if(ts.p.lastsort !== idxcol) {
|
|
if(ts.p.frozenColumns){
|
|
ts.grid.fhDiv.find("span.s-ico").hide();
|
|
}
|
|
$("span.s-ico",previousSelectedTh).hide();
|
|
$("span.s-ico",newSelectedTh).show();
|
|
}
|
|
}
|
|
index = index.substring(5 + ts.p.id.length + 1); // bad to be changed!?!
|
|
ts.p.sortname = ts.p.colModel[idxcol].index || index;
|
|
}
|
|
if ($(ts).triggerHandler("jqGridSortCol", [ts.p.sortname, idxcol, ts.p.sortorder]) === 'stop') {
|
|
ts.p.lastsort = idxcol;
|
|
return;
|
|
}
|
|
if($.isFunction(ts.p.onSortCol)) {if (ts.p.onSortCol.call(ts, ts.p.sortname, idxcol, ts.p.sortorder)==='stop') {ts.p.lastsort = idxcol; return;}}
|
|
if(ts.p.datatype === "local") {
|
|
if(ts.p.deselectAfterSort) {$(ts).jqGrid("resetSelection");}
|
|
} else {
|
|
ts.p.selrow = null;
|
|
if(ts.p.multiselect){setHeadCheckBox( false );}
|
|
ts.p.selarrrow =[];
|
|
ts.p.savedRow =[];
|
|
}
|
|
if(ts.p.scroll) {
|
|
var sscroll = ts.grid.bDiv.scrollLeft;
|
|
emptyRows.call(ts, true, false);
|
|
ts.grid.hDiv.scrollLeft = sscroll;
|
|
}
|
|
if(ts.p.subGrid && ts.p.datatype === 'local') {
|
|
$("td.sgexpanded","#"+$.jgrid.jqID(ts.p.id)).each(function(){
|
|
$(this).trigger("click");
|
|
});
|
|
}
|
|
populate();
|
|
ts.p.lastsort = idxcol;
|
|
if(ts.p.sortname !== index && idxcol) {ts.p.lastsort = idxcol;}
|
|
},
|
|
setColWidth = function () {
|
|
var initwidth = 0, brd=$.jgrid.cell_width? 0: intNum(ts.p.cellLayout,0), vc=0, lvc, scw=intNum(ts.p.scrollOffset,0),cw,hs=false,aw,gw=0,cr;
|
|
$.each(ts.p.colModel, function() {
|
|
if(this.hidden === undefined) {this.hidden=false;}
|
|
if(ts.p.grouping && ts.p.autowidth) {
|
|
var ind = $.inArray(this.name, ts.p.groupingView.groupField);
|
|
if(ind >= 0 && ts.p.groupingView.groupColumnShow.length > ind) {
|
|
this.hidden = !ts.p.groupingView.groupColumnShow[ind];
|
|
}
|
|
}
|
|
this.widthOrg = cw = intNum(this.width,0);
|
|
if(this.hidden===false){
|
|
initwidth += cw+brd;
|
|
if(this.fixed) {
|
|
gw += cw+brd;
|
|
} else {
|
|
vc++;
|
|
}
|
|
}
|
|
});
|
|
if(isNaN(ts.p.width)) {
|
|
ts.p.width = initwidth + ((ts.p.shrinkToFit ===false && !isNaN(ts.p.height)) ? scw : 0);
|
|
}
|
|
grid.width = ts.p.width;
|
|
ts.p.tblwidth = initwidth;
|
|
if(ts.p.shrinkToFit ===false && ts.p.forceFit === true) {ts.p.forceFit=false;}
|
|
if(ts.p.shrinkToFit===true && vc > 0) {
|
|
aw = grid.width-brd*vc-gw;
|
|
if(!isNaN(ts.p.height)) {
|
|
aw -= scw;
|
|
hs = true;
|
|
}
|
|
initwidth =0;
|
|
$.each(ts.p.colModel, function(i) {
|
|
if(this.hidden === false && !this.fixed){
|
|
cw = Math.round(aw*this.width/(ts.p.tblwidth-brd*vc-gw));
|
|
this.width =cw;
|
|
initwidth += cw;
|
|
lvc = i;
|
|
}
|
|
});
|
|
cr =0;
|
|
if (hs) {
|
|
if(grid.width-gw-(initwidth+brd*vc) !== scw){
|
|
cr = grid.width-gw-(initwidth+brd*vc)-scw;
|
|
}
|
|
} else if(!hs && Math.abs(grid.width-gw-(initwidth+brd*vc)) !== 1) {
|
|
cr = grid.width-gw-(initwidth+brd*vc);
|
|
}
|
|
ts.p.colModel[lvc].width += cr;
|
|
ts.p.tblwidth = initwidth+cr+brd*vc+gw;
|
|
if(ts.p.tblwidth > ts.p.width) {
|
|
ts.p.colModel[lvc].width -= (ts.p.tblwidth - parseInt(ts.p.width,10));
|
|
ts.p.tblwidth = ts.p.width;
|
|
}
|
|
}
|
|
},
|
|
nextVisible= function(iCol) {
|
|
var ret = iCol, j=iCol, i;
|
|
for (i = iCol+1;i<ts.p.colModel.length;i++){
|
|
if(ts.p.colModel[i].hidden !== true ) {
|
|
j=i; break;
|
|
}
|
|
}
|
|
return j-ret;
|
|
},
|
|
getOffset = function (iCol) {
|
|
var $th = $(ts.grid.headers[iCol].el), ret = [$th.position().left + $th.outerWidth()];
|
|
if(ts.p.direction==="rtl") { ret[0] = ts.p.width - ret[0]; }
|
|
ret[0] -= ts.grid.bDiv.scrollLeft;
|
|
ret.push($(ts.grid.hDiv).position().top);
|
|
ret.push($(ts.grid.bDiv).offset().top - $(ts.grid.hDiv).offset().top + $(ts.grid.bDiv).height());
|
|
return ret;
|
|
},
|
|
getColumnHeaderIndex = function (th) {
|
|
var i, headers = ts.grid.headers, ci = $.jgrid.getCellIndex(th);
|
|
for (i = 0; i < headers.length; i++) {
|
|
if (th === headers[i].el) {
|
|
ci = i;
|
|
break;
|
|
}
|
|
}
|
|
return ci;
|
|
};
|
|
this.p.id = this.id;
|
|
if ($.inArray(ts.p.multikey,sortkeys) === -1 ) {ts.p.multikey = false;}
|
|
ts.p.keyIndex=false;
|
|
ts.p.keyName=false;
|
|
for (i=0; i<ts.p.colModel.length;i++) {
|
|
ts.p.colModel[i] = $.extend(true, {}, ts.p.cmTemplate, ts.p.colModel[i].template || {}, ts.p.colModel[i]);
|
|
if (ts.p.keyIndex === false && ts.p.colModel[i].key===true) {
|
|
ts.p.keyIndex = i;
|
|
}
|
|
}
|
|
ts.p.sortorder = ts.p.sortorder.toLowerCase();
|
|
$.jgrid.cell_width = $.jgrid.cellWidth();
|
|
if(ts.p.grouping===true) {
|
|
ts.p.scroll = false;
|
|
ts.p.rownumbers = false;
|
|
//ts.p.subGrid = false; expiremental
|
|
ts.p.treeGrid = false;
|
|
ts.p.gridview = true;
|
|
}
|
|
if(this.p.treeGrid === true) {
|
|
try { $(this).jqGrid("setTreeGrid");} catch (_) {}
|
|
if(ts.p.datatype !== "local") { ts.p.localReader = {id: "_id_"}; }
|
|
}
|
|
if(this.p.subGrid) {
|
|
try { $(ts).jqGrid("setSubGrid");} catch (s){}
|
|
}
|
|
if(this.p.multiselect) {
|
|
this.p.colNames.unshift("<input role='checkbox' id='cb_"+this.p.id+"' class='cbox' type='checkbox'/>");
|
|
this.p.colModel.unshift({name:'cb',width:$.jgrid.cell_width ? ts.p.multiselectWidth+ts.p.cellLayout : ts.p.multiselectWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:'center',fixed:true});
|
|
}
|
|
if(this.p.rownumbers) {
|
|
this.p.colNames.unshift("");
|
|
this.p.colModel.unshift({name:'rn',width:ts.p.rownumWidth,sortable:false,resizable:false,hidedlg:true,search:false,align:'center',fixed:true});
|
|
}
|
|
ts.p.xmlReader = $.extend(true,{
|
|
root: "rows",
|
|
row: "row",
|
|
page: "rows>page",
|
|
total: "rows>total",
|
|
records : "rows>records",
|
|
repeatitems: true,
|
|
cell: "cell",
|
|
id: "[id]",
|
|
userdata: "userdata",
|
|
subgrid: {root:"rows", row: "row", repeatitems: true, cell:"cell"}
|
|
}, ts.p.xmlReader);
|
|
ts.p.jsonReader = $.extend(true,{
|
|
root: "rows",
|
|
page: "page",
|
|
total: "total",
|
|
records: "records",
|
|
repeatitems: true,
|
|
cell: "cell",
|
|
id: "id",
|
|
userdata: "userdata",
|
|
subgrid: {root:"rows", repeatitems: true, cell:"cell"}
|
|
},ts.p.jsonReader);
|
|
ts.p.localReader = $.extend(true,{
|
|
root: "rows",
|
|
page: "page",
|
|
total: "total",
|
|
records: "records",
|
|
repeatitems: false,
|
|
cell: "cell",
|
|
id: "id",
|
|
userdata: "userdata",
|
|
subgrid: {root:"rows", repeatitems: true, cell:"cell"}
|
|
},ts.p.localReader);
|
|
if(ts.p.scroll){
|
|
ts.p.pgbuttons = false; ts.p.pginput=false; ts.p.rowList=[];
|
|
}
|
|
if(ts.p.data.length) { refreshIndex(); }
|
|
var thead = "<thead><tr class='ui-jqgrid-labels' role='rowheader'>",
|
|
tdc, idn, w, res, sort,
|
|
td, ptr, tbody, imgs,iac="",idc="",sortarr=[], sortord=[], sotmp=[];
|
|
if(ts.p.shrinkToFit===true && ts.p.forceFit===true) {
|
|
for (i=ts.p.colModel.length-1;i>=0;i--){
|
|
if(!ts.p.colModel[i].hidden) {
|
|
ts.p.colModel[i].resizable=false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(ts.p.viewsortcols[1] === 'horizontal') {iac=" ui-i-asc";idc=" ui-i-desc";}
|
|
tdc = isMSIE ? "class='ui-th-div-ie'" :"";
|
|
imgs = "<span class='s-ico' style='display:none'><span sort='asc' class='ui-grid-ico-sort ui-icon-asc"+iac+" ui-state-disabled ui-icon ui-icon-triangle-1-n ui-sort-"+dir+"'></span>";
|
|
imgs += "<span sort='desc' class='ui-grid-ico-sort ui-icon-desc"+idc+" ui-state-disabled ui-icon ui-icon-triangle-1-s ui-sort-"+dir+"'></span></span>";
|
|
if(ts.p.multiSort) {
|
|
sortarr = ts.p.sortname.split(",");
|
|
for (i=0; i<sortarr.length; i++) {
|
|
sotmp = $.trim(sortarr[i]).split(" ");
|
|
sortarr[i] = $.trim(sotmp[0]);
|
|
sortord[i] = sotmp[1] ? $.trim(sotmp[1]) : ts.p.sortorder || "asc";
|
|
}
|
|
}
|
|
for(i=0;i<this.p.colNames.length;i++){
|
|
var tooltip = ts.p.headertitles ? (" title=\""+$.jgrid.stripHtml(ts.p.colNames[i])+"\"") :"";
|
|
thead += "<th id='"+ts.p.id+"_"+ts.p.colModel[i].name+"' role='columnheader' class='ui-state-default ui-th-column ui-th-"+dir+"'"+ tooltip+">";
|
|
idn = ts.p.colModel[i].index || ts.p.colModel[i].name;
|
|
thead += "<div id='jqgh_"+ts.p.id+"_"+ts.p.colModel[i].name+"' "+tdc+">"+ts.p.colNames[i];
|
|
if(!ts.p.colModel[i].width) { ts.p.colModel[i].width = 150; }
|
|
else { ts.p.colModel[i].width = parseInt(ts.p.colModel[i].width,10); }
|
|
if(typeof ts.p.colModel[i].title !== "boolean") { ts.p.colModel[i].title = true; }
|
|
ts.p.colModel[i].lso = "";
|
|
if (idn === ts.p.sortname) {
|
|
ts.p.lastsort = i;
|
|
}
|
|
if(ts.p.multiSort) {
|
|
sotmp = $.inArray(idn,sortarr);
|
|
if( sotmp !== -1 ) {
|
|
ts.p.colModel[i].lso = sortord[sotmp];
|
|
}
|
|
}
|
|
thead += imgs+"</div></th>";
|
|
}
|
|
thead += "</tr></thead>";
|
|
imgs = null;
|
|
$(this).append(thead);
|
|
$("thead tr:first th",this).hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-hover');});
|
|
if(this.p.multiselect) {
|
|
var emp=[], chk;
|
|
$('#cb_'+$.jgrid.jqID(ts.p.id),this).bind('click',function(){
|
|
ts.p.selarrrow = [];
|
|
var froz = ts.p.frozenColumns === true ? ts.p.id + "_frozen" : "";
|
|
if (this.checked) {
|
|
$(ts.rows).each(function(i) {
|
|
if (i>0) {
|
|
if(!$(this).hasClass("ui-subgrid") && !$(this).hasClass("jqgroup") && !$(this).hasClass('ui-state-disabled')){
|
|
$("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id) )[ts.p.useProp ? 'prop': 'attr']("checked",true);
|
|
$(this).addClass("ui-state-highlight").attr("aria-selected","true");
|
|
ts.p.selarrrow.push(this.id);
|
|
ts.p.selrow = this.id;
|
|
if(froz) {
|
|
$("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id), ts.grid.fbDiv )[ts.p.useProp ? 'prop': 'attr']("checked",true);
|
|
$("#"+$.jgrid.jqID(this.id), ts.grid.fbDiv).addClass("ui-state-highlight");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
chk=true;
|
|
emp=[];
|
|
}
|
|
else {
|
|
$(ts.rows).each(function(i) {
|
|
if(i>0) {
|
|
if(!$(this).hasClass("ui-subgrid") && !$(this).hasClass('ui-state-disabled')){
|
|
$("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id) )[ts.p.useProp ? 'prop': 'attr']("checked", false);
|
|
$(this).removeClass("ui-state-highlight").attr("aria-selected","false");
|
|
emp.push(this.id);
|
|
if(froz) {
|
|
$("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(this.id), ts.grid.fbDiv )[ts.p.useProp ? 'prop': 'attr']("checked",false);
|
|
$("#"+$.jgrid.jqID(this.id), ts.grid.fbDiv).removeClass("ui-state-highlight");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
ts.p.selrow = null;
|
|
chk=false;
|
|
}
|
|
$(ts).triggerHandler("jqGridSelectAll", [chk ? ts.p.selarrrow : emp, chk]);
|
|
if($.isFunction(ts.p.onSelectAll)) {ts.p.onSelectAll.call(ts, chk ? ts.p.selarrrow : emp,chk);}
|
|
});
|
|
}
|
|
|
|
if(ts.p.autowidth===true) {
|
|
var pw = $(eg).innerWidth();
|
|
ts.p.width = pw > 0? pw: 'nw';
|
|
}
|
|
setColWidth();
|
|
$(eg).css("width",grid.width+"px").append("<div class='ui-jqgrid-resize-mark' id='rs_m"+ts.p.id+"'> </div>");
|
|
$(gv).css("width",grid.width+"px");
|
|
thead = $("thead:first",ts).get(0);
|
|
var tfoot = "";
|
|
if(ts.p.footerrow) { tfoot += "<table role='grid' style='width:"+ts.p.tblwidth+"px' class='ui-jqgrid-ftable' cellspacing='0' cellpadding='0' border='0'><tbody><tr role='row' class='ui-widget-content footrow footrow-"+dir+"'>"; }
|
|
var thr = $("tr:first",thead),
|
|
firstr = "<tr class='jqgfirstrow' role='row' style='height:auto'>";
|
|
ts.p.disableClick=false;
|
|
$("th",thr).each(function ( j ) {
|
|
w = ts.p.colModel[j].width;
|
|
if(ts.p.colModel[j].resizable === undefined) {ts.p.colModel[j].resizable = true;}
|
|
if(ts.p.colModel[j].resizable){
|
|
res = document.createElement("span");
|
|
$(res).html(" ").addClass('ui-jqgrid-resize ui-jqgrid-resize-'+dir)
|
|
.css("cursor","col-resize");
|
|
$(this).addClass(ts.p.resizeclass);
|
|
} else {
|
|
res = "";
|
|
}
|
|
$(this).css("width",w+"px").prepend(res);
|
|
res = null;
|
|
var hdcol = "";
|
|
if( ts.p.colModel[j].hidden ) {
|
|
$(this).css("display","none");
|
|
hdcol = "display:none;";
|
|
}
|
|
firstr += "<td role='gridcell' style='height:0px;width:"+w+"px;"+hdcol+"'></td>";
|
|
grid.headers[j] = { width: w, el: this };
|
|
sort = ts.p.colModel[j].sortable;
|
|
if( typeof sort !== 'boolean') {ts.p.colModel[j].sortable = true; sort=true;}
|
|
var nm = ts.p.colModel[j].name;
|
|
if( !(nm === 'cb' || nm==='subgrid' || nm==='rn') ) {
|
|
if(ts.p.viewsortcols[2]){
|
|
$(">div",this).addClass('ui-jqgrid-sortable');
|
|
}
|
|
}
|
|
if(sort) {
|
|
if(ts.p.multiSort) {
|
|
if(ts.p.viewsortcols[0]) {
|
|
$("div span.s-ico",this).show();
|
|
if(ts.p.colModel[j].lso){
|
|
$("div span.ui-icon-"+ts.p.colModel[j].lso,this).removeClass("ui-state-disabled");
|
|
}
|
|
} else if( ts.p.colModel[j].lso) {
|
|
$("div span.s-ico",this).show();
|
|
$("div span.ui-icon-"+ts.p.colModel[j].lso,this).removeClass("ui-state-disabled");
|
|
}
|
|
} else {
|
|
if(ts.p.viewsortcols[0]) {$("div span.s-ico",this).show(); if(j===ts.p.lastsort){ $("div span.ui-icon-"+ts.p.sortorder,this).removeClass("ui-state-disabled");}}
|
|
else if( j === ts.p.lastsort) {$("div span.s-ico",this).show();$("div span.ui-icon-"+ts.p.sortorder,this).removeClass("ui-state-disabled");}
|
|
}
|
|
}
|
|
if(ts.p.footerrow) { tfoot += "<td role='gridcell' "+formatCol(j,0,'', null, '', false)+"> </td>"; }
|
|
}).mousedown(function(e) {
|
|
if ($(e.target).closest("th>span.ui-jqgrid-resize").length !== 1) { return; }
|
|
var ci = getColumnHeaderIndex(this);
|
|
if(ts.p.forceFit===true) {ts.p.nv= nextVisible(ci);}
|
|
grid.dragStart(ci, e, getOffset(ci));
|
|
return false;
|
|
}).click(function(e) {
|
|
if (ts.p.disableClick) {
|
|
ts.p.disableClick = false;
|
|
return false;
|
|
}
|
|
var s = "th>div.ui-jqgrid-sortable",r,d;
|
|
if (!ts.p.viewsortcols[2]) { s = "th>div>span>span.ui-grid-ico-sort"; }
|
|
var t = $(e.target).closest(s);
|
|
if (t.length !== 1) { return; }
|
|
var ci;
|
|
if(ts.p.frozenColumns) {
|
|
var tid = $(this)[0].id.substring( ts.p.id.length + 1 );
|
|
$(ts.p.colModel).each(function(i){
|
|
if (this.name === tid) {
|
|
ci = i;return false;
|
|
}
|
|
});
|
|
} else {
|
|
ci = getColumnHeaderIndex(this);
|
|
}
|
|
if (!ts.p.viewsortcols[2]) { r=true;d=t.attr("sort"); }
|
|
if(ci != null){
|
|
sortData( $('div',this)[0].id, ci, r, d, this);
|
|
}
|
|
return false;
|
|
});
|
|
if (ts.p.sortable && $.fn.sortable) {
|
|
try {
|
|
$(ts).jqGrid("sortableColumns", thr);
|
|
} catch (e){}
|
|
}
|
|
if(ts.p.footerrow) { tfoot += "</tr></tbody></table>"; }
|
|
firstr += "</tr>";
|
|
tbody = document.createElement("tbody");
|
|
this.appendChild(tbody);
|
|
$(this).addClass('ui-jqgrid-btable').append(firstr);
|
|
firstr = null;
|
|
var hTable = $("<table class='ui-jqgrid-htable' style='width:"+ts.p.tblwidth+"px' role='grid' aria-labelledby='gbox_"+this.id+"' cellspacing='0' cellpadding='0' border='0'></table>").append(thead),
|
|
hg = (ts.p.caption && ts.p.hiddengrid===true) ? true : false,
|
|
hb = $("<div class='ui-jqgrid-hbox" + (dir==="rtl" ? "-rtl" : "" )+"'></div>");
|
|
thead = null;
|
|
grid.hDiv = document.createElement("div");
|
|
$(grid.hDiv)
|
|
.css({ width: grid.width+"px"})
|
|
.addClass("ui-state-default ui-jqgrid-hdiv")
|
|
.append(hb);
|
|
$(hb).append(hTable);
|
|
hTable = null;
|
|
if(hg) { $(grid.hDiv).hide(); }
|
|
if(ts.p.pager){
|
|
// TBD -- escape ts.p.pager here?
|
|
if(typeof ts.p.pager === "string") {if(ts.p.pager.substr(0,1) !== "#") { ts.p.pager = "#"+ts.p.pager;} }
|
|
else { ts.p.pager = "#"+ $(ts.p.pager).attr("id");}
|
|
$(ts.p.pager).css({width: grid.width+"px"}).addClass('ui-state-default ui-jqgrid-pager ui-corner-bottom').appendTo(eg);
|
|
if(hg) {$(ts.p.pager).hide();}
|
|
setPager(ts.p.pager,'');
|
|
}
|
|
if( ts.p.cellEdit === false && ts.p.hoverrows === true) {
|
|
$(ts).bind('mouseover',function(e) {
|
|
ptr = $(e.target).closest("tr.jqgrow");
|
|
if($(ptr).attr("class") !== "ui-subgrid") {
|
|
$(ptr).addClass("ui-state-hover");
|
|
}
|
|
}).bind('mouseout',function(e) {
|
|
ptr = $(e.target).closest("tr.jqgrow");
|
|
$(ptr).removeClass("ui-state-hover");
|
|
});
|
|
}
|
|
var ri,ci, tdHtml;
|
|
$(ts).before(grid.hDiv).click(function(e) {
|
|
td = e.target;
|
|
ptr = $(td,ts.rows).closest("tr.jqgrow");
|
|
if($(ptr).length === 0 || ptr[0].className.indexOf( 'ui-state-disabled' ) > -1 || ($(td,ts).closest("table.ui-jqgrid-btable").attr('id') || '').replace("_frozen","") !== ts.id ) {
|
|
return this;
|
|
}
|
|
var scb = $(td).hasClass("cbox"),
|
|
cSel = $(ts).triggerHandler("jqGridBeforeSelectRow", [ptr[0].id, e]);
|
|
cSel = (cSel === false || cSel === 'stop') ? false : true;
|
|
if(cSel && $.isFunction(ts.p.beforeSelectRow)) { cSel = ts.p.beforeSelectRow.call(ts,ptr[0].id, e); }
|
|
if (td.tagName === 'A' || ((td.tagName === 'INPUT' || td.tagName === 'TEXTAREA' || td.tagName === 'OPTION' || td.tagName === 'SELECT' ) && !scb) ) { return; }
|
|
if(cSel === true) {
|
|
ri = ptr[0].id;
|
|
ci = $.jgrid.getCellIndex(td);
|
|
tdHtml = $(td).closest("td,th").html();
|
|
$(ts).triggerHandler("jqGridCellSelect", [ri,ci,tdHtml,e]);
|
|
if($.isFunction(ts.p.onCellSelect)) {
|
|
ts.p.onCellSelect.call(ts,ri,ci,tdHtml,e);
|
|
}
|
|
if(ts.p.cellEdit === true) {
|
|
if(ts.p.multiselect && scb){
|
|
$(ts).jqGrid("setSelection", ri ,true,e);
|
|
} else {
|
|
ri = ptr[0].rowIndex;
|
|
try {$(ts).jqGrid("editCell",ri,ci,true);} catch (_) {}
|
|
}
|
|
} else if ( !ts.p.multikey ) {
|
|
if(ts.p.multiselect && ts.p.multiboxonly) {
|
|
if(scb){$(ts).jqGrid("setSelection",ri,true,e);}
|
|
else {
|
|
var frz = ts.p.frozenColumns ? ts.p.id+"_frozen" : "";
|
|
$(ts.p.selarrrow).each(function(i,n){
|
|
var trid = $(ts).jqGrid('getGridRowById',n);
|
|
$( trid ).removeClass("ui-state-highlight");
|
|
$("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(n))[ts.p.useProp ? 'prop': 'attr']("checked", false);
|
|
if(frz) {
|
|
$("#"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(frz)).removeClass("ui-state-highlight");
|
|
$("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(frz))[ts.p.useProp ? 'prop': 'attr']("checked", false);
|
|
}
|
|
});
|
|
ts.p.selarrrow = [];
|
|
$(ts).jqGrid("setSelection",ri,true,e);
|
|
}
|
|
} else {
|
|
$(ts).jqGrid("setSelection",ri,true,e);
|
|
}
|
|
} else {
|
|
if(e[ts.p.multikey]) {
|
|
$(ts).jqGrid("setSelection",ri,true,e);
|
|
} else if(ts.p.multiselect && scb) {
|
|
scb = $("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+ri).is(":checked");
|
|
$("#jqg_"+$.jgrid.jqID(ts.p.id)+"_"+ri)[ts.p.useProp ? 'prop' : 'attr']("checked", scb);
|
|
}
|
|
}
|
|
}
|
|
}).bind('reloadGrid', function(e,opts) {
|
|
if(ts.p.treeGrid ===true) { ts.p.datatype = ts.p.treedatatype;}
|
|
if (opts && opts.current) {
|
|
ts.grid.selectionPreserver(ts);
|
|
}
|
|
if(ts.p.datatype==="local"){ $(ts).jqGrid("resetSelection"); if(ts.p.data.length) { refreshIndex();} }
|
|
else if(!ts.p.treeGrid) {
|
|
ts.p.selrow=null;
|
|
if(ts.p.multiselect) {ts.p.selarrrow =[];setHeadCheckBox(false);}
|
|
ts.p.savedRow = [];
|
|
}
|
|
if(ts.p.scroll) {emptyRows.call(ts, true, false);}
|
|
if (opts && opts.page) {
|
|
var page = opts.page;
|
|
if (page > ts.p.lastpage) { page = ts.p.lastpage; }
|
|
if (page < 1) { page = 1; }
|
|
ts.p.page = page;
|
|
if (ts.grid.prevRowHeight) {
|
|
ts.grid.bDiv.scrollTop = (page - 1) * ts.grid.prevRowHeight * ts.p.rowNum;
|
|
} else {
|
|
ts.grid.bDiv.scrollTop = 0;
|
|
}
|
|
}
|
|
if (ts.grid.prevRowHeight && ts.p.scroll) {
|
|
delete ts.p.lastpage;
|
|
ts.grid.populateVisible();
|
|
} else {
|
|
ts.grid.populate();
|
|
}
|
|
if(ts.p._inlinenav===true) {$(ts).jqGrid('showAddEditButtons');}
|
|
return false;
|
|
})
|
|
.dblclick(function(e) {
|
|
td = e.target;
|
|
ptr = $(td,ts.rows).closest("tr.jqgrow");
|
|
if($(ptr).length === 0 ){return;}
|
|
ri = ptr[0].rowIndex;
|
|
ci = $.jgrid.getCellIndex(td);
|
|
$(ts).triggerHandler("jqGridDblClickRow", [$(ptr).attr("id"),ri,ci,e]);
|
|
if ($.isFunction(ts.p.ondblClickRow)) { ts.p.ondblClickRow.call(ts,$(ptr).attr("id"),ri,ci, e); }
|
|
})
|
|
.bind('contextmenu', function(e) {
|
|
td = e.target;
|
|
ptr = $(td,ts.rows).closest("tr.jqgrow");
|
|
if($(ptr).length === 0 ){return;}
|
|
if(!ts.p.multiselect) { $(ts).jqGrid("setSelection",ptr[0].id,true,e); }
|
|
ri = ptr[0].rowIndex;
|
|
ci = $.jgrid.getCellIndex(td);
|
|
$(ts).triggerHandler("jqGridRightClickRow", [$(ptr).attr("id"),ri,ci,e]);
|
|
if ($.isFunction(ts.p.onRightClickRow)) { ts.p.onRightClickRow.call(ts,$(ptr).attr("id"),ri,ci, e); }
|
|
});
|
|
grid.bDiv = document.createElement("div");
|
|
if(isMSIE) { if(String(ts.p.height).toLowerCase() === "auto") { ts.p.height = "100%"; } }
|
|
$(grid.bDiv)
|
|
.append($('<div style="position:relative;'+(isMSIE && $.jgrid.msiever() < 8 ? "height:0.01%;" : "")+'"></div>').append('<div></div>').append(this))
|
|
.addClass("ui-jqgrid-bdiv")
|
|
.css({ height: ts.p.height+(isNaN(ts.p.height)?"":"px"), width: (grid.width)+"px"})
|
|
.scroll(grid.scrollGrid);
|
|
$("table:first",grid.bDiv).css({width:ts.p.tblwidth+"px"});
|
|
if( !$.support.tbody ) { //IE
|
|
if( $("tbody",this).length === 2 ) { $("tbody:gt(0)",this).remove();}
|
|
}
|
|
if(ts.p.multikey){
|
|
if( $.jgrid.msie) {
|
|
$(grid.bDiv).bind("selectstart",function(){return false;});
|
|
} else {
|
|
$(grid.bDiv).bind("mousedown",function(){return false;});
|
|
}
|
|
}
|
|
if(hg) {$(grid.bDiv).hide();}
|
|
grid.cDiv = document.createElement("div");
|
|
var arf = ts.p.hidegrid===true ? $("<a role='link' class='ui-jqgrid-titlebar-close HeaderButton' />").hover(
|
|
function(){ arf.addClass('ui-state-hover');},
|
|
function() {arf.removeClass('ui-state-hover');})
|
|
.append("<span class='ui-icon ui-icon-circle-triangle-n'></span>").css((dir==="rtl"?"left":"right"),"0px") : "";
|
|
$(grid.cDiv).append(arf).append("<span class='ui-jqgrid-title"+(dir==="rtl" ? "-rtl" :"" )+"'>"+ts.p.caption+"</span>")
|
|
.addClass("ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix");
|
|
$(grid.cDiv).insertBefore(grid.hDiv);
|
|
if( ts.p.toolbar[0] ) {
|
|
grid.uDiv = document.createElement("div");
|
|
if(ts.p.toolbar[1] === "top") {$(grid.uDiv).insertBefore(grid.hDiv);}
|
|
else if (ts.p.toolbar[1]==="bottom" ) {$(grid.uDiv).insertAfter(grid.hDiv);}
|
|
if(ts.p.toolbar[1]==="both") {
|
|
grid.ubDiv = document.createElement("div");
|
|
$(grid.uDiv).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id).insertBefore(grid.hDiv);
|
|
$(grid.ubDiv).addClass("ui-userdata ui-state-default").attr("id","tb_"+this.id).insertAfter(grid.hDiv);
|
|
if(hg) {$(grid.ubDiv).hide();}
|
|
} else {
|
|
$(grid.uDiv).width(grid.width).addClass("ui-userdata ui-state-default").attr("id","t_"+this.id);
|
|
}
|
|
if(hg) {$(grid.uDiv).hide();}
|
|
}
|
|
if(ts.p.toppager) {
|
|
ts.p.toppager = $.jgrid.jqID(ts.p.id)+"_toppager";
|
|
grid.topDiv = $("<div id='"+ts.p.toppager+"'></div>")[0];
|
|
ts.p.toppager = "#"+ts.p.toppager;
|
|
$(grid.topDiv).addClass('ui-state-default ui-jqgrid-toppager').width(grid.width).insertBefore(grid.hDiv);
|
|
setPager(ts.p.toppager,'_t');
|
|
}
|
|
if(ts.p.footerrow) {
|
|
grid.sDiv = $("<div class='ui-jqgrid-sdiv'></div>")[0];
|
|
hb = $("<div class='ui-jqgrid-hbox"+(dir==="rtl"?"-rtl":"")+"'></div>");
|
|
$(grid.sDiv).append(hb).width(grid.width).insertAfter(grid.hDiv);
|
|
$(hb).append(tfoot);
|
|
grid.footers = $(".ui-jqgrid-ftable",grid.sDiv)[0].rows[0].cells;
|
|
if(ts.p.rownumbers) { grid.footers[0].className = 'ui-state-default jqgrid-rownum'; }
|
|
if(hg) {$(grid.sDiv).hide();}
|
|
}
|
|
hb = null;
|
|
if(ts.p.caption) {
|
|
var tdt = ts.p.datatype;
|
|
if(ts.p.hidegrid===true) {
|
|
$(".ui-jqgrid-titlebar-close",grid.cDiv).click( function(e){
|
|
var onHdCl = $.isFunction(ts.p.onHeaderClick),
|
|
elems = ".ui-jqgrid-bdiv, .ui-jqgrid-hdiv, .ui-jqgrid-pager, .ui-jqgrid-sdiv",
|
|
counter, self = this;
|
|
if(ts.p.toolbar[0]===true) {
|
|
if( ts.p.toolbar[1]==='both') {
|
|
elems += ', #' + $(grid.ubDiv).attr('id');
|
|
}
|
|
elems += ', #' + $(grid.uDiv).attr('id');
|
|
}
|
|
counter = $(elems,"#gview_"+$.jgrid.jqID(ts.p.id)).length;
|
|
|
|
if(ts.p.gridstate === 'visible') {
|
|
$(elems,"#gbox_"+$.jgrid.jqID(ts.p.id)).slideUp("fast", function() {
|
|
counter--;
|
|
if (counter === 0) {
|
|
$("span",self).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
|
|
ts.p.gridstate = 'hidden';
|
|
if($("#gbox_"+$.jgrid.jqID(ts.p.id)).hasClass("ui-resizable")) { $(".ui-resizable-handle","#gbox_"+$.jgrid.jqID(ts.p.id)).hide(); }
|
|
$(ts).triggerHandler("jqGridHeaderClick", [ts.p.gridstate,e]);
|
|
if(onHdCl) {if(!hg) {ts.p.onHeaderClick.call(ts,ts.p.gridstate,e);}}
|
|
}
|
|
});
|
|
} else if(ts.p.gridstate === 'hidden'){
|
|
$(elems,"#gbox_"+$.jgrid.jqID(ts.p.id)).slideDown("fast", function() {
|
|
counter--;
|
|
if (counter === 0) {
|
|
$("span",self).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");
|
|
if(hg) {ts.p.datatype = tdt;populate();hg=false;}
|
|
ts.p.gridstate = 'visible';
|
|
if($("#gbox_"+$.jgrid.jqID(ts.p.id)).hasClass("ui-resizable")) { $(".ui-resizable-handle","#gbox_"+$.jgrid.jqID(ts.p.id)).show(); }
|
|
$(ts).triggerHandler("jqGridHeaderClick", [ts.p.gridstate,e]);
|
|
if(onHdCl) {if(!hg) {ts.p.onHeaderClick.call(ts,ts.p.gridstate,e);}}
|
|
}
|
|
});
|
|
}
|
|
return false;
|
|
});
|
|
if(hg) {ts.p.datatype="local"; $(".ui-jqgrid-titlebar-close",grid.cDiv).trigger("click");}
|
|
}
|
|
} else {$(grid.cDiv).hide();}
|
|
$(grid.hDiv).after(grid.bDiv)
|
|
.mousemove(function (e) {
|
|
if(grid.resizing){grid.dragMove(e);return false;}
|
|
});
|
|
$(".ui-jqgrid-labels",grid.hDiv).bind("selectstart", function () { return false; });
|
|
$(document).bind( "mouseup.jqGrid" + ts.p.id, function () {
|
|
if(grid.resizing) { grid.dragEnd(); return false;}
|
|
return true;
|
|
});
|
|
ts.formatCol = formatCol;
|
|
ts.sortData = sortData;
|
|
ts.updatepager = updatepager;
|
|
ts.refreshIndex = refreshIndex;
|
|
ts.setHeadCheckBox = setHeadCheckBox;
|
|
ts.constructTr = constructTr;
|
|
ts.formatter = function ( rowId, cellval , colpos, rwdat, act){return formatter(rowId, cellval , colpos, rwdat, act);};
|
|
$.extend(grid,{populate : populate, emptyRows: emptyRows, beginReq: beginReq, endReq: endReq});
|
|
this.grid = grid;
|
|
ts.addXmlData = function(d) {addXmlData(d,ts.grid.bDiv);};
|
|
ts.addJSONData = function(d) {addJSONData(d,ts.grid.bDiv);};
|
|
this.grid.cols = this.rows[0].cells;
|
|
$(ts).triggerHandler("jqGridInitGrid");
|
|
if ($.isFunction( ts.p.onInitGrid )) { ts.p.onInitGrid.call(ts); }
|
|
|
|
populate();ts.p.hiddengrid=false;
|
|
});
|
|
};
|
|
$.jgrid.extend({
|
|
getGridParam : function(pName) {
|
|
var $t = this[0];
|
|
if (!$t || !$t.grid) {return;}
|
|
if (!pName) { return $t.p; }
|
|
return $t.p[pName] !== undefined ? $t.p[pName] : null;
|
|
},
|
|
setGridParam : function (newParams){
|
|
return this.each(function(){
|
|
if (this.grid && typeof newParams === 'object') {$.extend(true,this.p,newParams);}
|
|
});
|
|
},
|
|
getGridRowById: function ( rowid ) {
|
|
var row;
|
|
this.each( function(){
|
|
try {
|
|
row = this.rows.namedItem( rowid );
|
|
} catch ( e ) {
|
|
row = $(this.grid.bDiv).find( "#" + $.jgrid.jqID( rowid ));
|
|
}
|
|
});
|
|
return row;
|
|
},
|
|
getDataIDs : function () {
|
|
var ids=[], i=0, len, j=0;
|
|
this.each(function(){
|
|
len = this.rows.length;
|
|
if(len && len>0){
|
|
while(i<len) {
|
|
if($(this.rows[i]).hasClass('jqgrow')) {
|
|
ids[j] = this.rows[i].id;
|
|
j++;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
});
|
|
return ids;
|
|
},
|
|
setSelection : function(selection,onsr, e) {
|
|
return this.each(function(){
|
|
var $t = this, stat,pt, ner, ia, tpsr, fid;
|
|
if(selection === undefined) { return; }
|
|
onsr = onsr === false ? false : true;
|
|
pt=$($t).jqGrid('getGridRowById', selection);
|
|
if(!pt || !pt.className || pt.className.indexOf( 'ui-state-disabled' ) > -1 ) { return; }
|
|
function scrGrid(iR){
|
|
var ch = $($t.grid.bDiv)[0].clientHeight,
|
|
st = $($t.grid.bDiv)[0].scrollTop,
|
|
rpos = $($t.rows[iR]).position().top,
|
|
rh = $t.rows[iR].clientHeight;
|
|
if(rpos+rh >= ch+st) { $($t.grid.bDiv)[0].scrollTop = rpos-(ch+st)+rh+st; }
|
|
else if(rpos < ch+st) {
|
|
if(rpos < st) {
|
|
$($t.grid.bDiv)[0].scrollTop = rpos;
|
|
}
|
|
}
|
|
}
|
|
if($t.p.scrollrows===true) {
|
|
ner = $($t).jqGrid('getGridRowById',selection).rowIndex;
|
|
if(ner >=0 ){
|
|
scrGrid(ner);
|
|
}
|
|
}
|
|
if($t.p.frozenColumns === true ) {
|
|
fid = $t.p.id+"_frozen";
|
|
}
|
|
if(!$t.p.multiselect) {
|
|
if(pt.className !== "ui-subgrid") {
|
|
if( $t.p.selrow !== pt.id) {
|
|
$( $($t).jqGrid('getGridRowById', $t.p.selrow) ).removeClass("ui-state-highlight").attr({"aria-selected":"false", "tabindex" : "-1"});
|
|
$(pt).addClass("ui-state-highlight").attr({"aria-selected":"true", "tabindex" : "0"});//.focus();
|
|
if(fid) {
|
|
$("#"+$.jgrid.jqID($t.p.selrow), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight");
|
|
$("#"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid)).addClass("ui-state-highlight");
|
|
}
|
|
stat = true;
|
|
} else {
|
|
stat = false;
|
|
}
|
|
$t.p.selrow = pt.id;
|
|
if( onsr ) {
|
|
$($t).triggerHandler("jqGridSelectRow", [pt.id, stat, e]);
|
|
if( $t.p.onSelectRow) { $t.p.onSelectRow.call($t, pt.id, stat, e); }
|
|
}
|
|
}
|
|
} else {
|
|
//unselect selectall checkbox when deselecting a specific row
|
|
$t.setHeadCheckBox( false );
|
|
$t.p.selrow = pt.id;
|
|
ia = $.inArray($t.p.selrow,$t.p.selarrrow);
|
|
if ( ia === -1 ){
|
|
if(pt.className !== "ui-subgrid") { $(pt).addClass("ui-state-highlight").attr("aria-selected","true");}
|
|
stat = true;
|
|
$t.p.selarrrow.push($t.p.selrow);
|
|
} else {
|
|
if(pt.className !== "ui-subgrid") { $(pt).removeClass("ui-state-highlight").attr("aria-selected","false");}
|
|
stat = false;
|
|
$t.p.selarrrow.splice(ia,1);
|
|
tpsr = $t.p.selarrrow[0];
|
|
$t.p.selrow = (tpsr === undefined) ? null : tpsr;
|
|
}
|
|
$("#jqg_"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(pt.id))[$t.p.useProp ? 'prop': 'attr']("checked",stat);
|
|
if(fid) {
|
|
if(ia === -1) {
|
|
$("#"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid)).addClass("ui-state-highlight");
|
|
} else {
|
|
$("#"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight");
|
|
}
|
|
$("#jqg_"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(selection), "#"+$.jgrid.jqID(fid))[$t.p.useProp ? 'prop': 'attr']("checked",stat);
|
|
}
|
|
if( onsr ) {
|
|
$($t).triggerHandler("jqGridSelectRow", [pt.id, stat, e]);
|
|
if( $t.p.onSelectRow) { $t.p.onSelectRow.call($t, pt.id , stat, e); }
|
|
}
|
|
}
|
|
});
|
|
},
|
|
resetSelection : function( rowid ){
|
|
return this.each(function(){
|
|
var t = this, sr, fid;
|
|
if( t.p.frozenColumns === true ) {
|
|
fid = t.p.id+"_frozen";
|
|
}
|
|
if(rowid !== undefined ) {
|
|
sr = rowid === t.p.selrow ? t.p.selrow : rowid;
|
|
$("#"+$.jgrid.jqID(t.p.id)+" tbody:first tr#"+$.jgrid.jqID(sr)).removeClass("ui-state-highlight").attr("aria-selected","false");
|
|
if (fid) { $("#"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight"); }
|
|
if(t.p.multiselect) {
|
|
$("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID(t.p.id))[t.p.useProp ? 'prop': 'attr']("checked",false);
|
|
if(fid) { $("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(sr), "#"+$.jgrid.jqID(fid))[t.p.useProp ? 'prop': 'attr']("checked",false); }
|
|
t.setHeadCheckBox( false);
|
|
}
|
|
sr = null;
|
|
} else if(!t.p.multiselect) {
|
|
if(t.p.selrow) {
|
|
$("#"+$.jgrid.jqID(t.p.id)+" tbody:first tr#"+$.jgrid.jqID(t.p.selrow)).removeClass("ui-state-highlight").attr("aria-selected","false");
|
|
if(fid) { $("#"+$.jgrid.jqID(t.p.selrow), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight"); }
|
|
t.p.selrow = null;
|
|
}
|
|
} else {
|
|
$(t.p.selarrrow).each(function(i,n){
|
|
$( $(t).jqGrid('getGridRowById',n) ).removeClass("ui-state-highlight").attr("aria-selected","false");
|
|
$("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(n))[t.p.useProp ? 'prop': 'attr']("checked",false);
|
|
if(fid) {
|
|
$("#"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(fid)).removeClass("ui-state-highlight");
|
|
$("#jqg_"+$.jgrid.jqID(t.p.id)+"_"+$.jgrid.jqID(n), "#"+$.jgrid.jqID(fid))[t.p.useProp ? 'prop': 'attr']("checked",false);
|
|
}
|
|
});
|
|
t.setHeadCheckBox( false );
|
|
t.p.selarrrow = [];
|
|
}
|
|
if(t.p.cellEdit === true) {
|
|
if(parseInt(t.p.iCol,10)>=0 && parseInt(t.p.iRow,10)>=0) {
|
|
$("td:eq("+t.p.iCol+")",t.rows[t.p.iRow]).removeClass("edit-cell ui-state-highlight");
|
|
$(t.rows[t.p.iRow]).removeClass("selected-row ui-state-hover");
|
|
}
|
|
}
|
|
t.p.savedRow = [];
|
|
});
|
|
},
|
|
getRowData : function( rowid ) {
|
|
var res = {}, resall, getall=false, len, j=0;
|
|
this.each(function(){
|
|
var $t = this,nm,ind;
|
|
if(rowid === undefined) {
|
|
getall = true;
|
|
resall = [];
|
|
len = $t.rows.length;
|
|
} else {
|
|
ind = $($t).jqGrid('getGridRowById', rowid);
|
|
if(!ind) { return res; }
|
|
len = 2;
|
|
}
|
|
while(j<len){
|
|
if(getall) { ind = $t.rows[j]; }
|
|
if( $(ind).hasClass('jqgrow') ) {
|
|
$('td[role="gridcell"]',ind).each( function(i) {
|
|
nm = $t.p.colModel[i].name;
|
|
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
|
|
if($t.p.treeGrid===true && nm === $t.p.ExpandColumn) {
|
|
res[nm] = $.jgrid.htmlDecode($("span:first",this).html());
|
|
} else {
|
|
try {
|
|
res[nm] = $.unformat.call($t,this,{rowId:ind.id, colModel:$t.p.colModel[i]},i);
|
|
} catch (e){
|
|
res[nm] = $.jgrid.htmlDecode($(this).html());
|
|
}
|
|
}
|
|
}
|
|
});
|
|
if(getall) { resall.push(res); res={}; }
|
|
}
|
|
j++;
|
|
}
|
|
});
|
|
return resall || res;
|
|
},
|
|
delRowData : function(rowid) {
|
|
var success = false, rowInd, ia;
|
|
this.each(function() {
|
|
var $t = this;
|
|
rowInd = $($t).jqGrid('getGridRowById', rowid);
|
|
if(!rowInd) {return false;}
|
|
$(rowInd).remove();
|
|
$t.p.records--;
|
|
$t.p.reccount--;
|
|
$t.updatepager(true,false);
|
|
success=true;
|
|
if($t.p.multiselect) {
|
|
ia = $.inArray(rowid,$t.p.selarrrow);
|
|
if(ia !== -1) { $t.p.selarrrow.splice(ia,1);}
|
|
}
|
|
if ($t.p.multiselect && $t.p.selarrrow.length > 0) {
|
|
$t.p.selrow = $t.p.selarrrow[$t.p.selarrrow.length-1];
|
|
} else {
|
|
$t.p.selrow = null;
|
|
}
|
|
if($t.p.datatype === 'local') {
|
|
var id = $.jgrid.stripPref($t.p.idPrefix, rowid),
|
|
pos = $t.p._index[id];
|
|
if(pos !== undefined) {
|
|
$t.p.data.splice(pos,1);
|
|
$t.refreshIndex();
|
|
}
|
|
}
|
|
if( $t.p.altRows === true && success ) {
|
|
var cn = $t.p.altclass;
|
|
$($t.rows).each(function(i){
|
|
if(i % 2 === 1) { $(this).addClass(cn); }
|
|
else { $(this).removeClass(cn); }
|
|
});
|
|
}
|
|
});
|
|
return success;
|
|
},
|
|
setRowData : function(rowid, data, cssp) {
|
|
var nm, success=true, title;
|
|
this.each(function(){
|
|
if(!this.grid) {return false;}
|
|
var t = this, vl, ind, cp = typeof cssp, lcdata={};
|
|
ind = $(this).jqGrid('getGridRowById', rowid);
|
|
if(!ind) { return false; }
|
|
if( data ) {
|
|
try {
|
|
$(this.p.colModel).each(function(i){
|
|
nm = this.name;
|
|
var dval =$.jgrid.getAccessor(data,nm);
|
|
if( dval !== undefined) {
|
|
lcdata[nm] = this.formatter && typeof this.formatter === 'string' && this.formatter === 'date' ? $.unformat.date.call(t,dval,this) : dval;
|
|
vl = t.formatter( rowid, dval, i, data, 'edit');
|
|
title = this.title ? {"title":$.jgrid.stripHtml(vl)} : {};
|
|
if(t.p.treeGrid===true && nm === t.p.ExpandColumn) {
|
|
$("td[role='gridcell']:eq("+i+") > span:first",ind).html(vl).attr(title);
|
|
} else {
|
|
$("td[role='gridcell']:eq("+i+")",ind).html(vl).attr(title);
|
|
}
|
|
}
|
|
});
|
|
if(t.p.datatype === 'local') {
|
|
var id = $.jgrid.stripPref(t.p.idPrefix, rowid),
|
|
pos = t.p._index[id], key;
|
|
if(t.p.treeGrid) {
|
|
for(key in t.p.treeReader){
|
|
if(t.p.treeReader.hasOwnProperty(key)) {
|
|
delete lcdata[t.p.treeReader[key]];
|
|
}
|
|
}
|
|
}
|
|
if(pos !== undefined) {
|
|
t.p.data[pos] = $.extend(true, t.p.data[pos], lcdata);
|
|
}
|
|
lcdata = null;
|
|
}
|
|
} catch (e) {
|
|
success = false;
|
|
}
|
|
}
|
|
if(success) {
|
|
if(cp === 'string') {$(ind).addClass(cssp);} else if(cp === 'object') {$(ind).css(cssp);}
|
|
$(t).triggerHandler("jqGridAfterGridComplete");
|
|
}
|
|
});
|
|
return success;
|
|
},
|
|
addRowData : function(rowid,rdata,pos,src) {
|
|
if(!pos) {pos = "last";}
|
|
var success = false, nm, row, gi, si, ni,sind, i, v, prp="", aradd, cnm, cn, data, cm, id;
|
|
if(rdata) {
|
|
if($.isArray(rdata)) {
|
|
aradd=true;
|
|
pos = "last";
|
|
cnm = rowid;
|
|
} else {
|
|
rdata = [rdata];
|
|
aradd = false;
|
|
}
|
|
this.each(function() {
|
|
var t = this, datalen = rdata.length;
|
|
ni = t.p.rownumbers===true ? 1 :0;
|
|
gi = t.p.multiselect ===true ? 1 :0;
|
|
si = t.p.subGrid===true ? 1 :0;
|
|
if(!aradd) {
|
|
if(rowid !== undefined) { rowid = String(rowid);}
|
|
else {
|
|
rowid = $.jgrid.randId();
|
|
if(t.p.keyIndex !== false) {
|
|
cnm = t.p.colModel[t.p.keyIndex+gi+si+ni].name;
|
|
if(rdata[0][cnm] !== undefined) { rowid = rdata[0][cnm]; }
|
|
}
|
|
}
|
|
}
|
|
cn = t.p.altclass;
|
|
var k = 0, cna ="", lcdata = {},
|
|
air = $.isFunction(t.p.afterInsertRow) ? true : false;
|
|
while(k < datalen) {
|
|
data = rdata[k];
|
|
row=[];
|
|
if(aradd) {
|
|
try {
|
|
rowid = data[cnm];
|
|
if(rowid===undefined) {
|
|
rowid = $.jgrid.randId();
|
|
}
|
|
}
|
|
catch (e) {rowid = $.jgrid.randId();}
|
|
cna = t.p.altRows === true ? (t.rows.length-1)%2 === 0 ? cn : "" : "";
|
|
}
|
|
id = rowid;
|
|
rowid = t.p.idPrefix + rowid;
|
|
if(ni){
|
|
prp = t.formatCol(0,1,'',null,rowid, true);
|
|
row[row.length] = "<td role=\"gridcell\" class=\"ui-state-default jqgrid-rownum\" "+prp+">0</td>";
|
|
}
|
|
if(gi) {
|
|
v = "<input role=\"checkbox\" type=\"checkbox\""+" id=\"jqg_"+t.p.id+"_"+rowid+"\" class=\"cbox\"/>";
|
|
prp = t.formatCol(ni,1,'', null, rowid, true);
|
|
row[row.length] = "<td role=\"gridcell\" "+prp+">"+v+"</td>";
|
|
}
|
|
if(si) {
|
|
row[row.length] = $(t).jqGrid("addSubGridCell",gi+ni,1);
|
|
}
|
|
for(i = gi+si+ni; i < t.p.colModel.length;i++){
|
|
cm = t.p.colModel[i];
|
|
nm = cm.name;
|
|
lcdata[nm] = data[nm];
|
|
v = t.formatter( rowid, $.jgrid.getAccessor(data,nm), i, data );
|
|
prp = t.formatCol(i,1,v, data, rowid, lcdata);
|
|
row[row.length] = "<td role=\"gridcell\" "+prp+">"+v+"</td>";
|
|
}
|
|
row.unshift( t.constructTr(rowid, false, cna, lcdata, data, false ) );
|
|
row[row.length] = "</tr>";
|
|
if(t.rows.length === 0){
|
|
$("table:first",t.grid.bDiv).append(row.join(''));
|
|
} else {
|
|
switch (pos) {
|
|
case 'last':
|
|
$(t.rows[t.rows.length-1]).after(row.join(''));
|
|
sind = t.rows.length-1;
|
|
break;
|
|
case 'first':
|
|
$(t.rows[0]).after(row.join(''));
|
|
sind = 1;
|
|
break;
|
|
case 'after':
|
|
sind = $(t).jqGrid('getGridRowById', src);
|
|
if (sind) {
|
|
if($(t.rows[sind.rowIndex+1]).hasClass("ui-subgrid")) { $(t.rows[sind.rowIndex+1]).after(row); }
|
|
else { $(sind).after(row.join('')); }
|
|
sind=sind.rowIndex + 1;
|
|
}
|
|
break;
|
|
case 'before':
|
|
sind = $(t).jqGrid('getGridRowById', src);
|
|
if(sind) {
|
|
$(sind).before(row.join(''));
|
|
sind=sind.rowIndex - 1;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if(t.p.subGrid===true) {
|
|
$(t).jqGrid("addSubGrid",gi+ni, sind);
|
|
}
|
|
t.p.records++;
|
|
t.p.reccount++;
|
|
$(t).triggerHandler("jqGridAfterInsertRow", [rowid,data,data]);
|
|
if(air) { t.p.afterInsertRow.call(t,rowid,data,data); }
|
|
k++;
|
|
if(t.p.datatype === 'local') {
|
|
lcdata[t.p.localReader.id] = id;
|
|
t.p._index[id] = t.p.data.length;
|
|
t.p.data.push(lcdata);
|
|
lcdata = {};
|
|
}
|
|
}
|
|
if( t.p.altRows === true && !aradd) {
|
|
if (pos === "last") {
|
|
if ((t.rows.length-1)%2 === 1) {$(t.rows[t.rows.length-1]).addClass(cn);}
|
|
} else {
|
|
$(t.rows).each(function(i){
|
|
if(i % 2 ===1) { $(this).addClass(cn); }
|
|
else { $(this).removeClass(cn); }
|
|
});
|
|
}
|
|
}
|
|
t.updatepager(true,true);
|
|
success = true;
|
|
});
|
|
}
|
|
return success;
|
|
},
|
|
footerData : function(action,data, format) {
|
|
var nm, success=false, res={}, title;
|
|
function isEmpty(obj) {
|
|
var i;
|
|
for(i in obj) {
|
|
if (obj.hasOwnProperty(i)) { return false; }
|
|
}
|
|
return true;
|
|
}
|
|
if(action === undefined) { action = "get"; }
|
|
if(typeof format !== "boolean") { format = true; }
|
|
action = action.toLowerCase();
|
|
this.each(function(){
|
|
var t = this, vl;
|
|
if(!t.grid || !t.p.footerrow) {return false;}
|
|
if(action === "set") { if(isEmpty(data)) { return false; } }
|
|
success=true;
|
|
$(this.p.colModel).each(function(i){
|
|
nm = this.name;
|
|
if(action === "set") {
|
|
if( data[nm] !== undefined) {
|
|
vl = format ? t.formatter( "", data[nm], i, data, 'edit') : data[nm];
|
|
title = this.title ? {"title":$.jgrid.stripHtml(vl)} : {};
|
|
$("tr.footrow td:eq("+i+")",t.grid.sDiv).html(vl).attr(title);
|
|
success = true;
|
|
}
|
|
} else if(action === "get") {
|
|
res[nm] = $("tr.footrow td:eq("+i+")",t.grid.sDiv).html();
|
|
}
|
|
});
|
|
});
|
|
return action === "get" ? res : success;
|
|
},
|
|
showHideCol : function(colname,show) {
|
|
return this.each(function() {
|
|
var $t = this, fndh=false, brd=$.jgrid.cell_width ? 0: $t.p.cellLayout, cw;
|
|
if (!$t.grid ) {return;}
|
|
if( typeof colname === 'string') {colname=[colname];}
|
|
show = show !== "none" ? "" : "none";
|
|
var sw = show === "" ? true :false,
|
|
gh = $t.p.groupHeader && (typeof $t.p.groupHeader === 'object' || $.isFunction($t.p.groupHeader) );
|
|
if(gh) { $($t).jqGrid('destroyGroupHeader', false); }
|
|
$(this.p.colModel).each(function(i) {
|
|
if ($.inArray(this.name,colname) !== -1 && this.hidden === sw) {
|
|
if($t.p.frozenColumns === true && this.frozen === true) {
|
|
return true;
|
|
}
|
|
$("tr[role=rowheader]",$t.grid.hDiv).each(function(){
|
|
$(this.cells[i]).css("display", show);
|
|
});
|
|
$($t.rows).each(function(){
|
|
if (!$(this).hasClass("jqgroup")) {
|
|
$(this.cells[i]).css("display", show);
|
|
}
|
|
});
|
|
if($t.p.footerrow) { $("tr.footrow td:eq("+i+")", $t.grid.sDiv).css("display", show); }
|
|
cw = parseInt(this.width,10);
|
|
if(show === "none") {
|
|
$t.p.tblwidth -= cw+brd;
|
|
} else {
|
|
$t.p.tblwidth += cw+brd;
|
|
}
|
|
this.hidden = !sw;
|
|
fndh=true;
|
|
$($t).triggerHandler("jqGridShowHideCol", [sw,this.name,i]);
|
|
}
|
|
});
|
|
if(fndh===true) {
|
|
if($t.p.shrinkToFit === true && !isNaN($t.p.height)) { $t.p.tblwidth += parseInt($t.p.scrollOffset,10);}
|
|
$($t).jqGrid("setGridWidth",$t.p.shrinkToFit === true ? $t.p.tblwidth : $t.p.width );
|
|
}
|
|
if( gh ) {
|
|
$($t).jqGrid('setGroupHeaders',$t.p.groupHeader);
|
|
}
|
|
});
|
|
},
|
|
hideCol : function (colname) {
|
|
return this.each(function(){$(this).jqGrid("showHideCol",colname,"none");});
|
|
},
|
|
showCol : function(colname) {
|
|
return this.each(function(){$(this).jqGrid("showHideCol",colname,"");});
|
|
},
|
|
remapColumns : function(permutation, updateCells, keepHeader)
|
|
{
|
|
function resortArray(a) {
|
|
var ac;
|
|
if (a.length) {
|
|
ac = $.makeArray(a);
|
|
} else {
|
|
ac = $.extend({}, a);
|
|
}
|
|
$.each(permutation, function(i) {
|
|
a[i] = ac[this];
|
|
});
|
|
}
|
|
var ts = this.get(0);
|
|
//isUpdateCells判断排列表头还是排列数据
|
|
function resortRows(parent, clobj, isUpdateCells) {
|
|
$(">tr" + (clobj || ""), parent).each(function () {
|
|
var row = this;
|
|
var elems = $.makeArray(row.cells);
|
|
var rowId = $(row).parent().parent()[0].id;
|
|
//排列数据时跳过子表
|
|
if (rowId == ts.id && isUpdateCells) {
|
|
$.each(permutation, function() {
|
|
var e = elems[this];
|
|
if (e) {
|
|
row.appendChild(e);
|
|
}
|
|
});
|
|
}
|
|
//对表头进行排序时执行
|
|
if (!isUpdateCells) {
|
|
$.each(permutation, function () {
|
|
var e = elems[this];
|
|
if (e) {
|
|
row.appendChild(e);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
resortArray(ts.p.colModel);
|
|
resortArray(ts.p.colNames);
|
|
resortArray(ts.grid.headers);
|
|
resortRows($("thead:first", ts.grid.hDiv), keepHeader && ":not(.ui-jqgrid-labels)", false);
|
|
if (updateCells) {
|
|
resortRows($("#"+$.jgrid.jqID(ts.p.id)+" tbody:first"), ".jqgfirstrow, tr.jqgrow, tr.jqfoot", true);
|
|
}
|
|
if (ts.p.footerrow) {
|
|
resortRows($("tbody:first", ts.grid.sDiv));
|
|
}
|
|
if (ts.p.remapColumns) {
|
|
if (!ts.p.remapColumns.length){
|
|
ts.p.remapColumns = $.makeArray(permutation);
|
|
} else {
|
|
resortArray(ts.p.remapColumns);
|
|
}
|
|
}
|
|
ts.p.lastsort = $.inArray(ts.p.lastsort, permutation);
|
|
if(ts.p.treeGrid) { ts.p.expColInd = $.inArray(ts.p.expColInd, permutation); }
|
|
$(ts).triggerHandler("jqGridRemapColumns", [permutation, updateCells, keepHeader]);
|
|
},
|
|
setGridWidth : function(nwidth, shrink) {
|
|
return this.each(function(){
|
|
if (!this.grid ) {return;}
|
|
var $t = this, cw,
|
|
initwidth = 0, brd=$.jgrid.cell_width ? 0: $t.p.cellLayout, lvc, vc=0, hs=false, scw=$t.p.scrollOffset, aw, gw=0, cr;
|
|
if(typeof shrink !== 'boolean') {
|
|
shrink=$t.p.shrinkToFit;
|
|
}
|
|
if(isNaN(nwidth)) {return;}
|
|
nwidth = parseInt(nwidth,10);
|
|
$t.grid.width = $t.p.width = nwidth;
|
|
$("#gbox_"+$.jgrid.jqID($t.p.id)).css("width",nwidth+"px");
|
|
$("#gview_"+$.jgrid.jqID($t.p.id)).css("width",nwidth+"px");
|
|
$($t.grid.bDiv).css("width",nwidth+"px");
|
|
$($t.grid.hDiv).css("width",nwidth+"px");
|
|
if($t.p.pager ) {$($t.p.pager).css("width",nwidth+"px");}
|
|
if($t.p.toppager ) {$($t.p.toppager).css("width",nwidth+"px");}
|
|
if($t.p.toolbar[0] === true){
|
|
$($t.grid.uDiv).css("width",nwidth+"px");
|
|
if($t.p.toolbar[1]==="both") {$($t.grid.ubDiv).css("width",nwidth+"px");}
|
|
}
|
|
if($t.p.footerrow) { $($t.grid.sDiv).css("width",nwidth+"px"); }
|
|
if(shrink ===false && $t.p.forceFit === true) {$t.p.forceFit=false;}
|
|
if(shrink===true) {
|
|
$.each($t.p.colModel, function() {
|
|
if(this.hidden===false){
|
|
cw = this.widthOrg;
|
|
initwidth += cw+brd;
|
|
if(this.fixed) {
|
|
gw += cw+brd;
|
|
} else {
|
|
vc++;
|
|
}
|
|
}
|
|
});
|
|
if(vc === 0) { return; }
|
|
$t.p.tblwidth = initwidth;
|
|
aw = nwidth-brd*vc-gw;
|
|
if(!isNaN($t.p.height)) {
|
|
if($($t.grid.bDiv)[0].clientHeight < $($t.grid.bDiv)[0].scrollHeight || $t.rows.length === 1){
|
|
hs = true;
|
|
aw -= scw;
|
|
}
|
|
}
|
|
initwidth =0;
|
|
var cle = $t.grid.cols.length >0;
|
|
$.each($t.p.colModel, function(i) {
|
|
if(this.hidden === false && !this.fixed){
|
|
cw = this.widthOrg;
|
|
cw = Math.round(aw*cw/($t.p.tblwidth-brd*vc-gw));
|
|
if (cw < 0) { return; }
|
|
this.width =cw;
|
|
initwidth += cw;
|
|
$t.grid.headers[i].width=cw;
|
|
$t.grid.headers[i].el.style.width=cw+"px";
|
|
if($t.p.footerrow) { $t.grid.footers[i].style.width = cw+"px"; }
|
|
if(cle) { $t.grid.cols[i].style.width = cw+"px"; }
|
|
lvc = i;
|
|
}
|
|
});
|
|
|
|
if (!lvc) { return; }
|
|
|
|
cr =0;
|
|
if (hs) {
|
|
if(nwidth-gw-(initwidth+brd*vc) !== scw){
|
|
cr = nwidth-gw-(initwidth+brd*vc)-scw;
|
|
}
|
|
} else if( Math.abs(nwidth-gw-(initwidth+brd*vc)) !== 1) {
|
|
cr = nwidth-gw-(initwidth+brd*vc);
|
|
}
|
|
$t.p.colModel[lvc].width += cr;
|
|
$t.p.tblwidth = initwidth+cr+brd*vc+gw;
|
|
if($t.p.tblwidth > nwidth) {
|
|
var delta = $t.p.tblwidth - parseInt(nwidth,10);
|
|
$t.p.tblwidth = nwidth;
|
|
cw = $t.p.colModel[lvc].width = $t.p.colModel[lvc].width-delta;
|
|
} else {
|
|
cw= $t.p.colModel[lvc].width;
|
|
}
|
|
$t.grid.headers[lvc].width = cw;
|
|
$t.grid.headers[lvc].el.style.width=cw+"px";
|
|
if(cle) { $t.grid.cols[lvc].style.width = cw+"px"; }
|
|
if($t.p.footerrow) {
|
|
$t.grid.footers[lvc].style.width = cw+"px";
|
|
}
|
|
}
|
|
if($t.p.tblwidth) {
|
|
$('table:first',$t.grid.bDiv).css("width",$t.p.tblwidth+"px");
|
|
$('table:first',$t.grid.hDiv).css("width",$t.p.tblwidth+"px");
|
|
$t.grid.hDiv.scrollLeft = $t.grid.bDiv.scrollLeft;
|
|
if($t.p.footerrow) {
|
|
$('table:first',$t.grid.sDiv).css("width",$t.p.tblwidth+"px");
|
|
}
|
|
}
|
|
});
|
|
},
|
|
setGridHeight : function (nh) {
|
|
return this.each(function (){
|
|
var $t = this;
|
|
if(!$t.grid) {return;}
|
|
var bDiv = $($t.grid.bDiv);
|
|
bDiv.css({height: nh+(isNaN(nh)?"":"px")});
|
|
if($t.p.frozenColumns === true){
|
|
//follow the original set height to use 16, better scrollbar width detection
|
|
$('#'+$.jgrid.jqID($t.p.id)+"_frozen").parent().height(bDiv.height() - 16);
|
|
}
|
|
$t.p.height = nh;
|
|
if ($t.p.scroll) { $t.grid.populateVisible(); }
|
|
});
|
|
},
|
|
setCaption : function (newcap){
|
|
return this.each(function(){
|
|
this.p.caption=newcap;
|
|
$("span.ui-jqgrid-title, span.ui-jqgrid-title-rtl",this.grid.cDiv).html(newcap);
|
|
$(this.grid.cDiv).show();
|
|
});
|
|
},
|
|
setLabel : function(colname, nData, prop, attrp ){
|
|
return this.each(function(){
|
|
var $t = this, pos=-1;
|
|
if(!$t.grid) {return;}
|
|
if(colname !== undefined) {
|
|
$($t.p.colModel).each(function(i){
|
|
if (this.name === colname) {
|
|
pos = i;return false;
|
|
}
|
|
});
|
|
} else { return; }
|
|
if(pos>=0) {
|
|
var thecol = $("tr.ui-jqgrid-labels th:eq("+pos+")",$t.grid.hDiv);
|
|
if (nData){
|
|
var ico = $(".s-ico",thecol);
|
|
$("[id^=jqgh_]",thecol).empty().html(nData).append(ico);
|
|
$t.p.colNames[pos] = nData;
|
|
}
|
|
if (prop) {
|
|
if(typeof prop === 'string') {$(thecol).addClass(prop);} else {$(thecol).css(prop);}
|
|
}
|
|
if(typeof attrp === 'object') {$(thecol).attr(attrp);}
|
|
}
|
|
});
|
|
},
|
|
setCell : function(rowid,colname,nData,cssp,attrp, forceupd) {
|
|
return this.each(function(){
|
|
var $t = this, pos =-1,v, title;
|
|
if(!$t.grid) {return;}
|
|
if(isNaN(colname)) {
|
|
$($t.p.colModel).each(function(i){
|
|
if (this.name === colname) {
|
|
pos = i;return false;
|
|
}
|
|
});
|
|
} else {pos = parseInt(colname,10);}
|
|
if(pos>=0) {
|
|
var ind = $($t).jqGrid('getGridRowById', rowid);
|
|
if (ind){
|
|
var tcell = $("td:eq("+pos+")",ind);
|
|
if(nData !== "" || forceupd === true) {
|
|
v = $t.formatter(rowid, nData, pos,ind,'edit');
|
|
title = $t.p.colModel[pos].title ? {"title":$.jgrid.stripHtml(v)} : {};
|
|
if($t.p.treeGrid && $(".tree-wrap",$(tcell)).length>0) {
|
|
$("span",$(tcell)).html(v).attr(title);
|
|
} else {
|
|
$(tcell).html(v).attr(title);
|
|
}
|
|
if($t.p.datatype === "local") {
|
|
var cm = $t.p.colModel[pos], index;
|
|
nData = cm.formatter && typeof cm.formatter === 'string' && cm.formatter === 'date' ? $.unformat.date.call($t,nData,cm) : nData;
|
|
index = $t.p._index[$.jgrid.stripPref($t.p.idPrefix, rowid)];
|
|
if(index !== undefined) {
|
|
$t.p.data[index][cm.name] = nData;
|
|
}
|
|
}
|
|
}
|
|
if(typeof cssp === 'string'){
|
|
$(tcell).addClass(cssp);
|
|
} else if(cssp) {
|
|
$(tcell).css(cssp);
|
|
}
|
|
if(typeof attrp === 'object') {$(tcell).attr(attrp);}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
getCell : function(rowid,col) {
|
|
var ret = false;
|
|
this.each(function(){
|
|
var $t=this, pos=-1;
|
|
if(!$t.grid) {return;}
|
|
if(isNaN(col)) {
|
|
$($t.p.colModel).each(function(i){
|
|
if (this.name === col) {
|
|
pos = i;return false;
|
|
}
|
|
});
|
|
} else {pos = parseInt(col,10);}
|
|
if(pos>=0) {
|
|
var ind = $($t).jqGrid('getGridRowById', rowid);
|
|
if(ind) {
|
|
try {
|
|
ret = $.unformat.call($t,$("td:eq("+pos+")",ind),{rowId:ind.id, colModel:$t.p.colModel[pos]},pos);
|
|
} catch (e){
|
|
ret = $.jgrid.htmlDecode($("td:eq("+pos+")",ind).html());
|
|
}
|
|
}
|
|
}
|
|
});
|
|
return ret;
|
|
},
|
|
getCol : function (col, obj, mathopr) {
|
|
var ret = [], val, sum=0, min, max, v;
|
|
obj = typeof obj !== 'boolean' ? false : obj;
|
|
if(mathopr === undefined) { mathopr = false; }
|
|
this.each(function(){
|
|
var $t=this, pos=-1;
|
|
if(!$t.grid) {return;}
|
|
if(isNaN(col)) {
|
|
$($t.p.colModel).each(function(i){
|
|
if (this.name === col) {
|
|
pos = i;return false;
|
|
}
|
|
});
|
|
} else {pos = parseInt(col,10);}
|
|
if(pos>=0) {
|
|
var ln = $t.rows.length, i =0, dlen=0;
|
|
if (ln && ln>0){
|
|
while(i<ln){
|
|
if($($t.rows[i]).hasClass('jqgrow')) {
|
|
try {
|
|
val = $.unformat.call($t,$($t.rows[i].cells[pos]),{rowId:$t.rows[i].id, colModel:$t.p.colModel[pos]},pos);
|
|
} catch (e) {
|
|
val = $.jgrid.htmlDecode($t.rows[i].cells[pos].innerHTML);
|
|
}
|
|
if(mathopr) {
|
|
v = parseFloat(val);
|
|
if(!isNaN(v)) {
|
|
sum += v;
|
|
if (max === undefined) {max = min = v;}
|
|
min = Math.min(min, v);
|
|
max = Math.max(max, v);
|
|
dlen++;
|
|
}
|
|
}
|
|
else if(obj) { ret.push( {id:$t.rows[i].id,value:val} ); }
|
|
else { ret.push( val ); }
|
|
}
|
|
i++;
|
|
}
|
|
if(mathopr) {
|
|
switch(mathopr.toLowerCase()){
|
|
case 'sum': ret =sum; break;
|
|
case 'avg': ret = sum/dlen; break;
|
|
case 'count': ret = (ln-1); break;
|
|
case 'min': ret = min; break;
|
|
case 'max': ret = max; break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
return ret;
|
|
},
|
|
clearGridData : function(clearfooter) {
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid) {return;}
|
|
if(typeof clearfooter !== 'boolean') { clearfooter = false; }
|
|
if($t.p.deepempty) {$("#"+$.jgrid.jqID($t.p.id)+" tbody:first tr:gt(0)").remove();}
|
|
else {
|
|
var trf = $("#"+$.jgrid.jqID($t.p.id)+" tbody:first tr:first")[0];
|
|
$("#"+$.jgrid.jqID($t.p.id)+" tbody:first").empty().append(trf);
|
|
}
|
|
if($t.p.footerrow && clearfooter) { $(".ui-jqgrid-ftable td",$t.grid.sDiv).html(" "); }
|
|
$t.p.selrow = null; $t.p.selarrrow= []; $t.p.savedRow = [];
|
|
$t.p.records = 0;$t.p.page=1;$t.p.lastpage=0;$t.p.reccount=0;
|
|
$t.p.data = []; $t.p._index = {};
|
|
$t.updatepager(true,false);
|
|
});
|
|
},
|
|
getInd : function(rowid,rc){
|
|
var ret =false,rw;
|
|
this.each(function(){
|
|
rw = $(this).jqGrid('getGridRowById', rowid);
|
|
if(rw) {
|
|
ret = rc===true ? rw: rw.rowIndex;
|
|
}
|
|
});
|
|
return ret;
|
|
},
|
|
bindKeys : function( settings ){
|
|
var o = $.extend({
|
|
onEnter: null,
|
|
onSpace: null,
|
|
onLeftKey: null,
|
|
onRightKey: null,
|
|
scrollingRows : true
|
|
},settings || {});
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if( !$('body').is('[role]') ){$('body').attr('role','application');}
|
|
$t.p.scrollrows = o.scrollingRows;
|
|
$($t).keydown(function(event){
|
|
var target = $($t).find('tr[tabindex=0]')[0], id, r, mind,
|
|
expanded = $t.p.treeReader.expanded_field;
|
|
//check for arrow keys
|
|
if(target) {
|
|
mind = $t.p._index[$.jgrid.stripPref($t.p.idPrefix, target.id)];
|
|
if(event.keyCode === 37 || event.keyCode === 38 || event.keyCode === 39 || event.keyCode === 40){
|
|
// up key
|
|
if(event.keyCode === 38 ){
|
|
r = target.previousSibling;
|
|
id = "";
|
|
if(r) {
|
|
if($(r).is(":hidden")) {
|
|
while(r) {
|
|
r = r.previousSibling;
|
|
if(!$(r).is(":hidden") && $(r).hasClass('jqgrow')) {id = r.id;break;}
|
|
}
|
|
} else {
|
|
id = r.id;
|
|
}
|
|
}
|
|
$($t).jqGrid('setSelection', id, true, event);
|
|
event.preventDefault();
|
|
}
|
|
//if key is down arrow
|
|
if(event.keyCode === 40){
|
|
r = target.nextSibling;
|
|
id ="";
|
|
if(r) {
|
|
if($(r).is(":hidden")) {
|
|
while(r) {
|
|
r = r.nextSibling;
|
|
if(!$(r).is(":hidden") && $(r).hasClass('jqgrow') ) {id = r.id;break;}
|
|
}
|
|
} else {
|
|
id = r.id;
|
|
}
|
|
}
|
|
$($t).jqGrid('setSelection', id, true, event);
|
|
event.preventDefault();
|
|
}
|
|
// left
|
|
if(event.keyCode === 37 ){
|
|
if($t.p.treeGrid && $t.p.data[mind][expanded]) {
|
|
$(target).find("div.treeclick").trigger('click');
|
|
}
|
|
$($t).triggerHandler("jqGridKeyLeft", [$t.p.selrow]);
|
|
if($.isFunction(o.onLeftKey)) {
|
|
o.onLeftKey.call($t, $t.p.selrow);
|
|
}
|
|
}
|
|
// right
|
|
if(event.keyCode === 39 ){
|
|
if($t.p.treeGrid && !$t.p.data[mind][expanded]) {
|
|
$(target).find("div.treeclick").trigger('click');
|
|
}
|
|
$($t).triggerHandler("jqGridKeyRight", [$t.p.selrow]);
|
|
if($.isFunction(o.onRightKey)) {
|
|
o.onRightKey.call($t, $t.p.selrow);
|
|
}
|
|
}
|
|
}
|
|
//check if enter was pressed on a grid or treegrid node
|
|
else if( event.keyCode === 13 ){
|
|
$($t).triggerHandler("jqGridKeyEnter", [$t.p.selrow]);
|
|
if($.isFunction(o.onEnter)) {
|
|
o.onEnter.call($t, $t.p.selrow);
|
|
}
|
|
} else if(event.keyCode === 32) {
|
|
$($t).triggerHandler("jqGridKeySpace", [$t.p.selrow]);
|
|
if($.isFunction(o.onSpace)) {
|
|
o.onSpace.call($t, $t.p.selrow);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
unbindKeys : function(){
|
|
return this.each(function(){
|
|
$(this).unbind('keydown');
|
|
});
|
|
},
|
|
getLocalRow : function (rowid) {
|
|
var ret = false, ind;
|
|
this.each(function(){
|
|
if(rowid !== undefined) {
|
|
ind = this.p._index[$.jgrid.stripPref(this.p.idPrefix, rowid)];
|
|
if(ind >= 0 ) {
|
|
ret = this.p.data[ind];
|
|
}
|
|
}
|
|
});
|
|
return ret;
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false */
|
|
/*global jQuery */
|
|
(function($){
|
|
/**
|
|
* jqGrid extension for custom methods
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
*
|
|
* Wildraid wildraid@mail.ru
|
|
* Oleg Kiriljuk oleg.kiriljuk@ok-soft-gmbh.com
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
**/
|
|
"use strict";
|
|
$.jgrid.extend({
|
|
getColProp : function(colname){
|
|
var ret ={}, $t = this[0];
|
|
if ( !$t.grid ) { return false; }
|
|
var cM = $t.p.colModel, i;
|
|
for ( i=0;i<cM.length;i++ ) {
|
|
if ( cM[i].name === colname ) {
|
|
ret = cM[i];
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
},
|
|
setColProp : function(colname, obj){
|
|
//do not set width will not work
|
|
return this.each(function(){
|
|
if ( this.grid ) {
|
|
if ( obj ) {
|
|
var cM = this.p.colModel, i;
|
|
for ( i=0;i<cM.length;i++ ) {
|
|
if ( cM[i].name === colname ) {
|
|
$.extend(true, this.p.colModel[i],obj);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
sortGrid : function(colname,reload, sor){
|
|
return this.each(function(){
|
|
var $t=this,idx=-1,i, sobj=false;
|
|
if ( !$t.grid ) { return;}
|
|
if ( !colname ) { colname = $t.p.sortname; }
|
|
for ( i=0;i<$t.p.colModel.length;i++ ) {
|
|
if ( $t.p.colModel[i].index === colname || $t.p.colModel[i].name === colname ) {
|
|
idx = i;
|
|
if($t.p.frozenColumns === true && $t.p.colModel[i].frozen === true) {
|
|
sobj = $t.grid.fhDiv.find("#" + $t.p.id + "_" + colname);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
if ( idx !== -1 ){
|
|
var sort = $t.p.colModel[idx].sortable;
|
|
if ( typeof sort !== 'boolean' ) { sort = true; }
|
|
if ( typeof reload !=='boolean' ) { reload = false; }
|
|
if ( sort ) { $t.sortData("jqgh_"+$t.p.id+"_" + colname, idx, reload, sor, sobj); }
|
|
}
|
|
});
|
|
},
|
|
clearBeforeUnload : function () {
|
|
return this.each(function(){
|
|
var grid = this.grid;
|
|
grid.emptyRows.call(this, true, true); // this work quick enough and reduce the size of memory leaks if we have someone
|
|
|
|
$(document).unbind("mouseup.jqGrid" + this.p.id );
|
|
$(grid.hDiv).unbind("mousemove"); // TODO add namespace
|
|
$(this).unbind();
|
|
|
|
grid.dragEnd = null;
|
|
grid.dragMove = null;
|
|
grid.dragStart = null;
|
|
grid.emptyRows = null;
|
|
grid.populate = null;
|
|
grid.populateVisible = null;
|
|
grid.scrollGrid = null;
|
|
grid.selectionPreserver = null;
|
|
|
|
grid.bDiv = null;
|
|
grid.cDiv = null;
|
|
grid.hDiv = null;
|
|
grid.cols = null;
|
|
var i, l = grid.headers.length;
|
|
for (i = 0; i < l; i++) {
|
|
grid.headers[i].el = null;
|
|
}
|
|
|
|
this.formatCol = null;
|
|
this.sortData = null;
|
|
this.updatepager = null;
|
|
this.refreshIndex = null;
|
|
this.setHeadCheckBox = null;
|
|
this.constructTr = null;
|
|
this.formatter = null;
|
|
this.addXmlData = null;
|
|
this.addJSONData = null;
|
|
});
|
|
},
|
|
GridDestroy : function () {
|
|
return this.each(function(){
|
|
if ( this.grid ) {
|
|
if ( this.p.pager ) { // if not part of grid
|
|
$(this.p.pager).remove();
|
|
}
|
|
try {
|
|
$(this).jqGrid('clearBeforeUnload');
|
|
$("#gbox_"+$.jgrid.jqID(this.id)).remove();
|
|
} catch (_) {}
|
|
}
|
|
});
|
|
},
|
|
GridUnload : function(){
|
|
return this.each(function(){
|
|
if ( !this.grid ) {return;}
|
|
var defgrid = {id: $(this).attr('id'),cl: $(this).attr('class')};
|
|
if (this.p.pager) {
|
|
$(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom");
|
|
}
|
|
var newtable = document.createElement('table');
|
|
$(newtable).attr({id:defgrid.id});
|
|
newtable.className = defgrid.cl;
|
|
var gid = $.jgrid.jqID(this.id);
|
|
$(newtable).removeClass("ui-jqgrid-btable");
|
|
if( $(this.p.pager).parents("#gbox_"+gid).length === 1 ) {
|
|
$(newtable).insertBefore("#gbox_"+gid).show();
|
|
$(this.p.pager).insertBefore("#gbox_"+gid);
|
|
} else {
|
|
$(newtable).insertBefore("#gbox_"+gid).show();
|
|
}
|
|
$(this).jqGrid('clearBeforeUnload');
|
|
$("#gbox_"+gid).remove();
|
|
});
|
|
},
|
|
setGridState : function(state) {
|
|
return this.each(function(){
|
|
if ( !this.grid ) {return;}
|
|
var $t = this;
|
|
if(state === 'hidden'){
|
|
$(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv","#gview_"+$.jgrid.jqID($t.p.id)).slideUp("fast");
|
|
if($t.p.pager) {$($t.p.pager).slideUp("fast");}
|
|
if($t.p.toppager) {$($t.p.toppager).slideUp("fast");}
|
|
if($t.p.toolbar[0]===true) {
|
|
if( $t.p.toolbar[1] === 'both') {
|
|
$($t.grid.ubDiv).slideUp("fast");
|
|
}
|
|
$($t.grid.uDiv).slideUp("fast");
|
|
}
|
|
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$.jgrid.jqID($t.p.id)).slideUp("fast"); }
|
|
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
|
|
$t.p.gridstate = 'hidden';
|
|
} else if(state === 'visible') {
|
|
$(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv","#gview_"+$.jgrid.jqID($t.p.id)).slideDown("fast");
|
|
if($t.p.pager) {$($t.p.pager).slideDown("fast");}
|
|
if($t.p.toppager) {$($t.p.toppager).slideDown("fast");}
|
|
if($t.p.toolbar[0]===true) {
|
|
if( $t.p.toolbar[1] === 'both') {
|
|
$($t.grid.ubDiv).slideDown("fast");
|
|
}
|
|
$($t.grid.uDiv).slideDown("fast");
|
|
}
|
|
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$.jgrid.jqID($t.p.id)).slideDown("fast"); }
|
|
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");
|
|
$t.p.gridstate = 'visible';
|
|
}
|
|
|
|
});
|
|
},
|
|
filterToolbar : function(p){
|
|
p = $.extend({
|
|
autosearch: true,
|
|
searchOnEnter : true,
|
|
beforeSearch: null,
|
|
afterSearch: null,
|
|
beforeClear: null,
|
|
afterClear: null,
|
|
searchurl : '',
|
|
stringResult: false,
|
|
groupOp: 'AND',
|
|
defaultSearch : "bw",
|
|
searchOperators : false,
|
|
operandTitle : "Click to select search operation.",
|
|
operands : { "eq" :"==", "ne":"!","lt":"<","le":"<=","gt":">","ge":">=","bw":"^","bn":"!^","in":"=","ni":"!=","ew":"|","en":"!@","cn":"~","nc":"!~","nu":"#","nn":"!#"}
|
|
}, $.jgrid.search , p || {});
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if(this.ftoolbar) { return; }
|
|
var triggerToolbar = function() {
|
|
var sdata={}, j=0, v, nm, sopt={},so;
|
|
$.each($t.p.colModel,function(){
|
|
var $elem = $("#gs_"+$.jgrid.jqID(this.name), (this.frozen===true && $t.p.frozenColumns === true) ? $t.grid.fhDiv : $t.grid.hDiv);
|
|
nm = this.index || this.name;
|
|
if(p.searchOperators ) {
|
|
so = $elem.parent().prev().children("a").attr("soper") || p.defaultSearch;
|
|
} else {
|
|
so = (this.searchoptions && this.searchoptions.sopt) ? this.searchoptions.sopt[0] : this.stype==='select'? 'eq' : p.defaultSearch;
|
|
}
|
|
v = this.stype === "custom" && $.isFunction(this.searchoptions.custom_value) && $elem.length > 0 && $elem[0].nodeName.toUpperCase() === "SPAN" ?
|
|
this.searchoptions.custom_value.call($t, $elem.children(".customelement:first"), "get") :
|
|
$elem.val();
|
|
if(v || so==="nu" || so==="nn") {
|
|
sdata[nm] = v;
|
|
sopt[nm] = so;
|
|
j++;
|
|
} else {
|
|
try {
|
|
delete $t.p.postData[nm];
|
|
} catch (z) {}
|
|
}
|
|
});
|
|
var sd = j>0 ? true : false;
|
|
if(p.stringResult === true || $t.p.datatype === "local") {
|
|
var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":[";
|
|
var gi=0;
|
|
$.each(sdata,function(i,n){
|
|
if (gi > 0) {ruleGroup += ",";}
|
|
ruleGroup += "{\"field\":\"" + i + "\",";
|
|
ruleGroup += "\"op\":\"" + sopt[i] + "\",";
|
|
n+="";
|
|
ruleGroup += "\"data\":\"" + n.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"}";
|
|
gi++;
|
|
});
|
|
ruleGroup += "]}";
|
|
$.extend($t.p.postData,{filters:ruleGroup});
|
|
$.each(['searchField', 'searchString', 'searchOper'], function(i, n){
|
|
if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];}
|
|
});
|
|
} else {
|
|
$.extend($t.p.postData,sdata);
|
|
}
|
|
var saveurl;
|
|
if($t.p.searchurl) {
|
|
saveurl = $t.p.url;
|
|
$($t).jqGrid("setGridParam",{url:$t.p.searchurl});
|
|
}
|
|
var bsr = $($t).triggerHandler("jqGridToolbarBeforeSearch") === 'stop' ? true : false;
|
|
if(!bsr && $.isFunction(p.beforeSearch)){bsr = p.beforeSearch.call($t);}
|
|
if(!bsr) { $($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]); }
|
|
if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});}
|
|
$($t).triggerHandler("jqGridToolbarAfterSearch");
|
|
if($.isFunction(p.afterSearch)){p.afterSearch.call($t);}
|
|
},
|
|
clearToolbar = function(trigger){
|
|
var sdata={}, j=0, nm;
|
|
trigger = (typeof trigger !== 'boolean') ? true : trigger;
|
|
$.each($t.p.colModel,function(){
|
|
var v, $elem = $("#gs_"+$.jgrid.jqID(this.name),(this.frozen===true && $t.p.frozenColumns === true) ? $t.grid.fhDiv : $t.grid.hDiv);
|
|
if(this.searchoptions && this.searchoptions.defaultValue !== undefined) { v = this.searchoptions.defaultValue; }
|
|
nm = this.index || this.name;
|
|
switch (this.stype) {
|
|
case 'select' :
|
|
$elem.find("option").each(function (i){
|
|
if(i===0) { this.selected = true; }
|
|
if ($(this).val() === v) {
|
|
this.selected = true;
|
|
return false;
|
|
}
|
|
});
|
|
if ( v !== undefined ) {
|
|
// post the key and not the text
|
|
sdata[nm] = v;
|
|
j++;
|
|
} else {
|
|
try {
|
|
delete $t.p.postData[nm];
|
|
} catch(e) {}
|
|
}
|
|
break;
|
|
case 'text':
|
|
$elem.val(v);
|
|
if(v !== undefined) {
|
|
sdata[nm] = v;
|
|
j++;
|
|
} else {
|
|
try {
|
|
delete $t.p.postData[nm];
|
|
} catch (y){}
|
|
}
|
|
break;
|
|
case 'custom':
|
|
if ($.isFunction(this.searchoptions.custom_value) && $elem.length > 0 && $elem[0].nodeName.toUpperCase() === "SPAN") {
|
|
this.searchoptions.custom_value.call($t, $elem.children(".customelement:first"), "set", v);
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
var sd = j>0 ? true : false;
|
|
if(p.stringResult === true || $t.p.datatype === "local") {
|
|
var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":[";
|
|
var gi=0;
|
|
$.each(sdata,function(i,n){
|
|
if (gi > 0) {ruleGroup += ",";}
|
|
ruleGroup += "{\"field\":\"" + i + "\",";
|
|
ruleGroup += "\"op\":\"" + "eq" + "\",";
|
|
n+="";
|
|
ruleGroup += "\"data\":\"" + n.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"}";
|
|
gi++;
|
|
});
|
|
ruleGroup += "]}";
|
|
$.extend($t.p.postData,{filters:ruleGroup});
|
|
$.each(['searchField', 'searchString', 'searchOper'], function(i, n){
|
|
if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];}
|
|
});
|
|
} else {
|
|
$.extend($t.p.postData,sdata);
|
|
}
|
|
var saveurl;
|
|
if($t.p.searchurl) {
|
|
saveurl = $t.p.url;
|
|
$($t).jqGrid("setGridParam",{url:$t.p.searchurl});
|
|
}
|
|
var bcv = $($t).triggerHandler("jqGridToolbarBeforeClear") === 'stop' ? true : false;
|
|
if(!bcv && $.isFunction(p.beforeClear)){bcv = p.beforeClear.call($t);}
|
|
if(!bcv) {
|
|
if(trigger) {
|
|
$($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
|
|
}
|
|
}
|
|
if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});}
|
|
$($t).triggerHandler("jqGridToolbarAfterClear");
|
|
if($.isFunction(p.afterClear)){p.afterClear();}
|
|
},
|
|
toggleToolbar = function(){
|
|
var trow = $("tr.ui-search-toolbar",$t.grid.hDiv),
|
|
trow2 = $t.p.frozenColumns === true ? $("tr.ui-search-toolbar",$t.grid.fhDiv) : false;
|
|
if(trow.css("display") === 'none') {
|
|
trow.show();
|
|
if(trow2) {
|
|
trow2.show();
|
|
}
|
|
} else {
|
|
trow.hide();
|
|
if(trow2) {
|
|
trow2.hide();
|
|
}
|
|
}
|
|
},
|
|
buildRuleMenu = function( elem, left, top ){
|
|
$("#sopt_menu").remove();
|
|
|
|
left=parseInt(left,10);
|
|
top=parseInt(top,10) + 18;
|
|
|
|
var fs = $('.ui-jqgrid-view').css('font-size') || '11px';
|
|
var str = '<ul id="sopt_menu" class="ui-search-menu" role="menu" tabindex="0" style="font-size:'+fs+';left:'+left+'px;top:'+top+'px;">',
|
|
selected = $(elem).attr("soper"), selclass,
|
|
aoprs = [], ina;
|
|
var i=0, nm =$(elem).attr("colname"),len = $t.p.colModel.length;
|
|
while(i<len) {
|
|
if($t.p.colModel[i].name === nm) {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
var cm = $t.p.colModel[i], options = $.extend({}, cm.searchoptions);
|
|
if(!options.sopt) {
|
|
options.sopt = [];
|
|
options.sopt[0]= cm.stype==='select' ? 'eq' : p.defaultSearch;
|
|
}
|
|
$.each(p.odata, function() { aoprs.push(this.oper); });
|
|
for ( i = 0 ; i < options.sopt.length; i++) {
|
|
ina = $.inArray(options.sopt[i],aoprs);
|
|
if(ina !== -1) {
|
|
selclass = selected === p.odata[ina].oper ? "ui-state-highlight" : "";
|
|
str += '<li class="ui-menu-item '+selclass+'" role="presentation"><a class="ui-corner-all g-menu-item" tabindex="0" role="menuitem" value="'+p.odata[ina].oper+'" oper="'+p.operands[p.odata[ina].oper]+'"><table cellspacing="0" cellpadding="0" border="0"><tr><td width="25px">'+p.operands[p.odata[ina].oper]+'</td><td>'+ p.odata[ina].text+'</td></tr></table></a></li>';
|
|
}
|
|
}
|
|
str += "</ul>";
|
|
$('body').append(str);
|
|
$("#sopt_menu").addClass("ui-menu ui-widget ui-widget-content ui-corner-all");
|
|
$("#sopt_menu > li > a").hover(
|
|
function(){ $(this).addClass("ui-state-hover"); },
|
|
function(){ $(this).removeClass("ui-state-hover"); }
|
|
).click(function( e ){
|
|
var v = $(this).attr("value"),
|
|
oper = $(this).attr("oper");
|
|
$($t).triggerHandler("jqGridToolbarSelectOper", [v, oper, elem]);
|
|
$("#sopt_menu").hide();
|
|
$(elem).text(oper).attr("soper",v);
|
|
if(p.autosearch===true){
|
|
var inpelm = $(elem).parent().next().children()[0];
|
|
if( $(inpelm).val() || v==="nu" || v ==="nn") {
|
|
triggerToolbar();
|
|
}
|
|
}
|
|
});
|
|
};
|
|
// create the row
|
|
var tr = $("<tr class='ui-search-toolbar' role='rowheader'></tr>");
|
|
var timeoutHnd;
|
|
$.each($t.p.colModel,function(ci){
|
|
var cm=this, soptions, surl, self, select = "", sot="=", so, i,
|
|
th = $("<th role='columnheader' class='ui-state-default ui-th-column ui-th-"+$t.p.direction+"'></th>"),
|
|
thd = $("<div style='position:relative;height:100%;padding-right:0.3em;padding-left:0.3em;'></div>"),
|
|
stbl = $("<table class='ui-search-table' cellspacing='0'><tr><td class='ui-search-oper'></td><td class='ui-search-input'></td><td class='ui-search-clear'></td></tr></table>");
|
|
if(this.hidden===true) { $(th).css("display","none");}
|
|
this.search = this.search === false ? false : true;
|
|
if(this.stype === undefined) {this.stype='text';}
|
|
soptions = $.extend({},this.searchoptions || {});
|
|
if(this.search){
|
|
if(p.searchOperators) {
|
|
so = (soptions.sopt) ? soptions.sopt[0] : cm.stype==='select' ? 'eq' : p.defaultSearch;
|
|
for(i = 0;i<p.odata.length;i++) {
|
|
if(p.odata[i].oper === so) {
|
|
sot = p.operands[so] || "";
|
|
break;
|
|
}
|
|
}
|
|
var st = soptions.searchtitle != null ? soptions.searchtitle : p.operandTitle;
|
|
select = "<a title='"+st+"' style='padding-right: 0.5em;' soper='"+so+"' class='soptclass' colname='"+this.name+"'>"+sot+"</a>";
|
|
}
|
|
$("td:eq(0)",stbl).attr("colindex",ci).append(select);
|
|
if(soptions.clearSearch === undefined) {
|
|
soptions.clearSearch = true;
|
|
}
|
|
if(soptions.clearSearch) {
|
|
$("td:eq(2)",stbl).append("<a title='Clear Search Value' style='padding-right: 0.3em;padding-left: 0.3em;' class='clearsearchclass'>x</a>");
|
|
}
|
|
switch (this.stype)
|
|
{
|
|
case "select":
|
|
surl = this.surl || soptions.dataUrl;
|
|
if(surl) {
|
|
// data returned should have already constructed html select
|
|
// primitive jQuery load
|
|
self = thd;
|
|
$(self).append(stbl);
|
|
$.ajax($.extend({
|
|
url: surl,
|
|
dataType: "html",
|
|
success: function(res) {
|
|
if(soptions.buildSelect !== undefined) {
|
|
var d = soptions.buildSelect(res);
|
|
if (d) {
|
|
$("td:eq(1)",stbl).append(d);
|
|
}
|
|
} else {
|
|
$("td:eq(1)",stbl).append(res);
|
|
}
|
|
if(soptions.defaultValue !== undefined) { $("select",self).val(soptions.defaultValue); }
|
|
$("select",self).attr({name:cm.index || cm.name, id: "gs_"+cm.name});
|
|
if(soptions.attr) {$("select",self).attr(soptions.attr);}
|
|
$("select",self).css({width: "100%"});
|
|
// preserve autoserch
|
|
$.jgrid.bindEv.call($t, $("select",self)[0], soptions);
|
|
if(p.autosearch===true){
|
|
$("select",self).change(function(){
|
|
triggerToolbar();
|
|
return false;
|
|
});
|
|
}
|
|
res=null;
|
|
}
|
|
}, $.jgrid.ajaxOptions, $t.p.ajaxSelectOptions || {} ));
|
|
} else {
|
|
var oSv, sep, delim;
|
|
if(cm.searchoptions) {
|
|
oSv = cm.searchoptions.value === undefined ? "" : cm.searchoptions.value;
|
|
sep = cm.searchoptions.separator === undefined ? ":" : cm.searchoptions.separator;
|
|
delim = cm.searchoptions.delimiter === undefined ? ";" : cm.searchoptions.delimiter;
|
|
} else if(cm.editoptions) {
|
|
oSv = cm.editoptions.value === undefined ? "" : cm.editoptions.value;
|
|
sep = cm.editoptions.separator === undefined ? ":" : cm.editoptions.separator;
|
|
delim = cm.editoptions.delimiter === undefined ? ";" : cm.editoptions.delimiter;
|
|
}
|
|
if (oSv) {
|
|
var elem = document.createElement("select");
|
|
elem.style.width = "100%";
|
|
$(elem).attr({name:cm.index || cm.name, id: "gs_"+cm.name});
|
|
var sv, ov, key, k;
|
|
if(typeof oSv === "string") {
|
|
so = oSv.split(delim);
|
|
for(k=0; k<so.length;k++){
|
|
sv = so[k].split(sep);
|
|
ov = document.createElement("option");
|
|
ov.value = sv[0]; ov.innerHTML = sv[1];
|
|
elem.appendChild(ov);
|
|
}
|
|
} else if(typeof oSv === "object" ) {
|
|
for (key in oSv) {
|
|
if(oSv.hasOwnProperty(key)) {
|
|
ov = document.createElement("option");
|
|
ov.value = key; ov.innerHTML = oSv[key];
|
|
elem.appendChild(ov);
|
|
}
|
|
}
|
|
}
|
|
if(soptions.defaultValue !== undefined) { $(elem).val(soptions.defaultValue); }
|
|
if(soptions.attr) {$(elem).attr(soptions.attr);}
|
|
$(thd).append(stbl);
|
|
$.jgrid.bindEv.call($t, elem , soptions);
|
|
$("td:eq(1)",stbl).append( elem );
|
|
if(p.autosearch===true){
|
|
$(elem).change(function(){
|
|
triggerToolbar();
|
|
return false;
|
|
});
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case "text":
|
|
var df = soptions.defaultValue !== undefined ? soptions.defaultValue: "";
|
|
|
|
$("td:eq(1)",stbl).append("<input type='text' style='width:100%;padding:0px;' name='"+(cm.index || cm.name)+"' id='gs_"+cm.name+"' value='"+df+"'/>");
|
|
$(thd).append(stbl);
|
|
|
|
if(soptions.attr) {$("input",thd).attr(soptions.attr);}
|
|
$.jgrid.bindEv.call($t, $("input",thd)[0], soptions);
|
|
if(p.autosearch===true){
|
|
if(p.searchOnEnter) {
|
|
$("input",thd).keypress(function(e){
|
|
var key = e.charCode || e.keyCode || 0;
|
|
if(key === 13){
|
|
triggerToolbar();
|
|
return false;
|
|
}
|
|
return this;
|
|
});
|
|
} else {
|
|
$("input",thd).keydown(function(e){
|
|
var key = e.which;
|
|
switch (key) {
|
|
case 13:
|
|
return false;
|
|
case 9 :
|
|
case 16:
|
|
case 37:
|
|
case 38:
|
|
case 39:
|
|
case 40:
|
|
case 27:
|
|
break;
|
|
default :
|
|
if(timeoutHnd) { clearTimeout(timeoutHnd); }
|
|
timeoutHnd = setTimeout(function(){triggerToolbar();},500);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
break;
|
|
case "custom":
|
|
$("td:eq(1)",stbl).append("<span style='width:95%;padding:0px;' name='"+(cm.index || cm.name)+"' id='gs_"+cm.name+"'/>");
|
|
$(thd).append(stbl);
|
|
try {
|
|
if($.isFunction(soptions.custom_element)) {
|
|
var celm = soptions.custom_element.call($t,soptions.defaultValue !== undefined ? soptions.defaultValue: "",soptions);
|
|
if(celm) {
|
|
celm = $(celm).addClass("customelement");
|
|
$(thd).find(">span").append(celm);
|
|
} else {
|
|
throw "e2";
|
|
}
|
|
} else {
|
|
throw "e1";
|
|
}
|
|
} catch (e) {
|
|
if (e === "e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose);}
|
|
if (e === "e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);}
|
|
else { $.jgrid.info_dialog($.jgrid.errors.errcap,typeof e==="string"?e:e.message,$.jgrid.edit.bClose); }
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
$(th).append(thd);
|
|
$(tr).append(th);
|
|
if(!p.searchOperators) {
|
|
$("td:eq(0)",stbl).hide();
|
|
}
|
|
});
|
|
$("table thead",$t.grid.hDiv).append(tr);
|
|
if(p.searchOperators) {
|
|
$(".soptclass",tr).click(function(e){
|
|
var offset = $(this).offset(),
|
|
left = ( offset.left ),
|
|
top = ( offset.top);
|
|
buildRuleMenu(this, left, top );
|
|
e.stopPropagation();
|
|
});
|
|
$("body").on('click', function(e){
|
|
if(e.target.className !== "soptclass") {
|
|
$("#sopt_menu").hide();
|
|
}
|
|
});
|
|
}
|
|
$(".clearsearchclass",tr).click(function(e){
|
|
var ptr = $(this).parents("tr:first"),
|
|
coli = parseInt($("td.ui-search-oper", ptr).attr('colindex'),10),
|
|
sval = $.extend({},$t.p.colModel[coli].searchoptions || {}),
|
|
dval = sval.defaultValue ? sval.defaultValue : "";
|
|
if($t.p.colModel[coli].stype === "select") {
|
|
if(dval) {
|
|
$("td.ui-search-input select", ptr).val( dval );
|
|
} else {
|
|
$("td.ui-search-input select", ptr)[0].selectedIndex = 0;
|
|
}
|
|
} else {
|
|
$("td.ui-search-input input", ptr).val( dval );
|
|
}
|
|
// ToDo custom search type
|
|
if(p.autosearch===true){
|
|
triggerToolbar();
|
|
}
|
|
|
|
});
|
|
this.ftoolbar = true;
|
|
this.triggerToolbar = triggerToolbar;
|
|
this.clearToolbar = clearToolbar;
|
|
this.toggleToolbar = toggleToolbar;
|
|
});
|
|
},
|
|
destroyFilterToolbar: function () {
|
|
return this.each(function () {
|
|
if (!this.ftoolbar) {
|
|
return;
|
|
}
|
|
this.triggerToolbar = null;
|
|
this.clearToolbar = null;
|
|
this.toggleToolbar = null;
|
|
this.ftoolbar = false;
|
|
$(this.grid.hDiv).find("table thead tr.ui-search-toolbar").remove();
|
|
});
|
|
},
|
|
destroyGroupHeader : function(nullHeader)
|
|
{
|
|
if(nullHeader === undefined) {
|
|
nullHeader = true;
|
|
}
|
|
return this.each(function()
|
|
{
|
|
var $t = this, $tr, i, l, headers, $th, $resizing, grid = $t.grid,
|
|
thead = $("table.ui-jqgrid-htable thead", grid.hDiv), cm = $t.p.colModel, hc;
|
|
if(!grid) { return; }
|
|
|
|
$(this).unbind('.setGroupHeaders');
|
|
$tr = $("<tr>", {role: "rowheader"}).addClass("ui-jqgrid-labels");
|
|
headers = grid.headers;
|
|
for (i = 0, l = headers.length; i < l; i++) {
|
|
hc = cm[i].hidden ? "none" : "";
|
|
$th = $(headers[i].el)
|
|
.width(headers[i].width)
|
|
.css('display',hc);
|
|
try {
|
|
$th.removeAttr("rowSpan");
|
|
} catch (rs) {
|
|
//IE 6/7
|
|
$th.attr("rowSpan",1);
|
|
}
|
|
$tr.append($th);
|
|
$resizing = $th.children("span.ui-jqgrid-resize");
|
|
if ($resizing.length>0) {// resizable column
|
|
$resizing[0].style.height = "";
|
|
}
|
|
$th.children("div")[0].style.top = "";
|
|
}
|
|
$(thead).children('tr.ui-jqgrid-labels').remove();
|
|
$(thead).prepend($tr);
|
|
|
|
if(nullHeader === true) {
|
|
$($t).jqGrid('setGridParam',{ 'groupHeader': null});
|
|
}
|
|
});
|
|
},
|
|
setGroupHeaders : function ( o ) {
|
|
o = $.extend({
|
|
useColSpanStyle : false,
|
|
groupHeaders: []
|
|
},o || {});
|
|
return this.each(function(){
|
|
this.p.groupHeader = o;
|
|
var ts = this,
|
|
i, cmi, skip = 0, $tr, $colHeader, th, $th, thStyle,
|
|
iCol,
|
|
cghi,
|
|
//startColumnName,
|
|
numberOfColumns,
|
|
titleText,
|
|
cVisibleColumns,
|
|
colModel = ts.p.colModel,
|
|
cml = colModel.length,
|
|
ths = ts.grid.headers,
|
|
$htable = $("table.ui-jqgrid-htable", ts.grid.hDiv),
|
|
$trLabels = $htable.children("thead").children("tr.ui-jqgrid-labels:last").addClass("jqg-second-row-header"),
|
|
$thead = $htable.children("thead"),
|
|
$theadInTable,
|
|
$firstHeaderRow = $htable.find(".jqg-first-row-header");
|
|
if($firstHeaderRow[0] === undefined) {
|
|
$firstHeaderRow = $('<tr>', {role: "row", "aria-hidden": "true"}).addClass("jqg-first-row-header").css("height", "auto");
|
|
} else {
|
|
$firstHeaderRow.empty();
|
|
}
|
|
var $firstRow,
|
|
inColumnHeader = function (text, columnHeaders) {
|
|
var length = columnHeaders.length, i;
|
|
for (i = 0; i < length; i++) {
|
|
if (columnHeaders[i].startColumnName === text) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
};
|
|
|
|
$(ts).prepend($thead);
|
|
$tr = $('<tr>', {role: "rowheader"}).addClass("ui-jqgrid-labels jqg-third-row-header");
|
|
for (i = 0; i < cml; i++) {
|
|
th = ths[i].el;
|
|
$th = $(th);
|
|
cmi = colModel[i];
|
|
// build the next cell for the first header row
|
|
thStyle = { height: '0px', width: ths[i].width + 'px', display: (cmi.hidden ? 'none' : '')};
|
|
$("<th>", {role: 'gridcell'}).css(thStyle).addClass("ui-first-th-"+ts.p.direction).appendTo($firstHeaderRow);
|
|
|
|
th.style.width = ""; // remove unneeded style
|
|
iCol = inColumnHeader(cmi.name, o.groupHeaders);
|
|
if (iCol >= 0) {
|
|
cghi = o.groupHeaders[iCol];
|
|
numberOfColumns = cghi.numberOfColumns;
|
|
titleText = cghi.titleText;
|
|
|
|
// caclulate the number of visible columns from the next numberOfColumns columns
|
|
for (cVisibleColumns = 0, iCol = 0; iCol < numberOfColumns && (i + iCol < cml); iCol++) {
|
|
if (!colModel[i + iCol].hidden) {
|
|
cVisibleColumns++;
|
|
}
|
|
}
|
|
|
|
// The next numberOfColumns headers will be moved in the next row
|
|
// in the current row will be placed the new column header with the titleText.
|
|
// The text will be over the cVisibleColumns columns
|
|
$colHeader = $('<th>').attr({role: "columnheader"})
|
|
.addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction)
|
|
.css({'height':'22px', 'border-top': '0px none'})
|
|
.html(titleText);
|
|
if(cVisibleColumns > 0) {
|
|
$colHeader.attr("colspan", String(cVisibleColumns));
|
|
}
|
|
if (ts.p.headertitles) {
|
|
$colHeader.attr("title", $colHeader.text());
|
|
}
|
|
// hide if not a visible cols
|
|
if( cVisibleColumns === 0) {
|
|
$colHeader.hide();
|
|
}
|
|
|
|
$th.before($colHeader); // insert new column header before the current
|
|
$tr.append(th); // move the current header in the next row
|
|
|
|
// set the coumter of headers which will be moved in the next row
|
|
skip = numberOfColumns - 1;
|
|
} else {
|
|
if (skip === 0) {
|
|
if (o.useColSpanStyle) {
|
|
// expand the header height to two rows
|
|
$th.attr("rowspan", "2");
|
|
} else {
|
|
$('<th>', {role: "columnheader"})
|
|
.addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction)
|
|
.css({"display": cmi.hidden ? 'none' : '', 'border-top': '0px none'})
|
|
.insertBefore($th);
|
|
$tr.append(th);
|
|
}
|
|
} else {
|
|
// move the header to the next row
|
|
//$th.css({"padding-top": "2px", height: "19px"});
|
|
$tr.append(th);
|
|
skip--;
|
|
}
|
|
}
|
|
}
|
|
$theadInTable = $(ts).children("thead");
|
|
$theadInTable.prepend($firstHeaderRow);
|
|
$tr.insertAfter($trLabels);
|
|
$htable.append($theadInTable);
|
|
|
|
if (o.useColSpanStyle) {
|
|
// Increase the height of resizing span of visible headers
|
|
$htable.find("span.ui-jqgrid-resize").each(function () {
|
|
var $parent = $(this).parent();
|
|
if ($parent.is(":visible")) {
|
|
this.style.cssText = 'height: ' + $parent.height() + 'px !important; cursor: col-resize;';
|
|
}
|
|
});
|
|
|
|
// Set position of the sortable div (the main lable)
|
|
// with the column header text to the middle of the cell.
|
|
// One should not do this for hidden headers.
|
|
$htable.find("div.ui-jqgrid-sortable").each(function () {
|
|
var $ts = $(this), $parent = $ts.parent();
|
|
if ($parent.is(":visible") && $parent.is(":has(span.ui-jqgrid-resize)")) {
|
|
$ts.css('top', ($parent.height() - $ts.outerHeight()) / 2 + 'px');
|
|
}
|
|
});
|
|
}
|
|
|
|
$firstRow = $theadInTable.find("tr.jqg-first-row-header");
|
|
$(ts).bind('jqGridResizeStop.setGroupHeaders', function (e, nw, idx) {
|
|
$firstRow.find('th').eq(idx).width(nw);
|
|
});
|
|
});
|
|
},
|
|
setFrozenColumns : function () {
|
|
return this.each(function() {
|
|
if ( !this.grid ) {return;}
|
|
var $t = this, cm = $t.p.colModel,i=0, len = cm.length, maxfrozen = -1, frozen= false;
|
|
// TODO treeGrid and grouping Support
|
|
if($t.p.subGrid === true || $t.p.treeGrid === true || $t.p.cellEdit === true || $t.p.sortable || $t.p.scroll || $t.p.grouping )
|
|
{
|
|
return;
|
|
}
|
|
if($t.p.rownumbers) { i++; }
|
|
if($t.p.multiselect) { i++; }
|
|
|
|
// get the max index of frozen col
|
|
while(i<len)
|
|
{
|
|
// from left, no breaking frozen
|
|
if(cm[i].frozen === true)
|
|
{
|
|
frozen = true;
|
|
maxfrozen = i;
|
|
} else {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
if( maxfrozen>=0 && frozen) {
|
|
var top = $t.p.caption ? $($t.grid.cDiv).outerHeight() : 0,
|
|
hth = $(".ui-jqgrid-htable","#gview_"+$.jgrid.jqID($t.p.id)).height();
|
|
//headers
|
|
if($t.p.toppager) {
|
|
top = top + $($t.grid.topDiv).outerHeight();
|
|
}
|
|
if($t.p.toolbar[0] === true) {
|
|
if($t.p.toolbar[1] !== "bottom") {
|
|
top = top + $($t.grid.uDiv).outerHeight();
|
|
}
|
|
}
|
|
$t.grid.fhDiv = $('<div style="position:absolute;left:0px;top:'+top+'px;height:'+hth+'px;" class="frozen-div ui-state-default ui-jqgrid-hdiv"></div>');
|
|
$t.grid.fbDiv = $('<div style="position:absolute;left:0px;top:'+(parseInt(top,10)+parseInt(hth,10) + 1)+'px;overflow-y:hidden" class="frozen-bdiv ui-jqgrid-bdiv"></div>');
|
|
$("#gview_"+$.jgrid.jqID($t.p.id)).append($t.grid.fhDiv);
|
|
var htbl = $(".ui-jqgrid-htable","#gview_"+$.jgrid.jqID($t.p.id)).clone(true);
|
|
// groupheader support - only if useColSpanstyle is false
|
|
if($t.p.groupHeader) {
|
|
$("tr.jqg-first-row-header, tr.jqg-third-row-header", htbl).each(function(){
|
|
$("th:gt("+maxfrozen+")",this).remove();
|
|
});
|
|
var swapfroz = -1, fdel = -1, cs, rs;
|
|
$("tr.jqg-second-row-header th", htbl).each(function(){
|
|
cs= parseInt($(this).attr("colspan"),10);
|
|
rs= parseInt($(this).attr("rowspan"),10);
|
|
if(rs) {
|
|
swapfroz++;
|
|
fdel++;
|
|
}
|
|
if(cs) {
|
|
swapfroz = swapfroz+cs;
|
|
fdel++;
|
|
}
|
|
if(swapfroz === maxfrozen) {
|
|
return false;
|
|
}
|
|
});
|
|
if(swapfroz !== maxfrozen) {
|
|
fdel = maxfrozen;
|
|
}
|
|
$("tr.jqg-second-row-header", htbl).each(function(){
|
|
$("th:gt("+fdel+")",this).remove();
|
|
});
|
|
} else {
|
|
$("tr",htbl).each(function(){
|
|
$("th:gt("+maxfrozen+")",this).remove();
|
|
});
|
|
}
|
|
$(htbl).width(1);
|
|
// resizing stuff
|
|
$($t.grid.fhDiv).append(htbl)
|
|
.mousemove(function (e) {
|
|
if($t.grid.resizing){ $t.grid.dragMove(e);return false; }
|
|
});
|
|
$($t).bind('jqGridResizeStop.setFrozenColumns', function (e, w, index) {
|
|
var rhth = $(".ui-jqgrid-htable",$t.grid.fhDiv);
|
|
$("th:eq("+index+")",rhth).width( w );
|
|
var btd = $(".ui-jqgrid-btable",$t.grid.fbDiv);
|
|
$("tr:first td:eq("+index+")",btd).width( w );
|
|
});
|
|
// sorting stuff
|
|
$($t).bind('jqGridSortCol.setFrozenColumns', function (e, index, idxcol) {
|
|
|
|
var previousSelectedTh = $("tr.ui-jqgrid-labels:last th:eq("+$t.p.lastsort+")",$t.grid.fhDiv), newSelectedTh = $("tr.ui-jqgrid-labels:last th:eq("+idxcol+")",$t.grid.fhDiv);
|
|
|
|
$("span.ui-grid-ico-sort",previousSelectedTh).addClass('ui-state-disabled');
|
|
$(previousSelectedTh).attr("aria-selected","false");
|
|
$("span.ui-icon-"+$t.p.sortorder,newSelectedTh).removeClass('ui-state-disabled');
|
|
$(newSelectedTh).attr("aria-selected","true");
|
|
if(!$t.p.viewsortcols[0]) {
|
|
if($t.p.lastsort !== idxcol) {
|
|
$("span.s-ico",previousSelectedTh).hide();
|
|
$("span.s-ico",newSelectedTh).show();
|
|
}
|
|
}
|
|
});
|
|
|
|
// data stuff
|
|
//TODO support for setRowData
|
|
$("#gview_"+$.jgrid.jqID($t.p.id)).append($t.grid.fbDiv);
|
|
$($t.grid.bDiv).scroll(function () {
|
|
$($t.grid.fbDiv).scrollTop($(this).scrollTop());
|
|
});
|
|
if($t.p.hoverrows === true) {
|
|
$("#"+$.jgrid.jqID($t.p.id)).unbind('mouseover').unbind('mouseout');
|
|
}
|
|
$($t).bind('jqGridAfterGridComplete.setFrozenColumns', function () {
|
|
$("#"+$.jgrid.jqID($t.p.id)+"_frozen").remove();
|
|
$($t.grid.fbDiv).height($($t.grid.bDiv).height()-16);
|
|
var btbl = $("#"+$.jgrid.jqID($t.p.id)).clone(true);
|
|
$("tr[role=row]",btbl).each(function(){
|
|
$("td[role=gridcell]:gt("+maxfrozen+")",this).remove();
|
|
});
|
|
|
|
$(btbl).width(1).attr("id",$t.p.id+"_frozen");
|
|
$($t.grid.fbDiv).append(btbl);
|
|
if($t.p.hoverrows === true) {
|
|
$("tr.jqgrow", btbl).hover(
|
|
function(){ $(this).addClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)).addClass("ui-state-hover"); },
|
|
function(){ $(this).removeClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)).removeClass("ui-state-hover"); }
|
|
);
|
|
$("tr.jqgrow", "#"+$.jgrid.jqID($t.p.id)).hover(
|
|
function(){ $(this).addClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)+"_frozen").addClass("ui-state-hover");},
|
|
function(){ $(this).removeClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)+"_frozen").removeClass("ui-state-hover"); }
|
|
);
|
|
}
|
|
btbl=null;
|
|
});
|
|
if(!$t.grid.hDiv.loading) {
|
|
$($t).triggerHandler("jqGridAfterGridComplete");
|
|
}
|
|
$t.p.frozenColumns = true;
|
|
}
|
|
});
|
|
},
|
|
destroyFrozenColumns : function() {
|
|
return this.each(function() {
|
|
if ( !this.grid ) {return;}
|
|
if(this.p.frozenColumns === true) {
|
|
var $t = this;
|
|
$($t.grid.fhDiv).remove();
|
|
$($t.grid.fbDiv).remove();
|
|
$t.grid.fhDiv = null; $t.grid.fbDiv=null;
|
|
$(this).unbind('.setFrozenColumns');
|
|
if($t.p.hoverrows === true) {
|
|
var ptr;
|
|
$("#"+$.jgrid.jqID($t.p.id)).bind('mouseover',function(e) {
|
|
ptr = $(e.target).closest("tr.jqgrow");
|
|
if($(ptr).attr("class") !== "ui-subgrid") {
|
|
$(ptr).addClass("ui-state-hover");
|
|
}
|
|
}).bind('mouseout',function(e) {
|
|
ptr = $(e.target).closest("tr.jqgrow");
|
|
$(ptr).removeClass("ui-state-hover");
|
|
});
|
|
}
|
|
this.p.frozenColumns = false;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*
|
|
* jqModal - Minimalist Modaling with jQuery
|
|
* (http://dev.iceburg.net/jquery/jqmodal/)
|
|
*
|
|
* Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
*
|
|
* $Version: 07/06/2008 +r13
|
|
*/
|
|
(function($) {
|
|
$.fn.jqm=function(o){
|
|
var p={
|
|
overlay: 50,
|
|
closeoverlay : true,
|
|
overlayClass: 'jqmOverlay',
|
|
closeClass: 'jqmClose',
|
|
trigger: '.jqModal',
|
|
ajax: F,
|
|
ajaxText: '',
|
|
target: F,
|
|
modal: F,
|
|
toTop: F,
|
|
onShow: F,
|
|
onHide: F,
|
|
onLoad: F
|
|
};
|
|
return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;
|
|
H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};
|
|
if(p.trigger)$(this).jqmAddTrigger(p.trigger);
|
|
});};
|
|
|
|
$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};
|
|
$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};
|
|
$.fn.jqmShow=function(t){return this.each(function(){$.jqm.open(this._jqm,t);});};
|
|
$.fn.jqmHide=function(t){return this.each(function(){$.jqm.close(this._jqm,t)});};
|
|
|
|
$.jqm = {
|
|
hash:{},
|
|
open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index')));z=(z>0)?z:3000;var o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);
|
|
if(c.modal) {if(!A[0])setTimeout(function(){L('bind');},1);A.push(s);}
|
|
else if(c.overlay > 0) {if(c.closeoverlay) h.w.jqmAddClose(o);}
|
|
else o=F;
|
|
|
|
h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;
|
|
|
|
if(c.ajax) {var r=c.target||h.w,u=c.ajax;r=(typeof r == 'string')?$(r,h.w):$(r);u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
|
|
r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
|
|
else if(cc)h.w.jqmAddClose($(cc,h.w));
|
|
|
|
if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);
|
|
(c.onShow)?c.onShow(h):h.w.show();e(h);return F;
|
|
},
|
|
close:function(s){var h=H[s];if(!h.a)return F;h.a=F;
|
|
if(A[0]){A.pop();if(!A[0])L('unbind');}
|
|
if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
|
|
if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F;
|
|
},
|
|
params:{}};
|
|
var s=0,H=$.jqm.hash,A=[],F=false,
|
|
e=function(h){f(h);},
|
|
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},
|
|
L=function(t){$(document)[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
|
|
m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r){$('.jqmID'+h.s).each(function(){var $self=$(this),offset=$self.offset();if(offset.top<=e.pageY && e.pageY<=offset.top+$self.height() && offset.left<=e.pageX && e.pageX<=offset.left+$self.width()){r=false;return false;}});f(h);}return !r;},
|
|
hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() {
|
|
if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};
|
|
})(jQuery);/*
|
|
* jqDnR - Minimalistic Drag'n'Resize for jQuery.
|
|
*
|
|
* Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
|
|
* Licensed under the MIT License:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
*
|
|
* $Version: 2007.08.19 +r2
|
|
*/
|
|
|
|
(function($){
|
|
$.fn.jqDrag=function(h){return i(this,h,'d');};
|
|
$.fn.jqResize=function(h,ar){return i(this,h,'r',ar);};
|
|
$.jqDnR={
|
|
dnr:{},
|
|
e:0,
|
|
drag:function(v){
|
|
if(M.k == 'd'){E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});}
|
|
else {
|
|
E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
|
|
if(M1){E1.css({width:Math.max(v.pageX-M1.pX+M1.W,0),height:Math.max(v.pageY-M1.pY+M1.H,0)});}
|
|
}
|
|
return false;
|
|
},
|
|
stop:function(){
|
|
//E.css('opacity',M.o);
|
|
$(document).unbind('mousemove',J.drag).unbind('mouseup',J.stop);
|
|
}
|
|
};
|
|
var J=$.jqDnR,M=J.dnr,E=J.e,E1,M1,
|
|
i=function(e,h,k,aR){
|
|
return e.each(function(){
|
|
h=(h)?$(h,e):e;
|
|
h.bind('mousedown',{e:e,k:k},function(v){
|
|
var d=v.data,p={};E=d.e;E1 = aR ? $(aR) : false;
|
|
// attempt utilization of dimensions plugin to fix IE issues
|
|
if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
|
|
M={
|
|
X:p.left||f('left')||0,
|
|
Y:p.top||f('top')||0,
|
|
W:f('width')||E[0].scrollWidth||0,
|
|
H:f('height')||E[0].scrollHeight||0,
|
|
pX:v.pageX,
|
|
pY:v.pageY,
|
|
k:d.k
|
|
//o:E.css('opacity')
|
|
};
|
|
// also resize
|
|
if(E1 && d.k != 'd'){
|
|
M1={
|
|
X:p.left||f1('left')||0,
|
|
Y:p.top||f1('top')||0,
|
|
W:E1[0].offsetWidth||f1('width')||0,
|
|
H:E1[0].offsetHeight||f1('height')||0,
|
|
pX:v.pageX,
|
|
pY:v.pageY,
|
|
k:d.k
|
|
};
|
|
} else {M1 = false;}
|
|
//E.css({opacity:0.8});
|
|
if($("input.hasDatepicker",E[0])[0]) {
|
|
try {$("input.hasDatepicker",E[0]).datepicker('hide');}catch (dpe){}
|
|
}
|
|
$(document).mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
|
|
return false;
|
|
});
|
|
});
|
|
},
|
|
f=function(k){return parseInt(E.css(k),10)||false;},
|
|
f1=function(k){return parseInt(E1.css(k),10)||false;};
|
|
})(jQuery);/*
|
|
The below work is licensed under Creative Commons GNU LGPL License.
|
|
|
|
Original work:
|
|
|
|
License: http://creativecommons.org/licenses/LGPL/2.1/
|
|
Author: Stefan Goessner/2006
|
|
Web: http://goessner.net/
|
|
|
|
Modifications made:
|
|
|
|
Version: 0.9-p5
|
|
Description: Restructured code, JSLint validated (no strict whitespaces),
|
|
added handling of empty arrays, empty strings, and int/floats values.
|
|
Author: Michael Schøler/2008-01-29
|
|
Web: http://michael.hinnerup.net/blog/2008/01/26/converting-json-to-xml-and-xml-to-json/
|
|
|
|
Description: json2xml added support to convert functions as CDATA
|
|
so it will be easy to write characters that cause some problems when convert
|
|
Author: Tony Tomov
|
|
*/
|
|
|
|
/*global alert */
|
|
var xmlJsonClass = {
|
|
// Param "xml": Element or document DOM node.
|
|
// Param "tab": Tab or indent string for pretty output formatting omit or use empty string "" to supress.
|
|
// Returns: JSON string
|
|
xml2json: function(xml, tab) {
|
|
if (xml.nodeType === 9) {
|
|
// document node
|
|
xml = xml.documentElement;
|
|
}
|
|
var nws = this.removeWhite(xml);
|
|
var obj = this.toObj(nws);
|
|
var json = this.toJson(obj, xml.nodeName, "\t");
|
|
return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}";
|
|
},
|
|
|
|
// Param "o": JavaScript object
|
|
// Param "tab": tab or indent string for pretty output formatting omit or use empty string "" to supress.
|
|
// Returns: XML string
|
|
json2xml: function(o, tab) {
|
|
var toXml = function(v, name, ind) {
|
|
var xml = "";
|
|
var i, n;
|
|
if (v instanceof Array) {
|
|
if (v.length === 0) {
|
|
xml += ind + "<"+name+">__EMPTY_ARRAY_</"+name+">\n";
|
|
}
|
|
else {
|
|
for (i = 0, n = v.length; i < n; i += 1) {
|
|
var sXml = ind + toXml(v[i], name, ind+"\t") + "\n";
|
|
xml += sXml;
|
|
}
|
|
}
|
|
}
|
|
else if (typeof(v) === "object") {
|
|
var hasChild = false;
|
|
xml += ind + "<" + name;
|
|
var m;
|
|
for (m in v) if (v.hasOwnProperty(m)) {
|
|
if (m.charAt(0) === "@") {
|
|
xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\"";
|
|
}
|
|
else {
|
|
hasChild = true;
|
|
}
|
|
}
|
|
xml += hasChild ? ">" : "/>";
|
|
if (hasChild) {
|
|
for (m in v) if (v.hasOwnProperty(m)) {
|
|
if (m === "#text") {
|
|
xml += v[m];
|
|
}
|
|
else if (m === "#cdata") {
|
|
xml += "<![CDATA[" + v[m] + "]]>";
|
|
}
|
|
else if (m.charAt(0) !== "@") {
|
|
xml += toXml(v[m], m, ind+"\t");
|
|
}
|
|
}
|
|
xml += (xml.charAt(xml.length - 1) === "\n" ? ind : "") + "</" + name + ">";
|
|
}
|
|
}
|
|
else if (typeof(v) === "function") {
|
|
xml += ind + "<" + name + ">" + "<![CDATA[" + v + "]]>" + "</" + name + ">";
|
|
}
|
|
else {
|
|
if (v === undefined ) { v = ""; }
|
|
if (v.toString() === "\"\"" || v.toString().length === 0) {
|
|
xml += ind + "<" + name + ">__EMPTY_STRING_</" + name + ">";
|
|
}
|
|
else {
|
|
xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">";
|
|
}
|
|
}
|
|
return xml;
|
|
};
|
|
var xml = "";
|
|
var m;
|
|
for (m in o) if (o.hasOwnProperty(m)) {
|
|
xml += toXml(o[m], m, "");
|
|
}
|
|
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
|
|
},
|
|
// Internal methods
|
|
toObj: function(xml) {
|
|
var o = {};
|
|
var FuncTest = /function/i;
|
|
if (xml.nodeType === 1) {
|
|
// element node ..
|
|
if (xml.attributes.length) {
|
|
// element with attributes ..
|
|
var i;
|
|
for (i = 0; i < xml.attributes.length; i += 1) {
|
|
o["@" + xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue || "").toString();
|
|
}
|
|
}
|
|
if (xml.firstChild) {
|
|
// element has child nodes ..
|
|
var textChild = 0, cdataChild = 0, hasElementChild = false;
|
|
var n;
|
|
for (n = xml.firstChild; n; n = n.nextSibling) {
|
|
if (n.nodeType === 1) {
|
|
hasElementChild = true;
|
|
}
|
|
else if (n.nodeType === 3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) {
|
|
// non-whitespace text
|
|
textChild += 1;
|
|
}
|
|
else if (n.nodeType === 4) {
|
|
// cdata section node
|
|
cdataChild += 1;
|
|
}
|
|
}
|
|
if (hasElementChild) {
|
|
if (textChild < 2 && cdataChild < 2) {
|
|
// structured element with evtl. a single text or/and cdata node ..
|
|
this.removeWhite(xml);
|
|
for (n = xml.firstChild; n; n = n.nextSibling) {
|
|
if (n.nodeType === 3) {
|
|
// text node
|
|
o["#text"] = this.escape(n.nodeValue);
|
|
}
|
|
else if (n.nodeType === 4) {
|
|
// cdata node
|
|
if (FuncTest.test(n.nodeValue)) {
|
|
o[n.nodeName] = [o[n.nodeName], n.nodeValue];
|
|
} else {
|
|
o["#cdata"] = this.escape(n.nodeValue);
|
|
}
|
|
}
|
|
else if (o[n.nodeName]) {
|
|
// multiple occurence of element ..
|
|
if (o[n.nodeName] instanceof Array) {
|
|
o[n.nodeName][o[n.nodeName].length] = this.toObj(n);
|
|
}
|
|
else {
|
|
o[n.nodeName] = [o[n.nodeName], this.toObj(n)];
|
|
}
|
|
}
|
|
else {
|
|
// first occurence of element ..
|
|
o[n.nodeName] = this.toObj(n);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
// mixed content
|
|
if (!xml.attributes.length) {
|
|
o = this.escape(this.innerXml(xml));
|
|
}
|
|
else {
|
|
o["#text"] = this.escape(this.innerXml(xml));
|
|
}
|
|
}
|
|
}
|
|
else if (textChild) {
|
|
// pure text
|
|
if (!xml.attributes.length) {
|
|
o = this.escape(this.innerXml(xml));
|
|
if (o === "__EMPTY_ARRAY_") {
|
|
o = "[]";
|
|
} else if (o === "__EMPTY_STRING_") {
|
|
o = "";
|
|
}
|
|
}
|
|
else {
|
|
o["#text"] = this.escape(this.innerXml(xml));
|
|
}
|
|
}
|
|
else if (cdataChild) {
|
|
// cdata
|
|
if (cdataChild > 1) {
|
|
o = this.escape(this.innerXml(xml));
|
|
}
|
|
else {
|
|
for (n = xml.firstChild; n; n = n.nextSibling) {
|
|
if(FuncTest.test(xml.firstChild.nodeValue)) {
|
|
o = xml.firstChild.nodeValue;
|
|
break;
|
|
} else {
|
|
o["#cdata"] = this.escape(n.nodeValue);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!xml.attributes.length && !xml.firstChild) {
|
|
o = null;
|
|
}
|
|
}
|
|
else if (xml.nodeType === 9) {
|
|
// document.node
|
|
o = this.toObj(xml.documentElement);
|
|
}
|
|
else {
|
|
alert("unhandled node type: " + xml.nodeType);
|
|
}
|
|
return o;
|
|
},
|
|
toJson: function(o, name, ind, wellform) {
|
|
if(wellform === undefined) wellform = true;
|
|
var json = name ? ("\"" + name + "\"") : "", tab = "\t", newline = "\n";
|
|
if(!wellform) {
|
|
tab= ""; newline= "";
|
|
}
|
|
|
|
if (o === "[]") {
|
|
json += (name ? ":[]" : "[]");
|
|
}
|
|
else if (o instanceof Array) {
|
|
var n, i, ar=[];
|
|
for (i = 0, n = o.length; i < n; i += 1) {
|
|
ar[i] = this.toJson(o[i], "", ind + tab, wellform);
|
|
}
|
|
json += (name ? ":[" : "[") + (ar.length > 1 ? (newline + ind + tab + ar.join(","+newline + ind + tab) + newline + ind) : ar.join("")) + "]";
|
|
}
|
|
else if (o === null) {
|
|
json += (name && ":") + "null";
|
|
}
|
|
else if (typeof(o) === "object") {
|
|
var arr = [], m;
|
|
for (m in o) {
|
|
if (o.hasOwnProperty(m)) {
|
|
arr[arr.length] = this.toJson(o[m], m, ind + tab, wellform);
|
|
}
|
|
}
|
|
json += (name ? ":{" : "{") + (arr.length > 1 ? (newline + ind + tab + arr.join(","+newline + ind + tab) + newline + ind) : arr.join("")) + "}";
|
|
}
|
|
else if (typeof(o) === "string") {
|
|
/*
|
|
var objRegExp = /(^-?\d+\.?\d*$)/;
|
|
var FuncTest = /function/i;
|
|
var os = o.toString();
|
|
if (objRegExp.test(os) || FuncTest.test(os) || os==="false" || os==="true") {
|
|
// int or float
|
|
json += (name && ":") + "\"" +os + "\"";
|
|
}
|
|
else {
|
|
*/
|
|
json += (name && ":") + "\"" + o.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"";
|
|
//}
|
|
}
|
|
else {
|
|
json += (name && ":") + o.toString();
|
|
}
|
|
return json;
|
|
},
|
|
innerXml: function(node) {
|
|
var s = "";
|
|
if ("innerHTML" in node) {
|
|
s = node.innerHTML;
|
|
}
|
|
else {
|
|
var asXml = function(n) {
|
|
var s = "", i;
|
|
if (n.nodeType === 1) {
|
|
s += "<" + n.nodeName;
|
|
for (i = 0; i < n.attributes.length; i += 1) {
|
|
s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue || "").toString() + "\"";
|
|
}
|
|
if (n.firstChild) {
|
|
s += ">";
|
|
for (var c = n.firstChild; c; c = c.nextSibling) {
|
|
s += asXml(c);
|
|
}
|
|
s += "</" + n.nodeName + ">";
|
|
}
|
|
else {
|
|
s += "/>";
|
|
}
|
|
}
|
|
else if (n.nodeType === 3) {
|
|
s += n.nodeValue;
|
|
}
|
|
else if (n.nodeType === 4) {
|
|
s += "<![CDATA[" + n.nodeValue + "]]>";
|
|
}
|
|
return s;
|
|
};
|
|
for (var c = node.firstChild; c; c = c.nextSibling) {
|
|
s += asXml(c);
|
|
}
|
|
}
|
|
return s;
|
|
},
|
|
escape: function(txt) {
|
|
return txt.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r');
|
|
},
|
|
removeWhite: function(e) {
|
|
e.normalize();
|
|
var n;
|
|
for (n = e.firstChild; n; ) {
|
|
if (n.nodeType === 3) {
|
|
// text node
|
|
if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) {
|
|
// pure whitespace text node
|
|
var nxt = n.nextSibling;
|
|
e.removeChild(n);
|
|
n = nxt;
|
|
}
|
|
else {
|
|
n = n.nextSibling;
|
|
}
|
|
}
|
|
else if (n.nodeType === 1) {
|
|
// element node
|
|
this.removeWhite(n);
|
|
n = n.nextSibling;
|
|
}
|
|
else {
|
|
// any other node
|
|
n = n.nextSibling;
|
|
}
|
|
}
|
|
return e;
|
|
}
|
|
};/*
|
|
**
|
|
* formatter for values but most of the values if for jqGrid
|
|
* Some of this was inspired and based on how YUI does the table datagrid but in jQuery fashion
|
|
* we are trying to keep it as light as possible
|
|
* Joshua Burnett josh@9ci.com
|
|
* http://www.greenbill.com
|
|
*
|
|
* Changes from Tony Tomov tony@trirand.com
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
**/
|
|
/*jshint eqeqeq:false */
|
|
/*global jQuery */
|
|
|
|
(function($) {
|
|
"use strict";
|
|
$.fmatter = {};
|
|
//opts can be id:row id for the row, rowdata:the data for the row, colmodel:the column model for this column
|
|
//example {id:1234,}
|
|
$.extend($.fmatter,{
|
|
isBoolean : function(o) {
|
|
return typeof o === 'boolean';
|
|
},
|
|
isObject : function(o) {
|
|
return (o && (typeof o === 'object' || $.isFunction(o))) || false;
|
|
},
|
|
isString : function(o) {
|
|
return typeof o === 'string';
|
|
},
|
|
isNumber : function(o) {
|
|
return typeof o === 'number' && isFinite(o);
|
|
},
|
|
isValue : function (o) {
|
|
return (this.isObject(o) || this.isString(o) || this.isNumber(o) || this.isBoolean(o));
|
|
},
|
|
isEmpty : function(o) {
|
|
if(!this.isString(o) && this.isValue(o)) {
|
|
return false;
|
|
}
|
|
if (!this.isValue(o)){
|
|
return true;
|
|
}
|
|
o = $.trim(o).replace(/\ \;/ig,'').replace(/\ \;/ig,'');
|
|
return o==="";
|
|
}
|
|
});
|
|
$.fn.fmatter = function(formatType, cellval, opts, rwd, act) {
|
|
// build main options before element iteration
|
|
var v=cellval;
|
|
opts = $.extend({}, $.jgrid.formatter, opts);
|
|
|
|
try {
|
|
v = $.fn.fmatter[formatType].call(this, cellval, opts, rwd, act);
|
|
} catch(fe){}
|
|
return v;
|
|
};
|
|
$.fmatter.util = {
|
|
// Taken from YAHOO utils
|
|
NumberFormat : function(nData,opts) {
|
|
if(!$.fmatter.isNumber(nData)) {
|
|
nData *= 1;
|
|
}
|
|
if($.fmatter.isNumber(nData)) {
|
|
var bNegative = (nData < 0);
|
|
var sOutput = String(nData);
|
|
var sDecimalSeparator = opts.decimalSeparator || ".";
|
|
var nDotIndex;
|
|
if($.fmatter.isNumber(opts.decimalPlaces)) {
|
|
// Round to the correct decimal place
|
|
var nDecimalPlaces = opts.decimalPlaces;
|
|
var nDecimal = Math.pow(10, nDecimalPlaces);
|
|
sOutput = String(Math.round(nData*nDecimal)/nDecimal);
|
|
nDotIndex = sOutput.lastIndexOf(".");
|
|
if(nDecimalPlaces > 0) {
|
|
// Add the decimal separator
|
|
if(nDotIndex < 0) {
|
|
sOutput += sDecimalSeparator;
|
|
nDotIndex = sOutput.length-1;
|
|
}
|
|
// Replace the "."
|
|
else if(sDecimalSeparator !== "."){
|
|
sOutput = sOutput.replace(".",sDecimalSeparator);
|
|
}
|
|
// Add missing zeros
|
|
while((sOutput.length - 1 - nDotIndex) < nDecimalPlaces) {
|
|
sOutput += "0";
|
|
}
|
|
}
|
|
}
|
|
if(opts.thousandsSeparator) {
|
|
var sThousandsSeparator = opts.thousandsSeparator;
|
|
nDotIndex = sOutput.lastIndexOf(sDecimalSeparator);
|
|
nDotIndex = (nDotIndex > -1) ? nDotIndex : sOutput.length;
|
|
var sNewOutput = sOutput.substring(nDotIndex);
|
|
var nCount = -1, i;
|
|
for (i=nDotIndex; i>0; i--) {
|
|
nCount++;
|
|
if ((nCount%3 === 0) && (i !== nDotIndex) && (!bNegative || (i > 1))) {
|
|
sNewOutput = sThousandsSeparator + sNewOutput;
|
|
}
|
|
sNewOutput = sOutput.charAt(i-1) + sNewOutput;
|
|
}
|
|
sOutput = sNewOutput;
|
|
}
|
|
// Prepend prefix
|
|
sOutput = (opts.prefix) ? opts.prefix + sOutput : sOutput;
|
|
// Append suffix
|
|
sOutput = (opts.suffix) ? sOutput + opts.suffix : sOutput;
|
|
return sOutput;
|
|
|
|
}
|
|
return nData;
|
|
}
|
|
};
|
|
$.fn.fmatter.defaultFormat = function(cellval, opts) {
|
|
return ($.fmatter.isValue(cellval) && cellval!=="" ) ? cellval : opts.defaultValue || " ";
|
|
};
|
|
$.fn.fmatter.email = function(cellval, opts) {
|
|
if(!$.fmatter.isEmpty(cellval)) {
|
|
return "<a href=\"mailto:" + cellval + "\">" + cellval + "</a>";
|
|
}
|
|
return $.fn.fmatter.defaultFormat(cellval,opts );
|
|
};
|
|
$.fn.fmatter.checkbox =function(cval, opts) {
|
|
var op = $.extend({},opts.checkbox), ds;
|
|
if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.colModel.formatoptions);
|
|
}
|
|
if(op.disabled===true) {ds = "disabled=\"disabled\"";} else {ds="";}
|
|
if($.fmatter.isEmpty(cval) || cval === undefined ) {cval = $.fn.fmatter.defaultFormat(cval,op);}
|
|
cval=String(cval);
|
|
cval=(cval+"").toLowerCase();
|
|
var bchk = cval.search(/(false|f|0|no|n|off|undefined)/i)<0 ? " checked='checked' " : "";
|
|
return "<input type=\"checkbox\" " + bchk + " value=\""+ cval+"\" offval=\"no\" "+ds+ "/>";
|
|
};
|
|
$.fn.fmatter.link = function(cellval, opts) {
|
|
var op = {target:opts.target};
|
|
var target = "";
|
|
if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.colModel.formatoptions);
|
|
}
|
|
if(op.target) {target = 'target=' + op.target;}
|
|
if(!$.fmatter.isEmpty(cellval)) {
|
|
return "<a "+target+" href=\"" + cellval + "\">" + cellval + "</a>";
|
|
}
|
|
return $.fn.fmatter.defaultFormat(cellval,opts);
|
|
};
|
|
$.fn.fmatter.showlink = function(cellval, opts) {
|
|
var op = {baseLinkUrl: opts.baseLinkUrl,showAction:opts.showAction, addParam: opts.addParam || "", target: opts.target, idName: opts.idName},
|
|
target = "", idUrl;
|
|
if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.colModel.formatoptions);
|
|
}
|
|
if(op.target) {target = 'target=' + op.target;}
|
|
idUrl = op.baseLinkUrl+op.showAction + '?'+ op.idName+'='+opts.rowId+op.addParam;
|
|
if($.fmatter.isString(cellval) || $.fmatter.isNumber(cellval)) { //add this one even if its blank string
|
|
return "<a "+target+" href=\"" + idUrl + "\">" + cellval + "</a>";
|
|
}
|
|
return $.fn.fmatter.defaultFormat(cellval,opts);
|
|
};
|
|
$.fn.fmatter.integer = function(cellval, opts) {
|
|
var op = $.extend({},opts.integer);
|
|
if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.colModel.formatoptions);
|
|
}
|
|
if($.fmatter.isEmpty(cellval)) {
|
|
return op.defaultValue;
|
|
}
|
|
return $.fmatter.util.NumberFormat(cellval,op);
|
|
};
|
|
$.fn.fmatter.number = function (cellval, opts) {
|
|
var op = $.extend({},opts.number);
|
|
if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.colModel.formatoptions);
|
|
}
|
|
if($.fmatter.isEmpty(cellval)) {
|
|
return op.defaultValue;
|
|
}
|
|
return $.fmatter.util.NumberFormat(cellval,op);
|
|
};
|
|
$.fn.fmatter.currency = function (cellval, opts) {
|
|
var op = $.extend({},opts.currency);
|
|
if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.colModel.formatoptions);
|
|
}
|
|
if($.fmatter.isEmpty(cellval)) {
|
|
return op.defaultValue;
|
|
}
|
|
return $.fmatter.util.NumberFormat(cellval,op);
|
|
};
|
|
$.fn.fmatter.date = function (cellval, opts, rwd, act) {
|
|
var op = $.extend({},opts.date);
|
|
if(opts.colModel !== undefined && opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.colModel.formatoptions);
|
|
}
|
|
if(!op.reformatAfterEdit && act === 'edit'){
|
|
return $.fn.fmatter.defaultFormat(cellval, opts);
|
|
}
|
|
if(!$.fmatter.isEmpty(cellval)) {
|
|
return $.jgrid.parseDate(op.srcformat,cellval,op.newformat,op);
|
|
}
|
|
return $.fn.fmatter.defaultFormat(cellval, opts);
|
|
};
|
|
$.fn.fmatter.select = function (cellval,opts) {
|
|
// jqGrid specific
|
|
cellval = String(cellval);
|
|
var oSelect = false, ret=[], sep, delim;
|
|
if(opts.colModel.formatoptions !== undefined){
|
|
oSelect= opts.colModel.formatoptions.value;
|
|
sep = opts.colModel.formatoptions.separator === undefined ? ":" : opts.colModel.formatoptions.separator;
|
|
delim = opts.colModel.formatoptions.delimiter === undefined ? ";" : opts.colModel.formatoptions.delimiter;
|
|
} else if(opts.colModel.editoptions !== undefined){
|
|
oSelect= opts.colModel.editoptions.value;
|
|
sep = opts.colModel.editoptions.separator === undefined ? ":" : opts.colModel.editoptions.separator;
|
|
delim = opts.colModel.editoptions.delimiter === undefined ? ";" : opts.colModel.editoptions.delimiter;
|
|
}
|
|
if (oSelect) {
|
|
var msl = opts.colModel.editoptions.multiple === true ? true : false,
|
|
scell = [], sv;
|
|
if(msl) {scell = cellval.split(",");scell = $.map(scell,function(n){return $.trim(n);});}
|
|
if ($.fmatter.isString(oSelect)) {
|
|
// mybe here we can use some caching with care ????
|
|
var so = oSelect.split(delim), j=0, i;
|
|
for(i=0; i<so.length;i++){
|
|
sv = so[i].split(sep);
|
|
if(sv.length > 2 ) {
|
|
sv[1] = $.map(sv,function(n,i){if(i>0) {return n;}}).join(sep);
|
|
}
|
|
if(msl) {
|
|
if($.inArray(sv[0],scell)>-1) {
|
|
ret[j] = sv[1];
|
|
j++;
|
|
}
|
|
} else if($.trim(sv[0]) === $.trim(cellval)) {
|
|
ret[0] = sv[1];
|
|
break;
|
|
}
|
|
}
|
|
} else if($.fmatter.isObject(oSelect)) {
|
|
// this is quicker
|
|
if(msl) {
|
|
ret = $.map(scell, function(n){
|
|
return oSelect[n];
|
|
});
|
|
} else {
|
|
ret[0] = oSelect[cellval] || "";
|
|
}
|
|
}
|
|
}
|
|
cellval = ret.join(", ");
|
|
return cellval === "" ? $.fn.fmatter.defaultFormat(cellval,opts) : cellval;
|
|
};
|
|
$.fn.fmatter.rowactions = function(act) {
|
|
var $tr = $(this).closest("tr.jqgrow"),
|
|
rid = $tr.attr("id"),
|
|
$id = $(this).closest("table.ui-jqgrid-btable").attr('id').replace(/_frozen([^_]*)$/,'$1'),
|
|
$grid = $("#"+$id),
|
|
$t = $grid[0],
|
|
p = $t.p,
|
|
cm = p.colModel[$.jgrid.getCellIndex(this)],
|
|
$actionsDiv = cm.frozen ? $("tr#"+rid+" td:eq("+$.jgrid.getCellIndex(this)+") > div",$grid) :$(this).parent(),
|
|
op = {
|
|
keys: false,
|
|
onEdit: null,
|
|
onSuccess: null,
|
|
afterSave: null,
|
|
onError: null,
|
|
afterRestore: null,
|
|
extraparam: {},
|
|
url: null,
|
|
restoreAfterError: true,
|
|
mtype: "POST",
|
|
delOptions: {},
|
|
editOptions: {}
|
|
},
|
|
saverow = function(rowid, res) {
|
|
if($.isFunction(op.afterSave)) { op.afterSave.call($t, rowid, res); }
|
|
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
|
|
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
|
|
},
|
|
restorerow = function(rowid) {
|
|
if($.isFunction(op.afterRestore)) { op.afterRestore.call($t, rowid); }
|
|
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
|
|
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
|
|
};
|
|
|
|
if (cm.formatoptions !== undefined) {
|
|
op = $.extend(op,cm.formatoptions);
|
|
}
|
|
if (p.editOptions !== undefined) {
|
|
op.editOptions = p.editOptions;
|
|
}
|
|
if (p.delOptions !== undefined) {
|
|
op.delOptions = p.delOptions;
|
|
}
|
|
if ($tr.hasClass("jqgrid-new-row")){
|
|
op.extraparam[p.prmNames.oper] = p.prmNames.addoper;
|
|
}
|
|
var actop = {
|
|
keys: op.keys,
|
|
oneditfunc: op.onEdit,
|
|
successfunc: op.onSuccess,
|
|
url: op.url,
|
|
extraparam: op.extraparam,
|
|
aftersavefunc: saverow,
|
|
errorfunc: op.onError,
|
|
afterrestorefunc: restorerow,
|
|
restoreAfterError: op.restoreAfterError,
|
|
mtype: op.mtype
|
|
};
|
|
switch(act)
|
|
{
|
|
case 'edit':
|
|
$grid.jqGrid('editRow', rid, actop);
|
|
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").hide();
|
|
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").show();
|
|
$grid.triggerHandler("jqGridAfterGridComplete");
|
|
break;
|
|
case 'save':
|
|
if ($grid.jqGrid('saveRow', rid, actop)) {
|
|
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
|
|
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
|
|
$grid.triggerHandler("jqGridAfterGridComplete");
|
|
}
|
|
break;
|
|
case 'cancel' :
|
|
$grid.jqGrid('restoreRow', rid, restorerow);
|
|
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
|
|
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
|
|
$grid.triggerHandler("jqGridAfterGridComplete");
|
|
break;
|
|
case 'del':
|
|
$grid.jqGrid('delGridRow', rid, op.delOptions);
|
|
break;
|
|
case 'formedit':
|
|
$grid.jqGrid('setSelection', rid);
|
|
$grid.jqGrid('editGridRow', rid, op.editOptions);
|
|
break;
|
|
}
|
|
};
|
|
$.fn.fmatter.actions = function(cellval,opts) {
|
|
var op={keys:false, editbutton:true, delbutton:true, editformbutton: false},
|
|
rowid=opts.rowId, str="",ocl;
|
|
if(opts.colModel.formatoptions !== undefined) {
|
|
op = $.extend(op,opts.colModel.formatoptions);
|
|
}
|
|
if(rowid === undefined || $.fmatter.isEmpty(rowid)) {return "";}
|
|
if(op.editformbutton){
|
|
ocl = "id='jEditButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'formedit'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
|
|
str += "<div title='"+$.jgrid.nav.edittitle+"' style='float:left;cursor:pointer;' class='ui-pg-div ui-inline-edit' "+ocl+"><span class='ui-icon ui-icon-pencil'></span></div>";
|
|
} else if(op.editbutton){
|
|
ocl = "id='jEditButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'edit'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover') ";
|
|
str += "<div title='"+$.jgrid.nav.edittitle+"' style='float:left;cursor:pointer;' class='ui-pg-div ui-inline-edit' "+ocl+"><span class='ui-icon ui-icon-pencil'></span></div>";
|
|
}
|
|
if(op.delbutton) {
|
|
ocl = "id='jDeleteButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'del'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
|
|
str += "<div title='"+$.jgrid.nav.deltitle+"' style='float:left;margin-left:5px;' class='ui-pg-div ui-inline-del' "+ocl+"><span class='ui-icon ui-icon-trash'></span></div>";
|
|
}
|
|
ocl = "id='jSaveButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'save'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
|
|
str += "<div title='"+$.jgrid.edit.bSubmit+"' style='float:left;display:none' class='ui-pg-div ui-inline-save' "+ocl+"><span class='ui-icon ui-icon-disk'></span></div>";
|
|
ocl = "id='jCancelButton_"+rowid+"' onclick=jQuery.fn.fmatter.rowactions.call(this,'cancel'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
|
|
str += "<div title='"+$.jgrid.edit.bCancel+"' style='float:left;display:none;margin-left:5px;' class='ui-pg-div ui-inline-cancel' "+ocl+"><span class='ui-icon ui-icon-cancel'></span></div>";
|
|
return "<div style='margin-left:8px;'>" + str + "</div>";
|
|
};
|
|
$.unformat = function (cellval,options,pos,cnt) {
|
|
// specific for jqGrid only
|
|
var ret, formatType = options.colModel.formatter,
|
|
op =options.colModel.formatoptions || {}, sep,
|
|
re = /([\.\*\_\'\(\)\{\}\+\?\\])/g,
|
|
unformatFunc = options.colModel.unformat||($.fn.fmatter[formatType] && $.fn.fmatter[formatType].unformat);
|
|
if(unformatFunc !== undefined && $.isFunction(unformatFunc) ) {
|
|
ret = unformatFunc.call(this, $(cellval).text(), options, cellval);
|
|
} else if(formatType !== undefined && $.fmatter.isString(formatType) ) {
|
|
var opts = $.jgrid.formatter || {}, stripTag;
|
|
switch(formatType) {
|
|
case 'integer' :
|
|
op = $.extend({},opts.integer,op);
|
|
sep = op.thousandsSeparator.replace(re,"\\$1");
|
|
stripTag = new RegExp(sep, "g");
|
|
ret = $(cellval).text().replace(stripTag,'');
|
|
break;
|
|
case 'number' :
|
|
op = $.extend({},opts.number,op);
|
|
sep = op.thousandsSeparator.replace(re,"\\$1");
|
|
stripTag = new RegExp(sep, "g");
|
|
ret = $(cellval).text().replace(stripTag,"").replace(op.decimalSeparator,'.');
|
|
break;
|
|
case 'currency':
|
|
op = $.extend({},opts.currency,op);
|
|
sep = op.thousandsSeparator.replace(re,"\\$1");
|
|
stripTag = new RegExp(sep, "g");
|
|
ret = $(cellval).text();
|
|
if (op.prefix && op.prefix.length) {
|
|
ret = ret.substr(op.prefix.length);
|
|
}
|
|
if (op.suffix && op.suffix.length) {
|
|
ret = ret.substr(0, ret.length - op.suffix.length);
|
|
}
|
|
ret = ret.replace(stripTag,'').replace(op.decimalSeparator,'.');
|
|
break;
|
|
case 'checkbox':
|
|
var cbv = (options.colModel.editoptions) ? options.colModel.editoptions.value.split(":") : ["Yes","No"];
|
|
ret = $('input',cellval).is(":checked") ? cbv[0] : cbv[1];
|
|
break;
|
|
case 'select' :
|
|
ret = $.unformat.select(cellval,options,pos,cnt);
|
|
break;
|
|
case 'actions':
|
|
return "";
|
|
default:
|
|
ret= $(cellval).text();
|
|
}
|
|
}
|
|
return ret !== undefined ? ret : cnt===true ? $(cellval).text() : $.jgrid.htmlDecode($(cellval).html());
|
|
};
|
|
$.unformat.select = function (cellval,options,pos,cnt) {
|
|
// Spacial case when we have local data and perform a sort
|
|
// cnt is set to true only in sortDataArray
|
|
var ret = [];
|
|
var cell = $(cellval).text();
|
|
if(cnt===true) {return cell;}
|
|
var op = $.extend({}, options.colModel.formatoptions !== undefined ? options.colModel.formatoptions: options.colModel.editoptions),
|
|
sep = op.separator === undefined ? ":" : op.separator,
|
|
delim = op.delimiter === undefined ? ";" : op.delimiter;
|
|
|
|
if(op.value){
|
|
var oSelect = op.value,
|
|
msl = op.multiple === true ? true : false,
|
|
scell = [], sv;
|
|
if(msl) {scell = cell.split(",");scell = $.map(scell,function(n){return $.trim(n);});}
|
|
if ($.fmatter.isString(oSelect)) {
|
|
var so = oSelect.split(delim), j=0, i;
|
|
for(i=0; i<so.length;i++){
|
|
sv = so[i].split(sep);
|
|
if(sv.length > 2 ) {
|
|
sv[1] = $.map(sv,function(n,i){if(i>0) {return n;}}).join(sep);
|
|
}
|
|
if(msl) {
|
|
if($.inArray(sv[1],scell)>-1) {
|
|
ret[j] = sv[0];
|
|
j++;
|
|
}
|
|
} else if($.trim(sv[1]) === $.trim(cell)) {
|
|
ret[0] = sv[0];
|
|
break;
|
|
}
|
|
}
|
|
} else if($.fmatter.isObject(oSelect) || $.isArray(oSelect) ){
|
|
if(!msl) {scell[0] = cell;}
|
|
ret = $.map(scell, function(n){
|
|
var rv;
|
|
$.each(oSelect, function(i,val){
|
|
if (val === n) {
|
|
rv = i;
|
|
return false;
|
|
}
|
|
});
|
|
if( rv !== undefined ) {return rv;}
|
|
});
|
|
}
|
|
return ret.join(", ");
|
|
}
|
|
return cell || "";
|
|
};
|
|
$.unformat.date = function (cellval, opts) {
|
|
var op = $.jgrid.formatter.date || {};
|
|
if(opts.formatoptions !== undefined) {
|
|
op = $.extend({},op,opts.formatoptions);
|
|
}
|
|
if(!$.fmatter.isEmpty(cellval)) {
|
|
return $.jgrid.parseDate(op.newformat,cellval,op.srcformat,op);
|
|
}
|
|
return $.fn.fmatter.defaultFormat(cellval, opts);
|
|
};
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false */
|
|
/*global jQuery */
|
|
(function($){
|
|
/*
|
|
* jqGrid common function
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
*/
|
|
"use strict";
|
|
$.extend($.jgrid,{
|
|
// Modal functions
|
|
showModal : function(h) {
|
|
h.w.show();
|
|
},
|
|
closeModal : function(h) {
|
|
h.w.hide().attr("aria-hidden","true");
|
|
if(h.o) {h.o.remove();}
|
|
},
|
|
hideModal : function (selector,o) {
|
|
o = $.extend({jqm : true, gb :''}, o || {});
|
|
if(o.onClose) {
|
|
var oncret = o.gb && typeof o.gb === "string" && o.gb.substr(0,6) === "#gbox_" ? o.onClose.call($("#" + o.gb.substr(6))[0], selector) : o.onClose(selector);
|
|
if (typeof oncret === 'boolean' && !oncret ) { return; }
|
|
}
|
|
if ($.fn.jqm && o.jqm === true) {
|
|
$(selector).attr("aria-hidden","true").jqmHide();
|
|
} else {
|
|
if(o.gb !== '') {
|
|
try {$(".jqgrid-overlay:first",o.gb).hide();} catch (e){}
|
|
}
|
|
$(selector).hide().attr("aria-hidden","true");
|
|
}
|
|
},
|
|
//Helper functions
|
|
findPos : function(obj) {
|
|
var curleft = 0, curtop = 0;
|
|
if (obj.offsetParent) {
|
|
do {
|
|
curleft += obj.offsetLeft;
|
|
curtop += obj.offsetTop;
|
|
} while (obj = obj.offsetParent);
|
|
//do not change obj == obj.offsetParent
|
|
}
|
|
return [curleft,curtop];
|
|
},
|
|
createModal : function(aIDs, content, p, insertSelector, posSelector, appendsel, css) {
|
|
p = $.extend(true, {}, $.jgrid.jqModal || {}, p);
|
|
var mw = document.createElement('div'), rtlsup, self = this;
|
|
css = $.extend({}, css || {});
|
|
rtlsup = $(p.gbox).attr("dir") === "rtl" ? true : false;
|
|
mw.className= "ui-widget ui-widget-content ui-corner-all ui-jqdialog";
|
|
mw.id = aIDs.themodal;
|
|
var mh = document.createElement('div');
|
|
mh.className = "ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix";
|
|
mh.id = aIDs.modalhead;
|
|
$(mh).append("<span class='ui-jqdialog-title'>"+p.caption+"</span>");
|
|
var ahr= $("<a class='ui-jqdialog-titlebar-close ui-corner-all'></a>")
|
|
.hover(function(){ahr.addClass('ui-state-hover');},
|
|
function(){ahr.removeClass('ui-state-hover');})
|
|
.append("<span class='ui-icon ui-icon-closethick'></span>");
|
|
$(mh).append(ahr);
|
|
if(rtlsup) {
|
|
mw.dir = "rtl";
|
|
$(".ui-jqdialog-title",mh).css("float","right");
|
|
$(".ui-jqdialog-titlebar-close",mh).css("left",0.3+"em");
|
|
} else {
|
|
mw.dir = "ltr";
|
|
$(".ui-jqdialog-title",mh).css("float","left");
|
|
$(".ui-jqdialog-titlebar-close",mh).css("right",0.3+"em");
|
|
}
|
|
var mc = document.createElement('div');
|
|
$(mc).addClass("ui-jqdialog-content ui-widget-content").attr("id",aIDs.modalcontent);
|
|
$(mc).append(content);
|
|
mw.appendChild(mc);
|
|
$(mw).prepend(mh);
|
|
if(appendsel===true) { $('body').append(mw); } //append as first child in body -for alert dialog
|
|
else if (typeof appendsel === "string") {
|
|
$(appendsel).append(mw);
|
|
} else {$(mw).insertBefore(insertSelector);}
|
|
$(mw).css(css);
|
|
if(p.jqModal === undefined) {p.jqModal = true;} // internal use
|
|
var coord = {};
|
|
if ( $.fn.jqm && p.jqModal === true) {
|
|
if(p.left ===0 && p.top===0 && p.overlay) {
|
|
var pos = [];
|
|
pos = $.jgrid.findPos(posSelector);
|
|
p.left = pos[0] + 4;
|
|
p.top = pos[1] + 4;
|
|
}
|
|
coord.top = p.top+"px";
|
|
coord.left = p.left;
|
|
} else if(p.left !==0 || p.top!==0) {
|
|
coord.left = p.left;
|
|
coord.top = p.top+"px";
|
|
}
|
|
$("a.ui-jqdialog-titlebar-close",mh).click(function(){
|
|
var oncm = $("#"+$.jgrid.jqID(aIDs.themodal)).data("onClose") || p.onClose;
|
|
var gboxclose = $("#"+$.jgrid.jqID(aIDs.themodal)).data("gbox") || p.gbox;
|
|
self.hideModal("#"+$.jgrid.jqID(aIDs.themodal),{gb:gboxclose,jqm:p.jqModal,onClose:oncm});
|
|
return false;
|
|
});
|
|
if (p.width === 0 || !p.width) {p.width = 300;}
|
|
if(p.height === 0 || !p.height) {p.height =200;}
|
|
if(!p.zIndex) {
|
|
var parentZ = $(insertSelector).parents("*[role=dialog]").filter(':first').css("z-index");
|
|
if(parentZ) {
|
|
p.zIndex = parseInt(parentZ,10)+2;
|
|
} else {
|
|
p.zIndex = 950;
|
|
}
|
|
}
|
|
var rtlt = 0;
|
|
if( rtlsup && coord.left && !appendsel) {
|
|
rtlt = $(p.gbox).width()- (!isNaN(p.width) ? parseInt(p.width,10) :0) - 8; // to do
|
|
// just in case
|
|
coord.left = parseInt(coord.left,10) + parseInt(rtlt,10);
|
|
}
|
|
if(coord.left) { coord.left += "px"; }
|
|
$(mw).css($.extend({
|
|
width: isNaN(p.width) ? "auto": p.width+"px",
|
|
height:isNaN(p.height) ? "auto" : p.height + "px",
|
|
zIndex:p.zIndex,
|
|
overflow: 'hidden'
|
|
},coord))
|
|
.attr({tabIndex: "-1","role":"dialog","aria-labelledby":aIDs.modalhead,"aria-hidden":"true"});
|
|
if(p.drag === undefined) { p.drag=true;}
|
|
if(p.resize === undefined) {p.resize=true;}
|
|
if (p.drag) {
|
|
$(mh).css('cursor','move');
|
|
if($.fn.jqDrag) {
|
|
$(mw).jqDrag(mh);
|
|
} else {
|
|
try {
|
|
$(mw).draggable({handle: $("#"+$.jgrid.jqID(mh.id))});
|
|
} catch (e) {}
|
|
}
|
|
}
|
|
if(p.resize) {
|
|
if($.fn.jqResize) {
|
|
$(mw).append("<div class='jqResize ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se'></div>");
|
|
$("#"+$.jgrid.jqID(aIDs.themodal)).jqResize(".jqResize",aIDs.scrollelm ? "#"+$.jgrid.jqID(aIDs.scrollelm) : false);
|
|
} else {
|
|
try {
|
|
$(mw).resizable({handles: 'se, sw',alsoResize: aIDs.scrollelm ? "#"+$.jgrid.jqID(aIDs.scrollelm) : false});
|
|
} catch (r) {}
|
|
}
|
|
}
|
|
if(p.closeOnEscape === true){
|
|
$(mw).keydown( function( e ) {
|
|
if( e.which == 27 ) {
|
|
var cone = $("#"+$.jgrid.jqID(aIDs.themodal)).data("onClose") || p.onClose;
|
|
self.hideModal("#"+$.jgrid.jqID(aIDs.themodal),{gb:p.gbox,jqm:p.jqModal,onClose: cone});
|
|
}
|
|
});
|
|
}
|
|
},
|
|
viewModal : function (selector,o){
|
|
o = $.extend({
|
|
toTop: true,
|
|
overlay: 10,
|
|
modal: false,
|
|
overlayClass : 'ui-widget-overlay',
|
|
onShow: $.jgrid.showModal,
|
|
onHide: $.jgrid.closeModal,
|
|
gbox: '',
|
|
jqm : true,
|
|
jqM : true
|
|
}, o || {});
|
|
if ($.fn.jqm && o.jqm === true) {
|
|
if(o.jqM) { $(selector).attr("aria-hidden","false").jqm(o).jqmShow(); }
|
|
else {$(selector).attr("aria-hidden","false").jqmShow();}
|
|
} else {
|
|
if(o.gbox !== '') {
|
|
$(".jqgrid-overlay:first",o.gbox).show();
|
|
$(selector).data("gbox",o.gbox);
|
|
}
|
|
$(selector).show().attr("aria-hidden","false");
|
|
try{$(':input:visible',selector)[0].focus();}catch(_){}
|
|
}
|
|
},
|
|
info_dialog : function(caption, content,c_b, modalopt) {
|
|
var mopt = {
|
|
width:290,
|
|
height:'auto',
|
|
dataheight: 'auto',
|
|
drag: true,
|
|
resize: false,
|
|
left:250,
|
|
top:170,
|
|
zIndex : 1000,
|
|
jqModal : true,
|
|
modal : false,
|
|
closeOnEscape : true,
|
|
align: 'center',
|
|
buttonalign : 'center',
|
|
buttons : []
|
|
// {text:'textbutt', id:"buttid", onClick : function(){...}}
|
|
// if the id is not provided we set it like info_button_+ the index in the array - i.e info_button_0,info_button_1...
|
|
};
|
|
$.extend(true, mopt, $.jgrid.jqModal || {}, {caption:"<b>"+caption+"</b>"}, modalopt || {});
|
|
var jm = mopt.jqModal, self = this;
|
|
if($.fn.jqm && !jm) { jm = false; }
|
|
// in case there is no jqModal
|
|
var buttstr ="", i;
|
|
if(mopt.buttons.length > 0) {
|
|
for(i=0;i<mopt.buttons.length;i++) {
|
|
if(mopt.buttons[i].id === undefined) { mopt.buttons[i].id = "info_button_"+i; }
|
|
buttstr += "<a id='"+mopt.buttons[i].id+"' class='fm-button ui-state-default ui-corner-all'>"+mopt.buttons[i].text+"</a>";
|
|
}
|
|
}
|
|
var dh = isNaN(mopt.dataheight) ? mopt.dataheight : mopt.dataheight+"px",
|
|
cn = "text-align:"+mopt.align+";";
|
|
var cnt = "<div id='info_id'>";
|
|
cnt += "<div id='infocnt' style='margin:0px;padding-bottom:1em;width:100%;overflow:auto;position:relative;height:"+dh+";"+cn+"'>"+content+"</div>";
|
|
cnt += c_b ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'><a id='closedialog' class='fm-button ui-state-default ui-corner-all'>"+c_b+"</a>"+buttstr+"</div>" :
|
|
buttstr !== "" ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'>"+buttstr+"</div>" : "";
|
|
cnt += "</div>";
|
|
|
|
try {
|
|
if($("#info_dialog").attr("aria-hidden") === "false") {
|
|
$.jgrid.hideModal("#info_dialog",{jqm:jm});
|
|
}
|
|
$("#info_dialog").remove();
|
|
} catch (e){}
|
|
$.jgrid.createModal({
|
|
themodal:'info_dialog',
|
|
modalhead:'info_head',
|
|
modalcontent:'info_content',
|
|
scrollelm: 'infocnt'},
|
|
cnt,
|
|
mopt,
|
|
'','',true
|
|
);
|
|
// attach onclick after inserting into the dom
|
|
if(buttstr) {
|
|
$.each(mopt.buttons,function(i){
|
|
$("#"+$.jgrid.jqID(this.id),"#info_id").bind('click',function(){mopt.buttons[i].onClick.call($("#info_dialog")); return false;});
|
|
});
|
|
}
|
|
$("#closedialog", "#info_id").click(function(){
|
|
self.hideModal("#info_dialog",{
|
|
jqm:jm,
|
|
onClose: $("#info_dialog").data("onClose") || mopt.onClose,
|
|
gb: $("#info_dialog").data("gbox") || mopt.gbox
|
|
});
|
|
return false;
|
|
});
|
|
$(".fm-button","#info_dialog").hover(
|
|
function(){$(this).addClass('ui-state-hover');},
|
|
function(){$(this).removeClass('ui-state-hover');}
|
|
);
|
|
if($.isFunction(mopt.beforeOpen) ) { mopt.beforeOpen(); }
|
|
$.jgrid.viewModal("#info_dialog",{
|
|
onHide: function(h) {
|
|
h.w.hide().remove();
|
|
if(h.o) { h.o.remove(); }
|
|
},
|
|
modal :mopt.modal,
|
|
jqm:jm
|
|
});
|
|
if($.isFunction(mopt.afterOpen) ) { mopt.afterOpen(); }
|
|
try{ $("#info_dialog").focus();} catch (m){}
|
|
},
|
|
bindEv: function (el, opt) {
|
|
var $t = this;
|
|
if($.isFunction(opt.dataInit)) {
|
|
opt.dataInit.call($t,el,opt);
|
|
}
|
|
if(opt.dataEvents) {
|
|
$.each(opt.dataEvents, function() {
|
|
if (this.data !== undefined) {
|
|
$(el).bind(this.type, this.data, this.fn);
|
|
} else {
|
|
$(el).bind(this.type, this.fn);
|
|
}
|
|
});
|
|
}
|
|
},
|
|
// Form Functions
|
|
createEl : function(eltype,options,vl,autowidth, ajaxso) {
|
|
var elem = "", $t = this;
|
|
function setAttributes(elm, atr, exl ) {
|
|
var exclude = ['dataInit','dataEvents','dataUrl', 'buildSelect','sopt', 'searchhidden', 'defaultValue', 'attr', 'custom_element', 'custom_value'];
|
|
if(exl !== undefined && $.isArray(exl)) {
|
|
$.merge(exclude, exl);
|
|
}
|
|
$.each(atr, function(key, value){
|
|
if($.inArray(key, exclude) === -1) {
|
|
$(elm).attr(key,value);
|
|
}
|
|
});
|
|
if(!atr.hasOwnProperty('id')) {
|
|
$(elm).attr('id', $.jgrid.randId());
|
|
}
|
|
}
|
|
switch (eltype)
|
|
{
|
|
case "textarea" :
|
|
elem = document.createElement("textarea");
|
|
if(autowidth) {
|
|
if(!options.cols) { $(elem).css({width:"98%"});}
|
|
} else if (!options.cols) { options.cols = 20; }
|
|
if(!options.rows) { options.rows = 2; }
|
|
if(vl===' ' || vl===' ' || (vl.length===1 && vl.charCodeAt(0)===160)) {vl="";}
|
|
elem.value = vl;
|
|
setAttributes(elem, options);
|
|
$(elem).attr({"role":"textbox","multiline":"true"});
|
|
break;
|
|
case "checkbox" : //what code for simple checkbox
|
|
elem = document.createElement("input");
|
|
elem.type = "checkbox";
|
|
if( !options.value ) {
|
|
var vl1 = (vl+"").toLowerCase();
|
|
if(vl1.search(/(false|f|0|no|n|off|undefined)/i)<0 && vl1!=="") {
|
|
elem.checked=true;
|
|
elem.defaultChecked=true;
|
|
elem.value = vl;
|
|
} else {
|
|
elem.value = "on";
|
|
}
|
|
$(elem).attr("offval","off");
|
|
} else {
|
|
var cbval = options.value.split(":");
|
|
if(vl === cbval[0]) {
|
|
elem.checked=true;
|
|
elem.defaultChecked=true;
|
|
}
|
|
elem.value = cbval[0];
|
|
$(elem).attr("offval",cbval[1]);
|
|
}
|
|
setAttributes(elem, options, ['value']);
|
|
$(elem).attr("role","checkbox");
|
|
break;
|
|
case "select" :
|
|
elem = document.createElement("select");
|
|
elem.setAttribute("role","select");
|
|
var msl, ovm = [];
|
|
if(options.multiple===true) {
|
|
msl = true;
|
|
elem.multiple="multiple";
|
|
$(elem).attr("aria-multiselectable","true");
|
|
} else { msl = false; }
|
|
if(options.dataUrl !== undefined) {
|
|
var rowid = options.name ? String(options.id).substring(0, String(options.id).length - String(options.name).length - 1) : String(options.id),
|
|
postData = options.postData || ajaxso.postData;
|
|
|
|
if ($t.p && $t.p.idPrefix) {
|
|
rowid = $.jgrid.stripPref($t.p.idPrefix, rowid);
|
|
}
|
|
$.ajax($.extend({
|
|
url: $.isFunction(options.dataUrl) ? options.dataUrl.call($t, rowid, vl, String(options.name)) : options.dataUrl,
|
|
type : "GET",
|
|
dataType: "html",
|
|
data: $.isFunction(postData) ? postData.call($t, rowid, vl, String(options.name)) : postData,
|
|
context: {elem:elem, options:options, vl:vl},
|
|
success: function(data){
|
|
var ovm = [], elem = this.elem, vl = this.vl,
|
|
options = $.extend({},this.options),
|
|
msl = options.multiple===true,
|
|
a = $.isFunction(options.buildSelect) ? options.buildSelect.call($t,data) : data;
|
|
if(typeof a === 'string') {
|
|
a = $( $.trim( a ) ).html();
|
|
}
|
|
if(a) {
|
|
$(elem).append(a);
|
|
setAttributes(elem, options, postData ? ['postData'] : undefined );
|
|
if(options.size === undefined) { options.size = msl ? 3 : 1;}
|
|
if(msl) {
|
|
ovm = vl.split(",");
|
|
ovm = $.map(ovm,function(n){return $.trim(n);});
|
|
} else {
|
|
ovm[0] = $.trim(vl);
|
|
}
|
|
//$(elem).attr(options);
|
|
setTimeout(function(){
|
|
$("option",elem).each(function(i){
|
|
//if(i===0) { this.selected = ""; }
|
|
// fix IE8/IE7 problem with selecting of the first item on multiple=true
|
|
if (i === 0 && elem.multiple) { this.selected = false; }
|
|
$(this).attr("role","option");
|
|
if($.inArray($.trim($(this).text()),ovm) > -1 || $.inArray($.trim($(this).val()),ovm) > -1 ) {
|
|
this.selected= "selected";
|
|
}
|
|
});
|
|
},0);
|
|
}
|
|
}
|
|
},ajaxso || {}));
|
|
} else if(options.value) {
|
|
var i;
|
|
if(options.size === undefined) {
|
|
options.size = msl ? 3 : 1;
|
|
}
|
|
if(msl) {
|
|
ovm = vl.split(",");
|
|
ovm = $.map(ovm,function(n){return $.trim(n);});
|
|
}
|
|
if(typeof options.value === 'function') { options.value = options.value(); }
|
|
var so,sv, ov,
|
|
sep = options.separator === undefined ? ":" : options.separator,
|
|
delim = options.delimiter === undefined ? ";" : options.delimiter;
|
|
if(typeof options.value === 'string') {
|
|
so = options.value.split(delim);
|
|
for(i=0; i<so.length;i++){
|
|
sv = so[i].split(sep);
|
|
if(sv.length > 2 ) {
|
|
sv[1] = $.map(sv,function(n,ii){if(ii>0) { return n;} }).join(sep);
|
|
}
|
|
ov = document.createElement("option");
|
|
ov.setAttribute("role","option");
|
|
ov.value = sv[0]; ov.innerHTML = sv[1];
|
|
elem.appendChild(ov);
|
|
if (!msl && ($.trim(sv[0]) === $.trim(vl) || $.trim(sv[1]) === $.trim(vl))) { ov.selected ="selected"; }
|
|
if (msl && ($.inArray($.trim(sv[1]), ovm)>-1 || $.inArray($.trim(sv[0]), ovm)>-1)) {ov.selected ="selected";}
|
|
}
|
|
} else if (typeof options.value === 'object') {
|
|
var oSv = options.value, key;
|
|
for (key in oSv) {
|
|
if (oSv.hasOwnProperty(key ) ){
|
|
ov = document.createElement("option");
|
|
ov.setAttribute("role","option");
|
|
ov.value = key; ov.innerHTML = oSv[key];
|
|
elem.appendChild(ov);
|
|
if (!msl && ( $.trim(key) === $.trim(vl) || $.trim(oSv[key]) === $.trim(vl)) ) { ov.selected ="selected"; }
|
|
if (msl && ($.inArray($.trim(oSv[key]),ovm)>-1 || $.inArray($.trim(key),ovm)>-1)) { ov.selected ="selected"; }
|
|
}
|
|
}
|
|
}
|
|
setAttributes(elem, options, ['value']);
|
|
}
|
|
break;
|
|
case "text" :
|
|
case "password" :
|
|
case "button" :
|
|
var role;
|
|
if(eltype==="button") { role = "button"; }
|
|
else { role = "textbox"; }
|
|
elem = document.createElement("input");
|
|
elem.type = eltype;
|
|
elem.value = vl;
|
|
setAttributes(elem, options);
|
|
if(eltype !== "button"){
|
|
if(autowidth) {
|
|
if(!options.size) { $(elem).css({width:"98%"}); }
|
|
} else if (!options.size) { options.size = 20; }
|
|
}
|
|
$(elem).attr("role",role);
|
|
break;
|
|
case "image" :
|
|
case "file" :
|
|
elem = document.createElement("input");
|
|
elem.type = eltype;
|
|
setAttributes(elem, options);
|
|
break;
|
|
case "custom" :
|
|
elem = document.createElement("span");
|
|
try {
|
|
if($.isFunction(options.custom_element)) {
|
|
var celm = options.custom_element.call($t,vl,options);
|
|
if(celm) {
|
|
celm = $(celm).addClass("customelement").attr({id:options.id,name:options.name});
|
|
$(elem).empty().append(celm);
|
|
} else {
|
|
throw "e2";
|
|
}
|
|
} else {
|
|
throw "e1";
|
|
}
|
|
} catch (e) {
|
|
if (e==="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.nodefined, $.jgrid.edit.bClose);}
|
|
if (e==="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);}
|
|
else { $.jgrid.info_dialog($.jgrid.errors.errcap,typeof e==="string"?e:e.message,$.jgrid.edit.bClose); }
|
|
}
|
|
break;
|
|
}
|
|
return elem;
|
|
},
|
|
// Date Validation Javascript
|
|
checkDate : function (format, date) {
|
|
var daysInFebruary = function(year){
|
|
// February has 29 days in any year evenly divisible by four,
|
|
// EXCEPT for centurial years which are not also divisible by 400.
|
|
return (((year % 4 === 0) && ( year % 100 !== 0 || (year % 400 === 0))) ? 29 : 28 );
|
|
},
|
|
tsp = {}, sep;
|
|
format = format.toLowerCase();
|
|
//we search for /,-,. for the date separator
|
|
if(format.indexOf("/") !== -1) {
|
|
sep = "/";
|
|
} else if(format.indexOf("-") !== -1) {
|
|
sep = "-";
|
|
} else if(format.indexOf(".") !== -1) {
|
|
sep = ".";
|
|
} else {
|
|
sep = "/";
|
|
}
|
|
format = format.split(sep);
|
|
date = date.split(sep);
|
|
if (date.length !== 3) { return false; }
|
|
var j=-1,yln, dln=-1, mln=-1, i;
|
|
for(i=0;i<format.length;i++){
|
|
var dv = isNaN(date[i]) ? 0 : parseInt(date[i],10);
|
|
tsp[format[i]] = dv;
|
|
yln = format[i];
|
|
if(yln.indexOf("y") !== -1) { j=i; }
|
|
if(yln.indexOf("m") !== -1) { mln=i; }
|
|
if(yln.indexOf("d") !== -1) { dln=i; }
|
|
}
|
|
if (format[j] === "y" || format[j] === "yyyy") {
|
|
yln=4;
|
|
} else if(format[j] ==="yy"){
|
|
yln = 2;
|
|
} else {
|
|
yln = -1;
|
|
}
|
|
var daysInMonth = [0,31,29,31,30,31,30,31,31,30,31,30,31],
|
|
strDate;
|
|
if (j === -1) {
|
|
return false;
|
|
}
|
|
strDate = tsp[format[j]].toString();
|
|
if(yln === 2 && strDate.length === 1) {yln = 1;}
|
|
if (strDate.length !== yln || (tsp[format[j]]===0 && date[j]!=="00")){
|
|
return false;
|
|
}
|
|
if(mln === -1) {
|
|
return false;
|
|
}
|
|
strDate = tsp[format[mln]].toString();
|
|
if (strDate.length<1 || tsp[format[mln]]<1 || tsp[format[mln]]>12){
|
|
return false;
|
|
}
|
|
if(dln === -1) {
|
|
return false;
|
|
}
|
|
strDate = tsp[format[dln]].toString();
|
|
if (strDate.length<1 || tsp[format[dln]]<1 || tsp[format[dln]]>31 || (tsp[format[mln]]===2 && tsp[format[dln]]>daysInFebruary(tsp[format[j]])) || tsp[format[dln]] > daysInMonth[tsp[format[mln]]]){
|
|
return false;
|
|
}
|
|
return true;
|
|
},
|
|
isEmpty : function(val)
|
|
{
|
|
if (val.match(/^\s+$/) || val === "") {
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
checkTime : function(time){
|
|
// checks only hh:ss (and optional am/pm)
|
|
var re = /^(\d{1,2}):(\d{2})([apAP][Mm])?$/,regs;
|
|
if(!$.jgrid.isEmpty(time))
|
|
{
|
|
regs = time.match(re);
|
|
if(regs) {
|
|
if(regs[3]) {
|
|
if(regs[1] < 1 || regs[1] > 12) { return false; }
|
|
} else {
|
|
if(regs[1] > 23) { return false; }
|
|
}
|
|
if(regs[2] > 59) {
|
|
return false;
|
|
}
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
checkValues : function(val, valref, customobject, nam) {
|
|
var edtrul,i, nm, dft, len, g = this, cm = g.p.colModel;
|
|
if(customobject === undefined) {
|
|
if(typeof valref==='string'){
|
|
for( i =0, len=cm.length;i<len; i++){
|
|
if(cm[i].name===valref) {
|
|
edtrul = cm[i].editrules;
|
|
valref = i;
|
|
if(cm[i].formoptions != null) { nm = cm[i].formoptions.label; }
|
|
break;
|
|
}
|
|
}
|
|
} else if(valref >=0) {
|
|
edtrul = cm[valref].editrules;
|
|
}
|
|
} else {
|
|
edtrul = customobject;
|
|
nm = nam===undefined ? "_" : nam;
|
|
}
|
|
if(edtrul) {
|
|
if(!nm) { nm = g.p.colNames != null ? g.p.colNames[valref] : cm[valref].label; }
|
|
if(edtrul.required === true) {
|
|
if( $.jgrid.isEmpty(val) ) { return [false,nm+": "+$.jgrid.edit.msg.required,""]; }
|
|
}
|
|
// force required
|
|
var rqfield = edtrul.required === false ? false : true;
|
|
if(edtrul.number === true) {
|
|
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
|
|
if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.number,""]; }
|
|
}
|
|
}
|
|
if(edtrul.minValue !== undefined && !isNaN(edtrul.minValue)) {
|
|
if (parseFloat(val) < parseFloat(edtrul.minValue) ) { return [false,nm+": "+$.jgrid.edit.msg.minValue+" "+edtrul.minValue,""];}
|
|
}
|
|
if(edtrul.maxValue !== undefined && !isNaN(edtrul.maxValue)) {
|
|
if (parseFloat(val) > parseFloat(edtrul.maxValue) ) { return [false,nm+": "+$.jgrid.edit.msg.maxValue+" "+edtrul.maxValue,""];}
|
|
}
|
|
var filter;
|
|
if(edtrul.email === true) {
|
|
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
|
|
// taken from $ Validate plugin
|
|
filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
|
|
if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.email,""];}
|
|
}
|
|
}
|
|
if(edtrul.integer === true) {
|
|
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
|
|
if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""]; }
|
|
if ((val % 1 !== 0) || (val.indexOf('.') !== -1)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""];}
|
|
}
|
|
}
|
|
if(edtrul.date === true) {
|
|
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
|
|
if(cm[valref].formatoptions && cm[valref].formatoptions.newformat) {
|
|
dft = cm[valref].formatoptions.newformat;
|
|
if( $.jgrid.formatter.date.masks.hasOwnProperty(dft) ) {
|
|
dft = $.jgrid.formatter.date.masks[dft];
|
|
}
|
|
} else {
|
|
dft = cm[valref].datefmt || "Y-m-d";
|
|
}
|
|
if(!$.jgrid.checkDate (dft, val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - "+dft,""]; }
|
|
}
|
|
}
|
|
if(edtrul.time === true) {
|
|
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
|
|
if(!$.jgrid.checkTime (val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - hh:mm (am/pm)",""]; }
|
|
}
|
|
}
|
|
if(edtrul.url === true) {
|
|
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
|
|
filter = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
|
|
if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.url,""];}
|
|
}
|
|
}
|
|
if(edtrul.custom === true) {
|
|
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
|
|
if($.isFunction(edtrul.custom_func)) {
|
|
var ret = edtrul.custom_func.call(g,val,nm,valref);
|
|
return $.isArray(ret) ? ret : [false,$.jgrid.edit.msg.customarray,""];
|
|
}
|
|
return [false,$.jgrid.edit.msg.customfcheck,""];
|
|
}
|
|
}
|
|
}
|
|
return [true,"",""];
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*
|
|
* jqFilter jQuery jqGrid filter addon.
|
|
* Copyright (c) 2011, Tony Tomov, tony@trirand.com
|
|
* Dual licensed under the MIT and GPL licenses
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
*
|
|
* The work is inspired from this Stefan Pirvu
|
|
* http://www.codeproject.com/KB/scripting/json-filtering.aspx
|
|
*
|
|
* The filter uses JSON entities to hold filter rules and groups. Here is an example of a filter:
|
|
|
|
{ "groupOp": "AND",
|
|
"groups" : [
|
|
{ "groupOp": "OR",
|
|
"rules": [
|
|
{ "field": "name", "op": "eq", "data": "England" },
|
|
{ "field": "id", "op": "le", "data": "5"}
|
|
]
|
|
}
|
|
],
|
|
"rules": [
|
|
{ "field": "name", "op": "eq", "data": "Romania" },
|
|
{ "field": "id", "op": "le", "data": "1"}
|
|
]
|
|
}
|
|
*/
|
|
/*jshint eqeqeq:false, eqnull:true, devel:true */
|
|
/*global jQuery */
|
|
|
|
(function ($) {
|
|
"use strict";
|
|
|
|
$.fn.jqFilter = function( arg ) {
|
|
if (typeof arg === 'string') {
|
|
|
|
var fn = $.fn.jqFilter[arg];
|
|
if (!fn) {
|
|
throw ("jqFilter - No such method: " + arg);
|
|
}
|
|
var args = $.makeArray(arguments).slice(1);
|
|
return fn.apply(this,args);
|
|
}
|
|
|
|
var p = $.extend(true,{
|
|
filter: null,
|
|
columns: [],
|
|
onChange : null,
|
|
afterRedraw : null,
|
|
checkValues : null,
|
|
error: false,
|
|
errmsg : "",
|
|
errorcheck : true,
|
|
showQuery : true,
|
|
sopt : null,
|
|
ops : [],
|
|
operands : null,
|
|
numopts : ['eq','ne', 'lt', 'le', 'gt', 'ge', 'nu', 'nn', 'in', 'ni'],
|
|
stropts : ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc', 'nu', 'nn', 'in', 'ni'],
|
|
strarr : ['text', 'string', 'blob'],
|
|
groupOps : [{ op: "AND", text: "AND" }, { op: "OR", text: "OR" }],
|
|
groupButton : true,
|
|
ruleButtons : true,
|
|
direction : "ltr"
|
|
}, $.jgrid.filter, arg || {});
|
|
return this.each( function() {
|
|
if (this.filter) {return;}
|
|
this.p = p;
|
|
// setup filter in case if they is not defined
|
|
if (this.p.filter === null || this.p.filter === undefined) {
|
|
this.p.filter = {
|
|
groupOp: this.p.groupOps[0].op,
|
|
rules: [],
|
|
groups: []
|
|
};
|
|
}
|
|
var i, len = this.p.columns.length, cl,
|
|
isIE = /msie/i.test(navigator.userAgent) && !window.opera;
|
|
|
|
// translating the options
|
|
this.p.initFilter = $.extend(true,{},this.p.filter);
|
|
|
|
// set default values for the columns if they are not set
|
|
if( !len ) {return;}
|
|
for(i=0; i < len; i++) {
|
|
cl = this.p.columns[i];
|
|
if( cl.stype ) {
|
|
// grid compatibility
|
|
cl.inputtype = cl.stype;
|
|
} else if(!cl.inputtype) {
|
|
cl.inputtype = 'text';
|
|
}
|
|
if( cl.sorttype ) {
|
|
// grid compatibility
|
|
cl.searchtype = cl.sorttype;
|
|
} else if (!cl.searchtype) {
|
|
cl.searchtype = 'string';
|
|
}
|
|
if(cl.hidden === undefined) {
|
|
// jqGrid compatibility
|
|
cl.hidden = false;
|
|
}
|
|
if(!cl.label) {
|
|
cl.label = cl.name;
|
|
}
|
|
if(cl.index) {
|
|
cl.name = cl.index;
|
|
}
|
|
if(!cl.hasOwnProperty('searchoptions')) {
|
|
cl.searchoptions = {};
|
|
}
|
|
if(!cl.hasOwnProperty('searchrules')) {
|
|
cl.searchrules = {};
|
|
}
|
|
|
|
}
|
|
if(this.p.showQuery) {
|
|
$(this).append("<table class='queryresult ui-widget ui-widget-content' style='display:block;max-width:440px;border:0px none;' dir='"+this.p.direction+"'><tbody><tr><td class='query'></td></tr></tbody></table>");
|
|
}
|
|
var getGrid = function () {
|
|
return $("#" + $.jgrid.jqID(p.id))[0] || null;
|
|
};
|
|
/*
|
|
*Perform checking.
|
|
*
|
|
*/
|
|
var checkData = function(val, colModelItem) {
|
|
var ret = [true,""], $t = getGrid();
|
|
if($.isFunction(colModelItem.searchrules)) {
|
|
ret = colModelItem.searchrules.call($t, val, colModelItem);
|
|
} else if($.jgrid && $.jgrid.checkValues) {
|
|
try {
|
|
ret = $.jgrid.checkValues.call($t, val, -1, colModelItem.searchrules, colModelItem.label);
|
|
} catch (e) {}
|
|
}
|
|
if(ret && ret.length && ret[0] === false) {
|
|
p.error = !ret[0];
|
|
p.errmsg = ret[1];
|
|
}
|
|
};
|
|
/* moving to common
|
|
randId = function() {
|
|
return Math.floor(Math.random()*10000).toString();
|
|
};
|
|
*/
|
|
|
|
this.onchange = function ( ){
|
|
// clear any error
|
|
this.p.error = false;
|
|
this.p.errmsg="";
|
|
return $.isFunction(this.p.onChange) ? this.p.onChange.call( this, this.p ) : false;
|
|
};
|
|
/*
|
|
* Redraw the filter every time when new field is added/deleted
|
|
* and field is changed
|
|
*/
|
|
this.reDraw = function() {
|
|
$("table.group:first",this).remove();
|
|
var t = this.createTableForGroup(p.filter, null);
|
|
$(this).append(t);
|
|
if($.isFunction(this.p.afterRedraw) ) {
|
|
this.p.afterRedraw.call(this, this.p);
|
|
}
|
|
};
|
|
/*
|
|
* Creates a grouping data for the filter
|
|
* @param group - object
|
|
* @param parentgroup - object
|
|
*/
|
|
this.createTableForGroup = function(group, parentgroup) {
|
|
var that = this, i;
|
|
// this table will hold all the group (tables) and rules (rows)
|
|
var table = $("<table class='group ui-widget ui-widget-content' style='border:0px none;'><tbody></tbody></table>"),
|
|
// create error message row
|
|
align = "left";
|
|
if(this.p.direction === "rtl") {
|
|
align = "right";
|
|
table.attr("dir","rtl");
|
|
}
|
|
if(parentgroup === null) {
|
|
table.append("<tr class='error' style='display:none;'><th colspan='5' class='ui-state-error' align='"+align+"'></th></tr>");
|
|
}
|
|
|
|
var tr = $("<tr></tr>");
|
|
table.append(tr);
|
|
// this header will hold the group operator type and group action buttons for
|
|
// creating subgroup "+ {}", creating rule "+" or deleting the group "-"
|
|
var th = $("<th colspan='5' align='"+align+"'></th>");
|
|
tr.append(th);
|
|
|
|
if(this.p.ruleButtons === true) {
|
|
// dropdown for: choosing group operator type
|
|
var groupOpSelect = $("<select class='opsel'></select>");
|
|
th.append(groupOpSelect);
|
|
// populate dropdown with all posible group operators: or, and
|
|
var str= "", selected;
|
|
for (i = 0; i < p.groupOps.length; i++) {
|
|
selected = group.groupOp === that.p.groupOps[i].op ? " selected='selected'" :"";
|
|
str += "<option value='"+that.p.groupOps[i].op+"'" + selected+">"+that.p.groupOps[i].text+"</option>";
|
|
}
|
|
|
|
groupOpSelect
|
|
.append(str)
|
|
.bind('change',function() {
|
|
group.groupOp = $(groupOpSelect).val();
|
|
that.onchange(); // signals that the filter has changed
|
|
});
|
|
}
|
|
// button for adding a new subgroup
|
|
var inputAddSubgroup ="<span></span>";
|
|
if(this.p.groupButton) {
|
|
inputAddSubgroup = $("<input type='button' value='+ {}' title='Add subgroup' class='add-group'/>");
|
|
inputAddSubgroup.bind('click',function() {
|
|
if (group.groups === undefined ) {
|
|
group.groups = [];
|
|
}
|
|
|
|
group.groups.push({
|
|
groupOp: p.groupOps[0].op,
|
|
rules: [],
|
|
groups: []
|
|
}); // adding a new group
|
|
|
|
that.reDraw(); // the html has changed, force reDraw
|
|
|
|
that.onchange(); // signals that the filter has changed
|
|
return false;
|
|
});
|
|
}
|
|
th.append(inputAddSubgroup);
|
|
if(this.p.ruleButtons === true) {
|
|
// button for adding a new rule
|
|
var inputAddRule = $("<input type='button' value='+' title='Add rule' class='add-rule ui-add'/>"), cm;
|
|
inputAddRule.bind('click',function() {
|
|
//if(!group) { group = {};}
|
|
if (group.rules === undefined) {
|
|
group.rules = [];
|
|
}
|
|
for (i = 0; i < that.p.columns.length; i++) {
|
|
// but show only serchable and serchhidden = true fields
|
|
var searchable = (that.p.columns[i].search === undefined) ? true: that.p.columns[i].search,
|
|
hidden = (that.p.columns[i].hidden === true),
|
|
ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true);
|
|
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
|
|
cm = that.p.columns[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
var opr;
|
|
if( cm.searchoptions.sopt ) {opr = cm.searchoptions.sopt;}
|
|
else if(that.p.sopt) { opr= that.p.sopt; }
|
|
else if ( $.inArray(cm.searchtype, that.p.strarr) !== -1 ) {opr = that.p.stropts;}
|
|
else {opr = that.p.numopts;}
|
|
|
|
group.rules.push({
|
|
field: cm.name,
|
|
op: opr[0],
|
|
data: ""
|
|
}); // adding a new rule
|
|
|
|
that.reDraw(); // the html has changed, force reDraw
|
|
// for the moment no change have been made to the rule, so
|
|
// this will not trigger onchange event
|
|
return false;
|
|
});
|
|
th.append(inputAddRule);
|
|
}
|
|
|
|
// button for delete the group
|
|
if (parentgroup !== null) { // ignore the first group
|
|
var inputDeleteGroup = $("<input type='button' value='-' title='Delete group' class='delete-group'/>");
|
|
th.append(inputDeleteGroup);
|
|
inputDeleteGroup.bind('click',function() {
|
|
// remove group from parent
|
|
for (i = 0; i < parentgroup.groups.length; i++) {
|
|
if (parentgroup.groups[i] === group) {
|
|
parentgroup.groups.splice(i, 1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
that.reDraw(); // the html has changed, force reDraw
|
|
|
|
that.onchange(); // signals that the filter has changed
|
|
return false;
|
|
});
|
|
}
|
|
|
|
// append subgroup rows
|
|
if (group.groups !== undefined) {
|
|
for (i = 0; i < group.groups.length; i++) {
|
|
var trHolderForSubgroup = $("<tr></tr>");
|
|
table.append(trHolderForSubgroup);
|
|
|
|
var tdFirstHolderForSubgroup = $("<td class='first'></td>");
|
|
trHolderForSubgroup.append(tdFirstHolderForSubgroup);
|
|
|
|
var tdMainHolderForSubgroup = $("<td colspan='4'></td>");
|
|
tdMainHolderForSubgroup.append(this.createTableForGroup(group.groups[i], group));
|
|
trHolderForSubgroup.append(tdMainHolderForSubgroup);
|
|
}
|
|
}
|
|
if(group.groupOp === undefined) {
|
|
group.groupOp = that.p.groupOps[0].op;
|
|
}
|
|
|
|
// append rules rows
|
|
if (group.rules !== undefined) {
|
|
for (i = 0; i < group.rules.length; i++) {
|
|
table.append(
|
|
this.createTableRowForRule(group.rules[i], group)
|
|
);
|
|
}
|
|
}
|
|
|
|
return table;
|
|
};
|
|
/*
|
|
* Create the rule data for the filter
|
|
*/
|
|
this.createTableRowForRule = function(rule, group ) {
|
|
// save current entity in a variable so that it could
|
|
// be referenced in anonimous method calls
|
|
|
|
var that=this, $t = getGrid(), tr = $("<tr></tr>"),
|
|
//document.createElement("tr"),
|
|
|
|
// first column used for padding
|
|
//tdFirstHolderForRule = document.createElement("td"),
|
|
i, op, trpar, cm, str="", selected;
|
|
//tdFirstHolderForRule.setAttribute("class", "first");
|
|
tr.append("<td class='first'></td>");
|
|
|
|
|
|
// create field container
|
|
var ruleFieldTd = $("<td class='columns'></td>");
|
|
tr.append(ruleFieldTd);
|
|
|
|
|
|
// dropdown for: choosing field
|
|
var ruleFieldSelect = $("<select></select>"), ina, aoprs = [];
|
|
ruleFieldTd.append(ruleFieldSelect);
|
|
ruleFieldSelect.bind('change',function() {
|
|
rule.field = $(ruleFieldSelect).val();
|
|
|
|
trpar = $(this).parents("tr:first");
|
|
for (i=0;i<that.p.columns.length;i++) {
|
|
if(that.p.columns[i].name === rule.field) {
|
|
cm = that.p.columns[i];
|
|
break;
|
|
}
|
|
}
|
|
if(!cm) {return;}
|
|
cm.searchoptions.id = $.jgrid.randId();
|
|
if(isIE && cm.inputtype === "text") {
|
|
if(!cm.searchoptions.size) {
|
|
cm.searchoptions.size = 10;
|
|
}
|
|
}
|
|
var elm = $.jgrid.createEl.call($t, cm.inputtype,cm.searchoptions, "", true, that.p.ajaxSelectOptions || {}, true);
|
|
$(elm).addClass("input-elm");
|
|
//that.createElement(rule, "");
|
|
|
|
if( cm.searchoptions.sopt ) {op = cm.searchoptions.sopt;}
|
|
else if(that.p.sopt) { op= that.p.sopt; }
|
|
else if ($.inArray(cm.searchtype, that.p.strarr) !== -1) {op = that.p.stropts;}
|
|
else {op = that.p.numopts;}
|
|
// operators
|
|
var s ="", so = 0;
|
|
aoprs = [];
|
|
$.each(that.p.ops, function() { aoprs.push(this.oper); });
|
|
for ( i = 0 ; i < op.length; i++) {
|
|
ina = $.inArray(op[i],aoprs);
|
|
if(ina !== -1) {
|
|
if(so===0) {
|
|
rule.op = that.p.ops[ina].oper;
|
|
}
|
|
s += "<option value='"+that.p.ops[ina].oper+"'>"+that.p.ops[ina].text+"</option>";
|
|
so++;
|
|
}
|
|
}
|
|
$(".selectopts",trpar).empty().append( s );
|
|
$(".selectopts",trpar)[0].selectedIndex = 0;
|
|
if( $.jgrid.msie && $.jgrid.msiever() < 9) {
|
|
var sw = parseInt($("select.selectopts",trpar)[0].offsetWidth, 10) + 1;
|
|
$(".selectopts",trpar).width( sw );
|
|
$(".selectopts",trpar).css("width","auto");
|
|
}
|
|
// data
|
|
$(".data",trpar).empty().append( elm );
|
|
$.jgrid.bindEv.call($t, elm, cm.searchoptions);
|
|
$(".input-elm",trpar).bind('change',function( e ) {
|
|
var tmo = $(this).hasClass("ui-autocomplete-input") ? 200 :0;
|
|
setTimeout(function(){
|
|
var elem = e.target;
|
|
rule.data = elem.nodeName.toUpperCase() === "SPAN" && cm.searchoptions && $.isFunction(cm.searchoptions.custom_value) ?
|
|
cm.searchoptions.custom_value.call($t, $(elem).children(".customelement:first"), 'get') : elem.value;
|
|
that.onchange(); // signals that the filter has changed
|
|
}, tmo);
|
|
});
|
|
setTimeout(function(){ //IE, Opera, Chrome
|
|
rule.data = $(elm).val();
|
|
that.onchange(); // signals that the filter has changed
|
|
}, 0);
|
|
});
|
|
|
|
// populate drop down with user provided column definitions
|
|
var j=0;
|
|
for (i = 0; i < that.p.columns.length; i++) {
|
|
// but show only serchable and serchhidden = true fields
|
|
var searchable = (that.p.columns[i].search === undefined) ? true: that.p.columns[i].search,
|
|
hidden = (that.p.columns[i].hidden === true),
|
|
ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true);
|
|
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
|
|
selected = "";
|
|
if(rule.field === that.p.columns[i].name) {
|
|
selected = " selected='selected'";
|
|
j=i;
|
|
}
|
|
str += "<option value='"+that.p.columns[i].name+"'" +selected+">"+that.p.columns[i].label+"</option>";
|
|
}
|
|
}
|
|
ruleFieldSelect.append( str );
|
|
|
|
|
|
// create operator container
|
|
var ruleOperatorTd = $("<td class='operators'></td>");
|
|
tr.append(ruleOperatorTd);
|
|
cm = p.columns[j];
|
|
// create it here so it can be referentiated in the onchange event
|
|
//var RD = that.createElement(rule, rule.data);
|
|
cm.searchoptions.id = $.jgrid.randId();
|
|
if(isIE && cm.inputtype === "text") {
|
|
if(!cm.searchoptions.size) {
|
|
cm.searchoptions.size = 10;
|
|
}
|
|
}
|
|
var ruleDataInput = $.jgrid.createEl.call($t, cm.inputtype,cm.searchoptions, rule.data, true, that.p.ajaxSelectOptions || {}, true);
|
|
if(rule.op === 'nu' || rule.op === 'nn') {
|
|
$(ruleDataInput).attr('readonly','true');
|
|
$(ruleDataInput).attr('disabled','true');
|
|
} //retain the state of disabled text fields in case of null ops
|
|
// dropdown for: choosing operator
|
|
var ruleOperatorSelect = $("<select class='selectopts'></select>");
|
|
ruleOperatorTd.append(ruleOperatorSelect);
|
|
ruleOperatorSelect.bind('change',function() {
|
|
rule.op = $(ruleOperatorSelect).val();
|
|
trpar = $(this).parents("tr:first");
|
|
var rd = $(".input-elm",trpar)[0];
|
|
if (rule.op === "nu" || rule.op === "nn") { // disable for operator "is null" and "is not null"
|
|
rule.data = "";
|
|
if(rd.tagName.toUpperCase() !== 'SELECT') rd.value = "";
|
|
rd.setAttribute("readonly", "true");
|
|
rd.setAttribute("disabled", "true");
|
|
} else {
|
|
if(rd.tagName.toUpperCase() === 'SELECT') rule.data = rd.value;
|
|
rd.removeAttribute("readonly");
|
|
rd.removeAttribute("disabled");
|
|
}
|
|
|
|
that.onchange(); // signals that the filter has changed
|
|
});
|
|
|
|
// populate drop down with all available operators
|
|
if( cm.searchoptions.sopt ) {op = cm.searchoptions.sopt;}
|
|
else if(that.p.sopt) { op= that.p.sopt; }
|
|
else if ($.inArray(cm.searchtype, that.p.strarr) !== -1) {op = that.p.stropts;}
|
|
else {op = that.p.numopts;}
|
|
str="";
|
|
$.each(that.p.ops, function() { aoprs.push(this.oper); });
|
|
for ( i = 0; i < op.length; i++) {
|
|
ina = $.inArray(op[i],aoprs);
|
|
if(ina !== -1) {
|
|
selected = rule.op === that.p.ops[ina].oper ? " selected='selected'" : "";
|
|
str += "<option value='"+that.p.ops[ina].oper+"'"+selected+">"+that.p.ops[ina].text+"</option>";
|
|
}
|
|
}
|
|
ruleOperatorSelect.append( str );
|
|
// create data container
|
|
var ruleDataTd = $("<td class='data'></td>");
|
|
tr.append(ruleDataTd);
|
|
|
|
// textbox for: data
|
|
// is created previously
|
|
//ruleDataInput.setAttribute("type", "text");
|
|
ruleDataTd.append(ruleDataInput);
|
|
$.jgrid.bindEv.call($t, ruleDataInput, cm.searchoptions);
|
|
$(ruleDataInput)
|
|
.addClass("input-elm")
|
|
.bind('change', function() {
|
|
rule.data = cm.inputtype === 'custom' ? cm.searchoptions.custom_value.call($t, $(this).children(".customelement:first"),'get') : $(this).val();
|
|
that.onchange(); // signals that the filter has changed
|
|
});
|
|
|
|
// create action container
|
|
var ruleDeleteTd = $("<td></td>");
|
|
tr.append(ruleDeleteTd);
|
|
|
|
// create button for: delete rule
|
|
if(this.p.ruleButtons === true) {
|
|
var ruleDeleteInput = $("<input type='button' value='-' title='Delete rule' class='delete-rule ui-del'/>");
|
|
ruleDeleteTd.append(ruleDeleteInput);
|
|
//$(ruleDeleteInput).html("").height(20).width(30).button({icons: { primary: "ui-icon-minus", text:false}});
|
|
ruleDeleteInput.bind('click',function() {
|
|
// remove rule from group
|
|
for (i = 0; i < group.rules.length; i++) {
|
|
if (group.rules[i] === rule) {
|
|
group.rules.splice(i, 1);
|
|
break;
|
|
}
|
|
}
|
|
|
|
that.reDraw(); // the html has changed, force reDraw
|
|
|
|
that.onchange(); // signals that the filter has changed
|
|
return false;
|
|
});
|
|
}
|
|
return tr;
|
|
};
|
|
|
|
this.getStringForGroup = function(group) {
|
|
var s = "(", index;
|
|
if (group.groups !== undefined) {
|
|
for (index = 0; index < group.groups.length; index++) {
|
|
if (s.length > 1) {
|
|
s += " " + group.groupOp + " ";
|
|
}
|
|
try {
|
|
s += this.getStringForGroup(group.groups[index]);
|
|
} catch (eg) {alert(eg);}
|
|
}
|
|
}
|
|
|
|
if (group.rules !== undefined) {
|
|
try{
|
|
for (index = 0; index < group.rules.length; index++) {
|
|
if (s.length > 1) {
|
|
s += " " + group.groupOp + " ";
|
|
}
|
|
s += this.getStringForRule(group.rules[index]);
|
|
}
|
|
} catch (e) {alert(e);}
|
|
}
|
|
|
|
s += ")";
|
|
|
|
if (s === "()") {
|
|
return ""; // ignore groups that don't have rules
|
|
}
|
|
return s;
|
|
};
|
|
this.getStringForRule = function(rule) {
|
|
var opUF = "",opC="", i, cm, ret, val,
|
|
numtypes = ['int', 'integer', 'float', 'number', 'currency']; // jqGrid
|
|
for (i = 0; i < this.p.ops.length; i++) {
|
|
if (this.p.ops[i].oper === rule.op) {
|
|
opUF = this.p.operands.hasOwnProperty(rule.op) ? this.p.operands[rule.op] : "";
|
|
opC = this.p.ops[i].oper;
|
|
break;
|
|
}
|
|
}
|
|
for (i=0; i<this.p.columns.length; i++) {
|
|
if(this.p.columns[i].name === rule.field) {
|
|
cm = this.p.columns[i];
|
|
break;
|
|
}
|
|
}
|
|
if (cm === undefined) { return ""; }
|
|
val = rule.data;
|
|
if(opC === 'bw' || opC === 'bn') { val = val+"%"; }
|
|
if(opC === 'ew' || opC === 'en') { val = "%"+val; }
|
|
if(opC === 'cn' || opC === 'nc') { val = "%"+val+"%"; }
|
|
if(opC === 'in' || opC === 'ni') { val = " ("+val+")"; }
|
|
if(p.errorcheck) { checkData(rule.data, cm); }
|
|
if($.inArray(cm.searchtype, numtypes) !== -1 || opC === 'nn' || opC === 'nu') { ret = rule.field + " " + opUF + " " + val; }
|
|
else { ret = rule.field + " " + opUF + " \"" + val + "\""; }
|
|
return ret;
|
|
};
|
|
this.resetFilter = function () {
|
|
this.p.filter = $.extend(true,{},this.p.initFilter);
|
|
this.reDraw();
|
|
this.onchange();
|
|
};
|
|
this.hideError = function() {
|
|
$("th.ui-state-error", this).html("");
|
|
$("tr.error", this).hide();
|
|
};
|
|
this.showError = function() {
|
|
$("th.ui-state-error", this).html(this.p.errmsg);
|
|
$("tr.error", this).show();
|
|
};
|
|
this.toUserFriendlyString = function() {
|
|
return this.getStringForGroup(p.filter);
|
|
};
|
|
this.toString = function() {
|
|
// this will obtain a string that can be used to match an item.
|
|
var that = this;
|
|
function getStringRule(rule) {
|
|
if(that.p.errorcheck) {
|
|
var i, cm;
|
|
for (i=0; i<that.p.columns.length; i++) {
|
|
if(that.p.columns[i].name === rule.field) {
|
|
cm = that.p.columns[i];
|
|
break;
|
|
}
|
|
}
|
|
if(cm) {checkData(rule.data, cm);}
|
|
}
|
|
return rule.op + "(item." + rule.field + ",'" + rule.data + "')";
|
|
}
|
|
|
|
function getStringForGroup(group) {
|
|
var s = "(", index;
|
|
|
|
if (group.groups !== undefined) {
|
|
for (index = 0; index < group.groups.length; index++) {
|
|
if (s.length > 1) {
|
|
if (group.groupOp === "OR") {
|
|
s += " || ";
|
|
}
|
|
else {
|
|
s += " && ";
|
|
}
|
|
}
|
|
s += getStringForGroup(group.groups[index]);
|
|
}
|
|
}
|
|
|
|
if (group.rules !== undefined) {
|
|
for (index = 0; index < group.rules.length; index++) {
|
|
if (s.length > 1) {
|
|
if (group.groupOp === "OR") {
|
|
s += " || ";
|
|
}
|
|
else {
|
|
s += " && ";
|
|
}
|
|
}
|
|
s += getStringRule(group.rules[index]);
|
|
}
|
|
}
|
|
|
|
s += ")";
|
|
|
|
if (s === "()") {
|
|
return ""; // ignore groups that don't have rules
|
|
}
|
|
return s;
|
|
}
|
|
|
|
return getStringForGroup(this.p.filter);
|
|
};
|
|
|
|
// Here we init the filter
|
|
this.reDraw();
|
|
|
|
if(this.p.showQuery) {
|
|
this.onchange();
|
|
}
|
|
// mark is as created so that it will not be created twice on this element
|
|
this.filter = true;
|
|
});
|
|
};
|
|
$.extend($.fn.jqFilter,{
|
|
/*
|
|
* Return SQL like string. Can be used directly
|
|
*/
|
|
toSQLString : function()
|
|
{
|
|
var s ="";
|
|
this.each(function(){
|
|
s = this.toUserFriendlyString();
|
|
});
|
|
return s;
|
|
},
|
|
/*
|
|
* Return filter data as object.
|
|
*/
|
|
filterData : function()
|
|
{
|
|
var s;
|
|
this.each(function(){
|
|
s = this.p.filter;
|
|
});
|
|
return s;
|
|
|
|
},
|
|
getParameter : function (param) {
|
|
if(param !== undefined) {
|
|
if (this.p.hasOwnProperty(param) ) {
|
|
return this.p[param];
|
|
}
|
|
}
|
|
return this.p;
|
|
},
|
|
resetFilter: function() {
|
|
return this.each(function(){
|
|
this.resetFilter();
|
|
});
|
|
},
|
|
addFilter: function (pfilter) {
|
|
if (typeof pfilter === "string") {
|
|
pfilter = $.jgrid.parse( pfilter );
|
|
}
|
|
this.each(function(){
|
|
this.p.filter = pfilter;
|
|
this.reDraw();
|
|
this.onchange();
|
|
});
|
|
}
|
|
|
|
});
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false, eqnull:true, devel:true */
|
|
/*global xmlJsonClass, jQuery */
|
|
(function($){
|
|
/**
|
|
* jqGrid extension for form editing Grid Data
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
**/
|
|
"use strict";
|
|
var rp_ge = {};
|
|
$.jgrid.extend({
|
|
searchGrid : function (p) {
|
|
p = $.extend(true, {
|
|
recreateFilter: false,
|
|
drag: true,
|
|
sField:'searchField',
|
|
sValue:'searchString',
|
|
sOper: 'searchOper',
|
|
sFilter: 'filters',
|
|
loadDefaults: true, // this options activates loading of default filters from grid's postData for Multipe Search only.
|
|
beforeShowSearch: null,
|
|
afterShowSearch : null,
|
|
onInitializeSearch: null,
|
|
afterRedraw : null,
|
|
afterChange: null,
|
|
closeAfterSearch : false,
|
|
closeAfterReset: false,
|
|
closeOnEscape : false,
|
|
searchOnEnter : false,
|
|
multipleSearch : false,
|
|
multipleGroup : false,
|
|
//cloneSearchRowOnAdd: true,
|
|
top : 0,
|
|
left: 0,
|
|
jqModal : true,
|
|
modal: false,
|
|
resize : true,
|
|
width: 450,
|
|
height: 'auto',
|
|
dataheight: 'auto',
|
|
showQuery: false,
|
|
errorcheck : true,
|
|
sopt: null,
|
|
stringResult: undefined,
|
|
onClose : null,
|
|
onSearch : null,
|
|
onReset : null,
|
|
toTop : true,
|
|
overlay : 30,
|
|
columns : [],
|
|
tmplNames : null,
|
|
tmplFilters : null,
|
|
tmplLabel : ' Template: ',
|
|
showOnLoad: false,
|
|
layer: null,
|
|
operands : { "eq" :"=", "ne":"<>","lt":"<","le":"<=","gt":">","ge":">=","bw":"LIKE","bn":"NOT LIKE","in":"IN","ni":"NOT IN","ew":"LIKE","en":"NOT LIKE","cn":"LIKE","nc":"NOT LIKE","nu":"IS NULL","nn":"ISNOT NULL"}
|
|
}, $.jgrid.search, p || {});
|
|
return this.each(function() {
|
|
var $t = this;
|
|
if(!$t.grid) {return;}
|
|
var fid = "fbox_"+$t.p.id,
|
|
showFrm = true,
|
|
mustReload = true,
|
|
IDs = {themodal:'searchmod'+fid,modalhead:'searchhd'+fid,modalcontent:'searchcnt'+fid, scrollelm : fid},
|
|
defaultFilters = $t.p.postData[p.sFilter];
|
|
if(typeof defaultFilters === "string") {
|
|
defaultFilters = $.jgrid.parse( defaultFilters );
|
|
}
|
|
if(p.recreateFilter === true) {
|
|
$("#"+$.jgrid.jqID(IDs.themodal)).remove();
|
|
}
|
|
function showFilter(_filter) {
|
|
showFrm = $($t).triggerHandler("jqGridFilterBeforeShow", [_filter]);
|
|
if(showFrm === undefined) {
|
|
showFrm = true;
|
|
}
|
|
if(showFrm && $.isFunction(p.beforeShowSearch)) {
|
|
showFrm = p.beforeShowSearch.call($t,_filter);
|
|
}
|
|
if(showFrm) {
|
|
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(fid),jqm:p.jqModal, modal:p.modal, overlay: p.overlay, toTop: p.toTop});
|
|
$($t).triggerHandler("jqGridFilterAfterShow", [_filter]);
|
|
if($.isFunction(p.afterShowSearch)) {
|
|
p.afterShowSearch.call($t, _filter);
|
|
}
|
|
}
|
|
}
|
|
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
|
|
showFilter($("#fbox_"+$.jgrid.jqID(+$t.p.id)));
|
|
} else {
|
|
var fil = $("<div><div id='"+fid+"' class='searchFilter' style='overflow:auto'></div></div>").insertBefore("#gview_"+$.jgrid.jqID($t.p.id)),
|
|
align = "left", butleft ="";
|
|
if($t.p.direction === "rtl") {
|
|
align = "right";
|
|
butleft = " style='text-align:left'";
|
|
fil.attr("dir","rtl");
|
|
}
|
|
var columns = $.extend([],$t.p.colModel),
|
|
bS ="<a id='"+fid+"_search' class='fm-button ui-state-default ui-corner-all fm-button-icon-right ui-reset'><span class='ui-icon ui-icon-search'></span>"+p.Find+"</a>",
|
|
bC ="<a id='"+fid+"_reset' class='fm-button ui-state-default ui-corner-all fm-button-icon-left ui-search'><span class='ui-icon ui-icon-arrowreturnthick-1-w'></span>"+p.Reset+"</a>",
|
|
bQ = "", tmpl="", colnm, found = false, bt, cmi=-1;
|
|
if(p.showQuery) {
|
|
bQ ="<a id='"+fid+"_query' class='fm-button ui-state-default ui-corner-all fm-button-icon-left'><span class='ui-icon ui-icon-comment'></span>Query</a>";
|
|
}
|
|
if(!p.columns.length) {
|
|
$.each(columns, function(i,n){
|
|
if(!n.label) {
|
|
n.label = $t.p.colNames[i];
|
|
}
|
|
// find first searchable column and set it if no default filter
|
|
if(!found) {
|
|
var searchable = (n.search === undefined) ? true: n.search ,
|
|
hidden = (n.hidden === true),
|
|
ignoreHiding = (n.searchoptions && n.searchoptions.searchhidden === true);
|
|
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
|
|
found = true;
|
|
colnm = n.index || n.name;
|
|
cmi =i;
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
columns = p.columns;
|
|
cmi = 0;
|
|
colnm = columns[0].index || columns[0].name;
|
|
}
|
|
// old behaviour
|
|
if( (!defaultFilters && colnm) || p.multipleSearch === false ) {
|
|
var cmop = "eq";
|
|
if(cmi >=0 && columns[cmi].searchoptions && columns[cmi].searchoptions.sopt) {
|
|
cmop = columns[cmi].searchoptions.sopt[0];
|
|
} else if(p.sopt && p.sopt.length) {
|
|
cmop = p.sopt[0];
|
|
}
|
|
defaultFilters = {groupOp: "AND", rules: [{field: colnm, op: cmop, data: ""}]};
|
|
}
|
|
found = false;
|
|
if(p.tmplNames && p.tmplNames.length) {
|
|
found = true;
|
|
tmpl = p.tmplLabel;
|
|
tmpl += "<select class='ui-template'>";
|
|
tmpl += "<option value='default'>Default</option>";
|
|
$.each(p.tmplNames, function(i,n){
|
|
tmpl += "<option value='"+i+"'>"+n+"</option>";
|
|
});
|
|
tmpl += "</select>";
|
|
}
|
|
|
|
bt = "<table class='EditTable' style='border:0px none;margin-top:5px' id='"+fid+"_2'><tbody><tr><td colspan='2'><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr><td class='EditButton' style='text-align:"+align+"'>"+bC+tmpl+"</td><td class='EditButton' "+butleft+">"+bQ+bS+"</td></tr></tbody></table>";
|
|
fid = $.jgrid.jqID( fid);
|
|
$("#"+fid).jqFilter({
|
|
columns : columns,
|
|
filter: p.loadDefaults ? defaultFilters : null,
|
|
showQuery: p.showQuery,
|
|
errorcheck : p.errorcheck,
|
|
sopt: p.sopt,
|
|
groupButton : p.multipleGroup,
|
|
ruleButtons : p.multipleSearch,
|
|
afterRedraw : p.afterRedraw,
|
|
ops : p.odata,
|
|
operands : p.operands,
|
|
ajaxSelectOptions: $t.p.ajaxSelectOptions,
|
|
groupOps: p.groupOps,
|
|
onChange : function() {
|
|
if(this.p.showQuery) {
|
|
$('.query',this).html(this.toUserFriendlyString());
|
|
}
|
|
if ($.isFunction(p.afterChange)) {
|
|
p.afterChange.call($t, $("#"+fid), p);
|
|
}
|
|
},
|
|
direction : $t.p.direction,
|
|
id: $t.p.id
|
|
});
|
|
fil.append( bt );
|
|
if(found && p.tmplFilters && p.tmplFilters.length) {
|
|
$(".ui-template", fil).bind('change', function(){
|
|
var curtempl = $(this).val();
|
|
if(curtempl==="default") {
|
|
$("#"+fid).jqFilter('addFilter', defaultFilters);
|
|
} else {
|
|
$("#"+fid).jqFilter('addFilter', p.tmplFilters[parseInt(curtempl,10)]);
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
if(p.multipleGroup === true) {p.multipleSearch = true;}
|
|
$($t).triggerHandler("jqGridFilterInitialize", [$("#"+fid)]);
|
|
if($.isFunction(p.onInitializeSearch) ) {
|
|
p.onInitializeSearch.call($t, $("#"+fid));
|
|
}
|
|
p.gbox = "#gbox_"+fid;
|
|
if (p.layer) {
|
|
$.jgrid.createModal(IDs ,fil,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0], "#"+$.jgrid.jqID(p.layer), {position: "relative"});
|
|
} else {
|
|
$.jgrid.createModal(IDs ,fil,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]);
|
|
}
|
|
if (p.searchOnEnter || p.closeOnEscape) {
|
|
$("#"+$.jgrid.jqID(IDs.themodal)).keydown(function (e) {
|
|
var $target = $(e.target);
|
|
if (p.searchOnEnter && e.which === 13 && // 13 === $.ui.keyCode.ENTER
|
|
!$target.hasClass('add-group') && !$target.hasClass('add-rule') &&
|
|
!$target.hasClass('delete-group') && !$target.hasClass('delete-rule') &&
|
|
(!$target.hasClass("fm-button") || !$target.is("[id$=_query]"))) {
|
|
$("#"+fid+"_search").focus().click();
|
|
return false;
|
|
}
|
|
if (p.closeOnEscape && e.which === 27) { // 27 === $.ui.keyCode.ESCAPE
|
|
$("#"+$.jgrid.jqID(IDs.modalhead)).find(".ui-jqdialog-titlebar-close").focus().click();
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
if(bQ) {
|
|
$("#"+fid+"_query").bind('click', function(){
|
|
$(".queryresult", fil).toggle();
|
|
return false;
|
|
});
|
|
}
|
|
if (p.stringResult===undefined) {
|
|
// to provide backward compatibility, inferring stringResult value from multipleSearch
|
|
p.stringResult = p.multipleSearch;
|
|
}
|
|
$("#"+fid+"_search").bind('click', function(){
|
|
var fl = $("#"+fid),
|
|
sdata={}, res,
|
|
filters = fl.jqFilter('filterData');
|
|
if(p.errorcheck) {
|
|
fl[0].hideError();
|
|
if(!p.showQuery) {fl.jqFilter('toSQLString');}
|
|
if(fl[0].p.error) {
|
|
fl[0].showError();
|
|
return false;
|
|
}
|
|
}
|
|
|
|
if(p.stringResult) {
|
|
try {
|
|
// xmlJsonClass or JSON.stringify
|
|
res = xmlJsonClass.toJson(filters, '', '', false);
|
|
} catch (e) {
|
|
try {
|
|
res = JSON.stringify(filters);
|
|
} catch (e2) { }
|
|
}
|
|
if(typeof res==="string") {
|
|
sdata[p.sFilter] = res;
|
|
$.each([p.sField,p.sValue, p.sOper], function() {sdata[this] = "";});
|
|
}
|
|
} else {
|
|
if(p.multipleSearch) {
|
|
sdata[p.sFilter] = filters;
|
|
$.each([p.sField,p.sValue, p.sOper], function() {sdata[this] = "";});
|
|
} else {
|
|
sdata[p.sField] = filters.rules[0].field;
|
|
sdata[p.sValue] = filters.rules[0].data;
|
|
sdata[p.sOper] = filters.rules[0].op;
|
|
sdata[p.sFilter] = "";
|
|
}
|
|
}
|
|
$t.p.search = true;
|
|
$.extend($t.p.postData,sdata);
|
|
mustReload = $($t).triggerHandler("jqGridFilterSearch");
|
|
if( mustReload === undefined) {
|
|
mustReload = true;
|
|
}
|
|
if(mustReload && $.isFunction(p.onSearch) ) {
|
|
mustReload = p.onSearch.call($t, $t.p.filters);
|
|
}
|
|
if (mustReload !== false) {
|
|
$($t).trigger("reloadGrid",[{page:1}]);
|
|
}
|
|
if(p.closeAfterSearch) {
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:p.jqModal,onClose: p.onClose});
|
|
}
|
|
return false;
|
|
});
|
|
$("#"+fid+"_reset").bind('click', function(){
|
|
var sdata={},
|
|
fl = $("#"+fid);
|
|
$t.p.search = false;
|
|
if(p.multipleSearch===false) {
|
|
sdata[p.sField] = sdata[p.sValue] = sdata[p.sOper] = "";
|
|
} else {
|
|
sdata[p.sFilter] = "";
|
|
}
|
|
fl[0].resetFilter();
|
|
if(found) {
|
|
$(".ui-template", fil).val("default");
|
|
}
|
|
$.extend($t.p.postData,sdata);
|
|
mustReload = $($t).triggerHandler("jqGridFilterReset");
|
|
if(mustReload === undefined) {
|
|
mustReload = true;
|
|
}
|
|
if(mustReload && $.isFunction(p.onReset) ) {
|
|
mustReload = p.onReset.call($t);
|
|
}
|
|
if(mustReload !== false) {
|
|
$($t).trigger("reloadGrid",[{page:1}]);
|
|
}
|
|
if (p.closeAfterReset) {
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:p.jqModal,onClose: p.onClose});
|
|
}
|
|
return false;
|
|
});
|
|
showFilter($("#"+fid));
|
|
$(".fm-button:not(.ui-state-disabled)",fil).hover(
|
|
function(){$(this).addClass('ui-state-hover');},
|
|
function(){$(this).removeClass('ui-state-hover');}
|
|
);
|
|
}
|
|
});
|
|
},
|
|
editGridRow : function(rowid, p){
|
|
p = $.extend(true, {
|
|
top : 0,
|
|
left: 0,
|
|
width: 300,
|
|
datawidth: 'auto',
|
|
height: 'auto',
|
|
dataheight: 'auto',
|
|
modal: false,
|
|
overlay : 30,
|
|
drag: true,
|
|
resize: true,
|
|
url: null,
|
|
mtype : "POST",
|
|
clearAfterAdd :true,
|
|
closeAfterEdit : false,
|
|
reloadAfterSubmit : true,
|
|
onInitializeForm: null,
|
|
beforeInitData: null,
|
|
beforeShowForm: null,
|
|
afterShowForm: null,
|
|
beforeSubmit: null,
|
|
afterSubmit: null,
|
|
onclickSubmit: null,
|
|
afterComplete: null,
|
|
onclickPgButtons : null,
|
|
afterclickPgButtons: null,
|
|
editData : {},
|
|
recreateForm : false,
|
|
jqModal : true,
|
|
closeOnEscape : false,
|
|
addedrow : "first",
|
|
topinfo : '',
|
|
bottominfo: '',
|
|
saveicon : [],
|
|
closeicon : [],
|
|
savekey: [false,13],
|
|
navkeys: [false,38,40],
|
|
checkOnSubmit : false,
|
|
checkOnUpdate : false,
|
|
_savedData : {},
|
|
processing : false,
|
|
onClose : null,
|
|
ajaxEditOptions : {},
|
|
serializeEditData : null,
|
|
viewPagerButtons : true,
|
|
overlayClass : 'ui-widget-overlay'
|
|
}, $.jgrid.edit, p || {});
|
|
rp_ge[$(this)[0].p.id] = p;
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if (!$t.grid || !rowid) {return;}
|
|
var gID = $t.p.id,
|
|
frmgr = "FrmGrid_"+gID, frmtborg = "TblGrid_"+gID, frmtb = "#"+$.jgrid.jqID(frmtborg),
|
|
IDs = {themodal:'editmod'+gID,modalhead:'edithd'+gID,modalcontent:'editcnt'+gID, scrollelm : frmgr},
|
|
onBeforeShow = $.isFunction(rp_ge[$t.p.id].beforeShowForm) ? rp_ge[$t.p.id].beforeShowForm : false,
|
|
onAfterShow = $.isFunction(rp_ge[$t.p.id].afterShowForm) ? rp_ge[$t.p.id].afterShowForm : false,
|
|
onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false,
|
|
onInitializeForm = $.isFunction(rp_ge[$t.p.id].onInitializeForm) ? rp_ge[$t.p.id].onInitializeForm : false,
|
|
showFrm = true,
|
|
maxCols = 1, maxRows=0, postdata, diff, frmoper;
|
|
frmgr = $.jgrid.jqID(frmgr);
|
|
if (rowid === "new") {
|
|
rowid = "_empty";
|
|
frmoper = "add";
|
|
p.caption=rp_ge[$t.p.id].addCaption;
|
|
} else {
|
|
p.caption=rp_ge[$t.p.id].editCaption;
|
|
frmoper = "edit";
|
|
}
|
|
if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) {
|
|
$("#"+$.jgrid.jqID(IDs.themodal)).remove();
|
|
}
|
|
var closeovrl = true;
|
|
if(p.checkOnUpdate && p.jqModal && !p.modal) {
|
|
closeovrl = false;
|
|
}
|
|
function getFormData(){
|
|
$(frmtb+" > tbody > tr > td > .FormElement").each(function() {
|
|
var celm = $(".customelement", this);
|
|
if (celm.length) {
|
|
var elem = celm[0], nm = $(elem).attr('name');
|
|
$.each($t.p.colModel, function(){
|
|
if(this.name === nm && this.editoptions && $.isFunction(this.editoptions.custom_value)) {
|
|
try {
|
|
postdata[nm] = this.editoptions.custom_value.call($t, $("#"+$.jgrid.jqID(nm),frmtb),'get');
|
|
if (postdata[nm] === undefined) {throw "e1";}
|
|
} catch (e) {
|
|
if (e==="e1") {$.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);}
|
|
else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose);}
|
|
}
|
|
return true;
|
|
}
|
|
});
|
|
} else {
|
|
switch ($(this).get(0).type) {
|
|
case "checkbox":
|
|
if($(this).is(":checked")) {
|
|
postdata[this.name]= $(this).val();
|
|
}else {
|
|
var ofv = $(this).attr("offval");
|
|
postdata[this.name]= ofv;
|
|
}
|
|
break;
|
|
case "select-one":
|
|
postdata[this.name]= $("option:selected",this).val();
|
|
break;
|
|
case "select-multiple":
|
|
postdata[this.name]= $(this).val();
|
|
if(postdata[this.name]) {postdata[this.name] = postdata[this.name].join(",");}
|
|
else {postdata[this.name] ="";}
|
|
var selectedText = [];
|
|
$("option:selected",this).each(
|
|
function(i,selected){
|
|
selectedText[i] = $(selected).text();
|
|
}
|
|
);
|
|
break;
|
|
case "password":
|
|
case "text":
|
|
case "textarea":
|
|
case "button":
|
|
postdata[this.name] = $(this).val();
|
|
|
|
break;
|
|
}
|
|
if($t.p.autoencode) {postdata[this.name] = $.jgrid.htmlEncode(postdata[this.name]);}
|
|
}
|
|
});
|
|
return true;
|
|
}
|
|
function createData(rowid,obj,tb,maxcols){
|
|
var nm, hc,trdata, cnt=0,tmp, dc,elc, retpos=[], ind=false,
|
|
tdtmpl = "<td class='CaptionTD'> </td><td class='DataTD'> </td>", tmpl="", i; //*2
|
|
for (i =1; i<=maxcols;i++) {
|
|
tmpl += tdtmpl;
|
|
}
|
|
if(rowid !== '_empty') {
|
|
ind = $(obj).jqGrid("getInd",rowid);
|
|
}
|
|
$(obj.p.colModel).each( function(i) {
|
|
nm = this.name;
|
|
// hidden fields are included in the form
|
|
if(this.editrules && this.editrules.edithidden === true) {
|
|
hc = false;
|
|
} else {
|
|
hc = this.hidden === true ? true : false;
|
|
}
|
|
dc = hc ? "style='display:none'" : "";
|
|
if ( nm !== 'cb' && nm !== 'subgrid' && this.editable===true && nm !== 'rn') {
|
|
if(ind === false) {
|
|
tmp = "";
|
|
} else {
|
|
if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
|
tmp = $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).text();
|
|
} else {
|
|
try {
|
|
tmp = $.unformat.call(obj, $("td[role='gridcell']:eq("+i+")",obj.rows[ind]),{rowId:rowid, colModel:this},i);
|
|
} catch (_) {
|
|
tmp = (this.edittype && this.edittype === "textarea") ? $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).text() : $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).html();
|
|
}
|
|
if(!tmp || tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';}
|
|
}
|
|
}
|
|
var opt = $.extend({}, this.editoptions || {} ,{id:nm,name:nm}),
|
|
frmopt = $.extend({}, {elmprefix:'',elmsuffix:'',rowabove:false,rowcontent:''}, this.formoptions || {}),
|
|
rp = parseInt(frmopt.rowpos,10) || cnt+1,
|
|
cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10);
|
|
if(rowid === "_empty" && opt.defaultValue ) {
|
|
tmp = $.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue;
|
|
}
|
|
if(!this.edittype) {this.edittype = "text";}
|
|
if($t.p.autoencode) {tmp = $.jgrid.htmlDecode(tmp);}
|
|
elc = $.jgrid.createEl.call($t,this.edittype,opt,tmp,false,$.extend({},$.jgrid.ajaxOptions,obj.p.ajaxSelectOptions || {}));
|
|
//if(tmp === "" && this.edittype == "checkbox") {tmp = $(elc).attr("offval");}
|
|
//if(tmp === "" && this.edittype == "select") {tmp = $("option:eq(0)",elc).text();}
|
|
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = tmp;}
|
|
$(elc).addClass("FormElement");
|
|
if( $.inArray(this.edittype, ['text','textarea','password','select']) > -1) {
|
|
$(elc).addClass("ui-widget-content ui-corner-all");
|
|
}
|
|
trdata = $(tb).find("tr[rowpos="+rp+"]");
|
|
if(frmopt.rowabove) {
|
|
var newdata = $("<tr><td class='contentinfo' colspan='"+(maxcols*2)+"'>"+frmopt.rowcontent+"</td></tr>");
|
|
$(tb).append(newdata);
|
|
newdata[0].rp = rp;
|
|
}
|
|
if ( trdata.length===0 ) {
|
|
trdata = $("<tr "+dc+" rowpos='"+rp+"'></tr>").addClass("FormData").attr("id","tr_"+nm);
|
|
$(trdata).append(tmpl);
|
|
$(tb).append(trdata);
|
|
trdata[0].rp = rp;
|
|
}
|
|
$("td:eq("+(cp-2)+")",trdata[0]).html(frmopt.label === undefined ? obj.p.colNames[i]: frmopt.label);
|
|
$("td:eq("+(cp-1)+")",trdata[0]).append(frmopt.elmprefix).append(elc).append(frmopt.elmsuffix);
|
|
if(this.edittype==='custom' && $.isFunction(opt.custom_value) ) {
|
|
opt.custom_value.call($t, $("#"+nm,"#"+frmgr),'set',tmp);
|
|
}
|
|
$.jgrid.bindEv.call($t, elc, opt);
|
|
retpos[cnt] = i;
|
|
cnt++;
|
|
}
|
|
});
|
|
if( cnt > 0) {
|
|
var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='"+ (maxcols*2-1)+"' class='DataTD'><input class='FormElement' id='id_g' type='text' name='"+obj.p.id+"_id' value='"+rowid+"'/></td></tr>");
|
|
idrow[0].rp = cnt+999;
|
|
$(tb).append(idrow);
|
|
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[obj.p.id+"_id"] = rowid;}
|
|
}
|
|
return retpos;
|
|
}
|
|
function fillData(rowid,obj,fmid){
|
|
var nm,cnt=0,tmp, fld,opt,vl,vlc;
|
|
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData = {};rp_ge[$t.p.id]._savedData[obj.p.id+"_id"]=rowid;}
|
|
var cm = obj.p.colModel;
|
|
if(rowid === '_empty') {
|
|
$(cm).each(function(){
|
|
nm = this.name;
|
|
opt = $.extend({}, this.editoptions || {} );
|
|
fld = $("#"+$.jgrid.jqID(nm),"#"+fmid);
|
|
if(fld && fld.length && fld[0] !== null) {
|
|
vl = "";
|
|
if(this.edittype === 'custom' && $.isFunction(opt.custom_value)) {
|
|
opt.custom_value.call($t, $("#"+nm,"#"+fmid),'set',vl);
|
|
} else if(opt.defaultValue ) {
|
|
vl = $.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue;
|
|
if(fld[0].type==='checkbox') {
|
|
vlc = vl.toLowerCase();
|
|
if(vlc.search(/(false|f|0|no|n|off|undefined)/i)<0 && vlc!=="") {
|
|
fld[0].checked = true;
|
|
fld[0].defaultChecked = true;
|
|
fld[0].value = vl;
|
|
} else {
|
|
fld[0].checked = false;
|
|
fld[0].defaultChecked = false;
|
|
}
|
|
} else {fld.val(vl);}
|
|
} else {
|
|
if( fld[0].type==='checkbox' ) {
|
|
fld[0].checked = false;
|
|
fld[0].defaultChecked = false;
|
|
vl = $(fld).attr("offval");
|
|
} else if (fld[0].type && fld[0].type.substr(0,6)==='select') {
|
|
fld[0].selectedIndex = 0;
|
|
} else {
|
|
fld.val(vl);
|
|
}
|
|
}
|
|
if(rp_ge[$t.p.id].checkOnSubmit===true || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = vl;}
|
|
}
|
|
});
|
|
$("#id_g","#"+fmid).val(rowid);
|
|
return;
|
|
}
|
|
var tre = $(obj).jqGrid("getInd",rowid,true);
|
|
if(!tre) {return;}
|
|
$('td[role="gridcell"]',tre).each( function(i) {
|
|
nm = cm[i].name;
|
|
// hidden fields are included in the form
|
|
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && cm[i].editable===true) {
|
|
if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
|
tmp = $(this).text();
|
|
} else {
|
|
try {
|
|
tmp = $.unformat.call(obj, $(this),{rowId:rowid, colModel:cm[i]},i);
|
|
} catch (_) {
|
|
tmp = cm[i].edittype==="textarea" ? $(this).text() : $(this).html();
|
|
}
|
|
}
|
|
if($t.p.autoencode) {tmp = $.jgrid.htmlDecode(tmp);}
|
|
if(rp_ge[$t.p.id].checkOnSubmit===true || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = tmp;}
|
|
nm = $.jgrid.jqID(nm);
|
|
switch (cm[i].edittype) {
|
|
case "password":
|
|
case "text":
|
|
case "button" :
|
|
case "image":
|
|
case "textarea":
|
|
if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';}
|
|
$("#"+nm,"#"+fmid).val(tmp);
|
|
break;
|
|
case "select":
|
|
var opv = tmp.split(",");
|
|
opv = $.map(opv,function(n){return $.trim(n);});
|
|
$("#"+nm+" option","#"+fmid).each(function(){
|
|
if (!cm[i].editoptions.multiple && ($.trim(tmp) === $.trim($(this).text()) || opv[0] === $.trim($(this).text()) || opv[0] === $.trim($(this).val())) ){
|
|
this.selected= true;
|
|
} else if (cm[i].editoptions.multiple){
|
|
if( $.inArray($.trim($(this).text()), opv ) > -1 || $.inArray($.trim($(this).val()), opv ) > -1 ){
|
|
this.selected = true;
|
|
}else{
|
|
this.selected = false;
|
|
}
|
|
} else {
|
|
this.selected = false;
|
|
}
|
|
});
|
|
break;
|
|
case "checkbox":
|
|
tmp = String(tmp);
|
|
if(cm[i].editoptions && cm[i].editoptions.value) {
|
|
var cb = cm[i].editoptions.value.split(":");
|
|
if(cb[0] === tmp) {
|
|
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']({"checked":true, "defaultChecked" : true});
|
|
} else {
|
|
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']({"checked":false, "defaultChecked" : false});
|
|
}
|
|
} else {
|
|
tmp = tmp.toLowerCase();
|
|
if(tmp.search(/(false|f|0|no|n|off|undefined)/i)<0 && tmp!=="") {
|
|
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked",true);
|
|
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked",true); //ie
|
|
} else {
|
|
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked", false);
|
|
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked", false); //ie
|
|
}
|
|
}
|
|
break;
|
|
case 'custom' :
|
|
try {
|
|
if(cm[i].editoptions && $.isFunction(cm[i].editoptions.custom_value)) {
|
|
cm[i].editoptions.custom_value.call($t, $("#"+nm,"#"+fmid),'set',tmp);
|
|
} else {throw "e1";}
|
|
} catch (e) {
|
|
if (e==="e1") {$.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose);}
|
|
else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose);}
|
|
}
|
|
break;
|
|
}
|
|
cnt++;
|
|
}
|
|
});
|
|
if(cnt>0) {$("#id_g",frmtb).val(rowid);}
|
|
}
|
|
function setNulls() {
|
|
$.each($t.p.colModel, function(i,n){
|
|
if(n.editoptions && n.editoptions.NullIfEmpty === true) {
|
|
if(postdata.hasOwnProperty(n.name) && postdata[n.name] === "") {
|
|
postdata[n.name] = 'null';
|
|
}
|
|
}
|
|
});
|
|
}
|
|
function postIt() {
|
|
var copydata, ret=[true,"",""], onCS = {}, opers = $t.p.prmNames, idname, oper, key, selr, i;
|
|
|
|
var retvals = $($t).triggerHandler("jqGridAddEditBeforeCheckValues", [$("#"+frmgr), frmoper]);
|
|
if(retvals && typeof retvals === 'object') {postdata = retvals;}
|
|
|
|
if($.isFunction(rp_ge[$t.p.id].beforeCheckValues)) {
|
|
retvals = rp_ge[$t.p.id].beforeCheckValues.call($t, postdata,$("#"+frmgr),frmoper);
|
|
if(retvals && typeof retvals === 'object') {postdata = retvals;}
|
|
}
|
|
for( key in postdata ){
|
|
if(postdata.hasOwnProperty(key)) {
|
|
ret = $.jgrid.checkValues.call($t,postdata[key],key);
|
|
if(ret[0] === false) {break;}
|
|
}
|
|
}
|
|
setNulls();
|
|
if(ret[0]) {
|
|
onCS = $($t).triggerHandler("jqGridAddEditClickSubmit", [rp_ge[$t.p.id], postdata, frmoper]);
|
|
if( onCS === undefined && $.isFunction( rp_ge[$t.p.id].onclickSubmit)) {
|
|
onCS = rp_ge[$t.p.id].onclickSubmit.call($t, rp_ge[$t.p.id], postdata, frmoper) || {};
|
|
}
|
|
ret = $($t).triggerHandler("jqGridAddEditBeforeSubmit", [postdata, $("#"+frmgr), frmoper]);
|
|
if(ret === undefined) {
|
|
ret = [true,"",""];
|
|
}
|
|
if( ret[0] && $.isFunction(rp_ge[$t.p.id].beforeSubmit)) {
|
|
ret = rp_ge[$t.p.id].beforeSubmit.call($t,postdata,$("#"+frmgr), frmoper);
|
|
}
|
|
}
|
|
|
|
if(ret[0] && !rp_ge[$t.p.id].processing) {
|
|
rp_ge[$t.p.id].processing = true;
|
|
$("#sData", frmtb+"_2").addClass('ui-state-active');
|
|
oper = opers.oper;
|
|
idname = opers.id;
|
|
// we add to pos data array the action - the name is oper
|
|
postdata[oper] = ($.trim(postdata[$t.p.id+"_id"]) === "_empty") ? opers.addoper : opers.editoper;
|
|
if(postdata[oper] !== opers.addoper) {
|
|
postdata[idname] = postdata[$t.p.id+"_id"];
|
|
} else {
|
|
// check to see if we have allredy this field in the form and if yes lieve it
|
|
if( postdata[idname] === undefined ) {postdata[idname] = postdata[$t.p.id+"_id"];}
|
|
}
|
|
delete postdata[$t.p.id+"_id"];
|
|
postdata = $.extend(postdata,rp_ge[$t.p.id].editData,onCS);
|
|
if($t.p.treeGrid === true) {
|
|
if(postdata[oper] === opers.addoper) {
|
|
selr = $($t).jqGrid("getGridParam", 'selrow');
|
|
var tr_par_id = $t.p.treeGridModel === 'adjacency' ? $t.p.treeReader.parent_id_field : 'parent_id';
|
|
postdata[tr_par_id] = selr;
|
|
}
|
|
for(i in $t.p.treeReader){
|
|
if($t.p.treeReader.hasOwnProperty(i)) {
|
|
var itm = $t.p.treeReader[i];
|
|
if(postdata.hasOwnProperty(itm)) {
|
|
if(postdata[oper] === opers.addoper && i === 'parent_id_field') {continue;}
|
|
delete postdata[itm];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, postdata[idname]);
|
|
var ajaxOptions = $.extend({
|
|
url: rp_ge[$t.p.id].url || $($t).jqGrid('getGridParam','editurl'),
|
|
type: rp_ge[$t.p.id].mtype,
|
|
data: $.isFunction(rp_ge[$t.p.id].serializeEditData) ? rp_ge[$t.p.id].serializeEditData.call($t,postdata) : postdata,
|
|
complete:function(data,status){
|
|
var key;
|
|
postdata[idname] = $t.p.idPrefix + postdata[idname];
|
|
if(data.status >= 300 && data.status !== 304) {
|
|
ret[0] = false;
|
|
ret[1] = $($t).triggerHandler("jqGridAddEditErrorTextFormat", [data, frmoper]);
|
|
if ($.isFunction(rp_ge[$t.p.id].errorTextFormat)) {
|
|
ret[1] = rp_ge[$t.p.id].errorTextFormat.call($t, data, frmoper);
|
|
} else {
|
|
ret[1] = status + " Status: '" + data.statusText + "'. Error code: " + data.status;
|
|
}
|
|
} else {
|
|
// data is posted successful
|
|
// execute aftersubmit with the returned data from server
|
|
ret = $($t).triggerHandler("jqGridAddEditAfterSubmit", [data, postdata, frmoper]);
|
|
if(ret === undefined) {
|
|
ret = [true,"",""];
|
|
}
|
|
if( ret[0] && $.isFunction(rp_ge[$t.p.id].afterSubmit) ) {
|
|
ret = rp_ge[$t.p.id].afterSubmit.call($t, data,postdata, frmoper);
|
|
}
|
|
}
|
|
if(ret[0] === false) {
|
|
$("#FormError>td",frmtb).html(ret[1]);
|
|
$("#FormError",frmtb).show();
|
|
} else {
|
|
if($t.p.autoencode) {
|
|
$.each(postdata,function(n,v){
|
|
postdata[n] = $.jgrid.htmlDecode(v);
|
|
});
|
|
}
|
|
//rp_ge[$t.p.id].reloadAfterSubmit = rp_ge[$t.p.id].reloadAfterSubmit && $t.p.datatype != "local";
|
|
// the action is add
|
|
if(postdata[oper] === opers.addoper ) {
|
|
//id processing
|
|
// user not set the id ret[2]
|
|
if(!ret[2]) {ret[2] = $.jgrid.randId();}
|
|
postdata[idname] = ret[2];
|
|
if(rp_ge[$t.p.id].reloadAfterSubmit) {
|
|
$($t).trigger("reloadGrid");
|
|
} else {
|
|
if($t.p.treeGrid === true){
|
|
$($t).jqGrid("addChildNode",ret[2],selr,postdata );
|
|
} else {
|
|
$($t).jqGrid("addRowData",ret[2],postdata,p.addedrow);
|
|
}
|
|
}
|
|
if(rp_ge[$t.p.id].closeAfterAdd) {
|
|
if($t.p.treeGrid !== true){
|
|
$($t).jqGrid("setSelection",ret[2]);
|
|
}
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
|
|
} else if (rp_ge[$t.p.id].clearAfterAdd) {
|
|
fillData("_empty",$t,frmgr);
|
|
}
|
|
} else {
|
|
// the action is update
|
|
if(rp_ge[$t.p.id].reloadAfterSubmit) {
|
|
$($t).trigger("reloadGrid");
|
|
if( !rp_ge[$t.p.id].closeAfterEdit ) {setTimeout(function(){$($t).jqGrid("setSelection",postdata[idname]);},1000);}
|
|
} else {
|
|
if($t.p.treeGrid === true) {
|
|
$($t).jqGrid("setTreeRow", postdata[idname],postdata);
|
|
} else {
|
|
$($t).jqGrid("setRowData", postdata[idname],postdata);
|
|
}
|
|
}
|
|
if(rp_ge[$t.p.id].closeAfterEdit) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});}
|
|
}
|
|
if($.isFunction(rp_ge[$t.p.id].afterComplete)) {
|
|
copydata = data;
|
|
setTimeout(function(){
|
|
$($t).triggerHandler("jqGridAddEditAfterComplete", [copydata, postdata, $("#"+frmgr), frmoper]);
|
|
rp_ge[$t.p.id].afterComplete.call($t, copydata, postdata, $("#"+frmgr), frmoper);
|
|
copydata=null;
|
|
},500);
|
|
}
|
|
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {
|
|
$("#"+frmgr).data("disabled",false);
|
|
if(rp_ge[$t.p.id]._savedData[$t.p.id+"_id"] !== "_empty"){
|
|
for(key in rp_ge[$t.p.id]._savedData) {
|
|
if(rp_ge[$t.p.id]._savedData.hasOwnProperty(key) && postdata[key]) {
|
|
rp_ge[$t.p.id]._savedData[key] = postdata[key];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
rp_ge[$t.p.id].processing=false;
|
|
$("#sData", frmtb+"_2").removeClass('ui-state-active');
|
|
try{$(':input:visible',"#"+frmgr)[0].focus();} catch (e){}
|
|
}
|
|
}, $.jgrid.ajaxOptions, rp_ge[$t.p.id].ajaxEditOptions );
|
|
|
|
if (!ajaxOptions.url && !rp_ge[$t.p.id].useDataProxy) {
|
|
if ($.isFunction($t.p.dataProxy)) {
|
|
rp_ge[$t.p.id].useDataProxy = true;
|
|
} else {
|
|
ret[0]=false;ret[1] += " "+$.jgrid.errors.nourl;
|
|
}
|
|
}
|
|
if (ret[0]) {
|
|
if (rp_ge[$t.p.id].useDataProxy) {
|
|
var dpret = $t.p.dataProxy.call($t, ajaxOptions, "set_"+$t.p.id);
|
|
if(dpret === undefined) {
|
|
dpret = [true, ""];
|
|
}
|
|
if(dpret[0] === false ) {
|
|
ret[0] = false;
|
|
ret[1] = dpret[1] || "Error deleting the selected row!" ;
|
|
} else {
|
|
if(ajaxOptions.data.oper === opers.addoper && rp_ge[$t.p.id].closeAfterAdd ) {
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
|
|
}
|
|
if(ajaxOptions.data.oper === opers.editoper && rp_ge[$t.p.id].closeAfterEdit ) {
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
|
|
}
|
|
}
|
|
} else {
|
|
$.ajax(ajaxOptions);
|
|
}
|
|
}
|
|
}
|
|
if(ret[0] === false) {
|
|
$("#FormError>td",frmtb).html(ret[1]);
|
|
$("#FormError",frmtb).show();
|
|
// return;
|
|
}
|
|
}
|
|
function compareData(nObj, oObj ) {
|
|
var ret = false,key;
|
|
for (key in nObj) {
|
|
if(nObj.hasOwnProperty(key) && nObj[key] != oObj[key]) {
|
|
ret = true;
|
|
break;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
function checkUpdates () {
|
|
var stat = true;
|
|
$("#FormError",frmtb).hide();
|
|
if(rp_ge[$t.p.id].checkOnUpdate) {
|
|
postdata = {};
|
|
getFormData();
|
|
diff = compareData(postdata,rp_ge[$t.p.id]._savedData);
|
|
if(diff) {
|
|
$("#"+frmgr).data("disabled",true);
|
|
$(".confirm","#"+IDs.themodal).show();
|
|
stat = false;
|
|
}
|
|
}
|
|
return stat;
|
|
}
|
|
function restoreInline()
|
|
{
|
|
var i;
|
|
if (rowid !== "_empty" && $t.p.savedRow !== undefined && $t.p.savedRow.length > 0 && $.isFunction($.fn.jqGrid.restoreRow)) {
|
|
for (i=0;i<$t.p.savedRow.length;i++) {
|
|
if ($t.p.savedRow[i].id == rowid) {
|
|
$($t).jqGrid('restoreRow',rowid);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function updateNav(cr, posarr){
|
|
var totr = posarr[1].length-1;
|
|
if (cr===0) {
|
|
$("#pData",frmtb+"_2").addClass('ui-state-disabled');
|
|
} else if( posarr[1][cr-1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr-1])).hasClass('ui-state-disabled')) {
|
|
$("#pData",frmtb+"_2").addClass('ui-state-disabled');
|
|
} else {
|
|
$("#pData",frmtb+"_2").removeClass('ui-state-disabled');
|
|
}
|
|
|
|
if (cr===totr) {
|
|
$("#nData",frmtb+"_2").addClass('ui-state-disabled');
|
|
} else if( posarr[1][cr+1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr+1])).hasClass('ui-state-disabled')) {
|
|
$("#nData",frmtb+"_2").addClass('ui-state-disabled');
|
|
} else {
|
|
$("#nData",frmtb+"_2").removeClass('ui-state-disabled');
|
|
}
|
|
}
|
|
function getCurrPos() {
|
|
var rowsInGrid = $($t).jqGrid("getDataIDs"),
|
|
selrow = $("#id_g",frmtb).val(),
|
|
pos = $.inArray(selrow,rowsInGrid);
|
|
return [pos,rowsInGrid];
|
|
}
|
|
|
|
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
|
|
showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+$.jgrid.jqID(frmgr)), frmoper]);
|
|
if(showFrm === undefined) {
|
|
showFrm = true;
|
|
}
|
|
if(showFrm && onBeforeInit) {
|
|
showFrm = onBeforeInit.call($t,$("#"+frmgr), frmoper);
|
|
}
|
|
if(showFrm === false) {return;}
|
|
restoreInline();
|
|
$(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption);
|
|
$("#FormError",frmtb).hide();
|
|
if(rp_ge[$t.p.id].topinfo) {
|
|
$(".topinfo",frmtb).html(rp_ge[$t.p.id].topinfo);
|
|
$(".tinfo",frmtb).show();
|
|
} else {
|
|
$(".tinfo",frmtb).hide();
|
|
}
|
|
if(rp_ge[$t.p.id].bottominfo) {
|
|
$(".bottominfo",frmtb+"_2").html(rp_ge[$t.p.id].bottominfo);
|
|
$(".binfo",frmtb+"_2").show();
|
|
} else {
|
|
$(".binfo",frmtb+"_2").hide();
|
|
}
|
|
// filldata
|
|
fillData(rowid,$t,frmgr);
|
|
///
|
|
if(rowid==="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {
|
|
$("#pData, #nData",frmtb+"_2").hide();
|
|
} else {
|
|
$("#pData, #nData",frmtb+"_2").show();
|
|
}
|
|
if(rp_ge[$t.p.id].processing===true) {
|
|
rp_ge[$t.p.id].processing=false;
|
|
$("#sData", frmtb+"_2").removeClass('ui-state-active');
|
|
}
|
|
if($("#"+frmgr).data("disabled")===true) {
|
|
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
|
|
$("#"+frmgr).data("disabled",false);
|
|
}
|
|
$($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]);
|
|
if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr), frmoper); }
|
|
$("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose);
|
|
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal, overlayClass : p.overlayClass});
|
|
if(!closeovrl) {
|
|
$("." + $.jgrid.jqID(p.overlayClass)).click(function(){
|
|
if(!checkUpdates()) {return false;}
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
|
|
return false;
|
|
});
|
|
}
|
|
$($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]);
|
|
if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr), frmoper); }
|
|
} else {
|
|
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px",
|
|
dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px",
|
|
frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid' onSubmit='return false;' style='width:"+dw+";overflow:auto;position:relative;height:"+dh+";'></form>").data("disabled",false),
|
|
tbl = $("<table id='"+frmtborg+"' class='EditTable' cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>");
|
|
showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+frmgr), frmoper]);
|
|
if(showFrm === undefined) {
|
|
showFrm = true;
|
|
}
|
|
if(showFrm && onBeforeInit) {
|
|
showFrm = onBeforeInit.call($t,$("#"+frmgr),frmoper);
|
|
}
|
|
if(showFrm === false) {return;}
|
|
restoreInline();
|
|
$($t.p.colModel).each( function() {
|
|
var fmto = this.formoptions;
|
|
maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
|
|
maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
|
|
});
|
|
$(frm).append(tbl);
|
|
var flr = $("<tr id='FormError' style='display:none'><td class='ui-state-error' colspan='"+(maxCols*2)+"'></td></tr>");
|
|
flr[0].rp = 0;
|
|
$(tbl).append(flr);
|
|
//topinfo
|
|
flr = $("<tr style='display:none' class='tinfo'><td class='topinfo' colspan='"+(maxCols*2)+"'>"+rp_ge[$t.p.id].topinfo+"</td></tr>");
|
|
flr[0].rp = 0;
|
|
$(tbl).append(flr);
|
|
// set the id.
|
|
// use carefull only to change here colproperties.
|
|
// create data
|
|
var rtlb = $t.p.direction === "rtl" ? true :false,
|
|
bp = rtlb ? "nData" : "pData",
|
|
bn = rtlb ? "pData" : "nData";
|
|
createData(rowid,$t,tbl,maxCols);
|
|
// buttons at footer
|
|
var bP = "<a id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
|
|
bN = "<a id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
|
|
bS ="<a id='sData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
|
|
bC ="<a id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
|
|
var bt = "<table border='0' cellspacing='0' cellpadding='0' class='EditTable' id='"+frmtborg+"_2'><tbody><tr><td colspan='2'><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr id='Act_Buttons'><td class='navButton'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bS+bC+"</td></tr>";
|
|
bt += "<tr style='display:none' class='binfo'><td class='bottominfo' colspan='2'>"+rp_ge[$t.p.id].bottominfo+"</td></tr>";
|
|
bt += "</tbody></table>";
|
|
if(maxRows > 0) {
|
|
var sd=[];
|
|
$.each($(tbl)[0].rows,function(i,r){
|
|
sd[i] = r;
|
|
});
|
|
sd.sort(function(a,b){
|
|
if(a.rp > b.rp) {return 1;}
|
|
if(a.rp < b.rp) {return -1;}
|
|
return 0;
|
|
});
|
|
$.each(sd, function(index, row) {
|
|
$('tbody',tbl).append(row);
|
|
});
|
|
}
|
|
p.gbox = "#gbox_"+$.jgrid.jqID(gID);
|
|
var cle = false;
|
|
if(p.closeOnEscape===true){
|
|
p.closeOnEscape = false;
|
|
cle = true;
|
|
}
|
|
var tms = $("<div></div>").append(frm).append(bt);
|
|
$.jgrid.createModal(IDs,tms,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]);
|
|
if(rtlb) {
|
|
$("#pData, #nData",frmtb+"_2").css("float","right");
|
|
$(".EditButton",frmtb+"_2").css("text-align","left");
|
|
}
|
|
if(rp_ge[$t.p.id].topinfo) {$(".tinfo",frmtb).show();}
|
|
if(rp_ge[$t.p.id].bottominfo) {$(".binfo",frmtb+"_2").show();}
|
|
tms = null;bt=null;
|
|
$("#"+$.jgrid.jqID(IDs.themodal)).keydown( function( e ) {
|
|
var wkey = e.target;
|
|
if ($("#"+frmgr).data("disabled")===true ) {return false;}//??
|
|
if(rp_ge[$t.p.id].savekey[0] === true && e.which === rp_ge[$t.p.id].savekey[1]) { // save
|
|
if(wkey.tagName !== "TEXTAREA") {
|
|
$("#sData", frmtb+"_2").trigger("click");
|
|
return false;
|
|
}
|
|
}
|
|
if(e.which === 27) {
|
|
if(!checkUpdates()) {return false;}
|
|
if(cle) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});}
|
|
return false;
|
|
}
|
|
if(rp_ge[$t.p.id].navkeys[0]===true) {
|
|
if($("#id_g",frmtb).val() === "_empty") {return true;}
|
|
if(e.which === rp_ge[$t.p.id].navkeys[1]){ //up
|
|
$("#pData", frmtb+"_2").trigger("click");
|
|
return false;
|
|
}
|
|
if(e.which === rp_ge[$t.p.id].navkeys[2]){ //down
|
|
$("#nData", frmtb+"_2").trigger("click");
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
if(p.checkOnUpdate) {
|
|
$("a.ui-jqdialog-titlebar-close span","#"+$.jgrid.jqID(IDs.themodal)).removeClass("jqmClose");
|
|
$("a.ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.themodal)).unbind("click")
|
|
.click(function(){
|
|
if(!checkUpdates()) {return false;}
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
|
|
return false;
|
|
});
|
|
}
|
|
p.saveicon = $.extend([true,"left","ui-icon-disk"],p.saveicon);
|
|
p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
|
|
// beforeinitdata after creation of the form
|
|
if(p.saveicon[0]===true) {
|
|
$("#sData",frmtb+"_2").addClass(p.saveicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
|
.append("<span class='ui-icon "+p.saveicon[2]+"'></span>");
|
|
}
|
|
if(p.closeicon[0]===true) {
|
|
$("#cData",frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
|
.append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
|
|
}
|
|
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {
|
|
bS ="<a id='sNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bYes+"</a>";
|
|
bN ="<a id='nNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bNo+"</a>";
|
|
bC ="<a id='cNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bExit+"</a>";
|
|
var zI = p.zIndex || 999;zI ++;
|
|
$("<div class='"+ p.overlayClass+" jqgrid-overlay confirm' style='z-index:"+zI+";display:none;'> "+"</div><div class='confirm ui-widget-content ui-jqconfirm' style='z-index:"+(zI+1)+"'>"+p.saveData+"<br/><br/>"+bS+bN+bC+"</div>").insertAfter("#"+frmgr);
|
|
$("#sNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
|
|
postIt();
|
|
$("#"+frmgr).data("disabled",false);
|
|
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
|
|
return false;
|
|
});
|
|
$("#nNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
|
|
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
|
|
$("#"+frmgr).data("disabled",false);
|
|
setTimeout(function(){$(":input:visible","#"+frmgr)[0].focus();},0);
|
|
return false;
|
|
});
|
|
$("#cNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
|
|
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
|
|
$("#"+frmgr).data("disabled",false);
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
|
|
return false;
|
|
});
|
|
}
|
|
// here initform - only once
|
|
$($t).triggerHandler("jqGridAddEditInitializeForm", [$("#"+frmgr), frmoper]);
|
|
if(onInitializeForm) {onInitializeForm.call($t,$("#"+frmgr), frmoper);}
|
|
if(rowid==="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {$("#pData,#nData",frmtb+"_2").hide();} else {$("#pData,#nData",frmtb+"_2").show();}
|
|
$($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]);
|
|
if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr), frmoper);}
|
|
$("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose);
|
|
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, overlay: p.overlay,modal:p.modal, overlayClass: p.overlayClass});
|
|
if(!closeovrl) {
|
|
$("." + $.jgrid.jqID(p.overlayClass)).click(function(){
|
|
if(!checkUpdates()) {return false;}
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
|
|
return false;
|
|
});
|
|
}
|
|
$($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]);
|
|
if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr), frmoper); }
|
|
$(".fm-button","#"+$.jgrid.jqID(IDs.themodal)).hover(
|
|
function(){$(this).addClass('ui-state-hover');},
|
|
function(){$(this).removeClass('ui-state-hover');}
|
|
);
|
|
$("#sData", frmtb+"_2").click(function(){
|
|
postdata = {};
|
|
$("#FormError",frmtb).hide();
|
|
// all depend on ret array
|
|
//ret[0] - succes
|
|
//ret[1] - msg if not succes
|
|
//ret[2] - the id that will be set if reload after submit false
|
|
getFormData();
|
|
if(postdata[$t.p.id+"_id"] === "_empty") {postIt();}
|
|
else if(p.checkOnSubmit===true ) {
|
|
diff = compareData(postdata,rp_ge[$t.p.id]._savedData);
|
|
if(diff) {
|
|
$("#"+frmgr).data("disabled",true);
|
|
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).show();
|
|
} else {
|
|
postIt();
|
|
}
|
|
} else {
|
|
postIt();
|
|
}
|
|
return false;
|
|
});
|
|
$("#cData", frmtb+"_2").click(function(){
|
|
if(!checkUpdates()) {return false;}
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
|
|
return false;
|
|
});
|
|
$("#nData", frmtb+"_2").click(function(){
|
|
if(!checkUpdates()) {return false;}
|
|
$("#FormError",frmtb).hide();
|
|
var npos = getCurrPos();
|
|
npos[0] = parseInt(npos[0],10);
|
|
if(npos[0] !== -1 && npos[1][npos[0]+1]) {
|
|
$($t).triggerHandler("jqGridAddEditClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
|
|
var nposret;
|
|
if($.isFunction(p.onclickPgButtons)) {
|
|
nposret = p.onclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]]);
|
|
if( nposret !== undefined && nposret === false ) {return false;}
|
|
}
|
|
if( $("#"+$.jgrid.jqID(npos[1][npos[0]+1])).hasClass('ui-state-disabled')) {return false;}
|
|
fillData(npos[1][npos[0]+1],$t,frmgr);
|
|
$($t).jqGrid("setSelection",npos[1][npos[0]+1]);
|
|
$($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
|
|
if($.isFunction(p.afterclickPgButtons)) {
|
|
p.afterclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]+1]);
|
|
}
|
|
updateNav(npos[0]+1,npos);
|
|
}
|
|
return false;
|
|
});
|
|
$("#pData", frmtb+"_2").click(function(){
|
|
if(!checkUpdates()) {return false;}
|
|
$("#FormError",frmtb).hide();
|
|
var ppos = getCurrPos();
|
|
if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) {
|
|
$($t).triggerHandler("jqGridAddEditClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
|
|
var pposret;
|
|
if($.isFunction(p.onclickPgButtons)) {
|
|
pposret = p.onclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]]);
|
|
if( pposret !== undefined && pposret === false ) {return false;}
|
|
}
|
|
if( $("#"+$.jgrid.jqID(ppos[1][ppos[0]-1])).hasClass('ui-state-disabled')) {return false;}
|
|
fillData(ppos[1][ppos[0]-1],$t,frmgr);
|
|
$($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
|
|
$($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
|
|
if($.isFunction(p.afterclickPgButtons)) {
|
|
p.afterclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
|
|
}
|
|
updateNav(ppos[0]-1,ppos);
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
var posInit =getCurrPos();
|
|
updateNav(posInit[0],posInit);
|
|
|
|
});
|
|
},
|
|
viewGridRow : function(rowid, p){
|
|
p = $.extend(true, {
|
|
top : 0,
|
|
left: 0,
|
|
width: 0,
|
|
datawidth: 'auto',
|
|
height: 'auto',
|
|
dataheight: 'auto',
|
|
modal: false,
|
|
overlay: 30,
|
|
drag: true,
|
|
resize: true,
|
|
jqModal: true,
|
|
closeOnEscape : false,
|
|
labelswidth: '30%',
|
|
closeicon: [],
|
|
navkeys: [false,38,40],
|
|
onClose: null,
|
|
beforeShowForm : null,
|
|
beforeInitData : null,
|
|
viewPagerButtons : true,
|
|
recreateForm : false
|
|
}, $.jgrid.view, p || {});
|
|
rp_ge[$(this)[0].p.id] = p;
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if (!$t.grid || !rowid) {return;}
|
|
var gID = $t.p.id,
|
|
frmgr = "ViewGrid_"+$.jgrid.jqID( gID ), frmtb = "ViewTbl_" + $.jgrid.jqID( gID ),
|
|
frmgr_id = "ViewGrid_"+gID, frmtb_id = "ViewTbl_"+gID,
|
|
IDs = {themodal:'viewmod'+gID,modalhead:'viewhd'+gID,modalcontent:'viewcnt'+gID, scrollelm : frmgr},
|
|
onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false,
|
|
showFrm = true,
|
|
maxCols = 1, maxRows=0;
|
|
if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) {
|
|
$("#"+$.jgrid.jqID(IDs.themodal)).remove();
|
|
}
|
|
function focusaref(){ //Sfari 3 issues
|
|
if(rp_ge[$t.p.id].closeOnEscape===true || rp_ge[$t.p.id].navkeys[0]===true) {
|
|
setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.modalhead)).focus();},0);
|
|
}
|
|
}
|
|
function createData(rowid,obj,tb,maxcols){
|
|
var nm, hc,trdata, cnt=0,tmp, dc, retpos=[], ind=false, i,
|
|
tdtmpl = "<td class='CaptionTD form-view-label ui-widget-content' width='"+p.labelswidth+"'> </td><td class='DataTD form-view-data ui-helper-reset ui-widget-content'> </td>", tmpl="",
|
|
tdtmpl2 = "<td class='CaptionTD form-view-label ui-widget-content'> </td><td class='DataTD form-view-data ui-widget-content'> </td>",
|
|
fmtnum = ['integer','number','currency'],max1 =0, max2=0 ,maxw,setme, viewfld;
|
|
for (i=1;i<=maxcols;i++) {
|
|
tmpl += i === 1 ? tdtmpl : tdtmpl2;
|
|
}
|
|
// find max number align rigth with property formatter
|
|
$(obj.p.colModel).each( function() {
|
|
if(this.editrules && this.editrules.edithidden === true) {
|
|
hc = false;
|
|
} else {
|
|
hc = this.hidden === true ? true : false;
|
|
}
|
|
if(!hc && this.align==='right') {
|
|
if(this.formatter && $.inArray(this.formatter,fmtnum) !== -1 ) {
|
|
max1 = Math.max(max1,parseInt(this.width,10));
|
|
} else {
|
|
max2 = Math.max(max2,parseInt(this.width,10));
|
|
}
|
|
}
|
|
});
|
|
maxw = max1 !==0 ? max1 : max2 !==0 ? max2 : 0;
|
|
ind = $(obj).jqGrid("getInd",rowid);
|
|
$(obj.p.colModel).each( function(i) {
|
|
nm = this.name;
|
|
setme = false;
|
|
// hidden fields are included in the form
|
|
if(this.editrules && this.editrules.edithidden === true) {
|
|
hc = false;
|
|
} else {
|
|
hc = this.hidden === true ? true : false;
|
|
}
|
|
dc = hc ? "style='display:none'" : "";
|
|
viewfld = (typeof this.viewable !== 'boolean') ? true : this.viewable;
|
|
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && viewfld) {
|
|
if(ind === false) {
|
|
tmp = "";
|
|
} else {
|
|
if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
|
tmp = $("td:eq("+i+")",obj.rows[ind]).text();
|
|
} else {
|
|
tmp = $("td:eq("+i+")",obj.rows[ind]).html();
|
|
}
|
|
}
|
|
setme = this.align === 'right' && maxw !==0 ? true : false;
|
|
var frmopt = $.extend({},{rowabove:false,rowcontent:''}, this.formoptions || {}),
|
|
rp = parseInt(frmopt.rowpos,10) || cnt+1,
|
|
cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10);
|
|
if(frmopt.rowabove) {
|
|
var newdata = $("<tr><td class='contentinfo' colspan='"+(maxcols*2)+"'>"+frmopt.rowcontent+"</td></tr>");
|
|
$(tb).append(newdata);
|
|
newdata[0].rp = rp;
|
|
}
|
|
trdata = $(tb).find("tr[rowpos="+rp+"]");
|
|
if ( trdata.length===0 ) {
|
|
trdata = $("<tr "+dc+" rowpos='"+rp+"'></tr>").addClass("FormData").attr("id","trv_"+nm);
|
|
$(trdata).append(tmpl);
|
|
$(tb).append(trdata);
|
|
trdata[0].rp = rp;
|
|
}
|
|
$("td:eq("+(cp-2)+")",trdata[0]).html('<b>'+ (frmopt.label === undefined ? obj.p.colNames[i]: frmopt.label)+'</b>');
|
|
$("td:eq("+(cp-1)+")",trdata[0]).append("<span>"+tmp+"</span>").attr("id","v_"+nm);
|
|
if(setme){
|
|
$("td:eq("+(cp-1)+") span",trdata[0]).css({'text-align':'right',width:maxw+"px"});
|
|
}
|
|
retpos[cnt] = i;
|
|
cnt++;
|
|
}
|
|
});
|
|
if( cnt > 0) {
|
|
var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='"+ (maxcols*2-1)+"' class='DataTD'><input class='FormElement' id='id_g' type='text' name='id' value='"+rowid+"'/></td></tr>");
|
|
idrow[0].rp = cnt+99;
|
|
$(tb).append(idrow);
|
|
}
|
|
return retpos;
|
|
}
|
|
function fillData(rowid,obj){
|
|
var nm, hc,cnt=0,tmp,trv;
|
|
trv = $(obj).jqGrid("getInd",rowid,true);
|
|
if(!trv) {return;}
|
|
$('td',trv).each( function(i) {
|
|
nm = obj.p.colModel[i].name;
|
|
// hidden fields are included in the form
|
|
if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden === true) {
|
|
hc = false;
|
|
} else {
|
|
hc = obj.p.colModel[i].hidden === true ? true : false;
|
|
}
|
|
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
|
|
if(nm === obj.p.ExpandColumn && obj.p.treeGrid === true) {
|
|
tmp = $(this).text();
|
|
} else {
|
|
tmp = $(this).html();
|
|
}
|
|
nm = $.jgrid.jqID("v_"+nm);
|
|
$("#"+nm+" span","#"+frmtb).html(tmp);
|
|
if (hc) {$("#"+nm,"#"+frmtb).parents("tr:first").hide();}
|
|
cnt++;
|
|
}
|
|
});
|
|
if(cnt>0) {$("#id_g","#"+frmtb).val(rowid);}
|
|
}
|
|
function updateNav(cr,posarr){
|
|
var totr = posarr[1].length-1;
|
|
if (cr===0) {
|
|
$("#pData","#"+frmtb+"_2").addClass('ui-state-disabled');
|
|
} else if( posarr[1][cr-1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr-1])).hasClass('ui-state-disabled')) {
|
|
$("#pData",frmtb+"_2").addClass('ui-state-disabled');
|
|
} else {
|
|
$("#pData","#"+frmtb+"_2").removeClass('ui-state-disabled');
|
|
}
|
|
if (cr===totr) {
|
|
$("#nData","#"+frmtb+"_2").addClass('ui-state-disabled');
|
|
} else if( posarr[1][cr+1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr+1])).hasClass('ui-state-disabled')) {
|
|
$("#nData",frmtb+"_2").addClass('ui-state-disabled');
|
|
} else {
|
|
$("#nData","#"+frmtb+"_2").removeClass('ui-state-disabled');
|
|
}
|
|
}
|
|
function getCurrPos() {
|
|
var rowsInGrid = $($t).jqGrid("getDataIDs"),
|
|
selrow = $("#id_g","#"+frmtb).val(),
|
|
pos = $.inArray(selrow,rowsInGrid);
|
|
return [pos,rowsInGrid];
|
|
}
|
|
|
|
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
|
|
if(onBeforeInit) {
|
|
showFrm = onBeforeInit.call($t,$("#"+frmgr));
|
|
if(showFrm === undefined) {
|
|
showFrm = true;
|
|
}
|
|
}
|
|
if(showFrm === false) {return;}
|
|
$(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption);
|
|
$("#FormError","#"+frmtb).hide();
|
|
fillData(rowid,$t);
|
|
if($.isFunction(rp_ge[$t.p.id].beforeShowForm)) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+frmgr));}
|
|
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal});
|
|
focusaref();
|
|
} else {
|
|
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px",
|
|
dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px",
|
|
frm = $("<form name='FormPost' id='"+frmgr_id+"' class='FormGrid' style='width:"+dw+";overflow:auto;position:relative;height:"+dh+";'></form>"),
|
|
tbl =$("<table id='"+frmtb_id+"' class='EditTable' cellspacing='1' cellpadding='2' border='0' style='table-layout:fixed'><tbody></tbody></table>");
|
|
if(onBeforeInit) {
|
|
showFrm = onBeforeInit.call($t,$("#"+frmgr));
|
|
if(showFrm === undefined) {
|
|
showFrm = true;
|
|
}
|
|
}
|
|
if(showFrm === false) {return;}
|
|
$($t.p.colModel).each( function() {
|
|
var fmto = this.formoptions;
|
|
maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
|
|
maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
|
|
});
|
|
// set the id.
|
|
$(frm).append(tbl);
|
|
createData(rowid, $t, tbl, maxCols);
|
|
var rtlb = $t.p.direction === "rtl" ? true :false,
|
|
bp = rtlb ? "nData" : "pData",
|
|
bn = rtlb ? "pData" : "nData",
|
|
|
|
// buttons at footer
|
|
bP = "<a id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
|
|
bN = "<a id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
|
|
bC ="<a id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bClose+"</a>";
|
|
if(maxRows > 0) {
|
|
var sd=[];
|
|
$.each($(tbl)[0].rows,function(i,r){
|
|
sd[i] = r;
|
|
});
|
|
sd.sort(function(a,b){
|
|
if(a.rp > b.rp) {return 1;}
|
|
if(a.rp < b.rp) {return -1;}
|
|
return 0;
|
|
});
|
|
$.each(sd, function(index, row) {
|
|
$('tbody',tbl).append(row);
|
|
});
|
|
}
|
|
p.gbox = "#gbox_"+$.jgrid.jqID(gID);
|
|
var bt = $("<div></div>").append(frm).append("<table border='0' class='EditTable' id='"+frmtb+"_2'><tbody><tr id='Act_Buttons'><td class='navButton' width='"+p.labelswidth+"'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bC+"</td></tr></tbody></table>");
|
|
$.jgrid.createModal(IDs,bt,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]);
|
|
if(rtlb) {
|
|
$("#pData, #nData","#"+frmtb+"_2").css("float","right");
|
|
$(".EditButton","#"+frmtb+"_2").css("text-align","left");
|
|
}
|
|
if(!p.viewPagerButtons) {$("#pData, #nData","#"+frmtb+"_2").hide();}
|
|
bt = null;
|
|
$("#"+IDs.themodal).keydown( function( e ) {
|
|
if(e.which === 27) {
|
|
if(rp_ge[$t.p.id].closeOnEscape) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: p.onClose});}
|
|
return false;
|
|
}
|
|
if(p.navkeys[0]===true) {
|
|
if(e.which === p.navkeys[1]){ //up
|
|
$("#pData", "#"+frmtb+"_2").trigger("click");
|
|
return false;
|
|
}
|
|
if(e.which === p.navkeys[2]){ //down
|
|
$("#nData", "#"+frmtb+"_2").trigger("click");
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
|
|
if(p.closeicon[0]===true) {
|
|
$("#cData","#"+frmtb+"_2").addClass(p.closeicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
|
.append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
|
|
}
|
|
if($.isFunction(p.beforeShowForm)) {p.beforeShowForm.call($t,$("#"+frmgr));}
|
|
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,overlay: p.overlay, modal:p.modal});
|
|
$(".fm-button:not(.ui-state-disabled)","#"+frmtb+"_2").hover(
|
|
function(){$(this).addClass('ui-state-hover');},
|
|
function(){$(this).removeClass('ui-state-hover');}
|
|
);
|
|
focusaref();
|
|
$("#cData", "#"+frmtb+"_2").click(function(){
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: p.onClose});
|
|
return false;
|
|
});
|
|
$("#nData", "#"+frmtb+"_2").click(function(){
|
|
$("#FormError","#"+frmtb).hide();
|
|
var npos = getCurrPos();
|
|
npos[0] = parseInt(npos[0],10);
|
|
if(npos[0] !== -1 && npos[1][npos[0]+1]) {
|
|
if($.isFunction(p.onclickPgButtons)) {
|
|
p.onclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]]);
|
|
}
|
|
fillData(npos[1][npos[0]+1],$t);
|
|
$($t).jqGrid("setSelection",npos[1][npos[0]+1]);
|
|
if($.isFunction(p.afterclickPgButtons)) {
|
|
p.afterclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]+1]);
|
|
}
|
|
updateNav(npos[0]+1,npos);
|
|
}
|
|
focusaref();
|
|
return false;
|
|
});
|
|
$("#pData", "#"+frmtb+"_2").click(function(){
|
|
$("#FormError","#"+frmtb).hide();
|
|
var ppos = getCurrPos();
|
|
if(ppos[0] !== -1 && ppos[1][ppos[0]-1]) {
|
|
if($.isFunction(p.onclickPgButtons)) {
|
|
p.onclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]]);
|
|
}
|
|
fillData(ppos[1][ppos[0]-1],$t);
|
|
$($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
|
|
if($.isFunction(p.afterclickPgButtons)) {
|
|
p.afterclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
|
|
}
|
|
updateNav(ppos[0]-1,ppos);
|
|
}
|
|
focusaref();
|
|
return false;
|
|
});
|
|
}
|
|
var posInit =getCurrPos();
|
|
updateNav(posInit[0],posInit);
|
|
});
|
|
},
|
|
delGridRow : function(rowids,p) {
|
|
p = $.extend(true, {
|
|
top : 0,
|
|
left: 0,
|
|
width: 240,
|
|
height: 'auto',
|
|
dataheight : 'auto',
|
|
modal: false,
|
|
overlay: 30,
|
|
drag: true,
|
|
resize: true,
|
|
url : '',
|
|
mtype : "POST",
|
|
reloadAfterSubmit: true,
|
|
beforeShowForm: null,
|
|
beforeInitData : null,
|
|
afterShowForm: null,
|
|
beforeSubmit: null,
|
|
onclickSubmit: null,
|
|
afterSubmit: null,
|
|
jqModal : true,
|
|
closeOnEscape : false,
|
|
delData: {},
|
|
delicon : [],
|
|
cancelicon : [],
|
|
onClose : null,
|
|
ajaxDelOptions : {},
|
|
processing : false,
|
|
serializeDelData : null,
|
|
useDataProxy : false
|
|
}, $.jgrid.del, p ||{});
|
|
rp_ge[$(this)[0].p.id] = p;
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if (!$t.grid ) {return;}
|
|
if(!rowids) {return;}
|
|
var onBeforeShow = $.isFunction( rp_ge[$t.p.id].beforeShowForm ),
|
|
onAfterShow = $.isFunction( rp_ge[$t.p.id].afterShowForm ),
|
|
onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false,
|
|
gID = $t.p.id, onCS = {},
|
|
showFrm = true,
|
|
dtbl = "DelTbl_"+$.jgrid.jqID(gID),postd, idname, opers, oper,
|
|
dtbl_id = "DelTbl_" + gID,
|
|
IDs = {themodal:'delmod'+gID,modalhead:'delhd'+gID,modalcontent:'delcnt'+gID, scrollelm: dtbl};
|
|
if ($.isArray(rowids)) {rowids = rowids.join();}
|
|
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
|
|
if(onBeforeInit) {
|
|
showFrm = onBeforeInit.call($t,$("#"+dtbl));
|
|
if(showFrm === undefined) {
|
|
showFrm = true;
|
|
}
|
|
}
|
|
if(showFrm === false) {return;}
|
|
$("#DelData>td","#"+dtbl).text(rowids);
|
|
$("#DelError","#"+dtbl).hide();
|
|
if( rp_ge[$t.p.id].processing === true) {
|
|
rp_ge[$t.p.id].processing=false;
|
|
$("#dData", "#"+dtbl).removeClass('ui-state-active');
|
|
}
|
|
if(onBeforeShow) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+dtbl));}
|
|
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal,jqM: false, overlay: rp_ge[$t.p.id].overlay, modal:rp_ge[$t.p.id].modal});
|
|
if(onAfterShow) {rp_ge[$t.p.id].afterShowForm.call($t,$("#"+dtbl));}
|
|
} else {
|
|
var dh = isNaN(rp_ge[$t.p.id].dataheight) ? rp_ge[$t.p.id].dataheight : rp_ge[$t.p.id].dataheight+"px",
|
|
dw = isNaN(p.datawidth) ? p.datawidth : p.datawidth+"px",
|
|
tbl = "<div id='"+dtbl_id+"' class='formdata' style='width:"+dw+";overflow:auto;position:relative;height:"+dh+";'>";
|
|
tbl += "<table class='DelTable'><tbody>";
|
|
// error data
|
|
tbl += "<tr id='DelError' style='display:none'><td class='ui-state-error'></td></tr>";
|
|
tbl += "<tr id='DelData' style='display:none'><td >"+rowids+"</td></tr>";
|
|
tbl += "<tr><td class=\"delmsg\" style=\"white-space:pre;\">"+rp_ge[$t.p.id].msg+"</td></tr><tr><td > </td></tr>";
|
|
// buttons at footer
|
|
tbl += "</tbody></table></div>";
|
|
var bS = "<a id='dData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
|
|
bC = "<a id='eData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
|
|
tbl += "<table cellspacing='0' cellpadding='0' border='0' class='EditTable' id='"+dtbl+"_2'><tbody><tr><td><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr><td class='DelButton EditButton'>"+bS+" "+bC+"</td></tr></tbody></table>";
|
|
p.gbox = "#gbox_"+$.jgrid.jqID(gID);
|
|
$.jgrid.createModal(IDs,tbl,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]);
|
|
|
|
if(onBeforeInit) {
|
|
showFrm = onBeforeInit.call($t,$("#"+dtbl));
|
|
if(showFrm === undefined) {
|
|
showFrm = true;
|
|
}
|
|
}
|
|
if(showFrm === false) {return;}
|
|
|
|
$(".fm-button","#"+dtbl+"_2").hover(
|
|
function(){$(this).addClass('ui-state-hover');},
|
|
function(){$(this).removeClass('ui-state-hover');}
|
|
);
|
|
p.delicon = $.extend([true,"left","ui-icon-scissors"],rp_ge[$t.p.id].delicon);
|
|
p.cancelicon = $.extend([true,"left","ui-icon-cancel"],rp_ge[$t.p.id].cancelicon);
|
|
if(p.delicon[0]===true) {
|
|
$("#dData","#"+dtbl+"_2").addClass(p.delicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
|
.append("<span class='ui-icon "+p.delicon[2]+"'></span>");
|
|
}
|
|
if(p.cancelicon[0]===true) {
|
|
$("#eData","#"+dtbl+"_2").addClass(p.cancelicon[1] === "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
|
|
.append("<span class='ui-icon "+p.cancelicon[2]+"'></span>");
|
|
}
|
|
$("#dData","#"+dtbl+"_2").click(function(){
|
|
var ret=[true,""], pk,
|
|
postdata = $("#DelData>td","#"+dtbl).text(); //the pair is name=val1,val2,...
|
|
onCS = {};
|
|
if( $.isFunction( rp_ge[$t.p.id].onclickSubmit ) ) {onCS = rp_ge[$t.p.id].onclickSubmit.call($t,rp_ge[$t.p.id], postdata) || {};}
|
|
if( $.isFunction( rp_ge[$t.p.id].beforeSubmit ) ) {ret = rp_ge[$t.p.id].beforeSubmit.call($t,postdata);}
|
|
if(ret[0] && !rp_ge[$t.p.id].processing) {
|
|
rp_ge[$t.p.id].processing = true;
|
|
opers = $t.p.prmNames;
|
|
postd = $.extend({},rp_ge[$t.p.id].delData, onCS);
|
|
oper = opers.oper;
|
|
postd[oper] = opers.deloper;
|
|
idname = opers.id;
|
|
postdata = String(postdata).split(",");
|
|
if(!postdata.length) { return false; }
|
|
for(pk in postdata) {
|
|
if(postdata.hasOwnProperty(pk)) {
|
|
postdata[pk] = $.jgrid.stripPref($t.p.idPrefix, postdata[pk]);
|
|
}
|
|
}
|
|
postd[idname] = postdata.join();
|
|
$(this).addClass('ui-state-active');
|
|
var ajaxOptions = $.extend({
|
|
url: rp_ge[$t.p.id].url || $($t).jqGrid('getGridParam','editurl'),
|
|
type: rp_ge[$t.p.id].mtype,
|
|
data: $.isFunction(rp_ge[$t.p.id].serializeDelData) ? rp_ge[$t.p.id].serializeDelData.call($t,postd) : postd,
|
|
complete:function(data,status){
|
|
var i;
|
|
if(data.status >= 300 && data.status !== 304) {
|
|
ret[0] = false;
|
|
if ($.isFunction(rp_ge[$t.p.id].errorTextFormat)) {
|
|
ret[1] = rp_ge[$t.p.id].errorTextFormat.call($t,data);
|
|
} else {
|
|
ret[1] = status + " Status: '" + data.statusText + "'. Error code: " + data.status;
|
|
}
|
|
} else {
|
|
// data is posted successful
|
|
// execute aftersubmit with the returned data from server
|
|
if( $.isFunction( rp_ge[$t.p.id].afterSubmit ) ) {
|
|
ret = rp_ge[$t.p.id].afterSubmit.call($t,data,postd);
|
|
}
|
|
}
|
|
if(ret[0] === false) {
|
|
$("#DelError>td","#"+dtbl).html(ret[1]);
|
|
$("#DelError","#"+dtbl).show();
|
|
} else {
|
|
if(rp_ge[$t.p.id].reloadAfterSubmit && $t.p.datatype !== "local") {
|
|
$($t).trigger("reloadGrid");
|
|
} else {
|
|
if($t.p.treeGrid===true){
|
|
try {$($t).jqGrid("delTreeNode",$t.p.idPrefix+postdata[0]);} catch(e){}
|
|
} else {
|
|
for(i=0;i<postdata.length;i++) {
|
|
$($t).jqGrid("delRowData",$t.p.idPrefix+ postdata[i]);
|
|
}
|
|
}
|
|
$t.p.selrow = null;
|
|
$t.p.selarrrow = [];
|
|
}
|
|
if($.isFunction(rp_ge[$t.p.id].afterComplete)) {
|
|
setTimeout(function(){rp_ge[$t.p.id].afterComplete.call($t,data,postdata);},500);
|
|
}
|
|
}
|
|
rp_ge[$t.p.id].processing=false;
|
|
$("#dData", "#"+dtbl+"_2").removeClass('ui-state-active');
|
|
if(ret[0]) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});}
|
|
}
|
|
}, $.jgrid.ajaxOptions, rp_ge[$t.p.id].ajaxDelOptions);
|
|
|
|
|
|
if (!ajaxOptions.url && !rp_ge[$t.p.id].useDataProxy) {
|
|
if ($.isFunction($t.p.dataProxy)) {
|
|
rp_ge[$t.p.id].useDataProxy = true;
|
|
} else {
|
|
ret[0]=false;ret[1] += " "+$.jgrid.errors.nourl;
|
|
}
|
|
}
|
|
if (ret[0]) {
|
|
if (rp_ge[$t.p.id].useDataProxy) {
|
|
var dpret = $t.p.dataProxy.call($t, ajaxOptions, "del_"+$t.p.id);
|
|
if(dpret === undefined) {
|
|
dpret = [true, ""];
|
|
}
|
|
if(dpret[0] === false ) {
|
|
ret[0] = false;
|
|
ret[1] = dpret[1] || "Error deleting the selected row!" ;
|
|
} else {
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
|
|
}
|
|
}
|
|
else {$.ajax(ajaxOptions);}
|
|
}
|
|
}
|
|
|
|
if(ret[0] === false) {
|
|
$("#DelError>td","#"+dtbl).html(ret[1]);
|
|
$("#DelError","#"+dtbl).show();
|
|
}
|
|
return false;
|
|
});
|
|
$("#eData", "#"+dtbl+"_2").click(function(){
|
|
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal, onClose: rp_ge[$t.p.id].onClose});
|
|
return false;
|
|
});
|
|
if(onBeforeShow) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+dtbl));}
|
|
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal, overlay: rp_ge[$t.p.id].overlay, modal:rp_ge[$t.p.id].modal});
|
|
if(onAfterShow) {rp_ge[$t.p.id].afterShowForm.call($t,$("#"+dtbl));}
|
|
}
|
|
if(rp_ge[$t.p.id].closeOnEscape===true) {
|
|
setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.modalhead)).focus();},0);
|
|
}
|
|
});
|
|
},
|
|
navGrid : function (elem, o, pEdit,pAdd,pDel,pSearch, pView) {
|
|
o = $.extend({
|
|
edit: true,
|
|
editicon: "ui-icon-pencil",
|
|
add: true,
|
|
addicon:"ui-icon-plus",
|
|
del: true,
|
|
delicon:"ui-icon-trash",
|
|
search: true,
|
|
searchicon:"ui-icon-search",
|
|
refresh: true,
|
|
refreshicon:"ui-icon-refresh",
|
|
refreshstate: 'firstpage',
|
|
view: false,
|
|
viewicon : "ui-icon-document",
|
|
position : "left",
|
|
closeOnEscape : true,
|
|
beforeRefresh : null,
|
|
afterRefresh : null,
|
|
cloneToTop : false,
|
|
alertwidth : 200,
|
|
alertheight : 'auto',
|
|
alerttop: null,
|
|
alertleft: null,
|
|
alertzIndex : null
|
|
}, $.jgrid.nav, o ||{});
|
|
return this.each(function() {
|
|
if(this.nav) {return;}
|
|
var alertIDs = {themodal: 'alertmod_' + this.p.id, modalhead: 'alerthd_' + this.p.id,modalcontent: 'alertcnt_' + this.p.id},
|
|
$t = this, twd, tdw;
|
|
if(!$t.grid || typeof elem !== 'string') {return;}
|
|
if ($("#"+alertIDs.themodal)[0] === undefined) {
|
|
if(!o.alerttop && !o.alertleft) {
|
|
if (window.innerWidth !== undefined) {
|
|
o.alertleft = window.innerWidth;
|
|
o.alerttop = window.innerHeight;
|
|
} else if (document.documentElement !== undefined && document.documentElement.clientWidth !== undefined && document.documentElement.clientWidth !== 0) {
|
|
o.alertleft = document.documentElement.clientWidth;
|
|
o.alerttop = document.documentElement.clientHeight;
|
|
} else {
|
|
o.alertleft=1024;
|
|
o.alerttop=768;
|
|
}
|
|
o.alertleft = o.alertleft/2 - parseInt(o.alertwidth,10)/2;
|
|
o.alerttop = o.alerttop/2-25;
|
|
}
|
|
$.jgrid.createModal(alertIDs,
|
|
"<div>"+o.alerttext+"</div><span tabindex='0'><span tabindex='-1' id='jqg_alrt'></span></span>",
|
|
{
|
|
gbox:"#gbox_"+$.jgrid.jqID($t.p.id),
|
|
jqModal:true,
|
|
drag:true,
|
|
resize:true,
|
|
caption:o.alertcap,
|
|
top:o.alerttop,
|
|
left:o.alertleft,
|
|
width:o.alertwidth,
|
|
height: o.alertheight,
|
|
closeOnEscape:o.closeOnEscape,
|
|
zIndex: o.alertzIndex
|
|
},
|
|
"#gview_"+$.jgrid.jqID($t.p.id),
|
|
$("#gbox_"+$.jgrid.jqID($t.p.id))[0],
|
|
true
|
|
);
|
|
}
|
|
var clone = 1, i,
|
|
onHoverIn = function () {
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
$(this).addClass("ui-state-hover");
|
|
}
|
|
},
|
|
onHoverOut = function () {
|
|
$(this).removeClass("ui-state-hover");
|
|
};
|
|
if(o.cloneToTop && $t.p.toppager) {clone = 2;}
|
|
for(i = 0; i<clone; i++) {
|
|
var tbd,
|
|
navtbl = $("<table cellspacing='0' cellpadding='0' border='0' class='ui-pg-table navtable' style='float:left;table-layout:auto;'><tbody><tr></tr></tbody></table>"),
|
|
sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>",
|
|
pgid, elemids;
|
|
if(i===0) {
|
|
pgid = elem;
|
|
elemids = $t.p.id;
|
|
if(pgid === $t.p.toppager) {
|
|
elemids += "_top";
|
|
clone = 1;
|
|
}
|
|
} else {
|
|
pgid = $t.p.toppager;
|
|
elemids = $t.p.id+"_top";
|
|
}
|
|
if($t.p.direction === "rtl") {$(navtbl).attr("dir","rtl").css("float","right");}
|
|
if (o.add) {
|
|
pAdd = pAdd || {};
|
|
tbd = $("<td class='ui-pg-button'></td>");
|
|
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.addicon+"'></span>"+o.addtext+"</div>");
|
|
$("tr",navtbl).append(tbd);
|
|
$(tbd,navtbl)
|
|
.attr({"title":o.addtitle || "",id : pAdd.id || "add_"+elemids})
|
|
.click(function(){
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
if ($.isFunction( o.addfunc )) {
|
|
o.addfunc.call($t);
|
|
} else {
|
|
$($t).jqGrid("editGridRow","new",pAdd);
|
|
}
|
|
}
|
|
return false;
|
|
}).hover(onHoverIn, onHoverOut);
|
|
tbd = null;
|
|
}
|
|
if (o.edit) {
|
|
tbd = $("<td class='ui-pg-button'></td>");
|
|
pEdit = pEdit || {};
|
|
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.editicon+"'></span>"+o.edittext+"</div>");
|
|
$("tr",navtbl).append(tbd);
|
|
$(tbd,navtbl)
|
|
.attr({"title":o.edittitle || "",id: pEdit.id || "edit_"+elemids})
|
|
.click(function(){
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
var sr = $t.p.selrow;
|
|
if (sr) {
|
|
if($.isFunction( o.editfunc ) ) {
|
|
o.editfunc.call($t, sr);
|
|
} else {
|
|
$($t).jqGrid("editGridRow",sr,pEdit);
|
|
}
|
|
} else {
|
|
$.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true});
|
|
$("#jqg_alrt").focus();
|
|
}
|
|
}
|
|
return false;
|
|
}).hover(onHoverIn, onHoverOut);
|
|
tbd = null;
|
|
}
|
|
if (o.view) {
|
|
tbd = $("<td class='ui-pg-button'></td>");
|
|
pView = pView || {};
|
|
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.viewicon+"'></span>"+o.viewtext+"</div>");
|
|
$("tr",navtbl).append(tbd);
|
|
$(tbd,navtbl)
|
|
.attr({"title":o.viewtitle || "",id: pView.id || "view_"+elemids})
|
|
.click(function(){
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
var sr = $t.p.selrow;
|
|
if (sr) {
|
|
if($.isFunction( o.viewfunc ) ) {
|
|
o.viewfunc.call($t, sr);
|
|
} else {
|
|
$($t).jqGrid("viewGridRow",sr,pView);
|
|
}
|
|
} else {
|
|
$.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true});
|
|
$("#jqg_alrt").focus();
|
|
}
|
|
}
|
|
return false;
|
|
}).hover(onHoverIn, onHoverOut);
|
|
tbd = null;
|
|
}
|
|
if (o.del) {
|
|
tbd = $("<td class='ui-pg-button'></td>");
|
|
pDel = pDel || {};
|
|
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.delicon+"'></span>"+o.deltext+"</div>");
|
|
$("tr",navtbl).append(tbd);
|
|
$(tbd,navtbl)
|
|
.attr({"title":o.deltitle || "",id: pDel.id || "del_"+elemids})
|
|
.click(function(){
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
var dr;
|
|
if($t.p.multiselect) {
|
|
dr = $t.p.selarrrow;
|
|
if(dr.length===0) {dr = null;}
|
|
} else {
|
|
dr = $t.p.selrow;
|
|
}
|
|
if(dr){
|
|
if($.isFunction( o.delfunc )){
|
|
o.delfunc.call($t, dr);
|
|
}else{
|
|
$($t).jqGrid("delGridRow",dr,pDel);
|
|
}
|
|
} else {
|
|
$.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true});$("#jqg_alrt").focus();
|
|
}
|
|
}
|
|
return false;
|
|
}).hover(onHoverIn, onHoverOut);
|
|
tbd = null;
|
|
}
|
|
if(o.add || o.edit || o.del || o.view) {$("tr",navtbl).append(sep);}
|
|
if (o.search) {
|
|
tbd = $("<td class='ui-pg-button'></td>");
|
|
pSearch = pSearch || {};
|
|
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.searchicon+"'></span>"+o.searchtext+"</div>");
|
|
$("tr",navtbl).append(tbd);
|
|
$(tbd,navtbl)
|
|
.attr({"title":o.searchtitle || "",id:pSearch.id || "search_"+elemids})
|
|
.click(function(){
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
if($.isFunction( o.searchfunc )) {
|
|
o.searchfunc.call($t, pSearch);
|
|
} else {
|
|
$($t).jqGrid("searchGrid",pSearch);
|
|
}
|
|
}
|
|
return false;
|
|
}).hover(onHoverIn, onHoverOut);
|
|
if (pSearch.showOnLoad && pSearch.showOnLoad === true) {
|
|
$(tbd,navtbl).click();
|
|
}
|
|
tbd = null;
|
|
}
|
|
if (o.refresh) {
|
|
tbd = $("<td class='ui-pg-button'></td>");
|
|
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.refreshicon+"'></span>"+o.refreshtext+"</div>");
|
|
$("tr",navtbl).append(tbd);
|
|
$(tbd,navtbl)
|
|
.attr({"title":o.refreshtitle || "",id: "refresh_"+elemids})
|
|
.click(function(){
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
if($.isFunction(o.beforeRefresh)) {o.beforeRefresh.call($t);}
|
|
$t.p.search = false;
|
|
try {
|
|
var gID = $t.p.id;
|
|
$t.p.postData.filters ="";
|
|
try {
|
|
$("#fbox_"+$.jgrid.jqID(gID)).jqFilter('resetFilter');
|
|
} catch(ef) {}
|
|
if($.isFunction($t.clearToolbar)) {$t.clearToolbar.call($t,false);}
|
|
} catch (e) {}
|
|
switch (o.refreshstate) {
|
|
case 'firstpage':
|
|
$($t).trigger("reloadGrid", [{page:1}]);
|
|
break;
|
|
case 'current':
|
|
$($t).trigger("reloadGrid", [{current:true}]);
|
|
break;
|
|
}
|
|
if($.isFunction(o.afterRefresh)) {o.afterRefresh.call($t);}
|
|
}
|
|
return false;
|
|
}).hover(onHoverIn, onHoverOut);
|
|
tbd = null;
|
|
}
|
|
tdw = $(".ui-jqgrid").css("font-size") || "11px";
|
|
$('body').append("<div id='testpg2' class='ui-jqgrid ui-widget ui-widget-content' style='font-size:"+tdw+";visibility:hidden;' ></div>");
|
|
twd = $(navtbl).clone().appendTo("#testpg2").width();
|
|
$("#testpg2").remove();
|
|
$(pgid+"_"+o.position,pgid).append(navtbl);
|
|
if($t.p._nvtd) {
|
|
if(twd > $t.p._nvtd[0] ) {
|
|
$(pgid+"_"+o.position,pgid).width(twd);
|
|
$t.p._nvtd[0] = twd;
|
|
}
|
|
$t.p._nvtd[1] = twd;
|
|
}
|
|
tdw =null;twd=null;navtbl =null;
|
|
this.nav = true;
|
|
}
|
|
});
|
|
},
|
|
navButtonAdd : function (elem, p) {
|
|
p = $.extend({
|
|
caption : "newButton",
|
|
title: '',
|
|
buttonicon : 'ui-icon-newwin',
|
|
onClickButton: null,
|
|
position : "last",
|
|
cursor : 'pointer'
|
|
}, p ||{});
|
|
return this.each(function() {
|
|
if( !this.grid) {return;}
|
|
if( typeof elem === "string" && elem.indexOf("#") !== 0) {elem = "#"+$.jgrid.jqID(elem);}
|
|
var findnav = $(".navtable",elem)[0], $t = this;
|
|
if (findnav) {
|
|
if( p.id && $("#"+$.jgrid.jqID(p.id), findnav)[0] !== undefined ) {return;}
|
|
var tbd = $("<td></td>");
|
|
if(p.buttonicon.toString().toUpperCase() === "NONE") {
|
|
$(tbd).addClass('ui-pg-button').append("<div class='ui-pg-div'>"+p.caption+"</div>");
|
|
} else {
|
|
$(tbd).addClass('ui-pg-button').append("<div class='ui-pg-div'><span class='ui-icon "+p.buttonicon+"'></span>"+p.caption+"</div>");
|
|
}
|
|
if(p.id) {$(tbd).attr("id",p.id);}
|
|
if(p.position==='first'){
|
|
if(findnav.rows[0].cells.length ===0 ) {
|
|
$("tr",findnav).append(tbd);
|
|
} else {
|
|
$("tr td:eq(0)",findnav).before(tbd);
|
|
}
|
|
} else {
|
|
$("tr",findnav).append(tbd);
|
|
}
|
|
$(tbd,findnav)
|
|
.attr("title",p.title || "")
|
|
.click(function(e){
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
if ($.isFunction(p.onClickButton) ) {p.onClickButton.call($t,e);}
|
|
}
|
|
return false;
|
|
})
|
|
.hover(
|
|
function () {
|
|
if (!$(this).hasClass('ui-state-disabled')) {
|
|
$(this).addClass('ui-state-hover');
|
|
}
|
|
},
|
|
function () {$(this).removeClass("ui-state-hover");}
|
|
);
|
|
}
|
|
});
|
|
},
|
|
navSeparatorAdd:function (elem,p) {
|
|
p = $.extend({
|
|
sepclass : "ui-separator",
|
|
sepcontent: '',
|
|
position : "last"
|
|
}, p ||{});
|
|
return this.each(function() {
|
|
if( !this.grid) {return;}
|
|
if( typeof elem === "string" && elem.indexOf("#") !== 0) {elem = "#"+$.jgrid.jqID(elem);}
|
|
var findnav = $(".navtable",elem)[0];
|
|
if(findnav) {
|
|
var sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='"+p.sepclass+"'></span>"+p.sepcontent+"</td>";
|
|
if (p.position === 'first') {
|
|
if (findnav.rows[0].cells.length === 0) {
|
|
$("tr", findnav).append(sep);
|
|
} else {
|
|
$("tr td:eq(0)", findnav).before(sep);
|
|
}
|
|
} else {
|
|
$("tr", findnav).append(sep);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
GridToForm : function( rowid, formid ) {
|
|
return this.each(function(){
|
|
var $t = this, i;
|
|
if (!$t.grid) {return;}
|
|
var rowdata = $($t).jqGrid("getRowData",rowid);
|
|
if (rowdata) {
|
|
for(i in rowdata) {
|
|
if(rowdata.hasOwnProperty(i)) {
|
|
if ( $("[name="+$.jgrid.jqID(i)+"]",formid).is("input:radio") || $("[name="+$.jgrid.jqID(i)+"]",formid).is("input:checkbox")) {
|
|
$("[name="+$.jgrid.jqID(i)+"]",formid).each( function() {
|
|
if( $(this).val() == rowdata[i] ) {
|
|
$(this)[$t.p.useProp ? 'prop': 'attr']("checked",true);
|
|
} else {
|
|
$(this)[$t.p.useProp ? 'prop': 'attr']("checked", false);
|
|
}
|
|
});
|
|
} else {
|
|
// this is very slow on big table and form.
|
|
$("[name="+$.jgrid.jqID(i)+"]",formid).val(rowdata[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
FormToGrid : function(rowid, formid, mode, position){
|
|
return this.each(function() {
|
|
var $t = this;
|
|
if(!$t.grid) {return;}
|
|
if(!mode) {mode = 'set';}
|
|
if(!position) {position = 'first';}
|
|
var fields = $(formid).serializeArray();
|
|
var griddata = {};
|
|
$.each(fields, function(i, field){
|
|
griddata[field.name] = field.value;
|
|
});
|
|
if(mode==='add') {$($t).jqGrid("addRowData",rowid,griddata, position);}
|
|
else if(mode==='set') {$($t).jqGrid("setRowData",rowid,griddata);}
|
|
});
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false, eqnull:true, devel:true */
|
|
/*global jQuery */
|
|
(function($){
|
|
/**
|
|
* jqGrid extension for manipulating Grid Data
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
**/
|
|
"use strict";
|
|
$.jgrid.inlineEdit = $.jgrid.inlineEdit || {};
|
|
$.jgrid.extend({
|
|
//Editing
|
|
editRow : function(rowid,keys,oneditfunc,successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
|
|
// Compatible mode old versions
|
|
var o={}, args = $.makeArray(arguments).slice(1);
|
|
|
|
if( $.type(args[0]) === "object" ) {
|
|
o = args[0];
|
|
} else {
|
|
if (keys !== undefined) { o.keys = keys; }
|
|
if ($.isFunction(oneditfunc)) { o.oneditfunc = oneditfunc; }
|
|
if ($.isFunction(successfunc)) { o.successfunc = successfunc; }
|
|
if (url !== undefined) { o.url = url; }
|
|
if (extraparam !== undefined) { o.extraparam = extraparam; }
|
|
if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; }
|
|
if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; }
|
|
if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
|
|
// last two not as param, but as object (sorry)
|
|
//if (restoreAfterError !== undefined) { o.restoreAfterError = restoreAfterError; }
|
|
//if (mtype !== undefined) { o.mtype = mtype || "POST"; }
|
|
}
|
|
o = $.extend(true, {
|
|
keys : false,
|
|
oneditfunc: null,
|
|
successfunc: null,
|
|
url: null,
|
|
extraparam: {},
|
|
aftersavefunc: null,
|
|
errorfunc: null,
|
|
afterrestorefunc: null,
|
|
restoreAfterError: true,
|
|
mtype: "POST"
|
|
}, $.jgrid.inlineEdit, o );
|
|
|
|
// End compatible
|
|
return this.each(function(){
|
|
var $t = this, nm, tmp, editable, cnt=0, focus=null, svr={}, ind,cm, bfer;
|
|
if (!$t.grid ) { return; }
|
|
ind = $($t).jqGrid("getInd",rowid,true);
|
|
if( ind === false ) {return;}
|
|
bfer = $.isFunction( o.beforeEditRow ) ? o.beforeEditRow.call($t,o, rowid) : undefined;
|
|
if( bfer === undefined ) {
|
|
bfer = true;
|
|
}
|
|
if(!bfer) { return; }
|
|
editable = $(ind).attr("editable") || "0";
|
|
if (editable === "0" && !$(ind).hasClass("not-editable-row")) {
|
|
cm = $t.p.colModel;
|
|
$('td[role="gridcell"]',ind).each( function(i) {
|
|
nm = cm[i].name;
|
|
var treeg = $t.p.treeGrid===true && nm === $t.p.ExpandColumn;
|
|
if(treeg) { tmp = $("span:first",this).html();}
|
|
else {
|
|
try {
|
|
tmp = $.unformat.call($t,this,{rowId:rowid, colModel:cm[i]},i);
|
|
} catch (_) {
|
|
tmp = ( cm[i].edittype && cm[i].edittype === 'textarea' ) ? $(this).text() : $(this).html();
|
|
}
|
|
}
|
|
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
|
|
if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
|
|
svr[nm]=tmp;
|
|
if(cm[i].editable===true) {
|
|
if(focus===null) { focus = i; }
|
|
if (treeg) { $("span:first",this).html(""); }
|
|
else { $(this).html(""); }
|
|
var opt = $.extend({},cm[i].editoptions || {},{id:rowid+"_"+nm,name:nm});
|
|
if(!cm[i].edittype) { cm[i].edittype = "text"; }
|
|
if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';}
|
|
var elc = $.jgrid.createEl.call($t,cm[i].edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {}));
|
|
$(elc).addClass("editable");
|
|
if(treeg) { $("span:first",this).append(elc); }
|
|
else { $(this).append(elc); }
|
|
$.jgrid.bindEv.call($t, elc, opt);
|
|
//Again IE
|
|
if(cm[i].edittype === "select" && cm[i].editoptions!==undefined && cm[i].editoptions.multiple===true && cm[i].editoptions.dataUrl===undefined && $.jgrid.msie) {
|
|
$(elc).width($(elc).width());
|
|
}
|
|
cnt++;
|
|
}
|
|
}
|
|
});
|
|
if(cnt > 0) {
|
|
svr.id = rowid; $t.p.savedRow.push(svr);
|
|
$(ind).attr("editable","1");
|
|
$("td:eq("+focus+") input",ind).focus();
|
|
if(o.keys===true) {
|
|
$(ind).bind("keydown",function(e) {
|
|
if (e.keyCode === 27) {
|
|
$($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
|
|
if($t.p._inlinenav) {
|
|
try {
|
|
$($t).jqGrid('showAddEditButtons');
|
|
} catch (eer1) {}
|
|
}
|
|
return false;
|
|
}
|
|
if (e.keyCode === 13) {
|
|
var ta = e.target;
|
|
if(ta.tagName === 'TEXTAREA') { return true; }
|
|
if( $($t).jqGrid("saveRow", rowid, o ) ) {
|
|
if($t.p._inlinenav) {
|
|
try {
|
|
$($t).jqGrid('showAddEditButtons');
|
|
} catch (eer2) {}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
$($t).triggerHandler("jqGridInlineEditRow", [rowid, o]);
|
|
if( $.isFunction(o.oneditfunc)) { o.oneditfunc.call($t, rowid); }
|
|
}
|
|
}
|
|
});
|
|
},
|
|
saveRow : function(rowid, successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
|
|
// Compatible mode old versions
|
|
var args = $.makeArray(arguments).slice(1), o = {};
|
|
|
|
if( $.type(args[0]) === "object" ) {
|
|
o = args[0];
|
|
} else {
|
|
if ($.isFunction(successfunc)) { o.successfunc = successfunc; }
|
|
if (url !== undefined) { o.url = url; }
|
|
if (extraparam !== undefined) { o.extraparam = extraparam; }
|
|
if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; }
|
|
if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; }
|
|
if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
|
|
}
|
|
o = $.extend(true, {
|
|
successfunc: null,
|
|
url: null,
|
|
extraparam: {},
|
|
aftersavefunc: null,
|
|
errorfunc: null,
|
|
afterrestorefunc: null,
|
|
restoreAfterError: true,
|
|
mtype: "POST"
|
|
}, $.jgrid.inlineEdit, o );
|
|
// End compatible
|
|
|
|
var success = false;
|
|
var $t = this[0], nm, tmp={}, tmp2={}, tmp3= {}, editable, fr, cv, ind;
|
|
if (!$t.grid ) { return success; }
|
|
ind = $($t).jqGrid("getInd",rowid,true);
|
|
if(ind === false) {return success;}
|
|
var bfsr = $.isFunction( o.beforeSaveRow ) ? o.beforeSaveRow.call($t,o, rowid) : undefined;
|
|
if( bfsr === undefined ) {
|
|
bfsr = true;
|
|
}
|
|
if(!bfsr) { return; }
|
|
editable = $(ind).attr("editable");
|
|
o.url = o.url || $t.p.editurl;
|
|
if (editable==="1") {
|
|
var cm;
|
|
$('td[role="gridcell"]',ind).each(function(i) {
|
|
cm = $t.p.colModel[i];
|
|
nm = cm.name;
|
|
if ( nm !== 'cb' && nm !== 'subgrid' && cm.editable===true && nm !== 'rn' && !$(this).hasClass('not-editable-cell')) {
|
|
switch (cm.edittype) {
|
|
case "checkbox":
|
|
var cbv = ["Yes","No"];
|
|
if(cm.editoptions ) {
|
|
cbv = cm.editoptions.value.split(":");
|
|
}
|
|
tmp[nm]= $("input",this).is(":checked") ? cbv[0] : cbv[1];
|
|
break;
|
|
case 'text':
|
|
case 'password':
|
|
case 'textarea':
|
|
case "button" :
|
|
tmp[nm]=$("input, textarea",this).val();
|
|
break;
|
|
case 'select':
|
|
if(!cm.editoptions.multiple) {
|
|
tmp[nm] = $("select option:selected",this).val();
|
|
tmp2[nm] = $("select option:selected", this).text();
|
|
} else {
|
|
var sel = $("select",this), selectedText = [];
|
|
tmp[nm] = $(sel).val();
|
|
if(tmp[nm]) { tmp[nm]= tmp[nm].join(","); } else { tmp[nm] =""; }
|
|
$("select option:selected",this).each(
|
|
function(i,selected){
|
|
selectedText[i] = $(selected).text();
|
|
}
|
|
);
|
|
tmp2[nm] = selectedText.join(",");
|
|
}
|
|
if(cm.formatter && cm.formatter === 'select') { tmp2={}; }
|
|
break;
|
|
case 'custom' :
|
|
try {
|
|
if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) {
|
|
tmp[nm] = cm.editoptions.custom_value.call($t, $(".customelement",this),'get');
|
|
if (tmp[nm] === undefined) { throw "e2"; }
|
|
} else { throw "e1"; }
|
|
} catch (e) {
|
|
if (e==="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose); }
|
|
if (e==="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose); }
|
|
else { $.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose); }
|
|
}
|
|
break;
|
|
}
|
|
cv = $.jgrid.checkValues.call($t,tmp[nm],i);
|
|
if(cv[0] === false) {
|
|
return false;
|
|
}
|
|
if($t.p.autoencode) { tmp[nm] = $.jgrid.htmlEncode(tmp[nm]); }
|
|
if(o.url !== 'clientArray' && cm.editoptions && cm.editoptions.NullIfEmpty === true) {
|
|
if(tmp[nm] === "") {
|
|
tmp3[nm] = 'null';
|
|
}
|
|
}
|
|
}
|
|
});
|
|
if (cv[0] === false){
|
|
try {
|
|
var tr = $($t).jqGrid('getGridRowById', rowid), positions = $.jgrid.findPos(tr);
|
|
$.jgrid.info_dialog($.jgrid.errors.errcap,cv[1],$.jgrid.edit.bClose,{left:positions[0],top:positions[1]+$(tr).outerHeight()});
|
|
} catch (e) {
|
|
alert(cv[1]);
|
|
}
|
|
return success;
|
|
}
|
|
var idname, opers = $t.p.prmNames, oldRowId = rowid;
|
|
if ($t.p.keyIndex === false) {
|
|
idname = opers.id;
|
|
} else {
|
|
idname = $t.p.colModel[$t.p.keyIndex +
|
|
($t.p.rownumbers === true ? 1 : 0) +
|
|
($t.p.multiselect === true ? 1 : 0) +
|
|
($t.p.subGrid === true ? 1 : 0)].name;
|
|
}
|
|
if(tmp) {
|
|
tmp[opers.oper] = opers.editoper;
|
|
if (tmp[idname] === undefined || tmp[idname]==="") {
|
|
tmp[idname] = rowid;
|
|
} else if (ind.id !== $t.p.idPrefix + tmp[idname]) {
|
|
// rename rowid
|
|
var oldid = $.jgrid.stripPref($t.p.idPrefix, rowid);
|
|
if ($t.p._index[oldid] !== undefined) {
|
|
$t.p._index[tmp[idname]] = $t.p._index[oldid];
|
|
delete $t.p._index[oldid];
|
|
}
|
|
rowid = $t.p.idPrefix + tmp[idname];
|
|
$(ind).attr("id", rowid);
|
|
if ($t.p.selrow === oldRowId) {
|
|
$t.p.selrow = rowid;
|
|
}
|
|
if ($.isArray($t.p.selarrrow)) {
|
|
var i = $.inArray(oldRowId, $t.p.selarrrow);
|
|
if (i>=0) {
|
|
$t.p.selarrrow[i] = rowid;
|
|
}
|
|
}
|
|
if ($t.p.multiselect) {
|
|
var newCboxId = "jqg_" + $t.p.id + "_" + rowid;
|
|
$("input.cbox",ind)
|
|
.attr("id", newCboxId)
|
|
.attr("name", newCboxId);
|
|
}
|
|
// TODO: to test the case of frozen columns
|
|
}
|
|
if($t.p.inlineData === undefined) { $t.p.inlineData ={}; }
|
|
tmp = $.extend({},tmp,$t.p.inlineData,o.extraparam);
|
|
}
|
|
if (o.url === 'clientArray') {
|
|
tmp = $.extend({},tmp, tmp2);
|
|
if($t.p.autoencode) {
|
|
$.each(tmp,function(n,v){
|
|
tmp[n] = $.jgrid.htmlDecode(v);
|
|
});
|
|
}
|
|
var k, resp = $($t).jqGrid("setRowData",rowid,tmp);
|
|
$(ind).attr("editable","0");
|
|
for(k=0;k<$t.p.savedRow.length;k++) {
|
|
if( String($t.p.savedRow[k].id) === String(oldRowId)) {fr = k; break;}
|
|
}
|
|
if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
|
|
$($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, resp, tmp, o]);
|
|
if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid,resp, o); }
|
|
success = true;
|
|
$(ind).removeClass("jqgrid-new-row").unbind("keydown");
|
|
} else {
|
|
$("#lui_"+$.jgrid.jqID($t.p.id)).show();
|
|
tmp3 = $.extend({},tmp,tmp3);
|
|
tmp3[idname] = $.jgrid.stripPref($t.p.idPrefix, tmp3[idname]);
|
|
$.ajax($.extend({
|
|
url:o.url,
|
|
data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData.call($t, tmp3) : tmp3,
|
|
type: o.mtype,
|
|
async : false, //?!?
|
|
complete: function(res,stat){
|
|
$("#lui_"+$.jgrid.jqID($t.p.id)).hide();
|
|
if (stat === "success"){
|
|
var ret = true, sucret, k;
|
|
sucret = $($t).triggerHandler("jqGridInlineSuccessSaveRow", [res, rowid, o]);
|
|
if (!$.isArray(sucret)) {sucret = [true, tmp];}
|
|
if (sucret[0] && $.isFunction(o.successfunc)) {sucret = o.successfunc.call($t, res);}
|
|
if($.isArray(sucret)) {
|
|
// expect array - status, data, rowid
|
|
ret = sucret[0];
|
|
tmp = sucret[1] || tmp;
|
|
} else {
|
|
ret = sucret;
|
|
}
|
|
if (ret===true) {
|
|
if($t.p.autoencode) {
|
|
$.each(tmp,function(n,v){
|
|
tmp[n] = $.jgrid.htmlDecode(v);
|
|
});
|
|
}
|
|
tmp = $.extend({},tmp, tmp2);
|
|
$($t).jqGrid("setRowData",rowid,tmp);
|
|
$(ind).attr("editable","0");
|
|
for(k=0;k<$t.p.savedRow.length;k++) {
|
|
if( String($t.p.savedRow[k].id) === String(rowid)) {fr = k; break;}
|
|
}
|
|
if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
|
|
$($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, res, tmp, o]);
|
|
if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid,res); }
|
|
success = true;
|
|
$(ind).removeClass("jqgrid-new-row").unbind("keydown");
|
|
} else {
|
|
$($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, null, o]);
|
|
if($.isFunction(o.errorfunc) ) {
|
|
o.errorfunc.call($t, rowid, res, stat, null);
|
|
}
|
|
if(o.restoreAfterError === true) {
|
|
$($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
error:function(res,stat,err){
|
|
$("#lui_"+$.jgrid.jqID($t.p.id)).hide();
|
|
$($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, err, o]);
|
|
if($.isFunction(o.errorfunc) ) {
|
|
o.errorfunc.call($t, rowid, res, stat, err);
|
|
} else {
|
|
var rT = res.responseText || res.statusText;
|
|
try {
|
|
$.jgrid.info_dialog($.jgrid.errors.errcap,'<div class="ui-state-error">'+ rT +'</div>', $.jgrid.edit.bClose,{buttonalign:'right'});
|
|
} catch(e) {
|
|
alert(rT);
|
|
}
|
|
}
|
|
if(o.restoreAfterError === true) {
|
|
$($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
|
|
}
|
|
}
|
|
}, $.jgrid.ajaxOptions, $t.p.ajaxRowOptions || {}));
|
|
}
|
|
}
|
|
return success;
|
|
},
|
|
restoreRow : function(rowid, afterrestorefunc) {
|
|
// Compatible mode old versions
|
|
var args = $.makeArray(arguments).slice(1), o={};
|
|
|
|
if( $.type(args[0]) === "object" ) {
|
|
o = args[0];
|
|
} else {
|
|
if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
|
|
}
|
|
o = $.extend(true, {}, $.jgrid.inlineEdit, o );
|
|
|
|
// End compatible
|
|
|
|
return this.each(function(){
|
|
var $t= this, fr, ind, ares={}, k;
|
|
if (!$t.grid ) { return; }
|
|
ind = $($t).jqGrid("getInd",rowid,true);
|
|
if(ind === false) {return;}
|
|
var bfcr = $.isFunction( o.beforeCancelRow ) ? o.beforeCancelRow.call($t,cancelPrm, sr) : undefined;
|
|
if( bfcr === undefined ) {
|
|
bfcr = true;
|
|
}
|
|
if(!bfcr) { return; }
|
|
for(k=0;k<$t.p.savedRow.length;k++) {
|
|
if( String($t.p.savedRow[k].id) === String(rowid)) {fr = k; break;}
|
|
}
|
|
if(fr >= 0) {
|
|
if($.isFunction($.fn.datepicker)) {
|
|
try {
|
|
$("input.hasDatepicker","#"+$.jgrid.jqID(ind.id)).datepicker('hide');
|
|
} catch (e) {}
|
|
}
|
|
$.each($t.p.colModel, function(){
|
|
if(this.editable === true && $t.p.savedRow[fr].hasOwnProperty(this.name)) {
|
|
ares[this.name] = $t.p.savedRow[fr][this.name];
|
|
}
|
|
});
|
|
$($t).jqGrid("setRowData",rowid,ares);
|
|
$(ind).attr("editable","0").unbind("keydown");
|
|
$t.p.savedRow.splice(fr,1);
|
|
if($("#"+$.jgrid.jqID(rowid), "#"+$.jgrid.jqID($t.p.id)).hasClass("jqgrid-new-row")){
|
|
setTimeout(function(){
|
|
$($t).jqGrid("delRowData",rowid);
|
|
$($t).jqGrid('showAddEditButtons');
|
|
},0);
|
|
}
|
|
}
|
|
$($t).triggerHandler("jqGridInlineAfterRestoreRow", [rowid]);
|
|
if ($.isFunction(o.afterrestorefunc))
|
|
{
|
|
o.afterrestorefunc.call($t, rowid);
|
|
}
|
|
});
|
|
},
|
|
addRow : function ( p ) {
|
|
p = $.extend(true, {
|
|
rowID : null,
|
|
initdata : {},
|
|
position :"first",
|
|
useDefValues : true,
|
|
useFormatter : false,
|
|
addRowParams : {extraparam:{}}
|
|
},p || {});
|
|
return this.each(function(){
|
|
if (!this.grid ) { return; }
|
|
var $t = this;
|
|
var bfar = $.isFunction( p.beforeAddRow ) ? p.beforeAddRow.call($t,p.addRowParams) : undefined;
|
|
if( bfar === undefined ) {
|
|
bfar = true;
|
|
}
|
|
if(!bfar) { return; }
|
|
p.rowID = $.isFunction(p.rowID) ? p.rowID.call($t, p) : ( (p.rowID != null) ? p.rowID : $.jgrid.randId());
|
|
if(p.useDefValues === true) {
|
|
$($t.p.colModel).each(function(){
|
|
if( this.editoptions && this.editoptions.defaultValue ) {
|
|
var opt = this.editoptions.defaultValue,
|
|
tmp = $.isFunction(opt) ? opt.call($t) : opt;
|
|
p.initdata[this.name] = tmp;
|
|
}
|
|
});
|
|
}
|
|
$($t).jqGrid('addRowData', p.rowID, p.initdata, p.position);
|
|
p.rowID = $t.p.idPrefix + p.rowID;
|
|
$("#"+$.jgrid.jqID(p.rowID), "#"+$.jgrid.jqID($t.p.id)).addClass("jqgrid-new-row");
|
|
if(p.useFormatter) {
|
|
$("#"+$.jgrid.jqID(p.rowID)+" .ui-inline-edit", "#"+$.jgrid.jqID($t.p.id)).click();
|
|
} else {
|
|
var opers = $t.p.prmNames,
|
|
oper = opers.oper;
|
|
p.addRowParams.extraparam[oper] = opers.addoper;
|
|
$($t).jqGrid('editRow', p.rowID, p.addRowParams);
|
|
$($t).jqGrid('setSelection', p.rowID);
|
|
}
|
|
});
|
|
},
|
|
inlineNav : function (elem, o) {
|
|
o = $.extend(true,{
|
|
edit: true,
|
|
editicon: "ui-icon-pencil",
|
|
add: true,
|
|
addicon:"ui-icon-plus",
|
|
save: true,
|
|
saveicon:"ui-icon-disk",
|
|
cancel: true,
|
|
cancelicon:"ui-icon-cancel",
|
|
addParams : {addRowParams: {extraparam: {}}},
|
|
editParams : {},
|
|
restoreAfterSelect : true
|
|
}, $.jgrid.nav, o ||{});
|
|
return this.each(function(){
|
|
if (!this.grid ) { return; }
|
|
var $t = this, onSelect, gID = $.jgrid.jqID($t.p.id);
|
|
$t.p._inlinenav = true;
|
|
// detect the formatactions column
|
|
if(o.addParams.useFormatter === true) {
|
|
var cm = $t.p.colModel,i;
|
|
for (i = 0; i<cm.length; i++) {
|
|
if(cm[i].formatter && cm[i].formatter === "actions" ) {
|
|
if(cm[i].formatoptions) {
|
|
var defaults = {
|
|
keys:false,
|
|
onEdit : null,
|
|
onSuccess: null,
|
|
afterSave:null,
|
|
onError: null,
|
|
afterRestore: null,
|
|
extraparam: {},
|
|
url: null
|
|
},
|
|
ap = $.extend( defaults, cm[i].formatoptions );
|
|
o.addParams.addRowParams = {
|
|
"keys" : ap.keys,
|
|
"oneditfunc" : ap.onEdit,
|
|
"successfunc" : ap.onSuccess,
|
|
"url" : ap.url,
|
|
"extraparam" : ap.extraparam,
|
|
"aftersavefunc" : ap.afterSave,
|
|
"errorfunc": ap.onError,
|
|
"afterrestorefunc" : ap.afterRestore
|
|
};
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(o.add) {
|
|
$($t).jqGrid('navButtonAdd', elem,{
|
|
caption : o.addtext,
|
|
title : o.addtitle,
|
|
buttonicon : o.addicon,
|
|
id : $t.p.id+"_iladd",
|
|
onClickButton : function () {
|
|
$($t).jqGrid('addRow', o.addParams);
|
|
if(!o.addParams.useFormatter) {
|
|
$("#"+gID+"_ilsave").removeClass('ui-state-disabled');
|
|
$("#"+gID+"_ilcancel").removeClass('ui-state-disabled');
|
|
$("#"+gID+"_iladd").addClass('ui-state-disabled');
|
|
$("#"+gID+"_iledit").addClass('ui-state-disabled');
|
|
}
|
|
}
|
|
});
|
|
}
|
|
if(o.edit) {
|
|
$($t).jqGrid('navButtonAdd', elem,{
|
|
caption : o.edittext,
|
|
title : o.edittitle,
|
|
buttonicon : o.editicon,
|
|
id : $t.p.id+"_iledit",
|
|
onClickButton : function () {
|
|
var sr = $($t).jqGrid('getGridParam','selrow');
|
|
if(sr) {
|
|
$($t).jqGrid('editRow', sr, o.editParams);
|
|
$("#"+gID+"_ilsave").removeClass('ui-state-disabled');
|
|
$("#"+gID+"_ilcancel").removeClass('ui-state-disabled');
|
|
$("#"+gID+"_iladd").addClass('ui-state-disabled');
|
|
$("#"+gID+"_iledit").addClass('ui-state-disabled');
|
|
} else {
|
|
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();
|
|
}
|
|
}
|
|
});
|
|
}
|
|
if(o.save) {
|
|
$($t).jqGrid('navButtonAdd', elem,{
|
|
caption : o.savetext || '',
|
|
title : o.savetitle || 'Save row',
|
|
buttonicon : o.saveicon,
|
|
id : $t.p.id+"_ilsave",
|
|
onClickButton : function () {
|
|
var sr = $t.p.savedRow[0].id;
|
|
if(sr) {
|
|
var opers = $t.p.prmNames,
|
|
oper = opers.oper, tmpParams = {};
|
|
if($("#"+$.jgrid.jqID(sr), "#"+gID ).hasClass("jqgrid-new-row")) {
|
|
o.addParams.addRowParams.extraparam[oper] = opers.addoper;
|
|
tmpParams = o.addParams.addRowParams;
|
|
} else {
|
|
if(!o.editParams.extraparam) {
|
|
o.editParams.extraparam = {};
|
|
}
|
|
o.editParams.extraparam[oper] = opers.editoper;
|
|
tmpParams = o.editParams;
|
|
}
|
|
if( $($t).jqGrid('saveRow', sr, tmpParams) ) {
|
|
$($t).jqGrid('showAddEditButtons');
|
|
}
|
|
} else {
|
|
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();
|
|
}
|
|
}
|
|
});
|
|
$("#"+gID+"_ilsave").addClass('ui-state-disabled');
|
|
}
|
|
if(o.cancel) {
|
|
$($t).jqGrid('navButtonAdd', elem,{
|
|
caption : o.canceltext || '',
|
|
title : o.canceltitle || 'Cancel row editing',
|
|
buttonicon : o.cancelicon,
|
|
id : $t.p.id+"_ilcancel",
|
|
onClickButton : function () {
|
|
var sr = $t.p.savedRow[0].id, cancelPrm = {};
|
|
if(sr) {
|
|
if($("#"+$.jgrid.jqID(sr), "#"+gID ).hasClass("jqgrid-new-row")) {
|
|
cancelPrm = o.addParams.addRowParams;
|
|
} else {
|
|
cancelPrm = o.editParams;
|
|
}
|
|
$($t).jqGrid('restoreRow', sr, cancelPrm);
|
|
$($t).jqGrid('showAddEditButtons');
|
|
} else {
|
|
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();
|
|
}
|
|
}
|
|
});
|
|
$("#"+gID+"_ilcancel").addClass('ui-state-disabled');
|
|
}
|
|
if(o.restoreAfterSelect === true) {
|
|
if($.isFunction($t.p.beforeSelectRow)) {
|
|
onSelect = $t.p.beforeSelectRow;
|
|
} else {
|
|
onSelect = false;
|
|
}
|
|
$t.p.beforeSelectRow = function(id, stat) {
|
|
var ret = true;
|
|
if($t.p.savedRow.length > 0 && $t.p._inlinenav===true && ( id !== $t.p.selrow && $t.p.selrow !==null) ) {
|
|
if($t.p.selrow === o.addParams.rowID ) {
|
|
$($t).jqGrid('delRowData', $t.p.selrow);
|
|
} else {
|
|
$($t).jqGrid('restoreRow', $t.p.selrow, o.editParams);
|
|
}
|
|
$($t).jqGrid('showAddEditButtons');
|
|
}
|
|
if(onSelect) {
|
|
ret = onSelect.call($t, id, stat);
|
|
}
|
|
return ret;
|
|
};
|
|
}
|
|
|
|
});
|
|
},
|
|
showAddEditButtons : function() {
|
|
return this.each(function(){
|
|
if (!this.grid ) { return; }
|
|
var gID = $.jgrid.jqID(this.p.id);
|
|
$("#"+gID+"_ilsave").addClass('ui-state-disabled');
|
|
$("#"+gID+"_ilcancel").addClass('ui-state-disabled');
|
|
$("#"+gID+"_iladd").removeClass('ui-state-disabled');
|
|
$("#"+gID+"_iledit").removeClass('ui-state-disabled');
|
|
});
|
|
}
|
|
//end inline edit
|
|
});
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false */
|
|
/*global jQuery */
|
|
(function($){
|
|
/*
|
|
**
|
|
* jqGrid extension for cellediting Grid Data
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
**/
|
|
/**
|
|
* all events and options here are aded anonynous and not in the base grid
|
|
* since the array is to big. Here is the order of execution.
|
|
* From this point we use jQuery isFunction
|
|
* formatCell
|
|
* beforeEditCell,
|
|
* onSelectCell (used only for noneditable cels)
|
|
* afterEditCell,
|
|
* beforeSaveCell, (called before validation of values if any)
|
|
* beforeSubmitCell (if cellsubmit remote (ajax))
|
|
* afterSubmitCell(if cellsubmit remote (ajax)),
|
|
* afterSaveCell,
|
|
* errorCell,
|
|
* serializeCellData - new
|
|
* Options
|
|
* cellsubmit (remote,clientArray) (added in grid options)
|
|
* cellurl
|
|
* ajaxCellOptions
|
|
* */
|
|
"use strict";
|
|
$.jgrid.extend({
|
|
editCell : function (iRow,iCol, ed){
|
|
return this.each(function (){
|
|
var $t = this, nm, tmp,cc, cm;
|
|
if (!$t.grid || $t.p.cellEdit !== true) {return;}
|
|
iCol = parseInt(iCol,10);
|
|
// select the row that can be used for other methods
|
|
$t.p.selrow = $t.rows[iRow].id;
|
|
if (!$t.p.knv) {$($t).jqGrid("GridNav");}
|
|
// check to see if we have already edited cell
|
|
if ($t.p.savedRow.length>0) {
|
|
// prevent second click on that field and enable selects
|
|
if (ed===true ) {
|
|
if(iRow == $t.p.iRow && iCol == $t.p.iCol){
|
|
return;
|
|
}
|
|
}
|
|
// save the cell
|
|
$($t).jqGrid("saveCell",$t.p.savedRow[0].id,$t.p.savedRow[0].ic);
|
|
} else {
|
|
window.setTimeout(function () { $("#"+$.jgrid.jqID($t.p.knv)).attr("tabindex","-1").focus();},0);
|
|
}
|
|
cm = $t.p.colModel[iCol];
|
|
nm = cm.name;
|
|
if (nm==='subgrid' || nm==='cb' || nm==='rn') {return;}
|
|
cc = $("td:eq("+iCol+")",$t.rows[iRow]);
|
|
if (cm.editable===true && ed===true && !cc.hasClass("not-editable-cell")) {
|
|
if(parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) {
|
|
$("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell ui-state-highlight");
|
|
$($t.rows[$t.p.iRow]).removeClass("selected-row ui-state-hover");
|
|
}
|
|
$(cc).addClass("edit-cell ui-state-highlight");
|
|
$($t.rows[iRow]).addClass("selected-row ui-state-hover");
|
|
try {
|
|
tmp = $.unformat.call($t,cc,{rowId: $t.rows[iRow].id, colModel:cm},iCol);
|
|
} catch (_) {
|
|
tmp = ( cm.edittype && cm.edittype === 'textarea' ) ? $(cc).text() : $(cc).html();
|
|
}
|
|
if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
|
|
if (!cm.edittype) {cm.edittype = "text";}
|
|
$t.p.savedRow.push({id:iRow,ic:iCol,name:nm,v:tmp});
|
|
if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';}
|
|
if($.isFunction($t.p.formatCell)) {
|
|
var tmp2 = $t.p.formatCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
|
|
if(tmp2 !== undefined ) {tmp = tmp2;}
|
|
}
|
|
$($t).triggerHandler("jqGridBeforeEditCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]);
|
|
if ($.isFunction($t.p.beforeEditCell)) {
|
|
$t.p.beforeEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
|
|
}
|
|
var opt = $.extend({}, cm.editoptions || {} ,{id:iRow+"_"+nm,name:nm});
|
|
var elc = $.jgrid.createEl.call($t,cm.edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {}));
|
|
$(cc).html("").append(elc).attr("tabindex","0");
|
|
$.jgrid.bindEv.call($t, elc, opt);
|
|
window.setTimeout(function () { $(elc).focus();},0);
|
|
$("input, select, textarea",cc).bind("keydown",function(e) {
|
|
if (e.keyCode === 27) {
|
|
if($("input.hasDatepicker",cc).length >0) {
|
|
if( $(".ui-datepicker").is(":hidden") ) { $($t).jqGrid("restoreCell",iRow,iCol); }
|
|
else { $("input.hasDatepicker",cc).datepicker('hide'); }
|
|
} else {
|
|
$($t).jqGrid("restoreCell",iRow,iCol);
|
|
}
|
|
} //ESC
|
|
if (e.keyCode === 13) {
|
|
$($t).jqGrid("saveCell",iRow,iCol);
|
|
// Prevent default action
|
|
return false;
|
|
} //Enter
|
|
if (e.keyCode === 9) {
|
|
if(!$t.grid.hDiv.loading ) {
|
|
if (e.shiftKey) {$($t).jqGrid("prevCell",iRow,iCol);} //Shift TAb
|
|
else {$($t).jqGrid("nextCell",iRow,iCol);} //Tab
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
e.stopPropagation();
|
|
});
|
|
$($t).triggerHandler("jqGridAfterEditCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]);
|
|
if ($.isFunction($t.p.afterEditCell)) {
|
|
$t.p.afterEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
|
|
}
|
|
} else {
|
|
if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) {
|
|
$("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell ui-state-highlight");
|
|
$($t.rows[$t.p.iRow]).removeClass("selected-row ui-state-hover");
|
|
}
|
|
cc.addClass("edit-cell ui-state-highlight");
|
|
$($t.rows[iRow]).addClass("selected-row ui-state-hover");
|
|
tmp = cc.html().replace(/\ \;/ig,'');
|
|
$($t).triggerHandler("jqGridSelectCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]);
|
|
if ($.isFunction($t.p.onSelectCell)) {
|
|
$t.p.onSelectCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
|
|
}
|
|
}
|
|
$t.p.iCol = iCol; $t.p.iRow = iRow;
|
|
});
|
|
},
|
|
saveCell : function (iRow, iCol){
|
|
return this.each(function(){
|
|
var $t= this, fr;
|
|
if (!$t.grid || $t.p.cellEdit !== true) {return;}
|
|
if ( $t.p.savedRow.length >= 1) {fr = 0;} else {fr=null;}
|
|
if(fr !== null) {
|
|
var cc = $("td:eq("+iCol+")",$t.rows[iRow]),v,v2,
|
|
cm = $t.p.colModel[iCol], nm = cm.name, nmjq = $.jgrid.jqID(nm) ;
|
|
switch (cm.edittype) {
|
|
case "select":
|
|
if(!cm.editoptions.multiple) {
|
|
v = $("#"+iRow+"_"+nmjq+" option:selected",$t.rows[iRow]).val();
|
|
v2 = $("#"+iRow+"_"+nmjq+" option:selected",$t.rows[iRow]).text();
|
|
} else {
|
|
var sel = $("#"+iRow+"_"+nmjq,$t.rows[iRow]), selectedText = [];
|
|
v = $(sel).val();
|
|
if(v) { v.join(",");} else { v=""; }
|
|
$("option:selected",sel).each(
|
|
function(i,selected){
|
|
selectedText[i] = $(selected).text();
|
|
}
|
|
);
|
|
v2 = selectedText.join(",");
|
|
}
|
|
if(cm.formatter) { v2 = v; }
|
|
break;
|
|
case "checkbox":
|
|
var cbv = ["Yes","No"];
|
|
if(cm.editoptions){
|
|
cbv = cm.editoptions.value.split(":");
|
|
}
|
|
v = $("#"+iRow+"_"+nmjq,$t.rows[iRow]).is(":checked") ? cbv[0] : cbv[1];
|
|
v2=v;
|
|
break;
|
|
case "password":
|
|
case "text":
|
|
case "textarea":
|
|
case "button" :
|
|
v = $("#"+iRow+"_"+nmjq,$t.rows[iRow]).val();
|
|
v2=v;
|
|
break;
|
|
case 'custom' :
|
|
try {
|
|
if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) {
|
|
v = cm.editoptions.custom_value.call($t, $(".customelement",cc),'get');
|
|
if (v===undefined) { throw "e2";} else { v2=v; }
|
|
} else { throw "e1"; }
|
|
} catch (e) {
|
|
if (e==="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose); }
|
|
if (e==="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose); }
|
|
else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose); }
|
|
}
|
|
break;
|
|
}
|
|
// The common approach is if nothing changed do not do anything
|
|
if (v2 !== $t.p.savedRow[fr].v){
|
|
var vvv = $($t).triggerHandler("jqGridBeforeSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]);
|
|
if (vvv) {v = vvv; v2=vvv;}
|
|
if ($.isFunction($t.p.beforeSaveCell)) {
|
|
var vv = $t.p.beforeSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
|
|
if (vv) {v = vv; v2=vv;}
|
|
}
|
|
var cv = $.jgrid.checkValues.call($t,v,iCol);
|
|
if(cv[0] === true) {
|
|
var addpost = $($t).triggerHandler("jqGridBeforeSubmitCell", [$t.rows[iRow].id, nm, v, iRow, iCol]) || {};
|
|
if ($.isFunction($t.p.beforeSubmitCell)) {
|
|
addpost = $t.p.beforeSubmitCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
|
|
if (!addpost) {addpost={};}
|
|
}
|
|
if( $("input.hasDatepicker",cc).length >0) { $("input.hasDatepicker",cc).datepicker('hide'); }
|
|
if ($t.p.cellsubmit === 'remote') {
|
|
if ($t.p.cellurl) {
|
|
var postdata = {};
|
|
if($t.p.autoencode) { v = $.jgrid.htmlEncode(v); }
|
|
postdata[nm] = v;
|
|
var idname,oper, opers;
|
|
opers = $t.p.prmNames;
|
|
idname = opers.id;
|
|
oper = opers.oper;
|
|
postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, $t.rows[iRow].id);
|
|
postdata[oper] = opers.editoper;
|
|
postdata = $.extend(addpost,postdata);
|
|
$("#lui_"+$.jgrid.jqID($t.p.id)).show();
|
|
$t.grid.hDiv.loading = true;
|
|
$.ajax( $.extend( {
|
|
url: $t.p.cellurl,
|
|
data :$.isFunction($t.p.serializeCellData) ? $t.p.serializeCellData.call($t, postdata) : postdata,
|
|
type: "POST",
|
|
complete: function (result, stat) {
|
|
$("#lui_"+$t.p.id).hide();
|
|
$t.grid.hDiv.loading = false;
|
|
if (stat === 'success') {
|
|
var ret = $($t).triggerHandler("jqGridAfterSubmitCell", [$t, result, postdata.id, nm, v, iRow, iCol]) || [true, ''];
|
|
if (ret[0] === true && $.isFunction($t.p.afterSubmitCell)) {
|
|
ret = $t.p.afterSubmitCell.call($t, result,postdata.id,nm,v,iRow,iCol);
|
|
}
|
|
if(ret[0] === true){
|
|
$(cc).empty();
|
|
$($t).jqGrid("setCell",$t.rows[iRow].id, iCol, v2, false, false, true);
|
|
$(cc).addClass("dirty-cell");
|
|
$($t.rows[iRow]).addClass("edited");
|
|
$($t).triggerHandler("jqGridAfterSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]);
|
|
if ($.isFunction($t.p.afterSaveCell)) {
|
|
$t.p.afterSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
|
|
}
|
|
$t.p.savedRow.splice(0,1);
|
|
} else {
|
|
$.jgrid.info_dialog($.jgrid.errors.errcap,ret[1],$.jgrid.edit.bClose);
|
|
$($t).jqGrid("restoreCell",iRow,iCol);
|
|
}
|
|
}
|
|
},
|
|
error:function(res,stat,err) {
|
|
$("#lui_"+$.jgrid.jqID($t.p.id)).hide();
|
|
$t.grid.hDiv.loading = false;
|
|
$($t).triggerHandler("jqGridErrorCell", [res, stat, err]);
|
|
if ($.isFunction($t.p.errorCell)) {
|
|
$t.p.errorCell.call($t, res,stat,err);
|
|
$($t).jqGrid("restoreCell",iRow,iCol);
|
|
} else {
|
|
$.jgrid.info_dialog($.jgrid.errors.errcap,res.status+" : "+res.statusText+"<br/>"+stat,$.jgrid.edit.bClose);
|
|
$($t).jqGrid("restoreCell",iRow,iCol);
|
|
}
|
|
}
|
|
}, $.jgrid.ajaxOptions, $t.p.ajaxCellOptions || {}));
|
|
} else {
|
|
try {
|
|
$.jgrid.info_dialog($.jgrid.errors.errcap,$.jgrid.errors.nourl,$.jgrid.edit.bClose);
|
|
$($t).jqGrid("restoreCell",iRow,iCol);
|
|
} catch (e) {}
|
|
}
|
|
}
|
|
if ($t.p.cellsubmit === 'clientArray') {
|
|
$(cc).empty();
|
|
$($t).jqGrid("setCell",$t.rows[iRow].id,iCol, v2, false, false, true);
|
|
$(cc).addClass("dirty-cell");
|
|
$($t.rows[iRow]).addClass("edited");
|
|
$($t).triggerHandler("jqGridAfterSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]);
|
|
if ($.isFunction($t.p.afterSaveCell)) {
|
|
$t.p.afterSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
|
|
}
|
|
$t.p.savedRow.splice(0,1);
|
|
}
|
|
} else {
|
|
try {
|
|
window.setTimeout(function(){$.jgrid.info_dialog($.jgrid.errors.errcap,v+" "+cv[1],$.jgrid.edit.bClose);},100);
|
|
$($t).jqGrid("restoreCell",iRow,iCol);
|
|
} catch (e) {}
|
|
}
|
|
} else {
|
|
$($t).jqGrid("restoreCell",iRow,iCol);
|
|
}
|
|
}
|
|
window.setTimeout(function () { $("#"+$.jgrid.jqID($t.p.knv)).attr("tabindex","-1").focus();},0);
|
|
});
|
|
},
|
|
restoreCell : function(iRow, iCol) {
|
|
return this.each(function(){
|
|
var $t= this, fr;
|
|
if (!$t.grid || $t.p.cellEdit !== true ) {return;}
|
|
if ( $t.p.savedRow.length >= 1) {fr = 0;} else {fr=null;}
|
|
if(fr !== null) {
|
|
var cc = $("td:eq("+iCol+")",$t.rows[iRow]);
|
|
// datepicker fix
|
|
if($.isFunction($.fn.datepicker)) {
|
|
try {
|
|
$("input.hasDatepicker",cc).datepicker('hide');
|
|
} catch (e) {}
|
|
}
|
|
$(cc).empty().attr("tabindex","-1");
|
|
$($t).jqGrid("setCell",$t.rows[iRow].id, iCol, $t.p.savedRow[fr].v, false, false, true);
|
|
$($t).triggerHandler("jqGridAfterRestoreCell", [$t.rows[iRow].id, $t.p.savedRow[fr].v, iRow, iCol]);
|
|
if ($.isFunction($t.p.afterRestoreCell)) {
|
|
$t.p.afterRestoreCell.call($t, $t.rows[iRow].id, $t.p.savedRow[fr].v, iRow, iCol);
|
|
}
|
|
$t.p.savedRow.splice(0,1);
|
|
}
|
|
window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0);
|
|
});
|
|
},
|
|
nextCell : function (iRow,iCol) {
|
|
return this.each(function (){
|
|
var $t = this, nCol=false, i;
|
|
if (!$t.grid || $t.p.cellEdit !== true) {return;}
|
|
// try to find next editable cell
|
|
for (i=iCol+1; i<$t.p.colModel.length; i++) {
|
|
if ( $t.p.colModel[i].editable ===true) {
|
|
nCol = i; break;
|
|
}
|
|
}
|
|
if(nCol !== false) {
|
|
$($t).jqGrid("editCell",iRow,nCol,true);
|
|
} else {
|
|
if ($t.p.savedRow.length >0) {
|
|
$($t).jqGrid("saveCell",iRow,iCol);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
prevCell : function (iRow,iCol) {
|
|
return this.each(function (){
|
|
var $t = this, nCol=false, i;
|
|
if (!$t.grid || $t.p.cellEdit !== true) {return;}
|
|
// try to find next editable cell
|
|
for (i=iCol-1; i>=0; i--) {
|
|
if ( $t.p.colModel[i].editable ===true) {
|
|
nCol = i; break;
|
|
}
|
|
}
|
|
if(nCol !== false) {
|
|
$($t).jqGrid("editCell",iRow,nCol,true);
|
|
} else {
|
|
if ($t.p.savedRow.length >0) {
|
|
$($t).jqGrid("saveCell",iRow,iCol);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
GridNav : function() {
|
|
return this.each(function () {
|
|
var $t = this;
|
|
if (!$t.grid || $t.p.cellEdit !== true ) {return;}
|
|
// trick to process keydown on non input elements
|
|
$t.p.knv = $t.p.id + "_kn";
|
|
var selection = $("<div style='position:fixed;top:0px;width:1px;height:1px;' tabindex='0'><div tabindex='-1' style='width:1px;height:1px;' id='"+$t.p.knv+"'></div></div>"),
|
|
i, kdir;
|
|
function scrollGrid(iR, iC, tp){
|
|
if (tp.substr(0,1)==='v') {
|
|
var ch = $($t.grid.bDiv)[0].clientHeight,
|
|
st = $($t.grid.bDiv)[0].scrollTop,
|
|
nROT = $t.rows[iR].offsetTop+$t.rows[iR].clientHeight,
|
|
pROT = $t.rows[iR].offsetTop;
|
|
if(tp === 'vd') {
|
|
if(nROT >= ch) {
|
|
$($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop + $t.rows[iR].clientHeight;
|
|
}
|
|
}
|
|
if(tp === 'vu'){
|
|
if (pROT < st ) {
|
|
$($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop - $t.rows[iR].clientHeight;
|
|
}
|
|
}
|
|
}
|
|
if(tp==='h') {
|
|
var cw = $($t.grid.bDiv)[0].clientWidth,
|
|
sl = $($t.grid.bDiv)[0].scrollLeft,
|
|
nCOL = $t.rows[iR].cells[iC].offsetLeft+$t.rows[iR].cells[iC].clientWidth,
|
|
pCOL = $t.rows[iR].cells[iC].offsetLeft;
|
|
if(nCOL >= cw+parseInt(sl,10)) {
|
|
$($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft + $t.rows[iR].cells[iC].clientWidth;
|
|
} else if (pCOL < sl) {
|
|
$($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft - $t.rows[iR].cells[iC].clientWidth;
|
|
}
|
|
}
|
|
}
|
|
function findNextVisible(iC,act){
|
|
var ind, i;
|
|
if(act === 'lft') {
|
|
ind = iC+1;
|
|
for (i=iC;i>=0;i--){
|
|
if ($t.p.colModel[i].hidden !== true) {
|
|
ind = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if(act === 'rgt') {
|
|
ind = iC-1;
|
|
for (i=iC; i<$t.p.colModel.length;i++){
|
|
if ($t.p.colModel[i].hidden !== true) {
|
|
ind = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return ind;
|
|
}
|
|
|
|
$(selection).insertBefore($t.grid.cDiv);
|
|
$("#"+$t.p.knv)
|
|
.focus()
|
|
.keydown(function (e){
|
|
kdir = e.keyCode;
|
|
if($t.p.direction === "rtl") {
|
|
if(kdir===37) { kdir = 39;}
|
|
else if (kdir===39) { kdir = 37; }
|
|
}
|
|
switch (kdir) {
|
|
case 38:
|
|
if ($t.p.iRow-1 >0 ) {
|
|
scrollGrid($t.p.iRow-1,$t.p.iCol,'vu');
|
|
$($t).jqGrid("editCell",$t.p.iRow-1,$t.p.iCol,false);
|
|
}
|
|
break;
|
|
case 40 :
|
|
if ($t.p.iRow+1 <= $t.rows.length-1) {
|
|
scrollGrid($t.p.iRow+1,$t.p.iCol,'vd');
|
|
$($t).jqGrid("editCell",$t.p.iRow+1,$t.p.iCol,false);
|
|
}
|
|
break;
|
|
case 37 :
|
|
if ($t.p.iCol -1 >= 0) {
|
|
i = findNextVisible($t.p.iCol-1,'lft');
|
|
scrollGrid($t.p.iRow, i,'h');
|
|
$($t).jqGrid("editCell",$t.p.iRow, i,false);
|
|
}
|
|
break;
|
|
case 39 :
|
|
if ($t.p.iCol +1 <= $t.p.colModel.length-1) {
|
|
i = findNextVisible($t.p.iCol+1,'rgt');
|
|
scrollGrid($t.p.iRow,i,'h');
|
|
$($t).jqGrid("editCell",$t.p.iRow,i,false);
|
|
}
|
|
break;
|
|
case 13:
|
|
if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) {
|
|
$($t).jqGrid("editCell",$t.p.iRow,$t.p.iCol,true);
|
|
}
|
|
break;
|
|
default :
|
|
return true;
|
|
}
|
|
return false;
|
|
});
|
|
});
|
|
},
|
|
getChangedCells : function (mthd) {
|
|
var ret=[];
|
|
if (!mthd) {mthd='all';}
|
|
this.each(function(){
|
|
var $t= this,nm;
|
|
if (!$t.grid || $t.p.cellEdit !== true ) {return;}
|
|
$($t.rows).each(function(j){
|
|
var res = {};
|
|
if ($(this).hasClass("edited")) {
|
|
$('td',this).each( function(i) {
|
|
nm = $t.p.colModel[i].name;
|
|
if ( nm !== 'cb' && nm !== 'subgrid') {
|
|
if (mthd==='dirty') {
|
|
if ($(this).hasClass('dirty-cell')) {
|
|
try {
|
|
res[nm] = $.unformat.call($t,this,{rowId:$t.rows[j].id, colModel:$t.p.colModel[i]},i);
|
|
} catch (e){
|
|
res[nm] = $.jgrid.htmlDecode($(this).html());
|
|
}
|
|
}
|
|
} else {
|
|
try {
|
|
res[nm] = $.unformat.call($t,this,{rowId:$t.rows[j].id,colModel:$t.p.colModel[i]},i);
|
|
} catch (e) {
|
|
res[nm] = $.jgrid.htmlDecode($(this).html());
|
|
}
|
|
}
|
|
}
|
|
});
|
|
res.id = this.id;
|
|
ret.push(res);
|
|
}
|
|
});
|
|
});
|
|
return ret;
|
|
}
|
|
/// end cell editing
|
|
});
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false */
|
|
/*global jQuery */
|
|
(function($){
|
|
/**
|
|
* jqGrid extension for SubGrid Data
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
**/
|
|
"use strict";
|
|
$.jgrid.extend({
|
|
setSubGrid : function () {
|
|
return this.each(function (){
|
|
var $t = this, cm, i,
|
|
suboptions = {
|
|
plusicon : "ui-icon-plus",
|
|
minusicon : "ui-icon-minus",
|
|
openicon: "ui-icon-carat-1-sw",
|
|
expandOnLoad: false,
|
|
delayOnLoad : 50,
|
|
selectOnExpand : false,
|
|
selectOnCollapse : false,
|
|
reloadOnExpand : true
|
|
};
|
|
$t.p.subGridOptions = $.extend(suboptions, $t.p.subGridOptions || {});
|
|
$t.p.colNames.unshift("");
|
|
$t.p.colModel.unshift({name:'subgrid',width: $.jgrid.cell_width ? $t.p.subGridWidth+$t.p.cellLayout : $t.p.subGridWidth,sortable: false,resizable:false,hidedlg:true,search:false,fixed:true});
|
|
cm = $t.p.subGridModel;
|
|
if(cm[0]) {
|
|
cm[0].align = $.extend([],cm[0].align || []);
|
|
for(i=0;i<cm[0].name.length;i++) { cm[0].align[i] = cm[0].align[i] || 'left';}
|
|
}
|
|
});
|
|
},
|
|
addSubGridCell :function (pos,iRow) {
|
|
var prp='',ic,sid;
|
|
this.each(function(){
|
|
prp = this.formatCol(pos,iRow);
|
|
sid= this.p.id;
|
|
ic = this.p.subGridOptions.plusicon;
|
|
});
|
|
return "<td role=\"gridcell\" aria-describedby=\""+sid+"_subgrid\" class=\"ui-sgcollapsed sgcollapsed\" "+prp+"><a style='cursor:pointer;'><span class='ui-icon "+ic+"'></span></a></td>";
|
|
},
|
|
addSubGrid : function( pos, sind ) {
|
|
return this.each(function(){
|
|
var ts = this;
|
|
if (!ts.grid ) { return; }
|
|
//-------------------------
|
|
var subGridCell = function(trdiv,cell,pos)
|
|
{
|
|
var tddiv = $("<td align='"+ts.p.subGridModel[0].align[pos]+"'></td>").html(cell);
|
|
$(trdiv).append(tddiv);
|
|
};
|
|
var subGridXml = function(sjxml, sbid){
|
|
var tddiv, i, sgmap,
|
|
dummy = $("<table cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>"),
|
|
trdiv = $("<tr></tr>");
|
|
for (i = 0; i<ts.p.subGridModel[0].name.length; i++) {
|
|
tddiv = $("<th class='ui-state-default ui-th-subgrid ui-th-column ui-th-"+ts.p.direction+"'></th>");
|
|
$(tddiv).html(ts.p.subGridModel[0].name[i]);
|
|
$(tddiv).width( ts.p.subGridModel[0].width[i]);
|
|
$(trdiv).append(tddiv);
|
|
}
|
|
$(dummy).append(trdiv);
|
|
if (sjxml){
|
|
sgmap = ts.p.xmlReader.subgrid;
|
|
$(sgmap.root+" "+sgmap.row, sjxml).each( function(){
|
|
trdiv = $("<tr class='ui-widget-content ui-subtblcell'></tr>");
|
|
if(sgmap.repeatitems === true) {
|
|
$(sgmap.cell,this).each( function(i) {
|
|
subGridCell(trdiv, $(this).text() || ' ',i);
|
|
});
|
|
} else {
|
|
var f = ts.p.subGridModel[0].mapping || ts.p.subGridModel[0].name;
|
|
if (f) {
|
|
for (i=0;i<f.length;i++) {
|
|
subGridCell(trdiv, $(f[i],this).text() || ' ',i);
|
|
}
|
|
}
|
|
}
|
|
$(dummy).append(trdiv);
|
|
});
|
|
}
|
|
var pID = $("table:first",ts.grid.bDiv).attr("id")+"_";
|
|
$("#"+$.jgrid.jqID(pID+sbid)).append(dummy);
|
|
ts.grid.hDiv.loading = false;
|
|
$("#load_"+$.jgrid.jqID(ts.p.id)).hide();
|
|
return false;
|
|
};
|
|
var subGridJson = function(sjxml, sbid){
|
|
var tddiv,result,i,cur, sgmap,j,
|
|
dummy = $("<table cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>"),
|
|
trdiv = $("<tr></tr>");
|
|
for (i = 0; i<ts.p.subGridModel[0].name.length; i++) {
|
|
tddiv = $("<th class='ui-state-default ui-th-subgrid ui-th-column ui-th-"+ts.p.direction+"'></th>");
|
|
$(tddiv).html(ts.p.subGridModel[0].name[i]);
|
|
$(tddiv).width( ts.p.subGridModel[0].width[i]);
|
|
$(trdiv).append(tddiv);
|
|
}
|
|
$(dummy).append(trdiv);
|
|
if (sjxml){
|
|
sgmap = ts.p.jsonReader.subgrid;
|
|
result = $.jgrid.getAccessor(sjxml, sgmap.root);
|
|
if ( result !== undefined ) {
|
|
for (i=0;i<result.length;i++) {
|
|
cur = result[i];
|
|
trdiv = $("<tr class='ui-widget-content ui-subtblcell'></tr>");
|
|
if(sgmap.repeatitems === true) {
|
|
if(sgmap.cell) { cur=cur[sgmap.cell]; }
|
|
for (j=0;j<cur.length;j++) {
|
|
subGridCell(trdiv, cur[j] || ' ',j);
|
|
}
|
|
} else {
|
|
var f = ts.p.subGridModel[0].mapping || ts.p.subGridModel[0].name;
|
|
if(f.length) {
|
|
for (j=0;j<f.length;j++) {
|
|
subGridCell(trdiv, cur[f[j]] || ' ',j);
|
|
}
|
|
}
|
|
}
|
|
$(dummy).append(trdiv);
|
|
}
|
|
}
|
|
}
|
|
var pID = $("table:first",ts.grid.bDiv).attr("id")+"_";
|
|
$("#"+$.jgrid.jqID(pID+sbid)).append(dummy);
|
|
ts.grid.hDiv.loading = false;
|
|
$("#load_"+$.jgrid.jqID(ts.p.id)).hide();
|
|
return false;
|
|
};
|
|
var populatesubgrid = function( rd )
|
|
{
|
|
var sid,dp, i, j;
|
|
sid = $(rd).attr("id");
|
|
dp = {nd_: (new Date().getTime())};
|
|
dp[ts.p.prmNames.subgridid]=sid;
|
|
if(!ts.p.subGridModel[0]) { return false; }
|
|
if(ts.p.subGridModel[0].params) {
|
|
for(j=0; j < ts.p.subGridModel[0].params.length; j++) {
|
|
for(i=0; i<ts.p.colModel.length; i++) {
|
|
if(ts.p.colModel[i].name === ts.p.subGridModel[0].params[j]) {
|
|
dp[ts.p.colModel[i].name]= $("td:eq("+i+")",rd).text().replace(/\ \;/ig,'');
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(!ts.grid.hDiv.loading) {
|
|
ts.grid.hDiv.loading = true;
|
|
$("#load_"+$.jgrid.jqID(ts.p.id)).show();
|
|
if(!ts.p.subgridtype) { ts.p.subgridtype = ts.p.datatype; }
|
|
if($.isFunction(ts.p.subgridtype)) {
|
|
ts.p.subgridtype.call(ts, dp);
|
|
} else {
|
|
ts.p.subgridtype = ts.p.subgridtype.toLowerCase();
|
|
}
|
|
switch(ts.p.subgridtype) {
|
|
case "xml":
|
|
case "json":
|
|
$.ajax($.extend({
|
|
type:ts.p.mtype,
|
|
url: ts.p.subGridUrl,
|
|
dataType:ts.p.subgridtype,
|
|
data: $.isFunction(ts.p.serializeSubGridData)? ts.p.serializeSubGridData.call(ts, dp) : dp,
|
|
complete: function(sxml) {
|
|
if(ts.p.subgridtype === "xml") {
|
|
subGridXml(sxml.responseXML, sid);
|
|
} else {
|
|
subGridJson($.jgrid.parse(sxml.responseText),sid);
|
|
}
|
|
sxml=null;
|
|
}
|
|
}, $.jgrid.ajaxOptions, ts.p.ajaxSubgridOptions || {}));
|
|
break;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
var _id, pID,atd, nhc=0, bfsc, r;
|
|
$.each(ts.p.colModel,function(){
|
|
if(this.hidden === true || this.name === 'rn' || this.name === 'cb') {
|
|
nhc++;
|
|
}
|
|
});
|
|
var len = ts.rows.length, i=1;
|
|
if( sind !== undefined && sind > 0) {
|
|
i = sind;
|
|
len = sind+1;
|
|
}
|
|
while(i < len) {
|
|
if($(ts.rows[i]).hasClass('jqgrow')) {
|
|
$(ts.rows[i].cells[pos]).bind('click', function() {
|
|
var tr = $(this).parent("tr")[0];
|
|
r = tr.nextSibling;
|
|
if($(this).hasClass("sgcollapsed")) {
|
|
pID = ts.p.id;
|
|
_id = tr.id;
|
|
if(ts.p.subGridOptions.reloadOnExpand === true || ( ts.p.subGridOptions.reloadOnExpand === false && !$(r).hasClass('ui-subgrid') ) ) {
|
|
atd = pos >=1 ? "<td colspan='"+pos+"'> </td>":"";
|
|
bfsc = $(ts).triggerHandler("jqGridSubGridBeforeExpand", [pID + "_" + _id, _id]);
|
|
bfsc = (bfsc === false || bfsc === 'stop') ? false : true;
|
|
if(bfsc && $.isFunction(ts.p.subGridBeforeExpand)) {
|
|
bfsc = ts.p.subGridBeforeExpand.call(ts, pID+"_"+_id,_id);
|
|
}
|
|
if(bfsc === false) {return false;}
|
|
$(tr).after( "<tr role='row' class='ui-subgrid'>"+atd+"<td class='ui-widget-content subgrid-cell'><span class='ui-icon "+ts.p.subGridOptions.openicon+"'></span></td><td colspan='"+parseInt(ts.p.colNames.length-1-nhc,10)+"' class='ui-widget-content subgrid-data'><div id="+pID+"_"+_id+" class='tablediv'></div></td></tr>" );
|
|
$(ts).triggerHandler("jqGridSubGridRowExpanded", [pID + "_" + _id, _id]);
|
|
if( $.isFunction(ts.p.subGridRowExpanded)) {
|
|
ts.p.subGridRowExpanded.call(ts, pID+"_"+ _id,_id);
|
|
} else {
|
|
populatesubgrid(tr);
|
|
}
|
|
} else {
|
|
$(r).show();
|
|
}
|
|
$(this).html("<a style='cursor:pointer;'><span class='ui-icon "+ts.p.subGridOptions.minusicon+"'></span></a>").removeClass("sgcollapsed").addClass("sgexpanded");
|
|
if(ts.p.subGridOptions.selectOnExpand) {
|
|
$(ts).jqGrid('setSelection',_id);
|
|
}
|
|
} else if($(this).hasClass("sgexpanded")) {
|
|
bfsc = $(ts).triggerHandler("jqGridSubGridRowColapsed", [pID + "_" + _id, _id]);
|
|
bfsc = (bfsc === false || bfsc === 'stop') ? false : true;
|
|
_id = tr.id;
|
|
if( bfsc && $.isFunction(ts.p.subGridRowColapsed)) {
|
|
bfsc = ts.p.subGridRowColapsed.call(ts, pID+"_"+_id,_id );
|
|
}
|
|
if(bfsc===false) {return false;}
|
|
if(ts.p.subGridOptions.reloadOnExpand === true) {
|
|
$(r).remove(".ui-subgrid");
|
|
} else if($(r).hasClass('ui-subgrid')) { // incase of dynamic deleting
|
|
$(r).hide();
|
|
}
|
|
$(this).html("<a style='cursor:pointer;'><span class='ui-icon "+ts.p.subGridOptions.plusicon+"'></span></a>").removeClass("sgexpanded").addClass("sgcollapsed");
|
|
if(ts.p.subGridOptions.selectOnCollapse) {
|
|
$(ts).jqGrid('setSelection',_id);
|
|
}
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
i++;
|
|
}
|
|
if(ts.p.subGridOptions.expandOnLoad === true) {
|
|
$(ts.rows).filter('.jqgrow').each(function(index,row){
|
|
$(row.cells[0]).click();
|
|
});
|
|
}
|
|
ts.subGridXml = function(xml,sid) {subGridXml(xml,sid);};
|
|
ts.subGridJson = function(json,sid) {subGridJson(json,sid);};
|
|
});
|
|
},
|
|
expandSubGridRow : function(rowid) {
|
|
return this.each(function () {
|
|
var $t = this;
|
|
if(!$t.grid && !rowid) {return;}
|
|
if($t.p.subGrid===true) {
|
|
var rc = $(this).jqGrid("getInd",rowid,true);
|
|
if(rc) {
|
|
var sgc = $("td.sgcollapsed",rc)[0];
|
|
if(sgc) {
|
|
$(sgc).trigger("click");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
collapseSubGridRow : function(rowid) {
|
|
return this.each(function () {
|
|
var $t = this;
|
|
if(!$t.grid && !rowid) {return;}
|
|
if($t.p.subGrid===true) {
|
|
var rc = $(this).jqGrid("getInd",rowid,true);
|
|
if(rc) {
|
|
var sgc = $("td.sgexpanded",rc)[0];
|
|
if(sgc) {
|
|
$(sgc).trigger("click");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
toggleSubGridRow : function(rowid) {
|
|
return this.each(function () {
|
|
var $t = this;
|
|
if(!$t.grid && !rowid) {return;}
|
|
if($t.p.subGrid===true) {
|
|
var rc = $(this).jqGrid("getInd",rowid,true);
|
|
if(rc) {
|
|
var sgc = $("td.sgcollapsed",rc)[0];
|
|
if(sgc) {
|
|
$(sgc).trigger("click");
|
|
} else {
|
|
sgc = $("td.sgexpanded",rc)[0];
|
|
if(sgc) {
|
|
$(sgc).trigger("click");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/**
|
|
* jqGrid extension - Tree Grid
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl.html
|
|
**/
|
|
|
|
/*jshint eqeqeq:false */
|
|
/*global jQuery */
|
|
(function($) {
|
|
"use strict";
|
|
$.jgrid.extend({
|
|
setTreeNode : function(i, len){
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if( !$t.grid || !$t.p.treeGrid ) {return;}
|
|
var expCol = $t.p.expColInd,
|
|
expanded = $t.p.treeReader.expanded_field,
|
|
isLeaf = $t.p.treeReader.leaf_field,
|
|
level = $t.p.treeReader.level_field,
|
|
icon = $t.p.treeReader.icon_field,
|
|
loaded = $t.p.treeReader.loaded, lft, rgt, curLevel, ident,lftpos, twrap,
|
|
ldat, lf;
|
|
while(i<len) {
|
|
var ind = $.jgrid.stripPref($t.p.idPrefix, $t.rows[i].id), dind = $t.p._index[ind], expan;
|
|
ldat = $t.p.data[dind];
|
|
//$t.rows[i].level = ldat[level];
|
|
if($t.p.treeGridModel === 'nested') {
|
|
if(!ldat[isLeaf]) {
|
|
lft = parseInt(ldat[$t.p.treeReader.left_field],10);
|
|
rgt = parseInt(ldat[$t.p.treeReader.right_field],10);
|
|
// NS Model
|
|
ldat[isLeaf] = (rgt === lft+1) ? 'true' : 'false';
|
|
$t.rows[i].cells[$t.p._treeleafpos].innerHTML = ldat[isLeaf];
|
|
}
|
|
}
|
|
//else {
|
|
//row.parent_id = rd[$t.p.treeReader.parent_id_field];
|
|
//}
|
|
curLevel = parseInt(ldat[level],10);
|
|
if($t.p.tree_root_level === 0) {
|
|
ident = curLevel+1;
|
|
lftpos = curLevel;
|
|
} else {
|
|
ident = curLevel;
|
|
lftpos = curLevel -1;
|
|
}
|
|
twrap = "<div class='tree-wrap tree-wrap-"+$t.p.direction+"' style='width:"+(ident*18)+"px;'>";
|
|
twrap += "<div style='"+($t.p.direction==="rtl" ? "right:" : "left:")+(lftpos*18)+"px;' class='ui-icon ";
|
|
|
|
|
|
if(ldat[loaded] !== undefined) {
|
|
if(ldat[loaded]==="true" || ldat[loaded]===true) {
|
|
ldat[loaded] = true;
|
|
} else {
|
|
ldat[loaded] = false;
|
|
}
|
|
}
|
|
if(ldat[isLeaf] === "true" || ldat[isLeaf] === true) {
|
|
twrap += ((ldat[icon] !== undefined && ldat[icon] !== "") ? ldat[icon] : $t.p.treeIcons.leaf)+" tree-leaf treeclick";
|
|
ldat[isLeaf] = true;
|
|
lf="leaf";
|
|
} else {
|
|
ldat[isLeaf] = false;
|
|
lf="";
|
|
}
|
|
ldat[expanded] = ((ldat[expanded] === "true" || ldat[expanded] === true) ? true : false) && (ldat[loaded] || ldat[loaded] === undefined);
|
|
if(ldat[expanded] === false) {
|
|
twrap += ((ldat[isLeaf] === true) ? "'" : $t.p.treeIcons.plus+" tree-plus treeclick'");
|
|
} else {
|
|
twrap += ((ldat[isLeaf] === true) ? "'" : $t.p.treeIcons.minus+" tree-minus treeclick'");
|
|
}
|
|
|
|
twrap += "></div></div>";
|
|
$($t.rows[i].cells[expCol]).wrapInner("<span class='cell-wrapper"+lf+"'></span>").prepend(twrap);
|
|
|
|
if(curLevel !== parseInt($t.p.tree_root_level,10)) {
|
|
var pn = $($t).jqGrid('getNodeParent',ldat);
|
|
expan = pn && pn.hasOwnProperty(expanded) ? pn[expanded] : true;
|
|
if( !expan ){
|
|
$($t.rows[i]).css("display","none");
|
|
}
|
|
}
|
|
$($t.rows[i].cells[expCol])
|
|
.find("div.treeclick")
|
|
.bind("click",function(e){
|
|
var target = e.target || e.srcElement,
|
|
ind2 =$.jgrid.stripPref($t.p.idPrefix,$(target,$t.rows).closest("tr.jqgrow")[0].id),
|
|
pos = $t.p._index[ind2];
|
|
if(!$t.p.data[pos][isLeaf]){
|
|
if($t.p.data[pos][expanded]){
|
|
$($t).jqGrid("collapseRow",$t.p.data[pos]);
|
|
$($t).jqGrid("collapseNode",$t.p.data[pos]);
|
|
} else {
|
|
$($t).jqGrid("expandRow",$t.p.data[pos]);
|
|
$($t).jqGrid("expandNode",$t.p.data[pos]);
|
|
}
|
|
}
|
|
return false;
|
|
});
|
|
if($t.p.ExpandColClick === true) {
|
|
$($t.rows[i].cells[expCol])
|
|
.find("span.cell-wrapper")
|
|
.css("cursor","pointer")
|
|
.bind("click",function(e) {
|
|
var target = e.target || e.srcElement,
|
|
ind2 =$.jgrid.stripPref($t.p.idPrefix,$(target,$t.rows).closest("tr.jqgrow")[0].id),
|
|
pos = $t.p._index[ind2];
|
|
if(!$t.p.data[pos][isLeaf]){
|
|
if($t.p.data[pos][expanded]){
|
|
$($t).jqGrid("collapseRow",$t.p.data[pos]);
|
|
$($t).jqGrid("collapseNode",$t.p.data[pos]);
|
|
} else {
|
|
$($t).jqGrid("expandRow",$t.p.data[pos]);
|
|
$($t).jqGrid("expandNode",$t.p.data[pos]);
|
|
}
|
|
}
|
|
$($t).jqGrid("setSelection",ind2);
|
|
return false;
|
|
});
|
|
}
|
|
i++;
|
|
}
|
|
|
|
});
|
|
},
|
|
setTreeGrid : function() {
|
|
return this.each(function (){
|
|
var $t = this, i=0, pico, ecol = false, nm, key, tkey, dupcols=[];
|
|
if(!$t.p.treeGrid) {return;}
|
|
if(!$t.p.treedatatype ) {$.extend($t.p,{treedatatype: $t.p.datatype});}
|
|
$t.p.subGrid = false;$t.p.altRows =false;
|
|
$t.p.pgbuttons = false;$t.p.pginput = false;
|
|
$t.p.gridview = true;
|
|
if($t.p.rowTotal === null ) { $t.p.rowNum = 10000; }
|
|
$t.p.multiselect = false;$t.p.rowList = [];
|
|
$t.p.expColInd = 0;
|
|
pico = 'ui-icon-triangle-1-' + ($t.p.direction==="rtl" ? 'w' : 'e');
|
|
$t.p.treeIcons = $.extend({plus:pico,minus:'ui-icon-triangle-1-s',leaf:'ui-icon-radio-off'},$t.p.treeIcons || {});
|
|
if($t.p.treeGridModel === 'nested') {
|
|
$t.p.treeReader = $.extend({
|
|
level_field: "level",
|
|
left_field:"lft",
|
|
right_field: "rgt",
|
|
leaf_field: "isLeaf",
|
|
expanded_field: "expanded",
|
|
loaded: "loaded",
|
|
icon_field: "icon"
|
|
},$t.p.treeReader);
|
|
} else if($t.p.treeGridModel === 'adjacency') {
|
|
$t.p.treeReader = $.extend({
|
|
level_field: "level",
|
|
parent_id_field: "parent",
|
|
leaf_field: "isLeaf",
|
|
expanded_field: "expanded",
|
|
loaded: "loaded",
|
|
icon_field: "icon"
|
|
},$t.p.treeReader );
|
|
}
|
|
for ( key in $t.p.colModel){
|
|
if($t.p.colModel.hasOwnProperty(key)) {
|
|
nm = $t.p.colModel[key].name;
|
|
if( nm === $t.p.ExpandColumn && !ecol ) {
|
|
ecol = true;
|
|
$t.p.expColInd = i;
|
|
}
|
|
i++;
|
|
//
|
|
for(tkey in $t.p.treeReader) {
|
|
if($t.p.treeReader.hasOwnProperty(tkey) && $t.p.treeReader[tkey] === nm) {
|
|
dupcols.push(nm);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
$.each($t.p.treeReader,function(j,n){
|
|
if(n && $.inArray(n, dupcols) === -1){
|
|
if(j==='leaf_field') { $t.p._treeleafpos= i; }
|
|
i++;
|
|
$t.p.colNames.push(n);
|
|
$t.p.colModel.push({name:n,width:1,hidden:true,sortable:false,resizable:false,hidedlg:true,editable:true,search:false});
|
|
}
|
|
});
|
|
});
|
|
},
|
|
expandRow: function (record){
|
|
this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
var childern = $($t).jqGrid("getNodeChildren",record),
|
|
//if ($($t).jqGrid("isVisibleNode",record)) {
|
|
expanded = $t.p.treeReader.expanded_field;
|
|
$(childern).each(function(){
|
|
var id = $t.p.idPrefix + $.jgrid.getAccessor(this,$t.p.localReader.id);
|
|
$($($t).jqGrid('getGridRowById', id)).css("display","");
|
|
if(this[expanded]) {
|
|
$($t).jqGrid("expandRow",this);
|
|
}
|
|
});
|
|
//}
|
|
});
|
|
},
|
|
collapseRow : function (record) {
|
|
this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
var childern = $($t).jqGrid("getNodeChildren",record),
|
|
expanded = $t.p.treeReader.expanded_field;
|
|
$(childern).each(function(){
|
|
var id = $t.p.idPrefix + $.jgrid.getAccessor(this,$t.p.localReader.id);
|
|
$($($t).jqGrid('getGridRowById', id)).css("display","none");
|
|
if(this[expanded]){
|
|
$($t).jqGrid("collapseRow",this);
|
|
}
|
|
});
|
|
});
|
|
},
|
|
// NS ,adjacency models
|
|
getRootNodes : function() {
|
|
var result = [];
|
|
this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
switch ($t.p.treeGridModel) {
|
|
case 'nested' :
|
|
var level = $t.p.treeReader.level_field;
|
|
$($t.p.data).each(function(){
|
|
if(parseInt(this[level],10) === parseInt($t.p.tree_root_level,10)) {
|
|
result.push(this);
|
|
}
|
|
});
|
|
break;
|
|
case 'adjacency' :
|
|
var parent_id = $t.p.treeReader.parent_id_field;
|
|
$($t.p.data).each(function(){
|
|
if(this[parent_id] === null || String(this[parent_id]).toLowerCase() === "null") {
|
|
result.push(this);
|
|
}
|
|
});
|
|
break;
|
|
}
|
|
});
|
|
return result;
|
|
},
|
|
getNodeDepth : function(rc) {
|
|
var ret = null;
|
|
this.each(function(){
|
|
if(!this.grid || !this.p.treeGrid) {return;}
|
|
var $t = this;
|
|
switch ($t.p.treeGridModel) {
|
|
case 'nested' :
|
|
var level = $t.p.treeReader.level_field;
|
|
ret = parseInt(rc[level],10) - parseInt($t.p.tree_root_level,10);
|
|
break;
|
|
case 'adjacency' :
|
|
ret = $($t).jqGrid("getNodeAncestors",rc).length;
|
|
break;
|
|
}
|
|
});
|
|
return ret;
|
|
},
|
|
getNodeParent : function(rc) {
|
|
var result = null;
|
|
this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
switch ($t.p.treeGridModel) {
|
|
case 'nested' :
|
|
var lftc = $t.p.treeReader.left_field,
|
|
rgtc = $t.p.treeReader.right_field,
|
|
levelc = $t.p.treeReader.level_field,
|
|
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
|
|
$(this.p.data).each(function(){
|
|
if(parseInt(this[levelc],10) === level-1 && parseInt(this[lftc],10) < lft && parseInt(this[rgtc],10) > rgt) {
|
|
result = this;
|
|
return false;
|
|
}
|
|
});
|
|
break;
|
|
case 'adjacency' :
|
|
var parent_id = $t.p.treeReader.parent_id_field,
|
|
dtid = $t.p.localReader.id;
|
|
$(this.p.data).each(function(){
|
|
if(this[dtid] === $.jgrid.stripPref($t.p.idPrefix, rc[parent_id]) ) {
|
|
result = this;
|
|
return false;
|
|
}
|
|
});
|
|
break;
|
|
}
|
|
});
|
|
return result;
|
|
},
|
|
getNodeChildren : function(rc) {
|
|
var result = [];
|
|
this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
switch ($t.p.treeGridModel) {
|
|
case 'nested' :
|
|
var lftc = $t.p.treeReader.left_field,
|
|
rgtc = $t.p.treeReader.right_field,
|
|
levelc = $t.p.treeReader.level_field,
|
|
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
|
|
$(this.p.data).each(function(){
|
|
if(parseInt(this[levelc],10) === level+1 && parseInt(this[lftc],10) > lft && parseInt(this[rgtc],10) < rgt) {
|
|
result.push(this);
|
|
}
|
|
});
|
|
break;
|
|
case 'adjacency' :
|
|
var parent_id = $t.p.treeReader.parent_id_field,
|
|
dtid = $t.p.localReader.id;
|
|
$(this.p.data).each(function(){
|
|
if(this[parent_id] == $.jgrid.stripPref($t.p.idPrefix, rc[dtid])) {
|
|
result.push(this);
|
|
}
|
|
});
|
|
break;
|
|
}
|
|
});
|
|
return result;
|
|
},
|
|
getFullTreeNode : function(rc) {
|
|
var result = [];
|
|
this.each(function(){
|
|
var $t = this, len;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
switch ($t.p.treeGridModel) {
|
|
case 'nested' :
|
|
var lftc = $t.p.treeReader.left_field,
|
|
rgtc = $t.p.treeReader.right_field,
|
|
levelc = $t.p.treeReader.level_field,
|
|
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
|
|
$(this.p.data).each(function(){
|
|
if(parseInt(this[levelc],10) >= level && parseInt(this[lftc],10) >= lft && parseInt(this[lftc],10) <= rgt) {
|
|
result.push(this);
|
|
}
|
|
});
|
|
break;
|
|
case 'adjacency' :
|
|
if(rc) {
|
|
result.push(rc);
|
|
var parent_id = $t.p.treeReader.parent_id_field,
|
|
dtid = $t.p.localReader.id;
|
|
$(this.p.data).each(function(i){
|
|
len = result.length;
|
|
for (i = 0; i < len; i++) {
|
|
if ($.jgrid.stripPref($t.p.idPrefix, result[i][dtid]) === this[parent_id]) {
|
|
result.push(this);
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
return result;
|
|
},
|
|
// End NS, adjacency Model
|
|
getNodeAncestors : function(rc) {
|
|
var ancestors = [];
|
|
this.each(function(){
|
|
if(!this.grid || !this.p.treeGrid) {return;}
|
|
var parent = $(this).jqGrid("getNodeParent",rc);
|
|
while (parent) {
|
|
ancestors.push(parent);
|
|
parent = $(this).jqGrid("getNodeParent",parent);
|
|
}
|
|
});
|
|
return ancestors;
|
|
},
|
|
isVisibleNode : function(rc) {
|
|
var result = true;
|
|
this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
var ancestors = $($t).jqGrid("getNodeAncestors",rc),
|
|
expanded = $t.p.treeReader.expanded_field;
|
|
$(ancestors).each(function(){
|
|
result = result && this[expanded];
|
|
if(!result) {return false;}
|
|
});
|
|
});
|
|
return result;
|
|
},
|
|
isNodeLoaded : function(rc) {
|
|
var result;
|
|
this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
var isLeaf = $t.p.treeReader.leaf_field,
|
|
loaded = $t.p.treeReader.loaded;
|
|
if(rc !== undefined ) {
|
|
if(rc[loaded] !== undefined) {
|
|
result = rc[loaded];
|
|
} else if( rc[isLeaf] || $($t).jqGrid("getNodeChildren",rc).length > 0){
|
|
result = true;
|
|
} else {
|
|
result = false;
|
|
}
|
|
} else {
|
|
result = false;
|
|
}
|
|
});
|
|
return result;
|
|
},
|
|
expandNode : function(rc) {
|
|
return this.each(function(){
|
|
if(!this.grid || !this.p.treeGrid) {return;}
|
|
var expanded = this.p.treeReader.expanded_field,
|
|
parent = this.p.treeReader.parent_id_field,
|
|
loaded = this.p.treeReader.loaded,
|
|
level = this.p.treeReader.level_field,
|
|
lft = this.p.treeReader.left_field,
|
|
rgt = this.p.treeReader.right_field;
|
|
|
|
if(!rc[expanded]) {
|
|
var id = $.jgrid.getAccessor(rc,this.p.localReader.id);
|
|
var rc1 = $("#" + this.p.idPrefix + $.jgrid.jqID(id),this.grid.bDiv)[0];
|
|
var position = this.p._index[id];
|
|
if( $(this).jqGrid("isNodeLoaded",this.p.data[position]) ) {
|
|
rc[expanded] = true;
|
|
$("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
|
|
} else if (!this.grid.hDiv.loading) {
|
|
rc[expanded] = true;
|
|
$("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
|
|
this.p.treeANode = rc1.rowIndex;
|
|
this.p.datatype = this.p.treedatatype;
|
|
if(this.p.treeGridModel === 'nested') {
|
|
$(this).jqGrid("setGridParam",{postData:{nodeid:id,n_left:rc[lft],n_right:rc[rgt],n_level:rc[level]}});
|
|
} else {
|
|
$(this).jqGrid("setGridParam",{postData:{nodeid:id,parentid:rc[parent],n_level:rc[level]}} );
|
|
}
|
|
$(this).trigger("reloadGrid");
|
|
rc[loaded] = true;
|
|
if(this.p.treeGridModel === 'nested') {
|
|
$(this).jqGrid("setGridParam",{postData:{nodeid:'',n_left:'',n_right:'',n_level:''}});
|
|
} else {
|
|
$(this).jqGrid("setGridParam",{postData:{nodeid:'',parentid:'',n_level:''}});
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
collapseNode : function(rc) {
|
|
return this.each(function(){
|
|
if(!this.grid || !this.p.treeGrid) {return;}
|
|
var expanded = this.p.treeReader.expanded_field;
|
|
if(rc[expanded]) {
|
|
rc[expanded] = false;
|
|
var id = $.jgrid.getAccessor(rc,this.p.localReader.id);
|
|
var rc1 = $("#" + this.p.idPrefix + $.jgrid.jqID(id),this.grid.bDiv)[0];
|
|
$("div.treeclick",rc1).removeClass(this.p.treeIcons.minus+" tree-minus").addClass(this.p.treeIcons.plus+" tree-plus");
|
|
}
|
|
});
|
|
},
|
|
SortTree : function( sortname, newDir, st, datefmt) {
|
|
return this.each(function(){
|
|
if(!this.grid || !this.p.treeGrid) {return;}
|
|
var i, len,
|
|
rec, records = [], $t = this, query, roots,
|
|
rt = $(this).jqGrid("getRootNodes");
|
|
// Sorting roots
|
|
query = $.jgrid.from(rt);
|
|
query.orderBy(sortname,newDir,st, datefmt);
|
|
roots = query.select();
|
|
|
|
// Sorting children
|
|
for (i = 0, len = roots.length; i < len; i++) {
|
|
rec = roots[i];
|
|
records.push(rec);
|
|
$(this).jqGrid("collectChildrenSortTree",records, rec, sortname, newDir,st, datefmt);
|
|
}
|
|
$.each(records, function(index) {
|
|
var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
|
|
$('#'+$.jgrid.jqID($t.p.id)+ ' tbody tr:eq('+index+')').after($('tr#'+$.jgrid.jqID(id),$t.grid.bDiv));
|
|
});
|
|
query = null;roots=null;records=null;
|
|
});
|
|
},
|
|
collectChildrenSortTree : function(records, rec, sortname, newDir,st, datefmt) {
|
|
return this.each(function(){
|
|
if(!this.grid || !this.p.treeGrid) {return;}
|
|
var i, len,
|
|
child, ch, query, children;
|
|
ch = $(this).jqGrid("getNodeChildren",rec);
|
|
query = $.jgrid.from(ch);
|
|
query.orderBy(sortname, newDir, st, datefmt);
|
|
children = query.select();
|
|
for (i = 0, len = children.length; i < len; i++) {
|
|
child = children[i];
|
|
records.push(child);
|
|
$(this).jqGrid("collectChildrenSortTree",records, child, sortname, newDir, st, datefmt);
|
|
}
|
|
});
|
|
},
|
|
// experimental
|
|
setTreeRow : function(rowid, data) {
|
|
var success=false;
|
|
this.each(function(){
|
|
var t = this;
|
|
if(!t.grid || !t.p.treeGrid) {return;}
|
|
success = $(t).jqGrid("setRowData",rowid,data);
|
|
});
|
|
return success;
|
|
},
|
|
delTreeNode : function (rowid) {
|
|
return this.each(function () {
|
|
var $t = this, rid = $t.p.localReader.id, i,
|
|
left = $t.p.treeReader.left_field,
|
|
right = $t.p.treeReader.right_field, myright, width, res, key;
|
|
if(!$t.grid || !$t.p.treeGrid) {return;}
|
|
var rc = $t.p._index[rowid];
|
|
if (rc !== undefined) {
|
|
// nested
|
|
myright = parseInt($t.p.data[rc][right],10);
|
|
width = myright - parseInt($t.p.data[rc][left],10) + 1;
|
|
var dr = $($t).jqGrid("getFullTreeNode",$t.p.data[rc]);
|
|
if(dr.length>0){
|
|
for (i=0;i<dr.length;i++){
|
|
$($t).jqGrid("delRowData",dr[i][rid]);
|
|
}
|
|
}
|
|
if( $t.p.treeGridModel === "nested") {
|
|
// ToDo - update grid data
|
|
res = $.jgrid.from($t.p.data)
|
|
.greater(left,myright,{stype:'integer'})
|
|
.select();
|
|
if(res.length) {
|
|
for( key in res) {
|
|
if(res.hasOwnProperty(key)) {
|
|
res[key][left] = parseInt(res[key][left],10) - width ;
|
|
}
|
|
}
|
|
}
|
|
res = $.jgrid.from($t.p.data)
|
|
.greater(right,myright,{stype:'integer'})
|
|
.select();
|
|
if(res.length) {
|
|
for( key in res) {
|
|
if(res.hasOwnProperty(key)) {
|
|
res[key][right] = parseInt(res[key][right],10) - width ;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
},
|
|
addChildNode : function( nodeid, parentid, data, expandData ) {
|
|
//return this.each(function(){
|
|
var $t = this[0];
|
|
if(data) {
|
|
// we suppose tha the id is autoincremet and
|
|
var expanded = $t.p.treeReader.expanded_field,
|
|
isLeaf = $t.p.treeReader.leaf_field,
|
|
level = $t.p.treeReader.level_field,
|
|
//icon = $t.p.treeReader.icon_field,
|
|
parent = $t.p.treeReader.parent_id_field,
|
|
left = $t.p.treeReader.left_field,
|
|
right = $t.p.treeReader.right_field,
|
|
loaded = $t.p.treeReader.loaded,
|
|
method, parentindex, parentdata, parentlevel, i, len, max=0, rowind = parentid, leaf, maxright;
|
|
if(expandData===undefined) {expandData = false;}
|
|
if ( nodeid === undefined || nodeid === null ) {
|
|
i = $t.p.data.length-1;
|
|
if( i>= 0 ) {
|
|
while(i>=0){max = Math.max(max, parseInt($t.p.data[i][$t.p.localReader.id],10)); i--;}
|
|
}
|
|
nodeid = max+1;
|
|
}
|
|
var prow = $($t).jqGrid('getInd', parentid);
|
|
leaf = false;
|
|
// if not a parent we assume root
|
|
if ( parentid === undefined || parentid === null || parentid==="") {
|
|
parentid = null;
|
|
rowind = null;
|
|
method = 'last';
|
|
parentlevel = $t.p.tree_root_level;
|
|
i = $t.p.data.length+1;
|
|
} else {
|
|
method = 'after';
|
|
parentindex = $t.p._index[parentid];
|
|
parentdata = $t.p.data[parentindex];
|
|
parentid = parentdata[$t.p.localReader.id];
|
|
parentlevel = parseInt(parentdata[level],10)+1;
|
|
var childs = $($t).jqGrid('getFullTreeNode', parentdata);
|
|
// if there are child nodes get the last index of it
|
|
if(childs.length) {
|
|
i = childs[childs.length-1][$t.p.localReader.id];
|
|
rowind = i;
|
|
i = $($t).jqGrid('getInd',rowind)+1;
|
|
} else {
|
|
i = $($t).jqGrid('getInd', parentid)+1;
|
|
}
|
|
// if the node is leaf
|
|
if(parentdata[isLeaf]) {
|
|
leaf = true;
|
|
parentdata[expanded] = true;
|
|
//var prow = $($t).jqGrid('getInd', parentid);
|
|
$($t.rows[prow])
|
|
.find("span.cell-wrapperleaf").removeClass("cell-wrapperleaf").addClass("cell-wrapper")
|
|
.end()
|
|
.find("div.tree-leaf").removeClass($t.p.treeIcons.leaf+" tree-leaf").addClass($t.p.treeIcons.minus+" tree-minus");
|
|
$t.p.data[parentindex][isLeaf] = false;
|
|
parentdata[loaded] = true;
|
|
}
|
|
}
|
|
len = i+1;
|
|
|
|
if( data[expanded]===undefined) {data[expanded]= false;}
|
|
if( data[loaded]===undefined ) { data[loaded] = false;}
|
|
data[level] = parentlevel;
|
|
if( data[isLeaf]===undefined) {data[isLeaf]= true;}
|
|
if( $t.p.treeGridModel === "adjacency") {
|
|
data[parent] = parentid;
|
|
}
|
|
if( $t.p.treeGridModel === "nested") {
|
|
// this method requiere more attention
|
|
var query, res, key;
|
|
//maxright = parseInt(maxright,10);
|
|
// ToDo - update grid data
|
|
if(parentid !== null) {
|
|
maxright = parseInt(parentdata[right],10);
|
|
query = $.jgrid.from($t.p.data);
|
|
query = query.greaterOrEquals(right,maxright,{stype:'integer'});
|
|
res = query.select();
|
|
if(res.length) {
|
|
for( key in res) {
|
|
if(res.hasOwnProperty(key)) {
|
|
res[key][left] = res[key][left] > maxright ? parseInt(res[key][left],10) +2 : res[key][left];
|
|
res[key][right] = res[key][right] >= maxright ? parseInt(res[key][right],10) +2 : res[key][right];
|
|
}
|
|
}
|
|
}
|
|
data[left] = maxright;
|
|
data[right]= maxright+1;
|
|
} else {
|
|
maxright = parseInt( $($t).jqGrid('getCol', right, false, 'max'), 10);
|
|
res = $.jgrid.from($t.p.data)
|
|
.greater(left,maxright,{stype:'integer'})
|
|
.select();
|
|
if(res.length) {
|
|
for( key in res) {
|
|
if(res.hasOwnProperty(key)) {
|
|
res[key][left] = parseInt(res[key][left],10) +2 ;
|
|
}
|
|
}
|
|
}
|
|
res = $.jgrid.from($t.p.data)
|
|
.greater(right,maxright,{stype:'integer'})
|
|
.select();
|
|
if(res.length) {
|
|
for( key in res) {
|
|
if(res.hasOwnProperty(key)) {
|
|
res[key][right] = parseInt(res[key][right],10) +2 ;
|
|
}
|
|
}
|
|
}
|
|
data[left] = maxright+1;
|
|
data[right] = maxright + 2;
|
|
}
|
|
}
|
|
if( parentid === null || $($t).jqGrid("isNodeLoaded",parentdata) || leaf ) {
|
|
$($t).jqGrid('addRowData', nodeid, data, method, rowind);
|
|
$($t).jqGrid('setTreeNode', i, len);
|
|
}
|
|
if(parentdata && !parentdata[expanded] && expandData) {
|
|
$($t.rows[prow])
|
|
.find("div.treeclick")
|
|
.click();
|
|
}
|
|
}
|
|
//});
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false, eqnull:true */
|
|
/*global jQuery */
|
|
// Grouping module
|
|
(function($){
|
|
"use strict";
|
|
$.extend($.jgrid,{
|
|
template : function(format){ //jqgformat
|
|
var args = $.makeArray(arguments).slice(1), j, al = args.length;
|
|
if(format==null) { format = ""; }
|
|
return format.replace(/\{([\w\-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g, function(m,i){
|
|
if(!isNaN(parseInt(i,10))) {
|
|
return args[parseInt(i,10)];
|
|
}
|
|
for(j=0; j < al;j++) {
|
|
if($.isArray(args[j])) {
|
|
var nmarr = args[ j ],
|
|
k = nmarr.length;
|
|
while(k--) {
|
|
if(i===nmarr[k].nm) {
|
|
return nmarr[k].v;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
$.jgrid.extend({
|
|
groupingSetup : function () {
|
|
return this.each(function (){
|
|
var $t = this, i, j, cml, cm = $t.p.colModel, grp = $t.p.groupingView;
|
|
if(grp !== null && ( (typeof grp === 'object') || $.isFunction(grp) ) ) {
|
|
if(!grp.groupField.length) {
|
|
$t.p.grouping = false;
|
|
} else {
|
|
if (grp.visibiltyOnNextGrouping === undefined) {
|
|
grp.visibiltyOnNextGrouping = [];
|
|
}
|
|
|
|
grp.lastvalues=[];
|
|
grp.groups =[];
|
|
grp.counters =[];
|
|
for(i=0;i<grp.groupField.length;i++) {
|
|
if(!grp.groupOrder[i]) {
|
|
grp.groupOrder[i] = 'asc';
|
|
}
|
|
if(!grp.groupText[i]) {
|
|
grp.groupText[i] = '{0}';
|
|
}
|
|
if( typeof grp.groupColumnShow[i] !== 'boolean') {
|
|
grp.groupColumnShow[i] = true;
|
|
}
|
|
if( typeof grp.groupSummary[i] !== 'boolean') {
|
|
grp.groupSummary[i] = false;
|
|
}
|
|
if(grp.groupColumnShow[i] === true) {
|
|
grp.visibiltyOnNextGrouping[i] = true;
|
|
$($t).jqGrid('showCol',grp.groupField[i]);
|
|
} else {
|
|
grp.visibiltyOnNextGrouping[i] = $("#"+$.jgrid.jqID($t.p.id+"_"+grp.groupField[i])).is(":visible");
|
|
$($t).jqGrid('hideCol',grp.groupField[i]);
|
|
}
|
|
}
|
|
grp.summary =[];
|
|
for(j=0, cml = cm.length; j < cml; j++) {
|
|
if(cm[j].summaryType ) {
|
|
if(cm[j].summaryDivider) {
|
|
grp.summary.push({nm:cm[j].name,st:cm[j].summaryType, v: '', sd:cm[j].summaryDivider, vd:'', sr: cm[j].summaryRound, srt: cm[j].summaryRoundType || 'round'});
|
|
} else {
|
|
grp.summary.push({nm:cm[j].name,st:cm[j].summaryType, v: '', sr: cm[j].summaryRound, srt: cm[j].summaryRoundType || 'round'});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
$t.p.grouping = false;
|
|
}
|
|
});
|
|
},
|
|
groupingPrepare : function (rData, gdata, record, irow) {
|
|
this.each(function(){
|
|
var grp = this.p.groupingView, $t= this, i,
|
|
grlen = grp.groupField.length,
|
|
fieldName,
|
|
v,
|
|
displayName,
|
|
displayValue,
|
|
changed = 0;
|
|
for(i=0;i<grlen;i++) {
|
|
fieldName = grp.groupField[i];
|
|
displayName = grp.displayField[i];
|
|
v = record[fieldName];
|
|
displayValue = displayName == null ? null : record[displayName];
|
|
|
|
if( displayValue == null ) {
|
|
displayValue = v;
|
|
}
|
|
if( v !== undefined ) {
|
|
if(irow === 0 ) {
|
|
// First record always starts a new group
|
|
grp.groups.push({idx:i,dataIndex:fieldName,value:v, displayValue: displayValue, startRow: irow, cnt:1, summary : [] } );
|
|
grp.lastvalues[i] = v;
|
|
grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
|
|
$.each(grp.counters[i].summary,function() {
|
|
if ($.isFunction(this.st)) {
|
|
this.v = this.st.call($t, this.v, this.nm, record);
|
|
} else {
|
|
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
|
|
if(this.st.toLowerCase() === 'avg' && this.sd) {
|
|
this.vd = $($t).jqGrid('groupingCalculations.handler',this.st, this.vd, this.sd, this.sr, this.srt, record);
|
|
}
|
|
}
|
|
});
|
|
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
|
|
} else {
|
|
if (typeof v !== "object" && ($.isArray(grp.isInTheSameGroup) && $.isFunction(grp.isInTheSameGroup[i]) ? ! grp.isInTheSameGroup[i].call($t, grp.lastvalues[i], v, i, grp): grp.lastvalues[i] !== v)) {
|
|
// This record is not in same group as previous one
|
|
grp.groups.push({idx:i,dataIndex:fieldName,value:v, displayValue: displayValue, startRow: irow, cnt:1, summary : [] } );
|
|
grp.lastvalues[i] = v;
|
|
changed = 1;
|
|
grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
|
|
$.each(grp.counters[i].summary,function() {
|
|
if ($.isFunction(this.st)) {
|
|
this.v = this.st.call($t, this.v, this.nm, record);
|
|
} else {
|
|
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
|
|
if(this.st.toLowerCase() === 'avg' && this.sd) {
|
|
this.vd = $($t).jqGrid('groupingCalculations.handler',this.st, this.vd, this.sd, this.sr, this.srt, record);
|
|
}
|
|
}
|
|
});
|
|
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
|
|
} else {
|
|
if (changed === 1) {
|
|
// This group has changed because an earlier group changed.
|
|
grp.groups.push({idx:i,dataIndex:fieldName,value:v, displayValue: displayValue, startRow: irow, cnt:1, summary : [] } );
|
|
grp.lastvalues[i] = v;
|
|
grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
|
|
$.each(grp.counters[i].summary,function() {
|
|
if ($.isFunction(this.st)) {
|
|
this.v = this.st.call($t, this.v, this.nm, record);
|
|
} else {
|
|
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
|
|
if(this.st.toLowerCase() === 'avg' && this.sd) {
|
|
this.vd = $($t).jqGrid('groupingCalculations.handler',this.st, this.vd, this.sd, this.sr, this.srt, record);
|
|
}
|
|
}
|
|
});
|
|
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
|
|
} else {
|
|
grp.counters[i].cnt += 1;
|
|
grp.groups[grp.counters[i].pos].cnt = grp.counters[i].cnt;
|
|
$.each(grp.counters[i].summary,function() {
|
|
if ($.isFunction(this.st)) {
|
|
this.v = this.st.call($t, this.v, this.nm, record);
|
|
} else {
|
|
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
|
|
if(this.st.toLowerCase() === 'avg' && this.sd) {
|
|
this.vd = $($t).jqGrid('groupingCalculations.handler',this.st, this.vd, this.sd, this.sr, this.srt, record);
|
|
}
|
|
}
|
|
});
|
|
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
gdata.push( rData );
|
|
});
|
|
return gdata;
|
|
},
|
|
groupingToggle : function(hid){
|
|
this.each(function(){
|
|
var $t = this,
|
|
grp = $t.p.groupingView,
|
|
strpos = hid.split('_'),
|
|
num = parseInt(strpos[strpos.length-2], 10);
|
|
strpos.splice(strpos.length-2,2);
|
|
var uid = strpos.join("_"),
|
|
minus = grp.minusicon,
|
|
plus = grp.plusicon,
|
|
tar = $("#"+$.jgrid.jqID(hid)),
|
|
r = tar.length ? tar[0].nextSibling : null,
|
|
tarspan = $("#"+$.jgrid.jqID(hid)+" span."+"tree-wrap-"+$t.p.direction),
|
|
getGroupingLevelFromClass = function (className) {
|
|
var nums = $.map(className.split(" "), function (item) {
|
|
if (item.substring(0, uid.length + 1) === uid + "_") {
|
|
return parseInt(item.substring(uid.length + 1), 10);
|
|
}
|
|
});
|
|
return nums.length > 0 ? nums[0] : undefined;
|
|
},
|
|
itemGroupingLevel,
|
|
showData,
|
|
collapsed = false;
|
|
if( tarspan.hasClass(minus) ) {
|
|
if(grp.showSummaryOnHide) {
|
|
if(r){
|
|
while(r) {
|
|
if($(r).hasClass('jqfoot') ) {
|
|
var lv = parseInt($(r).attr("jqfootlevel"),10);
|
|
if( lv <= num) {
|
|
break;
|
|
}
|
|
}
|
|
$(r).hide();
|
|
r = r.nextSibling;
|
|
}
|
|
}
|
|
} else {
|
|
if(r){
|
|
while(r) {
|
|
itemGroupingLevel = getGroupingLevelFromClass(r.className);
|
|
if (itemGroupingLevel !== undefined && itemGroupingLevel <= num) {
|
|
break;
|
|
}
|
|
$(r).hide();
|
|
r = r.nextSibling;
|
|
}
|
|
}
|
|
}
|
|
tarspan.removeClass(minus).addClass(plus);
|
|
collapsed = true;
|
|
} else {
|
|
if(r){
|
|
showData = undefined;
|
|
while(r) {
|
|
itemGroupingLevel = getGroupingLevelFromClass(r.className);
|
|
if (showData === undefined) {
|
|
showData = itemGroupingLevel === undefined; // if the first row after the opening group is data row then show the data rows
|
|
}
|
|
if (itemGroupingLevel !== undefined) {
|
|
if (itemGroupingLevel <= num) {
|
|
break;// next item of the same lever are found
|
|
}
|
|
if (itemGroupingLevel === num + 1) {
|
|
$(r).show().find(">td>span."+"tree-wrap-"+$t.p.direction).removeClass(minus).addClass(plus);
|
|
}
|
|
} else if (showData) {
|
|
$(r).show();
|
|
}
|
|
r = r.nextSibling;
|
|
}
|
|
}
|
|
tarspan.removeClass(plus).addClass(minus);
|
|
}
|
|
$($t).triggerHandler("jqGridGroupingClickGroup", [hid , collapsed]);
|
|
if( $.isFunction($t.p.onClickGroup)) { $t.p.onClickGroup.call($t, hid , collapsed); }
|
|
|
|
});
|
|
return false;
|
|
},
|
|
groupingRender : function (grdata, colspans ) {
|
|
return this.each(function(){
|
|
var $t = this,
|
|
grp = $t.p.groupingView,
|
|
str = "", icon = "", hid, clid, pmrtl = grp.groupCollapse ? grp.plusicon : grp.minusicon, gv, cp=[], len =grp.groupField.length;
|
|
pmrtl += " tree-wrap-"+$t.p.direction;
|
|
$.each($t.p.colModel, function (i,n){
|
|
var ii;
|
|
for(ii=0;ii<len;ii++) {
|
|
if(grp.groupField[ii] === n.name ) {
|
|
cp[ii] = i;
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
var toEnd = 0;
|
|
function findGroupIdx( ind , offset, grp) {
|
|
var ret = false, i;
|
|
if(offset===0) {
|
|
ret = grp[ind];
|
|
} else {
|
|
var id = grp[ind].idx;
|
|
if(id===0) {
|
|
ret = grp[ind];
|
|
} else {
|
|
for(i=ind;i >= 0; i--) {
|
|
if(grp[i].idx === id-offset) {
|
|
ret = grp[i];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
var sumreverse = $.makeArray(grp.groupSummary);
|
|
sumreverse.reverse();
|
|
|
|
$.each(grp.groups,function(i,n){
|
|
toEnd++;
|
|
clid = $t.p.id+"ghead_"+n.idx;
|
|
hid = clid+"_"+i;
|
|
icon = "<span style='cursor:pointer;' class='ui-icon "+pmrtl+"' onclick=\"jQuery('#"+$.jgrid.jqID($t.p.id)+"').jqGrid('groupingToggle','"+hid+"');return false;\"></span>";
|
|
try {
|
|
if ($.isArray(grp.formatDisplayField) && $.isFunction(grp.formatDisplayField[n.idx])) {
|
|
n.displayValue = grp.formatDisplayField[n.idx].call($t, n.displayValue, n.value, $t.p.colModel[cp[n.idx]], n.idx, grp);
|
|
gv = n.displayValue;
|
|
} else {
|
|
gv = $t.formatter(hid, n.displayValue, cp[n.idx], n.value );
|
|
}
|
|
} catch (egv) {
|
|
gv = n.displayValue;
|
|
}
|
|
str += "<tr id=\""+hid+"\"" +(grp.groupCollapse && n.idx>0 ? " style=\"display:none;\" " : " ") + "role=\"row\" class= \"ui-widget-content jqgroup ui-row-"+$t.p.direction+" "+clid+"\"><td style=\"padding-left:"+(n.idx * 12) + "px;"+"\" colspan=\""+colspans+"\">"+icon+$.jgrid.template(grp.groupText[n.idx], gv, n.cnt, n.summary)+"</td></tr>";
|
|
var leaf = len-1 === n.idx;
|
|
if( leaf ) {
|
|
var gg = grp.groups[i+1], k, kk, ik;
|
|
var end = gg !== undefined ? grp.groups[i+1].startRow : grdata.length;
|
|
for(kk=n.startRow;kk<end;kk++) {
|
|
str += grdata[kk].join('');
|
|
}
|
|
var jj;
|
|
if (gg !== undefined) {
|
|
for (jj = 0; jj < grp.groupField.length; jj++) {
|
|
if (gg.dataIndex === grp.groupField[jj]) {
|
|
break;
|
|
}
|
|
}
|
|
toEnd = grp.groupField.length - jj;
|
|
}
|
|
for (ik = 0; ik < toEnd; ik++) {
|
|
if(!sumreverse[ik]) { continue; }
|
|
var hhdr = "";
|
|
if(grp.groupCollapse && !grp.showSummaryOnHide) {
|
|
hhdr = " style=\"display:none;\"";
|
|
}
|
|
str += "<tr"+hhdr+" jqfootlevel=\""+(n.idx-ik)+"\" role=\"row\" class=\"ui-widget-content jqfoot ui-row-"+$t.p.direction+"\">";
|
|
var fdata = findGroupIdx(i, ik, grp.groups),
|
|
cm = $t.p.colModel,
|
|
vv, grlen = fdata.cnt;
|
|
for(k=0; k<colspans;k++) {
|
|
var tmpdata = "<td "+$t.formatCol(k,1,'')+"> </td>",
|
|
tplfld = "{0}";
|
|
$.each(fdata.summary,function(){
|
|
if(this.nm === cm[k].name) {
|
|
if(cm[k].summaryTpl) {
|
|
tplfld = cm[k].summaryTpl;
|
|
}
|
|
if(typeof this.st === 'string' && this.st.toLowerCase() === 'avg') {
|
|
if(this.sd && this.vd) {
|
|
this.v = (this.v/this.vd);
|
|
} else if(this.v && grlen > 0) {
|
|
this.v = (this.v/grlen);
|
|
}
|
|
}
|
|
try {
|
|
vv = $t.formatter('', this.v, k, this);
|
|
} catch (ef) {
|
|
vv = this.v;
|
|
}
|
|
tmpdata= "<td "+$t.formatCol(k,1,'')+">"+$.jgrid.format(tplfld,vv)+ "</td>";
|
|
return false;
|
|
}
|
|
});
|
|
str += tmpdata;
|
|
}
|
|
str += "</tr>";
|
|
}
|
|
toEnd = jj;
|
|
}
|
|
});
|
|
$("#"+$.jgrid.jqID($t.p.id)+" tbody:first").append(str);
|
|
// free up memory
|
|
str = null;
|
|
});
|
|
},
|
|
groupingGroupBy : function (name, options ) {
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if(typeof name === "string") {
|
|
name = [name];
|
|
}
|
|
var grp = $t.p.groupingView;
|
|
$t.p.grouping = true;
|
|
|
|
//Set default, in case visibilityOnNextGrouping is undefined
|
|
if (grp.visibiltyOnNextGrouping === undefined) {
|
|
grp.visibiltyOnNextGrouping = [];
|
|
}
|
|
var i;
|
|
// show previous hidden groups if they are hidden and weren't removed yet
|
|
for(i=0;i<grp.groupField.length;i++) {
|
|
if(!grp.groupColumnShow[i] && grp.visibiltyOnNextGrouping[i]) {
|
|
$($t).jqGrid('showCol',grp.groupField[i]);
|
|
}
|
|
}
|
|
// set visibility status of current group columns on next grouping
|
|
for(i=0;i<name.length;i++) {
|
|
grp.visibiltyOnNextGrouping[i] = $("#"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(name[i])).is(":visible");
|
|
}
|
|
$t.p.groupingView = $.extend($t.p.groupingView, options || {});
|
|
grp.groupField = name;
|
|
$($t).trigger("reloadGrid");
|
|
});
|
|
},
|
|
groupingRemove : function (current) {
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if(current === undefined) {
|
|
current = true;
|
|
}
|
|
$t.p.grouping = false;
|
|
if(current===true) {
|
|
var grp = $t.p.groupingView, i;
|
|
// show previous hidden groups if they are hidden and weren't removed yet
|
|
for(i=0;i<grp.groupField.length;i++) {
|
|
if (!grp.groupColumnShow[i] && grp.visibiltyOnNextGrouping[i]) {
|
|
$($t).jqGrid('showCol', grp.groupField);
|
|
}
|
|
}
|
|
$("tr.jqgroup, tr.jqfoot","#"+$.jgrid.jqID($t.p.id)+" tbody:first").remove();
|
|
$("tr.jqgrow:hidden","#"+$.jgrid.jqID($t.p.id)+" tbody:first").show();
|
|
} else {
|
|
$($t).trigger("reloadGrid");
|
|
}
|
|
});
|
|
},
|
|
groupingCalculations : {
|
|
handler: function(fn, v, field, round, roundType, rc) {
|
|
var funcs = {
|
|
sum: function() {
|
|
return parseFloat(v||0) + parseFloat((rc[field]||0));
|
|
},
|
|
|
|
min: function() {
|
|
if(v==="") {
|
|
return parseFloat(rc[field]||0);
|
|
}
|
|
return Math.min(parseFloat(v),parseFloat(rc[field]||0));
|
|
},
|
|
|
|
max: function() {
|
|
if(v==="") {
|
|
return parseFloat(rc[field]||0);
|
|
}
|
|
return Math.max(parseFloat(v),parseFloat(rc[field]||0));
|
|
},
|
|
|
|
count: function() {
|
|
if(v==="") {v=0;}
|
|
if(rc.hasOwnProperty(field)) {
|
|
return v+1;
|
|
}
|
|
return 0;
|
|
},
|
|
|
|
avg: function() {
|
|
// the same as sum, but at end we divide it
|
|
// so use sum instead of duplicating the code (?)
|
|
return funcs.sum();
|
|
}
|
|
};
|
|
|
|
if(!funcs[fn]) {
|
|
throw ("jqGrid Grouping No such method: " + fn);
|
|
}
|
|
var res = funcs[fn]();
|
|
|
|
if (round != null) {
|
|
if (roundType === 'fixed') {
|
|
res = res.toFixed(round);
|
|
} else {
|
|
var mul = Math.pow(10, round);
|
|
res = Math.round(res * mul) / mul;
|
|
}
|
|
}
|
|
|
|
return res;
|
|
}
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*jshint eqeqeq:false, eqnull:true, devel:true */
|
|
/*global jQuery, xmlJsonClass */
|
|
(function($){
|
|
/*
|
|
* jqGrid extension for constructing Grid Data from external file
|
|
* Tony Tomov tony@trirand.com
|
|
* http://trirand.com/blog/
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
**/
|
|
|
|
"use strict";
|
|
$.jgrid.extend({
|
|
jqGridImport : function(o) {
|
|
o = $.extend({
|
|
imptype : "xml", // xml, json, xmlstring, jsonstring
|
|
impstring: "",
|
|
impurl: "",
|
|
mtype: "GET",
|
|
impData : {},
|
|
xmlGrid :{
|
|
config : "roots>grid",
|
|
data: "roots>rows"
|
|
},
|
|
jsonGrid :{
|
|
config : "grid",
|
|
data: "data"
|
|
},
|
|
ajaxOptions :{}
|
|
}, o || {});
|
|
return this.each(function(){
|
|
var $t = this;
|
|
var xmlConvert = function (xml,o) {
|
|
var cnfg = $(o.xmlGrid.config,xml)[0];
|
|
var xmldata = $(o.xmlGrid.data,xml)[0], jstr, jstr1, key;
|
|
if(xmlJsonClass.xml2json && $.jgrid.parse) {
|
|
jstr = xmlJsonClass.xml2json(cnfg," ");
|
|
jstr = $.jgrid.parse(jstr);
|
|
for(key in jstr) {
|
|
if(jstr.hasOwnProperty(key)) {
|
|
jstr1=jstr[key];
|
|
}
|
|
}
|
|
if(xmldata) {
|
|
// save the datatype
|
|
var svdatatype = jstr.grid.datatype;
|
|
jstr.grid.datatype = 'xmlstring';
|
|
jstr.grid.datastr = xml;
|
|
$($t).jqGrid( jstr1 ).jqGrid("setGridParam",{datatype:svdatatype});
|
|
} else {
|
|
$($t).jqGrid( jstr1 );
|
|
}
|
|
jstr = null;jstr1=null;
|
|
} else {
|
|
alert("xml2json or parse are not present");
|
|
}
|
|
};
|
|
var jsonConvert = function (jsonstr,o){
|
|
if (jsonstr && typeof jsonstr === 'string') {
|
|
var _jsonparse = false;
|
|
if($.jgrid.useJSON) {
|
|
$.jgrid.useJSON = false;
|
|
_jsonparse = true;
|
|
}
|
|
var json = $.jgrid.parse(jsonstr);
|
|
if(_jsonparse) { $.jgrid.useJSON = true; }
|
|
var gprm = json[o.jsonGrid.config];
|
|
var jdata = json[o.jsonGrid.data];
|
|
if(jdata) {
|
|
var svdatatype = gprm.datatype;
|
|
gprm.datatype = 'jsonstring';
|
|
gprm.datastr = jdata;
|
|
$($t).jqGrid( gprm ).jqGrid("setGridParam",{datatype:svdatatype});
|
|
} else {
|
|
$($t).jqGrid( gprm );
|
|
}
|
|
}
|
|
};
|
|
switch (o.imptype){
|
|
case 'xml':
|
|
$.ajax($.extend({
|
|
url:o.impurl,
|
|
type:o.mtype,
|
|
data: o.impData,
|
|
dataType:"xml",
|
|
complete: function(xml,stat) {
|
|
if(stat === 'success') {
|
|
xmlConvert(xml.responseXML,o);
|
|
$($t).triggerHandler("jqGridImportComplete", [xml, o]);
|
|
if($.isFunction(o.importComplete)) {
|
|
o.importComplete(xml);
|
|
}
|
|
}
|
|
xml=null;
|
|
}
|
|
}, o.ajaxOptions));
|
|
break;
|
|
case 'xmlstring' :
|
|
// we need to make just the conversion and use the same code as xml
|
|
if(o.impstring && typeof o.impstring === 'string') {
|
|
var xmld = $.parseXML(o.impstring);
|
|
if(xmld) {
|
|
xmlConvert(xmld,o);
|
|
$($t).triggerHandler("jqGridImportComplete", [xmld, o]);
|
|
if($.isFunction(o.importComplete)) {
|
|
o.importComplete(xmld);
|
|
}
|
|
o.impstring = null;
|
|
}
|
|
xmld = null;
|
|
}
|
|
break;
|
|
case 'json':
|
|
$.ajax($.extend({
|
|
url:o.impurl,
|
|
type:o.mtype,
|
|
data: o.impData,
|
|
dataType:"json",
|
|
complete: function(json) {
|
|
try {
|
|
jsonConvert(json.responseText,o );
|
|
$($t).triggerHandler("jqGridImportComplete", [json, o]);
|
|
if($.isFunction(o.importComplete)) {
|
|
o.importComplete(json);
|
|
}
|
|
} catch (ee){}
|
|
json=null;
|
|
}
|
|
}, o.ajaxOptions ));
|
|
break;
|
|
case 'jsonstring' :
|
|
if(o.impstring && typeof o.impstring === 'string') {
|
|
jsonConvert(o.impstring,o );
|
|
$($t).triggerHandler("jqGridImportComplete", [o.impstring, o]);
|
|
if($.isFunction(o.importComplete)) {
|
|
o.importComplete(o.impstring);
|
|
}
|
|
o.impstring = null;
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
},
|
|
jqGridExport : function(o) {
|
|
o = $.extend({
|
|
exptype : "xmlstring",
|
|
root: "grid",
|
|
ident: "\t"
|
|
}, o || {});
|
|
var ret = null;
|
|
this.each(function () {
|
|
if(!this.grid) { return;}
|
|
var key, gprm = $.extend(true, {},$(this).jqGrid("getGridParam"));
|
|
// we need to check for:
|
|
// 1.multiselect, 2.subgrid 3. treegrid and remove the unneded columns from colNames
|
|
if(gprm.rownumbers) {
|
|
gprm.colNames.splice(0,1);
|
|
gprm.colModel.splice(0,1);
|
|
}
|
|
if(gprm.multiselect) {
|
|
gprm.colNames.splice(0,1);
|
|
gprm.colModel.splice(0,1);
|
|
}
|
|
if(gprm.subGrid) {
|
|
gprm.colNames.splice(0,1);
|
|
gprm.colModel.splice(0,1);
|
|
}
|
|
gprm.knv = null;
|
|
if(gprm.treeGrid) {
|
|
for (key in gprm.treeReader) {
|
|
if(gprm.treeReader.hasOwnProperty(key)) {
|
|
gprm.colNames.splice(gprm.colNames.length-1);
|
|
gprm.colModel.splice(gprm.colModel.length-1);
|
|
}
|
|
}
|
|
}
|
|
switch (o.exptype) {
|
|
case 'xmlstring' :
|
|
ret = "<"+o.root+">"+xmlJsonClass.json2xml(gprm,o.ident)+"</"+o.root+">";
|
|
break;
|
|
case 'jsonstring' :
|
|
ret = "{"+ xmlJsonClass.toJson(gprm,o.root,o.ident,false)+"}";
|
|
if(gprm.postData.filters !== undefined) {
|
|
ret=ret.replace(/filters":"/,'filters":');
|
|
ret=ret.replace(/}]}"/,'}]}');
|
|
}
|
|
break;
|
|
}
|
|
});
|
|
return ret;
|
|
},
|
|
excelExport : function(o) {
|
|
o = $.extend({
|
|
exptype : "remote",
|
|
url : null,
|
|
oper: "oper",
|
|
tag: "excel",
|
|
exportOptions : {}
|
|
}, o || {});
|
|
return this.each(function(){
|
|
if(!this.grid) { return;}
|
|
var url;
|
|
if(o.exptype === "remote") {
|
|
var pdata = $.extend({},this.p.postData);
|
|
pdata[o.oper] = o.tag;
|
|
var params = jQuery.param(pdata);
|
|
if(o.url.indexOf("?") !== -1) { url = o.url+"&"+params; }
|
|
else { url = o.url+"?"+params; }
|
|
window.location = url;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*jshint evil:true, eqeqeq:false, eqnull:true, devel:true */
|
|
/*global jQuery */
|
|
(function($){
|
|
/*
|
|
**
|
|
* jqGrid addons using jQuery UI
|
|
* Author: Mark Williams
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
* depends on jQuery UI
|
|
**/
|
|
"use strict";
|
|
if ($.jgrid.msie && $.jgrid.msiever()===8) {
|
|
$.expr[":"].hidden = function(elem) {
|
|
return elem.offsetWidth === 0 || elem.offsetHeight === 0 ||
|
|
elem.style.display === "none";
|
|
};
|
|
}
|
|
// requiere load multiselect before grid
|
|
$.jgrid._multiselect = false;
|
|
if($.ui) {
|
|
if ($.ui.multiselect ) {
|
|
if($.ui.multiselect.prototype._setSelected) {
|
|
var setSelected = $.ui.multiselect.prototype._setSelected;
|
|
$.ui.multiselect.prototype._setSelected = function(item,selected) {
|
|
var ret = setSelected.call(this,item,selected);
|
|
if (selected && this.selectedList) {
|
|
var elt = this.element;
|
|
this.selectedList.find('li').each(function() {
|
|
if ($(this).data('optionLink')) {
|
|
$(this).data('optionLink').remove().appendTo(elt);
|
|
}
|
|
});
|
|
}
|
|
return ret;
|
|
};
|
|
}
|
|
if($.ui.multiselect.prototype.destroy) {
|
|
$.ui.multiselect.prototype.destroy = function() {
|
|
this.element.show();
|
|
this.container.remove();
|
|
if ($.Widget === undefined) {
|
|
$.widget.prototype.destroy.apply(this, arguments);
|
|
} else {
|
|
$.Widget.prototype.destroy.apply(this, arguments);
|
|
}
|
|
};
|
|
}
|
|
$.jgrid._multiselect = true;
|
|
}
|
|
}
|
|
|
|
$.jgrid.extend({
|
|
sortableColumns : function (tblrow)
|
|
{
|
|
return this.each(function (){
|
|
var ts = this, tid= $.jgrid.jqID( ts.p.id );
|
|
function start() {ts.p.disableClick = true;}
|
|
var sortable_opts = {
|
|
"tolerance" : "pointer",
|
|
"axis" : "x",
|
|
"scrollSensitivity": "1",
|
|
"items": '>th:not(:has(#jqgh_'+tid+'_cb'+',#jqgh_'+tid+'_rn'+',#jqgh_'+tid+'_subgrid),:hidden)',
|
|
"placeholder": {
|
|
element: function(item) {
|
|
var el = $(document.createElement(item[0].nodeName))
|
|
.addClass(item[0].className+" ui-sortable-placeholder ui-state-highlight")
|
|
.removeClass("ui-sortable-helper")[0];
|
|
return el;
|
|
},
|
|
update: function(self, p) {
|
|
p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10));
|
|
p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10));
|
|
}
|
|
},
|
|
"update": function(event, ui) {
|
|
var p = $(ui.item).parent(),
|
|
th = $(">th", p),
|
|
colModel = ts.p.colModel,
|
|
cmMap = {}, tid= ts.p.id+"_";
|
|
$.each(colModel, function(i) { cmMap[this.name]=i; });
|
|
var permutation = [];
|
|
th.each(function() {
|
|
var id = $(">div", this).get(0).id.replace(/^jqgh_/, "").replace(tid,"");
|
|
if (cmMap.hasOwnProperty(id)) {
|
|
permutation.push(cmMap[id]);
|
|
}
|
|
});
|
|
|
|
$(ts).jqGrid("remapColumns",permutation, true, true);
|
|
if ($.isFunction(ts.p.sortable.update)) {
|
|
ts.p.sortable.update(permutation);
|
|
}
|
|
setTimeout(function(){ts.p.disableClick=false;}, 50);
|
|
}
|
|
};
|
|
if (ts.p.sortable.options) {
|
|
$.extend(sortable_opts, ts.p.sortable.options);
|
|
} else if ($.isFunction(ts.p.sortable)) {
|
|
ts.p.sortable = { "update" : ts.p.sortable };
|
|
}
|
|
if (sortable_opts.start) {
|
|
var s = sortable_opts.start;
|
|
sortable_opts.start = function(e,ui) {
|
|
start();
|
|
s.call(this,e,ui);
|
|
};
|
|
} else {
|
|
sortable_opts.start = start;
|
|
}
|
|
if (ts.p.sortable.exclude) {
|
|
sortable_opts.items += ":not("+ts.p.sortable.exclude+")";
|
|
}
|
|
tblrow.sortable(sortable_opts).data("sortable").floating = true;
|
|
});
|
|
},
|
|
columnChooser : function(opts) {
|
|
var self = this;
|
|
if($("#colchooser_"+$.jgrid.jqID(self[0].p.id)).length ) { return; }
|
|
var selector = $('<div id="colchooser_'+self[0].p.id+'" style="position:relative;overflow:hidden"><div><select multiple="multiple"></select></div></div>');
|
|
var select = $('select', selector);
|
|
|
|
function insert(perm,i,v) {
|
|
if(i>=0){
|
|
var a = perm.slice();
|
|
var b = a.splice(i,Math.max(perm.length-i,i));
|
|
if(i>perm.length) { i = perm.length; }
|
|
a[i] = v;
|
|
return a.concat(b);
|
|
}
|
|
}
|
|
opts = $.extend({
|
|
"width" : 420,
|
|
"height" : 240,
|
|
"classname" : null,
|
|
"done" : function(perm) { if (perm) { self.jqGrid("remapColumns", perm, true); } },
|
|
/* msel is either the name of a ui widget class that
|
|
extends a multiselect, or a function that supports
|
|
creating a multiselect object (with no argument,
|
|
or when passed an object), and destroying it (when
|
|
passed the string "destroy"). */
|
|
"msel" : "multiselect",
|
|
/* "msel_opts" : {}, */
|
|
|
|
/* dlog is either the name of a ui widget class that
|
|
behaves in a dialog-like way, or a function, that
|
|
supports creating a dialog (when passed dlog_opts)
|
|
or destroying a dialog (when passed the string
|
|
"destroy")
|
|
*/
|
|
"dlog" : "dialog",
|
|
"dialog_opts" : {
|
|
"minWidth": 470
|
|
},
|
|
/* dlog_opts is either an option object to be passed
|
|
to "dlog", or (more likely) a function that creates
|
|
the options object.
|
|
The default produces a suitable options object for
|
|
ui.dialog */
|
|
"dlog_opts" : function(opts) {
|
|
var buttons = {};
|
|
buttons[opts.bSubmit] = function() {
|
|
opts.apply_perm();
|
|
opts.cleanup(false);
|
|
};
|
|
buttons[opts.bCancel] = function() {
|
|
opts.cleanup(true);
|
|
};
|
|
return $.extend(true, {
|
|
"buttons": buttons,
|
|
"close": function() {
|
|
opts.cleanup(true);
|
|
},
|
|
"modal" : opts.modal || false,
|
|
"resizable": opts.resizable || true,
|
|
"width": opts.width+20
|
|
}, opts.dialog_opts || {});
|
|
},
|
|
/* Function to get the permutation array, and pass it to the
|
|
"done" function */
|
|
"apply_perm" : function() {
|
|
$('option',select).each(function() {
|
|
if (this.selected) {
|
|
self.jqGrid("showCol", colModel[this.value].name);
|
|
} else {
|
|
self.jqGrid("hideCol", colModel[this.value].name);
|
|
}
|
|
});
|
|
|
|
var perm = [];
|
|
//fixedCols.slice(0);
|
|
$('option:selected',select).each(function() { perm.push(parseInt(this.value,10)); });
|
|
$.each(perm, function() { delete colMap[colModel[parseInt(this,10)].name]; });
|
|
$.each(colMap, function() {
|
|
var ti = parseInt(this,10);
|
|
perm = insert(perm,ti,ti);
|
|
});
|
|
if (opts.done) {
|
|
opts.done.call(self, perm);
|
|
}
|
|
},
|
|
/* Function to cleanup the dialog, and select. Also calls the
|
|
done function with no permutation (to indicate that the
|
|
columnChooser was aborted */
|
|
"cleanup" : function(calldone) {
|
|
call(opts.dlog, selector, 'destroy');
|
|
call(opts.msel, select, 'destroy');
|
|
selector.remove();
|
|
if (calldone && opts.done) {
|
|
opts.done.call(self);
|
|
}
|
|
},
|
|
"msel_opts" : {}
|
|
}, $.jgrid.col, opts || {});
|
|
if($.ui) {
|
|
if ($.ui.multiselect ) {
|
|
if(opts.msel === "multiselect") {
|
|
if(!$.jgrid._multiselect) {
|
|
// should be in language file
|
|
alert("Multiselect plugin loaded after jqGrid. Please load the plugin before the jqGrid!");
|
|
return;
|
|
}
|
|
opts.msel_opts = $.extend($.ui.multiselect.defaults,opts.msel_opts);
|
|
}
|
|
}
|
|
}
|
|
if (opts.caption) {
|
|
selector.attr("title", opts.caption);
|
|
}
|
|
if (opts.classname) {
|
|
selector.addClass(opts.classname);
|
|
select.addClass(opts.classname);
|
|
}
|
|
if (opts.width) {
|
|
$(">div",selector).css({"width": opts.width,"margin":"0 auto"});
|
|
select.css("width", opts.width);
|
|
}
|
|
if (opts.height) {
|
|
$(">div",selector).css("height", opts.height);
|
|
select.css("height", opts.height - 10);
|
|
}
|
|
var colModel = self.jqGrid("getGridParam", "colModel");
|
|
var colNames = self.jqGrid("getGridParam", "colNames");
|
|
var realColNames = new Array();
|
|
$.each(colNames, function (i) {
|
|
var index = colNames[i].indexOf("<br/>");
|
|
if (index >= 0) {
|
|
realColNames.push(colNames[i].substring(0, index));
|
|
} else {
|
|
realColNames.push(colNames[i]);
|
|
}
|
|
});
|
|
var colMap = {}, fixedCols = [];
|
|
|
|
select.empty();
|
|
$.each(colModel, function(i) {
|
|
colMap[this.name] = i;
|
|
if (this.hidedlg) {
|
|
if (!this.hidden) {
|
|
fixedCols.push(i);
|
|
}
|
|
return;
|
|
}
|
|
if (!colModel[i].optionHide) {
|
|
select.append("<option value='"+i+"' "+
|
|
(this.hidden?"":"selected='selected'")+">"+$.jgrid.stripHtml(realColNames[i])+"</option>");
|
|
}
|
|
});
|
|
function call(fn, obj) {
|
|
if (!fn) { return; }
|
|
if (typeof fn === 'string') {
|
|
if ($.fn[fn]) {
|
|
$.fn[fn].apply(obj, $.makeArray(arguments).slice(2));
|
|
}
|
|
} else if ($.isFunction(fn)) {
|
|
fn.apply(obj, $.makeArray(arguments).slice(2));
|
|
}
|
|
}
|
|
|
|
var dopts = $.isFunction(opts.dlog_opts) ? opts.dlog_opts.call(self, opts) : opts.dlog_opts;
|
|
call(opts.dlog, selector, dopts);
|
|
var mopts = $.isFunction(opts.msel_opts) ? opts.msel_opts.call(self, opts) : opts.msel_opts;
|
|
call(opts.msel, select, mopts);
|
|
},
|
|
sortableRows : function (opts) {
|
|
// Can accept all sortable options and events
|
|
return this.each(function(){
|
|
var $t = this;
|
|
if(!$t.grid) { return; }
|
|
// Currently we disable a treeGrid sortable
|
|
if($t.p.treeGrid) { return; }
|
|
if($.fn.sortable) {
|
|
opts = $.extend({
|
|
"cursor":"move",
|
|
"axis" : "y",
|
|
"items": ".jqgrow"
|
|
},
|
|
opts || {});
|
|
if(opts.start && $.isFunction(opts.start)) {
|
|
opts._start_ = opts.start;
|
|
delete opts.start;
|
|
} else {opts._start_=false;}
|
|
if(opts.update && $.isFunction(opts.update)) {
|
|
opts._update_ = opts.update;
|
|
delete opts.update;
|
|
} else {opts._update_ = false;}
|
|
opts.start = function(ev,ui) {
|
|
$(ui.item).css("border-width","0px");
|
|
$("td",ui.item).each(function(i){
|
|
this.style.width = $t.grid.cols[i].style.width;
|
|
});
|
|
if($t.p.subGrid) {
|
|
var subgid = $(ui.item).attr("id");
|
|
try {
|
|
$($t).jqGrid('collapseSubGridRow',subgid);
|
|
} catch (e) {}
|
|
}
|
|
if(opts._start_) {
|
|
opts._start_.apply(this,[ev,ui]);
|
|
}
|
|
};
|
|
opts.update = function (ev,ui) {
|
|
$(ui.item).css("border-width","");
|
|
if($t.p.rownumbers === true) {
|
|
$("td.jqgrid-rownum",$t.rows).each(function( i ){
|
|
$(this).html( i+1+(parseInt($t.p.page,10)-1)*parseInt($t.p.rowNum,10) );
|
|
});
|
|
}
|
|
if(opts._update_) {
|
|
opts._update_.apply(this,[ev,ui]);
|
|
}
|
|
};
|
|
$("tbody:first",$t).sortable(opts);
|
|
$("tbody:first",$t).disableSelection();
|
|
}
|
|
});
|
|
},
|
|
gridDnD : function(opts) {
|
|
return this.each(function(){
|
|
var $t = this, i, cn;
|
|
if(!$t.grid) { return; }
|
|
// Currently we disable a treeGrid drag and drop
|
|
if($t.p.treeGrid) { return; }
|
|
if(!$.fn.draggable || !$.fn.droppable) { return; }
|
|
function updateDnD ()
|
|
{
|
|
var datadnd = $.data($t,"dnd");
|
|
$("tr.jqgrow:not(.ui-draggable)",$t).draggable($.isFunction(datadnd.drag) ? datadnd.drag.call($($t),datadnd) : datadnd.drag);
|
|
}
|
|
var appender = "<table id='jqgrid_dnd' class='ui-jqgrid-dnd'></table>";
|
|
if($("#jqgrid_dnd")[0] === undefined) {
|
|
$('body').append(appender);
|
|
}
|
|
|
|
if(typeof opts === 'string' && opts === 'updateDnD' && $t.p.jqgdnd===true) {
|
|
updateDnD();
|
|
return;
|
|
}
|
|
opts = $.extend({
|
|
"drag" : function (opts) {
|
|
return $.extend({
|
|
start : function (ev, ui) {
|
|
var i, subgid;
|
|
// if we are in subgrid mode try to collapse the node
|
|
if($t.p.subGrid) {
|
|
subgid = $(ui.helper).attr("id");
|
|
try {
|
|
$($t).jqGrid('collapseSubGridRow',subgid);
|
|
} catch (e) {}
|
|
}
|
|
// hack
|
|
// drag and drop does not insert tr in table, when the table has no rows
|
|
// we try to insert new empty row on the target(s)
|
|
for (i=0;i<$.data($t,"dnd").connectWith.length;i++){
|
|
if($($.data($t,"dnd").connectWith[i]).jqGrid('getGridParam','reccount') === 0 ){
|
|
$($.data($t,"dnd").connectWith[i]).jqGrid('addRowData','jqg_empty_row',{});
|
|
}
|
|
}
|
|
ui.helper.addClass("ui-state-highlight");
|
|
$("td",ui.helper).each(function(i) {
|
|
this.style.width = $t.grid.headers[i].width+"px";
|
|
});
|
|
if(opts.onstart && $.isFunction(opts.onstart) ) { opts.onstart.call($($t),ev,ui); }
|
|
},
|
|
stop :function(ev,ui) {
|
|
var i, ids;
|
|
if(ui.helper.dropped && !opts.dragcopy) {
|
|
ids = $(ui.helper).attr("id");
|
|
if(ids === undefined) { ids = $(this).attr("id"); }
|
|
$($t).jqGrid('delRowData',ids );
|
|
}
|
|
// if we have a empty row inserted from start event try to delete it
|
|
for (i=0;i<$.data($t,"dnd").connectWith.length;i++){
|
|
$($.data($t,"dnd").connectWith[i]).jqGrid('delRowData','jqg_empty_row');
|
|
}
|
|
if(opts.onstop && $.isFunction(opts.onstop) ) { opts.onstop.call($($t),ev,ui); }
|
|
}
|
|
},opts.drag_opts || {});
|
|
},
|
|
"drop" : function (opts) {
|
|
return $.extend({
|
|
accept: function(d) {
|
|
if (!$(d).hasClass('jqgrow')) { return d;}
|
|
var tid = $(d).closest("table.ui-jqgrid-btable");
|
|
if(tid.length > 0 && $.data(tid[0],"dnd") !== undefined) {
|
|
var cn = $.data(tid[0],"dnd").connectWith;
|
|
return $.inArray('#'+$.jgrid.jqID(this.id),cn) !== -1 ? true : false;
|
|
}
|
|
return false;
|
|
},
|
|
drop: function(ev, ui) {
|
|
if (!$(ui.draggable).hasClass('jqgrow')) { return; }
|
|
var accept = $(ui.draggable).attr("id");
|
|
var getdata = ui.draggable.parent().parent().jqGrid('getRowData',accept);
|
|
if(!opts.dropbyname) {
|
|
var j =0, tmpdata = {}, nm, key;
|
|
var dropmodel = $("#"+$.jgrid.jqID(this.id)).jqGrid('getGridParam','colModel');
|
|
try {
|
|
for (key in getdata) {
|
|
if (getdata.hasOwnProperty(key)) {
|
|
nm = dropmodel[j].name;
|
|
if( !(nm === 'cb' || nm === 'rn' || nm === 'subgrid' )) {
|
|
if(getdata.hasOwnProperty(key) && dropmodel[j]) {
|
|
tmpdata[nm] = getdata[key];
|
|
}
|
|
}
|
|
j++;
|
|
}
|
|
}
|
|
getdata = tmpdata;
|
|
} catch (e) {}
|
|
}
|
|
ui.helper.dropped = true;
|
|
if(opts.beforedrop && $.isFunction(opts.beforedrop) ) {
|
|
//parameters to this callback - event, element, data to be inserted, sender, reciever
|
|
// should return object which will be inserted into the reciever
|
|
var datatoinsert = opts.beforedrop.call(this,ev,ui,getdata,$('#'+$.jgrid.jqID($t.p.id)),$(this));
|
|
if (datatoinsert !== undefined && datatoinsert !== null && typeof datatoinsert === "object") { getdata = datatoinsert; }
|
|
}
|
|
if(ui.helper.dropped) {
|
|
var grid;
|
|
if(opts.autoid) {
|
|
if($.isFunction(opts.autoid)) {
|
|
grid = opts.autoid.call(this,getdata);
|
|
} else {
|
|
grid = Math.ceil(Math.random()*1000);
|
|
grid = opts.autoidprefix+grid;
|
|
}
|
|
}
|
|
// NULL is interpreted as undefined while null as object
|
|
$("#"+$.jgrid.jqID(this.id)).jqGrid('addRowData',grid,getdata,opts.droppos);
|
|
}
|
|
if(opts.ondrop && $.isFunction(opts.ondrop) ) { opts.ondrop.call(this,ev,ui, getdata); }
|
|
}}, opts.drop_opts || {});
|
|
},
|
|
"onstart" : null,
|
|
"onstop" : null,
|
|
"beforedrop": null,
|
|
"ondrop" : null,
|
|
"drop_opts" : {
|
|
"activeClass": "ui-state-active",
|
|
"hoverClass": "ui-state-hover"
|
|
},
|
|
"drag_opts" : {
|
|
"revert": "invalid",
|
|
"helper": "clone",
|
|
"cursor": "move",
|
|
"appendTo" : "#jqgrid_dnd",
|
|
"zIndex": 5000
|
|
},
|
|
"dragcopy": false,
|
|
"dropbyname" : false,
|
|
"droppos" : "first",
|
|
"autoid" : true,
|
|
"autoidprefix" : "dnd_"
|
|
}, opts || {});
|
|
|
|
if(!opts.connectWith) { return; }
|
|
opts.connectWith = opts.connectWith.split(",");
|
|
opts.connectWith = $.map(opts.connectWith,function(n){return $.trim(n);});
|
|
$.data($t,"dnd",opts);
|
|
|
|
if($t.p.reccount !== 0 && !$t.p.jqgdnd) {
|
|
updateDnD();
|
|
}
|
|
$t.p.jqgdnd = true;
|
|
for (i=0;i<opts.connectWith.length;i++){
|
|
cn =opts.connectWith[i];
|
|
$(cn).droppable($.isFunction(opts.drop) ? opts.drop.call($($t),opts) : opts.drop);
|
|
}
|
|
});
|
|
},
|
|
gridResize : function(opts) {
|
|
return this.each(function(){
|
|
var $t = this, gID = $.jgrid.jqID($t.p.id);
|
|
if(!$t.grid || !$.fn.resizable) { return; }
|
|
opts = $.extend({}, opts || {});
|
|
if(opts.alsoResize ) {
|
|
opts._alsoResize_ = opts.alsoResize;
|
|
delete opts.alsoResize;
|
|
} else {
|
|
opts._alsoResize_ = false;
|
|
}
|
|
if(opts.stop && $.isFunction(opts.stop)) {
|
|
opts._stop_ = opts.stop;
|
|
delete opts.stop;
|
|
} else {
|
|
opts._stop_ = false;
|
|
}
|
|
opts.stop = function (ev, ui) {
|
|
$($t).jqGrid('setGridParam',{height:$("#gview_"+gID+" .ui-jqgrid-bdiv").height()});
|
|
$($t).jqGrid('setGridWidth',ui.size.width,opts.shrinkToFit);
|
|
if(opts._stop_) { opts._stop_.call($t,ev,ui); }
|
|
};
|
|
if(opts._alsoResize_) {
|
|
var optstest = "{\'#gview_"+gID+" .ui-jqgrid-bdiv\':true,'" +opts._alsoResize_+"':true}";
|
|
opts.alsoResize = eval('('+optstest+')'); // the only way that I found to do this
|
|
} else {
|
|
opts.alsoResize = $(".ui-jqgrid-bdiv","#gview_"+gID);
|
|
}
|
|
delete opts._alsoResize_;
|
|
$("#gbox_"+gID).resizable(opts);
|
|
});
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*
|
|
Transform a table to a jqGrid.
|
|
Peter Romianowski <peter.romianowski@optivo.de>
|
|
If the first column of the table contains checkboxes or
|
|
radiobuttons then the jqGrid is made selectable.
|
|
*/
|
|
// Addition - selector can be a class or id
|
|
function tableToGrid(selector, options) {
|
|
jQuery(selector).each(function() {
|
|
if(this.grid) {return;} //Adedd from Tony Tomov
|
|
// This is a small "hack" to make the width of the jqGrid 100%
|
|
jQuery(this).width("99%");
|
|
var w = jQuery(this).width();
|
|
|
|
// Text whether we have single or multi select
|
|
var inputCheckbox = jQuery('tr td:first-child input[type=checkbox]:first', jQuery(this));
|
|
var inputRadio = jQuery('tr td:first-child input[type=radio]:first', jQuery(this));
|
|
var selectMultiple = inputCheckbox.length > 0;
|
|
var selectSingle = !selectMultiple && inputRadio.length > 0;
|
|
var selectable = selectMultiple || selectSingle;
|
|
//var inputName = inputCheckbox.attr("name") || inputRadio.attr("name");
|
|
|
|
// Build up the columnModel and the data
|
|
var colModel = [];
|
|
var colNames = [];
|
|
jQuery('th', jQuery(this)).each(function() {
|
|
if (colModel.length === 0 && selectable) {
|
|
colModel.push({
|
|
name: '__selection__',
|
|
index: '__selection__',
|
|
width: 0,
|
|
hidden: true
|
|
});
|
|
colNames.push('__selection__');
|
|
} else {
|
|
colModel.push({
|
|
name: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
|
|
index: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
|
|
width: jQuery(this).width() || 150
|
|
});
|
|
colNames.push(jQuery(this).html());
|
|
}
|
|
});
|
|
var data = [];
|
|
var rowIds = [];
|
|
var rowChecked = [];
|
|
jQuery('tbody > tr', jQuery(this)).each(function() {
|
|
var row = {};
|
|
var rowPos = 0;
|
|
jQuery('td', jQuery(this)).each(function() {
|
|
if (rowPos === 0 && selectable) {
|
|
var input = jQuery('input', jQuery(this));
|
|
var rowId = input.attr("value");
|
|
rowIds.push(rowId || data.length);
|
|
if (input.is(":checked")) {
|
|
rowChecked.push(rowId);
|
|
}
|
|
row[colModel[rowPos].name] = input.attr("value");
|
|
} else {
|
|
row[colModel[rowPos].name] = jQuery(this).html();
|
|
}
|
|
rowPos++;
|
|
});
|
|
if(rowPos >0) { data.push(row); }
|
|
});
|
|
|
|
// Clear the original HTML table
|
|
jQuery(this).empty();
|
|
|
|
// Mark it as jqGrid
|
|
jQuery(this).addClass("scroll");
|
|
|
|
jQuery(this).jqGrid(jQuery.extend({
|
|
datatype: "local",
|
|
width: w,
|
|
colNames: colNames,
|
|
colModel: colModel,
|
|
multiselect: selectMultiple
|
|
//inputName: inputName,
|
|
//inputValueCol: imputName != null ? "__selection__" : null
|
|
}, options || {}));
|
|
|
|
// Add data
|
|
var a;
|
|
for (a = 0; a < data.length; a++) {
|
|
var id = null;
|
|
if (rowIds.length > 0) {
|
|
id = rowIds[a];
|
|
if (id && id.replace) {
|
|
// We have to do this since the value of a checkbox
|
|
// or radio button can be anything
|
|
id = encodeURIComponent(id).replace(/[.\-%]/g, "_");
|
|
}
|
|
}
|
|
if (id === null) {
|
|
id = a + 1;
|
|
}
|
|
jQuery(this).jqGrid("addRowData",id, data[a]);
|
|
}
|
|
|
|
// Set the selection
|
|
for (a = 0; a < rowChecked.length; a++) {
|
|
jQuery(this).jqGrid("setSelection",rowChecked[a]);
|
|
}
|
|
});
|
|
};
|
|
|
|
;(function($){
|
|
/**
|
|
* jqGrid extension
|
|
* Paul Tiseo ptiseo@wasteconsultants.com
|
|
*
|
|
* Dual licensed under the MIT and GPL licenses:
|
|
* http://www.opensource.org/licenses/mit-license.php
|
|
* http://www.gnu.org/licenses/gpl-2.0.html
|
|
**/
|
|
$.jgrid.extend({
|
|
getPostData : function(){
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
return $t.p.postData;
|
|
},
|
|
setPostData : function( newdata ) {
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
// check if newdata is correct type
|
|
if ( typeof(newdata) === 'object' ) {
|
|
$t.p.postData = newdata;
|
|
}
|
|
else {
|
|
alert("Error: cannot add a non-object postData value. postData unchanged.");
|
|
}
|
|
},
|
|
appendPostData : function( newdata ) {
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
// check if newdata is correct type
|
|
if ( typeof(newdata) === 'object' ) {
|
|
$.extend($t.p.postData, newdata);
|
|
}
|
|
else {
|
|
alert("Error: cannot append a non-object postData value. postData unchanged.");
|
|
}
|
|
},
|
|
setPostDataItem : function( key, val ) {
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
$t.p.postData[key] = val;
|
|
},
|
|
getPostDataItem : function( key ) {
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
return $t.p.postData[key];
|
|
},
|
|
removePostDataItem : function( key ) {
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
delete $t.p.postData[key];
|
|
},
|
|
getUserData : function(){
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
return $t.p.userData;
|
|
},
|
|
getUserDataItem : function( key ) {
|
|
var $t = this[0];
|
|
if(!$t.grid) { return; }
|
|
return $t.p.userData[key];
|
|
}
|
|
});
|
|
})(jQuery);
|
|
/*!
|
|
* jquery-confirm v3.3.4 (http://craftpip.github.io/jquery-confirm/)
|
|
* Author: Boniface Pereira
|
|
* Website: www.craftpip.com
|
|
* Contact: hey@craftpip.com
|
|
*
|
|
* Copyright 2013-2019 jquery-confirm
|
|
* Licensed under MIT (https://github.com/craftpip/jquery-confirm/blob/master/LICENSE)
|
|
*/
|
|
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory);}else{if(typeof module==="object"&&module.exports){module.exports=function(root,jQuery){if(jQuery===undefined){if(typeof window!=="undefined"){jQuery=require("jquery");}else{jQuery=require("jquery")(root);}}factory(jQuery);return jQuery;};}else{factory(jQuery);}}}(function($){var w=window;$.fn.confirm=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false};}$(this).each(function(){var $this=$(this);if($this.attr("jc-attached")){console.warn("jConfirm has already been attached to this element ",$this[0]);return;}$this.on("click",function(e){e.preventDefault();var jcOption=$.extend({},options);if($this.attr("data-title")){jcOption.title=$this.attr("data-title");}if($this.attr("data-content")){jcOption.content=$this.attr("data-content");}if(typeof jcOption.buttons==="undefined"){jcOption.buttons={};}jcOption["$target"]=$this;if($this.attr("href")&&Object.keys(jcOption.buttons).length===0){var buttons=$.extend(true,{},w.jconfirm.pluginDefaults.defaultButtons,(w.jconfirm.defaults||{}).defaultButtons||{});var firstBtn=Object.keys(buttons)[0];jcOption.buttons=buttons;jcOption.buttons[firstBtn].action=function(){location.href=$this.attr("href");};}jcOption.closeIcon=false;var instance=$.confirm(jcOption);});$this.attr("jc-attached",true);});return $(this);};$.confirm=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false};}var putDefaultButtons=!(options.buttons===false);if(typeof options.buttons!=="object"){options.buttons={};}if(Object.keys(options.buttons).length===0&&putDefaultButtons){var buttons=$.extend(true,{},w.jconfirm.pluginDefaults.defaultButtons,(w.jconfirm.defaults||{}).defaultButtons||{});options.buttons=buttons;}return w.jconfirm(options);};$.alert=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false};}var putDefaultButtons=!(options.buttons===false);if(typeof options.buttons!=="object"){options.buttons={};}if(Object.keys(options.buttons).length===0&&putDefaultButtons){var buttons=$.extend(true,{},w.jconfirm.pluginDefaults.defaultButtons,(w.jconfirm.defaults||{}).defaultButtons||{});var firstBtn=Object.keys(buttons)[0];options.buttons[firstBtn]=buttons[firstBtn];}return w.jconfirm(options);};$.dialog=function(options,option2){if(typeof options==="undefined"){options={};}if(typeof options==="string"){options={content:options,title:(option2)?option2:false,closeIcon:function(){}};}options.buttons={};if(typeof options.closeIcon==="undefined"){options.closeIcon=function(){};}options.confirmKeys=[13];return w.jconfirm(options);};w.jconfirm=function(options){if(typeof options==="undefined"){options={};}var pluginOptions=$.extend(true,{},w.jconfirm.pluginDefaults);if(w.jconfirm.defaults){pluginOptions=$.extend(true,pluginOptions,w.jconfirm.defaults);}pluginOptions=$.extend(true,{},pluginOptions,options);var instance=new w.Jconfirm(pluginOptions);w.jconfirm.instances.push(instance);return instance;};w.Jconfirm=function(options){$.extend(this,options);this._init();};w.Jconfirm.prototype={_init:function(){var that=this;if(!w.jconfirm.instances.length){w.jconfirm.lastFocused=$("body").find(":focus");}this._id=Math.round(Math.random()*99999);this.contentParsed=$(document.createElement("div"));if(!this.lazyOpen){setTimeout(function(){that.open();},0);}},_buildHTML:function(){var that=this;this._parseAnimation(this.animation,"o");this._parseAnimation(this.closeAnimation,"c");this._parseBgDismissAnimation(this.backgroundDismissAnimation);this._parseColumnClass(this.columnClass);this._parseTheme(this.theme);this._parseType(this.type);var template=$(this.template);template.find(".jconfirm-box").addClass(this.animationParsed).addClass(this.backgroundDismissAnimationParsed).addClass(this.typeParsed);if(this.typeAnimated){template.find(".jconfirm-box").addClass("jconfirm-type-animated");}if(this.useBootstrap){template.find(".jc-bs3-row").addClass(this.bootstrapClasses.row);template.find(".jc-bs3-row").addClass("justify-content-md-center justify-content-sm-center justify-content-xs-center justify-content-lg-center");template.find(".jconfirm-box-container").addClass(this.columnClassParsed);if(this.containerFluid){template.find(".jc-bs3-container").addClass(this.bootstrapClasses.containerFluid);}else{template.find(".jc-bs3-container").addClass(this.bootstrapClasses.container);}}else{template.find(".jconfirm-box").css("width",this.boxWidth);}if(this.titleClass){template.find(".jconfirm-title-c").addClass(this.titleClass);}template.addClass(this.themeParsed);var ariaLabel="jconfirm-box"+this._id;template.find(".jconfirm-box").attr("aria-labelledby",ariaLabel).attr("tabindex",-1);template.find(".jconfirm-content").attr("id",ariaLabel);if(this.bgOpacity!==null){template.find(".jconfirm-bg").css("opacity",this.bgOpacity);}if(this.rtl){template.addClass("jconfirm-rtl");}this.$el=template.appendTo(this.container);this.$jconfirmBoxContainer=this.$el.find(".jconfirm-box-container");this.$jconfirmBox=this.$body=this.$el.find(".jconfirm-box");this.$jconfirmBg=this.$el.find(".jconfirm-bg");this.$title=this.$el.find(".jconfirm-title");this.$titleContainer=this.$el.find(".jconfirm-title-c");this.$content=this.$el.find("div.jconfirm-content");this.$contentPane=this.$el.find(".jconfirm-content-pane");this.$icon=this.$el.find(".jconfirm-icon-c");this.$closeIcon=this.$el.find(".jconfirm-closeIcon");this.$holder=this.$el.find(".jconfirm-holder");this.$btnc=this.$el.find(".jconfirm-buttons");this.$scrollPane=this.$el.find(".jconfirm-scrollpane");that.setStartingPoint();this._contentReady=$.Deferred();this._modalReady=$.Deferred();this.$holder.css({"padding-top":this.offsetTop,"padding-bottom":this.offsetBottom,});this.setTitle();this.setIcon();this._setButtons();this._parseContent();this.initDraggable();if(this.isAjax){this.showLoading(false);}$.when(this._contentReady,this._modalReady).then(function(){if(that.isAjaxLoading){setTimeout(function(){that.isAjaxLoading=false;that.setContent();that.setTitle();that.setIcon();setTimeout(function(){that.hideLoading(false);that._updateContentMaxHeight();},100);if(typeof that.onContentReady==="function"){that.onContentReady();}},50);}else{that._updateContentMaxHeight();that.setTitle();that.setIcon();if(typeof that.onContentReady==="function"){that.onContentReady();}}if(that.autoClose){that._startCountDown();}}).then(function(){that._watchContent();});if(this.animation==="none"){this.animationSpeed=1;this.animationBounce=1;}this.$body.css(this._getCSS(this.animationSpeed,this.animationBounce));this.$contentPane.css(this._getCSS(this.animationSpeed,1));this.$jconfirmBg.css(this._getCSS(this.animationSpeed,1));this.$jconfirmBoxContainer.css(this._getCSS(this.animationSpeed,1));},_typePrefix:"jconfirm-type-",typeParsed:"",_parseType:function(type){this.typeParsed=this._typePrefix+type;},setType:function(type){var oldClass=this.typeParsed;this._parseType(type);this.$jconfirmBox.removeClass(oldClass).addClass(this.typeParsed);},themeParsed:"",_themePrefix:"jconfirm-",setTheme:function(theme){var previous=this.theme;this.theme=theme||this.theme;this._parseTheme(this.theme);if(previous){this.$el.removeClass(previous);}this.$el.addClass(this.themeParsed);this.theme=theme;},_parseTheme:function(theme){var that=this;theme=theme.split(",");$.each(theme,function(k,a){if(a.indexOf(that._themePrefix)===-1){theme[k]=that._themePrefix+$.trim(a);}});this.themeParsed=theme.join(" ").toLowerCase();},backgroundDismissAnimationParsed:"",_bgDismissPrefix:"jconfirm-hilight-",_parseBgDismissAnimation:function(bgDismissAnimation){var animation=bgDismissAnimation.split(",");var that=this;$.each(animation,function(k,a){if(a.indexOf(that._bgDismissPrefix)===-1){animation[k]=that._bgDismissPrefix+$.trim(a);}});this.backgroundDismissAnimationParsed=animation.join(" ").toLowerCase();},animationParsed:"",closeAnimationParsed:"",_animationPrefix:"jconfirm-animation-",setAnimation:function(animation){this.animation=animation||this.animation;this._parseAnimation(this.animation,"o");},_parseAnimation:function(animation,which){which=which||"o";var animations=animation.split(",");var that=this;$.each(animations,function(k,a){if(a.indexOf(that._animationPrefix)===-1){animations[k]=that._animationPrefix+$.trim(a);}});var a_string=animations.join(" ").toLowerCase();if(which==="o"){this.animationParsed=a_string;}else{this.closeAnimationParsed=a_string;}return a_string;},setCloseAnimation:function(closeAnimation){this.closeAnimation=closeAnimation||this.closeAnimation;this._parseAnimation(this.closeAnimation,"c");},setAnimationSpeed:function(speed){this.animationSpeed=speed||this.animationSpeed;},columnClassParsed:"",setColumnClass:function(colClass){if(!this.useBootstrap){console.warn("cannot set columnClass, useBootstrap is set to false");return;}this.columnClass=colClass||this.columnClass;this._parseColumnClass(this.columnClass);this.$jconfirmBoxContainer.addClass(this.columnClassParsed);},_updateContentMaxHeight:function(){var height=$(window).height()-(this.$jconfirmBox.outerHeight()-this.$contentPane.outerHeight())-(this.offsetTop+this.offsetBottom);this.$contentPane.css({"max-height":height+"px"});},setBoxWidth:function(width){if(this.useBootstrap){console.warn("cannot set boxWidth, useBootstrap is set to true");return;}this.boxWidth=width;this.$jconfirmBox.css("width",width);},_parseColumnClass:function(colClass){colClass=colClass.toLowerCase();var p;switch(colClass){case"xl":case"xlarge":p="col-md-12";break;case"l":case"large":p="col-md-8 col-md-offset-2";break;case"m":case"medium":p="col-md-6 col-md-offset-3";break;case"s":case"small":p="col-md-4 col-md-offset-4";break;case"xs":case"xsmall":p="col-md-2 col-md-offset-5";break;default:p=colClass;}this.columnClassParsed=p;},initDraggable:function(){var that=this;var $t=this.$titleContainer;this.resetDrag();if(this.draggable){$t.on("mousedown",function(e){$t.addClass("jconfirm-hand");that.mouseX=e.clientX;that.mouseY=e.clientY;that.isDrag=true;});$(window).on("mousemove."+this._id,function(e){if(that.isDrag){that.movingX=e.clientX-that.mouseX+that.initialX;that.movingY=e.clientY-that.mouseY+that.initialY;that.setDrag();}});$(window).on("mouseup."+this._id,function(){$t.removeClass("jconfirm-hand");if(that.isDrag){that.isDrag=false;that.initialX=that.movingX;that.initialY=that.movingY;}});}},resetDrag:function(){this.isDrag=false;this.initialX=0;this.initialY=0;this.movingX=0;this.movingY=0;this.mouseX=0;this.mouseY=0;this.$jconfirmBoxContainer.css("transform","translate("+0+"px, "+0+"px)");},setDrag:function(){if(!this.draggable){return;}this.alignMiddle=false;var boxWidth=this.$jconfirmBox.outerWidth();var boxHeight=this.$jconfirmBox.outerHeight();var windowWidth=$(window).width();var windowHeight=$(window).height();var that=this;var dragUpdate=1;if(that.movingX%dragUpdate===0||that.movingY%dragUpdate===0){if(that.dragWindowBorder){var leftDistance=(windowWidth/2)-boxWidth/2;var topDistance=(windowHeight/2)-boxHeight/2;topDistance-=that.dragWindowGap;leftDistance-=that.dragWindowGap;if(leftDistance+that.movingX<0){that.movingX=-leftDistance;}else{if(leftDistance-that.movingX<0){that.movingX=leftDistance;}}if(topDistance+that.movingY<0){that.movingY=-topDistance;}else{if(topDistance-that.movingY<0){that.movingY=topDistance;}}}that.$jconfirmBoxContainer.css("transform","translate("+that.movingX+"px, "+that.movingY+"px)");}},_scrollTop:function(){if(typeof pageYOffset!=="undefined"){return pageYOffset;}else{var B=document.body;var D=document.documentElement;D=(D.clientHeight)?D:B;return D.scrollTop;}},_watchContent:function(){var that=this;if(this._timer){clearInterval(this._timer);}var prevContentHeight=0;this._timer=setInterval(function(){if(that.smoothContent){var contentHeight=that.$content.outerHeight()||0;if(contentHeight!==prevContentHeight){prevContentHeight=contentHeight;}var wh=$(window).height();var total=that.offsetTop+that.offsetBottom+that.$jconfirmBox.height()-that.$contentPane.height()+that.$content.height();if(total<wh){that.$contentPane.addClass("no-scroll");}else{that.$contentPane.removeClass("no-scroll");}}},this.watchInterval);},_overflowClass:"jconfirm-overflow",_hilightAnimating:false,highlight:function(){this.hiLightModal();},hiLightModal:function(){var that=this;if(this._hilightAnimating){return;}that.$body.addClass("hilight");var duration=parseFloat(that.$body.css("animation-duration"))||2;this._hilightAnimating=true;setTimeout(function(){that._hilightAnimating=false;that.$body.removeClass("hilight");},duration*1000);},_bindEvents:function(){var that=this;this.boxClicked=false;this.$scrollPane.click(function(e){if(!that.boxClicked){var buttonName=false;var shouldClose=false;var str;if(typeof that.backgroundDismiss==="function"){str=that.backgroundDismiss();}else{str=that.backgroundDismiss;}if(typeof str==="string"&&typeof that.buttons[str]!=="undefined"){buttonName=str;shouldClose=false;}else{if(typeof str==="undefined"||!!(str)===true){shouldClose=true;}else{shouldClose=false;}}if(buttonName){var btnResponse=that.buttons[buttonName].action.apply(that);shouldClose=(typeof btnResponse==="undefined")||!!(btnResponse);}if(shouldClose){that.close();}else{that.hiLightModal();}}that.boxClicked=false;});this.$jconfirmBox.click(function(e){that.boxClicked=true;});var isKeyDown=false;$(window).on("jcKeyDown."+that._id,function(e){if(!isKeyDown){isKeyDown=true;}});$(window).on("keyup."+that._id,function(e){if(isKeyDown){that.reactOnKey(e);isKeyDown=false;}});$(window).on("resize."+this._id,function(){that._updateContentMaxHeight();setTimeout(function(){that.resetDrag();},100);});},_cubic_bezier:"0.36, 0.55, 0.19",_getCSS:function(speed,bounce){return{"-webkit-transition-duration":speed/1000+"s","transition-duration":speed/1000+"s","-webkit-transition-timing-function":"cubic-bezier("+this._cubic_bezier+", "+bounce+")","transition-timing-function":"cubic-bezier("+this._cubic_bezier+", "+bounce+")"};},_setButtons:function(){var that=this;var total_buttons=0;if(typeof this.buttons!=="object"){this.buttons={};}$.each(this.buttons,function(key,button){total_buttons+=1;if(typeof button==="function"){that.buttons[key]=button={action:button};}that.buttons[key].text=button.text||key;that.buttons[key].btnClass=button.btnClass||"btn-default";that.buttons[key].action=button.action||function(){};that.buttons[key].keys=button.keys||[];that.buttons[key].isHidden=button.isHidden||false;that.buttons[key].isDisabled=button.isDisabled||false;$.each(that.buttons[key].keys,function(i,a){that.buttons[key].keys[i]=a.toLowerCase();});var button_element=$('<button type="button" class="btn"></button>').html(that.buttons[key].text).addClass(that.buttons[key].btnClass).prop("disabled",that.buttons[key].isDisabled).css("display",that.buttons[key].isHidden?"none":"").click(function(e){e.preventDefault();var res=that.buttons[key].action.apply(that,[that.buttons[key]]);that.onAction.apply(that,[key,that.buttons[key]]);that._stopCountDown();if(typeof res==="undefined"||res){that.close();}});that.buttons[key].el=button_element;that.buttons[key].setText=function(text){button_element.html(text);};that.buttons[key].addClass=function(className){button_element.addClass(className);};that.buttons[key].removeClass=function(className){button_element.removeClass(className);};that.buttons[key].disable=function(){that.buttons[key].isDisabled=true;button_element.prop("disabled",true);};that.buttons[key].enable=function(){that.buttons[key].isDisabled=false;button_element.prop("disabled",false);};that.buttons[key].show=function(){that.buttons[key].isHidden=false;button_element.css("display","");};that.buttons[key].hide=function(){that.buttons[key].isHidden=true;button_element.css("display","none");};that["$_"+key]=that["$$"+key]=button_element;that.$btnc.append(button_element);});if(total_buttons===0){this.$btnc.hide();}if(this.closeIcon===null&&total_buttons===0){this.closeIcon=true;}if(this.closeIcon){if(this.closeIconClass){var closeHtml='<i class="'+this.closeIconClass+'"></i>';this.$closeIcon.html(closeHtml);}this.$closeIcon.click(function(e){e.preventDefault();var buttonName=false;var shouldClose=false;var str;if(typeof that.closeIcon==="function"){str=that.closeIcon();}else{str=that.closeIcon;}if(typeof str==="string"&&typeof that.buttons[str]!=="undefined"){buttonName=str;shouldClose=false;}else{if(typeof str==="undefined"||!!(str)===true){shouldClose=true;}else{shouldClose=false;}}if(buttonName){var btnResponse=that.buttons[buttonName].action.apply(that);shouldClose=(typeof btnResponse==="undefined")||!!(btnResponse);}if(shouldClose){that.close();}});this.$closeIcon.show();}else{this.$closeIcon.hide();}},setTitle:function(string,force){force=force||false;if(typeof string!=="undefined"){if(typeof string==="string"){this.title=string;}else{if(typeof string==="function"){if(typeof string.promise==="function"){console.error("Promise was returned from title function, this is not supported.");}var response=string();if(typeof response==="string"){this.title=response;}else{this.title=false;}}else{this.title=false;}}}if(this.isAjaxLoading&&!force){return;}this.$title.html(this.title||"");this.updateTitleContainer();},setIcon:function(iconClass,force){force=force||false;if(typeof iconClass!=="undefined"){if(typeof iconClass==="string"){this.icon=iconClass;}else{if(typeof iconClass==="function"){var response=iconClass();if(typeof response==="string"){this.icon=response;}else{this.icon=false;}}else{this.icon=false;}}}if(this.isAjaxLoading&&!force){return;}this.$icon.html(this.icon?'<i class="'+this.icon+'"></i>':"");this.updateTitleContainer();},updateTitleContainer:function(){if(!this.title&&!this.icon){this.$titleContainer.hide();}else{this.$titleContainer.show();}},setContentPrepend:function(content,force){if(!content){return;}this.contentParsed.prepend(content);},setContentAppend:function(content){if(!content){return;}this.contentParsed.append(content);},setContent:function(content,force){force=!!force;var that=this;if(content){this.contentParsed.html("").append(content);}if(this.isAjaxLoading&&!force){return;}this.$content.html("");this.$content.append(this.contentParsed);setTimeout(function(){that.$body.find("input[autofocus]:visible:first").focus();},100);},loadingSpinner:false,showLoading:function(disableButtons){this.loadingSpinner=true;this.$jconfirmBox.addClass("loading");if(disableButtons){this.$btnc.find("button").prop("disabled",true);}},hideLoading:function(enableButtons){this.loadingSpinner=false;this.$jconfirmBox.removeClass("loading");if(enableButtons){this.$btnc.find("button").prop("disabled",false);}},ajaxResponse:false,contentParsed:"",isAjax:false,isAjaxLoading:false,_parseContent:function(){var that=this;var e=" ";if(typeof this.content==="function"){var res=this.content.apply(this);if(typeof res==="string"){this.content=res;}else{if(typeof res==="object"&&typeof res.always==="function"){this.isAjax=true;this.isAjaxLoading=true;res.always(function(data,status,xhr){that.ajaxResponse={data:data,status:status,xhr:xhr};that._contentReady.resolve(data,status,xhr);if(typeof that.contentLoaded==="function"){that.contentLoaded(data,status,xhr);}});this.content=e;}else{this.content=e;}}}if(typeof this.content==="string"&&this.content.substr(0,4).toLowerCase()==="url:"){this.isAjax=true;this.isAjaxLoading=true;var u=this.content.substring(4,this.content.length);$.get(u).done(function(html){that.contentParsed.html(html);}).always(function(data,status,xhr){that.ajaxResponse={data:data,status:status,xhr:xhr};that._contentReady.resolve(data,status,xhr);if(typeof that.contentLoaded==="function"){that.contentLoaded(data,status,xhr);}});}if(!this.content){this.content=e;}if(!this.isAjax){this.contentParsed.html(this.content);this.setContent();that._contentReady.resolve();}},_stopCountDown:function(){clearInterval(this.autoCloseInterval);if(this.$cd){this.$cd.remove();}},_startCountDown:function(){var that=this;var opt=this.autoClose.split("|");if(opt.length!==2){console.error("Invalid option for autoClose. example 'close|10000'");return false;}var button_key=opt[0];var time=parseInt(opt[1]);if(typeof this.buttons[button_key]==="undefined"){console.error("Invalid button key '"+button_key+"' for autoClose");return false;}var seconds=Math.ceil(time/1000);this.$cd=$('<span class="countdown"> ('+seconds+")</span>").appendTo(this["$_"+button_key]);this.autoCloseInterval=setInterval(function(){that.$cd.html(" ("+(seconds-=1)+") ");if(seconds<=0){that["$$"+button_key].trigger("click");that._stopCountDown();}},1000);},_getKey:function(key){switch(key){case 192:return"tilde";case 13:return"enter";case 16:return"shift";case 9:return"tab";case 20:return"capslock";case 17:return"ctrl";case 91:return"win";case 18:return"alt";case 27:return"esc";case 32:return"space";}var initial=String.fromCharCode(key);if(/^[A-z0-9]+$/.test(initial)){return initial.toLowerCase();}else{return false;}},reactOnKey:function(e){var that=this;var a=$(".jconfirm");if(a.eq(a.length-1)[0]!==this.$el[0]){return false;}var key=e.which;if(this.$content.find(":input").is(":focus")&&/13|32/.test(key)){return false;}var keyChar=this._getKey(key);if(keyChar==="esc"&&this.escapeKey){if(this.escapeKey===true){this.$scrollPane.trigger("click");}else{if(typeof this.escapeKey==="string"||typeof this.escapeKey==="function"){var buttonKey;if(typeof this.escapeKey==="function"){buttonKey=this.escapeKey();}else{buttonKey=this.escapeKey;}if(buttonKey){if(typeof this.buttons[buttonKey]==="undefined"){console.warn("Invalid escapeKey, no buttons found with key "+buttonKey);}else{this["$_"+buttonKey].trigger("click");}}}}}$.each(this.buttons,function(key,button){if(button.keys.indexOf(keyChar)!==-1){that["$_"+key].trigger("click");}});},setDialogCenter:function(){console.info("setDialogCenter is deprecated, dialogs are centered with CSS3 tables");},_unwatchContent:function(){clearInterval(this._timer);},close:function(onClosePayload){var that=this;if(typeof this.onClose==="function"){this.onClose(onClosePayload);}this._unwatchContent();$(window).unbind("resize."+this._id);$(window).unbind("keyup."+this._id);$(window).unbind("jcKeyDown."+this._id);if(this.draggable){$(window).unbind("mousemove."+this._id);$(window).unbind("mouseup."+this._id);this.$titleContainer.unbind("mousedown");}that.$el.removeClass(that.loadedClass);$("body").removeClass("jconfirm-no-scroll-"+that._id);that.$jconfirmBoxContainer.removeClass("jconfirm-no-transition");setTimeout(function(){that.$body.addClass(that.closeAnimationParsed);that.$jconfirmBg.addClass("jconfirm-bg-h");var closeTimer=(that.closeAnimation==="none")?1:that.animationSpeed;setTimeout(function(){that.$el.remove();var l=w.jconfirm.instances;var i=w.jconfirm.instances.length-1;for(i;i>=0;i--){if(w.jconfirm.instances[i]._id===that._id){w.jconfirm.instances.splice(i,1);}}if(!w.jconfirm.instances.length){if(that.scrollToPreviousElement&&w.jconfirm.lastFocused&&w.jconfirm.lastFocused.length&&$.contains(document,w.jconfirm.lastFocused[0])){var $lf=w.jconfirm.lastFocused;if(that.scrollToPreviousElementAnimate){var st=$(window).scrollTop();var ot=w.jconfirm.lastFocused.offset().top;var wh=$(window).height();if(!(ot>st&&ot<(st+wh))){var scrollTo=(ot-Math.round((wh/3)));$("html, body").animate({scrollTop:scrollTo},that.animationSpeed,"swing",function(){$lf.focus();});}else{$lf.focus();}}else{$lf.focus();}w.jconfirm.lastFocused=false;}}if(typeof that.onDestroy==="function"){that.onDestroy();}},closeTimer*0.4);},50);return true;},open:function(){if(this.isOpen()){return false;}this._buildHTML();this._bindEvents();this._open();return true;},setStartingPoint:function(){var el=false;if(this.animateFromElement!==true&&this.animateFromElement){el=this.animateFromElement;w.jconfirm.lastClicked=false;}else{if(w.jconfirm.lastClicked&&this.animateFromElement===true){el=w.jconfirm.lastClicked;w.jconfirm.lastClicked=false;}else{return false;}}if(!el){return false;}var offset=el.offset();var iTop=el.outerHeight()/2;var iLeft=el.outerWidth()/2;iTop-=this.$jconfirmBox.outerHeight()/2;iLeft-=this.$jconfirmBox.outerWidth()/2;var sourceTop=offset.top+iTop;sourceTop=sourceTop-this._scrollTop();var sourceLeft=offset.left+iLeft;var wh=$(window).height()/2;var ww=$(window).width()/2;var targetH=wh-this.$jconfirmBox.outerHeight()/2;var targetW=ww-this.$jconfirmBox.outerWidth()/2;sourceTop-=targetH;sourceLeft-=targetW;if(Math.abs(sourceTop)>wh||Math.abs(sourceLeft)>ww){return false;}this.$jconfirmBoxContainer.css("transform","translate("+sourceLeft+"px, "+sourceTop+"px)");},_open:function(){var that=this;if(typeof that.onOpenBefore==="function"){that.onOpenBefore();}this.$body.removeClass(this.animationParsed);this.$jconfirmBg.removeClass("jconfirm-bg-h");this.$body.focus();that.$jconfirmBoxContainer.css("transform","translate("+0+"px, "+0+"px)");setTimeout(function(){that.$body.css(that._getCSS(that.animationSpeed,1));that.$body.css({"transition-property":that.$body.css("transition-property")+", margin"});that.$jconfirmBoxContainer.addClass("jconfirm-no-transition");that._modalReady.resolve();if(typeof that.onOpen==="function"){that.onOpen();}that.$el.addClass(that.loadedClass);},this.animationSpeed);},loadedClass:"jconfirm-open",isClosed:function(){return !this.$el||this.$el.parent().length===0;},isOpen:function(){return !this.isClosed();},toggle:function(){if(!this.isOpen()){this.open();}else{this.close();}}};w.jconfirm.instances=[];w.jconfirm.lastFocused=false;w.jconfirm.pluginDefaults={template:'<div class="jconfirm"><div class="jconfirm-bg jconfirm-bg-h"></div><div class="jconfirm-scrollpane"><div class="jconfirm-row"><div class="jconfirm-cell"><div class="jconfirm-holder"><div class="jc-bs3-container"><div class="jc-bs3-row"><div class="jconfirm-box-container jconfirm-animated"><div class="jconfirm-box" role="dialog" aria-labelledby="labelled" tabindex="-1"><div class="jconfirm-closeIcon">×</div><div class="jconfirm-title-c"><span class="jconfirm-icon-c"></span><span class="jconfirm-title"></span></div><div class="jconfirm-content-pane"><div class="jconfirm-content"></div></div><div class="jconfirm-buttons"></div><div class="jconfirm-clear"></div></div></div></div></div></div></div></div></div></div>',title:"Hello",titleClass:"",type:"default",typeAnimated:true,draggable:true,dragWindowGap:15,dragWindowBorder:true,animateFromElement:true,alignMiddle:true,smoothContent:true,content:"Are you sure to continue?",buttons:{},defaultButtons:{ok:{action:function(){}},close:{action:function(){}}},contentLoaded:function(){},icon:"",lazyOpen:false,bgOpacity:null,theme:"light",animation:"scale",closeAnimation:"scale",animationSpeed:400,animationBounce:1,escapeKey:true,rtl:false,container:"body",containerFluid:false,backgroundDismiss:false,backgroundDismissAnimation:"shake",autoClose:false,closeIcon:null,closeIconClass:false,watchInterval:100,columnClass:"col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1",boxWidth:"50%",scrollToPreviousElement:true,scrollToPreviousElementAnimate:true,useBootstrap:true,offsetTop:40,offsetBottom:40,bootstrapClasses:{container:"container",containerFluid:"container-fluid",row:"row"},onContentReady:function(){},onOpenBefore:function(){},onOpen:function(){},onClose:function(){},onDestroy:function(){},onAction:function(){}};var keyDown=false;$(window).on("keydown",function(e){if(!keyDown){var $target=$(e.target);var pass=false;if($target.closest(".jconfirm-box").length){pass=true;}if(pass){$(window).trigger("jcKeyDown");}keyDown=true;}});$(window).on("keyup",function(){keyDown=false;});w.jconfirm.lastClicked=false;$(document).on("mousedown","button, a, [jc-source]",function(){w.jconfirm.lastClicked=$(this);});}));
|
|
window.moment = dayjs;
|
|
/* ========================================================================
|
|
* SaRibe: eModal.js v1.2.67
|
|
* http://saribe.github.io/eModal
|
|
* ========================================================================
|
|
* Copyright Samuel Ribeiro.
|
|
* Licensed under MIT.
|
|
* ======================================================================== */
|
|
|
|
/**
|
|
* Easy Modal for bootstrap, is a simple way to create modal dialogs using javascript.
|
|
* @params allowed elements:
|
|
* buttons {array}: An array of objects to configure buttons to modal footer; only able if message == string
|
|
* css {object}: CSS object try apply into message body; only able if message == string
|
|
* data {object}: Used for iframe with post data parameters
|
|
* loading {boolean}: Set loading progress as message.
|
|
* message {string|object}: The body message string or the HTML element. e.g.: $(selector);
|
|
* size {string}: sm || lg || xl -> define the modal size.
|
|
* subtitle {string}: The header subtitle string. This appear in a smaller text.
|
|
* title {string}: The header title string.
|
|
* useBin {boolean}: Set message as recyclable.
|
|
* </summary>
|
|
* <param name="params" >Modal options parameters of string body message.</param>
|
|
* <param name="title" >The string header title or a flag to set default parameters.</param>
|
|
* <returns type="Promise">{ then, element }.</returns>
|
|
*/
|
|
|
|
;
|
|
(function (define) {
|
|
define(['jquery'], function ($, root) {
|
|
var $modal;
|
|
var BIN = 'recycle-bin';
|
|
var DIV = '<div>';
|
|
var EMPTY = '';
|
|
var EVENT_CLICK = 'click';
|
|
var EVENT_HIDE = 'hide';
|
|
var EVENT_SHOW = 'shown.bs.modal';
|
|
var EVENT_SUBMIT = 'submit';
|
|
var FOOTER_ID = 'eFooter';
|
|
var HIDE = EVENT_HIDE + '.bs.modal';
|
|
var INPUT = 'input';
|
|
var KEY_DANGER = 'danger';
|
|
var LABEL = {
|
|
OK: 'Cancel',
|
|
True: 'False',
|
|
Yes: 'No'
|
|
};
|
|
var lastParams = {};
|
|
var MODAL_BODY = 'modal-body';
|
|
var MODAL_DIALOG = '.modal-dialog';
|
|
var options = {};
|
|
var REC_MODAL_CONTENT = 'modal-rec';
|
|
var SIZE = {
|
|
sm: 'sm',
|
|
lg: 'lg',
|
|
xl: 'xl'
|
|
};
|
|
var TMP_MODAL_CONTENT = 'modal-tmp';
|
|
|
|
var defaultSettings = {
|
|
allowContentRecycle: true,
|
|
confirmLabel: Object.keys(LABEL)[0],
|
|
labels: LABEL,
|
|
loadingHtml: '<h5>Loading...</h5><div class=progress><div class="progress-bar progress-bar-striped active" style="width: 100%"></div></div>',
|
|
size: EMPTY,
|
|
title: 'Attention',
|
|
autofocus: false
|
|
};
|
|
|
|
root = root || {};
|
|
root.addLabel = addLabel;
|
|
root.ajax = ajax;
|
|
root.alert = alert;
|
|
root.close = close;
|
|
root.confirm = confirm;
|
|
root.emptyBin = emptyBin;
|
|
root.iframe = iframe;
|
|
root.prompt = prompt;
|
|
root.setId = setId;
|
|
root.setEModalOptions = setEModalOptions;
|
|
root.setModalOptions = setModalOptions;
|
|
root.size = SIZE;
|
|
root.version = '1.2.67';
|
|
|
|
return root;
|
|
|
|
//#region /////////////////////////* Private Logic */////////////////////////
|
|
/**
|
|
* Find modal body and append message to it.
|
|
* @param {String | DOM} message
|
|
*/
|
|
function _build(message) {
|
|
$modal
|
|
.modal(options)
|
|
.find('.modal-content')
|
|
.append(message);
|
|
}
|
|
|
|
/**
|
|
* Will find what Promises approach the developer is using.
|
|
* Will use Promises A+ if Q.js is present, otherwise will use Promises A from jQuery.
|
|
* @returns {Promise}
|
|
*/
|
|
function _createDeferred() {
|
|
var defer;
|
|
|
|
// try native promise
|
|
//if (Promise) defer = Promise.defer();
|
|
|
|
var q;
|
|
|
|
try {
|
|
q = require('Q');
|
|
} // Load option Q by require if exist
|
|
catch (e) {
|
|
q = window.Q;
|
|
}
|
|
|
|
if (q) { // try Q
|
|
defer = q.defer();
|
|
} else { // Use jQuery :(
|
|
defer = $.Deferred();
|
|
defer.promise = defer.promise();
|
|
}
|
|
|
|
defer.promise.element = _getModalInstance(true).find(MODAL_DIALOG);
|
|
return defer;
|
|
}
|
|
|
|
/**
|
|
* Will create modal DOM footer with all buttons.
|
|
* @param {Array} buttons - all custom buttons, if none, will generate defaults
|
|
* @returns {$DOM} footer DOM element
|
|
*/
|
|
function _getFooter(buttons) {
|
|
if (buttons === false) {
|
|
return EMPTY;
|
|
}
|
|
|
|
var messageFotter = $(DIV).addClass('modal-footer').prop('id', FOOTER_ID);
|
|
if (buttons) {
|
|
for (var i = 0, k = buttons.length; i < k; i++) {
|
|
var btnOp = buttons[i];
|
|
var btn = $('<button>').addClass('btn btn-' + (btnOp.style || 'primary'));
|
|
|
|
for (var index in btnOp) {
|
|
if (btnOp.hasOwnProperty(index)) {
|
|
switch (index) {
|
|
case 'close':
|
|
//add close event
|
|
if (btnOp[index]) {
|
|
btn.attr('data-dismiss', 'modal')
|
|
.addClass('x');
|
|
}
|
|
break;
|
|
case EVENT_CLICK:
|
|
//click event
|
|
var fn = btnOp.click.bind(_getModalInstance(true).find('.modal-content'));
|
|
btn.click(fn);
|
|
break;
|
|
case 'text':
|
|
btn.html(btnOp[index]);
|
|
break;
|
|
default:
|
|
//all other possible HTML attributes to button element
|
|
btn.attr(index, btnOp[index]);
|
|
}
|
|
}
|
|
}
|
|
|
|
messageFotter.append(btn);
|
|
}
|
|
} else {
|
|
//if no buttons defined by user, add a standard close button.
|
|
messageFotter.append('<button class="x btn btn-primary" data-dismiss=modal type=button>Close</button>');
|
|
}
|
|
return messageFotter;
|
|
}
|
|
|
|
/**
|
|
* Extract message from arguments.
|
|
* @param {Object | String} data - this can be the message string or the full detailed object
|
|
* @returns {$DOM}
|
|
*/
|
|
function _getMessage(data) {
|
|
var $message;
|
|
var content = data.loading ?
|
|
defaultSettings.loadingHtml :
|
|
(data.message || data);
|
|
|
|
if (content.on || content.onclick) {
|
|
$message = data.clone === true ?
|
|
$(content).clone() :
|
|
$(content);
|
|
|
|
$message.addClass(data.useBin && !data.loading ? REC_MODAL_CONTENT : TMP_MODAL_CONTENT);
|
|
} else {
|
|
$message = $(DIV)
|
|
.attr('style', 'position:relative;word-wrap:break-word;')
|
|
.addClass(MODAL_BODY)
|
|
.html(content);
|
|
}
|
|
|
|
return data.css && (data.css !== $message.css && $message.css(data.css)), $message;
|
|
}
|
|
|
|
/**
|
|
* Return a new modal object if is the first request or the already created model.
|
|
* @param {boolean} skipEventChageIfExists
|
|
* @returns {jQuery Object}
|
|
*/
|
|
function _getModalInstance(skipEventChageIfExists) {
|
|
if (!$modal) {
|
|
//add recycle bin container to document
|
|
if (!$('#' + BIN).length) {
|
|
$('body').append($(DIV).prop('id', BIN).hide());
|
|
}
|
|
|
|
$modal = createModalElement();
|
|
}
|
|
|
|
if (skipEventChageIfExists && $modal) {
|
|
return $modal;
|
|
}
|
|
|
|
if (defaultSettings.autofocus) {
|
|
$modal
|
|
.on(EVENT_SHOW, function () {
|
|
$(this).find(INPUT).first().focus();
|
|
});
|
|
}
|
|
|
|
return $modal;
|
|
|
|
function createModalElement() {
|
|
return $('<div class="modal fade" tabindex="-1"><style>.modal-title{display:inline;}.modal-xl{width:96%;}.modal-body{max-height: calc(100vh - 145px);overflow-y: auto;}</style>' +
|
|
'<div class=modal-dialog>' +
|
|
'<div class=modal-content>' +
|
|
' <div class=modal-header><h5 class=modal-title></h5><button type=button class="x close" data-dismiss=modal aria-label="Close"><span aria-hidden=true>×</span></button></div>' +
|
|
'</div>' +
|
|
'</div>' +
|
|
'</div>')
|
|
.on('hidden.bs.modal', _recycleModal)
|
|
.on(EVENT_CLICK, 'button.x', function (ev) {
|
|
var btn = $(ev.currentTarget);
|
|
|
|
if (btn.prop('type') !== EVENT_SUBMIT)
|
|
return $modal.modal(EVENT_HIDE);
|
|
|
|
try {
|
|
if (btn.closest('form')[0].checkValidity())
|
|
return close();
|
|
} catch (e) {
|
|
return close();
|
|
}
|
|
|
|
return $modal;
|
|
});
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param {String} version
|
|
* @returns {Boolean}
|
|
*/
|
|
function _jQueryMinVersion(version) {
|
|
var $ver = $.fn.jquery.split('.');
|
|
var ver = version.split('.');
|
|
var $major = $ver[0];
|
|
var $minor = $ver[1];
|
|
var $patch = $ver[2];
|
|
var major = ver[0];
|
|
var minor = ver[1];
|
|
var patch = ver[2];
|
|
|
|
return !(
|
|
(major > $major) ||
|
|
(major === $major && minor > $minor) ||
|
|
(major === $major && minor === $minor && patch > $patch)
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Move content to recycle bin if is a DOM object defined by user,
|
|
* delete it if is a simple string message.
|
|
* All modal messages can be deleted if default setting "allowContentRecycle" = false.
|
|
*/
|
|
function _recycleModal() {
|
|
if (!$modal) return;
|
|
|
|
var $content = $modal.find('.' + REC_MODAL_CONTENT).removeClass(REC_MODAL_CONTENT)
|
|
.appendTo('#' + BIN);
|
|
|
|
$modal
|
|
.off(HIDE)
|
|
.off(EVENT_SHOW)
|
|
.find('.modal-content > div:not(:first-child)')
|
|
.remove();
|
|
|
|
if (!defaultSettings.allowContentRecycle || lastParams.clone) {
|
|
$content.remove();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Handle default values and toggle between {Object | String}.
|
|
* Create or get Modal element
|
|
* @param {Object | String} data - this can be the message string or the full detailed object
|
|
* @param {String} title - the string that will be shown in modal header
|
|
* @returns {Promise} Promise with modal $DOM element
|
|
*/
|
|
function _setup(params, title) {
|
|
if (!params) throw new Error('Invalid parameters!');
|
|
|
|
_recycleModal();
|
|
lastParams = params;
|
|
|
|
// Lazy loading
|
|
var $ref = _getModalInstance();
|
|
var size = 'modal-' + (params.size || defaultSettings.size);
|
|
|
|
// Change size
|
|
$ref.find(MODAL_DIALOG)
|
|
.removeClass('modal-sm modal-lg modal-xl')
|
|
.addClass(params.size || defaultSettings.size ? size : null);
|
|
|
|
// Change title
|
|
$ref.find('.modal-title')
|
|
.html((params.title || title || defaultSettings.title) + ' ')
|
|
.append($('<small>').html(params.subtitle || EMPTY));
|
|
|
|
$ref.on(HIDE, params.onHide);
|
|
}
|
|
//#endregion
|
|
|
|
//#region /////////////////////////* Public Methods */////////////////////////
|
|
|
|
function addLabel(yes, no) {
|
|
LABEL[yes] = no;
|
|
}
|
|
|
|
/**
|
|
* Gets data from URL to eModal body
|
|
* @param {Object | String} data - this can be the message string or the full detailed object
|
|
* @param {String} title - the string that will be shown in modal header
|
|
* @returns {Promise} Promise with modal $DOM element
|
|
*/
|
|
function ajax(data, title) {
|
|
|
|
var dfd = _createDeferred();
|
|
|
|
if (typeof data === 'object') {
|
|
setEModalOptions(data);
|
|
}
|
|
|
|
var params = {
|
|
async: true,
|
|
deferred: dfd,
|
|
xhrFields: { withCredentials: false },
|
|
loading: true,
|
|
title: title || defaultSettings.title,
|
|
url: data.url || data,
|
|
dataType: data.dataType || 'text'
|
|
};
|
|
|
|
if (data.url) {
|
|
$.extend(params, data);
|
|
}
|
|
|
|
$.ajax(params)
|
|
.done(ok)
|
|
.fail(error);
|
|
|
|
return alert(params, title);
|
|
|
|
function ok(html) {
|
|
$modal
|
|
.find('.' + MODAL_BODY)
|
|
.html(data.success ? data.success(html) : html);
|
|
|
|
return dfd.resolve($modal);
|
|
}
|
|
|
|
function error(responseText, textStatus) {
|
|
var msg = data.error ?
|
|
data.error(responseText, textStatus, params) :
|
|
'<div class="alert alert-danger">' +
|
|
'<strong>XHR Fail: </strong>URL [ ' + params.url + '] load fail.' +
|
|
'</div>';
|
|
|
|
$modal
|
|
.find('.' + MODAL_BODY)
|
|
.html(msg);
|
|
return dfd.reject(responseText);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Non blocking alert whit bootstrap.
|
|
* @param {Object | String} data - this can be the message string or the full detailed object.
|
|
* @param {String} title - the string that will be shown in modal header.
|
|
* @returns {Promise} Promise with modal $DOM element
|
|
*/
|
|
function alert(data, title) {
|
|
_setup(data, title);
|
|
|
|
var dfd = data.deferred || _createDeferred();
|
|
|
|
if (typeof data === 'object') {
|
|
setEModalOptions(data);
|
|
}
|
|
|
|
var $message = $(DIV).append(_getMessage(data), _getFooter(data.buttons));
|
|
|
|
_build($message);
|
|
|
|
if (!data.async) {
|
|
$modal.on(EVENT_SHOW, dfd.resolve);
|
|
}
|
|
|
|
return dfd.promise;
|
|
}
|
|
|
|
/**
|
|
* Non blocking confirm dialog with bootstrap.
|
|
* @param {Object | String} data - this can be the message string or the full detailed object.
|
|
* @param {String} title - the string that will be shown in modal header.
|
|
* @returns {Promise} Promise with modal $DOM element
|
|
*/
|
|
function confirm(data, title) {
|
|
var dfd = _createDeferred();
|
|
|
|
if (typeof data === 'object') {
|
|
setEModalOptions(data);
|
|
}
|
|
|
|
return alert({
|
|
async: true,
|
|
buttons: [{
|
|
close: true,
|
|
click: click,
|
|
text: LABEL[data.label] ? LABEL[data.label] : LABEL[defaultSettings.confirmLabel],
|
|
style: data.style && data.style[0] || KEY_DANGER
|
|
}, {
|
|
close: true,
|
|
click: click,
|
|
text: LABEL[data.label] ? data.label : defaultSettings.confirmLabel,
|
|
style: data.style && data.style[1]
|
|
}],
|
|
deferred: dfd,
|
|
message: data.message || data,
|
|
onHide: click,
|
|
size: data.size,
|
|
title: data.title || title
|
|
});
|
|
|
|
function click(ev) {
|
|
close();
|
|
|
|
var key = $(ev.currentTarget).html();
|
|
return LABEL[key] ? dfd.resolve() : dfd.reject();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Will load a URL in iFrame inside the modal body.
|
|
* @param {Object | String} data - this can be the URL string or the full detailed object.
|
|
* @param {String} title - the string that will be shown in modal header.
|
|
* @returns {Promise} Promise with modal $DOM element
|
|
*/
|
|
function iframe(params, title) {
|
|
var dfd = _createDeferred();
|
|
|
|
if (typeof data === 'object') {
|
|
setEModalOptions(data);
|
|
}
|
|
|
|
var postData = params.data ?
|
|
Object.keys(params.data).map(mapData).join(' ') :
|
|
'';
|
|
|
|
var html = ('<div class=modal-body style="position: absolute;width: 100%;background-color: rgba(255,255,255,0.8);height: 100%;">%1%</div>' +
|
|
'<iframe class="embed-responsive-item" frameborder=0 src="%0%" %2% style="width:100%;height:75vh;display:block;"/>')
|
|
.replace('%0%', params.message || params.url || params)
|
|
.replace('%1%', defaultSettings.loadingHtml)
|
|
.replace('%2%', postData);
|
|
|
|
var message = _jQueryMinVersion('3.0.0') ?
|
|
$(html).on('load', iframeReady) :
|
|
$(html).load(iframeReady);
|
|
|
|
return alert({
|
|
async: true,
|
|
buttons: params.buttons || false,
|
|
deferred: dfd,
|
|
message: message,
|
|
size: params.size || SIZE.xl,
|
|
title: params.title || title
|
|
});
|
|
//////////
|
|
|
|
function mapData(item) {
|
|
return item + '="' + params.data[item] + '"';
|
|
}
|
|
|
|
function iframeReady() {
|
|
$(this)
|
|
.parent()
|
|
.find('div.' + TMP_MODAL_CONTENT)
|
|
.fadeOut(function () {
|
|
$(this).remove();
|
|
});
|
|
|
|
return dfd.resolve();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Remove all Dom elements in recycle bin.
|
|
* @returns {Array} All removed elements
|
|
*/
|
|
function emptyBin() {
|
|
return $('#' + BIN + ' > *').remove();
|
|
}
|
|
|
|
/**
|
|
* Provides one value form.
|
|
* @param {Object | String} data - this can be the value string label or the full detailed object.
|
|
* @param {String} title - the string that will be shown in modal header.
|
|
* @returns {Promise} Promise with modal $DOM element
|
|
*/
|
|
function prompt(data, title) {
|
|
var dfd = _createDeferred();
|
|
|
|
if (typeof data === 'object') {
|
|
setEModalOptions(data);
|
|
}
|
|
|
|
var params = {
|
|
deferred: dfd
|
|
};
|
|
|
|
if (typeof data === 'object') {
|
|
$.extend(params, data);
|
|
} else {
|
|
params.message = data;
|
|
params.title = title;
|
|
}
|
|
|
|
params.async = true;
|
|
|
|
if (params.buttons) {
|
|
var btn;
|
|
for (var i = 0, k = params.buttons.length; i < k; i++) {
|
|
btn = params.buttons[i];
|
|
btn.style = (btn.style || 'default') + ' pull-left';
|
|
btn.type = btn.type || 'button';
|
|
}
|
|
}
|
|
|
|
var buttons = _getFooter([{
|
|
close: true,
|
|
type: 'reset',
|
|
text: LABEL.OK,
|
|
style: KEY_DANGER
|
|
}, {
|
|
close: false,
|
|
type: EVENT_SUBMIT,
|
|
text: defaultSettings.confirmLabel
|
|
}].concat(params.buttons || []));
|
|
|
|
params.buttons = false;
|
|
params.onHide = submit;
|
|
|
|
params.message = $('<form role=form style="margin-bottom:0;">' +
|
|
'<div class=modal-body>' +
|
|
'<label for=prompt-input class=control-label>' + (params.message || EMPTY) + '</label>' +
|
|
'<input type=text class=form-control required autocomplete="on" value="' + (params.value || EMPTY) + (params.pattern ? '" pattern="' + params.pattern : EMPTY) + '">' +
|
|
'</div></form>')
|
|
.append(buttons)
|
|
.on(EVENT_SUBMIT, submit);
|
|
|
|
return alert(params);
|
|
|
|
function submit(ev) {
|
|
var value = $modal.find(INPUT).val();
|
|
close();
|
|
|
|
//TODO:
|
|
ev.type !== EVENT_SUBMIT ?
|
|
dfd.reject(value) :
|
|
dfd.resolve(value);
|
|
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function setId(id) {
|
|
_getModalInstance(true)
|
|
.find(MODAL_DIALOG)
|
|
.prop('id', id);
|
|
}
|
|
|
|
/**
|
|
* Set or change eModal options.
|
|
* @param {Object} overrideOptions
|
|
* @returns {Object} merged eModal options
|
|
*/
|
|
function setEModalOptions(overrideOptions) {
|
|
return $.extend(defaultSettings, overrideOptions);
|
|
}
|
|
|
|
/**
|
|
* Set or change bootstrap modal options.
|
|
* @param {Object} overrideOptions
|
|
* @returns {Object} merged eModal options
|
|
*/
|
|
function setModalOptions(overrideOptions) {
|
|
$modal && $modal.remove();
|
|
|
|
return $.extend(options, overrideOptions);
|
|
}
|
|
|
|
/**
|
|
* Close the current open eModal
|
|
* @returns {$DOM} eModal DOM element
|
|
*/
|
|
function close() {
|
|
if ($modal) {
|
|
$modal.off(HIDE).modal(EVENT_HIDE);
|
|
}
|
|
return $modal;
|
|
}
|
|
//#endregion
|
|
});
|
|
}(typeof define == 'function' && define.amd ?
|
|
define :
|
|
function (args, mName) {
|
|
this.eModal = typeof module != 'undefined' && module.exports ?
|
|
mName(require(args[0], {}), module.exports) :
|
|
mName(window.$);
|
|
}));
|
|
/*!
|
|
* Bootstrap-select v1.13.14 (https://developer.snapappointments.com/bootstrap-select)
|
|
*
|
|
* Copyright 2012-2020 SnapAppointments, LLC
|
|
* Licensed under MIT (https://github.com/snapappointments/bootstrap-select/blob/master/LICENSE)
|
|
*/
|
|
|
|
!function(e,t){void 0===e&&void 0!==window&&(e=window),"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(e.jQuery)}(this,function(e){!function(z){"use strict";var d=["sanitize","whiteList","sanitizeFn"],r=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],e={"*":["class","dir","id","lang","role","tabindex","style",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},l=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,a=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function v(e,t){var i=e.nodeName.toLowerCase();if(-1!==z.inArray(i,t))return-1===z.inArray(i,r)||Boolean(e.nodeValue.match(l)||e.nodeValue.match(a));for(var s=z(t).filter(function(e,t){return t instanceof RegExp}),n=0,o=s.length;n<o;n++)if(i.match(s[n]))return!0;return!1}function P(e,t,i){if(i&&"function"==typeof i)return i(e);for(var s=Object.keys(t),n=0,o=e.length;n<o;n++)for(var r=e[n].querySelectorAll("*"),l=0,a=r.length;l<a;l++){var c=r[l],d=c.nodeName.toLowerCase();if(-1!==s.indexOf(d))for(var h=[].slice.call(c.attributes),p=[].concat(t["*"]||[],t[d]||[]),u=0,f=h.length;u<f;u++){var m=h[u];v(m,p)||c.removeAttribute(m.nodeName)}else c.parentNode.removeChild(c)}}"classList"in document.createElement("_")||function(e){if("Element"in e){var t="classList",i="prototype",s=e.Element[i],n=Object,o=function(){var i=z(this);return{add:function(e){return e=Array.prototype.slice.call(arguments).join(" "),i.addClass(e)},remove:function(e){return e=Array.prototype.slice.call(arguments).join(" "),i.removeClass(e)},toggle:function(e,t){return i.toggleClass(e,t)},contains:function(e){return i.hasClass(e)}}};if(n.defineProperty){var r={get:o,enumerable:!0,configurable:!0};try{n.defineProperty(s,t,r)}catch(e){void 0!==e.number&&-2146823252!==e.number||(r.enumerable=!1,n.defineProperty(s,t,r))}}else n[i].__defineGetter__&&s.__defineGetter__(t,o)}}(window);var t,c,i=document.createElement("_");if(i.classList.add("c1","c2"),!i.classList.contains("c2")){var s=DOMTokenList.prototype.add,n=DOMTokenList.prototype.remove;DOMTokenList.prototype.add=function(){Array.prototype.forEach.call(arguments,s.bind(this))},DOMTokenList.prototype.remove=function(){Array.prototype.forEach.call(arguments,n.bind(this))}}if(i.classList.toggle("c3",!1),i.classList.contains("c3")){var o=DOMTokenList.prototype.toggle;DOMTokenList.prototype.toggle=function(e,t){return 1 in arguments&&!this.contains(e)==!t?t:o.call(this,e)}}function h(e){if(null==this)throw new TypeError;var t=String(this);if(e&&"[object RegExp]"==c.call(e))throw new TypeError;var i=t.length,s=String(e),n=s.length,o=1<arguments.length?arguments[1]:void 0,r=o?Number(o):0;r!=r&&(r=0);var l=Math.min(Math.max(r,0),i);if(i<n+l)return!1;for(var a=-1;++a<n;)if(t.charCodeAt(l+a)!=s.charCodeAt(a))return!1;return!0}function O(e,t){var i,s=e.selectedOptions,n=[];if(t){for(var o=0,r=s.length;o<r;o++)(i=s[o]).disabled||"OPTGROUP"===i.parentNode.tagName&&i.parentNode.disabled||n.push(i);return n}return s}function T(e,t){for(var i,s=[],n=t||e.selectedOptions,o=0,r=n.length;o<r;o++)(i=n[o]).disabled||"OPTGROUP"===i.parentNode.tagName&&i.parentNode.disabled||s.push(i.value);return e.multiple?s:s.length?s[0]:null}i=null,String.prototype.startsWith||(t=function(){try{var e={},t=Object.defineProperty,i=t(e,e,e)&&t}catch(e){}return i}(),c={}.toString,t?t(String.prototype,"startsWith",{value:h,configurable:!0,writable:!0}):String.prototype.startsWith=h),Object.keys||(Object.keys=function(e,t,i){for(t in i=[],e)i.hasOwnProperty.call(e,t)&&i.push(t);return i}),HTMLSelectElement&&!HTMLSelectElement.prototype.hasOwnProperty("selectedOptions")&&Object.defineProperty(HTMLSelectElement.prototype,"selectedOptions",{get:function(){return this.querySelectorAll(":checked")}});var p={useDefault:!1,_set:z.valHooks.select.set};z.valHooks.select.set=function(e,t){return t&&!p.useDefault&&z(e).data("selected",!0),p._set.apply(this,arguments)};var A=null,u=function(){try{return new Event("change"),!0}catch(e){return!1}}();function k(e,t,i,s){for(var n=["display","subtext","tokens"],o=!1,r=0;r<n.length;r++){var l=n[r],a=e[l];if(a&&(a=a.toString(),"display"===l&&(a=a.replace(/<[^>]+>/g,"")),s&&(a=w(a)),a=a.toUpperCase(),o="contains"===i?0<=a.indexOf(t):a.startsWith(t)))break}return o}function L(e){return parseInt(e,10)||0}z.fn.triggerNative=function(e){var t,i=this[0];i.dispatchEvent?(u?t=new Event(e,{bubbles:!0}):(t=document.createEvent("Event")).initEvent(e,!0,!1),i.dispatchEvent(t)):i.fireEvent?((t=document.createEventObject()).eventType=e,i.fireEvent("on"+e,t)):this.trigger(e)};var f={"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"},m=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,g=RegExp("[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\u1ab0-\\u1aff\\u1dc0-\\u1dff]","g");function b(e){return f[e]}function w(e){return(e=e.toString())&&e.replace(m,b).replace(g,"")}var I,x,y,$,S=(I={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},x="(?:"+Object.keys(I).join("|")+")",y=RegExp(x),$=RegExp(x,"g"),function(e){return e=null==e?"":""+e,y.test(e)?e.replace($,E):e});function E(e){return I[e]}var C={32:" ",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",59:";",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9"},N=27,D=13,H=32,W=9,B=38,M=40,R={success:!1,major:"3"};try{R.full=(z.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split("."),R.major=R.full[0],R.success=!0}catch(e){}var U=0,j=".bs.select",V={DISABLED:"disabled",DIVIDER:"divider",SHOW:"open",DROPUP:"dropup",MENU:"dropdown-menu",MENURIGHT:"dropdown-menu-right",MENULEFT:"dropdown-menu-left",BUTTONCLASS:"btn-default",POPOVERHEADER:"popover-title",ICONBASE:"glyphicon",TICKICON:"glyphicon-ok"},F={MENU:"."+V.MENU},_={span:document.createElement("span"),i:document.createElement("i"),subtext:document.createElement("small"),a:document.createElement("a"),li:document.createElement("li"),whitespace:document.createTextNode("\xa0"),fragment:document.createDocumentFragment()};_.a.setAttribute("role","option"),"4"===R.major&&(_.a.className="dropdown-item"),_.subtext.className="text-muted",_.text=_.span.cloneNode(!1),_.text.className="text",_.checkMark=_.span.cloneNode(!1);var G=new RegExp(B+"|"+M),q=new RegExp("^"+W+"$|"+N),K={li:function(e,t,i){var s=_.li.cloneNode(!1);return e&&(1===e.nodeType||11===e.nodeType?s.appendChild(e):s.innerHTML=e),void 0!==t&&""!==t&&(s.className=t),null!=i&&s.classList.add("optgroup-"+i),s},a:function(e,t,i){var s=_.a.cloneNode(!0);return e&&(11===e.nodeType?s.appendChild(e):s.insertAdjacentHTML("beforeend",e)),void 0!==t&&""!==t&&s.classList.add.apply(s.classList,t.split(" ")),i&&s.setAttribute("style",i),s},text:function(e,t){var i,s,n=_.text.cloneNode(!1);if(e.content)n.innerHTML=e.content;else{if(n.textContent=e.text,e.icon){var o=_.whitespace.cloneNode(!1);(s=(!0===t?_.i:_.span).cloneNode(!1)).className=this.options.iconBase+" "+e.icon,_.fragment.appendChild(s),_.fragment.appendChild(o)}e.subtext&&((i=_.subtext.cloneNode(!1)).textContent=e.subtext,n.appendChild(i))}if(!0===t)for(;0<n.childNodes.length;)_.fragment.appendChild(n.childNodes[0]);else _.fragment.appendChild(n);return _.fragment},label:function(e){var t,i,s=_.text.cloneNode(!1);if(s.innerHTML=e.display,e.icon){var n=_.whitespace.cloneNode(!1);(i=_.span.cloneNode(!1)).className=this.options.iconBase+" "+e.icon,_.fragment.appendChild(i),_.fragment.appendChild(n)}return e.subtext&&((t=_.subtext.cloneNode(!1)).textContent=e.subtext,s.appendChild(t)),_.fragment.appendChild(s),_.fragment}},Y=function(e,t){var i=this;p.useDefault||(z.valHooks.select.set=p._set,p.useDefault=!0),this.$element=z(e),this.$newElement=null,this.$button=null,this.$menu=null,this.options=t,this.selectpicker={main:{},search:{},current:{},view:{},isSearching:!1,keydown:{keyHistory:"",resetKeyHistory:{start:function(){return setTimeout(function(){i.selectpicker.keydown.keyHistory=""},800)}}}},this.sizeInfo={},null===this.options.title&&(this.options.title=this.$element.attr("title"));var s=this.options.windowPadding;"number"==typeof s&&(this.options.windowPadding=[s,s,s,s]),this.val=Y.prototype.val,this.render=Y.prototype.render,this.refresh=Y.prototype.refresh,this.setStyle=Y.prototype.setStyle,this.selectAll=Y.prototype.selectAll,this.deselectAll=Y.prototype.deselectAll,this.destroy=Y.prototype.destroy,this.remove=Y.prototype.remove,this.show=Y.prototype.show,this.hide=Y.prototype.hide,this.init()};function Z(e){var l,a=arguments,c=e;if([].shift.apply(a),!R.success){try{R.full=(z.fn.dropdown.Constructor.VERSION||"").split(" ")[0].split(".")}catch(e){Y.BootstrapVersion?R.full=Y.BootstrapVersion.split(" ")[0].split("."):(R.full=[R.major,"0","0"],console.warn("There was an issue retrieving Bootstrap's version. Ensure Bootstrap is being loaded before bootstrap-select and there is no namespace collision. If loading Bootstrap asynchronously, the version may need to be manually specified via $.fn.selectpicker.Constructor.BootstrapVersion.",e))}R.major=R.full[0],R.success=!0}if("4"===R.major){var t=[];Y.DEFAULTS.style===V.BUTTONCLASS&&t.push({name:"style",className:"BUTTONCLASS"}),Y.DEFAULTS.iconBase===V.ICONBASE&&t.push({name:"iconBase",className:"ICONBASE"}),Y.DEFAULTS.tickIcon===V.TICKICON&&t.push({name:"tickIcon",className:"TICKICON"}),V.DIVIDER="dropdown-divider",V.SHOW="show",V.BUTTONCLASS="btn-light",V.POPOVERHEADER="popover-header",V.ICONBASE="",V.TICKICON="bs-ok-default";for(var i=0;i<t.length;i++){e=t[i];Y.DEFAULTS[e.name]=V[e.className]}}var s=this.each(function(){var e=z(this);if(e.is("select")){var t=e.data("selectpicker"),i="object"==typeof c&&c;if(t){if(i)for(var s in i)i.hasOwnProperty(s)&&(t.options[s]=i[s])}else{var n=e.data();for(var o in n)n.hasOwnProperty(o)&&-1!==z.inArray(o,d)&&delete n[o];var r=z.extend({},Y.DEFAULTS,z.fn.selectpicker.defaults||{},n,i);r.template=z.extend({},Y.DEFAULTS.template,z.fn.selectpicker.defaults?z.fn.selectpicker.defaults.template:{},n.template,i.template),e.data("selectpicker",t=new Y(this,r))}"string"==typeof c&&(l=t[c]instanceof Function?t[c].apply(t,a):t.options[c])}});return void 0!==l?l:s}Y.VERSION="1.13.14",Y.DEFAULTS={noneSelectedText:"Nothing selected",noneResultsText:"No results matched {0}",countSelectedText:function(e,t){return 1==e?"{0} item selected":"{0} items selected"},maxOptionsText:function(e,t){return[1==e?"Limit reached ({n} item max)":"Limit reached ({n} items max)",1==t?"Group limit reached ({n} item max)":"Group limit reached ({n} items max)"]},selectAllText:"Select All",deselectAllText:"Deselect All",doneButton:!1,doneButtonText:"Close",multipleSeparator:", ",styleBase:"btn",style:V.BUTTONCLASS,size:"auto",title:null,selectedTextFormat:"values",width:!1,container:!1,hideDisabled:!1,showSubtext:!1,showIcon:!0,showContent:!0,dropupAuto:!0,header:!1,liveSearch:!1,liveSearchPlaceholder:null,liveSearchNormalize:!1,liveSearchStyle:"contains",actionsBox:!1,iconBase:V.ICONBASE,tickIcon:V.TICKICON,showTick:!1,template:{caret:'<span class="caret"></span>'},maxOptions:!1,mobile:!1,selectOnTab:!1,dropdownAlignRight:!1,windowPadding:0,virtualScroll:600,display:!1,sanitize:!0,sanitizeFn:null,whiteList:e},Y.prototype={constructor:Y,init:function(){var i=this,e=this.$element.attr("id");U++,this.selectId="bs-select-"+U,this.$element[0].classList.add("bs-select-hidden"),this.multiple=this.$element.prop("multiple"),this.autofocus=this.$element.prop("autofocus"),this.$element[0].classList.contains("show-tick")&&(this.options.showTick=!0),this.$newElement=this.createDropdown(),this.buildData(),this.$element.after(this.$newElement).prependTo(this.$newElement),this.$button=this.$newElement.children("button"),this.$menu=this.$newElement.children(F.MENU),this.$menuInner=this.$menu.children(".inner"),this.$searchbox=this.$menu.find("input"),this.$element[0].classList.remove("bs-select-hidden"),!0===this.options.dropdownAlignRight&&this.$menu[0].classList.add(V.MENURIGHT),void 0!==e&&this.$button.attr("data-id",e),this.checkDisabled(),this.clickListener(),this.options.liveSearch?(this.liveSearchListener(),this.focusedParent=this.$searchbox[0]):this.focusedParent=this.$menuInner[0],this.setStyle(),this.render(),this.setWidth(),this.options.container?this.selectPosition():this.$element.on("hide"+j,function(){if(i.isVirtual()){var e=i.$menuInner[0],t=e.firstChild.cloneNode(!1);e.replaceChild(t,e.firstChild),e.scrollTop=0}}),this.$menu.data("this",this),this.$newElement.data("this",this),this.options.mobile&&this.mobile(),this.$newElement.on({"hide.bs.dropdown":function(e){i.$element.trigger("hide"+j,e)},"hidden.bs.dropdown":function(e){i.$element.trigger("hidden"+j,e)},"show.bs.dropdown":function(e){i.$element.trigger("show"+j,e)},"shown.bs.dropdown":function(e){i.$element.trigger("shown"+j,e)}}),i.$element[0].hasAttribute("required")&&this.$element.on("invalid"+j,function(){i.$button[0].classList.add("bs-invalid"),i.$element.on("shown"+j+".invalid",function(){i.$element.val(i.$element.val()).off("shown"+j+".invalid")}).on("rendered"+j,function(){this.validity.valid&&i.$button[0].classList.remove("bs-invalid"),i.$element.off("rendered"+j)}),i.$button.on("blur"+j,function(){i.$element.trigger("focus").trigger("blur"),i.$button.off("blur"+j)})}),setTimeout(function(){i.buildList(),i.$element.trigger("loaded"+j)})},createDropdown:function(){var e=this.multiple||this.options.showTick?" show-tick":"",t=this.multiple?' aria-multiselectable="true"':"",i="",s=this.autofocus?" autofocus":"";R.major<4&&this.$element.parent().hasClass("input-group")&&(i=" input-group-btn");var n,o="",r="",l="",a="";return this.options.header&&(o='<div class="'+V.POPOVERHEADER+'"><button type="button" class="close" aria-hidden="true">×</button>'+this.options.header+"</div>"),this.options.liveSearch&&(r='<div class="bs-searchbox"><input type="search" class="form-control" autocomplete="off"'+(null===this.options.liveSearchPlaceholder?"":' placeholder="'+S(this.options.liveSearchPlaceholder)+'"')+' role="combobox" aria-label="Search" aria-controls="'+this.selectId+'" aria-autocomplete="list"></div>'),this.multiple&&this.options.actionsBox&&(l='<div class="bs-actionsbox"><div class="btn-group btn-group-sm btn-block"><button type="button" class="actions-btn bs-select-all btn '+V.BUTTONCLASS+'">'+this.options.selectAllText+'</button><button type="button" class="actions-btn bs-deselect-all btn '+V.BUTTONCLASS+'">'+this.options.deselectAllText+"</button></div></div>"),this.multiple&&this.options.doneButton&&(a='<div class="bs-donebutton"><div class="btn-group btn-block"><button type="button" class="btn btn-sm '+V.BUTTONCLASS+'">'+this.options.doneButtonText+"</button></div></div>"),n='<div class="dropdown bootstrap-select'+e+i+'"><button type="button" class="'+this.options.styleBase+' dropdown-toggle" '+("static"===this.options.display?'data-display="static"':"")+'data-toggle="dropdown"'+s+' role="combobox" aria-owns="'+this.selectId+'" aria-haspopup="listbox" aria-expanded="false"><div class="filter-option"><div class="filter-option-inner"><div class="filter-option-inner-inner"></div></div> </div>'+("4"===R.major?"":'<span class="bs-caret">'+this.options.template.caret+"</span>")+'</button><div class="'+V.MENU+" "+("4"===R.major?"":V.SHOW)+'">'+o+r+l+'<div class="inner '+V.SHOW+'" role="listbox" id="'+this.selectId+'" tabindex="-1" '+t+'><ul class="'+V.MENU+" inner "+("4"===R.major?V.SHOW:"")+'" role="presentation"></ul></div>'+a+"</div></div>",z(n)},setPositionData:function(){this.selectpicker.view.canHighlight=[];for(var e=this.selectpicker.view.size=0;e<this.selectpicker.current.data.length;e++){var t=this.selectpicker.current.data[e],i=!0;"divider"===t.type?(i=!1,t.height=this.sizeInfo.dividerHeight):"optgroup-label"===t.type?(i=!1,t.height=this.sizeInfo.dropdownHeaderHeight):t.height=this.sizeInfo.liHeight,t.disabled&&(i=!1),this.selectpicker.view.canHighlight.push(i),i&&(this.selectpicker.view.size++,t.posinset=this.selectpicker.view.size),t.position=(0===e?0:this.selectpicker.current.data[e-1].position)+t.height}},isVirtual:function(){return!1!==this.options.virtualScroll&&this.selectpicker.main.elements.length>=this.options.virtualScroll||!0===this.options.virtualScroll},createView:function(A,e,t){var L,N,D=this,i=0,H=[];if(this.selectpicker.isSearching=A,this.selectpicker.current=A?this.selectpicker.search:this.selectpicker.main,this.setPositionData(),e)if(t)i=this.$menuInner[0].scrollTop;else if(!D.multiple){var s=D.$element[0],n=(s.options[s.selectedIndex]||{}).liIndex;if("number"==typeof n&&!1!==D.options.size){var o=D.selectpicker.main.data[n],r=o&&o.position;r&&(i=r-(D.sizeInfo.menuInnerHeight+D.sizeInfo.liHeight)/2)}}function l(e,t){var i,s,n,o,r,l,a,c,d=D.selectpicker.current.elements.length,h=[],p=!0,u=D.isVirtual();D.selectpicker.view.scrollTop=e,i=Math.ceil(D.sizeInfo.menuInnerHeight/D.sizeInfo.liHeight*1.5),s=Math.round(d/i)||1;for(var f=0;f<s;f++){var m=(f+1)*i;if(f===s-1&&(m=d),h[f]=[f*i+(f?1:0),m],!d)break;void 0===r&&e-1<=D.selectpicker.current.data[m-1].position-D.sizeInfo.menuInnerHeight&&(r=f)}if(void 0===r&&(r=0),l=[D.selectpicker.view.position0,D.selectpicker.view.position1],n=Math.max(0,r-1),o=Math.min(s-1,r+1),D.selectpicker.view.position0=!1===u?0:Math.max(0,h[n][0])||0,D.selectpicker.view.position1=!1===u?d:Math.min(d,h[o][1])||0,a=l[0]!==D.selectpicker.view.position0||l[1]!==D.selectpicker.view.position1,void 0!==D.activeIndex&&(N=D.selectpicker.main.elements[D.prevActiveIndex],H=D.selectpicker.main.elements[D.activeIndex],L=D.selectpicker.main.elements[D.selectedIndex],t&&(D.activeIndex!==D.selectedIndex&&D.defocusItem(H),D.activeIndex=void 0),D.activeIndex&&D.activeIndex!==D.selectedIndex&&D.defocusItem(L)),void 0!==D.prevActiveIndex&&D.prevActiveIndex!==D.activeIndex&&D.prevActiveIndex!==D.selectedIndex&&D.defocusItem(N),(t||a)&&(c=D.selectpicker.view.visibleElements?D.selectpicker.view.visibleElements.slice():[],D.selectpicker.view.visibleElements=!1===u?D.selectpicker.current.elements:D.selectpicker.current.elements.slice(D.selectpicker.view.position0,D.selectpicker.view.position1),D.setOptionStatus(),(A||!1===u&&t)&&(p=!function(e,i){return e.length===i.length&&e.every(function(e,t){return e===i[t]})}(c,D.selectpicker.view.visibleElements)),(t||!0===u)&&p)){var v,g,b=D.$menuInner[0],w=document.createDocumentFragment(),I=b.firstChild.cloneNode(!1),x=D.selectpicker.view.visibleElements,k=[];b.replaceChild(I,b.firstChild);f=0;for(var y=x.length;f<y;f++){var $,S,E=x[f];D.options.sanitize&&($=E.lastChild)&&(S=D.selectpicker.current.data[f+D.selectpicker.view.position0])&&S.content&&!S.sanitized&&(k.push($),S.sanitized=!0),w.appendChild(E)}if(D.options.sanitize&&k.length&&P(k,D.options.whiteList,D.options.sanitizeFn),!0===u?(v=0===D.selectpicker.view.position0?0:D.selectpicker.current.data[D.selectpicker.view.position0-1].position,g=D.selectpicker.view.position1>d-1?0:D.selectpicker.current.data[d-1].position-D.selectpicker.current.data[D.selectpicker.view.position1-1].position,b.firstChild.style.marginTop=v+"px",b.firstChild.style.marginBottom=g+"px"):(b.firstChild.style.marginTop=0,b.firstChild.style.marginBottom=0),b.firstChild.appendChild(w),!0===u&&D.sizeInfo.hasScrollBar){var C=b.firstChild.offsetWidth;if(t&&C<D.sizeInfo.menuInnerInnerWidth&&D.sizeInfo.totalMenuWidth>D.sizeInfo.selectWidth)b.firstChild.style.minWidth=D.sizeInfo.menuInnerInnerWidth+"px";else if(C>D.sizeInfo.menuInnerInnerWidth){D.$menu[0].style.minWidth=0;var O=b.firstChild.offsetWidth;O>D.sizeInfo.menuInnerInnerWidth&&(D.sizeInfo.menuInnerInnerWidth=O,b.firstChild.style.minWidth=D.sizeInfo.menuInnerInnerWidth+"px"),D.$menu[0].style.minWidth=""}}}if(D.prevActiveIndex=D.activeIndex,D.options.liveSearch){if(A&&t){var z,T=0;D.selectpicker.view.canHighlight[T]||(T=1+D.selectpicker.view.canHighlight.slice(1).indexOf(!0)),z=D.selectpicker.view.visibleElements[T],D.defocusItem(D.selectpicker.view.currentActive),D.activeIndex=(D.selectpicker.current.data[T]||{}).index,D.focusItem(z)}}else D.$menuInner.trigger("focus")}l(i,!0),this.$menuInner.off("scroll.createView").on("scroll.createView",function(e,t){D.noScroll||l(this.scrollTop,t),D.noScroll=!1}),z(window).off("resize"+j+"."+this.selectId+".createView").on("resize"+j+"."+this.selectId+".createView",function(){D.$newElement.hasClass(V.SHOW)&&l(D.$menuInner[0].scrollTop)})},focusItem:function(e,t,i){if(e){t=t||this.selectpicker.main.data[this.activeIndex];var s=e.firstChild;s&&(s.setAttribute("aria-setsize",this.selectpicker.view.size),s.setAttribute("aria-posinset",t.posinset),!0!==i&&(this.focusedParent.setAttribute("aria-activedescendant",s.id),e.classList.add("active"),s.classList.add("active")))}},defocusItem:function(e){e&&(e.classList.remove("active"),e.firstChild&&e.firstChild.classList.remove("active"))},setPlaceholder:function(){var e=!1;if(this.options.title&&!this.multiple){this.selectpicker.view.titleOption||(this.selectpicker.view.titleOption=document.createElement("option")),e=!0;var t=this.$element[0],i=!1,s=!this.selectpicker.view.titleOption.parentNode;if(s)this.selectpicker.view.titleOption.className="bs-title-option",this.selectpicker.view.titleOption.value="",i=void 0===z(t.options[t.selectedIndex]).attr("selected")&&void 0===this.$element.data("selected");!s&&0===this.selectpicker.view.titleOption.index||t.insertBefore(this.selectpicker.view.titleOption,t.firstChild),i&&(t.selectedIndex=0)}return e},buildData:function(){var p=':not([hidden]):not([data-hidden="true"])',u=[],f=0,e=this.setPlaceholder()?1:0;this.options.hideDisabled&&(p+=":not(:disabled)");var t=this.$element[0].querySelectorAll("select > *"+p);function m(e){var t=u[u.length-1];t&&"divider"===t.type&&(t.optID||e.optID)||((e=e||{}).type="divider",u.push(e))}function v(e,t){if((t=t||{}).divider="true"===e.getAttribute("data-divider"),t.divider)m({optID:t.optID});else{var i=u.length,s=e.style.cssText,n=s?S(s):"",o=(e.className||"")+(t.optgroupClass||"");t.optID&&(o="opt "+o),t.optionClass=o.trim(),t.inlineStyle=n,t.text=e.textContent,t.content=e.getAttribute("data-content"),t.tokens=e.getAttribute("data-tokens"),t.subtext=e.getAttribute("data-subtext"),t.icon=e.getAttribute("data-icon"),e.liIndex=i,t.display=t.content||t.text,t.type="option",t.index=i,t.option=e,t.selected=!!e.selected,t.disabled=t.disabled||!!e.disabled,u.push(t)}}function i(e,t){var i=t[e],s=t[e-1],n=t[e+1],o=i.querySelectorAll("option"+p);if(o.length){var r,l,a={display:S(i.label),subtext:i.getAttribute("data-subtext"),icon:i.getAttribute("data-icon"),type:"optgroup-label",optgroupClass:" "+(i.className||"")};f++,s&&m({optID:f}),a.optID=f,u.push(a);for(var c=0,d=o.length;c<d;c++){var h=o[c];0===c&&(l=(r=u.length-1)+d),v(h,{headerIndex:r,lastIndex:l,optID:a.optID,optgroupClass:a.optgroupClass,disabled:i.disabled})}n&&m({optID:f})}}for(var s=t.length;e<s;e++){var n=t[e];"OPTGROUP"!==n.tagName?v(n,{}):i(e,t)}this.selectpicker.main.data=this.selectpicker.current.data=u},buildList:function(){var s=this,e=this.selectpicker.main.data,n=[],o=0;function t(e){var t,i=0;switch(e.type){case"divider":t=K.li(!1,V.DIVIDER,e.optID?e.optID+"div":void 0);break;case"option":(t=K.li(K.a(K.text.call(s,e),e.optionClass,e.inlineStyle),"",e.optID)).firstChild&&(t.firstChild.id=s.selectId+"-"+e.index);break;case"optgroup-label":t=K.li(K.label.call(s,e),"dropdown-header"+e.optgroupClass,e.optID)}n.push(t),e.display&&(i+=e.display.length),e.subtext&&(i+=e.subtext.length),e.icon&&(i+=1),o<i&&(o=i,s.selectpicker.view.widestOption=n[n.length-1])}!s.options.showTick&&!s.multiple||_.checkMark.parentNode||(_.checkMark.className=this.options.iconBase+" "+s.options.tickIcon+" check-mark",_.a.appendChild(_.checkMark));for(var i=e.length,r=0;r<i;r++){t(e[r])}this.selectpicker.main.elements=this.selectpicker.current.elements=n},findLis:function(){return this.$menuInner.find(".inner > li")},render:function(){var e,t=this,i=this.$element[0],s=this.setPlaceholder()&&0===i.selectedIndex,n=O(i,this.options.hideDisabled),o=n.length,r=this.$button[0],l=r.querySelector(".filter-option-inner-inner"),a=document.createTextNode(this.options.multipleSeparator),c=_.fragment.cloneNode(!1),d=!1;if(r.classList.toggle("bs-placeholder",t.multiple?!o:!T(i,n)),this.tabIndex(),"static"===this.options.selectedTextFormat)c=K.text.call(this,{text:this.options.title},!0);else if(!1===(this.multiple&&-1!==this.options.selectedTextFormat.indexOf("count")&&1<o&&(1<(e=this.options.selectedTextFormat.split(">")).length&&o>e[1]||1===e.length&&2<=o))){if(!s){for(var h=0;h<o&&h<50;h++){var p=n[h],u=this.selectpicker.main.data[p.liIndex],f={};this.multiple&&0<h&&c.appendChild(a.cloneNode(!1)),p.title?f.text=p.title:u&&(u.content&&t.options.showContent?(f.content=u.content.toString(),d=!0):(t.options.showIcon&&(f.icon=u.icon),t.options.showSubtext&&!t.multiple&&u.subtext&&(f.subtext=" "+u.subtext),f.text=p.textContent.trim())),c.appendChild(K.text.call(this,f,!0))}49<o&&c.appendChild(document.createTextNode("..."))}}else{var m=':not([hidden]):not([data-hidden="true"]):not([data-divider="true"])';this.options.hideDisabled&&(m+=":not(:disabled)");var v=this.$element[0].querySelectorAll("select > option"+m+", optgroup"+m+" option"+m).length,g="function"==typeof this.options.countSelectedText?this.options.countSelectedText(o,v):this.options.countSelectedText;c=K.text.call(this,{text:g.replace("{0}",o.toString()).replace("{1}",v.toString())},!0)}if(null==this.options.title&&(this.options.title=this.$element.attr("title")),c.childNodes.length||(c=K.text.call(this,{text:void 0!==this.options.title?this.options.title:this.options.noneSelectedText},!0)),r.title=c.textContent.replace(/<[^>]*>?/g,"").trim(),this.options.sanitize&&d&&P([c],t.options.whiteList,t.options.sanitizeFn),l.innerHTML="",l.appendChild(c),R.major<4&&this.$newElement[0].classList.contains("bs3-has-addon")){var b=r.querySelector(".filter-expand"),w=l.cloneNode(!0);w.className="filter-expand",b?r.replaceChild(w,b):r.appendChild(w)}this.$element.trigger("rendered"+j)},setStyle:function(e,t){var i,s=this.$button[0],n=this.$newElement[0],o=this.options.style.trim();this.$element.attr("class")&&this.$newElement.addClass(this.$element.attr("class").replace(/selectpicker|mobile-device|bs-select-hidden|validate\[.*\]/gi,"")),R.major<4&&(n.classList.add("bs3"),n.parentNode.classList.contains("input-group")&&(n.previousElementSibling||n.nextElementSibling)&&(n.previousElementSibling||n.nextElementSibling).classList.contains("input-group-addon")&&n.classList.add("bs3-has-addon")),i=e?e.trim():o,"add"==t?i&&s.classList.add.apply(s.classList,i.split(" ")):"remove"==t?i&&s.classList.remove.apply(s.classList,i.split(" ")):(o&&s.classList.remove.apply(s.classList,o.split(" ")),i&&s.classList.add.apply(s.classList,i.split(" ")))},liHeight:function(e){if(e||!1!==this.options.size&&!Object.keys(this.sizeInfo).length){var t=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div"),n=document.createElement("ul"),o=document.createElement("li"),r=document.createElement("li"),l=document.createElement("li"),a=document.createElement("a"),c=document.createElement("span"),d=this.options.header&&0<this.$menu.find("."+V.POPOVERHEADER).length?this.$menu.find("."+V.POPOVERHEADER)[0].cloneNode(!0):null,h=this.options.liveSearch?document.createElement("div"):null,p=this.options.actionsBox&&this.multiple&&0<this.$menu.find(".bs-actionsbox").length?this.$menu.find(".bs-actionsbox")[0].cloneNode(!0):null,u=this.options.doneButton&&this.multiple&&0<this.$menu.find(".bs-donebutton").length?this.$menu.find(".bs-donebutton")[0].cloneNode(!0):null,f=this.$element.find("option")[0];if(this.sizeInfo.selectWidth=this.$newElement[0].offsetWidth,c.className="text",a.className="dropdown-item "+(f?f.className:""),t.className=this.$menu[0].parentNode.className+" "+V.SHOW,t.style.width=0,"auto"===this.options.width&&(i.style.minWidth=0),i.className=V.MENU+" "+V.SHOW,s.className="inner "+V.SHOW,n.className=V.MENU+" inner "+("4"===R.major?V.SHOW:""),o.className=V.DIVIDER,r.className="dropdown-header",c.appendChild(document.createTextNode("\u200b")),a.appendChild(c),l.appendChild(a),r.appendChild(c.cloneNode(!0)),this.selectpicker.view.widestOption&&n.appendChild(this.selectpicker.view.widestOption.cloneNode(!0)),n.appendChild(l),n.appendChild(o),n.appendChild(r),d&&i.appendChild(d),h){var m=document.createElement("input");h.className="bs-searchbox",m.className="form-control",h.appendChild(m),i.appendChild(h)}p&&i.appendChild(p),s.appendChild(n),i.appendChild(s),u&&i.appendChild(u),t.appendChild(i),document.body.appendChild(t);var v,g=l.offsetHeight,b=r?r.offsetHeight:0,w=d?d.offsetHeight:0,I=h?h.offsetHeight:0,x=p?p.offsetHeight:0,k=u?u.offsetHeight:0,y=z(o).outerHeight(!0),$=!!window.getComputedStyle&&window.getComputedStyle(i),S=i.offsetWidth,E=$?null:z(i),C={vert:L($?$.paddingTop:E.css("paddingTop"))+L($?$.paddingBottom:E.css("paddingBottom"))+L($?$.borderTopWidth:E.css("borderTopWidth"))+L($?$.borderBottomWidth:E.css("borderBottomWidth")),horiz:L($?$.paddingLeft:E.css("paddingLeft"))+L($?$.paddingRight:E.css("paddingRight"))+L($?$.borderLeftWidth:E.css("borderLeftWidth"))+L($?$.borderRightWidth:E.css("borderRightWidth"))},O={vert:C.vert+L($?$.marginTop:E.css("marginTop"))+L($?$.marginBottom:E.css("marginBottom"))+2,horiz:C.horiz+L($?$.marginLeft:E.css("marginLeft"))+L($?$.marginRight:E.css("marginRight"))+2};s.style.overflowY="scroll",v=i.offsetWidth-S,document.body.removeChild(t),this.sizeInfo.liHeight=g,this.sizeInfo.dropdownHeaderHeight=b,this.sizeInfo.headerHeight=w,this.sizeInfo.searchHeight=I,this.sizeInfo.actionsHeight=x,this.sizeInfo.doneButtonHeight=k,this.sizeInfo.dividerHeight=y,this.sizeInfo.menuPadding=C,this.sizeInfo.menuExtras=O,this.sizeInfo.menuWidth=S,this.sizeInfo.menuInnerInnerWidth=S-C.horiz,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth,this.sizeInfo.scrollBarWidth=v,this.sizeInfo.selectHeight=this.$newElement[0].offsetHeight,this.setPositionData()}},getSelectPosition:function(){var e,t=z(window),i=this.$newElement.offset(),s=z(this.options.container);this.options.container&&s.length&&!s.is("body")?((e=s.offset()).top+=parseInt(s.css("borderTopWidth")),e.left+=parseInt(s.css("borderLeftWidth"))):e={top:0,left:0};var n=this.options.windowPadding;this.sizeInfo.selectOffsetTop=i.top-e.top-t.scrollTop(),this.sizeInfo.selectOffsetBot=t.height()-this.sizeInfo.selectOffsetTop-this.sizeInfo.selectHeight-e.top-n[2],this.sizeInfo.selectOffsetLeft=i.left-e.left-t.scrollLeft(),this.sizeInfo.selectOffsetRight=t.width()-this.sizeInfo.selectOffsetLeft-this.sizeInfo.selectWidth-e.left-n[1],this.sizeInfo.selectOffsetTop-=n[0],this.sizeInfo.selectOffsetLeft-=n[3]},setMenuSize:function(e){this.getSelectPosition();var t,i,s,n,o,r,l,a,c=this.sizeInfo.selectWidth,d=this.sizeInfo.liHeight,h=this.sizeInfo.headerHeight,p=this.sizeInfo.searchHeight,u=this.sizeInfo.actionsHeight,f=this.sizeInfo.doneButtonHeight,m=this.sizeInfo.dividerHeight,v=this.sizeInfo.menuPadding,g=0;if(this.options.dropupAuto&&(l=d*this.selectpicker.current.elements.length+v.vert,a=this.sizeInfo.selectOffsetTop-this.sizeInfo.selectOffsetBot>this.sizeInfo.menuExtras.vert&&l+this.sizeInfo.menuExtras.vert+50>this.sizeInfo.selectOffsetBot,!0===this.selectpicker.isSearching&&(a=this.selectpicker.dropup),this.$newElement.toggleClass(V.DROPUP,a),this.selectpicker.dropup=a),"auto"===this.options.size)n=3<this.selectpicker.current.elements.length?3*this.sizeInfo.liHeight+this.sizeInfo.menuExtras.vert-2:0,i=this.sizeInfo.selectOffsetBot-this.sizeInfo.menuExtras.vert,s=n+h+p+u+f,r=Math.max(n-v.vert,0),this.$newElement.hasClass(V.DROPUP)&&(i=this.sizeInfo.selectOffsetTop-this.sizeInfo.menuExtras.vert),t=(o=i)-h-p-u-f-v.vert;else if(this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size){for(var b=0;b<this.options.size;b++)"divider"===this.selectpicker.current.data[b].type&&g++;t=(i=d*this.options.size+g*m+v.vert)-v.vert,o=i+h+p+u+f,s=r=""}this.$menu.css({"max-height":o+"px",overflow:"hidden","min-height":s+"px"}),this.$menuInner.css({"max-height":t+"px","overflow-y":"auto","min-height":r+"px"}),this.sizeInfo.menuInnerHeight=Math.max(t,1),this.selectpicker.current.data.length&&this.selectpicker.current.data[this.selectpicker.current.data.length-1].position>this.sizeInfo.menuInnerHeight&&(this.sizeInfo.hasScrollBar=!0,this.sizeInfo.totalMenuWidth=this.sizeInfo.menuWidth+this.sizeInfo.scrollBarWidth),"auto"===this.options.dropdownAlignRight&&this.$menu.toggleClass(V.MENURIGHT,this.sizeInfo.selectOffsetLeft>this.sizeInfo.selectOffsetRight&&this.sizeInfo.selectOffsetRight<this.sizeInfo.totalMenuWidth-c),this.dropdown&&this.dropdown._popper&&this.dropdown._popper.update()},setSize:function(e){if(this.liHeight(e),this.options.header&&this.$menu.css("padding-top",0),!1!==this.options.size){var t=this,i=z(window);this.setMenuSize(),this.options.liveSearch&&this.$searchbox.off("input.setMenuSize propertychange.setMenuSize").on("input.setMenuSize propertychange.setMenuSize",function(){return t.setMenuSize()}),"auto"===this.options.size?i.off("resize"+j+"."+this.selectId+".setMenuSize scroll"+j+"."+this.selectId+".setMenuSize").on("resize"+j+"."+this.selectId+".setMenuSize scroll"+j+"."+this.selectId+".setMenuSize",function(){return t.setMenuSize()}):this.options.size&&"auto"!=this.options.size&&this.selectpicker.current.elements.length>this.options.size&&i.off("resize"+j+"."+this.selectId+".setMenuSize scroll"+j+"."+this.selectId+".setMenuSize")}this.createView(!1,!0,e)},setWidth:function(){var i=this;"auto"===this.options.width?requestAnimationFrame(function(){i.$menu.css("min-width","0"),i.$element.on("loaded"+j,function(){i.liHeight(),i.setMenuSize();var e=i.$newElement.clone().appendTo("body"),t=e.css("width","auto").children("button").outerWidth();e.remove(),i.sizeInfo.selectWidth=Math.max(i.sizeInfo.totalMenuWidth,t),i.$newElement.css("width",i.sizeInfo.selectWidth+"px")})}):"fit"===this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width","").addClass("fit-width")):this.options.width?(this.$menu.css("min-width",""),this.$newElement.css("width",this.options.width)):(this.$menu.css("min-width",""),this.$newElement.css("width","")),this.$newElement.hasClass("fit-width")&&"fit"!==this.options.width&&this.$newElement[0].classList.remove("fit-width")},selectPosition:function(){this.$bsContainer=z('<div class="bs-container" />');function e(e){var t={},i=r.options.display||!!z.fn.dropdown.Constructor.Default&&z.fn.dropdown.Constructor.Default.display;r.$bsContainer.addClass(e.attr("class").replace(/form-control|fit-width/gi,"")).toggleClass(V.DROPUP,e.hasClass(V.DROPUP)),s=e.offset(),l.is("body")?n={top:0,left:0}:((n=l.offset()).top+=parseInt(l.css("borderTopWidth"))-l.scrollTop(),n.left+=parseInt(l.css("borderLeftWidth"))-l.scrollLeft()),o=e.hasClass(V.DROPUP)?0:e[0].offsetHeight,(R.major<4||"static"===i)&&(t.top=s.top-n.top+o,t.left=s.left-n.left),t.width=e[0].offsetWidth,r.$bsContainer.css(t)}var s,n,o,r=this,l=z(this.options.container);this.$button.on("click.bs.dropdown.data-api",function(){r.isDisabled()||(e(r.$newElement),r.$bsContainer.appendTo(r.options.container).toggleClass(V.SHOW,!r.$button.hasClass(V.SHOW)).append(r.$menu))}),z(window).off("resize"+j+"."+this.selectId+" scroll"+j+"."+this.selectId).on("resize"+j+"."+this.selectId+" scroll"+j+"."+this.selectId,function(){r.$newElement.hasClass(V.SHOW)&&e(r.$newElement)}),this.$element.on("hide"+j,function(){r.$menu.data("height",r.$menu.height()),r.$bsContainer.detach()})},setOptionStatus:function(e){var t=this;if(t.noScroll=!1,t.selectpicker.view.visibleElements&&t.selectpicker.view.visibleElements.length)for(var i=0;i<t.selectpicker.view.visibleElements.length;i++){var s=t.selectpicker.current.data[i+t.selectpicker.view.position0],n=s.option;n&&(!0!==e&&t.setDisabled(s.index,s.disabled),t.setSelected(s.index,n.selected))}},setSelected:function(e,t){var i,s,n=this.selectpicker.main.elements[e],o=this.selectpicker.main.data[e],r=void 0!==this.activeIndex,l=this.activeIndex===e||t&&!this.multiple&&!r;o.selected=t,s=n.firstChild,t&&(this.selectedIndex=e),n.classList.toggle("selected",t),l?(this.focusItem(n,o),this.selectpicker.view.currentActive=n,this.activeIndex=e):this.defocusItem(n),s&&(s.classList.toggle("selected",t),t?s.setAttribute("aria-selected",!0):this.multiple?s.setAttribute("aria-selected",!1):s.removeAttribute("aria-selected")),l||r||!t||void 0===this.prevActiveIndex||(i=this.selectpicker.main.elements[this.prevActiveIndex],this.defocusItem(i))},setDisabled:function(e,t){var i,s=this.selectpicker.main.elements[e];this.selectpicker.main.data[e].disabled=t,i=s.firstChild,s.classList.toggle(V.DISABLED,t),i&&("4"===R.major&&i.classList.toggle(V.DISABLED,t),t?(i.setAttribute("aria-disabled",t),i.setAttribute("tabindex",-1)):(i.removeAttribute("aria-disabled"),i.setAttribute("tabindex",0)))},isDisabled:function(){return this.$element[0].disabled},checkDisabled:function(){this.isDisabled()?(this.$newElement[0].classList.add(V.DISABLED),this.$button.addClass(V.DISABLED).attr("tabindex",-1).attr("aria-disabled",!0)):(this.$button[0].classList.contains(V.DISABLED)&&(this.$newElement[0].classList.remove(V.DISABLED),this.$button.removeClass(V.DISABLED).attr("aria-disabled",!1)),-1!=this.$button.attr("tabindex")||this.$element.data("tabindex")||this.$button.removeAttr("tabindex"))},tabIndex:function(){this.$element.data("tabindex")!==this.$element.attr("tabindex")&&-98!==this.$element.attr("tabindex")&&"-98"!==this.$element.attr("tabindex")&&(this.$element.data("tabindex",this.$element.attr("tabindex")),this.$button.attr("tabindex",this.$element.data("tabindex"))),this.$element.attr("tabindex",-98)},clickListener:function(){var C=this,t=z(document);function e(){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$menuInner.trigger("focus")}function i(){C.dropdown&&C.dropdown._popper&&C.dropdown._popper.state.isCreated?e():requestAnimationFrame(i)}t.data("spaceSelect",!1),this.$button.on("keyup",function(e){/(32)/.test(e.keyCode.toString(10))&&t.data("spaceSelect")&&(e.preventDefault(),t.data("spaceSelect",!1))}),this.$newElement.on("show.bs.dropdown",function(){3<R.major&&!C.dropdown&&(C.dropdown=C.$button.data("bs.dropdown"),C.dropdown._menu=C.$menu[0])}),this.$button.on("click.bs.dropdown.data-api",function(){C.$newElement.hasClass(V.SHOW)||C.setSize()}),this.$element.on("shown"+j,function(){C.$menuInner[0].scrollTop!==C.selectpicker.view.scrollTop&&(C.$menuInner[0].scrollTop=C.selectpicker.view.scrollTop),3<R.major?requestAnimationFrame(i):e()}),this.$menuInner.on("mouseenter","li a",function(e){var t=this.parentElement,i=C.isVirtual()?C.selectpicker.view.position0:0,s=Array.prototype.indexOf.call(t.parentElement.children,t),n=C.selectpicker.current.data[s+i];C.focusItem(t,n,!0)}),this.$menuInner.on("click","li a",function(e,t){var i=z(this),s=C.$element[0],n=C.isVirtual()?C.selectpicker.view.position0:0,o=C.selectpicker.current.data[i.parent().index()+n],r=o.index,l=T(s),a=s.selectedIndex,c=s.options[a],d=!0;if(C.multiple&&1!==C.options.maxOptions&&e.stopPropagation(),e.preventDefault(),!C.isDisabled()&&!i.parent().hasClass(V.DISABLED)){var h=o.option,p=z(h),u=h.selected,f=p.parent("optgroup"),m=f.find("option"),v=C.options.maxOptions,g=f.data("maxOptions")||!1;if(r===C.activeIndex&&(t=!0),t||(C.prevActiveIndex=C.activeIndex,C.activeIndex=void 0),C.multiple){if(h.selected=!u,C.setSelected(r,!u),i.trigger("blur"),!1!==v||!1!==g){var b=v<O(s).length,w=g<f.find("option:selected").length;if(v&&b||g&&w)if(v&&1==v)s.selectedIndex=-1,h.selected=!0,C.setOptionStatus(!0);else if(g&&1==g){for(var I=0;I<m.length;I++){var x=m[I];x.selected=!1,C.setSelected(x.liIndex,!1)}h.selected=!0,C.setSelected(r,!0)}else{var k="string"==typeof C.options.maxOptionsText?[C.options.maxOptionsText,C.options.maxOptionsText]:C.options.maxOptionsText,y="function"==typeof k?k(v,g):k,$=y[0].replace("{n}",v),S=y[1].replace("{n}",g),E=z('<div class="notify"></div>');y[2]&&($=$.replace("{var}",y[2][1<v?0:1]),S=S.replace("{var}",y[2][1<g?0:1])),h.selected=!1,C.$menu.append(E),v&&b&&(E.append(z("<div>"+$+"</div>")),d=!1,C.$element.trigger("maxReached"+j)),g&&w&&(E.append(z("<div>"+S+"</div>")),d=!1,C.$element.trigger("maxReachedGrp"+j)),setTimeout(function(){C.setSelected(r,!1)},10),E[0].classList.add("fadeOut"),setTimeout(function(){E.remove()},1050)}}}else c&&(c.selected=!1),h.selected=!0,C.setSelected(r,!0);!C.multiple||C.multiple&&1===C.options.maxOptions?C.$button.trigger("focus"):C.options.liveSearch&&C.$searchbox.trigger("focus"),d&&(!C.multiple&&a===s.selectedIndex||(A=[h.index,p.prop("selected"),l],C.$element.triggerNative("change")))}}),this.$menu.on("click","li."+V.DISABLED+" a, ."+V.POPOVERHEADER+", ."+V.POPOVERHEADER+" :not(.close)",function(e){e.currentTarget==this&&(e.preventDefault(),e.stopPropagation(),C.options.liveSearch&&!z(e.target).hasClass("close")?C.$searchbox.trigger("focus"):C.$button.trigger("focus"))}),this.$menuInner.on("click",".divider, .dropdown-header",function(e){e.preventDefault(),e.stopPropagation(),C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus")}),this.$menu.on("click","."+V.POPOVERHEADER+" .close",function(){C.$button.trigger("click")}),this.$searchbox.on("click",function(e){e.stopPropagation()}),this.$menu.on("click",".actions-btn",function(e){C.options.liveSearch?C.$searchbox.trigger("focus"):C.$button.trigger("focus"),e.preventDefault(),e.stopPropagation(),z(this).hasClass("bs-select-all")?C.selectAll():C.deselectAll()}),this.$element.on("change"+j,function(){C.render(),C.$element.trigger("changed"+j,A),A=null}).on("focus"+j,function(){C.options.mobile||C.$button.trigger("focus")})},liveSearchListener:function(){var u=this,f=document.createElement("li");this.$button.on("click.bs.dropdown.data-api",function(){u.$searchbox.val()&&u.$searchbox.val("")}),this.$searchbox.on("click.bs.dropdown.data-api focus.bs.dropdown.data-api touchend.bs.dropdown.data-api",function(e){e.stopPropagation()}),this.$searchbox.on("input propertychange",function(){var e=u.$searchbox.val();if(u.selectpicker.search.elements=[],u.selectpicker.search.data=[],e){var t=[],i=e.toUpperCase(),s={},n=[],o=u._searchStyle(),r=u.options.liveSearchNormalize;r&&(i=w(i));for(var l=0;l<u.selectpicker.main.data.length;l++){var a=u.selectpicker.main.data[l];s[l]||(s[l]=k(a,i,o,r)),s[l]&&void 0!==a.headerIndex&&-1===n.indexOf(a.headerIndex)&&(0<a.headerIndex&&(s[a.headerIndex-1]=!0,n.push(a.headerIndex-1)),s[a.headerIndex]=!0,n.push(a.headerIndex),s[a.lastIndex+1]=!0),s[l]&&"optgroup-label"!==a.type&&n.push(l)}l=0;for(var c=n.length;l<c;l++){var d=n[l],h=n[l-1],p=(a=u.selectpicker.main.data[d],u.selectpicker.main.data[h]);("divider"!==a.type||"divider"===a.type&&p&&"divider"!==p.type&&c-1!==l)&&(u.selectpicker.search.data.push(a),t.push(u.selectpicker.main.elements[d]))}u.activeIndex=void 0,u.noScroll=!0,u.$menuInner.scrollTop(0),u.selectpicker.search.elements=t,u.createView(!0),t.length||(f.className="no-results",f.innerHTML=u.options.noneResultsText.replace("{0}",'"'+S(e)+'"'),u.$menuInner[0].firstChild.appendChild(f))}else u.$menuInner.scrollTop(0),u.createView(!1)})},_searchStyle:function(){return this.options.liveSearchStyle||"contains"},val:function(e){var t=this.$element[0];if(void 0===e)return this.$element.val();var i=T(t);if(A=[null,null,i],this.$element.val(e).trigger("changed"+j,A),this.$newElement.hasClass(V.SHOW))if(this.multiple)this.setOptionStatus(!0);else{var s=(t.options[t.selectedIndex]||{}).liIndex;"number"==typeof s&&(this.setSelected(this.selectedIndex,!1),this.setSelected(s,!0))}return this.render(),A=null,this.$element},changeAll:function(e){if(this.multiple){void 0===e&&(e=!0);var t=this.$element[0],i=0,s=0,n=T(t);t.classList.add("bs-select-hidden");for(var o=0,r=this.selectpicker.current.data,l=r.length;o<l;o++){var a=r[o],c=a.option;c&&!a.disabled&&"divider"!==a.type&&(a.selected&&i++,!0===(c.selected=e)&&s++)}t.classList.remove("bs-select-hidden"),i!==s&&(this.setOptionStatus(),A=[null,null,n],this.$element.triggerNative("change"))}},selectAll:function(){return this.changeAll(!0)},deselectAll:function(){return this.changeAll(!1)},toggle:function(e){(e=e||window.event)&&e.stopPropagation(),this.$button.trigger("click.bs.dropdown.data-api")},keydown:function(e){var t,i,s,n,o,r=z(this),l=r.hasClass("dropdown-toggle"),a=(l?r.closest(".dropdown"):r.closest(F.MENU)).data("this"),c=a.findLis(),d=!1,h=e.which===W&&!l&&!a.options.selectOnTab,p=G.test(e.which)||h,u=a.$menuInner[0].scrollTop,f=!0===a.isVirtual()?a.selectpicker.view.position0:0;if(!(112<=e.which&&e.which<=123))if(!(i=a.$newElement.hasClass(V.SHOW))&&(p||48<=e.which&&e.which<=57||96<=e.which&&e.which<=105||65<=e.which&&e.which<=90)&&(a.$button.trigger("click.bs.dropdown.data-api"),a.options.liveSearch))a.$searchbox.trigger("focus");else{if(e.which===N&&i&&(e.preventDefault(),a.$button.trigger("click.bs.dropdown.data-api").trigger("focus")),p){if(!c.length)return;-1!==(t=(s=a.selectpicker.main.elements[a.activeIndex])?Array.prototype.indexOf.call(s.parentElement.children,s):-1)&&a.defocusItem(s),e.which===B?(-1!==t&&t--,t+f<0&&(t+=c.length),a.selectpicker.view.canHighlight[t+f]||-1===(t=a.selectpicker.view.canHighlight.slice(0,t+f).lastIndexOf(!0)-f)&&(t=c.length-1)):e.which!==M&&!h||(++t+f>=a.selectpicker.view.canHighlight.length&&(t=0),a.selectpicker.view.canHighlight[t+f]||(t=t+1+a.selectpicker.view.canHighlight.slice(t+f+1).indexOf(!0))),e.preventDefault();var m=f+t;e.which===B?0===f&&t===c.length-1?(a.$menuInner[0].scrollTop=a.$menuInner[0].scrollHeight,m=a.selectpicker.current.elements.length-1):d=(o=(n=a.selectpicker.current.data[m]).position-n.height)<u:e.which!==M&&!h||(0===t?m=a.$menuInner[0].scrollTop=0:d=u<(o=(n=a.selectpicker.current.data[m]).position-a.sizeInfo.menuInnerHeight)),s=a.selectpicker.current.elements[m],a.activeIndex=a.selectpicker.current.data[m].index,a.focusItem(s),a.selectpicker.view.currentActive=s,d&&(a.$menuInner[0].scrollTop=o),a.options.liveSearch?a.$searchbox.trigger("focus"):r.trigger("focus")}else if(!r.is("input")&&!q.test(e.which)||e.which===H&&a.selectpicker.keydown.keyHistory){var v,g,b=[];e.preventDefault(),a.selectpicker.keydown.keyHistory+=C[e.which],a.selectpicker.keydown.resetKeyHistory.cancel&&clearTimeout(a.selectpicker.keydown.resetKeyHistory.cancel),a.selectpicker.keydown.resetKeyHistory.cancel=a.selectpicker.keydown.resetKeyHistory.start(),g=a.selectpicker.keydown.keyHistory,/^(.)\1+$/.test(g)&&(g=g.charAt(0));for(var w=0;w<a.selectpicker.current.data.length;w++){var I=a.selectpicker.current.data[w];k(I,g,"startsWith",!0)&&a.selectpicker.view.canHighlight[w]&&b.push(I.index)}if(b.length){var x=0;c.removeClass("active").find("a").removeClass("active"),1===g.length&&(-1===(x=b.indexOf(a.activeIndex))||x===b.length-1?x=0:x++),v=b[x],d=0<u-(n=a.selectpicker.main.data[v]).position?(o=n.position-n.height,!0):(o=n.position-a.sizeInfo.menuInnerHeight,n.position>u+a.sizeInfo.menuInnerHeight),s=a.selectpicker.main.elements[v],a.activeIndex=b[x],a.focusItem(s),s&&s.firstChild.focus(),d&&(a.$menuInner[0].scrollTop=o),r.trigger("focus")}}i&&(e.which===H&&!a.selectpicker.keydown.keyHistory||e.which===D||e.which===W&&a.options.selectOnTab)&&(e.which!==H&&e.preventDefault(),a.options.liveSearch&&e.which===H||(a.$menuInner.find(".active a").trigger("click",!0),r.trigger("focus"),a.options.liveSearch||(e.preventDefault(),z(document).data("spaceSelect",!0))))}},mobile:function(){this.$element[0].classList.add("mobile-device")},refresh:function(){var e=z.extend({},this.options,this.$element.data());this.options=e,this.checkDisabled(),this.setStyle(),this.buildData(),this.render(),this.buildList(),this.setWidth(),this.setSize(!0),this.$element.trigger("refreshed"+j)},hide:function(){this.$newElement.hide()},show:function(){this.$newElement.show()},remove:function(){this.$newElement.remove(),this.$element.remove()},destroy:function(){this.$newElement.before(this.$element).remove(),this.$bsContainer?this.$bsContainer.remove():this.$menu.remove(),this.$element.off(j).removeData("selectpicker").removeClass("bs-select-hidden selectpicker"),z(window).off(j+"."+this.selectId)}};var J=z.fn.selectpicker;z.fn.selectpicker=Z,z.fn.selectpicker.Constructor=Y,z.fn.selectpicker.noConflict=function(){return z.fn.selectpicker=J,this};var Q=z.fn.dropdown.Constructor._dataApiKeydownHandler||z.fn.dropdown.Constructor.prototype.keydown;z(document).off("keydown.bs.dropdown.data-api").on("keydown.bs.dropdown.data-api",':not(.bootstrap-select) > [data-toggle="dropdown"]',Q).on("keydown.bs.dropdown.data-api",":not(.bootstrap-select) > .dropdown-menu",Q).on("keydown"+j,'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',Y.prototype.keydown).on("focusin.modal",'.bootstrap-select [data-toggle="dropdown"], .bootstrap-select [role="listbox"], .bootstrap-select .bs-searchbox input',function(e){e.stopPropagation()}),z(window).on("load"+j+".data-api",function(){z(".selectpicker").each(function(){var e=z(this);Z.call(e,e.data())})})}(e)});
|
|
//# sourceMappingURL=bootstrap-select.min.js.map
|
|
$.fn.selectpicker.Constructor.DEFAULTS = Object.assign($.fn.selectpicker.Constructor.DEFAULTS, {
|
|
|
|
deselectAllText: "全不选",
|
|
doneButtonText: "关闭",
|
|
noneResultsText: "未找到 {0}",
|
|
noneSelectedText: "未选择...",
|
|
selectAllText: "全选",
|
|
countSelectedText: function (numSelected, numTotal) {
|
|
return '{0} 个选中';
|
|
},
|
|
maxOptionsText: function (numAll, numGroup) {
|
|
return [
|
|
'最多{n}项可选',
|
|
'最多{n}组可选'
|
|
];
|
|
},
|
|
});
|
|
!function(G,b){function t(t,e){var i,s,o=this;e=e||{},this.$element=G(t),this.options=G.extend(!0,{},G.fn.ajaxSelectPicker.defaults,e),this.LOG_ERROR=1,this.LOG_WARNING=2,this.LOG_INFO=3,this.LOG_DEBUG=4,this.lastRequest=!1,this.previousQuery="",this.query="",this.request=!1;var l=[{from:"ajaxResultsPreHook",to:"preprocessData"},{from:"ajaxSearchUrl",to:{ajax:{url:"{{{value}}}"}}},{from:"ajaxOptions",to:"ajax"},{from:"debug",to:function(t){var e={};e.log=!!o.options[t.from],o.options=G.extend(!0,{},o.options,e),delete o.options[t.from],o.log(o.LOG_WARNING,'Deprecated option "'+t.from+'". Update code to use:',e)}},{from:"mixWithCurrents",to:"preserveSelected"},{from:"placeHolderOption",to:{locale:{emptyTitle:"{{{value}}}"}}}];l.length&&G.map(l,function(t){if(o.options[t.from])if(G.isPlainObject(t.to))o.replaceValue(t.to,"{{{value}}}",o.options[t.from]),o.options=G.extend(!0,{},o.options,t.to),o.log(o.LOG_WARNING,'Deprecated option "'+t.from+'". Update code to use:',t.to),delete o.options[t.from];else if(G.isFunction(t.to))t.to.apply(o,[t]);else{var e={};e[t.to]=o.options[t.from],o.options=G.extend(!0,{},o.options,e),o.log(o.LOG_WARNING,'Deprecated option "'+t.from+'". Update code to use:',e),delete o.options[t.from]}});var n=this.$element.data();function a(t,e){return e.toLowerCase()}n.searchUrl&&(o.log(o.LOG_WARNING,'Deprecated attribute name: "data-search-url". Update markup to use: \' data-abs-ajax-url="'+n.searchUrl+"\" '"),this.options.ajax.url=n.searchUrl);var r=function(t,e,i){var s=[].concat(t),o=s.length,l=i||{};if(o){var n=s.shift();l[n]=r(s,e,l[n])}return o?l:e},p=Object.keys(n).filter(/./.test.bind(new RegExp("^abs[A-Z]")));if(p.length){var c={},h=["locale"];for(i=0,s=p.length;i<s;i++){var u=p[i].replace(/^abs([A-Z])/,a).replace(/([A-Z])/g,"-$1").toLowerCase(),g=u.split("-");if(g[0]&&1<g.length&&-1!==h.indexOf(g[0])){for(var d=[g.shift()],f="",y=0;y<g.length;y++)f+=0===y?g[y]:g[y].charAt(0).toUpperCase()+g[y].slice(1);d.push(f),g=d}this.log(this.LOG_DEBUG,'Processing data attribute "data-abs-'+u+'":',n[p[i]]),r(g,n[p[i]],c)}this.options=G.extend(!0,{},this.options,c),this.log(this.LOG_DEBUG,"Merged in the data attribute options: ",c,this.options)}if(this.selectpicker=n.selectpicker,!this.selectpicker)return this.log(this.LOG_ERROR,"Cannot instantiate an AjaxBootstrapSelect instance without selectpicker first being initialized!"),null;if(!this.options.ajax.url)return this.log(this.LOG_ERROR,'Option "ajax.url" must be set! Options:',this.options),null;if(this.locale=G.extend(!0,{},G.fn.ajaxSelectPicker.locale),this.options.langCode=this.options.langCode||b.navigator.userLanguage||b.navigator.language||"en",!this.locale[this.options.langCode]){var O=this.options.langCode;this.options.langCode="en";var v=O.split("-");for(i=0,s=v.length;i<s;i++){var m=v.join("-");if(m.length&&this.locale[m]){this.options.langCode=m;break}v.pop()}this.log(this.LOG_WARNING,'Unknown langCode option: "'+O+'". Using the following langCode instead: "'+this.options.langCode+'".')}this.locale[this.options.langCode]=G.extend(!0,{},this.locale[this.options.langCode],this.options.locale),this.list=new b.AjaxBootstrapSelectList(this),this.list.refresh(),setTimeout(function(){o.init()},500)}t.prototype.init=function(){var s,o=this;this.options.preserveSelected&&this.selectpicker.$menu.off("click",".actions-btn").on("click",".actions-btn",function(t){o.selectpicker.options.liveSearch?o.selectpicker.$searchbox.focus():o.selectpicker.$button.focus(),t.preventDefault(),t.stopPropagation(),G(this).is(".bs-select-all")?(null===o.selectpicker.$lis&&(o.selectpicker.$lis=o.selectpicker.$menu.find("li")),o.$element.find("option:enabled").prop("selected",!0),G(o.selectpicker.$lis).not(".disabled").addClass("selected")):(null===o.selectpicker.$lis&&(o.selectpicker.$lis=o.selectpicker.$menu.find("li")),o.$element.find("option:enabled").prop("selected",!1),G(o.selectpicker.$lis).not(".disabled").removeClass("selected")),o.selectpicker.render(),o.selectpicker.$element.change()}),this.selectpicker.$searchbox.attr("placeholder",this.t("searchPlaceholder")).off("input propertychange"),this.selectpicker.$searchbox.on(this.options.bindEvent,function(t){var e=o.selectpicker.$searchbox.val();if(o.log(o.LOG_DEBUG,'Bind event fired: "'+o.options.bindEvent+'", keyCode:',t.keyCode,t),o.options.cache||(o.options.ignoredKeys[13]="enter"),o.options.ignoredKeys[t.keyCode])o.log(o.LOG_DEBUG,"Key ignored.");else if(clearTimeout(s),e.length||(o.options.clearOnEmpty&&o.list.destroy(),o.options.emptyRequest))if(e.length<o.options.minLength)o.list.setStatus(o.t("statusTooShort"));else{if(o.previousQuery=o.query,o.query=e,o.options.cache&&13!==t.keyCode){var i=o.list.cacheGet(o.query);if(i)return o.list.setStatus(i.length?"":o.t("statusNoResults")),o.list.replaceOptions(i),void o.log(o.LOG_INFO,"Rebuilt options from cached data.")}s=setTimeout(function(){o.lastRequest&&o.lastRequest.jqXHR&&G.isFunction(o.lastRequest.jqXHR.abort)&&o.lastRequest.jqXHR.abort(),o.request=new b.AjaxBootstrapSelectRequest(o),o.request.jqXHR.always(function(){o.lastRequest=o.request,o.request=!1})},o.options.requestDelay||300)}})},t.prototype.log=function(t,e){if(b.console&&this.options.log){if("number"!=typeof this.options.log)switch("string"==typeof this.options.log&&(this.options.log=this.options.log.toLowerCase()),this.options.log){case!0:case"debug":this.options.log=this.LOG_DEBUG;break;case"info":this.options.log=this.LOG_INFO;break;case"warn":case"warning":this.options.log=this.LOG_WARNING;break;default:case!1:case"error":this.options.log=this.LOG_ERROR}if(t<=this.options.log){var i=[].slice.apply(arguments,[2]);switch(t){case this.LOG_DEBUG:t="debug";break;case this.LOG_INFO:t="info";break;case this.LOG_WARNING:t="warn";break;default:case this.LOG_ERROR:t="error"}var s="["+t.toUpperCase()+"] AjaxBootstrapSelect:";"string"==typeof e?i.unshift(s+" "+e):(i.unshift(e),i.unshift(s)),b.console[t].apply(b.console,i)}}},t.prototype.replaceValue=function(i,s,o,l){var n=this;l=G.extend({recursive:!0,depth:!1,limit:!1},l),G.each(i,function(t,e){if(!1!==l.limit&&"number"==typeof l.limit&&l.limit<=0)return!1;G.isArray(i[t])||G.isPlainObject(i[t])?(l.recursive&&!1===l.depth||l.recursive&&"number"==typeof l.depth&&0<l.depth)&&n.replaceValue(i[t],s,o,l):e===s&&(!1!==l.limit&&"number"==typeof l.limit&&l.limit--,i[t]=o)})},t.prototype.t=function(t,e){return e=e||this.options.langCode,this.locale[e]&&Object.prototype.hasOwnProperty.call(this.locale[e],t)?this.locale[e][t]:(this.log(this.LOG_WARNING,"Unknown translation key:",t),t)},b.AjaxBootstrapSelect=b.AjaxBootstrapSelect||t;function e(i){var s=this;this.$status=G(i.options.templates.status).hide().appendTo(i.selectpicker.$menu);var t=i.t("statusInitialized");t&&t.length&&this.setStatus(t),this.cache={},this.plugin=i,this.selected=[],this.title=null,this.selectedTextFormat=i.selectpicker.options.selectedTextFormat;var o=[];i.$element.find("option").each(function(){var t=G(this),e=t.attr("value");o.push({value:e,text:t.text(),class:t.attr("class")||"",data:t.data()||{},preserved:i.options.preserveSelected,selected:!!t.attr("selected")})}),this.cacheSet("",o),i.options.preserveSelected&&(s.selected=o,i.$element.on("change.abs.preserveSelected",function(t){var e=i.$element.find(":selected");s.selected=[],i.selectpicker.multiple||(e=e.last()),e.each(function(){var t=G(this),e=t.attr("value");s.selected.push({value:e,text:t.text(),class:t.attr("class")||"",data:t.data()||{},preserved:!0,selected:!0})}),s.replaceOptions(s.cacheGet(s.plugin.query))}))}e.prototype.build=function(t){var e,i,s=t.length,o=G("<select/>"),l=G("<optgroup/>").attr("label",this.plugin.t("currentlySelected"));for(this.plugin.log(this.plugin.LOG_DEBUG,"Building the select list options from data:",t),i=0;i<s;i++){var n=t[i],a=G("<option/>").appendTo(n.preserved?l:o);if(Object.prototype.hasOwnProperty.call(n,"divider"))a.attr("data-divider","true");else for(e in a.val(n.value).text(n.text),n.title&&a.attr("title",n.title),n.class.length&&a.attr("class",n.class),n.disabled&&a.attr("disabled",!0),n.selected&&!this.plugin.selectpicker.multiple&&o.find(":selected").prop("selected",!1),n.selected&&a.attr("selected",!0),n.data)Object.prototype.hasOwnProperty.call(n.data,e)&&a.attr("data-"+e,n.data[e])}l.find("option").length&&l["before"===this.plugin.options.preserveSelectedPosition?"prependTo":"appendTo"](o);var r=o.html();return this.plugin.log(this.plugin.LOG_DEBUG,r),r},e.prototype.cacheGet=function(t,e){var i=this.cache[t]||e;return this.plugin.log(this.LOG_DEBUG,"Retrieving cache:",t,i),i},e.prototype.cacheSet=function(t,e){this.cache[t]=e,this.plugin.log(this.LOG_DEBUG,"Saving to cache:",t,e)},e.prototype.destroy=function(){this.replaceOptions(),this.plugin.list.setStatus(),this.plugin.log(this.plugin.LOG_DEBUG,"Destroyed select list.")},e.prototype.refresh=function(t){this.plugin.selectpicker.$menu.css("minHeight",0),this.plugin.selectpicker.$menu.find("> .inner").css("minHeight",0);var e=this.plugin.t("emptyTitle");!this.plugin.$element.find("option").length&&e&&e.length?this.setTitle(e):(this.title||"static"!==this.selectedTextFormat&&this.selectedTextFormat!==this.plugin.selectpicker.options.selectedTextFormat)&&this.restoreTitle(),this.plugin.selectpicker.refresh(),this.plugin.selectpicker.findLis(),t&&(this.plugin.log(this.plugin.LOG_DEBUG,"Triggering Change"),this.plugin.$element.trigger("change.$")),this.plugin.log(this.plugin.LOG_DEBUG,"Refreshed select list.")},e.prototype.replaceOptions=function(t){var e,i,s,o="",l=[],n=[],a=[];if(t=t||[],this.selected&&this.selected.length){for(this.plugin.log(this.plugin.LOG_INFO,"Processing preserved selections:",this.selected),i=(n=[].concat(this.selected,t)).length,e=0;e<i;e++)s=n[e],Object.prototype.hasOwnProperty.call(s,"value")&&-1===a.indexOf(s.value+"")?(a.push(s.value+""),l.push(s)):this.plugin.log(this.plugin.LOG_DEBUG,"Duplicate item found, ignoring.");t=l}t.length&&(o=this.plugin.list.build(t)),this.plugin.$element.html(o),this.refresh(),this.plugin.log(this.plugin.LOG_DEBUG,"Replaced options with data:",t)},e.prototype.restore=function(){var t=this.plugin.list.cacheGet(this.plugin.previousQuery);return t&&this.plugin.list.replaceOptions(t)&&this.plugin.log(this.plugin.LOG_DEBUG,"Restored select list to the previous query: ",this.plugin.previousQuery),this.plugin.log(this.plugin.LOG_DEBUG,"Unable to restore select list to the previous query:",this.plugin.previousQuery),!1},e.prototype.restoreTitle=function(){this.plugin.request||(this.plugin.selectpicker.options.selectedTextFormat=this.selectedTextFormat,this.title?this.plugin.$element.attr("title",this.title):this.plugin.$element.removeAttr("title"),this.title=null)},e.prototype.setTitle=function(t){this.plugin.request||(this.title=this.plugin.$element.attr("title"),this.plugin.selectpicker.options.selectedTextFormat="static",this.plugin.$element.attr("title",t))},e.prototype.setStatus=function(t){(t=t||"").length?this.$status.html(t).show():this.$status.html("").hide()},b.AjaxBootstrapSelectList=b.AjaxBootstrapSelectList||e;function i(t){function e(t){return function(){s.plugin.log(s.plugin.LOG_INFO,"Invoking AjaxBootstrapSelectRequest."+t+" callback:",arguments),s[t].apply(s,arguments),s.callbacks[t]&&(s.plugin.log(s.plugin.LOG_INFO,"Invoking ajax."+t+" callback:",arguments),s.callbacks[t].apply(s,arguments))}}var i,s=this,o=["beforeSend","success","error","complete"],l=o.length;for(this.plugin=t,this.options=G.extend(!0,{},t.options.ajax),this.callbacks={},i=0;i<l;i++){var n=o[i];this.options[n]&&G.isFunction(this.options[n])&&(this.callbacks[n]=this.options[n]),this.options[n]=e(n)}this.options.data&&G.isFunction(this.options.data)&&(this.options.data=this.options.data.apply(this)||{q:"{{{q}}}"}),this.plugin.replaceValue(this.options.data,"{{{q}}}",this.plugin.query),this.options.url&&G.isFunction(this.options.url)&&(this.options.url=this.options.url.apply(this)),this.jqXHR=G.ajax(this.options)}i.prototype.beforeSend=function(t){this.plugin.list.destroy(),this.plugin.list.setStatus(this.plugin.t("statusSearching"))},i.prototype.complete=function(t,e){if("abort"!==e){var i=this.plugin.list.cacheGet(this.plugin.query);if(i){if(!i.length)return this.plugin.list.destroy(),this.plugin.list.setStatus(this.plugin.t("statusNoResults")),void this.plugin.log(this.plugin.LOG_INFO,"No results were returned.");this.plugin.list.setStatus()}this.plugin.list.refresh(!0)}},i.prototype.error=function(t,e,i){"abort"!==e&&(this.plugin.list.cacheSet(this.plugin.query),this.plugin.options.clearOnError&&this.plugin.list.destroy(),this.plugin.list.setStatus(this.plugin.t("errorText")),this.plugin.options.restoreOnError&&(this.plugin.list.restore(),this.plugin.list.setStatus()))},i.prototype.process=function(t){var e,i,s,o,l,n,a=[],r=[];if(this.plugin.log(this.plugin.LOG_INFO,"Processing raw data for:",this.plugin.query,t),l=t,G.isFunction(this.plugin.options.preprocessData)&&(this.plugin.log(this.plugin.LOG_DEBUG,"Invoking preprocessData callback:",this.plugin.options.processData),null!=(s=this.plugin.options.preprocessData.apply(this,[l]))&&!1!==s&&(l=s)),!G.isArray(l))return this.plugin.log(this.plugin.LOG_ERROR,'The data returned is not an Array. Use the "preprocessData" callback option to parse the results and construct a proper array for this plugin.',l),!1;for(i=l.length,e=0;e<i;e++)o=l[e],this.plugin.log(this.plugin.LOG_DEBUG,"Processing item:",o),G.isPlainObject(o)&&(Object.prototype.hasOwnProperty.call(o,"divider")||Object.prototype.hasOwnProperty.call(o,"data")&&G.isPlainObject(o.data)&&o.data.divider?(this.plugin.log(this.plugin.LOG_DEBUG,"Item is a divider, ignoring provided data."),a.push({divider:!0})):Object.prototype.hasOwnProperty.call(o,"value")?-1===r.indexOf(o.value+"")?(r.push(o.value+""),o=G.extend({text:o.value,class:"",data:{},disabled:!1,selected:!1},o),a.push(o)):this.plugin.log(this.plugin.LOG_DEBUG,"Duplicate item found, ignoring."):this.plugin.log(this.plugin.LOG_DEBUG,'Data item must have a "value" property, skipping.'));if(n=[].concat(a),G.isFunction(this.plugin.options.processData)&&(this.plugin.log(this.plugin.LOG_DEBUG,"Invoking processData callback:",this.plugin.options.processData),null!=(s=this.plugin.options.processData.apply(this,[n]))&&!1!==s)){if(!G.isArray(s))return this.plugin.log(this.plugin.LOG_ERROR,"The processData callback did not return an array.",s),!1;n=s}return this.plugin.list.cacheSet(this.plugin.query,n),this.plugin.log(this.plugin.LOG_INFO,"Processed data:",n),n},i.prototype.success=function(t,e,i){if(!G.isArray(t)&&!G.isPlainObject(t))return this.plugin.log(this.plugin.LOG_ERROR,"Request did not return a JSON Array or Object.",t),void this.plugin.list.destroy();var s=this.process(t);this.plugin.list.replaceOptions(s)},b.AjaxBootstrapSelectRequest=b.AjaxBootstrapSelectRequest||i,G.fn.ajaxSelectPicker=function(t){return this.each(function(){G(this).data("AjaxBootstrapSelect")||G(this).data("AjaxBootstrapSelect",new b.AjaxBootstrapSelect(this,t))})},G.fn.ajaxSelectPicker.locale={},G.fn.ajaxSelectPicker.defaults={ajax:{url:null,type:"POST",dataType:"json",data:{q:"{{{q}}}"}},minLength:0,bindEvent:"keyup",cache:!0,clearOnEmpty:!0,clearOnError:!0,emptyRequest:!1,ignoredKeys:{9:"tab",16:"shift",17:"ctrl",18:"alt",27:"esc",37:"left",39:"right",38:"up",40:"down",91:"meta"},langCode:null,locale:null,log:"error",preprocessData:function(){},preserveSelected:!0,preserveSelectedPosition:"after",processData:function(){},requestDelay:300,restoreOnError:!1,templates:{status:'<div class="status"></div>'}},G.fn.ajaxSelectPicker.locale["en-US"]={currentlySelected:"Currently Selected",emptyTitle:"Select and begin typing",errorText:"Unable to retrieve results",searchPlaceholder:"Search...",statusInitialized:"Start typing a search query",statusNoResults:"No Results",statusSearching:"Searching...",statusTooShort:"Please enter more characters"},G.fn.ajaxSelectPicker.locale.en=G.fn.ajaxSelectPicker.locale["en-US"]}(jQuery,window);
|
|
/**
|
|
* Ajax Autocomplete for jQuery, version 1.4.10
|
|
* (c) 2017 Tomas Kirda
|
|
*
|
|
* Ajax Autocomplete for jQuery is freely distributable under the terms of an MIT-style license.
|
|
* For details, see the web site: https://github.com/devbridge/jQuery-Autocomplete
|
|
*/
|
|
!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports&&"function"==typeof require?require("jquery"):jQuery)}(function(a){"use strict";function b(c,d){var e=this;e.element=c,e.el=a(c),e.suggestions=[],e.badQueries=[],e.selectedIndex=-1,e.currentValue=e.element.value,e.timeoutId=null,e.cachedResponse={},e.onChangeTimeout=null,e.onChange=null,e.isLocal=!1,e.suggestionsContainer=null,e.noSuggestionsContainer=null,e.options=a.extend(!0,{},b.defaults,d),e.classes={selected:"autocomplete-selected",suggestion:"autocomplete-suggestion"},e.hint=null,e.hintValue="",e.selection=null,e.initialize(),e.setOptions(d)}function c(a,b,c){return a.value.toLowerCase().indexOf(c)!==-1}function d(b){return"string"==typeof b?a.parseJSON(b):b}function e(a,b){if(!b)return a.value;var c="("+g.escapeRegExChars(b)+")";return a.value.replace(new RegExp(c,"gi"),"<strong>$1</strong>").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/<(\/?strong)>/g,"<$1>")}function f(a,b){return'<div class="autocomplete-group">'+b+"</div>"}var g=function(){return{escapeRegExChars:function(a){return a.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&")},createNode:function(a){var b=document.createElement("div");return b.className=a,b.style.position="absolute",b.style.display="none",b}}}(),h={ESC:27,TAB:9,RETURN:13,LEFT:37,UP:38,RIGHT:39,DOWN:40},i=a.noop;b.utils=g,a.Autocomplete=b,b.defaults={ajaxSettings:{},autoSelectFirst:!1,appendTo:"body",serviceUrl:null,lookup:null,onSelect:null,width:"auto",minChars:1,maxHeight:300,deferRequestBy:0,params:{},formatResult:e,formatGroup:f,delimiter:null,zIndex:9999,type:"GET",noCache:!1,onSearchStart:i,onSearchComplete:i,onSearchError:i,preserveInput:!1,containerClass:"autocomplete-suggestions",tabDisabled:!1,dataType:"text",currentRequest:null,triggerSelectOnValidInput:!0,preventBadQueries:!0,lookupFilter:c,paramName:"query",transformResult:d,showNoSuggestionNotice:!1,noSuggestionNotice:"No results",orientation:"bottom",forceFixPosition:!1},b.prototype={initialize:function(){var c,d=this,e="."+d.classes.suggestion,f=d.classes.selected,g=d.options;d.element.setAttribute("autocomplete","off"),d.noSuggestionsContainer=a('<div class="autocomplete-no-suggestion"></div>').html(this.options.noSuggestionNotice).get(0),d.suggestionsContainer=b.utils.createNode(g.containerClass),c=a(d.suggestionsContainer),c.appendTo(g.appendTo||"body"),"auto"!==g.width&&c.css("width",g.width),c.on("mouseover.autocomplete",e,function(){d.activate(a(this).data("index"))}),c.on("mouseout.autocomplete",function(){d.selectedIndex=-1,c.children("."+f).removeClass(f)}),c.on("click.autocomplete",e,function(){d.select(a(this).data("index"))}),c.on("click.autocomplete",function(){clearTimeout(d.blurTimeoutId)}),d.fixPositionCapture=function(){d.visible&&d.fixPosition()},a(window).on("resize.autocomplete",d.fixPositionCapture),d.el.on("keydown.autocomplete",function(a){d.onKeyPress(a)}),d.el.on("keyup.autocomplete",function(a){d.onKeyUp(a)}),d.el.on("blur.autocomplete",function(){d.onBlur()}),d.el.on("focus.autocomplete",function(){d.onFocus()}),d.el.on("change.autocomplete",function(a){d.onKeyUp(a)}),d.el.on("input.autocomplete",function(a){d.onKeyUp(a)})},onFocus:function(){var a=this;a.fixPosition(),a.el.val().length>=a.options.minChars&&a.onValueChange()},onBlur:function(){var b=this,c=b.options,d=b.el.val(),e=b.getQuery(d);b.blurTimeoutId=setTimeout(function(){b.hide(),b.selection&&b.currentValue!==e&&(c.onInvalidateSelection||a.noop).call(b.element)},200)},abortAjax:function(){var a=this;a.currentRequest&&(a.currentRequest.abort(),a.currentRequest=null)},setOptions:function(b){var c=this,d=a.extend({},c.options,b);c.isLocal=Array.isArray(d.lookup),c.isLocal&&(d.lookup=c.verifySuggestionsFormat(d.lookup)),d.orientation=c.validateOrientation(d.orientation,"bottom"),a(c.suggestionsContainer).css({"max-height":d.maxHeight+"px",width:d.width+"px","z-index":d.zIndex}),this.options=d},clearCache:function(){this.cachedResponse={},this.badQueries=[]},clear:function(){this.clearCache(),this.currentValue="",this.suggestions=[]},disable:function(){var a=this;a.disabled=!0,clearTimeout(a.onChangeTimeout),a.abortAjax()},enable:function(){this.disabled=!1},fixPosition:function(){var b=this,c=a(b.suggestionsContainer),d=c.parent().get(0);if(d===document.body||b.options.forceFixPosition){var e=b.options.orientation,f=c.outerHeight(),g=b.el.outerHeight(),h=b.el.offset(),i={top:h.top,left:h.left};if("auto"===e){var j=a(window).height(),k=a(window).scrollTop(),l=-k+h.top-f,m=k+j-(h.top+g+f);e=Math.max(l,m)===l?"top":"bottom"}if("top"===e?i.top+=-f:i.top+=g,d!==document.body){var n,o=c.css("opacity");b.visible||c.css("opacity",0).show(),n=c.offsetParent().offset(),i.top-=n.top,i.top+=d.scrollTop,i.left-=n.left,b.visible||c.css("opacity",o).hide()}"auto"===b.options.width&&(i.width=b.el.outerWidth()+"px"),c.css(i)}},isCursorAtEnd:function(){var a,b=this,c=b.el.val().length,d=b.element.selectionStart;return"number"==typeof d?d===c:!document.selection||(a=document.selection.createRange(),a.moveStart("character",-c),c===a.text.length)},onKeyPress:function(a){var b=this;if(!b.disabled&&!b.visible&&a.which===h.DOWN&&b.currentValue)return void b.suggest();if(!b.disabled&&b.visible){switch(a.which){case h.ESC:b.el.val(b.currentValue),b.hide();break;case h.RIGHT:if(b.hint&&b.options.onHint&&b.isCursorAtEnd()){b.selectHint();break}return;case h.TAB:if(b.hint&&b.options.onHint)return void b.selectHint();if(b.selectedIndex===-1)return void b.hide();if(b.select(b.selectedIndex),b.options.tabDisabled===!1)return;break;case h.RETURN:if(b.selectedIndex===-1)return void b.hide();b.select(b.selectedIndex);break;case h.UP:b.moveUp();break;case h.DOWN:b.moveDown();break;default:return}a.stopImmediatePropagation(),a.preventDefault()}},onKeyUp:function(a){var b=this;if(!b.disabled){switch(a.which){case h.UP:case h.DOWN:return}clearTimeout(b.onChangeTimeout),b.currentValue!==b.el.val()&&(b.findBestHint(),b.options.deferRequestBy>0?b.onChangeTimeout=setTimeout(function(){b.onValueChange()},b.options.deferRequestBy):b.onValueChange())}},onValueChange:function(){if(this.ignoreValueChange)return void(this.ignoreValueChange=!1);var b=this,c=b.options,d=b.el.val(),e=b.getQuery(d);return b.selection&&b.currentValue!==e&&(b.selection=null,(c.onInvalidateSelection||a.noop).call(b.element)),clearTimeout(b.onChangeTimeout),b.currentValue=d,b.selectedIndex=-1,c.triggerSelectOnValidInput&&b.isExactMatch(e)?void b.select(0):void(e.length<c.minChars?b.hide():b.getSuggestions(e))},isExactMatch:function(a){var b=this.suggestions;return 1===b.length&&b[0].value.toLowerCase()===a.toLowerCase()},getQuery:function(b){var c,d=this.options.delimiter;return d?(c=b.split(d),a.trim(c[c.length-1])):b},getSuggestionsLocal:function(b){var c,d=this,e=d.options,f=b.toLowerCase(),g=e.lookupFilter,h=parseInt(e.lookupLimit,10);return c={suggestions:a.grep(e.lookup,function(a){return g(a,b,f)})},h&&c.suggestions.length>h&&(c.suggestions=c.suggestions.slice(0,h)),c},getSuggestions:function(b){var c,d,e,f,g=this,h=g.options,i=h.serviceUrl;if(h.params[h.paramName]=b,h.onSearchStart.call(g.element,h.params)!==!1){if(d=h.ignoreParams?null:h.params,a.isFunction(h.lookup))return void h.lookup(b,function(a){g.suggestions=a.suggestions,g.suggest(),h.onSearchComplete.call(g.element,b,a.suggestions)});g.isLocal?c=g.getSuggestionsLocal(b):(a.isFunction(i)&&(i=i.call(g.element,b)),e=i+"?"+a.param(d||{}),c=g.cachedResponse[e]),c&&Array.isArray(c.suggestions)?(g.suggestions=c.suggestions,g.suggest(),h.onSearchComplete.call(g.element,b,c.suggestions)):g.isBadQuery(b)?h.onSearchComplete.call(g.element,b,[]):(g.abortAjax(),f={url:i,data:d,type:h.type,dataType:h.dataType},a.extend(f,h.ajaxSettings),g.currentRequest=a.ajax(f).done(function(a){var c;g.currentRequest=null,c=h.transformResult(a,b),g.processResponse(c,b,e),h.onSearchComplete.call(g.element,b,c.suggestions)}).fail(function(a,c,d){h.onSearchError.call(g.element,b,a,c,d)}))}},isBadQuery:function(a){if(!this.options.preventBadQueries)return!1;for(var b=this.badQueries,c=b.length;c--;)if(0===a.indexOf(b[c]))return!0;return!1},hide:function(){var b=this,c=a(b.suggestionsContainer);a.isFunction(b.options.onHide)&&b.visible&&b.options.onHide.call(b.element,c),b.visible=!1,b.selectedIndex=-1,clearTimeout(b.onChangeTimeout),a(b.suggestionsContainer).hide(),b.signalHint(null)},suggest:function(){if(!this.suggestions.length)return void(this.options.showNoSuggestionNotice?this.noSuggestions():this.hide());var b,c=this,d=c.options,e=d.groupBy,f=d.formatResult,g=c.getQuery(c.currentValue),h=c.classes.suggestion,i=c.classes.selected,j=a(c.suggestionsContainer),k=a(c.noSuggestionsContainer),l=d.beforeRender,m="",n=function(a,c){var f=a.data[e];return b===f?"":(b=f,d.formatGroup(a,b))};return d.triggerSelectOnValidInput&&c.isExactMatch(g)?void c.select(0):(a.each(c.suggestions,function(a,b){e&&(m+=n(b,g,a)),m+='<div class="'+h+'" data-index="'+a+'">'+f(b,g,a)+"</div>"}),this.adjustContainerWidth(),k.detach(),j.html(m),a.isFunction(l)&&l.call(c.element,j,c.suggestions),c.fixPosition(),j.show(),d.autoSelectFirst&&(c.selectedIndex=0,j.scrollTop(0),j.children("."+h).first().addClass(i)),c.visible=!0,void c.findBestHint())},noSuggestions:function(){var b=this,c=b.options.beforeRender,d=a(b.suggestionsContainer),e=a(b.noSuggestionsContainer);this.adjustContainerWidth(),e.detach(),d.empty(),d.append(e),a.isFunction(c)&&c.call(b.element,d,b.suggestions),b.fixPosition(),d.show(),b.visible=!0},adjustContainerWidth:function(){var b,c=this,d=c.options,e=a(c.suggestionsContainer);"auto"===d.width?(b=c.el.outerWidth(),e.css("width",b>0?b:300)):"flex"===d.width&&e.css("width","")},findBestHint:function(){var b=this,c=b.el.val().toLowerCase(),d=null;c&&(a.each(b.suggestions,function(a,b){var e=0===b.value.toLowerCase().indexOf(c);return e&&(d=b),!e}),b.signalHint(d))},signalHint:function(b){var c="",d=this;b&&(c=d.currentValue+b.value.substr(d.currentValue.length)),d.hintValue!==c&&(d.hintValue=c,d.hint=b,(this.options.onHint||a.noop)(c))},verifySuggestionsFormat:function(b){return b.length&&"string"==typeof b[0]?a.map(b,function(a){return{value:a,data:null}}):b},validateOrientation:function(b,c){return b=a.trim(b||"").toLowerCase(),a.inArray(b,["auto","bottom","top"])===-1&&(b=c),b},processResponse:function(a,b,c){var d=this,e=d.options;a.suggestions=d.verifySuggestionsFormat(a.suggestions),e.noCache||(d.cachedResponse[c]=a,e.preventBadQueries&&!a.suggestions.length&&d.badQueries.push(b)),b===d.getQuery(d.currentValue)&&(d.suggestions=a.suggestions,d.suggest())},activate:function(b){var c,d=this,e=d.classes.selected,f=a(d.suggestionsContainer),g=f.find("."+d.classes.suggestion);return f.find("."+e).removeClass(e),d.selectedIndex=b,d.selectedIndex!==-1&&g.length>d.selectedIndex?(c=g.get(d.selectedIndex),a(c).addClass(e),c):null},selectHint:function(){var b=this,c=a.inArray(b.hint,b.suggestions);b.select(c)},select:function(a){var b=this;b.hide(),b.onSelect(a)},moveUp:function(){var b=this;if(b.selectedIndex!==-1)return 0===b.selectedIndex?(a(b.suggestionsContainer).children("."+b.classes.suggestion).first().removeClass(b.classes.selected),b.selectedIndex=-1,b.ignoreValueChange=!1,b.el.val(b.currentValue),void b.findBestHint()):void b.adjustScroll(b.selectedIndex-1)},moveDown:function(){var a=this;a.selectedIndex!==a.suggestions.length-1&&a.adjustScroll(a.selectedIndex+1)},adjustScroll:function(b){var c=this,d=c.activate(b);if(d){var e,f,g,h=a(d).outerHeight();e=d.offsetTop,f=a(c.suggestionsContainer).scrollTop(),g=f+c.options.maxHeight-h,e<f?a(c.suggestionsContainer).scrollTop(e):e>g&&a(c.suggestionsContainer).scrollTop(e-c.options.maxHeight+h),c.options.preserveInput||(c.ignoreValueChange=!0,c.el.val(c.getValue(c.suggestions[b].value))),c.signalHint(null)}},onSelect:function(b){var c=this,d=c.options.onSelect,e=c.suggestions[b];c.currentValue=c.getValue(e.value),c.currentValue===c.el.val()||c.options.preserveInput||c.el.val(c.currentValue),c.signalHint(null),c.suggestions=[],c.selection=e,a.isFunction(d)&&d.call(c.element,e)},getValue:function(a){var b,c,d=this,e=d.options.delimiter;return e?(b=d.currentValue,c=b.split(e),1===c.length?a:b.substr(0,b.length-c[c.length-1].length)+a):a},dispose:function(){var b=this;b.el.off(".autocomplete").removeData("autocomplete"),a(window).off("resize.autocomplete",b.fixPositionCapture),a(b.suggestionsContainer).remove()}},a.fn.devbridgeAutocomplete=function(c,d){var e="autocomplete";return arguments.length?this.each(function(){var f=a(this),g=f.data(e);"string"==typeof c?g&&"function"==typeof g[c]&&g[c](d):(g&&g.dispose&&g.dispose(),g=new b(this,c),f.data(e,g))}):this.first().data(e)},a.fn.autocomplete||(a.fn.autocomplete=a.fn.devbridgeAutocomplete)});
|
|
|
|
(function (window, $) {
|
|
|
|
function FastVue() {
|
|
|
|
}
|
|
|
|
FastVue.noop = function (a, b, c) { };
|
|
|
|
//解析数字,返回值:NAN或正常数字或''(输入参数为空)
|
|
FastVue.parseNumber = function (val,percent) {
|
|
|
|
switch (typeof val) {
|
|
case 'number': return val;
|
|
case 'string':
|
|
{
|
|
val = val.trim();
|
|
|
|
if (val === '') return '';
|
|
|
|
let isPercent = val.endsWith('%') || percent==true;
|
|
|
|
if (isPercent) {
|
|
val = val.replace(/%+$/, '');
|
|
if (val === '') return '';
|
|
}
|
|
if (val.endsWith('‱')) {
|
|
val = val.replace(/‱+$/, '');
|
|
if (val === '') return '';
|
|
}
|
|
let number = new Number(val);
|
|
|
|
return isPercent ? number / 100 : number;
|
|
}
|
|
default: return Number.NaN;
|
|
}
|
|
};
|
|
|
|
FastVue.extend = $.extend;
|
|
|
|
FastVue.setWidth = function (el, width) {
|
|
width && (el.style.width = typeof width === 'number' ? width + 'px' : width);
|
|
};
|
|
|
|
FastVue.getDomElement = function (el) {
|
|
if (!el) return null;
|
|
if (typeof el === 'string') {
|
|
return document.getElementById(el.startsWith('#') ? el.substring(1) : el);
|
|
}
|
|
el instanceof jQuery && (el = el[0]);
|
|
return el;
|
|
};
|
|
|
|
function Form(options) {
|
|
|
|
if (!(this instanceof Form)) {
|
|
throw 'FastVue.Form is a constructor and should be called with the `new` keyword';
|
|
}
|
|
|
|
this.data = {};
|
|
|
|
this.layout = {
|
|
display: 'inline',
|
|
title: {
|
|
width: 100
|
|
},
|
|
input: {
|
|
width: '165px'
|
|
}
|
|
};
|
|
|
|
this.submit = {
|
|
url: '',
|
|
before() { },
|
|
after() { }
|
|
};
|
|
|
|
this.fields = {};
|
|
|
|
this.view = {};
|
|
|
|
this.init(options);
|
|
}
|
|
|
|
FastVue.Form = Form;
|
|
|
|
window.FastVue = FastVue;
|
|
|
|
}(window, jQuery));
|
|
|
|
//autocomplete
|
|
(function (window, $) {
|
|
|
|
function __resetLookup(options, context) {
|
|
|
|
if (options.lookupFn) {
|
|
let lookupFn = options.lookupFn;
|
|
return options.lookup = function (query, callback) {
|
|
let queryLowerCase = (query || '').toLowerCase();
|
|
let suggestions = lookupFn.call(context) || [];
|
|
if (queryLowerCase) {
|
|
if (options.searchField) {
|
|
suggestions = suggestions.filter(data => {
|
|
return options.searchField.some(x => (data[x] || '').toLowerCase().indexOf(queryLowerCase) !== -1);
|
|
});
|
|
} else {
|
|
suggestions = suggestions.filter(data => {
|
|
return (data[options.valueField] || '').toLowerCase().indexOf(queryLowerCase) !== -1;
|
|
});
|
|
}
|
|
}
|
|
|
|
if (typeof suggestions[0] !== 'object') {
|
|
suggestions = suggestions.map(x => new Object({ value: x, data: x }));
|
|
} else {
|
|
suggestions = suggestions ? suggestions.map(x => {
|
|
return { value: x[options.nameField], data: x };
|
|
}) : [];
|
|
}
|
|
|
|
callback({ suggestions: suggestions });
|
|
};
|
|
}
|
|
|
|
if (!options.lookup) return;
|
|
|
|
if (typeof options.lookup === 'function') {
|
|
let lookupFn = options.lookup;
|
|
return options.lookup = function (query, callback) {
|
|
let queryLowerCase = (query || '').toLowerCase();
|
|
let suggestions = lookupFn.call(context, queryLowerCase) || [];
|
|
if (typeof suggestions[0] !== 'object') {
|
|
suggestions = suggestions.map(x => new Object({ value: x, data: x }));
|
|
} else {
|
|
suggestions = suggestions.map(x => {
|
|
return { value: x[options.nameField], data: x };
|
|
});
|
|
}
|
|
callback({ suggestions: suggestions });
|
|
};
|
|
}
|
|
|
|
if (Array.isArray(options.lookup)) {
|
|
|
|
let lookup = options.lookup;
|
|
|
|
if (typeof lookup[0] !== 'object') {
|
|
return options.lookup = lookup.map(x => new Object({ value: x, data: x }));
|
|
}
|
|
|
|
options.lookup = lookup.map(x => {
|
|
return { value: x[options.nameField], data: x };
|
|
});
|
|
|
|
if (options.searchField) {
|
|
options.lookupFilter = function (suggestion, originalQuery, queryLowerCase) {
|
|
return options.searchField.some(x => (suggestion.data[x] || '').toLowerCase().indexOf(queryLowerCase) !== -1);
|
|
};
|
|
} else {
|
|
options.lookupFilter = function (suggestion, originalQuery, queryLowerCase) {
|
|
return (suggestion.value || '').toLowerCase().indexOf(queryLowerCase) !== -1;
|
|
};
|
|
}
|
|
|
|
} else {
|
|
throw '[autocomplete.lookup]必须为数组或函数';
|
|
}
|
|
}
|
|
|
|
FastVue.autocomplete = function (el, options, context) {
|
|
|
|
!context && (context = this);
|
|
|
|
el = FastVue.getDomElement(el)
|
|
|
|
if (!el) throw '[FastVue.autocomplete]el is null or undefined:' + (options ? options.debugInfo : '');
|
|
|
|
let _el = el;//_el对应nameField
|
|
|
|
options = Object.assign({ minChars: 0, autoSelectFirst: true }, options);
|
|
|
|
!options.valueField && (options.valueField = options.nameField || 'value');
|
|
!options.nameField && (options.nameField = options.valueField);
|
|
|
|
if (options.nameField !== options.valueField) {
|
|
_el = el.cloneNode(true);
|
|
_el.setAttribute('name', '');
|
|
_el.setAttribute('value', '');
|
|
_el.id && _el.setAttribute('id', _el.id + '_auto');
|
|
el.setAttribute('type', 'hidden');
|
|
if (!el.parentNode) {
|
|
document.createElement("div").append(el);
|
|
}
|
|
el.parentNode.insertBefore(_el, el);
|
|
el.dataset.autocompleteClone = _el;
|
|
}
|
|
|
|
__resetLookup(options, context);
|
|
|
|
const onSelectFn = options.onSelect;
|
|
options.onSelect = function (suggestion) {
|
|
_el.dataset.select = '1';
|
|
if (options.nameField !== options.valueField) {
|
|
el.value = suggestion.data[options.valueField];
|
|
}
|
|
onSelectFn && onSelectFn(suggestion.data);
|
|
};
|
|
|
|
$(_el).autocomplete('dispose');
|
|
|
|
$(_el).on('focus', function () {
|
|
this.setAttribute("placeholder", this.value);
|
|
this.value = '';
|
|
this.dataset.select = '';
|
|
}).on('blur', function () {
|
|
!this.dataset.select && (this.value = this.getAttribute("placeholder"));
|
|
this.setAttribute("placeholder", '');
|
|
}).on('keydown', function (event) {
|
|
if ((event.which || event.keyCode) === 13) {
|
|
event.preventDefault();
|
|
event.stopPropagation();
|
|
$(this).blur();
|
|
}
|
|
}).autocomplete(options);
|
|
|
|
return {
|
|
setData(data) {
|
|
if (options.nameField === options.valueField) {
|
|
_el.value = (typeof data === 'object' ? data[options.nameField] : data) || '';
|
|
} else if (data) {
|
|
el.value = data[options.valueField] || '';
|
|
_el.value = data[options.nameField] || '';
|
|
} else {
|
|
_el.value = el.value = '';
|
|
}
|
|
},
|
|
dispose() {
|
|
$(_el).autocomplete('dispose');
|
|
$(_el).remove();
|
|
},
|
|
toggleDisabled(disabled) {
|
|
_el.disabled = typeof disabled === 'undefined' ? !_el.disabled : !!disabled;
|
|
},
|
|
clearCache() {
|
|
$(_el).autocomplete('clearCache');
|
|
},
|
|
setOptions(newOptions) {
|
|
$(_el).autocomplete('setOptions', Object.assign({}, options, newOptions));
|
|
}
|
|
};
|
|
};
|
|
|
|
//静态dispose方法
|
|
FastVue.autocomplete.dispose = function (el) {
|
|
(el instanceof jQuery) && (el = el.get(0));
|
|
if (!el) return;
|
|
$(el).autocomplete('dispose');
|
|
el.dataset && $(el.dataset.autocompleteClone).autocomplete('dispose');
|
|
};
|
|
|
|
}(FastVue, jQuery));
|
|
|
|
//numberInput
|
|
(function (window, $) {
|
|
|
|
FastVue.numberInput = function (el, options) {
|
|
|
|
let _el = typeof el === 'string' ? document.getElementById(el.replace(/^#/, '')) : el instanceof jQuery ? el[0] : el;
|
|
|
|
if (!_el) {
|
|
throw "[FastVue.numberInput]not found el:" + el;
|
|
}
|
|
|
|
let _ctrlV = false, _chnInput = -1;
|
|
|
|
let _options = { append: '', precision: 2, negative: false, grouping: false };
|
|
|
|
function getValue() {
|
|
let val = _el.value;
|
|
if (val && val !== _options.append) {
|
|
_options.append && _options.append !== '%' && _options.append !== '‱' && (val = val.replace(new RegExp(_options.append + "$"), ''));
|
|
return FastVue.parseNumber(val, _options.percent);
|
|
}
|
|
return '';
|
|
}
|
|
|
|
function setOptions(options) {
|
|
options = Object.assign(_options, options);
|
|
!options.append && (options.append = '');
|
|
let precision = parseInt(options.precision) || 0;
|
|
options.precision = precision < 0 ? 0 : precision;
|
|
options.negative = !!options.negative;
|
|
_options = options;
|
|
setValue(getValue());
|
|
}
|
|
|
|
function setValue(value) {
|
|
if (value || value === 0) {
|
|
let oval = parseFloat(value) || 0;
|
|
if (_options.append === '%' || _options.percent == true) {
|
|
oval *= 100;
|
|
}
|
|
else if (_options.append ==="‱") {
|
|
oval *= 10000;
|
|
}
|
|
if (_options.precision > 0) {
|
|
let str = main.formatNumber(oval, _options.precision, { grouping: _options.grouping });
|
|
if (typeof value === 'number' && str.endsWith("0") && str.includes('.')) {
|
|
str = str.replace(/\.?0+$/, '');
|
|
}
|
|
_el.value = str + _options.append;
|
|
} else {
|
|
let str = main.formatNumber(Math.floor(oval), 0, { grouping: _options.grouping });
|
|
_el.value = str + _options.append;
|
|
}
|
|
} else {
|
|
_el.value = '';
|
|
}
|
|
}
|
|
|
|
function checkDotInput() {
|
|
if (this.selectionStart >= this.value.length) {
|
|
return _options.append && this.value.endsWith(_options.append) ? false : this.value.indexOf('.') < 0;
|
|
}
|
|
if (this.value.length - _options.append.length - this.selectionEnd > _options.precision) {
|
|
return false;
|
|
}
|
|
return this.value.substring(0, this.selectionStart).indexOf('.') < 0 && this.value.substring(this.selectionEnd, this.value.length).indexOf('.') < 0;
|
|
}
|
|
|
|
function __keyHandle(event) {
|
|
if (!event) return false;
|
|
|
|
_chnInput = -1;
|
|
|
|
let charCode = event.which || event.keyCode;
|
|
|
|
switch (charCode) {
|
|
case 8: //break space
|
|
return !_options.append || !this.value.endsWith(_options.append) || this.selectionStart < this.value.length - _options.append.length + 1;
|
|
case 9: //tab
|
|
case 35: //end
|
|
case 36: //home
|
|
case 37: //left arrow
|
|
case 39: //right arrow
|
|
case 42: //print
|
|
case 116: //F5
|
|
return true;
|
|
case 46: //del
|
|
return !_options.append || !this.value.endsWith(_options.append) || this.selectionStart < this.value.length - _options.append.length;
|
|
case 229:
|
|
return _chnInput = this.selectionStart;
|
|
}
|
|
|
|
if (event.shiftKey) return false;
|
|
|
|
switch (charCode) {
|
|
case 109: //negative sign(-)
|
|
return _options.negative && this.selectionStart < 1 && this.value.charAt(0) !== '-';
|
|
case 189: //negative sign(-_)
|
|
return _options.negative && !event.shiftKey && this.selectionStart < 1 && this.value.charAt(0) !== '-';
|
|
case 110: //dot(.)
|
|
return _options.precision > 0 && checkDotInput.call(this);
|
|
case 190: //dot(.>)
|
|
return _options.precision > 0 && !event.shiftKey && checkDotInput.call(this);
|
|
case 13: //enter
|
|
case 108: //enter
|
|
$(this).blur();
|
|
return true;
|
|
case 67: //ctrl+c
|
|
return event.ctrlKey;
|
|
case 86: //ctrl+v
|
|
return event.ctrlKey && (_ctrlV = true);
|
|
default:
|
|
if (charCode < 48 || charCode > 57 && (charCode < 96 || charCode > 105)) {
|
|
return false;
|
|
}
|
|
if (this.selectionStart === 0) {
|
|
return !this.value || this.value.charAt(this.selectionEnd) !== '-';
|
|
}
|
|
if (_options.precision < 1) {
|
|
return true;
|
|
}
|
|
if (this.selectionStart >= this.value.length && _options.append && this.value.endsWith(_options.append)) {
|
|
return false;
|
|
}
|
|
if (this.selectionEnd > this.selectionStart) {
|
|
return /\d/.test(this.value.substring(this.selectionStart, this.selectionEnd));
|
|
} else {
|
|
let dotIndex = this.value.lastIndexOf('.', this.selectionStart - 1);
|
|
return dotIndex < 0 || !/\d/.test(this.value[dotIndex + _options.precision]);
|
|
}
|
|
}
|
|
}
|
|
|
|
//处理中文字符输入
|
|
function __onChineseInput(chnPos) {
|
|
if (this.value.length < chnPos) {
|
|
chnPos = this.value.length - 1;
|
|
}
|
|
let ch = this.value.charCodeAt(chnPos);
|
|
if (ch > 47 && ch < 58) {
|
|
chnPos += 1;
|
|
}
|
|
else if (ch === 46 || ch === 12290) {
|
|
if (_options.precision > 0 && !/\d/.test(this.value[this.selectionStart + _options.precision])
|
|
&& this.value.lastIndexOf('.', chnPos - 1) < 0 && this.value.indexOf('.', this.selectionStart) < 0) {
|
|
if (ch === 12290) {
|
|
this.value = this.value.substring(0, chnPos) + '.' + this.value.substring(this.selectionStart);
|
|
this.setSelectionRange(chnPos + 1, chnPos + 1);
|
|
return;
|
|
}
|
|
chnPos += 1;
|
|
}
|
|
}
|
|
else if (chnPos === 0 && ch === 45 && _options.negative && this.value[this.selectionStart] !== '-') { //负号
|
|
return;
|
|
} else {
|
|
for (; chnPos >= 0; chnPos--) {
|
|
ch = this.value.charCodeAt(chnPos);
|
|
if (ch === 46 || ch > 47 && ch < 58 || chnPos === 0 && ch === 45 && _options.negative) {
|
|
chnPos += 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
this.value = this.value.substring(0, chnPos) + this.value.substring(this.selectionStart);
|
|
this.setSelectionRange(chnPos, chnPos);
|
|
}
|
|
|
|
//处理字符输入
|
|
function __onInput() {
|
|
if (_ctrlV) {
|
|
_ctrlV = false;
|
|
return setValue(this.value);
|
|
}
|
|
if (_chnInput >= 0) {
|
|
__onChineseInput.call(this, _chnInput);
|
|
}
|
|
if (!_options.append || !this.value) return;
|
|
let appended = true;
|
|
if (this.value !== _options.append) {
|
|
appended = this.value.endsWith(_options.append);
|
|
}
|
|
if (!appended) {
|
|
let caretPos = this.selectionStart;
|
|
this.value += _options.append;
|
|
this.setSelectionRange(caretPos, caretPos);
|
|
} else if (_options.negative && this.selectionStart === 2 && this.value[1] === '-') {
|
|
this.value = this.value.substring(1);
|
|
this.setSelectionRange(1, 1);
|
|
}
|
|
}
|
|
|
|
//输入完成处理
|
|
function __change() {
|
|
let f = '';
|
|
if (this.value && this.value !== _options.append) {
|
|
f = parseFloat(this.value.replaceAll(",", "")) || 0;
|
|
if (_options.append === '%' || _options.percent == true) f /= 100;
|
|
else if (_options.append === '‱') f /= 10000;
|
|
|
|
}
|
|
_options.onchange && _options.onchange(f, this.value);
|
|
}
|
|
|
|
//功能禁用
|
|
function __disable() {
|
|
return false;
|
|
}
|
|
|
|
setOptions(options);
|
|
|
|
$(_el).on('keydown', __keyHandle).on('dragenter', __disable).on('input', __onInput).on('change', __change);
|
|
|
|
return {
|
|
isEmpty() {
|
|
return !_el.value || _el.value === _options.append;
|
|
},
|
|
getValue: getValue,
|
|
setValue: setValue,
|
|
setOptions: setOptions,
|
|
getOptions() {
|
|
return Object.assign({}, _options);
|
|
},
|
|
dispose() {
|
|
$(_el).off();
|
|
}
|
|
};
|
|
};
|
|
|
|
//静态dispose方法
|
|
FastVue.numberInput.dispose = function (el) {
|
|
(el instanceof jQuery ? el : $(el)).off();
|
|
};
|
|
|
|
}(FastVue, jQuery));
|
|
|
|
//FastVue.vueNumberInput
|
|
//数字输入组件(借助FastVue.numberInput)
|
|
(function (global) {
|
|
|
|
global.vueNumberInput = function () {
|
|
return {
|
|
props: {
|
|
value: {
|
|
type: Number,
|
|
default: ''
|
|
},
|
|
format: {
|
|
type: Object,
|
|
default: {
|
|
append: '',
|
|
precision: 2,
|
|
negative: false,
|
|
grouping: false,
|
|
percent: false
|
|
}
|
|
},
|
|
disabled: {
|
|
type: Boolean
|
|
},
|
|
ret_type: {
|
|
type: Number,
|
|
default: 0
|
|
}
|
|
},
|
|
data() {
|
|
return { inputctrl: null,init:true};
|
|
},
|
|
mounted() {
|
|
let self = this;
|
|
let options = FastVue.extend({ onchange: this.onchange }, this.format);
|
|
this.inputctrl = FastVue.numberInput(this.$el, options);
|
|
this.inputctrl.setValue(this.value)
|
|
},
|
|
methods: {
|
|
onchange(value, text) {
|
|
this.init = false;
|
|
this.$emit('input', this.ret_type === 1 ? text : value);
|
|
}
|
|
},
|
|
watch: {
|
|
value(val, old) {
|
|
let val1 = '';
|
|
switch (typeof val) {
|
|
case 'number':
|
|
val1 = val || 0; break;
|
|
case 'string':
|
|
if (val) {
|
|
val1 = parseFloat(val) || 0;
|
|
if (val1 && (val.trimEnd().endsWith('%') || (this.format.percent && !this.init))) {
|
|
val1 /= 100;
|
|
} else if (val1 && (val.trimEnd().endsWith('‱'))){
|
|
val1 /= 10000;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
if (!this.inputctrl.isEmpty()) {
|
|
let val2 = this.inputctrl.getValue();
|
|
if (Math.abs(val1 - val2) < 1e-10) return;
|
|
}
|
|
this.$nextTick(function () {
|
|
this.inputctrl.setValue(val1);
|
|
});
|
|
},
|
|
format: {
|
|
deep: true,
|
|
handler(val) {
|
|
this.inputctrl.setOptions(val);
|
|
this.$nextTick(function () {
|
|
this.inputctrl.setValue(this.value);
|
|
});
|
|
}
|
|
}
|
|
},
|
|
destroyed() {
|
|
FastVue.numberInput.dispose(this.$el);
|
|
},
|
|
template: '<input type="text" v-bind:disabled="disabled">'
|
|
};
|
|
};
|
|
|
|
}(window.FastVue));
|
|
//日期选择组件FastVue.DatePicker
|
|
(function (global) {
|
|
global.vueDatePicker = function () {
|
|
return {
|
|
props: ['value', 'mindate', 'maxdate', 'noholiday'],
|
|
mounted() {
|
|
this.init();
|
|
},
|
|
methods: {
|
|
init() {
|
|
var self = this;
|
|
|
|
if (this.value?.length > 10) {
|
|
this.value = this.value.substring(0, 10);
|
|
}
|
|
|
|
$(this.$el).val(this.value).on('change', function () {
|
|
let val = this.value.trim();
|
|
if (self.isDate(val)) return;
|
|
let val2 = self.identifyDate(val);
|
|
this.value = val2;
|
|
if (self.value !== val2) {
|
|
self.$emit('input', val2);
|
|
}
|
|
|
|
}).datepicker({
|
|
minDate: self.mindate,
|
|
beforeShowDay(date) {
|
|
return [(!self.maxdate || date <= new Date(self.maxdate)) && (self.noholiday || !ylotc.isHoliday(date))];
|
|
},
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
showButtonPanel: true,
|
|
showOtherMonths: true,
|
|
selectOtherMonths: true,
|
|
onClose(dateText) {
|
|
self.value !== dateText && self.isDate(dateText) && self.$emit('input', dateText);
|
|
}
|
|
});
|
|
$(this.$el).on('click', function (e) {
|
|
var scrollTop = $(window).scrollTop();
|
|
if (scrollTop > 0 && $(this).closest('.pricing-float').length) {
|
|
$("#ui-datepicker-div").css({ 'top': $(this).offset().top - scrollTop + 25 });
|
|
}
|
|
});
|
|
},
|
|
refresh(mindate, maxdate) {
|
|
this.mindate = mindate;
|
|
this.maxdate = maxdate;
|
|
$(this.$el).datepicker("destroy");
|
|
this.init();
|
|
},
|
|
isDate(str) {
|
|
return /^\d{4}-\d{2}-\d{2}$/.test(str);
|
|
},
|
|
identifyDate(dateVal) {
|
|
if (!dateVal) return '';
|
|
dateVal = dateVal.replace(/\D/g, '').padStart(4, '0');
|
|
switch (dateVal.length) {
|
|
case 4:
|
|
dateVal = new Date().getFullYear() + dateVal; break;
|
|
case 6:
|
|
dateVal = '20' + dateVal; break;
|
|
case 8: break;
|
|
default:
|
|
if (dateVal.length < 8) return '';
|
|
dateVal = dateVal.substring(0, 8); break;
|
|
}
|
|
if (dateVal) {
|
|
dateVal = moment(dateVal).format('YYYY-MM-DD');
|
|
!/^\d+/.test(dateVal) && (dateVal = '');
|
|
}
|
|
return dateVal;
|
|
}
|
|
},
|
|
watch: {
|
|
value(val, old) {
|
|
if (val !== old && val !== this.$el.value) {
|
|
this.$el.value = val;
|
|
}
|
|
}
|
|
},
|
|
destroyed() {
|
|
$(this.$el).datepicker('destroy');
|
|
},
|
|
template: '<input type="text" autocomplete="off">'
|
|
};
|
|
};
|
|
}(window.FastVue));
|
|
|
|
/*jQuery Nice Select - v1.1.0
|
|
https://github.com/hernansartorio/jquery-nice-select
|
|
Made by Hernán Sartorio */
|
|
|
|
(function ($) {
|
|
|
|
$.fn.niceSelect = function (method) {
|
|
|
|
// Methods
|
|
if (typeof method === 'string') {
|
|
if (method === 'update') {
|
|
this.each(function () {
|
|
var $select = $(this);
|
|
var $dropdown = $(this).next('.nice-select');
|
|
var open = $dropdown.hasClass('open');
|
|
|
|
if ($dropdown.length) {
|
|
$dropdown.remove();
|
|
create_nice_select($select);
|
|
|
|
if (open) {
|
|
$select.next().trigger('click');
|
|
}
|
|
}
|
|
});
|
|
} else if (method === 'destroy') {
|
|
this.each(function () {
|
|
var $select = $(this);
|
|
var $dropdown = $(this).next('.nice-select');
|
|
|
|
if ($dropdown.length) {
|
|
$dropdown.remove();
|
|
$select.css('display', '');
|
|
}
|
|
});
|
|
if ($('.nice-select').length === 0) {
|
|
$(document).off('.nice_select');
|
|
}
|
|
} else {
|
|
console.log('Method "' + method + '" does not exist.')
|
|
}
|
|
return this;
|
|
}
|
|
|
|
// Hide native select
|
|
this.hide();
|
|
|
|
// Create custom markup
|
|
this.each(function () {
|
|
var $select = $(this);
|
|
|
|
if (!$select.next().hasClass('nice-select')) {
|
|
create_nice_select($select);
|
|
}
|
|
});
|
|
|
|
function create_nice_select($select) {
|
|
$select.after($('<div></div>')
|
|
.addClass('nice-select')
|
|
.addClass($select.attr('class') || '')
|
|
.addClass($select.attr('disabled') ? 'disabled' : '')
|
|
.attr('tabindex', $select.attr('disabled') ? null : '0')
|
|
.html('<span class="current"></span><ul class="list"></ul>')
|
|
);
|
|
|
|
var $dropdown = $select.next();
|
|
var $options = $select.find('option');
|
|
var $selected = $select.find('option:selected');
|
|
|
|
$dropdown.find('.current').html($selected.data('display') || $selected.text());
|
|
|
|
$options.each(function (i) {
|
|
var $option = $(this);
|
|
var display = $option.data('display');
|
|
|
|
$dropdown.find('ul').append($('<li></li>')
|
|
.attr('data-value', $option.val())
|
|
.attr('data-display', (display || null))
|
|
.addClass('option' +
|
|
($option.is(':selected') ? ' selected' : '') +
|
|
($option.is(':disabled') ? ' disabled' : ''))
|
|
.html($option.text())
|
|
);
|
|
});
|
|
}
|
|
|
|
/* Event listeners */
|
|
|
|
// Unbind existing events in case that the plugin has been initialized before
|
|
$(document).off('.nice_select');
|
|
|
|
// Open/close
|
|
$(document).on('click.nice_select', '.nice-select', function (event) {
|
|
var $dropdown = $(this);
|
|
|
|
$('.nice-select').not($dropdown).removeClass('open');
|
|
$dropdown.toggleClass('open');
|
|
|
|
if ($dropdown.hasClass('open')) {
|
|
$dropdown.find('.option');
|
|
$dropdown.find('.focus').removeClass('focus');
|
|
$dropdown.find('.selected').addClass('focus');
|
|
} else {
|
|
$dropdown.focus();
|
|
}
|
|
});
|
|
|
|
// Close when clicking outside
|
|
$(document).on('click.nice_select', function (event) {
|
|
if ($(event.target).closest('.nice-select').length === 0) {
|
|
$('.nice-select').removeClass('open').find('.option');
|
|
}
|
|
});
|
|
|
|
// Option click
|
|
$(document).on('click.nice_select', '.nice-select .option:not(.disabled)', function (event) {
|
|
var $option = $(this);
|
|
var $dropdown = $option.closest('.nice-select');
|
|
|
|
$dropdown.find('.selected').removeClass('selected');
|
|
$option.addClass('selected');
|
|
|
|
var text = $option.data('display') || $option.text();
|
|
$dropdown.find('.current').text(text);
|
|
|
|
$dropdown.prev('select').val($option.data('value') + '').trigger('change');
|
|
});
|
|
|
|
// Keyboard events
|
|
$(document).on('keydown.nice_select', '.nice-select', function (event) {
|
|
var $dropdown = $(this);
|
|
var $focused_option = $($dropdown.find('.focus') || $dropdown.find('.list .option.selected'));
|
|
|
|
// Space or Enter
|
|
if (event.keyCode === 32 || event.keyCode === 13) {
|
|
if ($dropdown.hasClass('open')) {
|
|
$focused_option.trigger('click');
|
|
} else {
|
|
$dropdown.trigger('click');
|
|
}
|
|
return false;
|
|
// Down
|
|
} else if (event.keyCode === 40) {
|
|
if (!$dropdown.hasClass('open')) {
|
|
$dropdown.trigger('click');
|
|
} else {
|
|
var $next = $focused_option.nextAll('.option:not(.disabled)').first();
|
|
if ($next.length > 0) {
|
|
$dropdown.find('.focus').removeClass('focus');
|
|
$next.addClass('focus');
|
|
}
|
|
}
|
|
return false;
|
|
// Up
|
|
} else if (event.keyCode === 38) {
|
|
if (!$dropdown.hasClass('open')) {
|
|
$dropdown.trigger('click');
|
|
} else {
|
|
var $prev = $focused_option.prevAll('.option:not(.disabled)').first();
|
|
if ($prev.length > 0) {
|
|
$dropdown.find('.focus').removeClass('focus');
|
|
$prev.addClass('focus');
|
|
}
|
|
}
|
|
return false;
|
|
// Esc
|
|
} else if (event.keyCode === 27) {
|
|
if ($dropdown.hasClass('open')) {
|
|
$dropdown.trigger('click');
|
|
}
|
|
// Tab
|
|
} else if (event.keyCode === 9) {
|
|
if ($dropdown.hasClass('open')) {
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
|
|
// Detect CSS pointer-events support, for IE <= 10. From Modernizr.
|
|
var style = document.createElement('a').style;
|
|
style.cssText = 'pointer-events:auto';
|
|
if (style.pointerEvents !== 'auto') {
|
|
$('html').addClass('no-csspointerevents');
|
|
}
|
|
|
|
return this;
|
|
|
|
};
|
|
|
|
}(jQuery));
|
|
|
|
//下拉选择组件FastVue.vueNiceSelect
|
|
(function (global) {
|
|
global.vueNiceSelect = function () {
|
|
return {
|
|
props: ['value', 'items', 'disabled'],
|
|
data() {
|
|
return { type: 'string', jqSelect: null };
|
|
},
|
|
mounted() {
|
|
var self = this;
|
|
let type = typeof this.value;
|
|
//console.log('[vueNiceSelect]'+this.$el.getAttribute('name'));
|
|
if (type === 'undefined' || this.value === null) {
|
|
this.items[0] && (type = typeof this.items[0].value);
|
|
}
|
|
this.type = type;
|
|
this.jqSelect = $(this.$el).children('select');
|
|
this.jqSelect.val(this.value + '').prop('disabled', this.disabled);
|
|
this.jqSelect.niceSelect().on('change', function () {
|
|
let val = $(this).val();
|
|
if (self.type === 'number') {
|
|
val = parseFloat(val);
|
|
} else if (self.type === 'boolean') {
|
|
val = val === 'true' || val === '1';
|
|
}
|
|
self.$emit('input', val);
|
|
});
|
|
},
|
|
watch: {
|
|
value(val, old) {
|
|
if (typeof val === 'undefined') {
|
|
val = "";
|
|
}
|
|
else if (val === null) {
|
|
val = "";
|
|
} else {
|
|
val = val.toString();
|
|
}
|
|
this.jqSelect.val(val);
|
|
this.jqSelect.niceSelect('update');
|
|
},
|
|
disabled(val, old) {
|
|
this.jqSelect.prop('disabled', val).niceSelect('update');
|
|
},
|
|
items() {
|
|
this.$nextTick(function () {
|
|
this.jqSelect.val(this.value);
|
|
this.jqSelect.niceSelect('update');
|
|
});
|
|
}
|
|
},
|
|
destroyed() {
|
|
this.jqSelect.niceSelect('destroy');
|
|
},
|
|
template: '<div><select><option v-for="item in items" :value="item.value">{{item.text}}</option></select></div>'
|
|
};
|
|
};
|
|
}(window.FastVue));
|
|
//依赖类库:lodash.js + jquery + jquery.validate + bootstrap.emodal.js
|
|
|
|
var main = window.main || { version: "1.0" };
|
|
|
|
main.extend = $.extend;
|
|
|
|
//数字格式化
|
|
|
|
/**
|
|
* 构建数字格式化函数(依赖lodash.js)
|
|
* @see Intl.NumberFormat
|
|
* @param {any} precision - 小数位精度,默认2,如果是对象类,则当做带precision属性的options处理
|
|
* @param {object} options - 格式化选项
|
|
* @param {boolean} options.rounded - 是否四舍五入,明确传入false时禁止四舍五入
|
|
* @param {boolean} options.grouping - 是否使用千位分隔符,默认false
|
|
* @param {boolean} options.percent - 是否百分比格式,默认false
|
|
* @param {boolean} options.trimTailZeros - 是否去除小数点后的尾部的0,默认false
|
|
* @param {any} options.prefmt
|
|
* - 预先格式化,支持多种形式处理
|
|
* - 如果传入数组类型的参数值,则循环执行数组中的函数,如果执行结果为string或number类型,则prefmt值取此结果并跳出循环
|
|
* - 如果传入函数类型的参数值,prefmt值取函数执行结果
|
|
* - 如果prefmt值为数字类型,则格式化prefmt值
|
|
* - 如果prefmt值不为undefined|null|false,则返回prefmt值,否则忽略prefmt
|
|
* @param {string} options.nanfmt - 输入值解析成数字为NAN时的格式化处理,类型为字符串,默认返回0的格式化数值
|
|
* @return {function} - 返回带fromat函数的格式化对象
|
|
*/
|
|
main.numberFormat = function (precision, options) {
|
|
if (typeof precision === 'object') {
|
|
options = precision;
|
|
precision = options.precision;
|
|
}
|
|
else if (!options || typeof options !== 'object') {
|
|
options = {};
|
|
}
|
|
|
|
//解析小数位精度
|
|
precision = parseInt(precision);
|
|
if (isNaN(precision)) {
|
|
precision = 2;
|
|
} else if (precision < 0) {
|
|
precision = 0;
|
|
} else if (precision > 10) {
|
|
precision = 10;
|
|
}
|
|
|
|
//构建Intl.NumberFormat
|
|
const fmt = new Intl.NumberFormat('en', {
|
|
useGrouping: !!options.grouping,
|
|
minimumFractionDigits: precision,
|
|
maximumFractionDigits: precision,
|
|
style: options.percent ? 'percent' : 'decimal'
|
|
});
|
|
|
|
//百分比格式特殊精度位处理
|
|
if (options.percent) precision += 2;
|
|
|
|
//预格式化处理
|
|
function preformat(prefmt, fmtArgs) {
|
|
|
|
//如果是数组类型,则以管道形式执行函数
|
|
if (Array.isArray(prefmt)) {
|
|
var result = false;
|
|
_.each(prefmt, x => {
|
|
let match = typeof x === 'function';
|
|
while (match) {
|
|
x = x.apply(this, fmtArgs);
|
|
switch (typeof x) {
|
|
case 'function':
|
|
continue;
|
|
case 'number':
|
|
case 'string':
|
|
result = x;
|
|
return false;
|
|
default: return true;
|
|
}
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
//执行函数处理
|
|
while (typeof prefmt === 'function') {
|
|
prefmt = prefmt.apply(this, fmtArgs);
|
|
}
|
|
|
|
return prefmt;
|
|
}
|
|
|
|
function _format(val) {
|
|
//预格式化处理
|
|
let prefmt = preformat(options.prefmt, arguments);
|
|
let type = typeof prefmt;
|
|
if (type === 'number') {
|
|
val = prefmt;
|
|
}
|
|
else if (type !== 'undefined' && prefmt !== null && prefmt !== false) {
|
|
return prefmt;
|
|
}
|
|
if (precision <= 4) {
|
|
val = _.round(val, precision + 4);
|
|
}
|
|
//数值格式化
|
|
if (options.rounded !== false) {
|
|
let negative = val < 0;
|
|
val = _.round(negative ? -val : val, precision);
|
|
negative && (val = -val);
|
|
} else {
|
|
val = _.floor(val, precision);
|
|
}
|
|
if (isNaN(val)) {
|
|
return typeof options.nanfmt === 'string' ? options.nanfmt : fmt.format(0);
|
|
}
|
|
return fmt.format(Math.abs(val) < 1e-6 ? 0 : val);
|
|
}
|
|
|
|
function format(val) {
|
|
let str = _format(val);
|
|
return options.trimTailZeros && str.endsWith("0") && precision > 0 ? str.replace(/\.?0+$/, '') : str;
|
|
}
|
|
|
|
format.precision = precision;
|
|
|
|
return format;
|
|
};
|
|
|
|
/**
|
|
* 格式化数字(依赖lodash.js)
|
|
* @param {object} number - 数字数值
|
|
* @param {any} precision - 小数位精度,默认2,如果是对象类,则当做带precision属性的options处理
|
|
* @param {object} options - 格式化选项
|
|
* @param {boolean} options.rounded - 是否四舍五入,类型为布尔值,默认true
|
|
* @param {boolean} options.grouping - 是否使用千位分隔符,类型为布尔值,默认false
|
|
* @param {boolean} options.percent - 是否百分比格式,类型为布尔值,默认false
|
|
* @param {string} options.nanfmt - 输入值解析成数字为NAN时的格式化处理,类型为字符串,默认返回0的格式化数值
|
|
* @param {any} options.prefmt - 参考main.numberFormat
|
|
* @return {function} - 返回带fromat函数的格式化对象
|
|
*/
|
|
main.formatNumber = function (number, precision, options) {
|
|
return new main.numberFormat(precision, options)(number);
|
|
};
|
|
|
|
//各种常用处理
|
|
|
|
const __alert = function (message) {
|
|
window.alert(message);
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* 显示页面加载组件,等待操作执行完成
|
|
* @param {string} method -- 'show'||'hide'
|
|
* @returns {jQuery} -- jQuery对象
|
|
*/
|
|
$.fn.waitMe = function (method) {
|
|
return this.each(function () {
|
|
if (this.showCount === undefined || this.showCount === null) {
|
|
this.showCount = 0;
|
|
}
|
|
var isBody = $(this).is('body');
|
|
var $waitme = $(this).children(".yl-waitme");
|
|
if (method === "show") {
|
|
if (!$waitme.length) {
|
|
!isBody && $(this).css("position") === "static" && $(this).css("position", "relative");
|
|
$waitme = $('<div class="yl-waitme"></div>');
|
|
$waitme.appendTo($(this));
|
|
}
|
|
$waitme.show();
|
|
this.showCount++;
|
|
} else if (this.showCount > 0) {
|
|
(this.showCount -= 1) === 0 && $waitme.remove();
|
|
}
|
|
});
|
|
};
|
|
|
|
main.logError = function (data) {
|
|
if (!data) return;
|
|
if (console && typeof console.error === "function") {
|
|
console.error(data);
|
|
} else if ($.isPlainObject(data) || data.length) {
|
|
alert(JSON.stringify(data));
|
|
} else {
|
|
alert(data);
|
|
}
|
|
};
|
|
|
|
const _systemmsg = [];
|
|
|
|
/**
|
|
* 显示通知消息
|
|
* @param {any} message -- 消息文本
|
|
* @param {any} time -- 显示时间
|
|
* @returns {boolean} -- false
|
|
*/
|
|
main.message = function (message, time) {
|
|
main.toast(message, time);
|
|
try {
|
|
|
|
if (_systemmsg.length >= 3) {
|
|
_systemmsg.splice(0, 1);
|
|
}
|
|
_systemmsg.push(message);
|
|
|
|
$("#systemspanmsg").html(_systemmsg.join(";"));
|
|
|
|
} catch (e) {
|
|
console.log("[ERROR:main.message]" + e);
|
|
}
|
|
return false;
|
|
};
|
|
|
|
main.toast = function (message, delay) {
|
|
|
|
if (!$('#toast-container').length) {
|
|
$('<div id="toast-container" class="toast-container">').appendTo('body');
|
|
}
|
|
|
|
var $t = $(`
|
|
<div class="toast toast-main">
|
|
<div class="toast-header pb-0 pt-3">
|
|
<span class="mr-auto">提示</span>
|
|
<button type="button" class="close" data-dismiss="toast"><strong>×</strong></button>
|
|
</div>
|
|
<div class="toast-body">${message}</div>
|
|
</div>`);
|
|
$t.appendTo('#toast-container').toast({ autohide: true, delay: delay || 3000 }).toast('show')
|
|
.on('hidden.bs.toast', function () { $t.remove(); }).on('click', function () {
|
|
$(this).toast('hide');
|
|
});
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* 显示警告信息
|
|
* @param {any} message -- 消息文本
|
|
* @returns {boolean} -- false
|
|
*/
|
|
main.warn = function (message) {
|
|
return main.message(message, 60 * 60 * 1000);
|
|
};
|
|
|
|
/**
|
|
* 显示警告弹窗
|
|
* @param {any} message -- 消息文本
|
|
* @returns {boolean} -- false
|
|
*/
|
|
main.alert = function (message, okCall) {
|
|
$.alert({
|
|
title: '提示',
|
|
content: (message || '').replace('\n', '<br>'),
|
|
buttons: {
|
|
ok: { text: '确定', action: okCall }
|
|
},
|
|
boxWidth: '450px',
|
|
useBootstrap: false,
|
|
animateFromElement: false
|
|
});
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* 显示确认弹窗
|
|
* @param {any} message -- 确认消息
|
|
* @param {any} okCallback -- 确认执行回调
|
|
* @param {any} cancelCallback -- 取消后回调
|
|
* @param {any} title -- 弹窗标题
|
|
*/
|
|
main.confirm = function (message, okCallback, cancelCallback, title) {
|
|
$.confirm({
|
|
title: title || '确认?',
|
|
content: message,
|
|
type: 'red',
|
|
buttons: {
|
|
ok: {
|
|
text: "确认",
|
|
btnClass: 'btn-primary',
|
|
keys: ['enter'],
|
|
action() {
|
|
if (okCallback) {
|
|
var tempCall = okCallback;
|
|
//确保只执行一次
|
|
okCallback = null;
|
|
tempCall();
|
|
}
|
|
}
|
|
},
|
|
cancel: {
|
|
text: "取消",
|
|
action() {
|
|
cancelCallback && cancelCallback();
|
|
}
|
|
}
|
|
},
|
|
useBootstrap: false,
|
|
boxWidth: '450px',
|
|
animateFromElement: false
|
|
});
|
|
};
|
|
|
|
//使用$.Deferred对象处理
|
|
main.confirmV2 = function (message, title) {
|
|
var deferred = $.Deferred();
|
|
$.confirm({
|
|
title: title || '确认?',
|
|
content: message,
|
|
type: 'red',
|
|
buttons: {
|
|
ok: {
|
|
text: "确认",
|
|
btnClass: 'btn-primary',
|
|
keys: ['enter'],
|
|
action: deferred.resolve
|
|
},
|
|
cancel: {
|
|
text: "取消",
|
|
action: deferred.reject
|
|
}
|
|
},
|
|
useBootstrap: false,
|
|
boxWidth: '450px',
|
|
animateFromElement: false
|
|
});
|
|
return deferred.promise();
|
|
};
|
|
|
|
main.waitMe = function (opt) {
|
|
if (typeof opt === 'boolean') {
|
|
opt = opt ? 'show' : 'hide';
|
|
} else {
|
|
opt = opt || "show";
|
|
}
|
|
$(document.body).waitMe(opt);
|
|
};
|
|
|
|
function __getWaitMeFunc(options) {
|
|
|
|
var waitMeFunc = main.waitMe;
|
|
|
|
if (typeof options !== 'undefined') {
|
|
var m = options.waitMe;
|
|
if (typeof m === 'undefined') {
|
|
m = options;
|
|
}
|
|
if (!m) {
|
|
waitMeFunc = function () { };
|
|
} else if (typeof m === 'function') {
|
|
waitMeFunc = m;
|
|
}
|
|
}
|
|
|
|
return waitMeFunc;
|
|
}
|
|
|
|
function __post(url, data, deferred, options) {
|
|
|
|
if (!url) throw "post url 不能为空";
|
|
|
|
var waitMeFunc = __getWaitMeFunc(options);
|
|
|
|
var ajaxOptions = {
|
|
type: "POST",
|
|
data: data,
|
|
dataType: "json",
|
|
cache: false,
|
|
success(resp) {
|
|
if (options && options.dataType && options.dataType !== "json") {
|
|
deferred.resolve(resp);
|
|
return;
|
|
}
|
|
if (resp.success === false || resp.errcode) {
|
|
let alert = options && options.alertFn ? options.alertFn : main.alert;
|
|
let errmsg = (resp.msg || resp.errmsg || "错误").replace(/\n/g, '<p></p>');
|
|
alert(errmsg);
|
|
deferred.reject(resp);
|
|
} else {
|
|
resp.msg && main.message(resp.msg);
|
|
deferred.resolve(resp);
|
|
}
|
|
},
|
|
beforeSend(jqXHR) {
|
|
waitMeFunc(true);
|
|
},
|
|
complete(jqXHR, textStatus) {
|
|
waitMeFunc(false);
|
|
},
|
|
error(jqXHR, textStatus, errorThrown) {
|
|
options && options.suppressError || main.alert('请求失败');
|
|
console.error("请求失败,url:" + url + ",status:" + textStatus + ",error:" + errorThrown);
|
|
}
|
|
};
|
|
|
|
if (data instanceof FormData) {
|
|
ajaxOptions.processData = false;
|
|
ajaxOptions.contentType = false;
|
|
}
|
|
|
|
ajaxOptions = $.extend(ajaxOptions, options);
|
|
|
|
$.ajax(url, ajaxOptions).fail(deferred.reject);
|
|
}
|
|
|
|
/**
|
|
* 封装$.ajax方法
|
|
* @param {any} options
|
|
* -- boolean:是否显示加载等待
|
|
* -- function:自定义加载等待调用
|
|
* -- object:{waitMe,suppressError}
|
|
* @param {boolean} options.waitMe -- 是否显示加载等待
|
|
* @param {boolean} options.suppressError -- 禁止出错时提示
|
|
* @returns {jQuery} -- jquery延迟对象Deferred
|
|
*/
|
|
main.ajax = function (options) {
|
|
var deferred = $.Deferred();
|
|
var waitMeFunc = __getWaitMeFunc(options);
|
|
var ajaxOptions = {
|
|
type: "POST",
|
|
dataType: "json",
|
|
success(resp) {
|
|
if (resp.success === false) {
|
|
main.alert(resp.msg || "错误");
|
|
deferred.reject(resp);
|
|
} else {
|
|
main.message(resp.msg || "成功");
|
|
deferred.resolve(resp);
|
|
}
|
|
},
|
|
beforeSend: function () {
|
|
waitMeFunc(true);
|
|
},
|
|
complete: function () {
|
|
waitMeFunc(false);
|
|
},
|
|
error(jqXHR, textStatus, errorThrown) {
|
|
let error = "请求失败,url:" + url + ",status:" + textStatus + ",error:" + errorThrown;
|
|
(options.suppressError ? console.error : main.alert)(error);
|
|
}
|
|
};
|
|
|
|
ajaxOptions = $.extend(ajaxOptions, options);
|
|
|
|
$.ajax(ajaxOptions).fail(deferred.reject);
|
|
|
|
return deferred.promise();
|
|
};
|
|
|
|
/**
|
|
* 封装$.Post
|
|
* @param {any} url -- post url
|
|
* @param {any} data -- post data
|
|
* @param {any} options
|
|
* -- boolean:是否显示加载等待
|
|
* -- function:自定义加载等待调用
|
|
* -- object:{waitMe,suppressError}
|
|
* @param {boolean} options.waitMe -- 是否显示加载等待
|
|
* @param {boolean} options.suppressError -- 禁止出错时提示
|
|
* @returns {jQuery} -- jquery延迟对象Deferred
|
|
*/
|
|
main.post = function (url, data, options) {
|
|
var d = $.Deferred();
|
|
__post(url, data, d, options);
|
|
return d.promise();
|
|
};
|
|
|
|
//确认提交
|
|
main.confirmPost = function (confirmText, url, data, options) {
|
|
var d = $.Deferred();
|
|
var okCallback = function () {
|
|
__post(url, data, d, options);
|
|
};
|
|
var cancelCallback = function () {
|
|
d.reject({ cancel: true });
|
|
};
|
|
main.confirm(confirmText, okCallback, cancelCallback, "提示");
|
|
return d.promise();
|
|
};
|
|
|
|
//以提交表单的方式打开新页面
|
|
main.formOpenNewPage = function (url, postData) {
|
|
var $f = $('<form target="_blank" method="post" action="' + url + '">')
|
|
_.each(postData, (val, key) => {
|
|
if ($.isArray(val)) {
|
|
_.each(val, (v, i) => {
|
|
$f.append('<input type="hidden" name="' + key + '[' + i + ']" value="' + v + '" />');
|
|
})
|
|
} else {
|
|
$f.append('<input type="hidden" name="' + key + '" value="' + val + '" />');
|
|
}
|
|
});
|
|
$f.appendTo("body").submit();
|
|
$f.remove();
|
|
};
|
|
|
|
//转换为string
|
|
main.toString = function (val) {
|
|
if (typeof val === 'undefined' || val === null) {
|
|
return "";
|
|
}
|
|
return val.toString();
|
|
}
|
|
|
|
/**
|
|
* 封装表单操作(表单验证+表单提交)
|
|
* @param {any} options -- 选项,可以直接传入form对象
|
|
* @param {any} options.el -- form元素或者jquery对象或者jquery选择器
|
|
* @param {any} options.submit -- 默认true,内部自动生成ajax post提交处理,如果为false则不自动提交
|
|
* 自定义提交选项:
|
|
* {
|
|
* url: string,提交地址,默认选用form元素的action属性或window.location.href,
|
|
* before: function,提交前的回调,返回false则中止提交
|
|
* after: function,提交成功后的回调
|
|
* postData: function,获取提交数据,如果未赋值则使用默认的表单序列化函数
|
|
* }
|
|
* @param {any} options.validate -- 默认true,内部自动附加验证器,false则不验证或者传入function对象使用自定义验证
|
|
* @returns {any} --
|
|
*/
|
|
main.form = function (options) {
|
|
|
|
if (!options) {
|
|
return __alert('[错误][main.form]缺少选项');
|
|
}
|
|
|
|
!$.isPlainObject(options) && (options = { el: options });
|
|
|
|
var $form, _hasSaved = 0;
|
|
|
|
function __init() {
|
|
|
|
//jquery form
|
|
$form = options.el instanceof jQuery ? options.el : $(options.el);
|
|
if (!$form.is("form")) {
|
|
$form = $form.find("form:first");
|
|
if (!$form.length) {
|
|
return __alert("[错误][main.form]没有找到form元素");
|
|
}
|
|
}
|
|
|
|
let submit = options.submit;
|
|
let validate = options.validate;
|
|
let sumbitHandler = __submitHandle;
|
|
|
|
if (submit === false) {
|
|
sumbitHandler = function () { return true; };
|
|
}
|
|
else {
|
|
!$.isPlainObject(submit) && (submit = {});
|
|
!$.trim(submit.url) && (submit.url = $.trim($form.attr('action')) || window.location.href);
|
|
options.submit = submit;
|
|
}
|
|
|
|
//设置表单验证
|
|
|
|
if ($form.attr('novalidate') !== undefined || validate === false) {
|
|
return;
|
|
}
|
|
|
|
//自定义表单验证
|
|
if (typeof validate === "function") {
|
|
$form.attr("novalidate", true);
|
|
$form.on("submit.validate", function () {
|
|
try {
|
|
validate($form) && sumbitHandler();
|
|
} finally {
|
|
return false;
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
|
|
//jquery.validate表单验证
|
|
if (typeof validate === "object") {
|
|
validate = $.extend({ submitHandler: sumbitHandler }, validate);
|
|
} else {
|
|
validate = { submitHandler: sumbitHandler };
|
|
}
|
|
main.formValidate($form, validate);
|
|
}
|
|
|
|
//表单提交处理
|
|
function __submitHandle(form) {
|
|
|
|
var submit = options.submit;
|
|
|
|
try {
|
|
|
|
if (typeof submit.before === "function" && submit.before(form) === false) {
|
|
return false;
|
|
}
|
|
|
|
if (!submit.url) {
|
|
return __alert("[错误][main.form]submit.url未配置");
|
|
}
|
|
|
|
let data = typeof submit.postData === 'function' ? submit.postData() : $form.serialize();
|
|
|
|
main.post(submit.url, data).done(function (resp) {
|
|
_hasSaved += 1;
|
|
submit.after && submit.after(resp, _hasSaved);
|
|
});
|
|
|
|
} catch (e) {
|
|
console.log(e);
|
|
} finally {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$(__init);
|
|
|
|
return {
|
|
submit() { $form.submit(); }
|
|
};
|
|
};
|
|
|
|
/**
|
|
* 表单验证
|
|
* @param {any} form -- 表单元素或者jquery对象或者jquery元素选择器
|
|
* @param {any} options --jquery validate选项或者submitHandler函数
|
|
* @returns {any} --
|
|
*/
|
|
main.formValidate = function (form, options) {
|
|
|
|
if (typeof options === "function") {
|
|
options = { submitHandler: options };
|
|
}
|
|
|
|
if (!form) {
|
|
return __alert("[main.formValidate]参数错误:form");
|
|
}
|
|
|
|
if (!(form instanceof jQuery)) {
|
|
form = $(form);
|
|
}
|
|
|
|
//添加自定义验证规则,格式:$method:$param[message]$message[+]$method:$param[message]$message...
|
|
function __addCustomRule($el) {
|
|
var rulestr = $.trim($el.data("validate"));
|
|
if (!rulestr) return;
|
|
var ruleArr = rulestr.split("[+]");
|
|
ruleArr.forEach(function (rulePart) {
|
|
rulePart = rulePart.trim();
|
|
if (!rulePart) return;
|
|
if (!/^[a-zA-Z]/.test(rulePart)) {
|
|
console.error("不是正确的验证表达式:" + rulePart);
|
|
return;
|
|
}
|
|
let message, param, method;
|
|
let index1 = rulePart.indexOf(':');
|
|
method = rulePart.substring(0, index2).trim();
|
|
if (!method) {
|
|
console.error("不是有效的验证表达式(缺少method):" + rulePart);
|
|
return;
|
|
}
|
|
let index2 = rulePart.indexOf('[message]');
|
|
if (index2 > 0) {
|
|
message = rulePart.substring(index2 + 9).trim();
|
|
}
|
|
if (index1 > 0) {
|
|
param = rulePart.substring(index1, index2).trim();
|
|
}
|
|
let rule = {};
|
|
rule[method] = param || true;
|
|
if (message) {
|
|
rule.messages = {};
|
|
rule.messages[method] = decodeURIComponent(message);
|
|
}
|
|
$el.rules("add", rule);
|
|
});
|
|
}
|
|
|
|
var validator = form.validate(options);
|
|
|
|
form.find('input').each(function () {
|
|
var type = $(this).attr("type");
|
|
if (type === "text" || type === "password") {
|
|
__addCustomRule($(this));
|
|
}
|
|
});
|
|
|
|
return validator;
|
|
};
|
|
|
|
/**
|
|
* 解码HTML
|
|
* @param {any} inputStr
|
|
* @returns
|
|
*/
|
|
main.decodeHtmlEntity = function (inputStr) {
|
|
if (typeof inputStr !== 'string') return inputStr;
|
|
if (!inputStr) return '';
|
|
var textarea = document.createElement("textarea");
|
|
textarea.innerHTML = inputStr;
|
|
return textarea.value;
|
|
};
|
|
|
|
//jquery.validator
|
|
(function (factory) {
|
|
if (typeof define === "function" && define.amd) {
|
|
define(["jquery", "jquery.validate"], factory);
|
|
} else if (typeof module === "object" && module.exports) {
|
|
module.exports = factory(require("jquery"));
|
|
} else {
|
|
factory(jQuery);
|
|
}
|
|
}(function ($) {
|
|
if (!$.validator) {
|
|
return $;
|
|
}
|
|
$.validator.setDefaults({
|
|
errorElement: "span",
|
|
submitHandler: function () {
|
|
return true;
|
|
},
|
|
errorPlacement: function (error, element) {
|
|
error.appendTo(element.parent());
|
|
}
|
|
});
|
|
|
|
$.validator.addMethod("pattern", function (val, element, param) {
|
|
if (this.optional(element) || !param) {
|
|
return true;
|
|
}
|
|
val = val.replace(/(^\s*)|(\s*$)/g, "");
|
|
return new RegExp("^" + param + "$").test(val);
|
|
}, "输入不符合要求");
|
|
|
|
$.extend($.validator.messages, {
|
|
required: "必填",
|
|
remote: "请修正此字段",
|
|
email: "请输入有效的电子邮件地址",
|
|
url: "请输入有效的网址",
|
|
date: "请输入有效的日期",
|
|
dateISO: "请输入有效的日期 (YYYY-MM-DD)",
|
|
number: "请输入有效的数字",
|
|
digits: "只能输入数字",
|
|
creditcard: "请输入有效的信用卡号码",
|
|
equalTo: "你的输入不相同",
|
|
extension: "请输入有效的后缀",
|
|
maxlength: $.validator.format("最多可以输入 {0} 个字符"),
|
|
minlength: $.validator.format("最少要输入 {0} 个字符"),
|
|
rangelength: $.validator.format("请输入长度在 {0} 到 {1} 之间的字符串"),
|
|
range: $.validator.format("请输入范围在 {0} 到 {1} 之间的数值"),
|
|
step: $.validator.format("请输入 {0} 的整数倍值"),
|
|
max: $.validator.format("请输入不大于 {0} 的数值"),
|
|
min: $.validator.format("请输入不小于 {0} 的数值")
|
|
});
|
|
|
|
return $;
|
|
}));
|
|
|
|
//例:$('#form1').serializeObject
|
|
jQuery.prototype.serializeObject = function () {
|
|
var obj = new Object();
|
|
$.each(this.serializeArray(),
|
|
function (index, param) {
|
|
if (param.name in obj) {
|
|
obj[param.name] = [].concat(obj[param.name], param.value);
|
|
} else {
|
|
obj[param.name] = param.value;
|
|
}
|
|
});
|
|
return obj;
|
|
};
|
|
|
|
if (!String.prototype.replaceAll) {
|
|
String.prototype.replaceAll = function (oldString, newString) {
|
|
oldString = _.escapeRegExp(oldString);
|
|
return this.replace(new RegExp(oldString, "gm"), newString)
|
|
}
|
|
}
|
|
|
|
var main = main || {};
|
|
|
|
(function ($) {
|
|
|
|
(function extendJqgrid(ajaxOptions) {
|
|
|
|
var completeOrigin = $.jgrid.ajaxOptions.complete;
|
|
|
|
$.extend(ajaxOptions, {
|
|
complete(XMLHttpRequest, textStatus) {
|
|
let resp = XMLHttpRequest.responseJSON;
|
|
if (typeof resp !== 'object' || resp.success || !resp.msg && !resp.message) {
|
|
return typeof completeOrigin === 'function' ? completeOrigin(XMLHttpRequest, textStatus) : null;
|
|
}
|
|
main.alert("数据查询失败: " + (resp.msg || resp.message));
|
|
}
|
|
});
|
|
}($.jgrid.ajaxOptions));
|
|
|
|
function jqGridCtrl() {
|
|
|
|
this.initGrid = function (options) {
|
|
|
|
options = $.extend({
|
|
url: '#',
|
|
datatype: 'json',
|
|
multiselect: false,
|
|
height: 'auto',
|
|
width: '90%',
|
|
autowidth: false,
|
|
shrinkToFit: false,
|
|
viewrecords: true,
|
|
jsonReader: { repeatitems: false },
|
|
cmTemplate: { align: 'center', width: 120 },
|
|
mtype: 'POST',
|
|
postData: null,
|
|
afterInsertRow: null,
|
|
onSelectRow: null,
|
|
ondblClickRow: null,
|
|
colModel: null,
|
|
pager: jQuery('#pagerGrid'),
|
|
pagerpos: 'left',
|
|
rowNum: 20,
|
|
rowList: [20, 30, 50, 200, 10000],
|
|
loadComplete: null,
|
|
onPaging: null,
|
|
footerrow: false
|
|
}, options);
|
|
|
|
//为了兼容以前的配置
|
|
!options.colModel && options.colModelGrid && (options.colModel = options.colModelGrid);
|
|
if (!options.postData) {
|
|
options.postData = options.PostData || {};
|
|
}
|
|
!options.afterInsertRow && options.AfterInsertRow && (options.afterInsertRow = options.AfterInsertRow);
|
|
!options.onSelectRow && options.rowclick && (options.onSelectRow = options.rowclick);
|
|
!options.ondblClickRow && options.rowdblclick && (options.ondblClickRow = options.rowdblclick);
|
|
!options.loadComplete && options.gridComplete && (options.loadComplete = options.gridComplete);
|
|
!options.onPaging && options.onJqgridPaging && (options.onPaging = options.onJqgridPaging);
|
|
|
|
return (options.el ? $(options.el) : $('#listGrid')).jqGrid(options);
|
|
}
|
|
|
|
function SearchClick($jqGrid, $form, firstPage) {
|
|
|
|
$jqGrid.appendPostData($form.serializeObject());
|
|
|
|
if (firstPage === true) {
|
|
$jqGrid.jqGrid('setGridParam', { page: 1 });
|
|
}
|
|
|
|
$jqGrid.trigger('reloadGrid');
|
|
}
|
|
|
|
this.initSearch = function ($jqGrid, searchForm) {
|
|
|
|
let $form = $(searchForm || '#searchForm');
|
|
|
|
if ($form.length && $form.is('form')) {
|
|
|
|
let search = SearchClick.bind(null, $jqGrid, $form);
|
|
|
|
$form.on('keydown', function (event) {
|
|
(event.keyCode === 13) && search();
|
|
});
|
|
|
|
$form.on('submit', function () {
|
|
search();
|
|
return false;
|
|
});
|
|
|
|
return search;
|
|
}
|
|
}
|
|
}
|
|
|
|
main.jqGrid = function (options) {
|
|
let ctrl = new jqGridCtrl();
|
|
let $grid = ctrl.initGrid(options);
|
|
let search = ctrl.initSearch($grid, options.searchForm);
|
|
return {
|
|
SearchClick: search || $.noop
|
|
};
|
|
};
|
|
|
|
main.enterSearch = function (searchFn) {
|
|
if (!searchFn) return;
|
|
document.onkeydown = function (event) {
|
|
(event.keyCode === 13) && searchFn();
|
|
};
|
|
};
|
|
|
|
})(jQuery); |