forked from juijs/jui-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjui.table.min.js
3 lines (3 loc) · 85.4 KB
/
jui.table.min.js
1
2
3
!function(a,b,c){var d={jquery:a},e={},f=b.navigator,g={template:{evaluate:/<\!([\s\S]+?)\!>/g,interpolate:/<\!=([\s\S]+?)\!>/g,escape:/<\!-([\s\S]+?)\!>/g},logUrl:"tool/debug.html"},h=function(a,b){function c(b,c){var d=a[b];a[b]=a[c],a[c]=d}function d(b,d,f){var g=d,h=a[b];c(b,f);for(var i=d;f>i;i++)(e(a[i],h)||!e(h,a[i])&&i%2==1)&&(c(i,g),g++);return c(f,g),g}var e=null,a=b?a.slice(0):a;this.setCompare=function(a){e=a},this.run=function(b,c){var e=null;return"number"!=typeof b&&(b=0),"number"!=typeof c&&(c=a.length-1),c>b&&(e=b+Math.ceil(.5*(c-b)),newPivot=d(e,b,c),this.run(b,newPivot-1),this.run(newPivot+1,c)),a}},i=function(){this.isIndexDepth=function(a){return"string"==typeof a&&-1!=a.indexOf(".")?!0:!1},this.getIndexList=function(a){var b=[],c=""+a;if(1==c.length)b[0]=parseInt(a);else for(var d=c.split("."),e=0;e<d.length;e++)b[e]=parseInt(d[e]);return b},this.changeIndex=function(a,b,c){for(var d=this.getIndexList(c).length,e=this.getIndexList(a),f=this.getIndexList(b),g=0;d>g;g++)e.shift();return f.concat(e).join(".")},this.getNextIndex=function(a){var b=this.getIndexList(a),c=b.pop()+1;return b.push(c),b.join(".")},this.getParentIndex=function(a){if(!this.isIndexDepth(a))return null;var b=this.getIndexList(a);return 2==b.length?""+b[0]:b.length>2?(b.pop(),b.join(".")):void 0}},j={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(a){var b,c,d,e,f,g,h,i="",k=0;for(a=j._utf8_encode(a);k<a.length;)b=a.charCodeAt(k++),c=a.charCodeAt(k++),d=a.charCodeAt(k++),e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),i=i+j._keyStr.charAt(e)+j._keyStr.charAt(f)+j._keyStr.charAt(g)+j._keyStr.charAt(h);return i},decode:function(a){var b,c,d,e,f,g,h,i="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)e=j._keyStr.indexOf(a.charAt(k++)),f=j._keyStr.indexOf(a.charAt(k++)),g=j._keyStr.indexOf(a.charAt(k++)),h=j._keyStr.indexOf(a.charAt(k++)),b=e<<2|f>>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,i+=String.fromCharCode(b),64!=g&&(i+=String.fromCharCode(c)),64!=h&&(i+=String.fromCharCode(d));return i=j._utf8_decode(i)},_utf8_encode:function(a){a=a.replace(/\r\n/g,"\n");for(var b=String.fromCharCode(239)+String.fromCharCode(187)+String.fromCharCode(191),c=0;c<a.length;c++){var d=a.charCodeAt(c);128>d?b+=String.fromCharCode(d):d>127&&2048>d?(b+=String.fromCharCode(d>>6|192),b+=String.fromCharCode(63&d|128)):(b+=String.fromCharCode(d>>12|224),b+=String.fromCharCode(d>>6&63|128),b+=String.fromCharCode(63&d|128))}return b},_utf8_decode:function(a){for(var b="",c=0,d=c1=c2=0;c<a.length;)d=a.charCodeAt(c),128>d?(b+=String.fromCharCode(d),c++):d>191&&224>d?(c2=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&c2),c+=2):(c2=a.charCodeAt(c+1),c3=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&c2)<<6|63&c3),c+=3);return b}},k=function(a,b,c){var d={},e={},f=Array.prototype,h=f.slice,i=f.forEach,j={"\\":"\\","'":"'",r:"\r",n:"\n",t:" ",u2028:"\u2028",u2029:"\u2029"};for(var k in j)j[j[k]]=k;var l=/\\|'|\r|\n|\t|\u2028|\u2029/g,m=/\\(\\|'|r|n|t|u2028|u2029)/g,n=/.^/,o=function(a){return a.replace(m,function(a,b){return j[b]})},p=d.each=d.forEach=function(a,b,c){if(null!=a)if(i&&a.forEach===i)a.forEach(b,c);else if(a.length===+a.length){for(var f=0,g=a.length;g>f;f++)if(f in a&&b.call(c,a[f],f,a)===e)return}else for(var h in a)if(d.has(a,h)&&b.call(c,a[h],h,a)===e)return};return d.has=function(a,b){return hasOwnProperty.call(a,b)},d.defaults=function(a){return p(h.call(arguments,1),function(b){for(var c in b)null==a[c]&&(a[c]=b[c])}),a},d.template=function(a,b,c){c=d.defaults(c||{},g.template);var e="__p+='"+a.replace(l,function(a){return"\\"+j[a]}).replace(c.escape||n,function(a,b){return"'+\n_.escape("+o(b)+")+\n'"}).replace(c.interpolate||n,function(a,b){return"'+\n("+o(b)+")+\n'"}).replace(c.evaluate||n,function(a,b){return"';\n"+o(b)+"\n;__p+='"})+"';\n";c.variable||(e="with(obj||{}){\n"+e+"}\n"),e="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+e+"return __p;\n";var f=new Function(c.variable||"obj","_",e);if(b)return f(b,d);var h=function(a){return f.call(this,a,d)};return h.source="function("+(c.variable||"obj")+"){\n"+e+"}",h},d.template(a,b,c)},l=d["util.base"]={browser:{webkit:"undefined"!=typeof b.webkitURL?!0:!1,mozilla:"undefined"!=typeof b.mozInnerScreenX?!0:!1,msie:-1!=f.userAgent.indexOf("Trident")?!0:!1},isTouch:/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(f.userAgent),scrollWidth:function(){var b=a(".jui").size()>0&&this.browser.webkit?!0:!1,c=a('<div style="width:50px;height:50px;overflow:hidden;position:absolute;top:-200px;left:-200px;"><div style="height:100px;"></div></div>');a("body").append(c);var d=a("div",c).innerWidth();c.css("overflow-y","auto");var e=a("div",c).innerWidth();return a(c).remove(),b?10:d-e},inherit:function(a,b){this.typeCheck("function",a)&&this.typeCheck("function",b)&&(a.parent=b,a.prototype=new b,a.prototype.constructor=a,a.prototype.parent=a.prototype,a.prototype.super=function(a,b){return this.constructor.prototype[a].apply(this,b)})},extend:function(a,b,c){function d(a){return l.typeCheck("object",a)}if(this.typeCheck("object",a)||(a={}),!this.typeCheck("object",b))return a;for(var e in b)c===!0?d(a[e])?this.extend(a[e],b[e],c):this.typeCheck("undefined",a[e])&&(a[e]=b[e]):d(a[e])?this.extend(a[e],b[e],c):a[e]=b[e];return a},pxToInt:function(a){return"string"==typeof a&&-1!=a.indexOf("px")?parseInt(a.split("px").join("")):a},clone:function(b){var c=a.isArray(b)?[]:{};for(var d in b)c[d]=this.typeCheck("object",b[d])?this.clone(b[d]):b[d];return c},deepClone:function(a,b){var c=null;if(b=b||{},this.typeCheck("array",a)){c=new Array(a.length);for(var d=0,e=a.length;e>d;d++)c[d]=this.deepClone(a[d],b)}else if(this.typeCheck("date",a))c=a;else if(this.typeCheck("object",a)){c={};for(var f in a)c[f]=b[f]?a[f]:this.deepClone(a[f],b)}else c=a;return c},sort:function(a){return new h(a)},runtime:function(a,b){var c=(new Date).getTime();b();var d=(new Date).getTime();console.log(a+" : "+(d-c)+"ms")},template:function(a,b){return b?k(a,b):k(a)},resize:function(c,d){var e=function(){var a=0;return function(){clearTimeout(a),a=setTimeout(c,d)}}();a(b).resize(function(){e()})},index:function(){return new i},chunk:function(a,b){for(var c=[],d=0,e=a.length;e>d;)c.push(a.slice(d,d+=b));return c},typeCheck:function(a,b){function c(a,b){return"string"!=typeof a?!1:"string"==a?"string"==typeof b:"integer"==a?"number"==typeof b&&b%1==0:"float"==a?"number"==typeof b&&b%1!=0:"number"==a?"number"==typeof b:"boolean"==a?"boolean"==typeof b:"undefined"==a?"undefined"==typeof b:"null"==a?null===b:"array"==a?b instanceof Array:"date"==a?b instanceof Date:"function"==a?"function"==typeof b:"object"==a?!("object"!=typeof b||null===b||b instanceof Array||b instanceof Date||b instanceof RegExp):!1}if("object"==typeof a&&a.length){for(var d=a,e=0;e<d.length;e++)if(c(d[e],b))return!0;return!1}return c(a,b)},typeCheckObj:function(a,b){if("object"==typeof a){var c=this;for(var d in a){var e=a[d];"function"==typeof e&&!function(d,e){a[d]=function(){for(var a=arguments,f=b[d],g=0;g<a.length;g++)if(!c.typeCheck(f[g],a[g]))throw new Error("JUI_CRITICAL_ERR: the "+g+"th parameter is not a "+f[g]+" ("+name+")");return e.apply(this,a)}}(d,e)}}},dataToCsv:function(a,b,c){for(var d="",e=c?c:b.length,f=-1;e>f;f++){for(var g=[],h=0;h<a.length;h++)a[h]&&g.push(-1==f?a[h]:b[f][a[h]]);d+=g.join(",")+"\n"}return d},dataToCsv2:function(b){for(var c="",d=a.extend({fields:null,rows:null,names:null,count:this.typeCheck("integer",b.count)?b.count:b.rows.length},b),e=-1;e<d.count;e++){for(var f=[],g=0;g<d.fields.length;g++)d.fields[g]&&f.push(-1==e?d.names&&d.names[g]?d.names[g]:d.fields[g]:d.rows[e][d.fields[g]]);c+=f.join(",")+"\n"}return c},fileToCsv:function(a,b){var c=new FileReader;c.onload=function(a){"function"==typeof b&&b(a.target.result)},c.readAsText(a)},csvToBase64:function(a){return"data:application/octet-stream;base64,"+j.encode(a)},csvToData:function(b,c,d){for(var e=[],f=c.split("\n"),g=1;g<f.length;g++)if(""!=f[g]){for(var h=f[g].split(","),i={},j=0;j<b.length;j++)i[b[j]]=h[j],-1!=a.inArray(b[j],d)&&(i[b[j]]=parseFloat(h[j]));e.push(i)}return e},getCsvFields:function(a,b){for(var c=this.typeCheck("array",b)?b:a,d=0;d<c.length;d++)isNaN(c[d])||(c[d]=a[c[d]]);return c},svgToBase64:function(a){return"data:image/svg+xml;base64,"+j.encode(a)},dateFormat:function(a,b,c){function d(a,b){var c=a+"";for(b=b||2;c.length<b;)c="0"+c;return c}var e=["\x00","January","February","March","April","May","June","July","August","September","October","November","December"],f=["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],g=["","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],h=["","Sun","Mon","Tue","Wed","Thu","Fri","Sat"],i=c?a.getUTCFullYear():a.getFullYear();b=b.replace(/(^|[^\\])yyyy+/g,"$1"+i),b=b.replace(/(^|[^\\])yy/g,"$1"+i.toString().substr(2,2)),b=b.replace(/(^|[^\\])y/g,"$1"+i);var j=(c?a.getUTCMonth():a.getMonth())+1;b=b.replace(/(^|[^\\])MMMM+/g,"$1"+e[0]),b=b.replace(/(^|[^\\])MMM/g,"$1"+f[0]),b=b.replace(/(^|[^\\])MM/g,"$1"+d(j)),b=b.replace(/(^|[^\\])M/g,"$1"+j);var k=c?a.getUTCDate():a.getDate();b=b.replace(/(^|[^\\])dddd+/g,"$1"+g[0]),b=b.replace(/(^|[^\\])ddd/g,"$1"+h[0]),b=b.replace(/(^|[^\\])dd/g,"$1"+d(k)),b=b.replace(/(^|[^\\])d/g,"$1"+k);var l=c?a.getUTCHours():a.getHours();b=b.replace(/(^|[^\\])HH+/g,"$1"+d(l)),b=b.replace(/(^|[^\\])H/g,"$1"+l);var m=l>12?l-12:0==l?12:l;b=b.replace(/(^|[^\\])hh+/g,"$1"+d(m)),b=b.replace(/(^|[^\\])h/g,"$1"+m);var n=c?a.getUTCMinutes():a.getMinutes();b=b.replace(/(^|[^\\])mm+/g,"$1"+d(n)),b=b.replace(/(^|[^\\])m/g,"$1"+n);var o=c?a.getUTCSeconds():a.getSeconds();b=b.replace(/(^|[^\\])ss+/g,"$1"+d(o)),b=b.replace(/(^|[^\\])s/g,"$1"+o);var p=c?a.getUTCMilliseconds():a.getMilliseconds();b=b.replace(/(^|[^\\])fff+/g,"$1"+d(p,3)),p=Math.round(p/10),b=b.replace(/(^|[^\\])ff/g,"$1"+d(p)),p=Math.round(p/10),b=b.replace(/(^|[^\\])f/g,"$1"+p);var q=12>l?"AM":"PM";b=b.replace(/(^|[^\\])TT+/g,"$1"+q),b=b.replace(/(^|[^\\])T/g,"$1"+q.charAt(0));var r=q.toLowerCase();b=b.replace(/(^|[^\\])tt+/g,"$1"+r),b=b.replace(/(^|[^\\])t/g,"$1"+r.charAt(0));var s=-a.getTimezoneOffset(),t=c||!s?"Z":s>0?"+":"-";if(!c){s=Math.abs(s);var u=Math.floor(s/60),v=s%60;t+=d(u)+":"+d(v)}b=b.replace(/(^|[^\\])K/g,"$1"+t);var w=(c?a.getUTCDay():a.getDay())+1;return b=b.replace(new RegExp(g[0],"g"),g[w]),b=b.replace(new RegExp(h[0],"g"),h[w]),b=b.replace(new RegExp(e[0],"g"),e[j]),b=b.replace(new RegExp(f[0],"g"),f[j]),b=b.replace(/\\(.)/g,"$1")},createId:function(a){return[a||"id",+new Date,Math.round(100*Math.random())%100].join("-")},btoa:j.encode,atob:j.decode,loop:function(a,b){var c=0,d=a,e=Math.ceil(a/5);return function(a){for(var f=c,g=1*e,h=2*e,i=3*e,j=4*e,k=g,l=h,m=i,n=j,o=d;k>f&&d>f;)a.call(b,f,1),f++,l>g&&d>g&&(a.call(b,g,2),g++),m>h&&d>h&&(a.call(b,h,3),h++),n>i&&d>i&&(a.call(b,i,4),i++),o>j&&d>j&&(a.call(b,j,5),j++)}},loopArray:function(a,b){var c=a.length,d=0,e=c,f=Math.ceil(c/5);return function(c){for(var g=d,h=1*f,i=2*f,j=3*f,k=4*f,l=h,m=i,n=j,o=k,p=e;l>g&&e>g;)c.call(b,a[g],g,1),g++,m>h&&e>h&&(c.call(b,a[h],h,2),h++),n>i&&e>i&&(c.call(b,a[i],i,3),i++),o>j&&e>j&&(c.call(b,a[j],j,4),j++),p>k&&e>k&&(c.call(b,a[k],k,5),k++)}},makeIndex:function(a,b){var c={},d=this.loopArray(a);return d(function(a,d){var e=a[b];"undefined"==typeof c[e]&&(c[e]=[]),c[e].push(d)}),c}},m=function(a){for(var b=[],c=0;c<a.length;c++){var e=d[a[c]];if(l.typeCheck(["function","object"],e))b.push(e);else{var f=n(a[c]);if(null==f)throw new Error("JUI_CRITICAL_ERR: '"+a[c]+"' is not loaded");b.push(f)}}return b},n=function(a){var b=null,a=a+".";for(var c in d)if(-1!=c.indexOf(a)&&l.typeCheck(["function","object"],d[c])){var e=c.split(a).join("");-1==e.indexOf(".")&&(null==b&&(b={}),b[e]=d[c])}return b};b.jui=c.jui={ready:function(){var b=[],c=2==arguments.length?arguments[1]:arguments[0],d=2==arguments.length?arguments[0]:null;if(!l.typeCheck(["array","null"],d)||!l.typeCheck("function",c))throw new Error("JUI_CRITICAL_ERR: Invalid parameter type of the function");a(function(){b=d?m(d):[n("ui"),n("uix"),l],c.apply(null,b)})},defineUI:function(a,b,c,f){if(!(l.typeCheck("string",a)&&l.typeCheck("array",b)&&l.typeCheck("function",c)&&l.typeCheck(["string","undefined"],f)))throw new Error("JUI_CRITICAL_ERR: Invalid parameter type of the function");if(l.typeCheck("function",d[a]))throw new Error("JUI_CRITICAL_ERR: '"+a+"' is already exist");if(l.typeCheck("undefined",f)&&(f="core"),!l.typeCheck("function",d[f]))throw new Error("JUI_CRITICAL_ERR: Parents are the only function");if(e[f]!==!0)throw new Error("JUI_CRITICAL_ERR: UI function can not be inherited");var g=m(b),h=c.apply(null,g);l.inherit(h,d[f]),d[a]=d.core.init({type:a,"class":h})},define:function(a,b,c,f){if(!(l.typeCheck("string",a)&&l.typeCheck("array",b)&&l.typeCheck("function",c)&&l.typeCheck(["string","undefined"],f)))throw new Error("JUI_CRITICAL_ERR: Invalid parameter type of the function");if(l.typeCheck("function",d[a]))throw new Error("JUI_CRITICAL_ERR: '"+a+"' is already exist");var g=m(b),h=c.apply(null,g);if(l.typeCheck("function",d[f])){if(e[f]!==!0)throw new Error("JUI_CRITICAL_ERR: UI function can not be inherited");l.inherit(h,d[f])}d[a]=h,e[a]=!0},defineOptions:function(b,c,d){function e(a,b){if(l.typeCheck("function",a)){if(l.typeCheck("function",a.setup)){var c=a.setup();for(var d in c)l.typeCheck("undefined",b[d])&&(b[d]=c[d])}e(a.parent,b)}return b}for(var f=e(b,{}),g=Object.keys(f),h=Object.keys(c),i=0;i<h.length;i++){var j=h[i];if(-1==a.inArray(j,g)&&-1==a.inArray(j,d))throw new Error("JUI_CRITICAL_ERR: '"+j+"' is not an option")}return l.extend(c,f,!0),c},include:function(a){if(!l.typeCheck("string",a))throw new Error("JUI_CRITICAL_ERR: Invalid parameter type of the function");var b=d[a];if(l.typeCheck(["function","object"],b))return b;var c=n(a);if(null==c)throw new Error("JUI_CRITICAL_ERR: '"+a+"' is not loaded");return c},includeAll:function(){var a=[];for(var b in d)a.push(d[b]);return a},log:function(a){var c=b.open(a||g.logUrl,"JUIM","width=1024, height=768, toolbar=no, menubar=no, resizable=yes");return jui.debugAll(function(a,b){c.log(a,b)}),c},setup:function(a){return l.typeCheck("object",a)&&(g=l.extend(g,a)),g}}}(jQuery||$,window,"undefined"!=typeof global?global:window),jui.define("core",["jquery","util.base"],function(a,b){var c=new function(){var d=[],e=[];this.add=function(a){d.push(a)},this.emit=function(a,b,c){for(var e=[],f=0;f<d.length;f++){var g=d[f];(a==g.selector||a==g.type)&&e.push(g)}for(var f=0;f<e.length;f++)for(var g=e[f],h=0;h<g.length;h++)g[h].emit(b,c)},this.get=function(a){if(b.typeCheck("integer",a))return d[a];if(b.typeCheck("string",a)){for(var c=0;c<d.length;c++){var e=d[c];if(a==e.selector)return 1==e.length?e[0]:e}for(var f=[],c=0;c<d.length;c++){var e=d[c];a==e.type&&f.push(e)}return f}},this.getAll=function(){return d},this.remove=function(a){return b.typeCheck("integer",a)?d.splice(a,1)[0]:void 0},this.shift=function(){return d.shift()},this.pop=function(){return d.pop()},this.size=function(){return d.length},this.debug=function(b,c,d,e){if(b.__proto__){var f=["emit","on","addEvent","addValid","callBefore","callAfter","callDelay","setTpl","setVo","setOption"];for(var g in b){var h=b[g];"function"==typeof h&&-1==a.inArray(g,f)&&!function(a,d,f,g){b.__proto__[a]=function(){var b=Date.now(),h=d.apply(this,arguments),i=Date.now();return"function"==typeof e?e({type:jui.get(c).type,name:a,c_index:f,u_index:g,time:i-b},arguments):(console.log(isNaN(f)||isNaN(g)?"NAME("+a+"), TIME("+(i-b)+"ms), ARGUMENTS...":"TYPE("+jui.get(c).type+"), NAME("+a+"), INDEX("+f+":"+g+"), TIME("+(i-b)+"ms), ARGUMENTS..."),console.log(arguments),console.log("")),h}}(g,h,c,d)}}},this.debugAll=function(a){for(var b=0;b<d.length;b++)for(var c=d[b],e=0;e<c.length;e++)this.debug(c[e],b,e,a)},this.addClass=function(a){e.push(a)},this.getClass=function(a){if(b.typeCheck("integer",a))return e[a];if(b.typeCheck("string",a))for(var c=0;c<e.length;c++)if(a==e[c].type)return e[c];return null},this.getClassAll=function(){return e},this.create=function(a,d,e){var f=c.getClass(a);if(b.typeCheck("null",f))throw new Error("JUI_CRITICAL_ERR: '"+a+"' does not exist");return f["class"](d,e)}},d=function(){function c(b){for(var c=["webkit","moz","MS","o",""],d=0;d<c.length;d++){var e=b.type;c[d]||(e=e.toLowerCase()),a(b.target).on(c[d]+e,b.callback)}g.push(b)}function d(b){b.callback&&!b.children?a(b.target).on(b.type,b.callback):a(b.target).on(b.type,b.children,b.callback),g.push(b)}function e(b){b.callback&&!b.children?a(b.target).on(f(b.type),b.callback):a(b.target).on(f(b.type),b.children,b.callback),g.push(b)}function f(a){return{click:"touchstart",dblclick:"touchend",mousedown:"touchstart",mousemove:"touchmove",mouseup:"touchend"}[a]}var g=[];this.add=function(f){var g={target:f[0],type:f[1]};b.typeCheck("function",f[2])?g=a.extend(g,{callback:f[2]}):b.typeCheck("string",f[2])&&(g=a.extend(g,{children:f[2],callback:f[3]}));for(var h=b.typeCheck("array",g.type)?g.type:[g.type],i=0;i<h.length;i++)g.type=h[i],-1!=g.type.toLowerCase().indexOf("animation")?c(g):("body"!=g.target&&g.target!=window&&a(g.target).off(g.type),b.isTouch?e(g):d(g))},this.trigger=function(c,d){a(c).trigger(b.isTouch?f(d):d)},this.get=function(a){return g[a]},this.getAll=function(){return g},this.size=function(){return g.length}},e=function(a,b,c,d){this.type=a,this.selector=b,this.options=c,this.destroy=function(){for(var a=0;a<d.length;a++)d[a].destroy()};for(var e=0;e<d.length;e++)this.push(d[e])};e.prototype=Object.create(Array.prototype);var f=function(){var c=null;this.find=function(b){return a(this.root).find(b)},this.emit=function(a,b){if("string"==typeof a){for(var c,d=0;d<this.event.length;d++){var e=this.event[d];if(e.type==a.toLowerCase()){var f="object"==typeof b&&b.length?b:[b];c=e.callback.apply(this,f)}}return c}},this.on=function(a,b){"string"==typeof a&&"function"==typeof b&&this.event.push({type:a.toLowerCase(),callback:b,unique:!1})},this.off=function(a){for(var b=[],c=0;c<this.event.length;c++){var d=this.event[c];("function"==typeof a&&d.callback!=a||"string"==typeof a&&d.type!=a.toLowerCase())&&b.push(d)}this.event=b},this.addEvent=function(){this.listen.add(arguments)},this.addTrigger=function(a,b){this.listen.trigger(a,b)},this.addValid=function(a,c){if(this.__proto__){var d=this.__proto__[a];this.__proto__[a]=function(){for(var e=arguments,f=0;f<e.length;f++)if(!b.typeCheck(c[f],e[f]))throw new Error("JUI_CRITICAL_ERR: the "+f+"th parameter is not a "+c[f]+" ("+a+")");return d.apply(this,e)}}},this.callBefore=function(a,b){if(this.__proto__){var c=this.__proto__[a];this.__proto__[a]=function(){var a=arguments;return"function"!=typeof b?c.apply(this,a):b.apply(this,a)!==!1?c.apply(this,a):void 0}}},this.callAfter=function(a,b){if(this.__proto__){var c=this.__proto__[a];this.__proto__[a]=function(){var a=arguments,d=c.apply(this,a);return"function"==typeof b&&d!==!1&&b.apply(this,a),d}}},this.callDelay=function(a,b){function c(a,c){var e=d.apply(a,c);"function"==typeof b.after&&e!==!1&&b.after.apply(a,c)}if(this.__proto__){var d=this.__proto__[a],e=isNaN(b.delay)?0:b.delay;this.__proto__[a]=function(){var a=this,d=arguments;"function"==typeof b.before&&b.before.apply(a,d),e>0?setTimeout(function(){c(a,d)},e):c(a,d)}}},this.setTpl=function(a,c){this.tpl[a]=b.template(c)},this.setVo=function(){this.options.vo&&(null!=c&&c.reload(),c=a(this.selector).jbinder(),this.bind=c)},this.setOption=function(a,b){if("object"==typeof a)for(var c in a)this.options[c]=a[c];else this.options[a]=b},this.destroy=function(){if(this.__proto__){for(var b=0;b<this.listen.size();b++){var c=this.listen.get(b);a(c.target).off(c.type)}for(var d in this.__proto__)delete this.__proto__[d]}}};return f.build=function(f){return function(g,h){var i=a(g),j=[];return i.each(function(c){var e=new f["class"],k=jui.defineOptions(f["class"],h||{});e.init.prototype=e,e.init.prototype.selector=i.selector,e.init.prototype.root=this,e.init.prototype.options=k,e.init.prototype.tpl={},e.init.prototype.event=new Array,e.init.prototype.listen=new d,e.init.prototype.timestamp=(new Date).getTime(),e.init.prototype.index=c,e.init.prototype.module=f,a("script").each(function(){if(g==a(this).data("jui")||g==a(this).data("vo")||g instanceof HTMLElement){var b=a(this).data("tpl");if(""==b)throw new Error("JUI_CRITICAL_ERR: 'data-tpl' property is required");k.tpl[b]=a(this).html()}});for(var l in k.tpl){var m=k.tpl[l];b.typeCheck("string",m)&&""!=m&&(e.init.prototype.tpl[l]=b.template(m))}var n=new e.init;for(var o in k.event)n.on(o,k.event[o]);j[c]=n,this.jui=n}),c.add(new e(f.type,g,h,j)),0==j.length?null:1==j.length?j[0]:j}},f.init=function(a){var b=null;return"object"==typeof a&&(b=f.build(a),c.addClass({type:a.type,"class":b})),b},f.setup=function(){return{tpl:{},event:{},vo:null}},window.jui="object"==typeof jui?a.extend(jui,c):c,f}),jui.define("util.math",[],function(){var a={rotate:function(a,b,c){return{x:a*Math.cos(c)-b*Math.sin(c),y:a*Math.sin(c)+b*Math.cos(c)}},radian:function(a){return a*Math.PI/180},degree:function(a){return 180*a/Math.PI},angle:function(a,b,c,d){var e=c-a,f=d-b;return Math.atan2(f,e)},interpolateNumber:function(a,b){var c=b-a;return function(b){return a+c*b}},interpolateRound:function(a,b){var c=b-a;return function(b){return Math.round(a+c*b)}},nice:function(a,b,c,d){function e(a,b){var c=Math.floor(Math.log(a)/Math.LN10),d=a/Math.pow(10,c);return niceFraction=b?1.5>d?1:3>d?2:7>d?5:10:1>=d?1:2>=d?2:5>=d?5:10,niceFraction*Math.pow(10,c)}function f(){m=d?e(g-h,!1):g-h,l=d?e(m/k,!0):m/k,i=d?Math.floor(h/l)*l:h,j=d?Math.floor(g/l)*l:g}if(d=d||!1,a>b)var g=a,h=b;else var h=a,g=b;var i,j,k=c,l=0,m=[];return f(),{min:i,max:j,range:m,spacing:l}}};return a}),jui.define("util.time",["util.base"],function(a){var b={years:1,months:2,days:3,hours:4,minutes:5,seconds:6,milliseconds:7,weeks:8,add:function(a){if(arguments.length<=2)return a;if(arguments.length>2){for(var b=new Date(+a),c=1;c<arguments.length;c+=2){var d=arguments[c],e=arguments[c+1];this.years==d?b.setFullYear(b.getFullYear()+e):this.months==d?b.setMonth(b.getMonth()+e):this.days==d?b.setDate(b.getDate()+e):this.hours==d?b.setHours(b.getHours()+e):this.minutes==d?b.setMinutes(b.getMinutes()+e):this.seconds==d?b.setSeconds(b.getSeconds()+e):this.milliseconds==d?b.setMilliseconds(b.getMilliseconds()+e):this.weeks==d&&b.setDate(b.getDate()+7*e)}return b}},format:function(b,c,d){return a.dateFormat(b,c,d)}};return b}),jui.define("util.scale",["util.math","util.time"],function(a,b){var c={circle:function(){function a(){}var b=[],c=[],d=0;return a.domain=function(a){if("undefined"==typeof a)return b;for(var c=0;c<a.length;c++)b[c]=a[c];return this},a.range=function(a){if("undefined"==typeof a)return c;for(var b=0;b<a.length;b++)c[b]=a[b];return this},a.rangePoints=function(e,f){f=f||0;for(var g=b.length,h=(e[1]-e[0]-f)/g,i=[],j=0;j<b.length;j++)i[j]=0==j?e[0]+f/2+h/2:i[j-1]+h;return c=i,d=h,a},a.rangeBands=function(e,f,g){f=f||0,g=g||0;for(var h=b.length,i=h-1,j=(e[1]-e[0])/i,k=[],l=0;l<b.length;l++)k[l]=0==l?e[0]:j+k[l-1];return d=j,c=k,a},a.rangeBand=function(){return d},a},ordinal:function(){function a(a){var d=""+a;if("undefined"!=typeof e[d])return e[d];for(var f=-1,g=0;g<b.length;g++)if("string"==typeof a&&b[g]===a){f=g;break}return f>-1?(e[d]=c[f],c[f]):"undefined"!=typeof c[a]?(b[a]=a,e[d]=c[a],c[a]):null}var b=[],c=[],d=0,e={};return a.domain=function(a){if("undefined"==typeof a)return b;for(var c=0;c<a.length;c++)b[c]=a[c];return this},a.range=function(a){if("undefined"==typeof a)return c;for(var b=0;b<a.length;b++)c[b]=a[b];return this},a.rangePoints=function(e,f){f=f||0;for(var g=b.length,h=(e[1]-e[0]-f)/g,i=[],j=0;j<b.length;j++)i[j]=0==j?e[0]+f/2+h/2:i[j-1]+h;return c=i,d=h,a},a.rangeBands=function(e,f,g){f=f||0,g=g||0;for(var h=b.length,i=h-1,j=(e[1]-e[0])/i,k=[],l=0;l<b.length;l++)k[l]=0==l?e[0]:j+k[l-1];return d=j,c=k,a},a.rangeBand=function(){return d},a.invert=function(a){return Math.ceil(a/d)},a},time:function(){var a,d=[],e=c.linear(),f=e.domain;return e.domain=function(a){if(!arguments.length)return f.call(e);for(var b=0;b<a.length;b++)d[b]=+a[b];return f.call(e,d)},e.min=function(){return Math.min(d[0],d[d.length-1])},e.max=function(){return Math.max(d[0],d[d.length-1])},e.rate=function(a,b){return e(e.max()*(a/b))},e.ticks=function(c,f){for(var g=d[0],h=d[1],i=[];h>g;)i.push(new Date(+g)),g=b.add(g,c,f);i.push(new Date(+g));var j=e(i[0]),k=e(i[1]);return a=k-j,i},e.realTicks=function(c,f){var g=d[0],h=d[1],i=[],j=new Date(+g),k=null;for(c==b.years?k=new Date(j.getFullYear(),0,1):c==b.months?k=new Date(j.getFullYear(),j.getMonth(),1):c==b.days||c==b.weeks?k=new Date(j.getFullYear(),j.getMonth(),j.getDate()):c==b.hours?k=new Date(j.getFullYear(),j.getMonth(),j.getDate(),j.getHours(),0,0,0):c==b.minutes?k=new Date(j.getFullYear(),j.getMonth(),j.getDate(),j.getHours(),j.getMinutes(),0,0):c==b.seconds?k=new Date(j.getFullYear(),j.getMonth(),j.getDate(),j.getHours(),j.getMinutes(),j.getSeconds(),0):c==b.milliseconds&&(k=new Date(j.getFullYear(),j.getMonth(),j.getDate(),j.getHours(),j.getMinutes(),j.getSeconds(),j.getMilliseconds())),k=b.add(k,c,f);+h>+k;)i.push(new Date(+k)),k=b.add(k,c,f);var l=e(i[1]),m=e(i[2]);return a=m-l,i},e.rangeBand=function(){return a},e.invert=function(a){var b=c.linear().domain(e.range()).range(e.domain());return new Date(b(a))},e},linear:function(){function b(a){if(a>l)return g?b(l):e[0]+Math.abs(a-d[1])*o/p;if(k>a)return g?b(k):e[0]-Math.abs(a-d[0])*o/p;var c=(a-d[0])/o;return q(c)}var d=[0,1],e=[0,1],f=!1,g=!1,h={},i=null,j=null,k=null,l=null,m=null,n=null,o=null,p=null,q=null;return b.cache=function(){return h},b.min=function(){return Math.min.apply(Math,d)},b.max=function(){return Math.max.apply(Math,d)},b.rangeMin=function(){return Math.min.apply(Math,e)},b.rangeMax=function(){return Math.max.apply(Math,e)},b.rate=function(a,c){return b(b.max()*(a/c))},b.clamp=function(a){g=a||!1},b.domain=function(a){if(!arguments.length)return d;for(var c=0;c<a.length;c++)d[c]=a[c];return k=b.min(),l=b.max(),o=d[1]-d[0],this},b.range=function(c){if(!arguments.length)return e;for(var d=0;d<c.length;d++)e[d]=c[d];return i=a.interpolateRound(e[0],e[1]),j=a.interpolateNumber(e[0],e[1]),m=b.rangeMin(),n=b.rangeMax(),p=Math.abs(n-m),q=f?i:j,this},b.rangeRound=function(a){return f=!0,b.range(a)},b.invert=function(a){var b=c.linear().domain(e).range(d);return b(a)},b.ticks=function(b,c,e){if(e=e||1e4,0==d[0]&&0==d[1])return[];for(var f=a.nice(d[0],d[1],b||10,c||!1),g=[],h=f.min*e,i=f.max*e;i>=h;)g.push(h/e),h+=f.spacing*e;return g[g.length-1]*e!=i&&h>i&&g.push(i/e),d[0]>d[1]&&g.reverse(),g},b}};return c}),jui.define("util.color",[],function(){var a={regex:/(linear|radial)\((.*)\)(.*)/i,trim:function(a){return(a||"").replace(/^\s+|\s+$/g,"")},lighten:function(a,b){a=a.replace(/[^0-9a-f]/gi,""),b=b||0;var c,d,e=[];for(d=0;6>d;d+=2)c=parseInt(a.substr(d,2),16),c=Math.round(Math.min(Math.max(0,c+c*b),255)).toString(16),e.push(("00"+c).substr(c.length));return"#"+e.join("")},darken:function(a,b){return this.lighten(a,-b)},parse:function(a){return this.parseGradient(a)},parseGradient:function(a){var b=a.match(this.regex);if(!b)return a;var c=this.trim(b[1]),d=this.parseAttr(c,this.trim(b[2])),e=this.parseStop(this.trim(b[3])),f={type:c+"Gradient",attr:d,children:e};return f},parseStop:function(a){for(var b=a.split(","),c=[],d=0,e=b.length;e>d;d++){var a=b[d],f=a.split(" ");0!=f.length&&(1==f.length?c.push({type:"stop",attr:{"stop-color":f[0]}}):2==f.length?c.push({type:"stop",attr:{offset:f[0],"stop-color":f[1]}}):3==f.length&&c.push({type:"stop",attr:{offset:f[0],"stop-color":f[1],"stop-opacity":f[2]}}))}for(var g=-1,h=-1,d=0,e=c.length;e>d;d++){var a=c[d];if(0==d?a.offset||(a.offset=0):d==e-1&&(a.offset||(a.offset=1)),-1==g&&"undefined"==typeof a.offset)g=d;else if(-1==h&&"undefined"==typeof a.offset){h=d;for(var i=h-g,j=c[h].offset.indexOf("%")>-1?parseFloat(c[h].offset)/100:c[h].offset,k=c[g].offset.indexOf("%")>-1?parseFloat(c[g].offset)/100:c[g].offset,l=j-k,m=l/i,n=k+m,o=g+1;h>o;o++)c[o].offset=n,n+=m;g=h,h=-1}}return c},parseAttr:function(a,b){if("linear"!=a){for(var c=b.split(","),d=0,e=c.length;e>d;d++)-1==c[d].indexOf("%")&&(c[d]=parseFloat(c[d]));return{cx:c[0],cy:c[1],r:c[2],fx:c[3],fy:c[4]}}switch(b){case"":case"left":return{x1:0,y1:0,x2:1,y2:0,direction:b||"left"};case"right":return{x1:1,y1:0,x2:0,y2:0,direction:b};case"top":return{x1:0,y1:0,x2:0,y2:1,direction:b};case"bottom":return{x1:0,y1:1,x2:0,y2:0,direction:b};case"top left":return{x1:0,y1:0,x2:1,y2:1,direction:b};case"top right":return{x1:1,y1:0,x2:0,y2:1,direction:b};case"bottom left":return{x1:0,y1:1,x2:1,y2:0,direction:b};case"bottom right":return{x1:1,y1:1,x2:0,y2:0,direction:b};default:for(var c=b.split(","),d=0,e=c.length;e>d;d++)-1==c[d].indexOf("%")&&(c[d]=parseFloat(c[d]));return{x1:c[0],y1:c[1],x2:c[2],y2:c[3]}}}};return a}),jui.define("util.svg.element",[],function(){var a=function(){this.create=function(a,b){this.element=document.createElementNS("http://www.w3.org/2000/svg",a),this.childrens=[],this.parent=null,this.styles={},this.attributes={},this.attr(b)},this.each=function(a){if("function"==typeof a){for(var b=0,c=this.childrens.length;c>b;b++){var d=this.childrens[b];a.apply(d,[b,d])}return this.childrens}},this.get=function(a){return this.childrens[a]?this.childrens[a]:null},this.index=function(a){for(var b=0;b<this.childrens.length;b++)if(a==this.childrens[b])return b;return-1},this.append=function(b){return b instanceof a&&(b.parent&&b.remove(),this.childrens.push(b),b.parent=this),this},this.prepend=function(a){return this.insert(0,a)},this.insert=function(a,b){return b.parent&&b.remove(),this.childrens.splice(a,0,b),b.parent=this,this},this.remove=function(){for(var a=0,b=[],c=this.parent.childrens,d=0;d<c.length;d++){if(c[d]==this){a=d;break}b.push(c[d])}return this.parent.childrens=b,this},this.attr=function(a){if("undefined"!=typeof a&&a){if("string"==typeof a)return this.attributes[a]||this.element.getAttribute(a);for(var b in a)this.attributes[b]=a[b],-1!=b.indexOf("xlink:")?this.element.setAttributeNS("http://www.w3.org/1999/xlink",b,a[b]):this.element.setAttribute(b,a[b]);return this}},this.css=function(a){var b=[];for(var c in a)this.styles[c]=a[c];for(var c in a)b.push(c+":"+a[c]);return this.attr({style:b.join(";")}),this},this.html=function(a){return this.element.innerHTML=a,this},this.text=function(a){return this.element.appendChild(document.createTextNode(a)),this},this.on=function(a,b){return this.element.addEventListener(a,function(a){"function"==typeof b&&b.call(this,a)},!1),this},this.hover=function(a,b){return this.element.addEventListener("mouseover",function(b){"function"==typeof a&&a.call(this,b)},!1),this.element.addEventListener("mouseout",function(a){"function"==typeof b&&b.call(this,a)},!1),this},this.size=function(){var a={width:0,height:0},b=this.element.getBoundingClientRect();if(!b||0==b.width&&0==b.height){for(var c=["height","paddingTop","paddingBottom","borderTopWidth","borderBottomWidth"],d=["width","paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"],e=window.getComputedStyle(this.element),f=0;f<c.length;f++)a.height+=parseFloat(e[c[f]]);for(var f=0;f<d.length;f++)a.width+=parseFloat(e[d[f]]);a.width=a.width||this.element.getAttribute("width"),a.height=a.height||this.element.getAttribute("height")}else a.width=b.width,a.height=b.height;return isNaN(a.width)&&(a.width=0),isNaN(a.height)&&(a.height=0),a},this.is=function(a){return this instanceof jui.include(a)}};return a}),jui.define("util.svg.element.transform",["util.base"],function(a){var b=function(){function b(a){var b=[];for(var c in d)d[c]&&b.push(d[c]);a.attr({transform:b.join(" ")})}function c(a){for(var b=[],c=0;c<a.length;c++)b.push(a[c]);return b.join(",")}var d={};this.translate=function(){return d.translate="translate("+c(arguments)+")",b(this),this
},this.rotate=function(a,c,e){if(1==arguments.length)var f=a;else if(3==arguments.length)var f=a+" "+c+","+e;return d.rotate="rotate("+f+")",b(this),this},this.scale=function(){return d.scale="scale("+c(arguments)+")",b(this),this},this.skew=function(){return d.skew="skew("+c(arguments)+")",b(this),this},this.matrix=function(){return d.matrix="matrix("+c(arguments)+")",b(this),this},this.data=function(b){var c=this.attr("transform"),d={translate:/[^translate()]+/g,rotate:/[^rotate()]+/g,scale:/[^scale()]+/g,skew:/[^skew()]+/g,matrix:/[^matrix()]+/g};return a.typeCheck("string",c)?c.match(d[b])[0]:null}};return b},"util.svg.element"),jui.define("util.svg.element.path",["util.base"],function(a){var b=function(){var b=[];this.moveTo=function(a,c,d){return b.push((d||"m")+a+","+c),this},this.MoveTo=function(a,b){return this.moveTo(a,b,"M")},this.lineTo=function(a,c,d){return b.push((d||"l")+a+","+c),this},this.LineTo=function(a,b){return this.lineTo(a,b,"L")},this.hLineTo=function(a,c){return b.push((c||"h")+a),this},this.HLineTo=function(a){return this.hLineTo(a,"H")},this.vLineTo=function(a,c){return b.push((c||"v")+a),this},this.VLineTo=function(a){return this.vLineTo(a,"V")},this.curveTo=function(a,c,d,e,f,g,h){return b.push((h||"c")+a+","+c+" "+d+","+e+" "+f+","+g),this},this.CurveTo=function(a,b,c,d,e,f){return this.curveTo(a,b,c,d,e,f,"C")},this.sCurveTo=function(a,c,d,e,f){return b.push((f||"s")+a+","+c+" "+d+","+e),this},this.SCurveTo=function(a,b,c,d){return this.sCurveTo(a,b,c,d,"S")},this.qCurveTo=function(a,c,d,e,f){return b.push((f||"q")+a+","+c+" "+d+","+e),this},this.QCurveTo=function(a,b,c,d){return this.qCurveTo(a,b,c,d,"Q")},this.tCurveTo=function(a,c,d,e,f){return b.push((f||"t")+a+","+c+" "+d+","+e),this},this.TCurveTo=function(a,b,c,d){return this.tCurveTo(a,b,c,d,"T")},this.arc=function(a,c,d,e,f,g,h,i){return e=e?1:0,f=f?1:0,b.push((i||"a")+a+","+c+" "+d+" "+e+","+f+" "+g+","+h),this},this.Arc=function(a,b,c,d,e,f,g){return this.arc(a,b,c,d,e,f,g,"A")},this.closePath=function(a){return b.push(a||"z"),this},this.ClosePath=function(){return this.closePath("Z")},this.join=function(){b.length>0&&(this.attr({d:b.join(" ")}),b=[])},this.length=function(){var c=a.createId(),d=b.join(" "),e=document.createElement("svg"),f=document.createElementNS("http://www.w3.org/2000/svg","path");f.setAttributeNS(null,"id",c),f.setAttributeNS(null,"d",d),e.appendChild(f),document.body.appendChild(e);var g=document.getElementById(c).getTotalLength();return document.body.removeChild(e),g}};return b},"util.svg.element.transform"),jui.define("util.svg.element.path.symbol",["util.base"],function(){var a=function(){var a="";this.template=function(a,b){var c=a,d=half_r=a/2,e=b/2,f="a"+half_r+","+half_r+" 0 1,1 "+c+",0",g="a"+half_r+","+half_r+" 0 1,1 "+-c+",0",h={triangle:["m0,"+-e,"l"+d+","+b,"l"+-a+",0","l"+d+","+-b].join(" "),rect:["m"+-d+","+-e,"l"+a+",0","l0,"+b,"l"+-a+",0","l0,"+-b].join(" "),cross:["m"+-d+","+-e,"l"+a+","+b,"m0,"+-b,"l"+-a+","+b].join(" "),circle:["m"+-c+",0",f,g].join(" ")};return h.rectangle=h.rect,h},this.join=function(){a.length>0&&(this.attr({d:a}),a="")},this.add=function(b,c,d){a+=" M"+b+","+c+d},this.triangle=function(a,b,c,d){return this.MoveTo(a,b).moveTo(0,-d/2).lineTo(c/2,d).lineTo(-c,0).lineTo(c/2,-d)},this.rect=this.rectangle=function(a,b,c,d){return this.MoveTo(a,b).moveTo(-c/2,-d/2).lineTo(c,0).lineTo(0,d).lineTo(-c,0).lineTo(0,-d)},this.cross=function(a,b,c,d){return this.MoveTo(a,b).moveTo(-c/2,-d/2).lineTo(c,d).moveTo(0,-d).lineTo(-c,d)},this.circle=function(a,b,c){return this.MoveTo(a,b).moveTo(-c,0).arc(c/2,c/2,0,1,1,c,0).arc(c/2,c/2,0,1,1,-c,0)}};return a},"util.svg.element.path"),jui.define("util.svg.element.path.rect",["util.math"],function(a){var b=function(){this.round=function(a,b,c,d,e,f){c=c?c:0,d=d?d:0,e=e?e:0,f=f?f:0,this.MoveTo(0,c).Arc(c,c,0,0,1,c,0).HLineTo(a-d).Arc(d,d,0,0,1,a,d).VLineTo(b-e).Arc(e,e,0,0,1,a-e,b).HLineTo(f).Arc(f,f,0,0,1,0,b-f).ClosePath().join()},this.rect3d=function(b,c,d,e){var f=a.radian(d),g=0,h=0,i=b,j=c,k=Math.cos(f)*e+g,l=Math.sin(f)*e+h,m=b+k,n=c+l,o=svg.group({width:m,height:n},function(){this.MoveTo(k,g).LineTo(m,h).LineTo(i,l).LineTo(g,l),this.MoveTo(g,l).LineTo(g,n).LineTo(i,n).LineTo(i,l).ClosePath(),this.MoveTo(i,n).LineTo(m,j).LineTo(m,h).LineTo(i,l).ClosePath()});return o}};return b},"util.svg.element.path"),jui.define("util.svg.element.poly",[],function(){var a=function(){var a=[];this.point=function(b,c){return a.push(b+","+c),this},this.join=function(){if(a.length>0){var b=a[0];a.push(b),this.attr({points:a.join(" ")}),a=[]}}};return a},"util.svg.element.transform"),jui.define("util.svg",["util.base","util.math","util.svg.element","util.svg.element.transform","util.svg.element.path","util.svg.element.path.symbol","util.svg.element.path.rect","util.svg.element.poly"],function(a,b,c,d,e,f,g,h){var i=function(b,i){function j(){n.root=o=new c,p=new d,q=new d,o.create("svg",i),p.create("g"),q.create("g"),p.translate(.5,.5),q.translate(.5,.5),b.appendChild(o.element),o.append(p),o.append(q)}function k(b,c,d,e){return b.create(c,d),0==s?p.append(b):r[s].append(b),a.typeCheck("function",e)&&(s++,r[s]=b,e.call(b),s--),b}function l(a,b,c,d){if(a.parent==p)throw new Error("JUI_CRITICAL_ERR: Parents are required elements of the '"+b+"'");return k(a,b,c,d)}function m(a){for(var b=a.childrens.length,c=0;b>c;c++){var d=a.childrens[c];d&&(d.childrens.length>0&&m(d),(d instanceof e||d instanceof h)&&d.join(),d.parent==a&&a.element.appendChild(d.element))}}var n=this,o=null,p=null,q=null,r={},s=0,t=!1;this.size=function(){if(2!=arguments.length)return o.size();var a=arguments[0],b=arguments[1];o.attr({width:a,height:b})},this.clear=function(a){p.each(function(){this.element.parentNode&&p.element.removeChild(this.element)}),a===!0&&q.each(function(){this.element.parentNode&&q.element.removeChild(this.element)})},this.reset=function(a){this.clear(a),p.childrens=[],a===!0&&(q.childrens=[])},this.render=function(a){this.clear(),m(t===!1||a===!0?o:p),t=!0},this.download=function(b){a.typeCheck("string",b)&&(b=b.split(".")[0]);var c=document.createElement("a");c.download=b?b+".svg":"svg.svg",c.href=this.toDataURL(),document.body.appendChild(c),c.click(),c.parentNode.removeChild(c)},this.downloadImage=function(b,c){c=c||"image/png";var d=new Image,e=this.size(),f=this.toDataURL().replace('width="100%"','width="'+e.width+'"').replace('height="100%"','height="'+e.height+'"');d.onload=function(){var e=document.createElement("canvas");e.width=d.width,e.height=d.height;var f=e.getContext("2d");f.drawImage(d,0,0);var g=e.toDataURL(c);a.typeCheck("string",b)&&(b=b.split(".")[0]);var h=document.createElement("a");h.download=b?b+".png":"svg.png",h.href=g,document.body.appendChild(h),h.click(),h.parentNode.removeChild(h)},d.src=f},this.exportCanvas=function(a){var b=new Image,c=this.size(),d=this.toDataURL().replace('width="100%"','width="'+c.width+'"').replace('height="100%"','height="'+c.height+'"');b.onload=function(){a.width=b.width,a.height=b.height;var c=a.getContext("2d");c.drawImage(b,0,0)},b.src=d},this.toXml=function(){var a=b.innerHTML;return a=a.replace('xmlns="http://www.w3.org/2000/svg"',""),['<?xml version="1.0" encoding="utf-8"?>',a.replace("<svg ",'<svg xmlns="http://www.w3.org/2000/svg" ')].join("\n")},this.toDataURL=function(){var b=this.toXml();return(a.browser.mozilla||a.browser.msie)&&(b=encodeURIComponent(b)),a.browser.msie?"data:image/svg+xml,"+b:"data:image/svg+xml;utf8,"+b},this.autoRender=function(a,b){s>0||(b?p.append(a):q.append(a))},this.getTextRect=function(a){if(""==a)return{width:0,height:0};var b=document.createElementNS("http://www.w3.org/2000/svg","text");b.setAttributeNS(null,"x",-200),b.setAttributeNS(null,"y",-200),b.appendChild(document.createTextNode(a)),o.element.appendChild(b);var c=b.getBoundingClientRect();return o.element.removeChild(b),{width:c.width,height:c.height}},this.custom=function(a,b,d){return k(new c,a,b,d)},this.defs=function(a){return k(new c,"defs",null,a)},this.symbol=function(a,b){return k(new c,"symbol",a,b)},this.g=this.group=function(a,b){return k(new d,"g",a,b)},this.marker=function(a,b){return k(new c,"marker",a,b)},this.a=function(a,b){return k(new d,"a",a,b)},this.switch=function(a,b){return k(new c,"switch",a,b)},this.use=function(a){return k(new c,"use",a)},this.rect=function(a,b){return k(new d,"rect",a,b)},this.line=function(a,b){return k(new d,"line",a,b)},this.circle=function(a,b){return k(new d,"circle",a,b)},this.text=function(b,c){return 2==arguments.length?a.typeCheck("function",c)?k(new d,"text",b,c):k(new d,"text",b).text(c):k(new d,"text",b)},this.textPath=function(b,d){return a.typeCheck("string",d)?k(new c,"textPath",b).text(d):k(new c,"textPath",b)},this.tref=function(b,d){return a.typeCheck("string",d)?k(new c,"tref",b).text(d):k(new c,"tref",b)},this.tspan=function(b,d){return a.typeCheck("string",d)?k(new c,"tspan",b).text(d):k(new c,"tspan",b)},this.ellipse=function(a,b){return k(new d,"ellipse",a,b)},this.image=function(a,b){return k(new d,"image",a,b)},this.path=function(a,b){return k(new e,"path",a,b)},this.pathSymbol=function(a,b){return k(new f,"path",a,b)},this.pathRect=function(a,b){return k(new g,"path",a,b)},this.polyline=function(a,b){return k(new h,"polyline",a,b)},this.polygon=function(a,b){return k(new h,"polygon",a,b)},this.pattern=function(a,b){return k(new c,"pattern",a,b)},this.mask=function(a,b){return k(new c,"mask",a,b)},this.clipPath=function(a,b){return k(new c,"clipPath",a,b)},this.linearGradient=function(a,b){return k(new c,"linearGradient",a,b)},this.radialGradient=function(a,b){return k(new c,"radialGradient",a,b)},this.filter=function(a,b){return k(new c,"filter",a,b)},this.stop=function(a){return l(new c,"stop",a)},this.animate=function(a){return l(new c,"animate",a)},this.animateColor=function(a){return l(new c,"animateColor",a)},this.animateMotion=function(a){return l(new c,"animateMotion",a)},this.animateTransform=function(a){return l(new c,"animateTransform",a)},this.mpath=function(a){return l(new c,"mpath",a)},this.set=function(a){return l(new c,"set",a)},this.feBlend=function(a){return l(new c,"feBlend",a)},this.feColorMatrix=function(a){return l(new c,"feColorMatrix",a)},this.feComponentTransfer=function(a){return l(new c,"feComponentTransfer",a)},this.feComposite=function(a){return l(new c,"feComposite",a)},this.feConvolveMatrix=function(a){return l(new c,"feConvolveMatrix",a)},this.feDiffuseLighting=function(a){return l(new c,"feDiffuseLighting",a)},this.feDisplacementMap=function(a){return l(new c,"feDisplacementMap",a)},this.feFlood=function(a){return l(new c,"feFlood",a)},this.feGaussianBlur=function(a){return l(new c,"feGaussianBlur",a)},this.feImage=function(a){return l(new c,"feImage",a)},this.feMerge=function(a,b){return l(new c,"feMerge",a,b)},this.feMergeNode=function(a){return l(new c,"feMergeNode",a)},this.feMorphology=function(a){return l(new c,"feMorphology",a)},this.feOffset=function(a){return l(new c,"feOffset",a)},this.feSpecularLighting=function(a){return l(new c,"feSpecularLighting",a)},this.feTile=function(a){return l(new c,"feTile",a)},this.feTurbulence=function(a){return l(new c,"feTurbulence",a)},j()};return i.createElement=function(a){var b=new c;if(b.create(a.type,a.attr),a.children instanceof Array){var d=0;for(a.children.length;d<a.children.length;d++)b.append(i.createElement(a.children[d]))}return b},i}),jui.defineUI("ui.dropdown",["jquery"],function(a){var b=function(){var a=c();null!=a&&a.hide()},c=function(){for(var a=jui.get("ui.dropdown"),b=0;b<a.length;b++)for(var c=a[b],d=0;d<c.length;d++)if("show"==c[d].type)return c[d];return null};a(function(){a("body").on("click",function(a){var c=a.target.tagName;"LI"!=c&&"INPUT"!=c&&"A"!=c&&"BUTTON"!=c&&"I"!=c&&b()}),a(window).on("keydown",function(a){var b=c();null!=b&&b.wheel(a.which,function(){a.preventDefault()})})});var d=function(){function c(c){function d(a){var b=0;return f.each(function(c){a==this&&(b=c)}),b}var f=a(e.menu).find("li");f.off("click").off("hover"),c.addEvent(f,"click",function(e){if(!a(this).hasClass("divider")){var f=d(this),g=a(this).text(),h=a(this).attr("value");c.emit("change",[{index:f,value:h,text:g},e]),c.options.close&&b(),"A"==e.target.tagName&&e.preventDefault()}}),c.addEvent(f,"hover",function(){f.removeClass("active")})}function d(a,b){var c=e.menu.find("li"),d=c.eq(f);c.removeClass("active"),""!=d.val()||""!=d.html()?(d.addClass("active"),a.options.height>0&&e.menu.scrollTop(f*d.outerHeight())):"function"==typeof b&&b()}var e=null,f=-1;this.init=function(){var b=this.options,d=a(this.root),f=d.find("ul"),g=d.find(".anchor");f=0==f.size()?d:f,e={root:d,menu:f,anchor:g},e.root.outerWidth(e.menu.outerWidth()),b.width>0&&f.outerWidth(b.width),b.height>0&&f.css({maxHeight:b.height,overflow:"auto"}),b.left>0&&d.css("left",b.left),b.top>0&&d.css("top",b.top),f.css({display:"block"}),d.css({position:"absolute",display:"none"}),b.nodes.length>0?this.update(b.nodes):c(this),this.type="hide"},this.update=function(b){if(this.tpl.node){a(e.menu).empty();for(var d=0;d<b.length;d++)a(e.menu).append(this.tpl.node(b[d]));c(this)}},this.hide=function(){e.root.hide(),this.emit("hide"),this.type="hide"},this.show=function(a,c){b(),e.root.show(),e.anchor.size()>0&&e.root.css("margin-top","10px"),2==arguments.length&&this.move(a,c),this.emit("show"),this.type="show"},this.move=function(a,b){e.root.css("left",a),e.root.css("top",b)},this.wheel=function(a,b){if(this.options.keydown){var c=this,g=e.menu.find("li");(38==a||-1==a)&&(1>f?f=g.size()-1:f--,d(this,function(){f--,d(c)}),b&&b()),(40==a||1==a)&&(f<g.size()-1?f++:f=0,d(c,function(){f++,d(c)}),b&&b()),13!=a&&0!=a&&a||(c.addTrigger(g.eq(f),"click"),f=-1,b&&b())}},this.reload=function(){this.init(),this.emit("reload")}};return d.setup=function(){return{close:!0,keydown:!1,left:0,top:0,width:0,height:0,nodes:[]}},d}),jui.define("uix.table.column",["jquery"],function(a){var b=function(b){this.element=null,this.order="asc",this.name=null,this.data=[],this.list=[],this.index=b,this.type="show",this.width=null,this.hide=function(){this.type="hide",a(this.element).hide()},this.show=function(){this.type="show",a(this.element).show()}};return b}),jui.define("uix.table.row",["jquery"],function(a){var b=function(b,c,d){function e(a){k.rownum=isNaN(a)?k.rownum:a,k.index=k.parent?k.parent.index+"."+k.rownum:""+k.rownum,k.parent&&"string"==typeof k.index&&(k.depth=k.index.split(".").length-1),k.isLeaf()||f(k)}function f(a){for(var b=a.childrens,c=0;c<b.length;c++)b[c].reload(c),b[c].isLeaf()||f(b[c])}function g(){k.list=[],a(k.element).find("td").each(function(a){k.list[a]=this,l[a]&&(this.style.display="none")})}function h(){if(!c)return k.element;var b=a(c(a.extend({row:{index:k.index,data:k.data,depth:k.depth}},k.data))).get(0);return b}function i(b){a(b.element).remove();for(var c=0;c<b.childrens.length;c++){var d=b.childrens[c];d.isLeaf()?a(d.element).remove():i(d)}}function j(){for(var a=0;a<k.childrens.length;a++)k.childrens[a].reload(a)}var k=this,l={};this.data=b,this.rownum=null,this.index=null,this.element=null,this.list=[],this.parent=d?d:null,this.childrens=[],this.depth=0,this.type="fold",this.reload=function(b,c,d){if(c||e(b),null!=this.element){var f=h(),i=a(this.element).attr("class");a(f).addClass(i).insertAfter(this.element),a(this.element).remove(),this.element=f}else this.element=h();null!=d&&this.hideCells(d),g()},this.destroy=function(){null!=this.parent?this.parent.removeChild(this.index):(i(this),a(this.element).remove())},this.isLeaf=function(){return 0==this.childrens.length?!0:!1},this.fold=function(){this.type="fold";for(var b=0;b<this.childrens.length;b++){var c=this.childrens[b];a(c.element).hide(),c.isLeaf()||c.fold()}},this.open=function(){this.type="open";for(var b=0;b<this.childrens.length;b++){var c=this.childrens[b];a(c.element).show(),c.isLeaf()||c.open()}},this.appendChild=function(b){var c=this.isLeaf()?this.element:this.lastChildLeaf().element;a(b.element).insertAfter(c),this.childrens.push(b)},this.insertChild=function(b,c){var d=this.element;if(b>0){var e=this.childrens[b-1];d=e.isLeaf()&&this.childrens.length!=b+1?e.element:e.lastChildLeaf().element}a(c.element).insertAfter(d);var f=this.childrens.splice(0,b);f.push(c),this.childrens=f.concat(this.childrens),j()},this.removeChild=function(a){for(var b=0;b<this.childrens.length;b++){var c=this.childrens[b];c.index==a&&(this.childrens.splice(b,1),i(c))}j()},this.lastChild=function(){return this.isLeaf()?null:this.childrens[this.childrens.length-1]},this.lastChildLeaf=function(a){var b=a?a:this.lastChild();return b.isLeaf()?b:this.lastChildLeaf(b.lastChild())},this.showCell=function(b){l[b]=!1,a(this.list[b]).show()},this.hideCell=function(b){l[b]=!0,a(this.list[b]).hide()},this.hideCells=function(a){for(var b=0;b<a.length;b++)"hide"==a[b].type&&this.hideCell(b)}};return b}),jui.define("uix.table.base",["jquery","util.base","uix.table.column","uix.table.row"],function(a,b,c,d){var e=function(e,f){function g(){r(),h()}function h(){var b=[];t.thead.find("tr:last > th").each(function(){b.push(this)});for(var d=0;d<b.length;d++){var e=new c(d);v[d]?(e.element=v[d].element,e.order=v[d].order,e.name=v[d].name,e.data=v[d].data,e.list=v[d].list,e.type=v[d].type,e.width=v[d].width):(e.element=b[d],(a(e.element).attr("width")||a(e.element).attr("style")&&-1!=a(e.element).attr("style").indexOf("width"))&&(e.width=a(e.element).outerWidth()),f&&f[d]&&(e.name=f[d]));for(var g=0;g<w.length;g++)e.list.push(w[g].list[d]),e.data.push(w[g].data[e.name]);v[d]=e}}function i(a,b){if("reload"==a||"append"==a)for(var c=0;c<v.length;c++)v[c].list[b.index]=b.list[c],v[c].data[b.index]=b.data[v[c].name];else if("remove"==a)for(var c=0;c<v.length;c++)v[c].list.splice(b.index,1),v[c].data.splice(b.index,1);else h()}function j(a,b,c){var e=new d(a,u.row,c);return e.reload(b,!1,v),e}function k(a,b){var c=b.childrens;if(c.length>0)for(var d=0;d<c.length;d++)a.push(c[d]),c[d].childrens.length>0&&k(a,c[d])}function l(a,b){if(!b)return null;var c=a.shift();return void 0==c?b:l(a,b.childrens[c])}function m(){var a=arguments[0],b=arguments[1];"function"==typeof a?(b=a,a=0):a=isNaN(a)?0:a;for(var c=a;c<w.length;c++)w[c].reload(c),i("reload",w[c]),"function"==typeof b&&b(c)}function n(b,c){var d=j(c,b),e=d;if(w.length!=b||0==b&&1==w.length)a(d.element).insertBefore(w[b].element);else{var f=w[b-1];a(d.element).insertAfter(0==f.childrens.length?f.element:f.lastChildLeaf().element)}return e=w.splice(0,b),e.push(d),w=e.concat(w),m(b),d}function o(a,b){var c=z.getIndexList(a),d=s.getRowParent(a),e=c[c.length-1];return row=j(b,e,d),d.insertChild(e,row),row}function p(a){var b=j(a,w.length);return w.push(b),t.tbody.append(b.element),i("append",b),b}function q(a,b){var c=s.getRow(a),d=j(b,c.childrens.length,c);return c.appendChild(d),d}function r(){return"function"!=typeof u.none?!1:(y?w.length>0&&(t.tbody.find("tr:first").remove(),y=!1):0==w.length&&(t.tbody.html(u.none()),y=!0),!0)}var s=this,t=e.$obj,u=e.$tpl,v=[],w=[],x={},y=!1,z=b.index();this.appendRow=function(){var a=arguments[0],b=arguments[1],c=null;return c=b?q(a,b):p(a),r(),c},this.insertRow=function(a,b){var c=null;return c=z.isIndexDepth(a)?o(a,b):0==w.length&&0==parseInt(a)?this.appendRow(b):n(a,b),r(),c},this.updateRow=function(a,b){var c=this.getRow(a);for(var d in b)c.data[d]=b[d];return c.reload(null,!0),i("reload",c),c},this.moveRow=function(a,c){if(a!=c){var d=this.getRowAll(a),e=d[0],f=b.clone(e.data);if(d.length>1)for(var g=0;g<d.length;g++){var a=z.changeIndex(d[g].index,c,d[0].index);this.insertRow(a,d[g].data)}else this.insertRow(c,f);this.removeRow(e.index)}},this.removeRow=function(a){var b=this.getRow(a);z.isIndexDepth(a)?b.destroy():(b.destroy(),i("remove",w[a]),w.splice(a,1),m(a)),r()},this.openRow=function(a){this.getRow(a).open(),x[a]=!1;for(var b in x)if(x[b]!==!1){var c=this.getRow(x[b]);null!=c&&c.fold()}},this.openRowAll=function(){for(var a=this.getRowAll(),b=0;b<a.length;b++)a[b].isLeaf()||(a[b].open(),x[a[b].index]=!1)},this.foldRow=function(a){this.getRow(a).fold(),x[a]=a},this.foldRowAll=function(){for(var a=this.getRowAll(),b=0;b<a.length;b++)a[b].isLeaf()||(a[b].fold(),x[a[b].index]=a[b].index)},this.removeRows=function(){w=[],r()||t.tbody.html(""),i()},this.sortRows=function(a,c){function d(b){var c=b.data[a];return"string"==typeof c?c.toLowerCase():isNaN(c)||null==c?"":c}var e=b.sort(w);e.setCompare(c?function(a,b){return d(a)>d(b)?!0:!1}:function(a,b){return d(a)<d(b)?!0:!1}),e.run(),t.tbody.html(""),m(function(a){t.tbody.append(w[a].element)})},this.appendColumn=function(b,c){var d=v.length,e=a(u[b]({rows:c})),f=e.filter("thead").find("tr");f.each(function(b){var c=t.thead.find("tr").eq(b);a(this).find("th").each(function(){c.append(this),f.size()-1==b&&v.push({element:this,list:[]})})});for(var g=0;g<w.length;g++)e.filter("tbody").find("tr").eq(g).find("td").each(function(b){a(w[g].element).append(this),v[d+b].list.push(this),w[g].list.push(this),a.extend(w[g].data,c[g])})},this.removeColumn=function(b){for(var c=0;c<v[b].list.length;c++)a(v[b].element).remove(),a(v[b].list[c]).remove();for(var d=0;d<w.length;d++)w[d].list.splice(b,1);v.splice(b,1)},this.hideColumn=function(a){if("hide"!=v[a].type){for(var b=this.getRowAll(),c=0;c<b.length;c++)b[c].hideCell(a);v[a].hide()}},this.showColumn=function(a){if("show"!=v[a].type){for(var b=this.getRowAll(),c=0;c<b.length;c++)b[c].showCell(a);v[a].show()}},this.getColumnCount=function(){return v.length},this.getRowCount=function(){return w.length},this.getColumn=function(a){return null==a?v:v[a]},this.getRow=function(a){if(null==a)return w;if(z.isIndexDepth(a)){var b=z.getIndexList(a);return l(b,w[b.shift()])}return w[a]?w[a]:null},this.getRowAll=function(a){for(var b=[],c=null==a?w:[this.getRow(a)],d=0;d<c.length;d++)c[d]&&(b.push(c[d]),c[d].childrens.length>0&&k(b,c[d]));return b},this.getRowParent=function(a){return z.isIndexDepth(a)?this.getRow(z.getParentIndex(a)):null},this.setColumn=function(a,b){v[a]=b},this.setRow=function(a,b){w[a]=b},this.printInfo=function(){console.log(v),console.log(w)},g()};return e}),jui.defineUI("uix.table",["jquery","util.base","ui.dropdown","uix.table.base"],function(a,b,c,d){b.resize(function(){for(var a=jui.get("table"),b=0;b<a.length;b++)for(var c=a[b].list,d=0;d<c.length;d++)c[d].resize()},1e3);var e=function(){function e(a){return"<tr class='expand' style='display: none;'><td id='EXPAND_"+a.timestamp+"'></td></tr>"}function f(a,b){for(var c=[],d=0;d<b.length;d++)if("string"==typeof b[d]){var e=a.getColumn(b[d]);c.push(e.index)}else c.push(b[d]);return c}function g(b){var c=b.options.colshow,d=b.uit.getColumnCount();if(c===!0){b.options.colshow=c=[];for(var e=0;d>e;e++)c.push(e)}else c=f(b,c);for(var e=0;d>e;e++)-1==a.inArray(e,c)?b.uit.hideColumn(e):b.uit.showColumn(e)}function h(b){for(var d=null,e=b.listColumn(),f=[],g=0;g<e.length;g++)f.push(a(e[g].element).text());d=a(b.tpl.menu({columns:f})),a("body").append(d),s=c(d,{close:!1}),a(s.root).find("input[type=checkbox]").each(function(c){this.checked="show"==e[c].type?!0:!1,b.addEvent(this,"click",function(d){var e=a(s.root).find("input[type=checkbox]:checked").size();this.checked?b.showColumn(c,d):e>0?b.hideColumn(c,d):this.checked=!0,b.hideExpand(),b.scroll()})})}function i(c){for(var d=r.table.outerWidth(),e=c.uit.getColumnCount(),f=!1,g=e-1;g>=0;g--){var h=c.getColumn(g),i=a(h.element).outerWidth();"none"==a(h.element).css("display")||f||(i-=b.scrollWidth(),f=!0),a(h.list[0]).outerWidth(i)}r.tbody.outerWidth(d)}function j(b){a(b.root).hasClass("table-scroll")||b.scroll(),r.tbody.off("scroll").scroll(function(a){return r.tbody.scrollTop()+b.options.scrollHeight==r.tbody.get(0).scrollHeight?(b.emit("scroll",a),!1):void 0})}function k(a,b){a.uit.getRowCount()<1||(b&&(a.options.expand&&r.tbody.prepend(e(a)),a.scroll()),a.options.scroll&&j(a),a.setVo())}function l(a,b){for(var b=b?b:a.uit.getRow(),c=0;c<b.length;c++)!function(b){b.childrens.length>0?(m(a,b),l(a,b.childrens)):m(a,b)}(b[c])}function m(b,c){if(b.addEvent(c.element,"click",function(a){if(b.emit("select",[c,a]),b.emit("click",[c,a]),b.options.expand){if(b.options.expandEvent===!1)return;t===c.index?b.hideExpand(a):(null!=t&&b.hideExpand(a),b.showExpand(c.index,void 0,a))}}),b.addEvent(c.element,"dblclick",function(a){b.emit("dblclick",[c,a])}),b.addEvent(c.element,"contextmenu",function(a){return b.emit("rowmenu",[c,a]),!1}),b.options.fields&&b.options.editCell){if(b.options.editEvent===!1)return;a(c.element).find("td").each(function(a){var d=this;!function(a){b.addEvent(d,"dblclick",function(d){"TD"==d.target.tagName&&n(b,d.currentTarget,c,a),b.emit("editstart",[c,d])})}(a)})}if(b.options.fields&&b.options.editRow){if(b.options.editEvent===!1)return;b.addEvent(c.element,"dblclick",function(a){("TD"==a.target.tagName||"TR"==a.target.tagName)&&b.showEditRow(c.index,a)})}}function n(b,c,d,e,g,h){function i(){if("function"==typeof h)h();else{var a={};a[j.name]=m.val();var c=b.emit("editend",[a]);c!==!1&&(b.update(d.index,a),m.remove())}}var j=b.getColumn(e),k=j.name?j.data[d.index]:a(c).html(),l=h?b.options.editRow:b.options.editCell,m=a("<input type='text' class='edit' />").val(k).css("width","100%");a(c).html(m),(!j.name||l!==!0&&-1==a.inArray(e,f(b,l)))&&m.attr("disabled",!0),g&&g.target==c&&m.focus(),b.addEvent(m,"keypress",function(a){13==a.which&&i(a)}),b.addEvent(r.tbody.find("tr"),"click",function(a){("TD"==a.target.tagName||"TR"==a.target.tagName)&&i(a)})}function o(a){for(var b=a.options,c=a.uit.getColumnCount(),d=0;c>d;d++){var e=a.getColumn(d);!function(c,d){b.fields&&b.sort&&b.sortEvent===!0||a.addEvent(d.element,"click",function(b){a.emit("colclick",[d,b])}),a.addEvent(d.element,"dblclick",function(b){a.emit("coldblclick",[d,b])}),a.addEvent(d.element,"contextmenu",function(b){return a.emit("colmenu",[d,b]),!1})}(d,e)}}function p(b){for(var c=b.options.sort,d=c===!0?b.uit.getColumnCount():c.length,e=0;d>e;e++){var f=c===!0?e:c[e],g=b.getColumn(f);null!=g.element&&(!function(c,d){b.addEvent(d.element,"click",function(e){a(e.target).hasClass("resize")||(b.sort(c,void 0,e),b.emit("colclick",[d,e]))})}(f,g),a(g.element).css("cursor","pointer"))}}function q(c){function d(b){for(var d=b+1;d<c.uit.getColumnCount();d++){var e=c.getColumn(d).element;if(!a(e).is(":hidden"))return c.getColumn(d)}}function e(c,d){var e=30;if(!(e>j+d||e>k-d)&&(a(h.element).outerWidth(j+d),a(i.element).outerWidth(k-d),c.options.scroll)){var f=a(i.element).outerWidth()-(h.index==c.uit.getColumnCount()-2?b.scrollWidth():0);a(h.list[0]).outerWidth(a(h.element).outerWidth()),a(i.list[0]).outerWidth(f)}}var f=0,g=r.table.offset(),h=null,i=null,j=0,k=0,l=null;r.thead.find(".resize").remove();for(var m=0;m<c.uit.getColumnCount()-1;m++){var n=a(c.getColumn(m).element),o=a("<div class='resize'></div>"),p=n.offset();o.css({position:"absolute",width:"8px",height:n.outerHeight(),left:n.outerWidth()+(p.left-g.left)-1+"px",top:p.top-g.top+"px",cursor:"w-resize","z-index":"1"}),n.append(o),function(b){c.addEvent(o,"mousedown",function(e){return 0==f&&(f=e.pageX),h=c.getColumn(b),i=d(b),j=a(h.element).outerWidth(),k=a(i.element).outerWidth(),l=this,v=!0,!1})}(m)}c.addEvent("body","mousemove",function(a){f>0&&e(c,a.pageX-f)}),c.addEvent("body","mouseup",function(b){if(f>0){f=0,v=!1;var d=a(h.element).offset().left-g.left;return a(l).css("left",a(h.element).outerWidth()+d-1),c.emit("colresize",[h,b]),!1}})}var r=null,s=null,t=null,u={},v=!1;this.init=function(){var b=this.options;if(b.data=null!=b.rows?b.rows:b.data,r={table:a(this.root).css({position:"relative"}),thead:a(this.root).find("thead"),tbody:a(this.root).find("tbody")},this.uit=new d({$obj:r,$tpl:this.tpl},b.fields),b.fields&&b.colshow&&g(this),b.fields&&this.tpl.menu&&h(this),b.resize&&q(this),b.fields&&b.sort&&b.sortEvent===!0&&p(this),b.data.length>0?this.update(b.data):this.setVo(),b.width>0&&r.table.outerWidth(b.width),!b.fields&&(b.sort||b.colshow||b.editCell||b.editRow))throw new Error("JUI_CRITICAL_ERR: 'fields' option is required");o(this)},this.update=function(){var a=1==arguments.length?arguments[0]:arguments[1],b=2==arguments.length?arguments[0]:null;if(null!=b){var c=this.uit.updateRow(b,a);m(this,c),0==parseInt(b)&&this.scroll()}else this.uit.removeRows(),this.scroll(),this.append(a),this.options.sortIndex&&this.sort(this.options.sortIndex,this.options.sortOrder,null)},this.updateTree=function(a){var c=b.index();this.uit.removeRows();for(var d=0;d<a.length;d++){var e=c.getParentIndex(a[d].index);null==e?this.uit.appendRow(a[d].data):this.uit.appendRow(e,a[d].data)}k(this,!0),l(this)},this.append=function(){var a=this.count()>0?!1:!0,b=1==arguments.length?arguments[0]:arguments[1],c=2==arguments.length?arguments[0]:null;b=void 0==b.length?[b]:b;for(var d=0;d<b.length;d++){var e=null;e=null!=c?this.uit.appendRow(c,b[d]):this.uit.appendRow(b[d]),a||m(this,e)}k(this,a),a&&l(this)},this.insert=function(a,b){for(var c=this.count()>0?!1:!0,b=void 0==b.length?[b]:b,d=0;d<b.length;d++)this.uit.insertRow(a,b[d]);k(this,c),l(this)},this.select=function(b){var c=this.get(b);return this.hideExpand(),this.hideEditRow(),this.uncheckAll(),a(c.element).parent().find(".selected").removeClass("selected"),a(c.element).addClass("selected"),t=b,c},this.unselect=function(){if(null!=t){var b=this.get(t);return a(b.element).removeClass("selected"),t=null,b}},this.check=function(b){var c=this.get(b);this.hideExpand(),this.hideEditRow(),this.unselect(),u[b]=c,a(c.element).addClass("checked")},this.uncheck=function(b){var c=this.get(b);u[b]=null,a(c.element).removeClass("checked")},this.uncheckAll=function(){u={},r.tbody.find(".checked").removeClass("checked")},this.remove=function(a){return null==a?null:(this.uit.removeRow(a),l(this),void this.scroll())},this.reset=function(){this.uit.removeRows(),this.scroll()},this.move=function(a,b){this.uit.moveRow(a,b),l(this),(0==parseInt(a)||0==parseInt(b))&&this.scroll()},this.sort=function(a,b,c){if(this.options.fields&&this.options.sort&&!v){var d=this.getColumn(a);"string"==typeof d.name&&(d.order=b?b:"asc"==d.order?"desc":"asc",this.uit.setColumn(a,d),this.uit.sortRows(d.name,"desc"==d.order?!0:!1),this.emit("sort",[d,c]),k(this,!0),l(this))}},this.scroll=function(a){if(this.options.scroll){var b=this,c=a&&a>0?a:this.options.scrollHeight,c=c>0?c:200;this.options.scrollHeight=c,r.tbody.css("maxHeight",c+"px"),setTimeout(function(){r.tbody.outerHeight()<c?(r.table.css({"table-layout":""}),r.tbody.css({display:"",overflow:""})):(r.table.css({"table-layout":"fixed"}),r.tbody.css({display:"block",overflow:"auto"})),i(b)},10)}},this.open=function(a){null!=a&&(this.uit.openRow(a),this.emit("open",[this.get(a)]))},this.fold=function(a){null!=a&&(this.uit.foldRow(a),this.emit("fold",[this.get(a)]))},this.openAll=function(){this.uit.openRowAll(),this.emit("openall")},this.foldAll=function(){this.uit.foldRowAll(),this.emit("foldall")},this.resize=function(){this.scroll(),this.options.resize&&q(this)},this.resizeColumns=function(){for(var b=this.listColumn(),c=0;c<b.length;c++)null==b[c].width&&a(b[c].element).outerWidth("auto")},this.size=function(){return this.uit.getRowCount()},this.count=function(){return this.uit.getRowCount()},this.list=function(){return this.uit.getRow()},this.listData=function(){for(var a=this.list(),b=[],c=0;c<a.length;c++)b.push(a[c].data);return b},this.listAll=function(){return this.uit.getRowAll()},this.listChecked=function(){var a=[];for(var b in u)null!=u[b]&&a.push(u[b]);return a},this.listColumn=function(){return this.uit.getColumn()},this.get=function(a){return null==a?null:this.uit.getRow(a)},this.getAll=function(a){return null==a?null:this.uit.getRowAll(a)},this.getColumn=function(b){return null==b?null:this.uit.getColumn("string"==typeof b?a.inArray(b,this.options.fields):b)},this.showColumn=function(a,b){if(this.options.fields){var c=this.getColumn(a);this.uit.showColumn(c.index),this.scroll(),this.resizeColumns(),this.options.resize&&q(this),this.emit("colshow",[c,b])
}},this.hideColumn=function(a,b){if(this.options.fields){var c=this.getColumn(a);this.uit.hideColumn(c.index),this.scroll(),this.resizeColumns(),this.options.resize&&q(this),this.emit("colhide",[c,b])}},this.initColumns=function(a){"object"==typeof a&&(this.options.colshow=a,g(this),this.scroll(),this.resizeColumns(),this.options.resize&&q(this))},this.showColumnMenu=function(b){if(this.options.fields&&s){var c=this.listColumn(),d=r.thead.offset(),e=d.left+r.table.outerWidth()-a(s.root).outerWidth();b=isNaN(b)||b>e+d.left?e:b,b=0>b?0:b,a(s.root).find("input[type=checkbox]").each(function(a){this.checked="show"==c[a].type?!0:!1}),s.move(b,d.top+r.thead.outerHeight()),s.show()}},this.hideColumnMenu=function(){this.options.fields&&s&&s.hide()},this.toggleColumnMenu=function(a){this.options.fields&&s&&("show"==s.type?this.hideColumnMenu():this.showColumnMenu(a))},this.showExpand=function(b,c,d){if(this.options.expand){this.unselect(),this.hideEditRow();var e="#EXPAND_"+this.timestamp,f=this.get(b),c="object"!=typeof c?a.extend({row:f},f.data):c,g=a(e).parent().show();r.tbody.find("tr").removeClass("open"),g.insertAfter(a(f.element).addClass("open")),a(e).attr("colspan",r.thead.find("tr:last > th:visible").size()).html(this.tpl.expand(c)),this.scroll(),this.setVo(),t=b,this.emit("expand",[f,d])}},this.hideExpand=function(b){if(this.options.expand&&null!=t){var c=this.get(t);a("#EXPAND_"+this.timestamp).parent().hide(),r.tbody.find("tr").removeClass("open"),this.scroll(),t=null,this.emit("expandend",[c,b])}},this.getExpand=function(){return this.options.expand?null==t?null:this.get(t):void 0},this.showEditRow=function(b,c){if(this.options.editRow){this.unselect(),this.hideExpand();var d=this,e=this.get(b),f=a(e.element).find("td");f.each(function(b){n(d,this,e,b,c,function(){var b={},g=e.data;f.each(function(c){var e=d.getColumn(c);if(null!=e.name){var f=a(this).find(".edit").val();b[e.name]=isNaN(f)||null==f?f:parseFloat(f)}}),e.data=b;var h=d.emit("editend",[e,c]);h!==!1?d.update(e.index,b):e.data=g})}),t=b,d.emit("editstart",[e,c])}},this.hideEditRow=function(){if(this.options.editRow&&null!=t){var a=this.get(t);t=null,this.emit("editend",[a.data]),this.update(a.index,a.data)}},this.getEditRow=function(){return this.options.editRow?null==t?null:this.get(t):void 0},this.setCsv=function(){var a=this.options;if(a.fields||a.csv){var c=1==arguments.length?arguments[0]:arguments[1],d=2==arguments.length?arguments[0]:null,e=b.getCsvFields(a.fields,a.csv),f=a.csvNumber?b.getCsvFields(a.fields,a.csvNumber):null,g=b.csvToData(e,c,f);if(null==d)this.update(g);else{this.reset();for(var h=0;h<g.length;h++){var i=g[h][d];i&&this.insert(i,g[h])}}}},this.setCsvFile=function(){if(this.options.fields||this.options.csv){var a=this,c=1==arguments.length?arguments[0]:arguments[1],d=2==arguments.length?arguments[0]:null;b.fileToCsv(c,function(b){null==d?a.setCsv(b):a.setCsv(d,b)})}},this.getCsv=function(a){if(this.options.fields||this.options.csv){for(var c=b.getCsvFields(this.options.fields,this.options.csv),d=[],e=a?this.listAll():this.list(),f=0;f<e.length;f++)d.push(e[f].data);return b.dataToCsv2({fields:c,rows:d,names:this.options.csvNames})}},this.getCsvBase64=function(a){return this.options.fields||this.options.csv?b.csvToBase64(this.getCsv(a)):void 0},this.downloadCsv=function(a,c){b.typeCheck("string",a)&&(a=a.split(".")[0]);var d=document.createElement("a");d.download=a?a+".csv":"table.csv",d.href=this.getCsvBase64(c),document.body.appendChild(d),d.click(),d.parentNode.removeChild(d)},this.activeIndex=function(){return t}};return e.setup=function(){return{fields:null,csv:null,csvNames:null,csvNumber:null,data:[],rows:null,colshow:!1,scroll:!1,scrollHeight:200,width:0,expand:!1,expandEvent:!0,editCell:!1,editRow:!1,editEvent:!0,resize:!1,sort:!1,sortIndex:null,sortOrder:"asc",sortEvent:!0,animate:!1}},e}),jui.define("uix.tree.node",["jquery"],function(a){var b=function(b,c){function d(a){i.nodenum=isNaN(a)?i.nodenum:a,i.parent&&(i.index=null==i.parent.index?""+i.nodenum:i.parent.index+"."+i.nodenum),i.parent&&"string"==typeof i.index&&(i.depth=i.index.split(".").length),i.childrens.length>0&&e(i)}function e(a){for(var b=a.childrens,c=0;c<b.length;c++)b[c].reload(c),b[c].childrens.length>0&&e(b[c])}function f(){if(!c)return i.element;try{var b=a(c(a.extend({node:{index:i.index,data:i.data,depth:i.depth}},i.data))).get(0)}catch(d){console.log(d)}return b}function g(b){a(b.element).remove();for(var c=0;c<b.childrens.length;c++){var d=b.childrens[c];d.childrens.length>0?g(d):a(d.element).remove()}}function h(a){for(var b=0;b<a.childrens.length;b++){var c=a.childrens[b];c.reload(b),c.childrens.length>0&&h(c)}}var i=this;this.data=b,this.element=null,this.index=null,this.nodenum=null,this.parent=null,this.childrens=[],this.depth=0,this.type="open",this.reload=function(b,c){if(d(b),null!=this.element){var e=f();c?a(e).insertAfter(this.element):a(this.parent.element).children("ul").append(e),a(this.element).remove(),this.element=e}else this.element=f()},this.reloadChildrens=function(){h(this)},this.destroy=function(){null!=this.parent?this.parent.removeChild(this.index):(g(this),a(this.element).remove())},this.isLeaf=function(){return 0==this.childrens.length?!0:!1},this.fold=function(){a(this.element).children("ul").hide(),this.type="fold"},this.open=function(){a(this.element).children("ul").show(),this.type="open"},this.appendChild=function(b){a(this.element).children("ul").append(b.element),this.childrens.push(b)},this.insertChild=function(b,c){0==b?0==this.childrens.length?a(this.element).children("ul").append(c.element):a(c.element).insertBefore(this.childrens[0].element):a(c.element).insertAfter(this.childrens[b-1].element);var d=this.childrens.splice(0,b);d.push(c),this.childrens=d.concat(this.childrens),h(this)},this.removeChild=function(a){for(var b=0;b<this.childrens.length;b++){var c=this.childrens[b];c.index==a&&(this.childrens.splice(b,1),g(c))}h(this)},this.lastChild=function(){return this.childrens.length>0?this.childrens[this.childrens.length-1]:null},this.lastChildLeaf=function(a){var b=a?a:this.lastChild();return b.isLeaf()?b:this.lastChildLeaf(b.lastChild())}};return b}),jui.define("uix.tree.base",["jquery","util.base","uix.tree.node"],function(a,b,c){var d=function(a){function d(a,b,d){var e=new c(a,n.node);return e.parent=d?d:null,e.reload(b),e}function e(a,b){var c=b.childrens;if(c.length>0)for(var d=0;d<c.length;d++)a.push(c[d]),c[d].childrens.length>0&&e(a,c[d])}function f(a,b){if(!b)return null;var c=a.shift();return void 0==c?b:f(a,b.childrens[c])}function g(a,b){var c=o.getIndexList(a),e=k.getNodeParent(a),f=c[c.length-1];return node=d(b,f,e),e.insertChild(f,node),node}function h(a){if(null==l)l=d(a),m.tree.append(l.element);else{var b=d(a,l.childrens.length,l);l.appendChild(b)}return b}function i(a,b){var c=k.getNode(a),e=d(b,c.childrens.length,c);return c.appendChild(e),e}function j(a,b){for(var c=[];;){var d=b.parent;if(!d)break;c.push(d),b=d}for(var e=0;e<c.length;e++)if(a==c[e])return!0;return!1}var k=this,l=null,m=a.$obj,n=a.$tpl,o=b.index();this.appendNode=function(){var a=arguments[0],b=arguments[1];return b?i(a,b):h(a)},this.insertNode=function(a,b){return 0==l.childrens.length&&0==parseInt(a)?this.appendNode(b):g(a,b)},this.updateNode=function(a,b){var c=this.getNode(a);for(var d in b)c.data[d]=b[d];return c.reload(c.nodenum,!0),c.reloadChildrens(),c},this.removeNode=function(a){this.getNode(a).destroy()},this.removeNodes=function(){var a=l.childrens;if(a.length>0){var b=a.pop();b.parent=null,b.destroy(),this.removeNodes()}},this.openNode=function(a){null==a?this.getRoot().open():this.getNode(a).open()},this.foldNode=function(a){null==a?this.getRoot().fold():this.getNode(a).fold()},this.openNodeAll=function(a){for(var b=this.getNodeAll(a),c=0;c<b.length;c++)b[c].open();null==a&&this.getRoot().open()},this.foldNodeAll=function(a){for(var b=this.getNodeAll(a),c=0;c<b.length;c++)b[c].fold();null==a&&this.getRoot().fold()},this.moveNode=function(a,b){if(a!=b){var c=this.getNode(a),d=this.getNodeParent(b),e=o.getIndexList(b);if(tNo=e[e.length-1],!j(c,d)){c.parent.childrens.splice(c.nodenum,1),c.parent.reloadChildrens(),c.parent=d;var f=d.childrens.splice(0,tNo);f.push(c),d.childrens=f.concat(d.childrens),d.reloadChildrens()}}},this.getNode=function(a){if(null==a)return l.childrens;var b=l.childrens;if(o.isIndexDepth(a)){var c=o.getIndexList(a);return f(c,b[c.shift()])}return b[a]?b[a]:null},this.getNodeAll=function(a){for(var b=[],c=null==a?l.childrens:[this.getNode(a)],d=0;d<c.length;d++)c[d]&&(b.push(c[d]),c[d].childrens.length>0&&e(b,c[d]));return b},this.getNodeParent=function(a){var b=o.getIndexList(a);return 1==b.length?l:2==b.length?this.getNode(b[0]):b.length>2?(b.pop(),this.getNode(b.join("."))):void 0},this.getRoot=function(){return l}};return d}),jui.defineUI("uix.tree",["util.base","uix.tree.base"],function(a,b){var c=function(){function c(a,b){for(var c=0;c<b.length;c++){var d=b[c];$(d.element).removeClass("open fold leaf last"),d.parent&&d.isLeaf()?$(d.element).addClass("leaf"):"open"==d.type?($(d.element).addClass("open"),d.open()):($(d.element).addClass("fold"),d.fold()),d.parent?d.parent.lastChild()==d&&$(d.element).addClass("last"):$(d.element).addClass("root"),$(d.element).children("i:first-child").remove(),$(d.element).prepend($("<i></i>"))}}function d(a,b,c){if(null==b)if(a.options.rootHide){for(var d=a.uit.getRoot().childrens,e=0;e<d.length;e++)c(d[e].index);j(a,!1)}else c(b),j(a,!0);else c(b),j(a,!1)}function e(a,b){for(var c=0;c<b.length;c++)!function(b){var c=$(b.element);a.addEvent(c.children("i:first-child"),"click",function(c){"open"==b.type?a.fold(b.index,c):a.open(b.index,c),c.stopPropagation()}),a.addEvent(c.children("a,span,div")[0],"click",function(c){a.emit("select",[b,c]),c.stopPropagation()})}(b[c])}function f(a,b){if(a.options.drag){var c=a.uit.getRoot();$("body").off("mousemove").off("mouseup");for(var d=0;d<b.length;d++)!function(b){$(b.element).off("mousedown").off("mouseup"),a.addEvent(b.element,"mousedown",function(c){return"I"!=c.target.tagName?(null==k.start&&(k.start=b.index,a.emit("dragstart",[b.index,c])),!1):void 0}),a.addEvent(b.element,"mouseup",function(c){if("I"!=c.target.tagName){if(a.options.dragChild!==!1&&k.start&&k.start!=b.index){var d=b.lastChild(),e=d?m.getNextIndex(d.index):b.index+".0";a.move(k.start,e),a.emit("dragend",[e,c])}return k.start=null,k.end=null,!1}}),a.addEvent(c.element,"mouseup",function(b){if("I"!=b.target.tagName){if(a.options.dragChild!==!1&&k.start){var d=""+c.childrens.length;a.move(k.start,d),a.emit("dragend",[d,b])}return k.start=null,k.end=null,!1}})}(b[d]);a.addEvent("body","mouseup",function(b){return k.start&&k.end&&(a.move(k.start,k.end),a.emit("dragend",[k.end,b])),k.start=null,k.end=null,!1})}}function g(a){if(a.options.drag){$(a.root).find(".drag").remove();for(var b=a.listAll(),c=0;c<b.length;c++){var d=b[c],e=$(d.element).position();e.top>0&&i(a,d,e)}}}function h(a){if(a.options.drag)for(var b=a.listAll(),c=0;c<b.length;c++){var d=b[c],e=$(d.element).position();e.top>0&&d.parent&&d.parent.lastChild()==d&&(e.top=e.top+$(d.element).outerHeight(),i(a,d,e,!0))}}function i(a,b,c,d){if(a.options.drag){var e=d?m.getNextIndex(b.index):b.index,f=$("<div class='drag'></div>").attr("data-index",e).css(c).outerWidth($(b.element).outerWidth());$(a.root).append(f),a.addEvent(f,"mouseover",function(){k.start&&(k.end=e,f.addClass("on"))}),a.addEvent(f,"mouseout",function(){k.start&&f.removeClass("on")})}}function j(a,b){var d=a.listAll();c(a,d),e(a,d),f(a,d),g(a),h(a),b&&(c(a,[a.uit.getRoot()]),e(a,[a.uit.getRoot()]))}var k={start:null,end:null},l=null,m=a.index();this.init=function(){var a=this.options;if(this.uit=new b({$obj:{tree:$(this.root)},$tpl:this.tpl}),!a.root)throw new Error("JUI_CRITICAL_ERROR: root data is required");if(this.uit.appendNode(a.root),j(this,!0),a.rootHide){var c=this.uit.getRoot();$(c.element).css("padding-left","0px"),$(c.element).children("*:not(ul)").hide()}a.rootFold&&this.fold()},this.update=function(b){var c=1==arguments.length?arguments[0]:arguments[1],b=2==arguments.length?arguments[0]:null;if(null!=b)this.uit.updateNode(b,c);else{var d=a.index();this.uit.removeNodes();for(var e=0;e<c.length;e++){var f=d.getParentIndex(c[e].index);null==f?this.uit.appendNode(c[e].data):this.uit.appendNode(f,c[e].data)}}j(this)},this.append=function(){var a=1==arguments.length?arguments[0]:arguments[1],b=2==arguments.length?arguments[0]:null;a=void 0==a.length?[a]:a;for(var c=0;c<a.length;c++)null!=b?this.uit.appendNode(b,a[c]):this.uit.appendNode(a[c]);j(this)},this.insert=function(a,b){for(var c=void 0==b.length?[b]:b,d=0;d<c.length;d++)this.uit.insertNode(a,c[d]);j(this)},this.select=function(a){var b=null==a?this.uit.getRoot():this.get(a);return $(this.root).find("li").removeClass("active"),$(b.element).addClass("active"),l=a,b},this.unselect=function(){if(null!=l){var a=this.get(l);return $(a.element).removeClass("active"),l=null,a}},this.remove=function(a){this.uit.removeNode(a),j(this)},this.reset=function(){this.uit.removeNodes(),j(this)},this.move=function(a,b){this.uit.moveNode(a,b),j(this)},this.open=function(a,b){if(null!=a||!this.options.rootHide){var c=null==a;this.uit.openNode(a),j(this,c),this.emit("open",[c?this.uit.getRoot():this.get(a),b])}},this.fold=function(a,b){if(null!=a||!this.options.rootHide){var c=null==a;this.uit.foldNode(a),j(this,c),this.emit("fold",[c?this.uit.getRoot():this.get(a),b])}},this.openAll=function(a){var b=this,c=null==a;d(this,a,function(a){b.uit.openNodeAll(a)}),this.emit("openall",[c?this.uit.getRoot():this.get(a)])},this.foldAll=function(a){var b=this,c=null==a;d(this,a,function(a){b.uit.foldNodeAll(a)}),this.emit("foldall",[c?this.uit.getRoot():this.get(a)])},this.list=function(){return this.uit.getNode()},this.listAll=function(){return this.uit.getNodeAll()},this.listParents=function(a){function b(a){null!=a.index&&(d.push(a),null!=a.parent&&b(a.parent))}var c=this.get(a),d=[];return c.parent&&b(c.parent),d.reverse()},this.get=function(a){return null==a?null:this.uit.getNode(a)},this.getAll=function(a){return null==a?null:this.uit.getNodeAll(a)},this.activeIndex=function(){return l}};return c.setup=function(){return{root:null,rootHide:!1,rootFold:!1,drag:!1,dragChild:!0}},c}),jui.defineUI("uix.xtable",["jquery","util.base","ui.modal","uix.table"],function(a,b,c,d){var e=null;b.resize(function(){for(var a=jui.get("uix.xtable"),b=0;b<a.length;b++)for(var c=a[b],d=0;d<c.length;d++)c[d].resize()},1e3);var f=function(){function f(b){function c(b,c){var d={};for(var e in b.options)-1==a.inArray(e,c)&&(d[e]=b.options[e]);return d}function e(b,c,d){var e=b.options;if(a(b.root).css({position:"relative"}),a(c.root).css({position:"absolute",top:"0","border-bottom-width":"0",margin:"0"}),a(d.root).css({margin:"0"}),e.width>0&&a(b.root).outerWidth(e.width),e.scrollWidth>0){var f=a(b.root).outerWidth();a(b.root).css({"max-width":b.options.scrollWidth,"overflow-x":"auto","overflow-y":"hidden"}),a(c.root).outerWidth(f),a(d.root).parent().outerWidth(f)}}function f(b,c){var d=a(c.root).clone(),e=c.listColumn();a(c.root).wrap("page"!=b.options.buffer?"<div class='body' style='max-height: "+b.options.scrollHeight+"px'></div>":"<div class='body'></div>"),a(c.root).find("thead > tr").outerHeight(0).not(":last-child").remove();for(var f=0;f<e.length;f++){var g=a(e[f].element);g.html("").outerHeight(0).attr("style",g.attr("style")+"border-top-width: 0px !important;border-bottom-width: 0px !important;padding-top: 0px !important;padding-bottom: 0px !important")}d.children("tbody").remove(),a(b.root).append(d.addClass("head")),a(b.root).css("padding-top",d.height())}var g=["buffer","bufferCount","csvCount","sortLoading","sortCache","sortIndex","sortOrder","event","rows","scrollWidth","width"];k=d(a(b.root).children("table"),c(b,g.concat("resize"))),f(b,k),j=d(a(b.root).children("table.head"),c(b,g)),e(b,j,k)}function g(b){j.on("colresize",function(c,d){for(var e=j.listColumn(),f=k.listColumn(),g=!1,h=e.length-1;h>=0;h--){var i=a(e[h].element).outerWidth();"page"==b.options.buffer||"show"!=e[h].type||g?(a(e[h].element).outerWidth(i),a(f[h].element).outerWidth(i)):(a(f[h].element).outerWidth("auto"),g=!0)}b.emit("colresize",[c,d])}),j.on("colshow",function(a,c){k.uit.showColumn(a.index),b.resize(),b.emit("colshow",[a,c])}),j.on("colhide",function(a,c){k.uit.hideColumn(a.index),b.resize(),b.emit("colhide",[a,c])}),j.on("colclick",function(a,c){b.emit("colclick",[a,c])}),j.on("coldblclick",function(a,c){b.emit("coldblclick",[a,c])}),j.on("colmenu",function(a,c){b.emit("colmenu",[a,c])}),j.on("sort",function(a,c){b.sort(a.index,a.order,c),b.emit("sort",[a,c]),b.options.sortCache&&b.setOption({sortIndex:a.index,sortOrder:a.order})}),k.on("select",function(a,c){b.emit("select",[a,c])}),k.on("rowmenu",function(a,c){b.emit("rowmenu",[a,c])}),k.on("expand",function(a,c){b.emit("expand",[a,c])}),k.on("expandend",function(a,c){b.emit("expandend",[a,c])})}function h(b){var c=a(b.root).children(".body");c.off("scroll").scroll(function(a){return this.scrollTop+b.options.scrollHeight>=c.get(0).scrollHeight?(b.next(),b.emit("scroll",a),!1):void 0})}function i(b){function c(b){var c=30;f.column+b<c||(a(e.head.element).outerWidth(f.column+b),a(e.body.element).outerWidth(f.column+b),b>0&&(a(k.root).parent().outerWidth(f.body+b),a(j.root).outerWidth(f.body+b)))}function d(){for(var b=0;b<j.uit.getColumnCount()-1;b++){var c=a(j.getColumn(b).element);c.find(".resize").css("left",c.outerWidth()+c.position().left+"px")}}var e={},f={},g=0;a(b.root).find("thead .resize").remove();for(var h=0;h<j.uit.getColumnCount()-1;h++){var i=a(j.getColumn(h).element),l=a("<div class='resize'></div>"),m=i.position();l.css({position:"absolute",width:"8px",height:i.outerHeight(),left:i.outerWidth()+(m.left-1)+"px",top:m.top+"px",cursor:"w-resize","z-index":"1"}),i.append(l),function(c){b.addEvent(l,"mousedown",function(b){return 0==g&&(g=b.pageX),e={head:j.getColumn(c),body:k.getColumn(c)},f={column:a(e.head.element).outerWidth(),body:a(k.root).outerWidth()},q=!0,!1})}(h)}b.addEvent("body","mousemove",function(a){g>0&&c(a.pageX-g)}),b.addEvent("body","mouseup",function(a){return g>0?(g=0,q=!1,d(),j.emit("colresize",[e.head,a]),!1):void 0}),j.on("colshow",d),j.on("colhide",d)}var j=null,k=null,l=[],m=null,n=null,o=1,p=!1,q=!1;this.init=function(){var b=this.options;if(b.data=null!=b.rows?b.rows:b.data,"TABLE"==this.root.tagName){var d=a(this.root).wrap("<div class='xtable'></div>");this.root=d.parent().get(0)}if(f(this),g(this),"page"!=b.buffer){var e=a(this.root).children(".body");e.css({"overflow-y":"scroll","overflow-x":"hidden"}),e.children("table").css({"border-bottom-width":"0"})}if("scroll"==b.buffer&&h(this),b.data&&this.update(b.data),b.tpl.loading){var k=a(b.tpl.loading);a(this.root).append(k),n=c(k,{target:this.selector,opacity:.1,autoHide:!1}),b.sortLoading=b.sortLoading===!0?500:b.sortLoading}b.resize&&(j.resizeColumns(),j.resize()),!b.resize&&b.scrollWidth>0&&i(this)},this.select=function(a){return k.select(a)},this.update=function(a){l=a,this.clear(),this.next(),this.emit("update"),j.emit("colresize"),this.options.sortIndex&&this.sort(this.options.sortIndex,this.options.sortOrder,void 0,!0)},this.next=function(){var a=(o-1)*this.options.bufferCount,b=a+this.options.bufferCount;if(b=b>l.length?l.length:b,b<=l.length){for(var c=[],d=a;b>d;d++)c.push(l[d]);k.append(c),this.emit("next",[o]),c.length>0&&o++}},this.page=function(a){return"scroll"==this.options.buffer?!1:this.getPage()==a?!1:(e=o>a?"prev":"next",this.clear(),o=1>a?1:a,void this.next())},this.sort=function(a,c,d,e){function f(){var a=b.sort(l);a.setCompare("desc"==i.order?function(a,b){return g(a)>g(b)?!0:!1}:function(a,b){return g(a)<g(b)?!0:!1}),a.run(),h.emit("sortend",[i,d]),h.clear(),h.next(),h.hideLoading()}function g(a){var b=a[i.name];return"string"==typeof b?b.toLowerCase():isNaN(b)||null==b?"":b}if(this.options.fields&&this.options.sort&&!q){var h=this,i=j.getColumn(a);"string"==typeof i.name&&(i.order=c?c:"asc"==i.order?"desc":"asc",j.uit.setColumn(a,i),this.options.sortLoading&&!e?(h.showLoading(),setTimeout(function(){f()},this.options.sortLoading)):f())}},this.filter=function(a){if("function"==typeof a){null==m?m=l:l=m;for(var b=l.slice(),c=[],d=0,e=b.length;e>d;d++)a(b[d])===!0&&c.push(b[d]);this.update(c),this.emit("filter",[c])}},this.rollback=function(){null!=m&&(this.update(m),m=null)},this.clear=function(){o=1,k.uit.removeRows(),k.scroll()},this.reset=function(){this.clear(),l=[]},this.resize=function(){j.resizeColumns(),j.resize(),j.emit("colresize")},this.height=function(b){"scroll"==this.options.buffer&&(this.options.scrollHeight=b,a(this.root).find(".body").css("max-height",b+"px"),h(this))},this.size=function(){return l.length},this.count=function(){return l.length},this.list=function(){return k.list()},this.listColumn=function(){return j.listColumn()},this.listData=function(){return l},this.get=function(a){return null==a?null:k.get(a)},this.getColumn=function(a){return j.getColumn(a)},this.getData=function(a){return l[a]},this.showColumn=function(a){j.showColumn(a)},this.hideColumn=function(a){j.hideColumn(a)},this.initColumns=function(a){j.initColumns(a),k.initColumns(a),j.emit("colresize")},this.showColumnMenu=function(a){j.showColumnMenu(a)},this.hideColumnMenu=function(){j.hideColumnMenu()},this.toggleColumnMenu=function(a){j.toggleColumnMenu(a)},this.showExpand=function(a,b){k.showExpand(a,b)},this.hideExpand=function(a){a?k.hideExpand(a):k.hideExpand()},this.getExpand=function(){return k.getExpand()},this.showLoading=function(a){if(n&&!p&&(n.show(),p=!0,a>0)){var b=this;setTimeout(function(){b.hideLoading()},a)}},this.hideLoading=function(){n&&p&&(n.hide(),p=!1)},this.setCsv=function(a){var c=this.options;if(c.fields||c.csv){var d=b.getCsvFields(c.fields,c.csv),e=c.csvNumber?b.getCsvFields(c.fields,c.csvNumber):null;this.update(b.csvToData(d,a,e))}},this.setCsvFile=function(a){if(this.options.fields||this.options.csv){var c=this;b.fileToCsv(a,function(a){c.setCsv(a)})}},this.getCsv=function(){if(this.options.fields||this.options.csv){var a=b.getCsvFields(this.options.fields,this.options.csv),c=l.length>this.options.csvCount?this.options.csvCount:l.length;return b.dataToCsv2({fields:a,rows:l,count:c,names:this.options.csvNames})}},this.getCsvBase64=function(){return this.options.fields||this.options.csv?b.csvToBase64(this.getCsv()):void 0},this.downloadCsv=function(a){b.typeCheck("string",a)&&(a=a.split(".")[0]);var c=document.createElement("a");c.download=a?a+".csv":"table.csv",c.href=this.getCsvBase64(),document.body.appendChild(c),c.click(),c.parentNode.removeChild(c)},this.rowFunc=function(a,b,c){if(this.options.fields){var d="function"==typeof c?!0:!1,e=0,f=d?0:l.length,g=j.getColumn(b);if(g.name)for(var h=0;h<l.length;h++){var i=l[h][g.name];isNaN(i)||(d?c(l[h])&&(e+=i,f++):e+=i)}return"sum"==a?e:"avg"==a?e/f:null}},this.getPage=function(){return o-1},this.activeIndex=function(){return k.activeIndex()}};return f.setup=function(){return{fields:null,csv:null,csvNames:null,csvNumber:null,csvCount:1e4,data:[],rows:null,colshow:!1,expand:!1,expandEvent:!0,resize:!1,scrollHeight:200,scrollWidth:0,width:0,buffer:"scroll",bufferCount:100,sort:!1,sortLoading:!1,sortCache:!1,sortIndex:null,sortOrder:"asc",sortEvent:!0,animate:!1}},f});