diff --git a/Gruntfile.js b/Gruntfile.js index 10f06e3fe..606342a3e 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -171,7 +171,7 @@ module.exports = function (grunt) { "src/data/data.js", "src/data/**/*.js" ], - dest: "utils/utils.js" + dest: "dist/utils.js" } }, @@ -219,6 +219,7 @@ module.exports = function (grunt) { dist: { files: { "dist/bundle.min.js": ["<%= concat.bundleJs.dest %>"], + "dist/utils.min.js": ["<%= concat.utilsJs.dest %>"], "dist/_fineui.min.js": ["dist/polyfill.js", "dist/core.js", "dist/fix/fix.js", "src/third/**/*.js", "src/base/formula/config.js", "src/base/pane.js", diff --git a/dist/_fineui.min.js b/dist/_fineui.min.js index 61c825482..91f2d2f72 100644 --- a/dist/_fineui.min.js +++ b/dist/_fineui.min.js @@ -1,4 +1,4 @@ -/*! fineui 20-07-2018 */ +/*! fineui 23-07-2018 */ function accAdd(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g){c=0}try{d=b.toString().split(".")[1].length}catch(g){d=0}if(f=Math.abs(c-d),e=Math.pow(10,Math.max(c,d)),f>0){var h=Math.pow(10,f);c>d?(a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""))*h):(a=Number(a.toString().replace(".",""))*h,b=Number(b.toString().replace(".","")))}else a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""));return(a+b)/e}function accSub(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g){c=0}try{d=b.toString().split(".")[1].length}catch(g){d=0}return e=Math.pow(10,Math.max(c,d)),f=c>=d?c:d,((a*e-b*e)/e).toFixed(f)}function accMul(a,b){var c=0,d=a.toString(),e=b.toString();try{c+=d.split(".")[1].length}catch(f){}try{c+=e.split(".")[1].length}catch(f){}return Number(d.replace(".",""))*Number(e.replace(".",""))/Math.pow(10,c)}function digitLength(a){var b=a.toString().split(/[eE]/),c=(b[0].split(".")[1]||"").length-+(b[1]||0);return c>0?c:0}function float2Fixed(a){if(a.toString().indexOf("e")===-1)return Number(a.toString().replace(".",""));var b=digitLength(a);return b>0?a*Math.pow(10,b):a}function times(a,b){for(var c=[],d=2;d0)return times.apply(void 0,[times(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b),g=digitLength(a)+digitLength(b),h=e*f;return h/Math.pow(10,g)}function accDivide(a,b){for(var c=[],d=2;d0)return accDivide.apply(void 0,[accDivide(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b);return times(e/f,Math.pow(10,digitLength(b)-digitLength(a)))}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){var c;if(null==this)throw new TypeError('"this" is null or not defined');var d=Object(this),e=d.length>>>0;if(0===e)return-1;var f=0|b;if(f>=e)return-1;for(c=Math.max(f>=0?f:e-Math.abs(f),0);c>>0;if(0===e)return-1;for(b=e-1,arguments.length>1&&(b=Number(arguments[1]),b!=b?b=0:0!=b&&b!=1/0&&b!=-(1/0)&&(b=(b>0||-1)*Math.floor(Math.abs(b)))),c=b>=0?Math.min(b,e-1):e-Math.abs(b);c>=0;c--)if(c in d&&d[c]===a)return c;return-1}),window.console=window.console||function(){var a={};return a.log=a.warn=a.debug=a.info=a.error=a.time=a.dir=a.profile=a.clear=a.exception=a.trace=a.assert=function(){},a}(),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return this.prototype&&(d.prototype=this.prototype),e.prototype=new d,e}),window.localStorage||(window.localStorage={items:{},setItem:function(a,b){BI.Cache.addCookie(a,b)},getItem:function(a){return BI.Cache.getCookie(a)},removeItem:function(a){BI.Cache.deleteCookie(a)},key:function(){},clear:function(){this.items={}}}),Object.keys||(Object.keys=function(a){if(a!==Object(a))throw new TypeError("Object.keys called on a non-object");var b,c,d={__ob__:b,$accessors:b,$vbthis:b,$vbsetter:b},e=[];for(c in a)c in d||Object.prototype.hasOwnProperty.call(a,c)&&e.push(c);return e}),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),"function"!=typeof Object.getPrototypeOf&&(Object.getPrototypeOf="".__proto__===String.prototype?function(a){return a.__proto__}:function(a){return a.constructor.prototype}),Date.now||(Date.now=function(){return(new Date).valueOf()}),"undefined"!=typeof Set&&Set.toString().match(/native code/)||(Set=function(){this.set={}},Set.prototype.has=function(a){return void 0!==this.set[a]},Set.prototype.add=function(a){this.set[a]=1},Set.prototype.clear=function(){this.set={}}),!function(a){var b=a.navigator.userAgent.toLowerCase(),c=/msie|applewebkit.+safari/;if(c.test(b)){var d=Array.prototype.sort;Array.prototype.sort=function(a){if(a&&"function"==typeof a){if(this.length<2)return this;for(var b,c=0,e=c+1,f=this.length,g=!1,h=0;c0,g===!0&&(b=this[c],this[c]=this[e],this[e]=b);return this}return d.call(this)}}}(window),function(a,b){function c(a){var b=a.length,c=ia.type(a);return!ia.isWindow(a)&&(!(1!==a.nodeType||!b)||("array"===c||"function"!==c&&(0===b||"number"==typeof b&&b>0&&b-1 in a)))}function d(a){var b=xa[a]={};return ia.each(a.match(ka)||[],function(a,c){b[c]=!0}),b}function e(a,c,d,e){if(ia.acceptData(a)){var f,g,h=ia.expando,i="string"==typeof c,j=a.nodeType,k=j?ia.cache:a,l=j?a[h]:a[h]&&h;if(l&&k[l]&&(e||k[l].data)||!i||d!==b)return l||(j?a[h]=l=_.pop()||ia.guid++:l=h),k[l]||(k[l]={},j||(k[l].toJSON=ia.noop)),"object"!=typeof c&&"function"!=typeof c||(e?k[l]=ia.extend(k[l],c):k[l].data=ia.extend(k[l].data,c)),f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[ia.camelCase(c)]=d),i?(g=f[c],null==g&&(g=f[ia.camelCase(c)])):g=f,g}}function f(a,b,c){if(ia.acceptData(a)){var d,e,f,g=a.nodeType,i=g?ia.cache:a,j=g?a[ia.expando]:ia.expando;if(i[j]){if(b&&(f=c?i[j]:i[j].data)){ia.isArray(b)?b=b.concat(ia.map(b,ia.camelCase)):b in f?b=[b]:(b=ia.camelCase(b),b=b in f?[b]:b.split(" "));for(d=0,e=b.length;d=0===c})}function m(a){var b=Ua.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function n(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function o(a){var b=a.getAttributeNode("type");return a.type=(b&&b.specified)+"/"+a.type,a}function p(a){var b=eb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function q(a,b){for(var c,d=0;null!=(c=a[d]);d++)ia._data(c,"globalEval",!b||ia._data(b[d],"globalEval"))}function r(a,b){if(1===b.nodeType&&ia.hasData(a)){var c,d,e,f=ia._data(a),g=ia._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d").css("cssText","display:block !important")).appendTo(b.documentElement),b=(jb[0].contentWindow||jb[0].contentDocument).document,b.write(""),b.close(),c=C(a,b),jb.detach()),ub[a]=c),c}function C(a,b){var c=ia(b.createElement(a)).appendTo(b.body),d=ia.css(c[0],"display");return c.remove(),d}function D(a,b,c,d){var e;if(ia.isArray(b))ia.each(b,function(b,e){c||Ab.test(a)?d(a,e):D(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==ia.type(b))d(a,b);else for(e in b)D(a+"["+e+"]",b[e],c,d)}function E(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(ka)||[];if(ia.isFunction(c))for(;d=f[e++];)"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function F(a,b,c,d){function e(h){var i;return f[h]=!0,ia.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||g||f[j]?g?!(i=j):void 0:(b.dataTypes.unshift(j),e(j),!1)}),i}var f={},g=a===Rb;return e(b.dataTypes[0])||!f["*"]&&e("*")}function G(a,c){var d,e,f=ia.ajaxSettings.flatOptions||{};for(e in c)c[e]!==b&&((f[e]?a:d||(d={}))[e]=c[e]);return d&&ia.extend(!0,a,d),a}function H(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(h in k)h in d&&(c[k[h]]=d[h]);for(;"*"===j[0];)j.shift(),f===b&&(f=a.mimeType||c.getResponseHeader("Content-Type"));if(f)for(h in i)if(i[h]&&i[h].test(f)){j.unshift(h);break}if(j[0]in d)g=j[0];else{for(h in d){if(!j[0]||a.converters[h+" "+j[0]]){g=h;break}e||(e=h)}g=g||e}if(g)return g!==j[0]&&j.unshift(g),d[g]}function I(a,b){var c,d,e,f,g={},h=0,i=a.dataTypes.slice(),j=i[0];if(a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i[1])for(e in a.converters)g[e.toLowerCase()]=a.converters[e];for(;d=i[++h];)if("*"!==d){if("*"!==j&&j!==d){if(e=g[j+" "+d]||g["* "+d],!e)for(c in g)if(f=c.split(" "),f[1]===d&&(e=g[j+" "+f[0]]||g["* "+f[0]])){e===!0?e=g[c]:g[c]!==!0&&(d=f[0],i.splice(h--,0,d));break}if(e!==!0)if(e&&a["throws"])b=e(b);else try{b=e(b)}catch(k){return{state:"parsererror",error:e?k:"No conversion from "+j+" to "+d}}}j=d}return{state:"success",data:b}}function J(){try{return new a.XMLHttpRequest}catch(b){}}function K(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function L(){return setTimeout(function(){$b=b}),$b=ia.now()}function M(a,b){ia.each(b,function(b,c){for(var d=(ec[b]||[]).concat(ec["*"]),e=0,f=d.length;e)[^>]*|#([\w-]*))$/,na=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,oa=/^[\],:{}\s]*$/,pa=/(?:^|:|,)(?:\s*\[)+/g,qa=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,ra=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,sa=/^-ms-/,ta=/-([\da-z])/gi,ua=function(a,b){return b.toUpperCase()},va=function(a){(W.addEventListener||"load"===a.type||"complete"===W.readyState)&&(wa(),ia.ready())},wa=function(){W.addEventListener?(W.removeEventListener("DOMContentLoaded",va,!1),a.removeEventListener("load",va,!1)):(W.detachEvent("onreadystatechange",va),a.detachEvent("onload",va))};ia.fn=ia.prototype={jquery:aa,constructor:ia,init:function(a,c,d){var e,f;if(!a)return this;if("string"==typeof a){if(e="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:ma.exec(a),!e||!e[1]&&c)return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a);if(e[1]){if(c=c instanceof ia?c[0]:c,ia.merge(this,ia.parseHTML(e[1],c&&c.nodeType?c.ownerDocument||c:W,!0)),na.test(e[1])&&ia.isPlainObject(c))for(e in c)ia.isFunction(this[e])?this[e](c[e]):this.attr(e,c[e]);return this}if(f=W.getElementById(e[2]),f&&f.parentNode){if(f.id!==e[2])return d.find(a);this.length=1,this[0]=f}return this.context=W,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):ia.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),ia.makeArray(a,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return da.call(this)},get:function(a){return null==a?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a){var b=ia.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return ia.each(this,a,b)},ready:function(a){return ia.ready.promise().done(a),this},slice:function(){return this.pushStack(da.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0||(T.resolveWith(W,[ia]),ia.fn.trigger&&ia(W).trigger("ready").off("ready"))}},isFunction:function(a){return"function"===ia.type(a)},isArray:Array.isArray||function(a){return"array"===ia.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return null==a?String(a):"object"==typeof a||"function"==typeof a?$[fa.call(a)]||"object":typeof a},isPlainObject:function(a){if(!a||"object"!==ia.type(a)||a.nodeType||ia.isWindow(a))return!1;try{if(a.constructor&&!ga.call(a,"constructor")&&!ga.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||ga.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||W;var d=na.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=ia.buildFragment([a],b,e),e&&ia(e).remove(),ia.merge([],d.childNodes))},parseJSON:function(b){return a.JSON&&a.JSON.parse?a.JSON.parse(b):null===b?b:"string"==typeof b&&(b=ia.trim(b),b&&oa.test(b.replace(qa,"@").replace(ra,"]").replace(pa,"")))?new Function("return "+b)():void ia.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||"string"!=typeof c)return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return d&&d.documentElement&&!d.getElementsByTagName("parsererror").length||ia.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&ia.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(sa,"ms-").replace(ta,ua)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,d){var e,f=0,g=a.length,h=c(a);if(d){if(h)for(;f-1;)j.splice(d,1),c&&(d<=g&&g--,d<=h&&h--)}),this},has:function(a){return a?ia.inArray(a,j)>-1:!(!j||!j.length)},empty:function(){return j=[],this},disable:function(){return j=k=e=b,this},disabled:function(){return!j},lock:function(){return k=b,e||m.disable(),this},locked:function(){return!k},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],!j||f&&!k||(c?k.push(b):l(b)),this},fire:function(){return m.fireWith(this,arguments),this},fired:function(){return!!f}};return m},ia.extend({Deferred:function(a){var b=[["resolve","done",ia.Callbacks("once memory"),"resolved"],["reject","fail",ia.Callbacks("once memory"),"rejected"],["notify","progress",ia.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return ia.Deferred(function(c){ia.each(b,function(b,f){var g=f[0],h=ia.isFunction(a[b])&&a[b];e[f[1]](function(){var a=h&&h.apply(this,arguments);a&&ia.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[g+"With"](this===d?c.promise():this,h?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?ia.extend(a,d):d}},e={};return d.pipe=d.then,ia.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b,c,d,e=0,f=da.call(arguments),g=f.length,h=1!==g||a&&ia.isFunction(a.promise)?g:0,i=1===h?a:ia.Deferred(),j=function(a,c,d){return function(e){c[a]=this,d[a]=arguments.length>1?da.call(arguments):e,d===b?i.notifyWith(c,d):--h||i.resolveWith(c,d)}};if(g>1)for(b=new Array(g),c=new Array(g),d=new Array(g);e
a",c=l.getElementsByTagName("*"),d=l.getElementsByTagName("a")[0],!c||!d||!c.length)return{};f=W.createElement("select"),h=f.appendChild(W.createElement("option")),e=l.getElementsByTagName("input")[0],d.style.cssText="top:1px;float:left;opacity:.5",b={getSetAttribute:"t"!==l.className,leadingWhitespace:3===l.firstChild.nodeType,tbody:!l.getElementsByTagName("tbody").length,htmlSerialize:!!l.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:"/a"===d.getAttribute("href"),opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:!!e.value,optSelected:h.selected,enctype:!!W.createElement("form").enctype,html5Clone:"<:nav>"!==W.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===W.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},e.checked=!0,b.noCloneChecked=e.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!h.disabled;try{delete l.test}catch(m){b.deleteExpando=!1}e=W.createElement("input"),e.setAttribute("value",""),b.input=""===e.getAttribute("value"),e.value="t",e.setAttribute("type","radio"),b.radioValue="t"===e.value,e.setAttribute("checked","t"),e.setAttribute("name","t"),g=W.createDocumentFragment(),g.appendChild(e),b.appendChecked=e.checked,b.checkClone=g.cloneNode(!0).cloneNode(!0).lastChild.checked,l.attachEvent&&(l.attachEvent("onclick",function(){b.noCloneEvent=!1}),l.cloneNode(!0).click());for(k in{submit:!0,change:!0,focusin:!0})l.setAttribute(i="on"+k,"t"),b[k+"Bubbles"]=i in a||l.attributes[i].expando===!1;return l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",b.clearCloneStyle="content-box"===l.style.backgroundClip,ia(function(){var c,d,e,f="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",g=W.getElementsByTagName("body")[0];g&&(c=W.createElement("div"),c.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",g.appendChild(c).appendChild(l),l.innerHTML="
t
",e=l.getElementsByTagName("td"),e[0].style.cssText="padding:0;margin:0;border:0;display:none",j=0===e[0].offsetHeight,e[0].style.display="",e[1].style.display="none",b.reliableHiddenOffsets=j&&0===e[0].offsetHeight,l.innerHTML="",l.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=4===l.offsetWidth,b.doesNotIncludeMarginInBodyOffset=1!==g.offsetTop,a.getComputedStyle&&(b.pixelPosition="1%"!==(a.getComputedStyle(l,null)||{}).top,b.boxSizingReliable="4px"===(a.getComputedStyle(l,null)||{width:"4px"}).width,d=l.appendChild(W.createElement("div")),d.style.cssText=l.style.cssText=f,d.style.marginRight=d.style.width="0",l.style.width="1px",b.reliableMarginRight=!parseFloat((a.getComputedStyle(d,null)||{}).marginRight)),typeof l.style.zoom!==V&&(l.innerHTML="",l.style.cssText=f+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=3===l.offsetWidth,l.style.display="block",l.innerHTML="
",l.firstChild.style.width="5px",b.shrinkWrapBlocks=3!==l.offsetWidth,b.inlineBlockNeedsLayout&&(g.style.zoom=1)),g.removeChild(c),c=l=e=d=null)}),c=f=g=h=d=e=null,b}();var ya=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,za=/([A-Z])/g;ia.extend({cache:{},expando:"jQuery"+(aa+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?ia.cache[a[ia.expando]]:a[ia.expando],!!a&&!h(a)},data:function(a,b,c){return e(a,b,c)},removeData:function(a,b){return f(a,b)},_data:function(a,b,c){return e(a,b,c,!0)},_removeData:function(a,b){return f(a,b,!0)},acceptData:function(a){if(a.nodeType&&1!==a.nodeType&&9!==a.nodeType)return!1;var b=a.nodeName&&ia.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),ia.fn.extend({data:function(a,c){var d,e,f=this[0],h=0,i=null;if(a===b){if(this.length&&(i=ia.data(f),1===f.nodeType&&!ia._data(f,"parsedAttrs"))){for(d=f.attributes;h1,null,!0)},removeData:function(a){return this.each(function(){ia.removeData(this,a)})}}),ia.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=ia._data(a,b),c&&(!d||ia.isArray(c)?d=ia._data(a,b,ia.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=ia.queue(a,b),d=c.length,e=c.shift(),f=ia._queueHooks(a,b),g=function(){ia.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),f.cur=e,e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return ia._data(a,c)||ia._data(a,c,{empty:ia.Callbacks("once memory").add(function(){ia._removeData(a,b+"queue"),ia._removeData(a,c)})})}}),ia.fn.extend({queue:function(a,c){var d=2;return"string"!=typeof a&&(c=a,a="fx",d--),arguments.length1)},removeAttr:function(a){return this.each(function(){ ia.removeAttr(this,a)})},prop:function(a,b){return ia.access(this,ia.prop,a,b,arguments.length>1)},removeProp:function(a){return a=ia.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g=0,h=this.length,i="string"==typeof a&&a;if(ia.isFunction(a))return this.each(function(b){ia(this).addClass(a.call(this,b,this.className))});if(i)for(b=(a||"").match(ka)||[];g=0;)d=d.replace(" "+e+" "," ");c.className=a?ia.trim(d):""}return this},toggleClass:function(a,b){var c=typeof a,d="boolean"==typeof b;return ia.isFunction(a)?this.each(function(c){ia(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if("string"===c)for(var e,f=0,g=ia(this),h=b,i=a.match(ka)||[];e=i[f++];)h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e);else c!==V&&"boolean"!==c||(this.className&&ia._data(this,"__className__",this.className),this.className=this.className||a===!1?"":ia._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;c=0)return!0;return!1},val:function(a){var c,d,e,f=this[0];{if(arguments.length)return e=ia.isFunction(a),this.each(function(c){var f,g=ia(this);1===this.nodeType&&(f=e?a.call(this,c,g.val()):a,null==f?f="":"number"==typeof f?f+="":ia.isArray(f)&&(f=ia.map(f,function(a){return null==a?"":a+""})),d=ia.valHooks[this.type]||ia.valHooks[this.nodeName.toLowerCase()],d&&"set"in d&&d.set(this,f,"value")!==b||(this.value=f))});if(f)return d=ia.valHooks[f.type]||ia.valHooks[f.nodeName.toLowerCase()],d&&"get"in d&&(c=d.get(f,"value"))!==b?c:(c=f.value,"string"==typeof c?c.replace(Da,""):null==c?"":c)}}}),ia.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||e<0,g=f?null:[],h=f?e+1:d.length,i=e<0?h:f?e:0;i=0}),c.length||(a.selectedIndex=-1),c}}},attr:function(a,c,d){var e,f,g,h=a.nodeType;if(a&&3!==h&&8!==h&&2!==h)return typeof a.getAttribute===V?ia.prop(a,c,d):(f=1!==h||!ia.isXMLDoc(a),f&&(c=c.toLowerCase(),e=ia.attrHooks[c]||(Ga.test(c)?Ba:Aa)),d===b?e&&f&&"get"in e&&null!==(g=e.get(a,c))?g:(typeof a.getAttribute!==V&&(g=a.getAttribute(c)),null==g?b:g):null!==d?e&&f&&"set"in e&&(g=e.set(a,d,c))!==b?g:(a.setAttribute(c,d+""),d):void ia.removeAttr(a,c))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(ka);if(f&&1===a.nodeType)for(;c=f[e++];)d=ia.propFix[c]||c,Ga.test(c)?!Ia&&Ha.test(c)?a[ia.camelCase("default-"+c)]=a[d]=!1:a[d]=!1:ia.attr(a,c,""),a.removeAttribute(Ia?c:d)},attrHooks:{type:{set:function(a,b){if(!ia.support.radioValue&&"radio"===b&&ia.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;if(a&&3!==h&&8!==h&&2!==h)return g=1!==h||!ia.isXMLDoc(a),g&&(c=ia.propFix[c]||c,f=ia.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&null!==(e=f.get(a,c))?e:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):Ea.test(a.nodeName)||Fa.test(a.nodeName)&&a.href?0:b}}}}),Ba={get:function(a,c){var d=ia.prop(a,c),e="boolean"==typeof d&&a.getAttribute(c),f="boolean"==typeof d?Ja&&Ia?null!=e:Ha.test(c)?a[ia.camelCase("default-"+c)]:!!e:a.getAttributeNode(c);return f&&f.value!==!1?c.toLowerCase():b},set:function(a,b,c){return b===!1?ia.removeAttr(a,c):Ja&&Ia||!Ha.test(c)?a.setAttribute(!Ia&&ia.propFix[c]||c,c):a[ia.camelCase("default-"+c)]=a[c]=!0,c}},Ja&&Ia||(ia.attrHooks.value={get:function(a,c){var d=a.getAttributeNode(c);return ia.nodeName(a,"input")?a.defaultValue:d&&d.specified?d.value:b},set:function(a,b,c){return ia.nodeName(a,"input")?void(a.defaultValue=b):Aa&&Aa.set(a,b,c)}}),Ia||(Aa=ia.valHooks.button={get:function(a,c){var d=a.getAttributeNode(c);return d&&("id"===c||"name"===c||"coords"===c?""!==d.value:d.specified)?d.value:b},set:function(a,c,d){var e=a.getAttributeNode(d);return e||a.setAttributeNode(e=a.ownerDocument.createAttribute(d)),e.value=c+="","value"===d||c===a.getAttribute(d)?c:b}},ia.attrHooks.contenteditable={get:Aa.get,set:function(a,b,c){Aa.set(a,""!==b&&b,c)}},ia.each(["width","height"],function(a,b){ia.attrHooks[b]=ia.extend(ia.attrHooks[b],{set:function(a,c){if(""===c)return a.setAttribute(b,"auto"),c}})})),ia.support.hrefNormalized||(ia.each(["href","src","width","height"],function(a,c){ia.attrHooks[c]=ia.extend(ia.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return null==d?b:d}})}),ia.each(["href","src"],function(a,b){ia.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}})),ia.support.style||(ia.attrHooks.style={get:function(a){return a.style.cssText||b},set:function(a,b){return a.style.cssText=b+""}}),ia.support.optSelected||(ia.propHooks.selected=ia.extend(ia.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),ia.support.enctype||(ia.propFix.enctype="encoding"),ia.support.checkOn||ia.each(["radio","checkbox"],function(){ia.valHooks[this]={get:function(a){return null===a.getAttribute("value")?"on":a.value}}}),ia.each(["radio","checkbox"],function(){ia.valHooks[this]=ia.extend(ia.valHooks[this],{set:function(a,b){if(ia.isArray(b))return a.checked=ia.inArray(ia(a).val(),b)>=0}})});var Ka=/^(?:input|select|textarea)$/i,La=/^key/,Ma=/^(?:mouse|contextmenu)|click/,Na=/^(?:focusinfocus|focusoutblur)$/,Oa=/^([^.]*)(?:\.(.+)|)$/;ia.event={global:{},add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=ia._data(a);if(r){for(d.handler&&(j=d,d=j.handler,f=j.selector),d.guid||(d.guid=ia.guid++),(h=r.events)||(h=r.events={}),(l=r.handle)||(l=r.handle=function(a){return typeof ia===V||a&&ia.event.triggered===a.type?b:ia.event.dispatch.apply(l.elem,arguments)},l.elem=a),c=(c||"").match(ka)||[""],i=c.length;i--;)g=Oa.exec(c[i])||[],o=q=g[1],p=(g[2]||"").split(".").sort(),k=ia.event.special[o]||{},o=(f?k.delegateType:k.bindType)||o,k=ia.event.special[o]||{},m=ia.extend({type:o,origType:q,data:e,handler:d,guid:d.guid,selector:f,needsContext:f&&ia.expr.match.needsContext.test(f),namespace:p.join(".")},j),(n=h[o])||(n=h[o]=[],n.delegateCount=0,k.setup&&k.setup.call(a,e,p,l)!==!1||(a.addEventListener?a.addEventListener(o,l,!1):a.attachEvent&&a.attachEvent("on"+o,l))),k.add&&(k.add.call(a,m),m.handler.guid||(m.handler.guid=d.guid)),f?n.splice(n.delegateCount++,0,m):n.push(m),ia.event.global[o]=!0;a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=ia.hasData(a)&&ia._data(a);if(q&&(k=q.events)){for(b=(b||"").match(ka)||[""],j=b.length;j--;)if(h=Oa.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){for(l=ia.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=k[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;f--;)g=m[f],!e&&p!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||ia.removeEvent(a,n,q.handle),delete k[n])}else for(n in k)ia.event.remove(a,n+b[j],c,d,!0);ia.isEmptyObject(k)&&(delete q.handle,ia._removeData(a,"events"))}},trigger:function(c,d,e,f){var g,h,i,j,k,l,m,n=[e||W],o=ga.call(c,"type")?c.type:c,p=ga.call(c,"namespace")?c.namespace.split("."):[];if(i=l=e=e||W,3!==e.nodeType&&8!==e.nodeType&&!Na.test(o+ia.event.triggered)&&(o.indexOf(".")>=0&&(p=o.split("."),o=p.shift(),p.sort()),h=o.indexOf(":")<0&&"on"+o,c=c[ia.expando]?c:new ia.Event(o,"object"==typeof c&&c),c.isTrigger=!0,c.namespace=p.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,c.result=b,c.target||(c.target=e),d=null==d?[c]:ia.makeArray(d,[c]),k=ia.event.special[o]||{},f||!k.trigger||k.trigger.apply(e,d)!==!1)){if(!f&&!k.noBubble&&!ia.isWindow(e)){for(j=k.delegateType||o,Na.test(j+o)||(i=i.parentNode);i;i=i.parentNode)n.push(i),l=i;l===(e.ownerDocument||W)&&n.push(l.defaultView||l.parentWindow||a)}for(m=0;(i=n[m++])&&!c.isPropagationStopped();)c.type=m>1?j:k.bindType||o,g=(ia._data(i,"events")||{})[c.type]&&ia._data(i,"handle"),g&&g.apply(i,d),g=h&&i[h],g&&ia.acceptData(i)&&g.apply&&g.apply(i,d)===!1&&c.preventDefault();if(c.type=o,!f&&!c.isDefaultPrevented()&&(!k._default||k._default.apply(e.ownerDocument,d)===!1)&&("click"!==o||!ia.nodeName(e,"a"))&&ia.acceptData(e)&&h&&e[o]&&!ia.isWindow(e)){l=e[h],l&&(e[h]=null),ia.event.triggered=o;try{e[o]()}catch(q){}ia.event.triggered=b,l&&(e[h]=l)}return c.result}},dispatch:function(a){a=ia.event.fix(a);var c,d,e,f,g,h=[],i=da.call(arguments),j=(ia._data(this,"events")||{})[a.type]||[],k=ia.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){for(h=ia.event.handlers.call(this,a,j),c=0;(f=h[c++])&&!a.isPropagationStopped();)for(a.currentTarget=f.elem,g=0;(e=f.handlers[g++])&&!a.isImmediatePropagationStopped();)if(!a.namespace_re||a.namespace_re.test(e.namespace)){a.handleObj=e,a.data=e.data;var l=(ia.event.special[e.origType]||{}).handle||e.handler;l.apply&&(d=l.apply(f.elem,i)),d!==b&&(a.result=d)===!1&&(a.preventDefault(),a.stopPropagation())}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,c){var d,e,f,g,h=[],i=c.delegateCount,j=a.target;if(i&&j.nodeType&&(!a.button||"click"!==a.type))for(;j!=this;j=j.parentNode||this)if(1===j.nodeType&&(j.disabled!==!0||"click"!==a.type)){for(f=[],g=0;g=0:ia.find(d,this,null,[j]).length),f[d]&&f.push(e);f.length&&h.push({elem:j,handlers:f})}return iy.cacheLength&&delete a[b.shift()],a[c]=d}}function e(a){return a[N]=!0,a}function f(a){var b=F.createElement("div");try{return a(b)}catch(c){return!1}finally{b=null}}function g(a,b,c,d){var e,f,g,h,i,j,k,n,o,p;if((b?b.ownerDocument||b:O)!==F&&E(b),b=b||F,c=c||[],!a||"string"!=typeof a)return c;if(1!==(h=b.nodeType)&&9!==h)return[];if(!H&&!d){if(e=pa.exec(a))if(g=e[1]){if(9===h){if(f=b.getElementById(g),!f||!f.parentNode)return c;if(f.id===g)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(g))&&L(b,f)&&f.id===g)return c.push(f),c}else{if(e[2])return Z.apply(c,$.call(b.getElementsByTagName(a),0)),c;if((g=e[3])&&P.getByClassName&&b.getElementsByClassName)return Z.apply(c,$.call(b.getElementsByClassName(g),0)),c}if(P.qsa&&!I.test(a)){if(k=!0,n=N,o=b,p=9===h&&a,1===h&&"object"!==b.nodeName.toLowerCase()){for(j=l(a),(k=b.getAttribute("id"))?n=k.replace(sa,"\\$&"):b.setAttribute("id",n),n="[id='"+n+"'] ",i=j.length;i--;)j[i]=n+m(j[i]);o=na.test(a)&&b.parentNode||b,p=j.join(",")}if(p)try{return Z.apply(c,$.call(o.querySelectorAll(p),0)),c}catch(q){}finally{k||b.removeAttribute("id")}}}return u(a.replace(ga,"$1"),b,c,d)}function h(a,b){var c=b&&a,d=c&&(~b.sourceIndex||W)-(~a.sourceIndex||W);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function i(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function j(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function k(a){return e(function(b){return b=+b,e(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function l(a,b){var c,d,e,f,h,i,j,k=T[a+" "];if(k)return b?0:k.slice(0);for(h=a,i=[],j=y.preFilter;h;){c&&!(d=ha.exec(h))||(d&&(h=h.slice(d[0].length)||h),i.push(e=[])),c=!1,(d=ja.exec(h))&&(c=d.shift(),e.push({value:c,type:d[0].replace(ga," ")}),h=h.slice(c.length));for(f in y.filter)!(d=ma[f].exec(h))||j[f]&&!(d=j[f](d))||(c=d.shift(),e.push({value:c,type:f,matches:d}),h=h.slice(c.length));if(!c)break}return b?h.length:h?g.error(a):T(a,i).slice(0)}function m(a){for(var b=0,c=a.length,d="";b1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function p(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;h-1&&(e[j]=!(g[j]=l))}}else s=p(s===g?s.splice(o,s.length):s),f?f(null,g,s,i):Z.apply(g,s)})}function r(a){for(var b,c,d,e=a.length,f=y.relative[a[0].type],g=f||y.relative[" "],h=f?1:0,i=n(function(a){return a===b},g,!0),j=n(function(a){return _.call(b,a)>-1},g,!0),k=[function(a,c,d){return!f&&(d||c!==D)||((b=c).nodeType?i(a,c,d):j(a,c,d))}];h1&&o(k),h>1&&m(a.slice(0,h-1)).replace(ga,"$1"),c,h0,f=a.length>0,h=function(e,h,i,j,k){var l,m,n,o=[],q=0,r="0",s=e&&[],t=null!=k,u=D,v=e||f&&y.find.TAG("*",k&&h.parentNode||h),w=Q+=null==u?1:Math.random()||.1;for(t&&(D=h!==F&&h,x=c);null!=(l=v[r]);r++){if(f&&l){for(m=0;n=a[m++];)if(n(l,h,i)){j.push(l);break}t&&(Q=w,x=++c)}d&&((l=!n&&l)&&q--,e&&s.push(l))}if(q+=r,d&&r!==q){for(m=0;n=b[m++];)n(s,o,h,i);if(e){if(q>0)for(;r--;)s[r]||o[r]||(o[r]=Y.call(j));o=p(o)}Z.apply(j,o),t&&!e&&o.length>0&&q+b.length>1&&g.uniqueSort(j)}return t&&(Q=w,D=u),s};return d?e(h):h}function t(a,b,c){for(var d=0,e=b.length;d2&&"ID"===(g=f[0]).type&&9===b.nodeType&&!H&&y.relative[f[1].type]){if(b=y.find.ID(g.matches[0].replace(ua,va),b)[0],!b)return c;a=a.slice(f.shift().value.length)}for(e=ma.needsContext.test(a)?0:f.length;e--&&(g=f[e],!y.relative[h=g.type]);)if((i=y.find[h])&&(d=i(g.matches[0].replace(ua,va),na.test(f[0].type)&&b.parentNode||b))){if(f.splice(e,1),a=d.length&&m(f),!a)return Z.apply(c,$.call(d,0)),c;break}}return B(a,j)(d,b,H,c,na.test(a)),c}function v(){}var w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N="sizzle"+-new Date,O=a.document,P={},Q=0,R=0,S=d(),T=d(),U=d(),V=typeof b,W=1<<31,X=[],Y=X.pop,Z=X.push,$=X.slice,_=X.indexOf||function(a){for(var b=0,c=this.length;b+~])"+aa+"*"),ka=new RegExp(fa),la=new RegExp("^"+ca+"$"),ma={ID:new RegExp("^#("+ba+")"),CLASS:new RegExp("^\\.("+ba+")"),NAME:new RegExp("^\\[name=['\"]?("+ba+")['\"]?\\]"),TAG:new RegExp("^("+ba.replace("w","w*")+")"),ATTR:new RegExp("^"+ea),PSEUDO:new RegExp("^"+fa),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+aa+"*(even|odd|(([+-]|)(\\d*)n|)"+aa+"*(?:([+-]|)"+aa+"*(\\d+)|))"+aa+"*\\)|)","i"),needsContext:new RegExp("^"+aa+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+aa+"*((?:-\\d)?\\d*)"+aa+"*\\)|)(?=[^-]|$)","i")},na=/[\x20\t\r\n\f]*[+~]/,oa=/^[^{]+\{\s*\[native code/,pa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,qa=/^(?:input|select|textarea|button)$/i,ra=/^h\d$/i,sa=/'|\\/g,ta=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,ua=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,va=function(a,b){var c="0x"+b-65536;return c!==c?b:c<0?String.fromCharCode(c+65536):String.fromCharCode(c>>10|55296,1023&c|56320)};try{$.call(O.documentElement.childNodes,0)[0].nodeType}catch(wa){$=function(a){for(var b,c=[];b=this[a++];)c.push(b);return c}}A=g.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},E=g.setDocument=function(a){var d=a?a.ownerDocument||a:O;return d!==F&&9===d.nodeType&&d.documentElement?(F=d,G=d.documentElement,H=A(d),P.tagNameNoComments=f(function(a){return a.appendChild(d.createComment("")),!a.getElementsByTagName("*").length}),P.attributes=f(function(a){a.innerHTML="";var b=typeof a.lastChild.getAttribute("multiple");return"boolean"!==b&&"string"!==b}),P.getByClassName=f(function(a){return a.innerHTML="",!(!a.getElementsByClassName||!a.getElementsByClassName("e").length)&&(a.lastChild.className="e",2===a.getElementsByClassName("e").length)}),P.getByName=f(function(a){a.id=N+0,a.innerHTML="
",G.insertBefore(a,G.firstChild);var b=d.getElementsByName&&d.getElementsByName(N).length===2+d.getElementsByName(N+0).length;return P.getIdNotName=!d.getElementById(N),G.removeChild(a),b}),y.attrHandle=f(function(a){return a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!==V&&"#"===a.firstChild.getAttribute("href")})?{}:{href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}},P.getIdNotName?(y.find.ID=function(a,b){if(typeof b.getElementById!==V&&!H){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},y.filter.ID=function(a){var b=a.replace(ua,va);return function(a){return a.getAttribute("id")===b}}):(y.find.ID=function(a,c){if(typeof c.getElementById!==V&&!H){var d=c.getElementById(a);return d?d.id===a||typeof d.getAttributeNode!==V&&d.getAttributeNode("id").value===a?[d]:b:[]}},y.filter.ID=function(a){var b=a.replace(ua,va);return function(a){var c=typeof a.getAttributeNode!==V&&a.getAttributeNode("id");return c&&c.value===b}}),y.find.TAG=P.tagNameNoComments?function(a,b){if(typeof b.getElementsByTagName!==V)return b.getElementsByTagName(a)}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},y.find.NAME=P.getByName&&function(a,b){if(typeof b.getElementsByName!==V)return b.getElementsByName(name)},y.find.CLASS=P.getByClassName&&function(a,b){if(typeof b.getElementsByClassName!==V&&!H)return b.getElementsByClassName(a)},J=[],I=[":focus"],(P.qsa=c(d.querySelectorAll))&&(f(function(a){a.innerHTML="",a.querySelectorAll("[selected]").length||I.push("\\["+aa+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||I.push(":checked")}),f(function(a){a.innerHTML="",a.querySelectorAll("[i^='']").length&&I.push("[*^$]="+aa+"*(?:\"\"|'')"),a.querySelectorAll(":enabled").length||I.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),I.push(",.*:")})),(P.matchesSelector=c(K=G.matchesSelector||G.mozMatchesSelector||G.webkitMatchesSelector||G.oMatchesSelector||G.msMatchesSelector))&&f(function(a){P.disconnectedMatch=K.call(a,"div"),K.call(a,"[s!='']:x"),J.push("!=",fa)}),I=new RegExp(I.join("|")),J=new RegExp(J.join("|")),L=c(G.contains)||G.compareDocumentPosition?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},M=G.compareDocumentPosition?function(a,b){var c;return a===b?(C=!0,0):(c=b.compareDocumentPosition&&a.compareDocumentPosition&&a.compareDocumentPosition(b))?1&c||a.parentNode&&11===a.parentNode.nodeType?a===d||L(O,a)?-1:b===d||L(O,b)?1:0:4&c?-1:1:a.compareDocumentPosition?-1:1}:function(a,b){var c,e=0,f=a.parentNode,g=b.parentNode,i=[a],j=[b];if(a===b)return C=!0,0;if(!f||!g)return a===d?-1:b===d?1:f?-1:g?1:0;if(f===g)return h(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[e]===j[e];)e++;return e?h(i[e],j[e]):i[e]===O?-1:j[e]===O?1:0},C=!1,[0,0].sort(M),P.detectDuplicates=C,F):F},g.matches=function(a,b){return g(a,null,null,b)},g.matchesSelector=function(a,b){if((a.ownerDocument||a)!==F&&E(a),b=b.replace(ta,"='$1']"),P.matchesSelector&&!H&&(!J||!J.test(b))&&!I.test(b))try{var c=K.call(a,b);if(c||P.disconnectedMatch||a.document&&11!==a.document.nodeType)return c}catch(d){}return g(b,F,null,[a]).length>0},g.contains=function(a,b){return(a.ownerDocument||a)!==F&&E(a),L(a,b)},g.attr=function(a,b){var c;return(a.ownerDocument||a)!==F&&E(a),H||(b=b.toLowerCase()),(c=y.attrHandle[b])?c(a):H||P.attributes?a.getAttribute(b):((c=a.getAttributeNode(b))||a.getAttribute(b))&&a[b]===!0?b:c&&c.specified?c.value:null},g.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},g.uniqueSort=function(a){var b,c=[],d=1,e=0;if(C=!P.detectDuplicates,a.sort(M),C){for(;b=a[d];d++)b===a[d-1]&&(e=c.push(d));for(;e--;)a.splice(c[e],1)}return a},z=g.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=z(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d];d++)c+=z(b);return c},y=g.selectors={cacheLength:50,createPseudo:e,match:ma,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ua,va),a[3]=(a[4]||a[5]||"").replace(ua,va),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||g.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&g.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return ma.CHILD.test(a[0])?null:(a[4]?a[2]=a[4]:c&&ka.test(c)&&(b=l(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){return"*"===a?function(){return!0}:(a=a.replace(ua,va).toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=S[a+" "];return b||(b=new RegExp("(^|"+aa+")"+a+"("+aa+"|$)"))&&S(a,function(a){return b.test(a.className||typeof a.getAttribute!==V&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=g.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[N]||(q[N]={}),j=k[a]||[],n=j[0]===Q&&j[1],m=j[0]===Q&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[Q,n,m];break}}else if(s&&(j=(b[N]||(b[N]={}))[a])&&j[0]===Q)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[N]||(l[N]={}))[a]=[Q,m]),l!==b)););return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,d=y.pseudos[a]||y.setFilters[a.toLowerCase()]||g.error("unsupported pseudo: "+a);return d[N]?d(b):d.length>1?(c=[a,a,"",b], y.setFilters.hasOwnProperty(a.toLowerCase())?e(function(a,c){for(var e,f=d(a,b),g=f.length;g--;)e=_.call(a,f[g]),a[e]=!(c[e]=f[g])}):function(a){return d(a,0,c)}):d}},pseudos:{not:e(function(a){var b=[],c=[],d=B(a.replace(ga,"$1"));return d[N]?e(function(a,b,c,e){for(var f,g=d(a,null,e,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:e(function(a){return function(b){return g(a,b).length>0}}),contains:e(function(a){return function(b){return(b.textContent||b.innerText||z(b)).indexOf(a)>-1}}),lang:e(function(a){return la.test(a||"")||g.error("unsupported lang: "+a),a=a.replace(ua,va).toLowerCase(),function(b){var c;do if(c=H?b.getAttribute("xml:lang")||b.getAttribute("lang"):b.lang)return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===G},focus:function(a){return a===F.activeElement&&(!F.hasFocus||F.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeName>"@"||3===a.nodeType||4===a.nodeType)return!1;return!0},parent:function(a){return!y.pseudos.empty(a)},header:function(a){return ra.test(a.nodeName)},input:function(a){return qa.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||b.toLowerCase()===a.type)},first:k(function(){return[0]}),last:k(function(a,b){return[b-1]}),eq:k(function(a,b,c){return[c<0?c+b:c]}),even:k(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:k(function(a,b,c){for(var d=c<0?c+b:c;++d1?ia.unique(c):c),c.selector=(this.selector?this.selector+" ":"")+a,c},has:function(a){var b,c=ia(a,this),d=c.length;return this.filter(function(){for(b=0;b=0:ia.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=Sa.test(a)||"string"!=typeof a?ia(a,b||this.context):0;d-1:ia.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}return this.pushStack(f.length>1?ia.unique(f):f)},index:function(a){return a?"string"==typeof a?ia.inArray(this[0],ia(a)):ia.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){var c="string"==typeof a?ia(a,b):ia.makeArray(a&&a.nodeType?[a]:a),d=ia.merge(this.get(),c);return this.pushStack(ia.unique(d))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}}),ia.fn.andSelf=ia.fn.addBack,ia.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return ia.dir(a,"parentNode")},parentsUntil:function(a,b,c){return ia.dir(a,"parentNode",c)},next:function(a){return k(a,"nextSibling")},prev:function(a){return k(a,"previousSibling")},nextAll:function(a){return ia.dir(a,"nextSibling")},prevAll:function(a){return ia.dir(a,"previousSibling")},nextUntil:function(a,b,c){return ia.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return ia.dir(a,"previousSibling",c)},siblings:function(a){return ia.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return ia.sibling(a.firstChild)},contents:function(a){return ia.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:ia.merge([],a.childNodes)}},function(a,b){ia.fn[a]=function(c,d){var e=ia.map(this,b,c);return Pa.test(a)||(d=c),d&&"string"==typeof d&&(e=ia.filter(d,e)),e=this.length>1&&!Ta[a]?ia.unique(e):e,this.length>1&&Qa.test(a)&&(e=e.reverse()),this.pushStack(e)}}),ia.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),1===b.length?ia.find.matchesSelector(b[0],a)?[b[0]]:[]:ia.find.matches(a,b)},dir:function(a,c,d){for(var e=[],f=a[c];f&&9!==f.nodeType&&(d===b||1!==f.nodeType||!ia(f).is(d));)1===f.nodeType&&e.push(f),f=f[c];return e},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}});var Ua="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Va=/ jQuery\d+="(?:null|\d+)"/g,Wa=new RegExp("<(?:"+Ua+")[\\s/>]","i"),Xa=/^\s+/,Ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Za=/<([\w:]+)/,$a=/\s*$/g,gb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:ia.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},hb=m(W),ib=hb.appendChild(W.createElement("div"));gb.optgroup=gb.option,gb.tbody=gb.tfoot=gb.colgroup=gb.caption=gb.thead,gb.th=gb.td,ia.fn.extend({text:function(a){return ia.access(this,function(a){return a===b?ia.text(this):this.empty().append((this[0]&&this[0].ownerDocument||W).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(ia.isFunction(a))return this.each(function(b){ia(this).wrapAll(a.call(this,b))});if(this[0]){var b=ia(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstChild&&1===a.firstChild.nodeType;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return ia.isFunction(a)?this.each(function(b){ia(this).wrapInner(a.call(this,b))}):this.each(function(){var b=ia(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=ia.isFunction(a);return this.each(function(c){ia(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){ia.nodeName(this,"body")||ia(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.insertBefore(a,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=0;null!=(c=this[d]);d++)(!a||ia.filter(a,[c]).length>0)&&(b||1!==c.nodeType||ia.cleanData(t(c)),c.parentNode&&(b&&ia.contains(c.ownerDocument,c)&&q(t(c,"script")),c.parentNode.removeChild(c)));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){for(1===a.nodeType&&ia.cleanData(t(a,!1));a.firstChild;)a.removeChild(a.firstChild);a.options&&ia.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return ia.clone(this,a,b)})},html:function(a){return ia.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return 1===c.nodeType?c.innerHTML.replace(Va,""):b;if("string"==typeof a&&!ab.test(a)&&(ia.support.htmlSerialize||!Wa.test(a))&&(ia.support.leadingWhitespace||!Xa.test(a))&&!gb[(Za.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ya,"<$1>");try{for(;d")?f=a.cloneNode(!0):(ib.innerHTML=a.outerHTML,ib.removeChild(f=ib.firstChild)),!(ia.support.noCloneEvent&&ia.support.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||ia.isXMLDoc(a)))for(d=t(f),h=t(a),g=0;null!=(e=h[g]);++g)d[g]&&s(e,d[g]);if(b)if(c)for(h=h||t(a),d=d||t(f),g=0;null!=(e=h[g]);g++)r(e,d[g]);else r(a,f);return d=t(f,"script"),d.length>0&&q(d,!i&&t(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,l=a.length,n=m(b),o=[],p=0;p")+k[2],e=k[0];e--;)h=h.lastChild;if(!ia.support.leadingWhitespace&&Xa.test(f)&&o.push(b.createTextNode(Xa.exec(f)[0])),!ia.support.tbody)for(f="table"!==i||$a.test(f)?""!==k[1]||$a.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;e--;)ia.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j);for(ia.merge(o,h.childNodes),h.textContent="";h.firstChild;)h.removeChild(h.firstChild);h=n.lastChild}else o.push(b.createTextNode(f));for(h&&n.removeChild(h),ia.support.appendChecked||ia.grep(t(o,"input"),u),p=0;f=o[p++];)if((!d||ia.inArray(f,d)===-1)&&(g=ia.contains(f.ownerDocument,f),h=t(n.appendChild(f),"script"),g&&q(h),c))for(e=0;f=h[e++];)db.test(f.type||"")&&c.push(f);return h=null,n},cleanData:function(a,b){for(var c,d,e,f,g=0,h=ia.expando,i=ia.cache,j=ia.support.deleteExpando,k=ia.event.special;null!=(c=a[g]);g++)if((b||ia.acceptData(c))&&(e=c[h],f=e&&i[e])){if(f.events)for(d in f.events)k[d]?ia.event.remove(c,d):ia.removeEvent(c,d,f.handle);i[e]&&(delete i[e],j?delete c[h]:typeof c.removeAttribute!==V?c.removeAttribute(h):c[h]=null,_.push(e))}}});var jb,kb,lb,mb=/alpha\([^)]*\)/i,nb=/opacity\s*=\s*([^)]*)/,ob=/^(top|right|bottom|left)$/,pb=/^(none|table(?!-c[ea]).+)/,qb=/^margin/,rb=new RegExp("^("+ja+")(.*)$","i"),sb=new RegExp("^("+ja+")(?!px)[a-z%]+$","i"),tb=new RegExp("^([+-])=("+ja+")","i"),ub={BODY:"block"},vb={position:"absolute",visibility:"hidden",display:"block"},wb={letterSpacing:0,fontWeight:400},xb=["Top","Right","Bottom","Left"],yb=["Webkit","O","Moz","ms"];ia.fn.extend({css:function(a,c){return ia.access(this,function(a,c,d){var e,f,g={},h=0;if(ia.isArray(c)){for(f=kb(a),e=c.length;h1)},show:function(){return x(this,!0)},hide:function(){return x(this)},toggle:function(a){var b="boolean"==typeof a;return this.each(function(){(b?a:w(this))?ia(this).show():ia(this).hide()})}}),ia.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=lb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":ia.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var f,g,h,i=ia.camelCase(c),j=a.style;if(c=ia.cssProps[i]||(ia.cssProps[i]=v(j,i)),h=ia.cssHooks[c]||ia.cssHooks[i],d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];if(g=typeof d,"string"===g&&(f=tb.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(ia.css(a,c)),g="number"),!(null==d||"number"===g&&isNaN(d)||("number"!==g||ia.cssNumber[i]||(d+="px"),ia.support.clearCloneStyle||""!==d||0!==c.indexOf("background")||(j[c]="inherit"),h&&"set"in h&&(d=h.set(a,d,e))===b)))try{j[c]=d}catch(k){}}},css:function(a,c,d,e){var f,g,h,i=ia.camelCase(c);return c=ia.cssProps[i]||(ia.cssProps[i]=v(a.style,i)),h=ia.cssHooks[c]||ia.cssHooks[i],h&&"get"in h&&(g=h.get(a,!0,d)),g===b&&(g=lb(a,c,e)),"normal"===g&&c in wb&&(g=wb[c]),""===d||d?(f=parseFloat(g),d===!0||ia.isNumeric(f)?f||0:g):g},swap:function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e}}),a.getComputedStyle?(kb=function(b){return a.getComputedStyle(b,null)},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h.getPropertyValue(c)||h[c]:b,j=a.style;return h&&(""!==i||ia.contains(a.ownerDocument,a)||(i=ia.style(a,c)),sb.test(i)&&qb.test(c)&&(e=j.width,f=j.minWidth,g=j.maxWidth,j.minWidth=j.maxWidth=j.width=i,i=h.width,j.width=e,j.minWidth=f,j.maxWidth=g)),i}):W.documentElement.currentStyle&&(kb=function(a){return a.currentStyle},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h[c]:b,j=a.style;return null==i&&j&&j[c]&&(i=j[c]),sb.test(i)&&!ob.test(c)&&(e=j.left,f=a.runtimeStyle,g=f&&f.left,g&&(f.left=a.currentStyle.left),j.left="fontSize"===c?"1em":i,i=j.pixelLeft+"px",j.left=e,g&&(f.left=g)),""===i?"auto":i}),ia.each(["height","width"],function(a,b){ia.cssHooks[b]={get:function(a,c,d){if(c)return 0===a.offsetWidth&&pb.test(ia.css(a,"display"))?ia.swap(a,vb,function(){return A(a,b,d)}):A(a,b,d)},set:function(a,c,d){var e=d&&kb(a);return y(a,c,d?z(a,b,d,ia.support.boxSizing&&"border-box"===ia.css(a,"boxSizing",!1,e),e):0)}}}),ia.support.opacity||(ia.cssHooks.opacity={get:function(a,b){return nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=ia.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===ia.trim(f.replace(mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=mb.test(f)?f.replace(mb,e):f+" "+e)}}),ia(function(){ia.support.reliableMarginRight||(ia.cssHooks.marginRight={get:function(a,b){if(b)return ia.swap(a,{display:"inline-block"},lb,[a,"marginRight"])}}),!ia.support.pixelPosition&&ia.fn.position&&ia.each(["top","left"],function(a,b){ia.cssHooks[b]={get:function(a,c){if(c)return c=lb(a,b),sb.test(c)?ia(a).position()[b]+"px":c}}})}),ia.expr&&ia.expr.filters&&(ia.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!ia.support.reliableHiddenOffsets&&"none"===(a.style&&a.style.display||ia.css(a,"display"))},ia.expr.filters.visible=function(a){return!ia.expr.filters.hidden(a)}),ia.each({margin:"",padding:"",border:"Width"},function(a,b){ia.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+xb[d]+b]=f[d]||f[d-2]||f[0];return e}},qb.test(a)||(ia.cssHooks[a+b].set=y)});var zb=/%20/g,Ab=/\[\]$/,Bb=/\r?\n/g,Cb=/^(?:submit|button|image|reset|file)$/i,Db=/^(?:input|select|textarea|keygen)/i;ia.fn.extend({serialize:function(){return ia.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=ia.prop(this,"elements");return a?ia.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!ia(this).is(":disabled")&&Db.test(this.nodeName)&&!Cb.test(a)&&(this.checked||!bb.test(a))}).map(function(a,b){var c=ia(this).val();return null==c?null:ia.isArray(c)?ia.map(c,function(a){return{name:b.name,value:a.replace(Bb,"\r\n")}}):{name:b.name,value:c.replace(Bb,"\r\n")}}).get()}}),ia.param=function(a,c){var d,e=[],f=function(a,b){b=ia.isFunction(b)?b():null==b?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(c===b&&(c=ia.ajaxSettings&&ia.ajaxSettings.traditional),ia.isArray(a)||a.jquery&&!ia.isPlainObject(a))ia.each(a,function(){f(this.name,this.value)});else for(d in a)D(d,a[d],c,f);return e.join("&").replace(zb,"+")},ia.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){ia.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),ia.fn.hover=function(a,b){return this.mouseenter(a).mouseleave(b||a)};var Eb,Fb,Gb=ia.now(),Hb=/\?/,Ib=/#.*$/,Jb=/([?&])_=[^&]*/,Kb=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Lb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mb=/^(?:GET|HEAD)$/,Nb=/^\/\//,Ob=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Pb=ia.fn.load,Qb={},Rb={},Sb="*/".concat("*");try{Fb=X.href}catch(Tb){Fb=W.createElement("a"),Fb.href="",Fb=Fb.href}Eb=Ob.exec(Fb.toLowerCase())||[],ia.fn.load=function(a,c,d){if("string"!=typeof a&&Pb)return Pb.apply(this,arguments);var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),ia.isFunction(c)?(d=c,c=b):c&&"object"==typeof c&&(g="POST"),h.length>0&&ia.ajax({url:a,type:g,dataType:"html",data:c}).done(function(a){f=arguments,h.html(e?ia("
").append(ia.parseHTML(a)).find(e):a)}).complete(d&&function(a,b){h.each(d,f||[a.responseText,b,a])}),this},ia.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){ia.fn[b]=function(a){return this.on(b,a)}}),ia.each(["get","post"],function(a,c){ia[c]=function(a,d,e,f){return ia.isFunction(d)&&(f=f||e,e=d,d=b),ia.ajax({url:a,type:c,dataType:f,data:d,success:e})}}),ia.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fb,type:"GET",isLocal:Lb.test(Eb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Sb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":ia.parseJSON,"text xml":ia.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?G(G(a,ia.ajaxSettings),b):G(ia.ajaxSettings,a)},ajaxPrefilter:E(Qb),ajaxTransport:E(Rb),ajax:function(a,c){function d(a,c,d,e){var f,l,s,t,v,x=c;2!==u&&(u=2,i&&clearTimeout(i),k=b,h=e||"",w.readyState=a>0?4:0,d&&(t=H(m,w,d)),a>=200&&a<300||304===a?(m.ifModified&&(v=w.getResponseHeader("Last-Modified"),v&&(ia.lastModified[g]=v),v=w.getResponseHeader("etag"),v&&(ia.etag[g]=v)),204===a?(f=!0,x="nocontent"):304===a?(f=!0,x="notmodified"):(f=I(m,t),x=f.state,l=f.data,s=f.error,f=!s)):(s=x,!a&&x||(x="error",a<0&&(a=0))),w.status=a,w.statusText=(c||x)+"",f?p.resolveWith(n,[l,x,w]):p.rejectWith(n,[w,x,s]),w.statusCode(r),r=b,j&&o.trigger(f?"ajaxSuccess":"ajaxError",[w,m,f?l:s]),q.fireWith(n,[w,x]),j&&(o.trigger("ajaxComplete",[w,m]),--ia.active||ia.event.trigger("ajaxStop")))}"object"==typeof a&&(c=a,a=b),c=c||{};var e,f,g,h,i,j,k,l,m=ia.ajaxSetup({},c),n=m.context||m,o=m.context&&(n.nodeType||n.jquery)?ia(n):ia.event,p=ia.Deferred(),q=ia.Callbacks("once memory"),r=m.statusCode||{},s={},t={},u=0,v="canceled",w={readyState:0,getResponseHeader:function(a){var b;if(2===u){if(!l)for(l={};b=Kb.exec(h);)l[b[1].toLowerCase()]=b[2];b=l[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===u?h:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return u||(a=t[c]=t[c]||a,s[a]=b),this},overrideMimeType:function(a){return u||(m.mimeType=a),this},statusCode:function(a){var b;if(a)if(u<2)for(b in a)r[b]=[r[b],a[b]];else w.always(a[w.status]);return this},abort:function(a){var b=a||v;return k&&k.abort(b),d(0,b),this}};if(p.promise(w).complete=q.add,w.success=w.done,w.error=w.fail,m.url=((a||m.url||Fb)+"").replace(Ib,"").replace(Nb,Eb[1]+"//"),m.type=c.method||c.type||m.method||m.type,m.dataTypes=ia.trim(m.dataType||"*").toLowerCase().match(ka)||[""],null==m.crossDomain&&(e=Ob.exec(m.url.toLowerCase()),m.crossDomain=!(!e||e[1]===Eb[1]&&e[2]===Eb[2]&&(e[3]||("http:"===e[1]?80:443))==(Eb[3]||("http:"===Eb[1]?80:443)))),m.data&&m.processData&&"string"!=typeof m.data&&(m.data=ia.param(m.data,m.traditional)),F(Qb,m,c,w),2===u)return w;j=m.global,j&&0===ia.active++&&ia.event.trigger("ajaxStart"),m.type=m.type.toUpperCase(),m.hasContent=!Mb.test(m.type),g=m.url,m.hasContent||(m.data&&(g=m.url+=(Hb.test(g)?"&":"?")+m.data,delete m.data),m.cache===!1&&(m.url=Jb.test(g)?g.replace(Jb,"$1_="+Gb++):g+(Hb.test(g)?"&":"?")+"_="+Gb++)),m.ifModified&&(ia.lastModified[g]&&w.setRequestHeader("If-Modified-Since",ia.lastModified[g]),ia.etag[g]&&w.setRequestHeader("If-None-Match",ia.etag[g])),(m.data&&m.hasContent&&m.contentType!==!1||c.contentType)&&w.setRequestHeader("Content-Type",m.contentType),w.setRequestHeader("Accept",m.dataTypes[0]&&m.accepts[m.dataTypes[0]]?m.accepts[m.dataTypes[0]]+("*"!==m.dataTypes[0]?", "+Sb+"; q=0.01":""):m.accepts["*"]);for(f in m.headers)w.setRequestHeader(f,m.headers[f]);if(m.beforeSend&&(m.beforeSend.call(n,w,m)===!1||2===u))return w.abort();v="abort";for(f in{success:1,error:1,complete:1})w[f](m[f]);if(k=F(Rb,m,c,w)){w.readyState=1,j&&o.trigger("ajaxSend",[w,m]),m.async&&m.timeout>0&&(i=setTimeout(function(){w.abort("timeout")},m.timeout));try{u=1,k.send(s,d)}catch(x){if(!(u<2))throw x;d(-1,x)}}else d(-1,"No Transport");return w},getScript:function(a,c){return ia.get(a,b,c,"script")},getJSON:function(a,b,c){return ia.get(a,b,c,"json")}}),ia.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return ia.globalEval(a),a}}}),ia.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),ia.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=W.head||ia("head")[0]||W.documentElement;return{send:function(b,e){c=W.createElement("script"),c.async=!0,a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,b){(b||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c.parentNode&&c.parentNode.removeChild(c),c=null,b||e(200,"success"))},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(b,!0)}}}});var Ub=[],Vb=/(=)\?(?=&|$)|\?\?/;ia.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Ub.pop()||ia.expando+"_"+Gb++;return this[a]=!0,a}}),ia.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.jsonp!==!1&&(Vb.test(c.url)?"url":"string"==typeof c.data&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vb.test(c.data)&&"data");if(i||"jsonp"===c.dataTypes[0])return f=c.jsonpCallback=ia.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,i?c[i]=c[i].replace(Vb,"$1"+f):c.jsonp!==!1&&(c.url+=(Hb.test(c.url)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||ia.error(f+" was not called"),h[0]},c.dataTypes[0]="json",g=a[f],a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,Ub.push(f)),h&&ia.isFunction(g)&&g(h[0]),h=g=b}),"script"});var Wb,Xb,Yb=0,Zb=a.ActiveXObject&&function(){var a;for(a in Wb)Wb[a](b,!0)};ia.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&J()||K()}:J,Xb=ia.ajaxSettings.xhr(),ia.support.cors=!!Xb&&"withCredentials"in Xb,Xb=ia.support.ajax=!!Xb,Xb&&ia.ajaxTransport(function(c){if(!c.crossDomain||ia.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();if(c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async),c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),c.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l;try{if(d&&(e||4===i.readyState))if(d=b,g&&(i.onreadystatechange=ia.noop,Zb&&delete Wb[g]),e)4!==i.readyState&&i.abort();else{l={},h=i.status,j=i.getAllResponseHeaders(),"string"==typeof i.responseText&&(l.text=i.responseText);try{k=i.statusText}catch(m){k=""}h||!c.isLocal||c.crossDomain?1223===h&&(h=204):h=l.text?200:404}}catch(n){e||f(-1,n)}l&&f(h,k,l,j)},c.async?4===i.readyState?setTimeout(d):(g=++Yb,Zb&&(Wb||(Wb={},ia(a).unload(Zb)),Wb[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(b,!0)}}}});var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+ja+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[P],ec={"*":[function(a,b){var c,d,e=this.createTween(a,b),f=bc.exec(b),g=e.cur(),h=+g||0,i=1,j=20;if(f){if(c=+f[2],d=f[3]||(ia.cssNumber[a]?"":"px"),"px"!==d&&h){h=ia.css(e.elem,a,!0)||c||1;do i=i||".5",h/=i,ia.style(e.elem,a,h+d);while(i!==(i=e.cur()/g)&&1!==i&&--j)}e.unit=d,e.start=h,e.end=f[1]?h+(f[1]+1)*c:c}return e}]};ia.Animation=ia.extend(N,{tweener:function(a,b){ia.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;d-1,l={},m={}; diff --git a/dist/bundle.min.js b/dist/bundle.min.js index b5a8c96aa..3292c84b5 100644 --- a/dist/bundle.min.js +++ b/dist/bundle.min.js @@ -1,4 +1,4 @@ -/*! fineui 20-07-2018 */ +/*! fineui 23-07-2018 */ function accAdd(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g){c=0}try{d=b.toString().split(".")[1].length}catch(g){d=0}if(f=Math.abs(c-d),e=Math.pow(10,Math.max(c,d)),f>0){var h=Math.pow(10,f);c>d?(a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""))*h):(a=Number(a.toString().replace(".",""))*h,b=Number(b.toString().replace(".","")))}else a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""));return(a+b)/e}function accSub(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g){c=0}try{d=b.toString().split(".")[1].length}catch(g){d=0}return e=Math.pow(10,Math.max(c,d)),f=c>=d?c:d,((a*e-b*e)/e).toFixed(f)}function accMul(a,b){var c=0,d=a.toString(),e=b.toString();try{c+=d.split(".")[1].length}catch(f){}try{c+=e.split(".")[1].length}catch(f){}return Number(d.replace(".",""))*Number(e.replace(".",""))/Math.pow(10,c)}function digitLength(a){var b=a.toString().split(/[eE]/),c=(b[0].split(".")[1]||"").length-+(b[1]||0);return c>0?c:0}function float2Fixed(a){if(a.toString().indexOf("e")===-1)return Number(a.toString().replace(".",""));var b=digitLength(a);return b>0?a*Math.pow(10,b):a}function times(a,b){for(var c=[],d=2;d0)return times.apply(void 0,[times(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b),g=digitLength(a)+digitLength(b),h=e*f;return h/Math.pow(10,g)}function accDivide(a,b){for(var c=[],d=2;d0)return accDivide.apply(void 0,[accDivide(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b);return times(e/f,Math.pow(10,digitLength(b)-digitLength(a)))}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}!function(a,b){function c(a){var b=a.length,c=ia.type(a);return!ia.isWindow(a)&&(!(1!==a.nodeType||!b)||("array"===c||"function"!==c&&(0===b||"number"==typeof b&&b>0&&b-1 in a)))}function d(a){var b=xa[a]={};return ia.each(a.match(ka)||[],function(a,c){b[c]=!0}),b}function e(a,c,d,e){if(ia.acceptData(a)){var f,g,h=ia.expando,i="string"==typeof c,j=a.nodeType,k=j?ia.cache:a,l=j?a[h]:a[h]&&h;if(l&&k[l]&&(e||k[l].data)||!i||d!==b)return l||(j?a[h]=l=_.pop()||ia.guid++:l=h),k[l]||(k[l]={},j||(k[l].toJSON=ia.noop)),"object"!=typeof c&&"function"!=typeof c||(e?k[l]=ia.extend(k[l],c):k[l].data=ia.extend(k[l].data,c)),f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[ia.camelCase(c)]=d),i?(g=f[c],null==g&&(g=f[ia.camelCase(c)])):g=f,g}}function f(a,b,c){if(ia.acceptData(a)){var d,e,f,g=a.nodeType,i=g?ia.cache:a,j=g?a[ia.expando]:ia.expando;if(i[j]){if(b&&(f=c?i[j]:i[j].data)){ia.isArray(b)?b=b.concat(ia.map(b,ia.camelCase)):b in f?b=[b]:(b=ia.camelCase(b),b=b in f?[b]:b.split(" "));for(d=0,e=b.length;d=0===c})}function m(a){var b=Ua.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function n(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function o(a){var b=a.getAttributeNode("type");return a.type=(b&&b.specified)+"/"+a.type,a}function p(a){var b=eb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function q(a,b){for(var c,d=0;null!=(c=a[d]);d++)ia._data(c,"globalEval",!b||ia._data(b[d],"globalEval"))}function r(a,b){if(1===b.nodeType&&ia.hasData(a)){var c,d,e,f=ia._data(a),g=ia._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d").css("cssText","display:block !important")).appendTo(b.documentElement),b=(jb[0].contentWindow||jb[0].contentDocument).document,b.write(""),b.close(),c=C(a,b),jb.detach()),ub[a]=c),c}function C(a,b){var c=ia(b.createElement(a)).appendTo(b.body),d=ia.css(c[0],"display");return c.remove(),d}function D(a,b,c,d){var e;if(ia.isArray(b))ia.each(b,function(b,e){c||Ab.test(a)?d(a,e):D(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==ia.type(b))d(a,b);else for(e in b)D(a+"["+e+"]",b[e],c,d)}function E(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(ka)||[];if(ia.isFunction(c))for(;d=f[e++];)"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function F(a,b,c,d){function e(h){var i;return f[h]=!0,ia.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||g||f[j]?g?!(i=j):void 0:(b.dataTypes.unshift(j),e(j),!1)}),i}var f={},g=a===Rb;return e(b.dataTypes[0])||!f["*"]&&e("*")}function G(a,c){var d,e,f=ia.ajaxSettings.flatOptions||{};for(e in c)c[e]!==b&&((f[e]?a:d||(d={}))[e]=c[e]);return d&&ia.extend(!0,a,d),a}function H(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(h in k)h in d&&(c[k[h]]=d[h]);for(;"*"===j[0];)j.shift(),f===b&&(f=a.mimeType||c.getResponseHeader("Content-Type"));if(f)for(h in i)if(i[h]&&i[h].test(f)){j.unshift(h);break}if(j[0]in d)g=j[0];else{for(h in d){if(!j[0]||a.converters[h+" "+j[0]]){g=h;break}e||(e=h)}g=g||e}if(g)return g!==j[0]&&j.unshift(g),d[g]}function I(a,b){var c,d,e,f,g={},h=0,i=a.dataTypes.slice(),j=i[0];if(a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i[1])for(e in a.converters)g[e.toLowerCase()]=a.converters[e];for(;d=i[++h];)if("*"!==d){if("*"!==j&&j!==d){if(e=g[j+" "+d]||g["* "+d],!e)for(c in g)if(f=c.split(" "),f[1]===d&&(e=g[j+" "+f[0]]||g["* "+f[0]])){e===!0?e=g[c]:g[c]!==!0&&(d=f[0],i.splice(h--,0,d));break}if(e!==!0)if(e&&a["throws"])b=e(b);else try{b=e(b)}catch(k){return{state:"parsererror",error:e?k:"No conversion from "+j+" to "+d}}}j=d}return{state:"success",data:b}}function J(){try{return new a.XMLHttpRequest}catch(b){}}function K(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function L(){return setTimeout(function(){$b=b}),$b=ia.now()}function M(a,b){ia.each(b,function(b,c){for(var d=(ec[b]||[]).concat(ec["*"]),e=0,f=d.length;e)[^>]*|#([\w-]*))$/,na=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,oa=/^[\],:{}\s]*$/,pa=/(?:^|:|,)(?:\s*\[)+/g,qa=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,ra=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,sa=/^-ms-/,ta=/-([\da-z])/gi,ua=function(a,b){return b.toUpperCase()},va=function(a){(W.addEventListener||"load"===a.type||"complete"===W.readyState)&&(wa(),ia.ready())},wa=function(){W.addEventListener?(W.removeEventListener("DOMContentLoaded",va,!1),a.removeEventListener("load",va,!1)):(W.detachEvent("onreadystatechange",va),a.detachEvent("onload",va))};ia.fn=ia.prototype={jquery:aa,constructor:ia,init:function(a,c,d){var e,f;if(!a)return this;if("string"==typeof a){if(e="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:ma.exec(a),!e||!e[1]&&c)return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a);if(e[1]){if(c=c instanceof ia?c[0]:c,ia.merge(this,ia.parseHTML(e[1],c&&c.nodeType?c.ownerDocument||c:W,!0)),na.test(e[1])&&ia.isPlainObject(c))for(e in c)ia.isFunction(this[e])?this[e](c[e]):this.attr(e,c[e]);return this}if(f=W.getElementById(e[2]),f&&f.parentNode){if(f.id!==e[2])return d.find(a);this.length=1,this[0]=f}return this.context=W,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):ia.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),ia.makeArray(a,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return da.call(this)},get:function(a){return null==a?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a){var b=ia.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return ia.each(this,a,b)},ready:function(a){return ia.ready.promise().done(a),this},slice:function(){return this.pushStack(da.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0||(T.resolveWith(W,[ia]),ia.fn.trigger&&ia(W).trigger("ready").off("ready"))}},isFunction:function(a){return"function"===ia.type(a)},isArray:Array.isArray||function(a){return"array"===ia.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return null==a?String(a):"object"==typeof a||"function"==typeof a?$[fa.call(a)]||"object":typeof a},isPlainObject:function(a){if(!a||"object"!==ia.type(a)||a.nodeType||ia.isWindow(a))return!1;try{if(a.constructor&&!ga.call(a,"constructor")&&!ga.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||ga.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||W;var d=na.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=ia.buildFragment([a],b,e),e&&ia(e).remove(),ia.merge([],d.childNodes))},parseJSON:function(b){return a.JSON&&a.JSON.parse?a.JSON.parse(b):null===b?b:"string"==typeof b&&(b=ia.trim(b),b&&oa.test(b.replace(qa,"@").replace(ra,"]").replace(pa,"")))?new Function("return "+b)():void ia.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||"string"!=typeof c)return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return d&&d.documentElement&&!d.getElementsByTagName("parsererror").length||ia.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&ia.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(sa,"ms-").replace(ta,ua)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,d){var e,f=0,g=a.length,h=c(a);if(d){if(h)for(;f-1;)j.splice(d,1),c&&(d<=g&&g--,d<=h&&h--)}),this},has:function(a){return a?ia.inArray(a,j)>-1:!(!j||!j.length)},empty:function(){return j=[],this},disable:function(){return j=k=e=b,this},disabled:function(){return!j},lock:function(){return k=b,e||m.disable(),this},locked:function(){return!k},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],!j||f&&!k||(c?k.push(b):l(b)),this},fire:function(){return m.fireWith(this,arguments),this},fired:function(){return!!f}};return m},ia.extend({Deferred:function(a){var b=[["resolve","done",ia.Callbacks("once memory"),"resolved"],["reject","fail",ia.Callbacks("once memory"),"rejected"],["notify","progress",ia.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return ia.Deferred(function(c){ia.each(b,function(b,f){var g=f[0],h=ia.isFunction(a[b])&&a[b];e[f[1]](function(){var a=h&&h.apply(this,arguments);a&&ia.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[g+"With"](this===d?c.promise():this,h?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?ia.extend(a,d):d}},e={};return d.pipe=d.then,ia.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b,c,d,e=0,f=da.call(arguments),g=f.length,h=1!==g||a&&ia.isFunction(a.promise)?g:0,i=1===h?a:ia.Deferred(),j=function(a,c,d){return function(e){c[a]=this,d[a]=arguments.length>1?da.call(arguments):e,d===b?i.notifyWith(c,d):--h||i.resolveWith(c,d)}};if(g>1)for(b=new Array(g),c=new Array(g),d=new Array(g);e
a",c=l.getElementsByTagName("*"),d=l.getElementsByTagName("a")[0],!c||!d||!c.length)return{};f=W.createElement("select"),h=f.appendChild(W.createElement("option")),e=l.getElementsByTagName("input")[0],d.style.cssText="top:1px;float:left;opacity:.5",b={getSetAttribute:"t"!==l.className,leadingWhitespace:3===l.firstChild.nodeType,tbody:!l.getElementsByTagName("tbody").length,htmlSerialize:!!l.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:"/a"===d.getAttribute("href"),opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:!!e.value,optSelected:h.selected,enctype:!!W.createElement("form").enctype,html5Clone:"<:nav>"!==W.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===W.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},e.checked=!0,b.noCloneChecked=e.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!h.disabled;try{delete l.test}catch(m){b.deleteExpando=!1}e=W.createElement("input"),e.setAttribute("value",""),b.input=""===e.getAttribute("value"),e.value="t",e.setAttribute("type","radio"),b.radioValue="t"===e.value,e.setAttribute("checked","t"),e.setAttribute("name","t"),g=W.createDocumentFragment(),g.appendChild(e),b.appendChecked=e.checked,b.checkClone=g.cloneNode(!0).cloneNode(!0).lastChild.checked,l.attachEvent&&(l.attachEvent("onclick",function(){b.noCloneEvent=!1}),l.cloneNode(!0).click());for(k in{submit:!0,change:!0,focusin:!0})l.setAttribute(i="on"+k,"t"),b[k+"Bubbles"]=i in a||l.attributes[i].expando===!1;return l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",b.clearCloneStyle="content-box"===l.style.backgroundClip,ia(function(){var c,d,e,f="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",g=W.getElementsByTagName("body")[0];g&&(c=W.createElement("div"),c.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",g.appendChild(c).appendChild(l),l.innerHTML="
t
",e=l.getElementsByTagName("td"),e[0].style.cssText="padding:0;margin:0;border:0;display:none",j=0===e[0].offsetHeight,e[0].style.display="",e[1].style.display="none",b.reliableHiddenOffsets=j&&0===e[0].offsetHeight,l.innerHTML="",l.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=4===l.offsetWidth,b.doesNotIncludeMarginInBodyOffset=1!==g.offsetTop,a.getComputedStyle&&(b.pixelPosition="1%"!==(a.getComputedStyle(l,null)||{}).top,b.boxSizingReliable="4px"===(a.getComputedStyle(l,null)||{width:"4px"}).width,d=l.appendChild(W.createElement("div")),d.style.cssText=l.style.cssText=f,d.style.marginRight=d.style.width="0",l.style.width="1px",b.reliableMarginRight=!parseFloat((a.getComputedStyle(d,null)||{}).marginRight)),typeof l.style.zoom!==V&&(l.innerHTML="",l.style.cssText=f+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=3===l.offsetWidth,l.style.display="block",l.innerHTML="
",l.firstChild.style.width="5px",b.shrinkWrapBlocks=3!==l.offsetWidth,b.inlineBlockNeedsLayout&&(g.style.zoom=1)),g.removeChild(c),c=l=e=d=null)}),c=f=g=h=d=e=null,b}();var ya=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,za=/([A-Z])/g;ia.extend({cache:{},expando:"jQuery"+(aa+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?ia.cache[a[ia.expando]]:a[ia.expando],!!a&&!h(a)},data:function(a,b,c){return e(a,b,c)},removeData:function(a,b){return f(a,b)},_data:function(a,b,c){return e(a,b,c,!0)},_removeData:function(a,b){return f(a,b,!0)},acceptData:function(a){if(a.nodeType&&1!==a.nodeType&&9!==a.nodeType)return!1;var b=a.nodeName&&ia.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),ia.fn.extend({data:function(a,c){var d,e,f=this[0],h=0,i=null;if(a===b){if(this.length&&(i=ia.data(f),1===f.nodeType&&!ia._data(f,"parsedAttrs"))){for(d=f.attributes;h1,null,!0)},removeData:function(a){return this.each(function(){ia.removeData(this,a)})}}),ia.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=ia._data(a,b),c&&(!d||ia.isArray(c)?d=ia._data(a,b,ia.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=ia.queue(a,b),d=c.length,e=c.shift(),f=ia._queueHooks(a,b),g=function(){ia.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),f.cur=e,e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return ia._data(a,c)||ia._data(a,c,{empty:ia.Callbacks("once memory").add(function(){ia._removeData(a,b+"queue"),ia._removeData(a,c)})})}}),ia.fn.extend({queue:function(a,c){var d=2;return"string"!=typeof a&&(c=a,a="fx",d--),arguments.length1)},removeAttr:function(a){return this.each(function(){ia.removeAttr(this,a)})},prop:function(a,b){return ia.access(this,ia.prop,a,b,arguments.length>1)},removeProp:function(a){return a=ia.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g=0,h=this.length,i="string"==typeof a&&a;if(ia.isFunction(a))return this.each(function(b){ia(this).addClass(a.call(this,b,this.className))});if(i)for(b=(a||"").match(ka)||[];g=0;)d=d.replace(" "+e+" "," ");c.className=a?ia.trim(d):""}return this},toggleClass:function(a,b){var c=typeof a,d="boolean"==typeof b;return ia.isFunction(a)?this.each(function(c){ia(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if("string"===c)for(var e,f=0,g=ia(this),h=b,i=a.match(ka)||[];e=i[f++];)h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e);else c!==V&&"boolean"!==c||(this.className&&ia._data(this,"__className__",this.className),this.className=this.className||a===!1?"":ia._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;c=0)return!0;return!1},val:function(a){var c,d,e,f=this[0];{if(arguments.length)return e=ia.isFunction(a),this.each(function(c){var f,g=ia(this);1===this.nodeType&&(f=e?a.call(this,c,g.val()):a,null==f?f="":"number"==typeof f?f+="":ia.isArray(f)&&(f=ia.map(f,function(a){return null==a?"":a+""})),d=ia.valHooks[this.type]||ia.valHooks[this.nodeName.toLowerCase()],d&&"set"in d&&d.set(this,f,"value")!==b||(this.value=f))});if(f)return d=ia.valHooks[f.type]||ia.valHooks[f.nodeName.toLowerCase()],d&&"get"in d&&(c=d.get(f,"value"))!==b?c:(c=f.value,"string"==typeof c?c.replace(Da,""):null==c?"":c)}}}),ia.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||e<0,g=f?null:[],h=f?e+1:d.length,i=e<0?h:f?e:0;i=0}),c.length||(a.selectedIndex=-1),c}}},attr:function(a,c,d){var e,f,g,h=a.nodeType;if(a&&3!==h&&8!==h&&2!==h)return typeof a.getAttribute===V?ia.prop(a,c,d):(f=1!==h||!ia.isXMLDoc(a),f&&(c=c.toLowerCase(),e=ia.attrHooks[c]||(Ga.test(c)?Ba:Aa)),d===b?e&&f&&"get"in e&&null!==(g=e.get(a,c))?g:(typeof a.getAttribute!==V&&(g=a.getAttribute(c)),null==g?b:g):null!==d?e&&f&&"set"in e&&(g=e.set(a,d,c))!==b?g:(a.setAttribute(c,d+""),d):void ia.removeAttr(a,c))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(ka);if(f&&1===a.nodeType)for(;c=f[e++];)d=ia.propFix[c]||c,Ga.test(c)?!Ia&&Ha.test(c)?a[ia.camelCase("default-"+c)]=a[d]=!1:a[d]=!1:ia.attr(a,c,""),a.removeAttribute(Ia?c:d)},attrHooks:{type:{set:function(a,b){if(!ia.support.radioValue&&"radio"===b&&ia.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;if(a&&3!==h&&8!==h&&2!==h)return g=1!==h||!ia.isXMLDoc(a),g&&(c=ia.propFix[c]||c,f=ia.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&null!==(e=f.get(a,c))?e:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):Ea.test(a.nodeName)||Fa.test(a.nodeName)&&a.href?0:b}}}}),Ba={get:function(a,c){var d=ia.prop(a,c),e="boolean"==typeof d&&a.getAttribute(c),f="boolean"==typeof d?Ja&&Ia?null!=e:Ha.test(c)?a[ia.camelCase("default-"+c)]:!!e:a.getAttributeNode(c);return f&&f.value!==!1?c.toLowerCase():b},set:function(a,b,c){return b===!1?ia.removeAttr(a,c):Ja&&Ia||!Ha.test(c)?a.setAttribute(!Ia&&ia.propFix[c]||c,c):a[ia.camelCase("default-"+c)]=a[c]=!0,c}},Ja&&Ia||(ia.attrHooks.value={get:function(a,c){var d=a.getAttributeNode(c);return ia.nodeName(a,"input")?a.defaultValue:d&&d.specified?d.value:b},set:function(a,b,c){return ia.nodeName(a,"input")?void(a.defaultValue=b):Aa&&Aa.set(a,b,c)}}),Ia||(Aa=ia.valHooks.button={get:function(a,c){var d=a.getAttributeNode(c);return d&&("id"===c||"name"===c||"coords"===c?""!==d.value:d.specified)?d.value:b},set:function(a,c,d){var e=a.getAttributeNode(d);return e||a.setAttributeNode(e=a.ownerDocument.createAttribute(d)),e.value=c+="","value"===d||c===a.getAttribute(d)?c:b}},ia.attrHooks.contenteditable={get:Aa.get,set:function(a,b,c){Aa.set(a,""!==b&&b,c)}},ia.each(["width","height"],function(a,b){ia.attrHooks[b]=ia.extend(ia.attrHooks[b],{set:function(a,c){if(""===c)return a.setAttribute(b,"auto"),c}})})),ia.support.hrefNormalized||(ia.each(["href","src","width","height"],function(a,c){ia.attrHooks[c]=ia.extend(ia.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return null==d?b:d}})}),ia.each(["href","src"],function(a,b){ia.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}})),ia.support.style||(ia.attrHooks.style={get:function(a){return a.style.cssText||b},set:function(a,b){return a.style.cssText=b+""}}),ia.support.optSelected||(ia.propHooks.selected=ia.extend(ia.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),ia.support.enctype||(ia.propFix.enctype="encoding"),ia.support.checkOn||ia.each(["radio","checkbox"],function(){ia.valHooks[this]={get:function(a){return null===a.getAttribute("value")?"on":a.value}}}),ia.each(["radio","checkbox"],function(){ia.valHooks[this]=ia.extend(ia.valHooks[this],{set:function(a,b){if(ia.isArray(b))return a.checked=ia.inArray(ia(a).val(),b)>=0}})});var Ka=/^(?:input|select|textarea)$/i,La=/^key/,Ma=/^(?:mouse|contextmenu)|click/,Na=/^(?:focusinfocus|focusoutblur)$/,Oa=/^([^.]*)(?:\.(.+)|)$/;ia.event={global:{},add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=ia._data(a);if(r){for(d.handler&&(j=d,d=j.handler,f=j.selector),d.guid||(d.guid=ia.guid++),(h=r.events)||(h=r.events={}),(l=r.handle)||(l=r.handle=function(a){return typeof ia===V||a&&ia.event.triggered===a.type?b:ia.event.dispatch.apply(l.elem,arguments)},l.elem=a),c=(c||"").match(ka)||[""],i=c.length;i--;)g=Oa.exec(c[i])||[],o=q=g[1],p=(g[2]||"").split(".").sort(),k=ia.event.special[o]||{},o=(f?k.delegateType:k.bindType)||o,k=ia.event.special[o]||{},m=ia.extend({type:o,origType:q,data:e,handler:d,guid:d.guid,selector:f,needsContext:f&&ia.expr.match.needsContext.test(f),namespace:p.join(".")},j),(n=h[o])||(n=h[o]=[],n.delegateCount=0,k.setup&&k.setup.call(a,e,p,l)!==!1||(a.addEventListener?a.addEventListener(o,l,!1):a.attachEvent&&a.attachEvent("on"+o,l))),k.add&&(k.add.call(a,m),m.handler.guid||(m.handler.guid=d.guid)),f?n.splice(n.delegateCount++,0,m):n.push(m),ia.event.global[o]=!0;a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=ia.hasData(a)&&ia._data(a);if(q&&(k=q.events)){for(b=(b||"").match(ka)||[""],j=b.length;j--;)if(h=Oa.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){for(l=ia.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=k[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;f--;)g=m[f],!e&&p!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||ia.removeEvent(a,n,q.handle),delete k[n])}else for(n in k)ia.event.remove(a,n+b[j],c,d,!0);ia.isEmptyObject(k)&&(delete q.handle,ia._removeData(a,"events"))}},trigger:function(c,d,e,f){var g,h,i,j,k,l,m,n=[e||W],o=ga.call(c,"type")?c.type:c,p=ga.call(c,"namespace")?c.namespace.split("."):[];if(i=l=e=e||W,3!==e.nodeType&&8!==e.nodeType&&!Na.test(o+ia.event.triggered)&&(o.indexOf(".")>=0&&(p=o.split("."),o=p.shift(),p.sort()),h=o.indexOf(":")<0&&"on"+o,c=c[ia.expando]?c:new ia.Event(o,"object"==typeof c&&c),c.isTrigger=!0,c.namespace=p.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,c.result=b,c.target||(c.target=e),d=null==d?[c]:ia.makeArray(d,[c]),k=ia.event.special[o]||{},f||!k.trigger||k.trigger.apply(e,d)!==!1)){if(!f&&!k.noBubble&&!ia.isWindow(e)){for(j=k.delegateType||o,Na.test(j+o)||(i=i.parentNode);i;i=i.parentNode)n.push(i),l=i;l===(e.ownerDocument||W)&&n.push(l.defaultView||l.parentWindow||a)}for(m=0;(i=n[m++])&&!c.isPropagationStopped();)c.type=m>1?j:k.bindType||o,g=(ia._data(i,"events")||{})[c.type]&&ia._data(i,"handle"),g&&g.apply(i,d),g=h&&i[h],g&&ia.acceptData(i)&&g.apply&&g.apply(i,d)===!1&&c.preventDefault();if(c.type=o,!f&&!c.isDefaultPrevented()&&(!k._default||k._default.apply(e.ownerDocument,d)===!1)&&("click"!==o||!ia.nodeName(e,"a"))&&ia.acceptData(e)&&h&&e[o]&&!ia.isWindow(e)){l=e[h],l&&(e[h]=null),ia.event.triggered=o;try{e[o]()}catch(q){}ia.event.triggered=b,l&&(e[h]=l)}return c.result}},dispatch:function(a){a=ia.event.fix(a);var c,d,e,f,g,h=[],i=da.call(arguments),j=(ia._data(this,"events")||{})[a.type]||[],k=ia.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){for(h=ia.event.handlers.call(this,a,j),c=0;(f=h[c++])&&!a.isPropagationStopped();)for(a.currentTarget=f.elem,g=0;(e=f.handlers[g++])&&!a.isImmediatePropagationStopped();)if(!a.namespace_re||a.namespace_re.test(e.namespace)){a.handleObj=e,a.data=e.data;var l=(ia.event.special[e.origType]||{}).handle||e.handler;l.apply&&(d=l.apply(f.elem,i)),d!==b&&(a.result=d)===!1&&(a.preventDefault(),a.stopPropagation())}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,c){var d,e,f,g,h=[],i=c.delegateCount,j=a.target;if(i&&j.nodeType&&(!a.button||"click"!==a.type))for(;j!=this;j=j.parentNode||this)if(1===j.nodeType&&(j.disabled!==!0||"click"!==a.type)){for(f=[],g=0;g=0:ia.find(d,this,null,[j]).length),f[d]&&f.push(e);f.length&&h.push({elem:j,handlers:f})}return iy.cacheLength&&delete a[b.shift()],a[c]=d}}function e(a){return a[N]=!0,a}function f(a){var b=F.createElement("div");try{return a(b)}catch(c){return!1}finally{b=null}}function g(a,b,c,d){var e,f,g,h,i,j,k,n,o,p;if((b?b.ownerDocument||b:O)!==F&&E(b),b=b||F,c=c||[],!a||"string"!=typeof a)return c;if(1!==(h=b.nodeType)&&9!==h)return[];if(!H&&!d){if(e=pa.exec(a))if(g=e[1]){if(9===h){if(f=b.getElementById(g),!f||!f.parentNode)return c;if(f.id===g)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(g))&&L(b,f)&&f.id===g)return c.push(f),c}else{if(e[2])return Z.apply(c,$.call(b.getElementsByTagName(a),0)),c;if((g=e[3])&&P.getByClassName&&b.getElementsByClassName)return Z.apply(c,$.call(b.getElementsByClassName(g),0)),c}if(P.qsa&&!I.test(a)){if(k=!0,n=N,o=b,p=9===h&&a,1===h&&"object"!==b.nodeName.toLowerCase()){for(j=l(a),(k=b.getAttribute("id"))?n=k.replace(sa,"\\$&"):b.setAttribute("id",n),n="[id='"+n+"'] ",i=j.length;i--;)j[i]=n+m(j[i]);o=na.test(a)&&b.parentNode||b,p=j.join(",")}if(p)try{return Z.apply(c,$.call(o.querySelectorAll(p),0)),c}catch(q){}finally{k||b.removeAttribute("id")}}}return u(a.replace(ga,"$1"),b,c,d)}function h(a,b){var c=b&&a,d=c&&(~b.sourceIndex||W)-(~a.sourceIndex||W);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function i(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function j(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function k(a){return e(function(b){return b=+b,e(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function l(a,b){var c,d,e,f,h,i,j,k=T[a+" "];if(k)return b?0:k.slice(0);for(h=a,i=[],j=y.preFilter;h;){c&&!(d=ha.exec(h))||(d&&(h=h.slice(d[0].length)||h),i.push(e=[])),c=!1,(d=ja.exec(h))&&(c=d.shift(),e.push({value:c,type:d[0].replace(ga," ")}),h=h.slice(c.length));for(f in y.filter)!(d=ma[f].exec(h))||j[f]&&!(d=j[f](d))||(c=d.shift(),e.push({value:c,type:f,matches:d}),h=h.slice(c.length));if(!c)break}return b?h.length:h?g.error(a):T(a,i).slice(0)}function m(a){for(var b=0,c=a.length,d="";b1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function p(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;h-1&&(e[j]=!(g[j]=l))}}else s=p(s===g?s.splice(o,s.length):s),f?f(null,g,s,i):Z.apply(g,s)})}function r(a){for(var b,c,d,e=a.length,f=y.relative[a[0].type],g=f||y.relative[" "],h=f?1:0,i=n(function(a){return a===b},g,!0),j=n(function(a){return _.call(b,a)>-1},g,!0),k=[function(a,c,d){return!f&&(d||c!==D)||((b=c).nodeType?i(a,c,d):j(a,c,d))}];h1&&o(k),h>1&&m(a.slice(0,h-1)).replace(ga,"$1"),c,h0,f=a.length>0,h=function(e,h,i,j,k){var l,m,n,o=[],q=0,r="0",s=e&&[],t=null!=k,u=D,v=e||f&&y.find.TAG("*",k&&h.parentNode||h),w=Q+=null==u?1:Math.random()||.1;for(t&&(D=h!==F&&h,x=c);null!=(l=v[r]);r++){if(f&&l){for(m=0;n=a[m++];)if(n(l,h,i)){j.push(l);break}t&&(Q=w,x=++c)}d&&((l=!n&&l)&&q--,e&&s.push(l))}if(q+=r,d&&r!==q){for(m=0;n=b[m++];)n(s,o,h,i);if(e){if(q>0)for(;r--;)s[r]||o[r]||(o[r]=Y.call(j));o=p(o)}Z.apply(j,o),t&&!e&&o.length>0&&q+b.length>1&&g.uniqueSort(j)}return t&&(Q=w,D=u),s};return d?e(h):h}function t(a,b,c){for(var d=0,e=b.length;d2&&"ID"===(g=f[0]).type&&9===b.nodeType&&!H&&y.relative[f[1].type]){if(b=y.find.ID(g.matches[0].replace(ua,va),b)[0],!b)return c;a=a.slice(f.shift().value.length)}for(e=ma.needsContext.test(a)?0:f.length;e--&&(g=f[e],!y.relative[h=g.type]);)if((i=y.find[h])&&(d=i(g.matches[0].replace(ua,va),na.test(f[0].type)&&b.parentNode||b))){if(f.splice(e,1),a=d.length&&m(f),!a)return Z.apply(c,$.call(d,0)),c;break}}return B(a,j)(d,b,H,c,na.test(a)),c}function v(){}var w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N="sizzle"+-new Date,O=a.document,P={},Q=0,R=0,S=d(),T=d(),U=d(),V=typeof b,W=1<<31,X=[],Y=X.pop,Z=X.push,$=X.slice,_=X.indexOf||function(a){for(var b=0,c=this.length;b+~])"+aa+"*"),ka=new RegExp(fa),la=new RegExp("^"+ca+"$"),ma={ID:new RegExp("^#("+ba+")"),CLASS:new RegExp("^\\.("+ba+")"),NAME:new RegExp("^\\[name=['\"]?("+ba+")['\"]?\\]"),TAG:new RegExp("^("+ba.replace("w","w*")+")"),ATTR:new RegExp("^"+ea),PSEUDO:new RegExp("^"+fa),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+aa+"*(even|odd|(([+-]|)(\\d*)n|)"+aa+"*(?:([+-]|)"+aa+"*(\\d+)|))"+aa+"*\\)|)","i"),needsContext:new RegExp("^"+aa+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+aa+"*((?:-\\d)?\\d*)"+aa+"*\\)|)(?=[^-]|$)","i")},na=/[\x20\t\r\n\f]*[+~]/,oa=/^[^{]+\{\s*\[native code/,pa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,qa=/^(?:input|select|textarea|button)$/i,ra=/^h\d$/i,sa=/'|\\/g,ta=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,ua=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,va=function(a,b){var c="0x"+b-65536;return c!==c?b:c<0?String.fromCharCode(c+65536):String.fromCharCode(c>>10|55296,1023&c|56320)};try{$.call(O.documentElement.childNodes,0)[0].nodeType}catch(wa){$=function(a){for(var b,c=[];b=this[a++];)c.push(b);return c}}A=g.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},E=g.setDocument=function(a){var d=a?a.ownerDocument||a:O;return d!==F&&9===d.nodeType&&d.documentElement?(F=d,G=d.documentElement,H=A(d),P.tagNameNoComments=f(function(a){return a.appendChild(d.createComment("")),!a.getElementsByTagName("*").length}),P.attributes=f(function(a){a.innerHTML="";var b=typeof a.lastChild.getAttribute("multiple");return"boolean"!==b&&"string"!==b}),P.getByClassName=f(function(a){return a.innerHTML="",!(!a.getElementsByClassName||!a.getElementsByClassName("e").length)&&(a.lastChild.className="e",2===a.getElementsByClassName("e").length)}),P.getByName=f(function(a){a.id=N+0,a.innerHTML="
",G.insertBefore(a,G.firstChild);var b=d.getElementsByName&&d.getElementsByName(N).length===2+d.getElementsByName(N+0).length;return P.getIdNotName=!d.getElementById(N),G.removeChild(a),b}),y.attrHandle=f(function(a){return a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!==V&&"#"===a.firstChild.getAttribute("href")})?{}:{href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}},P.getIdNotName?(y.find.ID=function(a,b){if(typeof b.getElementById!==V&&!H){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},y.filter.ID=function(a){var b=a.replace(ua,va);return function(a){return a.getAttribute("id")===b}}):(y.find.ID=function(a,c){if(typeof c.getElementById!==V&&!H){var d=c.getElementById(a);return d?d.id===a||typeof d.getAttributeNode!==V&&d.getAttributeNode("id").value===a?[d]:b:[]}},y.filter.ID=function(a){var b=a.replace(ua,va);return function(a){var c=typeof a.getAttributeNode!==V&&a.getAttributeNode("id");return c&&c.value===b}}),y.find.TAG=P.tagNameNoComments?function(a,b){if(typeof b.getElementsByTagName!==V)return b.getElementsByTagName(a)}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},y.find.NAME=P.getByName&&function(a,b){if(typeof b.getElementsByName!==V)return b.getElementsByName(name)},y.find.CLASS=P.getByClassName&&function(a,b){if(typeof b.getElementsByClassName!==V&&!H)return b.getElementsByClassName(a)},J=[],I=[":focus"],(P.qsa=c(d.querySelectorAll))&&(f(function(a){a.innerHTML="",a.querySelectorAll("[selected]").length||I.push("\\["+aa+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||I.push(":checked")}),f(function(a){a.innerHTML="",a.querySelectorAll("[i^='']").length&&I.push("[*^$]="+aa+"*(?:\"\"|'')"),a.querySelectorAll(":enabled").length||I.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),I.push(",.*:")})),(P.matchesSelector=c(K=G.matchesSelector||G.mozMatchesSelector||G.webkitMatchesSelector||G.oMatchesSelector||G.msMatchesSelector))&&f(function(a){P.disconnectedMatch=K.call(a,"div"),K.call(a,"[s!='']:x"),J.push("!=",fa)}),I=new RegExp(I.join("|")),J=new RegExp(J.join("|")),L=c(G.contains)||G.compareDocumentPosition?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},M=G.compareDocumentPosition?function(a,b){var c;return a===b?(C=!0,0):(c=b.compareDocumentPosition&&a.compareDocumentPosition&&a.compareDocumentPosition(b))?1&c||a.parentNode&&11===a.parentNode.nodeType?a===d||L(O,a)?-1:b===d||L(O,b)?1:0:4&c?-1:1:a.compareDocumentPosition?-1:1}:function(a,b){var c,e=0,f=a.parentNode,g=b.parentNode,i=[a],j=[b];if(a===b)return C=!0,0;if(!f||!g)return a===d?-1:b===d?1:f?-1:g?1:0;if(f===g)return h(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[e]===j[e];)e++;return e?h(i[e],j[e]):i[e]===O?-1:j[e]===O?1:0},C=!1,[0,0].sort(M),P.detectDuplicates=C,F):F},g.matches=function(a,b){return g(a,null,null,b)},g.matchesSelector=function(a,b){if((a.ownerDocument||a)!==F&&E(a),b=b.replace(ta,"='$1']"),P.matchesSelector&&!H&&(!J||!J.test(b))&&!I.test(b))try{var c=K.call(a,b);if(c||P.disconnectedMatch||a.document&&11!==a.document.nodeType)return c}catch(d){}return g(b,F,null,[a]).length>0},g.contains=function(a,b){return(a.ownerDocument||a)!==F&&E(a),L(a,b)},g.attr=function(a,b){var c;return(a.ownerDocument||a)!==F&&E(a),H||(b=b.toLowerCase()),(c=y.attrHandle[b])?c(a):H||P.attributes?a.getAttribute(b):((c=a.getAttributeNode(b))||a.getAttribute(b))&&a[b]===!0?b:c&&c.specified?c.value:null},g.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},g.uniqueSort=function(a){var b,c=[],d=1,e=0;if(C=!P.detectDuplicates,a.sort(M),C){for(;b=a[d];d++)b===a[d-1]&&(e=c.push(d));for(;e--;)a.splice(c[e],1)}return a},z=g.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=z(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d];d++)c+=z(b);return c},y=g.selectors={cacheLength:50,createPseudo:e,match:ma,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ua,va),a[3]=(a[4]||a[5]||"").replace(ua,va),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||g.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&g.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return ma.CHILD.test(a[0])?null:(a[4]?a[2]=a[4]:c&&ka.test(c)&&(b=l(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){return"*"===a?function(){return!0}:(a=a.replace(ua,va).toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=S[a+" "];return b||(b=new RegExp("(^|"+aa+")"+a+"("+aa+"|$)"))&&S(a,function(a){return b.test(a.className||typeof a.getAttribute!==V&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=g.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[N]||(q[N]={}),j=k[a]||[],n=j[0]===Q&&j[1],m=j[0]===Q&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[Q,n,m];break}}else if(s&&(j=(b[N]||(b[N]={}))[a])&&j[0]===Q)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[N]||(l[N]={}))[a]=[Q,m]),l!==b)););return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,d=y.pseudos[a]||y.setFilters[a.toLowerCase()]||g.error("unsupported pseudo: "+a);return d[N]?d(b):d.length>1?(c=[a,a,"",b],y.setFilters.hasOwnProperty(a.toLowerCase())?e(function(a,c){for(var e,f=d(a,b),g=f.length;g--;)e=_.call(a,f[g]),a[e]=!(c[e]=f[g])}):function(a){return d(a,0,c)}):d}},pseudos:{not:e(function(a){var b=[],c=[],d=B(a.replace(ga,"$1"));return d[N]?e(function(a,b,c,e){for(var f,g=d(a,null,e,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:e(function(a){return function(b){return g(a,b).length>0}}),contains:e(function(a){return function(b){return(b.textContent||b.innerText||z(b)).indexOf(a)>-1}}),lang:e(function(a){return la.test(a||"")||g.error("unsupported lang: "+a),a=a.replace(ua,va).toLowerCase(),function(b){var c;do if(c=H?b.getAttribute("xml:lang")||b.getAttribute("lang"):b.lang)return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===G},focus:function(a){return a===F.activeElement&&(!F.hasFocus||F.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeName>"@"||3===a.nodeType||4===a.nodeType)return!1;return!0},parent:function(a){return!y.pseudos.empty(a)},header:function(a){return ra.test(a.nodeName)},input:function(a){return qa.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||b.toLowerCase()===a.type)},first:k(function(){return[0]}),last:k(function(a,b){return[b-1]}),eq:k(function(a,b,c){return[c<0?c+b:c]}),even:k(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:k(function(a,b,c){for(var d=c<0?c+b:c;++d1?ia.unique(c):c),c.selector=(this.selector?this.selector+" ":"")+a,c},has:function(a){var b,c=ia(a,this),d=c.length;return this.filter(function(){for(b=0;b=0:ia.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=Sa.test(a)||"string"!=typeof a?ia(a,b||this.context):0;d-1:ia.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}return this.pushStack(f.length>1?ia.unique(f):f)},index:function(a){return a?"string"==typeof a?ia.inArray(this[0],ia(a)):ia.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){var c="string"==typeof a?ia(a,b):ia.makeArray(a&&a.nodeType?[a]:a),d=ia.merge(this.get(),c);return this.pushStack(ia.unique(d))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}}),ia.fn.andSelf=ia.fn.addBack,ia.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return ia.dir(a,"parentNode")},parentsUntil:function(a,b,c){return ia.dir(a,"parentNode",c)},next:function(a){return k(a,"nextSibling")},prev:function(a){return k(a,"previousSibling")},nextAll:function(a){return ia.dir(a,"nextSibling")},prevAll:function(a){return ia.dir(a,"previousSibling")},nextUntil:function(a,b,c){return ia.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return ia.dir(a,"previousSibling",c)},siblings:function(a){return ia.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return ia.sibling(a.firstChild)},contents:function(a){return ia.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:ia.merge([],a.childNodes)}},function(a,b){ia.fn[a]=function(c,d){var e=ia.map(this,b,c);return Pa.test(a)||(d=c),d&&"string"==typeof d&&(e=ia.filter(d,e)),e=this.length>1&&!Ta[a]?ia.unique(e):e,this.length>1&&Qa.test(a)&&(e=e.reverse()),this.pushStack(e)}}),ia.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),1===b.length?ia.find.matchesSelector(b[0],a)?[b[0]]:[]:ia.find.matches(a,b)},dir:function(a,c,d){for(var e=[],f=a[c];f&&9!==f.nodeType&&(d===b||1!==f.nodeType||!ia(f).is(d));)1===f.nodeType&&e.push(f),f=f[c];return e},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}});var Ua="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Va=/ jQuery\d+="(?:null|\d+)"/g,Wa=new RegExp("<(?:"+Ua+")[\\s/>]","i"),Xa=/^\s+/,Ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Za=/<([\w:]+)/,$a=/\s*$/g,gb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:ia.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},hb=m(W),ib=hb.appendChild(W.createElement("div"));gb.optgroup=gb.option,gb.tbody=gb.tfoot=gb.colgroup=gb.caption=gb.thead,gb.th=gb.td,ia.fn.extend({text:function(a){return ia.access(this,function(a){return a===b?ia.text(this):this.empty().append((this[0]&&this[0].ownerDocument||W).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(ia.isFunction(a))return this.each(function(b){ia(this).wrapAll(a.call(this,b))});if(this[0]){var b=ia(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstChild&&1===a.firstChild.nodeType;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return ia.isFunction(a)?this.each(function(b){ia(this).wrapInner(a.call(this,b))}):this.each(function(){var b=ia(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=ia.isFunction(a);return this.each(function(c){ia(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){ia.nodeName(this,"body")||ia(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.insertBefore(a,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=0;null!=(c=this[d]);d++)(!a||ia.filter(a,[c]).length>0)&&(b||1!==c.nodeType||ia.cleanData(t(c)),c.parentNode&&(b&&ia.contains(c.ownerDocument,c)&&q(t(c,"script")),c.parentNode.removeChild(c)));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){for(1===a.nodeType&&ia.cleanData(t(a,!1));a.firstChild;)a.removeChild(a.firstChild);a.options&&ia.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return ia.clone(this,a,b)})},html:function(a){return ia.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return 1===c.nodeType?c.innerHTML.replace(Va,""):b;if("string"==typeof a&&!ab.test(a)&&(ia.support.htmlSerialize||!Wa.test(a))&&(ia.support.leadingWhitespace||!Xa.test(a))&&!gb[(Za.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ya,"<$1>");try{for(;d")?f=a.cloneNode(!0):(ib.innerHTML=a.outerHTML,ib.removeChild(f=ib.firstChild)),!(ia.support.noCloneEvent&&ia.support.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||ia.isXMLDoc(a)))for(d=t(f),h=t(a),g=0;null!=(e=h[g]);++g)d[g]&&s(e,d[g]);if(b)if(c)for(h=h||t(a),d=d||t(f),g=0;null!=(e=h[g]);g++)r(e,d[g]);else r(a,f);return d=t(f,"script"),d.length>0&&q(d,!i&&t(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,l=a.length,n=m(b),o=[],p=0;p")+k[2],e=k[0];e--;)h=h.lastChild;if(!ia.support.leadingWhitespace&&Xa.test(f)&&o.push(b.createTextNode(Xa.exec(f)[0])),!ia.support.tbody)for(f="table"!==i||$a.test(f)?""!==k[1]||$a.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;e--;)ia.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j);for(ia.merge(o,h.childNodes),h.textContent="";h.firstChild;)h.removeChild(h.firstChild);h=n.lastChild}else o.push(b.createTextNode(f));for(h&&n.removeChild(h),ia.support.appendChecked||ia.grep(t(o,"input"),u),p=0;f=o[p++];)if((!d||ia.inArray(f,d)===-1)&&(g=ia.contains(f.ownerDocument,f),h=t(n.appendChild(f),"script"),g&&q(h),c))for(e=0;f=h[e++];)db.test(f.type||"")&&c.push(f);return h=null,n},cleanData:function(a,b){for(var c,d,e,f,g=0,h=ia.expando,i=ia.cache,j=ia.support.deleteExpando,k=ia.event.special;null!=(c=a[g]);g++)if((b||ia.acceptData(c))&&(e=c[h],f=e&&i[e])){if(f.events)for(d in f.events)k[d]?ia.event.remove(c,d):ia.removeEvent(c,d,f.handle);i[e]&&(delete i[e],j?delete c[h]:typeof c.removeAttribute!==V?c.removeAttribute(h):c[h]=null,_.push(e))}}});var jb,kb,lb,mb=/alpha\([^)]*\)/i,nb=/opacity\s*=\s*([^)]*)/,ob=/^(top|right|bottom|left)$/,pb=/^(none|table(?!-c[ea]).+)/,qb=/^margin/,rb=new RegExp("^("+ja+")(.*)$","i"),sb=new RegExp("^("+ja+")(?!px)[a-z%]+$","i"),tb=new RegExp("^([+-])=("+ja+")","i"),ub={BODY:"block"},vb={position:"absolute",visibility:"hidden",display:"block"},wb={letterSpacing:0,fontWeight:400},xb=["Top","Right","Bottom","Left"],yb=["Webkit","O","Moz","ms"];ia.fn.extend({css:function(a,c){return ia.access(this,function(a,c,d){var e,f,g={},h=0;if(ia.isArray(c)){for(f=kb(a),e=c.length;h1)},show:function(){return x(this,!0)},hide:function(){return x(this)},toggle:function(a){var b="boolean"==typeof a;return this.each(function(){(b?a:w(this))?ia(this).show():ia(this).hide()})}}),ia.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=lb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":ia.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var f,g,h,i=ia.camelCase(c),j=a.style;if(c=ia.cssProps[i]||(ia.cssProps[i]=v(j,i)),h=ia.cssHooks[c]||ia.cssHooks[i],d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];if(g=typeof d,"string"===g&&(f=tb.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(ia.css(a,c)),g="number"),!(null==d||"number"===g&&isNaN(d)||("number"!==g||ia.cssNumber[i]||(d+="px"),ia.support.clearCloneStyle||""!==d||0!==c.indexOf("background")||(j[c]="inherit"),h&&"set"in h&&(d=h.set(a,d,e))===b)))try{j[c]=d}catch(k){}}},css:function(a,c,d,e){var f,g,h,i=ia.camelCase(c);return c=ia.cssProps[i]||(ia.cssProps[i]=v(a.style,i)),h=ia.cssHooks[c]||ia.cssHooks[i],h&&"get"in h&&(g=h.get(a,!0,d)),g===b&&(g=lb(a,c,e)),"normal"===g&&c in wb&&(g=wb[c]),""===d||d?(f=parseFloat(g),d===!0||ia.isNumeric(f)?f||0:g):g},swap:function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e}}),a.getComputedStyle?(kb=function(b){return a.getComputedStyle(b,null)},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h.getPropertyValue(c)||h[c]:b,j=a.style;return h&&(""!==i||ia.contains(a.ownerDocument,a)||(i=ia.style(a,c)),sb.test(i)&&qb.test(c)&&(e=j.width,f=j.minWidth,g=j.maxWidth,j.minWidth=j.maxWidth=j.width=i,i=h.width,j.width=e,j.minWidth=f,j.maxWidth=g)),i}):W.documentElement.currentStyle&&(kb=function(a){return a.currentStyle},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h[c]:b,j=a.style;return null==i&&j&&j[c]&&(i=j[c]),sb.test(i)&&!ob.test(c)&&(e=j.left,f=a.runtimeStyle,g=f&&f.left,g&&(f.left=a.currentStyle.left),j.left="fontSize"===c?"1em":i,i=j.pixelLeft+"px",j.left=e,g&&(f.left=g)),""===i?"auto":i}),ia.each(["height","width"],function(a,b){ia.cssHooks[b]={get:function(a,c,d){if(c)return 0===a.offsetWidth&&pb.test(ia.css(a,"display"))?ia.swap(a,vb,function(){return A(a,b,d)}):A(a,b,d)},set:function(a,c,d){var e=d&&kb(a);return y(a,c,d?z(a,b,d,ia.support.boxSizing&&"border-box"===ia.css(a,"boxSizing",!1,e),e):0)}}}),ia.support.opacity||(ia.cssHooks.opacity={get:function(a,b){return nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=ia.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===ia.trim(f.replace(mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=mb.test(f)?f.replace(mb,e):f+" "+e)}}),ia(function(){ia.support.reliableMarginRight||(ia.cssHooks.marginRight={get:function(a,b){if(b)return ia.swap(a,{display:"inline-block"},lb,[a,"marginRight"])}}),!ia.support.pixelPosition&&ia.fn.position&&ia.each(["top","left"],function(a,b){ia.cssHooks[b]={get:function(a,c){if(c)return c=lb(a,b),sb.test(c)?ia(a).position()[b]+"px":c}}})}),ia.expr&&ia.expr.filters&&(ia.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!ia.support.reliableHiddenOffsets&&"none"===(a.style&&a.style.display||ia.css(a,"display"))},ia.expr.filters.visible=function(a){return!ia.expr.filters.hidden(a)}),ia.each({margin:"",padding:"",border:"Width"},function(a,b){ia.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+xb[d]+b]=f[d]||f[d-2]||f[0];return e}},qb.test(a)||(ia.cssHooks[a+b].set=y)});var zb=/%20/g,Ab=/\[\]$/,Bb=/\r?\n/g,Cb=/^(?:submit|button|image|reset|file)$/i,Db=/^(?:input|select|textarea|keygen)/i;ia.fn.extend({serialize:function(){return ia.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=ia.prop(this,"elements");return a?ia.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!ia(this).is(":disabled")&&Db.test(this.nodeName)&&!Cb.test(a)&&(this.checked||!bb.test(a))}).map(function(a,b){var c=ia(this).val();return null==c?null:ia.isArray(c)?ia.map(c,function(a){return{name:b.name,value:a.replace(Bb,"\r\n")}}):{name:b.name,value:c.replace(Bb,"\r\n")}}).get()}}),ia.param=function(a,c){var d,e=[],f=function(a,b){b=ia.isFunction(b)?b():null==b?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(c===b&&(c=ia.ajaxSettings&&ia.ajaxSettings.traditional),ia.isArray(a)||a.jquery&&!ia.isPlainObject(a))ia.each(a,function(){f(this.name,this.value)});else for(d in a)D(d,a[d],c,f);return e.join("&").replace(zb,"+")},ia.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){ia.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),ia.fn.hover=function(a,b){return this.mouseenter(a).mouseleave(b||a)};var Eb,Fb,Gb=ia.now(),Hb=/\?/,Ib=/#.*$/,Jb=/([?&])_=[^&]*/,Kb=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Lb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mb=/^(?:GET|HEAD)$/,Nb=/^\/\//,Ob=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Pb=ia.fn.load,Qb={},Rb={},Sb="*/".concat("*");try{Fb=X.href}catch(Tb){Fb=W.createElement("a"),Fb.href="",Fb=Fb.href}Eb=Ob.exec(Fb.toLowerCase())||[],ia.fn.load=function(a,c,d){if("string"!=typeof a&&Pb)return Pb.apply(this,arguments);var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),ia.isFunction(c)?(d=c,c=b):c&&"object"==typeof c&&(g="POST"),h.length>0&&ia.ajax({url:a,type:g,dataType:"html",data:c}).done(function(a){f=arguments,h.html(e?ia("
").append(ia.parseHTML(a)).find(e):a)}).complete(d&&function(a,b){h.each(d,f||[a.responseText,b,a])}),this},ia.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){ia.fn[b]=function(a){return this.on(b,a)}}),ia.each(["get","post"],function(a,c){ia[c]=function(a,d,e,f){return ia.isFunction(d)&&(f=f||e,e=d,d=b),ia.ajax({url:a,type:c,dataType:f,data:d,success:e})}}),ia.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fb,type:"GET",isLocal:Lb.test(Eb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Sb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":ia.parseJSON,"text xml":ia.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?G(G(a,ia.ajaxSettings),b):G(ia.ajaxSettings,a)},ajaxPrefilter:E(Qb),ajaxTransport:E(Rb),ajax:function(a,c){function d(a,c,d,e){var f,l,s,t,v,x=c;2!==u&&(u=2,i&&clearTimeout(i),k=b,h=e||"",w.readyState=a>0?4:0,d&&(t=H(m,w,d)),a>=200&&a<300||304===a?(m.ifModified&&(v=w.getResponseHeader("Last-Modified"),v&&(ia.lastModified[g]=v),v=w.getResponseHeader("etag"),v&&(ia.etag[g]=v)),204===a?(f=!0,x="nocontent"):304===a?(f=!0,x="notmodified"):(f=I(m,t),x=f.state,l=f.data,s=f.error,f=!s)):(s=x,!a&&x||(x="error",a<0&&(a=0))),w.status=a,w.statusText=(c||x)+"",f?p.resolveWith(n,[l,x,w]):p.rejectWith(n,[w,x,s]),w.statusCode(r),r=b,j&&o.trigger(f?"ajaxSuccess":"ajaxError",[w,m,f?l:s]),q.fireWith(n,[w,x]),j&&(o.trigger("ajaxComplete",[w,m]),--ia.active||ia.event.trigger("ajaxStop")))}"object"==typeof a&&(c=a,a=b),c=c||{};var e,f,g,h,i,j,k,l,m=ia.ajaxSetup({},c),n=m.context||m,o=m.context&&(n.nodeType||n.jquery)?ia(n):ia.event,p=ia.Deferred(),q=ia.Callbacks("once memory"),r=m.statusCode||{},s={},t={},u=0,v="canceled",w={readyState:0,getResponseHeader:function(a){var b;if(2===u){if(!l)for(l={};b=Kb.exec(h);)l[b[1].toLowerCase()]=b[2];b=l[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===u?h:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return u||(a=t[c]=t[c]||a,s[a]=b),this},overrideMimeType:function(a){return u||(m.mimeType=a),this},statusCode:function(a){var b;if(a)if(u<2)for(b in a)r[b]=[r[b],a[b]];else w.always(a[w.status]);return this},abort:function(a){var b=a||v;return k&&k.abort(b),d(0,b),this}};if(p.promise(w).complete=q.add,w.success=w.done,w.error=w.fail,m.url=((a||m.url||Fb)+"").replace(Ib,"").replace(Nb,Eb[1]+"//"),m.type=c.method||c.type||m.method||m.type,m.dataTypes=ia.trim(m.dataType||"*").toLowerCase().match(ka)||[""],null==m.crossDomain&&(e=Ob.exec(m.url.toLowerCase()),m.crossDomain=!(!e||e[1]===Eb[1]&&e[2]===Eb[2]&&(e[3]||("http:"===e[1]?80:443))==(Eb[3]||("http:"===Eb[1]?80:443)))),m.data&&m.processData&&"string"!=typeof m.data&&(m.data=ia.param(m.data,m.traditional)),F(Qb,m,c,w),2===u)return w;j=m.global,j&&0===ia.active++&&ia.event.trigger("ajaxStart"),m.type=m.type.toUpperCase(),m.hasContent=!Mb.test(m.type),g=m.url,m.hasContent||(m.data&&(g=m.url+=(Hb.test(g)?"&":"?")+m.data,delete m.data),m.cache===!1&&(m.url=Jb.test(g)?g.replace(Jb,"$1_="+Gb++):g+(Hb.test(g)?"&":"?")+"_="+Gb++)),m.ifModified&&(ia.lastModified[g]&&w.setRequestHeader("If-Modified-Since",ia.lastModified[g]),ia.etag[g]&&w.setRequestHeader("If-None-Match",ia.etag[g])),(m.data&&m.hasContent&&m.contentType!==!1||c.contentType)&&w.setRequestHeader("Content-Type",m.contentType),w.setRequestHeader("Accept",m.dataTypes[0]&&m.accepts[m.dataTypes[0]]?m.accepts[m.dataTypes[0]]+("*"!==m.dataTypes[0]?", "+Sb+"; q=0.01":""):m.accepts["*"]);for(f in m.headers)w.setRequestHeader(f,m.headers[f]);if(m.beforeSend&&(m.beforeSend.call(n,w,m)===!1||2===u))return w.abort();v="abort";for(f in{success:1,error:1,complete:1})w[f](m[f]);if(k=F(Rb,m,c,w)){w.readyState=1,j&&o.trigger("ajaxSend",[w,m]),m.async&&m.timeout>0&&(i=setTimeout(function(){w.abort("timeout")},m.timeout));try{u=1,k.send(s,d)}catch(x){if(!(u<2))throw x;d(-1,x)}}else d(-1,"No Transport");return w},getScript:function(a,c){return ia.get(a,b,c,"script")},getJSON:function(a,b,c){return ia.get(a,b,c,"json")}}),ia.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return ia.globalEval(a),a}}}),ia.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),ia.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=W.head||ia("head")[0]||W.documentElement;return{send:function(b,e){c=W.createElement("script"),c.async=!0,a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,b){(b||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c.parentNode&&c.parentNode.removeChild(c),c=null,b||e(200,"success"))},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(b,!0)}}}});var Ub=[],Vb=/(=)\?(?=&|$)|\?\?/;ia.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Ub.pop()||ia.expando+"_"+Gb++;return this[a]=!0,a}}),ia.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.jsonp!==!1&&(Vb.test(c.url)?"url":"string"==typeof c.data&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vb.test(c.data)&&"data");if(i||"jsonp"===c.dataTypes[0])return f=c.jsonpCallback=ia.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,i?c[i]=c[i].replace(Vb,"$1"+f):c.jsonp!==!1&&(c.url+=(Hb.test(c.url)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||ia.error(f+" was not called"),h[0]},c.dataTypes[0]="json",g=a[f],a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,Ub.push(f)),h&&ia.isFunction(g)&&g(h[0]),h=g=b}),"script"});var Wb,Xb,Yb=0,Zb=a.ActiveXObject&&function(){var a;for(a in Wb)Wb[a](b,!0)};ia.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&J()||K()}:J,Xb=ia.ajaxSettings.xhr(),ia.support.cors=!!Xb&&"withCredentials"in Xb,Xb=ia.support.ajax=!!Xb,Xb&&ia.ajaxTransport(function(c){if(!c.crossDomain||ia.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();if(c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async),c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),c.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l;try{if(d&&(e||4===i.readyState))if(d=b,g&&(i.onreadystatechange=ia.noop,Zb&&delete Wb[g]),e)4!==i.readyState&&i.abort();else{l={},h=i.status,j=i.getAllResponseHeaders(),"string"==typeof i.responseText&&(l.text=i.responseText);try{k=i.statusText}catch(m){k=""}h||!c.isLocal||c.crossDomain?1223===h&&(h=204):h=l.text?200:404}}catch(n){e||f(-1,n)}l&&f(h,k,l,j)},c.async?4===i.readyState?setTimeout(d):(g=++Yb,Zb&&(Wb||(Wb={},ia(a).unload(Zb)),Wb[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(b,!0)}}}});var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+ja+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[P],ec={"*":[function(a,b){var c,d,e=this.createTween(a,b),f=bc.exec(b),g=e.cur(),h=+g||0,i=1,j=20;if(f){if(c=+f[2],d=f[3]||(ia.cssNumber[a]?"":"px"),"px"!==d&&h){h=ia.css(e.elem,a,!0)||c||1;do i=i||".5",h/=i,ia.style(e.elem,a,h+d);while(i!==(i=e.cur()/g)&&1!==i&&--j)}e.unit=d,e.start=h,e.end=f[1]?h+(f[1]+1)*c:c}return e}]};ia.Animation=ia.extend(N,{tweener:function(a,b){ia.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;d-1,l={},m={};k?(m=g.position(),e=m.top,f=m.left):(e=parseFloat(i)||0,f=parseFloat(j)||0),ia.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(l.top=b.top-h.top+e),null!=b.left&&(l.left=b.left-h.left+f),"using"in b?b.using.call(a,l):g.css(l)}},ia.fn.extend({position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===ia.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),ia.nodeName(a[0],"html")||(c=a.offset()),c.top+=ia.css(a[0],"borderTopWidth",!0),c.left+=ia.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-ia.css(d,"marginTop",!0),left:b.left-c.left-ia.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){for(var a=this.offsetParent||W.documentElement;a&&!ia.nodeName(a,"html")&&"static"===ia.css(a,"position");)a=a.offsetParent;return a||W.documentElement})}}),ia.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,c){var d=/Y/.test(c);ia.fn[a]=function(e){return ia.access(this,function(a,e,f){var g=S(a);return f===b?g?c in g?g[c]:g.document.documentElement[e]:a[e]:void(g?g.scrollTo(d?ia(g).scrollLeft():f,d?f:ia(g).scrollTop()):a[e]=f)},a,e,arguments.length,null)}}),ia.each({Height:"height",Width:"width"},function(a,c){ia.each({padding:"inner"+a,content:c,"":"outer"+a},function(d,e){ia.fn[e]=function(e,f){var g=arguments.length&&(d||"boolean"!=typeof e),h=d||(e===!0||f===!0?"margin":"border");return ia.access(this,function(c,d,e){var f;return ia.isWindow(c)?c.document.documentElement["client"+a]:9===c.nodeType?(f=c.documentElement,Math.max(c.body["scroll"+a],f["scroll"+a],c.body["offset"+a],f["offset"+a],f["client"+a])):e===b?ia.css(c,d,h):ia.style(c,d,e,h)},c,g?e:b,g,null)}})}),a.jQuery=a.$=ia,"function"==typeof define&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return ia})}(window),function(){function a(a,b,c){switch(c.length){case 0:return a.call(b);case 1:return a.call(b,c[0]);case 2:return a.call(b,c[0],c[1]);case 3:return a.call(b,c[0],c[1],c[2])}return a.apply(b,c)}function b(a,b,c,d){for(var e=-1,f=null==a?0:a.length;++e-1}function g(a,b,c){for(var d=-1,e=null==a?0:a.length;++d0){var h=Math.pow(10,f);c>d?(a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""))*h):(a=Number(a.toString().replace(".",""))*h,b=Number(b.toString().replace(".","")))}else a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""));return(a+b)/e}function accSub(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g){c=0}try{d=b.toString().split(".")[1].length}catch(g){d=0}return e=Math.pow(10,Math.max(c,d)),f=c>=d?c:d,((a*e-b*e)/e).toFixed(f)}function accMul(a,b){var c=0,d=a.toString(),e=b.toString();try{c+=d.split(".")[1].length}catch(f){}try{c+=e.split(".")[1].length}catch(f){}return Number(d.replace(".",""))*Number(e.replace(".",""))/Math.pow(10,c)}function digitLength(a){var b=a.toString().split(/[eE]/),c=(b[0].split(".")[1]||"").length-+(b[1]||0);return c>0?c:0}function float2Fixed(a){if(a.toString().indexOf("e")===-1)return Number(a.toString().replace(".",""));var b=digitLength(a);return b>0?a*Math.pow(10,b):a}function times(a,b){for(var c=[],d=2;d0)return times.apply(void 0,[times(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b),g=digitLength(a)+digitLength(b),h=e*f;return h/Math.pow(10,g)}function accDivide(a,b){for(var c=[],d=2;d0)return accDivide.apply(void 0,[accDivide(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b);return times(e/f,Math.pow(10,digitLength(b)-digitLength(a)))}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}Array.prototype.indexOf||(Array.prototype.indexOf=function(a,b){var c;if(null==this)throw new TypeError('"this" is null or not defined');var d=Object(this),e=d.length>>>0;if(0===e)return-1;var f=0|b;if(f>=e)return-1;for(c=Math.max(f>=0?f:e-Math.abs(f),0);c>>0;if(0===e)return-1;for(b=e-1,arguments.length>1&&(b=Number(arguments[1]),b!=b?b=0:0!=b&&b!=1/0&&b!=-(1/0)&&(b=(b>0||-1)*Math.floor(Math.abs(b)))),c=b>=0?Math.min(b,e-1):e-Math.abs(b);c>=0;c--)if(c in d&&d[c]===a)return c;return-1}),window.console=window.console||function(){var a={};return a.log=a.warn=a.debug=a.info=a.error=a.time=a.dir=a.profile=a.clear=a.exception=a.trace=a.assert=function(){},a}(),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d?this:a,b.concat(Array.prototype.slice.call(arguments)))};return this.prototype&&(d.prototype=this.prototype),e.prototype=new d,e}),window.localStorage||(window.localStorage={items:{},setItem:function(a,b){BI.Cache.addCookie(a,b)},getItem:function(a){return BI.Cache.getCookie(a)},removeItem:function(a){BI.Cache.deleteCookie(a)},key:function(){},clear:function(){this.items={}}}),Object.keys||(Object.keys=function(a){if(a!==Object(a))throw new TypeError("Object.keys called on a non-object");var b,c,d={__ob__:b,$accessors:b,$vbthis:b,$vbsetter:b},e=[];for(c in a)c in d||Object.prototype.hasOwnProperty.call(a,c)&&e.push(c);return e}),Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),"function"!=typeof Object.getPrototypeOf&&(Object.getPrototypeOf="".__proto__===String.prototype?function(a){return a.__proto__}:function(a){return a.constructor.prototype}),Date.now||(Date.now=function(){return(new Date).valueOf()}),"undefined"!=typeof Set&&Set.toString().match(/native code/)||(Set=function(){this.set={}},Set.prototype.has=function(a){return void 0!==this.set[a]},Set.prototype.add=function(a){this.set[a]=1},Set.prototype.clear=function(){this.set={}}),!function(a){var b=a.navigator.userAgent.toLowerCase(),c=/msie|applewebkit.+safari/;if(c.test(b)){var d=Array.prototype.sort;Array.prototype.sort=function(a){if(a&&"function"==typeof a){if(this.length<2)return this;for(var b,c=0,e=c+1,f=this.length,g=!1,h=0;c0,g===!0&&(b=this[c],this[c]=this[e],this[e]=b);return this}return d.call(this)}}}(window),function(a,b){function c(a){var b=a.length,c=ia.type(a);return!ia.isWindow(a)&&(!(1!==a.nodeType||!b)||("array"===c||"function"!==c&&(0===b||"number"==typeof b&&b>0&&b-1 in a)))}function d(a){var b=xa[a]={};return ia.each(a.match(ka)||[],function(a,c){b[c]=!0}),b}function e(a,c,d,e){if(ia.acceptData(a)){var f,g,h=ia.expando,i="string"==typeof c,j=a.nodeType,k=j?ia.cache:a,l=j?a[h]:a[h]&&h;if(l&&k[l]&&(e||k[l].data)||!i||d!==b)return l||(j?a[h]=l=_.pop()||ia.guid++:l=h),k[l]||(k[l]={},j||(k[l].toJSON=ia.noop)),"object"!=typeof c&&"function"!=typeof c||(e?k[l]=ia.extend(k[l],c):k[l].data=ia.extend(k[l].data,c)),f=k[l],e||(f.data||(f.data={}),f=f.data),d!==b&&(f[ia.camelCase(c)]=d),i?(g=f[c],null==g&&(g=f[ia.camelCase(c)])):g=f,g}}function f(a,b,c){if(ia.acceptData(a)){var d,e,f,g=a.nodeType,i=g?ia.cache:a,j=g?a[ia.expando]:ia.expando;if(i[j]){if(b&&(f=c?i[j]:i[j].data)){ia.isArray(b)?b=b.concat(ia.map(b,ia.camelCase)):b in f?b=[b]:(b=ia.camelCase(b),b=b in f?[b]:b.split(" "));for(d=0,e=b.length;d=0===c})}function m(a){var b=Ua.split("|"),c=a.createDocumentFragment();if(c.createElement)for(;b.length;)c.createElement(b.pop());return c}function n(a,b){return a.getElementsByTagName(b)[0]||a.appendChild(a.ownerDocument.createElement(b))}function o(a){var b=a.getAttributeNode("type");return a.type=(b&&b.specified)+"/"+a.type,a}function p(a){var b=eb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function q(a,b){for(var c,d=0;null!=(c=a[d]);d++)ia._data(c,"globalEval",!b||ia._data(b[d],"globalEval"))}function r(a,b){if(1===b.nodeType&&ia.hasData(a)){var c,d,e,f=ia._data(a),g=ia._data(b,f),h=f.events;if(h){delete g.handle,g.events={};for(c in h)for(d=0,e=h[c].length;d").css("cssText","display:block !important")).appendTo(b.documentElement),b=(jb[0].contentWindow||jb[0].contentDocument).document,b.write(""),b.close(),c=C(a,b),jb.detach()),ub[a]=c),c}function C(a,b){var c=ia(b.createElement(a)).appendTo(b.body),d=ia.css(c[0],"display");return c.remove(),d}function D(a,b,c,d){var e;if(ia.isArray(b))ia.each(b,function(b,e){c||Ab.test(a)?d(a,e):D(a+"["+("object"==typeof e?b:"")+"]",e,c,d)});else if(c||"object"!==ia.type(b))d(a,b);else for(e in b)D(a+"["+e+"]",b[e],c,d)}function E(a){return function(b,c){"string"!=typeof b&&(c=b,b="*");var d,e=0,f=b.toLowerCase().match(ka)||[];if(ia.isFunction(c))for(;d=f[e++];)"+"===d[0]?(d=d.slice(1)||"*",(a[d]=a[d]||[]).unshift(c)):(a[d]=a[d]||[]).push(c)}}function F(a,b,c,d){function e(h){var i;return f[h]=!0,ia.each(a[h]||[],function(a,h){var j=h(b,c,d);return"string"!=typeof j||g||f[j]?g?!(i=j):void 0:(b.dataTypes.unshift(j),e(j),!1)}),i}var f={},g=a===Rb;return e(b.dataTypes[0])||!f["*"]&&e("*")}function G(a,c){var d,e,f=ia.ajaxSettings.flatOptions||{};for(e in c)c[e]!==b&&((f[e]?a:d||(d={}))[e]=c[e]);return d&&ia.extend(!0,a,d),a}function H(a,c,d){var e,f,g,h,i=a.contents,j=a.dataTypes,k=a.responseFields;for(h in k)h in d&&(c[k[h]]=d[h]);for(;"*"===j[0];)j.shift(),f===b&&(f=a.mimeType||c.getResponseHeader("Content-Type"));if(f)for(h in i)if(i[h]&&i[h].test(f)){j.unshift(h);break}if(j[0]in d)g=j[0];else{for(h in d){if(!j[0]||a.converters[h+" "+j[0]]){g=h;break}e||(e=h)}g=g||e}if(g)return g!==j[0]&&j.unshift(g),d[g]}function I(a,b){var c,d,e,f,g={},h=0,i=a.dataTypes.slice(),j=i[0];if(a.dataFilter&&(b=a.dataFilter(b,a.dataType)),i[1])for(e in a.converters)g[e.toLowerCase()]=a.converters[e];for(;d=i[++h];)if("*"!==d){if("*"!==j&&j!==d){if(e=g[j+" "+d]||g["* "+d],!e)for(c in g)if(f=c.split(" "),f[1]===d&&(e=g[j+" "+f[0]]||g["* "+f[0]])){e===!0?e=g[c]:g[c]!==!0&&(d=f[0],i.splice(h--,0,d));break}if(e!==!0)if(e&&a["throws"])b=e(b);else try{b=e(b)}catch(k){return{state:"parsererror",error:e?k:"No conversion from "+j+" to "+d}}}j=d}return{state:"success",data:b}}function J(){try{return new a.XMLHttpRequest}catch(b){}}function K(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function L(){return setTimeout(function(){$b=b}),$b=ia.now()}function M(a,b){ia.each(b,function(b,c){for(var d=(ec[b]||[]).concat(ec["*"]),e=0,f=d.length;e)[^>]*|#([\w-]*))$/,na=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,oa=/^[\],:{}\s]*$/,pa=/(?:^|:|,)(?:\s*\[)+/g,qa=/\\(?:["\\\/bfnrt]|u[\da-fA-F]{4})/g,ra=/"[^"\\\r\n]*"|true|false|null|-?(?:\d+\.|)\d+(?:[eE][+-]?\d+|)/g,sa=/^-ms-/,ta=/-([\da-z])/gi,ua=function(a,b){return b.toUpperCase()},va=function(a){(W.addEventListener||"load"===a.type||"complete"===W.readyState)&&(wa(),ia.ready())},wa=function(){W.addEventListener?(W.removeEventListener("DOMContentLoaded",va,!1),a.removeEventListener("load",va,!1)):(W.detachEvent("onreadystatechange",va),a.detachEvent("onload",va))};ia.fn=ia.prototype={jquery:aa,constructor:ia,init:function(a,c,d){var e,f;if(!a)return this;if("string"==typeof a){if(e="<"===a.charAt(0)&&">"===a.charAt(a.length-1)&&a.length>=3?[null,a,null]:ma.exec(a),!e||!e[1]&&c)return!c||c.jquery?(c||d).find(a):this.constructor(c).find(a);if(e[1]){if(c=c instanceof ia?c[0]:c,ia.merge(this,ia.parseHTML(e[1],c&&c.nodeType?c.ownerDocument||c:W,!0)),na.test(e[1])&&ia.isPlainObject(c))for(e in c)ia.isFunction(this[e])?this[e](c[e]):this.attr(e,c[e]);return this}if(f=W.getElementById(e[2]),f&&f.parentNode){if(f.id!==e[2])return d.find(a);this.length=1,this[0]=f}return this.context=W,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):ia.isFunction(a)?d.ready(a):(a.selector!==b&&(this.selector=a.selector,this.context=a.context),ia.makeArray(a,this))},selector:"",length:0,size:function(){return this.length},toArray:function(){return da.call(this)},get:function(a){return null==a?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a){var b=ia.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return ia.each(this,a,b)},ready:function(a){return ia.ready.promise().done(a),this},slice:function(){return this.pushStack(da.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(a<0?b:0);return this.pushStack(c>=0&&c0||(T.resolveWith(W,[ia]),ia.fn.trigger&&ia(W).trigger("ready").off("ready"))}},isFunction:function(a){return"function"===ia.type(a)},isArray:Array.isArray||function(a){return"array"===ia.type(a)},isWindow:function(a){return null!=a&&a==a.window},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return null==a?String(a):"object"==typeof a||"function"==typeof a?$[fa.call(a)]||"object":typeof a},isPlainObject:function(a){if(!a||"object"!==ia.type(a)||a.nodeType||ia.isWindow(a))return!1;try{if(a.constructor&&!ga.call(a,"constructor")&&!ga.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||ga.call(a,d)},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},error:function(a){throw new Error(a)},parseHTML:function(a,b,c){if(!a||"string"!=typeof a)return null;"boolean"==typeof b&&(c=b,b=!1),b=b||W;var d=na.exec(a),e=!c&&[];return d?[b.createElement(d[1])]:(d=ia.buildFragment([a],b,e),e&&ia(e).remove(),ia.merge([],d.childNodes))},parseJSON:function(b){return a.JSON&&a.JSON.parse?a.JSON.parse(b):null===b?b:"string"==typeof b&&(b=ia.trim(b),b&&oa.test(b.replace(qa,"@").replace(ra,"]").replace(pa,"")))?new Function("return "+b)():void ia.error("Invalid JSON: "+b)},parseXML:function(c){var d,e;if(!c||"string"!=typeof c)return null;try{a.DOMParser?(e=new DOMParser,d=e.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(f){d=b}return d&&d.documentElement&&!d.getElementsByTagName("parsererror").length||ia.error("Invalid XML: "+c),d},noop:function(){},globalEval:function(b){b&&ia.trim(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(sa,"ms-").replace(ta,ua)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,d){var e,f=0,g=a.length,h=c(a);if(d){if(h)for(;f-1;)j.splice(d,1),c&&(d<=g&&g--,d<=h&&h--)}),this},has:function(a){return a?ia.inArray(a,j)>-1:!(!j||!j.length)},empty:function(){return j=[],this},disable:function(){return j=k=e=b,this},disabled:function(){return!j},lock:function(){return k=b,e||m.disable(),this},locked:function(){return!k},fireWith:function(a,b){return b=b||[],b=[a,b.slice?b.slice():b],!j||f&&!k||(c?k.push(b):l(b)),this},fire:function(){return m.fireWith(this,arguments),this},fired:function(){return!!f}};return m},ia.extend({Deferred:function(a){var b=[["resolve","done",ia.Callbacks("once memory"),"resolved"],["reject","fail",ia.Callbacks("once memory"),"rejected"],["notify","progress",ia.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return ia.Deferred(function(c){ia.each(b,function(b,f){var g=f[0],h=ia.isFunction(a[b])&&a[b];e[f[1]](function(){var a=h&&h.apply(this,arguments);a&&ia.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[g+"With"](this===d?c.promise():this,h?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?ia.extend(a,d):d}},e={};return d.pipe=d.then,ia.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b,c,d,e=0,f=da.call(arguments),g=f.length,h=1!==g||a&&ia.isFunction(a.promise)?g:0,i=1===h?a:ia.Deferred(),j=function(a,c,d){return function(e){c[a]=this,d[a]=arguments.length>1?da.call(arguments):e,d===b?i.notifyWith(c,d):--h||i.resolveWith(c,d)}};if(g>1)for(b=new Array(g),c=new Array(g),d=new Array(g);e
a",c=l.getElementsByTagName("*"),d=l.getElementsByTagName("a")[0],!c||!d||!c.length)return{};f=W.createElement("select"),h=f.appendChild(W.createElement("option")),e=l.getElementsByTagName("input")[0],d.style.cssText="top:1px;float:left;opacity:.5",b={getSetAttribute:"t"!==l.className,leadingWhitespace:3===l.firstChild.nodeType,tbody:!l.getElementsByTagName("tbody").length,htmlSerialize:!!l.getElementsByTagName("link").length,style:/top/.test(d.getAttribute("style")),hrefNormalized:"/a"===d.getAttribute("href"),opacity:/^0.5/.test(d.style.opacity),cssFloat:!!d.style.cssFloat,checkOn:!!e.value,optSelected:h.selected,enctype:!!W.createElement("form").enctype,html5Clone:"<:nav>"!==W.createElement("nav").cloneNode(!0).outerHTML,boxModel:"CSS1Compat"===W.compatMode,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0,boxSizingReliable:!0,pixelPosition:!1},e.checked=!0,b.noCloneChecked=e.cloneNode(!0).checked,f.disabled=!0,b.optDisabled=!h.disabled;try{delete l.test}catch(m){b.deleteExpando=!1}e=W.createElement("input"),e.setAttribute("value",""),b.input=""===e.getAttribute("value"),e.value="t",e.setAttribute("type","radio"),b.radioValue="t"===e.value,e.setAttribute("checked","t"),e.setAttribute("name","t"),g=W.createDocumentFragment(),g.appendChild(e),b.appendChecked=e.checked,b.checkClone=g.cloneNode(!0).cloneNode(!0).lastChild.checked,l.attachEvent&&(l.attachEvent("onclick",function(){b.noCloneEvent=!1}),l.cloneNode(!0).click());for(k in{submit:!0,change:!0,focusin:!0})l.setAttribute(i="on"+k,"t"),b[k+"Bubbles"]=i in a||l.attributes[i].expando===!1;return l.style.backgroundClip="content-box",l.cloneNode(!0).style.backgroundClip="",b.clearCloneStyle="content-box"===l.style.backgroundClip,ia(function(){var c,d,e,f="padding:0;margin:0;border:0;display:block;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;",g=W.getElementsByTagName("body")[0];g&&(c=W.createElement("div"),c.style.cssText="border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px",g.appendChild(c).appendChild(l),l.innerHTML="
t
",e=l.getElementsByTagName("td"),e[0].style.cssText="padding:0;margin:0;border:0;display:none",j=0===e[0].offsetHeight,e[0].style.display="",e[1].style.display="none",b.reliableHiddenOffsets=j&&0===e[0].offsetHeight,l.innerHTML="",l.style.cssText="box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;",b.boxSizing=4===l.offsetWidth,b.doesNotIncludeMarginInBodyOffset=1!==g.offsetTop,a.getComputedStyle&&(b.pixelPosition="1%"!==(a.getComputedStyle(l,null)||{}).top,b.boxSizingReliable="4px"===(a.getComputedStyle(l,null)||{width:"4px"}).width,d=l.appendChild(W.createElement("div")),d.style.cssText=l.style.cssText=f,d.style.marginRight=d.style.width="0",l.style.width="1px",b.reliableMarginRight=!parseFloat((a.getComputedStyle(d,null)||{}).marginRight)),typeof l.style.zoom!==V&&(l.innerHTML="",l.style.cssText=f+"width:1px;padding:1px;display:inline;zoom:1",b.inlineBlockNeedsLayout=3===l.offsetWidth,l.style.display="block",l.innerHTML="
",l.firstChild.style.width="5px",b.shrinkWrapBlocks=3!==l.offsetWidth,b.inlineBlockNeedsLayout&&(g.style.zoom=1)),g.removeChild(c),c=l=e=d=null)}),c=f=g=h=d=e=null,b}();var ya=/(?:\{[\s\S]*\}|\[[\s\S]*\])$/,za=/([A-Z])/g;ia.extend({cache:{},expando:"jQuery"+(aa+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){return a=a.nodeType?ia.cache[a[ia.expando]]:a[ia.expando],!!a&&!h(a)},data:function(a,b,c){return e(a,b,c)},removeData:function(a,b){return f(a,b)},_data:function(a,b,c){return e(a,b,c,!0)},_removeData:function(a,b){return f(a,b,!0)},acceptData:function(a){if(a.nodeType&&1!==a.nodeType&&9!==a.nodeType)return!1;var b=a.nodeName&&ia.noData[a.nodeName.toLowerCase()];return!b||b!==!0&&a.getAttribute("classid")===b}}),ia.fn.extend({data:function(a,c){var d,e,f=this[0],h=0,i=null;if(a===b){if(this.length&&(i=ia.data(f),1===f.nodeType&&!ia._data(f,"parsedAttrs"))){for(d=f.attributes;h1,null,!0)},removeData:function(a){return this.each(function(){ia.removeData(this,a)})}}),ia.extend({queue:function(a,b,c){var d;if(a)return b=(b||"fx")+"queue",d=ia._data(a,b),c&&(!d||ia.isArray(c)?d=ia._data(a,b,ia.makeArray(c)):d.push(c)),d||[]},dequeue:function(a,b){b=b||"fx";var c=ia.queue(a,b),d=c.length,e=c.shift(),f=ia._queueHooks(a,b),g=function(){ia.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),f.cur=e,e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return ia._data(a,c)||ia._data(a,c,{empty:ia.Callbacks("once memory").add(function(){ia._removeData(a,b+"queue"),ia._removeData(a,c)})})}}),ia.fn.extend({queue:function(a,c){var d=2;return"string"!=typeof a&&(c=a,a="fx",d--),arguments.length1)},removeAttr:function(a){return this.each(function(){ ia.removeAttr(this,a)})},prop:function(a,b){return ia.access(this,ia.prop,a,b,arguments.length>1)},removeProp:function(a){return a=ia.propFix[a]||a,this.each(function(){try{this[a]=b,delete this[a]}catch(c){}})},addClass:function(a){var b,c,d,e,f,g=0,h=this.length,i="string"==typeof a&&a;if(ia.isFunction(a))return this.each(function(b){ia(this).addClass(a.call(this,b,this.className))});if(i)for(b=(a||"").match(ka)||[];g=0;)d=d.replace(" "+e+" "," ");c.className=a?ia.trim(d):""}return this},toggleClass:function(a,b){var c=typeof a,d="boolean"==typeof b;return ia.isFunction(a)?this.each(function(c){ia(this).toggleClass(a.call(this,c,this.className,b),b)}):this.each(function(){if("string"===c)for(var e,f=0,g=ia(this),h=b,i=a.match(ka)||[];e=i[f++];)h=d?h:!g.hasClass(e),g[h?"addClass":"removeClass"](e);else c!==V&&"boolean"!==c||(this.className&&ia._data(this,"__className__",this.className),this.className=this.className||a===!1?"":ia._data(this,"__className__")||"")})},hasClass:function(a){for(var b=" "+a+" ",c=0,d=this.length;c=0)return!0;return!1},val:function(a){var c,d,e,f=this[0];{if(arguments.length)return e=ia.isFunction(a),this.each(function(c){var f,g=ia(this);1===this.nodeType&&(f=e?a.call(this,c,g.val()):a,null==f?f="":"number"==typeof f?f+="":ia.isArray(f)&&(f=ia.map(f,function(a){return null==a?"":a+""})),d=ia.valHooks[this.type]||ia.valHooks[this.nodeName.toLowerCase()],d&&"set"in d&&d.set(this,f,"value")!==b||(this.value=f))});if(f)return d=ia.valHooks[f.type]||ia.valHooks[f.nodeName.toLowerCase()],d&&"get"in d&&(c=d.get(f,"value"))!==b?c:(c=f.value,"string"==typeof c?c.replace(Da,""):null==c?"":c)}}}),ia.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){for(var b,c,d=a.options,e=a.selectedIndex,f="select-one"===a.type||e<0,g=f?null:[],h=f?e+1:d.length,i=e<0?h:f?e:0;i=0}),c.length||(a.selectedIndex=-1),c}}},attr:function(a,c,d){var e,f,g,h=a.nodeType;if(a&&3!==h&&8!==h&&2!==h)return typeof a.getAttribute===V?ia.prop(a,c,d):(f=1!==h||!ia.isXMLDoc(a),f&&(c=c.toLowerCase(),e=ia.attrHooks[c]||(Ga.test(c)?Ba:Aa)),d===b?e&&f&&"get"in e&&null!==(g=e.get(a,c))?g:(typeof a.getAttribute!==V&&(g=a.getAttribute(c)),null==g?b:g):null!==d?e&&f&&"set"in e&&(g=e.set(a,d,c))!==b?g:(a.setAttribute(c,d+""),d):void ia.removeAttr(a,c))},removeAttr:function(a,b){var c,d,e=0,f=b&&b.match(ka);if(f&&1===a.nodeType)for(;c=f[e++];)d=ia.propFix[c]||c,Ga.test(c)?!Ia&&Ha.test(c)?a[ia.camelCase("default-"+c)]=a[d]=!1:a[d]=!1:ia.attr(a,c,""),a.removeAttribute(Ia?c:d)},attrHooks:{type:{set:function(a,b){if(!ia.support.radioValue&&"radio"===b&&ia.nodeName(a,"input")){var c=a.value;return a.setAttribute("type",b),c&&(a.value=c),b}}}},propFix:{tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},prop:function(a,c,d){var e,f,g,h=a.nodeType;if(a&&3!==h&&8!==h&&2!==h)return g=1!==h||!ia.isXMLDoc(a),g&&(c=ia.propFix[c]||c,f=ia.propHooks[c]),d!==b?f&&"set"in f&&(e=f.set(a,d,c))!==b?e:a[c]=d:f&&"get"in f&&null!==(e=f.get(a,c))?e:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):Ea.test(a.nodeName)||Fa.test(a.nodeName)&&a.href?0:b}}}}),Ba={get:function(a,c){var d=ia.prop(a,c),e="boolean"==typeof d&&a.getAttribute(c),f="boolean"==typeof d?Ja&&Ia?null!=e:Ha.test(c)?a[ia.camelCase("default-"+c)]:!!e:a.getAttributeNode(c);return f&&f.value!==!1?c.toLowerCase():b},set:function(a,b,c){return b===!1?ia.removeAttr(a,c):Ja&&Ia||!Ha.test(c)?a.setAttribute(!Ia&&ia.propFix[c]||c,c):a[ia.camelCase("default-"+c)]=a[c]=!0,c}},Ja&&Ia||(ia.attrHooks.value={get:function(a,c){var d=a.getAttributeNode(c);return ia.nodeName(a,"input")?a.defaultValue:d&&d.specified?d.value:b},set:function(a,b,c){return ia.nodeName(a,"input")?void(a.defaultValue=b):Aa&&Aa.set(a,b,c)}}),Ia||(Aa=ia.valHooks.button={get:function(a,c){var d=a.getAttributeNode(c);return d&&("id"===c||"name"===c||"coords"===c?""!==d.value:d.specified)?d.value:b},set:function(a,c,d){var e=a.getAttributeNode(d);return e||a.setAttributeNode(e=a.ownerDocument.createAttribute(d)),e.value=c+="","value"===d||c===a.getAttribute(d)?c:b}},ia.attrHooks.contenteditable={get:Aa.get,set:function(a,b,c){Aa.set(a,""!==b&&b,c)}},ia.each(["width","height"],function(a,b){ia.attrHooks[b]=ia.extend(ia.attrHooks[b],{set:function(a,c){if(""===c)return a.setAttribute(b,"auto"),c}})})),ia.support.hrefNormalized||(ia.each(["href","src","width","height"],function(a,c){ia.attrHooks[c]=ia.extend(ia.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return null==d?b:d}})}),ia.each(["href","src"],function(a,b){ia.propHooks[b]={get:function(a){return a.getAttribute(b,4)}}})),ia.support.style||(ia.attrHooks.style={get:function(a){return a.style.cssText||b},set:function(a,b){return a.style.cssText=b+""}}),ia.support.optSelected||(ia.propHooks.selected=ia.extend(ia.propHooks.selected,{get:function(a){var b=a.parentNode;return b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex),null}})),ia.support.enctype||(ia.propFix.enctype="encoding"),ia.support.checkOn||ia.each(["radio","checkbox"],function(){ia.valHooks[this]={get:function(a){return null===a.getAttribute("value")?"on":a.value}}}),ia.each(["radio","checkbox"],function(){ia.valHooks[this]=ia.extend(ia.valHooks[this],{set:function(a,b){if(ia.isArray(b))return a.checked=ia.inArray(ia(a).val(),b)>=0}})});var Ka=/^(?:input|select|textarea)$/i,La=/^key/,Ma=/^(?:mouse|contextmenu)|click/,Na=/^(?:focusinfocus|focusoutblur)$/,Oa=/^([^.]*)(?:\.(.+)|)$/;ia.event={global:{},add:function(a,c,d,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=ia._data(a);if(r){for(d.handler&&(j=d,d=j.handler,f=j.selector),d.guid||(d.guid=ia.guid++),(h=r.events)||(h=r.events={}),(l=r.handle)||(l=r.handle=function(a){return typeof ia===V||a&&ia.event.triggered===a.type?b:ia.event.dispatch.apply(l.elem,arguments)},l.elem=a),c=(c||"").match(ka)||[""],i=c.length;i--;)g=Oa.exec(c[i])||[],o=q=g[1],p=(g[2]||"").split(".").sort(),k=ia.event.special[o]||{},o=(f?k.delegateType:k.bindType)||o,k=ia.event.special[o]||{},m=ia.extend({type:o,origType:q,data:e,handler:d,guid:d.guid,selector:f,needsContext:f&&ia.expr.match.needsContext.test(f),namespace:p.join(".")},j),(n=h[o])||(n=h[o]=[],n.delegateCount=0,k.setup&&k.setup.call(a,e,p,l)!==!1||(a.addEventListener?a.addEventListener(o,l,!1):a.attachEvent&&a.attachEvent("on"+o,l))),k.add&&(k.add.call(a,m),m.handler.guid||(m.handler.guid=d.guid)),f?n.splice(n.delegateCount++,0,m):n.push(m),ia.event.global[o]=!0;a=null}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q=ia.hasData(a)&&ia._data(a);if(q&&(k=q.events)){for(b=(b||"").match(ka)||[""],j=b.length;j--;)if(h=Oa.exec(b[j])||[],n=p=h[1],o=(h[2]||"").split(".").sort(),n){for(l=ia.event.special[n]||{},n=(d?l.delegateType:l.bindType)||n,m=k[n]||[],h=h[2]&&new RegExp("(^|\\.)"+o.join("\\.(?:.*\\.|)")+"(\\.|$)"),i=f=m.length;f--;)g=m[f],!e&&p!==g.origType||c&&c.guid!==g.guid||h&&!h.test(g.namespace)||d&&d!==g.selector&&("**"!==d||!g.selector)||(m.splice(f,1),g.selector&&m.delegateCount--,l.remove&&l.remove.call(a,g));i&&!m.length&&(l.teardown&&l.teardown.call(a,o,q.handle)!==!1||ia.removeEvent(a,n,q.handle),delete k[n])}else for(n in k)ia.event.remove(a,n+b[j],c,d,!0);ia.isEmptyObject(k)&&(delete q.handle,ia._removeData(a,"events"))}},trigger:function(c,d,e,f){var g,h,i,j,k,l,m,n=[e||W],o=ga.call(c,"type")?c.type:c,p=ga.call(c,"namespace")?c.namespace.split("."):[];if(i=l=e=e||W,3!==e.nodeType&&8!==e.nodeType&&!Na.test(o+ia.event.triggered)&&(o.indexOf(".")>=0&&(p=o.split("."),o=p.shift(),p.sort()),h=o.indexOf(":")<0&&"on"+o,c=c[ia.expando]?c:new ia.Event(o,"object"==typeof c&&c),c.isTrigger=!0,c.namespace=p.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,c.result=b,c.target||(c.target=e),d=null==d?[c]:ia.makeArray(d,[c]),k=ia.event.special[o]||{},f||!k.trigger||k.trigger.apply(e,d)!==!1)){if(!f&&!k.noBubble&&!ia.isWindow(e)){for(j=k.delegateType||o,Na.test(j+o)||(i=i.parentNode);i;i=i.parentNode)n.push(i),l=i;l===(e.ownerDocument||W)&&n.push(l.defaultView||l.parentWindow||a)}for(m=0;(i=n[m++])&&!c.isPropagationStopped();)c.type=m>1?j:k.bindType||o,g=(ia._data(i,"events")||{})[c.type]&&ia._data(i,"handle"),g&&g.apply(i,d),g=h&&i[h],g&&ia.acceptData(i)&&g.apply&&g.apply(i,d)===!1&&c.preventDefault();if(c.type=o,!f&&!c.isDefaultPrevented()&&(!k._default||k._default.apply(e.ownerDocument,d)===!1)&&("click"!==o||!ia.nodeName(e,"a"))&&ia.acceptData(e)&&h&&e[o]&&!ia.isWindow(e)){l=e[h],l&&(e[h]=null),ia.event.triggered=o;try{e[o]()}catch(q){}ia.event.triggered=b,l&&(e[h]=l)}return c.result}},dispatch:function(a){a=ia.event.fix(a);var c,d,e,f,g,h=[],i=da.call(arguments),j=(ia._data(this,"events")||{})[a.type]||[],k=ia.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){for(h=ia.event.handlers.call(this,a,j),c=0;(f=h[c++])&&!a.isPropagationStopped();)for(a.currentTarget=f.elem,g=0;(e=f.handlers[g++])&&!a.isImmediatePropagationStopped();)if(!a.namespace_re||a.namespace_re.test(e.namespace)){a.handleObj=e,a.data=e.data;var l=(ia.event.special[e.origType]||{}).handle||e.handler;l.apply&&(d=l.apply(f.elem,i)),d!==b&&(a.result=d)===!1&&(a.preventDefault(),a.stopPropagation())}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,c){var d,e,f,g,h=[],i=c.delegateCount,j=a.target;if(i&&j.nodeType&&(!a.button||"click"!==a.type))for(;j!=this;j=j.parentNode||this)if(1===j.nodeType&&(j.disabled!==!0||"click"!==a.type)){for(f=[],g=0;g=0:ia.find(d,this,null,[j]).length),f[d]&&f.push(e);f.length&&h.push({elem:j,handlers:f})}return iy.cacheLength&&delete a[b.shift()],a[c]=d}}function e(a){return a[N]=!0,a}function f(a){var b=F.createElement("div");try{return a(b)}catch(c){return!1}finally{b=null}}function g(a,b,c,d){var e,f,g,h,i,j,k,n,o,p;if((b?b.ownerDocument||b:O)!==F&&E(b),b=b||F,c=c||[],!a||"string"!=typeof a)return c;if(1!==(h=b.nodeType)&&9!==h)return[];if(!H&&!d){if(e=pa.exec(a))if(g=e[1]){if(9===h){if(f=b.getElementById(g),!f||!f.parentNode)return c;if(f.id===g)return c.push(f),c}else if(b.ownerDocument&&(f=b.ownerDocument.getElementById(g))&&L(b,f)&&f.id===g)return c.push(f),c}else{if(e[2])return Z.apply(c,$.call(b.getElementsByTagName(a),0)),c;if((g=e[3])&&P.getByClassName&&b.getElementsByClassName)return Z.apply(c,$.call(b.getElementsByClassName(g),0)),c}if(P.qsa&&!I.test(a)){if(k=!0,n=N,o=b,p=9===h&&a,1===h&&"object"!==b.nodeName.toLowerCase()){for(j=l(a),(k=b.getAttribute("id"))?n=k.replace(sa,"\\$&"):b.setAttribute("id",n),n="[id='"+n+"'] ",i=j.length;i--;)j[i]=n+m(j[i]);o=na.test(a)&&b.parentNode||b,p=j.join(",")}if(p)try{return Z.apply(c,$.call(o.querySelectorAll(p),0)),c}catch(q){}finally{k||b.removeAttribute("id")}}}return u(a.replace(ga,"$1"),b,c,d)}function h(a,b){var c=b&&a,d=c&&(~b.sourceIndex||W)-(~a.sourceIndex||W);if(d)return d;if(c)for(;c=c.nextSibling;)if(c===b)return-1;return a?1:-1}function i(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function j(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function k(a){return e(function(b){return b=+b,e(function(c,d){for(var e,f=a([],c.length,b),g=f.length;g--;)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function l(a,b){var c,d,e,f,h,i,j,k=T[a+" "];if(k)return b?0:k.slice(0);for(h=a,i=[],j=y.preFilter;h;){c&&!(d=ha.exec(h))||(d&&(h=h.slice(d[0].length)||h),i.push(e=[])),c=!1,(d=ja.exec(h))&&(c=d.shift(),e.push({value:c,type:d[0].replace(ga," ")}),h=h.slice(c.length));for(f in y.filter)!(d=ma[f].exec(h))||j[f]&&!(d=j[f](d))||(c=d.shift(),e.push({value:c,type:f,matches:d}),h=h.slice(c.length));if(!c)break}return b?h.length:h?g.error(a):T(a,i).slice(0)}function m(a){for(var b=0,c=a.length,d="";b1?function(b,c,d){for(var e=a.length;e--;)if(!a[e](b,c,d))return!1;return!0}:a[0]}function p(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;h-1&&(e[j]=!(g[j]=l))}}else s=p(s===g?s.splice(o,s.length):s),f?f(null,g,s,i):Z.apply(g,s)})}function r(a){for(var b,c,d,e=a.length,f=y.relative[a[0].type],g=f||y.relative[" "],h=f?1:0,i=n(function(a){return a===b},g,!0),j=n(function(a){return _.call(b,a)>-1},g,!0),k=[function(a,c,d){return!f&&(d||c!==D)||((b=c).nodeType?i(a,c,d):j(a,c,d))}];h1&&o(k),h>1&&m(a.slice(0,h-1)).replace(ga,"$1"),c,h0,f=a.length>0,h=function(e,h,i,j,k){var l,m,n,o=[],q=0,r="0",s=e&&[],t=null!=k,u=D,v=e||f&&y.find.TAG("*",k&&h.parentNode||h),w=Q+=null==u?1:Math.random()||.1;for(t&&(D=h!==F&&h,x=c);null!=(l=v[r]);r++){if(f&&l){for(m=0;n=a[m++];)if(n(l,h,i)){j.push(l);break}t&&(Q=w,x=++c)}d&&((l=!n&&l)&&q--,e&&s.push(l))}if(q+=r,d&&r!==q){for(m=0;n=b[m++];)n(s,o,h,i);if(e){if(q>0)for(;r--;)s[r]||o[r]||(o[r]=Y.call(j));o=p(o)}Z.apply(j,o),t&&!e&&o.length>0&&q+b.length>1&&g.uniqueSort(j)}return t&&(Q=w,D=u),s};return d?e(h):h}function t(a,b,c){for(var d=0,e=b.length;d2&&"ID"===(g=f[0]).type&&9===b.nodeType&&!H&&y.relative[f[1].type]){if(b=y.find.ID(g.matches[0].replace(ua,va),b)[0],!b)return c;a=a.slice(f.shift().value.length)}for(e=ma.needsContext.test(a)?0:f.length;e--&&(g=f[e],!y.relative[h=g.type]);)if((i=y.find[h])&&(d=i(g.matches[0].replace(ua,va),na.test(f[0].type)&&b.parentNode||b))){if(f.splice(e,1),a=d.length&&m(f),!a)return Z.apply(c,$.call(d,0)),c;break}}return B(a,j)(d,b,H,c,na.test(a)),c}function v(){}var w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N="sizzle"+-new Date,O=a.document,P={},Q=0,R=0,S=d(),T=d(),U=d(),V=typeof b,W=1<<31,X=[],Y=X.pop,Z=X.push,$=X.slice,_=X.indexOf||function(a){for(var b=0,c=this.length;b+~])"+aa+"*"),ka=new RegExp(fa),la=new RegExp("^"+ca+"$"),ma={ID:new RegExp("^#("+ba+")"),CLASS:new RegExp("^\\.("+ba+")"),NAME:new RegExp("^\\[name=['\"]?("+ba+")['\"]?\\]"),TAG:new RegExp("^("+ba.replace("w","w*")+")"),ATTR:new RegExp("^"+ea),PSEUDO:new RegExp("^"+fa),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+aa+"*(even|odd|(([+-]|)(\\d*)n|)"+aa+"*(?:([+-]|)"+aa+"*(\\d+)|))"+aa+"*\\)|)","i"),needsContext:new RegExp("^"+aa+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+aa+"*((?:-\\d)?\\d*)"+aa+"*\\)|)(?=[^-]|$)","i")},na=/[\x20\t\r\n\f]*[+~]/,oa=/^[^{]+\{\s*\[native code/,pa=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,qa=/^(?:input|select|textarea|button)$/i,ra=/^h\d$/i,sa=/'|\\/g,ta=/\=[\x20\t\r\n\f]*([^'"\]]*)[\x20\t\r\n\f]*\]/g,ua=/\\([\da-fA-F]{1,6}[\x20\t\r\n\f]?|.)/g,va=function(a,b){var c="0x"+b-65536;return c!==c?b:c<0?String.fromCharCode(c+65536):String.fromCharCode(c>>10|55296,1023&c|56320)};try{$.call(O.documentElement.childNodes,0)[0].nodeType}catch(wa){$=function(a){for(var b,c=[];b=this[a++];)c.push(b);return c}}A=g.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return!!b&&"HTML"!==b.nodeName},E=g.setDocument=function(a){var d=a?a.ownerDocument||a:O;return d!==F&&9===d.nodeType&&d.documentElement?(F=d,G=d.documentElement,H=A(d),P.tagNameNoComments=f(function(a){return a.appendChild(d.createComment("")),!a.getElementsByTagName("*").length}),P.attributes=f(function(a){a.innerHTML="";var b=typeof a.lastChild.getAttribute("multiple");return"boolean"!==b&&"string"!==b}),P.getByClassName=f(function(a){return a.innerHTML="",!(!a.getElementsByClassName||!a.getElementsByClassName("e").length)&&(a.lastChild.className="e",2===a.getElementsByClassName("e").length)}),P.getByName=f(function(a){a.id=N+0,a.innerHTML="
",G.insertBefore(a,G.firstChild);var b=d.getElementsByName&&d.getElementsByName(N).length===2+d.getElementsByName(N+0).length;return P.getIdNotName=!d.getElementById(N),G.removeChild(a),b}),y.attrHandle=f(function(a){return a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!==V&&"#"===a.firstChild.getAttribute("href")})?{}:{href:function(a){return a.getAttribute("href",2)},type:function(a){return a.getAttribute("type")}},P.getIdNotName?(y.find.ID=function(a,b){if(typeof b.getElementById!==V&&!H){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},y.filter.ID=function(a){var b=a.replace(ua,va);return function(a){return a.getAttribute("id")===b}}):(y.find.ID=function(a,c){if(typeof c.getElementById!==V&&!H){var d=c.getElementById(a);return d?d.id===a||typeof d.getAttributeNode!==V&&d.getAttributeNode("id").value===a?[d]:b:[]}},y.filter.ID=function(a){var b=a.replace(ua,va);return function(a){var c=typeof a.getAttributeNode!==V&&a.getAttributeNode("id");return c&&c.value===b}}),y.find.TAG=P.tagNameNoComments?function(a,b){if(typeof b.getElementsByTagName!==V)return b.getElementsByTagName(a)}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){for(;c=f[e++];)1===c.nodeType&&d.push(c);return d}return f},y.find.NAME=P.getByName&&function(a,b){if(typeof b.getElementsByName!==V)return b.getElementsByName(name)},y.find.CLASS=P.getByClassName&&function(a,b){if(typeof b.getElementsByClassName!==V&&!H)return b.getElementsByClassName(a)},J=[],I=[":focus"],(P.qsa=c(d.querySelectorAll))&&(f(function(a){a.innerHTML="",a.querySelectorAll("[selected]").length||I.push("\\["+aa+"*(?:checked|disabled|ismap|multiple|readonly|selected|value)"),a.querySelectorAll(":checked").length||I.push(":checked")}),f(function(a){a.innerHTML="",a.querySelectorAll("[i^='']").length&&I.push("[*^$]="+aa+"*(?:\"\"|'')"),a.querySelectorAll(":enabled").length||I.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),I.push(",.*:")})),(P.matchesSelector=c(K=G.matchesSelector||G.mozMatchesSelector||G.webkitMatchesSelector||G.oMatchesSelector||G.msMatchesSelector))&&f(function(a){P.disconnectedMatch=K.call(a,"div"),K.call(a,"[s!='']:x"),J.push("!=",fa)}),I=new RegExp(I.join("|")),J=new RegExp(J.join("|")),L=c(G.contains)||G.compareDocumentPosition?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)for(;b=b.parentNode;)if(b===a)return!0;return!1},M=G.compareDocumentPosition?function(a,b){var c;return a===b?(C=!0,0):(c=b.compareDocumentPosition&&a.compareDocumentPosition&&a.compareDocumentPosition(b))?1&c||a.parentNode&&11===a.parentNode.nodeType?a===d||L(O,a)?-1:b===d||L(O,b)?1:0:4&c?-1:1:a.compareDocumentPosition?-1:1}:function(a,b){var c,e=0,f=a.parentNode,g=b.parentNode,i=[a],j=[b];if(a===b)return C=!0,0;if(!f||!g)return a===d?-1:b===d?1:f?-1:g?1:0;if(f===g)return h(a,b);for(c=a;c=c.parentNode;)i.unshift(c);for(c=b;c=c.parentNode;)j.unshift(c);for(;i[e]===j[e];)e++;return e?h(i[e],j[e]):i[e]===O?-1:j[e]===O?1:0},C=!1,[0,0].sort(M),P.detectDuplicates=C,F):F},g.matches=function(a,b){return g(a,null,null,b)},g.matchesSelector=function(a,b){if((a.ownerDocument||a)!==F&&E(a),b=b.replace(ta,"='$1']"),P.matchesSelector&&!H&&(!J||!J.test(b))&&!I.test(b))try{var c=K.call(a,b);if(c||P.disconnectedMatch||a.document&&11!==a.document.nodeType)return c}catch(d){}return g(b,F,null,[a]).length>0},g.contains=function(a,b){return(a.ownerDocument||a)!==F&&E(a),L(a,b)},g.attr=function(a,b){var c;return(a.ownerDocument||a)!==F&&E(a),H||(b=b.toLowerCase()),(c=y.attrHandle[b])?c(a):H||P.attributes?a.getAttribute(b):((c=a.getAttributeNode(b))||a.getAttribute(b))&&a[b]===!0?b:c&&c.specified?c.value:null},g.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},g.uniqueSort=function(a){var b,c=[],d=1,e=0;if(C=!P.detectDuplicates,a.sort(M),C){for(;b=a[d];d++)b===a[d-1]&&(e=c.push(d));for(;e--;)a.splice(c[e],1)}return a},z=g.getText=function(a){var b,c="",d=0,e=a.nodeType;if(e){if(1===e||9===e||11===e){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=z(a)}else if(3===e||4===e)return a.nodeValue}else for(;b=a[d];d++)c+=z(b);return c},y=g.selectors={cacheLength:50,createPseudo:e,match:ma,find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ua,va),a[3]=(a[4]||a[5]||"").replace(ua,va),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||g.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&g.error(a[0]),a},PSEUDO:function(a){var b,c=!a[5]&&a[2];return ma.CHILD.test(a[0])?null:(a[4]?a[2]=a[4]:c&&ka.test(c)&&(b=l(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){return"*"===a?function(){return!0}:(a=a.replace(ua,va).toLowerCase(),function(b){return b.nodeName&&b.nodeName.toLowerCase()===a})},CLASS:function(a){var b=S[a+" "];return b||(b=new RegExp("(^|"+aa+")"+a+"("+aa+"|$)"))&&S(a,function(a){return b.test(a.className||typeof a.getAttribute!==V&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=g.attr(d,a);return null==e?"!="===b:!b||(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e+" ").indexOf(c)>-1:"|="===b&&(e===c||e.slice(0,c.length+1)===c+"-"))}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){for(;p;){for(l=b;l=l[p];)if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){for(k=q[N]||(q[N]={}),j=k[a]||[],n=j[0]===Q&&j[1],m=j[0]===Q&&j[2],l=n&&q.childNodes[n];l=++n&&l&&l[p]||(m=n=0)||o.pop();)if(1===l.nodeType&&++m&&l===b){k[a]=[Q,n,m];break}}else if(s&&(j=(b[N]||(b[N]={}))[a])&&j[0]===Q)m=j[1];else for(;(l=++n&&l&&l[p]||(m=n=0)||o.pop())&&((h?l.nodeName.toLowerCase()!==r:1!==l.nodeType)||!++m||(s&&((l[N]||(l[N]={}))[a]=[Q,m]),l!==b)););return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,d=y.pseudos[a]||y.setFilters[a.toLowerCase()]||g.error("unsupported pseudo: "+a);return d[N]?d(b):d.length>1?(c=[a,a,"",b], y.setFilters.hasOwnProperty(a.toLowerCase())?e(function(a,c){for(var e,f=d(a,b),g=f.length;g--;)e=_.call(a,f[g]),a[e]=!(c[e]=f[g])}):function(a){return d(a,0,c)}):d}},pseudos:{not:e(function(a){var b=[],c=[],d=B(a.replace(ga,"$1"));return d[N]?e(function(a,b,c,e){for(var f,g=d(a,null,e,[]),h=a.length;h--;)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),!c.pop()}}),has:e(function(a){return function(b){return g(a,b).length>0}}),contains:e(function(a){return function(b){return(b.textContent||b.innerText||z(b)).indexOf(a)>-1}}),lang:e(function(a){return la.test(a||"")||g.error("unsupported lang: "+a),a=a.replace(ua,va).toLowerCase(),function(b){var c;do if(c=H?b.getAttribute("xml:lang")||b.getAttribute("lang"):b.lang)return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===G},focus:function(a){return a===F.activeElement&&(!F.hasFocus||F.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeName>"@"||3===a.nodeType||4===a.nodeType)return!1;return!0},parent:function(a){return!y.pseudos.empty(a)},header:function(a){return ra.test(a.nodeName)},input:function(a){return qa.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||b.toLowerCase()===a.type)},first:k(function(){return[0]}),last:k(function(a,b){return[b-1]}),eq:k(function(a,b,c){return[c<0?c+b:c]}),even:k(function(a,b){for(var c=0;c=0;)a.push(d);return a}),gt:k(function(a,b,c){for(var d=c<0?c+b:c;++d1?ia.unique(c):c),c.selector=(this.selector?this.selector+" ":"")+a,c},has:function(a){var b,c=ia(a,this),d=c.length;return this.filter(function(){for(b=0;b=0:ia.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=Sa.test(a)||"string"!=typeof a?ia(a,b||this.context):0;d-1:ia.find.matchesSelector(c,a)){f.push(c);break}c=c.parentNode}return this.pushStack(f.length>1?ia.unique(f):f)},index:function(a){return a?"string"==typeof a?ia.inArray(this[0],ia(a)):ia.inArray(a.jquery?a[0]:a,this):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){var c="string"==typeof a?ia(a,b):ia.makeArray(a&&a.nodeType?[a]:a),d=ia.merge(this.get(),c);return this.pushStack(ia.unique(d))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}}),ia.fn.andSelf=ia.fn.addBack,ia.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return ia.dir(a,"parentNode")},parentsUntil:function(a,b,c){return ia.dir(a,"parentNode",c)},next:function(a){return k(a,"nextSibling")},prev:function(a){return k(a,"previousSibling")},nextAll:function(a){return ia.dir(a,"nextSibling")},prevAll:function(a){return ia.dir(a,"previousSibling")},nextUntil:function(a,b,c){return ia.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return ia.dir(a,"previousSibling",c)},siblings:function(a){return ia.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return ia.sibling(a.firstChild)},contents:function(a){return ia.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:ia.merge([],a.childNodes)}},function(a,b){ia.fn[a]=function(c,d){var e=ia.map(this,b,c);return Pa.test(a)||(d=c),d&&"string"==typeof d&&(e=ia.filter(d,e)),e=this.length>1&&!Ta[a]?ia.unique(e):e,this.length>1&&Qa.test(a)&&(e=e.reverse()),this.pushStack(e)}}),ia.extend({filter:function(a,b,c){return c&&(a=":not("+a+")"),1===b.length?ia.find.matchesSelector(b[0],a)?[b[0]]:[]:ia.find.matches(a,b)},dir:function(a,c,d){for(var e=[],f=a[c];f&&9!==f.nodeType&&(d===b||1!==f.nodeType||!ia(f).is(d));)1===f.nodeType&&e.push(f),f=f[c];return e},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}});var Ua="abbr|article|aside|audio|bdi|canvas|data|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",Va=/ jQuery\d+="(?:null|\d+)"/g,Wa=new RegExp("<(?:"+Ua+")[\\s/>]","i"),Xa=/^\s+/,Ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,Za=/<([\w:]+)/,$a=/\s*$/g,gb={option:[1,""],legend:[1,"
","
"],area:[1,"",""],param:[1,"",""],thead:[1,"","
"],tr:[2,"","
"],col:[2,"","
"],td:[3,"","
"],_default:ia.support.htmlSerialize?[0,"",""]:[1,"X
","
"]},hb=m(W),ib=hb.appendChild(W.createElement("div"));gb.optgroup=gb.option,gb.tbody=gb.tfoot=gb.colgroup=gb.caption=gb.thead,gb.th=gb.td,ia.fn.extend({text:function(a){return ia.access(this,function(a){return a===b?ia.text(this):this.empty().append((this[0]&&this[0].ownerDocument||W).createTextNode(a))},null,a,arguments.length)},wrapAll:function(a){if(ia.isFunction(a))return this.each(function(b){ia(this).wrapAll(a.call(this,b))});if(this[0]){var b=ia(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){for(var a=this;a.firstChild&&1===a.firstChild.nodeType;)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){return ia.isFunction(a)?this.each(function(b){ia(this).wrapInner(a.call(this,b))}):this.each(function(){var b=ia(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=ia.isFunction(a);return this.each(function(c){ia(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){ia.nodeName(this,"body")||ia(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||this.insertBefore(a,this.firstChild)})},before:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,!1,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=0;null!=(c=this[d]);d++)(!a||ia.filter(a,[c]).length>0)&&(b||1!==c.nodeType||ia.cleanData(t(c)),c.parentNode&&(b&&ia.contains(c.ownerDocument,c)&&q(t(c,"script")),c.parentNode.removeChild(c)));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++){for(1===a.nodeType&&ia.cleanData(t(a,!1));a.firstChild;)a.removeChild(a.firstChild);a.options&&ia.nodeName(a,"select")&&(a.options.length=0)}return this},clone:function(a,b){return a=null!=a&&a,b=null==b?a:b,this.map(function(){return ia.clone(this,a,b)})},html:function(a){return ia.access(this,function(a){var c=this[0]||{},d=0,e=this.length;if(a===b)return 1===c.nodeType?c.innerHTML.replace(Va,""):b;if("string"==typeof a&&!ab.test(a)&&(ia.support.htmlSerialize||!Wa.test(a))&&(ia.support.leadingWhitespace||!Xa.test(a))&&!gb[(Za.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Ya,"<$1>");try{for(;d")?f=a.cloneNode(!0):(ib.innerHTML=a.outerHTML,ib.removeChild(f=ib.firstChild)),!(ia.support.noCloneEvent&&ia.support.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||ia.isXMLDoc(a)))for(d=t(f),h=t(a),g=0;null!=(e=h[g]);++g)d[g]&&s(e,d[g]);if(b)if(c)for(h=h||t(a),d=d||t(f),g=0;null!=(e=h[g]);g++)r(e,d[g]);else r(a,f);return d=t(f,"script"),d.length>0&&q(d,!i&&t(a,"script")),d=h=e=null,f},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k,l=a.length,n=m(b),o=[],p=0;p")+k[2],e=k[0];e--;)h=h.lastChild;if(!ia.support.leadingWhitespace&&Xa.test(f)&&o.push(b.createTextNode(Xa.exec(f)[0])),!ia.support.tbody)for(f="table"!==i||$a.test(f)?""!==k[1]||$a.test(f)?0:h:h.firstChild,e=f&&f.childNodes.length;e--;)ia.nodeName(j=f.childNodes[e],"tbody")&&!j.childNodes.length&&f.removeChild(j);for(ia.merge(o,h.childNodes),h.textContent="";h.firstChild;)h.removeChild(h.firstChild);h=n.lastChild}else o.push(b.createTextNode(f));for(h&&n.removeChild(h),ia.support.appendChecked||ia.grep(t(o,"input"),u),p=0;f=o[p++];)if((!d||ia.inArray(f,d)===-1)&&(g=ia.contains(f.ownerDocument,f),h=t(n.appendChild(f),"script"),g&&q(h),c))for(e=0;f=h[e++];)db.test(f.type||"")&&c.push(f);return h=null,n},cleanData:function(a,b){for(var c,d,e,f,g=0,h=ia.expando,i=ia.cache,j=ia.support.deleteExpando,k=ia.event.special;null!=(c=a[g]);g++)if((b||ia.acceptData(c))&&(e=c[h],f=e&&i[e])){if(f.events)for(d in f.events)k[d]?ia.event.remove(c,d):ia.removeEvent(c,d,f.handle);i[e]&&(delete i[e],j?delete c[h]:typeof c.removeAttribute!==V?c.removeAttribute(h):c[h]=null,_.push(e))}}});var jb,kb,lb,mb=/alpha\([^)]*\)/i,nb=/opacity\s*=\s*([^)]*)/,ob=/^(top|right|bottom|left)$/,pb=/^(none|table(?!-c[ea]).+)/,qb=/^margin/,rb=new RegExp("^("+ja+")(.*)$","i"),sb=new RegExp("^("+ja+")(?!px)[a-z%]+$","i"),tb=new RegExp("^([+-])=("+ja+")","i"),ub={BODY:"block"},vb={position:"absolute",visibility:"hidden",display:"block"},wb={letterSpacing:0,fontWeight:400},xb=["Top","Right","Bottom","Left"],yb=["Webkit","O","Moz","ms"];ia.fn.extend({css:function(a,c){return ia.access(this,function(a,c,d){var e,f,g={},h=0;if(ia.isArray(c)){for(f=kb(a),e=c.length;h1)},show:function(){return x(this,!0)},hide:function(){return x(this)},toggle:function(a){var b="boolean"==typeof a;return this.each(function(){(b?a:w(this))?ia(this).show():ia(this).hide()})}}),ia.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=lb(a,"opacity");return""===c?"1":c}}}},cssNumber:{columnCount:!0,fillOpacity:!0,fontWeight:!0,lineHeight:!0,opacity:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{"float":ia.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,d,e){if(a&&3!==a.nodeType&&8!==a.nodeType&&a.style){var f,g,h,i=ia.camelCase(c),j=a.style;if(c=ia.cssProps[i]||(ia.cssProps[i]=v(j,i)),h=ia.cssHooks[c]||ia.cssHooks[i],d===b)return h&&"get"in h&&(f=h.get(a,!1,e))!==b?f:j[c];if(g=typeof d,"string"===g&&(f=tb.exec(d))&&(d=(f[1]+1)*f[2]+parseFloat(ia.css(a,c)),g="number"),!(null==d||"number"===g&&isNaN(d)||("number"!==g||ia.cssNumber[i]||(d+="px"),ia.support.clearCloneStyle||""!==d||0!==c.indexOf("background")||(j[c]="inherit"),h&&"set"in h&&(d=h.set(a,d,e))===b)))try{j[c]=d}catch(k){}}},css:function(a,c,d,e){var f,g,h,i=ia.camelCase(c);return c=ia.cssProps[i]||(ia.cssProps[i]=v(a.style,i)),h=ia.cssHooks[c]||ia.cssHooks[i],h&&"get"in h&&(g=h.get(a,!0,d)),g===b&&(g=lb(a,c,e)),"normal"===g&&c in wb&&(g=wb[c]),""===d||d?(f=parseFloat(g),d===!0||ia.isNumeric(f)?f||0:g):g},swap:function(a,b,c,d){var e,f,g={};for(f in b)g[f]=a.style[f],a.style[f]=b[f];e=c.apply(a,d||[]);for(f in b)a.style[f]=g[f];return e}}),a.getComputedStyle?(kb=function(b){return a.getComputedStyle(b,null)},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h.getPropertyValue(c)||h[c]:b,j=a.style;return h&&(""!==i||ia.contains(a.ownerDocument,a)||(i=ia.style(a,c)),sb.test(i)&&qb.test(c)&&(e=j.width,f=j.minWidth,g=j.maxWidth,j.minWidth=j.maxWidth=j.width=i,i=h.width,j.width=e,j.minWidth=f,j.maxWidth=g)),i}):W.documentElement.currentStyle&&(kb=function(a){return a.currentStyle},lb=function(a,c,d){var e,f,g,h=d||kb(a),i=h?h[c]:b,j=a.style;return null==i&&j&&j[c]&&(i=j[c]),sb.test(i)&&!ob.test(c)&&(e=j.left,f=a.runtimeStyle,g=f&&f.left,g&&(f.left=a.currentStyle.left),j.left="fontSize"===c?"1em":i,i=j.pixelLeft+"px",j.left=e,g&&(f.left=g)),""===i?"auto":i}),ia.each(["height","width"],function(a,b){ia.cssHooks[b]={get:function(a,c,d){if(c)return 0===a.offsetWidth&&pb.test(ia.css(a,"display"))?ia.swap(a,vb,function(){return A(a,b,d)}):A(a,b,d)},set:function(a,c,d){var e=d&&kb(a);return y(a,c,d?z(a,b,d,ia.support.boxSizing&&"border-box"===ia.css(a,"boxSizing",!1,e),e):0)}}}),ia.support.opacity||(ia.cssHooks.opacity={get:function(a,b){return nb.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?.01*parseFloat(RegExp.$1)+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=ia.isNumeric(b)?"alpha(opacity="+100*b+")":"",f=d&&d.filter||c.filter||"";c.zoom=1,(b>=1||""===b)&&""===ia.trim(f.replace(mb,""))&&c.removeAttribute&&(c.removeAttribute("filter"),""===b||d&&!d.filter)||(c.filter=mb.test(f)?f.replace(mb,e):f+" "+e)}}),ia(function(){ia.support.reliableMarginRight||(ia.cssHooks.marginRight={get:function(a,b){if(b)return ia.swap(a,{display:"inline-block"},lb,[a,"marginRight"])}}),!ia.support.pixelPosition&&ia.fn.position&&ia.each(["top","left"],function(a,b){ia.cssHooks[b]={get:function(a,c){if(c)return c=lb(a,b),sb.test(c)?ia(a).position()[b]+"px":c}}})}),ia.expr&&ia.expr.filters&&(ia.expr.filters.hidden=function(a){return a.offsetWidth<=0&&a.offsetHeight<=0||!ia.support.reliableHiddenOffsets&&"none"===(a.style&&a.style.display||ia.css(a,"display"))},ia.expr.filters.visible=function(a){return!ia.expr.filters.hidden(a)}),ia.each({margin:"",padding:"",border:"Width"},function(a,b){ia.cssHooks[a+b]={expand:function(c){for(var d=0,e={},f="string"==typeof c?c.split(" "):[c];d<4;d++)e[a+xb[d]+b]=f[d]||f[d-2]||f[0];return e}},qb.test(a)||(ia.cssHooks[a+b].set=y)});var zb=/%20/g,Ab=/\[\]$/,Bb=/\r?\n/g,Cb=/^(?:submit|button|image|reset|file)$/i,Db=/^(?:input|select|textarea|keygen)/i;ia.fn.extend({serialize:function(){return ia.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var a=ia.prop(this,"elements");return a?ia.makeArray(a):this}).filter(function(){var a=this.type;return this.name&&!ia(this).is(":disabled")&&Db.test(this.nodeName)&&!Cb.test(a)&&(this.checked||!bb.test(a))}).map(function(a,b){var c=ia(this).val();return null==c?null:ia.isArray(c)?ia.map(c,function(a){return{name:b.name,value:a.replace(Bb,"\r\n")}}):{name:b.name,value:c.replace(Bb,"\r\n")}}).get()}}),ia.param=function(a,c){var d,e=[],f=function(a,b){b=ia.isFunction(b)?b():null==b?"":b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};if(c===b&&(c=ia.ajaxSettings&&ia.ajaxSettings.traditional),ia.isArray(a)||a.jquery&&!ia.isPlainObject(a))ia.each(a,function(){f(this.name,this.value)});else for(d in a)D(d,a[d],c,f);return e.join("&").replace(zb,"+")},ia.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu".split(" "),function(a,b){ia.fn[b]=function(a,c){return arguments.length>0?this.on(b,null,a,c):this.trigger(b)}}),ia.fn.hover=function(a,b){return this.mouseenter(a).mouseleave(b||a)};var Eb,Fb,Gb=ia.now(),Hb=/\?/,Ib=/#.*$/,Jb=/([?&])_=[^&]*/,Kb=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,Lb=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,Mb=/^(?:GET|HEAD)$/,Nb=/^\/\//,Ob=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,Pb=ia.fn.load,Qb={},Rb={},Sb="*/".concat("*");try{Fb=X.href}catch(Tb){Fb=W.createElement("a"),Fb.href="",Fb=Fb.href}Eb=Ob.exec(Fb.toLowerCase())||[],ia.fn.load=function(a,c,d){if("string"!=typeof a&&Pb)return Pb.apply(this,arguments);var e,f,g,h=this,i=a.indexOf(" ");return i>=0&&(e=a.slice(i,a.length),a=a.slice(0,i)),ia.isFunction(c)?(d=c,c=b):c&&"object"==typeof c&&(g="POST"),h.length>0&&ia.ajax({url:a,type:g,dataType:"html",data:c}).done(function(a){f=arguments,h.html(e?ia("
").append(ia.parseHTML(a)).find(e):a)}).complete(d&&function(a,b){h.each(d,f||[a.responseText,b,a])}),this},ia.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){ia.fn[b]=function(a){return this.on(b,a)}}),ia.each(["get","post"],function(a,c){ia[c]=function(a,d,e,f){return ia.isFunction(d)&&(f=f||e,e=d,d=b),ia.ajax({url:a,type:c,dataType:f,data:d,success:e})}}),ia.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:Fb,type:"GET",isLocal:Lb.test(Eb[1]),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Sb,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":ia.parseJSON,"text xml":ia.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(a,b){return b?G(G(a,ia.ajaxSettings),b):G(ia.ajaxSettings,a)},ajaxPrefilter:E(Qb),ajaxTransport:E(Rb),ajax:function(a,c){function d(a,c,d,e){var f,l,s,t,v,x=c;2!==u&&(u=2,i&&clearTimeout(i),k=b,h=e||"",w.readyState=a>0?4:0,d&&(t=H(m,w,d)),a>=200&&a<300||304===a?(m.ifModified&&(v=w.getResponseHeader("Last-Modified"),v&&(ia.lastModified[g]=v),v=w.getResponseHeader("etag"),v&&(ia.etag[g]=v)),204===a?(f=!0,x="nocontent"):304===a?(f=!0,x="notmodified"):(f=I(m,t),x=f.state,l=f.data,s=f.error,f=!s)):(s=x,!a&&x||(x="error",a<0&&(a=0))),w.status=a,w.statusText=(c||x)+"",f?p.resolveWith(n,[l,x,w]):p.rejectWith(n,[w,x,s]),w.statusCode(r),r=b,j&&o.trigger(f?"ajaxSuccess":"ajaxError",[w,m,f?l:s]),q.fireWith(n,[w,x]),j&&(o.trigger("ajaxComplete",[w,m]),--ia.active||ia.event.trigger("ajaxStop")))}"object"==typeof a&&(c=a,a=b),c=c||{};var e,f,g,h,i,j,k,l,m=ia.ajaxSetup({},c),n=m.context||m,o=m.context&&(n.nodeType||n.jquery)?ia(n):ia.event,p=ia.Deferred(),q=ia.Callbacks("once memory"),r=m.statusCode||{},s={},t={},u=0,v="canceled",w={readyState:0,getResponseHeader:function(a){var b;if(2===u){if(!l)for(l={};b=Kb.exec(h);)l[b[1].toLowerCase()]=b[2];b=l[a.toLowerCase()]}return null==b?null:b},getAllResponseHeaders:function(){return 2===u?h:null},setRequestHeader:function(a,b){var c=a.toLowerCase();return u||(a=t[c]=t[c]||a,s[a]=b),this},overrideMimeType:function(a){return u||(m.mimeType=a),this},statusCode:function(a){var b;if(a)if(u<2)for(b in a)r[b]=[r[b],a[b]];else w.always(a[w.status]);return this},abort:function(a){var b=a||v;return k&&k.abort(b),d(0,b),this}};if(p.promise(w).complete=q.add,w.success=w.done,w.error=w.fail,m.url=((a||m.url||Fb)+"").replace(Ib,"").replace(Nb,Eb[1]+"//"),m.type=c.method||c.type||m.method||m.type,m.dataTypes=ia.trim(m.dataType||"*").toLowerCase().match(ka)||[""],null==m.crossDomain&&(e=Ob.exec(m.url.toLowerCase()),m.crossDomain=!(!e||e[1]===Eb[1]&&e[2]===Eb[2]&&(e[3]||("http:"===e[1]?80:443))==(Eb[3]||("http:"===Eb[1]?80:443)))),m.data&&m.processData&&"string"!=typeof m.data&&(m.data=ia.param(m.data,m.traditional)),F(Qb,m,c,w),2===u)return w;j=m.global,j&&0===ia.active++&&ia.event.trigger("ajaxStart"),m.type=m.type.toUpperCase(),m.hasContent=!Mb.test(m.type),g=m.url,m.hasContent||(m.data&&(g=m.url+=(Hb.test(g)?"&":"?")+m.data,delete m.data),m.cache===!1&&(m.url=Jb.test(g)?g.replace(Jb,"$1_="+Gb++):g+(Hb.test(g)?"&":"?")+"_="+Gb++)),m.ifModified&&(ia.lastModified[g]&&w.setRequestHeader("If-Modified-Since",ia.lastModified[g]),ia.etag[g]&&w.setRequestHeader("If-None-Match",ia.etag[g])),(m.data&&m.hasContent&&m.contentType!==!1||c.contentType)&&w.setRequestHeader("Content-Type",m.contentType),w.setRequestHeader("Accept",m.dataTypes[0]&&m.accepts[m.dataTypes[0]]?m.accepts[m.dataTypes[0]]+("*"!==m.dataTypes[0]?", "+Sb+"; q=0.01":""):m.accepts["*"]);for(f in m.headers)w.setRequestHeader(f,m.headers[f]);if(m.beforeSend&&(m.beforeSend.call(n,w,m)===!1||2===u))return w.abort();v="abort";for(f in{success:1,error:1,complete:1})w[f](m[f]);if(k=F(Rb,m,c,w)){w.readyState=1,j&&o.trigger("ajaxSend",[w,m]),m.async&&m.timeout>0&&(i=setTimeout(function(){w.abort("timeout")},m.timeout));try{u=1,k.send(s,d)}catch(x){if(!(u<2))throw x;d(-1,x)}}else d(-1,"No Transport");return w},getScript:function(a,c){return ia.get(a,b,c,"script")},getJSON:function(a,b,c){return ia.get(a,b,c,"json")}}),ia.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/(?:java|ecma)script/},converters:{"text script":function(a){return ia.globalEval(a),a}}}),ia.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),ia.ajaxTransport("script",function(a){if(a.crossDomain){var c,d=W.head||ia("head")[0]||W.documentElement;return{send:function(b,e){c=W.createElement("script"),c.async=!0,a.scriptCharset&&(c.charset=a.scriptCharset),c.src=a.url,c.onload=c.onreadystatechange=function(a,b){(b||!c.readyState||/loaded|complete/.test(c.readyState))&&(c.onload=c.onreadystatechange=null,c.parentNode&&c.parentNode.removeChild(c),c=null,b||e(200,"success"))},d.insertBefore(c,d.firstChild)},abort:function(){c&&c.onload(b,!0)}}}});var Ub=[],Vb=/(=)\?(?=&|$)|\?\?/;ia.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var a=Ub.pop()||ia.expando+"_"+Gb++;return this[a]=!0,a}}),ia.ajaxPrefilter("json jsonp",function(c,d,e){var f,g,h,i=c.jsonp!==!1&&(Vb.test(c.url)?"url":"string"==typeof c.data&&!(c.contentType||"").indexOf("application/x-www-form-urlencoded")&&Vb.test(c.data)&&"data");if(i||"jsonp"===c.dataTypes[0])return f=c.jsonpCallback=ia.isFunction(c.jsonpCallback)?c.jsonpCallback():c.jsonpCallback,i?c[i]=c[i].replace(Vb,"$1"+f):c.jsonp!==!1&&(c.url+=(Hb.test(c.url)?"&":"?")+c.jsonp+"="+f),c.converters["script json"]=function(){return h||ia.error(f+" was not called"),h[0]},c.dataTypes[0]="json",g=a[f],a[f]=function(){h=arguments},e.always(function(){a[f]=g,c[f]&&(c.jsonpCallback=d.jsonpCallback,Ub.push(f)),h&&ia.isFunction(g)&&g(h[0]),h=g=b}),"script"});var Wb,Xb,Yb=0,Zb=a.ActiveXObject&&function(){var a;for(a in Wb)Wb[a](b,!0)};ia.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&J()||K()}:J,Xb=ia.ajaxSettings.xhr(),ia.support.cors=!!Xb&&"withCredentials"in Xb,Xb=ia.support.ajax=!!Xb,Xb&&ia.ajaxTransport(function(c){if(!c.crossDomain||ia.support.cors){var d;return{send:function(e,f){var g,h,i=c.xhr();if(c.username?i.open(c.type,c.url,c.async,c.username,c.password):i.open(c.type,c.url,c.async),c.xhrFields)for(h in c.xhrFields)i[h]=c.xhrFields[h];c.mimeType&&i.overrideMimeType&&i.overrideMimeType(c.mimeType),c.crossDomain||e["X-Requested-With"]||(e["X-Requested-With"]="XMLHttpRequest");try{for(h in e)i.setRequestHeader(h,e[h])}catch(j){}i.send(c.hasContent&&c.data||null),d=function(a,e){var h,j,k,l;try{if(d&&(e||4===i.readyState))if(d=b,g&&(i.onreadystatechange=ia.noop,Zb&&delete Wb[g]),e)4!==i.readyState&&i.abort();else{l={},h=i.status,j=i.getAllResponseHeaders(),"string"==typeof i.responseText&&(l.text=i.responseText);try{k=i.statusText}catch(m){k=""}h||!c.isLocal||c.crossDomain?1223===h&&(h=204):h=l.text?200:404}}catch(n){e||f(-1,n)}l&&f(h,k,l,j)},c.async?4===i.readyState?setTimeout(d):(g=++Yb,Zb&&(Wb||(Wb={},ia(a).unload(Zb)),Wb[g]=d),i.onreadystatechange=d):d()},abort:function(){d&&d(b,!0)}}}});var $b,_b,ac=/^(?:toggle|show|hide)$/,bc=new RegExp("^(?:([+-])=|)("+ja+")([a-z%]*)$","i"),cc=/queueHooks$/,dc=[P],ec={"*":[function(a,b){var c,d,e=this.createTween(a,b),f=bc.exec(b),g=e.cur(),h=+g||0,i=1,j=20;if(f){if(c=+f[2],d=f[3]||(ia.cssNumber[a]?"":"px"),"px"!==d&&h){h=ia.css(e.elem,a,!0)||c||1;do i=i||".5",h/=i,ia.style(e.elem,a,h+d);while(i!==(i=e.cur()/g)&&1!==i&&--j)}e.unit=d,e.start=h,e.end=f[1]?h+(f[1]+1)*c:c}return e}]};ia.Animation=ia.extend(N,{tweener:function(a,b){ia.isFunction(a)?(b=a,a=["*"]):a=a.split(" ");for(var c,d=0,e=a.length;d-1,l={},m={}; diff --git a/utils/utils.js b/dist/utils.js similarity index 100% rename from utils/utils.js rename to dist/utils.js diff --git a/dist/utils.min.js b/dist/utils.min.js new file mode 100644 index 000000000..1b60dd376 --- /dev/null +++ b/dist/utils.min.js @@ -0,0 +1,6 @@ +/*! fineui 23-07-2018 */ +function accAdd(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g){c=0}try{d=b.toString().split(".")[1].length}catch(g){d=0}if(f=Math.abs(c-d),e=Math.pow(10,Math.max(c,d)),f>0){var h=Math.pow(10,f);c>d?(a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""))*h):(a=Number(a.toString().replace(".",""))*h,b=Number(b.toString().replace(".","")))}else a=Number(a.toString().replace(".","")),b=Number(b.toString().replace(".",""));return(a+b)/e}function accSub(a,b){var c,d,e,f;try{c=a.toString().split(".")[1].length}catch(g){c=0}try{d=b.toString().split(".")[1].length}catch(g){d=0}return e=Math.pow(10,Math.max(c,d)),f=c>=d?c:d,((a*e-b*e)/e).toFixed(f)}function accMul(a,b){var c=0,d=a.toString(),e=b.toString();try{c+=d.split(".")[1].length}catch(f){}try{c+=e.split(".")[1].length}catch(f){}return Number(d.replace(".",""))*Number(e.replace(".",""))/Math.pow(10,c)}function digitLength(a){var b=a.toString().split(/[eE]/),c=(b[0].split(".")[1]||"").length-+(b[1]||0);return c>0?c:0}function float2Fixed(a){if(a.toString().indexOf("e")===-1)return Number(a.toString().replace(".",""));var b=digitLength(a);return b>0?a*Math.pow(10,b):a}function times(a,b){for(var c=[],d=2;d0)return times.apply(void 0,[times(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b),g=digitLength(a)+digitLength(b),h=e*f;return h/Math.pow(10,g)}function accDivide(a,b){for(var c=[],d=2;d0)return accDivide.apply(void 0,[accDivide(a,b),c[0]].concat(c.slice(1)));var e=float2Fixed(a),f=float2Fixed(b);return times(e/f,Math.pow(10,digitLength(b)-digitLength(a)))}(function(){function a(a,b,c){switch(c.length){case 0:return a.call(b);case 1:return a.call(b,c[0]);case 2:return a.call(b,c[0],c[1]);case 3:return a.call(b,c[0],c[1],c[2])}return a.apply(b,c)}function b(a,b,c,d){for(var e=-1,f=null==a?0:a.length;++e-1}function g(a,b,c){for(var d=-1,e=null==a?0:a.length;++d-1}function ca(a,b){var c=this.__data__,d=va(c,a);return d<0?(++this.size,c.push([a,b])):c[d][1]=b,this}function da(a){var b=-1,c=null==a?0:a.length;for(this.clear();++b=b?a:b)),a}function Ca(a,b,d,e,f,g){var h,i=b&Le,j=b&Me,k=b&Ne;if(d&&(h=f?d(a,e,f,g):d(a)),h!==Ee)return h;if(!Pd(a))return a;var l=oi(a);if(l){if(h=uc(a),!i)return Nb(a,h)}else{var m=Zh(a),n=m==qf||m==rf;if(pi(a))return Db(a,i);if(m==vf||m==kf||n&&!f){if(h=j||n?{}:vc(a),!i)return j?Qb(a,ya(h,a)):Pb(a,xa(h,a))}else{if(!Ag[m])return f?a:{};h=wc(a,m,i)}}g||(g=new ma);var o=g.get(a);if(o)return o;if(g.set(a,h),ti(a))return a.forEach(function(c){h.add(Ca(c,b,d,c,a,g))}),h;if(ri(a))return a.forEach(function(c,e){h.set(e,Ca(c,b,d,e,a,g))}),h;var p=k?j?kc:jc:j?je:ie,q=l?Ee:p(a);return c(q||a,function(c,e){q&&(e=c,c=a[e]),ua(h,e,Ca(c,b,d,e,a,g))}),h}function Da(a,b,c){if("function"!=typeof a)throw new TypeError(He);return setTimeout(function(){a.apply(Ee,c)},b)}function Ea(a,b,c,d){var e=-1,i=f,j=!0,k=a.length,l=[],m=b.length;if(!k)return l;c&&(b=h(b,v(c))),d?(i=g,j=!1):b.length>=Ge&&(i=x,j=!1,b=new ja(b));a:for(;++e0&&c(h)?b>1?Ia(h,b-1,c,d,e):i(e,h):d||(e[e.length]=h)}return e}function Ja(a,b){return a&&Rh(a,b,ie)}function Ka(a,b){return a&&Sh(a,b,ie)}function La(a,b){return e(b,function(b){return Nd(a[b])})}function Ma(a,b){b=Cb(b,a);for(var c=0,d=b.length;null!=a&&cb}function Qa(a,b){return null!=a&&Yg.call(a,b)}function Ra(a,b){return null!=a&&b in Object(a)}function Sa(a,b,c){for(var d=c?g:f,e=a[0].length,i=a.length,j=i,k=Array(i),l=1/0,m=[];j--;){var n=a[j];j&&b&&(n=h(n,v(b))),l=wh(n.length,l),k[j]=!c&&(b||e>=120&&n.length>=120)?new ja(j&&n):Ee}n=a[0];var o=-1,p=k[0];a:for(;++oe?0:e+b),c=c>e?e:c,c<0&&(c+=e),e=b>c?0:c-b>>>0,b>>>=0;for(var f=Array(e);++d=Ge){var l=b?null:Vh(a);if(l)return G(l);i=!1,e=x,k=new ja}else k=b?[]:j;a:for(;++db||f&&g&&i&&!h&&!j||d&&g&&i||!c&&i||!e)return 1;if(!d&&!f&&!j&&a=h)return i;var j=c[d];return i*("desc"==j?-1:1)}}return a.index-b.index}function Lb(a,b,c,d){for(var e=-1,f=a.length,g=c.length,h=-1,i=b.length,j=vh(f-g,0),k=Array(i+j),l=!d;++h1?c[e-1]:Ee,g=e>2?c[2]:Ee;for(f=a.length>3&&"function"==typeof f?(e--,f):Ee,g&&Ac(c[0],c[1],g)&&(f=e<3?Ee:f,e=1),b=Object(b);++d-1?e[f?b[g]:g]:Ee}}function Zb(a,b,c,d,e,f,g,h,i,j){function k(){for(var r=arguments.length,s=Array(r),t=r;t--;)s[t]=arguments[t];if(o)var u=mc(k),v=y(s,u);if(d&&(s=Lb(s,d,e,o)),f&&(s=Mb(s,f,g,o)),r-=v,o&&r1&&s.reverse(),l&&ih))return!1;var j=f.get(a);if(j&&f.get(b))return j==b;var l=-1,m=!0,n=c&Pe?new ja:Ee;for(f.set(a,b),f.set(b,a);++l1?"& ":"")+b[d],b=b.join(c>2?", ":" "),a.replace(Wf,"{\n/* [wrapped with "+b+"] */\n")}function yc(a){return oi(a)||ni(a)||!!(lh&&a&&a[lh])}function zc(a,b){var c=typeof a;return b=null==b?ef:b,!!b&&("number"==c||"symbol"!=c&&dg.test(a))&&a>-1&&a%1==0&&a0){if(++b>=$e)return arguments[0]}else b=0;return a.apply(Ee,arguments)}}function Rc(a){if("string"==typeof a||Wd(a))return a;var b=a+"";return"0"==b&&1/a==-df?"-0":b}function Sc(a){if(null!=a){try{return Xg.call(a)}catch(b){}try{return a+""}catch(b){}}return""}function Tc(a,b){return c(jf,function(c){var d="_."+c[0];b&c[1]&&!f(a,d)&&a.push(d)}),a.sort()}function Uc(a){if(a instanceof P)return a.clone();var b=new O(a.__wrapped__,a.__chain__);return b.__actions__=Nb(a.__actions__),b.__index__=a.__index__,b.__values__=a.__values__,b}function Vc(a){for(var b=-1,c=null==a?0:a.length,d=0,e=[];++b0&&(c=b.apply(this,arguments)),a<=1&&(b=Ee),c}}function yd(a,b,c){function d(b){var c=m,d=n;return m=n=Ee,s=b,p=a.apply(d,c)}function e(a){return s=a,q=setTimeout(h,b),t?d(a):p}function f(a){var c=a-r,d=a-s,e=b-c;return u?wh(e,o-d):e}function g(a){var c=a-r,d=a-s;return r===Ee||c>=b||c<0||u&&d>=o}function h(){var a=ji();return g(a)?i(a):void(q=setTimeout(h,f(a)))}function i(a){return q=Ee,v&&m?d(a):(m=n=Ee,p)}function j(){q!==Ee&&clearTimeout(q),s=0,m=r=n=q=Ee}function k(){return q===Ee?p:i(ji())}function l(){var a=ji(),c=g(a);if(m=arguments,n=this,r=a,c){if(q===Ee)return e(r);if(u)return q=setTimeout(h,b),d(r)}return q===Ee&&(q=setTimeout(h,b)),p}var m,n,o,p,q,r,s=0,t=!1,u=!1,v=!0;if("function"!=typeof a)throw new TypeError(He);return b=_d(b)||0,Pd(c)&&(t=!!c.leading,u="maxWait"in c,o=u?vh(_d(c.maxWait)||0,b):o,v="trailing"in c?!!c.trailing:v),l.cancel=j,l.flush=k,l}function zd(a,b){if("function"!=typeof a||null!=b&&"function"!=typeof b)throw new TypeError(He);var c=function(){var d=arguments,e=b?b.apply(this,d):d[0],f=c.cache;if(f.has(e))return f.get(e);var g=a.apply(this,d);return c.cache=f.set(e,g)||f,g};return c.cache=new(zd.Cache||da),c}function Ad(a){if("function"!=typeof a)throw new TypeError(He);return function(){var b=arguments;switch(b.length){case 0:return!a.call(this);case 1:return!a.call(this,b[0]);case 2:return!a.call(this,b[0],b[1]);case 3:return!a.call(this,b[0],b[1],b[2])}return!a.apply(this,b)}}function Bd(a){return xd(2,a)}function Cd(a,b){if("function"!=typeof a)throw new TypeError(He);return b=b===Ee?b:$d(b),sb(a,b)}function Dd(a,b,c){var d=!0,e=!0;if("function"!=typeof a)throw new TypeError(He);return Pd(c)&&(d="leading"in c?!!c.leading:d,e="trailing"in c?!!c.trailing:e),yd(a,b,{leading:d,maxWait:b,trailing:e})}function Ed(a){return Ca(a,Ne)}function Fd(a){return Ca(a,Le|Ne)}function Gd(a,b){return a===b||a!==a&&b!==b}function Hd(a){return null!=a&&Od(a.length)&&!Nd(a)}function Id(a){return Qd(a)&&Hd(a)}function Jd(a){return a===!0||a===!1||Qd(a)&&Oa(a)==nf}function Kd(a){if(null==a)return!0;if(Hd(a)&&(oi(a)||"string"==typeof a||"function"==typeof a.splice||pi(a)||ui(a)||ni(a)))return!a.length;var b=Zh(a);if(b==sf||b==zf)return!a.size;if(Fc(a))return!eb(a).length;for(var c in a)if(Yg.call(a,c))return!1;return!0}function Ld(a,b){return Xa(a,b)}function Md(a){return"number"==typeof a&&th(a)}function Nd(a){if(!Pd(a))return!1;var b=Oa(a);return b==qf||b==rf||b==mf||b==xf}function Od(a){return"number"==typeof a&&a>-1&&a%1==0&&a<=ef}function Pd(a){var b=typeof a;return null!=a&&("object"==b||"function"==b)}function Qd(a){return null!=a&&"object"==typeof a}function Rd(a){return Td(a)&&a!=+a}function Sd(a){return null===a}function Td(a){return"number"==typeof a||Qd(a)&&Oa(a)==tf; +}function Ud(a){if(!Qd(a)||Oa(a)!=vf)return!1;var b=hh(a);if(null===b)return!0;var c=Yg.call(b,"constructor")&&b.constructor;return"function"==typeof c&&c instanceof c&&Xg.call(c)==ah}function Vd(a){return"string"==typeof a||!oi(a)&&Qd(a)&&Oa(a)==Af}function Wd(a){return"symbol"==typeof a||Qd(a)&&Oa(a)==Bf}function Xd(a){return a===Ee}function Yd(a){if(!a)return[];if(Hd(a))return Vd(a)?J(a):Nb(a);if(mh&&a[mh])return B(a[mh]());var b=Zh(a),c=b==sf?C:b==zf?G:ne;return c(a)}function Zd(a){if(!a)return 0===a?a:0;if(a=_d(a),a===df||a===-df){var b=a<0?-1:1;return b*ff}return a===a?a:0}function $d(a){var b=Zd(a),c=b%1;return b===b?c?b-c:b:0}function _d(a){if("number"==typeof a)return a;if(Wd(a))return gf;if(Pd(a)){var b="function"==typeof a.valueOf?a.valueOf():a;a=Pd(b)?b+"":b}if("string"!=typeof a)return 0===a?a:+a;a=a.replace(Vf,"");var c=ag.test(a);return c||cg.test(a)?Dg(a.slice(2),c?2:8):_f.test(a)?gf:+a}function ae(a){return Ob(a,je(a))}function be(a){return null==a?"":wb(a)}function ce(a,b){var c=Ph(a);return null==b?c:xa(c,b)}function de(a,b){return m(a,db(b,3),Ja)}function ee(a,b){return m(a,db(b,3),Ka)}function fe(a,b,c){var d=null==a?Ee:Ma(a,b);return d===Ee?c:d}function ge(a,b){return null!=a&&tc(a,b,Qa)}function he(a,b){return null!=a&&tc(a,b,Ra)}function ie(a){return Hd(a)?sa(a):eb(a)}function je(a){return Hd(a)?sa(a,!0):fb(a)}function ke(a,b){return le(a,Ad(db(b)))}function le(a,b){if(null==a)return{};var c=h(kc(a),function(a){return[a]});return b=db(b),ob(a,c,function(a,c){return b(a,c[0])})}function me(a,b,c){b=Cb(b,a);var d=-1,e=b.length;for(e||(e=1,a=Ee);++db){var d=a;a=b,b=d}if(c||a%1||b%1){var e=yh();return wh(a+e*(b-a+Cg("1e-"+((e+"").length-1))),b)}return qb(a,b)}function qe(a){return a=be(a),a&&Qf.test(a)?a.replace(Pf,Sg):a}function re(a){return function(){return a}}function se(a){return a}function te(a){return db("function"==typeof a?a:Ca(a,Le))}function ue(a){return ib(Ca(a,Le))}function ve(a,b,d){var e=ie(b),f=La(b,e);null!=d||Pd(b)&&(f.length||!e.length)||(d=b,b=a,a=this,f=La(b,ie(b)));var g=!(Pd(d)&&"chain"in d&&!d.chain),h=Nd(a);return c(f,function(c){var d=b[c];a[c]=d,h&&(a.prototype[c]=function(){var b=this.__chain__;if(g||b){var c=a(this.__wrapped__),e=c.__actions__=Nb(this.__actions__);return e.push({func:d,args:arguments,thisArg:a}),c.__chain__=b,c}return d.apply(a,i([this.value()],arguments))})}),a}function we(){return Gg._===this&&(Gg._=bh),this}function xe(){}function ye(a){return Bc(a)?q(Rc(a)):pb(a)}function ze(){return[]}function Ae(){return!1}function Be(a){var b=++Zg;return be(a)+b}function Ce(a){return a&&a.length?Ga(a,se,Pa):Ee}function De(a){return a&&a.length?Ga(a,se,gb):Ee}var Ee,Fe="4.17.5",Ge=200,He="Expected a function",Ie="__lodash_hash_undefined__",Je=500,Ke="__lodash_placeholder__",Le=1,Me=2,Ne=4,Oe=1,Pe=2,Qe=1,Re=2,Se=4,Te=8,Ue=16,Ve=32,We=64,Xe=128,Ye=256,Ze=512,$e=800,_e=16,af=1,bf=2,cf=3,df=1/0,ef=9007199254740991,ff=1.7976931348623157e308,gf=NaN,hf=4294967295,jf=[["ary",Xe],["bind",Qe],["bindKey",Re],["curry",Te],["curryRight",Ue],["flip",Ze],["partial",Ve],["partialRight",We],["rearg",Ye]],kf="[object Arguments]",lf="[object Array]",mf="[object AsyncFunction]",nf="[object Boolean]",of="[object Date]",pf="[object Error]",qf="[object Function]",rf="[object GeneratorFunction]",sf="[object Map]",tf="[object Number]",uf="[object Null]",vf="[object Object]",wf="[object Promise]",xf="[object Proxy]",yf="[object RegExp]",zf="[object Set]",Af="[object String]",Bf="[object Symbol]",Cf="[object Undefined]",Df="[object WeakMap]",Ef="[object ArrayBuffer]",Ff="[object DataView]",Gf="[object Float32Array]",Hf="[object Float64Array]",If="[object Int8Array]",Jf="[object Int16Array]",Kf="[object Int32Array]",Lf="[object Uint8Array]",Mf="[object Uint8ClampedArray]",Nf="[object Uint16Array]",Of="[object Uint32Array]",Pf=/[&<>"']/g,Qf=RegExp(Pf.source),Rf=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Sf=/^\w*$/,Tf=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Uf=/[\\^$.*+?()[\]{}|]/g,Vf=/^\s+|\s+$/g,Wf=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Xf=/\{\n\/\* \[wrapped with (.+)\] \*/,Yf=/,? & /,Zf=/\\(\\)?/g,$f=/\w*$/,_f=/^[-+]0x[0-9a-f]+$/i,ag=/^0b[01]+$/i,bg=/^\[object .+?Constructor\]$/,cg=/^0o[0-7]+$/i,dg=/^(?:0|[1-9]\d*)$/,eg="\\ud800-\\udfff",fg="\\u0300-\\u036f",gg="\\ufe20-\\ufe2f",hg="\\u20d0-\\u20ff",ig=fg+gg+hg,jg="\\ufe0e\\ufe0f",kg="["+eg+"]",lg="["+ig+"]",mg="\\ud83c[\\udffb-\\udfff]",ng="(?:"+lg+"|"+mg+")",og="[^"+eg+"]",pg="(?:\\ud83c[\\udde6-\\uddff]){2}",qg="[\\ud800-\\udbff][\\udc00-\\udfff]",rg="\\u200d",sg=ng+"?",tg="["+jg+"]?",ug="(?:"+rg+"(?:"+[og,pg,qg].join("|")+")"+tg+sg+")*",vg=tg+sg+ug,wg="(?:"+[og+lg+"?",lg,pg,qg,kg].join("|")+")",xg=RegExp(mg+"(?="+mg+")|"+wg+vg,"g"),yg=RegExp("["+rg+eg+ig+jg+"]"),zg={};zg[Gf]=zg[Hf]=zg[If]=zg[Jf]=zg[Kf]=zg[Lf]=zg[Mf]=zg[Nf]=zg[Of]=!0,zg[kf]=zg[lf]=zg[Ef]=zg[nf]=zg[Ff]=zg[of]=zg[pf]=zg[qf]=zg[sf]=zg[tf]=zg[vf]=zg[yf]=zg[zf]=zg[Af]=zg[Df]=!1;var Ag={};Ag[kf]=Ag[lf]=Ag[Ef]=Ag[Ff]=Ag[nf]=Ag[of]=Ag[Gf]=Ag[Hf]=Ag[If]=Ag[Jf]=Ag[Kf]=Ag[sf]=Ag[tf]=Ag[vf]=Ag[yf]=Ag[zf]=Ag[Af]=Ag[Bf]=Ag[Lf]=Ag[Mf]=Ag[Nf]=Ag[Of]=!0,Ag[pf]=Ag[qf]=Ag[Df]=!1;var Bg={"&":"&","<":"<",">":">",'"':""","'":"'"},Cg=parseFloat,Dg=parseInt,Eg="object"==typeof global&&global&&global.Object===Object&&global,Fg="object"==typeof self&&self&&self.Object===Object&&self,Gg=Eg||Fg||Function("return this")(),Hg="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ig=Hg&&"object"==typeof module&&module&&!module.nodeType&&module,Jg=Ig&&Ig.exports===Hg,Kg=Jg&&Eg.process,Lg=function(){try{return Kg&&Kg.binding&&Kg.binding("util")}catch(a){}}(),Mg=Lg&&Lg.isDate,Ng=Lg&&Lg.isMap,Og=Lg&&Lg.isRegExp,Pg=Lg&&Lg.isSet,Qg=Lg&&Lg.isTypedArray,Rg=q("length"),Sg=r(Bg),Tg=Array.prototype,Ug=Function.prototype,Vg=Object.prototype,Wg=Gg["__core-js_shared__"],Xg=Ug.toString,Yg=Vg.hasOwnProperty,Zg=0,$g=function(){var a=/[^.]+$/.exec(Wg&&Wg.keys&&Wg.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}(),_g=Vg.toString,ah=Xg.call(Object),bh=Gg._,ch=RegExp("^"+Xg.call(Yg).replace(Uf,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),dh=Jg?Gg.Buffer:Ee,eh=Gg.Symbol,fh=Gg.Uint8Array,gh=dh?dh.allocUnsafe:Ee,hh=D(Object.getPrototypeOf,Object),ih=Object.create,jh=Vg.propertyIsEnumerable,kh=Tg.splice,lh=eh?eh.isConcatSpreadable:Ee,mh=eh?eh.iterator:Ee,nh=eh?eh.toStringTag:Ee,oh=function(){try{var a=pc(Object,"defineProperty");return a({},"",{}),a}catch(b){}}(),ph=Math.ceil,qh=Math.floor,rh=Object.getOwnPropertySymbols,sh=dh?dh.isBuffer:Ee,th=Gg.isFinite,uh=D(Object.keys,Object),vh=Math.max,wh=Math.min,xh=Date.now,yh=Math.random,zh=(Tg.reverse,pc(Gg,"DataView")),Ah=pc(Gg,"Map"),Bh=pc(Gg,"Promise"),Ch=pc(Gg,"Set"),Dh=pc(Gg,"WeakMap"),Eh=pc(Object,"create"),Fh=Dh&&new Dh,Gh={},Hh=Sc(zh),Ih=Sc(Ah),Jh=Sc(Bh),Kh=Sc(Ch),Lh=Sc(Dh),Mh=eh?eh.prototype:Ee,Nh=Mh?Mh.valueOf:Ee,Oh=Mh?Mh.toString:Ee,Ph=function(){function a(){}return function(b){if(!Pd(b))return{};if(ih)return ih(b);a.prototype=b;var c=new a;return a.prototype=Ee,c}}();M.prototype=N.prototype,M.prototype.constructor=M,O.prototype=Ph(N.prototype),O.prototype.constructor=O,P.prototype=Ph(N.prototype),P.prototype.constructor=P,T.prototype.clear=U,T.prototype["delete"]=V,T.prototype.get=W,T.prototype.has=X,T.prototype.set=Y,Z.prototype.clear=$,Z.prototype["delete"]=_,Z.prototype.get=aa,Z.prototype.has=ba,Z.prototype.set=ca,da.prototype.clear=ea,da.prototype["delete"]=fa,da.prototype.get=ga,da.prototype.has=ha,da.prototype.set=ia,ja.prototype.add=ja.prototype.push=ka,ja.prototype.has=la,ma.prototype.clear=na,ma.prototype["delete"]=oa,ma.prototype.get=pa,ma.prototype.has=qa,ma.prototype.set=ra;var Qh=Tb(Ja),Rh=Ub(),Sh=Ub(!0),Th=Fh?function(a,b){return Fh.set(a,b),a}:se,Uh=oh?function(a,b){return oh(a,"toString",{configurable:!0,enumerable:!1,value:re(b),writable:!0})}:se,Vh=Ch&&1/G(new Ch([,-0]))[1]==df?function(a){return new Ch(a)}:xe,Wh=Fh?function(a){return Fh.get(a)}:xe,Xh=rh?function(a){return null==a?[]:(a=Object(a),e(rh(a),function(b){return jh.call(a,b)}))}:ze,Yh=rh?function(a){for(var b=[];a;)i(b,Xh(a)),a=hh(a);return b}:ze,Zh=Oa;(zh&&Zh(new zh(new ArrayBuffer(1)))!=Ff||Ah&&Zh(new Ah)!=sf||Bh&&Zh(Bh.resolve())!=wf||Ch&&Zh(new Ch)!=zf||Dh&&Zh(new Dh)!=Df)&&(Zh=function(a){var b=Oa(a),c=b==vf?a.constructor:Ee,d=c?Sc(c):"";if(d)switch(d){case Hh:return Ff;case Ih:return sf;case Jh:return wf;case Kh:return zf;case Lh:return Df}return b});var $h=Qc(Th),_h=Qc(Uh),ai=Ic(function(a){var b=[];return 46===a.charCodeAt(0)&&b.push(""),a.replace(Tf,function(a,c,d,e){b.push(d?e.replace(Zf,"$1"):c||a)}),b}),bi=sb(function(a,b){return Id(a)?Ea(a,Ia(b,1,Id,!0)):[]}),ci=sb(function(a){var b=h(a,Bb);return b.length&&b[0]===a[0]?Sa(b):[]}),di=sb(function(a){return xb(Ia(a,1,Id,!0))}),ei=sb(function(a,b){return Id(a)?Ea(a,b):[]}),fi=sb(jd),gi=(ic(function(a){var b=a.length,c=b?a[0]:0,d=this.__wrapped__,e=function(b){return Aa(b,a)};return!(b>1||this.__actions__.length)&&d instanceof P&&zc(c)?(d=d.slice(c,+c+(b?1:0)),d.__actions__.push({func:nd,args:[e],thisArg:Ee}),new O(d,this.__chain__).thru(function(a){return b&&!a.length&&a.push(Ee),a})):this.thru(e)}),Rb(function(a,b,c){Yg.call(a,c)?++a[c]:za(a,c,1)})),hi=Yb(Yc),ii=sb(function(a,b){if(null==a)return[];var c=b.length;return c>1&&Ac(a,b[0],b[1])?b=[]:c>2&&Ac(b[0],b[1],b[2])&&(b=[b[0]]),mb(a,Ia(b,1),[])}),ji=function(){return Gg.Date.now()},ki=sb(function(a,b,c){var d=Qe;if(c.length){var e=E(c,mc(ki));d|=Ve}return cc(a,d,b,c,e)}),li=sb(function(a,b){return Da(a,1,b)}),mi=sb(function(a,b,c){return Da(a,_d(b)||0,c)});zd.Cache=da;var ni=Va(function(){return arguments}())?Va:function(a){return Qd(a)&&Yg.call(a,"callee")&&!jh.call(a,"callee")},oi=Array.isArray,pi=sh||Ae,qi=Mg?v(Mg):Wa,ri=Ng?v(Ng):Za,si=Og?v(Og):ab,ti=Pg?v(Pg):bb,ui=Qg?v(Qg):cb,vi=Sb(function(a,b){Ob(b,je(b),a)}),wi=sb(function(a,b){a=Object(a);var c=-1,d=b.length,e=d>2?b[2]:Ee;for(e&&Ac(b[0],b[1],e)&&(d=1);++c1),b}),Ob(a,kc(a),c),d&&(c=Ca(c,Le|Me|Ne,ec));for(var e=b.length;e--;)yb(c,b[e]);return c}),Ci=ic(function(a,b){return null==a?{}:nb(a,b)}),Di=ac();M.assignIn=vi,M.before=xd,M.bind=ki,M.chain=ld,M.compact=Vc,M.concat=Wc,M.countBy=gi,M.create=ce,M.debounce=yd,M.defaults=wi,M.defaultsDeep=xi,M.defer=li,M.delay=mi,M.difference=bi,M.drop=Xc,M.filter=qd,M.flatten=$c,M.flattenDeep=_c,M.initial=cd,M.intersection=ci,M.invert=yi,M.invertBy=zi,M.iteratee=te,M.keys=ie,M.map=sd,M.matches=ue,M.mixin=ve,M.negate=Ad,M.omit=Bi,M.omitBy=ke,M.once=Bd,M.pick=Ci,M.range=Di,M.reject=ud,M.rest=Cd,M.slice=ed,M.sortBy=ii,M.take=fd,M.takeRight=gd,M.tap=md,M.throttle=Dd,M.thru=nd,M.toArray=Yd,M.union=di,M.uniq=hd,M.uniqBy=id,M.unzip=jd,M.values=ne,M.without=ei,M.zip=fi,M.zipObject=kd,M.extend=vi,ve(M,M),M.clamp=oe,M.clone=Ed,M.cloneDeep=Fd,M.escape=qe,M.every=pd,M.find=hi,M.findIndex=Yc,M.findKey=de,M.findLastIndex=Zc,M.findLastKey=ee,M.forEach=rd,M.get=fe,M.has=ge,M.head=ad,M.identity=se,M.indexOf=bd,M.isArguments=ni,M.isArray=oi,M.isArrayLike=Hd,M.isBoolean=Jd,M.isDate=qi,M.isEmpty=Kd,M.isEqual=Ld,M.isFinite=Md,M.isFunction=Nd,M.isNaN=Rd,M.isNull=Sd,M.isNumber=Td,M.isObject=Pd,M.isPlainObject=Ud,M.isRegExp=si,M.isString=Vd,M.isUndefined=Xd,M.last=dd,M.max=Ce,M.min=De,M.noConflict=we,M.noop=xe,M.random=pe,M.reduce=td,M.result=me,M.size=vd,M.some=wd,M.uniqueId=Be,M.each=rd,M.first=ad,ve(M,function(){var a={};return Ja(M,function(b,c){Yg.call(M.prototype,c)||(a[c]=b)}),a}(),{chain:!1}),M.VERSION=Fe,c(["drop","take"],function(a,b){P.prototype[a]=function(c){c=c===Ee?1:vh($d(c),0);var d=this.__filtered__&&!b?new P(this):this.clone();return d.__filtered__?d.__takeCount__=wh(c,d.__takeCount__):d.__views__.push({size:wh(c,hf),type:a+(d.__dir__<0?"Right":"")}),d},P.prototype[a+"Right"]=function(b){return this.reverse()[a](b).reverse()}}),c(["filter","map","takeWhile"],function(a,b){var c=b+1,d=c==af||c==cf;P.prototype[a]=function(a){var b=this.clone();return b.__iteratees__.push({iteratee:getIteratee(a,3),type:c}),b.__filtered__=b.__filtered__||d,b}}),c(["head","last"],function(a,b){var c="take"+(b?"Right":"");P.prototype[a]=function(){return this[c](1).value()[0]}}),c(["initial","tail"],function(a,b){var c="drop"+(b?"":"Right");P.prototype[a]=function(){return this.__filtered__?new P(this):this[c](1)}}),P.prototype.compact=function(){return this.filter(se)},P.prototype.find=function(a){return this.filter(a).head()},P.prototype.findLast=function(a){return this.reverse().find(a)},P.prototype.invokeMap=sb(function(a,b){return"function"==typeof a?new P(this):this.map(function(c){return Ua(c,a,b)})}),P.prototype.reject=function(a){return this.filter(Ad(getIteratee(a)))},P.prototype.slice=function(a,b){a=$d(a);var c=this;return c.__filtered__&&(a>0||b<0)?new P(c):(a<0?c=c.takeRight(-a):a&&(c=c.drop(a)),b!==Ee&&(b=$d(b),c=b<0?c.dropRight(-b):c.take(b-a)),c)},P.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},P.prototype.toArray=function(){return this.take(hf)},Ja(P.prototype,function(a,b){var c=/^(?:filter|find|map|reject)|While$/.test(b),d=/^(?:head|last)$/.test(b),e=M[d?"take"+("last"==b?"Right":""):b],f=d||/^find/.test(b);e&&(M.prototype[b]=function(){var b=this.__wrapped__,g=d?[1]:arguments,h=b instanceof P,j=g[0],k=h||oi(b),l=function(a){var b=e.apply(M,i([a],g));return d&&m?b[0]:b};k&&c&&"function"==typeof j&&1!=j.length&&(h=k=!1);var m=this.__chain__,n=!!this.__actions__.length,o=f&&!m,p=h&&!n;if(!f&&k){b=p?b:new P(this);var q=a.apply(b,g);return q.__actions__.push({func:nd,args:[l],thisArg:Ee}),new O(q,m)}return o&&p?a.apply(this,g):(q=this.thru(l),o?d?q.value()[0]:q.value():q)})}),c(["pop","push","shift","sort","splice","unshift"],function(a){var b=Tg[a],c=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",d=/^(?:pop|shift)$/.test(a);M.prototype[a]=function(){var a=arguments;if(d&&!this.__chain__){var e=this.value();return b.apply(oi(e)?e:[],a)}return this[c](function(c){return b.apply(oi(c)?c:[],a)})}}),Ja(P.prototype,function(a,b){var c=M[b];if(c){var d=c.name+"",e=Gh[d]||(Gh[d]=[]);e.push({name:b,func:c})}}),Gh[Zb(Ee,Re).name]=[{name:"wrapper",func:Ee}],P.prototype.clone=Q,P.prototype.reverse=R,P.prototype.value=S,M.prototype.first=M.prototype.head,mh&&(M.prototype[mh]=od),"function"==typeof define&&"object"==typeof define.amd&&define.amd?(Gg._=M,define(function(){return M})):Ig?((Ig.exports=M)._=M,Hg._=M):Gg._=M}).call(this),null==window.BI&&(window.BI={}),_.extend(BI,{MAX:0x1000000000000000,MIN:-0x1000000000000000,EVENT_RESPONSE_TIME:200,zIndex_layer:1e5,zIndex_popover:1e6,zIndex_popup:1e7,zIndex_masker:1e8,zIndex_tip:1e9,emptyStr:"",emptyFn:function(){},empty:null,Key:{48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",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",106:"*",107:"+",109:"-",110:".",111:"/"},KeyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38},Status:{SUCCESS:1,WRONG:2,START:3,END:4,WAITING:5,READY:6,RUNNING:7,OUTOFBOUNDS:8,NULL:-1},Direction:{Top:"top",Bottom:"bottom",Left:"left",Right:"right",Custom:"custom"},Axis:{Vertical:"vertical",Horizontal:"horizontal"},Selection:{Default:-2,None:-1,Single:0,Multi:1,All:2},HorizontalAlign:{Left:"left",Right:"right",Center:"center",Stretch:"stretch"},VerticalAlign:{Middle:"middle",Top:"top",Bottom:"bottom",Stretch:"stretch"}}),_.extend(Array.prototype,{contains:function(a){return this.indexOf(a)>-1},remove:function(a){var b=this.indexOf(a);return b!==-1&&this.splice(b,1),this},pushArray:function(a){for(var b=0;b=0;)c+=h[b],h[b]=Math.floor(c/a),c=c%a*f}function c(){for(var a=g,b="";--a>=0;)if(""!==b||0===a||0!==h[a]){var c=String(h[a]);""===b?b=c:b+="0000000".slice(0,7-c.length)+c}return b}function d(a,b,c){return 0===b?c:b%2===1?d(a,b-1,c*a):d(a*a,b/2,c)}function e(a){for(var b=0;a>=4096;)b+=12,a/=4096;for(;a>=2;)b+=1,a/=2;return b}var f,g,h;f=1e7,g=6,h=[0,0,0,0,0,0],Number.prototype.toFixed=function(f){var g,h,i,j,k,l,m,n;if(g=Number(f),g=g!==g?0:Math.floor(g),g<0||g>20)throw new RangeError("Number.toFixed called with invalid number of decimals");if(h=Number(this),h!==h)return"NaN";if(h<=-1e21||h>1e21)return String(h);if(i="",h<0&&(i="-",h=-h),j="0",h>1e-21)if(k=e(h*d(2,69,1))-69,l=k<0?h*d(2,-k,1):h/d(2,k,1),l*=4503599627370496,k=52-k,k>0){for(a(0,l),m=g;m>=7;)a(1e7,0),m-=7;for(a(d(10,m,1),0),m=k-1;m>=23;)b(1<<23),m-=23;b(1<0?(n=j.length,j=n<=g?i+"0.0000000000000000000".slice(0,g-n+2)+j:i+j.slice(0,n-g)+"."+j.slice(n-g)):j=i+j,j}}(),Number.prototype.add=function(a){return accAdd(a,this)},Number.prototype.sub=function(a){return accSub(this,a)},Number.prototype.mul=function(a){return accMul(a,this)},Number.prototype.div=function(a){return accDivide(this,a)},_.extend(String.prototype,{startWith:function(a){return!(null==a||""==a||0===this.length||a.length>this.length)&&this.substr(0,a.length)==a},endWith:function(a){return!(null==a||""==a||0===this.length||a.length>this.length)&&this.substring(this.length-a.length)==a},getQuery:function(a){var b=new RegExp("(^|&)"+a+"=([^&]*)(&|$)"),c=this.substr(this.indexOf("?")+1).match(b);return c?unescape(c[2]):null},appendQuery:function(a){if(!a)return this;var b=this;return b.indexOf("?")===-1&&(b+="?"),b.endWith("?")!==!1||(b+="&"),_.each(a,function(a,c){"string"==typeof c&&(b+=c+"="+a+"&")}),b=b.substr(0,b.length-1)},replaceAll:function(a,b){return this.replace(new RegExp(a,"gm"),b)},perfectStart:function(a){return this.startWith(a)?this:a+this},allIndexOf:function(a){if("string"!=typeof a)return[];for(var b=this,c=[],d=0;b.length>0;){var e=b.indexOf(a);if(e===-1)break;c.push(d+e),b=b.substring(e+a.length,b.length),d+=e+a.length}return c}}),Date.SECOND=1e3,Date.MINUTE=60*Date.SECOND,Date.HOUR=60*Date.MINUTE,Date.DAY=24*Date.HOUR,Date.WEEK=7*Date.DAY,Date.prototype.getTimezone=function(){return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/,"$1$2").replace(/[^A-Z]/g,"")},Date.prototype.getMonthDays=function(a){var b=this.getFullYear();return"undefined"==typeof a&&(a=this.getMonth()),0!=b%4||0==b%100&&0!=b%400||1!=a?Date._MD[a]:29},Date.prototype.getLastDateOfMonth=function(){return BI.getDate(this.getFullYear(),this.getMonth(),this.getMonthDays())},Date.prototype.getDayOfYear=function(){var a=BI.getDate(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0),b=BI.getDate(this.getFullYear(),0,0,0,0,0),c=a-b;return Math.floor(c/Date.DAY)},Date.prototype.getWeekNumber=function(){var a=BI.getDate(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0),b=0===a.getDay()?7:a.getDay();if(0===this.getMonth()&&this.getDate()<=b)return 1;a.setDate(this.getDate()-(b-1));var c=a.valueOf();a.setMonth(0),a.setDate(1);var d=Math.floor((c-a.valueOf())/6048e5)+1;return 1!==a.getDay()&&d++,d},Date.prototype.getQuarter=function(){return Math.floor(this.getMonth()/3)+1},Date.prototype.getOffsetDate=function(a){return BI.getDate(BI.getTime(this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds())+864e5*a)},Date.prototype.getOffsetQuarter=function(a){var b=BI.getDate(BI.getTime(this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds())),c=b.getDate(),d=BI.getDate(b.getFullYear(),b.getMonth()+3*BI.parseInt(a),1).getMonthDays();return c>d&&(c=d),b.setDate(c),b.setMonth(b.getMonth()+3*parseInt(a)),b},Date.prototype.getQuarterStartMonth=function(){var a=0,b=this.getMonth();return b<3&&(a=0),28&&(a=9),a},Date.prototype.getQuarterStartDate=function(){return BI.getDate(this.getFullYear(),this.getQuarterStartMonth(),1)},Date.prototype.getQuarterEndDate=function(){var a=this.getQuarterStartMonth()+2;return BI.getDate(this.getFullYear(),a,this.getMonthDays(a))},Date.prototype.getOffsetMonth=function(a){var b=BI.getDate(BI.getTime(this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds())),c=b.getDate(),d=BI.getDate(b.getFullYear(),b.getMonth()+parseInt(a),1).getMonthDays();return c>d&&(c=d),b.setDate(c),b.setMonth(b.getMonth()+parseInt(a)),b},Date.prototype.getWeekStartDate=function(){var a=this.getDay();return this.getOffsetDate(0===a?-6:1-a)},Date.prototype.getWeekEndDate=function(){var a=this.getDay();return this.getOffsetDate(0===a?0:7-a)},Date.prototype.equalsTo=function(a){return this.getFullYear()==a.getFullYear()&&this.getMonth()==a.getMonth()&&this.getDate()==a.getDate()&&this.getHours()==a.getHours()&&this.getMinutes()==a.getMinutes()&&this.getSeconds()==a.getSeconds()},Date.prototype.setDateOnly=function(a){var b=BI.getDate(a);this.setDate(1),this.setFullYear(b.getFullYear()),this.setMonth(b.getMonth()),this.setDate(b.getDate())},Date.prototype.print=function(a){for(var b=this.getMonth(),c=this.getDate(),d=this.getFullYear(),e=d+"";e.length<4;)e="0"+e;var f=this.getWeekNumber(),g=this.getQuarter(),h=this.getDay(),i={},j=this.getHours(),k=j>=12,l=k?j-12:j,m=this.getDayOfYear();0==l&&(l=12);var n=this.getMinutes(),o=this.getSeconds();i["%a"]=Date._SDN[h],i["%A"]=Date._DN[h],i["%b"]=Date._SMN[b],i["%B"]=Date._MN[b],i["%C"]=1+Math.floor(d/100),i["%d"]=c<10?"0"+c:c,i["%e"]=c,i["%H"]=j<10?"0"+j:j,i["%I"]=l<10?"0"+l:l,i["%j"]=m<100?m<10?"00"+m:"0"+m:m,i["%k"]=j,i["%l"]=l,i["%X"]=b<9?"0"+(1+b):1+b,i["%x"]=b+1,i["%M"]=n<10?"0"+n:n,i["%n"]="\n",i["%p"]=k?"PM":"AM",i["%P"]=k?"pm":"am",i["%s"]=Math.floor(this.getTime()/1e3),i["%S"]=o<10?"0"+o:o,i["%t"]="\t",i["%U"]=i["%W"]=i["%V"]=f<10?"0"+f:f,i["%u"]=h+1,i["%w"]=h,i["%y"]=e.substr(2,2),i["%Y"]=e,i["%%"]="%",i["%Q"]=g;var p=/%./g;if(!BI.isKhtml())return a.replace(p,function(a){return i[a]||a});for(var q=a.match(p),r=0;r1)for(var d=1;d=0;c--)a=BI.map(a,function(a,d){return BI.extend({},b[c],{items:[BI.extend({},b[c].el,{el:d})]})});return a},formatEL:function(a){return a&&!a.type&&a.el?a:{el:a}},stripEL:function(a){return a.type&&a||a.el||a},trans2Element:function(a){return BI.map(a,function(a,b){return b.element})}}),_.each(["where","findWhere","invoke","pluck","shuffle","sample","toArray","size"],function(a){BI[a]=c(a)}),_.each(["get","each","map","reduce","reduceRight","find","filter","reject","every","all","some","any","max","min","sortBy","groupBy","indexBy","countBy","partition","clamp"],function(a){"any"===a?BI[a]=d("some"):BI[a]=d(a)}),_.extend(BI,{count:function(a,b,c){var d;if(c)for(d=a;d=0;d--)b(d,a[d],a);return!1},backAny:function(a,b,c){b=BI.iteratee(b,c);for(var d=a.length-1;d>=0;d--)if(b(d,a[d],a))return!0;return!1},backEvery:function(a,b,c){b=BI.iteratee(b,c);for(var d=a.length-1;d>=0;d--)if(!b(d,a[d],a))return!1;return!0},backFindKey:function(a,b,c){b=BI.iteratee(b,c);for(var d,e=_.keys(a),f=e.length-1;f>=0;f--)if(d=e[f],b(a[d],d,a))return d},backFind:function(a,b,c){var d;if(d=BI.isArray(a)?BI.findLastIndex(a,b,c):BI.backFindKey(a,b,c),void 0!==d&&d!==-1)return a[d]},remove:function(a,b,c){var d=BI.isFunction(b);b=d||BI.isArray(b)?b:[b];var e;if(BI.isArray(a))for(e=0;e(2147483646-a.charAt(d).charCodeAt(0)+c.charCodeAt(0))/26)return 0;return b},int2Abc:function(a){var b=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],c=a,d="";if(0===a)return"";for(;0!==c;){var e=c%26;0===e&&(e=26),d=b[e-1]+d,c=(c-e)/26}return d}}),_.each(["first","initial","last","rest","compact","flatten","without","union","intersection","difference","zip","unzip","object","indexOf","lastIndexOf","sortedIndex","range","take","takeRight"],function(a){BI[a]=c(a)}),_.each(["findIndex","findLastIndex"],function(a){BI[a]=d(a)}),_.extend(BI,{makeArray:function(a,b){for(var c=[],d=0;d0},isCapitalEqual:function(a,b){return a=BI.isNull(a)?a:(""+a).toLowerCase(),b=BI.isNull(b)?b:(""+b).toLowerCase(),BI.isEqual(a,b)},isWidthOrHeight:function(a){return"number"==typeof a?a>=0:"string"==typeof a?/^\d{1,3}%$/.exec(a)||"auto"==a||/^\d+px$/.exec(a):void 0},isNotNull:function(a){return!BI.isNull(a)},isNull:function(a){return"undefined"==typeof a||null===a},isEmptyArray:function(a){return BI.isArray(a)&&BI.isEmpty(a)},isNotEmptyArray:function(a){return BI.isArray(a)&&!BI.isEmpty(a)},isEmptyObject:function(a){return BI.isEqual(a,{})},isNotEmptyObject:function(a){return BI.isPlainObject(a)&&!BI.isEmptyObject(a)},isEmptyString:function(a){return BI.isString(a)&&0===a.length},isNotEmptyString:function(a){return BI.isString(a)&&!BI.isEmptyString(a)},isWindow:function(){return $.isWindow.apply($,arguments)}}),_.extend(BI,{deepClone:_.cloneDeep,isDeepMatch:function(a,b){var c=BI.keys(b),d=c.length;if(null==a)return!d;for(var e=Object(a),f=0;f=0},deepContains:function(a,b){return BI.isObject(b)?BI.any(a,function(a,c){if(BI.isEqual(c,b))return!0}):BI.contains(a,b)},deepIndexOf:function(a,b){for(var c=0;c10;)c=(parseInt(c.substring(0,10))+parseInt(c.substring(10,c.length),10)).toString();c=(f*c+g)%h;for(var j="",k="",d=0;d10;)c=(parseInt(c.substring(0,10),10)+parseInt(c.substring(10,c.length),10)).toString();c=(g*c+h)%i;for(var k="",l="",d=0;de[0]?f=["y",1]:a>=d[0]&&a<=e[0]&&(a==d[0]&&(be[1]?f=["m",1]:b==e[1]&&c>e[2]&&(f=["d",1]))),f},checkDateLegal:function(a){var b=a.match(/\d+/g),c=0|b[0],d=0|b[1],e=0|b[2];if(b.length<=1)return!0;if(b.length<=2)return d>=1&&d<=12;var f=Date._MD.slice(0);return f[1]=BI.isLeapYear(c)?29:28,d>=1&&d<=12&&e<=f[d-1]},parseDateTime:function(a,b){var c=BI.getDate(),d=0,e=0,f=1,g=a.split(/\W+/);if("%y%x"==b.toLowerCase()||"%y%x%d"==b.toLowerCase()){var h=4,i=2;g[0]=a.substring(0,h),g[1]=a.substring(h,h+i),g[2]=a.substring(h+i,h+2*i)}var j=b.match(/%./g),k=0,l=0,m=0,n=0,o=0;for(k=0;k29?1900:2e3);break;case"%b":case"%B":for(l=0;l<12;++l)if(Date._MN[l].substr(0,g[k].length).toLowerCase()==g[k].toLowerCase()){e=l;break}break;case"%H":case"%I":case"%k":case"%l":m=parseInt(g[k],10);break;case"%P":case"%p":/pm/i.test(g[k])&&m<12?m+=12:/am/i.test(g[k])&&m>=12&&(m-=12);break;case"%M":n=parseInt(g[k],10);case"%S":o=parseInt(g[k],10)}if(isNaN(d)&&(d=c.getFullYear()),isNaN(e)&&(e=c.getMonth()),isNaN(f)&&(f=c.getDate()),isNaN(m)&&(m=c.getHours()),isNaN(n)&&(n=c.getMinutes()),isNaN(o)&&(o=c.getSeconds()),0!=d)return BI.getDate(d,e,f,m,n,o);for(d=0,e=-1,f=0,k=0;k31&&0==d?(d=parseInt(g[k],10),d<100&&(d+=d>29?1900:2e3)):0==f&&(f=g[k]);return 0==d&&(d=c.getFullYear()),e!=-1&&0!=f?BI.getDate(d,e,f,m,n,o):c},getDate:function(){var a,b=arguments.length,c=arguments;switch(b){case 0:a=new Date;break;case 1:a=new Date(c[0]);break;case 2:a=new Date(c[0],c[1]);break;case 3:a=new Date(c[0],c[1],c[2]);break;case 4:a=new Date(c[0],c[1],c[2],c[3]);break;case 5:a=new Date(c[0],c[1],c[2],c[3],c[4]);break;case 6:a=new Date(c[0],c[1],c[2],c[3],c[4],c[5]);break;case 7:a=new Date(c[0],c[1],c[2],c[3],c[4],c[5],c[6]);break;default:a=new Date}if(BI.isNotNull(BI.timeZone)&&(0===arguments.length||1===arguments.length&&BI.isNumber(arguments[0]))){var d=a.getTime(),e=6e4*a.getTimezoneOffset(),f=d+e;return new Date(f+BI.timeZone)}return a},getTime:function(){var a,b=arguments.length,c=arguments;switch(b){case 0:a=new Date;break;case 1:a=new Date(c[0]);break;case 2:a=new Date(c[0],c[1]);break;case 3:a=new Date(c[0],c[1],c[2]);break;case 4:a=new Date(c[0],c[1],c[2],c[3]);break;case 5:a=new Date(c[0],c[1],c[2],c[3],c[4]);break;case 6:a=new Date(c[0],c[1],c[2],c[3],c[4],c[5]);break;case 7:a=new Date(c[0],c[1],c[2],c[3],c[4],c[5],c[6]);break;default:a=new Date}return BI.isNotNull(BI.timeZone)?a.getTime()-BI.timeZone-6e4*a.getTimezoneOffset():a.getTime()}}),_.extend(BI,{isIE:function(){return null==this.__isIE&&(this.__isIE=/(msie|trident)/i.test(navigator.userAgent.toLowerCase())),this.__isIE},getIEVersion:function(){if(null!=this.__IEVersion)return this.__IEVersion;var a=0,b=navigator.userAgent.toLowerCase(),c=b.match(/(?:msie\s([\w.]+))/),d=b.match(/(?:trident.*rv:([\w.]+))/);return a=c&&d&&c[1]&&d[1]?Math.max(1*c[1],1*d[1]):c&&c[1]?1*c[1]:d&&d[1]?1*d[1]:0,this.__IEVersion=a},isIE9Below:function(){return!!BI.isIE()&&this.getIEVersion()<9},isEdge:function(){return/edge/i.test(navigator.userAgent.toLowerCase())},isChrome:function(){return/chrome/i.test(navigator.userAgent.toLowerCase())},isFireFox:function(){return/firefox/i.test(navigator.userAgent.toLowerCase())},isOpera:function(){return/opera/i.test(navigator.userAgent.toLowerCase())},isSafari:function(){return/safari/i.test(navigator.userAgent.toLowerCase())},isKhtml:function(){return/Konqueror|Safari|KHTML/i.test(navigator.userAgent)},isMac:function(){return/macintosh|mac os x/i.test(navigator.userAgent)},isWindows:function(){return/windows|win32/i.test(navigator.userAgent)},isSupportCss3:function(a){var b,c,d=["webkit","Moz","ms","o"],e=[],f=document.documentElement.style,g=function(a){return a.replace(/-(\w)/g,function(a,b){return b.toUpperCase()})};for(b in d)e.push(g(d[b]+"-"+a));for(e.push(g(a)),b=0,c=e.length;b="1")break}var l=h-i-g,m=a.substr(i,g),n=i+g-a.length;if(n>0)for(var o=0;o-1)return a>=0?_numberFormat(a+"",b.substring(0,c)):_numberFormat(-a+"",b.substr(c+1));if(+a<0&&"-"!==b.charAt(0))return _numberFormat(-a+"","-"+b);var d=a.split("."),e=b.split("."),f=d[0]||"",g=e[0]||"",h=d[1]||"",i=e[1]||"";if(/[%‰]$/.test(b)){var j=/[%]$/.test(b)?"00":"000";h+=j,f+=h.substr(0,j.length),f=f.replace(/^0+/gi,""),h=h.substr(j.length).replace(/0+$/gi,"")}var k=_dealWithRight(h,i);k.leftPlus&&(f=parseInt(f)+1+"",f=isNaN(f)?"1":f),k=k.num;var l=_dealWithLeft(f,g);return/[0-9]/.test(l)||(l+="0"),/[0-9]/.test(k)?l+"."+k:l+k}function _dealWithRight(a,b){for(var c="",d=0,e=0,f=b.length;e4){j.leftPlus=!0;var k=c.match(/^[0-9]+/);if(k){var l=k[0],m=l.length,n=parseInt(l)+1+"";n.length>m?n=n.substr(1):(n=BI.leftPad(n,m,"0"),j.leftPlus=!1),c=c.replace(/^[0-9]+/,n)}}return j.num=c,j}function _dealWithLeft(a,b){for(var c="",d=a.length-1,e=-1,f=-1,g=b.length-1;g>=0;g--){var h=b.charAt(g),i=a.charAt(d);switch(h){case"0":isEmpty(i)&&(i="0"),f=-1,c=i+c,d--;break;case"#":f=g,c=i+c,d--;break;case",":if(!isEmpty(i)){var j=b.match(/,[#0]+/);j&&(e=j[0].length-1),c=","+c}break;default:c=h+c}}if(f>-1){var k=a.substr(0,d+1);c=c.substr(0,f)+k+c.substr(f)}if(e>0){var l=c.match(/[0-9]+,/);if(l){l=l[0];for(var m="",n=l.length-1-e;n>=0;n-=e)m=l.substr(n,e)+","+m;var o=l.substr(0,n+e);isEmpty(o)||(m=o+","+m)}c=c.replace(/[0-9]+,/,m)}return c}window.BI||(window.BI={}),BI.cjkEncode=function(a){if("string"!=typeof a)return a;for(var b="",c=0;c=128||91===d||93===d?"["+d.toString(16)+"]":a.charAt(c)}return b},BI.cjkDecode=function(text){if(null==text)return"";if(!isNaN(text)||text.indexOf("[")==-1)return text;for(var newText="",i=0;ii+1){var subText=text.substring(i+1,rightIdx);subText.length>0&&(ch=String.fromCharCode(eval("0x"+subText))),i=rightIdx}}newText+=ch}return newText},BI.htmlEncode=function(a){return null==a?"":String(a).replace(/&/g,"&").replace(/\"/g,""").replace(//g,">").replace(/\s/g," ")},BI.htmlDecode=function(a){return null==a?"":String(a).replace(/&/g,"&").replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/ /g," ")},BI.cjkEncodeDO=function(a){if(BI.isPlainObject(a)){var b={};return _.each(a,function(a,c){"string"!=typeof a&&(a=BI.jsonEncode(a)),c=BI.cjkEncode(c),b[c]=BI.cjkEncode(a)}),b}return a},BI.jsonEncode=function(a){var b=!!{}.hasOwnProperty,c={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},d=function(a){return/["\\\x00-\x1f]/.test(a)?'"'+a.replace(/([\x00-\x1f\\"])/g,function(a,b){var d=c[b];return d?d:(d=b.charCodeAt(),"\\u00"+Math.floor(d/16).toString(16)+(d%16).toString(16))})+'"':'"'+a+'"'},e=function(a){var b,c,d,e=["["],f=a.length;for(c=0;c2?Date._MN[b.getMonth()]:d<2?b.getMonth()+1:BI.leftPad(b.getMonth()+1+"",2,"0");break;case"d":c=d>1?BI.leftPad(b.getDate()+"",2,"0"):b.getDate();break;case"h":var f=b.getHours()%12;0===f&&(f=12),c=d>1?BI.leftPad(f+"",2,"0"):f;break;case"H":c=d>1?BI.leftPad(b.getHours()+"",2,"0"):b.getHours();break;case"m":c=d>1?BI.leftPad(b.getMinutes()+"",2,"0"):b.getMinutes();break;case"s":c=d>1?BI.leftPad(b.getSeconds()+"",2,"0"):b.getSeconds();break;case"a":c=b.getHours()<12?"am":"pm";break;case"z":c=b.getTimezone();break;default:c=a.str}return c}if(!a)return"";var d=b.length,e="";if(d>0){for(var f=b.charAt(0),g=0,h=f,i=1;i127&&d<2048?(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},c=function(a){for(var b="",c=0,d=0,e=0,f=0;c191&&d<224?(f=a.charCodeAt(c+1),b+=String.fromCharCode((31&d)<<6|63&f),c+=2):(f=a.charCodeAt(c+1),e=a.charCodeAt(c+2),b+=String.fromCharCode((15&d)<<12|(63&f)<<6|63&e),c+=3);return b};_.extend(BI,{encode:function(c){var d,e,f,g,h,i,j,k="",l=0;for(c=b(c);l>2,h=(3&d)<<4|e>>4,i=(15&e)<<2|f>>6,j=63&f,isNaN(e)?i=j=64:isNaN(f)&&(j=64),k=k+a.charAt(g)+a.charAt(h)+a.charAt(i)+a.charAt(j);return k},decode:function(b){var d,e,f,g,h,i,j,k="",l=0;for(b=b.replace(/[^A-Za-z0-9\+\/\=]/g,"");l>4,e=(15&h)<<4|i>>2,f=(3&i)<<6|j,k+=String.fromCharCode(d),64!=i&&(k+=String.fromCharCode(e)),64!=j&&(k+=String.fromCharCode(f));return k=c(k)}})}(),BI.Cache={_prefix:"bi",setUsername:function(a){localStorage.setItem(BI.Cache._prefix+".username",(a+""||"").toUpperCase())},getUsername:function(){return localStorage.getItem(BI.Cache._prefix+".username")||""},_getKeyPrefix:function(){return BI.Cache.getUsername()+"."+BI.Cache._prefix+"."},_generateKey:function(a){return BI.Cache._getKeyPrefix()+(a||"")},getItem:function(a){return localStorage.getItem(BI.Cache._generateKey(a))},setItem:function(a,b){localStorage.setItem(BI.Cache._generateKey(a),b)},removeItem:function(a){localStorage.removeItem(BI.Cache._generateKey(a))},clear:function(){for(var a=localStorage.length;a>=0;a--){var b=localStorage.key(a);b&&0===b.indexOf(BI.Cache._getKeyPrefix())&&localStorage.removeItem(b)}},keys:function(){for(var a=[],b=localStorage.length;b>=0;b--){var c=localStorage.key(b);if(c){var d=BI.Cache._getKeyPrefix();0===c.indexOf(d)&&(a[a.length]=c.substring(d.length))}}return a},addCookie:function(a,b,c,d){var e=a+"="+escape(b);if(d&&d>0){var f=new Date;f.setTime(BI.getTime()+3600*d*1e3),e=e+"; expires="+f.toGMTString()}c&&(e=e+"; path="+c),document.cookie=e},getCookie:function(a){var b,c=new RegExp("(^| )"+a+"=([^;]*)(;|$)");return(b=document.cookie.match(c))?unescape(b[2]):null},deleteCookie:function(a,b){var c=new Date;c.setTime(BI.getTime()-1e4);var d=a+"=v; expires="+c.toGMTString();b&&(d=d+"; path="+b),document.cookie=d}},BI.CellSizeAndPositionManager=function(a,b,c){this._cellSizeGetter=b,this._cellCount=a,this._estimatedCellSize=c,this._cellSizeAndPositionData={},this._lastMeasuredIndex=-1},BI.CellSizeAndPositionManager.prototype={constructor:BI.CellSizeAndPositionManager,configure:function(a,b){this._cellCount=a,this._estimatedCellSize=b},getCellCount:function(){return this._cellCount},getEstimatedCellSize:function(){return this._estimatedCellSize},getLastMeasuredIndex:function(){return this._lastMeasuredIndex},getSizeAndPositionOfCell:function(a){if(!(a<0||a>=this._cellCount)){if(a>this._lastMeasuredIndex){for(var b=this.getSizeAndPositionOfLastMeasuredCell(),c=b.offset+b.size,d=this._lastMeasuredIndex+1;d<=a;d++){var e=this._cellSizeGetter(d);null==e||isNaN(e)||(this._cellSizeAndPositionData[d]={offset:c,size:e},c+=e)}this._lastMeasuredIndex=a}return this._cellSizeAndPositionData[a]}},getSizeAndPositionOfLastMeasuredCell:function(){return this._lastMeasuredIndex>=0?this._cellSizeAndPositionData[this._lastMeasuredIndex]:{offset:0,size:0}},getTotalSize:function(){var a=this.getSizeAndPositionOfLastMeasuredCell();return a.offset+a.size+(this._cellCount-this._lastMeasuredIndex-1)*this._estimatedCellSize},getUpdatedOffsetForIndex:function(a,b,c,d){var e,f=this.getSizeAndPositionOfCell(d),g=f.offset,h=g-b+f.size;switch(a){case"start":e=g;break;case"end":e=h;break;case"center":e=g-(b-f.size)/2;break;default:e=Math.max(h,Math.min(g,c))}var i=this.getTotalSize();return Math.max(0,Math.min(i-b,e))},getVisibleCellRange:function(a,b){var c=this.getTotalSize();if(0===c)return{};var d=b+a,e=this._findNearestCell(b),f=this.getSizeAndPositionOfCell(e);b=f.offset+f.size;for(var g=e;bc&&(a=d-1)}if(b>0)return b-1},_exponentialSearch:function(a,b){for(var c=1;a=a?this._binarySearch(c,0,a):this._exponentialSearch(c,a)}}},BI.ScalingCellSizeAndPositionManager=function(a,b,c,d){this._cellSizeAndPositionManager=new BI.CellSizeAndPositionManager(a,b,c),this._maxScrollSize=d||1e7},BI.ScalingCellSizeAndPositionManager.prototype={constructor:BI.ScalingCellSizeAndPositionManager,configure:function(){this._cellSizeAndPositionManager.configure.apply(this._cellSizeAndPositionManager,arguments)},getCellCount:function(){return this._cellSizeAndPositionManager.getCellCount()},getEstimatedCellSize:function(){return this._cellSizeAndPositionManager.getEstimatedCellSize()},getLastMeasuredIndex:function(){return this._cellSizeAndPositionManager.getLastMeasuredIndex()},getOffsetAdjustment:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize(),e=this._getOffsetPercentage(a,b,d);return Math.round(e*(d-c))},getSizeAndPositionOfCell:function(a){return this._cellSizeAndPositionManager.getSizeAndPositionOfCell(a)},getSizeAndPositionOfLastMeasuredCell:function(){return this._cellSizeAndPositionManager.getSizeAndPositionOfLastMeasuredCell()},getTotalSize:function(){return Math.min(this._maxScrollSize,this._cellSizeAndPositionManager.getTotalSize())},getUpdatedOffsetForIndex:function(a,b,c,d){c=this._safeOffsetToOffset(b,c);var e=this._cellSizeAndPositionManager.getUpdatedOffsetForIndex(a,b,c,d);return this._offsetToSafeOffset(b,e)},getVisibleCellRange:function(a,b){return b=this._safeOffsetToOffset(a,b),this._cellSizeAndPositionManager.getVisibleCellRange(a,b)},resetCell:function(a){this._cellSizeAndPositionManager.resetCell(a)},_getOffsetPercentage:function(a,b,c){return c<=a?0:b/(c-a)},_offsetToSafeOffset:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize();if(c===d)return b;var e=this._getOffsetPercentage(a,b,c);return Math.round(e*(d-a))},_safeOffsetToOffset:function(a,b){var c=this._cellSizeAndPositionManager.getTotalSize(),d=this.getTotalSize();if(c===d)return b;var e=this._getOffsetPercentage(a,b,d);return Math.round(e*(c-a))}},!function(){var a="YDYQSXMWZSSXJBYMGCCZQPSSQBYCDSCDQLDYLYBSSJGYZZJJFKCCLZDHWDWZJLJPFYYNWJJTMYHZWZHFLZPPQHGSCYYYNJQYXXGJHHSDSJNKKTMOMLCRXYPSNQSECCQZGGLLYJLMYZZSECYKYYHQWJSSGGYXYZYJWWKDJHYCHMYXJTLXJYQBYXZLDWRDJRWYSRLDZJPCBZJJBRCFTLECZSTZFXXZHTRQHYBDLYCZSSYMMRFMYQZPWWJJYFCRWFDFZQPYDDWYXKYJAWJFFXYPSFTZYHHYZYSWCJYXSCLCXXWZZXNBGNNXBXLZSZSBSGPYSYZDHMDZBQBZCWDZZYYTZHBTSYYBZGNTNXQYWQSKBPHHLXGYBFMJEBJHHGQTJCYSXSTKZHLYCKGLYSMZXYALMELDCCXGZYRJXSDLTYZCQKCNNJWHJTZZCQLJSTSTBNXBTYXCEQXGKWJYFLZQLYHYXSPSFXLMPBYSXXXYDJCZYLLLSJXFHJXPJBTFFYABYXBHZZBJYZLWLCZGGBTSSMDTJZXPTHYQTGLJSCQFZKJZJQNLZWLSLHDZBWJNCJZYZSQQYCQYRZCJJWYBRTWPYFTWEXCSKDZCTBZHYZZYYJXZCFFZZMJYXXSDZZOTTBZLQWFCKSZSXFYRLNYJMBDTHJXSQQCCSBXYYTSYFBXDZTGBCNSLCYZZPSAZYZZSCJCSHZQYDXLBPJLLMQXTYDZXSQJTZPXLCGLQTZWJBHCTSYJSFXYEJJTLBGXSXJMYJQQPFZASYJNTYDJXKJCDJSZCBARTDCLYJQMWNQNCLLLKBYBZZSYHQQLTWLCCXTXLLZNTYLNEWYZYXCZXXGRKRMTCNDNJTSYYSSDQDGHSDBJGHRWRQLYBGLXHLGTGXBQJDZPYJSJYJCTMRNYMGRZJCZGJMZMGXMPRYXKJNYMSGMZJYMKMFXMLDTGFBHCJHKYLPFMDXLQJJSMTQGZSJLQDLDGJYCALCMZCSDJLLNXDJFFFFJCZFMZFFPFKHKGDPSXKTACJDHHZDDCRRCFQYJKQCCWJDXHWJLYLLZGCFCQDSMLZPBJJPLSBCJGGDCKKDEZSQCCKJGCGKDJTJDLZYCXKLQSCGJCLTFPCQCZGWPJDQYZJJBYJHSJDZWGFSJGZKQCCZLLPSPKJGQJHZZLJPLGJGJJTHJJYJZCZMLZLYQBGJWMLJKXZDZNJQSYZMLJLLJKYWXMKJLHSKJGBMCLYYMKXJQLBMLLKMDXXKWYXYSLMLPSJQQJQXYXFJTJDXMXXLLCXQBSYJBGWYMBGGBCYXPJYGPEPFGDJGBHBNSQJYZJKJKHXQFGQZKFHYGKHDKLLSDJQXPQYKYBNQSXQNSZSWHBSXWHXWBZZXDMNSJBSBKBBZKLYLXGWXDRWYQZMYWSJQLCJXXJXKJEQXSCYETLZHLYYYSDZPAQYZCMTLSHTZCFYZYXYLJSDCJQAGYSLCQLYYYSHMRQQKLDXZSCSSSYDYCJYSFSJBFRSSZQSBXXPXJYSDRCKGJLGDKZJZBDKTCSYQPYHSTCLDJDHMXMCGXYZHJDDTMHLTXZXYLYMOHYJCLTYFBQQXPFBDFHHTKSQHZYYWCNXXCRWHOWGYJLEGWDQCWGFJYCSNTMYTOLBYGWQWESJPWNMLRYDZSZTXYQPZGCWXHNGPYXSHMYQJXZTDPPBFYHZHTJYFDZWKGKZBLDNTSXHQEEGZZYLZMMZYJZGXZXKHKSTXNXXWYLYAPSTHXDWHZYMPXAGKYDXBHNHXKDPJNMYHYLPMGOCSLNZHKXXLPZZLBMLSFBHHGYGYYGGBHSCYAQTYWLXTZQCEZYDQDQMMHTKLLSZHLSJZWFYHQSWSCWLQAZYNYTLSXTHAZNKZZSZZLAXXZWWCTGQQTDDYZTCCHYQZFLXPSLZYGPZSZNGLNDQTBDLXGTCTAJDKYWNSYZLJHHZZCWNYYZYWMHYCHHYXHJKZWSXHZYXLYSKQYSPSLYZWMYPPKBYGLKZHTYXAXQSYSHXASMCHKDSCRSWJPWXSGZJLWWSCHSJHSQNHCSEGNDAQTBAALZZMSSTDQJCJKTSCJAXPLGGXHHGXXZCXPDMMHLDGTYBYSJMXHMRCPXXJZCKZXSHMLQXXTTHXWZFKHCCZDYTCJYXQHLXDHYPJQXYLSYYDZOZJNYXQEZYSQYAYXWYPDGXDDXSPPYZNDLTWRHXYDXZZJHTCXMCZLHPYYYYMHZLLHNXMYLLLMDCPPXHMXDKYCYRDLTXJCHHZZXZLCCLYLNZSHZJZZLNNRLWHYQSNJHXYNTTTKYJPYCHHYEGKCTTWLGQRLGGTGTYGYHPYHYLQYQGCWYQKPYYYTTTTLHYHLLTYTTSPLKYZXGZWGPYDSSZZDQXSKCQNMJJZZBXYQMJRTFFBTKHZKBXLJJKDXJTLBWFZPPTKQTZTGPDGNTPJYFALQMKGXBDCLZFHZCLLLLADPMXDJHLCCLGYHDZFGYDDGCYYFGYDXKSSEBDHYKDKDKHNAXXYBPBYYHXZQGAFFQYJXDMLJCSQZLLPCHBSXGJYNDYBYQSPZWJLZKSDDTACTBXZDYZYPJZQSJNKKTKNJDJGYYPGTLFYQKASDNTCYHBLWDZHBBYDWJRYGKZYHEYYFJMSDTYFZJJHGCXPLXHLDWXXJKYTCYKSSSMTWCTTQZLPBSZDZWZXGZAGYKTYWXLHLSPBCLLOQMMZSSLCMBJCSZZKYDCZJGQQDSMCYTZQQLWZQZXSSFPTTFQMDDZDSHDTDWFHTDYZJYQJQKYPBDJYYXTLJHDRQXXXHAYDHRJLKLYTWHLLRLLRCXYLBWSRSZZSYMKZZHHKYHXKSMDSYDYCJPBZBSQLFCXXXNXKXWYWSDZYQOGGQMMYHCDZTTFJYYBGSTTTYBYKJDHKYXBELHTYPJQNFXFDYKZHQKZBYJTZBXHFDXKDASWTAWAJLDYJSFHBLDNNTNQJTJNCHXFJSRFWHZFMDRYJYJWZPDJKZYJYMPCYZNYNXFBYTFYFWYGDBNZZZDNYTXZEMMQBSQEHXFZMBMFLZZSRXYMJGSXWZJSPRYDJSJGXHJJGLJJYNZZJXHGXKYMLPYYYCXYTWQZSWHWLYRJLPXSLSXMFSWWKLCTNXNYNPSJSZHDZEPTXMYYWXYYSYWLXJQZQXZDCLEEELMCPJPCLWBXSQHFWWTFFJTNQJHJQDXHWLBYZNFJLALKYYJLDXHHYCSTYYWNRJYXYWTRMDRQHWQCMFJDYZMHMYYXJWMYZQZXTLMRSPWWCHAQBXYGZYPXYYRRCLMPYMGKSJSZYSRMYJSNXTPLNBAPPYPYLXYYZKYNLDZYJZCZNNLMZHHARQMPGWQTZMXXMLLHGDZXYHXKYXYCJMFFYYHJFSBSSQLXXNDYCANNMTCJCYPRRNYTYQNYYMBMSXNDLYLYSLJRLXYSXQMLLYZLZJJJKYZZCSFBZXXMSTBJGNXYZHLXNMCWSCYZYFZLXBRNNNYLBNRTGZQYSATSWRYHYJZMZDHZGZDWYBSSCSKXSYHYTXXGCQGXZZSHYXJSCRHMKKBXCZJYJYMKQHZJFNBHMQHYSNJNZYBKNQMCLGQHWLZNZSWXKHLJHYYBQLBFCDSXDLDSPFZPSKJYZWZXZDDXJSMMEGJSCSSMGCLXXKYYYLNYPWWWGYDKZJGGGZGGSYCKNJWNJPCXBJJTQTJWDSSPJXZXNZXUMELPXFSXTLLXCLJXJJLJZXCTPSWXLYDHLYQRWHSYCSQYYBYAYWJJJQFWQCQQCJQGXALDBZZYJGKGXPLTZYFXJLTPADKYQHPMATLCPDCKBMTXYBHKLENXDLEEGQDYMSAWHZMLJTWYGXLYQZLJEEYYBQQFFNLYXRDSCTGJGXYYNKLLYQKCCTLHJLQMKKZGCYYGLLLJDZGYDHZWXPYSJBZKDZGYZZHYWYFQYTYZSZYEZZLYMHJJHTSMQWYZLKYYWZCSRKQYTLTDXWCTYJKLWSQZWBDCQYNCJSRSZJLKCDCDTLZZZACQQZZDDXYPLXZBQJYLZLLLQDDZQJYJYJZYXNYYYNYJXKXDAZWYRDLJYYYRJLXLLDYXJCYWYWNQCCLDDNYYYNYCKCZHXXCCLGZQJGKWPPCQQJYSBZZXYJSQPXJPZBSBDSFNSFPZXHDWZTDWPPTFLZZBZDMYYPQJRSDZSQZSQXBDGCPZSWDWCSQZGMDHZXMWWFYBPDGPHTMJTHZSMMBGZMBZJCFZWFZBBZMQCFMBDMCJXLGPNJBBXGYHYYJGPTZGZMQBQTCGYXJXLWZKYDPDYMGCFTPFXYZTZXDZXTGKMTYBBCLBJASKYTSSQYYMSZXFJEWLXLLSZBQJJJAKLYLXLYCCTSXMCWFKKKBSXLLLLJYXTYLTJYYTDPJHNHNNKBYQNFQYYZBYYESSESSGDYHFHWTCJBSDZZTFDMXHCNJZYMQWSRYJDZJQPDQBBSTJGGFBKJBXTGQHNGWJXJGDLLTHZHHYYYYYYSXWTYYYCCBDBPYPZYCCZYJPZYWCBDLFWZCWJDXXHYHLHWZZXJTCZLCDPXUJCZZZLYXJJTXPHFXWPYWXZPTDZZBDZCYHJHMLXBQXSBYLRDTGJRRCTTTHYTCZWMXFYTWWZCWJWXJYWCSKYBZSCCTZQNHXNWXXKHKFHTSWOCCJYBCMPZZYKBNNZPBZHHZDLSYDDYTYFJPXYNGFXBYQXCBHXCPSXTYZDMKYSNXSXLHKMZXLYHDHKWHXXSSKQYHHCJYXGLHZXCSNHEKDTGZXQYPKDHEXTYKCNYMYYYPKQYYYKXZLTHJQTBYQHXBMYHSQCKWWYLLHCYYLNNEQXQWMCFBDCCMLJGGXDQKTLXKGNQCDGZJWYJJLYHHQTTTNWCHMXCXWHWSZJYDJCCDBQCDGDNYXZTHCQRXCBHZTQCBXWGQWYYBXHMBYMYQTYEXMQKYAQYRGYZSLFYKKQHYSSQYSHJGJCNXKZYCXSBXYXHYYLSTYCXQTHYSMGSCPMMGCCCCCMTZTASMGQZJHKLOSQYLSWTMXSYQKDZLJQQYPLSYCZTCQQPBBQJZCLPKHQZYYXXDTDDTSJCXFFLLCHQXMJLWCJCXTSPYCXNDTJSHJWXDQQJSKXYAMYLSJHMLALYKXCYYDMNMDQMXMCZNNCYBZKKYFLMCHCMLHXRCJJHSYLNMTJZGZGYWJXSRXCWJGJQHQZDQJDCJJZKJKGDZQGJJYJYLXZXXCDQHHHEYTMHLFSBDJSYYSHFYSTCZQLPBDRFRZTZYKYWHSZYQKWDQZRKMSYNBCRXQBJYFAZPZZEDZCJYWBCJWHYJBQSZYWRYSZPTDKZPFPBNZTKLQYHBBZPNPPTYZZYBQNYDCPJMMCYCQMCYFZZDCMNLFPBPLNGQJTBTTNJZPZBBZNJKLJQYLNBZQHKSJZNGGQSZZKYXSHPZSNBCGZKDDZQANZHJKDRTLZLSWJLJZLYWTJNDJZJHXYAYNCBGTZCSSQMNJPJYTYSWXZFKWJQTKHTZPLBHSNJZSYZBWZZZZLSYLSBJHDWWQPSLMMFBJDWAQYZTCJTBNNWZXQXCDSLQGDSDPDZHJTQQPSWLYYJZLGYXYZLCTCBJTKTYCZJTQKBSJLGMGZDMCSGPYNJZYQYYKNXRPWSZXMTNCSZZYXYBYHYZAXYWQCJTLLCKJJTJHGDXDXYQYZZBYWDLWQCGLZGJGQRQZCZSSBCRPCSKYDZNXJSQGXSSJMYDNSTZTPBDLTKZWXQWQTZEXNQCZGWEZKSSBYBRTSSSLCCGBPSZQSZLCCGLLLZXHZQTHCZMQGYZQZNMCOCSZJMMZSQPJYGQLJYJPPLDXRGZYXCCSXHSHGTZNLZWZKJCXTCFCJXLBMQBCZZWPQDNHXLJCTHYZLGYLNLSZZPCXDSCQQHJQKSXZPBAJYEMSMJTZDXLCJYRYYNWJBNGZZTMJXLTBSLYRZPYLSSCNXPHLLHYLLQQZQLXYMRSYCXZLMMCZLTZSDWTJJLLNZGGQXPFSKYGYGHBFZPDKMWGHCXMSGDXJMCJZDYCABXJDLNBCDQYGSKYDQTXDJJYXMSZQAZDZFSLQXYJSJZYLBTXXWXQQZBJZUFBBLYLWDSLJHXJYZJWTDJCZFQZQZZDZSXZZQLZCDZFJHYSPYMPQZMLPPLFFXJJNZZYLSJEYQZFPFZKSYWJJJHRDJZZXTXXGLGHYDXCSKYSWMMZCWYBAZBJKSHFHJCXMHFQHYXXYZFTSJYZFXYXPZLCHMZMBXHZZSXYFYMNCWDABAZLXKTCSHHXKXJJZJSTHYGXSXYYHHHJWXKZXSSBZZWHHHCWTZZZPJXSNXQQJGZYZYWLLCWXZFXXYXYHXMKYYSWSQMNLNAYCYSPMJKHWCQHYLAJJMZXHMMCNZHBHXCLXTJPLTXYJHDYYLTTXFSZHYXXSJBJYAYRSMXYPLCKDUYHLXRLNLLSTYZYYQYGYHHSCCSMZCTZQXKYQFPYYRPFFLKQUNTSZLLZMWWTCQQYZWTLLMLMPWMBZSSTZRBPDDTLQJJBXZCSRZQQYGWCSXFWZLXCCRSZDZMCYGGDZQSGTJSWLJMYMMZYHFBJDGYXCCPSHXNZCSBSJYJGJMPPWAFFYFNXHYZXZYLREMZGZCYZSSZDLLJCSQFNXZKPTXZGXJJGFMYYYSNBTYLBNLHPFZDCYFBMGQRRSSSZXYSGTZRNYDZZCDGPJAFJFZKNZBLCZSZPSGCYCJSZLMLRSZBZZLDLSLLYSXSQZQLYXZLSKKBRXBRBZCYCXZZZEEYFGKLZLYYHGZSGZLFJHGTGWKRAAJYZKZQTSSHJJXDCYZUYJLZYRZDQQHGJZXSSZBYKJPBFRTJXLLFQWJHYLQTYMBLPZDXTZYGBDHZZRBGXHWNJTJXLKSCFSMWLSDQYSJTXKZSCFWJLBXFTZLLJZLLQBLSQMQQCGCZFPBPHZCZJLPYYGGDTGWDCFCZQYYYQYSSCLXZSKLZZZGFFCQNWGLHQYZJJCZLQZZYJPJZZBPDCCMHJGXDQDGDLZQMFGPSYTSDYFWWDJZJYSXYYCZCYHZWPBYKXRYLYBHKJKSFXTZJMMCKHLLTNYYMSYXYZPYJQYCSYCWMTJJKQYRHLLQXPSGTLYYCLJSCPXJYZFNMLRGJJTYZBXYZMSJYJHHFZQMSYXRSZCWTLRTQZSSTKXGQKGSPTGCZNJSJCQCXHMXGGZTQYDJKZDLBZSXJLHYQGGGTHQSZPYHJHHGYYGKGGCWJZZYLCZLXQSFTGZSLLLMLJSKCTBLLZZSZMMNYTPZSXQHJCJYQXYZXZQZCPSHKZZYSXCDFGMWQRLLQXRFZTLYSTCTMJCXJJXHJNXTNRZTZFQYHQGLLGCXSZSJDJLJCYDSJTLNYXHSZXCGJZYQPYLFHDJSBPCCZHJJJQZJQDYBSSLLCMYTTMQTBHJQNNYGKYRQYQMZGCJKPDCGMYZHQLLSLLCLMHOLZGDYYFZSLJCQZLYLZQJESHNYLLJXGJXLYSYYYXNBZLJSSZCQQCJYLLZLTJYLLZLLBNYLGQCHXYYXOXCXQKYJXXXYKLXSXXYQXCYKQXQCSGYXXYQXYGYTQOHXHXPYXXXULCYEYCHZZCBWQBBWJQZSCSZSSLZYLKDESJZWMYMCYTSDSXXSCJPQQSQYLYYZYCMDJDZYWCBTJSYDJKCYDDJLBDJJSODZYSYXQQYXDHHGQQYQHDYXWGMMMAJDYBBBPPBCMUUPLJZSMTXERXJMHQNUTPJDCBSSMSSSTKJTSSMMTRCPLZSZMLQDSDMJMQPNQDXCFYNBFSDQXYXHYAYKQYDDLQYYYSSZBYDSLNTFQTZQPZMCHDHCZCWFDXTMYQSPHQYYXSRGJCWTJTZZQMGWJJTJHTQJBBHWZPXXHYQFXXQYWYYHYSCDYDHHQMNMTMWCPBSZPPZZGLMZFOLLCFWHMMSJZTTDHZZYFFYTZZGZYSKYJXQYJZQBHMBZZLYGHGFMSHPZFZSNCLPBQSNJXZSLXXFPMTYJYGBXLLDLXPZJYZJYHHZCYWHJYLSJEXFSZZYWXKZJLUYDTMLYMQJPWXYHXSKTQJEZRPXXZHHMHWQPWQLYJJQJJZSZCPHJLCHHNXJLQWZJHBMZYXBDHHYPZLHLHLGFWLCHYYTLHJXCJMSCPXSTKPNHQXSRTYXXTESYJCTLSSLSTDLLLWWYHDHRJZSFGXTSYCZYNYHTDHWJSLHTZDQDJZXXQHGYLTZPHCSQFCLNJTCLZPFSTPDYNYLGMJLLYCQHYSSHCHYLHQYQTMZYPBYWRFQYKQSYSLZDQJMPXYYSSRHZJNYWTQDFZBWWTWWRXCWHGYHXMKMYYYQMSMZHNGCEPMLQQMTCWCTMMPXJPJJHFXYYZSXZHTYBMSTSYJTTQQQYYLHYNPYQZLCYZHZWSMYLKFJXLWGXYPJYTYSYXYMZCKTTWLKSMZSYLMPWLZWXWQZSSAQSYXYRHSSNTSRAPXCPWCMGDXHXZDZYFJHGZTTSBJHGYZSZYSMYCLLLXBTYXHBBZJKSSDMALXHYCFYGMQYPJYCQXJLLLJGSLZGQLYCJCCZOTYXMTMTTLLWTGPXYMZMKLPSZZZXHKQYSXCTYJZYHXSHYXZKXLZWPSQPYHJWPJPWXQQYLXSDHMRSLZZYZWTTCYXYSZZSHBSCCSTPLWSSCJCHNLCGCHSSPHYLHFHHXJSXYLLNYLSZDHZXYLSXLWZYKCLDYAXZCMDDYSPJTQJZLNWQPSSSWCTSTSZLBLNXSMNYYMJQBQHRZWTYYDCHQLXKPZWBGQYBKFCMZWPZLLYYLSZYDWHXPSBCMLJBSCGBHXLQHYRLJXYSWXWXZSLDFHLSLYNJLZYFLYJYCDRJLFSYZFSLLCQYQFGJYHYXZLYLMSTDJCYHBZLLNWLXXYGYYHSMGDHXXHHLZZJZXCZZZCYQZFNGWPYLCPKPYYPMCLQKDGXZGGWQBDXZZKZFBXXLZXJTPJPTTBYTSZZDWSLCHZHSLTYXHQLHYXXXYYZYSWTXZKHLXZXZPYHGCHKCFSYHUTJRLXFJXPTZTWHPLYXFCRHXSHXKYXXYHZQDXQWULHYHMJTBFLKHTXCWHJFWJCFPQRYQXCYYYQYGRPYWSGSUNGWCHKZDXYFLXXHJJBYZWTSXXNCYJJYMSWZJQRMHXZWFQSYLZJZGBHYNSLBGTTCSYBYXXWXYHXYYXNSQYXMQYWRGYQLXBBZLJSYLPSYTJZYHYZAWLRORJMKSCZJXXXYXCHDYXRYXXJDTSQFXLYLTSFFYXLMTYJMJUYYYXLTZCSXQZQHZXLYYXZHDNBRXXXJCTYHLBRLMBRLLAXKYLLLJLYXXLYCRYLCJTGJCMTLZLLCYZZPZPCYAWHJJFYBDYYZSMPCKZDQYQPBPCJPDCYZMDPBCYYDYCNNPLMTMLRMFMMGWYZBSJGYGSMZQQQZTXMKQWGXLLPJGZBQCDJJJFPKJKCXBLJMSWMDTQJXLDLPPBXCWRCQFBFQJCZAHZGMYKPHYYHZYKNDKZMBPJYXPXYHLFPNYYGXJDBKXNXHJMZJXSTRSTLDXSKZYSYBZXJLXYSLBZYSLHXJPFXPQNBYLLJQKYGZMCYZZYMCCSLCLHZFWFWYXZMWSXTYNXJHPYYMCYSPMHYSMYDYSHQYZCHMJJMZCAAGCFJBBHPLYZYLXXSDJGXDHKXXTXXNBHRMLYJSLTXMRHNLXQJXYZLLYSWQGDLBJHDCGJYQYCMHWFMJYBMBYJYJWYMDPWHXQLDYGPDFXXBCGJSPCKRSSYZJMSLBZZJFLJJJLGXZGYXYXLSZQYXBEXYXHGCXBPLDYHWETTWWCJMBTXCHXYQXLLXFLYXLLJLSSFWDPZSMYJCLMWYTCZPCHQEKCQBWLCQYDPLQPPQZQFJQDJHYMMCXTXDRMJWRHXCJZYLQXDYYNHYYHRSLSRSYWWZJYMTLTLLGTQCJZYABTCKZCJYCCQLJZQXALMZYHYWLWDXZXQDLLQSHGPJFJLJHJABCQZDJGTKHSSTCYJLPSWZLXZXRWGLDLZRLZXTGSLLLLZLYXXWGDZYGBDPHZPBRLWSXQBPFDWOFMWHLYPCBJCCLDMBZPBZZLCYQXLDOMZBLZWPDWYYGDSTTHCSQSCCRSSSYSLFYBFNTYJSZDFNDPDHDZZMBBLSLCMYFFGTJJQWFTMTPJWFNLBZCMMJTGBDZLQLPYFHYYMJYLSDCHDZJWJCCTLJCLDTLJJCPDDSQDSSZYBNDBJLGGJZXSXNLYCYBJXQYCBYLZCFZPPGKCXZDZFZTJJFJSJXZBNZYJQTTYJYHTYCZHYMDJXTTMPXSPLZCDWSLSHXYPZGTFMLCJTYCBPMGDKWYCYZCDSZZYHFLYCTYGWHKJYYLSJCXGYWJCBLLCSNDDBTZBSCLYZCZZSSQDLLMQYYHFSLQLLXFTYHABXGWNYWYYPLLSDLDLLBJCYXJZMLHLJDXYYQYTDLLLBUGBFDFBBQJZZMDPJHGCLGMJJPGAEHHBWCQXAXHHHZCHXYPHJAXHLPHJPGPZJQCQZGJJZZUZDMQYYBZZPHYHYBWHAZYJHYKFGDPFQSDLZMLJXKXGALXZDAGLMDGXMWZQYXXDXXPFDMMSSYMPFMDMMKXKSYZYSHDZKXSYSMMZZZMSYDNZZCZXFPLSTMZDNMXCKJMZTYYMZMZZMSXHHDCZJEMXXKLJSTLWLSQLYJZLLZJSSDPPMHNLZJCZYHMXXHGZCJMDHXTKGRMXFWMCGMWKDTKSXQMMMFZZYDKMSCLCMPCGMHSPXQPZDSSLCXKYXTWLWJYAHZJGZQMCSNXYYMMPMLKJXMHLMLQMXCTKZMJQYSZJSYSZHSYJZJCDAJZYBSDQJZGWZQQXFKDMSDJLFWEHKZQKJPEYPZYSZCDWYJFFMZZYLTTDZZEFMZLBNPPLPLPEPSZALLTYLKCKQZKGENQLWAGYXYDPXLHSXQQWQCQXQCLHYXXMLYCCWLYMQYSKGCHLCJNSZKPYZKCQZQLJPDMDZHLASXLBYDWQLWDNBQCRYDDZTJYBKBWSZDXDTNPJDTCTQDFXQQMGNXECLTTBKPWSLCTYQLPWYZZKLPYGZCQQPLLKCCYLPQMZCZQCLJSLQZDJXLDDHPZQDLJJXZQDXYZQKZLJCYQDYJPPYPQYKJYRMPCBYMCXKLLZLLFQPYLLLMBSGLCYSSLRSYSQTMXYXZQZFDZUYSYZTFFMZZSMZQHZSSCCMLYXWTPZGXZJGZGSJSGKDDHTQGGZLLBJDZLCBCHYXYZHZFYWXYZYMSDBZZYJGTSMTFXQYXQSTDGSLNXDLRYZZLRYYLXQHTXSRTZNGZXBNQQZFMYKMZJBZYMKBPNLYZPBLMCNQYZZZSJZHJCTZKHYZZJRDYZHNPXGLFZTLKGJTCTSSYLLGZRZBBQZZKLPKLCZYSSUYXBJFPNJZZXCDWXZYJXZZDJJKGGRSRJKMSMZJLSJYWQSKYHQJSXPJZZZLSNSHRNYPZTWCHKLPSRZLZXYJQXQKYSJYCZTLQZYBBYBWZPQDWWYZCYTJCJXCKCWDKKZXSGKDZXWWYYJQYYTCYTDLLXWKCZKKLCCLZCQQDZLQLCSFQCHQHSFSMQZZLNBJJZBSJHTSZDYSJQJPDLZCDCWJKJZZLPYCGMZWDJJBSJQZSYZYHHXJPBJYDSSXDZNCGLQMBTSFSBPDZDLZNFGFJGFSMPXJQLMBLGQCYYXBQKDJJQYRFKZTJDHCZKLBSDZCFJTPLLJGXHYXZCSSZZXSTJYGKGCKGYOQXJPLZPBPGTGYJZGHZQZZLBJLSQFZGKQQJZGYCZBZQTLDXRJXBSXXPZXHYZYCLWDXJJHXMFDZPFZHQHQMQGKSLYHTYCGFRZGNQXCLPDLBZCSCZQLLJBLHBZCYPZZPPDYMZZSGYHCKCPZJGSLJLNSCDSLDLXBMSTLDDFJMKDJDHZLZXLSZQPQPGJLLYBDSZGQLBZLSLKYYHZTTNTJYQTZZPSZQZTLLJTYYLLQLLQYZQLBDZLSLYYZYMDFSZSNHLXZNCZQZPBWSKRFBSYZMTHBLGJPMCZZLSTLXSHTCSYZLZBLFEQHLXFLCJLYLJQCBZLZJHHSSTBRMHXZHJZCLXFNBGXGTQJCZTMSFZKJMSSNXLJKBHSJXNTNLZDNTLMSJXGZJYJCZXYJYJWRWWQNZTNFJSZPZSHZJFYRDJSFSZJZBJFZQZZHZLXFYSBZQLZSGYFTZDCSZXZJBQMSZKJRHYJZCKMJKHCHGTXKXQGLXPXFXTRTYLXJXHDTSJXHJZJXZWZLCQSBTXWXGXTXXHXFTSDKFJHZYJFJXRZSDLLLTQSQQZQWZXSYQTWGWBZCGZLLYZBCLMQQTZHZXZXLJFRMYZFLXYSQXXJKXRMQDZDMMYYBSQBHGZMWFWXGMXLZPYYTGZYCCDXYZXYWGSYJYZNBHPZJSQSYXSXRTFYZGRHZTXSZZTHCBFCLSYXZLZQMZLMPLMXZJXSFLBYZMYQHXJSXRXSQZZZSSLYFRCZJRCRXHHZXQYDYHXSJJHZCXZBTYNSYSXJBQLPXZQPYMLXZKYXLXCJLCYSXXZZLXDLLLJJYHZXGYJWKJRWYHCPSGNRZLFZWFZZNSXGXFLZSXZZZBFCSYJDBRJKRDHHGXJLJJTGXJXXSTJTJXLYXQFCSGSWMSBCTLQZZWLZZKXJMLTMJYHSDDBXGZHDLBMYJFRZFSGCLYJBPMLYSMSXLSZJQQHJZFXGFQFQBPXZGYYQXGZTCQWYLTLGWSGWHRLFSFGZJMGMGBGTJFSYZZGZYZAFLSSPMLPFLCWBJZCLJJMZLPJJLYMQDMYYYFBGYGYZMLYZDXQYXRQQQHSYYYQXYLJTYXFSFSLLGNQCYHYCWFHCCCFXPYLYPLLZYXXXXXKQHHXSHJZCFZSCZJXCPZWHHHHHAPYLQALPQAFYHXDYLUKMZQGGGDDESRNNZLTZGCHYPPYSQJJHCLLJTOLNJPZLJLHYMHEYDYDSQYCDDHGZUNDZCLZYZLLZNTNYZGSLHSLPJJBDGWXPCDUTJCKLKCLWKLLCASSTKZZDNQNTTLYYZSSYSSZZRYLJQKCQDHHCRXRZYDGRGCWCGZQFFFPPJFZYNAKRGYWYQPQXXFKJTSZZXSWZDDFBBXTBGTZKZNPZZPZXZPJSZBMQHKCYXYLDKLJNYPKYGHGDZJXXEAHPNZKZTZCMXCXMMJXNKSZQNMNLWBWWXJKYHCPSTMCSQTZJYXTPCTPDTNNPGLLLZSJLSPBLPLQHDTNJNLYYRSZFFJFQWDPHZDWMRZCCLODAXNSSNYZRESTYJWJYJDBCFXNMWTTBYLWSTSZGYBLJPXGLBOCLHPCBJLTMXZLJYLZXCLTPNCLCKXTPZJSWCYXSFYSZDKNTLBYJCYJLLSTGQCBXRYZXBXKLYLHZLQZLNZCXWJZLJZJNCJHXMNZZGJZZXTZJXYCYYCXXJYYXJJXSSSJSTSSTTPPGQTCSXWZDCSYFPTFBFHFBBLZJCLZZDBXGCXLQPXKFZFLSYLTUWBMQJHSZBMDDBCYSCCLDXYCDDQLYJJWMQLLCSGLJJSYFPYYCCYLTJANTJJPWYCMMGQYYSXDXQMZHSZXPFTWWZQSWQRFKJLZJQQYFBRXJHHFWJJZYQAZMYFRHCYYBYQWLPEXCCZSTYRLTTDMQLYKMBBGMYYJPRKZNPBSXYXBHYZDJDNGHPMFSGMWFZMFQMMBCMZZCJJLCNUXYQLMLRYGQZCYXZLWJGCJCGGMCJNFYZZJHYCPRRCMTZQZXHFQGTJXCCJEAQCRJYHPLQLSZDJRBCQHQDYRHYLYXJSYMHZYDWLDFRYHBPYDTSSCNWBXGLPZMLZZTQSSCPJMXXYCSJYTYCGHYCJWYRXXLFEMWJNMKLLSWTXHYYYNCMMCWJDQDJZGLLJWJRKHPZGGFLCCSCZMCBLTBHBQJXQDSPDJZZGHGLFQYWBZYZJLTSTDHQHCTCBCHFLQMPWDSHYYTQWCNZZJTLBYMBPDYYYXSQKXWYYFLXXNCWCXYPMAELYKKJMZZZBRXYYQJFLJPFHHHYTZZXSGQQMHSPGDZQWBWPJHZJDYSCQWZKTXXSQLZYYMYSDZGRXCKKUJLWPYSYSCSYZLRMLQSYLJXBCXTLWDQZPCYCYKPPPNSXFYZJJRCEMHSZMSXLXGLRWGCSTLRSXBZGBZGZTCPLUJLSLYLYMTXMTZPALZXPXJTJWTCYYZLBLXBZLQMYLXPGHDSLSSDMXMBDZZSXWHAMLCZCPJMCNHJYSNSYGCHSKQMZZQDLLKABLWJXSFMOCDXJRRLYQZKJMYBYQLYHETFJZFRFKSRYXFJTWDSXXSYSQJYSLYXWJHSNLXYYXHBHAWHHJZXWMYLJCSSLKYDZTXBZSYFDXGXZJKHSXXYBSSXDPYNZWRPTQZCZENYGCXQFJYKJBZMLJCMQQXUOXSLYXXLYLLJDZBTYMHPFSTTQQWLHOKYBLZZALZXQLHZWRRQHLSTMYPYXJJXMQSJFNBXYXYJXXYQYLTHYLQYFMLKLJTMLLHSZWKZHLJMLHLJKLJSTLQXYLMBHHLNLZXQJHXCFXXLHYHJJGBYZZKBXSCQDJQDSUJZYYHZHHMGSXCSYMXFEBCQWWRBPYYJQTYZCYQYQQZYHMWFFHGZFRJFCDPXNTQYZPDYKHJLFRZXPPXZDBBGZQSTLGDGYLCQMLCHHMFYWLZYXKJLYPQHSYWMQQGQZMLZJNSQXJQSYJYCBEHSXFSZPXZWFLLBCYYJDYTDTHWZSFJMQQYJLMQXXLLDTTKHHYBFPWTYYSQQWNQWLGWDEBZWCMYGCULKJXTMXMYJSXHYBRWFYMWFRXYQMXYSZTZZTFYKMLDHQDXWYYNLCRYJBLPSXCXYWLSPRRJWXHQYPHTYDNXHHMMYWYTZCSQMTSSCCDALWZTCPQPYJLLQZYJSWXMZZMMYLMXCLMXCZMXMZSQTZPPQQBLPGXQZHFLJJHYTJSRXWZXSCCDLXTYJDCQJXSLQYCLZXLZZXMXQRJMHRHZJBHMFLJLMLCLQNLDXZLLLPYPSYJYSXCQQDCMQJZZXHNPNXZMEKMXHYKYQLXSXTXJYYHWDCWDZHQYYBGYBCYSCFGPSJNZDYZZJZXRZRQJJYMCANYRJTLDPPYZBSTJKXXZYPFDWFGZZRPYMTNGXZQBYXNBUFNQKRJQZMJEGRZGYCLKXZDSKKNSXKCLJSPJYYZLQQJYBZSSQLLLKJXTBKTYLCCDDBLSPPFYLGYDTZJYQGGKQTTFZXBDKTYYHYBBFYTYYBCLPDYTGDHRYRNJSPTCSNYJQHKLLLZSLYDXXWBCJQSPXBPJZJCJDZFFXXBRMLAZHCSNDLBJDSZBLPRZTSWSBXBCLLXXLZDJZSJPYLYXXYFTFFFBHJJXGBYXJPMMMPSSJZJMTLYZJXSWXTYLEDQPJMYGQZJGDJLQJWJQLLSJGJGYGMSCLJJXDTYGJQJQJCJZCJGDZZSXQGSJGGCXHQXSNQLZZBXHSGZXCXYLJXYXYYDFQQJHJFXDHCTXJYRXYSQTJXYEFYYSSYYJXNCYZXFXMSYSZXYYSCHSHXZZZGZZZGFJDLTYLNPZGYJYZYYQZPBXQBDZTZCZYXXYHHSQXSHDHGQHJHGYWSZTMZMLHYXGEBTYLZKQWYTJZRCLEKYSTDBCYKQQSAYXCJXWWGSBHJYZYDHCSJKQCXSWXFLTYNYZPZCCZJQTZWJQDZZZQZLJJXLSBHPYXXPSXSHHEZTXFPTLQYZZXHYTXNCFZYYHXGNXMYWXTZSJPTHHGYMXMXQZXTSBCZYJYXXTYYZYPCQLMMSZMJZZLLZXGXZAAJZYXJMZXWDXZSXZDZXLEYJJZQBHZWZZZQTZPSXZTDSXJJJZNYAZPHXYYSRNQDTHZHYYKYJHDZXZLSWCLYBZYECWCYCRYLCXNHZYDZYDYJDFRJJHTRSQTXYXJRJHOJYNXELXSFSFJZGHPZSXZSZDZCQZBYYKLSGSJHCZSHDGQGXYZGXCHXZJWYQWGYHKSSEQZZNDZFKWYSSTCLZSTSYMCDHJXXYWEYXCZAYDMPXMDSXYBSQMJMZJMTZQLPJYQZCGQHXJHHLXXHLHDLDJQCLDWBSXFZZYYSCHTYTYYBHECXHYKGJPXHHYZJFXHWHBDZFYZBCAPNPGNYDMSXHMMMMAMYNBYJTMPXYYMCTHJBZYFCGTYHWPHFTWZZEZSBZEGPFMTSKFTYCMHFLLHGPZJXZJGZJYXZSBBQSCZZLZCCSTPGXMJSFTCCZJZDJXCYBZLFCJSYZFGSZLYBCWZZBYZDZYPSWYJZXZBDSYUXLZZBZFYGCZXBZHZFTPBGZGEJBSTGKDMFHYZZJHZLLZZGJQZLSFDJSSCBZGPDLFZFZSZYZYZSYGCXSNXXCHCZXTZZLJFZGQSQYXZJQDCCZTQCDXZJYQJQCHXZTDLGSCXZSYQJQTZWLQDQZTQCHQQJZYEZZZPBWKDJFCJPZTYPQYQTTYNLMBDKTJZPQZQZZFPZSBNJLGYJDXJDZZKZGQKXDLPZJTCJDQBXDJQJSTCKNXBXZMSLYJCQMTJQWWCJQNJNLLLHJCWQTBZQYDZCZPZZDZYDDCYZZZCCJTTJFZDPRRTZTJDCQTQZDTJNPLZBCLLCTZSXKJZQZPZLBZRBTJDCXFCZDBCCJJLTQQPLDCGZDBBZJCQDCJWYNLLZYZCCDWLLXWZLXRXNTQQCZXKQLSGDFQTDDGLRLAJJTKUYMKQLLTZYTDYYCZGJWYXDXFRSKSTQTENQMRKQZHHQKDLDAZFKYPBGGPZREBZZYKZZSPEGJXGYKQZZZSLYSYYYZWFQZYLZZLZHWCHKYPQGNPGBLPLRRJYXCCSYYHSFZFYBZYYTGZXYLXCZWXXZJZBLFFLGSKHYJZEYJHLPLLLLCZGXDRZELRHGKLZZYHZLYQSZZJZQLJZFLNBHGWLCZCFJYSPYXZLZLXGCCPZBLLCYBBBBUBBCBPCRNNZCZYRBFSRLDCGQYYQXYGMQZWTZYTYJXYFWTEHZZJYWLCCNTZYJJZDEDPZDZTSYQJHDYMBJNYJZLXTSSTPHNDJXXBYXQTZQDDTJTDYYTGWSCSZQFLSHLGLBCZPHDLYZJYCKWTYTYLBNYTSDSYCCTYSZYYEBHEXHQDTWNYGYCLXTSZYSTQMYGZAZCCSZZDSLZCLZRQXYYELJSBYMXSXZTEMBBLLYYLLYTDQYSHYMRQWKFKBFXNXSBYCHXBWJYHTQBPBSBWDZYLKGZSKYHXQZJXHXJXGNLJKZLYYCDXLFYFGHLJGJYBXQLYBXQPQGZTZPLNCYPXDJYQYDYMRBESJYYHKXXSTMXRCZZYWXYQYBMCLLYZHQYZWQXDBXBZWZMSLPDMYSKFMZKLZCYQYCZLQXFZZYDQZPZYGYJYZMZXDZFYFYTTQTZHGSPCZMLCCYTZXJCYTJMKSLPZHYSNZLLYTPZCTZZCKTXDHXXTQCYFKSMQCCYYAZHTJPCYLZLYJBJXTPNYLJYYNRXSYLMMNXJSMYBCSYSYLZYLXJJQYLDZLPQBFZZBLFNDXQKCZFYWHGQMRDSXYCYTXNQQJZYYPFZXDYZFPRXEJDGYQBXRCNFYYQPGHYJDYZXGRHTKYLNWDZNTSMPKLBTHBPYSZBZTJZSZZJTYYXZPHSSZZBZCZPTQFZMYFLYPYBBJQXZMXXDJMTSYSKKBJZXHJCKLPSMKYJZCXTMLJYXRZZQSLXXQPYZXMKYXXXJCLJPRMYYGADYSKQLSNDHYZKQXZYZTCGHZTLMLWZYBWSYCTBHJHJFCWZTXWYTKZLXQSHLYJZJXTMPLPYCGLTBZZTLZJCYJGDTCLKLPLLQPJMZPAPXYZLKKTKDZCZZBNZDYDYQZJYJGMCTXLTGXSZLMLHBGLKFWNWZHDXUHLFMKYSLGXDTWWFRJEJZTZHYDXYKSHWFZCQSHKTMQQHTZHYMJDJSKHXZJZBZZXYMPAGQMSTPXLSKLZYNWRTSQLSZBPSPSGZWYHTLKSSSWHZZLYYTNXJGMJSZSUFWNLSOZTXGXLSAMMLBWLDSZYLAKQCQCTMYCFJBSLXCLZZCLXXKSBZQCLHJPSQPLSXXCKSLNHPSFQQYTXYJZLQLDXZQJZDYYDJNZPTUZDSKJFSLJHYLZSQZLBTXYDGTQFDBYAZXDZHZJNHHQBYKNXJJQCZMLLJZKSPLDYCLBBLXKLELXJLBQYCXJXGCNLCQPLZLZYJTZLJGYZDZPLTQCSXFDMNYCXGBTJDCZNBGBQYQJWGKFHTNPYQZQGBKPBBYZMTJDYTBLSQMPSXTBNPDXKLEMYYCJYNZCTLDYKZZXDDXHQSHDGMZSJYCCTAYRZLPYLTLKXSLZCGGEXCLFXLKJRTLQJAQZNCMBYDKKCXGLCZJZXJHPTDJJMZQYKQSECQZDSHHADMLZFMMZBGNTJNNLGBYJBRBTMLBYJDZXLCJLPLDLPCQDHLXZLYCBLCXZZJADJLNZMMSSSMYBHBSQKBHRSXXJMXSDZNZPXLGBRHWGGFCXGMSKLLTSJYYCQLTSKYWYYHYWXBXQYWPYWYKQLSQPTNTKHQCWDQKTWPXXHCPTHTWUMSSYHBWCRWXHJMKMZNGWTMLKFGHKJYLSYYCXWHYECLQHKQHTTQKHFZLDXQWYZYYDESBPKYRZPJFYYZJCEQDZZDLATZBBFJLLCXDLMJSSXEGYGSJQXCWBXSSZPDYZCXDNYXPPZYDLYJCZPLTXLSXYZYRXCYYYDYLWWNZSAHJSYQYHGYWWAXTJZDAXYSRLTDPSSYYFNEJDXYZHLXLLLZQZSJNYQYQQXYJGHZGZCYJCHZLYCDSHWSHJZYJXCLLNXZJJYYXNFXMWFPYLCYLLABWDDHWDXJMCXZTZPMLQZHSFHZYNZTLLDYWLSLXHYMMYLMBWWKYXYADTXYLLDJPYBPWUXJMWMLLSAFDLLYFLBHHHBQQLTZJCQJLDJTFFKMMMBYTHYGDCQRDDWRQJXNBYSNWZDBYYTBJHPYBYTTJXAAHGQDQTMYSTQXKBTZPKJLZRBEQQSSMJJBDJOTGTBXPGBKTLHQXJJJCTHXQDWJLWRFWQGWSHCKRYSWGFTGYGBXSDWDWRFHWYTJJXXXJYZYSLPYYYPAYXHYDQKXSHXYXGSKQHYWFDDDPPLCJLQQEEWXKSYYKDYPLTJTHKJLTCYYHHJTTPLTZZCDLTHQKZXQYSTEEYWYYZYXXYYSTTJKLLPZMCYHQGXYHSRMBXPLLNQYDQHXSXXWGDQBSHYLLPJJJTHYJKYPPTHYYKTYEZYENMDSHLCRPQFDGFXZPSFTLJXXJBSWYYSKSFLXLPPLBBBLBSFXFYZBSJSSYLPBBFFFFSSCJDSTZSXZRYYSYFFSYZYZBJTBCTSBSDHRTJJBYTCXYJEYLXCBNEBJDSYXYKGSJZBXBYTFZWGENYHHTHZHHXFWGCSTBGXKLSXYWMTMBYXJSTZSCDYQRCYTWXZFHMYMCXLZNSDJTTTXRYCFYJSBSDYERXJLJXBBDEYNJGHXGCKGSCYMBLXJMSZNSKGXFBNBPTHFJAAFXYXFPXMYPQDTZCXZZPXRSYWZDLYBBKTYQPQJPZYPZJZNJPZJLZZFYSBTTSLMPTZRTDXQSJEHBZYLZDHLJSQMLHTXTJECXSLZZSPKTLZKQQYFSYGYWPCPQFHQHYTQXZKRSGTTSQCZLPTXCDYYZXSQZSLXLZMYCPCQBZYXHBSXLZDLTCDXTYLZJYYZPZYZLTXJSJXHLPMYTXCQRBLZSSFJZZTNJYTXMYJHLHPPLCYXQJQQKZZSCPZKSWALQSBLCCZJSXGWWWYGYKTJBBZTDKHXHKGTGPBKQYSLPXPJCKBMLLXDZSTBKLGGQKQLSBKKTFXRMDKBFTPZFRTBBRFERQGXYJPZSSTLBZTPSZQZSJDHLJQLZBPMSMMSXLQQNHKNBLRDDNXXDHDDJCYYGYLXGZLXSYGMQQGKHBPMXYXLYTQWLWGCPBMQXCYZYDRJBHTDJYHQSHTMJSBYPLWHLZFFNYPMHXXHPLTBQPFBJWQDBYGPNZTPFZJGSDDTQSHZEAWZZYLLTYYBWJKXXGHLFKXDJTMSZSQYNZGGSWQSPHTLSSKMCLZXYSZQZXNCJDQGZDLFNYKLJCJLLZLMZZNHYDSSHTHZZLZZBBHQZWWYCRZHLYQQJBEYFXXXWHSRXWQHWPSLMSSKZTTYGYQQWRSLALHMJTQJSMXQBJJZJXZYZKXBYQXBJXSHZTSFJLXMXZXFGHKZSZGGYLCLSARJYHSLLLMZXELGLXYDJYTLFBHBPNLYZFBBHPTGJKWETZHKJJXZXXGLLJLSTGSHJJYQLQZFKCGNNDJSSZFDBCTWWSEQFHQJBSAQTGYPQLBXBMMYWXGSLZHGLZGQYFLZBYFZJFRYSFMBYZHQGFWZSYFYJJPHZBYYZFFWODGRLMFTWLBZGYCQXCDJYGZYYYYTYTYDWEGAZYHXJLZYYHLRMGRXXZCLHNELJJTJTPWJYBJJBXJJTJTEEKHWSLJPLPSFYZPQQBDLQJJTYYQLYZKDKSQJYYQZLDQTGJQYZJSUCMRYQTHTEJMFCTYHYPKMHYZWJDQFHYYXWSHCTXRLJHQXHCCYYYJLTKTTYTMXGTCJTZAYYOCZLYLBSZYWJYTSJYHBYSHFJLYGJXXTMZYYLTXXYPZLXYJZYZYYPNHMYMDYYLBLHLSYYQQLLNJJYMSOYQBZGDLYXYLCQYXTSZEGXHZGLHWBLJHEYXTWQMAKBPQCGYSHHEGQCMWYYWLJYJHYYZLLJJYLHZYHMGSLJLJXCJJYCLYCJPCPZJZJMMYLCQLNQLJQJSXYJMLSZLJQLYCMMHCFMMFPQQMFYLQMCFFQMMMMHMZNFHHJGTTHHKHSLNCHHYQDXTMMQDCYZYXYQMYQYLTDCYYYZAZZCYMZYDLZFFFMMYCQZWZZMABTBYZTDMNZZGGDFTYPCGQYTTSSFFWFDTZQSSYSTWXJHXYTSXXYLBYQHWWKXHZXWZNNZZJZJJQJCCCHYYXBZXZCYZTLLCQXYNJYCYYCYNZZQYYYEWYCZDCJYCCHYJLBTZYYCQWMPWPYMLGKDLDLGKQQBGYCHJXY",b={ +19969:"DZ",19975:"WM",19988:"QJ",20048:"YL",20056:"SC",20060:"NM",20094:"QG",20127:"QJ",20167:"QC",20193:"YG",20250:"KH",20256:"ZC",20282:"SC",20285:"QJG",20291:"TD",20314:"YD",20315:"BF",20340:"NE",20375:"TD",20389:"YJ",20391:"CZ",20415:"PB",20446:"YS",20447:"SQ",20504:"TC",20608:"KG",20854:"QJ",20857:"ZC",20911:"PF",20985:"AW",21032:"PB",21048:"XQ",21049:"SC",21089:"YS",21119:"JC",21242:"SB",21273:"SC",21305:"YP",21306:"QO",21330:"ZC",21333:"SDC",21345:"QK",21378:"CA",21397:"SC",21414:"XS",21442:"SC",21477:"JG",21480:"TD",21484:"ZS",21494:"YX",21505:"YX",21512:"HG",21523:"XH",21537:"PB",21542:"PF",21549:"KH",21571:"E",21574:"DA",21588:"TD",21589:"O",21618:"ZC",21621:"KHA",21632:"ZJ",21654:"KG",21679:"LKG",21683:"KH",21710:"A",21719:"YH",21734:"WOE",21769:"A",21780:"WN",21804:"XH",21834:"A",21899:"ZD",21903:"RN",21908:"WO",21939:"ZC",21956:"SA",21964:"YA",21970:"TD",22003:"A",22031:"JG",22040:"XS",22060:"ZC",22066:"ZC",22079:"MH",22129:"XJ",22179:"XA",22237:"NJ",22244:"TD",22280:"JQ",22300:"YH",22313:"XW",22331:"YQ",22343:"YJ",22351:"PH",22395:"DC",22412:"TD",22484:"PB",22500:"PB",22534:"ZD",22549:"DH",22561:"PB",22612:"TD",22771:"KQ",22831:"HB",22841:"JG",22855:"QJ",22865:"XQ",23013:"ML",23081:"WM",23487:"SX",23558:"QJ",23561:"YW",23586:"YW",23614:"YW",23615:"SN",23631:"PB",23646:"ZS",23663:"ZT",23673:"YG",23762:"TD",23769:"ZS",23780:"QJ",23884:"QK",24055:"XH",24113:"DC",24162:"ZC",24191:"GA",24273:"QJ",24324:"NL",24377:"TD",24378:"QJ",24439:"PF",24554:"ZS",24683:"TD",24694:"WE",24733:"LK",24925:"TN",25094:"ZG",25100:"XQ",25103:"XH",25153:"PB",25170:"PB",25179:"KG",25203:"PB",25240:"ZS",25282:"FB",25303:"NA",25324:"KG",25341:"ZY",25373:"WZ",25375:"XJ",25384:"A",25457:"A",25528:"SD",25530:"SC",25552:"TD",25774:"ZC",25874:"ZC",26044:"YW",26080:"WM",26292:"PB",26333:"PB",26355:"ZY",26366:"CZ",26397:"ZC",26399:"QJ",26415:"ZS",26451:"SB",26526:"ZC",26552:"JG",26561:"TD",26588:"JG",26597:"CZ",26629:"ZS",26638:"YL",26646:"XQ",26653:"KG",26657:"XJ",26727:"HG",26894:"ZC",26937:"ZS",26946:"ZC",26999:"KJ",27099:"KJ",27449:"YQ",27481:"XS",27542:"ZS",27663:"ZS",27748:"TS",27784:"SC",27788:"ZD",27795:"TD",27812:"O",27850:"PB",27852:"MB",27895:"SL",27898:"PL",27973:"QJ",27981:"KH",27986:"HX",27994:"XJ",28044:"YC",28065:"WG",28177:"SM",28267:"QJ",28291:"KH",28337:"ZQ",28463:"TL",28548:"DC",28601:"TD",28689:"PB",28805:"JG",28820:"QG",28846:"PB",28952:"TD",28975:"ZC",29100:"A",29325:"QJ",29575:"SL",29602:"FB",30010:"TD",30044:"CX",30058:"PF",30091:"YSP",30111:"YN",30229:"XJ",30427:"SC",30465:"SX",30631:"YQ",30655:"QJ",30684:"QJG",30707:"SD",30729:"XH",30796:"LG",30917:"PB",31074:"NM",31085:"JZ",31109:"SC",31181:"ZC",31192:"MLB",31293:"JQ",31400:"YX",31584:"YJ",31896:"ZN",31909:"ZY",31995:"XJ",32321:"PF",32327:"ZY",32418:"HG",32420:"XQ",32421:"HG",32438:"LG",32473:"GJ",32488:"TD",32521:"QJ",32527:"PB",32562:"ZSQ",32564:"JZ",32735:"ZD",32793:"PB",33071:"PF",33098:"XL",33100:"YA",33152:"PB",33261:"CX",33324:"BP",33333:"TD",33406:"YA",33426:"WM",33432:"PB",33445:"JG",33486:"ZN",33493:"TS",33507:"QJ",33540:"QJ",33544:"ZC",33564:"XQ",33617:"YT",33632:"QJ",33636:"XH",33637:"YX",33694:"WG",33705:"PF",33728:"YW",33882:"SR",34067:"WM",34074:"YW",34121:"QJ",34255:"ZC",34259:"XL",34425:"JH",34430:"XH",34485:"KH",34503:"YS",34532:"HG",34552:"XS",34558:"YE",34593:"ZL",34660:"YQ",34892:"XH",34928:"SC",34999:"QJ",35048:"PB",35059:"SC",35098:"ZC",35203:"TQ",35265:"JX",35299:"JX",35782:"SZ",35828:"YS",35830:"E",35843:"TD",35895:"YG",35977:"MH",36158:"JG",36228:"QJ",36426:"XQ",36466:"DC",36710:"JC",36711:"ZYG",36767:"PB",36866:"SK",36951:"YW",37034:"YX",37063:"XH",37218:"ZC",37325:"ZC",38063:"PB",38079:"TD",38085:"QY",38107:"DC",38116:"TD",38123:"YD",38224:"HG",38241:"XTC",38271:"ZC",38415:"YE",38426:"KH",38461:"YD",38463:"AE",38466:"PB",38477:"XJ",38518:"YT",38551:"WK",38585:"ZC",38704:"XS",38739:"LJ",38761:"GJ",38808:"SQ",39048:"JG",39049:"XJ",39052:"HG",39076:"CZ",39271:"XT",39534:"TD",39552:"TD",39584:"PB",39647:"SB",39730:"LG",39748:"TPB",40109:"ZQ",40479:"ND",40516:"HG",40536:"HG",40583:"QJ",40765:"YQ",40784:"QJ",40840:"YK",40863:"QJG"},c=function(c){var d=c.charCodeAt(0);return d>40869||d<19968?c:b[d]?b[d]:a.charAt(d-19968)},d=function(a){for(var b,c=[""],d=0,e=a.length;d div, .contract-trigger:before { content: " "; display: block; position: absolute; top: 0; left: 0; height: 100%; width: 100%; overflow: hidden; } .resize-triggers > div { background: #eee; overflow: auto; } .contract-trigger:before { width: 200%; height: 200%; }',b=document.head||document.getElementsByTagName("head")[0],d=document.createElement("style");d.type="text/css",d.styleSheet?d.styleSheet.cssText=a:d.appendChild(document.createTextNode(a)),b.appendChild(d),c=!0}},v=function(a,c){b?(a.__resizeTriggers__||("static"===getComputedStyle(a).position&&(a.style.position="relative"),u(),a.__resizeLast__={},a.__resizeListeners__=[],(a.__resizeTriggers__=document.createElement("div")).className="resize-triggers",a.__resizeTriggers__.innerHTML='
',a.appendChild(a.__resizeTriggers__),f(a),a.addEventListener("scroll",h,!0),l&&a.__resizeTriggers__.addEventListener(l,function(b){b.animationName===r&&f(a)})),a.__resizeListeners__.push(c)):a.attachEvent("onresize",c)},w=function(a,c){b?(a.__resizeListeners__.splice(a.__resizeListeners__.indexOf(c),1),a.__resizeListeners__.length||(a.removeEventListener("scroll",h,!0),a.__resizeTriggers__=!a.removeChild(a.__resizeTriggers__))):a.detachEvent("onresize",c)};BI.ResizeDetector={addResizeListener:function(a,b){return v(a.element[0],b),function(){w(a.element[0],b)}},removeResizeListener:function(a,b){w(a.element[0],b)}}}(),function(){function a(a,b){return a0&&(this._items[0]=b,this._sinkDown(0)),a}},push:function(a){this._items[this._size++]=a,this._bubbleUp(this._size-1)},size:function(){return this._size},peek:function(){if(0!==this._size)return this._items[0]},_heapify:function(){for(var a=Math.floor((this._size+1)/2);a>=0;a--)this._sinkDown(a)},_bubbleUp:function(a){for(var b=this._items[a];a>0;){var c=Math.floor((a+1)/2)-1,d=this._items[c];if(this._comparator(d,b))return;this._items[c]=b,this._items[a]=d,a=c}},_sinkDown:function(a){for(var b=this._items[a];;){var c=2*(a+1)-1,d=2*(a+1),e=-1;if(cc?c:b},b=5,c={index:0,offset:0,position:0,contentHeight:0};BI.TableScrollHelper=function(a,b,c,d){this._rowOffsets=BI.PrefixIntervalTree.uniform(a,b),this._storedHeights=new Array(a);for(var e=0;e=0&&c>=a-b;){var d=this._updateRowHeight(c);this._position+=d,c--}},_updateRowHeight:function(a){if(a<0||a>=this._rowCount)return 0;var b=this._rowHeightGetter(a);if(b!==this._storedHeights[a]){var c=b-this._storedHeights[a];return this._rowOffsets.set(a,b),this._storedHeights[a]=b,this._contentHeight+=c,c}return 0},getRowPosition:function(a){return this._updateRowHeight(a),this._rowOffsets.sumUntil(a)},scrollBy:function(b){if(0===this._rowCount)return c;var d=this._rowOffsets.greatestLowerBound(this._position);d=a(d,0,Math.max(this._rowCount-1,0));var e=this._rowOffsets.sumUntil(d),f=d,g=this._position,h=this._updateRowHeight(f);0!==e&&(g+=h);var i=this._storedHeights[f]-(g-e);if(b>=0)for(;b>0&&f0&&f>=0;)if(b=0){var k=this._updateRowHeight(f);j=this._storedHeights[f],g+=k}}var l=this._contentHeight-this._viewportHeight;g=a(g,0,l),this._position=g;var m=this._rowOffsets.greatestLowerBound(g);m=a(m,0,Math.max(this._rowCount-1,0)),e=this._rowOffsets.sumUntil(m);var n=e-g;return this._updateHeightsInViewport(m,n),this._updateHeightsAboveViewport(m),{index:m,offset:n,position:this._position,contentHeight:this._contentHeight}},_getRowAtEndPosition:function(a){this._updateRowHeight(a);for(var b=a,c=this._storedHeights[b];c=0;)b--,b>=0&&(this._updateRowHeight(b),c+=this._storedHeights[b]);var d=this._rowOffsets.sumTo(a)-this._viewportHeight;return d<0&&(d=0),d},scrollTo:function(b){if(0===this._rowCount)return c;if(b<=0)return this._position=0,this._updateHeightsInViewport(0,0),{index:0,offset:0,position:this._position,contentHeight:this._contentHeight};if(b>=this._contentHeight-this._viewportHeight){var d=this._rowCount-1;b=this._getRowAtEndPosition(d)}this._position=b;var e=this._rowOffsets.greatestLowerBound(b);e=a(e,0,Math.max(this._rowCount-1,0));var f=this._rowOffsets.sumUntil(e),g=f-b;return this._updateHeightsInViewport(e,g),this._updateHeightsAboveViewport(e),{index:e,offset:g,position:this._position,contentHeight:this._contentHeight}},scrollToRow:function(b,c){b=a(b,0,Math.max(this._rowCount-1,0)),c=a(c,-this._storedHeights[b],0);var d=this._rowOffsets.sumUntil(b);return this.scrollTo(d-c)},scrollRowIntoView:function(b){b=a(b,0,Math.max(this._rowCount-1,0));var c=this._rowOffsets.sumUntil(b),d=c+this._storedHeights[b];if(c=a&&e<=b)return null;var f;a-d>e-b?(f=d,this._smallValues.pop()):(f=e,this._largeValues.pop());var g=this._valueToPositionMap[f];return delete this._valueToPositionMap[f],this._valueToPositionMap[c]=g,this._pushToHeaps(g,c),g},_pushToHeaps:function(a,b){var c={position:a,value:b};this._smallValues.push(c),this._largeValues.push(c)},_cleanHeaps:function(){this._cleanHeap(this._smallValues),this._cleanHeap(this._largeValues);var a=Math.min(this._smallValues.size(),this._largeValues.size()),b=Math.max(this._smallValues.size(),this._largeValues.size());b>10*a&&this._recreateHeaps()},_recreateHeaps:function(){for(var a=this._smallValues.size()b.value}},!function(){BI.LinkHashMap=function(){this.array=[],this.map={}},BI.LinkHashMap.prototype={constructor:BI.LinkHashMap,has:function(a){return a in this.map},add:function(a,b){"undefined"!=typeof a&&(a in this.map?this.map[a]=b:(this.array.push(a),this.map[a]=b))},remove:function(a){if(a in this.map){delete this.map[a];for(var b=0;b>5]|=128<>>9<<4)+14]=b;for(var c=1732584193,d=-271733879,e=-1732584194,f=271733878,g=0;g16&&(c=this.core_md5(c,a.length*this.chrsz));for(var d=Array(16),e=Array(16),f=0;f<16;f++)d[f]=909522486^c[f],e[f]=1549556828^c[f];var g=this.core_md5(d.concat(this.str2binl(b)),512+b.length*this.chrsz);return this.core_md5(e.concat(g),640)},a.prototype.safe_add=function(a,b){var c=(65535&a)+(65535&b),d=(a>>16)+(b>>16)+(c>>16);return d<<16|65535&c},a.prototype.bit_rol=function(a,b){return a<>>32-b},a.prototype.str2binl=function(a){for(var b=Array(),c=(1<>5]|=(a.charCodeAt(d/this.chrsz)&c)<>2]>>d%4*8+4&15)+b.charAt(a[d>>2]>>d%4*8&15);return c},a.prototype.binl2b64=function(a){for(var b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",c="",d=0;d<4*a.length;d+=3)for(var e=(a[d>>2]>>8*(d%4)&255)<<16|(a[d+1>>2]>>8*((d+1)%4)&255)<<8|a[d+2>>2]>>8*((d+2)%4)&255,f=0;f<4;f++)c+=8*d+6*f>32*a.length?this.b64pad:b.charAt(e>>6*(3-f)&63);return c},BI.MD5=new a}(),function(){var a=function(a){return Math.floor(a/2)},b=window.Int32Array||function(a){for(var b=[],c=a-1;c>=0;--c)b[c]=0;return b},c=function(a){for(var b=1;b0;--d)this._heap[d]=this._heap[2*d]+this._heap[2*d+1]},BI.PrefixIntervalTree.prototype={constructor:BI.PrefixIntervalTree,set:function(b,c){var d=this._half+b;for(this._heap[d]=c,d=a(d);0!==d;d=a(d))this._heap[d]=this._heap[2*d]+this._heap[2*d+1]},get:function(a){var b=this._half+a;return this._heap[b]},getSize:function(){return this._size},sumUntil:function(b){if(0===b)return 0;for(var c=this._half+b-1,d=this._heap[c];1!==c;c=a(c))c%2===1&&(d+=this._heap[c-1]);return d},sumTo:function(a){return this.sumUntil(a+1)},sum:function(a,b){return this.sumUntil(b)-this.sumUntil(a)},greatestLowerBound:function(a){if(a<0)return-1;var b=1;if(this._heap[b]<=a)return this._size;for(;b=0;--d)c[d]=b;return new BI.PrefixIntervalTree(c)},BI.PrefixIntervalTree.empty=function(a){return BI.PrefixIntervalTree.uniform(a,0)}}(),!function(){BI.Queue=function(a){this.capacity=a,this.array=[]},BI.Queue.prototype={constructor:BI.Queue,contains:function(a){return this.array.contains(a)},indexOf:function(a){return this.array.contains(a)},getElementByIndex:function(a){return this.array[a]},push:function(a){this.array.push(a),this.capacity&&this.array.length>this.capacity&&this.array.shift()},pop:function(){this.array.pop()},shift:function(){this.array.shift()},unshift:function(a){this.array.unshift(a),this.capacity&&this.array.length>this.capacity&&this.array.pop()},remove:function(a){this.array.remove(a)},splice:function(){this.array.splice.apply(this.array,arguments)},slice:function(){this.array.slice.apply(this.array,arguments)},size:function(){return this.array.length},each:function(a,b){var b=b||window,a=a||null;if(null!=a&&"function"==typeof a)for(var c=0;cc?c:a},b=6,c=10;BI.TableRowBuffer=function(d,e,f,g){this._bufferSet=new BI.IntegerBufferSet,this._defaultRowHeight=e,this._viewportRowsBegin=0,this._viewportRowsEnd=0,this._maxVisibleRowCount=Math.ceil(f/e)+1,this._bufferRowsCount=a(Math.floor(this._maxVisibleRowCount/2),b,c),this._rowsCount=d,this._rowHeightGetter=g,this._rows=[],this._viewportHeight=f},BI.TableRowBuffer.prototype={constructor:BI.TableRowBuffer,getRowsWithUpdatedBuffer:function(){for(var a=2*this._bufferRowsCount,b=Math.max(this._viewportRowsBegin-this._bufferRowsCount,0);b0;)this._addRowToBuffer(b,this._viewportRowsBegin,this._viewportRowsEnd-1),b++,a--;return this._rows},getRows:function(a,b){var c=b,d=c,e=a,f=Math.min(a+this._maxVisibleRowCount,this._rowsCount);for(this._viewportRowsBegin=a;e=f&&(d=this._bufferSet.replaceFurthestValuePosition(b,c,a)),null===d?(d=this._bufferSet.getNewPositionForValue(a),this._rows[d]=a):this._rows[d]=a}}}(),function(){BI.Tree=function(){this.root=new BI.Node(BI.UUID())},BI.Tree.prototype={constructor:BI.Tree,addNode:function(a,b,c){BI.isNull(b)?this.root.addChild(a,c):BI.isNull(a)?this.root.addChild(b,c):a.addChild(b,c)},isRoot:function(a){return a===this.root},getRoot:function(){return this.root},clear:function(){this.root.clear()},initTree:function(a){var b=this;this.clear();var c=[];for(BI.each(a,function(a,d){var e=new BI.Node(d);e.set("data",d),b.addNode(e),c.push(e)});!BI.isEmpty(c);){var d=c.shift(),e=d.get("data");BI.each(e.children,function(a,e){var f=new BI.Node(e);f.set("data",e),c.push(f),b.addNode(d,f)})}},_toJSON:function(a){var b=this,c=[];return BI.each(a.getChildren(),function(a,d){c.push(b._toJSON(d))}),BI.extend({id:a.id},BI.deepClone(a.get("data")),c.length>0?{children:c}:{})},toJSON:function(a){var b=this,c=[];return BI.each((a||this.root).getChildren(),function(a,d){c.push(b._toJSON(d))}),c},_toJSONWithNode:function(a){var b=this,c=[];return BI.each(a.getChildren(),function(a,d){c.push(b._toJSONWithNode(d))}),BI.extend({id:a.id},BI.deepClone(a.get("data")),{node:a},c.length>0?{children:c}:{})},toJSONWithNode:function(a){var b=this,c=[];return BI.each((a||this.root).getChildren(),function(a,d){c.push(b._toJSONWithNode(d))}),c},search:function(a,b,c){if(!(a instanceof BI.Node))return arguments.callee.apply(this,[this.root,a,b]);var d=this,e=null;return BI.isNull(b)?null:BI.isEqual(a[c||"id"],b)?a:(BI.any(a.getChildren(),function(a,f){if(e=d.search(f,b,c),null!==e)return!0}),e)},_traverse:function(a,b){var c=[];for(c.push(a);!BI.isEmpty(c);){var d=c.shift(),e=b&&b(d);if(e===!1)break;e!==!0&&null!=d&&(c=c.concat(d.getChildren()))}},traverse:function(a){this._traverse(this.root,a)},_recursion:function(a,b,c){var d=this;return BI.every(a.getChildren(),function(a,e){var f=BI.clone(b);f.push(e.id);var g=c&&c(e,f);return g!==!1&&(g===!0||d._recursion(e,f,c))})},recursion:function(a){this._recursion(this.root,[],a)},inOrderTraverse:function(a){this._inOrderTraverse(this.root,a)},_inOrderTraverse:function(a,b){null!=a&&(this._inOrderTraverse(a.getLeft()),b&&b(a),this._inOrderTraverse(a.getRight()))},nrInOrderTraverse:function(a){for(var b=[],c=this.root;null!=c||!BI.isEmpty(b);){for(;null!=c;)b.push(c),c=c.getLeft();c=b.pop(),a&&a(c),c=c.getRight()}},preOrderTraverse:function(a){this._preOrderTraverse(this.root,a)},_preOrderTraverse:function(a,b){null!=a&&(b&&b(a),this._preOrderTraverse(a.getLeft()),this._preOrderTraverse(a.getRight()))},nrPreOrderTraverse:function(a){for(var b=[],c=this.root;null!=c||!BI.isEmpty(b);){for(;null!=c;)a&&a(c),b.push(c),c=c.getLeft();c=b.pop(),c=c.getRight()}},postOrderTraverse:function(a){this._postOrderTraverse(this.root,a)},_postOrderTraverse:function(a,b){null!=a&&(this._postOrderTraverse(a.getLeft()),this._postOrderTraverse(a.getRight()),b&&b(a))},nrPostOrderTraverse:function(a){for(var b=[],c=this.root,d=null;null!=c||!BI.isEmpty(b);){for(;null!=c;)b.push(c),c=c.getLeft();c=BI.last(b),null==c.getRight()||c.getRight()==d?(a&&a(c),c=b.pop(),d=c,c=null):c=c.getRight()}}},BI.Node=function(a){BI.isObject(a)?BI.extend(this,a):this.id=a,this.clear.apply(this,arguments)},BI.Node.prototype={constructor:BI.Node,set:function(a,b){return BI.isObject(a)?void BI.extend(this,a):void(this[a]=b)},get:function(a){return this[a]},isLeaf:function(){return BI.isEmpty(this.children)},getChildren:function(){return this.children},getChildrenLength:function(){return this.children.length},getFirstChild:function(){return BI.first(this.children)},getLastChild:function(){return BI.last(this.children)},setLeft:function(a){this.left=a},getLeft:function(){return this.left},setRight:function(a){this.right=a},getRight:function(){return this.right},setParent:function(a){this.parent=a},getParent:function(){return this.parent},getChild:function(a){return this.children[a]},getChildIndex:function(a){return BI.findIndex(this.children,function(b,c){return c.get("id")===a})},removeChild:function(a){this.removeChildByIndex(this.getChildIndex(a))},removeChildByIndex:function(a){var b=this.getChild(a-1),c=this.getChild(a+1);null!=b&&b.setRight(c||null),null!=c&&c.setLeft(b||null),this.children.splice(a,1)},removeAllChilds:function(){this.children=[]},addChild:function(a,b){var c=null;c=BI.isUndefined(b)?this.children.length-1:b-1,a.setParent(this),c>=0&&(this.getChild(c)&&this.getChild(c).setRight(a),a.setLeft(this.getChild(c))),BI.isUndefined(b)?this.children.push(a):this.children.splice(b,0,a); +},equals:function(a){return this===a||this.id===a.id},clear:function(){this.parent=null,this.left=null,this.right=null,this.children=[]}},BI.extend(BI.Tree,{transformToArrayFormat:function(a,b){if(!a)return[];var c=[];if(BI.isArray(a))for(var d=0,e=a.length;d=this.x&&a<=this.x+this.w&&b>=this.y&&b<=this.y+this.h)},getPosition:function(){var a=[];return a.push(this.x+this.w/2),a.push(this.y+this.h/2),a}},function(){var a={};BI.BufferPool={put:function(b,c){if(BI.isNotNull(a[b]))throw new Error("Buffer Pool has the key already!");a[b]=c},get:function(b){return a[b]}}}(),function(){var a={};BI.SharingPool={_Shared:a,put:function(b,c){a[b]=c},cat:function(){for(var b=Array.prototype.slice.call(arguments,0),c=a,d=0;d 1 && **/BI.isNotEmptyArray(node.values)) { - cnt++; - } - } else { - cnt++; - } - return cnt; - } - - var start = 0, top = 0; - BI.each(nodes, function (i, node) { - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var cnt = getLeafCount(child); - result.push({ - text: count++, - start: start, - top: top, - cnt: cnt, - index: index, - height: cnt * o.rowSize - }); - start += cnt; - top += cnt * o.rowSize; - }); - if (BI.isNotEmptyArray(node.values)) { - result.push({ - text: BI.i18nText("BI-Summary_Values"), - start: start++, - top: top, - cnt: 1, - isSummary: true, - height: o.rowSize - }); - top += o.rowSize; - } - } - }); - return result; - }, - - _layout: function () { - var self = this, o = this.options; - var headerHeight = this._getHeaderHeight() - 2; - var items = this.layout.attr("items"); - if (o.isNeedFreeze === false) { - items[0].height = 0; - items[1].height = 0; - } else if (o.isNeedFreeze === true) { - items[0].height = headerHeight; - items[1].height = 2; - } - this.layout.attr("items", items); - this.layout.resize(); - try { - this.scrollContainer.element.scrollTop(o.scrollTop); - } catch (e) { - - } - }, - - _getHeaderHeight: function () { - var o = this.options; - return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); - }, - - _nextState: function () { - var o = this.options; - this._getNextSequence(o.items); - }, - - _prevState: function () { - var self = this, o = this.options; - var firstChild; - BI.some(o.items, function (i, node) { - if (BI.isNotEmptyArray(node.children)) { - return BI.some(node.children, function (j, child) { - firstChild = child; - return true; - }); - } - }); - if (firstChild && BI.isNotEmptyObject(this.cache)) { - this.start = this.cache[firstChild.text || firstChild.value]; - } else { - this.start = 1; - } - this._nextState(); - }, - - _getMaxScrollTop: function (numbers) { - var cnt = 0; - BI.each(numbers, function (i, number) { - cnt += number.cnt; - }); - return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); - }, - - _createHeader: function () { - var o = this.options; - BI.createWidget({ - type: "bi.absolute", - element: this.headerContainer, - items: [{ - el: o.sequenceHeaderCreator() || { - type: "bi.table_style_cell", - cls: "sequence-table-title-cell", - height: this._getHeaderHeight() - 2, - styleGetter: o.headerCellStyleGetter, - text: BI.i18nText("BI-Number_Index") - }, - left: 0, - top: 0, - right: 0, - bottom: 0 - }] - }); - }, - - _calculateChildrenToRender: function () { - var self = this, o = this.options; - - var renderedCells = [], renderedKeys = []; - var numbers = this._formatNumber(o.items); - var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); - BI.each(numbers, function (i, number) { - intervalTree.set(i, number.height); - }); - var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); - var index = intervalTree.greatestLowerBound(scrollTop); - var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); - var height = offsetTop; - var bodyHeight = o.height - this._getHeaderHeight(); - while (height < bodyHeight && index < numbers.length) { - renderedKeys.push(index); - offsetTop += numbers[index].height; - height += numbers[index].height; - index++; - } - - BI.each(renderedKeys, function (i, key) { - var index = BI.deepIndexOf(self.renderedKeys, key); - if (index > -1) { - if (numbers[key].height !== self.renderedCells[index]._height) { - self.renderedCells[index]._height = numbers[key].height; - self.renderedCells[index].el.setHeight(numbers[key].height); - } - if (numbers[key].top !== self.renderedCells[index].top) { - self.renderedCells[index].top = numbers[key].top; - self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); - } - renderedCells.push(self.renderedCells[index]); - } else { - var child = BI.createWidget(BI.extend({ - type: "bi.table_style_cell", - cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", - width: 60, - styleGetter: numbers[key].isSummary === true ? function () { - return o.summaryCellStyleGetter(true); - } : function (key) { - return function () { - return o.sequenceCellStyleGetter(key); - }; - }(numbers[key].index) - }, numbers[key])); - renderedCells.push({ - el: child, - left: 0, - top: numbers[key].top, - _height: numbers[key].height - }); - } - }); - - // 已存在的, 需要添加的和需要删除的 - var existSet = {}, addSet = {}, deleteArray = []; - BI.each(renderedKeys, function (i, key) { - if (BI.deepContains(self.renderedKeys, key)) { - existSet[i] = key; - } else { - addSet[i] = key; - } - }); - BI.each(this.renderedKeys, function (i, key) { - if (BI.deepContains(existSet, key)) { - return; - } - if (BI.deepContains(addSet, key)) { - return; - } - deleteArray.push(i); - }); - BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); - }); - var addedItems = []; - BI.each(addSet, function (index) { - addedItems.push(renderedCells[index]); - }); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: addedItems - }); - this.renderedCells = renderedCells; - this.renderedKeys = renderedKeys; - - this.container.setHeight(intervalTree.sumUntil(numbers.length)); - }, - - _restore: function () { - BI.each(this.renderedCells, function (i, cell) { - cell.el.destroy(); - }); - this.renderedCells = []; - this.renderedKeys = []; - }, - - _populate: function () { - var self = this; - BI.each(this.tasks, function (i, task) { - task.apply(self); - }); - this.tasks = []; - this.headerContainer.empty(); - this._createHeader(); - this._layout(); - this._calculateChildrenToRender(); - }, - - setVerticalScroll: function (scrollTop) { - if (this.options.scrollTop !== scrollTop) { - this.options.scrollTop = scrollTop; - try { - this.scrollContainer.element.scrollTop(scrollTop); - } catch (e) { - - } - } - }, - - getVerticalScroll: function () { - return this.options.scrollTop; - }, - - setVPage: function (v) { - if (v <= 1) { - this.cache = {}; - this.start = this.options.startSequence; - this._restore(); - this.tasks.push(this._nextState); - } else if (v === this.vCurr + 1) { - this.tasks.push(this._nextState); - } else if (v === this.vCurr - 1) { - this.tasks.push(this._prevState); - } - this.vCurr = v; - }, - - setHPage: function (v) { - if (v !== this.hCurr) { - this.tasks.push(this._prevState); - } - this.hCurr = v; - }, - - restore: function () { - this._restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items && items !== this.options.items) { - o.items = items; - this._restore(); - this.tasks.push(this._prevState); - } - if (header && header !== this.options.header) { - o.header = header; - } - if (crossItems && crossItems !== this.options.crossItems) { - o.crossItems = crossItems; - } - if (crossHeader && crossHeader !== this.options.crossHeader) { - o.crossHeader = crossHeader; - } - this._populate(); - } -}); -BI.shortcut("bi.sequence_table_tree_number", BI.SequenceTableTreeNumber);/** - * 日期控件中的月份下拉框 - * - * Created by GUY on 2015/9/7. - * @class BI.MonthDateCombo - * @extends BI.Trigger - */ -BI.MonthDateCombo = BI.inherit(BI.Trigger, { - _defaultConfig: function () { - return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-combo", - height: 24 - }); - }, - _init: function () { - BI.MonthDateCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.date_triangle_trigger" - }); - - this.popup = BI.createWidget({ - type: "bi.month_popup", - behaviors: o.behaviors - }); - - this.popup.on(BI.YearPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - }); - - - this.combo = BI.createWidget({ - type: "bi.combo", - offsetStyle: "center", - element: this, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - stopPropagation: false, - el: this.popup - } - }); - this.combo.on(BI.Combo.EVENT_CHANGE, function () { - self.combo.hideView(); - self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE); - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.doBehavior(); - }); - }, - - setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); -BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.month_date_combo", BI.MonthDateCombo);/** - * 年份下拉框 - * - * Created by GUY on 2015/9/7. - * @class BI.YearDateCombo - * @extends BI.Trigger - */ -BI.YearDateCombo = BI.inherit(BI.Trigger, { - _defaultConfig: function () { - return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-combo", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - behaviors: {}, - height: 24 - }); - }, - _init: function () { - BI.YearDateCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.date_triangle_trigger" - }); - - this.popup = BI.createWidget({ - type: "bi.year_popup", - behaviors: o.behaviors, - min: o.min, - max: o.max - }); - - this.popup.on(BI.YearPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); - }); - - - this.combo = BI.createWidget({ - type: "bi.combo", - offsetStyle: "center", - element: this, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 100, - stopPropagation: false, - el: this.popup - } - }); - this.combo.on(BI.Combo.EVENT_CHANGE, function () { - self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); - }); - // BI-22551 popup未初始化传入的behavior无效 - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.doBehavior(); - }); - }, - - setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); -BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.year_date_combo", BI.YearDateCombo); -/** - * Created by GUY on 2015/9/7. - * @class BI.DatePicker - * @extends BI.Widget - */ -BI.DatePicker = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-date-picker", - height: 40, - min: "1900-01-01", // 最小日期 - max: "2099-12-31" // 最大日期 - }); - }, - - _init: function () { - BI.DatePicker.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this._year = BI.getDate().getFullYear(); - this._month = BI.getDate().getMonth() + 1; - this.left = BI.createWidget({ - type: "bi.icon_button", - cls: "pre-page-h-font", - width: 24, - height: 24 - }); - this.left.on(BI.IconButton.EVENT_CHANGE, function () { - if (self._month === 1) { - self.setValue({ - year: self.year.getValue() - 1, - month: 12 - }); - } else { - self.setValue({ - year: self.year.getValue(), - month: self.month.getValue() - 1 - }); - } - self.fireEvent(BI.DatePicker.EVENT_CHANGE); - self._checkLeftValid(); - self._checkRightValid(); - }); - - this.right = BI.createWidget({ - type: "bi.icon_button", - cls: "next-page-h-font", - width: 24, - height: 24 - }); - - this.right.on(BI.IconButton.EVENT_CHANGE, function () { - if (self._month === 12) { - self.setValue({ - year: self.year.getValue() + 1, - month: 1 - }); - } else { - self.setValue({ - year: self.year.getValue(), - month: self.month.getValue() + 1 - }); - } - self.fireEvent(BI.DatePicker.EVENT_CHANGE); - self._checkLeftValid(); - self._checkRightValid(); - }); - - this.year = BI.createWidget({ - type: "bi.year_date_combo", - behaviors: o.behaviors, - min: o.min, - max: o.max - }); - this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { - self.setValue({ - year: self.year.getValue(), - month: self.month.getValue() - }); - self.fireEvent(BI.DatePicker.EVENT_CHANGE); - }); - this.month = BI.createWidget({ - type: "bi.month_date_combo", - behaviors: o.behaviors - }); - this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () { - self.setValue({ - year: self.year.getValue(), - month: self.month.getValue() - }); - self.fireEvent(BI.DatePicker.EVENT_CHANGE); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: { - type: "bi.center_adapt", - items: [this.left] - }, - width: 24 - }, { - type: "bi.center_adapt", - items: [{ - type: "bi.horizontal", - width: 100, - items: [this.year, this.month] - }] - }, { - el: { - type: "bi.center_adapt", - items: [this.right] - }, - width: 24 - }] - }); - this.setValue({ - year: this._year, - month: this._month - }); - }, - - _checkLeftValid: function () { - var o = this.options; - var valid = !(this._month === 1 && this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); - this.left.setEnable(valid); - return valid; - }, - - _checkRightValid: function () { - var o = this.options; - var valid = !(this._month === 12 && this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); - this.right.setEnable(valid); - return valid; - }, - - - - setValue: function (ob) { - this._year = ob.year; - this._month = ob.month; - this.year.setValue(ob.year); - this.month.setValue(ob.month); - this._checkLeftValid(); - this._checkRightValid(); - }, - - getValue: function () { - return { - year: this.year.getValue(), - month: this.month.getValue() - }; - } -}); -BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.date_picker", BI.DatePicker);/** - * Created by GUY on 2015/9/7. - * @class BI.YearPicker - * @extends BI.Widget - */ -BI.YearPicker = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.YearPicker.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-year-picker", - behaviors: {}, - height: 40, - min: "1900-01-01", // 最小日期 - max: "2099-12-31" // 最大日期 - }); - }, - - _init: function () { - BI.YearPicker.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this._year = BI.getDate().getFullYear(); - this.left = BI.createWidget({ - type: "bi.icon_button", - cls: "pre-page-h-font", - width: 25, - height: 25 - }); - this.left.on(BI.IconButton.EVENT_CHANGE, function () { - self.setValue(self.year.getValue() - 1); - self.fireEvent(BI.YearPicker.EVENT_CHANGE); - self._checkLeftValid(); - self._checkRightValid(); - }); - - this.right = BI.createWidget({ - type: "bi.icon_button", - cls: "next-page-h-font", - width: 25, - height: 25 - }); - - this.right.on(BI.IconButton.EVENT_CHANGE, function () { - self.setValue(self.year.getValue() + 1); - self.fireEvent(BI.YearPicker.EVENT_CHANGE); - self._checkLeftValid(); - self._checkRightValid(); - }); - - this.year = BI.createWidget({ - type: "bi.year_date_combo", - min: o.min, - behaviors: o.behaviors, - max: o.max - }); - this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { - self.setValue(self.year.getValue()); - self.fireEvent(BI.YearPicker.EVENT_CHANGE); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: { - type: "bi.center_adapt", - items: [this.left] - }, - width: 25 - }, { - type: "bi.center_adapt", - items: [this.year] - }, { - el: { - type: "bi.center_adapt", - items: [this.right] - }, - width: 25 - }] - }); - this.setValue({ - year: this._year - }); - }, - - _checkLeftValid: function () { - var o = this.options; - var valid = !(this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); - this.left.setEnable(valid); - return valid; - }, - - _checkRightValid: function () { - var o = this.options; - var valid = !(this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); - this.right.setEnable(valid); - return valid; - }, - - - - setValue: function (v) { - this._year = v; - this.year.setValue(v); - this._checkLeftValid(); - this._checkRightValid(); - }, - - getValue: function () { - return this.year.getValue(); - } -}); -BI.YearPicker.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.year_picker", BI.YearPicker); -/** - * Created by GUY on 2015/9/7. - * @class BI.DateCalendarPopup - * @extends BI.Widget - */ -BI.DateCalendarPopup = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-date-calendar-popup", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - selectedTime: null - }); - }, - - _createNav: function (v) { - var date = BI.Calendar.getDateJSONByPage(v); - var calendar = BI.createWidget({ - type: "bi.calendar", - logic: { - dynamic: true - }, - min: this.options.min, - max: this.options.max, - year: date.year, - month: date.month, - day: this.selectedTime.day - }); - return calendar; - }, - - _init: function () { - BI.DateCalendarPopup.superclass._init.apply(this, arguments); - var self = this, - o = this.options; - this.today = BI.getDate(); - this._year = this.today.getFullYear(); - this._month = this.today.getMonth() + 1; - this._day = this.today.getDate(); - - this.selectedTime = o.selectedTime || { - year: this._year, - month: this._month, - day: this._day - }; - this.datePicker = BI.createWidget({ - type: "bi.date_picker", - behaviors: o.behaviors, - min: o.min, - max: o.max - }); - - this.calendar = BI.createWidget({ - direction: "top", - logic: { - dynamic: true - }, - type: "bi.navigation", - tab: this.datePicker, - cardCreator: BI.bind(this._createNav, this), - - afterCardCreated: function () { - - }, - - afterCardShow: function () { - this.setValue(self.selectedTime); - } - }); - - this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { - self.selectedTime = self.datePicker.getValue(); - self.selectedTime.day = 1; - self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); - }); - - this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { - self.selectedTime = self.calendar.getValue(); - self.setValue(self.selectedTime); - self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.calendar, - left: 10, - right: 10 - }, { - el: { - type: "bi.layout", - cls: "bi-border-top" - }, - height: 1, - top: 40, - left: 0, - right: 0 - }] - }); - }, - - setValue: function (timeOb) { - this.datePicker.setValue(timeOb); - this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); - this.calendar.setValue(timeOb); - this.selectedTime = timeOb; - }, - - getValue: function () { - return this.selectedTime; - } -}); -BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/** - * 年份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.YearPopup - * @extends BI.Trigger - */ -BI.YearPopup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-popup", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31" // 最大日期 - }); - }, - - _createYearCalendar: function (v) { - var o = this.options, y = this._year; - - var calendar = BI.createWidget({ - type: "bi.year_calendar", - behaviors: o.behaviors, - min: o.min, - max: o.max, - logic: { - dynamic: true - }, - year: y + v * 12 - }); - calendar.setValue(this._year); - return calendar; - }, - - _init: function () { - BI.YearPopup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.selectedYear = this._year = BI.getDate().getFullYear(); - - var backBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "pre-page-h-font", - width: 24, - height: 24, - value: -1 - }); - - var preBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "next-page-h-font", - width: 24, - height: 24, - value: 1 - }); - - this.navigation = BI.createWidget({ - type: "bi.navigation", - element: this, - single: true, - logic: { - dynamic: true - }, - tab: { - cls: "year-popup-navigation bi-high-light bi-border-top", - height: 24, - items: [backBtn, preBtn] - }, - cardCreator: BI.bind(this._createYearCalendar, this), - - afterCardShow: function () { - this.setValue(self.selectedYear); - var calendar = this.getSelectedCard(); - backBtn.setEnable(!calendar.isFrontYear()); - preBtn.setEnable(!calendar.isFinalYear()); - } - }); - - this.navigation.on(BI.Navigation.EVENT_CHANGE, function () { - self.selectedYear = this.getValue(); - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear); - }); - - if(BI.isKey(o.value)){ - this.setValue(o.value); - } - }, - - getValue: function () { - return this.selectedYear; - }, - - setValue: function (v) { - var o = this.options; - v = BI.parseInt(v); - if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) { - v = BI.getDate().getFullYear(); - this.selectedYear = ""; - this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); - this.navigation.setValue(""); - } else { - this.selectedYear = v; - this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); - this.navigation.setValue(v); - } - } -}); -BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.year_popup", BI.YearPopup);/** - * 日期控件中的年份或月份trigger - * - * Created by GUY on 2015/9/7. - * @class BI.DateTriangleTrigger - * @extends BI.Trigger - */ -BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { - _const: { - height: 24, - iconWidth: 12, - iconHeight: 12 - }, - - _defaultConfig: function () { - return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", - height: 24 - }); - }, - _init: function () { - BI.DateTriangleTrigger.superclass._init.apply(this, arguments); - var o = this.options, c = this._const; - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-item-text", - textAlign: "right", - text: o.text, - value: o.value, - height: c.height - }); - this.icon = BI.createWidget({ - type: "bi.icon", - width: c.iconWidth, - height: c.iconHeight - }); - - BI.createWidget({ - type: "bi.center_adapt", - element: this, - items: [{ - type: "bi.center_adapt", - width: 50, - height: c.height, - items: [{ - el: this.text, - rgap: 10 - }, this.icon] - }] - }); - }, - - setValue: function (v) { - this.text.setValue(v); - }, - - getValue: function () { - return this.text.getValue(); - }, - - setText: function (v) { - this.text.setText(v); - }, - - getText: function () { - return this.item.getText(); - }, - - getKey: function () { - - } -}); -BI.shortcut("bi.date_triangle_trigger", BI.DateTriangleTrigger);/** - * Created by zcf on 2017/2/20. - */ -BI.StaticDatePaneCard = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.StaticDatePaneCard.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-date-pane", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - selectedTime: null - }); - }, - _init: function () { - BI.StaticDatePaneCard.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.today = BI.getDate(); - this._year = this.today.getFullYear(); - this._month = this.today.getMonth() + 1; - - this.selectedTime = o.selectedTime || { - year: this._year, - month: this._month - }; - - this.datePicker = BI.createWidget({ - type: "bi.date_picker", - behaviors: o.behaviors, - min: o.min, - max: o.max - }); - this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { - var value = self.datePicker.getValue(); - var monthDay = BI.getDate(value.year, value.month - 1, 1).getMonthDays(); - var day = self.selectedTime.day || 0; - if (day > monthDay) { - day = monthDay; - } - self.selectedTime = { - year: value.year, - month: value.month - }; - day !== 0 && (self.selectedTime.day = day); - self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); - self.calendar.setValue(self.selectedTime); - day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); - }); - - this.calendar = BI.createWidget({ - direction: "custom", - // logic: { - // dynamic: false - // }, - type: "bi.navigation", - tab: this.datePicker, - cardCreator: BI.bind(this._createNav, this) - }); - this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { - self.selectedTime = self.calendar.getValue(); - self.calendar.empty(); - self.setValue(self.selectedTime); - self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); - }); - this.setValue(o.selectedTime); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.datePicker, - height: 40 - }, this.calendar], - hgap: 10 - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: { - type: "bi.layout", - cls: "bi-border-top" - }, - height: 1, - top: 40, - left: 0, - right: 0 - }] - }); - - }, - - _createNav: function (v) { - var date = BI.Calendar.getDateJSONByPage(v); - var calendar = BI.createWidget({ - type: "bi.calendar", - logic: { - dynamic: false - }, - min: this.options.min, - max: this.options.max, - year: date.year, - month: date.month, - day: this.selectedTime.day - }); - return calendar; - }, - - _getNewCurrentDate: function () { - var today = BI.getDate(); - return { - year: today.getFullYear(), - month: today.getMonth() + 1 - }; - }, - - _setCalenderValue: function (date) { - this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); - this.calendar.setValue(date); - this.selectedTime = date; - }, - - _setDatePicker: function (timeOb) { - if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { - this.datePicker.setValue(this._getNewCurrentDate()); - } else { - this.datePicker.setValue(timeOb); - } - }, - - _setCalendar: function (timeOb) { - if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { - this.calendar.empty(); - this._setCalenderValue(this._getNewCurrentDate()); - } else { - this._setCalenderValue(timeOb); - } - }, - - setValue: function (timeOb) { - this._setDatePicker(timeOb); - this._setCalendar(timeOb); - }, - - getValue: function () { - return this.selectedTime; - } - -}); -BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard);BI.DynamicDatePane = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-dynamic-date-pane" - }, - - render: function () { - var self = this, o = this.options; - return { - type: "bi.vtape", - items: [{ - el: { - type: "bi.linear_segment", - cls: "bi-border-bottom", - height: 30, - items: BI.createItems([{ - text: BI.i18nText("BI-Multi_Date_YMD"), - value: BI.DynamicDatePane.Static - }, { - text: BI.i18nText("BI-Basic_Dynamic_Title"), - value: BI.DynamicDatePane.Dynamic - }], { - textAlign: "center" - }), - listeners: [{ - eventName: BI.ButtonGroup.EVENT_CHANGE, - action: function () { - var value = this.getValue()[0]; - self.dateTab.setSelect(value); - switch (value) { - case BI.DynamicDatePane.Static: - var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); - self.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - }); - break; - case BI.DynamicDatePane.Dynamic: - self.dynamicPane.setValue({ - year: 0 - }); - break; - default: - break; - } - } - }], - ref: function () { - self.switcher = this; - } - }, - height: 30 - }, { - type: "bi.tab", - ref: function () { - self.dateTab = this; - }, - showIndex: BI.DynamicDatePane.Static, - cardCreator: function (v) { - switch (v) { - case BI.DynamicDatePane.Static: - return { - type: "bi.static_date_pane_card", - behaviors: o.behaviors, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }], - ref: function () { - self.ymd = this; - } - }; - case BI.DynamicDatePane.Dynamic: - default: - return { - type: "bi.dynamic_date_card", - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - if(self._checkValue(self.getValue())) { - self.fireEvent("EVENT_CHANGE"); - } - } - }], - ref: function () { - self.dynamicPane = this; - } - }; - } - } - }] - }; - }, - - mounted: function () { - this.setValue(this.options.value); - }, - - _checkValueValid: function (value) { - return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); - }, - - _checkValue: function (v) { - switch (v.type) { - case BI.DynamicDateCombo.Dynamic: - return BI.isNotEmptyObject(v.value); - case BI.DynamicDateCombo.Static: - default: - return true; - } - }, - - setValue: function (v) { - v = v || {}; - var type = v.type || BI.DynamicDateCombo.Static; - var value = v.value || v; - this.switcher.setValue(type); - this.dateTab.setSelect(type); - switch (type) { - case BI.DynamicDateCombo.Dynamic: - this.dynamicPane.setValue(value); - break; - case BI.DynamicDateCombo.Static: - default: - if (this._checkValueValid(value)) { - var date = BI.getDate(); - this.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1 - }); - } else { - this.ymd.setValue(value); - } - break; - } - }, - - getValue: function () { - return { - type: this.dateTab.getSelect(), - value: this.dateTab.getValue() - }; - } -}); -BI.shortcut("bi.dynamic_date_pane", BI.DynamicDatePane); - -BI.extend(BI.DynamicDatePane, { - Static: 1, - Dynamic: 2 -});/** - * Created by Urthur on 2017/7/14. - */ -BI.DateTimeCombo = BI.inherit(BI.Single, { - constants: { - popupHeight: 290, - popupWidth: 270, - comboAdjustHeight: 1, - border: 1, - DATE_MIN_VALUE: "1900-01-01", - DATE_MAX_VALUE: "2099-12-31" - }, - _defaultConfig: function () { - return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-time-combo bi-border", - width: 200, - height: 24 - }); - }, - _init: function () { - BI.DateTimeCombo.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - var date = BI.getDate(); - this.storeValue = BI.isNotNull(opts.value) ? opts.value : { - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate(), - hour: date.getHours(), - minute: date.getMinutes(), - second: date.getSeconds() - }; - this.trigger = BI.createWidget({ - type: "bi.date_time_trigger", - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE, - value: opts.value - }); - - this.popup = BI.createWidget({ - type: "bi.date_time_popup", - behaviors: opts.behaviors, - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE, - value: opts.value - }); - self.setValue(this.storeValue); - - this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () { - self.setValue(self.storeValue); - self.hidePopupView(); - self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL); - }); - this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () { - self.storeValue = self.popup.getValue(); - self.setValue(self.storeValue); - self.hidePopupView(); - self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM); - }); - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - adjustLength: this.constants.comboAdjustHeight, - popup: { - el: this.popup, - width: this.constants.popupWidth, - stopPropagation: false - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW); - }); - - var triggerBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-font bi-border-right", - width: 24, - height: 24 - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - type: "bi.absolute", - items: [{ - el: this.combo, - top: 0, - left: 0, - right: 0, - bottom: 0 - }, { - el: triggerBtn, - top: 0, - left: 0 - }] - }] - }); - }, - - setValue: function (v) { - this.storeValue = v; - this.popup.setValue(v); - this.trigger.setValue(v); - }, - getValue: function () { - return this.storeValue; - }, - - hidePopupView: function () { - this.combo.hideView(); - } -}); - -BI.DateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL"; -BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.date_time_combo", BI.DateTimeCombo); -/** - * Created by Urthur on 2017/7/14. - */ -BI.DateTimePopup = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-time-popup", - width: 268, - height: 374 - }); - }, - _init: function () { - BI.DateTimePopup.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - this.cancelButton = BI.createWidget({ - type: "bi.text_button", - forceCenter: true, - cls: "multidate-popup-button bi-border-top bi-border-right", - shadow: true, - text: BI.i18nText("BI-Basic_Cancel") - }); - this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE); - }); - - this.okButton = BI.createWidget({ - type: "bi.text_button", - forceCenter: true, - cls: "multidate-popup-button bi-border-top", - shadow: true, - text: BI.i18nText("BI-Basic_OK") - }); - this.okButton.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE); - }); - - this.dateCombo = BI.createWidget({ - type: "bi.date_calendar_popup", - behaviors: opts.behaviors, - min: self.options.min, - max: self.options.max - }); - self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - }); - - this.dateSelect = BI.createWidget({ - type: "bi.vertical_adapt", - cls: "bi-border-top", - items: [{ - type: "bi.label", - text: BI.i18nText("BI-Basic_Time"), - width: 45 - }, { - type: "bi.date_time_select", - max: 23, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.hour = _ref; - } - }, { - type: "bi.label", - text: ":", - width: 15 - }, { - type: "bi.date_time_select", - max: 59, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.minute = _ref; - } - }, { - type: "bi.label", - text: ":", - width: 15 - }, { - type: "bi.date_time_select", - max: 59, - min: 0, - width: 60, - height: 30, - listeners: [{ - eventName: BI.DateTimeSelect.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); - } - }], - ref: function (_ref) { - self.second = _ref; - } - }] - }); - - this.setValue(opts.value); - - this.dateButton = BI.createWidget({ - type: "bi.grid", - items: [[this.cancelButton, this.okButton]] - }); - BI.createWidget({ - element: this, - type: "bi.vtape", - items: [{ - el: this.dateCombo - }, { - el: this.dateSelect, - height: 50 - }, { - el: this.dateButton, - height: 30 - }] - }); - }, - - setValue: function (v) { - var value = v, date; - if (BI.isNull(value)) { - date = BI.getDate(); - this.dateCombo.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - }); - this.hour.setValue(date.getHours()); - this.minute.setValue(date.getMinutes()); - this.second.setValue(date.getSeconds()); - } else { - this.dateCombo.setValue({ - year: value.year, - month: value.month, - day: value.day - }); - this.hour.setValue(value.hour); - this.minute.setValue(value.minute); - this.second.setValue(value.second); - } - }, - - getValue: function () { - return { - year: this.dateCombo.getValue().year, - month: this.dateCombo.getValue().month, - day: this.dateCombo.getValue().day, - hour: this.hour.getValue(), - minute: this.minute.getValue(), - second: this.second.getValue() - }; - } -}); -BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE"; -BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; -BI.shortcut("bi.date_time_popup", BI.DateTimePopup); -/** - * Created by Urthur on 2017/7/14. - */ -BI.DateTimeSelect = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-date-time-select bi-border", - max: 23, - min: 0 - }); - }, - - _init: function () { - BI.DateTimeSelect.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - value: this._alertInEditorValue(o.min), - allowBlank: false, - errorText: function (v) { - if(BI.isNumeric(v)) { - return BI.i18nText("BI-Please_Input_Natural_Number"); - } - return BI.i18nText("BI-Numerical_Interval_Input_Data"); - }, - validationChecker: function (v) { - return BI.isNaturalNumber(v); - } - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - self._finetuning(0); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" - }); - this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._finetuning(1); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this.bottomBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "column-next-page-h-font bottom-button bi-border-left" - }); - this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._finetuning(-1); - self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); - }); - this._finetuning(0); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [this.editor, { - el: { - type: "bi.grid", - columns: 1, - rows: 2, - items: [{ - column: 0, - row: 0, - el: this.topBtn - }, { - column: 0, - row: 1, - el: this.bottomBtn - }] - }, - width: 30 - }] - }); - }, - - _alertOutEditorValue: function (v) { - if (v > this.options.max) { - v = this.options.min; - } - if (v < this.options.min) { - v = this.options.max; - } - return BI.parseInt(v); - }, - - _alertInEditorValue: function (v) { - if (v > this.options.max) { - v = this.options.min; - } - if (v < this.options.min) { - v = this.options.max; - } - v = v < 10 ? "0" + v : v; - return v; - }, - - _finetuning: function (add) { - var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); - this.editor.setValue(this._alertInEditorValue(v + add)); - }, - - getValue: function () { - var v = this.editor.getValue(); - return this._alertOutEditorValue(v); - }, - - setValue: function (v) { - this.editor.setValue(this._alertInEditorValue(v)); - this._finetuning(0); - } - -}); -BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/** - * Created by Urthur on 2017/7/14. - */ -BI.DateTimeTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4 - }, - - _defaultConfig: function () { - return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-date-time-trigger", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24, - width: 200 - }); - }, - _init: function () { - BI.DateTimeTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - height: o.height, - width: o.width, - hgap: c.hgap - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: BI.createWidget(), - width: o.height - }, { - el: this.text - }] - }); - this.setValue(o.value); - }, - - _printTime: function (v) { - return v < 10 ? "0" + v : v; - }, - - setValue: function (v) { - var self = this; - var value = v, dateStr; - if(BI.isNull(value)) { - value = BI.getDate(); - dateStr = value.print("%Y-%X-%d %H:%M:%S"); - } else { - var date = BI.getDate(value.year, value.month - 1, value.day, value.hour, value.minute, value.second); - dateStr = date.print("%Y-%X-%d %H:%M:%S"); - - } - this.text.setText(dateStr); - this.text.setTitle(dateStr); - } - -}); -BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);BI.StaticDateTimePaneCard = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.StaticDateTimePaneCard.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-date-time-pane", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - selectedTime: null - }); - }, - _init: function () { - BI.StaticDateTimePaneCard.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.today = BI.getDate(); - this._year = this.today.getFullYear(); - this._month = this.today.getMonth() + 1; - - this.selectedTime = o.selectedTime || { - year: this._year, - month: this._month - }; - - this.datePicker = BI.createWidget({ - type: "bi.date_picker", - behaviors: o.behaviors, - min: o.min, - max: o.max - }); - this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { - var value = self.datePicker.getValue(); - var monthDay = BI.getDate(value.year, value.month - 1, 1).getMonthDays(); - var day = self.selectedTime.day || 0; - if (day > monthDay) { - day = monthDay; - } - self.selectedTime = BI.extend(self.selectedTime, { - year: value.year, - month: value.month, - day: day - }); - day !== 0 && (self.selectedTime.day = day); - self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); - self.calendar.setValue(self.selectedTime); - day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); - }); - - this.calendar = BI.createWidget({ - direction: "custom", - // logic: { - // dynamic: false - // }, - type: "bi.navigation", - tab: this.datePicker, - cardCreator: BI.bind(this._createNav, this) - }); - this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { - self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue()); - self.calendar.empty(); - self.setValue(self.selectedTime); - self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - hgap: 10, - items: [{ - el: this.datePicker, - height: 40 - }, this.calendar, { - el: { - type: "bi.dynamic_date_time_select", - ref: function () { - self.timeSelect = this; - }, - listeners: [{ - eventName: BI.DynamicDateTimeSelect.EVENT_CONFIRM, - action: function () { - self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue()); - self.fireEvent("EVENT_CHANGE"); - } - }] - }, - height: 40 - }] - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: { - type: "bi.layout", - cls: "bi-border-top" - }, - height: 1, - top: 40, - left: 0, - right: 0 - }] - }); - this.setValue(o.selectedTime); - - }, - - _createNav: function (v) { - var date = BI.Calendar.getDateJSONByPage(v); - var calendar = BI.createWidget({ - type: "bi.calendar", - logic: { - dynamic: false - }, - min: this.options.min, - max: this.options.max, - year: date.year, - month: date.month, - day: this.selectedTime.day - }); - return calendar; - }, - - _getNewCurrentDate: function () { - var today = BI.getDate(); - return { - year: today.getFullYear(), - month: today.getMonth() + 1 - }; - }, - - _setCalenderValue: function (date) { - this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); - this.calendar.setValue(date); - this.selectedTime = BI.extend({}, this.timeSelect.getValue(), date); - }, - - _setDatePicker: function (timeOb) { - if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { - this.datePicker.setValue(this._getNewCurrentDate()); - } else { - this.datePicker.setValue(timeOb); - } - }, - - _setCalendar: function (timeOb) { - if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { - this.calendar.empty(); - this._setCalenderValue(this._getNewCurrentDate()); - } else { - this._setCalenderValue(timeOb); - } - }, - - setValue: function (timeOb) { - timeOb = timeOb || {}; - this._setDatePicker(timeOb); - this._setCalendar(timeOb); - this.timeSelect.setValue({ - hour: timeOb.hour, - minute: timeOb.minute, - second: timeOb.second - }); - }, - - getValue: function () { - return this.selectedTime; - } - -}); -BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.DynamicDateTimePane = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-dynamic-date-pane" - }, - - render: function () { - var self = this, o = this.options; - return { - type: "bi.vtape", - items: [{ - el: { - type: "bi.linear_segment", - cls: "bi-border-bottom", - height: 30, - items: BI.createItems([{ - text: BI.i18nText("BI-Multi_Date_YMD"), - value: BI.DynamicDateTimePane.Static - }, { - text: BI.i18nText("BI-Basic_Dynamic_Title"), - value: BI.DynamicDateTimePane.Dynamic - }], { - textAlign: "center" - }), - listeners: [{ - eventName: BI.ButtonGroup.EVENT_CHANGE, - action: function () { - var value = this.getValue()[0]; - self.dateTab.setSelect(value); - switch (value) { - case BI.DynamicDateTimePane.Static: - var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); - self.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - }); - break; - case BI.DynamicDateTimePane.Dynamic: - self.dynamicPane.setValue({ - year: 0 - }); - break; - default: - break; - } - } - }], - ref: function () { - self.switcher = this; - } - }, - height: 30 - }, { - type: "bi.tab", - ref: function () { - self.dateTab = this; - }, - showIndex: BI.DynamicDateTimePane.Static, - cardCreator: function (v) { - switch (v) { - case BI.DynamicDateTimePane.Static: - return { - type: "bi.static_date_time_pane_card", - behaviors: o.behaviors, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }], - ref: function () { - self.ymd = this; - } - }; - case BI.DynamicDateTimePane.Dynamic: - default: - return { - type: "bi.dynamic_date_card", - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - if(self._checkValue(self.getValue())) { - self.fireEvent("EVENT_CHANGE"); - } - } - }], - ref: function () { - self.dynamicPane = this; - } - }; - } - } - }] - }; - }, - - mounted: function () { - this.setValue(this.options.value); - }, - - _checkValueValid: function (value) { - return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); - }, - - _checkValue: function (v) { - switch (v.type) { - case BI.DynamicDateCombo.Dynamic: - return BI.isNotEmptyObject(v.value); - case BI.DynamicDateCombo.Static: - default: - return true; - } - }, - - setValue: function (v) { - v = v || {}; - var type = v.type || BI.DynamicDateTimePane.Static; - var value = v.value || v; - this.switcher.setValue(type); - this.dateTab.setSelect(type); - switch (type) { - case BI.DynamicDateTimePane.Dynamic: - this.dynamicPane.setValue(value); - break; - case BI.DynamicDateTimePane.Static: - default: - if (this._checkValueValid(value)) { - var date = BI.getDate(); - this.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1 - }); - } else { - this.ymd.setValue(value); - } - break; - } - }, - - getValue: function () { - return { - type: this.dateTab.getSelect(), - value: this.dateTab.getValue() - }; - } -}); -BI.shortcut("bi.dynamic_date_time_pane", BI.DynamicDateTimePane); - -BI.extend(BI.DynamicDateTimePane, { - Static: 1, - Dynamic: 2 -});/** - * Created by roy on 15/8/14. - */ -BI.DownListCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-down-list-combo", - height: 24, - items: [], - adjustLength: 0, - direction: "bottom", - trigger: "click", - container: null, - stopPropagation: false, - el: {} - }); - }, - - _init: function () { - BI.DownListCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.popupview = BI.createWidget({ - type: "bi.down_list_popup", - items: o.items, - chooseType: o.chooseType, - value: o.value - }); - - this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) { - self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); - self.downlistcombo.hideView(); - }); - - this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { - self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); - self.downlistcombo.hideView(); - }); - - - this.downlistcombo = BI.createWidget({ - element: this, - type: "bi.combo", - trigger: o.trigger, - isNeedAdjustWidth: false, - container: o.container, - adjustLength: o.adjustLength, - direction: o.direction, - stopPropagation: o.stopPropagation, - el: BI.createWidget(o.el, { - type: "bi.icon_trigger", - extraCls: o.iconCls ? o.iconCls : "", - width: o.width, - height: o.height - }), - popup: { - el: this.popupview, - stopPropagation: true, - maxHeight: 1000, - minWidth: 140 - } - }); - - this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); - }); - }, - - hideView: function () { - this.downlistcombo.hideView(); - }, - - showView: function () { - this.downlistcombo.showView(); - }, - - populate: function (items) { - this.popupview.populate(items); - }, - - setValue: function (v) { - this.popupview.setValue(v); - }, - getValue: function () { - return this.popupview.getValue(); - } -}); -BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; -BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; - -BI.shortcut("bi.down_list_combo", BI.DownListCombo);/** - * Created by roy on 15/9/6. - */ -BI.DownListGroup = BI.inherit(BI.Widget, { - constants: { - iconCls: "check-mark-ha-font" - }, - _defaultConfig: function () { - return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-down-list-group", - items: [ - { - el: {} - } - ] - }); - }, - _init: function () { - BI.DownListGroup.superclass._init.apply(this, arguments); - var o = this.options, self = this; - - this.downlistgroup = BI.createWidget({ - element: this, - type: "bi.button_tree", - items: o.items, - chooseType: 0, // 0单选,1多选 - layouts: [{ - type: "bi.vertical", - hgap: 0, - vgap: 0 - }], - value: o.value - }); - this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if(type === BI.Events.CLICK) { - self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments); - } - }); - }, - getValue: function () { - return this.downlistgroup.getValue(); - }, - setValue: function (v) { - this.downlistgroup.setValue(v); - } - - -}); -BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-down-list-item bi-list-item-active", - cls: "", - height: 24, - logic: { - dynamic: true - }, - selected: false, - iconHeight: null, - iconWidth: null, - textHgap: 0, - textVgap: 0, - textLgap: 0, - textRgap: 0 - }); - }, - _init: function () { - BI.DownListItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-item-text", - textAlign: "left", - hgap: o.textHgap, - vgap: o.textVgap, - lgap: o.textLgap, - rgap: o.textRgap, - text: o.text, - value: o.value, - keyword: o.keyword, - height: o.height - }); - this.icon = BI.createWidget({ - type: "bi.center_adapt", - width: 36, - height: o.height, - items: [{ - el: { - type: "bi.icon", - width: o.iconWidth, - height: o.iconHeight - } - }] - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left), BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, this.icon, this.text) - })))); - }, - - setValue: function () { - if (!this.isReadOnly()) { - this.text.setValue.apply(this.text, arguments); - } - }, - - getValue: function () { - return this.text.getValue(); - }, - - setText: function () { - this.text.setText.apply(this.text, arguments); - }, - - getText: function () { - return this.text.getText(); - }, - - doClick: function () { - BI.DownListItem.superclass.doClick.apply(this, arguments); - if (this.isValid()) { - this.fireEvent(BI.DownListItem.EVENT_CHANGE, this.getValue(), this); - } - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - } -}); -BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-down-list-group-item", - logic: { - dynamic: false - }, - // invalid: true, - iconCls1: "dot-e-font", - iconCls2: "pull-right-e-font" - }); - }, - _init: function () { - BI.DownListGroupItem.superclass._init.apply(this, arguments); - var o = this.options; - var self = this; - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-group-item-text", - textAlign: "left", - text: o.text, - value: o.value, - height: o.height - }); - - this.icon1 = BI.createWidget({ - type: "bi.icon_button", - cls: o.iconCls1, - width: 36, - forceNotSelected: true, - selected: this._digest(o.value) - }); - - this.icon2 = BI.createWidget({ - type: "bi.icon_button", - cls: o.iconCls2, - width: 24, - forceNotSelected: true - }); - - var blank = BI.createWidget({ - type: "bi.layout", - width: 24 - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.icon2, - top: 0, - bottom: 0, - right: 0 - }] - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) - })))); - - this.element.hover(function () { - if (self.isEnabled()) { - self.hover(); - } - }, function () { - if (self.isEnabled()) { - self.dishover(); - } - }); - }, - - _digest: function (v) { - var self = this, o = this.options; - v = BI.isArray(v) ? v : [v]; - return BI.any(v, function (idx, value) { - return BI.contains(o.childValues, value); - }); - }, - - hover: function () { - BI.DownListGroupItem.superclass.hover.apply(this, arguments); - this.icon1.element.addClass("hover"); - this.icon2.element.addClass("hover"); - - }, - - dishover: function () { - BI.DownListGroupItem.superclass.dishover.apply(this, arguments); - this.icon1.element.removeClass("hover"); - this.icon2.element.removeClass("hover"); - }, - - doClick: function () { - BI.DownListGroupItem.superclass.doClick.apply(this, arguments); - if (this.isValid()) { - this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue()); - } - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - setValue: function (v) { - this.icon1.setSelected(this._digest(v)); - } -}); -BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/** - * Created by roy on 15/9/8. - * 处理popup中的item分组样式 - * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项 - */ -BI.DownListPopup = BI.inherit(BI.Pane, { - constants: { - nextIcon: "pull-right-e-font", - height: 24, - iconHeight: 12, - iconWidth: 12, - hgap: 0, - vgap: 0, - border: 1 - }, - _defaultConfig: function () { - var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-down-list-popup", - items: [], - chooseType: BI.Selection.Multi - }); - }, - _init: function () { - BI.DownListPopup.superclass._init.apply(this, arguments); - this.singleValues = []; - this.childValueMap = {}; - this.fatherValueMap = {}; - this.items = BI.deepClone(this.options.items); - var self = this, o = this.options, children = this._createChildren(this.items); - this.popup = BI.createWidget({ - type: "bi.button_tree", - items: BI.createItems(children, - {}, { - adjustLength: -2 - } - ), - layouts: [{ - type: "bi.vertical", - hgap: this.constants.hgap, - vgap: this.constants.vgap - }], - value: this._digest(o.value), - chooseType: o.chooseType - }); - - this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) { - var changedValue = value; - if (BI.isNotNull(self.childValueMap[value])) { - changedValue = self.childValueMap[value]; - self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value]); - } else { - self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object); - } - - - if (!self.singleValues.contains(changedValue)) { - var item = self.getValue(); - var result = []; - BI.each(item, function (i, valueObject) { - if (valueObject.value != changedValue) { - result.push(valueObject); - } - }); - self.setValue(result); - } - - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.popup], - vgap: 5 - }); - - }, - _createChildren: function (items) { - var self = this, result = []; - // 不能修改populate进来的item的引用 - BI.each(items, function (i, it) { - var item_done = { - type: "bi.down_list_group", - items: [] - }; - - BI.each(it, function (i, item) { - if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { - item.type = "bi.combo_group"; - item.cls = "down-list-group"; - item.trigger = "hover"; - item.isNeedAdjustWidth = false; - item.el.title = item.el.title || item.el.text; - item.el.type = "bi.down_list_group_item"; - item.el.logic = { - dynamic: true - }; - item.el.height = self.constants.height; - item.el.iconCls2 = self.constants.nextIcon; - item.popup = { - lgap: 1, - el: { - type: "bi.button_tree", - chooseType: 0, - layouts: [{ - type: "bi.vertical" - }] - - }, - innerVGap: 5, - maxHeight: 378 - }; - item.el.childValues = []; - BI.each(item.children, function (i, child) { - var fatherValue = BI.deepClone(item.el.value); - var childValue = BI.deepClone(child.value); - self.singleValues.push(child.value); - child.type = "bi.down_list_item"; - child.extraCls = " child-down-list-item"; - child.title = child.title || child.text; - child.textRgap = 10; - child.isNeedAdjustWidth = false; - child.logic = { - dynamic: true - }; - child.father = fatherValue; - self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; - self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; - child.value = self._createChildValue(fatherValue, childValue); - item.el.childValues.push(child.value); - }); - } else { - item.type = "bi.down_list_item"; - item.title = item.title || item.text; - item.textRgap = 10; - item.isNeedAdjustWidth = false; - item.logic = { - dynamic: true - }; - } - var el_done = {}; - el_done.el = item; - item_done.items.push(el_done); - }); - if (self._isGroup(item_done.items)) { - BI.each(item_done.items, function (i, item) { - self.singleValues.push(item.el.value); - }); - } - - result.push(item_done); - if (self._needSpliter(i, items.length)) { - var spliter_container = BI.createWidget({ - type: "bi.vertical", - items: [{ - el: { - type: "bi.layout", - cls: "bi-down-list-spliter bi-border-top cursor-pointer", - height: 0 - } - - }], - cls: "bi-down-list-spliter-container cursor-pointer", - lgap: 10, - rgap: 0 - }); - result.push(spliter_container); - } - }); - return result; - }, - - _isGroup: function (i) { - return i.length > 1; - }, - - _needSpliter: function (i, itemLength) { - return i < itemLength - 1; - }, - - _createChildValue: function (fatherValue, childValue) { - return fatherValue + "_" + childValue; - }, - - _digest: function (valueItem) { - var self = this; - var valueArray = []; - BI.each(valueItem, function (i, item) { - var value; - if (BI.isNotNull(item.childValue)) { - value = self._createChildValue(item.value, item.childValue); - } else { - value = item.value; - } - valueArray.push(value); - } - ); - return valueArray; - }, - - _checkValues: function (values) { - var value = []; - BI.each(this.items, function (idx, itemGroup) { - BI.each(itemGroup, function (id, item) { - if(BI.isNotNull(item.children)) { - var childValues = BI.map(item.children, "value"); - var v = joinValue(childValues, values[idx]); - if(BI.isNotEmptyString(v)) { - value.push(v); - } - }else{ - if(item.value === values[idx][0]) { - value.push(values[idx][0]); - } - } - }); - }); - return value; - - function joinValue (sources, targets) { - var value = ""; - BI.some(sources, function (idx, s) { - return BI.some(targets, function (id, t) { - if(s === t) { - value = s; - return true; - } - }); - }); - return value; - } - }, - - populate: function (items) { - BI.DownListPopup.superclass.populate.apply(this, arguments); - this.items = BI.deepClone(items); - this.childValueMap = {}; - this.fatherValueMap = {}; - this.singleValues = []; - var children = this._createChildren(this.items); - var popupItem = BI.createItems(children, - {}, { - adjustLength: -2 - } - ); - this.popup.populate(popupItem); - }, - - setValue: function (valueItem) { - this.popup.setValue(this._digest(valueItem)); - }, - - _getValue: function () { - var v = []; - BI.each(this.popup.getAllButtons(), function (i, item) { - i % 2 === 0 && v.push(item.getValue()); - }); - return v; - }, - - getValue: function () { - var self = this, result = []; - var values = this._checkValues(this._getValue()); - BI.each(values, function (i, value) { - var valueItem = {}; - if (BI.isNotNull(self.childValueMap[value])) { - var fartherValue = self.fatherValueMap[value]; - valueItem.childValue = self.childValueMap[value]; - valueItem.value = fartherValue; - } else { - valueItem.value = value; - } - result.push(valueItem); - }); - return result; - } - - -}); - -BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; -BI.shortcut("bi.down_list_popup", BI.DownListPopup);/** - * 汇总表格帮助类 - * Created by Young's on 2017/1/19. - */ -!(function () { - BI.DynamicDateHelper = {}; - BI.extend(BI.DynamicDateHelper, { - getCalculation: function (obj) { - var date = BI.getDate(); - - return this.getCalculationByDate(date, obj); - }, - - getCalculationByDate: function (date, obj) { - if (BI.isNotNull(obj.year)) { - date = BI.getDate((date.getFullYear() + BI.parseInt(obj.year)), date.getMonth(), date.getDate()); - } - if (BI.isNotNull(obj.quarter)) { - date = date.getOffsetQuarter(BI.parseInt(obj.quarter)); - } - if (BI.isNotNull(obj.month)) { - date = date.getOffsetMonth(BI.parseInt(obj.month)); - } - if (BI.isNotNull(obj.week)) { - date = date.getOffsetDate(BI.parseInt(obj.week) * 7); - } - if (BI.isNotNull(obj.day)) { - date = date.getOffsetDate(BI.parseInt(obj.day)); - } - if (BI.isNotNull(obj.workDay)) { - // 配置了节假日就按照节假日计算工作日偏移,否则按正常的天去算 - if(BI.isNotNull(BI.holidays)) { - var count = Math.abs(obj.workDay); - for (var i = 0; i < count; i++) { - date = date.getOffsetDate(obj.workDay < 0 ? -1 : 1); - if(BI.isNotNull(BI.holidays[date.print("%Y-%X-%d")])) { - i--; - } - } - } else { - date = date.getOffsetDate(BI.parseInt(obj.workDay)); - } - } - if (BI.isNotNull(obj.position) && obj.position !== BI.DynamicDateCard.OFFSET.CURRENT) { - date = this.getBeginDate(date, obj); - } - - return date; - }, - - getBeginDate: function (date, obj) { - if (BI.isNotNull(obj.day)) { - return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); - } - if (BI.isNotNull(obj.week)) { - return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? date.getWeekStartDate() : date.getWeekEndDate(); - } - if (BI.isNotNull(obj.month)) { - return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); - } - if (BI.isNotNull(obj.quarter)) { - return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? date.getQuarterStartDate() : date.getQuarterEndDate(); - } - if (BI.isNotNull(obj.year)) { - return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), 0, 1) : BI.getDate(date.getFullYear(), 11, 31); - } - return date; - } - }); -})(); -BI.DynamicDateCard = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-dynamic-date-card" - }, - - render: function () { - var self = this; - this.position = BI.DynamicDateCard.OFFSET.CURRENT; - return { - type: "bi.vertical", - items: [{ - el: { - type: "bi.label", - text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), - textAlign: "left", - height: 12, - lgap: 10 - }, - tgap: 10, - bgap: 5 - }, { - type: "bi.button_group", - ref: function () { - self.checkgroup = this; - }, - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - lgap: 4, - value: [BI.DynamicDateCard.TYPE.YEAR], - items: BI.createItems([{ - text: BI.i18nText("BI-Basic_Year"), - value: BI.DynamicDateCard.TYPE.YEAR - }, { - text: BI.i18nText("BI-Basic_Single_Quarter"), - value: BI.DynamicDateCard.TYPE.QUARTER - }, { - text: BI.i18nText("BI-Basic_Month"), - value: BI.DynamicDateCard.TYPE.MONTH - }, { - text: BI.i18nText("BI-Basic_Week"), - value: BI.DynamicDateCard.TYPE.WEEK - }, { - text: BI.i18nText("BI-Basic_Day"), - value: BI.DynamicDateCard.TYPE.DAY - }], { - type: "bi.multi_select_item", - logic: { - dynamic: true - } - }), - layouts: [{ - type: "bi.left", - rgap: 4 - }], - listeners: [{ - eventName: BI.ButtonGroup.EVENT_CHANGE, - action: function () { - var value = self.checkgroup.getValue(); - if(value.length !== 0) { - self.workDayBox.setSelected(false); - } - - var plainValue = {}; - BI.each(self.resultPane.getAllButtons(), function (idx, button) { - var value = button.getValue(); - if(BI.isNotNull(value.dateType)) { - plainValue[value.dateType] = { - value: value.value, - offset: value.offset - }; - } - }); - self.resultPane.populate(self._getParamJson(BI.map(self.checkgroup.getValue(), function (idx, v) { - var obj = { - dateType: v - }; - if(BI.has(plainValue, v)) { - obj.value = plainValue[v].value; - obj.offset = plainValue[v].offset; - } - return obj; - }))); - self.position = BI.DynamicDateCard.OFFSET.CURRENT; - self.fireEvent("EVENT_CHANGE"); - } - }] - }, { - type: "bi.vertical_adapt", - lgap: 2, - items: [{ - el: { - type: "bi.multi_select_item", - ref: function () { - self.workDayBox = this; - }, - logic: { - dynamic: true - }, - text: BI.i18nText("BI-Basic_Work_Day"), - value: BI.DynamicDateCard.TYPE.WORK_DAY, - listeners: [{ - eventName: BI.MultiSelectItem.EVENT_CHANGE, - action: function () { - if(this.isSelected()) { - self.checkgroup.setValue(); - } - self.resultPane.populate(this.isSelected() ? self._getParamJson([{ - dateType: BI.DynamicDateCard.TYPE.WORK_DAY - }]) : []); - self.position = BI.DynamicDateCard.OFFSET.CURRENT; - self.fireEvent("EVENT_CHANGE"); - } - }] - }, - bgap: 5 - }], - ref: function () { - self.workDay = this; - } - }, { - type: "bi.button_group", - items: this._getParamJson([{ - dateType: BI.DynamicDateCard.TYPE.YEAR - }]), - ref: function () { - self.resultPane = this; - }, - layouts: [{ - type: "bi.vertical", - bgap: 10, - hgap: 10 - }] - }] - }; - }, - - _getParamJson: function (values, positionValue) { - var self = this; - var items = BI.map(values, function (idx, value) { - return { - type: "bi.dynamic_date_param_item", - dateType: value.dateType, - value: value.value, - offset: value.offset, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }] - }; - }); - - if(values.length === 1 && values[0].dateType === BI.DynamicDateCard.TYPE.DAY) { - var comboItems = this._getText(BI.DynamicDateCard.TYPE.MONTH); - comboItems[0].text = BI.i18nText("BI-Basic_Empty"); - items.push({ - type: "bi.text_value_combo", - height: 24, - items: comboItems, - value: positionValue || BI.DynamicDateCard.OFFSET.CURRENT, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.position = this.getValue()[0]; - self.fireEvent("EVENT_CHANGE"); - } - }] - }); - }else{ - if(values.length !== 0 && BI.last(values).dateType !== BI.DynamicDateCard.TYPE.DAY && BI.last(values).dateType !== BI.DynamicDateCard.TYPE.WORK_DAY) { - items.push({ - type: "bi.text_value_combo", - height: 24, - items: this._getText(BI.last(values).dateType), - value: positionValue || BI.DynamicDateCard.OFFSET.CURRENT, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.position = this.getValue()[0]; - self.fireEvent("EVENT_CHANGE"); - } - }] - }); - - } - } - - return items; - }, - - _getText: function (lastValue) { - switch (lastValue) { - case BI.DynamicDateCard.TYPE.YEAR: - return [{ - text: BI.i18nText("BI-Basic_Current_Day"), - value: BI.DynamicDateCard.OFFSET.CURRENT - }, { - text: BI.i18nText("BI-Basic_Year_Begin"), - value: BI.DynamicDateCard.OFFSET.BEGIN - }, { - text: BI.i18nText("BI-Basic_Year_End"), - value: BI.DynamicDateCard.OFFSET.END - }]; - case BI.DynamicDateCard.TYPE.QUARTER: - return [{ - text: BI.i18nText("BI-Basic_Current_Day"), - value: BI.DynamicDateCard.OFFSET.CURRENT - }, { - text: BI.i18nText("BI-Basic_Quarter_Begin"), - value: BI.DynamicDateCard.OFFSET.BEGIN - }, { - text: BI.i18nText("BI-Basic_Quarter_End"), - value: BI.DynamicDateCard.OFFSET.END - }]; - case BI.DynamicDateCard.TYPE.MONTH: - return [{ - text: BI.i18nText("BI-Basic_Current_Day"), - value: BI.DynamicDateCard.OFFSET.CURRENT - }, { - text: BI.i18nText("BI-Basic_Month_Begin"), - value: BI.DynamicDateCard.OFFSET.BEGIN - }, { - text: BI.i18nText("BI-Basic_Month_End"), - value: BI.DynamicDateCard.OFFSET.END - }]; - case BI.DynamicDateCard.TYPE.WEEK: - default: - return [{ - text: BI.i18nText("BI-Basic_Current_Day"), - value: BI.DynamicDateCard.OFFSET.CURRENT - }, { - text: BI.i18nText("BI-Basic_Week_Begin"), - value: BI.DynamicDateCard.OFFSET.BEGIN - }, { - text: BI.i18nText("BI-Basic_Week_End"), - value: BI.DynamicDateCard.OFFSET.END - }]; - } - }, - - _createValue: function (type, v) { - return { - dateType: type, - value: Math.abs(v), - offset: v > 0 ? 1 : 0 - }; - }, - - setValue: function (v) { - v = v || {}; - this.position = v.position || BI.DynamicDateCard.OFFSET.CURRENT; - var values = []; - var valuesItems = []; - if(BI.isNotNull(v.year)) { - values.push(BI.DynamicDateCard.TYPE.YEAR); - valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); - } - if(BI.isNotNull(v.quarter)) { - values.push(BI.DynamicDateCard.TYPE.QUARTER); - valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter)); - } - if(BI.isNotNull(v.month)) { - values.push(BI.DynamicDateCard.TYPE.MONTH); - valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.MONTH, v.month)); - } - if(BI.isNotNull(v.week)) { - values.push(BI.DynamicDateCard.TYPE.WEEK); - valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.WEEK, v.week)); - } - if(BI.isNotNull(v.day)) { - values.push(BI.DynamicDateCard.TYPE.DAY); - valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.DAY, v.day)); - } - if(BI.isNotNull(v.workDay)) { - values.push(BI.DynamicDateCard.TYPE.WORK_DAY); - valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.WORK_DAY, v.workDay)); - } - this.checkgroup.setValue(values); - this.workDayBox.setSelected(BI.isNotNull(v.workDay)); - this.resultPane.populate(this._getParamJson(valuesItems, v.position)); - }, - - getValue: function () { - var self = this; - var valueMap = {}; - var selectValues = this.checkgroup.getValue(); - var buttons = this.resultPane.getAllButtons(); - if(selectValues.length !== 0) { - BI.each(buttons, function (idx, button) { - var value = button.getValue(); - switch (value.dateType) { - case BI.DynamicDateCard.TYPE.YEAR: - valueMap.year = (value.offset === 0 ? -value.value : value.value); - break; - case BI.DynamicDateCard.TYPE.QUARTER: - valueMap.quarter = (value.offset === 0 ? -value.value : value.value); - break; - case BI.DynamicDateCard.TYPE.MONTH: - valueMap.month = (value.offset === 0 ? -value.value : value.value); - break; - case BI.DynamicDateCard.TYPE.WEEK: - valueMap.week = (value.offset === 0 ? -value.value : value.value); - break; - case BI.DynamicDateCard.TYPE.DAY: - valueMap.day = (value.offset === 0 ? -value.value : value.value); - break; - default: - break; - } - if(BI.isNull(value.dateType)) { - valueMap.position = self.position || BI.DynamicDateCard.OFFSET.CURRENT; - } - }); - } - if(this.workDayBox.isSelected()) { - var value = buttons[0].getValue(); - valueMap.workDay = (value.offset === 0 ? -value.value : value.value); - } - return valueMap; - } - -}); -BI.shortcut("bi.dynamic_date_card", BI.DynamicDateCard); - -BI.extend(BI.DynamicDateCard, { - TYPE: { - YEAR: 1, - QUARTER: 2, - MONTH: 3, - WEEK: 4, - DAY: 5, - WORK_DAY: 6 - }, - OFFSET: { - CURRENT: 1, - BEGIN: 2, - END: 3 - } - -});BI.DynamicDateCombo = BI.inherit(BI.Single, { - constants: { - popupHeight: 259, - popupWidth: 270, - comboAdjustHeight: 1, - border: 1, - DATE_MIN_VALUE: "1900-01-01", - DATE_MAX_VALUE: "2099-12-31" - }, - - props: { - baseCls: "bi-dynamic-date-combo bi-border", - height: 24 - }, - - - render: function () { - var self = this, opts = this.options; - this.storeTriggerValue = ""; - var date = BI.getDate(); - this.storeValue = opts.value; - return { - type: "bi.htape", - items: [{ - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: 24, - ref: function () { - self.changeIcon = this; - } - }, - width: 24 - }, { - type: "bi.absolute", - items: [{ - el: { - type: "bi.combo", - ref: function () { - self.combo = this; - }, - toggle: false, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: { - type: "bi.dynamic_date_trigger", - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE, - value: opts.value, - ref: function () { - self.trigger = this; - }, - listeners: [{ - eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN, - action: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_STOP, - action: function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_FOCUS, - action: function () { - self.storeTriggerValue = self.trigger.getKey(); - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_ERROR, - action: function () { - self.storeValue = { - type: BI.DynamicDateCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1 - } - }; - self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_VALID, - action: function () { - self.fireEvent(BI.DynamicDateCombo.EVENT_VALID); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateCombo.EVENT_CHANGE); - } - }, { - eventName: BI.DynamicDateTrigger.EVENT_CONFIRM, - action: function () { - if (self.combo.isViewVisible()) { - return; - } - var dateStore = self.storeTriggerValue; - var dateObj = self.trigger.getKey(); - if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { - self.storeValue = self.trigger.getValue(); - self.setValue(self.trigger.getValue()); - } else if (BI.isEmptyString(dateObj)) { - self.storeValue = null; - self.trigger.setValue(); - } - self._checkDynamicValue(self.storeValue); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }] - }, - adjustLength: this.constants.comboAdjustHeight, - popup: { - el: { - type: "bi.dynamic_date_popup", - behaviors: opts.behaviors, - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE, - value: opts.value, - ref: function () { - self.popup = this; - }, - listeners: [{ - eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE, - action: function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE, - action: function () { - var date = BI.getDate(); - self.setValue({ - type: BI.DynamicDateCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - } - }); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE, - action: function () { - var value = self.popup.getValue(); - if(self._checkValue(value)) { - self.setValue(value); - } - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDatePopup.EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }] - }, - stopPropagation: false - }, - listeners: [{ - eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, - action: function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW); - } - }] - }, - top: 0, - left: 0, - right: 0, - bottom: 0 - }, { - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-font", - width: 24, - height: 24, - listeners: [{ - eventName: BI.IconButton.EVENT_CHANGE, - action: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - } - }] - }, - top: 0, - right: 0 - }] - }], - ref: function (_ref) { - self.comboWrapper = _ref; - } - }; - }, - - mounted: function () { - this._checkDynamicValue(this.storeValue); - }, - - _checkDynamicValue: function (v) { - var type = null; - if (BI.isNotNull(v)) { - type = v.type; - } - switch (type) { - case BI.DynamicDateCombo.Dynamic: - this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; - this.comboWrapper.resize(); - break; - default: - this.comboWrapper.attr("items")[0].width = 0; - this.comboWrapper.resize(); - this.changeIcon.setVisible(false); - break; - } - }, - - _checkValue: function (v) { - switch (v.type) { - case BI.DynamicDateCombo.Dynamic: - return BI.isNotEmptyObject(v.value); - case BI.DynamicDateCombo.Static: - default: - return true; - } - }, - - setValue: function (v) { - this.storeValue = v; - this.trigger.setValue(v); - this._checkDynamicValue(v); - }, - getValue: function () { - return this.storeValue; - }, - getKey: function () { - return this.trigger.getKey(); - }, - hidePopupView: function () { - this.combo.hideView(); - } -}); - -BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; -BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW"; - -BI.shortcut("bi.dynamic_date_combo", BI.DynamicDateCombo); - -BI.extend(BI.DynamicDateCombo, { - Static: 1, - Dynamic: 2 -});BI.DynamicDateParamItem = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-dynamic-date-param-item", - dateType: BI.DynamicDateCard.TYPE.YEAR, - value: 0, - offset: 0, - height: 24 - }, - - render: function () { - var self = this, o = this.options; - return { - type: "bi.htape", - items: [{ - el: { - type: "bi.sign_editor", - cls: "bi-border", - height: 22, - validationChecker: function (v) { - return BI.isNaturalNumber(v); - }, - value: o.value, - ref: function () { - self.editor = this; - }, - errorText: function (v) { - if(BI.isEmptyString(v)) { - return BI.i18nText("BI-Basic_Please_Input_Content"); - } - return BI.i18nText("BI-Please_Input_Natural_Number"); - }, - allowBlank: false, - listeners: [{ - eventName: BI.SignEditor.EVENT_CONFIRM, - action: function () { - self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE); - } - }] - }, - width: 60 - }, { - el: { - type: "bi.label", - height: 24, - text: this._getText() - }, - width: o.dateType === BI.DynamicDateCard.TYPE.WORK_DAY ? 60 : 20 - }, { - type: "bi.text_value_combo", - height: 24, - items: [{ - text: BI.i18nText("BI-Basic_Front"), - value: 0 - }, { - text: BI.i18nText("BI-Basic_Behind"), - value: 1 - }], - ref: function () { - self.offsetCombo = this; - }, - value: o.offset, - listeners: [{ - eventName: BI.TextValueCombo.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE); - } - }] - }] - }; - }, - - _getText: function () { - var text = ""; - switch (this.options.dateType) { - case BI.DynamicDateCard.TYPE.YEAR: - text = BI.i18nText("BI-Basic_Year"); - break; - case BI.DynamicDateCard.TYPE.QUARTER: - text = BI.i18nText("BI-Basic_Single_Quarter"); - break; - case BI.DynamicDateCard.TYPE.MONTH: - text = BI.i18nText("BI-Basic_Month"); - break; - case BI.DynamicDateCard.TYPE.WEEK: - text = BI.i18nText("BI-Basic_Week"); - break; - case BI.DynamicDateCard.TYPE.DAY: - text = BI.i18nText("BI-Basic_Day"); - break; - case BI.DynamicDateCard.TYPE.WORK_DAY: - default: - text = BI.i18nText("BI-Basic_Work_Day"); - break; - } - return text; - }, - - setValue: function (v) { - v = v || {}; - v.value = v.value || 0; - v.offset = v.offset || 0; - this.editor.setValue(v.value); - this.offsetCombo.setValue(v.offset); - }, - - getValue: function () { - return { - dateType: this.options.dateType, - value: this.editor.getValue(), - offset: this.offsetCombo.getValue()[0] - }; - } - -}); -BI.DynamicDateParamItem.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.dynamic_date_param_item", BI.DynamicDateParamItem); -BI.DynamicDatePopup = BI.inherit(BI.Widget, { - constants: { - tabHeight: 30, - buttonHeight: 24 - }, - - props: { - baseCls: "bi-dynamic-date-popup", - width: 248, - height: 344 - }, - - _init: function () { - BI.DynamicDatePopup.superclass._init.apply(this, arguments); - var self = this, opts = this.options, c = this.constants; - this.storeValue = {type: BI.DynamicDateCombo.Static}; - BI.createWidget({ - element: this, - type: "bi.vtape", - items: [{ - el: this._getTabJson() - }, { - el: { - type: "bi.grid", - items: [[{ - type: "bi.text_button", - forceCenter: true, - cls: "bi-high-light bi-border-top", - shadow: true, - text: BI.i18nText("BI-Basic_Clear"), - textHeight: c.buttonHeight - 1, - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-left bi-border-right bi-high-light bi-border-top", - shadow: true, - textHeight: c.buttonHeight - 1, - text: BI.i18nText("BI-Multi_Date_Today"), - ref: function () { - self.textButton = this; - }, - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-high-light bi-border-top", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_OK"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); - } - }] - }]] - }, - height: 24 - }] - }); - this.setValue(opts.value); - }, - - _getTabJson: function () { - var self = this, o = this.options; - return { - type: "bi.tab", - ref: function () { - self.dateTab = this; - }, - tab: { - type: "bi.linear_segment", - cls: "bi-border-bottom", - height: this.constants.tabHeight, - items: BI.createItems([{ - text: BI.i18nText("BI-Multi_Date_YMD"), - value: BI.DynamicDateCombo.Static - }, { - text: BI.i18nText("BI-Basic_Dynamic_Title"), - value: BI.DynamicDateCombo.Dynamic - }], { - textAlign: "center" - }) - }, - cardCreator: function (v) { - switch (v) { - case BI.DynamicDateCombo.Dynamic: - return { - type: "bi.dynamic_date_card", - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self._setInnerValue(self.year, v); - } - }], - ref: function () { - self.dynamicPane = this; - } - }; - case BI.DynamicDateCombo.Static: - default: - return { - type: "bi.date_calendar_popup", - behaviors: o.behaviors, - min: self.options.min, - max: self.options.max, - listeners: [{ - eventName: BI.DateCalendarPopup.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDatePopup.EVENT_CHANGE); - } - }], - ref: function () { - self.ymd = this; - } - }; - } - }, - listeners: [{ - eventName: BI.Tab.EVENT_CHANGE, - action: function () { - var v = self.dateTab.getSelect(); - switch (v) { - case BI.DynamicDateCombo.Static: - var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); - self.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - }); - self._setInnerValue(); - break; - case BI.DynamicDateCombo.Dynamic: - default: - if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) { - self.dynamicPane.setValue(self.storeValue.value); - }else{ - self.dynamicPane.setValue({ - year: 0 - }); - } - self._setInnerValue(); - break; - } - } - }] - }; - }, - - _setInnerValue: function () { - if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - this.textButton.setEnable(true); - } else { - var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); - date = date.print("%Y-%x-%e"); - this.textButton.setValue(date); - this.textButton.setEnable(false); - } - }, - - _checkValueValid: function (value) { - return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); - }, - - setValue: function (v) { - this.storeValue = v; - var self = this; - var type, value; - v = v || {}; - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - this.dateTab.setSelect(type); - switch (type) { - case BI.DynamicDateCombo.Dynamic: - this.dynamicPane.setValue(value); - self._setInnerValue(); - break; - case BI.DynamicDateCombo.Static: - default: - if (this._checkValueValid(value)) { - var date = BI.getDate(); - this.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - }); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } else { - this.ymd.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } - this.textButton.setEnable(true); - break; - } - }, - - getValue: function () { - return { - type: this.dateTab.getSelect(), - value: this.dateTab.getValue() - }; - } -}); -BI.DynamicDatePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; -BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; -BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2, - yearLength: 4, - yearMonthLength: 6, - yearFullMonthLength: 7 - }, - - props: { - extraCls: "bi-date-trigger", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }, - - _init: function () { - BI.DynamicDateTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.storeTriggerValue = ""; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - validationChecker: function (v) { - var date = v.match(/\d+/g); - self._autoAppend(v, date); - return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({ - year: date[0] | 0, - month: date[1] | 0, - day: date[2] | 0 - }); - }, - quitChecker: function () { - return false; - }, - hgap: c.hgap, - vgap: c.vgap, - allowBlank: true, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - errorText: function () { - if (self.editor.isEditing()) { - return BI.i18nText("BI-Date_Trigger_Error_Text"); - } - return BI.i18nText("BI-Year_Trigger_Invalid_Text"); - }, - title: function () { - var storeValue = self.storeValue || {}; - var type = storeValue.type || BI.DynamicDateCombo.Static; - var value = storeValue.value; - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = self._getText(value); - var date = BI.getDate(); - date = BI.DynamicDateHelper.getCalculation(value); - var dateStr = date.print("%Y-%x-%e"); - return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); - case BI.DynamicDateCombo.Static: - default: - if (BI.isNull(value) || BI.isNull(value.day)) { - return ""; - } - return BI.getDate(value.year, (value.month - 1), value.day).print("%Y-%X-%d"); - } - } - }); - this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { - self.fireEvent(BI.DynamicDateTrigger.EVENT_KEY_DOWN); - }); - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.storeTriggerValue = self.getKey(); - self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); - }); - this.editor.on(BI.SignEditor.EVENT_VALID, function () { - self.fireEvent(BI.DynamicDateTrigger.EVENT_VALID); - }); - this.editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.DynamicDateTrigger.EVENT_ERROR); - }); - this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { - var value = self.editor.getValue(); - if (BI.isNotNull(value)) { - self.editor.setState(value); - } - - if (BI.isNotEmptyString(value) && !BI.isEqual(self.storeTriggerValue, self.getKey())) { - var date = value.split("-"); - self.storeValue = { - type: BI.DynamicDateCombo.Static, - value: { - year: date[0] | 0, - month: date[1] | 0, - day: date[2] | 0 - } - }; - } - self.fireEvent(BI.DynamicDateTrigger.EVENT_CONFIRM); - }); - this.editor.on(BI.SignEditor.EVENT_SPACE, function () { - if (self.editor.isValid()) { - self.editor.blur(); - } - }); - this.editor.on(BI.SignEditor.EVENT_START, function () { - self.fireEvent(BI.DynamicDateTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.DynamicDateTrigger.EVENT_CHANGE); - }); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.editor - }, { - el: BI.createWidget(), - width: 24 - }] - }); - this.setValue(o.value); - }, - _dateCheck: function (date) { - return BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") === date || - BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") === date || - BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") === date || - BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") === date; - }, - _checkVoid: function (obj) { - return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; - }, - _autoAppend: function (v, dateObj) { - if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) { - switch (v.length) { - case this._const.yearLength: - if (this._yearCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - case this._const.yearMonthLength: - case this._const.yearFullMonthLength: - var splitMonth = v.split("-")[1]; - if ((BI.isNotNull(splitMonth) && splitMonth.length === 2) || this._monthCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - } - } - }, - - _yearCheck: function (v) { - var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); - return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; - }, - - _monthCheck: function (v) { - var date = BI.parseDateTime(v, "%Y-%X-%d"); - var dateStr = date.print("%Y-%X-%d"); - return (date.getMonth() >= 0 && (BI.parseDateTime(v, "%Y-%X").print("%Y-%X") === v || - BI.parseDateTime(v, "%Y-%x").print("%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max; - }, - - _setInnerValue: function (date) { - var dateStr = date.print("%Y-%x-%e"); - this.editor.setState(dateStr); - this.editor.setValue(dateStr); - }, - - _getText: function (obj) { - var value = ""; - var endText = ""; - if(BI.isNotNull(obj.year)) { - if(BI.parseInt(obj.year) !== 0) { - value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); - } - if(BI.isNotNull(obj.quarter)) { - if(BI.parseInt(obj.quarter) !== 0) { - value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); - } - if(BI.isNotNull(obj.month)) { - if(BI.parseInt(obj.month) !== 0) { - value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); - } - if(BI.isNotNull(obj.week)) { - if(BI.parseInt(obj.week) !== 0) { - value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); - } - if(BI.isNotNull(obj.day)) { - if(BI.parseInt(obj.day) !== 0) { - value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; - } - if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { - value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - return value + endText; - - function getPositionText (baseText, position) { - switch (position) { - case BI.DynamicDateCard.OFFSET.BEGIN: - return baseText + BI.i18nText("BI-Basic_Begin_Start"); - case BI.DynamicDateCard.OFFSET.END: - return baseText + BI.i18nText("BI-Basic_End_Stop"); - case BI.DynamicDateCard.OFFSET.CURRENT: - default: - return BI.i18nText("BI-Basic_Current_Day"); - } - } - }, - - setValue: function (v) { - var type, value, self = this; - var date = BI.getDate(); - this.storeValue = v; - if (BI.isNotNull(v)) { - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - } - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = this._getText(value); - date = BI.DynamicDateHelper.getCalculation(value); - this._setInnerValue(date, text); - break; - case BI.DynamicDateCombo.Static: - default: - if (BI.isNull(value) || BI.isNull(value.day)) { - this.editor.setState(""); - this.editor.setValue(""); - } else { - var dateStr = BI.getDate(value.year, (value.month - 1), value.day).print("%Y-%X-%d"); - this.editor.setState(dateStr); - this.editor.setValue(dateStr); - } - break; - } - }, - - getKey: function () { - return this.editor.getValue(); - }, - getValue: function () { - return this.storeValue; - } - -}); - -BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; -BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; -BI.DynamicDateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicDateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DynamicDateTrigger.EVENT_VALID = "EVENT_VALID"; -BI.DynamicDateTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.DynamicDateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.shortcut("bi.dynamic_date_trigger", BI.DynamicDateTrigger); -BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { - constants: { - popupHeight: 259, - popupWidth: 270, - comboAdjustHeight: 1, - border: 1, - DATE_MIN_VALUE: "1900-01-01", - DATE_MAX_VALUE: "2099-12-31" - }, - - props: { - baseCls: "bi-dynamic-date-combo bi-border", - height: 24 - }, - - - render: function () { - var self = this, opts = this.options; - this.storeTriggerValue = ""; - var date = BI.getDate(); - this.storeValue = opts.value; - return { - type: "bi.htape", - items: [{ - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: 24, - ref: function () { - self.changeIcon = this; - } - }, - width: 24 - }, { - type: "bi.absolute", - items: [{ - el: { - type: "bi.combo", - ref: function () { - self.combo = this; - }, - toggle: false, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: { - type: "bi.dynamic_date_time_trigger", - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE, - value: opts.value, - ref: function () { - self.trigger = this; - }, - listeners: [{ - eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN, - action: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_STOP, - action: function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK, - action: function () { - self.combo.toggle(); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS, - action: function () { - self.storeTriggerValue = self.trigger.getKey(); - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, - action: function () { - self.storeValue = { - type: BI.DynamicDateTimeCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1 - } - }; - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_VALID, - action: function () { - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE); - } - }, { - eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM, - action: function () { - if (self.combo.isViewVisible()) { - return; - } - var dateStore = self.storeTriggerValue; - var dateObj = self.trigger.getKey(); - if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { - self.storeValue = self.trigger.getValue(); - self.setValue(self.trigger.getValue()); - } else if (BI.isEmptyString(dateObj)) { - self.storeValue = null; - self.trigger.setValue(); - } - self._checkDynamicValue(self.storeValue); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }] - }, - adjustLength: this.constants.comboAdjustHeight, - popup: { - el: { - type: "bi.dynamic_date_time_popup", - behaviors: opts.behaviors, - min: this.constants.DATE_MIN_VALUE, - max: this.constants.DATE_MAX_VALUE, - value: opts.value, - ref: function () { - self.popup = this; - }, - listeners: [{ - eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE, - action: function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE, - action: function () { - var date = BI.getDate(); - self.setValue({ - type: BI.DynamicDateTimeCombo.Static, - value: { - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate(), - hour: 0, - minute: 0, - second: 0 - } - }); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE, - action: function () { - var value = self.popup.getValue(); - if(self._checkValue(value)) { - self.setValue(value); - } - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicDateTimePopup.EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); - } - }] - }, - stopPropagation: false - }, - listeners: [{ - eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, - action: function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); - } - }] - }, - top: 0, - left: 0, - right: 0, - bottom: 0 - }, { - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-font", - width: 24, - height: 24, - listeners: [{ - eventName: BI.IconButton.EVENT_CHANGE, - action: function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - } - }] - }, - top: 0, - right: 0 - }] - }], - ref: function (_ref) { - self.comboWrapper = _ref; - } - }; - }, - - mounted: function () { - this._checkDynamicValue(this.storeValue); - }, - - _checkDynamicValue: function (v) { - var type = null; - if (BI.isNotNull(v)) { - type = v.type; - } - switch (type) { - case BI.DynamicDateTimeCombo.Dynamic: - this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; - this.comboWrapper.resize(); - break; - default: - this.comboWrapper.attr("items")[0].width = 0; - this.comboWrapper.resize(); - this.changeIcon.setVisible(false); - break; - } - }, - - _checkValue: function (v) { - switch (v.type) { - case BI.DynamicDateCombo.Dynamic: - return BI.isNotEmptyObject(v.value); - case BI.DynamicDateCombo.Static: - default: - return true; - } - }, - - setValue: function (v) { - this.storeValue = v; - this.trigger.setValue(v); - this._checkDynamicValue(v); - }, - getValue: function () { - return this.storeValue; - }, - getKey: function () { - return this.trigger.getKey(); - }, - hidePopupView: function () { - this.combo.hideView(); - }, - - isValid: function () { - return this.trigger.isValid(); - } -}); - -BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; -BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; - -BI.shortcut("bi.dynamic_date_time_combo", BI.DynamicDateTimeCombo); - -BI.extend(BI.DynamicDateTimeCombo, { - Static: 1, - Dynamic: 2 -});BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { - constants: { - tabHeight: 30, - buttonHeight: 24 - }, - - props: { - baseCls: "bi-dynamic-date-time-popup", - width: 248, - height: 385 - }, - - _init: function () { - BI.DynamicDateTimePopup.superclass._init.apply(this, arguments); - var self = this, opts = this.options, c = this.constants; - this.storeValue = {type: BI.DynamicDateCombo.Static}; - BI.createWidget({ - element: this, - type: "bi.vtape", - items: [{ - el: this._getTabJson() - }, { - el: { - type: "bi.grid", - items: [[{ - type: "bi.text_button", - forceCenter: true, - cls: "bi-high-light bi-border-top", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_Clear"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-left bi-border-right bi-high-light bi-border-top", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Multi_Date_Today"), - ref: function () { - self.textButton = this; - }, - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-high-light bi-border-top", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_OK"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE); - } - }] - }]] - }, - height: 24 - }] - }); - this.setValue(opts.value); - }, - - _getTabJson: function () { - var self = this, o = this.options; - return { - type: "bi.tab", - ref: function () { - self.dateTab = this; - }, - tab: { - type: "bi.linear_segment", - cls: "bi-border-bottom", - height: this.constants.tabHeight, - items: BI.createItems([{ - text: BI.i18nText("BI-Multi_Date_YMD"), - value: BI.DynamicDateCombo.Static - }, { - text: BI.i18nText("BI-Basic_Dynamic_Title"), - value: BI.DynamicDateCombo.Dynamic - }], { - textAlign: "center" - }) - }, - cardCreator: function (v) { - switch (v) { - case BI.DynamicDateCombo.Dynamic: - return { - type: "bi.dynamic_date_card", - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self._setInnerValue(self.year, v); - } - }], - ref: function () { - self.dynamicPane = this; - } - }; - case BI.DynamicDateCombo.Static: - default: - return { - type: "bi.vtape", - items: [{ - type: "bi.date_calendar_popup", - behaviors: o.behaviors, - min: self.options.min, - max: self.options.max, - ref: function () { - self.ymd = this; - } - }, { - el: { - type: "bi.dynamic_date_time_select", - ref: function () { - self.timeSelect = this; - }, - listeners: [{ - eventName: BI.DynamicDateTimeSelect.EVENT_CONFIRM, - action: function () { - - } - }] - }, - height: 40 - }] - }; - } - }, - listeners: [{ - eventName: BI.Tab.EVENT_CHANGE, - action: function () { - var v = self.dateTab.getSelect(); - switch (v) { - case BI.DynamicDateCombo.Static: - var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); - self.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - }); - self.timeSelect.setValue(); - self._setInnerValue(); - break; - case BI.DynamicDateCombo.Dynamic: - default: - if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) { - self.dynamicPane.setValue(self.storeValue.value); - }else{ - self.dynamicPane.setValue({ - year: 0 - }); - } - self._setInnerValue(); - break; - } - } - }] - }; - }, - - _setInnerValue: function () { - if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - this.textButton.setEnable(true); - } else { - var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); - date = date.print("%Y-%x-%e"); - this.textButton.setValue(date); - this.textButton.setEnable(false); - } - }, - - _checkValueValid: function (value) { - return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); - }, - - setValue: function (v) { - this.storeValue = v; - var self = this; - var type, value; - v = v || {}; - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - this.dateTab.setSelect(type); - switch (type) { - case BI.DynamicDateCombo.Dynamic: - this.dynamicPane.setValue(value); - self._setInnerValue(); - break; - case BI.DynamicDateCombo.Static: - default: - if (this._checkValueValid(value)) { - var date = BI.getDate(); - this.ymd.setValue({ - year: date.getFullYear(), - month: date.getMonth() + 1, - day: date.getDate() - }); - this.timeSelect.setValue(); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } else { - this.ymd.setValue(value); - this.timeSelect.setValue({ - hour: value.hour, - minute: value.minute, - second: value.second - }); - this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); - } - this.textButton.setEnable(true); - break; - } - }, - - getValue: function () { - var type = this.dateTab.getSelect(); - return { - type: type, - value: type === BI.DynamicDateTimeCombo.Static ? BI.extend(this.ymd.getValue(), this.timeSelect.getValue()) : this.dynamicPane.getValue() - }; - } -}); -BI.DynamicDateTimePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; -BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; -BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-date-time-select bi-border-top" - }, - - render: function () { - var self = this; - return { - type: "bi.center_adapt", - items: [{ - type: "bi.vertical_adapt", - items: [{ - el: { - type: "bi.number_editor", - ref: function () { - self.hour = this; - }, - validationChecker: function (v) { - return BI.isNaturalNumber(v) && BI.parseInt(v) < 24; - }, - errorText: function (v) { - if(BI.isNumeric(v)) { - return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-23\""); - } - return BI.i18nText("BI-Numerical_Interval_Input_Data"); - }, - listeners: [{ - eventName: BI.SignEditor.EVENT_CONFIRM, - action: function () { - var value = this.getValue(); - self._checkHour(value); - this.setValue(self._formatValueToDoubleDigit(value)); - self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); - } - }, { - eventName: BI.SignEditor.EVENT_CHANGE, - action: function () { - var value = self._autoSwitch(this.getValue(), BI.DynamicDateTimeSelect.HOUR); - this.setValue(value); - } - }], - width: 60, - height: 24 - }, - lgap: 14 - }, { - type: "bi.label", - text: ":", - width: 20 - }, { - type: "bi.number_editor", - ref: function () { - self.minute = this; - }, - validationChecker: function (v) { - return BI.isNaturalNumber(v) && BI.parseInt(v) < 60; - }, - errorText: function (v) { - if(BI.isNumeric(v)) { - return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-59\""); - } - return BI.i18nText("BI-Numerical_Interval_Input_Data"); - }, - listeners: [{ - eventName: BI.SignEditor.EVENT_CONFIRM, - action: function () { - var value = this.getValue(); - self._checkMinute(value); - this.setValue(self._formatValueToDoubleDigit(value), BI.DynamicDateTimeSelect.MINUTE); - self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); - } - }, { - eventName: BI.SignEditor.EVENT_CHANGE, - action: function () { - var value = self._autoSwitch(this.getValue(), BI.DynamicDateTimeSelect.MINUTE); - this.setValue(value); - } - }], - width: 60, - height: 24 - }, { - type: "bi.label", - text: ":", - width: 20 - }, { - type: "bi.number_editor", - ref: function () { - self.second = this; - }, - validationChecker: function (v) { - return BI.isNaturalNumber(v) && BI.parseInt(v) < 60; - }, - errorText: function (v) { - if(BI.isNumeric(v)) { - return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-59\""); - } - return BI.i18nText("BI-Numerical_Interval_Input_Data"); - }, - listeners: [{ - eventName: BI.SignEditor.EVENT_CONFIRM, - action: function () { - var value = this.getValue(); - self._checkSecond(value); - this.setValue(self._formatValueToDoubleDigit(value)); - self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); - } - }], - width: 60, - height: 24 - }] - }] - }; - }, - - _checkBorder: function (v) { - v = v || {}; - this._checkHour(v.hour); - this._checkMinute(v.minute); - this._checkSecond(v.second); - }, - - _checkHour: function (value) { - this.hour.setDownEnable(BI.parseInt(value) > 0); - this.hour.setUpEnable(BI.parseInt(value) < 23); - }, - - _checkMinute: function (value) { - this.minute.setDownEnable(BI.parseInt(value) > 0); - this.minute.setUpEnable(BI.parseInt(value) < 59); - }, - - _checkSecond: function (value) { - this.second.setDownEnable(BI.parseInt(value) > 0); - this.second.setUpEnable(BI.parseInt(value) < 59); - }, - - _autoSwitch: function (v, type) { - var limit = 0; - var value = v; - switch (type) { - case BI.DynamicDateTimeSelect.HOUR: - limit = 2; - break; - case BI.DynamicDateTimeSelect.MINUTE: - limit = 5; - break; - default: - break; - } - if(v.length === 1 && BI.parseInt(v) > limit) { - value = "0" + value; - } - if (value.length === 2) { - type === BI.DynamicDateTimeSelect.HOUR ? this.minute.focus() : this.second.focus(); - } - return value; - }, - - _formatValueToDoubleDigit: function (v) { - if(BI.isNull(v) || BI.isEmptyString(v)) { - v = 0; - } - var value = BI.parseInt(v); - if(value < 10) { - value = "0" + value; - } - return value; - }, - - _assertValue: function (v) { - v = v || {}; - v.hour = this._formatValueToDoubleDigit(v.hour) || "00"; - v.minute = this._formatValueToDoubleDigit(v.minute) || "00"; - v.second = this._formatValueToDoubleDigit(v.second) || "00"; - return v; - }, - - getValue: function () { - return { - hour: BI.parseInt(this.hour.getValue()), - minute: BI.parseInt(this.minute.getValue()), - second: BI.parseInt(this.second.getValue()) - }; - }, - - setValue: function (v) { - v = this._assertValue(v); - this.hour.setValue(v.hour); - this.minute.setValue(v.minute); - this.second.setValue(v.second); - this._checkBorder(v); - } - -}); -BI.DynamicDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.dynamic_date_time_select", BI.DynamicDateTimeSelect); - -BI.extend(BI.DynamicDateTimeSelect, { - HOUR: 1, - MINUTE: 2 -});BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2, - yearLength: 4, - yearMonthLength: 6, - yearFullMonthLength: 7 - }, - - props: { - extraCls: "bi-date-time-trigger", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }, - - _init: function () { - BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.storeTriggerValue = ""; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - validationChecker: function (v) { - var date = v.match(/\d+/g); - self._autoAppend(v, date); - return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({ - year: date[0] | 0, - month: date[1] | 0, - day: date[2] | 0 - }); - }, - quitChecker: function () { - return false; - }, - hgap: c.hgap, - vgap: c.vgap, - allowBlank: true, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - errorText: function () { - if (self.editor.isEditing()) { - return BI.i18nText("BI-Basic_Date_Time_Error_Text"); - } - return BI.i18nText("BI-Year_Trigger_Invalid_Text"); - }, - title: function () { - var storeValue = self.storeValue || {}; - var type = storeValue.type || BI.DynamicDateCombo.Static; - var value = storeValue.value; - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = self._getText(value); - var date = BI.DynamicDateHelper.getCalculation(value); - var dateStr = date.print("%Y-%x-%e %H:%M:%S"); - return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); - case BI.DynamicDateCombo.Static: - default: - if (BI.isNull(value) || BI.isNull(value.day)) { - return ""; - } - return BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0, - value.second || 0).print("%Y-%X-%d %H:%M:%S"); - } - } - }); - this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN); - }); - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.storeTriggerValue = self.getKey(); - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); - }); - this.editor.on(BI.SignEditor.EVENT_VALID, function () { - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_VALID); - }); - this.editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_ERROR); - }); - this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { - var value = self.editor.getValue(); - if (BI.isNotNull(value)) { - self.editor.setState(value); - } - - if (BI.isNotEmptyString(value) && !BI.isEqual(self.storeTriggerValue, self.getKey())) { - var date = value.split(/-|\s|:/); - self.storeValue = { - type: BI.DynamicDateCombo.Static, - value: { - year: date[0] | 0, - month: date[1] | 0, - day: date[2] | 0, - hour: date[3] | 0, - minute: date[4] | 0, - second: date[5] | 0 - } - }; - } - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_CONFIRM); - }); - this.editor.on(BI.SignEditor.EVENT_START, function () { - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_CHANGE); - }); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.editor - }, { - el: BI.createWidget(), - width: 24 - }] - }); - this.setValue(o.value); - }, - _dateCheck: function (date) { - return BI.parseDateTime(date, "%Y-%x-%d %H:%M:%S").print("%Y-%x-%d %H:%M:%S") === date || - BI.parseDateTime(date, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S") === date || - BI.parseDateTime(date, "%Y-%x-%e %H:%M:%S").print("%Y-%x-%e %H:%M:%S") === date || - BI.parseDateTime(date, "%Y-%X-%e %H:%M:%S").print("%Y-%X-%e %H:%M:%S") === date || - - BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") === date || - BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") === date || - BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") === date || - BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") === date; - }, - _checkVoid: function (obj) { - return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; - }, - _autoAppend: function (v, dateObj) { - if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) { - switch (v.length) { - case this._const.yearLength: - if (this._yearCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - case this._const.yearMonthLength: - case this._const.yearFullMonthLength: - var splitMonth = v.split("-")[1]; - if ((BI.isNotNull(splitMonth) && splitMonth.length === 2) || this._monthCheck(v)) { - this.editor.setValue(v + "-"); - } - break; - } - } - }, - - _yearCheck: function (v) { - var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); - return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; - }, - - _monthCheck: function (v) { - var date = BI.parseDateTime(v, "%Y-%X-%d"); - var dateStr = date.print("%Y-%X-%d"); - return (date.getMonth() > 0 && (BI.parseDateTime(v, "%Y-%X").print("%Y-%X") === v || - BI.parseDateTime(v, "%Y-%x").print("%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max; - }, - - _setInnerValue: function (date) { - var dateStr = date.print("%Y-%x-%e %H:%M:%S"); - this.editor.setState(dateStr); - this.editor.setValue(dateStr); - }, - - _getText: function (obj) { - var value = ""; - var endText = ""; - if(BI.isNotNull(obj.year)) { - if(BI.parseInt(obj.year) !== 0) { - value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); - } - if(BI.isNotNull(obj.quarter)) { - if(BI.parseInt(obj.quarter) !== 0) { - value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); - } - if(BI.isNotNull(obj.month)) { - if(BI.parseInt(obj.month) !== 0) { - value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); - } - if(BI.isNotNull(obj.week)) { - if(BI.parseInt(obj.week) !== 0) { - value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); - } - if(BI.isNotNull(obj.day)) { - if(BI.parseInt(obj.day) !== 0) { - value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; - } - if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { - value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - return value + endText; - - function getPositionText (baseText, position) { - switch (position) { - case BI.DynamicDateCard.OFFSET.BEGIN: - return baseText + BI.i18nText("BI-Basic_Begin_Start"); - case BI.DynamicDateCard.OFFSET.END: - return baseText + BI.i18nText("BI-Basic_End_Stop"); - case BI.DynamicDateCard.OFFSET.CURRENT: - default: - return BI.i18nText("BI-Basic_Current_Day"); - } - } - }, - - setValue: function (v) { - var type, value, self = this; - var date = BI.getDate(); - this.storeValue = v; - if (BI.isNotNull(v)) { - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - } - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = this._getText(value); - date = BI.DynamicDateHelper.getCalculation(value); - this._setInnerValue(date, text); - break; - case BI.DynamicDateCombo.Static: - default: - if (BI.isNull(value) || BI.isNull(value.day)) { - this.editor.setState(""); - this.editor.setValue(""); - } else { - var dateStr = BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0, - value.second || 0).print("%Y-%X-%d %H:%M:%S"); - this.editor.setState(dateStr); - this.editor.setValue(dateStr); - } - break; - } - }, - - getKey: function () { - return this.editor.getValue(); - }, - getValue: function () { - return this.storeValue; - }, - - isValid: function () { - return this.editor.isValid(); - } - -}); - -BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; -BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; -BI.DynamicDateTimeTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicDateTimeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DynamicDateTimeTrigger.EVENT_VALID = "EVENT_VALID"; -BI.DynamicDateTimeTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.shortcut("bi.dynamic_date_time_trigger", BI.DynamicDateTimeTrigger);/** - * Created by roy on 15/9/14. - */ -BI.SearchEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.SearchEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-search-editor bi-border", - height: 24, - errorText: "", - watermark: BI.i18nText("BI-Basic_Search"), - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn - }); - }, - _init: function () { - this.options.height -= 2; - BI.SearchEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - watermark: o.watermark, - allowBlank: true, - hgap: 1, - errorText: o.errorText, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker - }); - this.clear = BI.createWidget({ - type: "bi.icon_button", - stopEvent: true, - cls: "circle-close-font" - }); - this.clear.on(BI.IconButton.EVENT_CHANGE, function () { - self.setValue(""); - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STOPEDIT); - self.fireEvent(BI.SearchEditor.EVENT_CLEAR); - }); - BI.createWidget({ - element: this, - type: "bi.htape", - items: [ - { - el: { - type: "bi.center_adapt", - cls: "search-font", - items: [{ - el: { - type: "bi.icon" - } - }] - }, - width: 24 - }, - { - el: self.editor - }, - { - el: this.clear, - width: 24 - } - ] - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.SearchEditor.EVENT_FOCUS); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.SearchEditor.EVENT_BLUR); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.SearchEditor.EVENT_CLICK); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self._checkClear(); - self.fireEvent(BI.SearchEditor.EVENT_CHANGE); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.SearchEditor.EVENT_KEY_DOWN, v); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function () { - self.fireEvent(BI.SearchEditor.EVENT_SPACE); - }); - this.editor.on(BI.Editor.EVENT_BACKSPACE, function () { - self.fireEvent(BI.SearchEditor.EVENT_BACKSPACE); - }); - - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.SearchEditor.EVENT_VALID); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self.fireEvent(BI.SearchEditor.EVENT_ERROR); - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.SearchEditor.EVENT_ENTER); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.SearchEditor.EVENT_RESTRICT); - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self._checkClear(); - self.fireEvent(BI.SearchEditor.EVENT_EMPTY); - }); - this.editor.on(BI.Editor.EVENT_REMOVE, function () { - self.fireEvent(BI.SearchEditor.EVENT_REMOVE); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self.fireEvent(BI.SearchEditor.EVENT_CONFIRM); - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.SearchEditor.EVENT_START); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.SearchEditor.EVENT_PAUSE); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.SearchEditor.EVENT_STOP); - }); - - this.clear.invisible(); - }, - - _checkClear: function () { - if (!this.getValue()) { - this.clear.invisible(); - } else { - this.clear.visible(); - } - }, - - focus: function () { - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - }, - - getValue: function () { - if (this.isValid()) { - var res = this.editor.getValue().match(/[\S]+/g); - return BI.isNull(res) ? "" : res[res.length - 1]; - } - }, - - getKeywords: function () { - var val = this.editor.getValue(); - var keywords = val.match(/[\S]+/g); - if (BI.isEndWithBlank(val)) { - return keywords.concat([" "]); - } - return keywords; - }, - - getLastValidValue: function () { - return this.editor.getLastValidValue(); - }, - - setValue: function (v) { - this.editor.setValue(v); - if (BI.isKey(v)) { - this.clear.visible(); - } - }, - - isEditing: function () { - return this.editor.isEditing(); - }, - - isValid: function () { - return this.editor.isValid(); - } -}); -BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SearchEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.SearchEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.SearchEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.SearchEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.SearchEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.SearchEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE"; -BI.SearchEditor.EVENT_CLEAR = "EVENT_CLEAR"; - -BI.SearchEditor.EVENT_START = "EVENT_START"; -BI.SearchEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SearchEditor.EVENT_STOP = "EVENT_STOP"; -BI.SearchEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.SearchEditor.EVENT_VALID = "EVENT_VALID"; -BI.SearchEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.SearchEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.SearchEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.SearchEditor.EVENT_REMOVE = "EVENT_REMOVE"; -BI.SearchEditor.EVENT_EMPTY = "EVENT_EMPTY"; -BI.shortcut("bi.search_editor", BI.SearchEditor);/** - * 小号搜索框 - * Created by GUY on 2015/9/29. - * @class BI.SmallSearchEditor - * @extends BI.SearchEditor - */ -BI.SmallSearchEditor = BI.inherit(BI.SearchEditor, { - _defaultConfig: function () { - var conf = BI.SmallSearchEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-small-search-editor", - height: 24 - }); - }, - - _init: function () { - BI.SmallSearchEditor.superclass._init.apply(this, arguments); - } -}); -BI.shortcut("bi.small_search_editor", BI.SmallSearchEditor);/** - * guy - * @class BI.TextEditor - * @extends BI.Single - */ -BI.TextEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.TextEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-text-editor bi-border", - hgap: 4, - vgap: 2, - lgap: 0, - rgap: 0, - tgap: 0, - bgap: 0, - validationChecker: BI.emptyFn, - quitChecker: BI.emptyFn, - allowBlank: false, - watermark: "", - errorText: "", - height: 24 - }); - }, - - _init: function () { - BI.TextEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - if (BI.isNumber(o.height)) { - this.element.css({height: o.height - 2}); - } - if (BI.isNumber(o.width)) { - this.element.css({width: o.width - 2}); - } - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height - 2, - hgap: o.hgap, - vgap: o.vgap, - lgap: o.lgap, - rgap: o.rgap, - tgap: o.tgap, - bgap: o.bgap, - value: o.value, - title: o.title, - tipType: o.tipType, - validationChecker: o.validationChecker, - quitChecker: o.quitChecker, - allowBlank: o.allowBlank, - watermark: o.watermark, - errorText: o.errorText - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.editor.on(BI.Editor.EVENT_FOCUS, function () { - self.fireEvent(BI.TextEditor.EVENT_FOCUS); - }); - this.editor.on(BI.Editor.EVENT_BLUR, function () { - self.fireEvent(BI.TextEditor.EVENT_BLUR); - }); - this.editor.on(BI.Editor.EVENT_CLICK, function () { - self.fireEvent(BI.TextEditor.EVENT_CLICK); - }); - this.editor.on(BI.Editor.EVENT_CHANGE, function () { - self.fireEvent(BI.TextEditor.EVENT_CHANGE); - }); - this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { - self.fireEvent(BI.TextEditor.EVENT_KEY_DOWN); - }); - this.editor.on(BI.Editor.EVENT_SPACE, function (v) { - self.fireEvent(BI.TextEditor.EVENT_SPACE); - }); - this.editor.on(BI.Editor.EVENT_BACKSPACE, function (v) { - self.fireEvent(BI.TextEditor.EVENT_BACKSPACE); - }); - - - this.editor.on(BI.Editor.EVENT_VALID, function () { - self.fireEvent(BI.TextEditor.EVENT_VALID); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self.fireEvent(BI.TextEditor.EVENT_CONFIRM); - }); - this.editor.on(BI.Editor.EVENT_REMOVE, function (v) { - self.fireEvent(BI.TextEditor.EVENT_REMOVE); - }); - this.editor.on(BI.Editor.EVENT_START, function () { - self.fireEvent(BI.TextEditor.EVENT_START); - }); - this.editor.on(BI.Editor.EVENT_PAUSE, function () { - self.fireEvent(BI.TextEditor.EVENT_PAUSE); - }); - this.editor.on(BI.Editor.EVENT_STOP, function () { - self.fireEvent(BI.TextEditor.EVENT_STOP); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self.fireEvent(BI.TextEditor.EVENT_ERROR, arguments); - }); - this.editor.on(BI.Editor.EVENT_ENTER, function () { - self.fireEvent(BI.TextEditor.EVENT_ENTER); - }); - this.editor.on(BI.Editor.EVENT_RESTRICT, function () { - self.fireEvent(BI.TextEditor.EVENT_RESTRICT); - }); - this.editor.on(BI.Editor.EVENT_EMPTY, function () { - self.fireEvent(BI.TextEditor.EVENT_EMPTY); - }); - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - element: this, - items: [this.editor] - }); - }, - - focus: function () { - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - }, - - setErrorText: function (text) { - this.editor.setErrorText(text); - }, - - getErrorText: function () { - return this.editor.getErrorText(); - }, - - isValid: function () { - return this.editor.isValid(); - }, - - setValue: function (v) { - this.editor.setValue(v); - }, - - getValue: function () { - return this.editor.getValue(); - } -}); -BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.TextEditor.EVENT_FOCUS = "EVENT_FOCUS"; -BI.TextEditor.EVENT_BLUR = "EVENT_BLUR"; -BI.TextEditor.EVENT_CLICK = "EVENT_CLICK"; -BI.TextEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.TextEditor.EVENT_SPACE = "EVENT_SPACE"; -BI.TextEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE"; - -BI.TextEditor.EVENT_START = "EVENT_START"; -BI.TextEditor.EVENT_PAUSE = "EVENT_PAUSE"; -BI.TextEditor.EVENT_STOP = "EVENT_STOP"; -BI.TextEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.TextEditor.EVENT_VALID = "EVENT_VALID"; -BI.TextEditor.EVENT_ERROR = "EVENT_ERROR"; -BI.TextEditor.EVENT_ENTER = "EVENT_ENTER"; -BI.TextEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; -BI.TextEditor.EVENT_REMOVE = "EVENT_REMOVE"; -BI.TextEditor.EVENT_EMPTY = "EVENT_EMPTY"; - -BI.shortcut("bi.text_editor", BI.TextEditor);/** - * 小号搜索框 - * Created by GUY on 2015/9/29. - * @class BI.SmallTextEditor - * @extends BI.SearchEditor - */ -BI.SmallTextEditor = BI.inherit(BI.TextEditor, { - _defaultConfig: function () { - var conf = BI.SmallTextEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-small-text-editor", - height: 24 - }); - }, - - _init: function () { - BI.SmallTextEditor.superclass._init.apply(this, arguments); - } -}); -BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);/** - * 文件管理控件组 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerButtonGroup - * @extends BI.Widget - */ -BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-button_group", - items: [] - }); - }, - - _init: function () { - BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.button_group = BI.createWidget({ - type: "bi.button_tree", - element: this, - chooseType: BI.Selection.Multi, - items: this._formatItems(o.items), - layouts: [{ - type: "bi.vertical" - }] - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - _formatItems: function (items) { - var self = this, o = this.options; - BI.each(items, function (i, item) { - if (item.children && item.children.length > 0) { - item.type = "bi.file_manager_folder_item"; - } else { - item.type = "bi.file_manager_file_item"; - } - }); - return items; - }, - - setValue: function (v) { - this.button_group.setValue(v); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getNotSelectedValue: function () { - return this.button_group.getNotSelectedValue(); - }, - - getAllLeaves: function () { - return this.button_group.getAllLeaves(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - getSelectedButtons: function () { - return this.button_group.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.button_group.getNotSelectedButtons(); - }, - - populate: function (items) { - this.button_group.populate(this._formatItems(items)); - } -}); -BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManager - * @extends BI.Widget - */ -BI.FileManager = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager", - el: {}, - items: [] - }); - }, - - _init: function () { - BI.FileManager.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tree = new BI.Tree(); - var items = BI.Tree.transformToTreeFormat(o.items); - this.tree.initTree(items); - this.selectedValues = []; - this.nav = BI.createWidget({ - type: "bi.file_manager_nav", - items: BI.deepClone(items) - }); - this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { - if (value == "-1") {// 根节点 - self.populate({children: self.tree.toJSON()}); - } else { - var node = self.tree.search(obj.attr("id")); - self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); - } - self.setValue(self.selectedValues); - }); - this.list = BI.createWidget(o.el, { - type: "bi.file_manager_list", - items: items - }); - this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { - if (type === BI.Events.CHANGE) { - var node = self.tree.search(obj.attr("id")); - self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); - } else if (type === BI.Events.CLICK) { - var values = []; - if (obj instanceof BI.MultiSelectBar) { - var t = self.list.getValue(); - selected = t.type === BI.Selection.All; - values = BI.concat(t.assist, t.value); - } else { - values = obj.getAllLeaves(); - } - BI.each(values, function (i, v) { - if (selected === true) { - self.selectedValues.pushDistinct(v); - } else { - self.selectedValues.remove(v); - } - }); - } - self.setValue(self.selectedValues); - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.list, - left: 0, - right: 0, - top: 0, - bottom: 10 - }, { - el: this.nav, - left: 40, - right: 100, - top: 0 - }] - }); - }, - - setValue: function (value) { - this.selectedValues = value || []; - this.list.setValue(this.selectedValues); - }, - - getValue: function () { - var obj = this.list.getValue(); - var res = obj.type === BI.Selection.All ? obj.assist : obj.value; - res.pushDistinctArray(this.selectedValues); - return res; - }, - - _populate: function (items) { - this.list.populate(items); - }, - - getSelectedValue: function () { - return this.nav.getValue()[0]; - }, - - getSelectedId: function () { - return this.nav.getId()[0]; - }, - - populate: function (node) { - var clone = BI.deepClone(node); - this._populate(node.children); - this.nav.populate(clone); - } -}); -BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; -BI.shortcut("bi.file_manager", BI.FileManager);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerFileItem - * @extends BI.Single - */ -BI.FileManagerFileItem = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", - height: 30 - }); - }, - - _init: function () { - BI.FileManagerFileItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checked = BI.createWidget({ - type: "bi.multi_select_bar", - text: "", - width: 36, - height: o.height - }); - this.checked.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.checked, - width: 36 - }, { - el: { - type: "bi.icon_button", - cls: "create-by-me-file-font" - }, - width: 20 - }, { - el: { - type: "bi.label", - textAlign: "left", - height: o.height, - text: o.text, - value: o.value - } - }] - }); - }, - - getAllLeaves: function () { - return [this.options.value]; - }, - - isSelected: function () { - return this.checked.isSelected(); - }, - - setSelected: function (v) { - this.checked.setSelected(v); - } -}); -BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** - * 文件管理控件 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerFolderItem - * @extends BI.Single - */ -BI.FileManagerFolderItem = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", - height: 30 - }); - }, - - _init: function () { - BI.FileManagerFolderItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checked = BI.createWidget({ - type: "bi.multi_select_bar", - text: "", - width: 36, - height: o.height - }); - this.checked.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button = BI.createWidget({ - type: "bi.text_button", - textAlign: "left", - height: o.height, - text: o.text, - value: o.value - }); - this.button.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); - }); - - this.tree = new BI.Tree(); - this.tree.initTree([{ - id: o.id, - children: o.children - }]); - this.selectValue = []; - - BI.createWidget({ - type: "bi.htape", - element: this, - items: [{ - el: this.checked, - width: 36 - }, { - el: { - type: "bi.icon_button", - cls: "create-by-me-folder-font" - }, - width: 20 - }, { - el: this.button - }] - }); - }, - - setAllSelected: function (v) { - this.checked.setSelected(v); - this.selectValue = []; - }, - - setHalfSelected: function (v) { - this.checked.setHalfSelected(v); - if(!v) { - this.selectValue = []; - } - }, - - setValue: function (v) { - var self = this, o = this.options; - var isHalf = false; - var selectValue = []; - this.tree.traverse(function (node) { - if (node.isLeaf()) { - if (BI.contains(v, node.get("data").value)) { - selectValue.push(node.get("data").value); - } else { - isHalf = true; - } - } - }); - this.setAllSelected(selectValue.length > 0 && !isHalf); - this.setHalfSelected(selectValue.length > 0 && isHalf); - if (this.checked.isHalfSelected()) { - this.selectValue = selectValue; - } - }, - - getAllButtons: function () { - return [this]; - }, - - getAllLeaves: function () { - var o = this.options; - var res = []; - this.tree.traverse(function (node) { - if (node.isLeaf()) { - res.push(node.get("data").value); - } - }); - return res; - }, - - getNotSelectedValue: function () { - var self = this, o = this.options; - var res = []; - var isAllSelected = this.checked.isSelected(); - if (isAllSelected === true) { - return res; - } - var isHalfSelected = this.checked.isHalfSelected(); - this.tree.traverse(function (node) { - if (node.isLeaf()) { - var v = node.get("data").value; - if (isHalfSelected === true) { - if (!BI.contains(self.selectValue, node.get("data").value)) { - res.push(v); - } - } else { - res.push(v); - } - } - }); - return res; - }, - - getValue: function () { - var res = []; - if (this.checked.isSelected()) { - this.tree.traverse(function (node) { - if (node.isLeaf()) { - res.push(node.get("data").value); - } - }); - return res; - } - if (this.checked.isHalfSelected()) { - return this.selectValue; - } - return []; - } -}); -BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** - * 文件管理控件列表 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerList - * @extends BI.Widget - */ -BI.FileManagerList = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-list", - el: {}, - items: [] - }); - }, - - _init: function () { - BI.FileManagerList.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.list = BI.createWidget({ - type: "bi.select_list", - element: this, - items: o.items, - toolbar: { - type: "bi.multi_select_bar", - height: 40, - text: "" - }, - el: { - type: "bi.list_pane", - el: BI.isWidget(o.el) ? o.el : BI.extend({ - type: "bi.file_manager_button_group" - }, o.el) - } - }); - this.list.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - setValue: function (v) { - this.list.setValue({ - value: v - }); - }, - - getValue: function () { - return this.list.getValue(); - }, - - populate: function (items) { - this.list.populate(items); - this.list.setToolBarVisible(true); - } -}); -BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** - * 文件管理导航按钮 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerNavButton - * @extends BI.Widget - */ -BI.FileManagerNavButton = BI.inherit(BI.Widget, { - - _const: { - normal_color: "#ffffff", - select_color: "#eff1f4" - }, - _defaultConfig: function () { - return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-nav-button", - selected: false, - height: 40 - }); - }, - - _init: function () { - BI.FileManagerNavButton.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.button = BI.createWidget({ - type: "bi.text_button", - cls: "file-manager-nav-button-text bi-card", - once: true, - selected: o.selected, - text: o.text, - title: o.text, - value: o.value, - height: o.height, - lgap: 20, - rgap: 10 - }); - this.button.on(BI.Controller.EVENT_CHANGE, function () { - arguments[2] = self; - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - var svg = BI.createWidget({ - type: "bi.svg", - cls: "file-manager-nav-button-triangle", - width: 15, - height: o.height - }); - var path = svg.path("M0,0L15,20L0,40").attr({ - stroke: c.select_color, - fill: o.selected ? c.select_color : c.normal_color - }); - this.button.on(BI.TextButton.EVENT_CHANGE, function () { - if (this.isSelected()) { - path.attr("fill", c.select_color); - } else { - path.attr("fill", c.normal_color); - } - }); - BI.createWidget({ - type: "bi.default", - element: this, - items: [this.button] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: svg, - right: -15, - top: 0, - bottom: 0 - }] - }); - }, - - isSelected: function () { - return this.button.isSelected(); - }, - - setValue: function (v) { - this.button.setValue(v); - }, - - getValue: function () { - return this.button.getValue(); - }, - - populate: function (items) { - - } -}); -BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** - * 文件管理导航 - * - * Created by GUY on 2015/12/11. - * @class BI.FileManagerNav - * @extends BI.Widget - */ -BI.FileManagerNav = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-file-manager-nav bi-border-left", - height: 40, - items: [] - }); - }, - - _init: function () { - BI.FileManagerNav.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tree = new BI.Tree(); - this.refreshTreeData(o.items); - this.tree.getRoot().set("data", { - text: BI.i18nText("BI-Created_By_Me"), - value: BI.FileManagerNav.ROOT_CREATE_BY_ME, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME - }); - this.button_group = BI.createWidget({ - type: "bi.button_group", - element: this, - items: [{ - type: "bi.file_manager_nav_button", - text: BI.i18nText("BI-Created_By_Me"), - selected: true, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME, - value: BI.FileManagerNav.ROOT_CREATE_BY_ME - }], - layouts: [{ - type: "bi.horizontal" - }] - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { - self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments); - }); - }, - - _getAllParents: function (id) { - var node, res = []; - if (!id) { - node = this.tree.getRoot(); - } else { - node = this.tree.search(id); - } - while (node.parent) { - res.push(node); - node = node.parent; - } - res.push(node); - return res.reverse(); - }, - - _formatNodes: function (nodes) { - var res = []; - BI.each(nodes, function (i, node) { - res.push(BI.extend({ - type: "bi.file_manager_nav_button", - id: node.id - }, node.get("data"))); - }); - BI.last(res).selected = true; - return res; - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getId: function () { - var ids = []; - BI.each(this.button_group.getSelectedButtons(), function (i, btn) { - ids.push(btn.attr("id")); - }); - return ids; - }, - - refreshTreeData: function (items) { - this.tree.initTree(BI.Tree.transformToTreeFormat(items)); - this.tree.getRoot().set("data", { - text: BI.i18nText("BI-Created_By_Me"), - value: BI.FileManagerNav.ROOT_CREATE_BY_ME, - id: BI.FileManagerNav.ROOT_CREATE_BY_ME - }); - }, - - populate: function (node) { - var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); - this.button_group.populate(this._formatNodes(parents)); - } -}); -BI.extend(BI.FileManagerNav, { - ROOT_CREATE_BY_ME: "-1" -}); -BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; -BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** - * Created by zcf on 2016/9/26. - */ -BI.IntervalSlider = BI.inherit(BI.Single, { - _constant: { - EDITOR_WIDTH: 58, - EDITOR_R_GAP: 60, - EDITOR_HEIGHT: 30, - SLIDER_WIDTH_HALF: 15, - SLIDER_WIDTH: 30, - SLIDER_HEIGHT: 30, - TRACK_HEIGHT: 24 - }, - - props: { - baseCls: "bi-interval-slider bi-slider-track", - digit: false, - unit: "" - }, - - render: function () { - - var self = this; - var c = this._constant; - this.enable = false; - this.valueOne = ""; - this.valueTwo = ""; - this.calculation = new BI.AccurateCalculationModel(); - - // this.backgroundTrack = BI.createWidget({ - // type: "bi.layout", - // cls: "background-track", - // height: c.TRACK_HEIGHT - // }); - this.grayTrack = BI.createWidget({ - type: "bi.layout", - cls: "gray-track", - height: 6 - }); - this.blueTrack = BI.createWidget({ - type: "bi.layout", - cls: "blue-track bi-high-light-background", - height: 6 - }); - this.track = this._createTrackWrapper(); - - this.labelOne = BI.createWidget({ - type: "bi.sign_text_editor", - cls: "slider-editor-button", - text: this.options.unit, - textAlign: "left", - allowBlank: false, - width: c.EDITOR_WIDTH, - validationChecker: function (v) { - return self._checkValidation(v); - } - }); - this.labelOne.element.hover(function () { - self.labelOne.element.removeClass("bi-border").addClass("bi-border"); - }, function () { - self.labelOne.element.removeClass("bi-border"); - }); - this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () { - var v = BI.parseFloat(this.getValue()); - self.valueOne = v; - var percent = self._getPercentByValue(v); - var significantPercent = BI.parseFloat(percent.toFixed(1));// 分成1000份 - self._setLabelOnePosition(significantPercent); - self._setSliderOnePosition(significantPercent); - self._setBlueTrack(); - self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); - }); - - this.labelTwo = BI.createWidget({ - type: "bi.sign_text_editor", - cls: "slider-editor-button", - text: this.options.unit, - allowBlank: false, - width: c.EDITOR_WIDTH, - textAlign: "right", - validationChecker: function (v) { - return self._checkValidation(v); - } - }); - this.labelTwo.element.hover(function () { - self.labelTwo.element.removeClass("bi-border").addClass("bi-border"); - }, function () { - self.labelTwo.element.removeClass("bi-border"); - }); - this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () { - var v = BI.parseFloat(this.getValue()); - self.valueTwo = v; - var percent = self._getPercentByValue(v); - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setLabelTwoPosition(significantPercent); - self._setSliderTwoPosition(significantPercent); - self._setBlueTrack(); - self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); - }); - - this.sliderOne = BI.createWidget({ - type: "bi.single_slider_button" - }); - this.sliderTwo = BI.createWidget({ - type: "bi.single_slider_button" - }); - this._draggable(this.sliderOne, true); - this._draggable(this.sliderTwo, false); - this._setVisible(false); - - return { - type: "bi.absolute", - element: this, - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.track, - width: "100%", - height: c.TRACK_HEIGHT - }] - }], - hgap: 7, - height: c.TRACK_HEIGHT - }, - top: 23, - left: 0, - width: "100%" - }, - this._createLabelWrapper(), - this._createSliderWrapper() - ] - }; - }, - - _rePosBySizeAfterMove: function (size, isLeft) { - var o = this.options; - var percent = size * 100 / (this._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1)); - var v = this._getValueByPercent(significantPercent); - v = this._assertValue(v); - v = o.digit === false ? v : v.toFixed(o.digit); - if(isLeft) { - this._setLabelOnePosition(significantPercent); - this._setSliderOnePosition(significantPercent); - this.labelOne.setValue(v); - this.valueOne = v; - }else{ - this._setLabelTwoPosition(significantPercent); - this._setSliderTwoPosition(significantPercent); - this.labelTwo.setValue(v); - this.valueTwo = v; - } - this._setBlueTrack(); - }, - - _rePosBySizeAfterStop: function (size, isLeft) { - var percent = size * 100 / (this._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1)); - isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent); - }, - - _draggable: function (widget, isLeft) { - var self = this, o = this.options; - var startDrag = false; - var size = 0, offset = 0, defaultSize = 0; - var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { - if (mouseMoveTracker.isDragging()) { - startDrag = true; - offset += deltaX; - size = optimizeSize(defaultSize + offset); - widget.element.addClass("dragging"); - self._rePosBySizeAfterMove(size, isLeft); - } - }, function () { - if (startDrag === true) { - size = optimizeSize(size); - self._rePosBySizeAfterStop(size, isLeft); - size = 0; - offset = 0; - defaultSize = size; - startDrag = false; - } - widget.element.removeClass("dragging"); - mouseMoveTracker.releaseMouseMoves(); - self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); - }, window); - widget.element.on("mousedown", function (event) { - if(!widget.isEnabled()) { - return; - } - defaultSize = this.offsetLeft; - optimizeSize(defaultSize); - mouseMoveTracker.captureMouseMoves(event); - }); - - function optimizeSize (s) { - return BI.clamp(s, 0, self._getGrayTrackLength()); - } - }, - - _createLabelWrapper: function () { - var c = this._constant; - return { - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.labelOne, - top: 0, - left: "0%" - }] - }, { - type: "bi.absolute", - items: [{ - el: this.labelTwo, - top: 0, - left: "100%" - }] - }], - rgap: c.EDITOR_R_GAP, - height: 70 - }, - top: 0, - left: 0, - width: "100%" - }; - }, - - _createSliderWrapper: function () { - var c = this._constant; - return { - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.sliderOne, - top: 0, - left: "0%" - }] - }, { - type: "bi.absolute", - items: [{ - el: this.sliderTwo, - top: 0, - left: "100%" - }] - }], - hgap: c.SLIDER_WIDTH_HALF, - height: c.SLIDER_HEIGHT - }, - top: 20, - left: 0, - width: "100%" - }; - }, - - _createTrackWrapper: function () { - return BI.createWidget({ - type: "bi.absolute", - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.grayTrack, - top: 0, - left: 0, - width: "100%" - }, { - el: this.blueTrack, - top: 0, - left: 0, - width: "0%" - }] - }], - hgap: 8, - height: 8 - }, - top: 8, - left: 0, - width: "100%" - }] - }); - }, - - _checkValidation: function (v) { - var o = this.options; - var valid = false; - // 像90.这样的既不属于整数又不属于小数,是不合法的值 - var dotText = (v + "").split(".")[1]; - if (BI.isEmptyString(dotText)) { - }else{ - if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) { - if(o.digit === false) { - valid = true; - }else{ - dotText = dotText || ""; - valid = (dotText.length === o.digit); - } - } - } - return valid; - }, - - _checkOverlap: function () { - var labelOneLeft = this.labelOne.element[0].offsetLeft; - var labelTwoLeft = this.labelTwo.element[0].offsetLeft; - if (labelOneLeft <= labelTwoLeft) { - if ((labelTwoLeft - labelOneLeft) < 90) { - this.labelTwo.element.css({top: 40}); - } else { - this.labelTwo.element.css({top: 0}); - } - } else { - if ((labelOneLeft - labelTwoLeft) < 90) { - this.labelTwo.element.css({top: 40}); - } else { - this.labelTwo.element.css({top: 0}); - } - } - }, - - _setLabelOnePosition: function (percent) { - // this.labelOne.element.css({left: percent + "%"}); - // this._checkOverlap(); - }, - - _setLabelTwoPosition: function (percent) { - // this.labelTwo.element.css({left: percent + "%"}); - // this._checkOverlap(); - }, - - _setSliderOnePosition: function (percent) { - this.sliderOne.element.css({left: percent + "%"}); - }, - - _setSliderTwoPosition: function (percent) { - this.sliderTwo.element.css({left: percent + "%"}); - }, - - _setBlueTrackLeft: function (percent) { - this.blueTrack.element.css({left: percent + "%"}); - }, - - _setBlueTrackWidth: function (percent) { - this.blueTrack.element.css({width: percent + "%"}); - }, - - _setBlueTrack: function () { - var percentOne = this._getPercentByValue(this.labelOne.getValue()); - var percentTwo = this._getPercentByValue(this.labelTwo.getValue()); - if (percentOne <= percentTwo) { - this._setBlueTrackLeft(percentOne); - this._setBlueTrackWidth(percentTwo - percentOne); - } else { - this._setBlueTrackLeft(percentTwo); - this._setBlueTrackWidth(percentOne - percentTwo); - } - }, - - _setAllPosition: function (one, two) { - this._setSliderOnePosition(one); - this._setLabelOnePosition(one); - this._setSliderTwoPosition(two); - this._setLabelTwoPosition(two); - this._setBlueTrack(); - }, - - _setVisible: function (visible) { - this.sliderOne.setVisible(visible); - this.sliderTwo.setVisible(visible); - this.labelOne.setVisible(visible); - this.labelTwo.setVisible(visible); - }, - - _setErrorText: function () { - var errorText = BI.i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max); - this.labelOne.setErrorText(errorText); - this.labelTwo.setErrorText(errorText); - }, - - _getGrayTrackLength: function () { - return this.grayTrack.element[0].scrollWidth; - }, - - // 其中取max-min后保留4为有效数字后的值的小数位数为最终value的精度 - _getValueByPercent: function (percent) {// return (((max-min)*percent)/100+min) - var sub = this.calculation.accurateSubtraction(this.max, this.min); - var mul = this.calculation.accurateMultiplication(sub, percent); - var div = this.calculation.accurateDivisionTenExponent(mul, 2); - if(this.precision < 0) { - var value = BI.parseFloat(this.calculation.accurateAddition(div, this.min)); - var reduceValue = Math.round(this.calculation.accurateDivisionTenExponent(value, -this.precision)); - return this.calculation.accurateMultiplication(reduceValue, Math.pow(10, -this.precision)); - } - return BI.parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision)); - - }, - - _getPercentByValue: function (v) { - return (v - this.min) * 100 / (this.max - this.min); - }, - - _setDraggableEnable: function (enable) { - this.sliderOne.setEnable(enable); - this.sliderTwo.setEnable(enable); - }, - - _getPrecision: function () { - // 计算每一份值的精度(最大值和最小值的差值保留4为有效数字后的精度) - // 如果差值的整数位数大于4,toPrecision(4)得到的是科学计数法123456 => 1.235e+5 - // 返回非负值: 保留的小数位数 - // 返回负值: 保留的10^n精度中的n - var sub = this.calculation.accurateSubtraction(this.max, this.min); - var pre = sub.toPrecision(4); - // 科学计数法 - var eIndex = pre.indexOf("e"); - var arr = []; - if(eIndex > -1) { - arr = pre.split("e"); - var decimalPartLength = BI.size(arr[0].split(".")[1]); - var sciencePartLength = BI.parseInt(arr[1].substring(1)); - return decimalPartLength - sciencePartLength; - } - arr = pre.split("."); - return arr.length > 1 ? arr[1].length : 0; - - }, - - _assertValue: function (value) { - if(value <= this.min) { - return this.min; - } - if(value >= this.max) { - return this.max; - } - return value; - }, - - _setEnable: function (b) { - BI.IntervalSlider.superclass._setEnable.apply(this, [b]); - if(b) { - this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); - } else { - this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); - } - }, - - getValue: function () { - if (this.valueOne <= this.valueTwo) { - return {min: this.valueOne, max: this.valueTwo}; - } - return {min: this.valueTwo, max: this.valueOne}; - - }, - - setMinAndMax: function (v) { - var minNumber = BI.parseFloat(v.min); - var maxNumber = BI.parseFloat(v.max); - if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber )) { - this.min = minNumber; - this.max = maxNumber; - this.valueOne = minNumber; - this.valueTwo = maxNumber; - this.precision = this._getPrecision(); - this._setDraggableEnable(true); - } - if (maxNumber === minNumber) { - this._setDraggableEnable(false); - } - }, - - setValue: function (v) { - var o = this.options; - var valueOne = BI.parseFloat(v.min); - var valueTwo = BI.parseFloat(v.max); - valueOne = o.digit === false ? valueOne : valueOne.toFixed(o.digit); - valueTwo = o.digit === false ? valueTwo : valueTwo.toFixed(o.digit); - if (!isNaN(valueOne) && !isNaN(valueTwo)) { - if (this._checkValidation(valueOne)) { - this.valueOne = valueOne; - } - if (this._checkValidation(valueTwo)) { - this.valueTwo = valueTwo; - } - if (valueOne < this.min) { - this.valueOne = this.min; - } - if (valueTwo > this.max) { - this.valueTwo = this.max; - } - } - }, - - reset: function () { - this._setVisible(false); - this.enable = false; - this.valueOne = ""; - this.valueTwo = ""; - this.min = NaN; - this.max = NaN; - this._setBlueTrackWidth(0); - }, - - populate: function () { - if (!isNaN(this.min) && !isNaN(this.max)) { - this.enable = true; - this._setVisible(true); - this._setErrorText(); - if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) { - this.labelOne.setValue(this.valueOne); - this.labelTwo.setValue(this.valueTwo); - this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo)); - } else { - this.labelOne.setValue(this.min); - this.labelTwo.setValue(this.max); - this._setAllPosition(0, 100); - } - } - } -}); -BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.interval_slider", BI.IntervalSlider);/** - * Created by zcf on 2017/3/1. - * 万恶的IEEE-754 - * 使用字符串精确计算含小数加法、减法、乘法和10的指数倍除法,支持负数 - */ -BI.AccurateCalculationModel = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), { - baseCls: "" - }); - }, - - _init: function () { - BI.AccurateCalculationModel.superclass._init.apply(this, arguments); - }, - - _getMagnitude: function (n) { - var magnitude = "1"; - for (var i = 0; i < n; i++) { - magnitude += "0"; - } - return BI.parseInt(magnitude); - }, - - _formatDecimal: function (stringNumber1, stringNumber2) { - if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) { - return; - } - var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength; - if (magnitudeDiff > 0) { - var needAddZero = stringNumber2; - } else { - var needAddZero = stringNumber1; - magnitudeDiff = (0 - magnitudeDiff); - } - for (var i = 0; i < magnitudeDiff; i++) { - if (needAddZero.numDecimal === "0" && i === 0) { - continue; - } - needAddZero.numDecimal += "0"; - } - }, - - _stringNumberFactory: function (num) { - var strNum = num.toString(); - var numStrArray = strNum.split("."); - var numInteger = numStrArray[0]; - if (numStrArray.length === 1) { - var numDecimal = "0"; - var numDecimalLength = 0; - } else { - var numDecimal = numStrArray[1]; - var numDecimalLength = numStrArray[1].length; - } - return { - numInteger: numInteger, - numDecimal: numDecimal, - numDecimalLength: numDecimalLength - }; - }, - - _accurateSubtraction: function (num1, num2) {// num1-num2 && num1>num2 - var stringNumber1 = this._stringNumberFactory(num1); - var stringNumber2 = this._stringNumberFactory(num2); - // 整数部分计算 - var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger); - // 小数部分 - this._formatDecimal(stringNumber1, stringNumber2); - var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2); - - if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) { - var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString(); - var decimalResult = addZero(decimalResultTemp, decimalMaxLength); - } else {// 否则借位 - integerResult--; - var borrow = this._getMagnitude(decimalMaxLength); - var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString(); - var decimalResult = addZero(decimalResultTemp, decimalMaxLength); - } - var result = integerResult + "." + decimalResult; - return BI.parseFloat(result); - - function getDecimalMaxLength (num1, num2) { - if (num1.numDecimal.length >= num2.numDecimal.length) { - return num1.numDecimal.length; - } - return num2.numDecimal.length; - } - - function addZero (resultTemp, length) { - var diff = length - resultTemp.length; - for (var i = 0; i < diff; i++) { - resultTemp = "0" + resultTemp; - } - return resultTemp; - } - }, - - _accurateAddition: function (num1, num2) {// 加法结合律 - var stringNumber1 = this._stringNumberFactory(num1); - var stringNumber2 = this._stringNumberFactory(num2); - // 整数部分计算 - var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger); - // 小数部分 - this._formatDecimal(stringNumber1, stringNumber2); - - var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString(); - - if (decimalResult !== "0") { - if (decimalResult.length <= stringNumber1.numDecimal.length) { - decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length); - } else { - integerResult++;// 进一 - decimalResult = decimalResult.slice(1); - } - } - var result = integerResult + "." + decimalResult; - return BI.parseFloat(result); - - function addZero (resultTemp, length) { - var diff = length - resultTemp.length; - for (var i = 0; i < diff; i++) { - resultTemp = "0" + resultTemp; - } - return resultTemp; - } - }, - - _accurateMultiplication: function (num1, num2) {// 乘法分配律 - var stringNumber1 = this._stringNumberFactory(num1); - var stringNumber2 = this._stringNumberFactory(num2); - // 整数部分计算 - var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger); - // num1的小数和num2的整数 - var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength); - // num1的整数和num2的小数 - var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength); - // 小数*小数 - var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength)); - - return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2); - }, - - _accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0 - var stringNumber = this._stringNumberFactory(num); - if (stringNumber.numInteger.length > n) { - var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n)); - var partDecimalResult = stringNumber.numInteger.slice(-n); - } else { - var integerResult = "0"; - var partDecimalResult = addZero(stringNumber.numInteger, n); - } - var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal; - return BI.parseFloat(result); - - function addZero (resultTemp, length) { - var diff = length - resultTemp.length; - for (var i = 0; i < diff; i++) { - resultTemp = "0" + resultTemp; - } - return resultTemp; - } - }, - - accurateSubtraction: function (num1, num2) { - if (num1 >= 0 && num2 >= 0) { - if (num1 >= num2) { - return this._accurateSubtraction(num1, num2); - } - return -this._accurateSubtraction(num2, num1); - } - if (num1 >= 0 && num2 < 0) { - return this._accurateAddition(num1, -num2); - } - if (num1 < 0 && num2 >= 0) { - return -this._accurateAddition(-num1, num2); - } - if (num1 < 0 && num2 < 0) { - if (num1 >= num2) { - return this._accurateSubtraction(-num2, -num1); - } - return this._accurateSubtraction(-num1, -num2); - } - }, - - accurateAddition: function (num1, num2) { - if (num1 >= 0 && num2 >= 0) { - return this._accurateAddition(num1, num2); - } - if (num1 >= 0 && num2 < 0) { - return this.accurateSubtraction(num1, -num2); - } - if (num1 < 0 && num2 >= 0) { - return this.accurateSubtraction(num2, -num1); - } - if (num1 < 0 && num2 < 0) { - return -this._accurateAddition(-num1, -num2); - } - }, - - accurateMultiplication: function (num1, num2) { - if (num1 >= 0 && num2 >= 0) { - return this._accurateMultiplication(num1, num2); - } - if (num1 >= 0 && num2 < 0) { - return -this._accurateMultiplication(num1, -num2); - } - if (num1 < 0 && num2 >= 0) { - return -this._accurateMultiplication(-num1, num2); - } - if (num1 < 0 && num2 < 0) { - return this._accurateMultiplication(-num1, -num2); - } - }, - - accurateDivisionTenExponent: function (num1, n) { - if (num1 >= 0) { - return this._accurateDivisionTenExponent(num1, n); - } - return -this._accurateDivisionTenExponent(-num1, n); - } -});/** - * 月份下拉框 - * - * Created by GUY on 2015/8/28. - * @class BI.MonthCombo - * @extends BI.Trigger - */ -BI.MonthCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-combo", - behaviors: {}, - height: 24 - }); - }, - _init: function () { - BI.MonthCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.month_trigger", - value: o.value - }); - - this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { - if (self.combo.isViewVisible()) { - return; - } - if (this.getKey() && this.getKey() !== self.storeValue) { - self.setValue(this.getValue()); - } else if (!this.getKey()) { - self.setValue(); - } - self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); - }); - this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () { - self.storeValue = this.getKey(); - }); - this.trigger.on(BI.MonthTrigger.EVENT_START, function () { - self.combo.hideView(); - }); - this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.popup = BI.createWidget({ - type: "bi.month_popup", - behaviors: o.behaviors, - value: o.value - }); - this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - el: this.popup - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW); - }); - }, - - setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - if (BI.isNull(this.popup)) { - return this.options.value || ""; - } else { - return this.popup.getValue() || ""; - } - } -}); - -BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.month_combo", BI.MonthCombo);/** - * 月份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.MonthPopup - * @extends BI.Trigger - */ -BI.MonthPopup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-month-popup", - behaviors: {} - }); - }, - - _init: function () { - BI.MonthPopup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - // 纵向排列月 - var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]; - var items = []; - items.push(month.slice(0, 2)); - items.push(month.slice(2, 4)); - items.push(month.slice(4, 6)); - items.push(month.slice(6, 8)); - items.push(month.slice(8, 10)); - items.push(month.slice(10, 12)); - items = BI.map(items, function (i, item) { - return BI.map(item, function (j, td) { - return { - type: "bi.text_item", - cls: "bi-list-item-active", - textAlign: "center", - whiteSpace: "nowrap", - once: false, - forceSelected: true, - height: 23, - width: 38, - value: td, - text: td - }; - }); - }); - - this.month = BI.createWidget({ - type: "bi.button_group", - element: this, - behaviors: o.behaviors, - items: BI.createItems(items, {}), - layouts: [BI.LogicFactory.createLogic("table", BI.extend({ - dynamic: true - }, { - columns: 2, - rows: 6, - columnSize: [1 / 2, 1 / 2], - rowSize: 25 - })), { - type: "bi.center_adapt", - vgap: 1, - hgap: 2 - }], - value: o.value - }); - - this.month.on(BI.Controller.EVENT_CHANGE, function (type) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.MonthPopup.EVENT_CHANGE); - } - }); - }, - - getValue: function () { - return this.month.getValue()[0]; - }, - - setValue: function (v) { - v = BI.parseInt(v); - this.month.setValue([v]); - } -}); -BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.month_popup", BI.MonthPopup);/** - * 月份trigger - * - * Created by GUY on 2015/8/21. - * @class BI.MonthTrigger - * @extends BI.Trigger - */ -BI.MonthTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2 - }, - - _defaultConfig: function () { - return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-month-trigger bi-border", - height: 24 - }); - }, - _init: function () { - BI.MonthTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - validationChecker: function (v) { - return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12); - }, - quitChecker: function (v) { - return false; - }, - hgap: c.hgap, - vgap: c.vgap, - allowBlank: true, - errorText: BI.i18nText("BI-Month_Trigger_Error_Text") - }); - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.MonthTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.MonthTrigger.EVENT_CHANGE); - }); - this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { - var value = self.editor.getValue(); - if (BI.isNotNull(value)) { - self.editor.setValue(value); - self.editor.setTitle(value); - } - self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM); - }); - this.editor.on(BI.SignEditor.EVENT_SPACE, function () { - if (self.editor.isValid()) { - self.editor.blur(); - } - }); - this.editor.on(BI.SignEditor.EVENT_START, function () { - self.fireEvent(BI.MonthTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.MonthTrigger.EVENT_STOP); - }); - BI.createWidget({ - element: this, - type: "bi.htape", - items: [ - { - el: this.editor - }, { - el: { - type: "bi.text_button", - text: BI.i18nText("BI-Multi_Date_Month"), - baseCls: "bi-trigger-month-text", - width: o.height - }, - width: o.height - }, { - el: { - type: "bi.trigger_icon_button", - width: o.height - }, - width: o.height - } - ] - }); - this.setValue(o.value); - }, - setValue: function (v) { - if(BI.isNotNull(v)) { - this.editor.setState(v + 1); - this.editor.setValue(v + 1); - this.editor.setTitle(v + 1); - return; - } - this.editor.setState(""); - this.editor.setValue(""); - this.editor.setTitle(""); - }, - getKey: function () { - return this.editor.getValue() | 0; - }, - getValue: function () { - return this.editor.getValue() - 1; - } -}); -BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.MonthTrigger.EVENT_START = "EVENT_START"; -BI.MonthTrigger.EVENT_STOP = "EVENT_STOP"; -BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.month_trigger", BI.MonthTrigger);/** - * Created by roy on 15/8/14. - */ -BI.DownListCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multilayer-down-list-combo", - height: 24, - items: [], - adjustLength: 0, - direction: "bottom", - trigger: "click", - container: null, - stopPropagation: false, - el: {} - }); - }, - - _init: function () { - BI.DownListCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.popupview = BI.createWidget({ - type: "bi.multi_layer_down_list_popup", - items: o.items, - chooseType: o.chooseType, - value: o.value - }); - - this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) { - self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); - self.downlistcombo.hideView(); - }); - - this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { - self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); - self.downlistcombo.hideView(); - }); - - - this.downlistcombo = BI.createWidget({ - element: this, - type: "bi.combo", - trigger: o.trigger, - isNeedAdjustWidth: false, - container: o.container, - adjustLength: o.adjustLength, - direction: o.direction, - stopPropagation: o.stopPropagation, - el: BI.createWidget(o.el, { - type: "bi.icon_trigger", - extraCls: o.iconCls ? o.iconCls : "pull-down-font", - width: o.width, - height: o.height - }), - popup: { - el: this.popupview, - stopPropagation: true, - maxHeight: 1000 - } - }); - - this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); - }); - }, - - hideView: function () { - this.downlistcombo.hideView(); - }, - - showView: function () { - this.downlistcombo.showView(); - }, - - populate: function (items) { - this.popupview.populate(items); - }, - - setValue: function (v) { - this.popupview.setValue(v); - }, - getValue: function () { - return this.popupview.getValue(); - } -}); -BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; -BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; - -BI.shortcut("bi.multi_layer_down_list_combo", BI.DownListCombo);/** - * Created by roy on 15/9/8. - * 处理popup中的item分组样式 - * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项 - */ -BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { - constants: { - nextIcon: "pull-right-e-font", - height: 25, - iconHeight: 12, - iconWidth: 12, - hgap: 0, - vgap: 0, - border: 1 - }, - _defaultConfig: function () { - var conf = BI.MultiLayerDownListPopup.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: "bi-down-list-popup", - items: [], - chooseType: BI.Selection.Multi - }); - }, - _init: function () { - BI.MultiLayerDownListPopup.superclass._init.apply(this, arguments); - this.singleValues = []; - this.childValueMap = {}; - this.fatherValueMap = {}; - var self = this, o = this.options, children = this._createPopupItems(o.items); - this.popup = BI.createWidget({ - type: "bi.button_tree", - items: BI.createItems(children, - {}, { - adjustLength: -2 - } - ), - layouts: [{ - type: "bi.vertical", - hgap: this.constants.hgap, - vgap: this.constants.vgap - }], - value: this._digest(o.value), - chooseType: o.chooseType - }); - - this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) { - var changedValue = value; - if (BI.isNotNull(self.childValueMap[value])) { - changedValue = self.childValueMap[value]; - var fatherValue = self.fatherValueMap[value]; - var fatherArrayValue = (fatherValue + "").split("_"); - self.fireEvent(BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, fatherArrayValue.length > 1 ? fatherArrayValue : fatherValue); - } else { - self.fireEvent(BI.MultiLayerDownListPopup.EVENT_CHANGE, changedValue, object); - } - - - if (!self.singleValues.contains(changedValue)) { - var item = self.getValue(); - var result = []; - BI.each(item, function (i, valueObject) { - if (valueObject.value != changedValue) { - result.push(valueObject); - } - }); - self.setValue(result); - } - - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.popup] - }); - - }, - _createPopupItems: function (items) { - var self = this, result = []; - BI.each(items, function (i, it) { - var item_done = { - type: "bi.down_list_group", - items: [] - }; - - BI.each(it, function (i, item) { - if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { - item.type = "bi.combo_group"; - item.cls = "down-list-group"; - item.trigger = "hover"; - item.isNeedAdjustWidth = false; - item.el.title = item.el.title || item.el.text; - item.el.type = "bi.down_list_group_item"; - item.el.logic = { - dynamic: true - }; - item.el.height = self.constants.height; - item.el.iconCls2 = self.constants.nextIcon; - item.popup = { - lgap: 4, - el: { - type: "bi.button_tree", - chooseType: 0, - layouts: [{ - type: "bi.vertical" - }] - - } - }; - item.el.childValues = []; - BI.each(item.children, function (i, child) { - child = child.el ? BI.extend(child.el, {children: child.children}) : child; - var fatherValue = BI.deepClone(item.el.value); - var childValue = BI.deepClone(child.value); - self.singleValues.push(child.value); - child.type = "bi.down_list_item"; - child.extraCls = " child-down-list-item"; - child.title = child.title || child.text; - child.textRgap = 10; - child.isNeedAdjustWidth = false; - child.logic = { - dynamic: true - }; - child.father = fatherValue; - self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; - self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; - child.value = self._createChildValue(fatherValue, childValue); - item.el.childValues.push(child.value); - if (BI.isNotEmptyArray(child.children)) { - child.type = "bi.down_list_group_item"; - self._createChildren(child); - child.height = self.constants.height; - child.iconCls2 = self.constants.nextIcon; - item.el.childValues = BI.concat(item.el.childValues, child.childValues); - } - }); - } else { - item.type = "bi.down_list_item"; - item.title = item.title || item.text; - item.textRgap = 10; - item.isNeedAdjustWidth = false; - item.logic = { - dynamic: true - }; - } - var el_done = {}; - el_done.el = item; - item_done.items.push(el_done); - }); - if (self._isGroup(item_done.items)) { - BI.each(item_done.items, function (i, item) { - self.singleValues.push(item.el.value); - }); - } - - result.push(item_done); - if (self._needSpliter(i, items.length)) { - var spliter_container = BI.createWidget({ - type: "bi.vertical", - items: [{ - el: { - type: "bi.layout", - cls: "bi-down-list-spliter bi-border-top cursor-pointer", - height: 0 - } - - }], - cls: "bi-down-list-spliter-container cursor-pointer", - lgap: 10, - rgap: 0 - }); - result.push(spliter_container); - } - }); - return result; - }, - - _createChildren: function (child) { - var self = this; - child.childValues = []; - BI.each(child.children, function (i, c) { - var fatherValue = BI.deepClone(child.value); - var childValue = BI.deepClone(c.value); - c.type = "bi.down_list_item"; - c.title = c.title || c.text; - c.textRgap = 10; - c.isNeedAdjustWidth = false; - c.logic = { - dynamic: true - }; - c.father = fatherValue; - self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; - self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; - c.value = self._createChildValue(fatherValue, childValue); - child.childValues.push(c.value); - }); - }, - - _isGroup: function (i) { - return i.length > 1; - }, - - _needSpliter: function (i, itemLength) { - return i < itemLength - 1; - }, - - _createChildValue: function (fatherValue, childValue) { - var fValue = fatherValue; - if(BI.isArray(fatherValue)) { - fValue = fatherValue.join("_"); - } - return fValue + "_" + childValue; - }, - - _digest: function (valueItem) { - var self = this; - var valueArray = []; - BI.each(valueItem, function (i, item) { - var value; - if (BI.isNotNull(item.childValue)) { - value = self._createChildValue(item.value, item.childValue); - } else { - value = item.value; - } - valueArray.push(value); - } - ); - return valueArray; - }, - - _checkValues: function (values) { - var self = this, o = this.options; - var value = []; - BI.each(o.items, function (idx, itemGroup) { - BI.each(itemGroup, function (id, item) { - if(BI.isNotNull(item.children)) { - var childValues = getChildrenValue(item); - var v = joinValue(childValues, values[idx]); - if(BI.isNotEmptyString(v)) { - value.push(v); - } - }else{ - if(item.value === values[idx][0]) { - value.push(values[idx][0]); - } - } - }); - }); - return value; - - function joinValue (sources, targets) { - var value = ""; - BI.some(sources, function (idx, s) { - return BI.some(targets, function (id, t) { - if(s === t) { - value = s; - return true; - } - }); - }); - return value; - } - - function getChildrenValue (item) { - var children = []; - if(BI.isNotNull(item.children)) { - BI.each(item.children, function (idx, child) { - children = BI.concat(children, getChildrenValue(child)); - }); - } else { - children.push(item.value); - } - return children; - } - }, - - populate: function (items) { - BI.MultiLayerDownListPopup.superclass.populate.apply(this, arguments); - var self = this; - self.childValueMap = {}; - self.fatherValueMap = {}; - self.singleValues = []; - var children = self._createPopupItems(items); - var popupItem = BI.createItems(children, - {}, { - adjustLength: -2 - } - ); - self.popup.populate(popupItem); - }, - - setValue: function (valueItem) { - this.popup.setValue(this._digest(valueItem)); - }, - - _getValue: function () { - var v = []; - BI.each(this.popup.getAllButtons(), function (i, item) { - i % 2 === 0 && v.push(item.getValue()); - }); - return v; - }, - - getValue: function () { - var self = this, result = []; - var values = this._checkValues(this._getValue()); - BI.each(values, function (i, value) { - var valueItem = {}; - if (BI.isNotNull(self.childValueMap[value])) { - var fartherValue = self.fatherValueMap[value]; - valueItem.childValue = self.childValueMap[value]; - var fatherArrayValue = (fartherValue + "").split("_"); - valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue; - } else { - valueItem.value = value; - } - result.push(valueItem); - }); - return result; - } - - -}); - -BI.MultiLayerDownListPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; -BI.shortcut("bi.multi_layer_down_list_popup", BI.MultiLayerDownListPopup);/** - * @class BI.MultiLayerSelectTreeCombo - * @extends BI.Widget - */ -BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multilayer_select_tree-combo", - isDefaultInit: false, - height: 24, - text: "", - items: [], - value: "" - }); - }, - - _init: function () { - BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.single_tree_trigger", - text: o.text, - height: o.height, - items: o.items, - value: o.value - }); - - this.popup = BI.createWidget({ - type: "bi.multilayer_select_tree_popup", - isDefaultInit: o.isDefaultInit, - items: o.items, - value: o.value - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup - } - }); - - this.combo.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE); - }); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - populate: function (items) { - this.combo.populate(items); - } -}); -BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/** - * guy - * 二级树 - * @class BI.MultiLayerSelectLevelTree - * @extends BI.Select - */ -BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multilayer-select-level-tree", - isDefaultInit: false, - items: [], - itemsCreator: BI.emptyFn, - value: "" - }); - }, - - _init: function () { - BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); - - this.initTree(this.options.items); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {}; - node.layer = layer; - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.multilayer_select_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.multilayer_select_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - - self._formatItems(node.children, layer + 1); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; - } - BI.defaults(node, extend); - } - }); - return nodes; - }, - - _assertId: function (sNodes) { - BI.each(sNodes, function (i, node) { - node.id = node.id || BI.UUID(); - }); - }, - - // 构造树结构, - initTree: function (nodes) { - var self = this, o = this.options; - this.empty(); - this._assertId(nodes); - this.tree = BI.createWidget({ - type: "bi.custom_tree", - cls: "tree-view display-table", - expander: { - type: "bi.select_tree_expander", - isDefaultInit: o.isDefaultInit, - el: {}, - popup: { - type: "bi.custom_tree" - } - }, - - items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), - itemsCreator: o.itemsCreator, - value: o.value, - - el: { - type: "bi.button_tree", - chooseType: BI.Selection.Single, - layouts: [{ - type: "bi.vertical" - }] - } - }); - this.tree.on(BI.Controller.EVENT_CHANGE, function (type) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments); - } - }); - - BI.createWidget({ - type: "bi.adaptive", - element: this, - scrollable: true, - items: [this.tree] - }) - }, - - populate: function (nodes) { - this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); - }, - - setValue: function (v) { - this.tree.setValue(v); - }, - - getValue: function () { - return BI.uniq(this.tree.getValue()); - }, - - getAllLeaves: function () { - return this.tree.getAllLeaves(); - }, - - getNodeById: function (id) { - return this.tree.getNodeById(id); - }, - - getNodeByValue: function (id) { - return this.tree.getNodeByValue(id); - } -}); -BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/** - * Created by GUY on 2016/1/26. - * - * @class BI.MultiLayerSelectTreePopup - * @extends BI.Pane - */ - -BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multilayer-select-tree-popup", - tipText: BI.i18nText("BI-No_Selected_Item"), - isDefaultInit: false, - itemsCreator: BI.emptyFn, - items: [], - value: "" - }); - }, - - _init: function () { - BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.tree = BI.createWidget({ - type: "bi.multilayer_select_level_tree", - isDefaultInit: o.isDefaultInit, - items: o.items, - value: o.value, - itemsCreator: o.itemsCreator - }); - - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - scrollable: true, - element: this, - vgap: 5, - items: [this.tree] - }); - - this.tree.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE); - }); - - this.check(); - }, - - getValue: function () { - return this.tree.getValue(); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.tree.setValue(v); - }, - - populate: function (items) { - BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments); - this.tree.populate(items); - } -}); - -BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/** - * 加号表示的组节点 - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSelectTreeFirstPlusGroupNode - * @extends BI.NodeButton - */ -BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active", - layer: 0, // 第几层级 - id: "", - pId: "", - readonly: true, - open: false, - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ - type: "bi.select_tree_first_plus_group_node", - cls: "bi-list-item-none", - stopPropagation: true, - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - open: o.open, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - self.setSelected(self.isSelected()); - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - isOnce: function () { - return true; - }, - - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, - - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, - - isSelected: function () { - return this.node.isSelected(); - }, - - setSelected: function (b) { - BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments); - this.node.setSelected(b); - }, - - doClick: function () { - BI.NodeButton.superclass.doClick.apply(this, arguments); - this.node.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); - this.node.setOpened(v); - } -}); - -BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/** - * 加号表示的组节点 - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSelectTreeLastPlusGroupNode - * @extends BI.NodeButton - */ -BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active", - layer: 0, // 第几层级 - id: "", - pId: "", - readonly: true, - open: false, - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ - type: "bi.select_tree_last_plus_group_node", - cls: "bi-list-item-none", - stopPropagation: true, - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - open: o.open, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - self.setSelected(self.isSelected()); - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, - - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, - - isSelected: function () { - return this.node.isSelected(); - }, - - setSelected: function (b) { - BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments); - this.node.setSelected(b); - }, - - doClick: function () { - BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); - this.node.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); - this.node.setOpened(v); - } -}); - -BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/** - * 加号表示的组节点 - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSelectTreeMidPlusGroupNode - * @extends BI.NodeButton - */ -BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active", - layer: 0, // 第几层级 - id: "", - pId: "", - readonly: true, - open: false, - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ - type: "bi.select_tree_mid_plus_group_node", - cls: "bi-list-item-none", - stopPropagation: true, - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - open: o.open, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py - }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - self.setSelected(self.isSelected()); - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, - - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, - - isSelected: function () { - return this.node.isSelected(); - }, - - setSelected: function (b) { - BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments); - this.node.setSelected(b); - }, - - doClick: function () { - BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); - this.node.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); - this.node.setOpened(v); - } -}); - -BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/** - * 多层级下拉单选树 - * Created by GUY on 2016/1/26. - * - * @class BI.MultiLayerSingleTreeCombo - * @extends BI.Widget - */ -BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multilayer-singletree-combo", - isDefaultInit: false, - height: 24, - text: "", - itemsCreator: BI.emptyFn, - items: [], - value: "" - }); - }, - - _init: function () { - BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.single_tree_trigger", - text: o.text, - height: o.height, - items: o.items, - value: o.value - }); - - this.popup = BI.createWidget({ - type: "bi.multilayer_single_tree_popup", - isDefaultInit: o.isDefaultInit, - itemsCreator: o.itemsCreator, - items: o.items, - value: o.value - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup - } - }); - - this.combo.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE); - }); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - populate: function (items) { - this.combo.populate(items); - } -}); - -BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/** - * guy - * 二级树 - * @class BI.MultiLayerSingleLevelTree - * @extends BI.Single - */ -BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multilayer-single-level-tree", - isDefaultInit: false, - items: [], - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); - - this.initTree(this.options.items); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {}; - node.layer = layer; - if (!BI.isKey(node.id)) { - node.id = BI.UUID(); - } - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.multilayer_single_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.multilayer_single_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - - self._formatItems(node.children, layer + 1); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; - break; - default : - extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; - } - BI.defaults(node, extend); - } - }); - return nodes; - }, - - _assertId: function (sNodes) { - BI.each(sNodes, function (i, node) { - node.id = node.id || BI.UUID(); - }); - }, - - // 构造树结构, - initTree: function (nodes) { - var self = this, o = this.options; - this.empty(); - this._assertId(nodes); - this.tree = BI.createWidget({ - type: "bi.custom_tree", - cls: "tree-view display-table", - expander: { - isDefaultInit: o.isDefaultInit, - el: {}, - popup: { - type: "bi.custom_tree" - } - }, - - items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), - value: o.value, - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (items) { - callback(BI.Tree.transformToTreeFormat(items), 0); - }); - }, - - el: { - type: "bi.button_tree", - chooseType: BI.Selection.Single, - layouts: [{ - type: "bi.vertical" - }] - } - }); - this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v); - } - }); - - BI.createWidget({ - type: "bi.adaptive", - element: this, - scrollable: true, - items: [this.tree] - }) - }, - - populate: function (nodes) { - this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); - }, - - setValue: function (v) { - this.tree.setValue(v); - }, - - getValue: function () { - return BI.filter(BI.uniq(this.tree.getValue()), function (idx, value) { - return BI.isNotNull(value); - }); - - }, - - getAllLeaves: function () { - return this.tree.getAllLeaves(); - }, - - getNodeById: function (id) { - return this.tree.getNodeById(id); - }, - - getNodeByValue: function (id) { - return this.tree.getNodeByValue(id); - } -}); -BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree); -/** - * Created by GUY on 2016/1/26. - * - * @class BI.MultiLayerSingleTreePopup - * @extends BI.Pane - */ - -BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multilayer-singletree-popup", - tipText: BI.i18nText("BI-No_Selected_Item"), - isDefaultInit: false, - itemsCreator: BI.emptyFn, - items: [] - }); - }, - - _init: function () { - BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.tree = BI.createWidget({ - type: "bi.multilayer_single_level_tree", - isDefaultInit: o.isDefaultInit, - items: o.items, - itemsCreator: o.itemsCreator, - value: o.value - }); - - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - scrollable: true, - element: this, - vgap: 5, - items: [this.tree] - }); - - this.tree.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE); - }); - - this.check(); - }, - - getValue: function () { - return this.tree.getValue(); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.tree.setValue(v); - }, - - populate: function (items) { - BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments); - this.tree.populate(items); - } -}); - -BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/** - * 加号表示的组节点 - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSingleTreeFirstPlusGroupNode - * @extends BI.NodeButton - */ -BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item", - layer: 0, // 第几层级 - id: "", - pId: "", - open: false, - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ - type: "bi.first_plus_group_node", - cls: "bi-list-item-none", - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - open: o.open, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - keyword: o.keyword - }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) {// 本身实现click功能 - return; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, - - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, - - doClick: function () { - BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments); - this.node.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.node)) { - this.node.setOpened(v); - } - } -}); - -BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/** - * 加号表示的组节点 - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSingleTreeLastPlusGroupNode - * @extends BI.NodeButton - */ -BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item", - layer: 0, // 第几层级 - id: "", - pId: "", - open: false, - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ - type: "bi.last_plus_group_node", - cls: "bi-list-item-none", - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - open: o.open, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - keyword: o.keyword - }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) {// 本身实现click功能 - return; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, - - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, - - doClick: function () { - BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); - this.node.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.node)) { - this.node.setOpened(v); - } - } -}); - -BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/** - * 加号表示的组节点 - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSingleTreeMidPlusGroupNode - * @extends BI.NodeButton - */ -BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item", - layer: 0, // 第几层级 - id: "", - pId: "", - open: false, - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.node = BI.createWidget({ - type: "bi.mid_plus_group_node", - cls: "bi-list-item-none", - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - open: o.open, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - keyword: o.keyword - }); - this.node.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) {// 本身实现click功能 - return; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.node); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doRedMark: function () { - this.node.doRedMark.apply(this.node, arguments); - }, - - unRedMark: function () { - this.node.unRedMark.apply(this.node, arguments); - }, - - doClick: function () { - BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); - this.node.setSelected(this.isSelected()); - }, - - setOpened: function (v) { - BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.node)) { - this.node.setOpened(v); - } - } -}); - -BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSingleTreeFirstTreeLeafItem - * @extends BI.BasicButton - */ -BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active", - logic: { - dynamic: false - }, - layer: 0, - id: "", - pId: "", - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.item = BI.createWidget({ - type: "bi.first_tree_leaf_item", - cls: "bi-list-item-none", - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - keyword: o.keyword - }); - this.item.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) {// 本身实现click功能 - return; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doHighLight: function () { - this.item.doHighLight.apply(this.item, arguments); - }, - - unHighLight: function () { - this.item.unHighLight.apply(this.item, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments); - this.item.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.item.setSelected(v); - } -}); - -BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/** - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSingleTreeLastTreeLeafItem - * @extends BI.BasicButton - */ -BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active", - logic: { - dynamic: false - }, - layer: 0, - id: "", - pId: "", - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.item = BI.createWidget({ - type: "bi.last_tree_leaf_item", - cls: "bi-list-item-none", - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - keyword: o.keyword - }); - this.item.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) {// 本身实现click功能 - return; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doHighLight: function () { - this.item.doHighLight.apply(this.item, arguments); - }, - - unHighLight: function () { - this.item.unHighLight.apply(this.item, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments); - this.item.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.item.setSelected(v); - } -}); - -BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/** - * - * Created by GUY on 2016/1/27. - * @class BI.MultiLayerSingleTreeMidTreeLeafItem - * @extends BI.BasicButton - */ -BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active", - logic: { - dynamic: false - }, - layer: 0, - id: "", - pId: "", - height: 24 - }); - }, - _init: function () { - BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.item = BI.createWidget({ - type: "bi.mid_tree_leaf_item", - cls: "bi-list-item-none", - logic: { - dynamic: true - }, - id: o.id, - pId: o.pId, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - py: o.py, - keyword: o.keyword - }); - this.item.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) {// 本身实现click功能 - return; - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - var items = []; - BI.count(0, o.layer, function () { - items.push({ - type: "bi.layout", - cls: "base-line-conn-background", - width: 12, - height: o.height - }); - }); - items.push(this.item); - BI.createWidget({ - type: "bi.td", - element: this, - columnSize: BI.makeArray(o.layer, 12), - items: [items] - }); - }, - - doHighLight: function () { - this.item.doHighLight.apply(this.item, arguments); - }, - - unHighLight: function () { - this.item.unHighLight.apply(this.item, arguments); - }, - - getId: function () { - return this.options.id; - }, - - getPId: function () { - return this.options.pId; - }, - - doClick: function () { - BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments); - this.item.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments); - this.item.setSelected(v); - } -}); - -BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/** - * - * @class BI.MultiSelectCheckPane - * @extends BI.Widget - */ -BI.MultiSelectCheckPane = BI.inherit(BI.Widget, { - - constants: { - height: 12, - lgap: 10, - tgap: 10, - bgap: 5 - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-check-pane bi-background", - items: [], - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - onClickContinueSelect: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectCheckPane.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - - this.storeValue = opts.value || {}; - this.display = BI.createWidget({ - type: "bi.display_selected_list", - items: opts.items, - itemsCreator: function (op, callback) { - op = BI.extend(op || {}, { - selectedValues: self.storeValue.value - }); - if (self.storeValue.type === BI.Selection.Multi) { - callback({ - items: BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt - }; - }) - }); - return; - } - opts.itemsCreator(op, callback); - } - }); - - this.continueSelect = BI.createWidget({ - type: "bi.text_button", - text: BI.i18nText("BI-Continue_Select"), - cls: "multi-select-check-selected bi-high-light" - }); - - this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { - opts.onClickContinueSelect(); - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - height: this.constants.height, - el: { - type: "bi.vertical_adapt", - cls: "multi-select-continue-select", - items: [ - { - el: { - type: "bi.label", - text: BI.i18nText("BI-Selected_Data") - }, - lgap: this.constants.lgap - }, - { - el: this.continueSelect, - lgap: this.constants.lgap - }] - }, - tgap: this.constants.tgap - }, { - height: "fill", - el: this.display, - tgap: this.constants.bgap - }] - }); - }, - - setValue: function (v) { - this.storeValue = v || {}; - }, - - empty: function () { - this.display.empty(); - }, - - populate: function () { - this.display.populate.apply(this.display, arguments); - } -}); - -BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/** - * - * - * 查看已选弹出层的展示面板 - * @class BI.DisplaySelectedList - * @extends BI.Widget - */ -BI.DisplaySelectedList = BI.inherit(BI.Pane, { - - constants: { - height: 24, - lgap: 10 - }, - - _defaultConfig: function () { - return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-display-list", - itemsCreator: BI.emptyFn, - items: [] - }); - }, - - _init: function () { - BI.DisplaySelectedList.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - - this.hasNext = false; - - this.button_group = BI.createWidget({ - type: "bi.list_pane", - element: this, - el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - items: this._createItems(opts.items), - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - layouts: [{ - type: "bi.vertical", - lgap: 10 - }] - }, - itemsCreator: function (options, callback) { - - opts.itemsCreator(options, function (ob) { - self.hasNext = !!ob.hasNext; - callback(self._createItems(ob.items)); - }); - }, - hasNext: function () { - return self.hasNext; - } - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.icon_text_item", - cls: "cursor-default check-font icon-size-12 display-list-item bi-tips", - once: true, - invalid: true, - selected: true, - height: this.constants.height, - logic: { - dynamic: true - } - }); - }, - - empty: function () { - this.button_group.empty(); - }, - - populate: function (items) { - if (arguments.length === 0) { - this.button_group.populate(); - } else { - this.button_group.populate(this._createItems(items)); - } - } -}); - -BI.shortcut("bi.display_selected_list", BI.DisplaySelectedList);/** - * - * @class BI.MultiSelectCombo - * @extends BI.Single - */ -BI.MultiSelectCombo = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-combo", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - height: 24 - }); - }, - - _init: function () { - BI.MultiSelectCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); - }; - this.storeValue = o.value || {}; - - this._assertValue(this.storeValue); - - // 标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - text: o.text, - // adapter: this.popup, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: 26 - } - }, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keywords)) { - // 预防trigger内部把当前的storeValue改掉 - self.trigger.setValue(BI.deepClone(self.getValue())); - } - callback.apply(self, arguments); - }); - }, - value: this.storeValue - }); - - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self._setStartValue(""); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self._setStartValue(""); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - self.combo.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); - self._setStartValue(""); - }); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(""); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } - }); - - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - }); - } else { - self._join(this.getValue(), function () { - assertShowValue(); - }); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - el: this.trigger, - adjustLength: 1, - popup: { - type: "bi.multi_select_popup_view", - ref: function () { - self.popup = this; - self.trigger.setAdapter(this); - }, - listeners: [{ - eventName: BI.MultiSelectPopupView.EVENT_CHANGE, - action: function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - }); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, - action: function () { - self._defaultState(); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, - action: function () { - self.setValue(); - self._defaultState(); - } - }], - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - onLoaded: function () { - BI.nextTick(function () { - self.combo.adjustWidth(); - self.combo.adjustHeight(); - self.trigger.getCounter().adjustView(); - self.trigger.getSearcher().adjustView(); - }); - } - }, - value: o.value, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - } - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self.element.removeClass("combo-show"); - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.element.removeClass("combo-show").addClass("combo-show"); - this.setValue(self.storeValue); - BI.nextTick(function () { - self.populate(); - }); - }); - // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 - this.wants2Quit = false; - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - // important:关闭弹出时又可能没有退出编辑状态 - self.trigger.stopEditing(); - if (self.requesting === true) { - self.wants2Quit = true; - } else { - self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); - } - }); - - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.trigger.getCounter().hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }] - }); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - this.combo.hideView(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - this.requesting = true; - o.itemsCreator({ - type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, - keywords: keywords - }, function (ob) { - var values = BI.map(ob.items, "value"); - digest(values); - }); - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); - } - }); - self._adjust(callback); - } - }, - - _joinAll: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this.requesting = true; - o.itemsCreator({ - type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, - keywords: [this.trigger.getKey()] - }, function (ob) { - var items = BI.map(ob.items, "value"); - if (self.storeValue.type === res.type) { - var change = false; - var map = self._makeMap(self.storeValue.value); - BI.each(items, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (self.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - var selectedMap = self._makeMap(self.storeValue.value); - var notSelectedMap = self._makeMap(res.value); - var newItems = []; - BI.each(items, function (i, item) { - if (BI.isNotNull(selectedMap[items[i]])) { - delete selectedMap[items[i]]; - } - if (BI.isNull(notSelectedMap[items[i]])) { - newItems.push(item); - } - }); - self.storeValue.value = newItems.concat(BI.values(selectedMap)); - self._adjust(callback); - }); - }, - - _adjust: function (callback) { - var self = this, o = this.options; - if (!this._count) { - o.itemsCreator({ - type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH - }, function (res) { - self._count = res.count; - adjust(); - callback(); - }); - } else { - adjust(); - callback(); - - } - - function adjust () { - if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.Multi, - value: [] - }; - } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.All, - value: [] - }; - } - if (self.wants2Quit === true) { - self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); - self.wants2Quit = false; - } - self.requesting = false; - } - }, - - _join: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this._assertValue(this.storeValue); - if (this.storeValue.type === res.type) { - var map = this._makeMap(this.storeValue.value); - BI.each(res.value, function (i, v) { - if (!map[v]) { - self.storeValue.value.push(v); - map[v] = v; - } - }); - var change = false; - BI.each(res.assist, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (this.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - this._joinAll(res, callback); - }, - - _setStartValue: function (value) { - this._startValue = value; - this.popup.setStartValue(value); - }, - - setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.combo.setValue(this.storeValue); - }, - - getValue: function () { - return BI.deepClone(this.storeValue); - }, - - populate: function () { - this._count = null; - this.combo.populate.apply(this.combo, arguments); - } -}); - -BI.extend(BI.MultiSelectCombo, { - REQ_GET_DATA_LENGTH: 1, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut("bi.multi_select_combo", BI.MultiSelectCombo);/** - * - * @class BI.MultiSelectInsertCombo - * @extends BI.Single - */ -BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectInsertCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-insert-combo", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - height: 24 - }); - }, - - _init: function () { - BI.MultiSelectInsertCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); - }; - this.storeValue = o.value || {}; - // 标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_insert_trigger", - height: o.height, - text: o.text, - // adapter: this.popup, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: 26 - } - }, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keywords)) { - // 预防trigger内部把当前的storeValue改掉 - self.trigger.setValue(BI.deepClone(self.getValue())); - } - callback.apply(self, arguments); - }); - }, - value: o.value - }); - - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_START, function () { - self._setStartValue(""); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_STOP, function () { - self._setStartValue(""); - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - self._addItem(assertShowValue); - } - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () { - if (!this.getSearcher().hasMatched()) { - self._addItem(assertShowValue); - self.trigger.stopEditing(); - } - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(""); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } - }); - - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - }); - } else { - self._join(this.getValue(), function () { - assertShowValue(); - }); - } - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - el: this.trigger, - adjustLength: 1, - popup: { - type: "bi.multi_select_popup_view", - ref: function () { - self.popup = this; - self.trigger.setAdapter(this); - }, - listeners: [{ - eventName: BI.MultiSelectPopupView.EVENT_CHANGE, - action: function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - }); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, - action: function () { - self._defaultState(); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, - action: function () { - self.setValue(); - self._defaultState(); - } - }], - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - onLoaded: function () { - BI.nextTick(function () { - self.combo.adjustWidth(); - self.combo.adjustHeight(); - self.trigger.getCounter().adjustView(); - self.trigger.getSearcher().adjustView(); - }); - } - }, - value: o.value, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - } - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self.element.removeClass("combo-show"); - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.element.removeClass("combo-show").addClass("combo-show"); - this.setValue(self.storeValue); - BI.nextTick(function () { - self.populate(); - }); - }); - // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 - this.wants2Quit = false; - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - // important:关闭弹出时又可能没有退出编辑状态 - self.trigger.stopEditing(); - if (self.requesting === true) { - self.wants2Quit = true; - } else { - self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM); - } - }); - - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.trigger.getCounter().hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }] - }); - }, - - _addItem: function (assertShowValue) { - var self = this; - var keyword = this.trigger.getSearcher().getKeyword(); - this._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - // 如果在不选的状态下直接把该值添加进来 - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - self.combo.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); - self._setStartValue(""); - }); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - this.combo.hideView(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - this.requesting = true; - o.itemsCreator({ - type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA, - keywords: keywords - }, function (ob) { - var values = BI.map(ob.items, "value"); - digest(values); - }); - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); - } - }); - self._adjust(callback); - } - }, - - _joinAll: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this.requesting = true; - o.itemsCreator({ - type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA, - keywords: [this.trigger.getKey()] - }, function (ob) { - var items = BI.map(ob.items, "value"); - if (self.storeValue.type === res.type) { - var change = false; - var map = self._makeMap(self.storeValue.value); - BI.each(items, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (self.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - var selectedMap = self._makeMap(self.storeValue.value); - var notSelectedMap = self._makeMap(res.value); - var newItems = []; - BI.each(items, function (i, item) { - if (BI.isNotNull(selectedMap[items[i]])) { - delete selectedMap[items[i]]; - } - if (BI.isNull(notSelectedMap[items[i]])) { - newItems.push(item); - } - }); - self.storeValue.value = newItems.concat(BI.values(selectedMap)); - self._adjust(callback); - }); - }, - - _adjust: function (callback) { - var self = this, o = this.options; - adjust(); - callback(); - function adjust () { - if (self.wants2Quit === true) { - self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM); - self.wants2Quit = false; - } - self.requesting = false; - } - }, - - _join: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this._assertValue(this.storeValue); - if (this.storeValue.type === res.type) { - var map = this._makeMap(this.storeValue.value); - BI.each(res.value, function (i, v) { - if (!map[v]) { - self.storeValue.value.push(v); - map[v] = v; - } - }); - var change = false; - BI.each(res.assist, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (this.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - this._joinAll(res, callback); - }, - - _setStartValue: function (value) { - this._startValue = value; - this.popup.setStartValue(value); - }, - - setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.combo.setValue(this.storeValue); - }, - - getValue: function () { - return BI.deepClone(this.storeValue); - }, - - populate: function () { - this.combo.populate.apply(this.combo, arguments); - } -}); - -BI.extend(BI.MultiSelectInsertCombo, { - REQ_GET_DATA_LENGTH: 1, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut("bi.multi_select_insert_combo", BI.MultiSelectInsertCombo);/** - * - * @class BI.MultiSelectInsertCombo - * @extends BI.Single - */ -BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectInsertNoBarCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-insert-combo", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - height: 24 - }); - }, - - _init: function () { - BI.MultiSelectInsertNoBarCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); - }; - this.storeValue = { - type: BI.Selection.Multi, - value: o.value || [] - }; - // 标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_insert_trigger", - height: o.height, - text: o.text, - // adapter: this.popup, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: 26 - } - }, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keywords)) { - // 预防trigger内部把当前的storeValue改掉 - self.trigger.setValue({ - type: BI.Selection.Multi, - value: self.getValue() - }); - } - callback.apply(self, arguments); - }); - }, - value: { - type: BI.Selection.Multi, - value: o.value - } - }); - - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_START, function () { - self._setStartValue(""); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_STOP, function () { - self._setStartValue(""); - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - self._addItem(assertShowValue); - } - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () { - if (!this.getSearcher().hasMatched()) { - self._addItem(assertShowValue); - self.trigger.stopEditing(); - } - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(""); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } - }); - - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - }); - } else { - self._join(this.getValue(), function () { - assertShowValue(); - }); - } - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - el: this.trigger, - adjustLength: 1, - popup: { - type: "bi.multi_select_no_bar_popup_view", - ref: function () { - self.popup = this; - self.trigger.setAdapter(this); - }, - listeners: [{ - eventName: BI.MultiSelectPopupView.EVENT_CHANGE, - action: function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - }); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, - action: function () { - self._defaultState(); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, - action: function () { - self.setValue(); - self._defaultState(); - } - }], - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - onLoaded: function () { - BI.nextTick(function () { - self.combo.adjustWidth(); - self.combo.adjustHeight(); - self.trigger.getCounter().adjustView(); - self.trigger.getSearcher().adjustView(); - }); - } - }, - value: { - type: BI.Selection.Multi, - value: o.value - }, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - } - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self.element.removeClass("combo-show"); - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.element.removeClass("combo-show").addClass("combo-show"); - this.setValue(self.storeValue); - BI.nextTick(function () { - self.populate(); - }); - }); - // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 - this.wants2Quit = false; - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - // important:关闭弹出时又可能没有退出编辑状态 - self.trigger.stopEditing(); - if (self.requesting === true) { - self.wants2Quit = true; - } else { - self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM); - } - }); - - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.trigger.getCounter().hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }] - }); - }, - - _addItem: function (assertShowValue) { - var self = this; - var keyword = this.trigger.getSearcher().getKeyword(); - this._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - // 如果在不选的状态下直接把该值添加进来 - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - self.combo.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); - self._setStartValue(""); - }); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - this.combo.hideView(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - this.requesting = true; - o.itemsCreator({ - type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA, - keywords: keywords - }, function (ob) { - var values = BI.map(ob.items, "value"); - digest(values); - }); - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); - } - }); - self._adjust(callback); - } - }, - - _joinAll: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this.requesting = true; - o.itemsCreator({ - type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA, - keywords: [this.trigger.getKey()] - }, function (ob) { - var items = BI.map(ob.items, "value"); - if (self.storeValue.type === res.type) { - var change = false; - var map = self._makeMap(self.storeValue.value); - BI.each(items, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (self.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - var selectedMap = self._makeMap(self.storeValue.value); - var notSelectedMap = self._makeMap(res.value); - var newItems = []; - BI.each(items, function (i, item) { - if (BI.isNotNull(selectedMap[items[i]])) { - delete selectedMap[items[i]]; - } - if (BI.isNull(notSelectedMap[items[i]])) { - newItems.push(item); - } - }); - self.storeValue.value = newItems.concat(BI.values(selectedMap)); - self._adjust(callback); - }); - }, - - _adjust: function (callback) { - var self = this, o = this.options; - adjust(); - callback(); - function adjust () { - if (self.wants2Quit === true) { - self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM); - self.wants2Quit = false; - } - self.requesting = false; - } - }, - - _join: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this._assertValue(this.storeValue); - if (this.storeValue.type === res.type) { - var map = this._makeMap(this.storeValue.value); - BI.each(res.value, function (i, v) { - if (!map[v]) { - self.storeValue.value.push(v); - map[v] = v; - } - }); - var change = false; - BI.each(res.assist, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (this.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - this._joinAll(res, callback); - }, - - _setStartValue: function (value) { - this._startValue = value; - this.popup.setStartValue(value); - }, - - setValue: function (v) { - this.storeValue = { - type: BI.Selection.Multi, - value: v || [] - }; - this.combo.setValue(this.storeValue); - }, - - getValue: function () { - return BI.deepClone(this.storeValue.value); - }, - - populate: function () { - this.combo.populate.apply(this.combo, arguments); - } -}); - -BI.extend(BI.MultiSelectInsertNoBarCombo, { - REQ_GET_DATA_LENGTH: 1, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut("bi.multi_select_insert_no_bar_combo", BI.MultiSelectInsertNoBarCombo);/** - * - * 复选下拉框 - * @class BI.MultiSelectInsertTrigger - * @extends BI.Trigger - */ - -BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, { - - constants: { - height: 14, - rgap: 4, - lgap: 4 - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectInsertTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-trigger bi-border", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - searcher: {}, - switcher: {}, - - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.MultiSelectInsertTrigger.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - if (o.height) { - this.setHeight(o.height - 2); - } - - this.searcher = BI.createWidget(o.searcher, { - type: "bi.multi_select_insert_searcher", - height: o.height, - text: o.text, - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - popup: {}, - adapter: o.adapter, - masker: o.masker, - value: o.value - }); - this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_START, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_START); - }); - this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM); - }); - this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_PAUSE, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_PAUSE); - }); - this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, arguments); - }); - this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_STOP, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_STOP); - }); - this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_CHANGE, arguments); - }); - this.numberCounter = BI.createWidget(o.switcher, { - type: "bi.multi_select_check_selected_switcher", - valueFormatter: o.valueFormatter, - itemsCreator: o.itemsCreator, - adapter: o.adapter, - masker: o.masker, - value: o.value - }); - this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK); - }); - this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); - }); - - var wrapNumberCounter = BI.createWidget({ - type: "bi.right_vertical_adapt", - hgap: 4, - items: [{ - el: this.numberCounter - }] - }); - - var wrapper = BI.createWidget({ - type: "bi.htape", - element: this, - items: [ - { - el: this.searcher, - width: "fill" - }, { - el: wrapNumberCounter, - width: 0 - }, { - el: BI.createWidget(), - width: 24 - }] - }); - - this.numberCounter.on(BI.Events.VIEW, function (b) { - BI.nextTick(function () {// 自动调整宽度 - wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); - wrapper.resize(); - }); - }); - - this.element.click(function (e) { - if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { - self.numberCounter.hideView(); - } - }); - }, - - getCounter: function () { - return this.numberCounter; - }, - - getSearcher: function () { - return this.searcher; - }, - - stopEditing: function () { - this.searcher.stopSearch(); - this.numberCounter.hideView(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - this.numberCounter.setAdapter(adapter); - }, - - setValue: function (ob) { - this.searcher.setValue(ob); - this.numberCounter.setValue(ob); - }, - - getKey: function () { - return this.searcher.getKey(); - }, - - getValue: function () { - return this.searcher.getValue(); - } -}); - -BI.MultiSelectInsertTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; -BI.MultiSelectInsertTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiSelectInsertTrigger.EVENT_START = "EVENT_START"; -BI.MultiSelectInsertTrigger.EVENT_STOP = "EVENT_STOP"; -BI.MultiSelectInsertTrigger.EVENT_PAUSE = "EVENT_PAUSE"; -BI.MultiSelectInsertTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; -BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; - -BI.shortcut("bi.multi_select_insert_trigger", BI.MultiSelectInsertTrigger);/** - * 多选加载数据面板 - * Created by guy on 15/11/2. - * @class BI.MultiSelectLoader - * @extends Widget - */ -BI.MultiSelectLoader = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-loader", - logic: { - dynamic: true - }, - el: { - height: 400 - }, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectLoader.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - var hasNext = false; - - this.storeValue = opts.value || {}; - this._assertValue(this.storeValue); - - this.button_group = BI.createWidget({ - type: "bi.select_list", - logic: opts.logic, - el: BI.extend({ - onLoaded: opts.onLoaded, - el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } - } - }, opts.el), - itemsCreator: function (op, callback) { - var startValue = self._startValue; - self.storeValue && (op = BI.extend(op || {}, { - selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi - ? self.storeValue.value.concat(startValue) : self.storeValue.value - })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); - if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { - var txt = opts.valueFormatter(startValue) || startValue; - json.unshift({ - text: txt, - value: startValue, - title: txt, - selected: true - }); - } - firstItems = self._createItems(json); - } - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { - BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); - self.setValue(self.storeValue); - } - (op.times === 1) && self._scrollToTop(); - }); - }, - hasNext: function () { - return hasNext; - }, - value: this.storeValue - }); - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.button_group], - vgap: 5 - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: this.options.logic, - cls: "bi-list-item-active", - height: 24, - selected: this.isAllSelected() - }); - }, - - _scrollToTop: function () { - var self = this; - BI.delay(function () { - self.button_group.element.scrollTop(0); - }, 30); - }, - - isAllSelected: function () { - return this.button_group.isAllSelected(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - setStartValue: function (v) { - this._startValue = v; - }, - - setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.button_group.setValue(this.storeValue); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - empty: function () { - this.button_group.empty(); - }, - - populate: function (items) { - arguments[0] = this._createItems(items); - this.button_group.populate.apply(this.button_group, arguments); - }, - - resetHeight: function (h) { - this.button_group.resetHeight(h); - }, - - resetWidth: function (w) { - this.button_group.resetWidth(w); - } -}); - -BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_loader", BI.MultiSelectLoader);/** - * 多选加载数据面板 - * Created by guy on 15/11/2. - * @class BI.MultiSelectNoBarLoader - * @extends Widget - */ -BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectNoBarLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-loader", - logic: { - dynamic: true - }, - el: { - height: 400 - }, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectNoBarLoader.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - var hasNext = false; - - this.storeValue = opts.value || {}; - this._assertValue(this.storeValue); - - this.button_group = BI.createWidget(BI.extend({ - type: "bi.list_pane", - onLoaded: opts.onLoaded, - el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } - }, - itemsCreator: function (op, callback) { - var startValue = self._startValue; - self.storeValue && (op = BI.extend(op || {}, { - selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi - ? self.storeValue.value.concat(startValue) : self.storeValue.value - })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); - if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { - var txt = opts.valueFormatter(startValue) || startValue; - json.unshift({ - text: txt, - value: startValue, - title: txt, - selected: true - }); - } - firstItems = self._createItems(json); - } - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { - BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); - self.setValue(self.storeValue); - } - (op.times === 1) && self._scrollToTop(); - }); - }, - hasNext: function () { - return hasNext; - }, - value: this.storeValue - }, opts.el)); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.button_group], - vgap: 5 - }); - - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectNoBarLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: this.options.logic, - height: 24 - }); - }, - - _scrollToTop: function () { - var self = this; - BI.delay(function () { - self.button_group.element.scrollTop(0); - }, 30); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - setStartValue: function (v) { - this._startValue = v; - }, - - setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.button_group.setValue(this.storeValue.value); - }, - - getValue: function () { - return { - type: BI.Selection.Multi, - value: this.button_group.getValue() - }; - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - empty: function () { - this.button_group.empty(); - }, - - populate: function (items) { - arguments[0] = this._createItems(items); - this.button_group.populate.apply(this.button_group, arguments); - }, - - resetHeight: function (h) { - this.button_group.element.css({"max-height": h + "px"}); - }, - - resetWidth: function () { - - } -}); - -BI.MultiSelectNoBarLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_no_bar_loader", BI.MultiSelectNoBarLoader);/** - * 带加载的多选下拉面板 - * @class BI.MultiSelectPopupView - * @extends Widget - */ -BI.MultiSelectPopupView = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-popup-view", - maxWidth: "auto", - minWidth: 135, - maxHeight: 400, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectPopupView.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - - this.loader = BI.createWidget({ - type: "bi.multi_select_loader", - itemsCreator: opts.itemsCreator, - valueFormatter: opts.valueFormatter, - onLoaded: opts.onLoaded, - value: opts.value - }); - - this.popupView = BI.createWidget({ - type: "bi.multi_popup_view", - stopPropagation: false, - maxWidth: opts.maxWidth, - minWidth: opts.minWidth, - maxHeight: opts.maxHeight, - element: this, - buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], - el: this.loader, - value: opts.value - }); - - this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE); - }); - this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { - switch (index) { - case 0: - self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR); - break; - case 1: - self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM); - break; - } - }); - }, - - isAllSelected: function () { - return this.loader.isAllSelected(); - }, - - setStartValue: function (v) { - this.loader.setStartValue(v); - }, - - setValue: function (v) { - this.popupView.setValue(v); - }, - - getValue: function () { - return this.popupView.getValue(); - }, - - populate: function (items) { - this.popupView.populate.apply(this.popupView, arguments); - }, - - resetHeight: function (h) { - this.popupView.resetHeight(h); - }, - - resetWidth: function (w) { - this.popupView.resetWidth(w); - } -}); - -BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; -BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; - - -BI.shortcut("bi.multi_select_popup_view", BI.MultiSelectPopupView);/** - * 带加载的多选下拉面板 - * @class BI.MultiSelectPopupView - * @extends Widget - */ -BI.MultiSelectNoBarPopupView = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectNoBarPopupView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-popup-view", - maxWidth: "auto", - minWidth: 135, - maxHeight: 400, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectNoBarPopupView.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - - this.loader = BI.createWidget({ - type: "bi.multi_select_no_bar_loader", - itemsCreator: opts.itemsCreator, - valueFormatter: opts.valueFormatter, - onLoaded: opts.onLoaded, - value: opts.value - }); - - this.popupView = BI.createWidget({ - type: "bi.multi_popup_view", - stopPropagation: false, - maxWidth: opts.maxWidth, - minWidth: opts.minWidth, - maxHeight: opts.maxHeight, - element: this, - buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], - el: this.loader, - value: opts.value - }); - - this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CHANGE); - }); - this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { - switch (index) { - case 0: - self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR); - break; - case 1: - self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM); - break; - } - }); - }, - - setStartValue: function (v) { - this.loader.setStartValue(v); - }, - - setValue: function (v) { - this.popupView.setValue(v); - }, - - getValue: function () { - return this.popupView.getValue(); - }, - - populate: function (items) { - this.popupView.populate.apply(this.popupView, arguments); - }, - - resetHeight: function (h) { - this.popupView.resetHeight(h); - }, - - resetWidth: function (w) { - this.popupView.resetWidth(w); - } -}); - -BI.MultiSelectNoBarPopupView.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; -BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; - - -BI.shortcut("bi.multi_select_no_bar_popup_view", BI.MultiSelectNoBarPopupView);/** - * - * 复选下拉框 - * @class BI.MultiSelectTrigger - * @extends BI.Trigger - */ - -BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { - - constants: { - height: 14, - rgap: 4, - lgap: 4 - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-trigger bi-border", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - searcher: {}, - switcher: {}, - - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.MultiSelectTrigger.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - if (o.height) { - this.setHeight(o.height - 2); - } - - this.searcher = BI.createWidget(o.searcher, { - type: "bi.multi_select_searcher", - height: o.height, - text: o.text, - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - popup: {}, - adapter: o.adapter, - masker: o.masker, - value: o.value - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () { - self.fireEvent(BI.MultiSelectTrigger.EVENT_START); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () { - self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () { - self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () { - self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments); - }); - this.numberCounter = BI.createWidget(o.switcher, { - type: "bi.multi_select_check_selected_switcher", - valueFormatter: o.valueFormatter, - itemsCreator: o.itemsCreator, - adapter: o.adapter, - masker: o.masker, - value: o.value - }); - this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { - self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK); - }); - this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); - }); - - var wrapNumberCounter = BI.createWidget({ - type: "bi.right_vertical_adapt", - hgap: 4, - items: [{ - el: this.numberCounter - }] - }); - - var wrapper = BI.createWidget({ - type: "bi.htape", - element: this, - items: [ - { - el: this.searcher, - width: "fill" - }, { - el: wrapNumberCounter, - width: 0 - }, { - el: BI.createWidget(), - width: 24 - }] - }); - - this.numberCounter.on(BI.Events.VIEW, function (b) { - BI.nextTick(function () {// 自动调整宽度 - wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); - wrapper.resize(); - }); - }); - - this.element.click(function (e) { - if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { - self.numberCounter.hideView(); - } - }); - }, - - getCounter: function () { - return this.numberCounter; - }, - - getSearcher: function () { - return this.searcher; - }, - - stopEditing: function () { - this.searcher.stopSearch(); - this.numberCounter.hideView(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - this.numberCounter.setAdapter(adapter); - }, - - setValue: function (ob) { - this.searcher.setValue(ob); - this.numberCounter.setValue(ob); - }, - - getKey: function () { - return this.searcher.getKey(); - }, - - getValue: function () { - return this.searcher.getValue(); - } -}); - -BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; -BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiSelectTrigger.EVENT_START = "EVENT_START"; -BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP"; -BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; -BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; - -BI.shortcut("bi.multi_select_trigger", BI.MultiSelectTrigger);/** - * - * 在搜索框中输入文本弹出的面板 - * @class BI.MultiSelectSearchInsertPane - * @extends Widget - */ - -BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, { - - constants: { - height: 24, - lgap: 10, - tgap: 5 - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectSearchInsertPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-search-pane bi-card", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - keywordGetter: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectSearchInsertPane.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.tooltipClick = BI.createWidget({ - type: "bi.label", - invisible: true, - text: BI.i18nText("BI-Click_Blank_To_Select"), - cls: "multi-select-toolbar", - height: this.constants.height - }); - - this.addNotMatchTip = BI.createWidget({ - type: "bi.text_button", - invisible: true, - text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""), - height: this.constants.height, - cls: "bi-high-light", - hgap: 5, - handler: function () { - self.fireEvent(BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, o.keywordGetter()); - } - }); - - this.loader = BI.createWidget({ - type: "bi.multi_select_search_loader", - keywordGetter: o.keywordGetter, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator.apply(self, [op, function (res) { - callback(res); - self.setKeyword(o.keywordGetter()); - }]); - }, - value: o.value - }); - this.loader.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.resizer = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - type: "bi.vertical", - items: [this.tooltipClick, this.addNotMatchTip], - height: this.constants.height - }, { - el: this.loader - }] - }); - }, - - setKeyword: function (keyword) { - var btn; - var isMatchTipVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); - this.tooltipClick.setVisible(isMatchTipVisible); - this.addNotMatchTip.setVisible(!isMatchTipVisible); - !isMatchTipVisible && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword)); - }, - - isAllSelected: function () { - return this.loader.isAllSelected(); - }, - - hasMatched: function () { - return this.tooltipClick.isVisible(); - }, - - setValue: function (v) { - this.loader.setValue(v); - }, - - getValue: function () { - return this.loader.getValue(); - }, - - empty: function () { - this.loader.empty(); - }, - - populate: function (items) { - this.loader.populate.apply(this.loader, arguments); - } -}); - -BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; - -BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane);/** - * 多选加载数据搜索loader面板 - * Created by guy on 15/11/4. - * @class BI.MultiSelectSearchLoader - * @extends Widget - */ -BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-search-loader", - itemsCreator: BI.emptyFn, - keywordGetter: BI.emptyFn, - valueFormatter: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - var hasNext = false; - this.storeValue = BI.deepClone(opts.value); - this.button_group = BI.createWidget({ - type: "bi.select_list", - element: this, - logic: { - dynamic: false - }, - value: opts.value, - el: { - tipText: BI.i18nText("BI-No_Select"), - el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } - } - }, - itemsCreator: function (op, callback) { - self.storeValue && (op = BI.extend(op || {}, { - selectedValues: self.storeValue.value - })); - opts.itemsCreator(op, function (ob) { - var keyword = ob.keyword = opts.keywordGetter(); - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = self._filterValues(self.storeValue); - firstItems = self._createItems(json); - } - callback(firstItems.concat(self._createItems(ob.items)), keyword); - if (op.times === 1 && self.storeValue) { - self.setValue(self.storeValue); - } - }); - }, - hasNext: function () { - return hasNext; - } - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: { - dynamic: false - }, - height: 24, - selected: this.isAllSelected() - }); - }, - - isAllSelected: function () { - return this.button_group.isAllSelected(); - }, - - _filterValues: function (src) { - var o = this.options; - var keyword = o.keywordGetter(); - var values = BI.deepClone(src.value) || []; - var newValues = BI.map(values, function (i, v) { - return { - text: o.valueFormatter(v) || v, - value: v - }; - }); - if (BI.isKey(keyword)) { - var search = BI.Func.getSearchResult(newValues, keyword); - values = search.match.concat(search.find); - } - return BI.map(values, function (i, v) { - return { - text: v.text, - title: v.text, - value: v.value, - selected: src.type === BI.Selection.All - }; - }); - }, - - setValue: function (v) { - // 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 - this.storeValue = BI.deepClone(v); - this.button_group.setValue(v); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - empty: function () { - this.button_group.empty(); - }, - - populate: function (items) { - this.button_group.populate.apply(this.button_group, arguments); - }, - - resetHeight: function (h) { - this.button_group.resetHeight(h); - }, - - resetWidth: function (w) { - this.button_group.resetWidth(w); - } -}); - -BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_search_loader", BI.MultiSelectSearchLoader);/** - * - * 在搜索框中输入文本弹出的面板 - * @class BI.MultiSelectSearchPane - * @extends Widget - */ - -BI.MultiSelectSearchPane = BI.inherit(BI.Widget, { - - constants: { - height: 24, - lgap: 10, - tgap: 5 - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-search-pane bi-card", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - keywordGetter: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectSearchPane.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.tooltipClick = BI.createWidget({ - type: "bi.label", - invisible: true, - text: BI.i18nText("BI-Click_Blank_To_Select"), - cls: "multi-select-toolbar", - height: this.constants.height - }); - - this.loader = BI.createWidget({ - type: "bi.multi_select_search_loader", - keywordGetter: o.keywordGetter, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator.apply(self, [op, function (res) { - callback(res); - self.setKeyword(o.keywordGetter()); - }]); - }, - value: o.value - }); - this.loader.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.resizer = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.tooltipClick, - height: 0 - }, { - el: this.loader - }] - }); - this.tooltipClick.setVisible(false); - }, - - setKeyword: function (keyword) { - var btn; - var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); - if (isVisible !== this.tooltipClick.isVisible()) { - this.tooltipClick.setVisible(isVisible); - this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); - this.resizer.resize(); - } - }, - - isAllSelected: function () { - return this.loader.isAllSelected(); - }, - - hasMatched: function () { - return this.tooltipClick.isVisible(); - }, - - setValue: function (v) { - this.loader.setValue(v); - }, - - getValue: function () { - return this.loader.getValue(); - }, - - empty: function () { - this.loader.empty(); - }, - - populate: function (items) { - this.loader.populate.apply(this.loader, arguments); - } -}); - -BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/** - * 查看已选按钮 - * Created by guy on 15/11/3. - * @class BI.MultiSelectCheckSelectedButton - * @extends BI.Single - */ -BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-check-selected-button", - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.numberCounter = BI.createWidget({ - type: "bi.text_button", - element: this, - hgap: 4, - text: "0", - textAlign: "center", - textHeight: 16, - cls: "bi-high-light-background count-tip" - }); - this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); - }); - - this.numberCounter.element.hover(function () { - self.numberCounter.setTag(self.numberCounter.getText()); - self.numberCounter.setText(BI.i18nText("BI-Check_Selected")); - }, function () { - self.numberCounter.setText(self.numberCounter.getTag()); - }); - this.setVisible(false); - if(BI.isNotNull(o.value)){ - this.setValue(o.value); - } - }, - - setValue: function (ob) { - var self = this, o = this.options; - ob || (ob = {}); - ob.type || (ob.type = BI.Selection.Multi); - ob.value || (ob.value = []); - if (ob.type === BI.Selection.All) { - o.itemsCreator({ - type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH - }, function (res) { - var length = res.count - ob.value.length; - BI.nextTick(function () { - self.numberCounter.setText(length); - self.setVisible(length > 0); - }); - }); - return; - } - BI.nextTick(function () { - self.numberCounter.setText(ob.value.length); - self.setVisible(ob.value.length > 0); - }); - }, - - getValue: function () { - - } -}); - -BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_select_check_selected_button", BI.MultiSelectCheckSelectedButton);/** - * 多选输入框 - * Created by guy on 15/11/3. - * @class BI.MultiSelectEditor - * @extends Widget - */ -BI.MultiSelectEditor = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-editor", - el: {} - }); - }, - - _init: function () { - BI.MultiSelectEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget(o.el, { - type: "bi.state_editor", - element: this, - height: o.height, - watermark: BI.i18nText("BI-Basic_Search"), - allowBlank: true, - value: o.value, - text: o.text - }); - - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.editor.on(BI.StateEditor.EVENT_PAUSE, function () { - self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE); - }); - this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () { - - }); - }, - - focus: function () { - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - }, - - setState: function (state) { - this.editor.setState(state); - }, - - setValue: function (v) { - this.editor.setValue(v); - }, - - getValue: function () { - var v = this.editor.getState(); - if (BI.isArray(v) && v.length > 0) { - return v[v.length - 1]; - } - return ""; - - }, - - getKeywords: function () { - var val = this.editor.getLastValidValue(); - var keywords = val.match(/[\S]+/g); - if (BI.isEndWithBlank(val)) { - return keywords.concat([" "]); - } - return keywords; - }, - - populate: function (items) { - - } -}); -BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE"; -BI.shortcut("bi.multi_select_editor", BI.MultiSelectEditor);/** - * searcher - * Created by guy on 15/11/3. - * @class BI.MultiSelectInsertSearcher - * @extends Widget - */ -BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectInsertSearcher.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-searcher", - itemsCreator: BI.emptyFn, - el: {}, - popup: {}, - valueFormatter: BI.emptyFn, - adapter: null, - masker: {}, - text: BI.i18nText("BI-Basic_Please_Select") - }); - }, - - _init: function () { - BI.MultiSelectInsertSearcher.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget(o.el, { - type: "bi.multi_select_editor", - height: o.height, - text: o.text - }); - - this.searcher = BI.createWidget({ - type: "bi.searcher", - element: this, - height: o.height, - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - el: this.editor, - - popup: BI.extend({ - type: "bi.multi_select_search_insert_pane", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.editor.getValue(); - }, - itemsCreator: function (op, callback) { - var keyword = self.editor.getValue(); - op.keywords = [keyword]; - this.setKeyword(keyword); - o.itemsCreator(op, callback); - }, - value: o.value, - listeners: [{ - eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, - action: function () { - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM); - } - }] - }, o.popup), - - adapter: o.adapter, - masker: o.masker - }); - this.searcher.on(BI.Searcher.EVENT_START, function () { - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_START); - }); - this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { - if (this.hasMatched()) { - - } - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_PAUSE); - }); - this.searcher.on(BI.Searcher.EVENT_STOP, function () { - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_STOP); - }); - this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_CHANGE, arguments); - }); - this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { - var keywords = this.getKeywords(); - self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, keywords); - }); - if (BI.isNotNull(o.value)) { - this.setState(o.value); - } - }, - - adjustView: function () { - this.searcher.adjustView(); - }, - - isSearching: function () { - return this.searcher.isSearching(); - }, - - stopSearch: function () { - this.searcher.stopSearch(); - }, - - getKeyword: function () { - return this.editor.getValue(); - }, - - hasMatched: function () { - return this.searcher.hasMatched(); - }, - - hasChecked: function () { - return this.searcher.getView() && this.searcher.getView().hasChecked(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - }, - - setState: function (ob) { - var o = this.options; - ob || (ob = {}); - ob.value || (ob.value = []); - if (ob.type === BI.Selection.All) { - if (ob.value.length === 0) { - this.editor.setState(BI.Selection.All); - } else if (BI.size(ob.assist) <= 20) { - var state = ""; - BI.each(ob.assist, function (i, v) { - if (i === 0) { - state += "" + (o.valueFormatter(v + "") || v); - } else { - state += "," + (o.valueFormatter(v + "") || v); - } - }); - this.editor.setState(state); - } else { - this.editor.setState(BI.Selection.Multi); - } - } else { - if (ob.value.length === 0) { - this.editor.setState(BI.Selection.None); - } else if (BI.size(ob.value) <= 20) { - var state = ""; - BI.each(ob.value, function (i, v) { - if (i === 0) { - state += "" + (o.valueFormatter(v + "") || v); - } else { - state += "," + (o.valueFormatter(v + "") || v); - } - }); - this.editor.setState(state); - } else { - this.editor.setState(BI.Selection.Multi); - } - } - }, - - setValue: function (ob) { - this.setState(ob); - this.searcher.setValue(ob); - }, - - getKey: function () { - return this.editor.getValue(); - }, - - getValue: function () { - return this.searcher.getValue(); - }, - - populate: function (items) { - this.searcher.populate.apply(this.searcher, arguments); - } -}); - -BI.MultiSelectInsertSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.MultiSelectInsertSearcher.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiSelectInsertSearcher.EVENT_START = "EVENT_START"; -BI.MultiSelectInsertSearcher.EVENT_STOP = "EVENT_STOP"; -BI.MultiSelectInsertSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -BI.MultiSelectInsertSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; -BI.shortcut("bi.multi_select_insert_searcher", BI.MultiSelectInsertSearcher);/** - * searcher - * Created by guy on 15/11/3. - * @class BI.MultiSelectSearcher - * @extends Widget - */ -BI.MultiSelectSearcher = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-searcher", - itemsCreator: BI.emptyFn, - el: {}, - popup: {}, - valueFormatter: BI.emptyFn, - adapter: null, - masker: {}, - text: BI.i18nText("BI-Basic_Please_Select") - }); - }, - - _init: function () { - BI.MultiSelectSearcher.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget(o.el, { - type: "bi.multi_select_editor", - height: o.height, - text: o.text - }); - - this.searcher = BI.createWidget({ - type: "bi.searcher", - element: this, - height: o.height, - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - el: this.editor, - - popup: BI.extend({ - type: "bi.multi_select_search_pane", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.editor.getValue(); - }, - itemsCreator: function (op, callback) { - var keyword = self.editor.getValue(); - op.keywords = [keyword]; - this.setKeyword(keyword); - o.itemsCreator(op, callback); - }, - value: o.value - }, o.popup), - - adapter: o.adapter, - masker: o.masker - }); - this.searcher.on(BI.Searcher.EVENT_START, function () { - self.fireEvent(BI.MultiSelectSearcher.EVENT_START); - }); - this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { - if (this.hasMatched()) { - - } - self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE); - }); - this.searcher.on(BI.Searcher.EVENT_STOP, function () { - self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP); - }); - this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments); - }); - this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { - var keywords = this.getKeywords(); - self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords); - }); - if (BI.isNotNull(o.value)) { - this.setState(o.value); - } - }, - - adjustView: function () { - this.searcher.adjustView(); - }, - - isSearching: function () { - return this.searcher.isSearching(); - }, - - stopSearch: function () { - this.searcher.stopSearch(); - }, - - getKeyword: function () { - return this.editor.getValue(); - }, - - hasMatched: function () { - return this.searcher.hasMatched(); - }, - - hasChecked: function () { - return this.searcher.getView() && this.searcher.getView().hasChecked(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - }, - - setState: function (ob) { - var o = this.options; - ob || (ob = {}); - ob.value || (ob.value = []); - if (ob.type === BI.Selection.All) { - if (ob.value.length === 0) { - this.editor.setState(BI.Selection.All); - } else if (BI.size(ob.assist) <= 20) { - var state = ""; - BI.each(ob.assist, function (i, v) { - if (i === 0) { - state += "" + (o.valueFormatter(v + "") || v); - } else { - state += "," + (o.valueFormatter(v + "") || v); - } - }); - this.editor.setState(state); - } else { - this.editor.setState(BI.Selection.Multi); - } - } else { - if (ob.value.length === 0) { - this.editor.setState(BI.Selection.None); - } else if (BI.size(ob.value) <= 20) { - var state = ""; - BI.each(ob.value, function (i, v) { - if (i === 0) { - state += "" + (o.valueFormatter(v + "") || v); - } else { - state += "," + (o.valueFormatter(v + "") || v); - } - }); - this.editor.setState(state); - } else { - this.editor.setState(BI.Selection.Multi); - } - } - }, - - setValue: function (ob) { - this.setState(ob); - this.searcher.setValue(ob); - }, - - getKey: function () { - return this.editor.getValue(); - }, - - getValue: function () { - return this.searcher.getValue(); - }, - - populate: function (items) { - this.searcher.populate.apply(this.searcher, arguments); - } -}); - -BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiSelectSearcher.EVENT_START = "EVENT_START"; -BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; -BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.shortcut("bi.multi_select_searcher", BI.MultiSelectSearcher);/** - * 查看已选switcher - * Created by guy on 15/11/3. - * @class BI.MultiSelectCheckSelectedSwitcher - * @extends Widget - */ -BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-check-selected-switcher", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - el: {}, - popup: {}, - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.button = BI.createWidget(o.el, { - type: "bi.multi_select_check_selected_button", - itemsCreator: o.itemsCreator, - value: o.value - }); - this.button.on(BI.Events.VIEW, function () { - self.fireEvent(BI.Events.VIEW, arguments); - }); - this.switcher = BI.createWidget({ - type: "bi.switcher", - toggle: false, - element: this, - el: this.button, - popup: BI.extend({ - type: "bi.multi_select_check_pane", - valueFormatter: o.valueFormatter, - itemsCreator: o.itemsCreator, - onClickContinueSelect: function () { - self.switcher.hideView(); - }, - value: o.value - }, o.popup), - adapter: o.adapter, - masker: o.masker - }); - this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () { - self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE); - }); - this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW); - }); - this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () { - var me = this; - BI.nextTick(function () { - me.populate(); - }); - }); - - this.switcher.element.click(function (e) { - e.stopPropagation(); - }); - }, - - adjustView: function () { - this.switcher.adjustView(); - }, - - hideView: function () { - this.switcher.empty(); - this.switcher.hideView(); - }, - - setAdapter: function (adapter) { - this.switcher.setAdapter(adapter); - }, - - setValue: function (v) { - this.switcher.setValue(v); - }, - - setButtonChecked: function (v) { - this.button.setValue(v); - }, - - getValue: function () { - - }, - - populate: function (items) { - this.switcher.populate.apply(this.switcher, arguments); - } -}); - -BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; -BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.multi_select_check_selected_switcher", BI.MultiSelectCheckSelectedSwitcher);/** - * Created by zcf_1 on 2017/5/2. - */ -BI.MultiSelectInsertList = BI.inherit(BI.Single, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectInsertList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-insert-list", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn - }); - }, - _init: function () { - BI.MultiSelectInsertList.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - this.storeValue = o.value || {}; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - // self.trigger.setValue(self.storeValue); - }; - - this.adapter = BI.createWidget({ - type: "bi.multi_select_loader", - cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - logic: { - dynamic: true - }, - // onLoaded: o.onLoaded, - el: {}, - value: o.value - }); - this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { - self.storeValue = this.getValue(); - assertShowValue(); - self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); - }); - - this.searcherPane = BI.createWidget({ - type: "bi.multi_select_search_insert_pane", - cls: "bi-border-left bi-border-right bi-border-bottom", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.trigger.getKeyword(); - }, - itemsCreator: function (op, callback) { - op.keywords = [self.trigger.getKeyword()]; - this.setKeyword(op.keywords[0]); - o.itemsCreator(op, callback); - }, - listeners: [{ - eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, - action: function () { - var keyword = self.trigger.getKeyword(); - if (!self.trigger.hasMatched()) { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self.adapter.populate(); - if (self.storeValue.type === BI.Selection.Multi) { - self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); - } - } - } - }] - }); - this.searcherPane.setVisible(false); - - this.trigger = BI.createWidget({ - type: "bi.searcher", - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - adapter: this.adapter, - popup: this.searcherPane, - height: 200, - masker: false, - listeners: [{ - eventName: BI.Searcher.EVENT_START, - action: function () { - self._showSearcherPane(); - self._setStartValue(""); - this.setValue(BI.deepClone(self.storeValue)); - } - }, { - eventName: BI.Searcher.EVENT_STOP, - action: function () { - self._showAdapter(); - self._setStartValue(""); - self.adapter.setValue(self.storeValue); - // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 - self.adapter.populate(); - } - }, { - eventName: BI.Searcher.EVENT_PAUSE, - action: function () { - var keyword = this.getKeyword(); - if (this.hasMatched()) { - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); - }); - } - self._showAdapter(); - } - }, { - eventName: BI.Searcher.EVENT_SEARCHING, - action: function () { - var keywords = this.getKeywords(); - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.adapter.setValue(self.storeValue); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - } else { - self.adapter.setValue(self.storeValue); - assertShowValue(); - } - }); - } - } - }, { - eventName: BI.Searcher.EVENT_CHANGE, - action: function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); - }); - } else { - self._join(this.getValue(), function () { - assertShowValue(); - self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); - }); - } - } - }], - value: o.value - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.trigger, - height: 24 - }, { - el: this.adapter, - height: "fill" - }] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.searcherPane, - top: 30, - bottom: 0, - left: 0, - right: 0 - }] - }); - }, - - _showAdapter: function () { - this.adapter.setVisible(true); - this.searcherPane.setVisible(false); - }, - - _showSearcherPane: function () { - this.searcherPane.setVisible(true); - this.adapter.setVisible(false); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - if (!this._allData) { - o.itemsCreator({ - type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA - }, function (ob) { - self._allData = BI.map(ob.items, "value"); - digest(self._allData); - }); - } else { - digest(this._allData); - } - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); - } - }); - callback(); - } - }, - - _joinAll: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - o.itemsCreator({ - type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA, - keywords: [self.trigger.getKeyword()] - }, function (ob) { - var items = BI.map(ob.items, "value"); - if (self.storeValue.type === res.type) { - var change = false; - var map = self._makeMap(self.storeValue.value); - BI.each(items, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (self.storeValue.value = BI.values(map)); - callback(); - return; - } - var selectedMap = self._makeMap(self.storeValue.value); - var notSelectedMap = self._makeMap(res.value); - var newItems = []; - BI.each(items, function (i, item) { - if (BI.isNotNull(selectedMap[items[i]])) { - delete selectedMap[items[i]]; - } - if (BI.isNull(notSelectedMap[items[i]])) { - newItems.push(item); - } - }); - self.storeValue.value = newItems.concat(BI.values(selectedMap)); - callback(); - }); - }, - - _join: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this._assertValue(this.storeValue); - if (this.storeValue.type === res.type) { - var map = this._makeMap(this.storeValue.value); - BI.each(res.value, function (i, v) { - if (!map[v]) { - self.storeValue.value.push(v); - map[v] = v; - } - }); - var change = false; - BI.each(res.assist, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (this.storeValue.value = BI.values(map)); - callback(); - return; - } - this._joinAll(res, callback); - }, - - _setStartValue: function (value) { - this._startValue = value; - this.adapter.setStartValue(value); - }, - - isAllSelected: function () { - return this.adapter.isAllSelected(); - }, - - resize: function () { - // this.trigger.getCounter().adjustView(); - // this.trigger.adjustView(); - }, - setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.adapter.setValue(this.storeValue); - this.trigger.setValue(this.storeValue); - }, - - getValue: function () { - return BI.deepClone(this.storeValue); - }, - - populate: function () { - this._count = null; - this._allData = null; - this.adapter.populate.apply(this.adapter, arguments); - this.trigger.populate.apply(this.trigger, arguments); - } -}); - -BI.extend(BI.MultiSelectInsertList, { - REQ_GET_DATA_LENGTH: 1, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectInsertList.EVENT_CHANGE = "BI.MultiSelectInsertList.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_insert_list", BI.MultiSelectInsertList);/** - * Created by zcf_1 on 2017/5/2. - */ -BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectInsertNoBarList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-insert-list", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn - }); - }, - _init: function () { - BI.MultiSelectInsertNoBarList.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - this.storeValue = { - type: BI.Selection.Multi, - value: o.value || [] - }; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - // self.trigger.setValue(self.storeValue); - }; - - this.adapter = BI.createWidget({ - type: "bi.multi_select_no_bar_loader", - cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - logic: { - dynamic: false - }, - // onLoaded: o.onLoaded, - el: {}, - value: { - type: BI.Selection.Multi, - value: o.value || [] - } - }); - this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { - self.storeValue = this.getValue(); - assertShowValue(); - self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); - }); - - this.searcherPane = BI.createWidget({ - type: "bi.multi_select_search_insert_pane", - cls: "bi-border-left bi-border-right bi-border-bottom", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.trigger.getKeyword(); - }, - itemsCreator: function (op, callback) { - op.keywords = [self.trigger.getKeyword()]; - this.setKeyword(op.keywords[0]); - o.itemsCreator(op, callback); - }, - listeners: [{ - eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, - action: function () { - var keyword = self.trigger.getKeyword(); - if (!self.trigger.hasMatched()) { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self.adapter.populate(); - if (self.storeValue.type === BI.Selection.Multi) { - self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); - } - } - } - }] - }); - this.searcherPane.setVisible(false); - - this.trigger = BI.createWidget({ - type: "bi.searcher", - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - adapter: this.adapter, - popup: this.searcherPane, - height: 200, - masker: false, - listeners: [{ - eventName: BI.Searcher.EVENT_START, - action: function () { - self._showSearcherPane(); - self._setStartValue(""); - this.setValue(BI.deepClone(self.storeValue)); - } - }, { - eventName: BI.Searcher.EVENT_STOP, - action: function () { - self._showAdapter(); - self._setStartValue(""); - self.adapter.setValue(self.storeValue); - // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 - self.adapter.populate(); - } - }, { - eventName: BI.Searcher.EVENT_PAUSE, - action: function () { - var keyword = this.getKeyword(); - if (this.hasMatched()) { - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - if (self.storeValue.type === BI.Selection.Multi) { - self.storeValue.value.pushDistinct(keyword); - } - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); - }); - } - } - }, { - eventName: BI.Searcher.EVENT_SEARCHING, - action: function () { - var keywords = this.getKeywords(); - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.adapter.setValue(self.storeValue); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - } else { - self.adapter.setValue(self.storeValue); - assertShowValue(); - } - }); - } - } - }, { - eventName: BI.Searcher.EVENT_CHANGE, - action: function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); - }); - } else { - self._join(this.getValue(), function () { - assertShowValue(); - self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); - }); - } - } - }], - value: { - type: BI.Selection.Multi, - value: o.value || [] - } - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.trigger, - height: 24 - }, { - el: this.adapter, - height: "fill" - }] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.searcherPane, - top: 30, - bottom: 0, - left: 0, - right: 0 - }] - }); - }, - - _showAdapter: function () { - this.adapter.setVisible(true); - this.searcherPane.setVisible(false); - }, - - _showSearcherPane: function () { - this.searcherPane.setVisible(true); - this.adapter.setVisible(false); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - if (!this._allData) { - o.itemsCreator({ - type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA - }, function (ob) { - self._allData = BI.map(ob.items, "value"); - digest(self._allData); - }); - } else { - digest(this._allData); - } - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); - } - }); - callback(); - } - }, - - _joinAll: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - o.itemsCreator({ - type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA, - keywords: [self.trigger.getKeyword()] - }, function (ob) { - var items = BI.map(ob.items, "value"); - if (self.storeValue.type === res.type) { - var change = false; - var map = self._makeMap(self.storeValue.value); - BI.each(items, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (self.storeValue.value = BI.values(map)); - callback(); - return; - } - var selectedMap = self._makeMap(self.storeValue.value); - var notSelectedMap = self._makeMap(res.value); - var newItems = []; - BI.each(items, function (i, item) { - if (BI.isNotNull(selectedMap[items[i]])) { - delete selectedMap[items[i]]; - } - if (BI.isNull(notSelectedMap[items[i]])) { - newItems.push(item); - } - }); - self.storeValue.value = newItems.concat(BI.values(selectedMap)); - callback(); - }); - }, - - _join: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this._assertValue(this.storeValue); - if (this.storeValue.type === res.type) { - var map = this._makeMap(this.storeValue.value); - BI.each(res.value, function (i, v) { - if (!map[v]) { - self.storeValue.value.push(v); - map[v] = v; - } - }); - var change = false; - BI.each(res.assist, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (this.storeValue.value = BI.values(map)); - callback(); - return; - } - this._joinAll(res, callback); - }, - - _setStartValue: function (value) { - this._startValue = value; - this.adapter.setStartValue(value); - }, - - isAllSelected: function () { - return this.adapter.isAllSelected(); - }, - - resize: function () { - // this.trigger.getCounter().adjustView(); - // this.trigger.adjustView(); - }, - setValue: function (v) { - this.storeValue = { - type: BI.Selection.Multi, - value: v || [] - }; - this.adapter.setValue(this.storeValue); - this.trigger.setValue(this.storeValue); - }, - - getValue: function () { - return BI.deepClone(this.storeValue.value); - }, - - populate: function () { - this._count = null; - this._allData = null; - this.adapter.populate.apply(this.adapter, arguments); - this.trigger.populate.apply(this.trigger, arguments); - } -}); - -BI.extend(BI.MultiSelectInsertNoBarList, { - REQ_GET_DATA_LENGTH: 1, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectInsertNoBarList.EVENT_CHANGE = "BI.MultiSelectInsertNoBarList.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_insert_no_bar_list", BI.MultiSelectInsertNoBarList);/** - * Created by zcf_1 on 2017/5/2. - */ -BI.MultiSelectList = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-list", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn - }); - }, - _init: function () { - BI.MultiSelectList.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - this.storeValue = {}; - - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - // self.trigger.setValue(self.storeValue); - }; - - this.adapter = BI.createWidget({ - type: "bi.multi_select_loader", - cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - logic: { - dynamic: false - }, - // onLoaded: o.onLoaded, - el: {} - }); - this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); - }); - }); - - this.searcherPane = BI.createWidget({ - type: "bi.multi_select_search_pane", - cls: "bi-border-left bi-border-right bi-border-bottom", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.trigger.getKeyword(); - }, - itemsCreator: function (op, callback) { - op.keywords = [self.trigger.getKeyword()]; - this.setKeyword(op.keywords[0]); - o.itemsCreator(op, callback); - } - }); - this.searcherPane.setVisible(false); - - this.trigger = BI.createWidget({ - type: "bi.searcher", - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - adapter: this.adapter, - popup: this.searcherPane, - height: 200, - masker: false, - listeners: [{ - eventName: BI.Searcher.EVENT_START, - action: function () { - self._showSearcherPane(); - self._setStartValue(""); - this.setValue(BI.deepClone(self.storeValue)); - } - }, { - eventName: BI.Searcher.EVENT_STOP, - action: function () { - self._showAdapter(); - self._setStartValue(""); - self.adapter.setValue(self.storeValue); - // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 - self.adapter.populate(); - } - }, { - eventName: BI.Searcher.EVENT_PAUSE, - action: function () { - var keyword = this.getKeyword(); - if (this.hasMatched()) { - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); - }); - } - } - }, { - eventName: BI.Searcher.EVENT_SEARCHING, - action: function () { - var keywords = this.getKeyword(); - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.adapter.setValue(self.storeValue); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(""); - } else { - self.adapter.setValue(self.storeValue); - assertShowValue(); - } - }); - } - } - }, { - eventName: BI.Searcher.EVENT_CHANGE, - action: function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); - }); - } else { - self._join(this.getValue(), function () { - assertShowValue(); - self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); - }); - } - } - }] - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.trigger, - height: 24 - }, { - el: this.adapter, - height: "fill" - }] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.searcherPane, - top: 30, - bottom: 0, - left: 0, - right: 0 - }] - }); - }, - - _showAdapter: function () { - this.adapter.setVisible(true); - this.searcherPane.setVisible(false); - }, - - _showSearcherPane: function () { - this.searcherPane.setVisible(true); - this.adapter.setVisible(false); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - if (!this._allData) { - o.itemsCreator({ - type: BI.MultiSelectList.REQ_GET_ALL_DATA - }, function (ob) { - self._allData = BI.map(ob.items, "value"); - digest(self._allData); - }); - } else { - digest(this._allData); - } - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); - } - }); - self._adjust(callback); - } - }, - - _joinAll: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - o.itemsCreator({ - type: BI.MultiSelectList.REQ_GET_ALL_DATA, - keywords: [this.trigger.getKey()] - }, function (ob) { - var items = BI.map(ob.items, "value"); - if (self.storeValue.type === res.type) { - var change = false; - var map = self._makeMap(self.storeValue.value); - BI.each(items, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (self.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - var selectedMap = self._makeMap(self.storeValue.value); - var notSelectedMap = self._makeMap(res.value); - var newItems = []; - BI.each(items, function (i, item) { - if (BI.isNotNull(selectedMap[items[i]])) { - delete selectedMap[items[i]]; - } - if (BI.isNull(notSelectedMap[items[i]])) { - newItems.push(item); - } - }); - self.storeValue.value = newItems.concat(BI.values(selectedMap)); - self._adjust(callback); - }); - }, - - _adjust: function (callback) { - var self = this, o = this.options; - if (!this._count) { - o.itemsCreator({ - type: BI.MultiSelectList.REQ_GET_DATA_LENGTH - }, function (res) { - self._count = res.count; - adjust(); - callback(); - }); - } else { - adjust(); - callback(); - } - - function adjust () { - if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.Multi, - value: [] - }; - } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.All, - value: [] - }; - } - } - }, - - _join: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this._assertValue(this.storeValue); - if (this.storeValue.type === res.type) { - var map = this._makeMap(this.storeValue.value); - BI.each(res.value, function (i, v) { - if (!map[v]) { - self.storeValue.value.push(v); - map[v] = v; - } - }); - var change = false; - BI.each(res.assist, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (this.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - this._joinAll(res, callback); - }, - - _setStartValue: function (value) { - this._startValue = value; - this.adapter.setStartValue(value); - }, - - isAllSelected: function () { - return this.adapter.isAllSelected(); - }, - - resize: function () { - // this.trigger.getCounter().adjustView(); - // this.trigger.adjustView(); - }, - setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.adapter.setValue(this.storeValue); - this.trigger.setValue(this.storeValue); - }, - - getValue: function () { - return BI.deepClone(this.storeValue); - }, - - populate: function () { - this._count = null; - this._allData = null; - this.adapter.populate.apply(this.adapter, arguments); - this.trigger.populate.apply(this.trigger, arguments); - } -}); - -BI.extend(BI.MultiSelectList, { - REQ_GET_DATA_LENGTH: 1, - REQ_GET_ALL_DATA: -1 -}); - -BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/** - * Created by zcf_1 on 2017/5/11. - */ -BI.MultiSelectTree = BI.inherit(BI.Single, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-tree", - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiSelectTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = {value: {}}; - - this.adapter = BI.createWidget({ - type: "bi.multi_select_tree_popup", - itemsCreator: o.itemsCreator - }); - this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { - if (self.searcher.isSearching()) { - self.storeValue = {value: self.searcherPane.getValue()}; - } else { - self.storeValue = {value: self.adapter.getValue()}; - } - self.setSelectedValue(self.storeValue.value); - self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); - }); - - // 搜索中的时候用的是parttree,同adapter中的synctree不一样 - this.searcherPane = BI.createWidget({ - type: "bi.multi_tree_search_pane", - cls: "bi-border-left bi-border-right bi-border-bottom", - keywordGetter: function () { - return self.searcher.getKeyword(); - }, - itemsCreator: function (op, callback) { - op.keyword = self.searcher.getKeyword(); - o.itemsCreator(op, callback); - } - }); - this.searcherPane.setVisible(false); - - this.searcher = BI.createWidget({ - type: "bi.searcher", - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback({ - keyword: self.searcher.getKeyword() - }); - }, - adapter: this.adapter, - popup: this.searcherPane, - masker: false, - listeners: [{ - eventName: BI.Searcher.EVENT_START, - action: function () { - self._showSearcherPane(); - // self.storeValue = {value: self.adapter.getValue()}; - // self.searcherPane.setSelectedValue(self.storeValue.value); - } - }, { - eventName: BI.Searcher.EVENT_STOP, - action: function () { - self._showAdapter(); - // self.storeValue = {value: self.searcherPane.getValue()}; - // self.adapter.setSelectedValue(self.storeValue.value); - BI.nextTick(function () { - self.adapter.populate(); - }); - } - }, { - eventName: BI.Searcher.EVENT_CHANGE, - action: function () { - if (self.searcher.isSearching()) { - self.storeValue = {value: self.searcherPane.getValue()}; - } else { - self.storeValue = {value: self.adapter.getValue()}; - } - self.setSelectedValue(self.storeValue.value); - self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); - } - }, { - eventName: BI.Searcher.EVENT_PAUSE, - action: function () { - self._showAdapter(); - } - }] - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.searcher, - height: 24 - }, { - el: this.adapter, - height: "fill" - }] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.searcherPane, - top: 30, - bottom: 0, - left: 0, - right: 0 - }] - }); - - }, - - _showAdapter: function () { - this.adapter.setVisible(true); - this.searcherPane.setVisible(false); - }, - - _showSearcherPane: function () { - this.searcherPane.setVisible(true); - this.adapter.setVisible(false); - }, - - resize: function () { - - }, - - setSelectedValue: function (v) { - this.storeValue.value = v || {}; - this.adapter.setSelectedValue(v); - this.searcherPane.setSelectedValue(v); - this.searcher.setValue({ - value: v || {} - }); - }, - - setValue: function (v) { - this.adapter.setValue(v); - }, - - stopSearch: function () { - this.searcher.stopSearch(); - }, - - updateValue: function (v) { - this.adapter.updateValue(v); - }, - - getValue: function () { - return this.storeValue.value; - }, - - populate: function () { - this.searcher.populate.apply(this.searcher, arguments); - this.adapter.populate.apply(this.adapter, arguments); - } -}); -BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** - * Created by zcf on 2016/12/21. - */ -BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom", - itemsCreator: BI.emptyFn - }); - }, - _init: function () { - BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.popup = BI.createWidget({ - type: "bi.async_tree", - element: this, - itemsCreator: o.itemsCreator - }); - this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { - self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT); - }); - this.popup.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE); - }); - }, - - hasChecked: function () { - return this.popup.hasChecked(); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - setValue: function (v) { - v || (v = {}); - this.popup.setValue(v); - }, - - setSelectedValue: function (v) { - v || (v = {}); - this.popup.setSelectedValue(v); - }, - - updateValue: function (v) { - this.popup.updateValue(v); - this.popup.refresh(); - }, - - populate: function (config) { - this.popup.stroke(config); - } - -}); -BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; -BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; -BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/** - * - * @class BI.MultiTreeCheckPane - * @extends BI.Pane - */ -BI.MultiTreeCheckPane = BI.inherit(BI.Pane, { - - constants: { - height: 25, - lgap: 10, - tgap: 5 - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-check-pane bi-background", - onClickContinueSelect: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiTreeCheckPane.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - - this.selectedValues = {}; - - var continueSelect = BI.createWidget({ - type: "bi.text_button", - text: BI.i18nText("BI-Continue_Select"), - cls: "multi-tree-check-selected" - }); - continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { - opts.onClickContinueSelect(); - BI.nextTick(function () { - self.empty(); - }); - }); - - var backToPopup = BI.createWidget({ - type: "bi.left", - cls: "multi-tree-continue-select", - items: [ - { - el: { - type: "bi.label", - text: BI.i18nText("BI-Selected_Data") - }, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }, - { - el: continueSelect, - lgap: this.constants.lgap, - tgap: this.constants.tgap - }] - }); - - this.display = BI.createWidget({ - type: "bi.display_tree", - cls: "bi-multi-tree-display", - itemsCreator: function (op, callback) { - op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA; - opts.itemsCreator(op, callback); - }, - value: (opts.value || {}).value - }); - - this.display.on(BI.Events.AFTERINIT, function () { - self.fireEvent(BI.Events.AFTERINIT); - }); - - this.display.on(BI.TreeView.EVENT_INIT, function () { - backToPopup.setVisible(false); - }); - - this.display.on(BI.TreeView.EVENT_AFTERINIT, function () { - backToPopup.setVisible(true); - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - height: this.constants.height, - el: backToPopup - }, { - height: "fill", - el: this.display - }] - }); - - }, - - empty: function () { - this.display.empty(); - }, - - populate: function (configs) { - this.display.stroke(configs); - }, - - setValue: function (v) { - v || (v = {}); - this.display.setSelectedValue(v.value); - }, - - getValue: function () { - - } -}); - -BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK"; - - -BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/** - * - * @class BI.MultiTreeCombo - * @extends BI.Single - */ - -BI.MultiTreeCombo = BI.inherit(BI.Single, { - - constants: { - offset: { - top: 0, - left: 0, - right: 0, - bottom: 31 - } - }, - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-combo", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - height: 24 - }); - }, - - _init: function () { - BI.MultiTreeCombo.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - var isInit = false; - var want2showCounter = false; - - this.storeValue = {value: o.value || {}}; - - this.trigger = BI.createWidget({ - type: "bi.multi_select_trigger", - height: o.height, - valueFormatter: o.valueFormatter, - // adapter: this.popup, - masker: { - offset: this.constants.offset - }, - searcher: { - type: "bi.multi_tree_searcher", - itemsCreator: o.itemsCreator - }, - switcher: { - el: { - type: "bi.multi_tree_check_selected_button" - }, - popup: { - type: "bi.multi_tree_check_pane", - itemsCreator: o.itemsCreator - } - }, - value: {value: o.value || {}} - - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - el: this.trigger, - adjustLength: 1, - popup: { - type: "bi.multi_tree_popup_view", - ref: function () { - self.popup = this; - self.trigger.setAdapter(this); - }, - listeners: [{ - eventName: BI.MultiTreePopup.EVENT_AFTERINIT, - action: function () { - self.trigger.getCounter().adjustView(); - isInit = true; - if (want2showCounter === true) { - showCounter(); - } - } - }, { - eventName: BI.MultiTreePopup.EVENT_CHANGE, - action: function () { - change = true; - var val = { - type: BI.Selection.Multi, - value: this.hasChecked() ? this.getValue() : {} - }; - self.trigger.getSearcher().setState(val); - self.trigger.getCounter().setButtonChecked(val); - } - }, { - eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, - action: function () { - self.combo.hideView(); - } - }, { - eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, - action: function () { - clear = true; - self.setValue(); - self._defaultState(); - } - }], - itemsCreator: o.itemsCreator, - onLoaded: function () { - BI.nextTick(function () { - self.trigger.getCounter().adjustView(); - self.trigger.getSearcher().adjustView(); - }); - } - }, - value: {value: o.value || {}}, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - } - }); - - var change = false; - var clear = false; // 标识当前是否点击了清空 - - var isSearching = function () { - return self.trigger.getSearcher().isSearching(); - }; - - var isPopupView = function () { - return self.combo.isViewVisible(); - }; - - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self.storeValue = {value: self.combo.getValue()}; - this.setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self.storeValue = {value: this.getValue()}; - self.combo.setValue(self.storeValue); - BI.nextTick(function () { - if (isPopupView()) { - self.combo.populate(); - } - }); - }); - - function showCounter () { - if (isSearching()) { - self.storeValue = {value: self.trigger.getValue()}; - } else if (isPopupView()) { - self.storeValue = {value: self.combo.getValue()}; - } - self.trigger.setValue(self.storeValue); - } - - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - if (want2showCounter === false) { - want2showCounter = true; - } - if (isInit === true) { - want2showCounter = null; - showCounter(); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () { - self.combo.toggle(); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () { - var checked = this.getSearcher().hasChecked(); - var val = { - type: BI.Selection.Multi, - value: checked ? {1: 1} : {} - }; - this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None); - this.getCounter().setButtonChecked(val); - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.element.removeClass("combo-show").addClass("combo-show"); - if (isSearching()) { - return; - } - if (change === true) { - self.storeValue = {value: self.combo.getValue()}; - change = false; - } - self.combo.setValue(self.storeValue); - self.populate(); - - }); - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self.element.removeClass("combo-show"); - if (isSearching()) { - self.trigger.stopEditing(); - self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); - } else { - if (isPopupView()) { - self.trigger.stopEditing(); - self.storeValue = {value: self.combo.getValue()}; - if (clear === true) { - self.storeValue = {value: {}}; - } - self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); - } - } - clear = false; - change = false; - }); - - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.trigger.getCounter().hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }] - }); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - this.combo.hideView(); - }, - - setValue: function (v) { - this.storeValue.value = v || {}; - this.combo.setValue({ - value: v || {} - }); - }, - - getValue: function () { - return this.storeValue.value; - }, - - populate: function () { - this.combo.populate.apply(this.combo, arguments); - } -}); - -BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM"; - -BI.shortcut("bi.multi_tree_combo", BI.MultiTreeCombo);/** - * 带加载的多选下拉面板 - * @class BI.MultiTreePopup - * @extends BI.Pane - */ -BI.MultiTreePopup = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-popup", - maxWidth: "auto", - minWidth: 100, - maxHeight: 400, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiTreePopup.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - - this.selectedValues = {}; - - this.tree = BI.createWidget({ - type: "bi.async_tree", - height: 400, - cls: "popup-view-tree", - itemsCreator: opts.itemsCreator, - onLoaded: opts.onLoaded, - value: opts.value || {} - }); - - this.popupView = BI.createWidget({ - type: "bi.multi_popup_view", - element: this, - stopPropagation: false, - maxWidth: opts.maxWidth, - minWidth: opts.minWidth, - maxHeight: opts.maxHeight, - buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], - el: this.tree - }); - - this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { - switch (index) { - case 0: - self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR); - break; - case 1: - self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM); - break; - } - }); - - this.tree.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE); - }); - - this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () { - self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT); - }); - - }, - - getValue: function () { - return this.tree.getValue(); - }, - - setValue: function (v) { - v || (v = {}); - this.tree.setSelectedValue(v.value); - }, - - populate: function (config) { - this.tree.stroke(config); - }, - - hasChecked: function () { - return this.tree.hasChecked(); - }, - - resetHeight: function (h) { - this.popupView.resetHeight(h); - }, - - resetWidth: function (w) { - this.popupView.resetWidth(w); - } -}); - -BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; -BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; -BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT"; - - -BI.shortcut("bi.multi_tree_popup_view", BI.MultiTreePopup);/** - * - * 在搜索框中输入文本弹出的面板 - * @class BI.MultiTreeSearchPane - * @extends BI.Pane - */ - -BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-search-pane bi-card", - itemsCreator: BI.emptyFn, - keywordGetter: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiTreeSearchPane.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - - this.partTree = BI.createWidget({ - type: "bi.part_tree", - element: this, - tipText: BI.i18nText("BI-No_Select"), - itemsCreator: function (op, callback) { - op.keyword = opts.keywordGetter(); - opts.itemsCreator(op, callback); - }, - value: opts.value - }); - - this.partTree.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.partTree.on(BI.TreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); - }); - }, - - hasChecked: function () { - return this.partTree.hasChecked(); - }, - - setValue: function (v) { - this.setSelectedValue(v.value); - }, - - setSelectedValue: function (v) { - v || (v = {}); - this.partTree.setSelectedValue(v); - }, - - getValue: function () { - return this.partTree.getValue(); - }, - - empty: function () { - this.partTree.empty(); - }, - - populate: function (op) { - this.partTree.stroke.apply(this.partTree, arguments); - } -}); - -BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; -BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; - -BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/** - * 查看已选按钮 - * Created by guy on 15/11/3. - * @class BI.MultiTreeCheckSelectedButton - * @extends BI.Single - */ -BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-check-selected-button", - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments); - var self = this; - this.indicator = BI.createWidget({ - type: "bi.icon_button", - cls: "check-font trigger-check-selected icon-size-12", - width: 15, - height: 15, - stopPropagation: true - }); - - this.checkSelected = BI.createWidget({ - type: "bi.text_button", - cls: "trigger-check-selected", - invisible: true, - hgap: 4, - text: BI.i18nText("BI-Check_Selected"), - textAlign: "center", - textHeight: 15 - }); - this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); - }); - - BI.createWidget({ - type: "bi.horizontal", - element: this, - items: [this.indicator, this.checkSelected] - }); - - this.element.hover(function () { - self.indicator.setVisible(false); - self.checkSelected.setVisible(true); - }, function () { - self.indicator.setVisible(true); - self.checkSelected.setVisible(false); - }); - this.setVisible(false); - }, - - setValue: function (v) { - v || (v = {}); - this.setVisible(BI.size(v.value) > 0); - } -}); - -BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.multi_tree_check_selected_button", BI.MultiTreeCheckSelectedButton);/** - * searcher - * Created by guy on 15/11/3. - * @class BI.MultiTreeSearcher - * @extends Widget - */ -BI.MultiTreeSearcher = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-tree-searcher", - itemsCreator: BI.emptyFn, - valueFormatter: function (v) { - return v; - }, - popup: {}, - - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.MultiTreeSearcher.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.multi_select_editor", - height: o.height, - el: { - type: "bi.simple_state_editor", - height: o.height - } - }); - - this.searcher = BI.createWidget({ - type: "bi.searcher", - element: this, - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback({ - keyword: self.editor.getValue() - }); - }, - el: this.editor, - - popup: BI.extend({ - type: "bi.multi_tree_search_pane", - keywordGetter: function () { - return self.editor.getValue(); - }, - itemsCreator: function (op, callback) { - op.keyword = self.editor.getValue(); - o.itemsCreator(op, callback); - }, - value: o.value - }, o.popup), - - adapter: o.adapter, - masker: o.masker - }); - this.searcher.on(BI.Searcher.EVENT_START, function () { - self.fireEvent(BI.MultiTreeSearcher.EVENT_START); - }); - this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { - if (this.hasMatched()) { - - } - self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE); - }); - this.searcher.on(BI.Searcher.EVENT_STOP, function () { - self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP); - }); - this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { - self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments); - }); - if (BI.isNotNull(o.value)) { - this.setState(o.value); - } - }, - - adjustView: function () { - this.searcher.adjustView(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - }, - - isSearching: function () { - return this.searcher.isSearching(); - }, - - stopSearch: function () { - this.searcher.stopSearch(); - }, - - getKeyword: function () { - return this.editor.getValue(); - }, - - hasMatched: function () { - return this.searcher.hasMatched(); - }, - - hasChecked: function () { - return this.searcher.getView() && this.searcher.getView().hasChecked(); - }, - - setState: function (ob) { - var o = this.options; - ob || (ob = {}); - ob.value || (ob.value = {}); - var count = 0; - if (BI.isNumber(ob)) { - this.editor.setState(ob); - } else if (BI.size(ob.value) === 0) { - this.editor.setState(BI.Selection.None); - } else { - var text = ""; - BI.each(ob.value, function (name, children) { - var childNodes = getChildrenNode(children); - text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + "; "; - if (childNodes === "") { - count++; - } - }); - - if (count > 20) { - this.editor.setState(BI.Selection.Multi); - } else { - this.editor.setState(text); - } - } - - function getChildrenNode (ob) { - var text = ""; - var index = 0, size = BI.size(ob); - BI.each(ob, function (name, children) { - index++; - var childNodes = getChildrenNode(children); - text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ","); - if (childNodes === "") { - count++; - } - }); - return text; - } - }, - - setValue: function (ob) { - this.setState(ob); - this.searcher.setValue(ob); - }, - - getKey: function () { - return this.editor.getValue(); - }, - - getValue: function () { - return this.searcher.getValue(); - }, - - populate: function (items) { - this.searcher.populate.apply(this.searcher, arguments); - } -}); - -BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE"; -BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; -BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; -BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -BI.shortcut("bi.multi_tree_searcher", BI.MultiTreeSearcher);/** - * Created by windy on 2017/3/13. - * 数值微调器 - */ -BI.NumberEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-number-editor bi-border", - validationChecker: function () { - return true; - }, - valueFormatter: function (v) { - return v; - }, - value: 0, - allowBlank: false, - errorText: "", - step: 1 - }); - }, - - _init: function () { - BI.NumberEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - allowBlank: o.allowBlank, - value: o.valueFormatter(o.value), - validationChecker: o.validationChecker, - errorText: o.errorText - }); - this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { - o.value = BI.parseFloat(this.getValue()); - self.fireEvent(BI.NumberEditor.EVENT_CHANGE); - }); - this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { - this.setValue(BI.parseFloat(this.getValue())); - self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); - }); - this.topBtn = BI.createWidget({ - type: "bi.icon_button", - forceNotSelected: true, - trigger: "lclick,", - cls: "add-up-font top-button bi-border-left bi-list-item-active3 icon-size-12" - }); - this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._finetuning(o.step); - self.fireEvent(BI.NumberEditor.EVENT_CHANGE); - self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); - }); - this.bottomBtn = BI.createWidget({ - type: "bi.icon_button", - trigger: "lclick,", - forceNotSelected: true, - cls: "minus-down-font bottom-button bi-border-left bi-list-item-active3 icon-size-12" - }); - this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { - self._finetuning(-o.step); - self.fireEvent(BI.NumberEditor.EVENT_CHANGE); - self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); - }); - BI.createWidget({ - type: "bi.htape", - element: this, - items: [this.editor, { - el: { - type: "bi.grid", - columns: 1, - rows: 2, - items: [{ - column: 0, - row: 0, - el: this.topBtn - }, { - column: 0, - row: 1, - el: this.bottomBtn - }] - }, - width: 23 - }] - }); - }, - - focus: function () { - this.editor.focus(); - }, - - // 微调 - _finetuning: function (add) { - var v = BI.parseFloat(this.getValue()); - this.setValue(v.add(add)); - }, - - setUpEnable: function (v) { - this.topBtn.setEnable(!!v); - }, - - setDownEnable: function (v) { - this.bottomBtn.setEnable(!!v); - }, - - getValue: function () { - return this.options.value; - }, - - setValue: function (v) { - var o = this.options; - o.value = v; - this.editor.setValue(o.valueFormatter(v)); - } - -}); -BI.NumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.NumberEditor.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.number_editor", BI.NumberEditor);// 小于号的值为:0,小于等于号的值为:1 -// closeMIn:最小值的符号,closeMax:最大值的符号 -/** - * Created by roy on 15/9/17. - * - */ -BI.NumberInterval = BI.inherit(BI.Single, { - constants: { - typeError: "typeBubble", - numberError: "numberBubble", - signalError: "signalBubble", - editorWidth: 114, - columns: 5, - width: 24, - rows: 1, - numberErrorCls: "number-error", - border: 1, - less: 0, - less_equal: 1, - numTip: "", - adjustYOffset: 2 - }, - _defaultConfig: function () { - var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-number-interval", - height: 24, - validation: "valid", - closeMin: true - }); - }, - _init: function () { - var self = this, c = this.constants, o = this.options; - BI.NumberInterval.superclass._init.apply(this, arguments); - this.smallEditor = BI.createWidget({ - type: "bi.editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - allowBlank: true, - value: o.min, - level: "warning", - tipType: "warning", - quitChecker: function () { - return false; - }, - validationChecker: function (v) { - if (!BI.isNumeric(v)) { - self.smallEditorBubbleType = c.typeError; - return false; - } - return true; - }, - cls: "number-interval-small-editor bi-border-top bi-border-bottom bi-border-left" - }); - - this.smallTip = BI.createWidget({ - type: "bi.label", - text: o.numTip, - height: o.height - 2, - invisible: true - }); - BI.createWidget({ - type: "bi.absolute", - element: this.smallEditor.element, - items: [{ - el: this.smallTip, - top: 0, - right: 5 - }] - }); - - this.bigEditor = BI.createWidget({ - type: "bi.editor", - height: o.height - 2, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - allowBlank: true, - value: o.max, - level: "warning", - tipType: "warning", - quitChecker: function () { - return false; - }, - validationChecker: function (v) { - if (!BI.isNumeric(v)) { - self.bigEditorBubbleType = c.typeError; - return false; - } - return true; - }, - cls: "number-interval-big-editor bi-border-top bi-border-bottom bi-border-right" - }); - - this.bigTip = BI.createWidget({ - type: "bi.label", - text: o.numTip, - height: o.height - 2, - invisible: true - }); - BI.createWidget({ - type: "bi.absolute", - element: this.bigEditor.element, - items: [{ - el: this.bigTip, - top: 0, - right: 5 - }] - }); - - // this.smallCombo = BI.createWidget({ - // type: "bi.number_interval_combo", - // cls: "number-interval-small-combo", - // height: o.height, - // value: o.closemin ? 1 : 0, - // offsetStyle: "left" - // }); - // - // this.bigCombo = BI.createWidget({ - // type: "bi.number_interval_combo", - // cls: "number-interval-big-combo", - // height: o.height, - // value: o.closemax ? 1 : 0, - // offsetStyle: "left" - // }); - this.smallCombo = BI.createWidget({ - type: "bi.icon_combo", - cls: "number-interval-small-combo bi-border", - height: o.height - 2, - items: [{ - text: "(" + BI.i18nText("BI-Less_Than") + ")", - iconCls: "less-font", - value: 0 - }, { - text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", - value: 1, - iconCls: "less-equal-font" - }] - }); - if (o.closeMin === true) { - this.smallCombo.setValue(1); - } else { - this.smallCombo.setValue(0); - } - this.bigCombo = BI.createWidget({ - type: "bi.icon_combo", - cls: "number-interval-big-combo bi-border", - height: o.height - 2, - items: [{ - text: "(" + BI.i18nText("BI-Less_Than") + ")", - iconCls: "less-font", - value: 0 - }, { - text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", - value: 1, - iconCls: "less-equal-font" - }] - }); - if (o.closeMax === true) { - this.bigCombo.setValue(1); - } else { - this.bigCombo.setValue(0); - } - this.label = BI.createWidget({ - type: "bi.label", - text: BI.i18nText("BI-Basic_Value"), - textHeight: o.height - c.border * 2, - width: c.width - c.border * 2, - height: o.height - c.border * 2, - level: "warning", - tipType: "warning" - }); - this.left = BI.createWidget({ - type: "bi.htape", - items: [{ - el: self.smallEditor - }, { - el: self.smallCombo, - width: c.width - c.border * 2 - }] - - }); - this.right = BI.createWidget({ - type: "bi.htape", - items: [{ - el: self.bigCombo, - width: c.width - c.border * 2 - }, { - el: self.bigEditor, - // BI-23883 间距考虑边框 - lgap: 1 - }] - }); - - - BI.createWidget({ - element: self, - type: "bi.center", - hgap: 15, - height: o.height, - items: [ - { - type: "bi.absolute", - items: [{ - el: self.left, - left: -15, - right: 0, - top: 0, - bottom: 0 - }] - }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: 0, - right: -15, - top: 0, - bottom: 0 - }] - } - ] - }); - - BI.createWidget({ - element: self, - type: "bi.horizontal_auto", - items: [ - self.label - ] - }); - - - self._setValidEvent(self.bigEditor, c.bigEditor); - self._setValidEvent(self.smallEditor, c.smallEditor); - self._setErrorEvent(self.bigEditor, c.bigEditor); - self._setErrorEvent(self.smallEditor, c.smallEditor); - self._setBlurEvent(self.bigEditor); - self._setBlurEvent(self.smallEditor); - self._setFocusEvent(self.bigEditor); - self._setFocusEvent(self.smallEditor); - self._setComboValueChangedEvent(self.bigCombo); - self._setComboValueChangedEvent(self.smallCombo); - self._setEditorValueChangedEvent(self.bigEditor); - self._setEditorValueChangedEvent(self.smallEditor); - }, - - _checkValidation: function () { - var self = this, c = this.constants, o = this.options; - self._setTitle(""); - BI.Bubbles.hide(c.typeError); - BI.Bubbles.hide(c.numberError); - BI.Bubbles.hide(c.signalError); - if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) { - self.element.removeClass("number-error"); - o.validation = "invalid"; - return c.typeError; - } - if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { - self.element.removeClass("number-error"); - o.validation = "valid"; - return ""; - } - var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()), - bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue(); - if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) { - if (smallValue > bigValue) { - self.element.addClass("number-error"); - o.validation = "invalid"; - return c.numberError; - } - self.element.removeClass("number-error"); - o.validation = "valid"; - return ""; - - } - if (smallValue > bigValue) { - self.element.addClass("number-error"); - o.validation = "invalid"; - return c.numberError; - } else if (smallValue === bigValue) { - self.element.addClass("number-error"); - o.validation = "invalid"; - return c.signalError; - } - self.element.removeClass("number-error"); - o.validation = "valid"; - return ""; - - - - - - }, - - _setTitle: function (v) { - var self = this; - self.bigEditor.setTitle(v); - self.smallEditor.setTitle(v); - self.label.setTitle(v); - }, - - _setFocusEvent: function (w) { - var self = this, c = this.constants; - w.on(BI.Editor.EVENT_FOCUS, function () { - self._setTitle(""); - switch (self._checkValidation()) { - case c.typeError: - BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - break; - case c.numberError: - BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - break; - default : - return; - } - - }); - }, - _setBlurEvent: function (w) { - var c = this.constants, self = this; - w.on(BI.Editor.EVENT_BLUR, function () { - BI.Bubbles.hide(c.typeError); - BI.Bubbles.hide(c.numberError); - BI.Bubbles.hide(c.signalError); - switch (self._checkValidation()) { - case c.typeError: - self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); - break; - case c.numberError: - self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); - break; - case c.signalError: - self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); - break; - default: - self._setTitle(""); - } - }); - }, - - _setErrorEvent: function (w) { - var c = this.constants, self = this; - w.on(BI.Editor.EVENT_ERROR, function () { - self._checkValidation(); - BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - }); - }, - - - _setValidEvent: function (w) { - var self = this, c = this.constants; - w.on(BI.Editor.EVENT_VALID, function () { - switch (self._checkValidation()) { - case c.numberError: - BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - break; - default: - self.fireEvent(BI.NumberInterval.EVENT_VALID); - } - }); - }, - - - _setEditorValueChangedEvent: function (w) { - var self = this, c = this.constants; - w.on(BI.Editor.EVENT_CHANGE, function () { - switch (self._checkValidation()) { - case c.typeError: - BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - break; - case c.numberError: - BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - break; - case c.signalError: - BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { - offsetStyle: "left", - adjustYOffset: c.adjustYOffset - }); - break; - default : - break; - } - self.fireEvent(BI.NumberInterval.EVENT_CHANGE); - }); - w.on(BI.Editor.EVENT_CONFIRM, function () { - self.fireEvent(BI.NumberInterval.EVENT_CONFIRM); - }); - }, - - _setComboValueChangedEvent: function (w) { - var self = this, c = this.constants; - w.on(BI.IconCombo.EVENT_CHANGE, function () { - switch (self._checkValidation()) { - case c.typeError: - self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - break; - case c.numberError: - self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - break; - case c.signalError: - self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); - self.fireEvent(BI.NumberInterval.EVENT_ERROR); - break; - default : - self.fireEvent(BI.NumberInterval.EVENT_CHANGE); - self.fireEvent(BI.NumberInterval.EVENT_CONFIRM); - self.fireEvent(BI.NumberInterval.EVENT_VALID); - } - }); - }, - - isStateValid: function () { - return this.options.validation === "valid"; - }, - - setMinEnable: function (b) { - this.smallEditor.setEnable(b); - }, - - setCloseMinEnable: function (b) { - this.smallCombo.setEnable(b); - }, - - setMaxEnable: function (b) { - this.bigEditor.setEnable(b); - }, - - setCloseMaxEnable: function (b) { - this.bigCombo.setEnable(b); - }, - - showNumTip: function () { - this.smallTip.setVisible(true); - this.bigTip.setVisible(true); - }, - - hideNumTip: function () { - this.smallTip.setVisible(false); - this.bigTip.setVisible(false); - }, - - setNumTip: function (numTip) { - this.smallTip.setText(numTip); - this.bigTip.setText(numTip); - }, - - getNumTip: function () { - return this.smallTip.getText(); - }, - - setValue: function (data) { - data = data || {}; - var self = this, combo_value; - if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) { - self.smallEditor.setValue(data.min); - } - - if (!BI.isNotNull(data.min)) { - self.smallEditor.setValue(""); - } - - if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) { - self.bigEditor.setValue(data.max); - } - - if (!BI.isNotNull(data.max)) { - self.bigEditor.setValue(""); - } - - if (!BI.isNull(data.closeMin)) { - if (data.closeMin === true) { - combo_value = 1; - } else { - combo_value = 0; - } - self.smallCombo.setValue(combo_value); - } - - if (!BI.isNull(data.closeMax)) { - if (data.closeMax === true) { - combo_value = 1; - } else { - combo_value = 0; - } - self.bigCombo.setValue(combo_value); - } - }, - - - getValue: function () { - var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue(); - value.min = self.smallEditor.getValue(); - value.max = self.bigEditor.getValue(); - if (minComboValue[0] === 0) { - value.closeMin = false; - } else { - value.closeMin = true; - } - - if (maxComboValue[0] === 0) { - value.closeMax = false; - } else { - value.closeMax = true; - } - return value; - } -}); -BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.NumberInterval.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.NumberInterval.EVENT_VALID = "EVENT_VALID"; -BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.shortcut("bi.number_interval", BI.NumberInterval);/** - * - * 表格 - * - * Created by GUY on 2015/9/22. - * @class BI.PageTableCell - * @extends BI.Single - */ -BI.PageTableCell = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-page-table-cell", - text: "", - title: "" - }); - }, - - _init: function () { - BI.PageTableCell.superclass._init.apply(this, arguments); - var label = BI.createWidget({ - type: "bi.label", - element: this, - textAlign: "left", - whiteSpace: "nowrap", - height: this.options.height, - text: this.options.text, - title: this.options.title, - value: this.options.value, - lgap: 5, - rgap: 5 - }); - - if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { - this.element.css(this.options.styles); - } - } -}); - -BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** - * 分页表格 - * - * Created by GUY on 2016/2/15. - * @class BI.PageTable - * @extends BI.Widget - */ -BI.PageTable = BI.inherit(BI.Widget, { - - _const: { - scrollWidth: 18, - minScrollWidth: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-page-table", - el: { - type: "bi.sequence_table" - }, - pager: { - horizontal: { - pages: false, // 总页数 - curr: 1, // 初始化当前页, pages为数字时可用 - - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, - firstPage: 1, - lastPage: BI.emptyFn - }, - vertical: { - pages: false, // 总页数 - curr: 1, // 初始化当前页, pages为数字时可用 - - hasPrev: BI.emptyFn, - hasNext: BI.emptyFn, - firstPage: 1, - lastPage: BI.emptyFn - } - }, - - itemsCreator: BI.emptyFn, - - isNeedFreeze: false, // 是否需要冻结单元格 - freezeCols: [], // 冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false, // 是否需要合并单元格 - mergeCols: [], // 合并的单元格列号 - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], // 二维数组 - - // 交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.PageTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.hCurr = 1; - this.vCurr = 1; - - this.table = BI.createWidget(o.el, { - type: "bi.sequence_table", - width: o.width, - height: o.height && o.height - 30, - - isNeedResize: true, - isResizeAdapt: false, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter, - - header: o.header, - items: o.items, - // 交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - - this.pager = BI.createWidget(o.pager, { - type: "bi.direction_pager", - height: 30 - }); - this.pager.on(BI.Pager.EVENT_CHANGE, function () { - var vpage = this.getVPage && this.getVPage(); - if (BI.isNull(vpage)) { - vpage = this.getCurrentPage(); - } - var hpage = this.getHPage && this.getHPage(); - o.itemsCreator({ - vpage: vpage, - hpage: hpage - }, function (items, header, crossItems, crossHeader) { - self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); - self.table.setHPage && self.table.setHPage(hpage); - self.populate.apply(self, arguments); - }); - }); - - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.table, - left: 0, - top: 0 - }, { - el: this.pager, - left: 0, - right: 0, - bottom: 0 - }] - }); - }, - - setHPage: function (v) { - this.hCurr = v; - this.pager.setHPage && this.pager.setHPage(v); - this.table.setHPage && this.table.setHPage(v); - }, - - setVPage: function (v) { - this.vCurr = v; - this.pager.setVPage && this.pager.setVPage(v); - this.table.setVPage && this.table.setVPage(v); - }, - - getHPage: function () { - var hpage = this.pager.getHPage && this.pager.getHPage(); - if (BI.isNotNull(hpage)) { - return hpage; - } - hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); - if (BI.isNotNull(hpage)) { - return hpage; - } - return this.hpage; - }, - - getVPage: function () { - var vpage = this.pager.getVPage && this.pager.getVPage(); - if (BI.isNotNull(vpage)) { - return vpage; - } - vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); - if (BI.isNotNull(vpage)) { - return vpage; - } - return this.vpage; - }, - - setWidth: function (width) { - BI.PageTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(width); - }, - - setHeight: function (height) { - BI.PageTable.superclass.setHeight.apply(this, arguments); - var showPager = false; - if (this.pager.alwaysShowPager) { - showPager = true; - } else if (this.pager.hasHNext && this.pager.hasHNext()) { - showPager = true; - } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { - showPager = true; - } else if (this.pager.hasVNext && this.pager.hasVNext()) { - showPager = true; - } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { - showPager = true; - } else if (this.pager.hasNext && this.pager.hasNext()) { - showPager = true; - } else if (this.pager.hasPrev && this.pager.hasPrev()) { - showPager = true; - } - this.table.setHeight(height - (showPager ? 30 : 0)); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - restore: function () { - this.table.restore(); - }, - - attr: function () { - BI.PageTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - }, - - populate: function () { - this.pager.populate(); - this.table.populate.apply(this.table, arguments); - }, - - destroy: function () { - this.table.destroy(); - this.pager && this.pager.destroy(); - BI.PageTable.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut("bi.page_table", BI.PageTable);/** - * 预览表列 +/** * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTableCell + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableTreeNumber * @extends BI.Widget */ -BI.PreviewTableCell = BI.inherit(BI.Widget, { +BI.SequenceTableTreeNumber = BI.inherit(BI.Widget, { _defaultConfig: function () { - return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table-cell", - text: "" - }); - }, + return BI.extend(BI.SequenceTableTreeNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-tree-number", + isNeedFreeze: false, + startSequence: 1, // 开始的序号 + scrollTop: 0, + headerRowSize: 25, + rowSize: 25, - _init: function () { - BI.PreviewTableCell.superclass._init.apply(this, arguments); - var self = this, o = this.options; + sequenceHeaderCreator: BI.emptyFn, - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: o.textAlign || "left", - whiteSpace: o.whiteSpace || "normal", - height: this.options.height, - text: this.options.text, - value: this.options.value, - lgap: o.lgap, - rgap: o.rgap, - hgap: o.hgap || 5 - }); - } -}); -BI.shortcut("bi.preview_table_cell", BI.PreviewTableCell);/** - * 预览表 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTableHeaderCell - * @extends BI.Widget - */ -BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { + header: [], + items: [], // 二维数组 - _defaultConfig: function () { - return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table-header-cell", - text: "" + // 交叉表头 + crossHeader: [], + crossItems: [] }); }, _init: function () { - BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); + BI.SequenceTableTreeNumber.superclass._init.apply(this, arguments); var self = this, o = this.options; + this.vCurr = 1; + this.hCurr = 1; + this.tasks = []; + this.renderedCells = []; + this.renderedKeys = []; - BI.createWidget({ - type: "bi.label", - element: this, - textAlign: o.textAlign || "left", - whiteSpace: o.whiteSpace || "normal", - height: this.options.height, - text: this.options.text, - value: this.options.value, - lgap: o.lgap, - rgap: o.rgap, - hgap: o.hgap || 5 + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false }); - } -}); -BI.shortcut("bi.preview_table_header_cell", BI.PreviewTableHeaderCell);/** - * 预览表 - * - * Created by GUY on 2015/12/25. - * @class BI.PreviewTable - * @extends BI.Widget - */ -BI.PreviewTable = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-preview-table", - isNeedFreeze: false, - freezeCols: [], - rowSize: null, - columnSize: [], - headerRowSize: 30, - header: [], - items: [] + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] }); - }, - _init: function () { - BI.PreviewTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); - this.table = BI.createWidget({ - type: "bi.table_view", + this.layout = BI.createWidget({ + type: "bi.vtape", element: this, - isNeedResize: false, + items: [{ + el: this.headerContainer, + height: this._getHeaderHeight() - 2 + }, {el: {type: "bi.layout"}, height: 2}, { + el: this.scrollContainer + }] + }); + // 缓存第一行对应的序号 + this.start = this.options.startSequence; + this.cache = {}; + this._nextState(); - isResizeAdapt: false, + this._populate(); + }, - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, + _getNextSequence: function (nodes) { + var self = this; + var start = this.start; + var cnt = this.start; - rowSize: o.rowSize, - columnSize: o.columnSize, - headerRowSize: o.headerRowSize, + function track (node) { + // 如果已经有缓存了就不改计数了,复杂表会出现这种情况 + self.cache[node.text || node.value] || (self.cache[node.text || node.value] = cnt); + cnt++; + } - header: BI.map(o.header, function (i, items) { - return BI.map(items, function (j, item) { - return BI.extend({ - type: "bi.preview_table_header_cell" - }, item); - }); - }), - items: BI.map(o.items, function (i, items) { - return BI.map(items, function (j, item) { - return BI.extend({ - type: "bi.preview_table_cell" - }, item); + BI.each(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = cnt = self.cache[child.text || child.value]; + } + } + track(child); }); - }) - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self._adjustColumns(); + } }); - this._adjustColumns(); + this.start = cnt; + return start; }, - // 是否有自适应调节的列,即列宽为"" - _hasAdaptCol: function (columnSize) { - return BI.any(columnSize, function (i, size) { - return size === ""; + _getStart: function (nodes) { + var self = this; + var start = this.start; + BI.some(nodes, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (index, child) { + if (index === 0) { + if (self.cache[child.text || child.value]) { + start = self.cache[child.text || child.value]; + return true; + } + } + }); + } }); + return start; }, - _isPercentage: function (columnSize) { - return columnSize[0] <= 1; - }, - - _adjustColumns: function () { + _formatNumber: function (nodes) { var self = this, o = this.options; - if (o.isNeedFreeze === true) { - // 如果存在百分比的情况 - if (this._isPercentage(o.columnSize)) { - if (this._hasAdaptCol(o.columnSize)) { - var findCols = [], remain = 0; - BI.each(o.columnSize, function (i, size) { - if (size === "") { - findCols.push(i); - } else { - remain += size; - } + var result = []; + var count = this._getStart(nodes); + + function getLeafCount (node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (/** node.children.length > 1 && **/BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize }); - remain = 1 - remain; - var average = remain / findCols.length; - BI.each(findCols, function (i, col) { - o.columnSize[col] = average; + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize }); + top += o.rowSize; } - var isRight = BI.first(o.freezeCols) !== 0; - var freezeSize = [], notFreezeSize = []; - BI.each(o.columnSize, function (i, size) { - if (o.freezeCols.contains(i)) { - freezeSize.push(size); - } else { - notFreezeSize.push(size); - } - }); - var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); - BI.each(freezeSize, function (i, size) { - freezeSize[i] = size / sumFreezeSize; - }); - BI.each(notFreezeSize, function (i, size) { - notFreezeSize[i] = size / sumNotFreezeSize; - }); - this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); - this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); - } - } else { - // 如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% - if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { - this.table.setRegionColumnSize(["100%"]); } - } + }); + return result; }, - setColumnSize: function (columnSize) { - return this.table.setColumnSize(columnSize); - }, + _layout: function () { + var self = this, o = this.options; + var headerHeight = this._getHeaderHeight() - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { - getColumnSize: function () { - return this.table.getColumnSize(); + } }, - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); + _getHeaderHeight: function () { + var o = this.options; + return o.headerRowSize * (o.crossHeader.length + (o.header.length > 0 ? 1 : 0)); }, - setHeaderColumnSize: function (columnSize) { - return this.table.setHeaderColumnSize(columnSize); + _nextState: function () { + var o = this.options; + this._getNextSequence(o.items); }, - setRegionColumnSize: function (columnSize) { - return this.table.setRegionColumnSize(columnSize); + _prevState: function () { + var self = this, o = this.options; + var firstChild; + BI.some(o.items, function (i, node) { + if (BI.isNotEmptyArray(node.children)) { + return BI.some(node.children, function (j, child) { + firstChild = child; + return true; + }); + } + }); + if (firstChild && BI.isNotEmptyObject(this.cache)) { + this.start = this.cache[firstChild.text || firstChild.value]; + } else { + this.start = 1; + } + this._nextState(); }, - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); + _getMaxScrollTop: function (numbers) { + var cnt = 0; + BI.each(numbers, function (i, number) { + cnt += number.cnt; + }); + return Math.max(0, cnt * this.options.rowSize - (this.options.height - this._getHeaderHeight()) + BI.DOM.getScrollWidth()); }, - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator() || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + height: this._getHeaderHeight() - 2, + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); }, - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, + _calculateChildrenToRender: function () { + var self = this, o = this.options; - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, + var renderedCells = [], renderedKeys = []; + var numbers = this._formatNumber(o.items); + var intervalTree = BI.PrefixIntervalTree.uniform(numbers.length, 0); + BI.each(numbers, function (i, number) { + intervalTree.set(i, number.height); + }); + var scrollTop = BI.clamp(o.scrollTop, 0, this._getMaxScrollTop(numbers)); + var index = intervalTree.greatestLowerBound(scrollTop); + var offsetTop = -(scrollTop - (index > 0 ? intervalTree.sumTo(index - 1) : 0)); + var height = offsetTop; + var bodyHeight = o.height - this._getHeaderHeight(); + while (height < bodyHeight && index < numbers.length) { + renderedKeys.push(index); + offsetTop += numbers[index].height; + height += numbers[index].height; + index++; + } - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, + BI.each(renderedKeys, function (i, key) { + var index = BI.deepIndexOf(self.renderedKeys, key); + if (index > -1) { + if (numbers[key].height !== self.renderedCells[index]._height) { + self.renderedCells[index]._height = numbers[key].height; + self.renderedCells[index].el.setHeight(numbers[key].height); + } + if (numbers[key].top !== self.renderedCells[index].top) { + self.renderedCells[index].top = numbers[key].top; + self.renderedCells[index].el.element.css("top", numbers[key].top + "px"); + } + renderedCells.push(self.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + styleGetter: numbers[key].isSummary === true ? function () { + return o.summaryCellStyleGetter(true); + } : function (key) { + return function () { + return o.sequenceCellStyleGetter(key); + }; + }(numbers[key].index) + }, numbers[key])); + renderedCells.push({ + el: child, + left: 0, + top: numbers[key].top, + _height: numbers[key].height + }); + } + }); - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, + // 已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]); + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); + this.container.setHeight(intervalTree.sumUntil(numbers.length)); }, - setVerticalScroll: function (scrollTop) { - return this.table.setVerticalScroll(scrollTop); + _restore: function () { + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; }, - setLeftHorizontalScroll: function (scrollLeft) { - return this.table.setLeftHorizontalScroll(scrollLeft); + _populate: function () { + var self = this; + BI.each(this.tasks, function (i, task) { + task.apply(self); + }); + this.tasks = []; + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); }, - setRightHorizontalScroll: function (scrollLeft) { - return this.table.setRightHorizontalScroll(scrollLeft); + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } }, getVerticalScroll: function () { - return this.table.getVerticalScroll(); + return this.options.scrollTop; }, - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); + setVPage: function (v) { + if (v <= 1) { + this.cache = {}; + this.start = this.options.startSequence; + this._restore(); + this.tasks.push(this._nextState); + } else if (v === this.vCurr + 1) { + this.tasks.push(this._nextState); + } else if (v === this.vCurr - 1) { + this.tasks.push(this._prevState); + } + this.vCurr = v; }, - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); + setHPage: function (v) { + if (v !== this.hCurr) { + this.tasks.push(this._prevState); + } + this.hCurr = v; }, - getColumns: function () { - return this.table.getColumns(); + restore: function () { + this._restore(); }, - populate: function (items, header) { - if (items) { - items = BI.map(items, function (i, items) { - return BI.map(items, function (j, item) { + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + this.tasks.push(this._prevState); + } + if (header && header !== this.options.header) { + o.header = header; + } + if (crossItems && crossItems !== this.options.crossItems) { + o.crossItems = crossItems; + } + if (crossHeader && crossHeader !== this.options.crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + } +}); +BI.shortcut("bi.sequence_table_tree_number", BI.SequenceTableTreeNumber);/** + * 日期控件中的月份下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.MonthDateCombo + * @extends BI.Trigger + */ +BI.MonthDateCombo = BI.inherit(BI.Trigger, { + _defaultConfig: function () { + return BI.extend( BI.MonthDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-combo", + height: 24 + }); + }, + _init: function () { + BI.MonthDateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_triangle_trigger" + }); + + this.popup = BI.createWidget({ + type: "bi.month_popup", + behaviors: o.behaviors + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + }); + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_CHANGE, function () { + self.combo.hideView(); + self.fireEvent(BI.MonthDateCombo.EVENT_CHANGE); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.doBehavior(); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.MonthDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.month_date_combo", BI.MonthDateCombo);/** + * 年份下拉框 + * + * Created by GUY on 2015/9/7. + * @class BI.YearDateCombo + * @extends BI.Trigger + */ +BI.YearDateCombo = BI.inherit(BI.Trigger, { + _defaultConfig: function () { + return BI.extend( BI.YearDateCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-combo", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + behaviors: {}, + height: 24 + }); + }, + _init: function () { + BI.YearDateCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.date_triangle_trigger" + }); + + this.popup = BI.createWidget({ + type: "bi.year_popup", + behaviors: o.behaviors, + min: o.min, + max: o.max + }); + + this.popup.on(BI.YearPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }); + + + this.combo = BI.createWidget({ + type: "bi.combo", + offsetStyle: "center", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 100, + stopPropagation: false, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_CHANGE, function () { + self.fireEvent(BI.YearDateCombo.EVENT_CHANGE); + }); + // BI-22551 popup未初始化传入的behavior无效 + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.doBehavior(); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); +BI.YearDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.year_date_combo", BI.YearDateCombo); +/** + * Created by GUY on 2015/9/7. + * @class BI.DatePicker + * @extends BI.Widget + */ +BI.DatePicker = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DatePicker.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-picker", + height: 40, + min: "1900-01-01", // 最小日期 + max: "2099-12-31" // 最大日期 + }); + }, + + _init: function () { + BI.DatePicker.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._year = BI.getDate().getFullYear(); + this._month = BI.getDate().getMonth() + 1; + this.left = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 24, + height: 24 + }); + this.left.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 1) { + self.setValue({ + year: self.year.getValue() - 1, + month: 12 + }); + } else { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() - 1 + }); + } + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + self._checkLeftValid(); + self._checkRightValid(); + }); + + this.right = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 24, + height: 24 + }); + + this.right.on(BI.IconButton.EVENT_CHANGE, function () { + if (self._month === 12) { + self.setValue({ + year: self.year.getValue() + 1, + month: 1 + }); + } else { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + 1 + }); + } + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + self._checkLeftValid(); + self._checkRightValid(); + }); + + this.year = BI.createWidget({ + type: "bi.year_date_combo", + behaviors: o.behaviors, + min: o.min, + max: o.max + }); + this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + }); + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + this.month = BI.createWidget({ + type: "bi.month_date_combo", + behaviors: o.behaviors + }); + this.month.on(BI.MonthDateCombo.EVENT_CHANGE, function () { + self.setValue({ + year: self.year.getValue(), + month: self.month.getValue() + }); + self.fireEvent(BI.DatePicker.EVENT_CHANGE); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: { + type: "bi.center_adapt", + items: [this.left] + }, + width: 24 + }, { + type: "bi.center_adapt", + items: [{ + type: "bi.horizontal", + width: 100, + items: [this.year, this.month] + }] + }, { + el: { + type: "bi.center_adapt", + items: [this.right] + }, + width: 24 + }] + }); + this.setValue({ + year: this._year, + month: this._month + }); + }, + + _checkLeftValid: function () { + var o = this.options; + var valid = !(this._month === 1 && this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); + this.left.setEnable(valid); + return valid; + }, + + _checkRightValid: function () { + var o = this.options; + var valid = !(this._month === 12 && this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); + this.right.setEnable(valid); + return valid; + }, + + + + setValue: function (ob) { + this._year = ob.year; + this._month = ob.month; + this.year.setValue(ob.year); + this.month.setValue(ob.month); + this._checkLeftValid(); + this._checkRightValid(); + }, + + getValue: function () { + return { + year: this.year.getValue(), + month: this.month.getValue() + }; + } +}); +BI.DatePicker.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.date_picker", BI.DatePicker);/** + * Created by GUY on 2015/9/7. + * @class BI.YearPicker + * @extends BI.Widget + */ +BI.YearPicker = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.YearPicker.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-year-picker", + behaviors: {}, + height: 40, + min: "1900-01-01", // 最小日期 + max: "2099-12-31" // 最大日期 + }); + }, + + _init: function () { + BI.YearPicker.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this._year = BI.getDate().getFullYear(); + this.left = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25 + }); + this.left.on(BI.IconButton.EVENT_CHANGE, function () { + self.setValue(self.year.getValue() - 1); + self.fireEvent(BI.YearPicker.EVENT_CHANGE); + self._checkLeftValid(); + self._checkRightValid(); + }); + + this.right = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25 + }); + + this.right.on(BI.IconButton.EVENT_CHANGE, function () { + self.setValue(self.year.getValue() + 1); + self.fireEvent(BI.YearPicker.EVENT_CHANGE); + self._checkLeftValid(); + self._checkRightValid(); + }); + + this.year = BI.createWidget({ + type: "bi.year_date_combo", + min: o.min, + behaviors: o.behaviors, + max: o.max + }); + this.year.on(BI.YearDateCombo.EVENT_CHANGE, function () { + self.setValue(self.year.getValue()); + self.fireEvent(BI.YearPicker.EVENT_CHANGE); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: { + type: "bi.center_adapt", + items: [this.left] + }, + width: 25 + }, { + type: "bi.center_adapt", + items: [this.year] + }, { + el: { + type: "bi.center_adapt", + items: [this.right] + }, + width: 25 + }] + }); + this.setValue({ + year: this._year + }); + }, + + _checkLeftValid: function () { + var o = this.options; + var valid = !(this._year === BI.parseDateTime(o.min, "%Y-%X-%d").getFullYear()); + this.left.setEnable(valid); + return valid; + }, + + _checkRightValid: function () { + var o = this.options; + var valid = !(this._year === BI.parseDateTime(o.max, "%Y-%X-%d").getFullYear()); + this.right.setEnable(valid); + return valid; + }, + + + + setValue: function (v) { + this._year = v; + this.year.setValue(v); + this._checkLeftValid(); + this._checkRightValid(); + }, + + getValue: function () { + return this.year.getValue(); + } +}); +BI.YearPicker.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.year_picker", BI.YearPicker); +/** + * Created by GUY on 2015/9/7. + * @class BI.DateCalendarPopup + * @extends BI.Widget + */ +BI.DateCalendarPopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.DateCalendarPopup.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-calendar-popup", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + selectedTime: null + }); + }, + + _createNav: function (v) { + var date = BI.Calendar.getDateJSONByPage(v); + var calendar = BI.createWidget({ + type: "bi.calendar", + logic: { + dynamic: true + }, + min: this.options.min, + max: this.options.max, + year: date.year, + month: date.month, + day: this.selectedTime.day + }); + return calendar; + }, + + _init: function () { + BI.DateCalendarPopup.superclass._init.apply(this, arguments); + var self = this, + o = this.options; + this.today = BI.getDate(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth() + 1; + this._day = this.today.getDate(); + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month, + day: this._day + }; + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + behaviors: o.behaviors, + min: o.min, + max: o.max + }); + + this.calendar = BI.createWidget({ + direction: "top", + logic: { + dynamic: true + }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this), + + afterCardCreated: function () { + + }, + + afterCardShow: function () { + this.setValue(self.selectedTime); + } + }); + + this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { + self.selectedTime = self.datePicker.getValue(); + self.selectedTime.day = 1; + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + }); + + this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedTime = self.calendar.getValue(); + self.setValue(self.selectedTime); + self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.calendar, + left: 10, + right: 10 + }, { + el: { + type: "bi.layout", + cls: "bi-border-top" + }, + height: 1, + top: 40, + left: 0, + right: 0 + }] + }); + }, + + setValue: function (timeOb) { + this.datePicker.setValue(timeOb); + this.calendar.setSelect(BI.Calendar.getPageByDateJSON(timeOb)); + this.calendar.setValue(timeOb); + this.selectedTime = timeOb; + }, + + getValue: function () { + return this.selectedTime; + } +}); +BI.DateCalendarPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.date_calendar_popup", BI.DateCalendarPopup);/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.YearPopup + * @extends BI.Trigger + */ +BI.YearPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.YearPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-popup", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31" // 最大日期 + }); + }, + + _createYearCalendar: function (v) { + var o = this.options, y = this._year; + + var calendar = BI.createWidget({ + type: "bi.year_calendar", + behaviors: o.behaviors, + min: o.min, + max: o.max, + logic: { + dynamic: true + }, + year: y + v * 12 + }); + calendar.setValue(this._year); + return calendar; + }, + + _init: function () { + BI.YearPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.selectedYear = this._year = BI.getDate().getFullYear(); + + var backBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 24, + height: 24, + value: -1 + }); + + var preBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 24, + height: 24, + value: 1 + }); + + this.navigation = BI.createWidget({ + type: "bi.navigation", + element: this, + single: true, + logic: { + dynamic: true + }, + tab: { + cls: "year-popup-navigation bi-high-light bi-border-top", + height: 24, + items: [backBtn, preBtn] + }, + cardCreator: BI.bind(this._createYearCalendar, this), + + afterCardShow: function () { + this.setValue(self.selectedYear); + var calendar = this.getSelectedCard(); + backBtn.setEnable(!calendar.isFrontYear()); + preBtn.setEnable(!calendar.isFinalYear()); + } + }); + + this.navigation.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedYear = this.getValue(); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.YearPopup.EVENT_CHANGE, self.selectedYear); + }); + + if(BI.isKey(o.value)){ + this.setValue(o.value); + } + }, + + getValue: function () { + return this.selectedYear; + }, + + setValue: function (v) { + var o = this.options; + v = BI.parseInt(v); + if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) { + v = BI.getDate().getFullYear(); + this.selectedYear = ""; + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(""); + } else { + this.selectedYear = v; + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(v); + } + } +}); +BI.YearPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.year_popup", BI.YearPopup);/** + * 日期控件中的年份或月份trigger + * + * Created by GUY on 2015/9/7. + * @class BI.DateTriangleTrigger + * @extends BI.Trigger + */ +BI.DateTriangleTrigger = BI.inherit(BI.Trigger, { + _const: { + height: 24, + iconWidth: 12, + iconHeight: 12 + }, + + _defaultConfig: function () { + return BI.extend( BI.DateTriangleTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-triangle-trigger pull-down-ha-font cursor-pointer", + height: 24 + }); + }, + _init: function () { + BI.DateTriangleTrigger.superclass._init.apply(this, arguments); + var o = this.options, c = this._const; + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-item-text", + textAlign: "right", + text: o.text, + value: o.value, + height: c.height + }); + this.icon = BI.createWidget({ + type: "bi.icon", + width: c.iconWidth, + height: c.iconHeight + }); + + BI.createWidget({ + type: "bi.center_adapt", + element: this, + items: [{ + type: "bi.center_adapt", + width: 50, + height: c.height, + items: [{ + el: this.text, + rgap: 10 + }, this.icon] + }] + }); + }, + + setValue: function (v) { + this.text.setValue(v); + }, + + getValue: function () { + return this.text.getValue(); + }, + + setText: function (v) { + this.text.setText(v); + }, + + getText: function () { + return this.item.getText(); + }, + + getKey: function () { + + } +}); +BI.shortcut("bi.date_triangle_trigger", BI.DateTriangleTrigger);/** + * Created by zcf on 2017/2/20. + */ +BI.StaticDatePaneCard = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.StaticDatePaneCard.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-pane", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + selectedTime: null + }); + }, + _init: function () { + BI.StaticDatePaneCard.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.today = BI.getDate(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth() + 1; + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month + }; + + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + behaviors: o.behaviors, + min: o.min, + max: o.max + }); + this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { + var value = self.datePicker.getValue(); + var monthDay = BI.getDate(value.year, value.month - 1, 1).getMonthDays(); + var day = self.selectedTime.day || 0; + if (day > monthDay) { + day = monthDay; + } + self.selectedTime = { + year: value.year, + month: value.month + }; + day !== 0 && (self.selectedTime.day = day); + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + self.calendar.setValue(self.selectedTime); + day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + + this.calendar = BI.createWidget({ + direction: "custom", + // logic: { + // dynamic: false + // }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this) + }); + this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedTime = self.calendar.getValue(); + self.calendar.empty(); + self.setValue(self.selectedTime); + self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + this.setValue(o.selectedTime); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.datePicker, + height: 40 + }, this.calendar], + hgap: 10 + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: { + type: "bi.layout", + cls: "bi-border-top" + }, + height: 1, + top: 40, + left: 0, + right: 0 + }] + }); + + }, + + _createNav: function (v) { + var date = BI.Calendar.getDateJSONByPage(v); + var calendar = BI.createWidget({ + type: "bi.calendar", + logic: { + dynamic: false + }, + min: this.options.min, + max: this.options.max, + year: date.year, + month: date.month, + day: this.selectedTime.day + }); + return calendar; + }, + + _getNewCurrentDate: function () { + var today = BI.getDate(); + return { + year: today.getFullYear(), + month: today.getMonth() + 1 + }; + }, + + _setCalenderValue: function (date) { + this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); + this.calendar.setValue(date); + this.selectedTime = date; + }, + + _setDatePicker: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { + this.datePicker.setValue(this._getNewCurrentDate()); + } else { + this.datePicker.setValue(timeOb); + } + }, + + _setCalendar: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { + this.calendar.empty(); + this._setCalenderValue(this._getNewCurrentDate()); + } else { + this._setCalenderValue(timeOb); + } + }, + + setValue: function (timeOb) { + this._setDatePicker(timeOb); + this._setCalendar(timeOb); + }, + + getValue: function () { + return this.selectedTime; + } + +}); +BI.shortcut("bi.static_date_pane_card", BI.StaticDatePaneCard);BI.DynamicDatePane = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-dynamic-date-pane" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vtape", + items: [{ + el: { + type: "bi.linear_segment", + cls: "bi-border-bottom", + height: 30, + items: BI.createItems([{ + text: BI.i18nText("BI-Multi_Date_YMD"), + value: BI.DynamicDatePane.Static + }, { + text: BI.i18nText("BI-Basic_Dynamic_Title"), + value: BI.DynamicDatePane.Dynamic + }], { + textAlign: "center" + }), + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function () { + var value = this.getValue()[0]; + self.dateTab.setSelect(value); + switch (value) { + case BI.DynamicDatePane.Static: + var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); + self.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + }); + break; + case BI.DynamicDatePane.Dynamic: + self.dynamicPane.setValue({ + year: 0 + }); + break; + default: + break; + } + } + }], + ref: function () { + self.switcher = this; + } + }, + height: 30 + }, { + type: "bi.tab", + ref: function () { + self.dateTab = this; + }, + showIndex: BI.DynamicDatePane.Static, + cardCreator: function (v) { + switch (v) { + case BI.DynamicDatePane.Static: + return { + type: "bi.static_date_pane_card", + behaviors: o.behaviors, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }], + ref: function () { + self.ymd = this; + } + }; + case BI.DynamicDatePane.Dynamic: + default: + return { + type: "bi.dynamic_date_card", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + if(self._checkValue(self.getValue())) { + self.fireEvent("EVENT_CHANGE"); + } + } + }], + ref: function () { + self.dynamicPane = this; + } + }; + } + } + }] + }; + }, + + mounted: function () { + this.setValue(this.options.value); + }, + + _checkValueValid: function (value) { + return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); + }, + + _checkValue: function (v) { + switch (v.type) { + case BI.DynamicDateCombo.Dynamic: + return BI.isNotEmptyObject(v.value); + case BI.DynamicDateCombo.Static: + default: + return true; + } + }, + + setValue: function (v) { + v = v || {}; + var type = v.type || BI.DynamicDateCombo.Static; + var value = v.value || v; + this.switcher.setValue(type); + this.dateTab.setSelect(type); + switch (type) { + case BI.DynamicDateCombo.Dynamic: + this.dynamicPane.setValue(value); + break; + case BI.DynamicDateCombo.Static: + default: + if (this._checkValueValid(value)) { + var date = BI.getDate(); + this.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1 + }); + } else { + this.ymd.setValue(value); + } + break; + } + }, + + getValue: function () { + return { + type: this.dateTab.getSelect(), + value: this.dateTab.getValue() + }; + } +}); +BI.shortcut("bi.dynamic_date_pane", BI.DynamicDatePane); + +BI.extend(BI.DynamicDatePane, { + Static: 1, + Dynamic: 2 +});/** + * Created by Urthur on 2017/7/14. + */ +BI.DateTimeCombo = BI.inherit(BI.Single, { + constants: { + popupHeight: 290, + popupWidth: 270, + comboAdjustHeight: 1, + border: 1, + DATE_MIN_VALUE: "1900-01-01", + DATE_MAX_VALUE: "2099-12-31" + }, + _defaultConfig: function () { + return BI.extend(BI.DateTimeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-time-combo bi-border", + width: 200, + height: 24 + }); + }, + _init: function () { + BI.DateTimeCombo.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + var date = BI.getDate(); + this.storeValue = BI.isNotNull(opts.value) ? opts.value : { + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate(), + hour: date.getHours(), + minute: date.getMinutes(), + second: date.getSeconds() + }; + this.trigger = BI.createWidget({ + type: "bi.date_time_trigger", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE, + value: opts.value + }); + + this.popup = BI.createWidget({ + type: "bi.date_time_popup", + behaviors: opts.behaviors, + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE, + value: opts.value + }); + self.setValue(this.storeValue); + + this.popup.on(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE, function () { + self.setValue(self.storeValue); + self.hidePopupView(); + self.fireEvent(BI.DateTimeCombo.EVENT_CANCEL); + }); + this.popup.on(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE, function () { + self.storeValue = self.popup.getValue(); + self.setValue(self.storeValue); + self.hidePopupView(); + self.fireEvent(BI.DateTimeCombo.EVENT_CONFIRM); + }); + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: this.popup, + width: this.constants.popupWidth, + stopPropagation: false + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW); + }); + + var triggerBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-font bi-border-right", + width: 24, + height: 24 + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + type: "bi.absolute", + items: [{ + el: this.combo, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: triggerBtn, + top: 0, + left: 0 + }] + }] + }); + }, + + setValue: function (v) { + this.storeValue = v; + this.popup.setValue(v); + this.trigger.setValue(v); + }, + getValue: function () { + return this.storeValue; + }, + + hidePopupView: function () { + this.combo.hideView(); + } +}); + +BI.DateTimeCombo.EVENT_CANCEL = "EVENT_CANCEL"; +BI.DateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW = "BI.DateTimeCombo.EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.date_time_combo", BI.DateTimeCombo); +/** + * Created by Urthur on 2017/7/14. + */ +BI.DateTimePopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateTimePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-time-popup", + width: 268, + height: 374 + }); + }, + _init: function () { + BI.DateTimePopup.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + this.cancelButton = BI.createWidget({ + type: "bi.text_button", + forceCenter: true, + cls: "multidate-popup-button bi-border-top bi-border-right", + shadow: true, + text: BI.i18nText("BI-Basic_Cancel") + }); + this.cancelButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE); + }); + + this.okButton = BI.createWidget({ + type: "bi.text_button", + forceCenter: true, + cls: "multidate-popup-button bi-border-top", + shadow: true, + text: BI.i18nText("BI-Basic_OK") + }); + this.okButton.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE); + }); + + this.dateCombo = BI.createWidget({ + type: "bi.date_calendar_popup", + behaviors: opts.behaviors, + min: self.options.min, + max: self.options.max + }); + self.dateCombo.on(BI.DateCalendarPopup.EVENT_CHANGE, function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + }); + + this.dateSelect = BI.createWidget({ + type: "bi.vertical_adapt", + cls: "bi-border-top", + items: [{ + type: "bi.label", + text: BI.i18nText("BI-Basic_Time"), + width: 45 + }, { + type: "bi.date_time_select", + max: 23, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.hour = _ref; + } + }, { + type: "bi.label", + text: ":", + width: 15 + }, { + type: "bi.date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.minute = _ref; + } + }, { + type: "bi.label", + text: ":", + width: 15 + }, { + type: "bi.date_time_select", + max: 59, + min: 0, + width: 60, + height: 30, + listeners: [{ + eventName: BI.DateTimeSelect.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DateTimePopup.CALENDAR_EVENT_CHANGE); + } + }], + ref: function (_ref) { + self.second = _ref; + } + }] + }); + + this.setValue(opts.value); + + this.dateButton = BI.createWidget({ + type: "bi.grid", + items: [[this.cancelButton, this.okButton]] + }); + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this.dateCombo + }, { + el: this.dateSelect, + height: 50 + }, { + el: this.dateButton, + height: 30 + }] + }); + }, + + setValue: function (v) { + var value = v, date; + if (BI.isNull(value)) { + date = BI.getDate(); + this.dateCombo.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + }); + this.hour.setValue(date.getHours()); + this.minute.setValue(date.getMinutes()); + this.second.setValue(date.getSeconds()); + } else { + this.dateCombo.setValue({ + year: value.year, + month: value.month, + day: value.day + }); + this.hour.setValue(value.hour); + this.minute.setValue(value.minute); + this.second.setValue(value.second); + } + }, + + getValue: function () { + return { + year: this.dateCombo.getValue().year, + month: this.dateCombo.getValue().month, + day: this.dateCombo.getValue().day, + hour: this.hour.getValue(), + minute: this.minute.getValue(), + second: this.second.getValue() + }; + } +}); +BI.DateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.DateTimePopup.BUTTON_CANCEL_EVENT_CHANGE = "BUTTON_CANCEL_EVENT_CHANGE"; +BI.DateTimePopup.CALENDAR_EVENT_CHANGE = "CALENDAR_EVENT_CHANGE"; +BI.shortcut("bi.date_time_popup", BI.DateTimePopup); +/** + * Created by Urthur on 2017/7/14. + */ +BI.DateTimeSelect = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DateTimeSelect.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-date-time-select bi-border", + max: 23, + min: 0 + }); + }, + + _init: function () { + BI.DateTimeSelect.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + value: this._alertInEditorValue(o.min), + allowBlank: false, + errorText: function (v) { + if(BI.isNumeric(v)) { + return BI.i18nText("BI-Please_Input_Natural_Number"); + } + return BI.i18nText("BI-Numerical_Interval_Input_Data"); + }, + validationChecker: function (v) { + return BI.isNaturalNumber(v); + } + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { + self._finetuning(0); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-pre-page-h-font top-button bi-border-left bi-border-bottom" + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { + self._finetuning(1); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "column-next-page-h-font bottom-button bi-border-left" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { + self._finetuning(-1); + self.fireEvent(BI.DateTimeSelect.EVENT_CONFIRM); + }); + this._finetuning(0); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [this.editor, { + el: { + type: "bi.grid", + columns: 1, + rows: 2, + items: [{ + column: 0, + row: 0, + el: this.topBtn + }, { + column: 0, + row: 1, + el: this.bottomBtn + }] + }, + width: 30 + }] + }); + }, + + _alertOutEditorValue: function (v) { + if (v > this.options.max) { + v = this.options.min; + } + if (v < this.options.min) { + v = this.options.max; + } + return BI.parseInt(v); + }, + + _alertInEditorValue: function (v) { + if (v > this.options.max) { + v = this.options.min; + } + if (v < this.options.min) { + v = this.options.max; + } + v = v < 10 ? "0" + v : v; + return v; + }, + + _finetuning: function (add) { + var v = BI.parseInt(this._alertOutEditorValue(this.editor.getValue())); + this.editor.setValue(this._alertInEditorValue(v + add)); + }, + + getValue: function () { + var v = this.editor.getValue(); + return this._alertOutEditorValue(v); + }, + + setValue: function (v) { + this.editor.setValue(this._alertInEditorValue(v)); + this._finetuning(0); + } + +}); +BI.DateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.date_time_select", BI.DateTimeSelect);/** + * Created by Urthur on 2017/7/14. + */ +BI.DateTimeTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4 + }, + + _defaultConfig: function () { + return BI.extend(BI.DateTimeTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-date-time-trigger", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24, + width: 200 + }); + }, + _init: function () { + BI.DateTimeTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + height: o.height, + width: o.width, + hgap: c.hgap + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: BI.createWidget(), + width: o.height + }, { + el: this.text + }] + }); + this.setValue(o.value); + }, + + _printTime: function (v) { + return v < 10 ? "0" + v : v; + }, + + setValue: function (v) { + var self = this; + var value = v, dateStr; + if(BI.isNull(value)) { + value = BI.getDate(); + dateStr = value.print("%Y-%X-%d %H:%M:%S"); + } else { + var date = BI.getDate(value.year, value.month - 1, value.day, value.hour, value.minute, value.second); + dateStr = date.print("%Y-%X-%d %H:%M:%S"); + + } + this.text.setText(dateStr); + this.text.setTitle(dateStr); + } + +}); +BI.shortcut("bi.date_time_trigger", BI.DateTimeTrigger);BI.StaticDateTimePaneCard = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.StaticDateTimePaneCard.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-date-time-pane", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + selectedTime: null + }); + }, + _init: function () { + BI.StaticDateTimePaneCard.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.today = BI.getDate(); + this._year = this.today.getFullYear(); + this._month = this.today.getMonth() + 1; + + this.selectedTime = o.selectedTime || { + year: this._year, + month: this._month + }; + + this.datePicker = BI.createWidget({ + type: "bi.date_picker", + behaviors: o.behaviors, + min: o.min, + max: o.max + }); + this.datePicker.on(BI.DatePicker.EVENT_CHANGE, function () { + var value = self.datePicker.getValue(); + var monthDay = BI.getDate(value.year, value.month - 1, 1).getMonthDays(); + var day = self.selectedTime.day || 0; + if (day > monthDay) { + day = monthDay; + } + self.selectedTime = BI.extend(self.selectedTime, { + year: value.year, + month: value.month, + day: day + }); + day !== 0 && (self.selectedTime.day = day); + self.calendar.setSelect(BI.Calendar.getPageByDateJSON(self.selectedTime)); + self.calendar.setValue(self.selectedTime); + day !== 0 && self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + + this.calendar = BI.createWidget({ + direction: "custom", + // logic: { + // dynamic: false + // }, + type: "bi.navigation", + tab: this.datePicker, + cardCreator: BI.bind(this._createNav, this) + }); + this.calendar.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue()); + self.calendar.empty(); + self.setValue(self.selectedTime); + self.fireEvent(BI.DateCalendarPopup.EVENT_CHANGE); + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + hgap: 10, + items: [{ + el: this.datePicker, + height: 40 + }, this.calendar, { + el: { + type: "bi.dynamic_date_time_select", + ref: function () { + self.timeSelect = this; + }, + listeners: [{ + eventName: BI.DynamicDateTimeSelect.EVENT_CONFIRM, + action: function () { + self.selectedTime = BI.extend(self.calendar.getValue(), self.timeSelect.getValue()); + self.fireEvent("EVENT_CHANGE"); + } + }] + }, + height: 40 + }] + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: { + type: "bi.layout", + cls: "bi-border-top" + }, + height: 1, + top: 40, + left: 0, + right: 0 + }] + }); + this.setValue(o.selectedTime); + + }, + + _createNav: function (v) { + var date = BI.Calendar.getDateJSONByPage(v); + var calendar = BI.createWidget({ + type: "bi.calendar", + logic: { + dynamic: false + }, + min: this.options.min, + max: this.options.max, + year: date.year, + month: date.month, + day: this.selectedTime.day + }); + return calendar; + }, + + _getNewCurrentDate: function () { + var today = BI.getDate(); + return { + year: today.getFullYear(), + month: today.getMonth() + 1 + }; + }, + + _setCalenderValue: function (date) { + this.calendar.setSelect(BI.Calendar.getPageByDateJSON(date)); + this.calendar.setValue(date); + this.selectedTime = BI.extend({}, this.timeSelect.getValue(), date); + }, + + _setDatePicker: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.year) || BI.isNull(timeOb.month)) { + this.datePicker.setValue(this._getNewCurrentDate()); + } else { + this.datePicker.setValue(timeOb); + } + }, + + _setCalendar: function (timeOb) { + if (BI.isNull(timeOb) || BI.isNull(timeOb.day)) { + this.calendar.empty(); + this._setCalenderValue(this._getNewCurrentDate()); + } else { + this._setCalenderValue(timeOb); + } + }, + + setValue: function (timeOb) { + timeOb = timeOb || {}; + this._setDatePicker(timeOb); + this._setCalendar(timeOb); + this.timeSelect.setValue({ + hour: timeOb.hour, + minute: timeOb.minute, + second: timeOb.second + }); + }, + + getValue: function () { + return this.selectedTime; + } + +}); +BI.shortcut("bi.static_date_time_pane_card", BI.StaticDateTimePaneCard);BI.DynamicDateTimePane = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-dynamic-date-pane" + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vtape", + items: [{ + el: { + type: "bi.linear_segment", + cls: "bi-border-bottom", + height: 30, + items: BI.createItems([{ + text: BI.i18nText("BI-Multi_Date_YMD"), + value: BI.DynamicDateTimePane.Static + }, { + text: BI.i18nText("BI-Basic_Dynamic_Title"), + value: BI.DynamicDateTimePane.Dynamic + }], { + textAlign: "center" + }), + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function () { + var value = this.getValue()[0]; + self.dateTab.setSelect(value); + switch (value) { + case BI.DynamicDateTimePane.Static: + var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); + self.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + }); + break; + case BI.DynamicDateTimePane.Dynamic: + self.dynamicPane.setValue({ + year: 0 + }); + break; + default: + break; + } + } + }], + ref: function () { + self.switcher = this; + } + }, + height: 30 + }, { + type: "bi.tab", + ref: function () { + self.dateTab = this; + }, + showIndex: BI.DynamicDateTimePane.Static, + cardCreator: function (v) { + switch (v) { + case BI.DynamicDateTimePane.Static: + return { + type: "bi.static_date_time_pane_card", + behaviors: o.behaviors, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }], + ref: function () { + self.ymd = this; + } + }; + case BI.DynamicDateTimePane.Dynamic: + default: + return { + type: "bi.dynamic_date_card", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + if(self._checkValue(self.getValue())) { + self.fireEvent("EVENT_CHANGE"); + } + } + }], + ref: function () { + self.dynamicPane = this; + } + }; + } + } + }] + }; + }, + + mounted: function () { + this.setValue(this.options.value); + }, + + _checkValueValid: function (value) { + return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); + }, + + _checkValue: function (v) { + switch (v.type) { + case BI.DynamicDateCombo.Dynamic: + return BI.isNotEmptyObject(v.value); + case BI.DynamicDateCombo.Static: + default: + return true; + } + }, + + setValue: function (v) { + v = v || {}; + var type = v.type || BI.DynamicDateTimePane.Static; + var value = v.value || v; + this.switcher.setValue(type); + this.dateTab.setSelect(type); + switch (type) { + case BI.DynamicDateTimePane.Dynamic: + this.dynamicPane.setValue(value); + break; + case BI.DynamicDateTimePane.Static: + default: + if (this._checkValueValid(value)) { + var date = BI.getDate(); + this.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1 + }); + } else { + this.ymd.setValue(value); + } + break; + } + }, + + getValue: function () { + return { + type: this.dateTab.getSelect(), + value: this.dateTab.getValue() + }; + } +}); +BI.shortcut("bi.dynamic_date_time_pane", BI.DynamicDateTimePane); + +BI.extend(BI.DynamicDateTimePane, { + Static: 1, + Dynamic: 2 +});/** + * Created by roy on 15/8/14. + */ +BI.DownListCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-down-list-combo", + height: 24, + items: [], + adjustLength: 0, + direction: "bottom", + trigger: "click", + container: null, + stopPropagation: false, + el: {} + }); + }, + + _init: function () { + BI.DownListCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.popupview = BI.createWidget({ + type: "bi.down_list_popup", + items: o.items, + chooseType: o.chooseType, + value: o.value + }); + + this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) { + self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); + self.downlistcombo.hideView(); + }); + + this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { + self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); + self.downlistcombo.hideView(); + }); + + + this.downlistcombo = BI.createWidget({ + element: this, + type: "bi.combo", + trigger: o.trigger, + isNeedAdjustWidth: false, + container: o.container, + adjustLength: o.adjustLength, + direction: o.direction, + stopPropagation: o.stopPropagation, + el: BI.createWidget(o.el, { + type: "bi.icon_trigger", + extraCls: o.iconCls ? o.iconCls : "", + width: o.width, + height: o.height + }), + popup: { + el: this.popupview, + stopPropagation: true, + maxHeight: 1000, + minWidth: 140 + } + }); + + this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + hideView: function () { + this.downlistcombo.hideView(); + }, + + showView: function () { + this.downlistcombo.showView(); + }, + + populate: function (items) { + this.popupview.populate(items); + }, + + setValue: function (v) { + this.popupview.setValue(v); + }, + getValue: function () { + return this.popupview.getValue(); + } +}); +BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; + +BI.shortcut("bi.down_list_combo", BI.DownListCombo);/** + * Created by roy on 15/9/6. + */ +BI.DownListGroup = BI.inherit(BI.Widget, { + constants: { + iconCls: "check-mark-ha-font" + }, + _defaultConfig: function () { + return BI.extend(BI.DownListGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-down-list-group", + items: [ + { + el: {} + } + ] + }); + }, + _init: function () { + BI.DownListGroup.superclass._init.apply(this, arguments); + var o = this.options, self = this; + + this.downlistgroup = BI.createWidget({ + element: this, + type: "bi.button_tree", + items: o.items, + chooseType: 0, // 0单选,1多选 + layouts: [{ + type: "bi.vertical", + hgap: 0, + vgap: 0 + }], + value: o.value + }); + this.downlistgroup.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if(type === BI.Events.CLICK) { + self.fireEvent(BI.DownListGroup.EVENT_CHANGE, arguments); + } + }); + }, + getValue: function () { + return this.downlistgroup.getValue(); + }, + setValue: function (v) { + this.downlistgroup.setValue(v); + } + + +}); +BI.DownListGroup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_group", BI.DownListGroup);BI.DownListItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + var conf = BI.DownListItem.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-down-list-item bi-list-item-active", + cls: "", + height: 24, + logic: { + dynamic: true + }, + selected: false, + iconHeight: null, + iconWidth: null, + textHgap: 0, + textVgap: 0, + textLgap: 0, + textRgap: 0 + }); + }, + _init: function () { + BI.DownListItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-item-text", + textAlign: "left", + hgap: o.textHgap, + vgap: o.textVgap, + lgap: o.textLgap, + rgap: o.textRgap, + text: o.text, + value: o.value, + keyword: o.keyword, + height: o.height + }); + this.icon = BI.createWidget({ + type: "bi.center_adapt", + width: 36, + height: o.height, + items: [{ + el: { + type: "bi.icon", + width: o.iconWidth, + height: o.iconHeight + } + }] + }); + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left), BI.extend(o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, this.icon, this.text) + })))); + }, + + setValue: function () { + if (!this.isReadOnly()) { + this.text.setValue.apply(this.text, arguments); + } + }, + + getValue: function () { + return this.text.getValue(); + }, + + setText: function () { + this.text.setText.apply(this.text, arguments); + }, + + getText: function () { + return this.text.getText(); + }, + + doClick: function () { + BI.DownListItem.superclass.doClick.apply(this, arguments); + if (this.isValid()) { + this.fireEvent(BI.DownListItem.EVENT_CHANGE, this.getValue(), this); + } + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doHighLight: function () { + this.text.doHighLight.apply(this.text, arguments); + }, + + unHighLight: function () { + this.text.unHighLight.apply(this.text, arguments); + } +}); +BI.DownListItem.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_item", BI.DownListItem);BI.DownListGroupItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + var conf = BI.DownListGroupItem.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-down-list-group-item", + logic: { + dynamic: false + }, + // invalid: true, + iconCls1: "dot-e-font", + iconCls2: "pull-right-e-font" + }); + }, + _init: function () { + BI.DownListGroupItem.superclass._init.apply(this, arguments); + var o = this.options; + var self = this; + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-group-item-text", + textAlign: "left", + text: o.text, + value: o.value, + height: o.height + }); + + this.icon1 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls1, + width: 36, + forceNotSelected: true, + selected: this._digest(o.value) + }); + + this.icon2 = BI.createWidget({ + type: "bi.icon_button", + cls: o.iconCls2, + width: 24, + forceNotSelected: true + }); + + var blank = BI.createWidget({ + type: "bi.layout", + width: 24 + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.icon2, + top: 0, + bottom: 0, + right: 0 + }] + }); + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection("left", this.icon1, this.text, blank) + })))); + + this.element.hover(function () { + if (self.isEnabled()) { + self.hover(); + } + }, function () { + if (self.isEnabled()) { + self.dishover(); + } + }); + }, + + _digest: function (v) { + var self = this, o = this.options; + v = BI.isArray(v) ? v : [v]; + return BI.any(v, function (idx, value) { + return BI.contains(o.childValues, value); + }); + }, + + hover: function () { + BI.DownListGroupItem.superclass.hover.apply(this, arguments); + this.icon1.element.addClass("hover"); + this.icon2.element.addClass("hover"); + + }, + + dishover: function () { + BI.DownListGroupItem.superclass.dishover.apply(this, arguments); + this.icon1.element.removeClass("hover"); + this.icon2.element.removeClass("hover"); + }, + + doClick: function () { + BI.DownListGroupItem.superclass.doClick.apply(this, arguments); + if (this.isValid()) { + this.fireEvent(BI.DownListGroupItem.EVENT_CHANGE, this.getValue()); + } + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + setValue: function (v) { + this.icon1.setSelected(this._digest(v)); + } +}); +BI.DownListGroupItem.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.down_list_group_item", BI.DownListGroupItem);/** + * Created by roy on 15/9/8. + * 处理popup中的item分组样式 + * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项 + */ +BI.DownListPopup = BI.inherit(BI.Pane, { + constants: { + nextIcon: "pull-right-e-font", + height: 24, + iconHeight: 12, + iconWidth: 12, + hgap: 0, + vgap: 0, + border: 1 + }, + _defaultConfig: function () { + var conf = BI.DownListPopup.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-down-list-popup", + items: [], + chooseType: BI.Selection.Multi + }); + }, + _init: function () { + BI.DownListPopup.superclass._init.apply(this, arguments); + this.singleValues = []; + this.childValueMap = {}; + this.fatherValueMap = {}; + this.items = BI.deepClone(this.options.items); + var self = this, o = this.options, children = this._createChildren(this.items); + this.popup = BI.createWidget({ + type: "bi.button_tree", + items: BI.createItems(children, + {}, { + adjustLength: -2 + } + ), + layouts: [{ + type: "bi.vertical", + hgap: this.constants.hgap, + vgap: this.constants.vgap + }], + value: this._digest(o.value), + chooseType: o.chooseType + }); + + this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) { + var changedValue = value; + if (BI.isNotNull(self.childValueMap[value])) { + changedValue = self.childValueMap[value]; + self.fireEvent(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, self.fatherValueMap[value]); + } else { + self.fireEvent(BI.DownListPopup.EVENT_CHANGE, changedValue, object); + } + + + if (!self.singleValues.contains(changedValue)) { + var item = self.getValue(); + var result = []; + BI.each(item, function (i, valueObject) { + if (valueObject.value != changedValue) { + result.push(valueObject); + } + }); + self.setValue(result); + } + + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup], + vgap: 5 + }); + + }, + _createChildren: function (items) { + var self = this, result = []; + // 不能修改populate进来的item的引用 + BI.each(items, function (i, it) { + var item_done = { + type: "bi.down_list_group", + items: [] + }; + + BI.each(it, function (i, item) { + if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { + item.type = "bi.combo_group"; + item.cls = "down-list-group"; + item.trigger = "hover"; + item.isNeedAdjustWidth = false; + item.el.title = item.el.title || item.el.text; + item.el.type = "bi.down_list_group_item"; + item.el.logic = { + dynamic: true + }; + item.el.height = self.constants.height; + item.el.iconCls2 = self.constants.nextIcon; + item.popup = { + lgap: 1, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical" + }] + + }, + innerVGap: 5, + maxHeight: 378 + }; + item.el.childValues = []; + BI.each(item.children, function (i, child) { + var fatherValue = BI.deepClone(item.el.value); + var childValue = BI.deepClone(child.value); + self.singleValues.push(child.value); + child.type = "bi.down_list_item"; + child.extraCls = " child-down-list-item"; + child.title = child.title || child.text; + child.textRgap = 10; + child.isNeedAdjustWidth = false; + child.logic = { + dynamic: true + }; + child.father = fatherValue; + self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; + self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; + child.value = self._createChildValue(fatherValue, childValue); + item.el.childValues.push(child.value); + }); + } else { + item.type = "bi.down_list_item"; + item.title = item.title || item.text; + item.textRgap = 10; + item.isNeedAdjustWidth = false; + item.logic = { + dynamic: true + }; + } + var el_done = {}; + el_done.el = item; + item_done.items.push(el_done); + }); + if (self._isGroup(item_done.items)) { + BI.each(item_done.items, function (i, item) { + self.singleValues.push(item.el.value); + }); + } + + result.push(item_done); + if (self._needSpliter(i, items.length)) { + var spliter_container = BI.createWidget({ + type: "bi.vertical", + items: [{ + el: { + type: "bi.layout", + cls: "bi-down-list-spliter bi-border-top cursor-pointer", + height: 0 + } + + }], + cls: "bi-down-list-spliter-container cursor-pointer", + lgap: 10, + rgap: 0 + }); + result.push(spliter_container); + } + }); + return result; + }, + + _isGroup: function (i) { + return i.length > 1; + }, + + _needSpliter: function (i, itemLength) { + return i < itemLength - 1; + }, + + _createChildValue: function (fatherValue, childValue) { + return fatherValue + "_" + childValue; + }, + + _digest: function (valueItem) { + var self = this; + var valueArray = []; + BI.each(valueItem, function (i, item) { + var value; + if (BI.isNotNull(item.childValue)) { + value = self._createChildValue(item.value, item.childValue); + } else { + value = item.value; + } + valueArray.push(value); + } + ); + return valueArray; + }, + + _checkValues: function (values) { + var value = []; + BI.each(this.items, function (idx, itemGroup) { + BI.each(itemGroup, function (id, item) { + if(BI.isNotNull(item.children)) { + var childValues = BI.map(item.children, "value"); + var v = joinValue(childValues, values[idx]); + if(BI.isNotEmptyString(v)) { + value.push(v); + } + }else{ + if(item.value === values[idx][0]) { + value.push(values[idx][0]); + } + } + }); + }); + return value; + + function joinValue (sources, targets) { + var value = ""; + BI.some(sources, function (idx, s) { + return BI.some(targets, function (id, t) { + if(s === t) { + value = s; + return true; + } + }); + }); + return value; + } + }, + + populate: function (items) { + BI.DownListPopup.superclass.populate.apply(this, arguments); + this.items = BI.deepClone(items); + this.childValueMap = {}; + this.fatherValueMap = {}; + this.singleValues = []; + var children = this._createChildren(this.items); + var popupItem = BI.createItems(children, + {}, { + adjustLength: -2 + } + ); + this.popup.populate(popupItem); + }, + + setValue: function (valueItem) { + this.popup.setValue(this._digest(valueItem)); + }, + + _getValue: function () { + var v = []; + BI.each(this.popup.getAllButtons(), function (i, item) { + i % 2 === 0 && v.push(item.getValue()); + }); + return v; + }, + + getValue: function () { + var self = this, result = []; + var values = this._checkValues(this._getValue()); + BI.each(values, function (i, value) { + var valueItem = {}; + if (BI.isNotNull(self.childValueMap[value])) { + var fartherValue = self.fatherValueMap[value]; + valueItem.childValue = self.childValueMap[value]; + valueItem.value = fartherValue; + } else { + valueItem.value = value; + } + result.push(valueItem); + }); + return result; + } + + +}); + +BI.DownListPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.shortcut("bi.down_list_popup", BI.DownListPopup);/** + * 汇总表格帮助类 + * Created by Young's on 2017/1/19. + */ +!(function () { + BI.DynamicDateHelper = {}; + BI.extend(BI.DynamicDateHelper, { + getCalculation: function (obj) { + var date = BI.getDate(); + + return this.getCalculationByDate(date, obj); + }, + + getCalculationByDate: function (date, obj) { + if (BI.isNotNull(obj.year)) { + date = BI.getDate((date.getFullYear() + BI.parseInt(obj.year)), date.getMonth(), date.getDate()); + } + if (BI.isNotNull(obj.quarter)) { + date = date.getOffsetQuarter(BI.parseInt(obj.quarter)); + } + if (BI.isNotNull(obj.month)) { + date = date.getOffsetMonth(BI.parseInt(obj.month)); + } + if (BI.isNotNull(obj.week)) { + date = date.getOffsetDate(BI.parseInt(obj.week) * 7); + } + if (BI.isNotNull(obj.day)) { + date = date.getOffsetDate(BI.parseInt(obj.day)); + } + if (BI.isNotNull(obj.workDay)) { + // 配置了节假日就按照节假日计算工作日偏移,否则按正常的天去算 + if(BI.isNotNull(BI.holidays)) { + var count = Math.abs(obj.workDay); + for (var i = 0; i < count; i++) { + date = date.getOffsetDate(obj.workDay < 0 ? -1 : 1); + if(BI.isNotNull(BI.holidays[date.print("%Y-%X-%d")])) { + i--; + } + } + } else { + date = date.getOffsetDate(BI.parseInt(obj.workDay)); + } + } + if (BI.isNotNull(obj.position) && obj.position !== BI.DynamicDateCard.OFFSET.CURRENT) { + date = this.getBeginDate(date, obj); + } + + return date; + }, + + getBeginDate: function (date, obj) { + if (BI.isNotNull(obj.day)) { + return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); + } + if (BI.isNotNull(obj.week)) { + return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? date.getWeekStartDate() : date.getWeekEndDate(); + } + if (BI.isNotNull(obj.month)) { + return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), date.getMonth(), 1) : BI.getDate(date.getFullYear(), date.getMonth(), (date.getLastDateOfMonth()).getDate()); + } + if (BI.isNotNull(obj.quarter)) { + return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? date.getQuarterStartDate() : date.getQuarterEndDate(); + } + if (BI.isNotNull(obj.year)) { + return obj.position === BI.DynamicDateCard.OFFSET.BEGIN ? BI.getDate(date.getFullYear(), 0, 1) : BI.getDate(date.getFullYear(), 11, 31); + } + return date; + } + }); +})(); +BI.DynamicDateCard = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-dynamic-date-card" + }, + + render: function () { + var self = this; + this.position = BI.DynamicDateCard.OFFSET.CURRENT; + return { + type: "bi.vertical", + items: [{ + el: { + type: "bi.label", + text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), + textAlign: "left", + height: 12, + lgap: 10 + }, + tgap: 10, + bgap: 5 + }, { + type: "bi.button_group", + ref: function () { + self.checkgroup = this; + }, + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + lgap: 4, + value: [BI.DynamicDateCard.TYPE.YEAR], + items: BI.createItems([{ + text: BI.i18nText("BI-Basic_Year"), + value: BI.DynamicDateCard.TYPE.YEAR + }, { + text: BI.i18nText("BI-Basic_Single_Quarter"), + value: BI.DynamicDateCard.TYPE.QUARTER + }, { + text: BI.i18nText("BI-Basic_Month"), + value: BI.DynamicDateCard.TYPE.MONTH + }, { + text: BI.i18nText("BI-Basic_Week"), + value: BI.DynamicDateCard.TYPE.WEEK + }, { + text: BI.i18nText("BI-Basic_Day"), + value: BI.DynamicDateCard.TYPE.DAY + }], { + type: "bi.multi_select_item", + logic: { + dynamic: true + } + }), + layouts: [{ + type: "bi.left", + rgap: 4 + }], + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function () { + var value = self.checkgroup.getValue(); + if(value.length !== 0) { + self.workDayBox.setSelected(false); + } + + var plainValue = {}; + BI.each(self.resultPane.getAllButtons(), function (idx, button) { + var value = button.getValue(); + if(BI.isNotNull(value.dateType)) { + plainValue[value.dateType] = { + value: value.value, + offset: value.offset + }; + } + }); + self.resultPane.populate(self._getParamJson(BI.map(self.checkgroup.getValue(), function (idx, v) { + var obj = { + dateType: v + }; + if(BI.has(plainValue, v)) { + obj.value = plainValue[v].value; + obj.offset = plainValue[v].offset; + } + return obj; + }))); + self.position = BI.DynamicDateCard.OFFSET.CURRENT; + self.fireEvent("EVENT_CHANGE"); + } + }] + }, { + type: "bi.vertical_adapt", + lgap: 2, + items: [{ + el: { + type: "bi.multi_select_item", + ref: function () { + self.workDayBox = this; + }, + logic: { + dynamic: true + }, + text: BI.i18nText("BI-Basic_Work_Day"), + value: BI.DynamicDateCard.TYPE.WORK_DAY, + listeners: [{ + eventName: BI.MultiSelectItem.EVENT_CHANGE, + action: function () { + if(this.isSelected()) { + self.checkgroup.setValue(); + } + self.resultPane.populate(this.isSelected() ? self._getParamJson([{ + dateType: BI.DynamicDateCard.TYPE.WORK_DAY + }]) : []); + self.position = BI.DynamicDateCard.OFFSET.CURRENT; + self.fireEvent("EVENT_CHANGE"); + } + }] + }, + bgap: 5 + }], + ref: function () { + self.workDay = this; + } + }, { + type: "bi.button_group", + items: this._getParamJson([{ + dateType: BI.DynamicDateCard.TYPE.YEAR + }]), + ref: function () { + self.resultPane = this; + }, + layouts: [{ + type: "bi.vertical", + bgap: 10, + hgap: 10 + }] + }] + }; + }, + + _getParamJson: function (values, positionValue) { + var self = this; + var items = BI.map(values, function (idx, value) { + return { + type: "bi.dynamic_date_param_item", + dateType: value.dateType, + value: value.value, + offset: value.offset, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }] + }; + }); + + if(values.length === 1 && values[0].dateType === BI.DynamicDateCard.TYPE.DAY) { + var comboItems = this._getText(BI.DynamicDateCard.TYPE.MONTH); + comboItems[0].text = BI.i18nText("BI-Basic_Empty"); + items.push({ + type: "bi.text_value_combo", + height: 24, + items: comboItems, + value: positionValue || BI.DynamicDateCard.OFFSET.CURRENT, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.position = this.getValue()[0]; + self.fireEvent("EVENT_CHANGE"); + } + }] + }); + }else{ + if(values.length !== 0 && BI.last(values).dateType !== BI.DynamicDateCard.TYPE.DAY && BI.last(values).dateType !== BI.DynamicDateCard.TYPE.WORK_DAY) { + items.push({ + type: "bi.text_value_combo", + height: 24, + items: this._getText(BI.last(values).dateType), + value: positionValue || BI.DynamicDateCard.OFFSET.CURRENT, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.position = this.getValue()[0]; + self.fireEvent("EVENT_CHANGE"); + } + }] + }); + + } + } + + return items; + }, + + _getText: function (lastValue) { + switch (lastValue) { + case BI.DynamicDateCard.TYPE.YEAR: + return [{ + text: BI.i18nText("BI-Basic_Current_Day"), + value: BI.DynamicDateCard.OFFSET.CURRENT + }, { + text: BI.i18nText("BI-Basic_Year_Begin"), + value: BI.DynamicDateCard.OFFSET.BEGIN + }, { + text: BI.i18nText("BI-Basic_Year_End"), + value: BI.DynamicDateCard.OFFSET.END + }]; + case BI.DynamicDateCard.TYPE.QUARTER: + return [{ + text: BI.i18nText("BI-Basic_Current_Day"), + value: BI.DynamicDateCard.OFFSET.CURRENT + }, { + text: BI.i18nText("BI-Basic_Quarter_Begin"), + value: BI.DynamicDateCard.OFFSET.BEGIN + }, { + text: BI.i18nText("BI-Basic_Quarter_End"), + value: BI.DynamicDateCard.OFFSET.END + }]; + case BI.DynamicDateCard.TYPE.MONTH: + return [{ + text: BI.i18nText("BI-Basic_Current_Day"), + value: BI.DynamicDateCard.OFFSET.CURRENT + }, { + text: BI.i18nText("BI-Basic_Month_Begin"), + value: BI.DynamicDateCard.OFFSET.BEGIN + }, { + text: BI.i18nText("BI-Basic_Month_End"), + value: BI.DynamicDateCard.OFFSET.END + }]; + case BI.DynamicDateCard.TYPE.WEEK: + default: + return [{ + text: BI.i18nText("BI-Basic_Current_Day"), + value: BI.DynamicDateCard.OFFSET.CURRENT + }, { + text: BI.i18nText("BI-Basic_Week_Begin"), + value: BI.DynamicDateCard.OFFSET.BEGIN + }, { + text: BI.i18nText("BI-Basic_Week_End"), + value: BI.DynamicDateCard.OFFSET.END + }]; + } + }, + + _createValue: function (type, v) { + return { + dateType: type, + value: Math.abs(v), + offset: v > 0 ? 1 : 0 + }; + }, + + setValue: function (v) { + v = v || {}; + this.position = v.position || BI.DynamicDateCard.OFFSET.CURRENT; + var values = []; + var valuesItems = []; + if(BI.isNotNull(v.year)) { + values.push(BI.DynamicDateCard.TYPE.YEAR); + valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); + } + if(BI.isNotNull(v.quarter)) { + values.push(BI.DynamicDateCard.TYPE.QUARTER); + valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter)); + } + if(BI.isNotNull(v.month)) { + values.push(BI.DynamicDateCard.TYPE.MONTH); + valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.MONTH, v.month)); + } + if(BI.isNotNull(v.week)) { + values.push(BI.DynamicDateCard.TYPE.WEEK); + valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.WEEK, v.week)); + } + if(BI.isNotNull(v.day)) { + values.push(BI.DynamicDateCard.TYPE.DAY); + valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.DAY, v.day)); + } + if(BI.isNotNull(v.workDay)) { + values.push(BI.DynamicDateCard.TYPE.WORK_DAY); + valuesItems.push(this._createValue(BI.DynamicDateCard.TYPE.WORK_DAY, v.workDay)); + } + this.checkgroup.setValue(values); + this.workDayBox.setSelected(BI.isNotNull(v.workDay)); + this.resultPane.populate(this._getParamJson(valuesItems, v.position)); + }, + + getValue: function () { + var self = this; + var valueMap = {}; + var selectValues = this.checkgroup.getValue(); + var buttons = this.resultPane.getAllButtons(); + if(selectValues.length !== 0) { + BI.each(buttons, function (idx, button) { + var value = button.getValue(); + switch (value.dateType) { + case BI.DynamicDateCard.TYPE.YEAR: + valueMap.year = (value.offset === 0 ? -value.value : value.value); + break; + case BI.DynamicDateCard.TYPE.QUARTER: + valueMap.quarter = (value.offset === 0 ? -value.value : value.value); + break; + case BI.DynamicDateCard.TYPE.MONTH: + valueMap.month = (value.offset === 0 ? -value.value : value.value); + break; + case BI.DynamicDateCard.TYPE.WEEK: + valueMap.week = (value.offset === 0 ? -value.value : value.value); + break; + case BI.DynamicDateCard.TYPE.DAY: + valueMap.day = (value.offset === 0 ? -value.value : value.value); + break; + default: + break; + } + if(BI.isNull(value.dateType)) { + valueMap.position = self.position || BI.DynamicDateCard.OFFSET.CURRENT; + } + }); + } + if(this.workDayBox.isSelected()) { + var value = buttons[0].getValue(); + valueMap.workDay = (value.offset === 0 ? -value.value : value.value); + } + return valueMap; + } + +}); +BI.shortcut("bi.dynamic_date_card", BI.DynamicDateCard); + +BI.extend(BI.DynamicDateCard, { + TYPE: { + YEAR: 1, + QUARTER: 2, + MONTH: 3, + WEEK: 4, + DAY: 5, + WORK_DAY: 6 + }, + OFFSET: { + CURRENT: 1, + BEGIN: 2, + END: 3 + } + +});BI.DynamicDateCombo = BI.inherit(BI.Single, { + constants: { + popupHeight: 259, + popupWidth: 270, + comboAdjustHeight: 1, + border: 1, + DATE_MIN_VALUE: "1900-01-01", + DATE_MAX_VALUE: "2099-12-31" + }, + + props: { + baseCls: "bi-dynamic-date-combo bi-border", + height: 24 + }, + + + render: function () { + var self = this, opts = this.options; + this.storeTriggerValue = ""; + var date = BI.getDate(); + this.storeValue = opts.value; + return { + type: "bi.htape", + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: 24, + height: 24, + ref: function () { + self.changeIcon = this; + } + }, + width: 24 + }, { + type: "bi.absolute", + items: [{ + el: { + type: "bi.combo", + ref: function () { + self.combo = this; + }, + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: { + type: "bi.dynamic_date_trigger", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE, + value: opts.value, + ref: function () { + self.trigger = this; + }, + listeners: [{ + eventName: BI.DynamicDateTrigger.EVENT_KEY_DOWN, + action: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_STOP, + action: function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK, + action: function () { + self.combo.toggle(); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_FOCUS, + action: function () { + self.storeTriggerValue = self.trigger.getKey(); + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + self.fireEvent(BI.DynamicDateCombo.EVENT_FOCUS); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_ERROR, + action: function () { + self.storeValue = { + type: BI.DynamicDateCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1 + } + }; + self.fireEvent(BI.DynamicDateCombo.EVENT_ERROR); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_VALID, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_VALID); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateCombo.EVENT_CHANGE); + } + }, { + eventName: BI.DynamicDateTrigger.EVENT_CONFIRM, + action: function () { + if (self.combo.isViewVisible()) { + return; + } + var dateStore = self.storeTriggerValue; + var dateObj = self.trigger.getKey(); + if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { + self.storeValue = self.trigger.getValue(); + self.setValue(self.trigger.getValue()); + } else if (BI.isEmptyString(dateObj)) { + self.storeValue = null; + self.trigger.setValue(); + } + self._checkDynamicValue(self.storeValue); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }] + }, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: { + type: "bi.dynamic_date_popup", + behaviors: opts.behaviors, + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE, + value: opts.value, + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE, + action: function () { + var date = BI.getDate(); + self.setValue({ + type: BI.DynamicDateCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + } + }); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE, + action: function () { + var value = self.popup.getValue(); + if(self._checkValue(value)) { + self.setValue(value); + } + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDatePopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }] + }, + stopPropagation: false + }, + listeners: [{ + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, + action: function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW); + } + }] + }, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-font", + width: 24, + height: 24, + listeners: [{ + eventName: BI.IconButton.EVENT_CHANGE, + action: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + } + }] + }, + top: 0, + right: 0 + }] + }], + ref: function (_ref) { + self.comboWrapper = _ref; + } + }; + }, + + mounted: function () { + this._checkDynamicValue(this.storeValue); + }, + + _checkDynamicValue: function (v) { + var type = null; + if (BI.isNotNull(v)) { + type = v.type; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + this.changeIcon.setVisible(true); + this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.resize(); + break; + default: + this.comboWrapper.attr("items")[0].width = 0; + this.comboWrapper.resize(); + this.changeIcon.setVisible(false); + break; + } + }, + + _checkValue: function (v) { + switch (v.type) { + case BI.DynamicDateCombo.Dynamic: + return BI.isNotEmptyObject(v.value); + case BI.DynamicDateCombo.Static: + default: + return true; + } + }, + + setValue: function (v) { + this.storeValue = v; + this.trigger.setValue(v); + this._checkDynamicValue(v); + }, + getValue: function () { + return this.storeValue; + }, + getKey: function () { + return this.trigger.getKey(); + }, + hidePopupView: function () { + this.combo.hideView(); + } +}); + +BI.DynamicDateCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicDateCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DynamicDateCombo.EVENT_VALID = "EVENT_VALID"; +BI.DynamicDateCombo.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW = "BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW"; + +BI.shortcut("bi.dynamic_date_combo", BI.DynamicDateCombo); + +BI.extend(BI.DynamicDateCombo, { + Static: 1, + Dynamic: 2 +});BI.DynamicDateParamItem = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-dynamic-date-param-item", + dateType: BI.DynamicDateCard.TYPE.YEAR, + value: 0, + offset: 0, + height: 24 + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.htape", + items: [{ + el: { + type: "bi.sign_editor", + cls: "bi-border", + height: 22, + validationChecker: function (v) { + return BI.isNaturalNumber(v); + }, + value: o.value, + ref: function () { + self.editor = this; + }, + errorText: function (v) { + if(BI.isEmptyString(v)) { + return BI.i18nText("BI-Basic_Please_Input_Content"); + } + return BI.i18nText("BI-Please_Input_Natural_Number"); + }, + allowBlank: false, + listeners: [{ + eventName: BI.SignEditor.EVENT_CONFIRM, + action: function () { + self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE); + } + }] + }, + width: 60 + }, { + el: { + type: "bi.label", + height: 24, + text: this._getText() + }, + width: o.dateType === BI.DynamicDateCard.TYPE.WORK_DAY ? 60 : 20 + }, { + type: "bi.text_value_combo", + height: 24, + items: [{ + text: BI.i18nText("BI-Basic_Front"), + value: 0 + }, { + text: BI.i18nText("BI-Basic_Behind"), + value: 1 + }], + ref: function () { + self.offsetCombo = this; + }, + value: o.offset, + listeners: [{ + eventName: BI.TextValueCombo.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateParamItem.EVENT_CHANGE); + } + }] + }] + }; + }, + + _getText: function () { + var text = ""; + switch (this.options.dateType) { + case BI.DynamicDateCard.TYPE.YEAR: + text = BI.i18nText("BI-Basic_Year"); + break; + case BI.DynamicDateCard.TYPE.QUARTER: + text = BI.i18nText("BI-Basic_Single_Quarter"); + break; + case BI.DynamicDateCard.TYPE.MONTH: + text = BI.i18nText("BI-Basic_Month"); + break; + case BI.DynamicDateCard.TYPE.WEEK: + text = BI.i18nText("BI-Basic_Week"); + break; + case BI.DynamicDateCard.TYPE.DAY: + text = BI.i18nText("BI-Basic_Day"); + break; + case BI.DynamicDateCard.TYPE.WORK_DAY: + default: + text = BI.i18nText("BI-Basic_Work_Day"); + break; + } + return text; + }, + + setValue: function (v) { + v = v || {}; + v.value = v.value || 0; + v.offset = v.offset || 0; + this.editor.setValue(v.value); + this.offsetCombo.setValue(v.offset); + }, + + getValue: function () { + return { + dateType: this.options.dateType, + value: this.editor.getValue(), + offset: this.offsetCombo.getValue()[0] + }; + } + +}); +BI.DynamicDateParamItem.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.dynamic_date_param_item", BI.DynamicDateParamItem); +BI.DynamicDatePopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + buttonHeight: 24 + }, + + props: { + baseCls: "bi-dynamic-date-popup", + width: 248, + height: 344 + }, + + _init: function () { + BI.DynamicDatePopup.superclass._init.apply(this, arguments); + var self = this, opts = this.options, c = this.constants; + this.storeValue = {type: BI.DynamicDateCombo.Static}; + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this._getTabJson() + }, { + el: { + type: "bi.grid", + items: [[{ + type: "bi.text_button", + forceCenter: true, + cls: "bi-high-light bi-border-top", + shadow: true, + text: BI.i18nText("BI-Basic_Clear"), + textHeight: c.buttonHeight - 1, + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-left bi-border-right bi-high-light bi-border-top", + shadow: true, + textHeight: c.buttonHeight - 1, + text: BI.i18nText("BI-Multi_Date_Today"), + ref: function () { + self.textButton = this; + }, + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-high-light bi-border-top", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_OK"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE); + } + }] + }]] + }, + height: 24 + }] + }); + this.setValue(opts.value); + }, + + _getTabJson: function () { + var self = this, o = this.options; + return { + type: "bi.tab", + ref: function () { + self.dateTab = this; + }, + tab: { + type: "bi.linear_segment", + cls: "bi-border-bottom", + height: this.constants.tabHeight, + items: BI.createItems([{ + text: BI.i18nText("BI-Multi_Date_YMD"), + value: BI.DynamicDateCombo.Static + }, { + text: BI.i18nText("BI-Basic_Dynamic_Title"), + value: BI.DynamicDateCombo.Dynamic + }], { + textAlign: "center" + }) + }, + cardCreator: function (v) { + switch (v) { + case BI.DynamicDateCombo.Dynamic: + return { + type: "bi.dynamic_date_card", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self._setInnerValue(self.year, v); + } + }], + ref: function () { + self.dynamicPane = this; + } + }; + case BI.DynamicDateCombo.Static: + default: + return { + type: "bi.date_calendar_popup", + behaviors: o.behaviors, + min: self.options.min, + max: self.options.max, + listeners: [{ + eventName: BI.DateCalendarPopup.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDatePopup.EVENT_CHANGE); + } + }], + ref: function () { + self.ymd = this; + } + }; + } + }, + listeners: [{ + eventName: BI.Tab.EVENT_CHANGE, + action: function () { + var v = self.dateTab.getSelect(); + switch (v) { + case BI.DynamicDateCombo.Static: + var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); + self.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + }); + self._setInnerValue(); + break; + case BI.DynamicDateCombo.Dynamic: + default: + if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) { + self.dynamicPane.setValue(self.storeValue.value); + }else{ + self.dynamicPane.setValue({ + year: 0 + }); + } + self._setInnerValue(); + break; + } + } + }] + }; + }, + + _setInnerValue: function () { + if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.textButton.setEnable(true); + } else { + var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); + date = date.print("%Y-%x-%e"); + this.textButton.setValue(date); + this.textButton.setEnable(false); + } + }, + + _checkValueValid: function (value) { + return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); + }, + + setValue: function (v) { + this.storeValue = v; + var self = this; + var type, value; + v = v || {}; + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + this.dateTab.setSelect(type); + switch (type) { + case BI.DynamicDateCombo.Dynamic: + this.dynamicPane.setValue(value); + self._setInnerValue(); + break; + case BI.DynamicDateCombo.Static: + default: + if (this._checkValueValid(value)) { + var date = BI.getDate(); + this.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + }); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } else { + this.ymd.setValue(value); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } + this.textButton.setEnable(true); + break; + } + }, + + getValue: function () { + return { + type: this.dateTab.getSelect(), + value: this.dateTab.getValue() + }; + } +}); +BI.DynamicDatePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DynamicDatePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.DynamicDatePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; +BI.DynamicDatePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; +BI.shortcut("bi.dynamic_date_popup", BI.DynamicDatePopup);BI.DynamicDateTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + yearLength: 4, + yearMonthLength: 6, + yearFullMonthLength: 7 + }, + + props: { + extraCls: "bi-date-trigger", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }, + + _init: function () { + BI.DynamicDateTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.storeTriggerValue = ""; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + var date = v.match(/\d+/g); + self._autoAppend(v, date); + return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({ + year: date[0] | 0, + month: date[1] | 0, + day: date[2] | 0 + }); + }, + quitChecker: function () { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + errorText: function () { + if (self.editor.isEditing()) { + return BI.i18nText("BI-Date_Trigger_Error_Text"); + } + return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + }, + title: function () { + var storeValue = self.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = self._getText(value); + var date = BI.getDate(); + date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y-%x-%e"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + return ""; + } + return BI.getDate(value.year, (value.month - 1), value.day).print("%Y-%X-%d"); + } + } + }); + this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_KEY_DOWN); + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.storeTriggerValue = self.getKey(); + self.fireEvent(BI.DynamicDateTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_VALID, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_VALID); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_ERROR); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setState(value); + } + + if (BI.isNotEmptyString(value) && !BI.isEqual(self.storeTriggerValue, self.getKey())) { + var date = value.split("-"); + self.storeValue = { + type: BI.DynamicDateCombo.Static, + value: { + year: date[0] | 0, + month: date[1] | 0, + day: date[2] | 0 + } + }; + } + self.fireEvent(BI.DynamicDateTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.DynamicDateTrigger.EVENT_CHANGE); + }); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.editor + }, { + el: BI.createWidget(), + width: 24 + }] + }); + this.setValue(o.value); + }, + _dateCheck: function (date) { + return BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") === date || + BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") === date || + BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") === date || + BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") === date; + }, + _checkVoid: function (obj) { + return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; + }, + _autoAppend: function (v, dateObj) { + if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) { + switch (v.length) { + case this._const.yearLength: + if (this._yearCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + case this._const.yearMonthLength: + case this._const.yearFullMonthLength: + var splitMonth = v.split("-")[1]; + if ((BI.isNotNull(splitMonth) && splitMonth.length === 2) || this._monthCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + } + } + }, + + _yearCheck: function (v) { + var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; + }, + + _monthCheck: function (v) { + var date = BI.parseDateTime(v, "%Y-%X-%d"); + var dateStr = date.print("%Y-%X-%d"); + return (date.getMonth() >= 0 && (BI.parseDateTime(v, "%Y-%X").print("%Y-%X") === v || + BI.parseDateTime(v, "%Y-%x").print("%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max; + }, + + _setInnerValue: function (date) { + var dateStr = date.print("%Y-%x-%e"); + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + }, + + _getText: function (obj) { + var value = ""; + var endText = ""; + if(BI.isNotNull(obj.year)) { + if(BI.parseInt(obj.year) !== 0) { + value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); + } + if(BI.isNotNull(obj.quarter)) { + if(BI.parseInt(obj.quarter) !== 0) { + value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); + } + if(BI.isNotNull(obj.month)) { + if(BI.parseInt(obj.month) !== 0) { + value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); + } + if(BI.isNotNull(obj.week)) { + if(BI.parseInt(obj.week) !== 0) { + value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); + } + if(BI.isNotNull(obj.day)) { + if(BI.parseInt(obj.day) !== 0) { + value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; + } + if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { + value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + return value + endText; + + function getPositionText (baseText, position) { + switch (position) { + case BI.DynamicDateCard.OFFSET.BEGIN: + return baseText + BI.i18nText("BI-Basic_Begin_Start"); + case BI.DynamicDateCard.OFFSET.END: + return baseText + BI.i18nText("BI-Basic_End_Stop"); + case BI.DynamicDateCard.OFFSET.CURRENT: + default: + return BI.i18nText("BI-Basic_Current_Day"); + } + } + }, + + setValue: function (v) { + var type, value, self = this; + var date = BI.getDate(); + this.storeValue = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + date = BI.DynamicDateHelper.getCalculation(value); + this._setInnerValue(date, text); + break; + case BI.DynamicDateCombo.Static: + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + this.editor.setState(""); + this.editor.setValue(""); + } else { + var dateStr = BI.getDate(value.year, (value.month - 1), value.day).print("%Y-%X-%d"); + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + } + break; + } + }, + + getKey: function () { + return this.editor.getValue(); + }, + getValue: function () { + return this.storeValue; + } + +}); + +BI.DynamicDateTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTrigger.EVENT_START = "EVENT_START"; +BI.DynamicDateTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DynamicDateTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicDateTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DynamicDateTrigger.EVENT_VALID = "EVENT_VALID"; +BI.DynamicDateTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicDateTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.DynamicDateTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.dynamic_date_trigger", BI.DynamicDateTrigger); +BI.DynamicDateTimeCombo = BI.inherit(BI.Single, { + constants: { + popupHeight: 259, + popupWidth: 270, + comboAdjustHeight: 1, + border: 1, + DATE_MIN_VALUE: "1900-01-01", + DATE_MAX_VALUE: "2099-12-31" + }, + + props: { + baseCls: "bi-dynamic-date-combo bi-border", + height: 24 + }, + + + render: function () { + var self = this, opts = this.options; + this.storeTriggerValue = ""; + var date = BI.getDate(); + this.storeValue = opts.value; + return { + type: "bi.htape", + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: 24, + height: 24, + ref: function () { + self.changeIcon = this; + } + }, + width: 24 + }, { + type: "bi.absolute", + items: [{ + el: { + type: "bi.combo", + ref: function () { + self.combo = this; + }, + toggle: false, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: { + type: "bi.dynamic_date_time_trigger", + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE, + value: opts.value, + ref: function () { + self.trigger = this; + }, + listeners: [{ + eventName: BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN, + action: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_STOP, + action: function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK, + action: function () { + self.combo.toggle(); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_FOCUS, + action: function () { + self.storeTriggerValue = self.trigger.getKey(); + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_FOCUS); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_ERROR, + action: function () { + self.storeValue = { + type: BI.DynamicDateTimeCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1 + } + }; + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_ERROR); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_VALID, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_VALID); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CHANGE); + } + }, { + eventName: BI.DynamicDateTimeTrigger.EVENT_CONFIRM, + action: function () { + if (self.combo.isViewVisible()) { + return; + } + var dateStore = self.storeTriggerValue; + var dateObj = self.trigger.getKey(); + if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { + self.storeValue = self.trigger.getValue(); + self.setValue(self.trigger.getValue()); + } else if (BI.isEmptyString(dateObj)) { + self.storeValue = null; + self.trigger.setValue(); + } + self._checkDynamicValue(self.storeValue); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }] + }, + adjustLength: this.constants.comboAdjustHeight, + popup: { + el: { + type: "bi.dynamic_date_time_popup", + behaviors: opts.behaviors, + min: this.constants.DATE_MIN_VALUE, + max: this.constants.DATE_MAX_VALUE, + value: opts.value, + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE, + action: function () { + var date = BI.getDate(); + self.setValue({ + type: BI.DynamicDateTimeCombo.Static, + value: { + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate(), + hour: 0, + minute: 0, + second: 0 + } + }); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE, + action: function () { + var value = self.popup.getValue(); + if(self._checkValue(value)) { + self.setValue(value); + } + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicDateTimePopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_CONFIRM); + } + }] + }, + stopPropagation: false + }, + listeners: [{ + eventName: BI.Combo.EVENT_BEFORE_POPUPVIEW, + action: function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW); + } + }] + }, + top: 0, + left: 0, + right: 0, + bottom: 0 + }, { + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-font", + width: 24, + height: 24, + listeners: [{ + eventName: BI.IconButton.EVENT_CHANGE, + action: function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + } + }] + }, + top: 0, + right: 0 + }] + }], + ref: function (_ref) { + self.comboWrapper = _ref; + } + }; + }, + + mounted: function () { + this._checkDynamicValue(this.storeValue); + }, + + _checkDynamicValue: function (v) { + var type = null; + if (BI.isNotNull(v)) { + type = v.type; + } + switch (type) { + case BI.DynamicDateTimeCombo.Dynamic: + this.changeIcon.setVisible(true); + this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.resize(); + break; + default: + this.comboWrapper.attr("items")[0].width = 0; + this.comboWrapper.resize(); + this.changeIcon.setVisible(false); + break; + } + }, + + _checkValue: function (v) { + switch (v.type) { + case BI.DynamicDateCombo.Dynamic: + return BI.isNotEmptyObject(v.value); + case BI.DynamicDateCombo.Static: + default: + return true; + } + }, + + setValue: function (v) { + this.storeValue = v; + this.trigger.setValue(v); + this._checkDynamicValue(v); + }, + getValue: function () { + return this.storeValue; + }, + getKey: function () { + return this.trigger.getKey(); + }, + hidePopupView: function () { + this.combo.hideView(); + }, + + isValid: function () { + return this.trigger.isValid(); + } +}); + +BI.DynamicDateTimeCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicDateTimeCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DynamicDateTimeCombo.EVENT_VALID = "EVENT_VALID"; +BI.DynamicDateTimeCombo.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; + +BI.shortcut("bi.dynamic_date_time_combo", BI.DynamicDateTimeCombo); + +BI.extend(BI.DynamicDateTimeCombo, { + Static: 1, + Dynamic: 2 +});BI.DynamicDateTimePopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + buttonHeight: 24 + }, + + props: { + baseCls: "bi-dynamic-date-time-popup", + width: 248, + height: 385 + }, + + _init: function () { + BI.DynamicDateTimePopup.superclass._init.apply(this, arguments); + var self = this, opts = this.options, c = this.constants; + this.storeValue = {type: BI.DynamicDateCombo.Static}; + BI.createWidget({ + element: this, + type: "bi.vtape", + items: [{ + el: this._getTabJson() + }, { + el: { + type: "bi.grid", + items: [[{ + type: "bi.text_button", + forceCenter: true, + cls: "bi-high-light bi-border-top", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_Clear"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-left bi-border-right bi-high-light bi-border-top", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Multi_Date_Today"), + ref: function () { + self.textButton = this; + }, + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-high-light bi-border-top", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_OK"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE); + } + }] + }]] + }, + height: 24 + }] + }); + this.setValue(opts.value); + }, + + _getTabJson: function () { + var self = this, o = this.options; + return { + type: "bi.tab", + ref: function () { + self.dateTab = this; + }, + tab: { + type: "bi.linear_segment", + cls: "bi-border-bottom", + height: this.constants.tabHeight, + items: BI.createItems([{ + text: BI.i18nText("BI-Multi_Date_YMD"), + value: BI.DynamicDateCombo.Static + }, { + text: BI.i18nText("BI-Basic_Dynamic_Title"), + value: BI.DynamicDateCombo.Dynamic + }], { + textAlign: "center" + }) + }, + cardCreator: function (v) { + switch (v) { + case BI.DynamicDateCombo.Dynamic: + return { + type: "bi.dynamic_date_card", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self._setInnerValue(self.year, v); + } + }], + ref: function () { + self.dynamicPane = this; + } + }; + case BI.DynamicDateCombo.Static: + default: + return { + type: "bi.vtape", + items: [{ + type: "bi.date_calendar_popup", + behaviors: o.behaviors, + min: self.options.min, + max: self.options.max, + ref: function () { + self.ymd = this; + } + }, { + el: { + type: "bi.dynamic_date_time_select", + ref: function () { + self.timeSelect = this; + }, + listeners: [{ + eventName: BI.DynamicDateTimeSelect.EVENT_CONFIRM, + action: function () { + + } + }] + }, + height: 40 + }] + }; + } + }, + listeners: [{ + eventName: BI.Tab.EVENT_CHANGE, + action: function () { + var v = self.dateTab.getSelect(); + switch (v) { + case BI.DynamicDateCombo.Static: + var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); + self.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + }); + self.timeSelect.setValue(); + self._setInnerValue(); + break; + case BI.DynamicDateCombo.Dynamic: + default: + if(self.storeValue && self.storeValue.type === BI.DynamicDateCombo.Dynamic) { + self.dynamicPane.setValue(self.storeValue.value); + }else{ + self.dynamicPane.setValue({ + year: 0 + }); + } + self._setInnerValue(); + break; + } + } + }] + }; + }, + + _setInnerValue: function () { + if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + this.textButton.setEnable(true); + } else { + var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); + date = date.print("%Y-%x-%e"); + this.textButton.setValue(date); + this.textButton.setEnable(false); + } + }, + + _checkValueValid: function (value) { + return BI.isNull(value) || BI.isEmptyObject(value) || BI.isEmptyString(value); + }, + + setValue: function (v) { + this.storeValue = v; + var self = this; + var type, value; + v = v || {}; + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + this.dateTab.setSelect(type); + switch (type) { + case BI.DynamicDateCombo.Dynamic: + this.dynamicPane.setValue(value); + self._setInnerValue(); + break; + case BI.DynamicDateCombo.Static: + default: + if (this._checkValueValid(value)) { + var date = BI.getDate(); + this.ymd.setValue({ + year: date.getFullYear(), + month: date.getMonth() + 1, + day: date.getDate() + }); + this.timeSelect.setValue(); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } else { + this.ymd.setValue(value); + this.timeSelect.setValue({ + hour: value.hour, + minute: value.minute, + second: value.second + }); + this.textButton.setValue(BI.i18nText("BI-Multi_Date_Today")); + } + this.textButton.setEnable(true); + break; + } + }, + + getValue: function () { + var type = this.dateTab.getSelect(); + return { + type: type, + value: type === BI.DynamicDateTimeCombo.Static ? BI.extend(this.ymd.getValue(), this.timeSelect.getValue()) : this.dynamicPane.getValue() + }; + } +}); +BI.DynamicDateTimePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DynamicDateTimePopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.DynamicDateTimePopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; +BI.DynamicDateTimePopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; +BI.shortcut("bi.dynamic_date_time_popup", BI.DynamicDateTimePopup);BI.DynamicDateTimeSelect = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-date-time-select bi-border-top" + }, + + render: function () { + var self = this; + return { + type: "bi.center_adapt", + items: [{ + type: "bi.vertical_adapt", + items: [{ + el: { + type: "bi.number_editor", + ref: function () { + self.hour = this; + }, + validationChecker: function (v) { + return BI.isNaturalNumber(v) && BI.parseInt(v) < 24; + }, + errorText: function (v) { + if(BI.isNumeric(v)) { + return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-23\""); + } + return BI.i18nText("BI-Numerical_Interval_Input_Data"); + }, + listeners: [{ + eventName: BI.SignEditor.EVENT_CONFIRM, + action: function () { + var value = this.getValue(); + self._checkHour(value); + this.setValue(self._formatValueToDoubleDigit(value)); + self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); + } + }, { + eventName: BI.SignEditor.EVENT_CHANGE, + action: function () { + var value = self._autoSwitch(this.getValue(), BI.DynamicDateTimeSelect.HOUR); + this.setValue(value); + } + }], + width: 60, + height: 24 + }, + lgap: 14 + }, { + type: "bi.label", + text: ":", + width: 20 + }, { + type: "bi.number_editor", + ref: function () { + self.minute = this; + }, + validationChecker: function (v) { + return BI.isNaturalNumber(v) && BI.parseInt(v) < 60; + }, + errorText: function (v) { + if(BI.isNumeric(v)) { + return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-59\""); + } + return BI.i18nText("BI-Numerical_Interval_Input_Data"); + }, + listeners: [{ + eventName: BI.SignEditor.EVENT_CONFIRM, + action: function () { + var value = this.getValue(); + self._checkMinute(value); + this.setValue(self._formatValueToDoubleDigit(value), BI.DynamicDateTimeSelect.MINUTE); + self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); + } + }, { + eventName: BI.SignEditor.EVENT_CHANGE, + action: function () { + var value = self._autoSwitch(this.getValue(), BI.DynamicDateTimeSelect.MINUTE); + this.setValue(value); + } + }], + width: 60, + height: 24 + }, { + type: "bi.label", + text: ":", + width: 20 + }, { + type: "bi.number_editor", + ref: function () { + self.second = this; + }, + validationChecker: function (v) { + return BI.isNaturalNumber(v) && BI.parseInt(v) < 60; + }, + errorText: function (v) { + if(BI.isNumeric(v)) { + return BI.i18nText("BI-Basic_Input_From_To_Number", "\"00-59\""); + } + return BI.i18nText("BI-Numerical_Interval_Input_Data"); + }, + listeners: [{ + eventName: BI.SignEditor.EVENT_CONFIRM, + action: function () { + var value = this.getValue(); + self._checkSecond(value); + this.setValue(self._formatValueToDoubleDigit(value)); + self.fireEvent(BI.DynamicDateTimeSelect.EVENT_CONFIRM); + } + }], + width: 60, + height: 24 + }] + }] + }; + }, + + _checkBorder: function (v) { + v = v || {}; + this._checkHour(v.hour); + this._checkMinute(v.minute); + this._checkSecond(v.second); + }, + + _checkHour: function (value) { + this.hour.setDownEnable(BI.parseInt(value) > 0); + this.hour.setUpEnable(BI.parseInt(value) < 23); + }, + + _checkMinute: function (value) { + this.minute.setDownEnable(BI.parseInt(value) > 0); + this.minute.setUpEnable(BI.parseInt(value) < 59); + }, + + _checkSecond: function (value) { + this.second.setDownEnable(BI.parseInt(value) > 0); + this.second.setUpEnable(BI.parseInt(value) < 59); + }, + + _autoSwitch: function (v, type) { + var limit = 0; + var value = v; + switch (type) { + case BI.DynamicDateTimeSelect.HOUR: + limit = 2; + break; + case BI.DynamicDateTimeSelect.MINUTE: + limit = 5; + break; + default: + break; + } + if(v.length === 1 && BI.parseInt(v) > limit) { + value = "0" + value; + } + if (value.length === 2) { + type === BI.DynamicDateTimeSelect.HOUR ? this.minute.focus() : this.second.focus(); + } + return value; + }, + + _formatValueToDoubleDigit: function (v) { + if(BI.isNull(v) || BI.isEmptyString(v)) { + v = 0; + } + var value = BI.parseInt(v); + if(value < 10) { + value = "0" + value; + } + return value; + }, + + _assertValue: function (v) { + v = v || {}; + v.hour = this._formatValueToDoubleDigit(v.hour) || "00"; + v.minute = this._formatValueToDoubleDigit(v.minute) || "00"; + v.second = this._formatValueToDoubleDigit(v.second) || "00"; + return v; + }, + + getValue: function () { + return { + hour: BI.parseInt(this.hour.getValue()), + minute: BI.parseInt(this.minute.getValue()), + second: BI.parseInt(this.second.getValue()) + }; + }, + + setValue: function (v) { + v = this._assertValue(v); + this.hour.setValue(v.hour); + this.minute.setValue(v.minute); + this.second.setValue(v.second); + this._checkBorder(v); + } + +}); +BI.DynamicDateTimeSelect.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.dynamic_date_time_select", BI.DynamicDateTimeSelect); + +BI.extend(BI.DynamicDateTimeSelect, { + HOUR: 1, + MINUTE: 2 +});BI.DynamicDateTimeTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + yearLength: 4, + yearMonthLength: 6, + yearFullMonthLength: 7 + }, + + props: { + extraCls: "bi-date-time-trigger", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }, + + _init: function () { + BI.DynamicDateTimeTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.storeTriggerValue = ""; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + var date = v.match(/\d+/g); + self._autoAppend(v, date); + return self._dateCheck(v) && BI.checkDateLegal(v) && self._checkVoid({ + year: date[0] | 0, + month: date[1] | 0, + day: date[2] | 0 + }); + }, + quitChecker: function () { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + errorText: function () { + if (self.editor.isEditing()) { + return BI.i18nText("BI-Basic_Date_Time_Error_Text"); + } + return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + }, + title: function () { + var storeValue = self.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = self._getText(value); + var date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y-%x-%e %H:%M:%S"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + return ""; + } + return BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0, + value.second || 0).print("%Y-%X-%d %H:%M:%S"); + } + } + }); + this.editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN); + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.storeTriggerValue = self.getKey(); + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_VALID, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_VALID); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_ERROR); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setState(value); + } + + if (BI.isNotEmptyString(value) && !BI.isEqual(self.storeTriggerValue, self.getKey())) { + var date = value.split(/-|\s|:/); + self.storeValue = { + type: BI.DynamicDateCombo.Static, + value: { + year: date[0] | 0, + month: date[1] | 0, + day: date[2] | 0, + hour: date[3] | 0, + minute: date[4] | 0, + second: date[5] | 0 + } + }; + } + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.DynamicDateTimeTrigger.EVENT_CHANGE); + }); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.editor + }, { + el: BI.createWidget(), + width: 24 + }] + }); + this.setValue(o.value); + }, + _dateCheck: function (date) { + return BI.parseDateTime(date, "%Y-%x-%d %H:%M:%S").print("%Y-%x-%d %H:%M:%S") === date || + BI.parseDateTime(date, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S") === date || + BI.parseDateTime(date, "%Y-%x-%e %H:%M:%S").print("%Y-%x-%e %H:%M:%S") === date || + BI.parseDateTime(date, "%Y-%X-%e %H:%M:%S").print("%Y-%X-%e %H:%M:%S") === date || + + BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") === date || + BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") === date || + BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") === date || + BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") === date; + }, + _checkVoid: function (obj) { + return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.options.min, this.options.max)[0]; + }, + _autoAppend: function (v, dateObj) { + if (BI.isNotNull(dateObj) && BI.checkDateLegal(v)) { + switch (v.length) { + case this._const.yearLength: + if (this._yearCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + case this._const.yearMonthLength: + case this._const.yearFullMonthLength: + var splitMonth = v.split("-")[1]; + if ((BI.isNotNull(splitMonth) && splitMonth.length === 2) || this._monthCheck(v)) { + this.editor.setValue(v + "-"); + } + break; + } + } + }, + + _yearCheck: function (v) { + var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; + }, + + _monthCheck: function (v) { + var date = BI.parseDateTime(v, "%Y-%X-%d"); + var dateStr = date.print("%Y-%X-%d"); + return (date.getMonth() > 0 && (BI.parseDateTime(v, "%Y-%X").print("%Y-%X") === v || + BI.parseDateTime(v, "%Y-%x").print("%Y-%x") === v)) && dateStr >= this.options.min && dateStr <= this.options.max; + }, + + _setInnerValue: function (date) { + var dateStr = date.print("%Y-%x-%e %H:%M:%S"); + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + }, + + _getText: function (obj) { + var value = ""; + var endText = ""; + if(BI.isNotNull(obj.year)) { + if(BI.parseInt(obj.year) !== 0) { + value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Year"), obj.position); + } + if(BI.isNotNull(obj.quarter)) { + if(BI.parseInt(obj.quarter) !== 0) { + value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Single_Quarter"), obj.position); + } + if(BI.isNotNull(obj.month)) { + if(BI.parseInt(obj.month) !== 0) { + value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Month"), obj.position); + } + if(BI.isNotNull(obj.week)) { + if(BI.parseInt(obj.week) !== 0) { + value += Math.abs(obj.week) + BI.i18nText("BI-Basic_Week") + (obj.week < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = getPositionText(BI.i18nText("BI-Basic_Week"), obj.position); + } + if(BI.isNotNull(obj.day)) { + if(BI.parseInt(obj.day) !== 0) { + value += Math.abs(obj.day) + BI.i18nText("BI-Basic_Day") + (obj.day < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + endText = BI.size(obj) === 1 ? getPositionText(BI.i18nText("BI-Basic_Month"), obj.position) : ""; + } + if(BI.isNotNull(obj.workDay) && BI.parseInt(obj.workDay) !== 0) { + value += Math.abs(obj.workDay) + BI.i18nText("BI-Basic_Work_Day") + (obj.workDay < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + return value + endText; + + function getPositionText (baseText, position) { + switch (position) { + case BI.DynamicDateCard.OFFSET.BEGIN: + return baseText + BI.i18nText("BI-Basic_Begin_Start"); + case BI.DynamicDateCard.OFFSET.END: + return baseText + BI.i18nText("BI-Basic_End_Stop"); + case BI.DynamicDateCard.OFFSET.CURRENT: + default: + return BI.i18nText("BI-Basic_Current_Day"); + } + } + }, + + setValue: function (v) { + var type, value, self = this; + var date = BI.getDate(); + this.storeValue = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + date = BI.DynamicDateHelper.getCalculation(value); + this._setInnerValue(date, text); + break; + case BI.DynamicDateCombo.Static: + default: + if (BI.isNull(value) || BI.isNull(value.day)) { + this.editor.setState(""); + this.editor.setValue(""); + } else { + var dateStr = BI.getDate(value.year, (value.month - 1), value.day, value.hour || 0, value.minute || 0, + value.second || 0).print("%Y-%X-%d %H:%M:%S"); + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + } + break; + } + }, + + getKey: function () { + return this.editor.getValue(); + }, + getValue: function () { + return this.storeValue; + }, + + isValid: function () { + return this.editor.isValid(); + } + +}); + +BI.DynamicDateTimeTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicDateTimeTrigger.EVENT_START = "EVENT_START"; +BI.DynamicDateTimeTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DynamicDateTimeTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicDateTimeTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DynamicDateTimeTrigger.EVENT_VALID = "EVENT_VALID"; +BI.DynamicDateTimeTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicDateTimeTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.DynamicDateTimeTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.dynamic_date_time_trigger", BI.DynamicDateTimeTrigger);/** + * Created by roy on 15/9/14. + */ +BI.SearchEditor = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.SearchEditor.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-search-editor bi-border", + height: 24, + errorText: "", + watermark: BI.i18nText("BI-Basic_Search"), + validationChecker: BI.emptyFn, + quitChecker: BI.emptyFn + }); + }, + _init: function () { + this.options.height -= 2; + BI.SearchEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.editor", + height: o.height, + watermark: o.watermark, + allowBlank: true, + hgap: 1, + errorText: o.errorText, + validationChecker: o.validationChecker, + quitChecker: o.quitChecker + }); + this.clear = BI.createWidget({ + type: "bi.icon_button", + stopEvent: true, + cls: "circle-close-font" + }); + this.clear.on(BI.IconButton.EVENT_CHANGE, function () { + self.setValue(""); + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.STOPEDIT); + self.fireEvent(BI.SearchEditor.EVENT_CLEAR); + }); + BI.createWidget({ + element: this, + type: "bi.htape", + items: [ + { + el: { + type: "bi.center_adapt", + cls: "search-font", + items: [{ + el: { + type: "bi.icon" + } + }] + }, + width: 24 + }, + { + el: self.editor + }, + { + el: this.clear, + width: 24 + } + ] + }); + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.editor.on(BI.Editor.EVENT_FOCUS, function () { + self.fireEvent(BI.SearchEditor.EVENT_FOCUS); + }); + this.editor.on(BI.Editor.EVENT_BLUR, function () { + self.fireEvent(BI.SearchEditor.EVENT_BLUR); + }); + this.editor.on(BI.Editor.EVENT_CLICK, function () { + self.fireEvent(BI.SearchEditor.EVENT_CLICK); + }); + this.editor.on(BI.Editor.EVENT_CHANGE, function () { + self._checkClear(); + self.fireEvent(BI.SearchEditor.EVENT_CHANGE); + }); + this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { + self.fireEvent(BI.SearchEditor.EVENT_KEY_DOWN, v); + }); + this.editor.on(BI.Editor.EVENT_SPACE, function () { + self.fireEvent(BI.SearchEditor.EVENT_SPACE); + }); + this.editor.on(BI.Editor.EVENT_BACKSPACE, function () { + self.fireEvent(BI.SearchEditor.EVENT_BACKSPACE); + }); + + + this.editor.on(BI.Editor.EVENT_VALID, function () { + self.fireEvent(BI.SearchEditor.EVENT_VALID); + }); + this.editor.on(BI.Editor.EVENT_ERROR, function () { + self.fireEvent(BI.SearchEditor.EVENT_ERROR); + }); + this.editor.on(BI.Editor.EVENT_ENTER, function () { + self.fireEvent(BI.SearchEditor.EVENT_ENTER); + }); + this.editor.on(BI.Editor.EVENT_RESTRICT, function () { + self.fireEvent(BI.SearchEditor.EVENT_RESTRICT); + }); + this.editor.on(BI.Editor.EVENT_EMPTY, function () { + self._checkClear(); + self.fireEvent(BI.SearchEditor.EVENT_EMPTY); + }); + this.editor.on(BI.Editor.EVENT_REMOVE, function () { + self.fireEvent(BI.SearchEditor.EVENT_REMOVE); + }); + this.editor.on(BI.Editor.EVENT_CONFIRM, function () { + self.fireEvent(BI.SearchEditor.EVENT_CONFIRM); + }); + this.editor.on(BI.Editor.EVENT_START, function () { + self.fireEvent(BI.SearchEditor.EVENT_START); + }); + this.editor.on(BI.Editor.EVENT_PAUSE, function () { + self.fireEvent(BI.SearchEditor.EVENT_PAUSE); + }); + this.editor.on(BI.Editor.EVENT_STOP, function () { + self.fireEvent(BI.SearchEditor.EVENT_STOP); + }); + + this.clear.invisible(); + }, + + _checkClear: function () { + if (!this.getValue()) { + this.clear.invisible(); + } else { + this.clear.visible(); + } + }, + + focus: function () { + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + }, + + getValue: function () { + if (this.isValid()) { + var res = this.editor.getValue().match(/[\S]+/g); + return BI.isNull(res) ? "" : res[res.length - 1]; + } + }, + + getKeywords: function () { + var val = this.editor.getValue(); + var keywords = val.match(/[\S]+/g); + if (BI.isEndWithBlank(val)) { + return keywords.concat([" "]); + } + return keywords; + }, + + getLastValidValue: function () { + return this.editor.getLastValidValue(); + }, + + setValue: function (v) { + this.editor.setValue(v); + if (BI.isKey(v)) { + this.clear.visible(); + } + }, + + isEditing: function () { + return this.editor.isEditing(); + }, + + isValid: function () { + return this.editor.isValid(); + } +}); +BI.SearchEditor.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SearchEditor.EVENT_FOCUS = "EVENT_FOCUS"; +BI.SearchEditor.EVENT_BLUR = "EVENT_BLUR"; +BI.SearchEditor.EVENT_CLICK = "EVENT_CLICK"; +BI.SearchEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.SearchEditor.EVENT_SPACE = "EVENT_SPACE"; +BI.SearchEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE"; +BI.SearchEditor.EVENT_CLEAR = "EVENT_CLEAR"; + +BI.SearchEditor.EVENT_START = "EVENT_START"; +BI.SearchEditor.EVENT_PAUSE = "EVENT_PAUSE"; +BI.SearchEditor.EVENT_STOP = "EVENT_STOP"; +BI.SearchEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.SearchEditor.EVENT_VALID = "EVENT_VALID"; +BI.SearchEditor.EVENT_ERROR = "EVENT_ERROR"; +BI.SearchEditor.EVENT_ENTER = "EVENT_ENTER"; +BI.SearchEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; +BI.SearchEditor.EVENT_REMOVE = "EVENT_REMOVE"; +BI.SearchEditor.EVENT_EMPTY = "EVENT_EMPTY"; +BI.shortcut("bi.search_editor", BI.SearchEditor);/** + * 小号搜索框 + * Created by GUY on 2015/9/29. + * @class BI.SmallSearchEditor + * @extends BI.SearchEditor + */ +BI.SmallSearchEditor = BI.inherit(BI.SearchEditor, { + _defaultConfig: function () { + var conf = BI.SmallSearchEditor.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-small-search-editor", + height: 24 + }); + }, + + _init: function () { + BI.SmallSearchEditor.superclass._init.apply(this, arguments); + } +}); +BI.shortcut("bi.small_search_editor", BI.SmallSearchEditor);/** + * guy + * @class BI.TextEditor + * @extends BI.Single + */ +BI.TextEditor = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.TextEditor.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-text-editor bi-border", + hgap: 4, + vgap: 2, + lgap: 0, + rgap: 0, + tgap: 0, + bgap: 0, + validationChecker: BI.emptyFn, + quitChecker: BI.emptyFn, + allowBlank: false, + watermark: "", + errorText: "", + height: 24 + }); + }, + + _init: function () { + BI.TextEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + if (BI.isNumber(o.height)) { + this.element.css({height: o.height - 2}); + } + if (BI.isNumber(o.width)) { + this.element.css({width: o.width - 2}); + } + this.editor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + hgap: o.hgap, + vgap: o.vgap, + lgap: o.lgap, + rgap: o.rgap, + tgap: o.tgap, + bgap: o.bgap, + value: o.value, + title: o.title, + tipType: o.tipType, + validationChecker: o.validationChecker, + quitChecker: o.quitChecker, + allowBlank: o.allowBlank, + watermark: o.watermark, + errorText: o.errorText + }); + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.editor.on(BI.Editor.EVENT_FOCUS, function () { + self.fireEvent(BI.TextEditor.EVENT_FOCUS); + }); + this.editor.on(BI.Editor.EVENT_BLUR, function () { + self.fireEvent(BI.TextEditor.EVENT_BLUR); + }); + this.editor.on(BI.Editor.EVENT_CLICK, function () { + self.fireEvent(BI.TextEditor.EVENT_CLICK); + }); + this.editor.on(BI.Editor.EVENT_CHANGE, function () { + self.fireEvent(BI.TextEditor.EVENT_CHANGE); + }); + this.editor.on(BI.Editor.EVENT_KEY_DOWN, function (v) { + self.fireEvent(BI.TextEditor.EVENT_KEY_DOWN); + }); + this.editor.on(BI.Editor.EVENT_SPACE, function (v) { + self.fireEvent(BI.TextEditor.EVENT_SPACE); + }); + this.editor.on(BI.Editor.EVENT_BACKSPACE, function (v) { + self.fireEvent(BI.TextEditor.EVENT_BACKSPACE); + }); + + + this.editor.on(BI.Editor.EVENT_VALID, function () { + self.fireEvent(BI.TextEditor.EVENT_VALID); + }); + this.editor.on(BI.Editor.EVENT_CONFIRM, function () { + self.fireEvent(BI.TextEditor.EVENT_CONFIRM); + }); + this.editor.on(BI.Editor.EVENT_REMOVE, function (v) { + self.fireEvent(BI.TextEditor.EVENT_REMOVE); + }); + this.editor.on(BI.Editor.EVENT_START, function () { + self.fireEvent(BI.TextEditor.EVENT_START); + }); + this.editor.on(BI.Editor.EVENT_PAUSE, function () { + self.fireEvent(BI.TextEditor.EVENT_PAUSE); + }); + this.editor.on(BI.Editor.EVENT_STOP, function () { + self.fireEvent(BI.TextEditor.EVENT_STOP); + }); + this.editor.on(BI.Editor.EVENT_ERROR, function () { + self.fireEvent(BI.TextEditor.EVENT_ERROR, arguments); + }); + this.editor.on(BI.Editor.EVENT_ENTER, function () { + self.fireEvent(BI.TextEditor.EVENT_ENTER); + }); + this.editor.on(BI.Editor.EVENT_RESTRICT, function () { + self.fireEvent(BI.TextEditor.EVENT_RESTRICT); + }); + this.editor.on(BI.Editor.EVENT_EMPTY, function () { + self.fireEvent(BI.TextEditor.EVENT_EMPTY); + }); + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + element: this, + items: [this.editor] + }); + }, + + focus: function () { + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + }, + + setErrorText: function (text) { + this.editor.setErrorText(text); + }, + + getErrorText: function () { + return this.editor.getErrorText(); + }, + + isValid: function () { + return this.editor.isValid(); + }, + + setValue: function (v) { + this.editor.setValue(v); + }, + + getValue: function () { + return this.editor.getValue(); + } +}); +BI.TextEditor.EVENT_CHANGE = "EVENT_CHANGE"; +BI.TextEditor.EVENT_FOCUS = "EVENT_FOCUS"; +BI.TextEditor.EVENT_BLUR = "EVENT_BLUR"; +BI.TextEditor.EVENT_CLICK = "EVENT_CLICK"; +BI.TextEditor.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.TextEditor.EVENT_SPACE = "EVENT_SPACE"; +BI.TextEditor.EVENT_BACKSPACE = "EVENT_BACKSPACE"; + +BI.TextEditor.EVENT_START = "EVENT_START"; +BI.TextEditor.EVENT_PAUSE = "EVENT_PAUSE"; +BI.TextEditor.EVENT_STOP = "EVENT_STOP"; +BI.TextEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.TextEditor.EVENT_VALID = "EVENT_VALID"; +BI.TextEditor.EVENT_ERROR = "EVENT_ERROR"; +BI.TextEditor.EVENT_ENTER = "EVENT_ENTER"; +BI.TextEditor.EVENT_RESTRICT = "EVENT_RESTRICT"; +BI.TextEditor.EVENT_REMOVE = "EVENT_REMOVE"; +BI.TextEditor.EVENT_EMPTY = "EVENT_EMPTY"; + +BI.shortcut("bi.text_editor", BI.TextEditor);/** + * 小号搜索框 + * Created by GUY on 2015/9/29. + * @class BI.SmallTextEditor + * @extends BI.SearchEditor + */ +BI.SmallTextEditor = BI.inherit(BI.TextEditor, { + _defaultConfig: function () { + var conf = BI.SmallTextEditor.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-small-text-editor", + height: 24 + }); + }, + + _init: function () { + BI.SmallTextEditor.superclass._init.apply(this, arguments); + } +}); +BI.shortcut("bi.small_text_editor", BI.SmallTextEditor);/** + * 文件管理控件组 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerButtonGroup + * @extends BI.Widget + */ +BI.FileManagerButtonGroup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerButtonGroup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-button_group", + items: [] + }); + }, + + _init: function () { + BI.FileManagerButtonGroup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.button_group = BI.createWidget({ + type: "bi.button_tree", + element: this, + chooseType: BI.Selection.Multi, + items: this._formatItems(o.items), + layouts: [{ + type: "bi.vertical" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + _formatItems: function (items) { + var self = this, o = this.options; + BI.each(items, function (i, item) { + if (item.children && item.children.length > 0) { + item.type = "bi.file_manager_folder_item"; + } else { + item.type = "bi.file_manager_file_item"; + } + }); + return items; + }, + + setValue: function (v) { + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getNotSelectedValue: function () { + return this.button_group.getNotSelectedValue(); + }, + + getAllLeaves: function () { + return this.button_group.getAllLeaves(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + getSelectedButtons: function () { + return this.button_group.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.button_group.getNotSelectedButtons(); + }, + + populate: function (items) { + this.button_group.populate(this._formatItems(items)); + } +}); +BI.FileManagerButtonGroup.EVENT_CHANGE = "FileManagerButtonGroup.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_button_group", BI.FileManagerButtonGroup);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManager + * @extends BI.Widget + */ +BI.FileManager = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManager.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager", + el: {}, + items: [] + }); + }, + + _init: function () { + BI.FileManager.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + var items = BI.Tree.transformToTreeFormat(o.items); + this.tree.initTree(items); + this.selectedValues = []; + this.nav = BI.createWidget({ + type: "bi.file_manager_nav", + items: BI.deepClone(items) + }); + this.nav.on(BI.FileManagerNav.EVENT_CHANGE, function (value, obj) { + if (value == "-1") {// 根节点 + self.populate({children: self.tree.toJSON()}); + } else { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } + self.setValue(self.selectedValues); + }); + this.list = BI.createWidget(o.el, { + type: "bi.file_manager_list", + items: items + }); + this.list.on(BI.Controller.EVENT_CHANGE, function (type, selected, obj) { + if (type === BI.Events.CHANGE) { + var node = self.tree.search(obj.attr("id")); + self.populate(BI.extend({id: node.id}, node.get("data"), {children: self.tree.toJSON(node)})); + } else if (type === BI.Events.CLICK) { + var values = []; + if (obj instanceof BI.MultiSelectBar) { + var t = self.list.getValue(); + selected = t.type === BI.Selection.All; + values = BI.concat(t.assist, t.value); + } else { + values = obj.getAllLeaves(); + } + BI.each(values, function (i, v) { + if (selected === true) { + self.selectedValues.pushDistinct(v); + } else { + self.selectedValues.remove(v); + } + }); + } + self.setValue(self.selectedValues); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.list, + left: 0, + right: 0, + top: 0, + bottom: 10 + }, { + el: this.nav, + left: 40, + right: 100, + top: 0 + }] + }); + }, + + setValue: function (value) { + this.selectedValues = value || []; + this.list.setValue(this.selectedValues); + }, + + getValue: function () { + var obj = this.list.getValue(); + var res = obj.type === BI.Selection.All ? obj.assist : obj.value; + res.pushDistinctArray(this.selectedValues); + return res; + }, + + _populate: function (items) { + this.list.populate(items); + }, + + getSelectedValue: function () { + return this.nav.getValue()[0]; + }, + + getSelectedId: function () { + return this.nav.getId()[0]; + }, + + populate: function (node) { + var clone = BI.deepClone(node); + this._populate(node.children); + this.nav.populate(clone); + } +}); +BI.FileManager.EVENT_CHANGE = "FileManager.EVENT_CHANGE"; +BI.shortcut("bi.file_manager", BI.FileManager);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFileItem + * @extends BI.Single + */ +BI.FileManagerFileItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFileItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-file-item bi-list-item bi-border-bottom", + height: 30 + }); + }, + + _init: function () { + BI.FileManagerFileItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-file-font" + }, + width: 20 + }, { + el: { + type: "bi.label", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + } + }] + }); + }, + + getAllLeaves: function () { + return [this.options.value]; + }, + + isSelected: function () { + return this.checked.isSelected(); + }, + + setSelected: function (v) { + this.checked.setSelected(v); + } +}); +BI.FileManagerFileItem.EVENT_CHANGE = "FileManagerFileItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_file_item", BI.FileManagerFileItem);/** + * 文件管理控件 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerFolderItem + * @extends BI.Single + */ +BI.FileManagerFolderItem = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerFolderItem.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-folder-item bi-list-item bi-border-bottom", + height: 30 + }); + }, + + _init: function () { + BI.FileManagerFolderItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checked = BI.createWidget({ + type: "bi.multi_select_bar", + text: "", + width: 36, + height: o.height + }); + this.checked.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button = BI.createWidget({ + type: "bi.text_button", + textAlign: "left", + height: o.height, + text: o.text, + value: o.value + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, BI.Events.CHANGE, o.value, self); + }); + + this.tree = new BI.Tree(); + this.tree.initTree([{ + id: o.id, + children: o.children + }]); + this.selectValue = []; + + BI.createWidget({ + type: "bi.htape", + element: this, + items: [{ + el: this.checked, + width: 36 + }, { + el: { + type: "bi.icon_button", + cls: "create-by-me-folder-font" + }, + width: 20 + }, { + el: this.button + }] + }); + }, + + setAllSelected: function (v) { + this.checked.setSelected(v); + this.selectValue = []; + }, + + setHalfSelected: function (v) { + this.checked.setHalfSelected(v); + if(!v) { + this.selectValue = []; + } + }, + + setValue: function (v) { + var self = this, o = this.options; + var isHalf = false; + var selectValue = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + if (BI.contains(v, node.get("data").value)) { + selectValue.push(node.get("data").value); + } else { + isHalf = true; + } + } + }); + this.setAllSelected(selectValue.length > 0 && !isHalf); + this.setHalfSelected(selectValue.length > 0 && isHalf); + if (this.checked.isHalfSelected()) { + this.selectValue = selectValue; + } + }, + + getAllButtons: function () { + return [this]; + }, + + getAllLeaves: function () { + var o = this.options; + var res = []; + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value); + } + }); + return res; + }, + + getNotSelectedValue: function () { + var self = this, o = this.options; + var res = []; + var isAllSelected = this.checked.isSelected(); + if (isAllSelected === true) { + return res; + } + var isHalfSelected = this.checked.isHalfSelected(); + this.tree.traverse(function (node) { + if (node.isLeaf()) { + var v = node.get("data").value; + if (isHalfSelected === true) { + if (!BI.contains(self.selectValue, node.get("data").value)) { + res.push(v); + } + } else { + res.push(v); + } + } + }); + return res; + }, + + getValue: function () { + var res = []; + if (this.checked.isSelected()) { + this.tree.traverse(function (node) { + if (node.isLeaf()) { + res.push(node.get("data").value); + } + }); + return res; + } + if (this.checked.isHalfSelected()) { + return this.selectValue; + } + return []; + } +}); +BI.FileManagerFolderItem.EVENT_CHANGE = "FileManagerFolderItem.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_folder_item", BI.FileManagerFolderItem);/** + * 文件管理控件列表 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerList + * @extends BI.Widget + */ +BI.FileManagerList = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-list", + el: {}, + items: [] + }); + }, + + _init: function () { + BI.FileManagerList.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.list = BI.createWidget({ + type: "bi.select_list", + element: this, + items: o.items, + toolbar: { + type: "bi.multi_select_bar", + height: 40, + text: "" + }, + el: { + type: "bi.list_pane", + el: BI.isWidget(o.el) ? o.el : BI.extend({ + type: "bi.file_manager_button_group" + }, o.el) + } + }); + this.list.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + this.list.setValue({ + value: v + }); + }, + + getValue: function () { + return this.list.getValue(); + }, + + populate: function (items) { + this.list.populate(items); + this.list.setToolBarVisible(true); + } +}); +BI.FileManagerList.EVENT_CHANGE = "FileManagerList.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_list", BI.FileManagerList);/** + * 文件管理导航按钮 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNavButton + * @extends BI.Widget + */ +BI.FileManagerNavButton = BI.inherit(BI.Widget, { + + _const: { + normal_color: "#ffffff", + select_color: "#eff1f4" + }, + _defaultConfig: function () { + return BI.extend(BI.FileManagerNavButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav-button", + selected: false, + height: 40 + }); + }, + + _init: function () { + BI.FileManagerNavButton.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.button = BI.createWidget({ + type: "bi.text_button", + cls: "file-manager-nav-button-text bi-card", + once: true, + selected: o.selected, + text: o.text, + title: o.text, + value: o.value, + height: o.height, + lgap: 20, + rgap: 10 + }); + this.button.on(BI.Controller.EVENT_CHANGE, function () { + arguments[2] = self; + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + var svg = BI.createWidget({ + type: "bi.svg", + cls: "file-manager-nav-button-triangle", + width: 15, + height: o.height + }); + var path = svg.path("M0,0L15,20L0,40").attr({ + stroke: c.select_color, + fill: o.selected ? c.select_color : c.normal_color + }); + this.button.on(BI.TextButton.EVENT_CHANGE, function () { + if (this.isSelected()) { + path.attr("fill", c.select_color); + } else { + path.attr("fill", c.normal_color); + } + }); + BI.createWidget({ + type: "bi.default", + element: this, + items: [this.button] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: svg, + right: -15, + top: 0, + bottom: 0 + }] + }); + }, + + isSelected: function () { + return this.button.isSelected(); + }, + + setValue: function (v) { + this.button.setValue(v); + }, + + getValue: function () { + return this.button.getValue(); + }, + + populate: function (items) { + + } +}); +BI.FileManagerNavButton.EVENT_CHANGE = "FileManagerNavButton.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav_button", BI.FileManagerNavButton);/** + * 文件管理导航 + * + * Created by GUY on 2015/12/11. + * @class BI.FileManagerNav + * @extends BI.Widget + */ +BI.FileManagerNav = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.FileManagerNav.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-file-manager-nav bi-border-left", + height: 40, + items: [] + }); + }, + + _init: function () { + BI.FileManagerNav.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tree = new BI.Tree(); + this.refreshTreeData(o.items); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + this.button_group = BI.createWidget({ + type: "bi.button_group", + element: this, + items: [{ + type: "bi.file_manager_nav_button", + text: BI.i18nText("BI-Created_By_Me"), + selected: true, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME, + value: BI.FileManagerNav.ROOT_CREATE_BY_ME + }], + layouts: [{ + type: "bi.horizontal" + }] + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.ButtonGroup.EVENT_CHANGE, function (value, obj) { + self.fireEvent(BI.FileManagerNav.EVENT_CHANGE, arguments); + }); + }, + + _getAllParents: function (id) { + var node, res = []; + if (!id) { + node = this.tree.getRoot(); + } else { + node = this.tree.search(id); + } + while (node.parent) { + res.push(node); + node = node.parent; + } + res.push(node); + return res.reverse(); + }, + + _formatNodes: function (nodes) { + var res = []; + BI.each(nodes, function (i, node) { + res.push(BI.extend({ + type: "bi.file_manager_nav_button", + id: node.id + }, node.get("data"))); + }); + BI.last(res).selected = true; + return res; + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getId: function () { + var ids = []; + BI.each(this.button_group.getSelectedButtons(), function (i, btn) { + ids.push(btn.attr("id")); + }); + return ids; + }, + + refreshTreeData: function (items) { + this.tree.initTree(BI.Tree.transformToTreeFormat(items)); + this.tree.getRoot().set("data", { + text: BI.i18nText("BI-Created_By_Me"), + value: BI.FileManagerNav.ROOT_CREATE_BY_ME, + id: BI.FileManagerNav.ROOT_CREATE_BY_ME + }); + }, + + populate: function (node) { + var parents = BI.isNull(node) ? [this.tree.getRoot()] : this._getAllParents(node.id); + this.button_group.populate(this._formatNodes(parents)); + } +}); +BI.extend(BI.FileManagerNav, { + ROOT_CREATE_BY_ME: "-1" +}); +BI.FileManagerNav.EVENT_CHANGE = "FileManagerNav.EVENT_CHANGE"; +BI.shortcut("bi.file_manager_nav", BI.FileManagerNav);/** + * Created by zcf on 2016/9/26. + */ +BI.IntervalSlider = BI.inherit(BI.Single, { + _constant: { + EDITOR_WIDTH: 58, + EDITOR_R_GAP: 60, + EDITOR_HEIGHT: 30, + SLIDER_WIDTH_HALF: 15, + SLIDER_WIDTH: 30, + SLIDER_HEIGHT: 30, + TRACK_HEIGHT: 24 + }, + + props: { + baseCls: "bi-interval-slider bi-slider-track", + digit: false, + unit: "" + }, + + render: function () { + + var self = this; + var c = this._constant; + this.enable = false; + this.valueOne = ""; + this.valueTwo = ""; + this.calculation = new BI.AccurateCalculationModel(); + + // this.backgroundTrack = BI.createWidget({ + // type: "bi.layout", + // cls: "background-track", + // height: c.TRACK_HEIGHT + // }); + this.grayTrack = BI.createWidget({ + type: "bi.layout", + cls: "gray-track", + height: 6 + }); + this.blueTrack = BI.createWidget({ + type: "bi.layout", + cls: "blue-track bi-high-light-background", + height: 6 + }); + this.track = this._createTrackWrapper(); + + this.labelOne = BI.createWidget({ + type: "bi.sign_text_editor", + cls: "slider-editor-button", + text: this.options.unit, + textAlign: "left", + allowBlank: false, + width: c.EDITOR_WIDTH, + validationChecker: function (v) { + return self._checkValidation(v); + } + }); + this.labelOne.element.hover(function () { + self.labelOne.element.removeClass("bi-border").addClass("bi-border"); + }, function () { + self.labelOne.element.removeClass("bi-border"); + }); + this.labelOne.on(BI.Editor.EVENT_CONFIRM, function () { + var v = BI.parseFloat(this.getValue()); + self.valueOne = v; + var percent = self._getPercentByValue(v); + var significantPercent = BI.parseFloat(percent.toFixed(1));// 分成1000份 + self._setLabelOnePosition(significantPercent); + self._setSliderOnePosition(significantPercent); + self._setBlueTrack(); + self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); + }); + + this.labelTwo = BI.createWidget({ + type: "bi.sign_text_editor", + cls: "slider-editor-button", + text: this.options.unit, + allowBlank: false, + width: c.EDITOR_WIDTH, + textAlign: "right", + validationChecker: function (v) { + return self._checkValidation(v); + } + }); + this.labelTwo.element.hover(function () { + self.labelTwo.element.removeClass("bi-border").addClass("bi-border"); + }, function () { + self.labelTwo.element.removeClass("bi-border"); + }); + this.labelTwo.on(BI.Editor.EVENT_CONFIRM, function () { + var v = BI.parseFloat(this.getValue()); + self.valueTwo = v; + var percent = self._getPercentByValue(v); + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setLabelTwoPosition(significantPercent); + self._setSliderTwoPosition(significantPercent); + self._setBlueTrack(); + self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); + }); + + this.sliderOne = BI.createWidget({ + type: "bi.single_slider_button" + }); + this.sliderTwo = BI.createWidget({ + type: "bi.single_slider_button" + }); + this._draggable(this.sliderOne, true); + this._draggable(this.sliderTwo, false); + this._setVisible(false); + + return { + type: "bi.absolute", + element: this, + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.track, + width: "100%", + height: c.TRACK_HEIGHT + }] + }], + hgap: 7, + height: c.TRACK_HEIGHT + }, + top: 23, + left: 0, + width: "100%" + }, + this._createLabelWrapper(), + this._createSliderWrapper() + ] + }; + }, + + _rePosBySizeAfterMove: function (size, isLeft) { + var o = this.options; + var percent = size * 100 / (this._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1)); + var v = this._getValueByPercent(significantPercent); + v = this._assertValue(v); + v = o.digit === false ? v : v.toFixed(o.digit); + if(isLeft) { + this._setLabelOnePosition(significantPercent); + this._setSliderOnePosition(significantPercent); + this.labelOne.setValue(v); + this.valueOne = v; + }else{ + this._setLabelTwoPosition(significantPercent); + this._setSliderTwoPosition(significantPercent); + this.labelTwo.setValue(v); + this.valueTwo = v; + } + this._setBlueTrack(); + }, + + _rePosBySizeAfterStop: function (size, isLeft) { + var percent = size * 100 / (this._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1)); + isLeft ? this._setSliderOnePosition(significantPercent) : this._setSliderTwoPosition(significantPercent); + }, + + _draggable: function (widget, isLeft) { + var self = this, o = this.options; + var startDrag = false; + var size = 0, offset = 0, defaultSize = 0; + var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { + if (mouseMoveTracker.isDragging()) { + startDrag = true; + offset += deltaX; + size = optimizeSize(defaultSize + offset); + widget.element.addClass("dragging"); + self._rePosBySizeAfterMove(size, isLeft); + } + }, function () { + if (startDrag === true) { + size = optimizeSize(size); + self._rePosBySizeAfterStop(size, isLeft); + size = 0; + offset = 0; + defaultSize = size; + startDrag = false; + } + widget.element.removeClass("dragging"); + mouseMoveTracker.releaseMouseMoves(); + self.fireEvent(BI.IntervalSlider.EVENT_CHANGE); + }, window); + widget.element.on("mousedown", function (event) { + if(!widget.isEnabled()) { + return; + } + defaultSize = this.offsetLeft; + optimizeSize(defaultSize); + mouseMoveTracker.captureMouseMoves(event); + }); + + function optimizeSize (s) { + return BI.clamp(s, 0, self._getGrayTrackLength()); + } + }, + + _createLabelWrapper: function () { + var c = this._constant; + return { + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.labelOne, + top: 0, + left: "0%" + }] + }, { + type: "bi.absolute", + items: [{ + el: this.labelTwo, + top: 0, + left: "100%" + }] + }], + rgap: c.EDITOR_R_GAP, + height: 70 + }, + top: 0, + left: 0, + width: "100%" + }; + }, + + _createSliderWrapper: function () { + var c = this._constant; + return { + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.sliderOne, + top: 0, + left: "0%" + }] + }, { + type: "bi.absolute", + items: [{ + el: this.sliderTwo, + top: 0, + left: "100%" + }] + }], + hgap: c.SLIDER_WIDTH_HALF, + height: c.SLIDER_HEIGHT + }, + top: 20, + left: 0, + width: "100%" + }; + }, + + _createTrackWrapper: function () { + return BI.createWidget({ + type: "bi.absolute", + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.grayTrack, + top: 0, + left: 0, + width: "100%" + }, { + el: this.blueTrack, + top: 0, + left: 0, + width: "0%" + }] + }], + hgap: 8, + height: 8 + }, + top: 8, + left: 0, + width: "100%" + }] + }); + }, + + _checkValidation: function (v) { + var o = this.options; + var valid = false; + // 像90.这样的既不属于整数又不属于小数,是不合法的值 + var dotText = (v + "").split(".")[1]; + if (BI.isEmptyString(dotText)) { + }else{ + if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) { + if(o.digit === false) { + valid = true; + }else{ + dotText = dotText || ""; + valid = (dotText.length === o.digit); + } + } + } + return valid; + }, + + _checkOverlap: function () { + var labelOneLeft = this.labelOne.element[0].offsetLeft; + var labelTwoLeft = this.labelTwo.element[0].offsetLeft; + if (labelOneLeft <= labelTwoLeft) { + if ((labelTwoLeft - labelOneLeft) < 90) { + this.labelTwo.element.css({top: 40}); + } else { + this.labelTwo.element.css({top: 0}); + } + } else { + if ((labelOneLeft - labelTwoLeft) < 90) { + this.labelTwo.element.css({top: 40}); + } else { + this.labelTwo.element.css({top: 0}); + } + } + }, + + _setLabelOnePosition: function (percent) { + // this.labelOne.element.css({left: percent + "%"}); + // this._checkOverlap(); + }, + + _setLabelTwoPosition: function (percent) { + // this.labelTwo.element.css({left: percent + "%"}); + // this._checkOverlap(); + }, + + _setSliderOnePosition: function (percent) { + this.sliderOne.element.css({left: percent + "%"}); + }, + + _setSliderTwoPosition: function (percent) { + this.sliderTwo.element.css({left: percent + "%"}); + }, + + _setBlueTrackLeft: function (percent) { + this.blueTrack.element.css({left: percent + "%"}); + }, + + _setBlueTrackWidth: function (percent) { + this.blueTrack.element.css({width: percent + "%"}); + }, + + _setBlueTrack: function () { + var percentOne = this._getPercentByValue(this.labelOne.getValue()); + var percentTwo = this._getPercentByValue(this.labelTwo.getValue()); + if (percentOne <= percentTwo) { + this._setBlueTrackLeft(percentOne); + this._setBlueTrackWidth(percentTwo - percentOne); + } else { + this._setBlueTrackLeft(percentTwo); + this._setBlueTrackWidth(percentOne - percentTwo); + } + }, + + _setAllPosition: function (one, two) { + this._setSliderOnePosition(one); + this._setLabelOnePosition(one); + this._setSliderTwoPosition(two); + this._setLabelTwoPosition(two); + this._setBlueTrack(); + }, + + _setVisible: function (visible) { + this.sliderOne.setVisible(visible); + this.sliderTwo.setVisible(visible); + this.labelOne.setVisible(visible); + this.labelTwo.setVisible(visible); + }, + + _setErrorText: function () { + var errorText = BI.i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max); + this.labelOne.setErrorText(errorText); + this.labelTwo.setErrorText(errorText); + }, + + _getGrayTrackLength: function () { + return this.grayTrack.element[0].scrollWidth; + }, + + // 其中取max-min后保留4为有效数字后的值的小数位数为最终value的精度 + _getValueByPercent: function (percent) {// return (((max-min)*percent)/100+min) + var sub = this.calculation.accurateSubtraction(this.max, this.min); + var mul = this.calculation.accurateMultiplication(sub, percent); + var div = this.calculation.accurateDivisionTenExponent(mul, 2); + if(this.precision < 0) { + var value = BI.parseFloat(this.calculation.accurateAddition(div, this.min)); + var reduceValue = Math.round(this.calculation.accurateDivisionTenExponent(value, -this.precision)); + return this.calculation.accurateMultiplication(reduceValue, Math.pow(10, -this.precision)); + } + return BI.parseFloat(this.calculation.accurateAddition(div, this.min).toFixed(this.precision)); + + }, + + _getPercentByValue: function (v) { + return (v - this.min) * 100 / (this.max - this.min); + }, + + _setDraggableEnable: function (enable) { + this.sliderOne.setEnable(enable); + this.sliderTwo.setEnable(enable); + }, + + _getPrecision: function () { + // 计算每一份值的精度(最大值和最小值的差值保留4为有效数字后的精度) + // 如果差值的整数位数大于4,toPrecision(4)得到的是科学计数法123456 => 1.235e+5 + // 返回非负值: 保留的小数位数 + // 返回负值: 保留的10^n精度中的n + var sub = this.calculation.accurateSubtraction(this.max, this.min); + var pre = sub.toPrecision(4); + // 科学计数法 + var eIndex = pre.indexOf("e"); + var arr = []; + if(eIndex > -1) { + arr = pre.split("e"); + var decimalPartLength = BI.size(arr[0].split(".")[1]); + var sciencePartLength = BI.parseInt(arr[1].substring(1)); + return decimalPartLength - sciencePartLength; + } + arr = pre.split("."); + return arr.length > 1 ? arr[1].length : 0; + + }, + + _assertValue: function (value) { + if(value <= this.min) { + return this.min; + } + if(value >= this.max) { + return this.max; + } + return value; + }, + + _setEnable: function (b) { + BI.IntervalSlider.superclass._setEnable.apply(this, [b]); + if(b) { + this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); + } else { + this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); + } + }, + + getValue: function () { + if (this.valueOne <= this.valueTwo) { + return {min: this.valueOne, max: this.valueTwo}; + } + return {min: this.valueTwo, max: this.valueOne}; + + }, + + setMinAndMax: function (v) { + var minNumber = BI.parseFloat(v.min); + var maxNumber = BI.parseFloat(v.max); + if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber >= minNumber )) { + this.min = minNumber; + this.max = maxNumber; + this.valueOne = minNumber; + this.valueTwo = maxNumber; + this.precision = this._getPrecision(); + this._setDraggableEnable(true); + } + if (maxNumber === minNumber) { + this._setDraggableEnable(false); + } + }, + + setValue: function (v) { + var o = this.options; + var valueOne = BI.parseFloat(v.min); + var valueTwo = BI.parseFloat(v.max); + valueOne = o.digit === false ? valueOne : valueOne.toFixed(o.digit); + valueTwo = o.digit === false ? valueTwo : valueTwo.toFixed(o.digit); + if (!isNaN(valueOne) && !isNaN(valueTwo)) { + if (this._checkValidation(valueOne)) { + this.valueOne = valueOne; + } + if (this._checkValidation(valueTwo)) { + this.valueTwo = valueTwo; + } + if (valueOne < this.min) { + this.valueOne = this.min; + } + if (valueTwo > this.max) { + this.valueTwo = this.max; + } + } + }, + + reset: function () { + this._setVisible(false); + this.enable = false; + this.valueOne = ""; + this.valueTwo = ""; + this.min = NaN; + this.max = NaN; + this._setBlueTrackWidth(0); + }, + + populate: function () { + if (!isNaN(this.min) && !isNaN(this.max)) { + this.enable = true; + this._setVisible(true); + this._setErrorText(); + if ((BI.isNumeric(this.valueOne) || BI.isNotEmptyString(this.valueOne)) && (BI.isNumeric(this.valueTwo) || BI.isNotEmptyString(this.valueTwo))) { + this.labelOne.setValue(this.valueOne); + this.labelTwo.setValue(this.valueTwo); + this._setAllPosition(this._getPercentByValue(this.valueOne), this._getPercentByValue(this.valueTwo)); + } else { + this.labelOne.setValue(this.min); + this.labelTwo.setValue(this.max); + this._setAllPosition(0, 100); + } + } + } +}); +BI.IntervalSlider.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.interval_slider", BI.IntervalSlider);/** + * Created by zcf on 2017/3/1. + * 万恶的IEEE-754 + * 使用字符串精确计算含小数加法、减法、乘法和10的指数倍除法,支持负数 + */ +BI.AccurateCalculationModel = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.AccurateCalculationModel.superclass._defaultConfig.apply(this, arguments), { + baseCls: "" + }); + }, + + _init: function () { + BI.AccurateCalculationModel.superclass._init.apply(this, arguments); + }, + + _getMagnitude: function (n) { + var magnitude = "1"; + for (var i = 0; i < n; i++) { + magnitude += "0"; + } + return BI.parseInt(magnitude); + }, + + _formatDecimal: function (stringNumber1, stringNumber2) { + if (stringNumber1.numDecimalLength === stringNumber2.numDecimalLength) { + return; + } + var magnitudeDiff = stringNumber1.numDecimalLength - stringNumber2.numDecimalLength; + if (magnitudeDiff > 0) { + var needAddZero = stringNumber2; + } else { + var needAddZero = stringNumber1; + magnitudeDiff = (0 - magnitudeDiff); + } + for (var i = 0; i < magnitudeDiff; i++) { + if (needAddZero.numDecimal === "0" && i === 0) { + continue; + } + needAddZero.numDecimal += "0"; + } + }, + + _stringNumberFactory: function (num) { + var strNum = num.toString(); + var numStrArray = strNum.split("."); + var numInteger = numStrArray[0]; + if (numStrArray.length === 1) { + var numDecimal = "0"; + var numDecimalLength = 0; + } else { + var numDecimal = numStrArray[1]; + var numDecimalLength = numStrArray[1].length; + } + return { + numInteger: numInteger, + numDecimal: numDecimal, + numDecimalLength: numDecimalLength + }; + }, + + _accurateSubtraction: function (num1, num2) {// num1-num2 && num1>num2 + var stringNumber1 = this._stringNumberFactory(num1); + var stringNumber2 = this._stringNumberFactory(num2); + // 整数部分计算 + var integerResult = BI.parseInt(stringNumber1.numInteger) - BI.parseInt(stringNumber2.numInteger); + // 小数部分 + this._formatDecimal(stringNumber1, stringNumber2); + var decimalMaxLength = getDecimalMaxLength(stringNumber1, stringNumber2); + + if (BI.parseInt(stringNumber1.numDecimal) >= BI.parseInt(stringNumber2.numDecimal)) { + var decimalResultTemp = (BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString(); + var decimalResult = addZero(decimalResultTemp, decimalMaxLength); + } else {// 否则借位 + integerResult--; + var borrow = this._getMagnitude(decimalMaxLength); + var decimalResultTemp = (borrow + BI.parseInt(stringNumber1.numDecimal) - BI.parseInt(stringNumber2.numDecimal)).toString(); + var decimalResult = addZero(decimalResultTemp, decimalMaxLength); + } + var result = integerResult + "." + decimalResult; + return BI.parseFloat(result); + + function getDecimalMaxLength (num1, num2) { + if (num1.numDecimal.length >= num2.numDecimal.length) { + return num1.numDecimal.length; + } + return num2.numDecimal.length; + } + + function addZero (resultTemp, length) { + var diff = length - resultTemp.length; + for (var i = 0; i < diff; i++) { + resultTemp = "0" + resultTemp; + } + return resultTemp; + } + }, + + _accurateAddition: function (num1, num2) {// 加法结合律 + var stringNumber1 = this._stringNumberFactory(num1); + var stringNumber2 = this._stringNumberFactory(num2); + // 整数部分计算 + var integerResult = BI.parseInt(stringNumber1.numInteger) + BI.parseInt(stringNumber2.numInteger); + // 小数部分 + this._formatDecimal(stringNumber1, stringNumber2); + + var decimalResult = (BI.parseInt(stringNumber1.numDecimal) + BI.parseInt(stringNumber2.numDecimal)).toString(); + + if (decimalResult !== "0") { + if (decimalResult.length <= stringNumber1.numDecimal.length) { + decimalResult = addZero(decimalResult, stringNumber1.numDecimal.length); + } else { + integerResult++;// 进一 + decimalResult = decimalResult.slice(1); + } + } + var result = integerResult + "." + decimalResult; + return BI.parseFloat(result); + + function addZero (resultTemp, length) { + var diff = length - resultTemp.length; + for (var i = 0; i < diff; i++) { + resultTemp = "0" + resultTemp; + } + return resultTemp; + } + }, + + _accurateMultiplication: function (num1, num2) {// 乘法分配律 + var stringNumber1 = this._stringNumberFactory(num1); + var stringNumber2 = this._stringNumberFactory(num2); + // 整数部分计算 + var integerResult = BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numInteger); + // num1的小数和num2的整数 + var dec1Int2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numInteger), stringNumber1.numDecimalLength); + // num1的整数和num2的小数 + var int1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numInteger) * BI.parseInt(stringNumber2.numDecimal), stringNumber2.numDecimalLength); + // 小数*小数 + var dec1dec2 = this._accurateDivisionTenExponent(BI.parseInt(stringNumber1.numDecimal) * BI.parseInt(stringNumber2.numDecimal), (stringNumber1.numDecimalLength + stringNumber2.numDecimalLength)); + + return this._accurateAddition(this._accurateAddition(this._accurateAddition(integerResult, dec1Int2), int1dec2), dec1dec2); + }, + + _accurateDivisionTenExponent: function (num, n) {// num/10^n && n>0 + var stringNumber = this._stringNumberFactory(num); + if (stringNumber.numInteger.length > n) { + var integerResult = stringNumber.numInteger.slice(0, (stringNumber.numInteger.length - n)); + var partDecimalResult = stringNumber.numInteger.slice(-n); + } else { + var integerResult = "0"; + var partDecimalResult = addZero(stringNumber.numInteger, n); + } + var result = integerResult + "." + partDecimalResult + stringNumber.numDecimal; + return BI.parseFloat(result); + + function addZero (resultTemp, length) { + var diff = length - resultTemp.length; + for (var i = 0; i < diff; i++) { + resultTemp = "0" + resultTemp; + } + return resultTemp; + } + }, + + accurateSubtraction: function (num1, num2) { + if (num1 >= 0 && num2 >= 0) { + if (num1 >= num2) { + return this._accurateSubtraction(num1, num2); + } + return -this._accurateSubtraction(num2, num1); + } + if (num1 >= 0 && num2 < 0) { + return this._accurateAddition(num1, -num2); + } + if (num1 < 0 && num2 >= 0) { + return -this._accurateAddition(-num1, num2); + } + if (num1 < 0 && num2 < 0) { + if (num1 >= num2) { + return this._accurateSubtraction(-num2, -num1); + } + return this._accurateSubtraction(-num1, -num2); + } + }, + + accurateAddition: function (num1, num2) { + if (num1 >= 0 && num2 >= 0) { + return this._accurateAddition(num1, num2); + } + if (num1 >= 0 && num2 < 0) { + return this.accurateSubtraction(num1, -num2); + } + if (num1 < 0 && num2 >= 0) { + return this.accurateSubtraction(num2, -num1); + } + if (num1 < 0 && num2 < 0) { + return -this._accurateAddition(-num1, -num2); + } + }, + + accurateMultiplication: function (num1, num2) { + if (num1 >= 0 && num2 >= 0) { + return this._accurateMultiplication(num1, num2); + } + if (num1 >= 0 && num2 < 0) { + return -this._accurateMultiplication(num1, -num2); + } + if (num1 < 0 && num2 >= 0) { + return -this._accurateMultiplication(-num1, num2); + } + if (num1 < 0 && num2 < 0) { + return this._accurateMultiplication(-num1, -num2); + } + }, + + accurateDivisionTenExponent: function (num1, n) { + if (num1 >= 0) { + return this._accurateDivisionTenExponent(num1, n); + } + return -this._accurateDivisionTenExponent(-num1, n); + } +});/** + * 月份下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.MonthCombo + * @extends BI.Trigger + */ +BI.MonthCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MonthCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-combo", + behaviors: {}, + height: 24 + }); + }, + _init: function () { + BI.MonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.month_trigger", + value: o.value + }); + + this.trigger.on(BI.MonthTrigger.EVENT_CONFIRM, function (v) { + if (self.combo.isViewVisible()) { + return; + } + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getValue()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); + }); + this.trigger.on(BI.MonthTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.MonthTrigger.EVENT_START, function () { + self.combo.hideView(); + }); + this.trigger.on(BI.MonthTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.popup = BI.createWidget({ + type: "bi.month_popup", + behaviors: o.behaviors, + value: o.value + }); + this.popup.on(BI.MonthPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MonthCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + if (BI.isNull(this.popup)) { + return this.options.value || ""; + } else { + return this.popup.getValue() || ""; + } + } +}); + +BI.MonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.month_combo", BI.MonthCombo);/** + * 月份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.MonthPopup + * @extends BI.Trigger + */ +BI.MonthPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MonthPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-month-popup", + behaviors: {} + }); + }, + + _init: function () { + BI.MonthPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + // 纵向排列月 + var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]; + var items = []; + items.push(month.slice(0, 2)); + items.push(month.slice(2, 4)); + items.push(month.slice(4, 6)); + items.push(month.slice(6, 8)); + items.push(month.slice(8, 10)); + items.push(month.slice(10, 12)); + items = BI.map(items, function (i, item) { + return BI.map(item, function (j, td) { + return { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "center", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 23, + width: 38, + value: td, + text: td + }; + }); + }); + + this.month = BI.createWidget({ + type: "bi.button_group", + element: this, + behaviors: o.behaviors, + items: BI.createItems(items, {}), + layouts: [BI.LogicFactory.createLogic("table", BI.extend({ + dynamic: true + }, { + columns: 2, + rows: 6, + columnSize: [1 / 2, 1 / 2], + rowSize: 25 + })), { + type: "bi.center_adapt", + vgap: 1, + hgap: 2 + }], + value: o.value + }); + + this.month.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MonthPopup.EVENT_CHANGE); + } + }); + }, + + getValue: function () { + return this.month.getValue()[0]; + }, + + setValue: function (v) { + v = BI.parseInt(v); + this.month.setValue([v]); + } +}); +BI.MonthPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.month_popup", BI.MonthPopup);/** + * 月份trigger + * + * Created by GUY on 2015/8/21. + * @class BI.MonthTrigger + * @extends BI.Trigger + */ +BI.MonthTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2 + }, + + _defaultConfig: function () { + return BI.extend(BI.MonthTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-month-trigger bi-border", + height: 24 + }); + }, + _init: function () { + BI.MonthTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 12); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: BI.i18nText("BI-Month_Trigger_Error_Text") + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.MonthTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.MonthTrigger.EVENT_CHANGE); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.MonthTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.MonthTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.MonthTrigger.EVENT_STOP); + }); + BI.createWidget({ + element: this, + type: "bi.htape", + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + text: BI.i18nText("BI-Multi_Date_Month"), + baseCls: "bi-trigger-month-text", + width: o.height + }, + width: o.height + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height + }, + width: o.height + } + ] + }); + this.setValue(o.value); + }, + setValue: function (v) { + if(BI.isNotNull(v)) { + this.editor.setState(v + 1); + this.editor.setValue(v + 1); + this.editor.setTitle(v + 1); + return; + } + this.editor.setState(""); + this.editor.setValue(""); + this.editor.setTitle(""); + }, + getKey: function () { + return this.editor.getValue() | 0; + }, + getValue: function () { + return this.editor.getValue() - 1; + } +}); +BI.MonthTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.MonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.MonthTrigger.EVENT_START = "EVENT_START"; +BI.MonthTrigger.EVENT_STOP = "EVENT_STOP"; +BI.MonthTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.month_trigger", BI.MonthTrigger);/** + * Created by roy on 15/8/14. + */ +BI.DownListCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.DownListCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-down-list-combo", + height: 24, + items: [], + adjustLength: 0, + direction: "bottom", + trigger: "click", + container: null, + stopPropagation: false, + el: {} + }); + }, + + _init: function () { + BI.DownListCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.popupview = BI.createWidget({ + type: "bi.multi_layer_down_list_popup", + items: o.items, + chooseType: o.chooseType, + value: o.value + }); + + this.popupview.on(BI.DownListPopup.EVENT_CHANGE, function (value) { + self.fireEvent(BI.DownListCombo.EVENT_CHANGE, value); + self.downlistcombo.hideView(); + }); + + this.popupview.on(BI.DownListPopup.EVENT_SON_VALUE_CHANGE, function (value, fatherValue) { + self.fireEvent(BI.DownListCombo.EVENT_SON_VALUE_CHANGE, value, fatherValue); + self.downlistcombo.hideView(); + }); + + + this.downlistcombo = BI.createWidget({ + element: this, + type: "bi.combo", + trigger: o.trigger, + isNeedAdjustWidth: false, + container: o.container, + adjustLength: o.adjustLength, + direction: o.direction, + stopPropagation: o.stopPropagation, + el: BI.createWidget(o.el, { + type: "bi.icon_trigger", + extraCls: o.iconCls ? o.iconCls : "pull-down-font", + width: o.width, + height: o.height + }), + popup: { + el: this.popupview, + stopPropagation: true, + maxHeight: 1000 + } + }); + + this.downlistcombo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.DownListCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + hideView: function () { + this.downlistcombo.hideView(); + }, + + showView: function () { + this.downlistcombo.showView(); + }, + + populate: function (items) { + this.popupview.populate(items); + }, + + setValue: function (v) { + this.popupview.setValue(v); + }, + getValue: function () { + return this.popupview.getValue(); + } +}); +BI.DownListCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.DownListCombo.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.DownListCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; + +BI.shortcut("bi.multi_layer_down_list_combo", BI.DownListCombo);/** + * Created by roy on 15/9/8. + * 处理popup中的item分组样式 + * 一个item分组中的成员大于一时,该分组设置为单选,并且默认状态第一个成员设置为已选择项 + */ +BI.MultiLayerDownListPopup = BI.inherit(BI.Pane, { + constants: { + nextIcon: "pull-right-e-font", + height: 25, + iconHeight: 12, + iconWidth: 12, + hgap: 0, + vgap: 0, + border: 1 + }, + _defaultConfig: function () { + var conf = BI.MultiLayerDownListPopup.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: "bi-down-list-popup", + items: [], + chooseType: BI.Selection.Multi + }); + }, + _init: function () { + BI.MultiLayerDownListPopup.superclass._init.apply(this, arguments); + this.singleValues = []; + this.childValueMap = {}; + this.fatherValueMap = {}; + var self = this, o = this.options, children = this._createPopupItems(o.items); + this.popup = BI.createWidget({ + type: "bi.button_tree", + items: BI.createItems(children, + {}, { + adjustLength: -2 + } + ), + layouts: [{ + type: "bi.vertical", + hgap: this.constants.hgap, + vgap: this.constants.vgap + }], + value: this._digest(o.value), + chooseType: o.chooseType + }); + + this.popup.on(BI.ButtonTree.EVENT_CHANGE, function (value, object) { + var changedValue = value; + if (BI.isNotNull(self.childValueMap[value])) { + changedValue = self.childValueMap[value]; + var fatherValue = self.fatherValueMap[value]; + var fatherArrayValue = (fatherValue + "").split("_"); + self.fireEvent(BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE, changedValue, fatherArrayValue.length > 1 ? fatherArrayValue : fatherValue); + } else { + self.fireEvent(BI.MultiLayerDownListPopup.EVENT_CHANGE, changedValue, object); + } + + + if (!self.singleValues.contains(changedValue)) { + var item = self.getValue(); + var result = []; + BI.each(item, function (i, valueObject) { + if (valueObject.value != changedValue) { + result.push(valueObject); + } + }); + self.setValue(result); + } + + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.popup] + }); + + }, + _createPopupItems: function (items) { + var self = this, result = []; + BI.each(items, function (i, it) { + var item_done = { + type: "bi.down_list_group", + items: [] + }; + + BI.each(it, function (i, item) { + if (BI.isNotEmptyArray(item.children) && !BI.isEmpty(item.el)) { + item.type = "bi.combo_group"; + item.cls = "down-list-group"; + item.trigger = "hover"; + item.isNeedAdjustWidth = false; + item.el.title = item.el.title || item.el.text; + item.el.type = "bi.down_list_group_item"; + item.el.logic = { + dynamic: true + }; + item.el.height = self.constants.height; + item.el.iconCls2 = self.constants.nextIcon; + item.popup = { + lgap: 4, + el: { + type: "bi.button_tree", + chooseType: 0, + layouts: [{ + type: "bi.vertical" + }] + + } + }; + item.el.childValues = []; + BI.each(item.children, function (i, child) { + child = child.el ? BI.extend(child.el, {children: child.children}) : child; + var fatherValue = BI.deepClone(item.el.value); + var childValue = BI.deepClone(child.value); + self.singleValues.push(child.value); + child.type = "bi.down_list_item"; + child.extraCls = " child-down-list-item"; + child.title = child.title || child.text; + child.textRgap = 10; + child.isNeedAdjustWidth = false; + child.logic = { + dynamic: true + }; + child.father = fatherValue; + self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; + self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; + child.value = self._createChildValue(fatherValue, childValue); + item.el.childValues.push(child.value); + if (BI.isNotEmptyArray(child.children)) { + child.type = "bi.down_list_group_item"; + self._createChildren(child); + child.height = self.constants.height; + child.iconCls2 = self.constants.nextIcon; + item.el.childValues = BI.concat(item.el.childValues, child.childValues); + } + }); + } else { + item.type = "bi.down_list_item"; + item.title = item.title || item.text; + item.textRgap = 10; + item.isNeedAdjustWidth = false; + item.logic = { + dynamic: true + }; + } + var el_done = {}; + el_done.el = item; + item_done.items.push(el_done); + }); + if (self._isGroup(item_done.items)) { + BI.each(item_done.items, function (i, item) { + self.singleValues.push(item.el.value); + }); + } + + result.push(item_done); + if (self._needSpliter(i, items.length)) { + var spliter_container = BI.createWidget({ + type: "bi.vertical", + items: [{ + el: { + type: "bi.layout", + cls: "bi-down-list-spliter bi-border-top cursor-pointer", + height: 0 + } + + }], + cls: "bi-down-list-spliter-container cursor-pointer", + lgap: 10, + rgap: 0 + }); + result.push(spliter_container); + } + }); + return result; + }, + + _createChildren: function (child) { + var self = this; + child.childValues = []; + BI.each(child.children, function (i, c) { + var fatherValue = BI.deepClone(child.value); + var childValue = BI.deepClone(c.value); + c.type = "bi.down_list_item"; + c.title = c.title || c.text; + c.textRgap = 10; + c.isNeedAdjustWidth = false; + c.logic = { + dynamic: true + }; + c.father = fatherValue; + self.fatherValueMap[self._createChildValue(fatherValue, childValue)] = fatherValue; + self.childValueMap[self._createChildValue(fatherValue, childValue)] = childValue; + c.value = self._createChildValue(fatherValue, childValue); + child.childValues.push(c.value); + }); + }, + + _isGroup: function (i) { + return i.length > 1; + }, + + _needSpliter: function (i, itemLength) { + return i < itemLength - 1; + }, + + _createChildValue: function (fatherValue, childValue) { + var fValue = fatherValue; + if(BI.isArray(fatherValue)) { + fValue = fatherValue.join("_"); + } + return fValue + "_" + childValue; + }, + + _digest: function (valueItem) { + var self = this; + var valueArray = []; + BI.each(valueItem, function (i, item) { + var value; + if (BI.isNotNull(item.childValue)) { + value = self._createChildValue(item.value, item.childValue); + } else { + value = item.value; + } + valueArray.push(value); + } + ); + return valueArray; + }, + + _checkValues: function (values) { + var self = this, o = this.options; + var value = []; + BI.each(o.items, function (idx, itemGroup) { + BI.each(itemGroup, function (id, item) { + if(BI.isNotNull(item.children)) { + var childValues = getChildrenValue(item); + var v = joinValue(childValues, values[idx]); + if(BI.isNotEmptyString(v)) { + value.push(v); + } + }else{ + if(item.value === values[idx][0]) { + value.push(values[idx][0]); + } + } + }); + }); + return value; + + function joinValue (sources, targets) { + var value = ""; + BI.some(sources, function (idx, s) { + return BI.some(targets, function (id, t) { + if(s === t) { + value = s; + return true; + } + }); + }); + return value; + } + + function getChildrenValue (item) { + var children = []; + if(BI.isNotNull(item.children)) { + BI.each(item.children, function (idx, child) { + children = BI.concat(children, getChildrenValue(child)); + }); + } else { + children.push(item.value); + } + return children; + } + }, + + populate: function (items) { + BI.MultiLayerDownListPopup.superclass.populate.apply(this, arguments); + var self = this; + self.childValueMap = {}; + self.fatherValueMap = {}; + self.singleValues = []; + var children = self._createPopupItems(items); + var popupItem = BI.createItems(children, + {}, { + adjustLength: -2 + } + ); + self.popup.populate(popupItem); + }, + + setValue: function (valueItem) { + this.popup.setValue(this._digest(valueItem)); + }, + + _getValue: function () { + var v = []; + BI.each(this.popup.getAllButtons(), function (i, item) { + i % 2 === 0 && v.push(item.getValue()); + }); + return v; + }, + + getValue: function () { + var self = this, result = []; + var values = this._checkValues(this._getValue()); + BI.each(values, function (i, value) { + var valueItem = {}; + if (BI.isNotNull(self.childValueMap[value])) { + var fartherValue = self.fatherValueMap[value]; + valueItem.childValue = self.childValueMap[value]; + var fatherArrayValue = (fartherValue + "").split("_"); + valueItem.value = fatherArrayValue.length > 1 ? fatherArrayValue : fartherValue; + } else { + valueItem.value = value; + } + result.push(valueItem); + }); + return result; + } + + +}); + +BI.MultiLayerDownListPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiLayerDownListPopup.EVENT_SON_VALUE_CHANGE = "EVENT_SON_VALUE_CHANGE"; +BI.shortcut("bi.multi_layer_down_list_popup", BI.MultiLayerDownListPopup);/** + * @class BI.MultiLayerSelectTreeCombo + * @extends BI.Widget + */ +BI.MultiLayerSelectTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer_select_tree-combo", + isDefaultInit: false, + height: 24, + text: "", + items: [], + value: "" + }); + }, + + _init: function () { + BI.MultiLayerSelectTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items, + value: o.value + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_select_tree_popup", + isDefaultInit: o.isDefaultInit, + items: o.items, + value: o.value + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.MultiLayerSelectTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiLayerSelectTreeCombo.EVENT_CHANGE); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); +BI.MultiLayerSelectTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_select_tree_combo", BI.MultiLayerSelectTreeCombo);/** + * guy + * 二级树 + * @class BI.MultiLayerSelectLevelTree + * @extends BI.Select + */ +BI.MultiLayerSelectLevelTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectLevelTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-select-level-tree", + isDefaultInit: false, + items: [], + itemsCreator: BI.emptyFn, + value: "" + }); + }, + + _init: function () { + BI.MultiLayerSelectLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _assertId: function (sNodes) { + BI.each(sNodes, function (i, node) { + node.id = node.id || BI.UUID(); + }); + }, + + // 构造树结构, + initTree: function (nodes) { + var self = this, o = this.options; + this.empty(); + this._assertId(nodes); + this.tree = BI.createWidget({ + type: "bi.custom_tree", + cls: "tree-view display-table", + expander: { + type: "bi.select_tree_expander", + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + itemsCreator: o.itemsCreator, + value: o.value, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + layouts: [{ + type: "bi.vertical" + }] + } + }); + this.tree.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, arguments); + } + }); + + BI.createWidget({ + type: "bi.adaptive", + element: this, + scrollable: true, + items: [this.tree] + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + setValue: function (v) { + this.tree.setValue(v); + }, + + getValue: function () { + return BI.uniq(this.tree.getValue()); + }, + + getAllLeaves: function () { + return this.tree.getAllLeaves(); + }, + + getNodeById: function (id) { + return this.tree.getNodeById(id); + }, + + getNodeByValue: function (id) { + return this.tree.getNodeByValue(id); + } +}); +BI.MultiLayerSelectLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multilayer_select_level_tree", BI.MultiLayerSelectLevelTree);/** + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSelectTreePopup + * @extends BI.Pane + */ + +BI.MultiLayerSelectTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-select-tree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + isDefaultInit: false, + itemsCreator: BI.emptyFn, + items: [], + value: "" + }); + }, + + _init: function () { + BI.MultiLayerSelectTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: "bi.multilayer_select_level_tree", + isDefaultInit: o.isDefaultInit, + items: o.items, + value: o.value, + itemsCreator: o.itemsCreator + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + vgap: 5, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.MultiLayerSelectLevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiLayerSelectTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.MultiLayerSelectTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.MultiLayerSelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_select_tree_popup", BI.MultiLayerSelectTreePopup);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-first-plus-group-node bi-list-item-active", + layer: 0, // 第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_first_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_first_plus_group_node", BI.MultiLayerSelectTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-last-plus-group-node bi-list-item-active", + layer: 0, // 第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_last_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_last_plus_group_node", BI.MultiLayerSelectTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSelectTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-select-tree-mid-plus-group-node bi-list-item-active", + layer: 0, // 第几层级 + id: "", + pId: "", + readonly: true, + open: false, + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.select_tree_mid_plus_group_node", + cls: "bi-list-item-none", + stopPropagation: true, + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + self.setSelected(self.isSelected()); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + isSelected: function () { + return this.node.isSelected(); + }, + + setSelected: function (b) { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setSelected.apply(this, arguments); + this.node.setSelected(b); + }, + + doClick: function () { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + this.node.setOpened(v); + } +}); + +BI.shortcut("bi.multilayer_select_tree_mid_plus_group_node", BI.MultiLayerSelectTreeMidPlusGroupNode);/** + * 多层级下拉单选树 + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSingleTreeCombo + * @extends BI.Widget + */ +BI.MultiLayerSingleTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-singletree-combo", + isDefaultInit: false, + height: 24, + text: "", + itemsCreator: BI.emptyFn, + items: [], + value: "" + }); + }, + + _init: function () { + BI.MultiLayerSingleTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items, + value: o.value + }); + + this.popup = BI.createWidget({ + type: "bi.multilayer_single_tree_popup", + isDefaultInit: o.isDefaultInit, + itemsCreator: o.itemsCreator, + items: o.items, + value: o.value + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.MultiLayerSingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.MultiLayerSingleTreeCombo.EVENT_CHANGE); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); + +BI.MultiLayerSingleTreeCombo.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_single_tree_combo", BI.MultiLayerSingleTreeCombo);/** + * guy + * 二级树 + * @class BI.MultiLayerSingleLevelTree + * @extends BI.Single + */ +BI.MultiLayerSingleLevelTree = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleLevelTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-single-level-tree", + isDefaultInit: false, + items: [], + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiLayerSingleLevelTree.superclass._init.apply(this, arguments); + + this.initTree(this.options.items); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {}; + node.layer = layer; + if (!BI.isKey(node.id)) { + node.id = BI.UUID(); + } + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.multilayer_single_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.multilayer_single_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + + self._formatItems(node.children, layer + 1); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.multilayer_single_tree_last_tree_leaf_item"; + break; + default : + extend.type = "bi.multilayer_single_tree_mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _assertId: function (sNodes) { + BI.each(sNodes, function (i, node) { + node.id = node.id || BI.UUID(); + }); + }, + + // 构造树结构, + initTree: function (nodes) { + var self = this, o = this.options; + this.empty(); + this._assertId(nodes); + this.tree = BI.createWidget({ + type: "bi.custom_tree", + cls: "tree-view display-table", + expander: { + isDefaultInit: o.isDefaultInit, + el: {}, + popup: { + type: "bi.custom_tree" + } + }, + + items: this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0), + value: o.value, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (items) { + callback(BI.Tree.transformToTreeFormat(items), 0); + }); + }, + + el: { + type: "bi.button_tree", + chooseType: BI.Selection.Single, + layouts: [{ + type: "bi.vertical" + }] + } + }); + this.tree.on(BI.Controller.EVENT_CHANGE, function (type, v) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, v); + } + }); + + BI.createWidget({ + type: "bi.adaptive", + element: this, + scrollable: true, + items: [this.tree] + }) + }, + + populate: function (nodes) { + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(nodes), 0)); + }, + + setValue: function (v) { + this.tree.setValue(v); + }, + + getValue: function () { + return BI.filter(BI.uniq(this.tree.getValue()), function (idx, value) { + return BI.isNotNull(value); + }); + + }, + + getAllLeaves: function () { + return this.tree.getAllLeaves(); + }, + + getNodeById: function (id) { + return this.tree.getNodeById(id); + }, + + getNodeByValue: function (id) { + return this.tree.getNodeByValue(id); + } +}); +BI.MultiLayerSingleLevelTree.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multilayer_single_level_tree", BI.MultiLayerSingleLevelTree); +/** + * Created by GUY on 2016/1/26. + * + * @class BI.MultiLayerSingleTreePopup + * @extends BI.Pane + */ + +BI.MultiLayerSingleTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multilayer-singletree-popup", + tipText: BI.i18nText("BI-No_Selected_Item"), + isDefaultInit: false, + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.MultiLayerSingleTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: "bi.multilayer_single_level_tree", + isDefaultInit: o.isDefaultInit, + items: o.items, + itemsCreator: o.itemsCreator, + value: o.value + }); + + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + scrollable: true, + element: this, + vgap: 5, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.MultiLayerSingleLevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiLayerSingleTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.MultiLayerSingleTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.MultiLayerSingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multilayer_single_tree_popup", BI.MultiLayerSingleTreePopup);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-first-plus-group-node bi-list-item", + layer: 0, // 第几层级 + id: "", + pId: "", + open: false, + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.first_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {// 本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_first_plus_group_node", BI.MultiLayerSingleTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-last-plus-group-node bi-list-item", + layer: 0, // 第几层级 + id: "", + pId: "", + open: false, + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.last_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {// 本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_last_plus_group_node", BI.MultiLayerSingleTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.MultiLayerSingleTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-multilayer-single-tree-mid-plus-group-node bi-list-item", + layer: 0, // 第几层级 + id: "", + pId: "", + open: false, + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.node = BI.createWidget({ + type: "bi.mid_plus_group_node", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + open: o.open, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword + }); + this.node.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {// 本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.node); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doRedMark: function () { + this.node.doRedMark.apply(this.node, arguments); + }, + + unRedMark: function () { + this.node.unRedMark.apply(this.node, arguments); + }, + + doClick: function () { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.doClick.apply(this, arguments); + this.node.setSelected(this.isSelected()); + }, + + setOpened: function (v) { + BI.MultiLayerSingleTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.node)) { + this.node.setOpened(v); + } + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_plus_group_node", BI.MultiLayerSingleTreeMidPlusGroupNode);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeFirstTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeFirstTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-first-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.first_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {// 本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeFirstTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_first_tree_leaf_item", BI.MultiLayerSingleTreeFirstTreeLeafItem);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeLastTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeLastTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-last-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.last_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {// 本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeLastTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_last_tree_leaf_item", BI.MultiLayerSingleTreeLastTreeLeafItem);/** + * + * Created by GUY on 2016/1/27. + * @class BI.MultiLayerSingleTreeMidTreeLeafItem + * @extends BI.BasicButton + */ +BI.MultiLayerSingleTreeMidTreeLeafItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-multilayer-single-tree-mid-tree-leaf-item bi-list-item-active", + logic: { + dynamic: false + }, + layer: 0, + id: "", + pId: "", + height: 24 + }); + }, + _init: function () { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.item = BI.createWidget({ + type: "bi.mid_tree_leaf_item", + cls: "bi-list-item-none", + logic: { + dynamic: true + }, + id: o.id, + pId: o.pId, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + py: o.py, + keyword: o.keyword + }); + this.item.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) {// 本身实现click功能 + return; + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + var items = []; + BI.count(0, o.layer, function () { + items.push({ + type: "bi.layout", + cls: "base-line-conn-background", + width: 12, + height: o.height + }); + }); + items.push(this.item); + BI.createWidget({ + type: "bi.td", + element: this, + columnSize: BI.makeArray(o.layer, 12), + items: [items] + }); + }, + + doHighLight: function () { + this.item.doHighLight.apply(this.item, arguments); + }, + + unHighLight: function () { + this.item.unHighLight.apply(this.item, arguments); + }, + + getId: function () { + return this.options.id; + }, + + getPId: function () { + return this.options.pId; + }, + + doClick: function () { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.doClick.apply(this, arguments); + this.item.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.MultiLayerSingleTreeMidTreeLeafItem.superclass.setSelected.apply(this, arguments); + this.item.setSelected(v); + } +}); + +BI.shortcut("bi.multilayer_single_tree_mid_tree_leaf_item", BI.MultiLayerSingleTreeMidTreeLeafItem);/** + * + * @class BI.MultiSelectCheckPane + * @extends BI.Widget + */ +BI.MultiSelectCheckPane = BI.inherit(BI.Widget, { + + constants: { + height: 12, + lgap: 10, + tgap: 10, + bgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-check-pane bi-background", + items: [], + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + onClickContinueSelect: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.storeValue = opts.value || {}; + this.display = BI.createWidget({ + type: "bi.display_selected_list", + items: opts.items, + itemsCreator: function (op, callback) { + op = BI.extend(op || {}, { + selectedValues: self.storeValue.value + }); + if (self.storeValue.type === BI.Selection.Multi) { + callback({ + items: BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt + }; + }) + }); + return; + } + opts.itemsCreator(op, callback); + } + }); + + this.continueSelect = BI.createWidget({ + type: "bi.text_button", + text: BI.i18nText("BI-Continue_Select"), + cls: "multi-select-check-selected bi-high-light" + }); + + this.continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { + opts.onClickContinueSelect(); + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + height: this.constants.height, + el: { + type: "bi.vertical_adapt", + cls: "multi-select-continue-select", + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText("BI-Selected_Data") + }, + lgap: this.constants.lgap + }, + { + el: this.continueSelect, + lgap: this.constants.lgap + }] + }, + tgap: this.constants.tgap + }, { + height: "fill", + el: this.display, + tgap: this.constants.bgap + }] + }); + }, + + setValue: function (v) { + this.storeValue = v || {}; + }, + + empty: function () { + this.display.empty(); + }, + + populate: function () { + this.display.populate.apply(this.display, arguments); + } +}); + +BI.shortcut("bi.multi_select_check_pane", BI.MultiSelectCheckPane);/** + * + * + * 查看已选弹出层的展示面板 + * @class BI.DisplaySelectedList + * @extends BI.Widget + */ +BI.DisplaySelectedList = BI.inherit(BI.Pane, { + + constants: { + height: 24, + lgap: 10 + }, + + _defaultConfig: function () { + return BI.extend(BI.DisplaySelectedList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-display-list", + itemsCreator: BI.emptyFn, + items: [] + }); + }, + + _init: function () { + BI.DisplaySelectedList.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.list_pane", + element: this, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + items: this._createItems(opts.items), + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + layouts: [{ + type: "bi.vertical", + lgap: 10 + }] + }, + itemsCreator: function (options, callback) { + + opts.itemsCreator(options, function (ob) { + self.hasNext = !!ob.hasNext; + callback(self._createItems(ob.items)); + }); + }, + hasNext: function () { + return self.hasNext; + } + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.icon_text_item", + cls: "cursor-default check-font icon-size-12 display-list-item bi-tips", + once: true, + invalid: true, + selected: true, + height: this.constants.height, + logic: { + dynamic: true + } + }); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + if (arguments.length === 0) { + this.button_group.populate(); + } else { + this.button_group.populate(this._createItems(items)); + } + } +}); + +BI.shortcut("bi.display_selected_list", BI.DisplaySelectedList);/** + * + * @class BI.MultiSelectCombo + * @extends BI.Single + */ +BI.MultiSelectCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-combo", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 24 + }); + }, + + _init: function () { + BI.MultiSelectCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = o.value || {}; + + this._assertValue(this.storeValue); + + // 标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + text: o.text, + // adapter: this.popup, + masker: { + offset: { + left: 0, + top: 0, + right: 0, + bottom: 26 + } + }, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + // 预防trigger内部把当前的storeValue改掉 + self.trigger.setValue(BI.deepClone(self.getValue())); + } + callback.apply(self, arguments); + }); + }, + value: this.storeValue + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { + self._setStartValue(""); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { + self._setStartValue(""); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { + if (this.getSearcher().hasMatched()) { + var keyword = this.getSearcher().getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.populate(); + self._setStartValue(""); + }); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(""); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + }); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + this.getCounter().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: "bi.multi_select_popup_view", + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + value: o.value, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self.element.removeClass("combo-show"); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.element.removeClass("combo-show").addClass("combo-show"); + this.setValue(self.storeValue); + BI.nextTick(function () { + self.populate(); + }); + }); + // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + // important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.map(ob.items, "value"); + digest(values); + }); + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_ALL_DATA, + keywords: [this.trigger.getKey()] + }, function (ob) { + var items = BI.map(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }); + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + + } + + function adjust () { + if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.Multi, + value: [] + }; + } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.All, + value: [] + }; + } + if (self.wants2Quit === true) { + self.fireEvent(BI.MultiSelectCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.combo.setValue(this.storeValue); + }, + + getValue: function () { + return BI.deepClone(this.storeValue); + }, + + populate: function () { + this._count = null; + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.extend(BI.MultiSelectCombo, { + REQ_GET_DATA_LENGTH: 1, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut("bi.multi_select_combo", BI.MultiSelectCombo);/** + * + * @class BI.MultiSelectInsertCombo + * @extends BI.Single + */ +BI.MultiSelectInsertCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInsertCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-insert-combo", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 24 + }); + }, + + _init: function () { + BI.MultiSelectInsertCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = o.value || {}; + // 标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_insert_trigger", + height: o.height, + text: o.text, + // adapter: this.popup, + masker: { + offset: { + left: 0, + top: 0, + right: 0, + bottom: 26 + } + }, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + // 预防trigger内部把当前的storeValue改掉 + self.trigger.setValue(BI.deepClone(self.getValue())); + } + callback.apply(self, arguments); + }); + }, + value: o.value + }); + + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_START, function () { + self._setStartValue(""); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_STOP, function () { + self._setStartValue(""); + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () { + if (this.getSearcher().hasMatched()) { + self._addItem(assertShowValue); + } + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () { + if (!this.getSearcher().hasMatched()) { + self._addItem(assertShowValue); + self.trigger.stopEditing(); + } + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(""); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + }); + } + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + this.getCounter().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: "bi.multi_select_popup_view", + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + value: o.value, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self.element.removeClass("combo-show"); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.element.removeClass("combo-show").addClass("combo-show"); + this.setValue(self.storeValue); + BI.nextTick(function () { + self.populate(); + }); + }); + // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + // important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }); + }, + + _addItem: function (assertShowValue) { + var self = this; + var keyword = this.trigger.getSearcher().getKeyword(); + this._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + // 如果在不选的状态下直接把该值添加进来 + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.populate(); + self._setStartValue(""); + }); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.map(ob.items, "value"); + digest(values); + }); + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectInsertCombo.REQ_GET_ALL_DATA, + keywords: [this.trigger.getKey()] + }, function (ob) { + var items = BI.map(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }); + }, + + _adjust: function (callback) { + var self = this, o = this.options; + adjust(); + callback(); + function adjust () { + if (self.wants2Quit === true) { + self.fireEvent(BI.MultiSelectInsertCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.combo.setValue(this.storeValue); + }, + + getValue: function () { + return BI.deepClone(this.storeValue); + }, + + populate: function () { + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.extend(BI.MultiSelectInsertCombo, { + REQ_GET_DATA_LENGTH: 1, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut("bi.multi_select_insert_combo", BI.MultiSelectInsertCombo);/** + * + * @class BI.MultiSelectInsertCombo + * @extends BI.Single + */ +BI.MultiSelectInsertNoBarCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInsertNoBarCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-insert-combo", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 24 + }); + }, + + _init: function () { + BI.MultiSelectInsertNoBarCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = { + type: BI.Selection.Multi, + value: o.value || [] + }; + // 标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_insert_trigger", + height: o.height, + text: o.text, + // adapter: this.popup, + masker: { + offset: { + left: 0, + top: 0, + right: 0, + bottom: 26 + } + }, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + // 预防trigger内部把当前的storeValue改掉 + self.trigger.setValue({ + type: BI.Selection.Multi, + value: self.getValue() + }); + } + callback.apply(self, arguments); + }); + }, + value: { + type: BI.Selection.Multi, + value: o.value + } + }); + + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_START, function () { + self._setStartValue(""); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_STOP, function () { + self._setStartValue(""); + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_PAUSE, function () { + if (this.getSearcher().hasMatched()) { + self._addItem(assertShowValue); + } + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM, function () { + if (!this.getSearcher().hasMatched()) { + self._addItem(assertShowValue); + self.trigger.stopEditing(); + } + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(""); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_CHANGE, function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + }); + } + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + this.getCounter().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: "bi.multi_select_no_bar_popup_view", + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + value: { + type: BI.Selection.Multi, + value: o.value + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self.element.removeClass("combo-show"); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.element.removeClass("combo-show").addClass("combo-show"); + this.setValue(self.storeValue); + BI.nextTick(function () { + self.populate(); + }); + }); + // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + // important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }); + }, + + _addItem: function (assertShowValue) { + var self = this; + var keyword = this.trigger.getSearcher().getKeyword(); + this._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + // 如果在不选的状态下直接把该值添加进来 + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.populate(); + self._setStartValue(""); + }); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.map(ob.items, "value"); + digest(values); + }); + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this.requesting = true; + o.itemsCreator({ + type: BI.MultiSelectInsertNoBarCombo.REQ_GET_ALL_DATA, + keywords: [this.trigger.getKey()] + }, function (ob) { + var items = BI.map(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }); + }, + + _adjust: function (callback) { + var self = this, o = this.options; + adjust(); + callback(); + function adjust () { + if (self.wants2Quit === true) { + self.fireEvent(BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + setValue: function (v) { + this.storeValue = { + type: BI.Selection.Multi, + value: v || [] + }; + this.combo.setValue(this.storeValue); + }, + + getValue: function () { + return BI.deepClone(this.storeValue.value); + }, + + populate: function () { + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.extend(BI.MultiSelectInsertNoBarCombo, { + REQ_GET_DATA_LENGTH: 1, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectInsertNoBarCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut("bi.multi_select_insert_no_bar_combo", BI.MultiSelectInsertNoBarCombo);/** + * + * 复选下拉框 + * @class BI.MultiSelectInsertTrigger + * @extends BI.Trigger + */ + +BI.MultiSelectInsertTrigger = BI.inherit(BI.Trigger, { + + constants: { + height: 14, + rgap: 4, + lgap: 4 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInsertTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-trigger bi-border", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + searcher: {}, + switcher: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectInsertTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + if (o.height) { + this.setHeight(o.height - 2); + } + + this.searcher = BI.createWidget(o.searcher, { + type: "bi.multi_select_insert_searcher", + height: o.height, + text: o.text, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + popup: {}, + adapter: o.adapter, + masker: o.masker, + value: o.value + }); + this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_START); + }); + this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM); + }); + this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_PAUSE); + }); + this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_SEARCHING, arguments); + }); + this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_STOP); + }); + this.searcher.on(BI.MultiSelectInsertSearcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_CHANGE, arguments); + }); + this.numberCounter = BI.createWidget(o.switcher, { + type: "bi.multi_select_check_selected_switcher", + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + adapter: o.adapter, + masker: o.masker, + value: o.value + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK); + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); + }); + + var wrapNumberCounter = BI.createWidget({ + type: "bi.right_vertical_adapt", + hgap: 4, + items: [{ + el: this.numberCounter + }] + }); + + var wrapper = BI.createWidget({ + type: "bi.htape", + element: this, + items: [ + { + el: this.searcher, + width: "fill" + }, { + el: wrapNumberCounter, + width: 0 + }, { + el: BI.createWidget(), + width: 24 + }] + }); + + this.numberCounter.on(BI.Events.VIEW, function (b) { + BI.nextTick(function () {// 自动调整宽度 + wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); + wrapper.resize(); + }); + }); + + this.element.click(function (e) { + if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { + self.numberCounter.hideView(); + } + }); + }, + + getCounter: function () { + return this.numberCounter; + }, + + getSearcher: function () { + return this.searcher; + }, + + stopEditing: function () { + this.searcher.stopSearch(); + this.numberCounter.hideView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + this.numberCounter.setAdapter(adapter); + }, + + setValue: function (ob) { + this.searcher.setValue(ob); + this.numberCounter.setValue(ob); + }, + + getKey: function () { + return this.searcher.getKey(); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); + +BI.MultiSelectInsertTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.MultiSelectInsertTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; +BI.MultiSelectInsertTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectInsertTrigger.EVENT_START = "EVENT_START"; +BI.MultiSelectInsertTrigger.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectInsertTrigger.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectInsertTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.MultiSelectInsertTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; +BI.MultiSelectInsertTrigger.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; + +BI.shortcut("bi.multi_select_insert_trigger", BI.MultiSelectInsertTrigger);/** + * 多选加载数据面板 + * Created by guy on 15/11/2. + * @class BI.MultiSelectLoader + * @extends Widget + */ +BI.MultiSelectLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-loader", + logic: { + dynamic: true + }, + el: { + height: 400 + }, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.storeValue = opts.value || {}; + this._assertValue(this.storeValue); + + this.button_group = BI.createWidget({ + type: "bi.select_list", + logic: opts.logic, + el: BI.extend({ + onLoaded: opts.onLoaded, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, opts.el), + itemsCreator: function (op, callback) { + var startValue = self._startValue; + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi + ? self.storeValue.value.concat(startValue) : self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); + if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { + var txt = opts.valueFormatter(startValue) || startValue; + json.unshift({ + text: txt, + value: startValue, + title: txt, + selected: true + }); + } + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { + BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + hasNext: function () { + return hasNext; + }, + value: this.storeValue + }); + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.button_group], + vgap: 5 + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: this.options.logic, + cls: "bi-list-item-active", + height: 24, + selected: this.isAllSelected() + }); + }, + + _scrollToTop: function () { + var self = this; + BI.delay(function () { + self.button_group.element.scrollTop(0); + }, 30); + }, + + isAllSelected: function () { + return this.button_group.isAllSelected(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + setStartValue: function (v) { + this._startValue = v; + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.button_group.setValue(this.storeValue); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + arguments[0] = this._createItems(items); + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.MultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multi_select_loader", BI.MultiSelectLoader);/** + * 多选加载数据面板 + * Created by guy on 15/11/2. + * @class BI.MultiSelectNoBarLoader + * @extends Widget + */ +BI.MultiSelectNoBarLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectNoBarLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-loader", + logic: { + dynamic: true + }, + el: { + height: 400 + }, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectNoBarLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.storeValue = opts.value || {}; + this._assertValue(this.storeValue); + + this.button_group = BI.createWidget(BI.extend({ + type: "bi.list_pane", + onLoaded: opts.onLoaded, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + }, + itemsCreator: function (op, callback) { + var startValue = self._startValue; + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi + ? self.storeValue.value.concat(startValue) : self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); + if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { + var txt = opts.valueFormatter(startValue) || startValue; + json.unshift({ + text: txt, + value: startValue, + title: txt, + selected: true + }); + } + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { + BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + hasNext: function () { + return hasNext; + }, + value: this.storeValue + }, opts.el)); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.button_group], + vgap: 5 + }); + + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectNoBarLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: this.options.logic, + height: 24 + }); + }, + + _scrollToTop: function () { + var self = this; + BI.delay(function () { + self.button_group.element.scrollTop(0); + }, 30); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + setStartValue: function (v) { + this._startValue = v; + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.button_group.setValue(this.storeValue.value); + }, + + getValue: function () { + return { + type: BI.Selection.Multi, + value: this.button_group.getValue() + }; + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + arguments[0] = this._createItems(items); + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.element.css({"max-height": h + "px"}); + }, + + resetWidth: function () { + + } +}); + +BI.MultiSelectNoBarLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multi_select_no_bar_loader", BI.MultiSelectNoBarLoader);/** + * 带加载的多选下拉面板 + * @class BI.MultiSelectPopupView + * @extends Widget + */ +BI.MultiSelectPopupView = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-popup-view", + maxWidth: "auto", + minWidth: 135, + maxHeight: 400, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectPopupView.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.loader = BI.createWidget({ + type: "bi.multi_select_loader", + itemsCreator: opts.itemsCreator, + valueFormatter: opts.valueFormatter, + onLoaded: opts.onLoaded, + value: opts.value + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + element: this, + buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], + el: this.loader, + value: opts.value + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectPopupView.EVENT_CHANGE); + }); + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM); + break; + } + }); + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + setStartValue: function (v) { + this.loader.setStartValue(v); + }, + + setValue: function (v) { + this.popupView.setValue(v); + }, + + getValue: function () { + return this.popupView.getValue(); + }, + + populate: function (items) { + this.popupView.populate.apply(this.popupView, arguments); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.MultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + + +BI.shortcut("bi.multi_select_popup_view", BI.MultiSelectPopupView);/** + * 带加载的多选下拉面板 + * @class BI.MultiSelectPopupView + * @extends Widget + */ +BI.MultiSelectNoBarPopupView = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectNoBarPopupView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-popup-view", + maxWidth: "auto", + minWidth: 135, + maxHeight: 400, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectNoBarPopupView.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.loader = BI.createWidget({ + type: "bi.multi_select_no_bar_loader", + itemsCreator: opts.itemsCreator, + valueFormatter: opts.valueFormatter, + onLoaded: opts.onLoaded, + value: opts.value + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + element: this, + buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], + el: this.loader, + value: opts.value + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CHANGE); + }); + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM); + break; + } + }); + }, + + setStartValue: function (v) { + this.loader.setStartValue(v); + }, + + setValue: function (v) { + this.popupView.setValue(v); + }, + + getValue: function () { + return this.popupView.getValue(); + }, + + populate: function (items) { + this.popupView.populate.apply(this.popupView, arguments); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.MultiSelectNoBarPopupView.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectNoBarPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiSelectNoBarPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + + +BI.shortcut("bi.multi_select_no_bar_popup_view", BI.MultiSelectNoBarPopupView);/** + * + * 复选下拉框 + * @class BI.MultiSelectTrigger + * @extends BI.Trigger + */ + +BI.MultiSelectTrigger = BI.inherit(BI.Trigger, { + + constants: { + height: 14, + rgap: 4, + lgap: 4 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-trigger bi-border", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + searcher: {}, + switcher: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + if (o.height) { + this.setHeight(o.height - 2); + } + + this.searcher = BI.createWidget(o.searcher, { + type: "bi.multi_select_searcher", + height: o.height, + text: o.text, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + popup: {}, + adapter: o.adapter, + masker: o.masker, + value: o.value + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_START); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_PAUSE); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_SEARCHING, arguments); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_STOP); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_CHANGE, arguments); + }); + this.numberCounter = BI.createWidget(o.switcher, { + type: "bi.multi_select_check_selected_switcher", + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + adapter: o.adapter, + masker: o.masker, + value: o.value + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK); + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); + }); + + var wrapNumberCounter = BI.createWidget({ + type: "bi.right_vertical_adapt", + hgap: 4, + items: [{ + el: this.numberCounter + }] + }); + + var wrapper = BI.createWidget({ + type: "bi.htape", + element: this, + items: [ + { + el: this.searcher, + width: "fill" + }, { + el: wrapNumberCounter, + width: 0 + }, { + el: BI.createWidget(), + width: 24 + }] + }); + + this.numberCounter.on(BI.Events.VIEW, function (b) { + BI.nextTick(function () {// 自动调整宽度 + wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); + wrapper.resize(); + }); + }); + + this.element.click(function (e) { + if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { + self.numberCounter.hideView(); + } + }); + }, + + getCounter: function () { + return this.numberCounter; + }, + + getSearcher: function () { + return this.searcher; + }, + + stopEditing: function () { + this.searcher.stopSearch(); + this.numberCounter.hideView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + this.numberCounter.setAdapter(adapter); + }, + + setValue: function (ob) { + this.searcher.setValue(ob); + this.numberCounter.setValue(ob); + }, + + getKey: function () { + return this.searcher.getKey(); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); + +BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.MultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; +BI.MultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectTrigger.EVENT_START = "EVENT_START"; +BI.MultiSelectTrigger.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; + +BI.shortcut("bi.multi_select_trigger", BI.MultiSelectTrigger);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.MultiSelectSearchInsertPane + * @extends Widget + */ + +BI.MultiSelectSearchInsertPane = BI.inherit(BI.Widget, { + + constants: { + height: 24, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearchInsertPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-search-pane bi-card", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectSearchInsertPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.tooltipClick = BI.createWidget({ + type: "bi.label", + invisible: true, + text: BI.i18nText("BI-Click_Blank_To_Select"), + cls: "multi-select-toolbar", + height: this.constants.height + }); + + this.addNotMatchTip = BI.createWidget({ + type: "bi.text_button", + invisible: true, + text: BI.i18nText("BI-Basic_Click_To_Add_Text", ""), + height: this.constants.height, + cls: "bi-high-light", + hgap: 5, + handler: function () { + self.fireEvent(BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, o.keywordGetter()); + } + }); + + this.loader = BI.createWidget({ + type: "bi.multi_select_search_loader", + keywordGetter: o.keywordGetter, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator.apply(self, [op, function (res) { + callback(res); + self.setKeyword(o.keywordGetter()); + }]); + }, + value: o.value + }); + this.loader.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.resizer = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + type: "bi.vertical", + items: [this.tooltipClick, this.addNotMatchTip], + height: this.constants.height + }, { + el: this.loader + }] + }); + }, + + setKeyword: function (keyword) { + var btn; + var isMatchTipVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); + this.tooltipClick.setVisible(isMatchTipVisible); + this.addNotMatchTip.setVisible(!isMatchTipVisible); + !isMatchTipVisible && this.addNotMatchTip.setText(BI.i18nText("BI-Basic_Click_To_Add_Text", keyword)); + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + hasMatched: function () { + return this.tooltipClick.isVisible(); + }, + + setValue: function (v) { + this.loader.setValue(v); + }, + + getValue: function () { + return this.loader.getValue(); + }, + + empty: function () { + this.loader.empty(); + }, + + populate: function (items) { + this.loader.populate.apply(this.loader, arguments); + } +}); + +BI.MultiSelectSearchInsertPane.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; + +BI.shortcut("bi.multi_select_search_insert_pane", BI.MultiSelectSearchInsertPane);/** + * 多选加载数据搜索loader面板 + * Created by guy on 15/11/4. + * @class BI.MultiSelectSearchLoader + * @extends Widget + */ +BI.MultiSelectSearchLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-search-loader", + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn, + valueFormatter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectSearchLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + this.storeValue = BI.deepClone(opts.value); + this.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: { + dynamic: false + }, + value: opts.value, + el: { + tipText: BI.i18nText("BI-No_Select"), + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, + itemsCreator: function (op, callback) { + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + var keyword = ob.keyword = opts.keywordGetter(); + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = self._filterValues(self.storeValue); + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), keyword); + if (op.times === 1 && self.storeValue) { + self.setValue(self.storeValue); + } + }); + }, + hasNext: function () { + return hasNext; + } + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectSearchLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: { + dynamic: false + }, + height: 24, + selected: this.isAllSelected() + }); + }, + + isAllSelected: function () { + return this.button_group.isAllSelected(); + }, + + _filterValues: function (src) { + var o = this.options; + var keyword = o.keywordGetter(); + var values = BI.deepClone(src.value) || []; + var newValues = BI.map(values, function (i, v) { + return { + text: o.valueFormatter(v) || v, + value: v + }; + }); + if (BI.isKey(keyword)) { + var search = BI.Func.getSearchResult(newValues, keyword); + values = search.match.concat(search.find); + } + return BI.map(values, function (i, v) { + return { + text: v.text, + title: v.text, + value: v.value, + selected: src.type === BI.Selection.All + }; + }); + }, + + setValue: function (v) { + // 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 + this.storeValue = BI.deepClone(v); + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.MultiSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multi_select_search_loader", BI.MultiSelectSearchLoader);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.MultiSelectSearchPane + * @extends Widget + */ + +BI.MultiSelectSearchPane = BI.inherit(BI.Widget, { + + constants: { + height: 24, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-search-pane bi-card", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectSearchPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.tooltipClick = BI.createWidget({ + type: "bi.label", + invisible: true, + text: BI.i18nText("BI-Click_Blank_To_Select"), + cls: "multi-select-toolbar", + height: this.constants.height + }); + + this.loader = BI.createWidget({ + type: "bi.multi_select_search_loader", + keywordGetter: o.keywordGetter, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator.apply(self, [op, function (res) { + callback(res); + self.setKeyword(o.keywordGetter()); + }]); + }, + value: o.value + }); + this.loader.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.resizer = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.tooltipClick, + height: 0 + }, { + el: this.loader + }] + }); + this.tooltipClick.setVisible(false); + }, + + setKeyword: function (keyword) { + var btn; + var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); + if (isVisible !== this.tooltipClick.isVisible()) { + this.tooltipClick.setVisible(isVisible); + this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); + this.resizer.resize(); + } + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + hasMatched: function () { + return this.tooltipClick.isVisible(); + }, + + setValue: function (v) { + this.loader.setValue(v); + }, + + getValue: function () { + return this.loader.getValue(); + }, + + empty: function () { + this.loader.empty(); + }, + + populate: function (items) { + this.loader.populate.apply(this.loader, arguments); + } +}); + +BI.MultiSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.multi_select_search_pane", BI.MultiSelectSearchPane);/** + * 查看已选按钮 + * Created by guy on 15/11/3. + * @class BI.MultiSelectCheckSelectedButton + * @extends BI.Single + */ +BI.MultiSelectCheckSelectedButton = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-check-selected-button", + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.numberCounter = BI.createWidget({ + type: "bi.text_button", + element: this, + hgap: 4, + text: "0", + textAlign: "center", + textHeight: 16, + cls: "bi-high-light-background count-tip" + }); + this.numberCounter.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.numberCounter.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); + }); + + this.numberCounter.element.hover(function () { + self.numberCounter.setTag(self.numberCounter.getText()); + self.numberCounter.setText(BI.i18nText("BI-Check_Selected")); + }, function () { + self.numberCounter.setText(self.numberCounter.getTag()); + }); + this.setVisible(false); + if(BI.isNotNull(o.value)){ + this.setValue(o.value); + } + }, + + setValue: function (ob) { + var self = this, o = this.options; + ob || (ob = {}); + ob.type || (ob.type = BI.Selection.Multi); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + o.itemsCreator({ + type: BI.MultiSelectCombo.REQ_GET_DATA_LENGTH + }, function (res) { + var length = res.count - ob.value.length; + BI.nextTick(function () { + self.numberCounter.setText(length); + self.setVisible(length > 0); + }); + }); + return; + } + BI.nextTick(function () { + self.numberCounter.setText(ob.value.length); + self.setVisible(ob.value.length > 0); + }); + }, + + getValue: function () { + + } +}); + +BI.MultiSelectCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multi_select_check_selected_button", BI.MultiSelectCheckSelectedButton);/** + * 多选输入框 + * Created by guy on 15/11/3. + * @class BI.MultiSelectEditor + * @extends Widget + */ +BI.MultiSelectEditor = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectEditor.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-editor", + el: {} + }); + }, + + _init: function () { + BI.MultiSelectEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.state_editor", + element: this, + height: o.height, + watermark: BI.i18nText("BI-Basic_Search"), + allowBlank: true, + value: o.value, + text: o.text + }); + + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.editor.on(BI.StateEditor.EVENT_PAUSE, function () { + self.fireEvent(BI.MultiSelectEditor.EVENT_PAUSE); + }); + this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () { + + }); + }, + + focus: function () { + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + }, + + setState: function (state) { + this.editor.setState(state); + }, + + setValue: function (v) { + this.editor.setValue(v); + }, + + getValue: function () { + var v = this.editor.getState(); + if (BI.isArray(v) && v.length > 0) { + return v[v.length - 1]; + } + return ""; + + }, + + getKeywords: function () { + var val = this.editor.getLastValidValue(); + var keywords = val.match(/[\S]+/g); + if (BI.isEndWithBlank(val)) { + return keywords.concat([" "]); + } + return keywords; + }, + + populate: function (items) { + + } +}); +BI.MultiSelectEditor.EVENT_PAUSE = "MultiSelectEditor.EVENT_PAUSE"; +BI.shortcut("bi.multi_select_editor", BI.MultiSelectEditor);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.MultiSelectInsertSearcher + * @extends Widget + */ +BI.MultiSelectInsertSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInsertSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-searcher", + itemsCreator: BI.emptyFn, + el: {}, + popup: {}, + valueFormatter: BI.emptyFn, + adapter: null, + masker: {}, + text: BI.i18nText("BI-Basic_Please_Select") + }); + }, + + _init: function () { + BI.MultiSelectInsertSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.multi_select_editor", + height: o.height, + text: o.text + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + height: o.height, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_select_search_insert_pane", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + var keyword = self.editor.getValue(); + op.keywords = [keyword]; + this.setKeyword(keyword); + o.itemsCreator(op, callback); + }, + value: o.value, + listeners: [{ + eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, + action: function () { + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM); + } + }] + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_CHANGE, arguments); + }); + this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { + var keywords = this.getKeywords(); + self.fireEvent(BI.MultiSelectInsertSearcher.EVENT_SEARCHING, keywords); + }); + if (BI.isNotNull(o.value)) { + this.setState(o.value); + } + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + setState: function (ob) { + var o = this.options; + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + if (ob.value.length === 0) { + this.editor.setState(BI.Selection.All); + } else if (BI.size(ob.assist) <= 20) { + var state = ""; + BI.each(ob.assist, function (i, v) { + if (i === 0) { + state += "" + (o.valueFormatter(v + "") || v); + } else { + state += "," + (o.valueFormatter(v + "") || v); + } + }); + this.editor.setState(state); + } else { + this.editor.setState(BI.Selection.Multi); + } + } else { + if (ob.value.length === 0) { + this.editor.setState(BI.Selection.None); + } else if (BI.size(ob.value) <= 20) { + var state = ""; + BI.each(ob.value, function (i, v) { + if (i === 0) { + state += "" + (o.valueFormatter(v + "") || v); + } else { + state += "," + (o.valueFormatter(v + "") || v); + } + }); + this.editor.setState(state); + } else { + this.editor.setState(BI.Selection.Multi); + } + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.MultiSelectInsertSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.MultiSelectInsertSearcher.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectInsertSearcher.EVENT_START = "EVENT_START"; +BI.MultiSelectInsertSearcher.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectInsertSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectInsertSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.MultiSelectInsertSearcher.EVENT_ADD_ITEM = "EVENT_ADD_ITEM"; +BI.shortcut("bi.multi_select_insert_searcher", BI.MultiSelectInsertSearcher);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.MultiSelectSearcher + * @extends Widget + */ +BI.MultiSelectSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-searcher", + itemsCreator: BI.emptyFn, + el: {}, + popup: {}, + valueFormatter: BI.emptyFn, + adapter: null, + masker: {}, + text: BI.i18nText("BI-Basic_Please_Select") + }); + }, + + _init: function () { + BI.MultiSelectSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.multi_select_editor", + height: o.height, + text: o.text + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + height: o.height, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_select_search_pane", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + var keyword = self.editor.getValue(); + op.keywords = [keyword]; + this.setKeyword(keyword); + o.itemsCreator(op, callback); + }, + value: o.value + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.MultiSelectSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectSearcher.EVENT_CHANGE, arguments); + }); + this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { + var keywords = this.getKeywords(); + self.fireEvent(BI.MultiSelectSearcher.EVENT_SEARCHING, keywords); + }); + if (BI.isNotNull(o.value)) { + this.setState(o.value); + } + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + setState: function (ob) { + var o = this.options; + ob || (ob = {}); + ob.value || (ob.value = []); + if (ob.type === BI.Selection.All) { + if (ob.value.length === 0) { + this.editor.setState(BI.Selection.All); + } else if (BI.size(ob.assist) <= 20) { + var state = ""; + BI.each(ob.assist, function (i, v) { + if (i === 0) { + state += "" + (o.valueFormatter(v + "") || v); + } else { + state += "," + (o.valueFormatter(v + "") || v); + } + }); + this.editor.setState(state); + } else { + this.editor.setState(BI.Selection.Multi); + } + } else { + if (ob.value.length === 0) { + this.editor.setState(BI.Selection.None); + } else if (BI.size(ob.value) <= 20) { + var state = ""; + BI.each(ob.value, function (i, v) { + if (i === 0) { + state += "" + (o.valueFormatter(v + "") || v); + } else { + state += "," + (o.valueFormatter(v + "") || v); + } + }); + this.editor.setState(state); + } else { + this.editor.setState(BI.Selection.Multi); + } + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.MultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.MultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiSelectSearcher.EVENT_START = "EVENT_START"; +BI.MultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; +BI.MultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.MultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.shortcut("bi.multi_select_searcher", BI.MultiSelectSearcher);/** + * 查看已选switcher + * Created by guy on 15/11/3. + * @class BI.MultiSelectCheckSelectedSwitcher + * @extends Widget + */ +BI.MultiSelectCheckSelectedSwitcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiSelectCheckSelectedSwitcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-check-selected-switcher", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + el: {}, + popup: {}, + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiSelectCheckSelectedSwitcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.button = BI.createWidget(o.el, { + type: "bi.multi_select_check_selected_button", + itemsCreator: o.itemsCreator, + value: o.value + }); + this.button.on(BI.Events.VIEW, function () { + self.fireEvent(BI.Events.VIEW, arguments); + }); + this.switcher = BI.createWidget({ + type: "bi.switcher", + toggle: false, + element: this, + el: this.button, + popup: BI.extend({ + type: "bi.multi_select_check_pane", + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + onClickContinueSelect: function () { + self.switcher.hideView(); + }, + value: o.value + }, o.popup), + adapter: o.adapter, + masker: o.masker + }); + this.switcher.on(BI.Switcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE); + }); + this.switcher.on(BI.Switcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW); + }); + this.switcher.on(BI.Switcher.EVENT_AFTER_POPUPVIEW, function () { + var me = this; + BI.nextTick(function () { + me.populate(); + }); + }); + + this.switcher.element.click(function (e) { + e.stopPropagation(); + }); + }, + + adjustView: function () { + this.switcher.adjustView(); + }, + + hideView: function () { + this.switcher.empty(); + this.switcher.hideView(); + }, + + setAdapter: function (adapter) { + this.switcher.setAdapter(adapter); + }, + + setValue: function (v) { + this.switcher.setValue(v); + }, + + setButtonChecked: function (v) { + this.button.setValue(v); + }, + + getValue: function () { + + }, + + populate: function (items) { + this.switcher.populate.apply(this.switcher, arguments); + } +}); + +BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE = "MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE"; +BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW = "MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.multi_select_check_selected_switcher", BI.MultiSelectCheckSelectedSwitcher);/** + * Created by zcf_1 on 2017/5/2. + */ +BI.MultiSelectInsertList = BI.inherit(BI.Single, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInsertList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-insert-list", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn + }); + }, + _init: function () { + BI.MultiSelectInsertList.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + this.storeValue = o.value || {}; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + // self.trigger.setValue(self.storeValue); + }; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_loader", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + logic: { + dynamic: true + }, + // onLoaded: o.onLoaded, + el: {}, + value: o.value + }); + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + self.storeValue = this.getValue(); + assertShowValue(); + self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); + }); + + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_insert_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keywords = [self.trigger.getKeyword()]; + this.setKeyword(op.keywords[0]); + o.itemsCreator(op, callback); + }, + listeners: [{ + eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, + action: function () { + var keyword = self.trigger.getKeyword(); + if (!self.trigger.hasMatched()) { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self.adapter.populate(); + if (self.storeValue.type === BI.Selection.Multi) { + self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); + } + } + } + }] + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self._setStartValue(""); + this.setValue(BI.deepClone(self.storeValue)); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 + self.adapter.populate(); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + var keyword = this.getKeyword(); + if (this.hasMatched()) { + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); + }); + } + self._showAdapter(); + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeywords(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectInsertList.EVENT_CHANGE); + }); + } + } + }], + value: o.value + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.trigger, + height: 24 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }); + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + if (!this._allData) { + o.itemsCreator({ + type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.map(ob.items, "value"); + digest(self._allData); + }); + } else { + digest(this._allData); + } + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + callback(); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + o.itemsCreator({ + type: BI.MultiSelectInsertList.REQ_GET_ALL_DATA, + keywords: [self.trigger.getKeyword()] + }, function (ob) { + var items = BI.map(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + callback(); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + callback(); + }); + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + callback(); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.adapter.setStartValue(value); + }, + + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, + + resize: function () { + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); + }, + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.adapter.setValue(this.storeValue); + this.trigger.setValue(this.storeValue); + }, + + getValue: function () { + return BI.deepClone(this.storeValue); + }, + + populate: function () { + this._count = null; + this._allData = null; + this.adapter.populate.apply(this.adapter, arguments); + this.trigger.populate.apply(this.trigger, arguments); + } +}); + +BI.extend(BI.MultiSelectInsertList, { + REQ_GET_DATA_LENGTH: 1, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectInsertList.EVENT_CHANGE = "BI.MultiSelectInsertList.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_insert_list", BI.MultiSelectInsertList);/** + * Created by zcf_1 on 2017/5/2. + */ +BI.MultiSelectInsertNoBarList = BI.inherit(BI.Single, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectInsertNoBarList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-insert-list", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn + }); + }, + _init: function () { + BI.MultiSelectInsertNoBarList.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + this.storeValue = { + type: BI.Selection.Multi, + value: o.value || [] + }; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + // self.trigger.setValue(self.storeValue); + }; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_no_bar_loader", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + logic: { + dynamic: false + }, + // onLoaded: o.onLoaded, + el: {}, + value: { + type: BI.Selection.Multi, + value: o.value || [] + } + }); + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + self.storeValue = this.getValue(); + assertShowValue(); + self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); + }); + + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_insert_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keywords = [self.trigger.getKeyword()]; + this.setKeyword(op.keywords[0]); + o.itemsCreator(op, callback); + }, + listeners: [{ + eventName: BI.MultiSelectSearchInsertPane.EVENT_ADD_ITEM, + action: function () { + var keyword = self.trigger.getKeyword(); + if (!self.trigger.hasMatched()) { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self.adapter.populate(); + if (self.storeValue.type === BI.Selection.Multi) { + self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); + } + } + } + }] + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self._setStartValue(""); + this.setValue(BI.deepClone(self.storeValue)); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 + self.adapter.populate(); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + var keyword = this.getKeyword(); + if (this.hasMatched()) { + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + if (self.storeValue.type === BI.Selection.Multi) { + self.storeValue.value.pushDistinct(keyword); + } + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); + }); + } + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeywords(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectInsertNoBarList.EVENT_CHANGE); + }); + } + } + }], + value: { + type: BI.Selection.Multi, + value: o.value || [] + } + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.trigger, + height: 24 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }); + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + if (!this._allData) { + o.itemsCreator({ + type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.map(ob.items, "value"); + digest(self._allData); + }); + } else { + digest(this._allData); + } + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + callback(); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + o.itemsCreator({ + type: BI.MultiSelectInsertNoBarList.REQ_GET_ALL_DATA, + keywords: [self.trigger.getKeyword()] + }, function (ob) { + var items = BI.map(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + callback(); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + callback(); + }); + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + callback(); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.adapter.setStartValue(value); + }, + + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, + + resize: function () { + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); + }, + setValue: function (v) { + this.storeValue = { + type: BI.Selection.Multi, + value: v || [] + }; + this.adapter.setValue(this.storeValue); + this.trigger.setValue(this.storeValue); + }, + + getValue: function () { + return BI.deepClone(this.storeValue.value); + }, + + populate: function () { + this._count = null; + this._allData = null; + this.adapter.populate.apply(this.adapter, arguments); + this.trigger.populate.apply(this.trigger, arguments); + } +}); + +BI.extend(BI.MultiSelectInsertNoBarList, { + REQ_GET_DATA_LENGTH: 1, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectInsertNoBarList.EVENT_CHANGE = "BI.MultiSelectInsertNoBarList.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_insert_no_bar_list", BI.MultiSelectInsertNoBarList);/** + * Created by zcf_1 on 2017/5/2. + */ +BI.MultiSelectList = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-list", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn + }); + }, + _init: function () { + BI.MultiSelectList.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + this.storeValue = {}; + + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + // self.trigger.setValue(self.storeValue); + }; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_loader", + cls: "popup-multi-select-list bi-border-left bi-border-right bi-border-bottom", + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + logic: { + dynamic: false + }, + // onLoaded: o.onLoaded, + el: {} + }); + this.adapter.on(BI.MultiSelectLoader.EVENT_CHANGE, function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }); + }); + + this.searcherPane = BI.createWidget({ + type: "bi.multi_select_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keywords = [self.trigger.getKeyword()]; + this.setKeyword(op.keywords[0]); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self._setStartValue(""); + this.setValue(BI.deepClone(self.storeValue)); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(""); + self.adapter.setValue(self.storeValue); + // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 + self.adapter.populate(); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + var keyword = this.getKeyword(); + if (this.hasMatched()) { + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }); + } + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeyword(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(""); + } else { + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + self.fireEvent(BI.MultiSelectList.EVENT_CHANGE); + }); + } + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.trigger, + height: 24 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }); + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + if (!this._allData) { + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.map(ob.items, "value"); + digest(self._allData); + }); + } else { + digest(this._allData); + } + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_ALL_DATA, + keywords: [this.trigger.getKey()] + }, function (ob) { + var items = BI.map(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }); + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + o.itemsCreator({ + type: BI.MultiSelectList.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + } + + function adjust () { + if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.Multi, + value: [] + }; + } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.All, + value: [] + }; + } + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.adapter.setStartValue(value); + }, + + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, + + resize: function () { + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); + }, + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.adapter.setValue(this.storeValue); + this.trigger.setValue(this.storeValue); + }, + + getValue: function () { + return BI.deepClone(this.storeValue); + }, + + populate: function () { + this._count = null; + this._allData = null; + this.adapter.populate.apply(this.adapter, arguments); + this.trigger.populate.apply(this.trigger, arguments); + } +}); + +BI.extend(BI.MultiSelectList, { + REQ_GET_DATA_LENGTH: 1, + REQ_GET_ALL_DATA: -1 +}); + +BI.MultiSelectList.EVENT_CHANGE = "BI.MultiSelectList.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_list", BI.MultiSelectList);/** + * Created by zcf_1 on 2017/5/11. + */ +BI.MultiSelectTree = BI.inherit(BI.Single, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-tree", + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiSelectTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = {value: {}}; + + this.adapter = BI.createWidget({ + type: "bi.multi_select_tree_popup", + itemsCreator: o.itemsCreator + }); + this.adapter.on(BI.MultiSelectTreePopup.EVENT_CHANGE, function () { + if (self.searcher.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.setSelectedValue(self.storeValue.value); + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + }); + + // 搜索中的时候用的是parttree,同adapter中的synctree不一样 + this.searcherPane = BI.createWidget({ + type: "bi.multi_tree_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + keywordGetter: function () { + return self.searcher.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.searcher.getKeyword(); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.searcher.getKeyword() + }); + }, + adapter: this.adapter, + popup: this.searcherPane, + masker: false, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + // self.storeValue = {value: self.adapter.getValue()}; + // self.searcherPane.setSelectedValue(self.storeValue.value); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + // self.storeValue = {value: self.searcherPane.getValue()}; + // self.adapter.setSelectedValue(self.storeValue.value); + BI.nextTick(function () { + self.adapter.populate(); + }); + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + if (self.searcher.isSearching()) { + self.storeValue = {value: self.searcherPane.getValue()}; + } else { + self.storeValue = {value: self.adapter.getValue()}; + } + self.setSelectedValue(self.storeValue.value); + self.fireEvent(BI.MultiSelectTree.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + self._showAdapter(); + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.searcher, + height: 24 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }); + + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + resize: function () { + + }, + + setSelectedValue: function (v) { + this.storeValue.value = v || {}; + this.adapter.setSelectedValue(v); + this.searcherPane.setSelectedValue(v); + this.searcher.setValue({ + value: v || {} + }); + }, + + setValue: function (v) { + this.adapter.setValue(v); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + updateValue: function (v) { + this.adapter.updateValue(v); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.searcher.populate.apply(this.searcher, arguments); + this.adapter.populate.apply(this.adapter, arguments); + } +}); +BI.MultiSelectTree.EVENT_CHANGE = "BI.MultiSelectTree.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree", BI.MultiSelectTree);/** + * Created by zcf on 2016/12/21. + */ +BI.MultiSelectTreePopup = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.MultiSelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-tree-popup bi-border-left bi-border-right bi-border-bottom", + itemsCreator: BI.emptyFn + }); + }, + _init: function () { + BI.MultiSelectTreePopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.popup = BI.createWidget({ + type: "bi.async_tree", + element: this, + itemsCreator: o.itemsCreator + }); + this.popup.on(BI.TreeView.EVENT_AFTERINIT, function () { + self.fireEvent(BI.MultiSelectTreePopup.EVENT_AFTER_INIT); + }); + this.popup.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectTreePopup.EVENT_CHANGE); + }); + }, + + hasChecked: function () { + return this.popup.hasChecked(); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + setValue: function (v) { + v || (v = {}); + this.popup.setValue(v); + }, + + setSelectedValue: function (v) { + v || (v = {}); + this.popup.setSelectedValue(v); + }, + + updateValue: function (v) { + this.popup.updateValue(v); + this.popup.refresh(); + }, + + populate: function (config) { + this.popup.stroke(config); + } + +}); +BI.MultiSelectTreePopup.EVENT_AFTER_INIT = "BI.MultiSelectTreePopup.EVENT_AFTER_INIT"; +BI.MultiSelectTreePopup.EVENT_CHANGE = "BI.MultiSelectTreePopup.EVENT_CHANGE"; +BI.shortcut("bi.multi_select_tree_popup", BI.MultiSelectTreePopup);/** + * + * @class BI.MultiTreeCheckPane + * @extends BI.Pane + */ +BI.MultiTreeCheckPane = BI.inherit(BI.Pane, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCheckPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-check-pane bi-background", + onClickContinueSelect: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeCheckPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.selectedValues = {}; + + var continueSelect = BI.createWidget({ + type: "bi.text_button", + text: BI.i18nText("BI-Continue_Select"), + cls: "multi-tree-check-selected" + }); + continueSelect.on(BI.TextButton.EVENT_CHANGE, function () { + opts.onClickContinueSelect(); + BI.nextTick(function () { + self.empty(); + }); + }); + + var backToPopup = BI.createWidget({ + type: "bi.left", + cls: "multi-tree-continue-select", + items: [ + { + el: { + type: "bi.label", + text: BI.i18nText("BI-Selected_Data") + }, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }, + { + el: continueSelect, + lgap: this.constants.lgap, + tgap: this.constants.tgap + }] + }); + + this.display = BI.createWidget({ + type: "bi.display_tree", + cls: "bi-multi-tree-display", + itemsCreator: function (op, callback) { + op.type = BI.TreeView.REQ_TYPE_GET_SELECTED_DATA; + opts.itemsCreator(op, callback); + }, + value: (opts.value || {}).value + }); + + this.display.on(BI.Events.AFTERINIT, function () { + self.fireEvent(BI.Events.AFTERINIT); + }); + + this.display.on(BI.TreeView.EVENT_INIT, function () { + backToPopup.setVisible(false); + }); + + this.display.on(BI.TreeView.EVENT_AFTERINIT, function () { + backToPopup.setVisible(true); + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + height: this.constants.height, + el: backToPopup + }, { + height: "fill", + el: this.display + }] + }); + + }, + + empty: function () { + this.display.empty(); + }, + + populate: function (configs) { + this.display.stroke(configs); + }, + + setValue: function (v) { + v || (v = {}); + this.display.setSelectedValue(v.value); + }, + + getValue: function () { + + } +}); + +BI.MultiTreeCheckPane.EVENT_CONTINUE_CLICK = "EVENT_CONTINUE_CLICK"; + + +BI.shortcut("bi.multi_tree_check_pane", BI.MultiTreeCheckPane);/** + * + * @class BI.MultiTreeCombo + * @extends BI.Single + */ + +BI.MultiTreeCombo = BI.inherit(BI.Single, { + + constants: { + offset: { + top: 0, + left: 0, + right: 0, + bottom: 31 + } + }, + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-combo", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 24 + }); + }, + + _init: function () { + BI.MultiTreeCombo.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + var isInit = false; + var want2showCounter = false; + + this.storeValue = {value: o.value || {}}; + + this.trigger = BI.createWidget({ + type: "bi.multi_select_trigger", + height: o.height, + valueFormatter: o.valueFormatter, + // adapter: this.popup, + masker: { + offset: this.constants.offset + }, + searcher: { + type: "bi.multi_tree_searcher", + itemsCreator: o.itemsCreator + }, + switcher: { + el: { + type: "bi.multi_tree_check_selected_button" + }, + popup: { + type: "bi.multi_tree_check_pane", + itemsCreator: o.itemsCreator + } + }, + value: {value: o.value || {}} + + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: "bi.multi_tree_popup_view", + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiTreePopup.EVENT_AFTERINIT, + action: function () { + self.trigger.getCounter().adjustView(); + isInit = true; + if (want2showCounter === true) { + showCounter(); + } + } + }, { + eventName: BI.MultiTreePopup.EVENT_CHANGE, + action: function () { + change = true; + var val = { + type: BI.Selection.Multi, + value: this.hasChecked() ? this.getValue() : {} + }; + self.trigger.getSearcher().setState(val); + self.trigger.getCounter().setButtonChecked(val); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CONFIRM, + action: function () { + self.combo.hideView(); + } + }, { + eventName: BI.MultiTreePopup.EVENT_CLICK_CLEAR, + action: function () { + clear = true; + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: o.itemsCreator, + onLoaded: function () { + BI.nextTick(function () { + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + value: {value: o.value || {}}, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + var change = false; + var clear = false; // 标识当前是否点击了清空 + + var isSearching = function () { + return self.trigger.getSearcher().isSearching(); + }; + + var isPopupView = function () { + return self.combo.isViewVisible(); + }; + + this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { + self.storeValue = {value: self.combo.getValue()}; + this.setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { + self.storeValue = {value: this.getValue()}; + self.combo.setValue(self.storeValue); + BI.nextTick(function () { + if (isPopupView()) { + self.combo.populate(); + } + }); + }); + + function showCounter () { + if (isSearching()) { + self.storeValue = {value: self.trigger.getValue()}; + } else if (isPopupView()) { + self.storeValue = {value: self.combo.getValue()}; + } + self.trigger.setValue(self.storeValue); + } + + this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + if (want2showCounter === false) { + want2showCounter = true; + } + if (isInit === true) { + want2showCounter = null; + showCounter(); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_TRIGGER_CLICK, function () { + self.combo.toggle(); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function () { + var checked = this.getSearcher().hasChecked(); + var val = { + type: BI.Selection.Multi, + value: checked ? {1: 1} : {} + }; + this.getSearcher().setState(checked ? BI.Selection.Multi : BI.Selection.None); + this.getCounter().setButtonChecked(val); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.element.removeClass("combo-show").addClass("combo-show"); + if (isSearching()) { + return; + } + if (change === true) { + self.storeValue = {value: self.combo.getValue()}; + change = false; + } + self.combo.setValue(self.storeValue); + self.populate(); + + }); + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self.element.removeClass("combo-show"); + if (isSearching()) { + self.trigger.stopEditing(); + self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); + } else { + if (isPopupView()) { + self.trigger.stopEditing(); + self.storeValue = {value: self.combo.getValue()}; + if (clear === true) { + self.storeValue = {value: {}}; + } + self.fireEvent(BI.MultiTreeCombo.EVENT_CONFIRM); + } + } + clear = false; + change = false; + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + setValue: function (v) { + this.storeValue.value = v || {}; + this.combo.setValue({ + value: v || {} + }); + }, + + getValue: function () { + return this.storeValue.value; + }, + + populate: function () { + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.MultiTreeCombo.EVENT_CONFIRM = "MultiTreeCombo.EVENT_CONFIRM"; + +BI.shortcut("bi.multi_tree_combo", BI.MultiTreeCombo);/** + * 带加载的多选下拉面板 + * @class BI.MultiTreePopup + * @extends BI.Pane + */ +BI.MultiTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-popup", + maxWidth: "auto", + minWidth: 100, + maxHeight: 400, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreePopup.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.selectedValues = {}; + + this.tree = BI.createWidget({ + type: "bi.async_tree", + height: 400, + cls: "popup-view-tree", + itemsCreator: opts.itemsCreator, + onLoaded: opts.onLoaded, + value: opts.value || {} + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + element: this, + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], + el: this.tree + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.MultiTreePopup.EVENT_CLICK_CONFIRM); + break; + } + }); + + this.tree.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreePopup.EVENT_CHANGE); + }); + + this.tree.on(BI.TreeView.EVENT_AFTERINIT, function () { + self.fireEvent(BI.MultiTreePopup.EVENT_AFTERINIT); + }); + + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v || (v = {}); + this.tree.setSelectedValue(v.value); + }, + + populate: function (config) { + this.tree.stroke(config); + }, + + hasChecked: function () { + return this.tree.hasChecked(); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.MultiTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiTreePopup.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiTreePopup.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; +BI.MultiTreePopup.EVENT_AFTERINIT = "EVENT_AFTERINIT"; + + +BI.shortcut("bi.multi_tree_popup_view", BI.MultiTreePopup);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.MultiTreeSearchPane + * @extends BI.Pane + */ + +BI.MultiTreeSearchPane = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeSearchPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-search-pane bi-card", + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeSearchPane.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + + this.partTree = BI.createWidget({ + type: "bi.part_tree", + element: this, + tipText: BI.i18nText("BI-No_Select"), + itemsCreator: function (op, callback) { + op.keyword = opts.keywordGetter(); + opts.itemsCreator(op, callback); + }, + value: opts.value + }); + + this.partTree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.partTree.on(BI.TreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreeSearchPane.EVENT_CHANGE); + }); + }, + + hasChecked: function () { + return this.partTree.hasChecked(); + }, + + setValue: function (v) { + this.setSelectedValue(v.value); + }, + + setSelectedValue: function (v) { + v || (v = {}); + this.partTree.setSelectedValue(v); + }, + + getValue: function () { + return this.partTree.getValue(); + }, + + empty: function () { + this.partTree.empty(); + }, + + populate: function (op) { + this.partTree.stroke.apply(this.partTree, arguments); + } +}); + +BI.MultiTreeSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.MultiTreeSearchPane.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.MultiTreeSearchPane.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + +BI.shortcut("bi.multi_tree_search_pane", BI.MultiTreeSearchPane);/** + * 查看已选按钮 + * Created by guy on 15/11/3. + * @class BI.MultiTreeCheckSelectedButton + * @extends BI.Single + */ +BI.MultiTreeCheckSelectedButton = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeCheckSelectedButton.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-check-selected-button", + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.MultiTreeCheckSelectedButton.superclass._init.apply(this, arguments); + var self = this; + this.indicator = BI.createWidget({ + type: "bi.icon_button", + cls: "check-font trigger-check-selected icon-size-12", + width: 15, + height: 15, + stopPropagation: true + }); + + this.checkSelected = BI.createWidget({ + type: "bi.text_button", + cls: "trigger-check-selected", + invisible: true, + hgap: 4, + text: BI.i18nText("BI-Check_Selected"), + textAlign: "center", + textHeight: 15 + }); + this.checkSelected.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.checkSelected.on(BI.TextButton.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiSelectCheckSelectedButton.EVENT_CHANGE, arguments); + }); + + BI.createWidget({ + type: "bi.horizontal", + element: this, + items: [this.indicator, this.checkSelected] + }); + + this.element.hover(function () { + self.indicator.setVisible(false); + self.checkSelected.setVisible(true); + }, function () { + self.indicator.setVisible(true); + self.checkSelected.setVisible(false); + }); + this.setVisible(false); + }, + + setValue: function (v) { + v || (v = {}); + this.setVisible(BI.size(v.value) > 0); + } +}); + +BI.MultiTreeCheckSelectedButton.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.multi_tree_check_selected_button", BI.MultiTreeCheckSelectedButton);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.MultiTreeSearcher + * @extends Widget + */ +BI.MultiTreeSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.MultiTreeSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-tree-searcher", + itemsCreator: BI.emptyFn, + valueFormatter: function (v) { + return v; + }, + popup: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.MultiTreeSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.multi_select_editor", + height: o.height, + el: { + type: "bi.simple_state_editor", + height: o.height + } + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback({ + keyword: self.editor.getValue() + }); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_tree_search_pane", + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + op.keyword = self.editor.getValue(); + o.itemsCreator(op, callback); + }, + value: o.value + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.MultiTreeSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.MultiTreeSearcher.EVENT_CHANGE, arguments); + }); + if (BI.isNotNull(o.value)) { + this.setState(o.value); + } + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setState: function (ob) { + var o = this.options; + ob || (ob = {}); + ob.value || (ob.value = {}); + var count = 0; + if (BI.isNumber(ob)) { + this.editor.setState(ob); + } else if (BI.size(ob.value) === 0) { + this.editor.setState(BI.Selection.None); + } else { + var text = ""; + BI.each(ob.value, function (name, children) { + var childNodes = getChildrenNode(children); + text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + "; "; + if (childNodes === "") { + count++; + } + }); + + if (count > 20) { + this.editor.setState(BI.Selection.Multi); + } else { + this.editor.setState(text); + } + } + + function getChildrenNode (ob) { + var text = ""; + var index = 0, size = BI.size(ob); + BI.each(ob, function (name, children) { + index++; + var childNodes = getChildrenNode(children); + text += (o.valueFormatter(name + "") || name) + (childNodes === "" ? "" : (":" + childNodes)) + (index === size ? "" : ","); + if (childNodes === "") { + count++; + } + }); + return text; + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.MultiTreeSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.MultiTreeSearcher.EVENT_CHANGE = "EVENT_CHANGE"; +BI.MultiTreeSearcher.EVENT_START = "EVENT_START"; +BI.MultiTreeSearcher.EVENT_STOP = "EVENT_STOP"; +BI.MultiTreeSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.shortcut("bi.multi_tree_searcher", BI.MultiTreeSearcher);/** + * Created by windy on 2017/3/13. + * 数值微调器 + */ +BI.NumberEditor = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.NumberEditor.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-number-editor bi-border", + validationChecker: function () { + return true; + }, + valueFormatter: function (v) { + return v; + }, + value: 0, + allowBlank: false, + errorText: "", + step: 1 + }); + }, + + _init: function () { + BI.NumberEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + allowBlank: o.allowBlank, + value: o.valueFormatter(o.value), + validationChecker: o.validationChecker, + errorText: o.errorText + }); + this.editor.on(BI.TextEditor.EVENT_CHANGE, function () { + o.value = BI.parseFloat(this.getValue()); + self.fireEvent(BI.NumberEditor.EVENT_CHANGE); + }); + this.editor.on(BI.TextEditor.EVENT_CONFIRM, function () { + this.setValue(BI.parseFloat(this.getValue())); + self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); + }); + this.topBtn = BI.createWidget({ + type: "bi.icon_button", + forceNotSelected: true, + trigger: "lclick,", + cls: "add-up-font top-button bi-border-left bi-list-item-active3 icon-size-12" + }); + this.topBtn.on(BI.IconButton.EVENT_CHANGE, function () { + self._finetuning(o.step); + self.fireEvent(BI.NumberEditor.EVENT_CHANGE); + self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); + }); + this.bottomBtn = BI.createWidget({ + type: "bi.icon_button", + trigger: "lclick,", + forceNotSelected: true, + cls: "minus-down-font bottom-button bi-border-left bi-list-item-active3 icon-size-12" + }); + this.bottomBtn.on(BI.IconButton.EVENT_CHANGE, function () { + self._finetuning(-o.step); + self.fireEvent(BI.NumberEditor.EVENT_CHANGE); + self.fireEvent(BI.NumberEditor.EVENT_CONFIRM); + }); + BI.createWidget({ + type: "bi.htape", + element: this, + items: [this.editor, { + el: { + type: "bi.grid", + columns: 1, + rows: 2, + items: [{ + column: 0, + row: 0, + el: this.topBtn + }, { + column: 0, + row: 1, + el: this.bottomBtn + }] + }, + width: 23 + }] + }); + }, + + focus: function () { + this.editor.focus(); + }, + + // 微调 + _finetuning: function (add) { + var v = BI.parseFloat(this.getValue()); + this.setValue(v.add(add)); + }, + + setUpEnable: function (v) { + this.topBtn.setEnable(!!v); + }, + + setDownEnable: function (v) { + this.bottomBtn.setEnable(!!v); + }, + + getValue: function () { + return this.options.value; + }, + + setValue: function (v) { + var o = this.options; + o.value = v; + this.editor.setValue(o.valueFormatter(v)); + } + +}); +BI.NumberEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.NumberEditor.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.number_editor", BI.NumberEditor);// 小于号的值为:0,小于等于号的值为:1 +// closeMIn:最小值的符号,closeMax:最大值的符号 +/** + * Created by roy on 15/9/17. + * + */ +BI.NumberInterval = BI.inherit(BI.Single, { + constants: { + typeError: "typeBubble", + numberError: "numberBubble", + signalError: "signalBubble", + editorWidth: 114, + columns: 5, + width: 24, + rows: 1, + numberErrorCls: "number-error", + border: 1, + less: 0, + less_equal: 1, + numTip: "", + adjustYOffset: 2 + }, + _defaultConfig: function () { + var conf = BI.NumberInterval.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-number-interval", + height: 24, + validation: "valid", + closeMin: true + }); + }, + _init: function () { + var self = this, c = this.constants, o = this.options; + BI.NumberInterval.superclass._init.apply(this, arguments); + this.smallEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.min, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; + }, + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.smallEditorBubbleType = c.typeError; + return false; + } + return true; + }, + cls: "number-interval-small-editor bi-border-top bi-border-bottom bi-border-left" + }); + + this.smallTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true + }); + BI.createWidget({ + type: "bi.absolute", + element: this.smallEditor.element, + items: [{ + el: this.smallTip, + top: 0, + right: 5 + }] + }); + + this.bigEditor = BI.createWidget({ + type: "bi.editor", + height: o.height - 2, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + value: o.max, + level: "warning", + tipType: "warning", + quitChecker: function () { + return false; + }, + validationChecker: function (v) { + if (!BI.isNumeric(v)) { + self.bigEditorBubbleType = c.typeError; + return false; + } + return true; + }, + cls: "number-interval-big-editor bi-border-top bi-border-bottom bi-border-right" + }); + + this.bigTip = BI.createWidget({ + type: "bi.label", + text: o.numTip, + height: o.height - 2, + invisible: true + }); + BI.createWidget({ + type: "bi.absolute", + element: this.bigEditor.element, + items: [{ + el: this.bigTip, + top: 0, + right: 5 + }] + }); + + // this.smallCombo = BI.createWidget({ + // type: "bi.number_interval_combo", + // cls: "number-interval-small-combo", + // height: o.height, + // value: o.closemin ? 1 : 0, + // offsetStyle: "left" + // }); + // + // this.bigCombo = BI.createWidget({ + // type: "bi.number_interval_combo", + // cls: "number-interval-big-combo", + // height: o.height, + // value: o.closemax ? 1 : 0, + // offsetStyle: "left" + // }); + this.smallCombo = BI.createWidget({ + type: "bi.icon_combo", + cls: "number-interval-small-combo bi-border", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconCls: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconCls: "less-equal-font" + }] + }); + if (o.closeMin === true) { + this.smallCombo.setValue(1); + } else { + this.smallCombo.setValue(0); + } + this.bigCombo = BI.createWidget({ + type: "bi.icon_combo", + cls: "number-interval-big-combo bi-border", + height: o.height - 2, + items: [{ + text: "(" + BI.i18nText("BI-Less_Than") + ")", + iconCls: "less-font", + value: 0 + }, { + text: "(" + BI.i18nText("BI-Less_And_Equal") + ")", + value: 1, + iconCls: "less-equal-font" + }] + }); + if (o.closeMax === true) { + this.bigCombo.setValue(1); + } else { + this.bigCombo.setValue(0); + } + this.label = BI.createWidget({ + type: "bi.label", + text: BI.i18nText("BI-Basic_Value"), + textHeight: o.height - c.border * 2, + width: c.width - c.border * 2, + height: o.height - c.border * 2, + level: "warning", + tipType: "warning" + }); + this.left = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.smallEditor + }, { + el: self.smallCombo, + width: c.width - c.border * 2 + }] + + }); + this.right = BI.createWidget({ + type: "bi.htape", + items: [{ + el: self.bigCombo, + width: c.width - c.border * 2 + }, { + el: self.bigEditor, + // BI-23883 间距考虑边框 + lgap: 1 + }] + }); + + + BI.createWidget({ + element: self, + type: "bi.center", + hgap: 15, + height: o.height, + items: [ + { + type: "bi.absolute", + items: [{ + el: self.left, + left: -15, + right: 0, + top: 0, + bottom: 0 + }] + }, { + type: "bi.absolute", + items: [{ + el: self.right, + left: 0, + right: -15, + top: 0, + bottom: 0 + }] + } + ] + }); + + BI.createWidget({ + element: self, + type: "bi.horizontal_auto", + items: [ + self.label + ] + }); + + + self._setValidEvent(self.bigEditor, c.bigEditor); + self._setValidEvent(self.smallEditor, c.smallEditor); + self._setErrorEvent(self.bigEditor, c.bigEditor); + self._setErrorEvent(self.smallEditor, c.smallEditor); + self._setBlurEvent(self.bigEditor); + self._setBlurEvent(self.smallEditor); + self._setFocusEvent(self.bigEditor); + self._setFocusEvent(self.smallEditor); + self._setComboValueChangedEvent(self.bigCombo); + self._setComboValueChangedEvent(self.smallCombo); + self._setEditorValueChangedEvent(self.bigEditor); + self._setEditorValueChangedEvent(self.smallEditor); + }, + + _checkValidation: function () { + var self = this, c = this.constants, o = this.options; + self._setTitle(""); + BI.Bubbles.hide(c.typeError); + BI.Bubbles.hide(c.numberError); + BI.Bubbles.hide(c.signalError); + if (!self.smallEditor.isValid() || !self.bigEditor.isValid()) { + self.element.removeClass("number-error"); + o.validation = "invalid"; + return c.typeError; + } + if (BI.isEmptyString(self.smallEditor.getValue()) || BI.isEmptyString(self.bigEditor.getValue())) { + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + } + var smallValue = parseFloat(self.smallEditor.getValue()), bigValue = parseFloat(self.bigEditor.getValue()), + bigComboValue = self.bigCombo.getValue(), smallComboValue = self.smallCombo.getValue(); + if (bigComboValue[0] === c.less_equal && smallComboValue[0] === c.less_equal) { + if (smallValue > bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.numberError; + } + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + + } + if (smallValue > bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.numberError; + } else if (smallValue === bigValue) { + self.element.addClass("number-error"); + o.validation = "invalid"; + return c.signalError; + } + self.element.removeClass("number-error"); + o.validation = "valid"; + return ""; + + + + + + }, + + _setTitle: function (v) { + var self = this; + self.bigEditor.setTitle(v); + self.smallEditor.setTitle(v); + self.label.setTitle(v); + }, + + _setFocusEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_FOCUS, function () { + self._setTitle(""); + switch (self._checkValidation()) { + case c.typeError: + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + break; + default : + return; + } + + }); + }, + _setBlurEvent: function (w) { + var c = this.constants, self = this; + w.on(BI.Editor.EVENT_BLUR, function () { + BI.Bubbles.hide(c.typeError); + BI.Bubbles.hide(c.numberError); + BI.Bubbles.hide(c.signalError); + switch (self._checkValidation()) { + case c.typeError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); + break; + case c.numberError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); + break; + case c.signalError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); + break; + default: + self._setTitle(""); + } + }); + }, + + _setErrorEvent: function (w) { + var c = this.constants, self = this; + w.on(BI.Editor.EVENT_ERROR, function () { + self._checkValidation(); + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + }); + }, + + + _setValidEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_VALID, function () { + switch (self._checkValidation()) { + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + break; + default: + self.fireEvent(BI.NumberInterval.EVENT_VALID); + } + }); + }, + + + _setEditorValueChangedEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.Editor.EVENT_CHANGE, function () { + switch (self._checkValidation()) { + case c.typeError: + BI.Bubbles.show(c.typeError, BI.i18nText("BI-Numerical_Interval_Input_Data"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + break; + case c.numberError: + BI.Bubbles.show(c.numberError, BI.i18nText("BI-Numerical_Interval_Number_Value"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + break; + case c.signalError: + BI.Bubbles.show(c.signalError, BI.i18nText("BI-Numerical_Interval_Signal_Value"), self, { + offsetStyle: "left", + adjustYOffset: c.adjustYOffset + }); + break; + default : + break; + } + self.fireEvent(BI.NumberInterval.EVENT_CHANGE); + }); + w.on(BI.Editor.EVENT_CONFIRM, function () { + self.fireEvent(BI.NumberInterval.EVENT_CONFIRM); + }); + }, + + _setComboValueChangedEvent: function (w) { + var self = this, c = this.constants; + w.on(BI.IconCombo.EVENT_CHANGE, function () { + switch (self._checkValidation()) { + case c.typeError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Input_Data")); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + break; + case c.numberError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Number_Value")); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + break; + case c.signalError: + self._setTitle(BI.i18nText("BI-Numerical_Interval_Signal_Value")); + self.fireEvent(BI.NumberInterval.EVENT_ERROR); + break; + default : + self.fireEvent(BI.NumberInterval.EVENT_CHANGE); + self.fireEvent(BI.NumberInterval.EVENT_CONFIRM); + self.fireEvent(BI.NumberInterval.EVENT_VALID); + } + }); + }, + + isStateValid: function () { + return this.options.validation === "valid"; + }, + + setMinEnable: function (b) { + this.smallEditor.setEnable(b); + }, + + setCloseMinEnable: function (b) { + this.smallCombo.setEnable(b); + }, + + setMaxEnable: function (b) { + this.bigEditor.setEnable(b); + }, + + setCloseMaxEnable: function (b) { + this.bigCombo.setEnable(b); + }, + + showNumTip: function () { + this.smallTip.setVisible(true); + this.bigTip.setVisible(true); + }, + + hideNumTip: function () { + this.smallTip.setVisible(false); + this.bigTip.setVisible(false); + }, + + setNumTip: function (numTip) { + this.smallTip.setText(numTip); + this.bigTip.setText(numTip); + }, + + getNumTip: function () { + return this.smallTip.getText(); + }, + + setValue: function (data) { + data = data || {}; + var self = this, combo_value; + if (BI.isNumeric(data.min) || BI.isEmptyString(data.min)) { + self.smallEditor.setValue(data.min); + } + + if (!BI.isNotNull(data.min)) { + self.smallEditor.setValue(""); + } + + if (BI.isNumeric(data.max) || BI.isEmptyString(data.max)) { + self.bigEditor.setValue(data.max); + } + + if (!BI.isNotNull(data.max)) { + self.bigEditor.setValue(""); + } + + if (!BI.isNull(data.closeMin)) { + if (data.closeMin === true) { + combo_value = 1; + } else { + combo_value = 0; + } + self.smallCombo.setValue(combo_value); + } + + if (!BI.isNull(data.closeMax)) { + if (data.closeMax === true) { + combo_value = 1; + } else { + combo_value = 0; + } + self.bigCombo.setValue(combo_value); + } + }, + + + getValue: function () { + var self = this, value = {}, minComboValue = self.smallCombo.getValue(), maxComboValue = self.bigCombo.getValue(); + value.min = self.smallEditor.getValue(); + value.max = self.bigEditor.getValue(); + if (minComboValue[0] === 0) { + value.closeMin = false; + } else { + value.closeMin = true; + } + + if (maxComboValue[0] === 0) { + value.closeMax = false; + } else { + value.closeMax = true; + } + return value; + } +}); +BI.NumberInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.NumberInterval.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.NumberInterval.EVENT_VALID = "EVENT_VALID"; +BI.NumberInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.shortcut("bi.number_interval", BI.NumberInterval);/** + * + * 表格 + * + * Created by GUY on 2015/9/22. + * @class BI.PageTableCell + * @extends BI.Single + */ +BI.PageTableCell = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.PageTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table-cell", + text: "", + title: "" + }); + }, + + _init: function () { + BI.PageTableCell.superclass._init.apply(this, arguments); + var label = BI.createWidget({ + type: "bi.label", + element: this, + textAlign: "left", + whiteSpace: "nowrap", + height: this.options.height, + text: this.options.text, + title: this.options.title, + value: this.options.value, + lgap: 5, + rgap: 5 + }); + + if (BI.isNotNull(this.options.styles) && BI.isObject(this.options.styles)) { + this.element.css(this.options.styles); + } + } +}); + +BI.shortcut("bi.page_table_cell", BI.PageTableCell);/** + * 分页表格 + * + * Created by GUY on 2016/2/15. + * @class BI.PageTable + * @extends BI.Widget + */ +BI.PageTable = BI.inherit(BI.Widget, { + + _const: { + scrollWidth: 18, + minScrollWidth: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.PageTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-page-table", + el: { + type: "bi.sequence_table" + }, + pager: { + horizontal: { + pages: false, // 总页数 + curr: 1, // 初始化当前页, pages为数字时可用 + + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn, + firstPage: 1, + lastPage: BI.emptyFn + }, + vertical: { + pages: false, // 总页数 + curr: 1, // 初始化当前页, pages为数字时可用 + + hasPrev: BI.emptyFn, + hasNext: BI.emptyFn, + firstPage: 1, + lastPage: BI.emptyFn + } + }, + + itemsCreator: BI.emptyFn, + + isNeedFreeze: false, // 是否需要冻结单元格 + freezeCols: [], // 冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false, // 是否需要合并单元格 + mergeCols: [], // 合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], // 二维数组 + + // 交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.PageTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.hCurr = 1; + this.vCurr = 1; + + this.table = BI.createWidget(o.el, { + type: "bi.sequence_table", + width: o.width, + height: o.height && o.height - 30, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + // 交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.pager = BI.createWidget(o.pager, { + type: "bi.direction_pager", + height: 30 + }); + this.pager.on(BI.Pager.EVENT_CHANGE, function () { + var vpage = this.getVPage && this.getVPage(); + if (BI.isNull(vpage)) { + vpage = this.getCurrentPage(); + } + var hpage = this.getHPage && this.getHPage(); + o.itemsCreator({ + vpage: vpage, + hpage: hpage + }, function (items, header, crossItems, crossHeader) { + self.table.setVPage ? self.table.setVPage(vpage) : self.table.setValue(vpage); + self.table.setHPage && self.table.setHPage(hpage); + self.populate.apply(self, arguments); + }); + }); + + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.table, + left: 0, + top: 0 + }, { + el: this.pager, + left: 0, + right: 0, + bottom: 0 + }] + }); + }, + + setHPage: function (v) { + this.hCurr = v; + this.pager.setHPage && this.pager.setHPage(v); + this.table.setHPage && this.table.setHPage(v); + }, + + setVPage: function (v) { + this.vCurr = v; + this.pager.setVPage && this.pager.setVPage(v); + this.table.setVPage && this.table.setVPage(v); + }, + + getHPage: function () { + var hpage = this.pager.getHPage && this.pager.getHPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + hpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(hpage)) { + return hpage; + } + return this.hpage; + }, + + getVPage: function () { + var vpage = this.pager.getVPage && this.pager.getVPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + vpage = this.pager.getCurrentPage && this.pager.getCurrentPage(); + if (BI.isNotNull(vpage)) { + return vpage; + } + return this.vpage; + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + var showPager = false; + if (this.pager.alwaysShowPager) { + showPager = true; + } else if (this.pager.hasHNext && this.pager.hasHNext()) { + showPager = true; + } else if (this.pager.hasHPrev && this.pager.hasHPrev()) { + showPager = true; + } else if (this.pager.hasVNext && this.pager.hasVNext()) { + showPager = true; + } else if (this.pager.hasVPrev && this.pager.hasVPrev()) { + showPager = true; + } else if (this.pager.hasNext && this.pager.hasNext()) { + showPager = true; + } else if (this.pager.hasPrev && this.pager.hasPrev()) { + showPager = true; + } + this.table.setHeight(height - (showPager ? 30 : 0)); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + restore: function () { + this.table.restore(); + }, + + attr: function () { + BI.PageTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function () { + this.pager.populate(); + this.table.populate.apply(this.table, arguments); + }, + + destroy: function () { + this.table.destroy(); + this.pager && this.pager.destroy(); + BI.PageTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut("bi.page_table", BI.PageTable);/** + * 预览表列 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableCell + * @extends BI.Widget + */ +BI.PreviewTableCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: o.textAlign || "left", + whiteSpace: o.whiteSpace || "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value, + lgap: o.lgap, + rgap: o.rgap, + hgap: o.hgap || 5 + }); + } +}); +BI.shortcut("bi.preview_table_cell", BI.PreviewTableCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTableHeaderCell + * @extends BI.Widget + */ +BI.PreviewTableHeaderCell = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTableHeaderCell.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table-header-cell", + text: "" + }); + }, + + _init: function () { + BI.PreviewTableHeaderCell.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + BI.createWidget({ + type: "bi.label", + element: this, + textAlign: o.textAlign || "left", + whiteSpace: o.whiteSpace || "normal", + height: this.options.height, + text: this.options.text, + value: this.options.value, + lgap: o.lgap, + rgap: o.rgap, + hgap: o.hgap || 5 + }); + } +}); +BI.shortcut("bi.preview_table_header_cell", BI.PreviewTableHeaderCell);/** + * 预览表 + * + * Created by GUY on 2015/12/25. + * @class BI.PreviewTable + * @extends BI.Widget + */ +BI.PreviewTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.PreviewTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-preview-table", + isNeedFreeze: false, + freezeCols: [], + rowSize: null, + columnSize: [], + headerRowSize: 30, + header: [], + items: [] + }); + }, + + _init: function () { + BI.PreviewTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + isNeedResize: false, + + isResizeAdapt: false, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + rowSize: o.rowSize, + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + + header: BI.map(o.header, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_header_cell" + }, item); + }); + }), + items: BI.map(o.items, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_cell" + }, item); + }); + }) + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._adjustColumns(); + }); + this._adjustColumns(); + }, + + // 是否有自适应调节的列,即列宽为"" + _hasAdaptCol: function (columnSize) { + return BI.any(columnSize, function (i, size) { + return size === ""; + }); + }, + + _isPercentage: function (columnSize) { + return columnSize[0] <= 1; + }, + + _adjustColumns: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + // 如果存在百分比的情况 + if (this._isPercentage(o.columnSize)) { + if (this._hasAdaptCol(o.columnSize)) { + var findCols = [], remain = 0; + BI.each(o.columnSize, function (i, size) { + if (size === "") { + findCols.push(i); + } else { + remain += size; + } + }); + remain = 1 - remain; + var average = remain / findCols.length; + BI.each(findCols, function (i, col) { + o.columnSize[col] = average; + }); + } + var isRight = BI.first(o.freezeCols) !== 0; + var freezeSize = [], notFreezeSize = []; + BI.each(o.columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + freezeSize.push(size); + } else { + notFreezeSize.push(size); + } + }); + var sumFreezeSize = BI.sum(freezeSize), sumNotFreezeSize = BI.sum(notFreezeSize); + BI.each(freezeSize, function (i, size) { + freezeSize[i] = size / sumFreezeSize; + }); + BI.each(notFreezeSize, function (i, size) { + notFreezeSize[i] = size / sumNotFreezeSize; + }); + this.table.setRegionColumnSize(isRight ? ["fill", sumFreezeSize] : [sumFreezeSize, "fill"]); + this.table.setColumnSize(isRight ? (notFreezeSize.concat(freezeSize)) : (freezeSize.concat(notFreezeSize))); + } + } else { + // 如果存在自适应宽度的列或者是百分比计算的列,需要将整个表宽设为100% + if (this._hasAdaptCol(o.columnSize) || this._isPercentage(o.columnSize)) { + this.table.setRegionColumnSize(["100%"]); + } + } + }, + + setColumnSize: function (columnSize) { + return this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + return this.table.setHeaderColumnSize(columnSize); + }, + + setRegionColumnSize: function (columnSize) { + return this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + return this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + return this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + return this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + populate: function (items, header) { + if (items) { + items = BI.map(items, function (i, items) { + return BI.map(items, function (j, item) { return BI.extend({ type: "bi.preview_table_cell" }, item); }); }); } - if (header) { - header = BI.map(header, function (i, items) { - return BI.map(items, function (j, item) { - return BI.extend({ - type: "bi.preview_table_header_cell" - }, item); + if (header) { + header = BI.map(header, function (i, items) { + return BI.map(items, function (j, item) { + return BI.extend({ + type: "bi.preview_table_header_cell" + }, item); + }); + }); + } + this.table.populate(items, header); + this._adjustColumns(); + } +}); +BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; +BI.shortcut("bi.preview_table", BI.PreviewTable);/** + * 季度下拉框 + * + * Created by GUY on 2015/8/28. + * @class BI.QuarterCombo + * @extends BI.Widget + */ +BI.QuarterCombo = BI.inherit(BI.Widget, { + _defaultConfig: function () { + return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-quarter-combo", + behaviors: {}, + height: 25 + }); + }, + _init: function () { + BI.QuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = ""; + this.trigger = BI.createWidget({ + type: "bi.quarter_trigger", + value: o.value + }); + + this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () { + self.storeValue = this.getKey(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () { + if (self.combo.isViewVisible()) { + return; + } + if (this.getKey() && this.getKey() !== self.storeValue) { + self.setValue(this.getKey()); + } else if (!this.getKey()) { + self.setValue(); + } + self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); + }); + this.popup = BI.createWidget({ + type: "bi.quarter_popup", + behaviors: o.behaviors, + value: o.value + }); + + this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + el: this.popup + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + }, + + setValue: function (v) { + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + if (BI.isNull(this.popup)) { + return this.options.value || ""; + } else { + return this.popup.getValue() || ""; + } + } +}); + +BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.quarter_combo", BI.QuarterCombo);/** + * 季度展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.QuarterPopup + * @extends BI.Trigger + */ +BI.QuarterPopup = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-quarter-popup", + behaviors: {} + }); + }, + + _init: function () { + BI.QuarterPopup.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var items = [{ + text: Date._QN[1], + value: 1 + }, { + text: Date._QN[2], + value: 2 + }, { + text: Date._QN[3], + value: 3 + }, { + text: Date._QN[4], + value: 4 + }]; + items = BI.map(items, function (j, item) { + return BI.extend(item, { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "left", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 25 + }); + }); + + this.quarter = BI.createWidget({ + type: "bi.button_group", + element: this, + behaviors: o.behaviors, + items: BI.createItems(items, {}), + layouts: [{ + type: "bi.vertical" + }], + value: o.value + }); + + this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + if (type === BI.Events.CLICK) { + self.fireEvent(BI.MonthPopup.EVENT_CHANGE); + } + }); + }, + + getValue: function () { + return this.quarter.getValue()[0]; + }, + + setValue: function (v) { + this.quarter.setValue([v]); + } +}); +BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/** + * 季度trigger + * + * Created by GUY on 2015/8/21. + * @class BI.QuarterTrigger + * @extends BI.Trigger + */ +BI.QuarterTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2, + textWidth: 40 + }, + + _defaultConfig: function () { + return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-quarter-trigger bi-border", + height: 24 + }); + }, + _init: function () { + BI.QuarterTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true, + errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + self.editor.setTitle(value); + } + self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.QuarterTrigger.EVENT_STOP); + }); + + BI.createWidget({ + element: this, + type: "bi.htape", + items: [ + { + el: this.editor + }, { + el: { + type: "bi.text_button", + baseCls: "bi-trigger-quarter-text", + text: BI.i18nText("BI-Multi_Date_Quarter"), + width: c.textWidth + }, + width: c.textWidth + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height + }, + width: o.height + } + ] + }); + this.setValue(o.value); + }, + + setValue: function (v) { + v = v || ""; + this.editor.setState(v); + this.editor.setValue(v); + this.editor.setTitle(v); + }, + + getKey: function () { + return this.editor.getValue(); + } +}); +BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.QuarterTrigger.EVENT_START = "EVENT_START"; +BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP"; +BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/** + * 自适应宽度的表格 + * + * Created by GUY on 2016/2/3. + * @class BI.ResponisveTable + * @extends BI.Widget + */ +BI.ResponisveTable = BI.inherit(BI.Widget, { + + _const: { + perColumnSize: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-responsive-table", + isNeedFreeze: false, // 是否需要冻结单元格 + freezeCols: [], // 冻结的列号,从0开始,isNeedFreeze为true时生效 + logic: { // 冻结的页面布局逻辑 + dynamic: false + }, + + isNeedMerge: false, // 是否需要合并单元格 + mergeCols: [], // 合并的单元格列号 + mergeRule: function (row1, row2) { // 合并规则, 默认相等时合并 + return BI.isEqual(row1, row2); + }, + + columnSize: [], + headerRowSize: 25, + footerRowSize: 25, + rowSize: 25, + + regionColumnSize: false, + + header: [], + footer: false, + items: [], // 二维数组 + + // 交叉表头 + crossHeader: [], + crossItems: [] + }); + }, + + _init: function () { + BI.ResponisveTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.table = BI.createWidget({ + type: "bi.table_view", + element: this, + logic: o.logic, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + headerRowSize: o.headerRowSize, + footerRowSize: o.footerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + header: o.header, + footer: o.footer, + items: o.items, + // 交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { + // important:在冻结并自适应列宽的情况下要随时变更表头宽度 + if (o.isNeedResize === true && self._isAdaptiveColumn()) { + self._resizeHeader(); + } + self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + + this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { + self._resizeBody(); + self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { + self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + self._resizeRegion(); + self._resizeHeader(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + }, + + _initRegionSize: function () { + var o = this.options; + if (o.isNeedFreeze === true) { + var regionColumnSize = this.table.getRegionColumnSize(); + var maxWidth = this.table.element.width(); + if (!regionColumnSize[0] || (regionColumnSize[0] === "fill") || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { + var freezeCols = o.freezeCols; + if (freezeCols.length === 0) { + this.table.setRegionColumnSize([0, "fill"]); + } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } else { + this.table.setRegionColumnSize(["fill", 0]); + } + } + } + }, + + _getBlockSize: function () { + var o = this.options; + var columnSize = this.table.getCalculateColumnSize(); + if (o.isNeedFreeze === true) { + var columnSizeLeft = [], columnSizeRight = []; + BI.each(columnSize, function (i, size) { + if (o.freezeCols.contains(i)) { + columnSizeLeft.push(size); + } else { + columnSizeRight.push(size); + } + }); + // 因为有边框,所以加上数组长度的参数调整 + var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, + sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; + return { + sumLeft: sumLeft, + sumRight: sumRight, + left: columnSizeLeft, + right: columnSizeRight + }; + } + return { + size: columnSize, + sum: BI.sum(columnSize) + columnSize.length + }; + }, + + _isAdaptiveColumn: function (columnSize) { + return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); + }, + + _resizeHeader: function () { + var self = this, o = this.options; + if (o.isNeedFreeze === true) { + // 若是当前处于自适应调节阶段 + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.table.setHeaderColumnSize(columnSize); + } else { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + var columnSizeLeft = block.left, columnSizeRight = block.right; + columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; + columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; + + var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); + newLeft[newLeft.length - 1] = ""; + newRight[newRight.length - 1] = ""; + this.table.setColumnSize(newLeft.concat(newRight)); + + block = self._getBlockSize(); + if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { + columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]; + } + if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { + columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]; + } + + self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); + } + } else { + if (!this._isAdaptiveColumn()) { + var regionColumnSize = this.table.getClientRegionColumnSize(); + var block = this._getBlockSize(); + var sum = block.sum; + var size = block.size; + + size[size.length - 1] += regionColumnSize[0] - sum; + + var newSize = BI.clone(size); + newSize[newSize.length - 1] = ""; + this.table.setColumnSize(newSize); + block = this._getBlockSize(); + + if (size[size.length - 1] < block.size[block.size.length - 1]) { + size[size.length - 1] = block.size[block.size.length - 1]; + } + this.table.setColumnSize(size); + } + } + }, + + _resizeBody: function () { + if (this._isAdaptiveColumn()) { + var columnSize = this.table.getCalculateColumnSize(); + this.setColumnSize(columnSize); + } + }, + + _adjustRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var block = this._getBlockSize(); + var sumLeft = block.sumLeft, sumRight = block.sumRight; + if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { + this.table.setRegionColumnSize([sumLeft, "fill"]); + } + this._resizeRegion(); + } + }, + + _resizeRegion: function () { + var o = this.options; + var regionColumnSize = this.table.getCalculateRegionColumnSize(); + if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { + var maxWidth = this.table.element.width(); + if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { + var freezeCols = o.freezeCols; + var size = maxWidth / 3; + if (freezeCols.length > o.columnSize.length / 2) { + size = maxWidth * 2 / 3; + } + this.table.setRegionColumnSize([size, "fill"]); + } + } + }, + + + resize: function () { + this.table.resize(); + this._resizeRegion(); + this._resizeHeader(); + }, + + setColumnSize: function (columnSize) { + this.table.setColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + getCalculateColumnSize: function () { + return this.table.getCalculateColumnSize(); + }, + + setHeaderColumnSize: function (columnSize) { + this.table.setHeaderColumnSize(columnSize); + this._adjustRegion(); + this._resizeHeader(); + }, + + setRegionColumnSize: function (columnSize) { + this.table.setRegionColumnSize(columnSize); + this._resizeHeader(); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + getCalculateRegionColumnSize: function () { + return this.table.getCalculateRegionColumnSize(); + }, + + getCalculateRegionRowSize: function () { + return this.table.getCalculateRegionRowSize(); + }, + + getClientRegionColumnSize: function () { + return this.table.getClientRegionColumnSize(); + }, + + getScrollRegionColumnSize: function () { + return this.table.getScrollRegionColumnSize(); + }, + + getScrollRegionRowSize: function () { + return this.table.getScrollRegionRowSize(); + }, + + hasVerticalScroll: function () { + return this.table.hasVerticalScroll(); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + getLeftHorizontalScroll: function () { + return this.table.getLeftHorizontalScroll(); + }, + + getRightHorizontalScroll: function () { + return this.table.getRightHorizontalScroll(); + }, + + getColumns: function () { + return this.table.getColumns(); + }, + + attr: function () { + BI.ResponisveTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + }, + + populate: function (items) { + var self = this, o = this.options; + this.table.populate.apply(this.table, arguments); + if (o.isNeedFreeze === true) { + BI.nextTick(function () { + self._initRegionSize(); + self.table.resize(); + self._resizeHeader(); + }); + } + } +}); +BI.shortcut("bi.responsive_table", BI.ResponisveTable);/** + * + * @class BI.SearchMultiTextValueCombo + * @extends BI.Single + */ +BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.SearchMultiTextValueCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-combo bi-search-multi-text-value-combo", + height: 24, + items: [] + }); + }, + + _init: function () { + BI.SearchMultiTextValueCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + var assertShowValue = function () { + BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); + self._updateAllValue(); + self._checkError(); + self.trigger.getSearcher().setState(self.storeValue); + self.trigger.getCounter().setButtonChecked(self.storeValue); + }; + this.storeValue = BI.deepClone(o.value || {}); + this._updateAllValue(); + + this._assertValue(this.storeValue); + this._checkError(); + + // 标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.search_multi_select_trigger", + text: o.text, + height: o.height, + // adapter: this.popup, + masker: { + offset: { + left: 0, + top: 0, + right: 0, + bottom: 26 + } + }, + allValueGetter: function () { + return self.allValue; + }, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + self._itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + // 预防trigger内部把当前的storeValue改掉 + self.trigger.setValue(BI.deepClone(self.getValue())); + } + callback.apply(self, arguments); + }); + }, + value: this.storeValue + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { + self._setStartValue(""); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { + self._setStartValue(""); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { + if (this.getSearcher().hasMatched()) { + var keyword = this.getSearcher().getKeyword(); + self._join({ + type: BI.Selection.Multi, + value: [keyword] + }, function () { + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self._populate(); + self._setStartValue(""); + }); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(""); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { + if (obj instanceof BI.MultiSelectBar) { + self._joinAll(this.getValue(), function () { + assertShowValue(); + }); + } else { + self._join(this.getValue(), function () { + assertShowValue(); + }); + } + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { + this.getCounter().setValue(self.storeValue); + }); + this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: "bi.search_multi_select_popup_view", + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.MultiSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + }); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, + action: function () { + self._defaultState(); + } + }, { + eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, + action: function () { + self.setValue(); + self._defaultState(); + } + }], + itemsCreator: BI.bind(self._itemsCreator, this), + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getCounter().adjustView(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + value: o.value, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + } + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self.element.removeClass("combo-show"); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.element.removeClass("combo-show").addClass("combo-show"); + this.setValue(self.storeValue); + BI.nextTick(function () { + self._populate(); + }); + }); + // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + // important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "multi-select-trigger-icon-button" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + self.trigger.getCounter().hideView(); + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }); + this._checkError(); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) { + var o = this.options; + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + BI.remove(val.value, function (idx, value) { + return !BI.contains(BI.map(o.items, "value"), value); + }); + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + this._itemsCreator({ + type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.map(ob.items, "value"); + digest(values); + }); + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); + } + }); + self._adjust(callback); + } + }, + + _joinAll: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this.requesting = true; + this._itemsCreator({ + type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA, + keywords: [this.trigger.getKey()] + }, function (ob) { + var items = BI.map(ob.items, "value"); + if (self.storeValue.type === res.type) { + var change = false; + var map = self._makeMap(self.storeValue.value); + BI.each(items, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (self.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + var selectedMap = self._makeMap(self.storeValue.value); + var notSelectedMap = self._makeMap(res.value); + var newItems = []; + BI.each(items, function (i, item) { + if (BI.isNotNull(selectedMap[items[i]])) { + delete selectedMap[items[i]]; + } + if (BI.isNull(notSelectedMap[items[i]])) { + newItems.push(item); + } + }); + self.storeValue.value = newItems.concat(BI.values(selectedMap)); + self._adjust(callback); + }); + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + this._itemsCreator({ + type: BI.SearchMultiTextValueCombo.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + + } + + function adjust () { + if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.Multi, + value: [] + }; + } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { + self.storeValue = { + type: BI.Selection.All, + value: [] + }; + } + self._updateAllValue(); + self._checkError(); + if (self.wants2Quit === true) { + self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _join: function (res, callback) { + var self = this, o = this.options; + this._assertValue(res); + this._assertValue(this.storeValue); + if (this.storeValue.type === res.type) { + var map = this._makeMap(this.storeValue.value); + BI.each(res.value, function (i, v) { + if (!map[v]) { + self.storeValue.value.push(v); + map[v] = v; + } + }); + var change = false; + BI.each(res.assist, function (i, v) { + if (BI.isNotNull(map[v])) { + change = true; + delete map[v]; + } + }); + change && (this.storeValue.value = BI.values(map)); + self._adjust(callback); + return; + } + this._joinAll(res, callback); + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + _getItemsByTimes: function (items, times) { + var res = []; + for (var i = (times - 1) * 10; items[i] && i < times * 10; i++) { + res.push(items[i]); + } + return res; + }, + + _hasNextByTimes: function (items, times) { + return times * 10 < items.length; + }, + + _itemsCreator: function (options, callback) { + var self = this, o = this.options; + var items = o.items; + var keywords = (options.keywords || []).slice(); + if (options.keyword) { + keywords.push(options.keyword); + } + BI.each(keywords, function (i, kw) { + var search = BI.Func.getSearchResult(items, kw); + items = search.match.concat(search.find); + }); + if (options.selectedValues) {// 过滤 + var filter = BI.makeObject(options.selectedValues, true); + items = BI.filter(items, function (i, ob) { + return !filter[ob.value]; + }); + } + if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) { + callback({ + items: items + }); + return; + } + if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { + callback({count: items.length}); + return; + } + callback({ + items: self._getItemsByTimes(items, options.times), + hasNext: self._hasNextByTimes(items, options.times) + }); + }, + + _checkError: function () { + var v = this.storeValue.value || []; + if(BI.isNotEmptyArray(v)) { + v = BI.isArray(v) ? v : [v]; + var result = BI.find(this.allValue, function (idx, value) { + return !BI.contains(v, value); + }); + if (BI.isNull(result)) { + this.element.removeClass("combo-error"); + } else { + this.element.addClass("combo-error"); + } + } else { + v.length === this.allValue.length ? this.element.removeClass("combo-error") : this.element.addClass("combo-error"); + } + }, + + _updateAllValue: function () { + this.storeValue = this.storeValue || {}; + this.allValue = BI.deepClone(this.storeValue.value || []); + }, + + setValue: function (v) { + this.storeValue = BI.deepClone(v || {}); + this._updateAllValue(); + this._assertValue(this.storeValue); + this.combo.setValue(this.storeValue); + this._checkError(); + }, + + getValue: function () { + return BI.deepClone(this.storeValue); + }, + + _populate: function () { + this._count = null; + this.combo.populate(); + }, + + populate: function (items) { + this.options.items = items; + this._populate(); + } +}); + +BI.extend(BI.SearchMultiTextValueCombo, { + REQ_GET_DATA_LENGTH: 1, + REQ_GET_ALL_DATA: -1 +}); + +BI.SearchMultiTextValueCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut("bi.search_multi_text_value_combo", BI.SearchMultiTextValueCombo);BI.SearchMultiSelectTrigger = BI.inherit(BI.Trigger, { + + constants: { + height: 14, + rgap: 4, + lgap: 4 + }, + + _defaultConfig: function () { + return BI.extend(BI.SearchMultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-trigger bi-border", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + searcher: {}, + switcher: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.SearchMultiSelectTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + if (o.height) { + this.setHeight(o.height - 2); + } + + this.searcher = BI.createWidget(o.searcher, { + type: "bi.search_multi_select_searcher", + height: o.height, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + allValueGetter: o.allValueGetter, + popup: {}, + adapter: o.adapter, + masker: o.masker, + value: o.value, + text: o.text + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () { + self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_START); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () { + self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_PAUSE); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () { + self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_SEARCHING, arguments); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () { + self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_STOP); + }); + this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () { + self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_CHANGE, arguments); + }); + this.numberCounter = BI.createWidget(o.switcher, { + type: "bi.multi_select_check_selected_switcher", + valueFormatter: o.valueFormatter, + itemsCreator: o.itemsCreator, + adapter: o.adapter, + masker: o.masker, + value: o.value + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { + self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK); + }); + this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); + }); + + var wrapNumberCounter = BI.createWidget({ + type: "bi.right_vertical_adapt", + hgap: 4, + items: [{ + el: this.numberCounter + }] + }); + + var wrapper = BI.createWidget({ + type: "bi.htape", + element: this, + items: [ + { + el: this.searcher, + width: "fill" + }, { + el: wrapNumberCounter, + width: 0 + }, { + el: BI.createWidget(), + width: 24 + }] + }); + + this.numberCounter.on(BI.Events.VIEW, function (b) { + BI.nextTick(function () {// 自动调整宽度 + wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); + wrapper.resize(); + }); + }); + + this.element.click(function (e) { + if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { + self.numberCounter.hideView(); + } + }); + }, + + getCounter: function () { + return this.numberCounter; + }, + + getSearcher: function () { + return this.searcher; + }, + + stopEditing: function () { + this.searcher.stopSearch(); + this.numberCounter.hideView(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + this.numberCounter.setAdapter(adapter); + }, + + setValue: function (ob) { + this.searcher.setValue(ob); + this.numberCounter.setValue(ob); + }, + + getKey: function () { + return this.searcher.getKey(); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); + +BI.SearchMultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; +BI.SearchMultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SearchMultiSelectTrigger.EVENT_START = "EVENT_START"; +BI.SearchMultiSelectTrigger.EVENT_STOP = "EVENT_STOP"; +BI.SearchMultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; +BI.SearchMultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; + +BI.shortcut("bi.search_multi_select_trigger", BI.SearchMultiSelectTrigger);/** + * 多选加载数据面板 + * Created by guy on 15/11/2. + * @class BI.SearchMultiSelectLoader + * @extends Widget + */ +BI.SearchMultiSelectLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SearchMultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-loader", + logic: { + dynamic: true + }, + el: { + height: 400 + }, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.SearchMultiSelectLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.storeValue = opts.value || {}; + this._assertValue(this.storeValue); + + this.button_group = BI.createWidget({ + type: "bi.select_list", + element: this, + logic: opts.logic, + el: BI.extend({ + onLoaded: opts.onLoaded, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, opts.el), + itemsCreator: function (op, callback) { + var startValue = self._startValue; + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi + ? self.storeValue.value.concat(startValue) : self.storeValue.value + })); + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && self.storeValue) { + var json = BI.map(self.storeValue.value, function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: self.storeValue.type === BI.Selection.Multi + }; + }); + if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { + var txt = opts.valueFormatter(startValue) || startValue; + json.unshift({ + text: txt, + value: startValue, + title: txt, + selected: true + }); + } + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { + BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + hasNext: function () { + return hasNext; + }, + value: this.storeValue + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.SearchMultiSelectLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.multi_select_item", + logic: this.options.logic, + height: 24, + selected: this.isAllSelected() + }); + }, + + _scrollToTop: function () { + var self = this; + BI.delay(function () { + self.button_group.element.scrollTop(0); + }, 30); + }, + + isAllSelected: function () { + return this.button_group.isAllSelected(); + }, + + _assertValue: function (val) { + val || (val = {}); + val.type || (val.type = BI.Selection.Multi); + val.value || (val.value = []); + }, + + setStartValue: function (v) { + this._startValue = v; + }, + + setValue: function (v) { + this.storeValue = v || {}; + this._assertValue(this.storeValue); + this.button_group.setValue(this.storeValue); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + arguments[0] = this._createItems(items); + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.SearchMultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.search_multi_select_loader", BI.SearchMultiSelectLoader);BI.SearchMultiSelectPopupView = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SearchMultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-popup-view", + maxWidth: "auto", + minWidth: 135, + maxHeight: 400, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.SearchMultiSelectPopupView.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.loader = BI.createWidget({ + type: "bi.search_multi_select_loader", + itemsCreator: opts.itemsCreator, + valueFormatter: opts.valueFormatter, + onLoaded: opts.onLoaded, + value: opts.value + }); + + this.popupView = BI.createWidget({ + type: "bi.multi_popup_view", + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + element: this, + buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], + el: this.loader, + value: opts.value + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { + self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CHANGE); + }); + this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { + switch (index) { + case 0: + self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR); + break; + case 1: + self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM); + break; + } + }); + }, + + isAllSelected: function () { + return this.loader.isAllSelected(); + }, + + setStartValue: function (v) { + this.loader.setStartValue(v); + }, + + setValue: function (v) { + this.popupView.setValue(v); + }, + + getValue: function () { + return this.popupView.getValue(); + }, + + populate: function (items) { + this.popupView.populate.apply(this.popupView, arguments); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.SearchMultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; +BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; + + +BI.shortcut("bi.search_multi_select_popup_view", BI.SearchMultiSelectPopupView);BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SearchMultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-searcher", + itemsCreator: BI.emptyFn, + el: {}, + popup: {}, + valueFormatter: BI.emptyFn, + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.SearchMultiSelectSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.multi_select_editor", + height: o.height, + text: o.text + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + height: o.height, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.multi_select_search_pane", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + var keyword = self.editor.getValue(); + op.keywords = [keyword]; + this.setKeyword(keyword); + o.itemsCreator(op, callback); + }, + value: o.value + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_CHANGE, arguments); + }); + this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { + var keywords = this.getKeywords(); + self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_SEARCHING, keywords); + }); + if(BI.isNotNull(o.value)) { + this.setState(o.value); + } + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + setState: function (obj) { + var o = this.options; + var ob = {}; + ob.type = obj.type; + ob.value = o.allValueGetter() || []; + ob.assist = obj.assist; + if (ob.type === BI.Selection.All) { + if (ob.value.length === 0) { + this.editor.setState(BI.Selection.All); + } else if (BI.size(ob.assist) <= 20) { + var state = ""; + BI.each(ob.assist, function (i, v) { + if (i === 0) { + state += "" + (o.valueFormatter(v + "") || v); + } else { + state += "," + (o.valueFormatter(v + "") || v); + } + }); + this.editor.setState(state); + } else { + this.editor.setState(BI.Selection.Multi); + } + } else { + if (ob.value.length === 0) { + this.editor.setState(BI.Selection.None); + } else if (BI.size(ob.value) <= 20) { + var state = ""; + BI.each(ob.value, function (i, v) { + if (i === 0) { + state += "" + (o.valueFormatter(v + "") || v); + } else { + state += "," + (o.valueFormatter(v + "") || v); + } + }); + this.editor.setState(state); + } else { + this.editor.setState(BI.Selection.Multi); + } + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.SearchMultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.SearchMultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SearchMultiSelectSearcher.EVENT_START = "EVENT_START"; +BI.SearchMultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; +BI.SearchMultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.SearchMultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.shortcut("bi.search_multi_select_searcher", BI.SearchMultiSelectSearcher);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeFirstPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 24 + }); + }, + _init: function () { + BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.first_tree_node_checkbox", + stopPropagation: true + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + keyword: o.keyword, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 24, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeLastPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 24 + }); + }, + _init: function () { + BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.last_tree_node_checkbox", + stopPropagation: true + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + keyword: o.keyword, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 24, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/** + * 加号表示的组节点 + * Created by GUY on 2015/9/6. + * @class BI.SelectTreeMidPlusGroupNode + * @extends BI.NodeButton + */ +BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { + _defaultConfig: function () { + var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active", + logic: { + dynamic: false + }, + id: "", + pId: "", + readonly: true, + open: false, + height: 24 + }); + }, + _init: function () { + BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.checkbox = BI.createWidget({ + type: "bi.mid_tree_node_checkbox", + stopPropagation: true + }); + this.text = BI.createWidget({ + type: "bi.label", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + value: o.value, + keyword: o.keyword, + py: o.py + }); + this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.triggerExpand(); + } else { + self.triggerCollapse(); + } + } + }); + var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); + var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { + width: 24, + el: this.checkbox + }, this.text); + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { + items: items + })))); + }, + + isOnce: function () { + return true; + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.NodeButton.superclass.doClick.apply(this, arguments); + }, + + setOpened: function (v) { + BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); + if (BI.isNotNull(this.checkbox)) { + this.checkbox.setSelected(v); + } + } +}); + +BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/** + * @class BI.SelectTreeCombo + * @extends BI.Widget + */ +BI.SelectTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-combo", + height: 30, + text: "", + items: [], + value: "" + }); + }, + + _init: function () { + BI.SelectTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items, + value: o.value + }); + + this.popup = BI.createWidget({ + type: "bi.select_level_tree", + items: o.items, + value: o.value + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + }, + + populate: function (items) { + this.combo.populate(items); + } +}); + + +BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/** + * @class BI.SelectTreeExpander + * @extends BI.Widget + */ +BI.SelectTreeExpander = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-tree-expander", + trigger: "", + toggle: true, + direction: "bottom", + isDefaultInit: true, + el: {}, + popup: {} + }); + }, + + _init: function () { + BI.SelectTreeExpander.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget(o.el); + this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + if (this.isSelected()) { + self.expander.setValue([]); + } + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.expander = BI.createWidget({ + type: "bi.expander", + element: this, + trigger: o.trigger, + toggle: o.toggle, + direction: o.direction, + isDefaultInit: o.isDefaultInit, + el: this.trigger, + popup: o.popup + }); + this.expander.on(BI.Controller.EVENT_CHANGE, function (type) { + if (type === BI.Events.CLICK) { + self.trigger.setSelected(false); + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + }, + + setValue: function (v) { + if (BI.contains(v, this.trigger.getValue())) { + this.trigger.setSelected(true); + this.expander.setValue([]); + } else { + this.trigger.setSelected(false); + this.expander.setValue(v); + } + }, + + getValue: function () { + if (this.trigger.isSelected()) { + return [this.trigger.getValue()]; + } + return this.expander.getValue(); + }, + + populate: function (items) { + this.expander.populate(items); + } +}); + +BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/** + * @class BI.SelectTreePopup + * @extends BI.Pane + */ + +BI.SelectTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-level-tree", + tipText: BI.i18nText("BI-No_Selected_Item"), + items: [], + value: "" + }); + }, + + _formatItems: function (nodes, layer) { + var self = this; + BI.each(nodes, function (i, node) { + var extend = {layer: layer}; + node.id = node.id || BI.UUID(); + if (node.isParent === true || BI.isNotEmptyArray(node.children)) { + switch (i) { + case 0 : + extend.type = "bi.select_tree_first_plus_group_node"; + break; + case nodes.length - 1 : + extend.type = "bi.select_tree_last_plus_group_node"; + break; + default : + extend.type = "bi.select_tree_mid_plus_group_node"; + break; + } + BI.defaults(node, extend); + self._formatItems(node.children); + } else { + switch (i) { + case nodes.length - 1: + extend.type = "bi.last_tree_leaf_item"; + break; + default : + extend.type = "bi.mid_tree_leaf_item"; + } + BI.defaults(node, extend); + } + }); + return nodes; + }, + + _init: function () { + BI.SelectTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: "bi.level_tree", + expander: { + type: "bi.select_tree_expander", + isDefaultInit: true + }, + items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)), + value: o.value, + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + vgap: 5, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.SelectTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(items))); + } +}); + +BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.select_level_tree", BI.SelectTreePopup);/** + * + * Created by GUY on 2016/8/10. + * @class BI.SequenceTableDynamicNumber + * @extends BI.SequenceTableTreeNumber + */ +BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-sequence-table-dynamic-number" + }); + }, + + _init: function () { + BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); + }, + + _formatNumber: function (nodes) { + var self = this, o = this.options; + var result = []; + var count = this._getStart(nodes); + + function getLeafCount (node) { + var cnt = 0; + if (BI.isNotEmptyArray(node.children)) { + BI.each(node.children, function (index, child) { + cnt += getLeafCount(child); + }); + if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { + cnt++; + } + } else { + cnt++; + } + return cnt; + } + + var start = 0, top = 0; + BI.each(nodes, function (i, node) { + if (BI.isArray(node.children)) { + BI.each(node.children, function (index, child) { + var cnt = getLeafCount(child); + result.push({ + text: count++, + start: start, + top: top, + cnt: cnt, + index: index, + height: cnt * o.rowSize + }); + start += cnt; + top += cnt * o.rowSize; + }); + if (BI.isNotEmptyArray(node.values)) { + result.push({ + text: BI.i18nText("BI-Summary_Values"), + start: start++, + top: top, + cnt: 1, + isSummary: true, + height: o.rowSize + }); + top += o.rowSize; + } + } + }); + return result; + } +}); +BI.shortcut("bi.sequence_table_dynamic_number", BI.SequenceTableDynamicNumber);/** + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTableListNumber + * @extends BI.Widget + */ +BI.SequenceTableListNumber = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table-list-number", + isNeedFreeze: false, + scrollTop: 0, + startSequence: 1, // 开始的序号 + headerRowSize: 25, + rowSize: 25, + + sequenceHeaderCreator: BI.emptyFn, + + header: [], + items: [], // 二维数组 + + // 交叉表头 + crossHeader: [], + crossItems: [], + + pageSize: 20 + }); + }, + + _init: function () { + BI.SequenceTableListNumber.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.start = o.startSequence; + this.renderedCells = []; + this.renderedKeys = []; + + this.container = BI.createWidget({ + type: "bi.absolute", + width: 60, + scrollable: false + }); + + this.scrollContainer = BI.createWidget({ + type: "bi.vertical", + scrollable: false, + scrolly: false, + items: [this.container] + }); + + this.headerContainer = BI.createWidget({ + type: "bi.absolute", + cls: "bi-border", + width: 58, + scrollable: false + }); + + this.layout = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.headerContainer, + height: o.headerRowSize * o.header.length - 2 + }, { + el: {type: "bi.layout"}, + height: 2 + }, { + el: this.scrollContainer + }] + }); + this._populate(); + }, + + _layout: function () { + var self = this, o = this.options; + var headerHeight = o.headerRowSize * o.header.length - 2; + var items = this.layout.attr("items"); + if (o.isNeedFreeze === false) { + items[0].height = 0; + items[1].height = 0; + } else if (o.isNeedFreeze === true) { + items[0].height = headerHeight; + items[1].height = 2; + } + this.layout.attr("items", items); + this.layout.resize(); + this.container.setHeight(o.items.length * o.rowSize); + try { + this.scrollContainer.element.scrollTop(o.scrollTop); + } catch (e) { + + } + }, + + _createHeader: function () { + var o = this.options; + BI.createWidget({ + type: "bi.absolute", + element: this.headerContainer, + items: [{ + el: o.sequenceHeaderCreator() || { + type: "bi.table_style_cell", + cls: "sequence-table-title-cell", + styleGetter: o.headerCellStyleGetter, + text: BI.i18nText("BI-Number_Index") + }, + left: 0, + top: 0, + right: 0, + bottom: 0 + }] + }); + }, + + _calculateChildrenToRender: function () { + var self = this, o = this.options; + var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); + var start = Math.floor(scrollTop / o.rowSize); + var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); + var renderedCells = [], renderedKeys = []; + for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { + var index = BI.deepIndexOf(this.renderedKeys, this.start + i); + var top = i * o.rowSize; + if (index > -1) { + if (o.rowSize !== this.renderedCells[index]._height) { + this.renderedCells[index]._height = o.rowSize; + this.renderedCells[index].el.setHeight(o.rowSize); + } + if (this.renderedCells[index].top !== top) { + this.renderedCells[index].top = top; + this.renderedCells[index].el.element.css("top", top + "px"); + } + renderedCells.push(this.renderedCells[index]); + } else { + var child = BI.createWidget(BI.extend({ + type: "bi.table_style_cell", + cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", + width: 60, + height: o.rowSize, + text: this.start + i, + styleGetter: function (index) { + return function () { + return o.sequenceCellStyleGetter(self.start + i - 1); + }; + }(cnt) + })); + renderedCells.push({ + el: child, + left: 0, + top: top, + _height: o.rowSize + }); + } + renderedKeys.push(this.start + i); + } + + // 已存在的, 需要添加的和需要删除的 + var existSet = {}, addSet = {}, deleteArray = []; + BI.each(renderedKeys, function (i, key) { + if (BI.deepContains(self.renderedKeys, key)) { + existSet[i] = key; + } else { + addSet[i] = key; + } + }); + BI.each(this.renderedKeys, function (i, key) { + if (BI.deepContains(existSet, key)) { + return; + } + if (BI.deepContains(addSet, key)) { + return; + } + deleteArray.push(i); + }); + BI.each(deleteArray, function (i, index) { + self.renderedCells[index].el.destroy(); + }); + var addedItems = []; + BI.each(addSet, function (index) { + addedItems.push(renderedCells[index]); + }); + BI.createWidget({ + type: "bi.absolute", + element: this.container, + items: addedItems + }); + this.renderedCells = renderedCells; + this.renderedKeys = renderedKeys; + }, + + _populate: function () { + this.headerContainer.empty(); + this._createHeader(); + this._layout(); + this._calculateChildrenToRender(); + }, + + setVerticalScroll: function (scrollTop) { + if (this.options.scrollTop !== scrollTop) { + this.options.scrollTop = scrollTop; + try { + this.scrollContainer.element.scrollTop(scrollTop); + } catch (e) { + + } + } + }, + + getVerticalScroll: function () { + return this.options.scrollTop; + }, + + setVPage: function (v) { + v = v < 1 ? 1 : v; + var o = this.options; + this.start = (v - 1) * o.pageSize + 1; + }, + + _restore: function () { + var o = this.options; + BI.each(this.renderedCells, function (i, cell) { + cell.el.destroy(); + }); + this.renderedCells = []; + this.renderedKeys = []; + }, + + restore: function () { + this._restore(); + }, + + populate: function (items, header) { + var o = this.options; + if (items && items !== this.options.items) { + o.items = items; + this._restore(); + } + if (header && header !== this.options.header) { + o.header = header; + } + this._populate(); + } +}); +BI.shortcut("bi.sequence_table_list_number", BI.SequenceTableListNumber);/** + * 带有序号的表格 + * + * Created by GUY on 2016/5/26. + * @class BI.SequenceTable + * @extends BI.Widget + */ +BI.SequenceTable = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-sequence-table", + el: { + type: "bi.adaptive_table" + }, + + sequence: {}, + + isNeedResize: true, + isResizeAdapt: false, + + isNeedFreeze: false, // 是否需要冻结单元格 + freezeCols: [], // 冻结的列号,从0开始,isNeedFreeze为true时生效 + + isNeedMerge: false, // 是否需要合并单元格 + mergeCols: [], // 合并的单元格列号 + mergeRule: BI.emptyFn, + + columnSize: [], + minColumnSize: [], + maxColumnSize: [], + headerRowSize: 25, + rowSize: 25, + + regionColumnSize: [], + + headerCellStyleGetter: BI.emptyFn, + summaryCellStyleGetter: BI.emptyFn, + sequenceCellStyleGetter: BI.emptyFn, + + header: [], + items: [], // 二维数组 + + // 交叉表头 + crossHeader: [], + crossItems: [], + + showSequence: false, + startSequence: 1// 开始的序号 + }); + }, + + _init: function () { + BI.SequenceTable.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.sequence = BI.createWidget(o.sequence, { + type: "bi.sequence_table_list_number", + invisible: o.showSequence === false, + startSequence: o.startSequence, + isNeedFreeze: o.isNeedFreeze, + header: o.header, + items: o.items, + crossHeader: o.crossHeader, + crossItems: o.crossItems, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + width: 60, + height: o.height && o.height - BI.GridTableScrollbar.SIZE, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter + }); + this.table = BI.createWidget(o.el, { + type: "bi.adaptive_table", + width: o.showSequence === true ? o.width - 60 : o.width, + height: o.height, + isNeedResize: o.isNeedResize, + isResizeAdapt: o.isResizeAdapt, + + isNeedFreeze: o.isNeedFreeze, + freezeCols: o.freezeCols, + + isNeedMerge: o.isNeedMerge, + mergeCols: o.mergeCols, + mergeRule: o.mergeRule, + + columnSize: o.columnSize, + minColumnSize: o.minColumnSize, + maxColumnSize: o.maxColumnSize, + headerRowSize: o.headerRowSize, + rowSize: o.rowSize, + + regionColumnSize: o.regionColumnSize, + + headerCellStyleGetter: o.headerCellStyleGetter, + summaryCellStyleGetter: o.summaryCellStyleGetter, + sequenceCellStyleGetter: o.sequenceCellStyleGetter, + + header: o.header, + items: o.items, + // 交叉表头 + crossHeader: o.crossHeader, + crossItems: o.crossItems + }); + + this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { + if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { + self.sequence.setVerticalScroll(this.getVerticalScroll()); + self.sequence.populate(); + } + self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); + }); + this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { + o.regionColumnSize = this.getRegionColumnSize(); + o.columnSize = this.getColumnSize(); + self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); + }); + + this.htape = BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.sequence, + left: 0, + top: 0 + }, { + el: this.table, + top: 0, + left: o.showSequence === true ? 60 : 0 + }] + }); + this._populate(); + }, + + _populate: function () { + var o = this.options; + if (o.showSequence === true) { + this.sequence.setVisible(true); + this.table.element.css("left", "60px"); + this.table.setWidth(o.width - 60); + } else { + this.sequence.setVisible(false); + this.table.element.css("left", "0px"); + this.table.setWidth(o.width); + } + }, + + setWidth: function (width) { + BI.PageTable.superclass.setWidth.apply(this, arguments); + this.table.setWidth(this.options.showSequence ? width - 60 : width); + }, + + setHeight: function (height) { + BI.PageTable.superclass.setHeight.apply(this, arguments); + this.table.setHeight(height); + this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); + }, + + setColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setColumnSize(columnSize); + }, + + getColumnSize: function () { + return this.table.getColumnSize(); + }, + + setRegionColumnSize: function (columnSize) { + this.options.columnSize = columnSize; + this.table.setRegionColumnSize(columnSize); + }, + + getRegionColumnSize: function () { + return this.table.getRegionColumnSize(); + }, + + hasLeftHorizontalScroll: function () { + return this.table.hasLeftHorizontalScroll(); + }, + + hasRightHorizontalScroll: function () { + return this.table.hasRightHorizontalScroll(); + }, + + setLeftHorizontalScroll: function (scrollLeft) { + this.table.setLeftHorizontalScroll(scrollLeft); + }, + + setRightHorizontalScroll: function (scrollLeft) { + this.table.setRightHorizontalScroll(scrollLeft); + }, + + setVerticalScroll: function (scrollTop) { + this.table.setVerticalScroll(scrollTop); + this.sequence.setVerticalScroll(scrollTop); + }, + + getVerticalScroll: function () { + return this.table.getVerticalScroll(); + }, + + setVPage: function (page) { + this.sequence.setVPage && this.sequence.setVPage(page); + }, + + setHPage: function (page) { + this.sequence.setHPage && this.sequence.setHPage(page); + }, + + attr: function () { + BI.SequenceTable.superclass.attr.apply(this, arguments); + this.table.attr.apply(this.table, arguments); + this.sequence.attr.apply(this.sequence, arguments); + }, + + restore: function () { + this.table.restore(); + this.sequence.restore(); + }, + + populate: function (items, header, crossItems, crossHeader) { + var o = this.options; + if (items) { + o.items = items; + } + if (header) { + o.header = header; + } + if (crossItems) { + o.crossItems = crossItems; + } + if (crossHeader) { + o.crossHeader = crossHeader; + } + this._populate(); + this.table.populate.apply(this.table, arguments); + this.sequence.populate.apply(this.sequence, arguments); + this.sequence.setVerticalScroll(this.table.getVerticalScroll()); + }, + + destroy: function () { + this.table.destroy(); + BI.SequenceTable.superclass.destroy.apply(this, arguments); + } +}); +BI.shortcut("bi.sequence_table", BI.SequenceTable);/** + * 单选加载数据搜索loader面板 + * Created by guy on 15/11/4. + * @class BI.SingleSelectSearchLoader + * @extends Widget + */ +BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-search-loader", + itemsCreator: BI.emptyFn, + keywordGetter: BI.emptyFn, + valueFormatter: BI.emptyFn + }); + }, + + _init: function () { + BI.SingleSelectSearchLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + + this.button_group = BI.createWidget({ + type: "bi.single_select_list", + element: this, + logic: { + dynamic: false + }, + value: opts.value, + el: { + tipText: BI.i18nText("BI-No_Select"), + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, + itemsCreator: function (op, callback) { + self.storeValue && (op = BI.extend(op || {}, { + selectedValues: [self.storeValue] + })); + opts.itemsCreator(op, function (ob) { + var keyword = ob.keyword = opts.keywordGetter(); + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && BI.isNotNull(self.storeValue)) { + var json = self._filterValues(self.storeValue); + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), keyword || ""); + if (op.times === 1 && self.storeValue) { + self.setValue(self.storeValue); + } + }); + }, + hasNext: function () { + return hasNext; + } + }); + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleSelectSearchLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.single_select_combo.item", + logic: { + dynamic: false + }, + height: 25, + selected: false + }); + }, + + _filterValues: function (src) { + var o = this.options; + var keyword = o.keywordGetter(); + var values = src || []; + var newValues = BI.map(BI.isArray(values) ? values : [values], function (i, v) { + return { + text: o.valueFormatter(v) || v, + value: v + }; + }); + if (BI.isKey(keyword)) { + var search = BI.Func.getSearchResult(newValues, keyword); + values = search.match.concat(search.find); + } + return BI.map(values, function (i, v) { + return { + text: v.text, + title: v.text, + value: v.value, + selected: false + }; + }); + }, + + setValue: function (v) { + // 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 + this.storeValue = v; + this.button_group.setValue(v); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.SingleSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_select_search_loader", BI.SingleSelectSearchLoader);/** + * + * 在搜索框中输入文本弹出的面板 + * @class BI.SingleSelectSearchPane + * @extends Widget + */ + +BI.SingleSelectSearchPane = BI.inherit(BI.Widget, { + + constants: { + height: 25, + lgap: 10, + tgap: 5 + }, + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-search-pane bi-card", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + keywordGetter: BI.emptyFn + }); + }, + + _init: function () { + BI.SingleSelectSearchPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.tooltipClick = BI.createWidget({ + type: "bi.label", + invisible: true, + text: BI.i18nText("BI-Click_Blank_To_Select"), + cls: "multi-select-toolbar", + height: this.constants.height + }); + + this.loader = BI.createWidget({ + type: "bi.single_select_search_loader", + keywordGetter: o.keywordGetter, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator.apply(self, [op, function (res) { + callback(res); + self.setKeyword(o.keywordGetter()); + }]); + }, + value: o.value + }); + this.loader.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.resizer = BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.tooltipClick, + height: 0 + }, { + el: this.loader + }] + }); + this.tooltipClick.setVisible(false); + }, + + setKeyword: function (keyword) { + var btn; + var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); + if (isVisible !== this.tooltipClick.isVisible()) { + this.tooltipClick.setVisible(isVisible); + this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); + this.resizer.resize(); + } + }, + + hasMatched: function () { + return this.tooltipClick.isVisible(); + }, + + setValue: function (v) { + this.loader.setValue(v); + }, + + getValue: function () { + return this.loader.getValue(); + }, + + empty: function () { + this.loader.empty(); + }, + + populate: function (items) { + this.loader.populate.apply(this.loader, arguments); + } +}); + +BI.SingleSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; + +BI.shortcut("bi.single_select_search_pane", BI.SingleSelectSearchPane);/** + * + * @class BI.SingleSelectCombo + * @extends BI.Single + */ +BI.SingleSelectCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-combo", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 24 + }); + }, + + _init: function () { + BI.SingleSelectCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && (self.storeValue = self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + }; + this.storeValue = o.value; + // 标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.single_select_trigger", + height: o.height, + // adapter: this.popup, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + // 预防trigger内部把当前的storeValue改掉 + self.trigger.setValue(self.getValue()); + } + callback.apply(self, arguments); + }); + }, + value: this.storeValue + }); + + this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () { + self._setStartValue(); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () { + self._setStartValue(); + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { + if (this.getSearcher().hasMatched()) { + var keyword = this.getSearcher().getKeyword(); + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.populate(); + self._setStartValue(); + } + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) { + self.storeValue = this.getValue(); + assertShowValue(); + self._defaultState(); + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: "bi.single_select_popup_view", + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.SingleSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + self._defaultState(); + }); + } + }], + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + }, + value: o.value + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { + self.element.removeClass("combo-show"); + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.element.removeClass("combo-show").addClass("combo-show"); + this.setValue(self.storeValue); + BI.nextTick(function () { + self.populate(); + }); + }); + // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + // important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "single-select-trigger-icon-button" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) {}, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + o.itemsCreator({ + type: BI.SingleSelectCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.map(ob.items, "value"); + digest(values); + }); + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value["remove"](val); + } + }); + self._adjust(callback); + } + }, + + _adjust: function (callback) { + var self = this, o = this.options; + if (!this._count) { + o.itemsCreator({ + type: BI.SingleSelectCombo.REQ_GET_DATA_LENGTH + }, function (res) { + self._count = res.count; + adjust(); + callback(); + }); + } else { + adjust(); + callback(); + + } + + function adjust () { + if (self.wants2Quit === true) { + self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + setValue: function (v) { + this.storeValue = v; + this._assertValue(this.storeValue); + this.combo.setValue(this.storeValue); + }, + + getValue: function () { + return this.storeValue; + }, + + populate: function () { + this._count = null; + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.extend(BI.SingleSelectCombo, { + REQ_GET_DATA_LENGTH: 0, + REQ_GET_ALL_DATA: -1 +}); + +BI.SingleSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut("bi.single_select_combo", BI.SingleSelectCombo); +/** + * + * @class BI.SingleSelectInsertCombo + * @extends BI.Single + */ +BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectInsertCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-combo", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + height: 24 + }); + }, + + _init: function () { + BI.SingleSelectInsertCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + var assertShowValue = function () { + BI.isKey(self._startValue) && (self.storeValue = self._startValue); + self.trigger.getSearcher().setState(self.storeValue); + }; + this.storeValue = o.value; + // 标记正在请求数据 + this.requesting = false; + + this.trigger = BI.createWidget({ + type: "bi.single_select_trigger", + height: o.height, + // adapter: this.popup, + valueFormatter: o.valueFormatter, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (res) { + if (op.times === 1 && BI.isNotNull(op.keywords)) { + // 预防trigger内部把当前的storeValue改掉 + self.trigger.setValue(self.getValue()); + } + callback.apply(self, arguments); + }); + }, + value: this.storeValue + }); + + this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () { + self._setStartValue(); + this.getSearcher().setValue(self.storeValue); + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () { + self._setStartValue(); + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { + var keyword = this.getSearcher().getKeyword(); + self.storeValue = keyword; + self.combo.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.populate(); + self._setStartValue(); + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.combo.setValue(self.storeValue); + assertShowValue(); + self.combo.populate(); + self._setStartValue(); + } else { + self.combo.setValue(self.storeValue); + assertShowValue(); + } + }); + } + }); + + this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) { + self.storeValue = this.getValue(); + assertShowValue(); + self._defaultState(); + }); + this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () { + if (!self.combo.isViewVisible()) { + self.combo.showView(); + } + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + toggle: false, + el: this.trigger, + adjustLength: 1, + popup: { + type: "bi.single_select_popup_view", + ref: function () { + self.popup = this; + self.trigger.setAdapter(this); + }, + listeners: [{ + eventName: BI.SingleSelectPopupView.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self._adjust(function () { + assertShowValue(); + self._defaultState(); + }); + } + }], + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + onLoaded: function () { + BI.nextTick(function () { + self.combo.adjustWidth(); + self.combo.adjustHeight(); + self.trigger.getSearcher().adjustView(); + }); + } + }, + hideChecker: function (e) { + return triggerBtn.element.find(e.target).length === 0; + }, + value: o.value + }); + + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + this.setValue(self.storeValue); + BI.nextTick(function () { + self.populate(); + }); + }); + // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 + this.wants2Quit = false; + this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { + // important:关闭弹出时又可能没有退出编辑状态 + self.trigger.stopEditing(); + if (self.requesting === true) { + self.wants2Quit = true; + } else { + self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); + } + }); + + var triggerBtn = BI.createWidget({ + type: "bi.trigger_icon_button", + width: o.height, + height: o.height, + cls: "single-select-trigger-icon-button" + }); + triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { + if (self.combo.isViewVisible()) { + self.combo.hideView(); + } else { + self.combo.showView(); + } + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.combo, + left: 0, + right: 0, + top: 0, + bottom: 0 + }, { + el: triggerBtn, + right: 0, + top: 0, + bottom: 0 + }] + }); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + this.combo.hideView(); + }, + + _assertValue: function (val) { + }, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + this.requesting = true; + o.itemsCreator({ + type: BI.SingleSelectInsertCombo.REQ_GET_ALL_DATA, + keywords: keywords + }, function (ob) { + var values = BI.map(ob.items, "value"); + digest(values); + }); + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value["remove"](val); + } + }); + self._adjust(callback); + } + }, + + _adjust: function (callback) { + var self = this, o = this.options; + adjust(); + callback(); + + function adjust () { + if (self.wants2Quit === true) { + self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); + self.wants2Quit = false; + } + self.requesting = false; + } + }, + + _setStartValue: function (value) { + this._startValue = value; + this.popup.setStartValue(value); + }, + + setValue: function (v) { + this.storeValue = v; + this._assertValue(this.storeValue); + this.combo.setValue(this.storeValue); + }, + + getValue: function () { + return this.storeValue; + }, + + populate: function () { + this.combo.populate.apply(this.combo, arguments); + } +}); + +BI.extend(BI.SingleSelectInsertCombo, { + REQ_GET_DATA_LENGTH: 0, + REQ_GET_ALL_DATA: -1 +}); + +BI.SingleSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; + +BI.shortcut("bi.single_select_insert_combo", BI.SingleSelectInsertCombo);/** + * guy + * 单选框item + * @type {*|void|Object} + */ +BI.SingleSelectComboItem = BI.inherit(BI.BasicButton, { + _defaultConfig: function () { + return BI.extend(BI.SingleSelectComboItem.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-single-select-radio-item", + logic: { + dynamic: false + }, + height: 24 + }); + }, + _init: function () { + BI.SingleSelectComboItem.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.radio = BI.createWidget({ + type: "bi.radio" + }); + this.text = BI.createWidget({ + type: "bi.label", + cls: "list-item-text", + textAlign: "left", + whiteSpace: "nowrap", + textHeight: o.height, + height: o.height, + hgap: o.hgap, + text: o.text, + keyword: o.keyword, + value: o.value, + py: o.py + }); + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection("left", { + type: "bi.center_adapt", + items: [this.radio], + width: 26 + }, this.text) + })))); + }, + + doRedMark: function () { + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doClick: function () { + BI.SingleSelectComboItem.superclass.doClick.apply(this, arguments); + this.radio.setSelected(this.isSelected()); + }, + + setSelected: function (v) { + BI.SingleSelectComboItem.superclass.setSelected.apply(this, arguments); + this.radio.setSelected(v); + + } +}); + +BI.shortcut("bi.single_select_combo.item", BI.SingleSelectComboItem);/** + * 选择列表 + * + * Created by GUY on 2015/11/1. + * @class BI.SingleSelectList + * @extends BI.Widget + */ +BI.SingleSelectList = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-select-list", + direction: BI.Direction.Top, // toolbar的位置 + logic: { + dynamic: true + }, + items: [], + itemsCreator: BI.emptyFn, + hasNext: BI.emptyFn, + onLoaded: BI.emptyFn, + el: { + type: "bi.list_pane" + } + }); + }, + _init: function () { + BI.SingleSelectList.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.list = BI.createWidget(o.el, { + type: "bi.list_pane", + items: o.items, + itemsCreator: function (op, callback) { + o.itemsCreator(op, function (items) { + callback.apply(self, arguments); + }); + }, + onLoaded: o.onLoaded, + hasNext: o.hasNext, + value: o.value + }); + + this.list.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { + if (type === BI.Events.CLICK) { + self.fireEvent(BI.SingleSelectList.EVENT_CHANGE, value, obj); + } + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + BI.createWidget(BI.extend({ + element: this + }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ + scrolly: true + }, o.logic, { + items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.list) + })))); + + }, + + hasPrev: function () { + return this.list.hasPrev(); + }, + + hasNext: function () { + return this.list.hasNext(); + }, + + prependItems: function (items) { + this.list.prependItems.apply(this.list, arguments); + }, + + addItems: function (items) { + this.list.addItems.apply(this.list, arguments); + }, + + setValue: function (v) { + this.list.setValue([v]); + }, + + getValue: function () { + return this.list.getValue()[0]; + }, + + empty: function () { + this.list.empty(); + }, + + populate: function (items) { + this.list.populate.apply(this.list, arguments); + }, + + resetHeight: function (h) { + this.list.resetHeight ? this.list.resetHeight(h) : + this.list.element.css({"max-height": h + "px"}); + }, + + setNotSelectedValue: function () { + this.list.setNotSelectedValue.apply(this.list, arguments); + }, + + getNotSelectedValue: function () { + return this.list.getNotSelectedValue(); + }, + + getAllButtons: function () { + return this.list.getAllButtons(); + }, + + getAllLeaves: function () { + return this.list.getAllLeaves(); + }, + + getSelectedButtons: function () { + return this.list.getSelectedButtons(); + }, + + getNotSelectedButtons: function () { + return this.list.getNotSelectedButtons(); + }, + + getIndexByValue: function (value) { + return this.list.getIndexByValue(value); + }, + + getNodeById: function (id) { + return this.list.getNodeById(id); + }, + + getNodeByValue: function (value) { + return this.list.getNodeByValue(value); + } +}); +BI.SingleSelectList.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_select_list", BI.SingleSelectList);/** + * 单选加载数据面板 + * Created by guy on 15/11/2. + * @class BI.SingleSelectLoader + * @extends Widget + */ +BI.SingleSelectLoader = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectLoader.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-loader", + logic: { + dynamic: true + }, + el: { + height: 400 + }, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.SingleSelectLoader.superclass._init.apply(this, arguments); + + var self = this, opts = this.options; + var hasNext = false; + this.storeValue = opts.value; + this.button_group = BI.createWidget({ + type: "bi.single_select_list", + logic: opts.logic, + el: BI.extend({ + onLoaded: opts.onLoaded, + el: { + type: "bi.loader", + isDefaultInit: false, + logic: { + dynamic: true, + scrolly: true + }, + el: { + chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, + behaviors: { + redmark: function () { + return true; + } + }, + layouts: [{ + type: "bi.vertical" + }] + } + } + }, opts.el), + itemsCreator: function (op, callback) { + var startValue = self._startValue; + BI.isNotNull(self.storeValue) && (op = BI.extend(op || {}, { + selectedValues: [self.storeValue] + })); + opts.itemsCreator(op, function (ob) { + hasNext = ob.hasNext; + var firstItems = []; + if (op.times === 1 && BI.isNotNull(self.storeValue)) { + var json = BI.map([self.storeValue], function (i, v) { + var txt = opts.valueFormatter(v) || v; + return { + text: txt, + value: v, + title: txt, + selected: true + }; + }); + firstItems = self._createItems(json); + } + callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); + if (op.times === 1 && self.storeValue) { + BI.isKey(startValue) && (self.storeValue = startValue); + self.setValue(self.storeValue); + } + (op.times === 1) && self._scrollToTop(); + }); + }, + hasNext: function () { + return hasNext; + }, + value: this.storeValue + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + items: [this.button_group], + vgap: 5 + }); + + this.button_group.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleSelectLoader.EVENT_CHANGE, arguments); + }); + }, + + _createItems: function (items) { + return BI.createItems(items, { + type: "bi.single_select_combo.item", + logic: this.options.logic, + cls: "bi-list-item-active", + height: 24, + selected: false + }); + }, + + _scrollToTop: function () { + var self = this; + BI.delay(function () { + self.button_group.element.scrollTop(0); + }, 30); + }, + + _assertValue: function (val) {}, + + setStartValue: function (v) { + this._startValue = v; + }, + + setValue: function (v) { + this.storeValue = v; + this._assertValue(this.storeValue); + this.button_group.setValue(this.storeValue); + }, + + getValue: function () { + return this.button_group.getValue(); + }, + + getAllButtons: function () { + return this.button_group.getAllButtons(); + }, + + empty: function () { + this.button_group.empty(); + }, + + populate: function (items) { + this.button_group.populate.apply(this.button_group, arguments); + }, + + resetHeight: function (h) { + this.button_group.resetHeight(h); + }, + + resetWidth: function (w) { + this.button_group.resetWidth(w); + } +}); + +BI.SingleSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_select_loader", BI.SingleSelectLoader); +/** + * 带加载的单选下拉面板 + * @class BI.SingleSelectPopupView + * @extends Widget + */ +BI.SingleSelectPopupView = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectPopupView.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-popup-view", + maxWidth: "auto", + minWidth: 135, + maxHeight: 400, + valueFormatter: BI.emptyFn, + itemsCreator: BI.emptyFn, + onLoaded: BI.emptyFn + }); + }, + + _init: function () { + BI.SingleSelectPopupView.superclass._init.apply(this, arguments); + var self = this, opts = this.options; + + this.loader = BI.createWidget({ + type: "bi.single_select_loader", + itemsCreator: opts.itemsCreator, + valueFormatter: opts.valueFormatter, + onLoaded: opts.onLoaded, + value: opts.value + }); + + this.popupView = BI.createWidget({ + type: "bi.popup_view", + stopPropagation: false, + maxWidth: opts.maxWidth, + minWidth: opts.minWidth, + maxHeight: opts.maxHeight, + element: this, + el: this.loader, + value: opts.value + }); + + this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleSelectPopupView.EVENT_CHANGE); + }); + }, + + setStartValue: function (v) { + this.loader.setStartValue(v); + }, + + setValue: function (v) { + this.popupView.setValue(v); + }, + + getValue: function () { + return this.popupView.getValue(); + }, + + populate: function (items) { + this.popupView.populate.apply(this.popupView, arguments); + }, + + resetHeight: function (h) { + this.popupView.resetHeight(h); + }, + + resetWidth: function (w) { + this.popupView.resetWidth(w); + } +}); + +BI.SingleSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; + + +BI.shortcut("bi.single_select_popup_view", BI.SingleSelectPopupView);/** + * + * 单选下拉框 + * @class BI.SingleSelectTrigger + * @extends BI.Trigger + */ + +BI.SingleSelectTrigger = BI.inherit(BI.Trigger, { + + constants: { + height: 14, + rgap: 4, + lgap: 4 + }, + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-trigger bi-border", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn, + searcher: {}, + switcher: {}, + + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.SingleSelectTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + if (o.height) { + this.setHeight(o.height - 2); + } + + this.searcher = BI.createWidget(o.searcher, { + type: "bi.single_select_searcher", + height: o.height, + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + popup: {}, + adapter: o.adapter, + masker: o.masker, + value: o.value + }); + this.searcher.on(BI.SingleSelectSearcher.EVENT_START, function () { + self.fireEvent(BI.SingleSelectTrigger.EVENT_START); + }); + this.searcher.on(BI.SingleSelectSearcher.EVENT_PAUSE, function () { + self.fireEvent(BI.SingleSelectTrigger.EVENT_PAUSE); + }); + this.searcher.on(BI.SingleSelectSearcher.EVENT_SEARCHING, function () { + self.fireEvent(BI.SingleSelectTrigger.EVENT_SEARCHING, arguments); + }); + this.searcher.on(BI.SingleSelectSearcher.EVENT_STOP, function () { + self.fireEvent(BI.SingleSelectTrigger.EVENT_STOP); + }); + this.searcher.on(BI.SingleSelectSearcher.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleSelectTrigger.EVENT_CHANGE, arguments); + }); + + var wrapper = BI.createWidget({ + type: "bi.htape", + element: this, + items: [ + { + el: this.searcher, + width: "fill" + }, { + el: BI.createWidget(), + width: 24 + }] + }); + }, + + getSearcher: function () { + return this.searcher; + }, + + stopEditing: function () { + this.searcher.stopSearch(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + setValue: function (v) { + this.searcher.setValue(v); + }, + + getKey: function () { + return this.searcher.getKey(); + }, + + getValue: function () { + return this.searcher.getValue(); + } +}); + +BI.SingleSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; +BI.SingleSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; +BI.SingleSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SingleSelectTrigger.EVENT_START = "EVENT_START"; +BI.SingleSelectTrigger.EVENT_STOP = "EVENT_STOP"; +BI.SingleSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; +BI.SingleSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.SingleSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; + +BI.shortcut("bi.single_select_trigger", BI.SingleSelectTrigger);/** + * @author: Teller + * @createdAt: 2018/3/28 + * @Description +*/ +BI.SingleSelectInsertList = BI.inherit(BI.Single, { + _defaultConfig: function () { + return BI.extend(BI.SingleSelectInsertList.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-multi-select-insert-list", + itemsCreator: BI.emptyFn, + valueFormatter: BI.emptyFn + }); + }, + _init: function () { + BI.SingleSelectInsertList.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + this.storeValue = o.value; + + var assertShowValue = function () { + BI.isKey(self._startValue) && (self.storeValue = self._startValue); + // self.trigger.setValue(self.storeValue); + }; + + this.adapter = BI.createWidget({ + type: "bi.single_select_loader", + cls: "popup-single-select-list bi-border-left bi-border-right bi-border-bottom", + itemsCreator: o.itemsCreator, + valueFormatter: o.valueFormatter, + logic: { + dynamic: true + }, + // onLoaded: o.onLoaded, + el: {}, + value: o.value + }); + this.adapter.on(BI.SingleSelectLoader.EVENT_CHANGE, function () { + self.storeValue = this.getValue(); + assertShowValue(); + self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); + }); + + this.searcherPane = BI.createWidget({ + type: "bi.single_select_search_pane", + cls: "bi-border-left bi-border-right bi-border-bottom", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.trigger.getKeyword(); + }, + itemsCreator: function (op, callback) { + op.keywords = [self.trigger.getKeyword()]; + this.setKeyword(op.keywords[0]); + o.itemsCreator(op, callback); + } + }); + this.searcherPane.setVisible(false); + + this.trigger = BI.createWidget({ + type: "bi.searcher", + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + adapter: this.adapter, + popup: this.searcherPane, + height: 200, + masker: false, + value: o.value, + listeners: [{ + eventName: BI.Searcher.EVENT_START, + action: function () { + self._showSearcherPane(); + self._setStartValue(); + this.setValue(BI.deepClone(self.storeValue)); + } + }, { + eventName: BI.Searcher.EVENT_STOP, + action: function () { + self._showAdapter(); + self._setStartValue(); + self.adapter.setValue(self.storeValue); + // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 + self.adapter.populate(); + } + }, { + eventName: BI.Searcher.EVENT_PAUSE, + action: function () { + var keyword = this.getKeyword(); + self.storeValue = keyword; + self._showAdapter(); + self.adapter.setValue(self.storeValue); + self._setStartValue(keyword); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(); + self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); + } + }, { + eventName: BI.Searcher.EVENT_SEARCHING, + action: function () { + var keywords = this.getKeyword(); + var last = BI.last(keywords); + keywords = BI.initial(keywords || []); + if (keywords.length > 0) { + self._joinKeywords(keywords, function () { + if (BI.isEndWithBlank(last)) { + self.adapter.setValue(self.storeValue); + assertShowValue(); + self.adapter.populate(); + self._setStartValue(); + } else { + self.adapter.setValue(self.storeValue); + assertShowValue(); + } + }); + } + } + }, { + eventName: BI.Searcher.EVENT_CHANGE, + action: function () { + self.storeValue = this.getValue(); + self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); + } + }] + }); + + BI.createWidget({ + type: "bi.vtape", + element: this, + items: [{ + el: this.trigger, + height: 24 + }, { + el: this.adapter, + height: "fill" + }] + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.searcherPane, + top: 30, + bottom: 0, + left: 0, + right: 0 + }] + }); + }, + + _showAdapter: function () { + this.adapter.setVisible(true); + this.searcherPane.setVisible(false); + }, + + _showSearcherPane: function () { + this.searcherPane.setVisible(true); + this.adapter.setVisible(false); + }, + + _defaultState: function () { + this.trigger.stopEditing(); + }, + + _assertValue: function () {}, + + _makeMap: function (values) { + return BI.makeObject(values || []); + }, + + _joinKeywords: function (keywords, callback) { + var self = this, o = this.options; + this._assertValue(this.storeValue); + if (!this._allData) { + o.itemsCreator({ + type: BI.SingleSelectInsertList.REQ_GET_ALL_DATA + }, function (ob) { + self._allData = BI.map(ob.items, "value"); + digest(self._allData); + }); + } else { + digest(this._allData); + } + + function digest (items) { + var selectedMap = self._makeMap(items); + BI.each(keywords, function (i, val) { + if (BI.isNotNull(selectedMap[val])) { + self.storeValue.value[self.storeValue.type === BI.Selection.Single ? "pushDistinct" : "remove"](val); + } + }); + callback(); + } + }, + + _setStartValue: function (value) { + this._startValue = value; + this.adapter.setStartValue(value); + }, + + isAllSelected: function () { + return this.adapter.isAllSelected(); + }, + + resize: function () { + // this.trigger.getCounter().adjustView(); + // this.trigger.adjustView(); + }, + setValue: function (v) { + this.storeValue = v; + this.adapter.setValue(this.storeValue); + this.trigger.setValue(this.storeValue); + }, + + getValue: function () { + return BI.deepClone(this.storeValue); + }, + + populate: function () { + this._count = null; + this._allData = null; + this.adapter.populate.apply(this.adapter, arguments); + this.trigger.populate.apply(this.trigger, arguments); + } +}); + +BI.extend(BI.SingleSelectInsertList, { + REQ_GET_DATA_LENGTH: 0, + REQ_GET_ALL_DATA: -1 +}); + +BI.SingleSelectInsertList.EVENT_CHANGE = "BI.SingleSelectInsertList.EVENT_CHANGE"; +BI.shortcut("bi.single_select_insert_list", BI.SingleSelectInsertList); +/** + * 单选输入框 + * Created by guy on 15/11/3. + * @class BI.SingleSelectEditor + * @extends Widget + */ +BI.SingleSelectEditor = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectEditor.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-editor", + el: {} + }); + }, + + _init: function () { + BI.SingleSelectEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.state_editor", + element: this, + height: o.height, + watermark: BI.i18nText("BI-Basic_Search"), + allowBlank: true, + value: o.value + }); + + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.editor.on(BI.StateEditor.EVENT_PAUSE, function () { + self.fireEvent(BI.SingleSelectEditor.EVENT_PAUSE); + }); + this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () { + + }); + }, + + focus: function () { + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + }, + + setState: function (state) { + this.editor.setState(state); + }, + + setValue: function (v) { + this.editor.setValue(v); + }, + + getValue: function () { + var v = this.editor.getState(); + if (BI.isArray(v) && v.length > 0) { + return v[v.length - 1]; + } + return ""; + + }, + + getKeywords: function () { + var val = this.editor.getLastValidValue(); + var keywords = val.match(/[\S]+/g); + if (BI.isEndWithBlank(val)) { + return keywords.concat([" "]); + } + return keywords; + }, + + populate: function (items) { + + } +}); +BI.SingleSelectEditor.EVENT_PAUSE = "SingleSelectEditor.EVENT_PAUSE"; +BI.shortcut("bi.single_select_editor", BI.SingleSelectEditor);/** + * searcher + * Created by guy on 15/11/3. + * @class BI.SingleSelectSearcher + * @extends Widget + */ +BI.SingleSelectSearcher = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleSelectSearcher.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-select-searcher", + itemsCreator: BI.emptyFn, + el: {}, + popup: {}, + valueFormatter: BI.emptyFn, + adapter: null, + masker: {} + }); + }, + + _init: function () { + BI.SingleSelectSearcher.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget(o.el, { + type: "bi.single_select_editor", + height: o.height + }); + + this.searcher = BI.createWidget({ + type: "bi.searcher", + element: this, + height: o.height, + isAutoSearch: false, + isAutoSync: false, + onSearch: function (op, callback) { + callback(); + }, + el: this.editor, + + popup: BI.extend({ + type: "bi.single_select_search_pane", + valueFormatter: o.valueFormatter, + keywordGetter: function () { + return self.editor.getValue(); + }, + itemsCreator: function (op, callback) { + var keyword = self.editor.getValue(); + op.keywords = [keyword]; + this.setKeyword(keyword); + o.itemsCreator(op, callback); + }, + value: o.value + }, o.popup), + + adapter: o.adapter, + masker: o.masker + }); + this.searcher.on(BI.Searcher.EVENT_START, function () { + self.fireEvent(BI.SingleSelectSearcher.EVENT_START); + }); + this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { + if (this.hasMatched()) { + + } + self.fireEvent(BI.SingleSelectSearcher.EVENT_PAUSE); + }); + this.searcher.on(BI.Searcher.EVENT_STOP, function () { + self.fireEvent(BI.SingleSelectSearcher.EVENT_STOP); + }); + this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleSelectSearcher.EVENT_CHANGE, arguments); + }); + this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { + var keywords = this.getKeywords(); + self.fireEvent(BI.SingleSelectSearcher.EVENT_SEARCHING, keywords); + }); + + if(BI.isNotNull(o.value)){ + this.setState(o.value); + } + }, + + adjustView: function () { + this.searcher.adjustView(); + }, + + isSearching: function () { + return this.searcher.isSearching(); + }, + + stopSearch: function () { + this.searcher.stopSearch(); + }, + + getKeyword: function () { + return this.editor.getValue(); + }, + + hasMatched: function () { + return this.searcher.hasMatched(); + }, + + hasChecked: function () { + return this.searcher.getView() && this.searcher.getView().hasChecked(); + }, + + setAdapter: function (adapter) { + this.searcher.setAdapter(adapter); + }, + + setState: function (v) { + var o = this.options; + if (BI.isNull(v)) { + this.editor.setState(BI.Selection.None); + } else { + this.editor.setState(o.valueFormatter(v + "") || (v + "")); + } + }, + + setValue: function (ob) { + this.setState(ob); + this.searcher.setValue(ob); + }, + + getKey: function () { + return this.editor.getValue(); + }, + + getValue: function () { + return this.searcher.getValue(); + }, + + populate: function (items) { + this.searcher.populate.apply(this.searcher, arguments); + } +}); + +BI.SingleSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.SingleSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; +BI.SingleSelectSearcher.EVENT_START = "EVENT_START"; +BI.SingleSelectSearcher.EVENT_STOP = "EVENT_STOP"; +BI.SingleSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; +BI.SingleSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; +BI.shortcut("bi.single_select_searcher", BI.SingleSelectSearcher); +/** + * Created by User on 2017/11/16. + */ +BI.SignTextEditor = BI.inherit(BI.Widget, { + _defaultConfig: function () { + var conf = BI.SignTextEditor.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + baseCls: (conf.baseCls || "") + " bi-sign-initial-editor", + validationChecker: BI.emptyFn, + text: "", + height: 24 + }); + }, + + _init: function () { + BI.SignTextEditor.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.editor = BI.createWidget({ + type: "bi.editor", + height: o.height, + hgap: 4, + vgap: 2, + value: o.value, + validationChecker: o.validationChecker, + allowBlank: false + }); + this.text = BI.createWidget({ + type: "bi.text_button", + cls: "sign-editor-text", + title: function () { + return self.getValue(); + }, + textAlign: o.textAlign, + height: o.height, + hgap: 4, + handler: function () { + self._showInput(); + self.editor.focus(); + self.editor.selectAll(); + } + }); + this.text.on(BI.TextButton.EVENT_CHANGE, function () { + BI.nextTick(function () { + self.fireEvent(BI.SignTextEditor.EVENT_CLICK_LABEL); + }); + }); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: this.text, + left: 0, + right: 0, + top: 0, + bottom: 0 + }] + }); + this.editor.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.editor.on(BI.Editor.EVENT_CONFIRM, function () { + self._showHint(); + self._checkText(); + self.fireEvent(BI.SignTextEditor.EVENT_CONFIRM, arguments); + }); + this.editor.on(BI.Editor.EVENT_ERROR, function () { + self._checkText(); + }); + BI.createWidget({ + type: "bi.vertical", + scrolly: false, + element: this, + items: [this.editor] + }); + this._showHint(); + self._checkText(); + }, + + _checkText: function () { + var o = this.options; + BI.nextTick(BI.bind(function () { + if (this.editor.getValue() === "") { + this.text.setValue(o.watermark || ""); + this.text.element.addClass("bi-water-mark"); + } else { + var v = this.editor.getValue(); + v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text; + this.text.setValue(v); + this.text.element.removeClass("bi-water-mark"); + } + }, this)); + }, + + _showInput: function () { + this.editor.visible(); + this.text.invisible(); + }, + + _showHint: function () { + this.editor.invisible(); + this.text.visible(); + }, + + setTitle: function (title) { + this.text.setTitle(title); + }, + + setWarningTitle: function (title) { + this.text.setWarningTitle(title); + }, + + focus: function () { + this._showInput(); + this.editor.focus(); + }, + + blur: function () { + this.editor.blur(); + this._showHint(); + this._checkText(); + }, + + doRedMark: function () { + if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { + return; + } + this.text.doRedMark.apply(this.text, arguments); + }, + + unRedMark: function () { + this.text.unRedMark.apply(this.text, arguments); + }, + + doHighLight: function () { + if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { + return; + } + this.text.doHighLight.apply(this.text, arguments); + }, + + unHighLight: function () { + this.text.unHighLight.apply(this.text, arguments); + }, + + isValid: function () { + return this.editor.isValid(); + }, + + setErrorText: function (text) { + this.editor.setErrorText(text); + }, + + getErrorText: function () { + return this.editor.getErrorText(); + }, + + isEditing: function () { + return this.editor.isEditing(); + }, + + getLastValidValue: function () { + return this.editor.getLastValidValue(); + }, + + setValue: function (v) { + this.editor.setValue(v); + this._checkText(); + }, + + getValue: function () { + return this.editor.getValue(); + }, + + getState: function () { + return this.text.getValue(); + }, + + setState: function (v) { + var o = this.options; + this._showHint(); + v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text; + this.text.setValue(v); + } +}); +BI.SignTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.SignTextEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; + +BI.shortcut("bi.sign_text_editor", BI.SignTextEditor);/** + * Created by zcf on 2016/9/22. + */ +BI.SliderIconButton = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-single-slider-button" + }, + + constants: { + LARGE_SIZE: 16, + NORMAL_SIZE: 12, + LARGE_OFFSET: 4, + NORMAL_OFFSET: 6 + }, + + render: function () { + var self = this; + return { + type: "bi.absolute", + ref: function () { + self.wrapper = this; + }, + items: [{ + el: { + type: "bi.text_button", + forceNotSelected: true, + cls: "slider-button bi-list-item-select2", + ref: function () { + self.slider = this; + } + } + }] + }; + } +}); +BI.shortcut("bi.single_slider_button", BI.SliderIconButton);/** + * Created by zcf on 2016/9/22. + */ +BI.SingleSlider = BI.inherit(BI.Widget, { + _constant: { + EDITOR_WIDTH: 90, + EDITOR_HEIGHT: 30, + SLIDER_WIDTH_HALF: 15, + SLIDER_WIDTH: 30, + SLIDER_HEIGHT: 30, + TRACK_HEIGHT: 24 + }, + + props: { + baseCls: "bi-single-slider bi-slider-track", + digit: false, + unit: "" + }, + + render: function () { + var self = this, o = this.options; + var c = this._constant; + this.enable = false; + this.value = ""; + + this.grayTrack = BI.createWidget({ + type: "bi.layout", + cls: "gray-track", + height: 6 + }); + this.blueTrack = BI.createWidget({ + type: "bi.layout", + cls: "blue-track bi-high-light-background", + height: 6 + }); + this.track = this._createTrackWrapper(); + + this.slider = BI.createWidget({ + type: "bi.single_slider_button" + }); + this._draggable(this.slider); + var sliderVertical = BI.createWidget({ + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [this.slider] + }], + hgap: c.SLIDER_WIDTH_HALF, + height: c.SLIDER_HEIGHT + }); + // 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点 + sliderVertical.element.click(function (e) { + if (self.enable && self.isEnabled()) { + var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF; + var trackLength = self.track.element[0].scrollWidth; + var percent = 0; + if (offset < 0) { + percent = 0; + } + if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) { + percent = offset * 100 / self._getGrayTrackLength(); + } + if (offset > (trackLength - c.SLIDER_WIDTH)) { + percent = 100; + } + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setAllPosition(significantPercent); + var v = self._getValueByPercent(significantPercent); + v = o.digit === false ? v : v.toFixed(o.digit); + self.label.setValue(v); + self.value = v; + self.fireEvent(BI.SingleSlider.EVENT_CHANGE); + } + }); + this.label = BI.createWidget({ + type: "bi.sign_text_editor", + cls: "slider-editor-button", + text: o.unit, + width: c.EDITOR_WIDTH - 2, + allowBlank: false, + textAlign: "center", + validationChecker: function (v) { + return self._checkValidation(v); + } + }); + this.label.element.hover(function () { + self.label.element.removeClass("bi-border").addClass("bi-border"); + }, function () { + self.label.element.removeClass("bi-border"); + }); + this.label.on(BI.SignEditor.EVENT_CONFIRM, function () { + var v = BI.parseFloat(this.getValue()); + var percent = self._getPercentByValue(v); + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setAllPosition(significantPercent); + this.setValue(v); + self.value = v; + self.fireEvent(BI.SingleSlider.EVENT_CHANGE); + }); + this._setVisible(false); + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.track, + width: "100%", + height: c.TRACK_HEIGHT + }] + }], + hgap: 7, + height: c.TRACK_HEIGHT + }, + top: 23, + left: 0, + width: "100%" + }, { + el: sliderVertical, + top: 20, + left: 0, + width: "100%" + }, { + el: { + type: "bi.vertical", + items: [{ + type: "bi.horizontal_auto", + items: [this.label] + }], + height: c.EDITOR_HEIGHT + }, + top: 0, + left: 0, + width: "100%" + }] + }; + }, + + _draggable: function (widget) { + var self = this, o = this.options; + var startDrag = false; + var size = 0, offset = 0, defaultSize = 0; + var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { + if (mouseMoveTracker.isDragging()) { + startDrag = true; + offset += deltaX; + size = optimizeSize(defaultSize + offset); + widget.element.addClass("dragging"); + var percent = size * 100 / (self._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 + self._setBlueTrack(significantPercent); + self._setLabelPosition(significantPercent); + self._setSliderPosition(significantPercent); + var v = self._getValueByPercent(significantPercent); + v = o.digit === false ? v : v.toFixed(o.digit); + self.label.setValue(v); + self.value = v; + self.fireEvent(BI.SingleSlider.EVENT_CHANGE); + } + }, function () { + if (startDrag === true) { + size = optimizeSize(size); + var percent = size * 100 / (self._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setSliderPosition(significantPercent); + size = 0; + offset = 0; + defaultSize = size; + startDrag = false; + } + widget.element.removeClass("dragging"); + mouseMoveTracker.releaseMouseMoves(); + self.fireEvent(BI.SingleSlider.EVENT_CHANGE); + }, window); + widget.element.on("mousedown", function (event) { + if(!widget.isEnabled()) { + return; + } + defaultSize = this.offsetLeft; + optimizeSize(defaultSize); + mouseMoveTracker.captureMouseMoves(event); + }); + + function optimizeSize (s) { + return BI.clamp(s, 0, self._getGrayTrackLength()); + } + }, + + _createTrackWrapper: function () { + return BI.createWidget({ + type: "bi.absolute", + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.grayTrack, + top: 0, + left: 0, + width: "100%" + }, { + el: this.blueTrack, + top: 0, + left: 0, + width: "0%" + }] + }], + hgap: 8, + height: 8 + }, + top: 8, + left: 0, + width: "100%" + }] + }); + }, + + _checkValidation: function (v) { + var o = this.options; + var valid = false; + if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) { + if(o.digit === false) { + valid = true; + }else{ + var dotText = (v + "").split(".")[1] || ""; + valid = (dotText.length === o.digit); + } + } + return valid; + }, + + _setBlueTrack: function (percent) { + this.blueTrack.element.css({width: percent + "%"}); + }, + + _setLabelPosition: function (percent) { + // this.label.element.css({left: percent + "%"}); + }, + + _setSliderPosition: function (percent) { + this.slider.element.css({left: percent + "%"}); + }, + + _setAllPosition: function (percent) { + this._setSliderPosition(percent); + this._setLabelPosition(percent); + this._setBlueTrack(percent); + }, + + _setVisible: function (visible) { + this.slider.setVisible(visible); + this.label.setVisible(visible); + }, + + _getGrayTrackLength: function () { + return this.grayTrack.element[0].scrollWidth; + }, + + _getValueByPercent: function (percent) { + var thousandth = BI.parseInt(percent * 10); + return (((this.max - this.min) * thousandth) / 1000 + this.min); + }, + + _getPercentByValue: function (v) { + return (v - this.min) * 100 / (this.max - this.min); + }, + + getValue: function () { + return this.value; + }, + + setValue: function (v) { + var o = this.options; + v = BI.parseFloat(v); + v = o.digit === false ? v : v.toFixed(o.digit); + if ((!isNaN(v))) { + if (this._checkValidation(v)) { + this.value = v; + } + if (v > this.max) { + this.value = this.max; + } + if (v < this.min) { + this.value = this.min; + } + } + }, + + _setEnable: function (b) { + BI.SingleSlider.superclass._setEnable.apply(this, [b]); + if(b) { + this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); + } else { + this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); + } + }, + + setMinAndMax: function (v) { + var minNumber = BI.parseFloat(v.min); + var maxNumber = BI.parseFloat(v.max); + if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) { + this.min = minNumber; + this.max = maxNumber; + } + }, + + reset: function () { + this._setVisible(false); + this.enable = false; + this.value = ""; + this.min = 0; + this.max = 0; + this._setBlueTrack(0); + + }, + + populate: function () { + if (!isNaN(this.min) && !isNaN(this.max)) { + this._setVisible(true); + this.enable = true; + this.label.setErrorText(BI.i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max)); + if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) { + this.label.setValue(this.value); + this._setAllPosition(this._getPercentByValue(this.value)); + } else { + this.label.setValue(this.max); + this._setAllPosition(100); + } + } + } +}); +BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_slider", BI.SingleSlider);/** + * Created by Urthur on 2017/9/12. + */ +BI.SingleSliderLabel = BI.inherit(BI.Widget, { + _constant: { + EDITOR_WIDTH: 90, + EDITOR_HEIGHT: 20, + HEIGHT: 20, + SLIDER_WIDTH_HALF: 15, + SLIDER_WIDTH: 30, + SLIDER_HEIGHT: 30, + TRACK_HEIGHT: 24 + }, + _defaultConfig: function () { + return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-slider-label bi-slider-track", + digit: false, + unit: "" + }); + }, + _init: function () { + BI.SingleSliderLabel.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + var c = this._constant; + this.enable = false; + this.value = ""; + + this.grayTrack = BI.createWidget({ + type: "bi.layout", + cls: "gray-track", + height: 6 + }); + this.blueTrack = BI.createWidget({ + type: "bi.layout", + cls: "blue-track bi-high-light-background", + height: 6 + }); + this.track = this._createTrackWrapper(); + + this.slider = BI.createWidget({ + type: "bi.single_slider_button" + }); + this._draggable(this.slider); + var sliderVertical = BI.createWidget({ + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [this.slider] + }], + hgap: c.SLIDER_WIDTH_HALF, + height: c.SLIDER_HEIGHT + }); + sliderVertical.element.click(function (e) { + if (self.enable && self.isEnabled()) { + var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF; + var trackLength = self.track.element[0].scrollWidth; + var percent = 0; + if (offset < 0) { + percent = 0; + } + if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) { + percent = offset * 100 / self._getGrayTrackLength(); + } + if (offset > (trackLength - c.SLIDER_WIDTH)) { + percent = 100; + } + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setAllPosition(significantPercent); + var v = self._getValueByPercent(significantPercent); + v = o.digit === false ? v : v.toFixed(o.digit); + self.label.setText(v + o.unit); + self.value = v; + self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); + } + }); + this.label = BI.createWidget({ + type: "bi.label", + height: c.HEIGHT, + width: c.EDITOR_WIDTH - 2 + }); + + this._setVisible(false); + BI.createWidget({ + type: "bi.absolute", + element: this, + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.track, + width: "100%", + height: c.TRACK_HEIGHT + }] + }], + hgap: 7, + height: c.TRACK_HEIGHT + }, + top: 13, + left: 0, + width: "100%" + }, { + el: sliderVertical, + top: 10, + left: 0, + width: "100%" + }, { + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [this.label] + }], + rgap: c.EDITOR_WIDTH, + height: c.EDITOR_HEIGHT + }, + top: 0, + left: 0, + width: "100%" + }] + }); + }, + + _draggable: function (widget) { + var self = this, o = this.options; + var startDrag = false; + var size = 0, offset = 0, defaultSize = 0; + var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { + if (mouseMoveTracker.isDragging()) { + startDrag = true; + offset += deltaX; + size = optimizeSize(defaultSize + offset); + widget.element.addClass("dragging"); + var percent = size * 100 / (self._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 + self._setBlueTrack(significantPercent); + self._setLabelPosition(significantPercent); + self._setSliderPosition(significantPercent); + var v = self._getValueByPercent(significantPercent); + v = o.digit === false ? v : v.toFixed(o.digit); + self.label.setValue(v); + self.value = v; + self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); + } + }, function () { + if (startDrag === true) { + size = optimizeSize(size); + var percent = size * 100 / (self._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setSliderPosition(significantPercent); + size = 0; + offset = 0; + defaultSize = size; + startDrag = false; + } + widget.element.removeClass("dragging"); + mouseMoveTracker.releaseMouseMoves(); + self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); + }, window); + widget.element.on("mousedown", function (event) { + if(!widget.isEnabled()) { + return; + } + defaultSize = this.offsetLeft; + optimizeSize(defaultSize); + mouseMoveTracker.captureMouseMoves(event); + }); + + function optimizeSize (s) { + return BI.clamp(s, 0, self._getGrayTrackLength()); + } + }, + + _createTrackWrapper: function () { + return BI.createWidget({ + type: "bi.absolute", + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.grayTrack, + top: 0, + left: 0, + width: "100%" + }, { + el: this.blueTrack, + top: 0, + left: 0, + width: "0%" + }] + }], + hgap: 8, + height: 8 + }, + top: 8, + left: 0, + width: "100%" + }] + }); + }, + + _checkValidation: function (v) { + return BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max); + }, + + _setBlueTrack: function (percent) { + this.blueTrack.element.css({width: percent + "%"}); + }, + + _setLabelPosition: function (percent) { + this.label.element.css({left: percent + "%"}); + }, + + _setSliderPosition: function (percent) { + this.slider.element.css({left: percent + "%"}); + }, + + _setAllPosition: function (percent) { + this._setSliderPosition(percent); + this._setLabelPosition(percent); + this._setBlueTrack(percent); + }, + + _setVisible: function (visible) { + this.slider.setVisible(visible); + this.label.setVisible(visible); + }, + + _getGrayTrackLength: function () { + return this.grayTrack.element[0].scrollWidth; + }, + + _getValueByPercent: function (percent) { + var thousandth = BI.parseInt(percent * 10); + return (((this.max - this.min) * thousandth) / 1000 + this.min); + }, + + _getPercentByValue: function (v) { + return (v - this.min) * 100 / (this.max - this.min); + }, + + _setEnable: function (b) { + BI.SingleSliderLabel.superclass._setEnable.apply(this, [b]); + if(b) { + this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); + } else { + this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); + } + }, + + getValue: function () { + return this.value; + }, + + setValue: function (v) { + var o = this.options; + v = BI.parseFloat(v); + v = o.digit === false ? v : v.toFixed(o.digit); + if ((!isNaN(v))) { + if (this._checkValidation(v)) { + this.value = v; + } + if (v > this.max) { + this.value = this.max; + } + if (v < this.min) { + this.value = this.min; + } + } + }, + + setMinAndMax: function (v) { + var minNumber = BI.parseFloat(v.min); + var maxNumber = BI.parseFloat(v.max); + if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) { + this.min = minNumber; + this.max = maxNumber; + } + }, + + reset: function () { + this._setVisible(false); + this.enable = false; + this.value = ""; + this.min = 0; + this.max = 0; + this._setBlueTrack(0); + }, + + populate: function () { + var o = this.options; + if (!isNaN(this.min) && !isNaN(this.max)) { + this._setVisible(true); + this.enable = true; + if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) { + this.label.setValue(this.value + o.unit); + this._setAllPosition(this._getPercentByValue(this.value)); + } else { + this.label.setValue(this.max + o.unit); + this._setAllPosition(100); + } + } + } +}); +BI.SingleSliderLabel.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_slider_label", BI.SingleSliderLabel);/** + * normal single slider + * Created by Young on 2017/6/21. + */ +BI.SingleSliderNormal = BI.inherit(BI.Widget, { + + _constant: { + HEIGHT: 28, + SLIDER_WIDTH_HALF: 15, + SLIDER_WIDTH: 30, + SLIDER_HEIGHT: 30, + TRACK_HEIGHT: 24 + }, + + props: { + baseCls: "bi-single-slider-normal bi-slider-track", + minMax: { + min: 0, + max: 100 + } + // color: "#3f8ce8" + }, + + render: function () { + var self = this; + var c = this._constant; + var track = this._createTrack(); + this.slider = BI.createWidget({ + type: "bi.single_slider_button" + }); + this._draggable(this.slider); + + var sliderVertical = BI.createWidget({ + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [this.slider] + }], + hgap: c.SLIDER_WIDTH_HALF, + height: c.SLIDER_HEIGHT + }); + sliderVertical.element.click(function (e) { + if (self.enable && self.isEnabled()) { + var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF; + var trackLength = self.track.element[0].scrollWidth; + var percent = 0; + if (offset < 0) { + percent = 0; + } + if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) { + percent = offset * 100 / self._getGrayTrackLength(); + } + if (offset > (trackLength - c.SLIDER_WIDTH)) { + percent = 100; + } + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setAllPosition(significantPercent); + var v = self._getValueByPercent(significantPercent); + self.value = v; + self.fireEvent(BI.SingleSlider.EVENT_CHANGE); + } + }); + + return { + type: "bi.absolute", + element: this, + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: track, + width: "100%", + height: c.TRACK_HEIGHT + }] + }], + hgap: 7, + height: c.TRACK_HEIGHT + }, + top: 3, + left: 0, + width: "100%" + }, { + el: sliderVertical, + top: 0, + left: 0, + width: "100%" + }] + }; + }, + + _draggable: function (widget) { + var self = this, o = this.options; + var startDrag = false; + var size = 0, offset = 0, defaultSize = 0; + var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { + if (mouseMoveTracker.isDragging()) { + startDrag = true; + offset += deltaX; + size = optimizeSize(defaultSize + offset); + widget.element.addClass("dragging"); + var percent = size * 100 / (self._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 + self._setBlueTrack(significantPercent); + self._setSliderPosition(significantPercent); + var v = self._getValueByPercent(significantPercent); + v = o.digit === false ? v : v.toFixed(o.digit); + self.value = v; + self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v); + } + }, function () { + if (startDrag === true) { + size = optimizeSize(size); + var percent = size * 100 / (self._getGrayTrackLength()); + var significantPercent = BI.parseFloat(percent.toFixed(1)); + self._setSliderPosition(significantPercent); + size = 0; + offset = 0; + defaultSize = size; + startDrag = false; + } + widget.element.removeClass("dragging"); + mouseMoveTracker.releaseMouseMoves(); + self.fireEvent(BI.SingleSlider.EVENT_CHANGE); + }, window); + widget.element.on("mousedown", function (event) { + if(!widget.isEnabled()) { + return; + } + defaultSize = this.offsetLeft; + optimizeSize(defaultSize); + mouseMoveTracker.captureMouseMoves(event); + }); + + function optimizeSize (s) { + return BI.clamp(s, 0, self._getGrayTrackLength()); + } + }, + + _createTrack: function () { + var self = this; + var c = this._constant; + this.grayTrack = BI.createWidget({ + type: "bi.layout", + cls: "gray-track", + height: 6 + }); + this.blueTrack = BI.createWidget({ + type: "bi.layout", + cls: "blue-track bi-high-light-background", + height: 6 + }); + if (this.options.color) { + this.blueTrack.element.css({"background-color": this.options.color}); + } + + return { + type: "bi.absolute", + items: [{ + el: { + type: "bi.vertical", + items: [{ + type: "bi.absolute", + items: [{ + el: this.grayTrack, + top: 0, + left: 0, + width: "100%" + }, { + el: this.blueTrack, + top: 0, + left: 0, + width: "0%" + }] + }], + hgap: 8, + height: 8 + }, + top: 8, + left: 0, + width: "100%" + }], + ref: function (ref) { + self.track = ref; + } + }; + }, + + _checkValidation: function (v) { + return !(BI.isNull(v) || v < this.min || v > this.max); + }, + + _setBlueTrack: function (percent) { + this.blueTrack.element.css({width: percent + "%"}); + }, + + _setSliderPosition: function (percent) { + this.slider.element.css({left: percent + "%"}); + }, + + _setAllPosition: function (percent) { + this._setSliderPosition(percent); + this._setBlueTrack(percent); + }, + + _setVisible: function (visible) { + this.slider.setVisible(visible); + }, + + _getGrayTrackLength: function () { + return this.grayTrack.element[0].scrollWidth; + }, + + _getValueByPercent: function (percent) { + var thousandth = BI.parseInt(percent * 10); + return (((this.max - this.min) * thousandth) / 1000 + this.min); + }, + + _getPercentByValue: function (v) { + return (v - this.min) * 100 / (this.max - this.min); + }, + + _setEnable: function (b) { + BI.SingleSliderNormal.superclass._setEnable.apply(this, [b]); + if(b) { + this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); + } else { + this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); + } + }, + + getValue: function () { + return this.value; + }, + + setValue: function (v) { + var value = BI.parseFloat(v); + if ((!isNaN(value))) { + if (this._checkValidation(value)) { + this.value = value; + } + if (value > this.max) { + this.value = this.max; + } + if (value < this.min) { + this.value = this.min; + } + } + }, + + setMinAndMax: function (v) { + var minNumber = BI.parseFloat(v.min); + var maxNumber = BI.parseFloat(v.max); + if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) { + this.min = minNumber; + this.max = maxNumber; + } + }, + + reset: function () { + this._setVisible(false); + this.enable = false; + this.value = ""; + this.min = 0; + this.max = 0; + this._setBlueTrack(0); + }, + + populate: function () { + if (!isNaN(this.min) && !isNaN(this.max)) { + this._setVisible(true); + this.enable = true; + if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) { + this._setAllPosition(this._getPercentByValue(this.value)); + } else { + this._setAllPosition(100); + } + } + } +}); +BI.SingleSliderNormal.EVENT_DRAG = "EVENT_DRAG"; +BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal);/** + * @class BI.SingleTreeCombo + * @extends BI.Widget + */ +BI.SingleTreeCombo = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-combo", + trigger: {}, + height: 24, + text: "", + items: [], + value: "" + }); + }, + + _init: function () { + BI.SingleTreeCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.trigger = BI.createWidget(BI.extend({ + type: "bi.single_tree_trigger", + text: o.text, + height: o.height, + items: o.items, + value: o.value + }, o.trigger)); + + this.popup = BI.createWidget({ + type: "bi.single_level_tree", + items: o.items, + value: o.value + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + element: this, + adjustLength: 2, + el: this.trigger, + popup: { + el: this.popup + } + }); + + this.combo.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments); + }); + + this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); + }); + }, + + populate: function (items) { + this.combo.populate(items); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.trigger.setValue(v); + this.popup.setValue(v); + }, + + getValue: function () { + return this.popup.getValue(); + } +}); + +BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE"; +BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/** + * @class BI.SingleTreePopup + * @extends BI.Pane + */ + +BI.SingleTreePopup = BI.inherit(BI.Pane, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-level-tree", + tipText: BI.i18nText("BI-No_Selected_Item"), + items: [], + value: "" + }); + }, + + _init: function () { + BI.SingleTreePopup.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.tree = BI.createWidget({ + type: "bi.level_tree", + expander: { + isDefaultInit: true + }, + items: o.items, + value: o.value, + chooseType: BI.Selection.Single + }); + + BI.createWidget({ + type: "bi.vertical", + element: this, + vgap: 5, + items: [this.tree] + }); + + this.tree.on(BI.Controller.EVENT_CHANGE, function () { + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + }); + + this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE); + }); + + this.check(); + }, + + getValue: function () { + return this.tree.getValue(); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.tree.setValue(v); + }, + + populate: function (items) { + BI.SingleTreePopup.superclass.populate.apply(this, arguments); + this.tree.populate(items); + } +}); + +BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.single_level_tree", BI.SingleTreePopup);/** + * @class BI.SingleTreeTrigger + * @extends BI.Trigger + */ + +BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { + + _defaultConfig: function () { + return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-single-tree-trigger", + height: 24, + text: "", + items: [], + value: "" + }); + }, + + _init: function () { + BI.SingleTreeTrigger.superclass._init.apply(this, arguments); + + var self = this, o = this.options; + + this.trigger = BI.createWidget({ + type: "bi.select_text_trigger", + element: this, + text: o.text, + items: o.items, + height: o.height, + value: o.value + }); + }, + + _checkTitle: function () { + var self = this, val = this.getValue(); + BI.any(this.options.items, function (i, item) { + if (val.contains(item.value)) { + self.trigger.setTitle(item.text || item.value); + return true; + } + }); + }, + + setValue: function (v) { + v = BI.isArray(v) ? v : [v]; + this.options.value = v; + this.trigger.setValue(v); + this._checkTitle(); + }, + + getValue: function () { + return this.options.value || []; + }, + + populate: function (items) { + BI.SingleTreeTrigger.superclass.populate.apply(this, arguments); + this.trigger.populate(items); + } + +}); + +BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/** + * 可以单选多选切换的树 + * + * Created by GUY on 2015/12/21. + * @class BI.SwitchTree + * @extends BI.Widget + */ +BI.SwitchTree = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-switch-tree", + items: [] + }); + }, + + _init: function () { + BI.SwitchTree.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.tab = BI.createWidget({ + type: "bi.tab", + element: this, + tab: null, + showIndex: BI.SwitchTree.SelectType.SingleSelect, + cardCreator: BI.bind(this._createTree, this) + }); + }, + + _createTree: function (type) { + var self = this, o = this.options; + switch (type) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree = BI.createWidget({ + type: "bi.multilayer_single_level_tree", + isDefaultInit: true, + items: BI.deepClone(o.items), + value: o.value + }); + this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.levelTree; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree = BI.createWidget({ + type: "bi.simple_tree", + items: this._removeIsParent(BI.deepClone(o.items)), + value: o.value + }); + this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { + self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); + }); + return this.tree; + } + }, + + _removeIsParent: function (items) { + BI.each(items, function (i, item) { + BI.isNotNull(item.isParent) && delete item.isParent; + }); + return items; + }, + + switchSelect: function () { + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.setSelect(BI.SwitchTree.SelectType.MultiSelect); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.setSelect(BI.SwitchTree.SelectType.SingleSelect); + break; + } + }, + + setSelect: function (v) { + this.tab.setSelect(v); + }, + + getSelect: function () { + return this.tab.getSelect(); + }, + + setValue: function (v) { + this.storeValue = v; + switch (this.getSelect()) { + case BI.SwitchTree.SelectType.SingleSelect: + this.levelTree.setValue(v); + break; + case BI.SwitchTree.SelectType.MultiSelect: + this.tree.setValue(v); + break; + } + }, + + getValue: function () { + return this.tab.getValue(); + }, + + populate: function (items) { + this.options.items = items; + if (BI.isNotNull(this.levelTree)) { + this.levelTree.populate(BI.deepClone(items)); + } + if (BI.isNotNull(this.tree)) { + this.tree.populate(this._removeIsParent(BI.deepClone(items))); + } + } +}); +BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; +BI.SwitchTree.SelectType = { + SingleSelect: BI.Selection.Single, + MultiSelect: BI.Selection.Multi +}; +BI.shortcut("bi.switch_tree", BI.SwitchTree); +/** + * Created by Baron on 2015/10/19. + */ +BI.DateInterval = BI.inherit(BI.Single, { + constants: { + height: 24, + width: 24, + lgap: 15, + offset: -15, + timeErrorCls: "time-error", + DATE_MIN_VALUE: "1900-01-01", + DATE_MAX_VALUE: "2099-12-31" + }, + _defaultConfig: function () { + var conf = BI.DateInterval.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-date-interval" + }); + }, + _init: function () { + var self = this, o = this.options; + BI.DateInterval.superclass._init.apply(this, arguments); + + o.value = o.value || {}; + this.left = this._createCombo(o.value.start); + this.right = this._createCombo(o.value.end); + this.label = BI.createWidget({ + type: "bi.label", + height: this.constants.height, + width: this.constants.width, + text: "-" + }); + BI.createWidget({ + element: self, + type: "bi.center", + hgap: 15, + height: this.constants.height, + items: [{ + type: "bi.absolute", + items: [{ + el: self.left, + left: this.constants.offset, + right: 0, + top: 0, + bottom: 0 + }] + }, { + type: "bi.absolute", + items: [{ + el: self.right, + left: 0, + right: this.constants.offset, + top: 0, + bottom: 0 + }] + }] + }); + BI.createWidget({ + type: "bi.horizontal_auto", + element: this, + items: [ + self.label + ] + }); + }, + + _createCombo: function (v) { + var self = this, o = this.options; + var combo = BI.createWidget({ + type: "bi.dynamic_date_combo", + behaviors: o.behaviors, + value: v + }); + combo.on(BI.DynamicDateCombo.EVENT_ERROR, function () { + self._clearTitle(); + BI.Bubbles.hide("error"); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.DateInterval.EVENT_ERROR); + }); + + combo.on(BI.DynamicDateCombo.EVENT_VALID, function () { + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.DateInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.DynamicDateCombo.EVENT_FOCUS, function () { + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.DateInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.left.hidePopupView(); + self.right.hidePopupView(); + }); + + combo.on(BI.DynamicDateCombo.EVENT_CONFIRM, function () { + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + self.fireEvent(BI.DateInterval.EVENT_ERROR); + }else{ + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.DateInterval.EVENT_CHANGE); + } + }); + return combo; + }, + _dateCheck: function (date) { + return BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") === date || + BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") === date || + BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") === date || + BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") === date; + }, + _checkVoid: function (obj) { + return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0]; + }, + _check: function (smallDate, bigDate) { + var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g); + return this._dateCheck(smallDate) && BI.checkDateLegal(smallDate) && this._checkVoid({ + year: smallObj[0], + month: smallObj[1], + day: smallObj[2] + }) && this._dateCheck(bigDate) && BI.checkDateLegal(bigDate) && this._checkVoid({ + year: bigObj[0], + month: bigObj[1], + day: bigObj[2] + }); + }, + _compare: function (smallDate, bigDate) { + smallDate = BI.parseDateTime(smallDate, "%Y-%X-%d").print("%Y-%X-%d"); + bigDate = BI.parseDateTime(bigDate, "%Y-%X-%d").print("%Y-%X-%d"); + return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; + }, + _setTitle: function (v) { + this.left.setTitle(v); + this.right.setTitle(v); + this.label.setTitle(v); + }, + _clearTitle: function () { + this.left.setTitle(""); + this.right.setTitle(""); + this.label.setTitle(""); + }, + setValue: function (date) { + date = date || {}; + this.left.setValue(date.start); + this.right.setValue(date.end); + }, + getValue: function () { + return {start: this.left.getValue(), end: this.right.getValue()}; + } +}); +BI.DateInterval.EVENT_VALID = "EVENT_VALID"; +BI.DateInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.DateInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.date_interval", BI.DateInterval);/** + * Created by Baron on 2015/10/19. + */ +BI.TimeInterval = BI.inherit(BI.Single, { + constants: { + height: 24, + width: 24, + lgap: 15, + offset: -15, + timeErrorCls: "time-error", + DATE_MIN_VALUE: "1900-01-01", + DATE_MAX_VALUE: "2099-12-31" + }, + _defaultConfig: function () { + var conf = BI.TimeInterval.superclass._defaultConfig.apply(this, arguments); + return BI.extend(conf, { + extraCls: "bi-time-interval" + }); + }, + _init: function () { + var self = this, o = this.options; + BI.TimeInterval.superclass._init.apply(this, arguments); + + o.value = o.value || {}; + this.left = this._createCombo(o.value.start); + this.right = this._createCombo(o.value.end); + this.label = BI.createWidget({ + type: "bi.label", + height: this.constants.height, + width: this.constants.width, + text: "-" + }); + BI.createWidget({ + element: self, + type: "bi.center", + hgap: 15, + height: this.constants.height, + items: [{ + type: "bi.absolute", + items: [{ + el: self.left, + left: this.constants.offset, + right: 0, + top: 0, + bottom: 0 + }] + }, { + type: "bi.absolute", + items: [{ + el: self.right, + left: 0, + right: this.constants.offset, + top: 0, + bottom: 0 + }] + }] + }); + BI.createWidget({ + type: "bi.horizontal_auto", + element: this, + items: [ + self.label + ] + }); + }, + + _createCombo: function (v) { + var self = this, o = this.options; + var combo = BI.createWidget({ + type: "bi.dynamic_date_time_combo", + behaviors: o.behaviors, + value: v + }); + combo.on(BI.DynamicDateTimeCombo.EVENT_ERROR, function () { + self._clearTitle(); + BI.Bubbles.hide("error"); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.TimeInterval.EVENT_ERROR); + }); + + combo.on(BI.DynamicDateTimeCombo.EVENT_VALID, function () { + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.TimeInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.DynamicDateTimeCombo.EVENT_FOCUS, function () { + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.TimeInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }); + + combo.on(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.left.hidePopupView(); + self.right.hidePopupView(); + }); + + combo.on(BI.DynamicDateTimeCombo.EVENT_CONFIRM, function () { + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + self.fireEvent(BI.TimeInterval.EVENT_ERROR); + }else{ + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.TimeInterval.EVENT_CHANGE); + } + }); + return combo; + }, + _dateCheck: function (date) { + return BI.parseDateTime(date, "%Y-%x-%d %H:%M:%S").print("%Y-%x-%d %H:%M:%S") === date || + BI.parseDateTime(date, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S") === date || + BI.parseDateTime(date, "%Y-%x-%e %H:%M:%S").print("%Y-%x-%e %H:%M:%S") === date || + BI.parseDateTime(date, "%Y-%X-%e %H:%M:%S").print("%Y-%X-%e %H:%M:%S") === date; + }, + _checkVoid: function (obj) { + return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0]; + }, + _check: function (smallDate, bigDate) { + var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g); + return this._dateCheck(smallDate) && BI.checkDateLegal(smallDate) && this._checkVoid({ + year: smallObj[0], + month: smallObj[1], + day: smallObj[2] + }) && this._dateCheck(bigDate) && BI.checkDateLegal(bigDate) && this._checkVoid({ + year: bigObj[0], + month: bigObj[1], + day: bigObj[2] + }); + }, + _compare: function (smallDate, bigDate) { + smallDate = BI.parseDateTime(smallDate, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S"); + bigDate = BI.parseDateTime(bigDate, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S"); + return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; + }, + _setTitle: function (v) { + this.left.setTitle(v); + this.right.setTitle(v); + this.label.setTitle(v); + }, + _clearTitle: function () { + this.left.setTitle(""); + this.right.setTitle(""); + this.label.setTitle(""); + }, + setValue: function (date) { + date = date || {}; + this.left.setValue(date.start); + this.right.setValue(date.end); + }, + getValue: function () { + return {start: this.left.getValue(), end: this.right.getValue()}; + } +}); +BI.TimeInterval.EVENT_VALID = "EVENT_VALID"; +BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.time_interval", BI.TimeInterval);/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.YearCard + * @extends BI.Trigger + */ +BI.DynamicYearCard = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-year-card" + }, + + render: function () { + var self = this; + return { + type: "bi.vertical", + items: [{ + type: "bi.label", + text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), + textAlign: "left", + height: 24 + }, { + type: "bi.dynamic_date_param_item", + ref: function () { + self.item = this; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }] + }], + vgap: 10, + hgap: 10 + }; + }, + + _createValue: function (type, v) { + return { + dateType: type, + value: Math.abs(v), + offset: v > 0 ? 1 : 0 + }; + }, + + setValue: function (v) { + v = v || {year: 0}; + this.item.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); + }, + + getValue: function () { + var value = this.item.getValue(); + return { + year: (value.offset === 0 ? -value.value : value.value) + }; + } +}); +BI.DynamicYearCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.dynamic_year_card", BI.DynamicYearCard);/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.StaticYearCard + * @extends BI.Trigger + */ +BI.StaticYearCard = BI.inherit(BI.Widget, { + + _defaultConfig: function () { + return BI.extend(BI.StaticYearCard.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-year-card", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31" // 最大日期 + }); + }, + + _createYearCalendar: function (v) { + var o = this.options, y = this._year; + + var calendar = BI.createWidget({ + type: "bi.year_calendar", + behaviors: o.behaviors, + min: o.min, + max: o.max, + logic: { + dynamic: true + }, + year: y + v * 12 + }); + calendar.setValue(this._year); + return calendar; + }, + + _init: function () { + BI.StaticYearCard.superclass._init.apply(this, arguments); + var self = this, o = this.options; + + this.selectedYear = this._year = BI.getDate().getFullYear(); + + this.backBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "pre-page-h-font", + width: 25, + height: 25, + value: -1, + listeners: [{ + eventName: BI.IconButton.EVENT_CHANGE, + action: function () { + self.navigation.setSelect(self.navigation.getSelect() - 1); + self._checkLeftValid(); + self._checkRightValid(); + } + }] + }); + + this.preBtn = BI.createWidget({ + type: "bi.icon_button", + cls: "next-page-h-font", + width: 25, + height: 25, + value: 1, + listeners: [{ + eventName: BI.IconButton.EVENT_CHANGE, + action: function () { + self.navigation.setSelect(self.navigation.getSelect() + 1); + self._checkLeftValid(); + self._checkRightValid(); + } + }] + }); + + this.navigation = BI.createWidget({ + type: "bi.navigation", + direction: "top", + element: this, + single: true, + logic: { + dynamic: true + }, + tab: { + type: "bi.htape", + cls: "bi-border-top bi-border-bottom", + height: 30, + items: [{ + el: { + type: "bi.center_adapt", + items: [self.backBtn] + }, + width: 25 + }, { + type: "bi.layout" + }, { + el: { + type: "bi.center_adapt", + items: [self.preBtn] + }, + width: 25 + }] + }, + cardCreator: BI.bind(this._createYearCalendar, this), + + afterCardShow: function () { + this.setValue(self.selectedYear); + var calendar = this.getSelectedCard(); + self.backBtn.setEnable(!calendar.isFrontYear()); + self.preBtn.setEnable(!calendar.isFinalYear()); + } + }); + + this.navigation.on(BI.Navigation.EVENT_CHANGE, function () { + self.selectedYear = this.getValue(); + self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); + self.fireEvent(BI.StaticYearCard.EVENT_CHANGE, self.selectedYear); + }); + + if(BI.isKey(o.value)){ + this.setValue(o.value); + } + }, + + _checkLeftValid: function () { + var o = this.options; + var valid = true; + this.backBtn.setEnable(valid); + return valid; + }, + + _checkRightValid: function () { + var o = this.options; + var valid = true; + this.preBtn.setEnable(valid); + return valid; + }, + + getValue: function () { + return { + year: this.selectedYear + }; + }, + + setValue: function (obj) { + var o = this.options; + obj = obj || {}; + var v = obj.year; + if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) { + v = BI.getDate().getFullYear(); + this.selectedYear = ""; + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(""); + } else { + this.selectedYear = BI.parseInt(v); + this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); + this.navigation.setValue(this.selectedYear); + } + this._checkLeftValid(); + this._checkRightValid(); + } +}); +BI.StaticYearCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.static_year_card", BI.StaticYearCard);BI.DynamicYearCombo = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-year-combo bi-border", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }, + + _init: function () { + BI.DynamicYearCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = o.value; + this.trigger = BI.createWidget({ + type: "bi.dynamic_year_trigger", + min: o.min, + max: o.max, + value: o.value || "" + }); + this.trigger.on(BI.DynamicYearTrigger.EVENT_FOCUS, function () { + self.storeTriggerValue = this.getKey(); + }); + this.trigger.on(BI.DynamicYearTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.DynamicYearTrigger.EVENT_STOP, function () { + self.combo.showView(); + }); + this.trigger.on(BI.DynamicYearTrigger.EVENT_ERROR, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.DynamicYearTrigger.EVENT_CONFIRM, function () { + if (self.combo.isViewVisible()) { + return; + } + if (this.getKey() && this.getKey() !== self.storeTriggerValue) { + self.storeValue = self.trigger.getValue(); + self.setValue(self.storeValue); + } else if (!this.getKey()) { + self.storeValue = null; + self.setValue(); + } + self._checkDynamicValue(self.storeValue); + self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: { + type: "bi.dynamic_year_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.DynamicYearPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE, + action: function () { + var date = BI.getDate(); + self.setValue({type: BI.DynamicYearCombo.Static, value: {year: date.getFullYear()}}); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + }, + value: o.value || "" + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + ref: function () { + self.comboWrapper = this; + }, + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: 24, + height: 24, + ref: function () { + self.changeIcon = this; + } + }, + width: 24 + }, this.combo] + }); + this._checkDynamicValue(o.value); + }, + + _checkDynamicValue: function (v) { + var type = null; + if (BI.isNotNull(v)) { + type = v.type; + } + switch (type) { + case BI.DynamicYearCombo.Dynamic: + this.changeIcon.setVisible(true); + this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.resize(); + break; + default: + this.comboWrapper.attr("items")[0].width = 0; + this.comboWrapper.resize(); + this.changeIcon.setVisible(false); + break; + } + }, + + setValue: function (v) { + this.storeValue = v; + this.trigger.setValue(v); + this._checkDynamicValue(v); + }, + + getValue: function () { + return this.storeValue; + } + +}); +BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.dynamic_year_combo", BI.DynamicYearCombo); + +BI.extend(BI.DynamicYearCombo, { + Static: 1, + Dynamic: 2 +});/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.DynamicYearPopup + * @extends BI.Trigger + */ +BI.DynamicYearPopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + buttonHeight: 24 + }, + + props: { + baseCls: "bi-year-popup", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期, + width: 180, + height: 240 + }, + + render: function () { + var self = this, opts = this.options, c = this.constants; + this.storeValue = {type: BI.DynamicYearCombo.Static}; + return { + type: "bi.vtape", + items: [{ + el: this._getTabJson() + }, { + el: { + type: "bi.grid", + items: [[{ + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-top bi-high-light", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_Clear"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + textHeight: c.buttonHeight - 1, + cls: "bi-border-left bi-border-right bi-high-light bi-border-top", + shadow: true, + text: BI.i18nText("BI-Basic_Current_Year"), + ref: function () { + self.textButton = this; + }, + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-top bi-high-light", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_OK"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE); + } + }] + }]] + }, + height: 24 + }] + }; + }, + + _setInnerValue: function () { + if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { + this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); + this.textButton.setEnable(true); + } else { + var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); + date = date.print("%Y"); + this.textButton.setValue(date); + this.textButton.setEnable(false); + } + }, + + _getTabJson: function () { + var self = this, o = this.options; + return { + type: "bi.tab", + ref: function () { + self.dateTab = this; + }, + tab: { + type: "bi.linear_segment", + cls: "bi-border-bottom", + height: this.constants.tabHeight, + items: BI.createItems([{ + text: BI.i18nText("BI-Basic_Year_Fen"), + value: BI.DynamicYearCombo.Static + }, { + text: BI.i18nText("BI-Basic_Dynamic_Title"), + value: BI.DynamicYearCombo.Dynamic + }], { + textAlign: "center" + }) + }, + cardCreator: function (v) { + switch (v) { + case BI.DynamicYearCombo.Dynamic: + return { + type: "bi.dynamic_year_card", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self._setInnerValue(self.year, v); + } + }], + ref: function () { + self.dynamicPane = this; + } + }; + case BI.DynamicYearCombo.Static: + default: + return { + type: "bi.static_year_card", + behaviors: o.behaviors, + min: self.options.min, + max: self.options.max, + listeners: [{ + eventName: BI.StaticYearCard.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearPopup.EVENT_CHANGE); + } + }], + ref: function () { + self.year = this; + } + }; + } + }, + listeners: [{ + eventName: BI.Tab.EVENT_CHANGE, + action: function () { + var v = self.dateTab.getSelect(); + switch (v) { + case BI.DynamicYearCombo.Static: + var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); + self.year.setValue({year: date.getFullYear()}); + self._setInnerValue(); + break; + case BI.DynamicYearCombo.Dynamic: + default: + if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) { + self.dynamicPane.setValue(self.storeValue.value); + }else{ + self.dynamicPane.setValue({ + year: 0 + }); + } + self._setInnerValue(); + break; + } + } + }] + }; + }, + + setValue: function (v) { + this.storeValue = v; + var self = this; + var type, value; + v = v || {}; + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + this.dateTab.setSelect(type); + switch (type) { + case BI.DynamicDateCombo.Dynamic: + this.dynamicPane.setValue(value); + self._setInnerValue(); + break; + case BI.DynamicDateCombo.Static: + default: + this.year.setValue(value); + this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); + this.textButton.setEnable(true); + break; + } + }, + + getValue: function () { + return { + type: this.dateTab.getSelect(), + value: this.dateTab.getValue() + }; + } + +}); +BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; +BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; +BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.DynamicYearPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2 + }, + + _defaultConfig: function () { + return BI.extend(BI.DynamicYearTrigger.superclass._defaultConfig.apply(this, arguments), { + extraCls: "bi-year-trigger", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }); + }, + + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + + _init: function () { + BI.DynamicYearTrigger.superclass._init.apply(this, arguments); + var self = this, o = this.options, c = this._const; + this.editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]); + }, + quitChecker: function (v) { + return false; + }, + hgap: c.hgap, + vgap: c.vgap, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + allowBlank: true, + errorText: function () { + return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + } + }); + this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.DynamicYearTrigger.EVENT_FOCUS); + }); + this.editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DynamicYearTrigger.EVENT_STOP); + }); + this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + var value = self.editor.getValue(); + if (BI.isNotNull(value)) { + self.editor.setValue(value); + } + if (BI.isNotEmptyString(value)) { + self.storeValue = { + type: BI.DynamicDateCombo.Static, + value: { + year: value + } + }; + } + + self.fireEvent(BI.DynamicYearTrigger.EVENT_CONFIRM); + }); + this.editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (self.editor.isValid()) { + self.editor.blur(); + } + }); + this.editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.DynamicYearTrigger.EVENT_START); + }); + this.editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DynamicYearTrigger.EVENT_ERROR); + }); + BI.createWidget({ + element: this, + type: "bi.htape", + items: [{ + el: this.editor + }, { + el: { + type: "bi.text_button", + baseCls: "bi-trigger-year-text", + text: BI.i18nText("BI-Multi_Date_Year"), + width: o.height + }, + width: o.height + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height + }, + width: o.height + }] + }); + this.setValue(o.value); + }, + + _getText: function (obj) { + var value = ""; + if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) { + value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + return value; + }, + + _setInnerValue: function (date, text) { + var dateStr = date.print("%Y"); + this.editor.setState(dateStr); + this.editor.setValue(dateStr); + }, + + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.editor.isValid()) { + return ""; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + var date = BI.getDate(); + date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return value.year; + } + }, + + setValue: function (v) { + var type, value; + var date = BI.getDate(); + this.storeValue = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + date = BI.DynamicDateHelper.getCalculation(value); + this._setInnerValue(date, text); + break; + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + this.editor.setState(value.year); + this.editor.setValue(value.year); + break; + } + }, + + getValue: function () { + return this.storeValue; + }, + + getKey: function () { + return this.editor.getValue() | 0; + } +}); +BI.DynamicYearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicYearTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicYearTrigger.EVENT_START = "EVENT_START"; +BI.DynamicYearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicYearTrigger.EVENT_STOP = "EVENT_STOP"; +BI.shortcut("bi.dynamic_year_trigger", BI.DynamicYearTrigger);/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.YearCard + * @extends BI.Trigger + */ +BI.DynamicYearMonthCard = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-year-month-card" + }, + + render: function () { + var self = this; + return { + type: "bi.vertical", + items: [{ + type: "bi.label", + text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), + textAlign: "left", + height: 24 + }, { + type: "bi.dynamic_date_param_item", + ref: function () { + self.year = this; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }] + }, { + type: "bi.dynamic_date_param_item", + dateType: BI.DynamicDateCard.TYPE.MONTH, + ref: function () { + self.month = this; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }] + }], + vgap: 10, + hgap: 10 + }; + }, + + _createValue: function (type, v) { + return { + dateType: type, + value: Math.abs(v), + offset: v > 0 ? 1 : 0 + }; + }, + + setValue: function (v) { + v = v || {year: 0, month: 0}; + this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); + this.month.setValue(this._createValue(BI.DynamicDateCard.TYPE.MONTH, v.month)); + }, + + getValue: function () { + var year = this.year.getValue(); + var month = this.month.getValue(); + return { + year: (year.offset === 0 ? -year.value : year.value), + month: (month.offset === 0 ? -month.value : month.value) + }; + } +}); +BI.DynamicYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.dynamic_year_month_card", BI.DynamicYearMonthCard);BI.StaticYearMonthCard = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-static-year-month-card", + behaviors: {} + }, + + _createMonths: function () { + // 纵向排列月 + var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]; + var items = []; + items.push(month.slice(0, 2)); + items.push(month.slice(2, 4)); + items.push(month.slice(4, 6)); + items.push(month.slice(6, 8)); + items.push(month.slice(8, 10)); + items.push(month.slice(10, 12)); + return BI.map(items, function (i, item) { + return BI.map(item, function (j, td) { + return { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "center", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 23, + width: 38, + value: td, + text: td + }; + }); + }); + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.year_picker", + ref: function () { + self.yearPicker = this; + }, + behaviors: o.behaviors, + height: 30, + listeners: [{ + eventName: BI.YearPicker.EVENT_CHANGE, + action: function () { + var value = this.getValue(); + self.setValue({ + year: value, + month: self.selectedMonth + }); + } + }] + }, { + type: "bi.button_group", + cls: "bi-border-top", + behaviors: o.behaviors, + ref: function () { + self.month = this; + }, + items: this._createMonths(), + layouts: [BI.LogicFactory.createLogic("table", BI.extend({ + dynamic: true + }, { + columns: 2, + rows: 6, + columnSize: [1 / 2, 1 / 2], + rowSize: 25 + })), { + type: "bi.center_adapt", + vgap: 1, + hgap: 2 + }], + value: o.value, + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function () { + self.selectedYear = self.yearPicker.getValue(); + self.selectedMonth = this.getValue()[0]; + self.fireEvent(BI.StaticYearMonthCard.EVENT_CHANGE); + } + }] + }] + }; + }, + + + getValue: function () { + return { + year: this.selectedYear, + month: this.selectedMonth + }; + }, + + setValue: function (obj) { + var o = this.options; + var newObj = {}; + newObj.year = obj.year || 0; + newObj.month = obj.month || 0; + if (newObj.year === 0 || newObj.month === 0 || BI.checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) { + var year = newObj.year || BI.getDate().getFullYear(); + this.selectedYear = year; + this.selectedMonth = ""; + this.yearPicker.setValue(year); + this.month.setValue(); + } else { + this.selectedYear = BI.parseInt(newObj.year); + this.selectedMonth = BI.parseInt(newObj.month); + this.yearPicker.setValue(this.selectedYear); + this.month.setValue(this.selectedMonth); + } + } +}); +BI.StaticYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.static_year_month_card", BI.StaticYearMonthCard); +BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { + + props: { + baseCls: "bi-year-month-combo bi-border", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }, + + _init: function () { + BI.DynamicYearMonthCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = o.value; + this.storeTriggerValue = ""; + this.trigger = BI.createWidget({ + type: "bi.dynamic_year_month_trigger", + min: o.min, + max: o.max, + value: o.value || "" + }); + this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_STOP, function () { + self.combo.showView(); + }); + this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_ERROR, function () { + self.combo.isViewVisible() && self.combo.hideView(); + self.fireEvent(BI.DynamicYearMonthCombo.EVENT_ERROR); + }); + this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_VALID, function () { + self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID); + }); + this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_CONFIRM, function () { + // 没看出来干啥的,先去掉 + // if (self.combo.isViewVisible()) { + // return; + // } + var dateStore = self.storeTriggerValue; + var dateObj = self.trigger.getKey(); + if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { + self.storeValue = self.trigger.getValue(); + self.setValue(self.trigger.getValue()); + } + self._checkDynamicValue(self.storeValue); + self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM); + }); + this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_FOCUS, function () { + self.storeTriggerValue = self.trigger.getKey(); + self.fireEvent(BI.DynamicYearMonthCombo.EVENT_FOCUS); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 100, + stopPropagation: false, + el: { + type: "bi.dynamic_year_month_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.DynamicYearMonthPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE, + action: function () { + var date = BI.getDate(); + self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), month: date.getMonth() + 1}}); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + }, + value: o.value || "" + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + ref: function () { + self.comboWrapper = this; + }, + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: 24, + height: 24, + ref: function () { + self.changeIcon = this; + } + }, + width: 24 + }, this.combo] + }); + this._checkDynamicValue(o.value); + }, + + _checkDynamicValue: function (v) { + var type = null; + if (BI.isNotNull(v)) { + type = v.type; + } + switch (type) { + case BI.DynamicYearMonthCombo.Dynamic: + this.changeIcon.setVisible(true); + this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.resize(); + break; + default: + this.comboWrapper.attr("items")[0].width = 0; + this.comboWrapper.resize(); + this.changeIcon.setVisible(false); + break; + } + }, + + hideView: function () { + this.combo.hideView(); + }, + + setValue: function (v) { + this.storeValue = v; + this.trigger.setValue(v); + this._checkDynamicValue(v); + }, + + getValue: function () { + return this.storeValue; + }, + + getKey: function () { + return this.trigger.getKey(); + }, + + isValid: function () { + return this.trigger.isValid(); + } + +}); +BI.DynamicYearMonthCombo.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicYearMonthCombo.EVENT_VALID = "EVENT_VALID"; +BI.DynamicYearMonthCombo.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicYearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.dynamic_year_month_combo", BI.DynamicYearMonthCombo); + +BI.extend(BI.DynamicYearMonthCombo, { + Static: 1, + Dynamic: 2 +});/** + * 年月 + * + * Created by GUY on 2015/9/2. + * @class BI.DynamicYearMonthPopup + * @extends BI.Trigger + */ +BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + buttonHeight: 24 + }, + + props: { + baseCls: "bi-year-month-popup", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期, + width: 180, + height: 240 + }, + + render: function () { + var self = this, opts = this.options, c = this.constants; + this.storeValue = {type: BI.DynamicYearMonthCombo.Static}; + return { + type: "bi.vtape", + items: [{ + el: this._getTabJson() + }, { + el: { + type: "bi.grid", + items: [[{ + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-top bi-high-light", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_Clear"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-left bi-border-right bi-high-light bi-border-top", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_Current_Month"), + ref: function () { + self.textButton = this; + }, + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-top bi-high-light", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_OK"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE); + } + }] + }]] + }, + height: 24 + }] + }; + }, + + _setInnerValue: function () { + if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { + this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); + this.textButton.setEnable(true); + } else { + var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); + date = date.print("%Y-%x"); + this.textButton.setValue(date); + this.textButton.setEnable(false); + } + }, + + _getTabJson: function () { + var self = this, o = this.options; + return { + type: "bi.tab", + ref: function () { + self.dateTab = this; + }, + tab: { + type: "bi.linear_segment", + cls: "bi-border-bottom", + height: this.constants.tabHeight, + items: BI.createItems([{ + text: BI.i18nText("BI-Basic_Year_Month"), + value: BI.DynamicYearCombo.Static + }, { + text: BI.i18nText("BI-Basic_Dynamic_Title"), + value: BI.DynamicYearCombo.Dynamic + }], { + textAlign: "center" + }) + }, + cardCreator: function (v) { + switch (v) { + case BI.DynamicYearCombo.Dynamic: + return { + type: "bi.dynamic_year_month_card", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self._setInnerValue(self.year, v); + } + }], + ref: function () { + self.dynamicPane = this; + } + }; + case BI.DynamicYearCombo.Static: + default: + return { + type: "bi.static_year_month_card", + behaviors: o.behaviors, + min: self.options.min, + max: self.options.max, + listeners: [{ + eventName: BI.StaticYearMonthCard.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearMonthPopup.EVENT_CHANGE); + } + }], + ref: function () { + self.year = this; + } + }; + } + }, + listeners: [{ + eventName: BI.Tab.EVENT_CHANGE, + action: function () { + var v = self.dateTab.getSelect(); + switch (v) { + case BI.DynamicYearCombo.Static: + var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); + self.year.setValue({year: date.getFullYear(), month: date.getMonth() + 1}); + self._setInnerValue(); + break; + case BI.DynamicYearCombo.Dynamic: + default: + if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) { + self.dynamicPane.setValue(self.storeValue.value); + }else{ + self.dynamicPane.setValue({ + year: 0 + }); + } + self._setInnerValue(); + break; + } + } + }] + }; + }, + + setValue: function (v) { + this.storeValue = v; + var self = this; + var type, value; + v = v || {}; + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + this.dateTab.setSelect(type); + switch (type) { + case BI.DynamicDateCombo.Dynamic: + this.dynamicPane.setValue(value); + self._setInnerValue(); + break; + case BI.DynamicDateCombo.Static: + default: + this.year.setValue(value); + this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); + this.textButton.setEnable(true); + break; + } + }, + + getValue: function () { + return { + type: this.dateTab.getSelect(), + value: this.dateTab.getValue() + }; + } + +}); +BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; +BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; +BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.DynamicYearMonthPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2 + }, + + props: { + extraCls: "bi-year-month-trigger", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }, + + beforeInit: function (callback) { + var o = this.options; + o.title = BI.bind(this._titleCreator, this); + callback(); + }, + + _init: function () { + BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); + var o = this.options; + + this.yearEditor = this._createEditor(true); + this.monthEditor = this._createEditor(false); + + BI.createWidget({ + element: this, + type: "bi.htape", + items: [{ + type: "bi.center", + items: [{ + type: "bi.htape", + items: [this.yearEditor, { + el: { + type: "bi.text_button", + text: BI.i18nText("BI-Multi_Date_Year"), + width: o.height + }, + width: o.height + }] + }, { + type: "bi.htape", + items: [this.monthEditor, { + el: { + type: "bi.text_button", + text: BI.i18nText("BI-Multi_Date_Month"), + width: o.height + }, + width: o.height}] + }] + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height + }, + width: o.height + }] + }); + this.setValue(o.value); + }, + + _createEditor: function (isYear) { + var self = this, o = this.options, c = this._const; + var editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + if(isYear) { + return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]); + } + return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 12) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]); + }, + quitChecker: function () { + return false; + }, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + errorText: function (v) { + return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + }, + hgap: c.hgap, + vgap: c.vgap, + allowBlank: true + }); + editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN); + }); + editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_FOCUS); + }); + editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_STOP); + }); + editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + self._doEditorConfirm(editor); + self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM); + }); + editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (editor.isValid()) { + editor.blur(); + } + }); + editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_START); + }); + editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_ERROR); + }); + editor.on(BI.SignEditor.EVENT_VALID, function () { + var year = self.yearEditor.getValue(); + var month = self.monthEditor.getValue(); + if(BI.isNotEmptyString(year) && BI.isNotEmptyString(month)) { + if(BI.isPositiveInteger(year) && month >= 1 && month <= 12 && !BI.checkDateVoid(year, month, 1, o.min, o.max)[0]) { + self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID); + } + } + }); + editor.on(BI.SignEditor.EVENT_CHANGE, function () { + if(isYear) { + self._autoSwitch(editor); + } + }); + + return editor; + }, + + _titleCreator: function () { + var storeValue = this.storeValue || {}; + var type = storeValue.type || BI.DynamicDateCombo.Static; + var value = storeValue.value; + if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) { + return ""; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + var date = BI.getDate(); + date = BI.DynamicDateHelper.getCalculation(value); + var dateStr = date.print("%Y-%x"); + return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + return this._getStaticTitle(value); + } + }, + + _doEditorConfirm: function (editor) { + var value = editor.getValue(); + if (BI.isNotNull(value)) { + editor.setValue(value); + } + var monthValue = this.monthEditor.getValue(); + this.storeValue = { + type: BI.DynamicDateCombo.Static, + value: { + year: this.yearEditor.getValue(), + month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue + } + }; + }, + + _yearCheck: function (v) { + var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; + }, + + _autoSwitch: function (editor) { + var v = editor.getValue(); + if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) { + if (v.length === 4 && this._yearCheck(v)) { + this._doEditorConfirm(editor); + this.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM); + this.monthEditor.focus(); + } + } + }, + + _getText: function (obj) { + var value = ""; + if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) { + value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + if(BI.isNotNull(obj.month) && BI.parseInt(obj.month) !== 0) { + value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + return value; + }, + + _setInnerValue: function (date, text) { + this.yearEditor.setValue(date.getFullYear()); + this.monthEditor.setValue(date.getMonth() + 1); + }, + + _getStaticTitle: function (value) { + value = value || {}; + var yearStr = (BI.isNull(value.year) || BI.isEmptyString(value.year)) ? "" : value.year; + var monthStr = (BI.isNull(value.month) || BI.isEmptyString(value.month)) ? "" : "-" + value.month; + return yearStr + monthStr; + }, + + setValue: function (v) { + var type, value; + var date = BI.getDate(); + this.storeValue = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + } + switch (type) { + case BI.DynamicDateCombo.Dynamic: + var text = this._getText(value); + date = BI.DynamicDateHelper.getCalculation(value); + this._setInnerValue(date, text); + break; + case BI.DynamicDateCombo.Static: + default: + value = value || {}; + var month = BI.isNull(value.month) ? null : value.month; + this.yearEditor.setValue(value.year); + this.monthEditor.setValue(month); + break; + } + }, + + getValue: function () { + return this.storeValue; + }, + + getKey: function () { + return this.yearEditor.getValue() + "-" + this.monthEditor.getValue(); + }, + + isValid: function () { + return this.yearEditor.isValid() && this.monthEditor.isValid(); + } +}); +BI.DynamicYearMonthTrigger.EVENT_VALID = "EVENT_VALID"; +BI.DynamicYearMonthTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicYearMonthTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicYearMonthTrigger.EVENT_START = "EVENT_START"; +BI.DynamicYearMonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicYearMonthTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.YearMonthInterval = BI.inherit(BI.Single, { + constants: { + height: 26, + width: 25, + lgap: 15, + offset: -15, + timeErrorCls: "time-error", + DATE_MIN_VALUE: "1900-01-01", + DATE_MAX_VALUE: "2099-12-31" + }, + + props: { + extraCls: "bi-year-month-interval" + }, + + _init: function () { + var self = this, o = this.options; + BI.YearMonthInterval.superclass._init.apply(this, arguments); + + o.value = o.value || {}; + this.left = this._createCombo(o.value.start); + this.right = this._createCombo(o.value.end); + this.label = BI.createWidget({ + type: "bi.label", + height: this.constants.height, + width: this.constants.width, + text: "-" + }); + BI.createWidget({ + element: self, + type: "bi.center", + hgap: 15, + height: this.constants.height, + items: [{ + type: "bi.absolute", + items: [{ + el: self.left, + left: this.constants.offset, + right: 0, + top: 0, + bottom: 0 + }] + }, { + type: "bi.absolute", + items: [{ + el: self.right, + left: 0, + right: this.constants.offset, + top: 0, + bottom: 0 + }] + }] + }); + BI.createWidget({ + type: "bi.horizontal_auto", + element: this, + items: [ + self.label + ] + }); + }, + + _createCombo: function (v) { + var self = this, o = this.options; + var combo = BI.createWidget({ + type: "bi.dynamic_year_month_combo", + behaviors: o.behaviors, + value: v, + listeners: [{ + eventName: BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, + action: function () { + self.fireEvent(BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW); + } + }] + }); + combo.on(BI.DynamicYearMonthCombo.EVENT_ERROR, function () { + self._clearTitle(); + BI.Bubbles.hide("error"); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); + }); + + combo.on(BI.DynamicYearMonthCombo.EVENT_VALID, function () { + self._checkValid(); + }); + + combo.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () { + self._checkValid(); + }); + + combo.on(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, function () { + self.left.hideView(); + self.right.hideView(); + }); + + combo.on(BI.DynamicYearMonthCombo.EVENT_CONFIRM, function () { + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); + }else{ + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + self.fireEvent(BI.YearMonthInterval.EVENT_CHANGE); + } + }); + return combo; + }, + + + _dateCheck: function (date) { + return BI.parseDateTime(date, "%Y-%x").print("%Y-%x") === date || BI.parseDateTime(date, "%Y-%X").print("%Y-%X") === date; + }, + + + // 判是否在最大最小之间 + _checkVoid: function (obj) { + return !BI.checkDateVoid(obj.year, obj.month, 1, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0]; + }, + + // 判格式合法 + _check: function (smallDate, bigDate) { + var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g); + + var smallDate4Check = ""; + if (BI.isNotNull(smallObj)) { + smallDate4Check = (smallObj[0] || "") + "-" + (smallObj[1] || 1); + } + + var bigDate4Check = ""; + if (BI.isNotNull(bigObj)) { + bigDate4Check = (bigObj[0] || "") + "-" + (bigObj[1] || 1); + } + + return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate) && this._checkVoid({ + year: smallObj[0], + month: smallObj[1], + day: 1 + }) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate) && this._checkVoid({ + year: bigObj[0], + month: bigObj[1], + day: 1 + }); + }, + + _compare: function (smallDate, bigDate) { + smallDate = BI.parseDateTime(smallDate, "%Y-%X").print("%Y-%X"); + bigDate = BI.parseDateTime(bigDate, "%Y-%X").print("%Y-%X"); + return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; + }, + _setTitle: function (v) { + this.setTitle(v); + }, + _clearTitle: function () { + this.setTitle(""); + }, + _checkValid: function () { + var self = this; + + BI.Bubbles.hide("error"); + var smallDate = self.left.getKey(), bigDate = self.right.getKey(); + if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { + self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); + self.element.addClass(self.constants.timeErrorCls); + BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { + offsetStyle: "center" + }); + self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); + } else { + self._clearTitle(); + self.element.removeClass(self.constants.timeErrorCls); + } + }, + setValue: function (date) { + date = date || {}; + this.left.setValue(date.start); + this.right.setValue(date.end); + + this._checkValid(); + }, + getValue: function () { + return {start: this.left.getValue(), end: this.right.getValue()}; + } +}); +BI.YearMonthInterval.EVENT_VALID = "EVENT_VALID"; +BI.YearMonthInterval.EVENT_ERROR = "EVENT_ERROR"; +BI.YearMonthInterval.EVENT_CHANGE = "EVENT_CHANGE"; +BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.year_month_interval", BI.YearMonthInterval); +/** + * 年份展示面板 + * + * Created by GUY on 2015/9/2. + * @class BI.YearCard + * @extends BI.Trigger + */ +BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-year-month-card" + }, + + render: function () { + var self = this; + return { + type: "bi.vertical", + items: [{ + type: "bi.label", + text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), + textAlign: "left", + height: 24 + }, { + type: "bi.dynamic_date_param_item", + ref: function () { + self.year = this; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }] + }, { + type: "bi.dynamic_date_param_item", + dateType: BI.DynamicDateCard.TYPE.QUARTER, + ref: function () { + self.quarter = this; + }, + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self.fireEvent("EVENT_CHANGE"); + } + }] + }], + vgap: 10, + hgap: 10 + }; + }, + + _createValue: function (type, v) { + return { + dateType: type, + value: Math.abs(v), + offset: v > 0 ? 1 : 0 + }; + }, + + setValue: function (v) { + v = v || {year: 0, month: 0}; + this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); + this.quarter.setValue(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter)); + }, + + getValue: function () { + var year = this.year.getValue(); + var quarter = this.quarter.getValue(); + return { + year: (year.offset === 0 ? -year.value : year.value), + quarter: (quarter.offset === 0 ? -quarter.value : quarter.value) + }; + } +}); +BI.DynamicYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.dynamic_year_quarter_card", BI.DynamicYearQuarterCard);BI.StaticYearQuarterCard = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-static-year-quarter-card", + behaviors: {} + }, + + _createQuarter: function () { + + var items = [{ + text: Date._QN[1], + value: 1 + }, { + text: Date._QN[2], + value: 2 + }, { + text: Date._QN[3], + value: 3 + }, { + text: Date._QN[4], + value: 4 + }]; + return BI.map(items, function (j, item) { + return BI.extend(item, { + type: "bi.text_item", + cls: "bi-list-item-active", + textAlign: "center", + whiteSpace: "nowrap", + once: false, + forceSelected: true, + height: 24 + }); + }); + }, + + render: function () { + var self = this, o = this.options; + return { + type: "bi.vertical", + items: [{ + type: "bi.year_picker", + ref: function () { + self.yearPicker = this; + }, + behaviors: o.behaviors, + height: 30, + listeners: [{ + eventName: BI.YearPicker.EVENT_CHANGE, + action: function () { + var value = this.getValue(); + self.setValue({ + year: value, + quarter: self.selectedQuarter + }); + } + }] + }, { + type: "bi.button_group", + behaviors: o.behaviors, + ref: function () { + self.quarter = this; + }, + items: this._createQuarter(), + layouts: [{ + type: "bi.vertical", + vgap: 10 + }], + value: o.value, + listeners: [{ + eventName: BI.ButtonGroup.EVENT_CHANGE, + action: function () { + self.selectedYear = self.yearPicker.getValue(); + self.selectedQuarter = this.getValue()[0]; + self.fireEvent(BI.StaticYearQuarterCard.EVENT_CHANGE); + } + }] + }] + }; + }, + + + getValue: function () { + return { + year: this.selectedYear, + quarter: this.selectedQuarter + }; + }, + + setValue: function (obj) { + var o = this.options; + var newObj = {}; + newObj.year = obj.year || 0; + newObj.quarter = obj.quarter || 0; + if (newObj.quarter === 0 || newObj.year === 0 || BI.checkDateVoid(newObj.year, newObj.quarter, 1, o.min, o.max)[0]) { + var year = newObj.year || BI.getDate().getFullYear(); + this.selectedYear = year; + this.selectedQuarter = ""; + this.yearPicker.setValue(year); + this.quarter.setValue(); + } else { + this.selectedYear = BI.parseInt(newObj.year); + this.selectedQuarter = BI.parseInt(newObj.quarter); + this.yearPicker.setValue(this.selectedYear); + this.quarter.setValue(this.selectedQuarter); + } + } +}); +BI.StaticYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.static_year_quarter_card", BI.StaticYearQuarterCard); +BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { + + props: { + baseCls: "bi-year-quarter-combo bi-border", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }, + + _init: function () { + BI.DynamicYearQuarterCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.storeValue = o.value; + self.storeTriggerValue = ""; + this.trigger = BI.createWidget({ + type: "bi.dynamic_year_quarter_trigger", + min: o.min, + max: o.max, + value: o.value || "" + }); + this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_START, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_STOP, function () { + self.combo.showView(); + }); + this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_ERROR, function () { + self.combo.isViewVisible() && self.combo.hideView(); + }); + this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM, function () { + // 没看出来干啥的,先去掉 + // if (self.combo.isViewVisible()) { + // return; + // } + var dateStore = self.storeTriggerValue; + var dateObj = self.trigger.getKey(); + if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { + self.storeValue = self.trigger.getValue(); + self.setValue(self.trigger.getValue()); + } + self._checkDynamicValue(self.storeValue); + self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM); + }); + this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_FOCUS, function () { + self.storeTriggerValue = self.trigger.getKey(); + }); + + this.combo = BI.createWidget({ + type: "bi.combo", + isNeedAdjustHeight: false, + isNeedAdjustWidth: false, + el: this.trigger, + popup: { + minWidth: 85, + stopPropagation: false, + el: { + type: "bi.dynamic_year_quarter_popup", + ref: function () { + self.popup = this; + }, + listeners: [{ + eventName: BI.DynamicYearQuarterPopup.EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE, + action: function () { + self.setValue(); + self.combo.hideView(); + self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE, + action: function () { + var date = BI.getDate(); + self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), quarter: date.getQuarter()}}); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }, { + eventName: BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE, + action: function () { + self.setValue(self.popup.getValue()); + self.combo.hideView(); + self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); + } + }], + behaviors: o.behaviors, + min: o.min, + max: o.max + }, + value: o.value || "" + } + }); + this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { + self.popup.setValue(self.storeValue); + self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW); + }); + + BI.createWidget({ + type: "bi.htape", + element: this, + ref: function () { + self.comboWrapper = this; + }, + items: [{ + el: { + type: "bi.icon_button", + cls: "bi-trigger-icon-button date-change-h-font", + width: 24, + height: 24, + ref: function () { + self.changeIcon = this; + } + }, + width: 24 + }, this.combo] + }); + this._checkDynamicValue(o.value); + }, + + _checkDynamicValue: function (v) { + var type = null; + if (BI.isNotNull(v)) { + type = v.type; + } + switch (type) { + case BI.DynamicYearQuarterCombo.Dynamic: + this.changeIcon.setVisible(true); + this.comboWrapper.attr("items")[0].width = 24; + this.comboWrapper.resize(); + break; + default: + this.comboWrapper.attr("items")[0].width = 0; + this.comboWrapper.resize(); + this.changeIcon.setVisible(false); + break; + } + }, + + setValue: function (v) { + this.storeValue = v; + this.trigger.setValue(v); + this._checkDynamicValue(v); + }, + + getValue: function () { + return this.storeValue; + } + +}); +BI.DynamicYearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; +BI.shortcut("bi.dynamic_year_quarter_combo", BI.DynamicYearQuarterCombo); + +BI.extend(BI.DynamicYearQuarterCombo, { + Static: 1, + Dynamic: 2 +});BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, { + constants: { + tabHeight: 30, + buttonHeight: 24 + }, + + props: { + baseCls: "bi-year-quarter-popup", + behaviors: {}, + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期, + width: 180, + height: 240 + }, + + render: function () { + var self = this, opts = this.options, c = this.constants; + this.storeValue = {type: BI.DynamicYearQuarterCombo.Static}; + return { + type: "bi.vtape", + items: [{ + el: this._getTabJson() + }, { + el: { + type: "bi.grid", + items: [[{ + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-top bi-high-light", + shadow: true, + textHeight: c.buttonHeight - 1, + text: BI.i18nText("BI-Basic_Clear"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-left bi-border-right bi-high-light bi-border-top", + textHeight: c.buttonHeight - 1, + shadow: true, + text: BI.i18nText("BI-Basic_Current_Quarter"), + ref: function () { + self.textButton = this; + }, + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE); + } + }] + }, { + type: "bi.text_button", + forceCenter: true, + cls: "bi-border-top bi-high-light", + shadow: true, + textHeight: c.buttonHeight - 1, + text: BI.i18nText("BI-Basic_OK"), + listeners: [{ + eventName: BI.TextButton.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE); + } + }] + }]] + }, + height: 24 + }] + }; + }, + + _setInnerValue: function () { + if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) { + this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); + this.textButton.setEnable(true); + } else { + var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); + date = date.print("%Y-%Q"); + this.textButton.setValue(date); + this.textButton.setEnable(false); + } + }, + + _getTabJson: function () { + var self = this, o = this.options; + return { + type: "bi.tab", + ref: function () { + self.dateTab = this; + }, + tab: { + type: "bi.linear_segment", + cls: "bi-border-bottom", + height: this.constants.tabHeight, + items: BI.createItems([{ + text: BI.i18nText("BI-Basic_Year_Quarter"), + value: BI.DynamicYearQuarterCombo.Static + }, { + text: BI.i18nText("BI-Basic_Dynamic_Title"), + value: BI.DynamicYearQuarterCombo.Dynamic + }], { + textAlign: "center" + }) + }, + cardCreator: function (v) { + switch (v) { + case BI.DynamicYearQuarterCombo.Dynamic: + return { + type: "bi.dynamic_year_quarter_card", + listeners: [{ + eventName: "EVENT_CHANGE", + action: function () { + self._setInnerValue(self.year, v); + } + }], + ref: function () { + self.dynamicPane = this; + } + }; + case BI.DynamicYearQuarterCombo.Static: + default: + return { + type: "bi.static_year_quarter_card", + behaviors: o.behaviors, + min: self.options.min, + max: self.options.max, + listeners: [{ + eventName: BI.DynamicYearCard.EVENT_CHANGE, + action: function () { + self.fireEvent(BI.DynamicYearQuarterPopup.EVENT_CHANGE); + } + }], + ref: function () { + self.year = this; + } + }; + } + }, + listeners: [{ + eventName: BI.Tab.EVENT_CHANGE, + action: function () { + var v = self.dateTab.getSelect(); + switch (v) { + case BI.DynamicYearQuarterCombo.Static: + var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); + self.year.setValue({year: date.getFullYear(), quarter: date.getQuarter()}); + self._setInnerValue(); + break; + case BI.DynamicYearQuarterCombo.Dynamic: + default: + if(self.storeValue && self.storeValue.type === BI.DynamicYearQuarterCombo.Dynamic) { + self.dynamicPane.setValue(self.storeValue.value); + }else{ + self.dynamicPane.setValue({ + year: 0 + }); + } + self._setInnerValue(); + break; + } + } + }] + }; + }, + + setValue: function (v) { + this.storeValue = v; + var self = this; + var type, value; + v = v || {}; + type = v.type || BI.DynamicDateCombo.Static; + value = v.value || v; + this.dateTab.setSelect(type); + switch (type) { + case BI.DynamicDateCombo.Dynamic: + this.dynamicPane.setValue(value); + self._setInnerValue(); + break; + case BI.DynamicDateCombo.Static: + default: + this.year.setValue(value); + this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); + this.textButton.setEnable(true); + break; + } + }, + + getValue: function () { + return { + type: this.dateTab.getSelect(), + value: this.dateTab.getValue() + }; + } + +}); +BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; +BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; +BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; +BI.DynamicYearQuarterPopup.EVENT_CHANGE = "EVENT_CHANGE"; +BI.shortcut("bi.dynamic_year_quarter_popup", BI.DynamicYearQuarterPopup);BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { + _const: { + hgap: 4, + vgap: 2 + }, + + props: { + extraCls: "bi-year-quarter-trigger", + min: "1900-01-01", // 最小日期 + max: "2099-12-31", // 最大日期 + height: 24 + }, + + _init: function () { + BI.DynamicYearQuarterTrigger.superclass._init.apply(this, arguments); + var o = this.options; + + this.yearEditor = this._createEditor(true); + this.quarterEditor = this._createEditor(false); + + BI.createWidget({ + element: this, + type: "bi.htape", + items: [{ + type: "bi.center", + items: [{ + type: "bi.htape", + items: [this.yearEditor, { + el: { + type: "bi.text_button", + text: BI.i18nText("BI-Multi_Date_Year"), + width: o.height + }, + width: o.height + }] + }, { + type: "bi.htape", + items: [this.quarterEditor, { + el: { + type: "bi.text_button", + text: BI.i18nText("BI-Multi_Date_Quarter"), + width: o.height + }, + width: o.height}] + }] + }, { + el: { + type: "bi.trigger_icon_button", + width: o.height + }, + width: o.height + }] + }); + this.setValue(o.value); + }, + + _createEditor: function (isYear) { + var self = this, o = this.options, c = this._const; + var editor = BI.createWidget({ + type: "bi.sign_editor", + height: o.height, + validationChecker: function (v) { + if(isYear) { + return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]); + } + return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 4) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]); + }, + quitChecker: function () { + return false; + }, + errorText: function (v) { + return BI.i18nText("BI-Year_Trigger_Invalid_Text"); + }, + watermark: BI.i18nText("BI-Basic_Unrestricted"), + hgap: c.hgap, + vgap: c.vgap, + title: "", + allowBlank: true + }); + editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { + self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN); + }); + editor.on(BI.SignEditor.EVENT_FOCUS, function () { + self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_FOCUS); + }); + editor.on(BI.SignEditor.EVENT_STOP, function () { + self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_STOP); + }); + editor.on(BI.SignEditor.EVENT_CONFIRM, function () { + self._doEditorConfirm(editor); + self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM); + }); + editor.on(BI.SignEditor.EVENT_SPACE, function () { + if (editor.isValid()) { + editor.blur(); + } + }); + editor.on(BI.SignEditor.EVENT_START, function () { + self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_START); + }); + editor.on(BI.SignEditor.EVENT_ERROR, function () { + self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_ERROR); + }); + editor.on(BI.SignEditor.EVENT_CHANGE, function () { + if(isYear) { + self._autoSwitch(editor); + } + }); + + return editor; + }, + + _doEditorConfirm: function (editor) { + var value = editor.getValue(); + if (BI.isNotNull(value)) { + editor.setValue(value); + } + var quarterValue = this.quarterEditor.getValue(); + this.storeValue = { + type: BI.DynamicYearQuarterCombo.Static, + value: { + year: this.yearEditor.getValue(), + quarter: BI.isEmptyString(this.quarterEditor.getValue()) ? "" : quarterValue + } + }; + this.setTitle(this._getStaticTitle(this.storeValue.value)); + }, + + _yearCheck: function (v) { + var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); + return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; + }, + + _autoSwitch: function (editor) { + var v = editor.getValue(); + if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) { + if (v.length === 4 && this._yearCheck(v)) { + this._doEditorConfirm(editor); + this.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM); + this.quarterEditor.focus(); + } + } + }, + + _getStaticTitle: function (value) { + value = value || {}; + var yearStr = (BI.isNull(value.year) || BI.isEmptyString(value.year)) ? "" : value.year; + var quarterStr = (BI.isNull(value.quarter) || BI.isEmptyString(value.quarter)) ? "" : "-" + value.quarter; + return yearStr + quarterStr; + }, + + _getText: function (obj) { + var value = ""; + if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) { + value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + if(BI.isNotNull(obj.quarter) && BI.parseInt(obj.quarter) !== 0) { + value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); + } + return value; + }, + + _setInnerValue: function (date, text) { + var dateStr = date.print("%Y-%Q"); + this.yearEditor.setValue(date.getFullYear()); + this.quarterEditor.setValue(date.getQuarter()); + this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); + }, + + setValue: function (v) { + var type, value; + var date = BI.getDate(); + this.storeValue = v; + if (BI.isNotNull(v)) { + type = v.type || BI.DynamicYearQuarterCombo.Static; + value = v.value || v; + } + switch (type) { + case BI.DynamicYearQuarterCombo.Dynamic: + var text = this._getText(value); + date = BI.DynamicDateHelper.getCalculation(value); + this._setInnerValue(date, text); + break; + case BI.DynamicYearQuarterCombo.Static: + default: + value = value || {}; + var quarter = BI.isNull(value.quarter) ? null : value.quarter; + this.yearEditor.setValue(value.year); + this.yearEditor.setTitle(value.year); + this.quarterEditor.setValue(quarter); + this.quarterEditor.setTitle(quarter); + this.setTitle(this._getStaticTitle(value)); + break; + } + }, + + getValue: function () { + return this.storeValue; + }, + + getKey: function () { + return this.yearEditor.getValue() + "-" + this.quarterEditor.getValue(); + } +}); +BI.DynamicYearQuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS"; +BI.DynamicYearQuarterTrigger.EVENT_ERROR = "EVENT_ERROR"; +BI.DynamicYearQuarterTrigger.EVENT_START = "EVENT_START"; +BI.DynamicYearQuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; +BI.DynamicYearQuarterTrigger.EVENT_STOP = "EVENT_STOP"; +BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; +BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger);/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 + * 封装了字段处理逻辑 + * + * Created by GUY on 2015/10/29. + * @class BI.AbstractAllValueChooser + * @extends BI.Widget + */ +BI.AbstractAllValueChooser = BI.inherit(BI.Widget, { + + _const: { + perPage: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), { + width: 200, + height: 30, + items: null, + itemsCreator: BI.emptyFn, + cache: true + }); + }, + + _valueFormatter: function (v) { + var text = v; + if (BI.isNotNull(this.items)) { + BI.some(this.items, function (i, item) { + // 把value都换成字符串 + // 需要考虑到value也可能是数字 + if (item.value === v || item.value + "" === v) { + text = item.text; + return true; + } + }); + } + return text; + }, + + _itemsCreator: function (options, callback) { + var self = this, o = this.options; + if (!o.cache || !this.items) { + o.itemsCreator({}, function (items) { + self.items = items; + call(items); + }); + } else { + call(this.items); + } + function call (items) { + var keywords = (options.keywords || []).slice(); + if (options.keyword) { + keywords.push(options.keyword); + } + BI.each(keywords, function (i, kw) { + var search = BI.Func.getSearchResult(items, kw); + items = search.match.concat(search.find); + }); + if (options.selectedValues) {// 过滤 + var filter = BI.makeObject(options.selectedValues, true); + items = BI.filter(items, function (i, ob) { + return !filter[ob.value]; + }); + } + if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) { + callback({ + items: items + }); + return; + } + if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { + callback({count: items.length}); + return; + } + callback({ + items: items, + hasNext: false + }); + } + } +});/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 + * 封装了字段处理逻辑 + * + * Created by GUY on 2015/10/29. + * @class BI.AllValueChooserCombo + * @extends BI.AbstractAllValueChooser + */ +BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, { + + _defaultConfig: function () { + return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-all-value-chooser-combo", + width: 200, + height: 30, + items: null, + itemsCreator: BI.emptyFn, + cache: true + }); + }, + + _init: function () { + BI.AllValueChooserCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + if (BI.isNotNull(o.items)) { + this.items = o.items; + } + this.combo = BI.createWidget({ + type: "bi.multi_select_combo", + text: o.text, + element: this, + itemsCreator: BI.bind(this._itemsCreator, this), + valueFormatter: BI.bind(this._valueFormatter, this), + width: o.width, + height: o.height, + value: { + type: BI.Selection.Multi, + value: o.value || [] + } + }); + + this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM); + }); + }, + + setValue: function (v) { + this.combo.setValue({ + type: BI.Selection.Multi, + value: v || [] + }); + }, + + getValue: function () { + var val = this.combo.getValue() || {}; + if (val.type === BI.Selection.All) { + return val.assist; + } + return val.value || []; + }, + + populate: function (items) { + // 直接用combo的populate不会作用到AbstractValueChooser上 + this.items = items; + this.combo.populate.apply(this, arguments); + } +}); +BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM"; +BI.shortcut("bi.all_value_chooser_combo", BI.AllValueChooserCombo);/** + * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 + * 封装了字段处理逻辑 + * + * Created by GUY on 2015/10/29. + * @class BI.AllValueChooserPane + * @extends BI.AbstractAllValueChooser + */ +BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, { + + _defaultConfig: function () { + return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-all-value-chooser-pane", + width: 200, + height: 30, + items: null, + itemsCreator: BI.emptyFn, + cache: true + }); + }, + + _init: function () { + BI.AllValueChooserPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + if (BI.isNotNull(o.items)) { + this.items = o.items; + } + this.list = BI.createWidget({ + type: "bi.multi_select_list", + element: this, + itemsCreator: BI.bind(this._itemsCreator, this), + valueFormatter: BI.bind(this._valueFormatter, this), + width: o.width, + height: o.height + }); + + this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE); + }); + }, + + setValue: function (v) { + this.list.setValue({ + type: BI.Selection.Multi, + value: v || [] + }); + }, + + getValue: function () { + var val = this.list.getValue() || {}; + if (val.type === BI.Selection.All) { + return val.assist; + } + return val.value || []; + }, + + populate: function (items) { + // 直接用combo的populate不会作用到AbstractValueChooser上 + this.items = items; + this.list.populate.apply(this.list, arguments); + } +}); +BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE"; +BI.shortcut("bi.all_value_chooser_pane", BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { + + _const: { + perPage: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), { + items: null, + itemsCreator: BI.emptyFn + }); + }, + + _valueFormatter: function (v) { + var text = v; + if (BI.isNotNull(this.items)) { + BI.some(this.items, function (i, item) { + if (item.value + "" === v) { + text = item.text; + return true; + } + }); + } + return text; + }, + + _initData: function (items) { + this.items = items; + var nodes = BI.Tree.treeFormat(items); + this.tree = new BI.Tree(); + this.tree.initTree(nodes); + }, + + _itemsCreator: function (options, callback) { + var self = this, o = this.options; + if (!this.items) { + o.itemsCreator({}, function (items) { + self._initData(items); + call(); + }); + } else { + call(); + } + function call () { + switch (options.type) { + case BI.TreeView.REQ_TYPE_INIT_DATA: + self._reqInitTreeNode(options, callback); + break; + case BI.TreeView.REQ_TYPE_ADJUST_DATA: + self._reqAdjustTreeNode(options, callback); + break; + case BI.TreeView.REQ_TYPE_SELECT_DATA: + self._reqSelectedTreeNode(options, callback); + break; + case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA: + self._reqDisplayTreeNode(options, callback); + break; + default : + self._reqTreeNode(options, callback); + break; + } + } + }, + + _reqDisplayTreeNode: function (op, callback) { + var self = this; + var result = []; + var selectedValues = op.selectedValues; + + if (selectedValues == null || BI.isEmpty(selectedValues)) { + callback({}); + return; + } + + doCheck([], this.tree.getRoot(), selectedValues); + + callback({ + items: result + }); + + function doCheck (parentValues, node, selected) { + if (selected == null || BI.isEmpty(selected)) { + BI.each(node.getChildren(), function (i, child) { + var newParents = BI.clone(parentValues); + newParents.push(child.value); + var llen = self._getChildCount(newParents); + createOneJson(child, node.id, llen); + doCheck(newParents, child, {}); + }); + return; + } + BI.each(selected, function (k) { + var node = self._getTreeNode(parentValues, k); + var newParents = BI.clone(parentValues); + newParents.push(node.value); + createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents)); + doCheck(newParents, node, selected[k]); + }); + } + + function getCount (jo, parentValues) { + if (jo == null) { + return 0; + } + if (BI.isEmpty(jo)) { + return self._getChildCount(parentValues); + } + + return BI.size(jo); + } + + function createOneJson (node, pId, llen) { + result.push({ + id: node.id, + pId: pId, + text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""), + value: node.value, + open: true + }); + } + }, + + _reqSelectedTreeNode: function (op, callback) { + var self = this; + var selectedValues = BI.deepClone(op.selectedValues); + var notSelectedValue = op.notSelectedValue || {}; + var keyword = op.keyword || ""; + var parentValues = op.parentValues || []; + + if (selectedValues == null || BI.isEmpty(selectedValues)) { + callback({}); + return; + } + + dealWithSelectedValues(selectedValues); + callback(selectedValues); + + + function dealWithSelectedValues (selectedValues) { + var p = parentValues.concat(notSelectedValue); + // 存储的值中存在这个值就把它删掉 + // 例如选中了中国-江苏-南京, 取消中国或江苏或南京 + if (canFindKey(selectedValues, p)) { + // 如果搜索的值在父亲链中 + if (isSearchValueInParent(p)) { + // 例如选中了 中国-江苏, 搜索江苏, 取消江苏 + // 例如选中了 中国-江苏, 搜索江苏, 取消中国 + self._deleteNode(selectedValues, p); + } else { + var searched = []; + var find = search(parentValues, notSelectedValue, [], searched); + if (find && BI.isNotEmptyArray(searched)) { + BI.each(searched, function (i, arr) { + var node = self._getNode(selectedValues, arr); + if (node) { + // 例如选中了 中国-江苏-南京,搜索南京,取消中国 + self._deleteNode(selectedValues, arr); + } else { + // 例如选中了 中国-江苏,搜索南京,取消中国 + expandSelectedValue(selectedValues, arr, BI.last(arr)); + } + }); + } + } + } + + // 存储的值中不存在这个值,但父亲节点是全选的情况 + // 例如选中了中国-江苏,取消南京 + // important 选中了中国-江苏,取消了江苏,但是搜索的是南京 + if (isChild(selectedValues, p)) { + var result = [], find = false; + // 如果parentValues中有匹配的值,说明搜索结果不在当前值下 + if (isSearchValueInParent(p)) { + find = true; + } else { + // 从当前值开始搜 + find = search(parentValues, notSelectedValue, result); + p = parentValues; + } + + if (find === true) { + // 去掉点击的节点之后的结果集 + expandSelectedValue(selectedValues, p, notSelectedValue); + // 添加去掉搜索的结果集 + if (result.length > 0) { + BI.each(result, function (i, strs) { + self._buildTree(selectedValues, strs); + }); + } + } + } + + } + + function expandSelectedValue (selectedValues, parents, notSelectedValue) { + var next = selectedValues; + var childrenCount = []; + var path = []; + // 去掉点击的节点之后的结果集 + BI.some(parents, function (i, v) { + var t = next[v]; + if (t == null) { + if (i === 0) { + return true; + } + if (BI.isEmpty(next)) { + var split = parents.slice(0, i); + var expanded = self._getChildren(split); + path.push(split); + childrenCount.push(expanded.length); + // 如果只有一个值且取消的就是这个值 + if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) { + for (var j = childrenCount.length - 1; j >= 0; j--) { + if (childrenCount[j] === 1) { + self._deleteNode(selectedValues, path[j]); + } else { + break; + } + } + } else { + BI.each(expanded, function (m, child) { + if (i === parents.length - 1 && child.value === notSelectedValue) { + return true; + } + next[child.value] = {}; + }); + } + next = next[v]; + } else { + return true; + // next = {}; + // next[v] = {}; + } + } else { + next = t; + } + }); + } + + function search (parents, current, result, searched) { + var newParents = BI.clone(parents); + newParents.push(current); + if (self._isMatch(parents, current, keyword)) { + searched && searched.push(newParents); + return true; + } + + var children = self._getChildren(newParents); + + var notSearch = []; + var can = false; + + BI.each(children, function (i, child) { + if (search(newParents, child.value, result, searched)) { + can = true; + } else { + notSearch.push(child.value); + } + }); + if (can === true) { + BI.each(notSearch, function (i, v) { + var next = BI.clone(newParents); + next.push(v); + result.push(next); + }); + } + return can; + } + + function isSearchValueInParent (parentValues) { + for (var i = 0, len = parentValues.length; i < len; i++) { + if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) { + return true; + } + } + return false; + } + + function canFindKey (selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + t = t[v]; + if (t == null) { + return false; + } + } + return true; + } + + function isChild (selectedValues, parents) { + var t = selectedValues; + for (var i = 0; i < parents.length; i++) { + var v = parents[i]; + if (!BI.has(t, v)) { + return false; + } + t = t[v]; + if (BI.isEmpty(t)) { + return true; + } + } + return false; + } + }, + + _reqAdjustTreeNode: function (op, callback) { + var self = this; + var result = []; + var selectedValues = op.selectedValues; + if (selectedValues == null || BI.isEmpty(selectedValues)) { + callback({}); + return; + } + BI.each(selectedValues, function (k, v) { + result.push([k]); + }); + + dealWithSelectedValues(selectedValues, []); + + var jo = {}; + BI.each(result, function (i, strs) { + self._buildTree(jo, strs); + }); + callback(jo); + + function dealWithSelectedValues (selected, parents) { + if (selected == null || BI.isEmpty(selected)) { + return true; + } + var can = true; + BI.each(selected, function (k, v) { + var p = BI.clone(parents); + p.push(k); + if (!dealWithSelectedValues(selected[k], p)) { + BI.each(selected[k], function (nk, nv) { + var t = BI.clone(p); + t.push(nk); + result.push(t); + }); + can = false; + } + }); + return can && isAllSelected(selected, parents); + } + + function isAllSelected (selected, parents) { + return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected); + } + }, + + _reqInitTreeNode: function (op, callback) { + var self = this; + var result = []; + var keyword = op.keyword || ""; + var selectedValues = op.selectedValues; + var lastSearchValue = op.lastSearchValue || ""; + var output = search(); + BI.nextTick(function () { + callback({ + hasNext: output.length > self._const.perPage, + items: result, + lastSearchValue: BI.last(output) + }); + }); + + function search () { + var children = self._getChildren([]); + var start = children.length; + if (lastSearchValue !== "") { + for (var j = 0, len = start; j < len; j++) { + if (children[j].value === lastSearchValue) { + start = j + 1; + break; + } + } + } else { + start = 0; + } + var output = []; + for (var i = start, len = children.length; i < len; i++) { + if (output.length < self._const.perPage) { + var find = nodeSearch(1, [], children[i].value, false, result); + } else if (output.length === self._const.perPage) { + var find = nodeSearch(1, [], children[i].value, false, []); + } + if (find[0] === true) { + output.push(children[i].value); + } + if (output.length > self._const.perPage) { + break; + } + } + return output; + } + + function nodeSearch (deep, parentValues, current, isAllSelect, result) { + if (self._isMatch(parentValues, current, keyword)) { + var checked = isAllSelect || isSelected(parentValues, current); + createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result); + return [true, checked]; + } + var newParents = BI.clone(parentValues); + newParents.push(current); + var children = self._getChildren(newParents); + + var can = false, checked = false; + + var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current); + BI.each(children, function (i, child) { + var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result); + if (state[1] === true) { + checked = true; + } + if (state[0] === true) { + can = true; + } + }); + if (can === true) { + checked = isCurAllSelected || (isSelected(parentValues, current) && checked); + createOneJson(parentValues, current, true, checked, false, false, result); + } + return [can, checked]; + } + + function createOneJson (parentValues, value, isOpen, checked, half, flag, result) { + var node = self._getTreeNode(parentValues, value); + result.push({ + id: node.id, + pId: node.pId, + text: node.text, + value: node.value, + title: node.title, + isParent: node.getChildrenLength() > 0, + open: isOpen, + checked: checked, + halfCheck: half, + flag: flag + }); + } + + function isHalf (parentValues, value) { + var find = findSelectedObj(parentValues); + if (find == null) { + return null; + } + return BI.any(find, function (v, ob) { + if (v === value) { + if (ob != null && !BI.isEmpty(ob)) { + return true; + } + } + }); + } + + function isAllSelected (parentValues, value) { + var find = findSelectedObj(parentValues); + if (find == null) { + return null; + } + return BI.any(find, function (v, ob) { + if (v === value) { + if (ob != null && BI.isEmpty(ob)) { + return true; + } + } + }); + } + + function isSelected (parentValues, value) { + var find = findSelectedObj(parentValues); + if (find == null) { + return false; + } + return BI.any(find, function (v) { + if (v === value) { + return true; + } + }); + } + + function findSelectedObj (parentValues) { + var find = selectedValues; + if (find == null) { + return null; + } + BI.every(parentValues, function (i, v) { + find = find[v]; + if (find == null) { + return false; + } + return true; + }); + return find; + } + }, + + _reqTreeNode: function (op, callback) { + var self = this; + var result = []; + var times = op.times; + var checkState = op.checkState || {}; + var parentValues = op.parentValues || []; + var selectedValues = op.selectedValues || {}; + var valueMap = {}; + // if (judgeState(parentValues, selectedValues, checkState)) { + valueMap = dealWidthSelectedValue(parentValues, selectedValues); + // } + var nodes = this._getChildren(parentValues); + for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { + var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); + result.push({ + id: nodes[i].id, + pId: nodes[i].pId, + value: nodes[i].value, + text: nodes[i].text, + times: 1, + isParent: nodes[i].getChildrenLength() > 0, + checked: state[0], + halfCheck: state[1] + }); + } + BI.nextTick(function () { + callback({ + items: result, + hasNext: nodes.length > times * self._const.perPage + }); + }); + + function judgeState (parentValues, selected_value, checkState) { + var checked = checkState.checked, half = checkState.half; + if (parentValues.length > 0 && !checked) { + return false; + } + return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value)); + } + + function dealWidthSelectedValue (parentValues, selectedValues) { + var valueMap = {}; + BI.each(parentValues, function (i, v) { + selectedValues = selectedValues[v] || {}; + }); + BI.each(selectedValues, function (value, obj) { + if (BI.isNull(obj)) { + valueMap[value] = [0, 0]; + return; + } + if (BI.isEmpty(obj)) { + valueMap[value] = [2, 0]; + return; + } + var nextNames = {}; + BI.each(obj, function (t, o) { + if (BI.isNull(o) || BI.isEmpty(o)) { + nextNames[t] = true; + } + }); + valueMap[value] = [1, BI.size(nextNames)]; + }); + return valueMap; + } + + function getCheckState (current, parentValues, valueMap, checkState) { + var checked = checkState.checked, half = checkState.half; + var tempCheck = false, halfCheck = false; + if (BI.has(valueMap, current)) { + // 可能是半选 + if (valueMap[current][0] === 1) { + var values = BI.clone(parentValues); + values.push(current); + var childCount = self._getChildCount(values); + if (childCount > 0 && childCount !== valueMap[current][1]) { + halfCheck = true; + } + } else if (valueMap[current][0] === 2) { + tempCheck = true; + } + } + var check; + if (!checked && !halfCheck && !tempCheck) { + check = BI.has(valueMap, current); + } else { + check = ((tempCheck || checked) && !half) || BI.has(valueMap, current); + } + return [check, halfCheck]; + } + }, + + _getNode: function (selectedValues, parentValues) { + var pNode = selectedValues; + for (var i = 0, len = parentValues.length; i < len; i++) { + if (pNode == null) { + return null; + } + pNode = pNode[parentValues[i]]; + } + return pNode; + }, + + _deleteNode: function (selectedValues, values) { + var name = values[values.length - 1]; + var p = values.slice(0, values.length - 1); + var pNode = this._getNode(selectedValues, p); + if (pNode != null && pNode[name]) { + delete pNode[name]; + // 递归删掉空父节点 + while (p.length > 0 && BI.isEmpty(pNode)) { + name = p[p.length - 1]; + p = p.slice(0, p.length - 1); + pNode = this._getNode(selectedValues, p); + if (pNode != null) { + delete pNode[name]; + } + } + } + }, + + _buildTree: function (jo, values) { + var t = jo; + BI.each(values, function (i, v) { + if (!BI.has(t, v)) { + t[v] = {}; + } + t = t[v]; + }); + }, + + _isMatch: function (parentValues, value, keyword) { + var node = this._getTreeNode(parentValues, value); + if (!node) { + return false; + } + var find = BI.Func.getSearchResult([node.text || node.value], keyword); + return find.find.length > 0 || find.match.length > 0; + }, + + _getTreeNode: function (parentValues, v) { + var self = this; + var findParentNode; + var index = 0; + this.tree.traverse(function (node) { + if (self.tree.isRoot(node)) { + return; + } + if (index > parentValues.length) { + return false; + } + if (index === parentValues.length && node.value === v) { + findParentNode = node; + return false; + } + if (node.value === parentValues[index]) { + index++; + return; + } + return true; + }); + return findParentNode; + }, + + _getChildren: function (parentValues) { + if (parentValues.length > 0) { + var value = BI.last(parentValues); + var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value); + } else { + var parent = this.tree.getRoot(); + } + return parent.getChildren(); + }, + + _getChildCount: function (parentValues) { + return this._getChildren(parentValues).length; + } +});/** + * 简单的复选下拉树控件, 适用于数据量少的情况 + * + * Created by GUY on 2015/10/29. + * @class BI.TreeValueChooserCombo + * @extends BI.Widget + */ +BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, { + + _defaultConfig: function () { + return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-tree-value-chooser-combo", + width: 200, + height: 30, + items: null, + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.TreeValueChooserCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + if (BI.isNotNull(o.items)) { + this._initData(o.items); + } + this.combo = BI.createWidget({ + type: "bi.multi_tree_combo", + element: this, + itemsCreator: BI.bind(this._itemsCreator, this), + valueFormatter: BI.bind(this._valueFormatter, this), + width: o.width, + height: o.height + }); + + this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM); + }); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + return this.combo.getValue(); + }, + + populate: function (items) { + this._initData(items); + this.combo.populate.apply(this.combo, arguments); + } +}); +BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM"; +BI.shortcut("bi.tree_value_chooser_combo", BI.TreeValueChooserCombo);/** + * 简单的复选下拉树控件, 适用于数据量少的情况 + * + * Created by GUY on 2015/10/29. + * @class BI.TreeValueChooserPane + * @extends BI.AbstractTreeValueChooser + */ +BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, { + + _defaultConfig: function () { + return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-tree-value-chooser-pane", + items: null, + itemsCreator: BI.emptyFn + }); + }, + + _init: function () { + BI.TreeValueChooserPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.pane = BI.createWidget({ + type: "bi.multi_select_tree", + element: this, + itemsCreator: BI.bind(this._itemsCreator, this) + }); + + this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () { + self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE); + }); + if (BI.isNotNull(o.items)) { + this._initData(o.items); + this.populate(); + } + }, + + setSelectedValue: function (v) { + this.pane.setSelectedValue(v); + }, + + setValue: function (v) { + this.pane.setValue(v); + }, + + getValue: function () { + return this.pane.getValue(); + }, + + populate: function () { + this.pane.populate.apply(this.pane, arguments); + } +}); +BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE"; +BI.shortcut("bi.tree_value_chooser_pane", BI.TreeValueChooserPane);/** + * 简单的复选下拉框控件, 适用于数据量少的情况 + * 封装了字段处理逻辑 + * + * Created by GUY on 2015/10/29. + * @class BI.AbstractValueChooser + * @extends BI.Widget + */ +BI.AbstractValueChooser = BI.inherit(BI.Widget, { + + _const: { + perPage: 100 + }, + + _defaultConfig: function () { + return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), { + items: null, + itemsCreator: BI.emptyFn, + cache: true + }); + }, + + _valueFormatter: function (v) { + var text = v; + if (BI.isNotNull(this.items)) { + BI.some(this.items, function (i, item) { + // 把value都换成字符串 + if (item.value + "" === v) { + text = item.text; + return true; + } + }); + } + return text; + }, + + _getItemsByTimes: function (items, times) { + var res = []; + for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) { + res.push(items[i]); + } + return res; + }, + + _hasNextByTimes: function (items, times) { + return times * this._const.perPage < items.length; + }, + + _itemsCreator: function (options, callback) { + var self = this, o = this.options; + if (!o.cache || !this.items) { + o.itemsCreator({}, function (items) { + self.items = items; + call(items); + }); + } else { + call(this.items); + } + function call (items) { + var keywords = (options.keywords || []).slice(); + BI.each(keywords, function (i, kw) { + var search = BI.Func.getSearchResult(items, kw); + items = search.match.concat(search.find); + }); + if (options.selectedValues) {// 过滤 + var filter = BI.makeObject(options.selectedValues, true); + items = BI.filter(items, function (i, ob) { + return !filter[ob.value]; }); + } + if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) { + callback({ + items: items + }); + return; + } + if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { + callback({count: items.length}); + return; + } + callback({ + items: self._getItemsByTimes(items, options.times), + hasNext: self._hasNextByTimes(items, options.times) }); } - this.table.populate(items, header); - this._adjustColumns(); + } +});/** + * 简单的复选下拉框控件, 适用于数据量少的情况 + * 封装了字段处理逻辑 + * + * Created by GUY on 2015/10/29. + * @class BI.ValueChooserCombo + * @extends BI.Widget + */ +BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, { + + _defaultConfig: function () { + return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-value-chooser-combo", + width: 200, + height: 30, + items: null, + itemsCreator: BI.emptyFn, + cache: true + }); + }, + + _init: function () { + BI.ValueChooserCombo.superclass._init.apply(this, arguments); + var self = this, o = this.options; + if (BI.isNotNull(o.items)) { + this.items = o.items; + } + this.combo = BI.createWidget({ + type: "bi.multi_select_combo", + element: this, + text: o.text, + itemsCreator: BI.bind(this._itemsCreator, this), + valueFormatter: BI.bind(this._valueFormatter, this), + width: o.width, + height: o.height + }); + + this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { + self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM); + }); + }, + + setValue: function (v) { + this.combo.setValue(v); + }, + + getValue: function () { + var val = this.combo.getValue() || {}; + return { + type: val.type, + value: val.value + }; + }, + + populate: function (items) { + // 直接用combo的populate不会作用到AbstractValueChooser上 + this.items = items; + this.combo.populate.apply(this, arguments); } }); -BI.PreviewTable.EVENT_CHANGE = "PreviewTable.EVENT_CHANGE"; -BI.shortcut("bi.preview_table", BI.PreviewTable);/** - * 季度下拉框 - * - * Created by GUY on 2015/8/28. - * @class BI.QuarterCombo - * @extends BI.Widget - */ -BI.QuarterCombo = BI.inherit(BI.Widget, { - _defaultConfig: function () { - return BI.extend(BI.QuarterCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-quarter-combo", - behaviors: {}, - height: 25 - }); - }, - _init: function () { - BI.QuarterCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = ""; - this.trigger = BI.createWidget({ - type: "bi.quarter_trigger", - value: o.value - }); - - this.trigger.on(BI.QuarterTrigger.EVENT_FOCUS, function () { - self.storeValue = this.getKey(); - }); - this.trigger.on(BI.QuarterTrigger.EVENT_START, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.QuarterTrigger.EVENT_STOP, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - this.trigger.on(BI.QuarterTrigger.EVENT_CONFIRM, function () { - if (self.combo.isViewVisible()) { - return; - } - if (this.getKey() && this.getKey() !== self.storeValue) { - self.setValue(this.getKey()); - } else if (!this.getKey()) { - self.setValue(); - } - self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); - }); - this.popup = BI.createWidget({ - type: "bi.quarter_popup", - behaviors: o.behaviors, - value: o.value - }); - - this.popup.on(BI.QuarterPopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.QuarterCombo.EVENT_CONFIRM); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - el: this.popup - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW); - }); - }, - - setValue: function (v) { - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - if (BI.isNull(this.popup)) { - return this.options.value || ""; - } else { - return this.popup.getValue() || ""; - } - } -}); - -BI.QuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.QuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.quarter_combo", BI.QuarterCombo);/** - * 季度展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.QuarterPopup - * @extends BI.Trigger - */ -BI.QuarterPopup = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.QuarterPopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-quarter-popup", - behaviors: {} - }); - }, - - _init: function () { - BI.QuarterPopup.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var items = [{ - text: Date._QN[1], - value: 1 - }, { - text: Date._QN[2], - value: 2 - }, { - text: Date._QN[3], - value: 3 - }, { - text: Date._QN[4], - value: 4 - }]; - items = BI.map(items, function (j, item) { - return BI.extend(item, { - type: "bi.text_item", - cls: "bi-list-item-active", - textAlign: "left", - whiteSpace: "nowrap", - once: false, - forceSelected: true, - height: 25 - }); - }); - - this.quarter = BI.createWidget({ - type: "bi.button_group", - element: this, - behaviors: o.behaviors, - items: BI.createItems(items, {}), - layouts: [{ - type: "bi.vertical" - }], - value: o.value - }); - - this.quarter.on(BI.Controller.EVENT_CHANGE, function (type) { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - if (type === BI.Events.CLICK) { - self.fireEvent(BI.MonthPopup.EVENT_CHANGE); - } - }); - }, - - getValue: function () { - return this.quarter.getValue()[0]; - }, - - setValue: function (v) { - this.quarter.setValue([v]); - } -}); -BI.QuarterPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.quarter_popup", BI.QuarterPopup);/** - * 季度trigger - * - * Created by GUY on 2015/8/21. - * @class BI.QuarterTrigger - * @extends BI.Trigger - */ -BI.QuarterTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2, - textWidth: 40 - }, - - _defaultConfig: function () { - return BI.extend(BI.QuarterTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-quarter-trigger bi-border", - height: 24 - }); - }, - _init: function () { - BI.QuarterTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - validationChecker: function (v) { - return v === "" || (BI.isPositiveInteger(v) && v >= 1 && v <= 4); - }, - quitChecker: function (v) { - return false; - }, - hgap: c.hgap, - vgap: c.vgap, - allowBlank: true, - errorText: BI.i18nText("BI-Quarter_Trigger_Error_Text") - }); - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.QuarterTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_CHANGE, function () { - self.fireEvent(BI.QuarterTrigger.EVENT_CHANGE); - }); - this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { - var value = self.editor.getValue(); - if (BI.isNotNull(value)) { - self.editor.setValue(value); - self.editor.setTitle(value); - } - self.fireEvent(BI.QuarterTrigger.EVENT_CONFIRM); - }); - this.editor.on(BI.SignEditor.EVENT_SPACE, function () { - if (self.editor.isValid()) { - self.editor.blur(); - } - }); - this.editor.on(BI.SignEditor.EVENT_START, function () { - self.fireEvent(BI.QuarterTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.QuarterTrigger.EVENT_STOP); - }); - - BI.createWidget({ - element: this, - type: "bi.htape", - items: [ - { - el: this.editor - }, { - el: { - type: "bi.text_button", - baseCls: "bi-trigger-quarter-text", - text: BI.i18nText("BI-Multi_Date_Quarter"), - width: c.textWidth - }, - width: c.textWidth - }, { - el: { - type: "bi.trigger_icon_button", - width: o.height - }, - width: o.height - } - ] - }); - this.setValue(o.value); - }, - - setValue: function (v) { - v = v || ""; - this.editor.setState(v); - this.editor.setValue(v); - this.editor.setTitle(v); - }, - - getKey: function () { - return this.editor.getValue(); - } -}); -BI.QuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.QuarterTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.QuarterTrigger.EVENT_START = "EVENT_START"; -BI.QuarterTrigger.EVENT_STOP = "EVENT_STOP"; -BI.QuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.shortcut("bi.quarter_trigger", BI.QuarterTrigger);/** - * 自适应宽度的表格 - * - * Created by GUY on 2016/2/3. - * @class BI.ResponisveTable - * @extends BI.Widget - */ -BI.ResponisveTable = BI.inherit(BI.Widget, { - - _const: { - perColumnSize: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.ResponisveTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-responsive-table", - isNeedFreeze: false, // 是否需要冻结单元格 - freezeCols: [], // 冻结的列号,从0开始,isNeedFreeze为true时生效 - logic: { // 冻结的页面布局逻辑 - dynamic: false - }, - - isNeedMerge: false, // 是否需要合并单元格 - mergeCols: [], // 合并的单元格列号 - mergeRule: function (row1, row2) { // 合并规则, 默认相等时合并 - return BI.isEqual(row1, row2); - }, - - columnSize: [], - headerRowSize: 25, - footerRowSize: 25, - rowSize: 25, - - regionColumnSize: false, - - header: [], - footer: false, - items: [], // 二维数组 - - // 交叉表头 - crossHeader: [], - crossItems: [] - }); - }, - - _init: function () { - BI.ResponisveTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.table = BI.createWidget({ - type: "bi.table_view", - element: this, - logic: o.logic, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - headerRowSize: o.headerRowSize, - footerRowSize: o.footerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - header: o.header, - footer: o.footer, - items: o.items, - // 交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_INIT, function () { - self._initRegionSize(); - self.table.resize(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_INIT, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_RESIZE, function () { - self._resizeRegion(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function () { - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_REGION_RESIZE, function () { - // important:在冻结并自适应列宽的情况下要随时变更表头宽度 - if (o.isNeedResize === true && self._isAdaptiveColumn()) { - self._resizeHeader(); - } - self.fireEvent(BI.Table.EVENT_TABLE_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - - this.table.on(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, function () { - self._resizeBody(); - self.fireEvent(BI.Table.EVENT_TABLE_BEFORE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_COLUMN_RESIZE, function () { - self.fireEvent(BI.Table.EVENT_TABLE_COLUMN_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - self._resizeRegion(); - self._resizeHeader(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - }, - - _initRegionSize: function () { - var o = this.options; - if (o.isNeedFreeze === true) { - var regionColumnSize = this.table.getRegionColumnSize(); - var maxWidth = this.table.element.width(); - if (!regionColumnSize[0] || (regionColumnSize[0] === "fill") || regionColumnSize[0] > maxWidth || regionColumnSize[1] > maxWidth) { - var freezeCols = o.freezeCols; - if (freezeCols.length === 0) { - this.table.setRegionColumnSize([0, "fill"]); - } else if (freezeCols.length > 0 && freezeCols.length < o.columnSize.length) { - var size = maxWidth / 3; - if (freezeCols.length > o.columnSize.length / 2) { - size = maxWidth * 2 / 3; - } - this.table.setRegionColumnSize([size, "fill"]); - } else { - this.table.setRegionColumnSize(["fill", 0]); - } - } - } - }, - - _getBlockSize: function () { - var o = this.options; - var columnSize = this.table.getCalculateColumnSize(); - if (o.isNeedFreeze === true) { - var columnSizeLeft = [], columnSizeRight = []; - BI.each(columnSize, function (i, size) { - if (o.freezeCols.contains(i)) { - columnSizeLeft.push(size); - } else { - columnSizeRight.push(size); - } - }); - // 因为有边框,所以加上数组长度的参数调整 - var sumLeft = BI.sum(columnSizeLeft) + columnSizeLeft.length, - sumRight = BI.sum(columnSizeRight) + columnSizeRight.length; - return { - sumLeft: sumLeft, - sumRight: sumRight, - left: columnSizeLeft, - right: columnSizeRight - }; - } - return { - size: columnSize, - sum: BI.sum(columnSize) + columnSize.length - }; - }, - - _isAdaptiveColumn: function (columnSize) { - return !(BI.last(columnSize || this.table.getColumnSize()) > 1.05); - }, - - _resizeHeader: function () { - var self = this, o = this.options; - if (o.isNeedFreeze === true) { - // 若是当前处于自适应调节阶段 - if (this._isAdaptiveColumn()) { - var columnSize = this.table.getCalculateColumnSize(); - this.table.setHeaderColumnSize(columnSize); - } else { - var regionColumnSize = this.table.getClientRegionColumnSize(); - var block = this._getBlockSize(); - var sumLeft = block.sumLeft, sumRight = block.sumRight; - var columnSizeLeft = block.left, columnSizeRight = block.right; - columnSizeLeft[columnSizeLeft.length - 1] += regionColumnSize[0] - sumLeft; - columnSizeRight[columnSizeRight.length - 1] += regionColumnSize[1] - sumRight; - - var newLeft = BI.clone(columnSizeLeft), newRight = BI.clone(columnSizeRight); - newLeft[newLeft.length - 1] = ""; - newRight[newRight.length - 1] = ""; - this.table.setColumnSize(newLeft.concat(newRight)); - - block = self._getBlockSize(); - if (columnSizeLeft[columnSizeLeft.length - 1] < block.left[block.left.length - 1]) { - columnSizeLeft[columnSizeLeft.length - 1] = block.left[block.left.length - 1]; - } - if (columnSizeRight[columnSizeRight.length - 1] < block.right[block.right.length - 1]) { - columnSizeRight[columnSizeRight.length - 1] = block.right[block.right.length - 1]; - } - - self.table.setColumnSize(columnSizeLeft.concat(columnSizeRight)); - } - } else { - if (!this._isAdaptiveColumn()) { - var regionColumnSize = this.table.getClientRegionColumnSize(); - var block = this._getBlockSize(); - var sum = block.sum; - var size = block.size; - - size[size.length - 1] += regionColumnSize[0] - sum; - - var newSize = BI.clone(size); - newSize[newSize.length - 1] = ""; - this.table.setColumnSize(newSize); - block = this._getBlockSize(); - - if (size[size.length - 1] < block.size[block.size.length - 1]) { - size[size.length - 1] = block.size[block.size.length - 1]; - } - this.table.setColumnSize(size); - } - } - }, - - _resizeBody: function () { - if (this._isAdaptiveColumn()) { - var columnSize = this.table.getCalculateColumnSize(); - this.setColumnSize(columnSize); - } - }, - - _adjustRegion: function () { - var o = this.options; - var regionColumnSize = this.table.getCalculateRegionColumnSize(); - if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - var block = this._getBlockSize(); - var sumLeft = block.sumLeft, sumRight = block.sumRight; - if (sumLeft < regionColumnSize[0] || regionColumnSize[0] >= (sumLeft + sumRight)) { - this.table.setRegionColumnSize([sumLeft, "fill"]); - } - this._resizeRegion(); - } - }, - - _resizeRegion: function () { - var o = this.options; - var regionColumnSize = this.table.getCalculateRegionColumnSize(); - if (o.isNeedFreeze === true && o.freezeCols.length > 0 && o.freezeCols.length < o.columnSize.length) { - var maxWidth = this.table.element.width(); - if (regionColumnSize[0] < 15 || regionColumnSize[1] < 15) { - var freezeCols = o.freezeCols; - var size = maxWidth / 3; - if (freezeCols.length > o.columnSize.length / 2) { - size = maxWidth * 2 / 3; - } - this.table.setRegionColumnSize([size, "fill"]); - } - } - }, - - - resize: function () { - this.table.resize(); - this._resizeRegion(); - this._resizeHeader(); - }, - - setColumnSize: function (columnSize) { - this.table.setColumnSize(columnSize); - this._adjustRegion(); - this._resizeHeader(); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - getCalculateColumnSize: function () { - return this.table.getCalculateColumnSize(); - }, - - setHeaderColumnSize: function (columnSize) { - this.table.setHeaderColumnSize(columnSize); - this._adjustRegion(); - this._resizeHeader(); - }, - - setRegionColumnSize: function (columnSize) { - this.table.setRegionColumnSize(columnSize); - this._resizeHeader(); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - getCalculateRegionColumnSize: function () { - return this.table.getCalculateRegionColumnSize(); - }, - - getCalculateRegionRowSize: function () { - return this.table.getCalculateRegionRowSize(); - }, - - getClientRegionColumnSize: function () { - return this.table.getClientRegionColumnSize(); - }, - - getScrollRegionColumnSize: function () { - return this.table.getScrollRegionColumnSize(); - }, - - getScrollRegionRowSize: function () { - return this.table.getScrollRegionRowSize(); - }, - - hasVerticalScroll: function () { - return this.table.hasVerticalScroll(); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - getLeftHorizontalScroll: function () { - return this.table.getLeftHorizontalScroll(); - }, - - getRightHorizontalScroll: function () { - return this.table.getRightHorizontalScroll(); - }, - - getColumns: function () { - return this.table.getColumns(); - }, - - attr: function () { - BI.ResponisveTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - }, - - populate: function (items) { - var self = this, o = this.options; - this.table.populate.apply(this.table, arguments); - if (o.isNeedFreeze === true) { - BI.nextTick(function () { - self._initRegionSize(); - self.table.resize(); - self._resizeHeader(); - }); - } - } -}); -BI.shortcut("bi.responsive_table", BI.ResponisveTable);/** - * - * @class BI.SearchMultiTextValueCombo - * @extends BI.Single - */ -BI.SearchMultiTextValueCombo = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.SearchMultiTextValueCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-combo bi-search-multi-text-value-combo", - height: 24, - items: [] - }); - }, - - _init: function () { - BI.SearchMultiTextValueCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - var assertShowValue = function () { - BI.isKey(self._startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](self._startValue); - self._updateAllValue(); - self._checkError(); - self.trigger.getSearcher().setState(self.storeValue); - self.trigger.getCounter().setButtonChecked(self.storeValue); - }; - this.storeValue = BI.deepClone(o.value || {}); - this._updateAllValue(); - - this._assertValue(this.storeValue); - this._checkError(); - - // 标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.search_multi_select_trigger", - text: o.text, - height: o.height, - // adapter: this.popup, - masker: { - offset: { - left: 0, - top: 0, - right: 0, - bottom: 26 - } - }, - allValueGetter: function () { - return self.allValue; - }, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - self._itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keywords)) { - // 预防trigger内部把当前的storeValue改掉 - self.trigger.setValue(BI.deepClone(self.getValue())); - } - callback.apply(self, arguments); - }); - }, - value: this.storeValue - }); - - this.trigger.on(BI.MultiSelectTrigger.EVENT_START, function () { - self._setStartValue(""); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_STOP, function () { - self._setStartValue(""); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); - self._join({ - type: BI.Selection.Multi, - value: [keyword] - }, function () { - self.combo.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self._populate(); - self._setStartValue(""); - }); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(""); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } - }); - - this.trigger.on(BI.MultiSelectTrigger.EVENT_CHANGE, function (value, obj) { - if (obj instanceof BI.MultiSelectBar) { - self._joinAll(this.getValue(), function () { - assertShowValue(); - }); - } else { - self._join(this.getValue(), function () { - assertShowValue(); - }); - } - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW, function () { - this.getCounter().setValue(self.storeValue); - }); - this.trigger.on(BI.MultiSelectTrigger.EVENT_COUNTER_CLICK, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - el: this.trigger, - adjustLength: 1, - popup: { - type: "bi.search_multi_select_popup_view", - ref: function () { - self.popup = this; - self.trigger.setAdapter(this); - }, - listeners: [{ - eventName: BI.MultiSelectPopupView.EVENT_CHANGE, - action: function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - }); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CONFIRM, - action: function () { - self._defaultState(); - } - }, { - eventName: BI.MultiSelectPopupView.EVENT_CLICK_CLEAR, - action: function () { - self.setValue(); - self._defaultState(); - } - }], - itemsCreator: BI.bind(self._itemsCreator, this), - valueFormatter: o.valueFormatter, - onLoaded: function () { - BI.nextTick(function () { - self.combo.adjustWidth(); - self.combo.adjustHeight(); - self.trigger.getCounter().adjustView(); - self.trigger.getSearcher().adjustView(); - }); - } - }, - value: o.value, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - } - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self.element.removeClass("combo-show"); - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.element.removeClass("combo-show").addClass("combo-show"); - this.setValue(self.storeValue); - BI.nextTick(function () { - self._populate(); - }); - }); - // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 - this.wants2Quit = false; - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - // important:关闭弹出时又可能没有退出编辑状态 - self.trigger.stopEditing(); - if (self.requesting === true) { - self.wants2Quit = true; - } else { - self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM); - } - }); - - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "multi-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - self.trigger.getCounter().hideView(); - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }] - }); - this._checkError(); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - this.combo.hideView(); - }, - - _assertValue: function (val) { - var o = this.options; - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - BI.remove(val.value, function (idx, value) { - return !BI.contains(BI.map(o.items, "value"), value); - }); - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - this.requesting = true; - this._itemsCreator({ - type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA, - keywords: keywords - }, function (ob) { - var values = BI.map(ob.items, "value"); - digest(values); - }); - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Multi ? "pushDistinct" : "remove"](val); - } - }); - self._adjust(callback); - } - }, - - _joinAll: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this.requesting = true; - this._itemsCreator({ - type: BI.SearchMultiTextValueCombo.REQ_GET_ALL_DATA, - keywords: [this.trigger.getKey()] - }, function (ob) { - var items = BI.map(ob.items, "value"); - if (self.storeValue.type === res.type) { - var change = false; - var map = self._makeMap(self.storeValue.value); - BI.each(items, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (self.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - var selectedMap = self._makeMap(self.storeValue.value); - var notSelectedMap = self._makeMap(res.value); - var newItems = []; - BI.each(items, function (i, item) { - if (BI.isNotNull(selectedMap[items[i]])) { - delete selectedMap[items[i]]; - } - if (BI.isNull(notSelectedMap[items[i]])) { - newItems.push(item); - } - }); - self.storeValue.value = newItems.concat(BI.values(selectedMap)); - self._adjust(callback); - }); - }, - - _adjust: function (callback) { - var self = this, o = this.options; - if (!this._count) { - this._itemsCreator({ - type: BI.SearchMultiTextValueCombo.REQ_GET_DATA_LENGTH - }, function (res) { - self._count = res.count; - adjust(); - callback(); - }); - } else { - adjust(); - callback(); - - } - - function adjust () { - if (self.storeValue.type === BI.Selection.All && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.Multi, - value: [] - }; - } else if (self.storeValue.type === BI.Selection.Multi && self.storeValue.value.length >= self._count) { - self.storeValue = { - type: BI.Selection.All, - value: [] - }; - } - self._updateAllValue(); - self._checkError(); - if (self.wants2Quit === true) { - self.fireEvent(BI.SearchMultiTextValueCombo.EVENT_CONFIRM); - self.wants2Quit = false; - } - self.requesting = false; - } - }, - - _join: function (res, callback) { - var self = this, o = this.options; - this._assertValue(res); - this._assertValue(this.storeValue); - if (this.storeValue.type === res.type) { - var map = this._makeMap(this.storeValue.value); - BI.each(res.value, function (i, v) { - if (!map[v]) { - self.storeValue.value.push(v); - map[v] = v; - } - }); - var change = false; - BI.each(res.assist, function (i, v) { - if (BI.isNotNull(map[v])) { - change = true; - delete map[v]; - } - }); - change && (this.storeValue.value = BI.values(map)); - self._adjust(callback); - return; - } - this._joinAll(res, callback); - }, - - _setStartValue: function (value) { - this._startValue = value; - this.popup.setStartValue(value); - }, - - _getItemsByTimes: function (items, times) { - var res = []; - for (var i = (times - 1) * 10; items[i] && i < times * 10; i++) { - res.push(items[i]); - } - return res; - }, - - _hasNextByTimes: function (items, times) { - return times * 10 < items.length; - }, - - _itemsCreator: function (options, callback) { - var self = this, o = this.options; - var items = o.items; - var keywords = (options.keywords || []).slice(); - if (options.keyword) { - keywords.push(options.keyword); - } - BI.each(keywords, function (i, kw) { - var search = BI.Func.getSearchResult(items, kw); - items = search.match.concat(search.find); - }); - if (options.selectedValues) {// 过滤 - var filter = BI.makeObject(options.selectedValues, true); - items = BI.filter(items, function (i, ob) { - return !filter[ob.value]; - }); - } - if (options.type == BI.MultiSelectCombo.REQ_GET_ALL_DATA) { - callback({ - items: items - }); - return; - } - if (options.type == BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { - callback({count: items.length}); - return; - } - callback({ - items: self._getItemsByTimes(items, options.times), - hasNext: self._hasNextByTimes(items, options.times) - }); - }, - - _checkError: function () { - var v = this.storeValue.value || []; - if(BI.isNotEmptyArray(v)) { - v = BI.isArray(v) ? v : [v]; - var result = BI.find(this.allValue, function (idx, value) { - return !BI.contains(v, value); - }); - if (BI.isNull(result)) { - this.element.removeClass("combo-error"); - } else { - this.element.addClass("combo-error"); - } - } else { - v.length === this.allValue.length ? this.element.removeClass("combo-error") : this.element.addClass("combo-error"); - } - }, - - _updateAllValue: function () { - this.storeValue = this.storeValue || {}; - this.allValue = BI.deepClone(this.storeValue.value || []); - }, - - setValue: function (v) { - this.storeValue = BI.deepClone(v || {}); - this._updateAllValue(); - this._assertValue(this.storeValue); - this.combo.setValue(this.storeValue); - this._checkError(); - }, - - getValue: function () { - return BI.deepClone(this.storeValue); - }, - - _populate: function () { - this._count = null; - this.combo.populate(); - }, - - populate: function (items) { - this.options.items = items; - this._populate(); - } -}); - -BI.extend(BI.SearchMultiTextValueCombo, { - REQ_GET_DATA_LENGTH: 1, - REQ_GET_ALL_DATA: -1 -}); - -BI.SearchMultiTextValueCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut("bi.search_multi_text_value_combo", BI.SearchMultiTextValueCombo);BI.SearchMultiSelectTrigger = BI.inherit(BI.Trigger, { - - constants: { - height: 14, - rgap: 4, - lgap: 4 - }, - - _defaultConfig: function () { - return BI.extend(BI.SearchMultiSelectTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-trigger bi-border", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - searcher: {}, - switcher: {}, - - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.SearchMultiSelectTrigger.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - if (o.height) { - this.setHeight(o.height - 2); - } - - this.searcher = BI.createWidget(o.searcher, { - type: "bi.search_multi_select_searcher", - height: o.height, - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - allValueGetter: o.allValueGetter, - popup: {}, - adapter: o.adapter, - masker: o.masker, - value: o.value, - text: o.text - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_START, function () { - self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_START); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_PAUSE, function () { - self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_PAUSE); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_SEARCHING, function () { - self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_SEARCHING, arguments); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_STOP, function () { - self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_STOP); - }); - this.searcher.on(BI.MultiSelectSearcher.EVENT_CHANGE, function () { - self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_CHANGE, arguments); - }); - this.numberCounter = BI.createWidget(o.switcher, { - type: "bi.multi_select_check_selected_switcher", - valueFormatter: o.valueFormatter, - itemsCreator: o.itemsCreator, - adapter: o.adapter, - masker: o.masker, - value: o.value - }); - this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_TRIGGER_CHANGE, function () { - self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK); - }); - this.numberCounter.on(BI.MultiSelectCheckSelectedSwitcher.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW); - }); - - var wrapNumberCounter = BI.createWidget({ - type: "bi.right_vertical_adapt", - hgap: 4, - items: [{ - el: this.numberCounter - }] - }); - - var wrapper = BI.createWidget({ - type: "bi.htape", - element: this, - items: [ - { - el: this.searcher, - width: "fill" - }, { - el: wrapNumberCounter, - width: 0 - }, { - el: BI.createWidget(), - width: 24 - }] - }); - - this.numberCounter.on(BI.Events.VIEW, function (b) { - BI.nextTick(function () {// 自动调整宽度 - wrapper.attr("items")[1].width = (b === true ? self.numberCounter.element.outerWidth() + 8 : 0); - wrapper.resize(); - }); - }); - - this.element.click(function (e) { - if (self.element.__isMouseInBounds__(e) && !self.numberCounter.element.__isMouseInBounds__(e)) { - self.numberCounter.hideView(); - } - }); - }, - - getCounter: function () { - return this.numberCounter; - }, - - getSearcher: function () { - return this.searcher; - }, - - stopEditing: function () { - this.searcher.stopSearch(); - this.numberCounter.hideView(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - this.numberCounter.setAdapter(adapter); - }, - - setValue: function (ob) { - this.searcher.setValue(ob); - this.numberCounter.setValue(ob); - }, - - getKey: function () { - return this.searcher.getKey(); - }, - - getValue: function () { - return this.searcher.getValue(); - } -}); - -BI.SearchMultiSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.SearchMultiSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; -BI.SearchMultiSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SearchMultiSelectTrigger.EVENT_START = "EVENT_START"; -BI.SearchMultiSelectTrigger.EVENT_STOP = "EVENT_STOP"; -BI.SearchMultiSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SearchMultiSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.SearchMultiSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; - -BI.shortcut("bi.search_multi_select_trigger", BI.SearchMultiSelectTrigger);/** - * 多选加载数据面板 - * Created by guy on 15/11/2. - * @class BI.SearchMultiSelectLoader - * @extends Widget - */ -BI.SearchMultiSelectLoader = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SearchMultiSelectLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-loader", - logic: { - dynamic: true - }, - el: { - height: 400 - }, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.SearchMultiSelectLoader.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - var hasNext = false; - - this.storeValue = opts.value || {}; - this._assertValue(this.storeValue); - - this.button_group = BI.createWidget({ - type: "bi.select_list", - element: this, - logic: opts.logic, - el: BI.extend({ - onLoaded: opts.onLoaded, - el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_MULTI, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } - } - }, opts.el), - itemsCreator: function (op, callback) { - var startValue = self._startValue; - self.storeValue && (op = BI.extend(op || {}, { - selectedValues: BI.isKey(startValue) && self.storeValue.type === BI.Selection.Multi - ? self.storeValue.value.concat(startValue) : self.storeValue.value - })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && self.storeValue) { - var json = BI.map(self.storeValue.value, function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: self.storeValue.type === BI.Selection.Multi - }; - }); - if (BI.isKey(self._startValue) && !self.storeValue.value.contains(self._startValue)) { - var txt = opts.valueFormatter(startValue) || startValue; - json.unshift({ - text: txt, - value: startValue, - title: txt, - selected: true - }); - } - firstItems = self._createItems(json); - } - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { - BI.isKey(startValue) && self.storeValue.value[self.storeValue.type === BI.Selection.All ? "remove" : "pushDistinct"](startValue); - self.setValue(self.storeValue); - } - (op.times === 1) && self._scrollToTop(); - }); - }, - hasNext: function () { - return hasNext; - }, - value: this.storeValue - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button_group.on(BI.SelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.SearchMultiSelectLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.multi_select_item", - logic: this.options.logic, - height: 24, - selected: this.isAllSelected() - }); - }, - - _scrollToTop: function () { - var self = this; - BI.delay(function () { - self.button_group.element.scrollTop(0); - }, 30); - }, - - isAllSelected: function () { - return this.button_group.isAllSelected(); - }, - - _assertValue: function (val) { - val || (val = {}); - val.type || (val.type = BI.Selection.Multi); - val.value || (val.value = []); - }, - - setStartValue: function (v) { - this._startValue = v; - }, - - setValue: function (v) { - this.storeValue = v || {}; - this._assertValue(this.storeValue); - this.button_group.setValue(this.storeValue); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - empty: function () { - this.button_group.empty(); - }, - - populate: function (items) { - arguments[0] = this._createItems(items); - this.button_group.populate.apply(this.button_group, arguments); - }, - - resetHeight: function (h) { - this.button_group.resetHeight(h); - }, - - resetWidth: function (w) { - this.button_group.resetWidth(w); - } -}); - -BI.SearchMultiSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.search_multi_select_loader", BI.SearchMultiSelectLoader);BI.SearchMultiSelectPopupView = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SearchMultiSelectPopupView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-popup-view", - maxWidth: "auto", - minWidth: 135, - maxHeight: 400, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.SearchMultiSelectPopupView.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - - this.loader = BI.createWidget({ - type: "bi.search_multi_select_loader", - itemsCreator: opts.itemsCreator, - valueFormatter: opts.valueFormatter, - onLoaded: opts.onLoaded, - value: opts.value - }); - - this.popupView = BI.createWidget({ - type: "bi.multi_popup_view", - stopPropagation: false, - maxWidth: opts.maxWidth, - minWidth: opts.minWidth, - maxHeight: opts.maxHeight, - element: this, - buttons: [BI.i18nText("BI-Basic_Clears"), BI.i18nText("BI-Basic_Sure")], - el: this.loader, - value: opts.value - }); - - this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { - self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CHANGE); - }); - this.popupView.on(BI.MultiPopupView.EVENT_CLICK_TOOLBAR_BUTTON, function (index) { - switch (index) { - case 0: - self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR); - break; - case 1: - self.fireEvent(BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM); - break; - } - }); - }, - - isAllSelected: function () { - return this.loader.isAllSelected(); - }, - - setStartValue: function (v) { - this.loader.setStartValue(v); - }, - - setValue: function (v) { - this.popupView.setValue(v); - }, - - getValue: function () { - return this.popupView.getValue(); - }, - - populate: function (items) { - this.popupView.populate.apply(this.popupView, arguments); - }, - - resetHeight: function (h) { - this.popupView.resetHeight(h); - }, - - resetWidth: function (w) { - this.popupView.resetWidth(w); - } -}); - -BI.SearchMultiSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SearchMultiSelectPopupView.EVENT_CLICK_CONFIRM = "EVENT_CLICK_CONFIRM"; -BI.SearchMultiSelectPopupView.EVENT_CLICK_CLEAR = "EVENT_CLICK_CLEAR"; - - -BI.shortcut("bi.search_multi_select_popup_view", BI.SearchMultiSelectPopupView);BI.SearchMultiSelectSearcher = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SearchMultiSelectSearcher.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-searcher", - itemsCreator: BI.emptyFn, - el: {}, - popup: {}, - valueFormatter: BI.emptyFn, - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.SearchMultiSelectSearcher.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget(o.el, { - type: "bi.multi_select_editor", - height: o.height, - text: o.text - }); - - this.searcher = BI.createWidget({ - type: "bi.searcher", - element: this, - height: o.height, - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - el: this.editor, - - popup: BI.extend({ - type: "bi.multi_select_search_pane", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.editor.getValue(); - }, - itemsCreator: function (op, callback) { - var keyword = self.editor.getValue(); - op.keywords = [keyword]; - this.setKeyword(keyword); - o.itemsCreator(op, callback); - }, - value: o.value - }, o.popup), - - adapter: o.adapter, - masker: o.masker - }); - this.searcher.on(BI.Searcher.EVENT_START, function () { - self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_START); - }); - this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { - if (this.hasMatched()) { - - } - self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_PAUSE); - }); - this.searcher.on(BI.Searcher.EVENT_STOP, function () { - self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_STOP); - }); - this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { - self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_CHANGE, arguments); - }); - this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { - var keywords = this.getKeywords(); - self.fireEvent(BI.SearchMultiSelectSearcher.EVENT_SEARCHING, keywords); - }); - if(BI.isNotNull(o.value)) { - this.setState(o.value); - } - }, - - adjustView: function () { - this.searcher.adjustView(); - }, - - isSearching: function () { - return this.searcher.isSearching(); - }, - - stopSearch: function () { - this.searcher.stopSearch(); - }, - - getKeyword: function () { - return this.editor.getValue(); - }, - - hasMatched: function () { - return this.searcher.hasMatched(); - }, - - hasChecked: function () { - return this.searcher.getView() && this.searcher.getView().hasChecked(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - }, - - setState: function (obj) { - var o = this.options; - var ob = {}; - ob.type = obj.type; - ob.value = o.allValueGetter() || []; - ob.assist = obj.assist; - if (ob.type === BI.Selection.All) { - if (ob.value.length === 0) { - this.editor.setState(BI.Selection.All); - } else if (BI.size(ob.assist) <= 20) { - var state = ""; - BI.each(ob.assist, function (i, v) { - if (i === 0) { - state += "" + (o.valueFormatter(v + "") || v); - } else { - state += "," + (o.valueFormatter(v + "") || v); - } - }); - this.editor.setState(state); - } else { - this.editor.setState(BI.Selection.Multi); - } - } else { - if (ob.value.length === 0) { - this.editor.setState(BI.Selection.None); - } else if (BI.size(ob.value) <= 20) { - var state = ""; - BI.each(ob.value, function (i, v) { - if (i === 0) { - state += "" + (o.valueFormatter(v + "") || v); - } else { - state += "," + (o.valueFormatter(v + "") || v); - } - }); - this.editor.setState(state); - } else { - this.editor.setState(BI.Selection.Multi); - } - } - }, - - setValue: function (ob) { - this.setState(ob); - this.searcher.setValue(ob); - }, - - getKey: function () { - return this.editor.getValue(); - }, - - getValue: function () { - return this.searcher.getValue(); - }, - - populate: function (items) { - this.searcher.populate.apply(this.searcher, arguments); - } -}); - -BI.SearchMultiSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.SearchMultiSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SearchMultiSelectSearcher.EVENT_START = "EVENT_START"; -BI.SearchMultiSelectSearcher.EVENT_STOP = "EVENT_STOP"; -BI.SearchMultiSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SearchMultiSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.shortcut("bi.search_multi_select_searcher", BI.SearchMultiSelectSearcher);/** - * 加号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.SelectTreeFirstPlusGroupNode - * @extends BI.NodeButton - */ -BI.SelectTreeFirstPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.SelectTreeFirstPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-select-tree-first-plus-group-node bi-list-item-active", - logic: { - dynamic: false - }, - id: "", - pId: "", - readonly: true, - open: false, - height: 24 - }); - }, - _init: function () { - BI.SelectTreeFirstPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.first_tree_node_checkbox", - stopPropagation: true - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - keyword: o.keyword, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); - } else { - self.triggerCollapse(); - } - } - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 24, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - isOnce: function () { - return true; - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.NodeButton.superclass.doClick.apply(this, arguments); - }, - - setOpened: function (v) { - BI.SelectTreeFirstPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.select_tree_first_plus_group_node", BI.SelectTreeFirstPlusGroupNode);/** - * 加号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.SelectTreeLastPlusGroupNode - * @extends BI.NodeButton - */ -BI.SelectTreeLastPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.SelectTreeLastPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-select-tree-last-plus-group-node bi-list-item-active", - logic: { - dynamic: false - }, - id: "", - pId: "", - readonly: true, - open: false, - height: 24 - }); - }, - _init: function () { - BI.SelectTreeLastPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.last_tree_node_checkbox", - stopPropagation: true - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - keyword: o.keyword, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); - } else { - self.triggerCollapse(); - } - } - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 24, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - isOnce: function () { - return true; - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.NodeButton.superclass.doClick.apply(this, arguments); - }, - - setOpened: function (v) { - BI.SelectTreeLastPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.select_tree_last_plus_group_node", BI.SelectTreeLastPlusGroupNode);/** - * 加号表示的组节点 - * Created by GUY on 2015/9/6. - * @class BI.SelectTreeMidPlusGroupNode - * @extends BI.NodeButton - */ -BI.SelectTreeMidPlusGroupNode = BI.inherit(BI.NodeButton, { - _defaultConfig: function () { - var conf = BI.SelectTreeMidPlusGroupNode.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-select-tree-mid-plus-group-node bi-list-item-active", - logic: { - dynamic: false - }, - id: "", - pId: "", - readonly: true, - open: false, - height: 24 - }); - }, - _init: function () { - BI.SelectTreeMidPlusGroupNode.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.checkbox = BI.createWidget({ - type: "bi.mid_tree_node_checkbox", - stopPropagation: true - }); - this.text = BI.createWidget({ - type: "bi.label", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - value: o.value, - keyword: o.keyword, - py: o.py - }); - this.checkbox.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.triggerExpand(); - } else { - self.triggerCollapse(); - } - } - }); - var type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); - var items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { - width: 24, - el: this.checkbox - }, this.text); - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(type, BI.extend(o.logic, { - items: items - })))); - }, - - isOnce: function () { - return true; - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.NodeButton.superclass.doClick.apply(this, arguments); - }, - - setOpened: function (v) { - BI.SelectTreeMidPlusGroupNode.superclass.setOpened.apply(this, arguments); - if (BI.isNotNull(this.checkbox)) { - this.checkbox.setSelected(v); - } - } -}); - -BI.shortcut("bi.select_tree_mid_plus_group_node", BI.SelectTreeMidPlusGroupNode);/** - * @class BI.SelectTreeCombo - * @extends BI.Widget - */ -BI.SelectTreeCombo = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SelectTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-select-tree-combo", - height: 30, - text: "", - items: [], - value: "" - }); - }, - - _init: function () { - BI.SelectTreeCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.single_tree_trigger", - text: o.text, - height: o.height, - items: o.items, - value: o.value - }); - - this.popup = BI.createWidget({ - type: "bi.select_level_tree", - items: o.items, - value: o.value - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup - } - }); - - this.combo.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - }); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - }, - - populate: function (items) { - this.combo.populate(items); - } -}); - - -BI.shortcut("bi.select_tree_combo", BI.SelectTreeCombo);/** - * @class BI.SelectTreeExpander - * @extends BI.Widget - */ -BI.SelectTreeExpander = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SelectTreeExpander.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-select-tree-expander", - trigger: "", - toggle: true, - direction: "bottom", - isDefaultInit: true, - el: {}, - popup: {} - }); - }, - - _init: function () { - BI.SelectTreeExpander.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget(o.el); - this.trigger.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - if (this.isSelected()) { - self.expander.setValue([]); - } - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.expander = BI.createWidget({ - type: "bi.expander", - element: this, - trigger: o.trigger, - toggle: o.toggle, - direction: o.direction, - isDefaultInit: o.isDefaultInit, - el: this.trigger, - popup: o.popup - }); - this.expander.on(BI.Controller.EVENT_CHANGE, function (type) { - if (type === BI.Events.CLICK) { - self.trigger.setSelected(false); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - }, - - setValue: function (v) { - if (BI.contains(v, this.trigger.getValue())) { - this.trigger.setSelected(true); - this.expander.setValue([]); - } else { - this.trigger.setSelected(false); - this.expander.setValue(v); - } - }, - - getValue: function () { - if (this.trigger.isSelected()) { - return [this.trigger.getValue()]; - } - return this.expander.getValue(); - }, - - populate: function (items) { - this.expander.populate(items); - } -}); - -BI.shortcut("bi.select_tree_expander", BI.SelectTreeExpander);/** - * @class BI.SelectTreePopup - * @extends BI.Pane - */ - -BI.SelectTreePopup = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.SelectTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-select-level-tree", - tipText: BI.i18nText("BI-No_Selected_Item"), - items: [], - value: "" - }); - }, - - _formatItems: function (nodes, layer) { - var self = this; - BI.each(nodes, function (i, node) { - var extend = {layer: layer}; - node.id = node.id || BI.UUID(); - if (node.isParent === true || BI.isNotEmptyArray(node.children)) { - switch (i) { - case 0 : - extend.type = "bi.select_tree_first_plus_group_node"; - break; - case nodes.length - 1 : - extend.type = "bi.select_tree_last_plus_group_node"; - break; - default : - extend.type = "bi.select_tree_mid_plus_group_node"; - break; - } - BI.defaults(node, extend); - self._formatItems(node.children); - } else { - switch (i) { - case nodes.length - 1: - extend.type = "bi.last_tree_leaf_item"; - break; - default : - extend.type = "bi.mid_tree_leaf_item"; - } - BI.defaults(node, extend); - } - }); - return nodes; - }, - - _init: function () { - BI.SelectTreePopup.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.tree = BI.createWidget({ - type: "bi.level_tree", - expander: { - type: "bi.select_tree_expander", - isDefaultInit: true - }, - items: this._formatItems(BI.Tree.transformToTreeFormat(o.items)), - value: o.value, - chooseType: BI.Selection.Single - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - vgap: 5, - items: [this.tree] - }); - - this.tree.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.SelectTreePopup.EVENT_CHANGE); - }); - - this.check(); - }, - - getValue: function () { - return this.tree.getValue(); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.tree.setValue(v); - }, - - populate: function (items) { - BI.SelectTreePopup.superclass.populate.apply(this, arguments); - this.tree.populate(this._formatItems(BI.Tree.transformToTreeFormat(items))); - } -}); - -BI.SelectTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.select_level_tree", BI.SelectTreePopup);/** - * - * Created by GUY on 2016/8/10. - * @class BI.SequenceTableDynamicNumber - * @extends BI.SequenceTableTreeNumber - */ -BI.SequenceTableDynamicNumber = BI.inherit(BI.SequenceTableTreeNumber, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableDynamicNumber.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-sequence-table-dynamic-number" - }); - }, - - _init: function () { - BI.SequenceTableDynamicNumber.superclass._init.apply(this, arguments); - }, - - _formatNumber: function (nodes) { - var self = this, o = this.options; - var result = []; - var count = this._getStart(nodes); - - function getLeafCount (node) { - var cnt = 0; - if (BI.isNotEmptyArray(node.children)) { - BI.each(node.children, function (index, child) { - cnt += getLeafCount(child); - }); - if (node.children.length > 1 && BI.isNotEmptyArray(node.values)) { - cnt++; - } - } else { - cnt++; - } - return cnt; - } - - var start = 0, top = 0; - BI.each(nodes, function (i, node) { - if (BI.isArray(node.children)) { - BI.each(node.children, function (index, child) { - var cnt = getLeafCount(child); - result.push({ - text: count++, - start: start, - top: top, - cnt: cnt, - index: index, - height: cnt * o.rowSize - }); - start += cnt; - top += cnt * o.rowSize; - }); - if (BI.isNotEmptyArray(node.values)) { - result.push({ - text: BI.i18nText("BI-Summary_Values"), - start: start++, - top: top, - cnt: 1, - isSummary: true, - height: o.rowSize - }); - top += o.rowSize; - } - } - }); - return result; - } -}); -BI.shortcut("bi.sequence_table_dynamic_number", BI.SequenceTableDynamicNumber);/** - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTableListNumber - * @extends BI.Widget - */ -BI.SequenceTableListNumber = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTableListNumber.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table-list-number", - isNeedFreeze: false, - scrollTop: 0, - startSequence: 1, // 开始的序号 - headerRowSize: 25, - rowSize: 25, - - sequenceHeaderCreator: BI.emptyFn, - - header: [], - items: [], // 二维数组 - - // 交叉表头 - crossHeader: [], - crossItems: [], - - pageSize: 20 - }); - }, - - _init: function () { - BI.SequenceTableListNumber.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.start = o.startSequence; - this.renderedCells = []; - this.renderedKeys = []; - - this.container = BI.createWidget({ - type: "bi.absolute", - width: 60, - scrollable: false - }); - - this.scrollContainer = BI.createWidget({ - type: "bi.vertical", - scrollable: false, - scrolly: false, - items: [this.container] - }); - - this.headerContainer = BI.createWidget({ - type: "bi.absolute", - cls: "bi-border", - width: 58, - scrollable: false - }); - - this.layout = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.headerContainer, - height: o.headerRowSize * o.header.length - 2 - }, { - el: {type: "bi.layout"}, - height: 2 - }, { - el: this.scrollContainer - }] - }); - this._populate(); - }, - - _layout: function () { - var self = this, o = this.options; - var headerHeight = o.headerRowSize * o.header.length - 2; - var items = this.layout.attr("items"); - if (o.isNeedFreeze === false) { - items[0].height = 0; - items[1].height = 0; - } else if (o.isNeedFreeze === true) { - items[0].height = headerHeight; - items[1].height = 2; - } - this.layout.attr("items", items); - this.layout.resize(); - this.container.setHeight(o.items.length * o.rowSize); - try { - this.scrollContainer.element.scrollTop(o.scrollTop); - } catch (e) { - - } - }, - - _createHeader: function () { - var o = this.options; - BI.createWidget({ - type: "bi.absolute", - element: this.headerContainer, - items: [{ - el: o.sequenceHeaderCreator() || { - type: "bi.table_style_cell", - cls: "sequence-table-title-cell", - styleGetter: o.headerCellStyleGetter, - text: BI.i18nText("BI-Number_Index") - }, - left: 0, - top: 0, - right: 0, - bottom: 0 - }] - }); - }, - - _calculateChildrenToRender: function () { - var self = this, o = this.options; - var scrollTop = BI.clamp(o.scrollTop, 0, o.rowSize * o.items.length - (o.height - o.header.length * o.headerRowSize) + BI.DOM.getScrollWidth()); - var start = Math.floor(scrollTop / o.rowSize); - var end = start + Math.floor((o.height - o.header.length * o.headerRowSize) / o.rowSize); - var renderedCells = [], renderedKeys = []; - for (var i = start, cnt = 0; i <= end && i < o.items.length; i++, cnt++) { - var index = BI.deepIndexOf(this.renderedKeys, this.start + i); - var top = i * o.rowSize; - if (index > -1) { - if (o.rowSize !== this.renderedCells[index]._height) { - this.renderedCells[index]._height = o.rowSize; - this.renderedCells[index].el.setHeight(o.rowSize); - } - if (this.renderedCells[index].top !== top) { - this.renderedCells[index].top = top; - this.renderedCells[index].el.element.css("top", top + "px"); - } - renderedCells.push(this.renderedCells[index]); - } else { - var child = BI.createWidget(BI.extend({ - type: "bi.table_style_cell", - cls: "sequence-table-number-cell bi-border-left bi-border-right bi-border-bottom", - width: 60, - height: o.rowSize, - text: this.start + i, - styleGetter: function (index) { - return function () { - return o.sequenceCellStyleGetter(self.start + i - 1); - }; - }(cnt) - })); - renderedCells.push({ - el: child, - left: 0, - top: top, - _height: o.rowSize - }); - } - renderedKeys.push(this.start + i); - } - - // 已存在的, 需要添加的和需要删除的 - var existSet = {}, addSet = {}, deleteArray = []; - BI.each(renderedKeys, function (i, key) { - if (BI.deepContains(self.renderedKeys, key)) { - existSet[i] = key; - } else { - addSet[i] = key; - } - }); - BI.each(this.renderedKeys, function (i, key) { - if (BI.deepContains(existSet, key)) { - return; - } - if (BI.deepContains(addSet, key)) { - return; - } - deleteArray.push(i); - }); - BI.each(deleteArray, function (i, index) { - self.renderedCells[index].el.destroy(); - }); - var addedItems = []; - BI.each(addSet, function (index) { - addedItems.push(renderedCells[index]); - }); - BI.createWidget({ - type: "bi.absolute", - element: this.container, - items: addedItems - }); - this.renderedCells = renderedCells; - this.renderedKeys = renderedKeys; - }, - - _populate: function () { - this.headerContainer.empty(); - this._createHeader(); - this._layout(); - this._calculateChildrenToRender(); - }, - - setVerticalScroll: function (scrollTop) { - if (this.options.scrollTop !== scrollTop) { - this.options.scrollTop = scrollTop; - try { - this.scrollContainer.element.scrollTop(scrollTop); - } catch (e) { - - } - } - }, - - getVerticalScroll: function () { - return this.options.scrollTop; - }, - - setVPage: function (v) { - v = v < 1 ? 1 : v; - var o = this.options; - this.start = (v - 1) * o.pageSize + 1; - }, - - _restore: function () { - var o = this.options; - BI.each(this.renderedCells, function (i, cell) { - cell.el.destroy(); - }); - this.renderedCells = []; - this.renderedKeys = []; - }, - - restore: function () { - this._restore(); - }, - - populate: function (items, header) { - var o = this.options; - if (items && items !== this.options.items) { - o.items = items; - this._restore(); - } - if (header && header !== this.options.header) { - o.header = header; - } - this._populate(); - } -}); -BI.shortcut("bi.sequence_table_list_number", BI.SequenceTableListNumber);/** - * 带有序号的表格 - * - * Created by GUY on 2016/5/26. - * @class BI.SequenceTable - * @extends BI.Widget - */ -BI.SequenceTable = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SequenceTable.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-sequence-table", - el: { - type: "bi.adaptive_table" - }, - - sequence: {}, - - isNeedResize: true, - isResizeAdapt: false, - - isNeedFreeze: false, // 是否需要冻结单元格 - freezeCols: [], // 冻结的列号,从0开始,isNeedFreeze为true时生效 - - isNeedMerge: false, // 是否需要合并单元格 - mergeCols: [], // 合并的单元格列号 - mergeRule: BI.emptyFn, - - columnSize: [], - minColumnSize: [], - maxColumnSize: [], - headerRowSize: 25, - rowSize: 25, - - regionColumnSize: [], - - headerCellStyleGetter: BI.emptyFn, - summaryCellStyleGetter: BI.emptyFn, - sequenceCellStyleGetter: BI.emptyFn, - - header: [], - items: [], // 二维数组 - - // 交叉表头 - crossHeader: [], - crossItems: [], - - showSequence: false, - startSequence: 1// 开始的序号 - }); - }, - - _init: function () { - BI.SequenceTable.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.sequence = BI.createWidget(o.sequence, { - type: "bi.sequence_table_list_number", - invisible: o.showSequence === false, - startSequence: o.startSequence, - isNeedFreeze: o.isNeedFreeze, - header: o.header, - items: o.items, - crossHeader: o.crossHeader, - crossItems: o.crossItems, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - width: 60, - height: o.height && o.height - BI.GridTableScrollbar.SIZE, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter - }); - this.table = BI.createWidget(o.el, { - type: "bi.adaptive_table", - width: o.showSequence === true ? o.width - 60 : o.width, - height: o.height, - isNeedResize: o.isNeedResize, - isResizeAdapt: o.isResizeAdapt, - - isNeedFreeze: o.isNeedFreeze, - freezeCols: o.freezeCols, - - isNeedMerge: o.isNeedMerge, - mergeCols: o.mergeCols, - mergeRule: o.mergeRule, - - columnSize: o.columnSize, - minColumnSize: o.minColumnSize, - maxColumnSize: o.maxColumnSize, - headerRowSize: o.headerRowSize, - rowSize: o.rowSize, - - regionColumnSize: o.regionColumnSize, - - headerCellStyleGetter: o.headerCellStyleGetter, - summaryCellStyleGetter: o.summaryCellStyleGetter, - sequenceCellStyleGetter: o.sequenceCellStyleGetter, - - header: o.header, - items: o.items, - // 交叉表头 - crossHeader: o.crossHeader, - crossItems: o.crossItems - }); - - this.table.on(BI.Table.EVENT_TABLE_SCROLL, function (scroll) { - if (self.sequence.getVerticalScroll() !== this.getVerticalScroll()) { - self.sequence.setVerticalScroll(this.getVerticalScroll()); - self.sequence.populate(); - } - self.fireEvent(BI.Table.EVENT_TABLE_SCROLL, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_REGION_RESIZE, arguments); - }); - this.table.on(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, function () { - o.regionColumnSize = this.getRegionColumnSize(); - o.columnSize = this.getColumnSize(); - self.fireEvent(BI.Table.EVENT_TABLE_AFTER_COLUMN_RESIZE, arguments); - }); - - this.htape = BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.sequence, - left: 0, - top: 0 - }, { - el: this.table, - top: 0, - left: o.showSequence === true ? 60 : 0 - }] - }); - this._populate(); - }, - - _populate: function () { - var o = this.options; - if (o.showSequence === true) { - this.sequence.setVisible(true); - this.table.element.css("left", "60px"); - this.table.setWidth(o.width - 60); - } else { - this.sequence.setVisible(false); - this.table.element.css("left", "0px"); - this.table.setWidth(o.width); - } - }, - - setWidth: function (width) { - BI.PageTable.superclass.setWidth.apply(this, arguments); - this.table.setWidth(this.options.showSequence ? width - 60 : width); - }, - - setHeight: function (height) { - BI.PageTable.superclass.setHeight.apply(this, arguments); - this.table.setHeight(height); - this.sequence.setHeight(height - BI.GridTableScrollbar.SIZE); - }, - - setColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setColumnSize(columnSize); - }, - - getColumnSize: function () { - return this.table.getColumnSize(); - }, - - setRegionColumnSize: function (columnSize) { - this.options.columnSize = columnSize; - this.table.setRegionColumnSize(columnSize); - }, - - getRegionColumnSize: function () { - return this.table.getRegionColumnSize(); - }, - - hasLeftHorizontalScroll: function () { - return this.table.hasLeftHorizontalScroll(); - }, - - hasRightHorizontalScroll: function () { - return this.table.hasRightHorizontalScroll(); - }, - - setLeftHorizontalScroll: function (scrollLeft) { - this.table.setLeftHorizontalScroll(scrollLeft); - }, - - setRightHorizontalScroll: function (scrollLeft) { - this.table.setRightHorizontalScroll(scrollLeft); - }, - - setVerticalScroll: function (scrollTop) { - this.table.setVerticalScroll(scrollTop); - this.sequence.setVerticalScroll(scrollTop); - }, - - getVerticalScroll: function () { - return this.table.getVerticalScroll(); - }, - - setVPage: function (page) { - this.sequence.setVPage && this.sequence.setVPage(page); - }, - - setHPage: function (page) { - this.sequence.setHPage && this.sequence.setHPage(page); - }, - - attr: function () { - BI.SequenceTable.superclass.attr.apply(this, arguments); - this.table.attr.apply(this.table, arguments); - this.sequence.attr.apply(this.sequence, arguments); - }, - - restore: function () { - this.table.restore(); - this.sequence.restore(); - }, - - populate: function (items, header, crossItems, crossHeader) { - var o = this.options; - if (items) { - o.items = items; - } - if (header) { - o.header = header; - } - if (crossItems) { - o.crossItems = crossItems; - } - if (crossHeader) { - o.crossHeader = crossHeader; - } - this._populate(); - this.table.populate.apply(this.table, arguments); - this.sequence.populate.apply(this.sequence, arguments); - this.sequence.setVerticalScroll(this.table.getVerticalScroll()); - }, - - destroy: function () { - this.table.destroy(); - BI.SequenceTable.superclass.destroy.apply(this, arguments); - } -}); -BI.shortcut("bi.sequence_table", BI.SequenceTable);/** - * 单选加载数据搜索loader面板 - * Created by guy on 15/11/4. - * @class BI.SingleSelectSearchLoader - * @extends Widget - */ -BI.SingleSelectSearchLoader = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectSearchLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-search-loader", - itemsCreator: BI.emptyFn, - keywordGetter: BI.emptyFn, - valueFormatter: BI.emptyFn - }); - }, - - _init: function () { - BI.SingleSelectSearchLoader.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - var hasNext = false; - - this.button_group = BI.createWidget({ - type: "bi.single_select_list", - element: this, - logic: { - dynamic: false - }, - value: opts.value, - el: { - tipText: BI.i18nText("BI-No_Select"), - el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } - } - }, - itemsCreator: function (op, callback) { - self.storeValue && (op = BI.extend(op || {}, { - selectedValues: [self.storeValue] - })); - opts.itemsCreator(op, function (ob) { - var keyword = ob.keyword = opts.keywordGetter(); - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && BI.isNotNull(self.storeValue)) { - var json = self._filterValues(self.storeValue); - firstItems = self._createItems(json); - } - callback(firstItems.concat(self._createItems(ob.items)), keyword || ""); - if (op.times === 1 && self.storeValue) { - self.setValue(self.storeValue); - } - }); - }, - hasNext: function () { - return hasNext; - } - }); - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.SingleSelectSearchLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.single_select_combo.item", - logic: { - dynamic: false - }, - height: 25, - selected: false - }); - }, - - _filterValues: function (src) { - var o = this.options; - var keyword = o.keywordGetter(); - var values = src || []; - var newValues = BI.map(BI.isArray(values) ? values : [values], function (i, v) { - return { - text: o.valueFormatter(v) || v, - value: v - }; - }); - if (BI.isKey(keyword)) { - var search = BI.Func.getSearchResult(newValues, keyword); - values = search.match.concat(search.find); - } - return BI.map(values, function (i, v) { - return { - text: v.text, - title: v.text, - value: v.value, - selected: false - }; - }); - }, - - setValue: function (v) { - // 暂存的值一定是新的值,不然v改掉后,storeValue也跟着改了 - this.storeValue = v; - this.button_group.setValue(v); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - empty: function () { - this.button_group.empty(); - }, - - populate: function (items) { - this.button_group.populate.apply(this.button_group, arguments); - }, - - resetHeight: function (h) { - this.button_group.resetHeight(h); - }, - - resetWidth: function (w) { - this.button_group.resetWidth(w); - } -}); - -BI.SingleSelectSearchLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_select_search_loader", BI.SingleSelectSearchLoader);/** - * - * 在搜索框中输入文本弹出的面板 - * @class BI.SingleSelectSearchPane - * @extends Widget - */ - -BI.SingleSelectSearchPane = BI.inherit(BI.Widget, { - - constants: { - height: 25, - lgap: 10, - tgap: 5 - }, - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectSearchPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-search-pane bi-card", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - keywordGetter: BI.emptyFn - }); - }, - - _init: function () { - BI.SingleSelectSearchPane.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.tooltipClick = BI.createWidget({ - type: "bi.label", - invisible: true, - text: BI.i18nText("BI-Click_Blank_To_Select"), - cls: "multi-select-toolbar", - height: this.constants.height - }); - - this.loader = BI.createWidget({ - type: "bi.single_select_search_loader", - keywordGetter: o.keywordGetter, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator.apply(self, [op, function (res) { - callback(res); - self.setKeyword(o.keywordGetter()); - }]); - }, - value: o.value - }); - this.loader.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.resizer = BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.tooltipClick, - height: 0 - }, { - el: this.loader - }] - }); - this.tooltipClick.setVisible(false); - }, - - setKeyword: function (keyword) { - var btn; - var isVisible = this.loader.getAllButtons().length > 0 && (btn = this.loader.getAllButtons()[0]) && (keyword === btn.getValue()); - if (isVisible !== this.tooltipClick.isVisible()) { - this.tooltipClick.setVisible(isVisible); - this.resizer.attr("items")[0].height = (isVisible ? this.constants.height : 0); - this.resizer.resize(); - } - }, - - hasMatched: function () { - return this.tooltipClick.isVisible(); - }, - - setValue: function (v) { - this.loader.setValue(v); - }, - - getValue: function () { - return this.loader.getValue(); - }, - - empty: function () { - this.loader.empty(); - }, - - populate: function (items) { - this.loader.populate.apply(this.loader, arguments); - } -}); - -BI.SingleSelectSearchPane.EVENT_CHANGE = "EVENT_CHANGE"; - -BI.shortcut("bi.single_select_search_pane", BI.SingleSelectSearchPane);/** - * - * @class BI.SingleSelectCombo - * @extends BI.Single - */ -BI.SingleSelectCombo = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-combo", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - height: 24 - }); - }, - - _init: function () { - BI.SingleSelectCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var assertShowValue = function () { - BI.isKey(self._startValue) && (self.storeValue = self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - }; - this.storeValue = o.value; - // 标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.single_select_trigger", - height: o.height, - // adapter: this.popup, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keywords)) { - // 预防trigger内部把当前的storeValue改掉 - self.trigger.setValue(self.getValue()); - } - callback.apply(self, arguments); - }); - }, - value: this.storeValue - }); - - this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () { - self._setStartValue(); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () { - self._setStartValue(); - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { - if (this.getSearcher().hasMatched()) { - var keyword = this.getSearcher().getKeyword(); - self.combo.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); - self._setStartValue(); - } - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } - }); - - this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) { - self.storeValue = this.getValue(); - assertShowValue(); - self._defaultState(); - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - el: this.trigger, - adjustLength: 1, - popup: { - type: "bi.single_select_popup_view", - ref: function () { - self.popup = this; - self.trigger.setAdapter(this); - }, - listeners: [{ - eventName: BI.SingleSelectPopupView.EVENT_CHANGE, - action: function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - self._defaultState(); - }); - } - }], - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - onLoaded: function () { - BI.nextTick(function () { - self.combo.adjustWidth(); - self.combo.adjustHeight(); - self.trigger.getSearcher().adjustView(); - }); - } - }, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - }, - value: o.value - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_HIDEVIEW, function () { - self.element.removeClass("combo-show"); - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.element.removeClass("combo-show").addClass("combo-show"); - this.setValue(self.storeValue); - BI.nextTick(function () { - self.populate(); - }); - }); - // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 - this.wants2Quit = false; - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - // important:关闭弹出时又可能没有退出编辑状态 - self.trigger.stopEditing(); - if (self.requesting === true) { - self.wants2Quit = true; - } else { - self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); - } - }); - - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "single-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }] - }); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - this.combo.hideView(); - }, - - _assertValue: function (val) {}, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - this.requesting = true; - o.itemsCreator({ - type: BI.SingleSelectCombo.REQ_GET_ALL_DATA, - keywords: keywords - }, function (ob) { - var values = BI.map(ob.items, "value"); - digest(values); - }); - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value["remove"](val); - } - }); - self._adjust(callback); - } - }, - - _adjust: function (callback) { - var self = this, o = this.options; - if (!this._count) { - o.itemsCreator({ - type: BI.SingleSelectCombo.REQ_GET_DATA_LENGTH - }, function (res) { - self._count = res.count; - adjust(); - callback(); - }); - } else { - adjust(); - callback(); - - } - - function adjust () { - if (self.wants2Quit === true) { - self.fireEvent(BI.SingleSelectCombo.EVENT_CONFIRM); - self.wants2Quit = false; - } - self.requesting = false; - } - }, - - _setStartValue: function (value) { - this._startValue = value; - this.popup.setStartValue(value); - }, - - setValue: function (v) { - this.storeValue = v; - this._assertValue(this.storeValue); - this.combo.setValue(this.storeValue); - }, - - getValue: function () { - return this.storeValue; - }, - - populate: function () { - this._count = null; - this.combo.populate.apply(this.combo, arguments); - } -}); - -BI.extend(BI.SingleSelectCombo, { - REQ_GET_DATA_LENGTH: 0, - REQ_GET_ALL_DATA: -1 -}); - -BI.SingleSelectCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut("bi.single_select_combo", BI.SingleSelectCombo); -/** - * - * @class BI.SingleSelectInsertCombo - * @extends BI.Single - */ -BI.SingleSelectInsertCombo = BI.inherit(BI.Single, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectInsertCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-combo", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - height: 24 - }); - }, - - _init: function () { - BI.SingleSelectInsertCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - var assertShowValue = function () { - BI.isKey(self._startValue) && (self.storeValue = self._startValue); - self.trigger.getSearcher().setState(self.storeValue); - }; - this.storeValue = o.value; - // 标记正在请求数据 - this.requesting = false; - - this.trigger = BI.createWidget({ - type: "bi.single_select_trigger", - height: o.height, - // adapter: this.popup, - valueFormatter: o.valueFormatter, - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (res) { - if (op.times === 1 && BI.isNotNull(op.keywords)) { - // 预防trigger内部把当前的storeValue改掉 - self.trigger.setValue(self.getValue()); - } - callback.apply(self, arguments); - }); - }, - value: this.storeValue - }); - - this.trigger.on(BI.SingleSelectTrigger.EVENT_START, function () { - self._setStartValue(); - this.getSearcher().setValue(self.storeValue); - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_STOP, function () { - self._setStartValue(); - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_PAUSE, function () { - var keyword = this.getSearcher().getKeyword(); - self.storeValue = keyword; - self.combo.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.populate(); - self._setStartValue(); - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_SEARCHING, function (keywords) { - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.combo.setValue(self.storeValue); - assertShowValue(); - self.combo.populate(); - self._setStartValue(); - } else { - self.combo.setValue(self.storeValue); - assertShowValue(); - } - }); - } - }); - - this.trigger.on(BI.SingleSelectTrigger.EVENT_CHANGE, function (value, obj) { - self.storeValue = this.getValue(); - assertShowValue(); - self._defaultState(); - }); - this.trigger.on(BI.SingleSelectTrigger.EVENT_COUNTER_CLICK, function () { - if (!self.combo.isViewVisible()) { - self.combo.showView(); - } - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - toggle: false, - el: this.trigger, - adjustLength: 1, - popup: { - type: "bi.single_select_popup_view", - ref: function () { - self.popup = this; - self.trigger.setAdapter(this); - }, - listeners: [{ - eventName: BI.SingleSelectPopupView.EVENT_CHANGE, - action: function () { - self.storeValue = this.getValue(); - self._adjust(function () { - assertShowValue(); - self._defaultState(); - }); - } - }], - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - onLoaded: function () { - BI.nextTick(function () { - self.combo.adjustWidth(); - self.combo.adjustHeight(); - self.trigger.getSearcher().adjustView(); - }); - } - }, - hideChecker: function (e) { - return triggerBtn.element.find(e.target).length === 0; - }, - value: o.value - }); - - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - this.setValue(self.storeValue); - BI.nextTick(function () { - self.populate(); - }); - }); - // 当退出的时候如果还在处理请求,则等请求结束后再对外发确定事件 - this.wants2Quit = false; - this.combo.on(BI.Combo.EVENT_AFTER_HIDEVIEW, function () { - // important:关闭弹出时又可能没有退出编辑状态 - self.trigger.stopEditing(); - if (self.requesting === true) { - self.wants2Quit = true; - } else { - self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); - } - }); - - var triggerBtn = BI.createWidget({ - type: "bi.trigger_icon_button", - width: o.height, - height: o.height, - cls: "single-select-trigger-icon-button" - }); - triggerBtn.on(BI.TriggerIconButton.EVENT_CHANGE, function () { - if (self.combo.isViewVisible()) { - self.combo.hideView(); - } else { - self.combo.showView(); - } - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.combo, - left: 0, - right: 0, - top: 0, - bottom: 0 - }, { - el: triggerBtn, - right: 0, - top: 0, - bottom: 0 - }] - }); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - this.combo.hideView(); - }, - - _assertValue: function (val) { - }, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - this.requesting = true; - o.itemsCreator({ - type: BI.SingleSelectInsertCombo.REQ_GET_ALL_DATA, - keywords: keywords - }, function (ob) { - var values = BI.map(ob.items, "value"); - digest(values); - }); - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value["remove"](val); - } - }); - self._adjust(callback); - } - }, - - _adjust: function (callback) { - var self = this, o = this.options; - adjust(); - callback(); - - function adjust () { - if (self.wants2Quit === true) { - self.fireEvent(BI.SingleSelectInsertCombo.EVENT_CONFIRM); - self.wants2Quit = false; - } - self.requesting = false; - } - }, - - _setStartValue: function (value) { - this._startValue = value; - this.popup.setStartValue(value); - }, - - setValue: function (v) { - this.storeValue = v; - this._assertValue(this.storeValue); - this.combo.setValue(this.storeValue); - }, - - getValue: function () { - return this.storeValue; - }, - - populate: function () { - this.combo.populate.apply(this.combo, arguments); - } -}); - -BI.extend(BI.SingleSelectInsertCombo, { - REQ_GET_DATA_LENGTH: 0, - REQ_GET_ALL_DATA: -1 -}); - -BI.SingleSelectInsertCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; - -BI.shortcut("bi.single_select_insert_combo", BI.SingleSelectInsertCombo);/** - * guy - * 单选框item - * @type {*|void|Object} - */ -BI.SingleSelectComboItem = BI.inherit(BI.BasicButton, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectComboItem.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-single-select-radio-item", - logic: { - dynamic: false - }, - height: 24 - }); - }, - _init: function () { - BI.SingleSelectComboItem.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.radio = BI.createWidget({ - type: "bi.radio" - }); - this.text = BI.createWidget({ - type: "bi.label", - cls: "list-item-text", - textAlign: "left", - whiteSpace: "nowrap", - textHeight: o.height, - height: o.height, - hgap: o.hgap, - text: o.text, - keyword: o.keyword, - value: o.value, - py: o.py - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic("horizontal", BI.extend(o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection("left", { - type: "bi.center_adapt", - items: [this.radio], - width: 26 - }, this.text) - })))); - }, - - doRedMark: function () { - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doClick: function () { - BI.SingleSelectComboItem.superclass.doClick.apply(this, arguments); - this.radio.setSelected(this.isSelected()); - }, - - setSelected: function (v) { - BI.SingleSelectComboItem.superclass.setSelected.apply(this, arguments); - this.radio.setSelected(v); - - } -}); - -BI.shortcut("bi.single_select_combo.item", BI.SingleSelectComboItem);/** - * 选择列表 - * - * Created by GUY on 2015/11/1. - * @class BI.SingleSelectList - * @extends BI.Widget - */ -BI.SingleSelectList = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-select-list", - direction: BI.Direction.Top, // toolbar的位置 - logic: { - dynamic: true - }, - items: [], - itemsCreator: BI.emptyFn, - hasNext: BI.emptyFn, - onLoaded: BI.emptyFn, - el: { - type: "bi.list_pane" - } - }); - }, - _init: function () { - BI.SingleSelectList.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.list = BI.createWidget(o.el, { - type: "bi.list_pane", - items: o.items, - itemsCreator: function (op, callback) { - o.itemsCreator(op, function (items) { - callback.apply(self, arguments); - }); - }, - onLoaded: o.onLoaded, - hasNext: o.hasNext, - value: o.value - }); - - this.list.on(BI.Controller.EVENT_CHANGE, function (type, value, obj) { - if (type === BI.Events.CLICK) { - self.fireEvent(BI.SingleSelectList.EVENT_CHANGE, value, obj); - } - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - BI.createWidget(BI.extend({ - element: this - }, BI.LogicFactory.createLogic(BI.LogicFactory.createLogicTypeByDirection(o.direction), BI.extend({ - scrolly: true - }, o.logic, { - items: BI.LogicFactory.createLogicItemsByDirection(o.direction, this.list) - })))); - - }, - - hasPrev: function () { - return this.list.hasPrev(); - }, - - hasNext: function () { - return this.list.hasNext(); - }, - - prependItems: function (items) { - this.list.prependItems.apply(this.list, arguments); - }, - - addItems: function (items) { - this.list.addItems.apply(this.list, arguments); - }, - - setValue: function (v) { - this.list.setValue([v]); - }, - - getValue: function () { - return this.list.getValue()[0]; - }, - - empty: function () { - this.list.empty(); - }, - - populate: function (items) { - this.list.populate.apply(this.list, arguments); - }, - - resetHeight: function (h) { - this.list.resetHeight ? this.list.resetHeight(h) : - this.list.element.css({"max-height": h + "px"}); - }, - - setNotSelectedValue: function () { - this.list.setNotSelectedValue.apply(this.list, arguments); - }, - - getNotSelectedValue: function () { - return this.list.getNotSelectedValue(); - }, - - getAllButtons: function () { - return this.list.getAllButtons(); - }, - - getAllLeaves: function () { - return this.list.getAllLeaves(); - }, - - getSelectedButtons: function () { - return this.list.getSelectedButtons(); - }, - - getNotSelectedButtons: function () { - return this.list.getNotSelectedButtons(); - }, - - getIndexByValue: function (value) { - return this.list.getIndexByValue(value); - }, - - getNodeById: function (id) { - return this.list.getNodeById(id); - }, - - getNodeByValue: function (value) { - return this.list.getNodeByValue(value); - } -}); -BI.SingleSelectList.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_select_list", BI.SingleSelectList);/** - * 单选加载数据面板 - * Created by guy on 15/11/2. - * @class BI.SingleSelectLoader - * @extends Widget - */ -BI.SingleSelectLoader = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectLoader.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-loader", - logic: { - dynamic: true - }, - el: { - height: 400 - }, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.SingleSelectLoader.superclass._init.apply(this, arguments); - - var self = this, opts = this.options; - var hasNext = false; - this.storeValue = opts.value; - this.button_group = BI.createWidget({ - type: "bi.single_select_list", - logic: opts.logic, - el: BI.extend({ - onLoaded: opts.onLoaded, - el: { - type: "bi.loader", - isDefaultInit: false, - logic: { - dynamic: true, - scrolly: true - }, - el: { - chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, - behaviors: { - redmark: function () { - return true; - } - }, - layouts: [{ - type: "bi.vertical" - }] - } - } - }, opts.el), - itemsCreator: function (op, callback) { - var startValue = self._startValue; - BI.isNotNull(self.storeValue) && (op = BI.extend(op || {}, { - selectedValues: [self.storeValue] - })); - opts.itemsCreator(op, function (ob) { - hasNext = ob.hasNext; - var firstItems = []; - if (op.times === 1 && BI.isNotNull(self.storeValue)) { - var json = BI.map([self.storeValue], function (i, v) { - var txt = opts.valueFormatter(v) || v; - return { - text: txt, - value: v, - title: txt, - selected: true - }; - }); - firstItems = self._createItems(json); - } - callback(firstItems.concat(self._createItems(ob.items)), ob.keyword || ""); - if (op.times === 1 && self.storeValue) { - BI.isKey(startValue) && (self.storeValue = startValue); - self.setValue(self.storeValue); - } - (op.times === 1) && self._scrollToTop(); - }); - }, - hasNext: function () { - return hasNext; - }, - value: this.storeValue - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - items: [this.button_group], - vgap: 5 - }); - - this.button_group.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.button_group.on(BI.SingleSelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.SingleSelectLoader.EVENT_CHANGE, arguments); - }); - }, - - _createItems: function (items) { - return BI.createItems(items, { - type: "bi.single_select_combo.item", - logic: this.options.logic, - cls: "bi-list-item-active", - height: 24, - selected: false - }); - }, - - _scrollToTop: function () { - var self = this; - BI.delay(function () { - self.button_group.element.scrollTop(0); - }, 30); - }, - - _assertValue: function (val) {}, - - setStartValue: function (v) { - this._startValue = v; - }, - - setValue: function (v) { - this.storeValue = v; - this._assertValue(this.storeValue); - this.button_group.setValue(this.storeValue); - }, - - getValue: function () { - return this.button_group.getValue(); - }, - - getAllButtons: function () { - return this.button_group.getAllButtons(); - }, - - empty: function () { - this.button_group.empty(); - }, - - populate: function (items) { - this.button_group.populate.apply(this.button_group, arguments); - }, - - resetHeight: function (h) { - this.button_group.resetHeight(h); - }, - - resetWidth: function (w) { - this.button_group.resetWidth(w); - } -}); - -BI.SingleSelectLoader.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_select_loader", BI.SingleSelectLoader); -/** - * 带加载的单选下拉面板 - * @class BI.SingleSelectPopupView - * @extends Widget - */ -BI.SingleSelectPopupView = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectPopupView.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-popup-view", - maxWidth: "auto", - minWidth: 135, - maxHeight: 400, - valueFormatter: BI.emptyFn, - itemsCreator: BI.emptyFn, - onLoaded: BI.emptyFn - }); - }, - - _init: function () { - BI.SingleSelectPopupView.superclass._init.apply(this, arguments); - var self = this, opts = this.options; - - this.loader = BI.createWidget({ - type: "bi.single_select_loader", - itemsCreator: opts.itemsCreator, - valueFormatter: opts.valueFormatter, - onLoaded: opts.onLoaded, - value: opts.value - }); - - this.popupView = BI.createWidget({ - type: "bi.popup_view", - stopPropagation: false, - maxWidth: opts.maxWidth, - minWidth: opts.minWidth, - maxHeight: opts.maxHeight, - element: this, - el: this.loader, - value: opts.value - }); - - this.popupView.on(BI.MultiPopupView.EVENT_CHANGE, function () { - self.fireEvent(BI.SingleSelectPopupView.EVENT_CHANGE); - }); - }, - - setStartValue: function (v) { - this.loader.setStartValue(v); - }, - - setValue: function (v) { - this.popupView.setValue(v); - }, - - getValue: function () { - return this.popupView.getValue(); - }, - - populate: function (items) { - this.popupView.populate.apply(this.popupView, arguments); - }, - - resetHeight: function (h) { - this.popupView.resetHeight(h); - }, - - resetWidth: function (w) { - this.popupView.resetWidth(w); - } -}); - -BI.SingleSelectPopupView.EVENT_CHANGE = "EVENT_CHANGE"; - - -BI.shortcut("bi.single_select_popup_view", BI.SingleSelectPopupView);/** - * - * 单选下拉框 - * @class BI.SingleSelectTrigger - * @extends BI.Trigger - */ - -BI.SingleSelectTrigger = BI.inherit(BI.Trigger, { - - constants: { - height: 14, - rgap: 4, - lgap: 4 - }, - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-trigger bi-border", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn, - searcher: {}, - switcher: {}, - - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.SingleSelectTrigger.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - if (o.height) { - this.setHeight(o.height - 2); - } - - this.searcher = BI.createWidget(o.searcher, { - type: "bi.single_select_searcher", - height: o.height, - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - popup: {}, - adapter: o.adapter, - masker: o.masker, - value: o.value - }); - this.searcher.on(BI.SingleSelectSearcher.EVENT_START, function () { - self.fireEvent(BI.SingleSelectTrigger.EVENT_START); - }); - this.searcher.on(BI.SingleSelectSearcher.EVENT_PAUSE, function () { - self.fireEvent(BI.SingleSelectTrigger.EVENT_PAUSE); - }); - this.searcher.on(BI.SingleSelectSearcher.EVENT_SEARCHING, function () { - self.fireEvent(BI.SingleSelectTrigger.EVENT_SEARCHING, arguments); - }); - this.searcher.on(BI.SingleSelectSearcher.EVENT_STOP, function () { - self.fireEvent(BI.SingleSelectTrigger.EVENT_STOP); - }); - this.searcher.on(BI.SingleSelectSearcher.EVENT_CHANGE, function () { - self.fireEvent(BI.SingleSelectTrigger.EVENT_CHANGE, arguments); - }); - - var wrapper = BI.createWidget({ - type: "bi.htape", - element: this, - items: [ - { - el: this.searcher, - width: "fill" - }, { - el: BI.createWidget(), - width: 24 - }] - }); - }, - - getSearcher: function () { - return this.searcher; - }, - - stopEditing: function () { - this.searcher.stopSearch(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - }, - - setValue: function (v) { - this.searcher.setValue(v); - }, - - getKey: function () { - return this.searcher.getKey(); - }, - - getValue: function () { - return this.searcher.getValue(); - } -}); - -BI.SingleSelectTrigger.EVENT_TRIGGER_CLICK = "EVENT_TRIGGER_CLICK"; -BI.SingleSelectTrigger.EVENT_COUNTER_CLICK = "EVENT_COUNTER_CLICK"; -BI.SingleSelectTrigger.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SingleSelectTrigger.EVENT_START = "EVENT_START"; -BI.SingleSelectTrigger.EVENT_STOP = "EVENT_STOP"; -BI.SingleSelectTrigger.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SingleSelectTrigger.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.SingleSelectTrigger.EVENT_BEFORE_COUNTER_POPUPVIEW = "EVENT_BEFORE_COUNTER_POPUPVIEW"; - -BI.shortcut("bi.single_select_trigger", BI.SingleSelectTrigger);/** - * @author: Teller - * @createdAt: 2018/3/28 - * @Description -*/ -BI.SingleSelectInsertList = BI.inherit(BI.Single, { - _defaultConfig: function () { - return BI.extend(BI.SingleSelectInsertList.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-multi-select-insert-list", - itemsCreator: BI.emptyFn, - valueFormatter: BI.emptyFn - }); - }, - _init: function () { - BI.SingleSelectInsertList.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - this.storeValue = o.value; - - var assertShowValue = function () { - BI.isKey(self._startValue) && (self.storeValue = self._startValue); - // self.trigger.setValue(self.storeValue); - }; - - this.adapter = BI.createWidget({ - type: "bi.single_select_loader", - cls: "popup-single-select-list bi-border-left bi-border-right bi-border-bottom", - itemsCreator: o.itemsCreator, - valueFormatter: o.valueFormatter, - logic: { - dynamic: true - }, - // onLoaded: o.onLoaded, - el: {}, - value: o.value - }); - this.adapter.on(BI.SingleSelectLoader.EVENT_CHANGE, function () { - self.storeValue = this.getValue(); - assertShowValue(); - self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); - }); - - this.searcherPane = BI.createWidget({ - type: "bi.single_select_search_pane", - cls: "bi-border-left bi-border-right bi-border-bottom", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.trigger.getKeyword(); - }, - itemsCreator: function (op, callback) { - op.keywords = [self.trigger.getKeyword()]; - this.setKeyword(op.keywords[0]); - o.itemsCreator(op, callback); - } - }); - this.searcherPane.setVisible(false); - - this.trigger = BI.createWidget({ - type: "bi.searcher", - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - adapter: this.adapter, - popup: this.searcherPane, - height: 200, - masker: false, - value: o.value, - listeners: [{ - eventName: BI.Searcher.EVENT_START, - action: function () { - self._showSearcherPane(); - self._setStartValue(); - this.setValue(BI.deepClone(self.storeValue)); - } - }, { - eventName: BI.Searcher.EVENT_STOP, - action: function () { - self._showAdapter(); - self._setStartValue(); - self.adapter.setValue(self.storeValue); - // 需要刷新回到初始界面,否则搜索的结果不能放在最前面 - self.adapter.populate(); - } - }, { - eventName: BI.Searcher.EVENT_PAUSE, - action: function () { - var keyword = this.getKeyword(); - self.storeValue = keyword; - self._showAdapter(); - self.adapter.setValue(self.storeValue); - self._setStartValue(keyword); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(); - self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); - } - }, { - eventName: BI.Searcher.EVENT_SEARCHING, - action: function () { - var keywords = this.getKeyword(); - var last = BI.last(keywords); - keywords = BI.initial(keywords || []); - if (keywords.length > 0) { - self._joinKeywords(keywords, function () { - if (BI.isEndWithBlank(last)) { - self.adapter.setValue(self.storeValue); - assertShowValue(); - self.adapter.populate(); - self._setStartValue(); - } else { - self.adapter.setValue(self.storeValue); - assertShowValue(); - } - }); - } - } - }, { - eventName: BI.Searcher.EVENT_CHANGE, - action: function () { - self.storeValue = this.getValue(); - self.fireEvent(BI.SingleSelectInsertList.EVENT_CHANGE); - } - }] - }); - - BI.createWidget({ - type: "bi.vtape", - element: this, - items: [{ - el: this.trigger, - height: 24 - }, { - el: this.adapter, - height: "fill" - }] - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.searcherPane, - top: 30, - bottom: 0, - left: 0, - right: 0 - }] - }); - }, - - _showAdapter: function () { - this.adapter.setVisible(true); - this.searcherPane.setVisible(false); - }, - - _showSearcherPane: function () { - this.searcherPane.setVisible(true); - this.adapter.setVisible(false); - }, - - _defaultState: function () { - this.trigger.stopEditing(); - }, - - _assertValue: function () {}, - - _makeMap: function (values) { - return BI.makeObject(values || []); - }, - - _joinKeywords: function (keywords, callback) { - var self = this, o = this.options; - this._assertValue(this.storeValue); - if (!this._allData) { - o.itemsCreator({ - type: BI.SingleSelectInsertList.REQ_GET_ALL_DATA - }, function (ob) { - self._allData = BI.map(ob.items, "value"); - digest(self._allData); - }); - } else { - digest(this._allData); - } - - function digest (items) { - var selectedMap = self._makeMap(items); - BI.each(keywords, function (i, val) { - if (BI.isNotNull(selectedMap[val])) { - self.storeValue.value[self.storeValue.type === BI.Selection.Single ? "pushDistinct" : "remove"](val); - } - }); - callback(); - } - }, - - _setStartValue: function (value) { - this._startValue = value; - this.adapter.setStartValue(value); - }, - - isAllSelected: function () { - return this.adapter.isAllSelected(); - }, - - resize: function () { - // this.trigger.getCounter().adjustView(); - // this.trigger.adjustView(); - }, - setValue: function (v) { - this.storeValue = v; - this.adapter.setValue(this.storeValue); - this.trigger.setValue(this.storeValue); - }, - - getValue: function () { - return BI.deepClone(this.storeValue); - }, - - populate: function () { - this._count = null; - this._allData = null; - this.adapter.populate.apply(this.adapter, arguments); - this.trigger.populate.apply(this.trigger, arguments); - } -}); - -BI.extend(BI.SingleSelectInsertList, { - REQ_GET_DATA_LENGTH: 0, - REQ_GET_ALL_DATA: -1 -}); - -BI.SingleSelectInsertList.EVENT_CHANGE = "BI.SingleSelectInsertList.EVENT_CHANGE"; -BI.shortcut("bi.single_select_insert_list", BI.SingleSelectInsertList); -/** - * 单选输入框 - * Created by guy on 15/11/3. - * @class BI.SingleSelectEditor - * @extends Widget - */ -BI.SingleSelectEditor = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectEditor.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-editor", - el: {} - }); - }, - - _init: function () { - BI.SingleSelectEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget(o.el, { - type: "bi.state_editor", - element: this, - height: o.height, - watermark: BI.i18nText("BI-Basic_Search"), - allowBlank: true, - value: o.value - }); - - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.editor.on(BI.StateEditor.EVENT_PAUSE, function () { - self.fireEvent(BI.SingleSelectEditor.EVENT_PAUSE); - }); - this.editor.on(BI.StateEditor.EVENT_CLICK_LABEL, function () { - - }); - }, - - focus: function () { - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - }, - - setState: function (state) { - this.editor.setState(state); - }, - - setValue: function (v) { - this.editor.setValue(v); - }, - - getValue: function () { - var v = this.editor.getState(); - if (BI.isArray(v) && v.length > 0) { - return v[v.length - 1]; - } - return ""; - - }, - - getKeywords: function () { - var val = this.editor.getLastValidValue(); - var keywords = val.match(/[\S]+/g); - if (BI.isEndWithBlank(val)) { - return keywords.concat([" "]); - } - return keywords; - }, - - populate: function (items) { - - } -}); -BI.SingleSelectEditor.EVENT_PAUSE = "SingleSelectEditor.EVENT_PAUSE"; -BI.shortcut("bi.single_select_editor", BI.SingleSelectEditor);/** - * searcher - * Created by guy on 15/11/3. - * @class BI.SingleSelectSearcher - * @extends Widget - */ -BI.SingleSelectSearcher = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleSelectSearcher.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-select-searcher", - itemsCreator: BI.emptyFn, - el: {}, - popup: {}, - valueFormatter: BI.emptyFn, - adapter: null, - masker: {} - }); - }, - - _init: function () { - BI.SingleSelectSearcher.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget(o.el, { - type: "bi.single_select_editor", - height: o.height - }); - - this.searcher = BI.createWidget({ - type: "bi.searcher", - element: this, - height: o.height, - isAutoSearch: false, - isAutoSync: false, - onSearch: function (op, callback) { - callback(); - }, - el: this.editor, - - popup: BI.extend({ - type: "bi.single_select_search_pane", - valueFormatter: o.valueFormatter, - keywordGetter: function () { - return self.editor.getValue(); - }, - itemsCreator: function (op, callback) { - var keyword = self.editor.getValue(); - op.keywords = [keyword]; - this.setKeyword(keyword); - o.itemsCreator(op, callback); - }, - value: o.value - }, o.popup), - - adapter: o.adapter, - masker: o.masker - }); - this.searcher.on(BI.Searcher.EVENT_START, function () { - self.fireEvent(BI.SingleSelectSearcher.EVENT_START); - }); - this.searcher.on(BI.Searcher.EVENT_PAUSE, function () { - if (this.hasMatched()) { - - } - self.fireEvent(BI.SingleSelectSearcher.EVENT_PAUSE); - }); - this.searcher.on(BI.Searcher.EVENT_STOP, function () { - self.fireEvent(BI.SingleSelectSearcher.EVENT_STOP); - }); - this.searcher.on(BI.Searcher.EVENT_CHANGE, function () { - self.fireEvent(BI.SingleSelectSearcher.EVENT_CHANGE, arguments); - }); - this.searcher.on(BI.Searcher.EVENT_SEARCHING, function () { - var keywords = this.getKeywords(); - self.fireEvent(BI.SingleSelectSearcher.EVENT_SEARCHING, keywords); - }); - - if(BI.isNotNull(o.value)){ - this.setState(o.value); - } - }, - - adjustView: function () { - this.searcher.adjustView(); - }, - - isSearching: function () { - return this.searcher.isSearching(); - }, - - stopSearch: function () { - this.searcher.stopSearch(); - }, - - getKeyword: function () { - return this.editor.getValue(); - }, - - hasMatched: function () { - return this.searcher.hasMatched(); - }, - - hasChecked: function () { - return this.searcher.getView() && this.searcher.getView().hasChecked(); - }, - - setAdapter: function (adapter) { - this.searcher.setAdapter(adapter); - }, - - setState: function (v) { - var o = this.options; - if (BI.isNull(v)) { - this.editor.setState(BI.Selection.None); - } else { - this.editor.setState(o.valueFormatter(v + "") || (v + "")); - } - }, - - setValue: function (ob) { - this.setState(ob); - this.searcher.setValue(ob); - }, - - getKey: function () { - return this.editor.getValue(); - }, - - getValue: function () { - return this.searcher.getValue(); - }, - - populate: function (items) { - this.searcher.populate.apply(this.searcher, arguments); - } -}); - -BI.SingleSelectSearcher.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.SingleSelectSearcher.EVENT_CHANGE = "EVENT_CHANGE"; -BI.SingleSelectSearcher.EVENT_START = "EVENT_START"; -BI.SingleSelectSearcher.EVENT_STOP = "EVENT_STOP"; -BI.SingleSelectSearcher.EVENT_PAUSE = "EVENT_PAUSE"; -BI.SingleSelectSearcher.EVENT_SEARCHING = "EVENT_SEARCHING"; -BI.shortcut("bi.single_select_searcher", BI.SingleSelectSearcher); -/** - * Created by User on 2017/11/16. - */ -BI.SignTextEditor = BI.inherit(BI.Widget, { - _defaultConfig: function () { - var conf = BI.SignTextEditor.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - baseCls: (conf.baseCls || "") + " bi-sign-initial-editor", - validationChecker: BI.emptyFn, - text: "", - height: 24 - }); - }, - - _init: function () { - BI.SignTextEditor.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.editor = BI.createWidget({ - type: "bi.editor", - height: o.height, - hgap: 4, - vgap: 2, - value: o.value, - validationChecker: o.validationChecker, - allowBlank: false - }); - this.text = BI.createWidget({ - type: "bi.text_button", - cls: "sign-editor-text", - title: function () { - return self.getValue(); - }, - textAlign: o.textAlign, - height: o.height, - hgap: 4, - handler: function () { - self._showInput(); - self.editor.focus(); - self.editor.selectAll(); - } - }); - this.text.on(BI.TextButton.EVENT_CHANGE, function () { - BI.nextTick(function () { - self.fireEvent(BI.SignTextEditor.EVENT_CLICK_LABEL); - }); - }); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: this.text, - left: 0, - right: 0, - top: 0, - bottom: 0 - }] - }); - this.editor.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.editor.on(BI.Editor.EVENT_CONFIRM, function () { - self._showHint(); - self._checkText(); - self.fireEvent(BI.SignTextEditor.EVENT_CONFIRM, arguments); - }); - this.editor.on(BI.Editor.EVENT_ERROR, function () { - self._checkText(); - }); - BI.createWidget({ - type: "bi.vertical", - scrolly: false, - element: this, - items: [this.editor] - }); - this._showHint(); - self._checkText(); - }, - - _checkText: function () { - var o = this.options; - BI.nextTick(BI.bind(function () { - if (this.editor.getValue() === "") { - this.text.setValue(o.watermark || ""); - this.text.element.addClass("bi-water-mark"); - } else { - var v = this.editor.getValue(); - v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text; - this.text.setValue(v); - this.text.element.removeClass("bi-water-mark"); - } - }, this)); - }, - - _showInput: function () { - this.editor.visible(); - this.text.invisible(); - }, - - _showHint: function () { - this.editor.invisible(); - this.text.visible(); - }, - - setTitle: function (title) { - this.text.setTitle(title); - }, - - setWarningTitle: function (title) { - this.text.setWarningTitle(title); - }, - - focus: function () { - this._showInput(); - this.editor.focus(); - }, - - blur: function () { - this.editor.blur(); - this._showHint(); - this._checkText(); - }, - - doRedMark: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doRedMark.apply(this.text, arguments); - }, - - unRedMark: function () { - this.text.unRedMark.apply(this.text, arguments); - }, - - doHighLight: function () { - if (this.editor.getValue() === "" && BI.isKey(this.options.watermark)) { - return; - } - this.text.doHighLight.apply(this.text, arguments); - }, - - unHighLight: function () { - this.text.unHighLight.apply(this.text, arguments); - }, - - isValid: function () { - return this.editor.isValid(); - }, - - setErrorText: function (text) { - this.editor.setErrorText(text); - }, - - getErrorText: function () { - return this.editor.getErrorText(); - }, - - isEditing: function () { - return this.editor.isEditing(); - }, - - getLastValidValue: function () { - return this.editor.getLastValidValue(); - }, - - setValue: function (v) { - this.editor.setValue(v); - this._checkText(); - }, - - getValue: function () { - return this.editor.getValue(); - }, - - getState: function () { - return this.text.getValue(); - }, - - setState: function (v) { - var o = this.options; - this._showHint(); - v = (BI.isEmpty(v) || v == o.text) ? o.text : v + o.text; - this.text.setValue(v); - } -}); -BI.SignTextEditor.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.SignTextEditor.EVENT_CLICK_LABEL = "EVENT_CLICK_LABEL"; - -BI.shortcut("bi.sign_text_editor", BI.SignTextEditor);/** - * Created by zcf on 2016/9/22. - */ -BI.SliderIconButton = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-single-slider-button" - }, - - constants: { - LARGE_SIZE: 16, - NORMAL_SIZE: 12, - LARGE_OFFSET: 4, - NORMAL_OFFSET: 6 - }, - - render: function () { - var self = this; - return { - type: "bi.absolute", - ref: function () { - self.wrapper = this; - }, - items: [{ - el: { - type: "bi.text_button", - forceNotSelected: true, - cls: "slider-button bi-list-item-select2", - ref: function () { - self.slider = this; - } - } - }] - }; - } -}); -BI.shortcut("bi.single_slider_button", BI.SliderIconButton);/** - * Created by zcf on 2016/9/22. - */ -BI.SingleSlider = BI.inherit(BI.Widget, { - _constant: { - EDITOR_WIDTH: 90, - EDITOR_HEIGHT: 30, - SLIDER_WIDTH_HALF: 15, - SLIDER_WIDTH: 30, - SLIDER_HEIGHT: 30, - TRACK_HEIGHT: 24 - }, - - props: { - baseCls: "bi-single-slider bi-slider-track", - digit: false, - unit: "" - }, - - render: function () { - var self = this, o = this.options; - var c = this._constant; - this.enable = false; - this.value = ""; - - this.grayTrack = BI.createWidget({ - type: "bi.layout", - cls: "gray-track", - height: 6 - }); - this.blueTrack = BI.createWidget({ - type: "bi.layout", - cls: "blue-track bi-high-light-background", - height: 6 - }); - this.track = this._createTrackWrapper(); - - this.slider = BI.createWidget({ - type: "bi.single_slider_button" - }); - this._draggable(this.slider); - var sliderVertical = BI.createWidget({ - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [this.slider] - }], - hgap: c.SLIDER_WIDTH_HALF, - height: c.SLIDER_HEIGHT - }); - // 这边其实是有问题的,拖拽区域是个圆,在圆的边缘拖拽后放开,这边计算出来的蓝条宽度实际上会比放开时长一点或者短一点 - sliderVertical.element.click(function (e) { - if (self.enable && self.isEnabled()) { - var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF; - var trackLength = self.track.element[0].scrollWidth; - var percent = 0; - if (offset < 0) { - percent = 0; - } - if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) { - percent = offset * 100 / self._getGrayTrackLength(); - } - if (offset > (trackLength - c.SLIDER_WIDTH)) { - percent = 100; - } - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setAllPosition(significantPercent); - var v = self._getValueByPercent(significantPercent); - v = o.digit === false ? v : v.toFixed(o.digit); - self.label.setValue(v); - self.value = v; - self.fireEvent(BI.SingleSlider.EVENT_CHANGE); - } - }); - this.label = BI.createWidget({ - type: "bi.sign_text_editor", - cls: "slider-editor-button", - text: o.unit, - width: c.EDITOR_WIDTH - 2, - allowBlank: false, - textAlign: "center", - validationChecker: function (v) { - return self._checkValidation(v); - } - }); - this.label.element.hover(function () { - self.label.element.removeClass("bi-border").addClass("bi-border"); - }, function () { - self.label.element.removeClass("bi-border"); - }); - this.label.on(BI.SignEditor.EVENT_CONFIRM, function () { - var v = BI.parseFloat(this.getValue()); - var percent = self._getPercentByValue(v); - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setAllPosition(significantPercent); - this.setValue(v); - self.value = v; - self.fireEvent(BI.SingleSlider.EVENT_CHANGE); - }); - this._setVisible(false); - return { - type: "bi.absolute", - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.track, - width: "100%", - height: c.TRACK_HEIGHT - }] - }], - hgap: 7, - height: c.TRACK_HEIGHT - }, - top: 23, - left: 0, - width: "100%" - }, { - el: sliderVertical, - top: 20, - left: 0, - width: "100%" - }, { - el: { - type: "bi.vertical", - items: [{ - type: "bi.horizontal_auto", - items: [this.label] - }], - height: c.EDITOR_HEIGHT - }, - top: 0, - left: 0, - width: "100%" - }] - }; - }, - - _draggable: function (widget) { - var self = this, o = this.options; - var startDrag = false; - var size = 0, offset = 0, defaultSize = 0; - var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { - if (mouseMoveTracker.isDragging()) { - startDrag = true; - offset += deltaX; - size = optimizeSize(defaultSize + offset); - widget.element.addClass("dragging"); - var percent = size * 100 / (self._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 - self._setBlueTrack(significantPercent); - self._setLabelPosition(significantPercent); - self._setSliderPosition(significantPercent); - var v = self._getValueByPercent(significantPercent); - v = o.digit === false ? v : v.toFixed(o.digit); - self.label.setValue(v); - self.value = v; - self.fireEvent(BI.SingleSlider.EVENT_CHANGE); - } - }, function () { - if (startDrag === true) { - size = optimizeSize(size); - var percent = size * 100 / (self._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setSliderPosition(significantPercent); - size = 0; - offset = 0; - defaultSize = size; - startDrag = false; - } - widget.element.removeClass("dragging"); - mouseMoveTracker.releaseMouseMoves(); - self.fireEvent(BI.SingleSlider.EVENT_CHANGE); - }, window); - widget.element.on("mousedown", function (event) { - if(!widget.isEnabled()) { - return; - } - defaultSize = this.offsetLeft; - optimizeSize(defaultSize); - mouseMoveTracker.captureMouseMoves(event); - }); - - function optimizeSize (s) { - return BI.clamp(s, 0, self._getGrayTrackLength()); - } - }, - - _createTrackWrapper: function () { - return BI.createWidget({ - type: "bi.absolute", - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.grayTrack, - top: 0, - left: 0, - width: "100%" - }, { - el: this.blueTrack, - top: 0, - left: 0, - width: "0%" - }] - }], - hgap: 8, - height: 8 - }, - top: 8, - left: 0, - width: "100%" - }] - }); - }, - - _checkValidation: function (v) { - var o = this.options; - var valid = false; - if (BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max)) { - if(o.digit === false) { - valid = true; - }else{ - var dotText = (v + "").split(".")[1] || ""; - valid = (dotText.length === o.digit); - } - } - return valid; - }, - - _setBlueTrack: function (percent) { - this.blueTrack.element.css({width: percent + "%"}); - }, - - _setLabelPosition: function (percent) { - // this.label.element.css({left: percent + "%"}); - }, - - _setSliderPosition: function (percent) { - this.slider.element.css({left: percent + "%"}); - }, - - _setAllPosition: function (percent) { - this._setSliderPosition(percent); - this._setLabelPosition(percent); - this._setBlueTrack(percent); - }, - - _setVisible: function (visible) { - this.slider.setVisible(visible); - this.label.setVisible(visible); - }, - - _getGrayTrackLength: function () { - return this.grayTrack.element[0].scrollWidth; - }, - - _getValueByPercent: function (percent) { - var thousandth = BI.parseInt(percent * 10); - return (((this.max - this.min) * thousandth) / 1000 + this.min); - }, - - _getPercentByValue: function (v) { - return (v - this.min) * 100 / (this.max - this.min); - }, - - getValue: function () { - return this.value; - }, - - setValue: function (v) { - var o = this.options; - v = BI.parseFloat(v); - v = o.digit === false ? v : v.toFixed(o.digit); - if ((!isNaN(v))) { - if (this._checkValidation(v)) { - this.value = v; - } - if (v > this.max) { - this.value = this.max; - } - if (v < this.min) { - this.value = this.min; - } - } - }, - - _setEnable: function (b) { - BI.SingleSlider.superclass._setEnable.apply(this, [b]); - if(b) { - this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); - } else { - this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); - } - }, - - setMinAndMax: function (v) { - var minNumber = BI.parseFloat(v.min); - var maxNumber = BI.parseFloat(v.max); - if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) { - this.min = minNumber; - this.max = maxNumber; - } - }, - - reset: function () { - this._setVisible(false); - this.enable = false; - this.value = ""; - this.min = 0; - this.max = 0; - this._setBlueTrack(0); - - }, - - populate: function () { - if (!isNaN(this.min) && !isNaN(this.max)) { - this._setVisible(true); - this.enable = true; - this.label.setErrorText(BI.i18nText("BI-Basic_Please_Enter_Number_Between", this.min, this.max)); - if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) { - this.label.setValue(this.value); - this._setAllPosition(this._getPercentByValue(this.value)); - } else { - this.label.setValue(this.max); - this._setAllPosition(100); - } - } - } -}); -BI.SingleSlider.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_slider", BI.SingleSlider);/** - * Created by Urthur on 2017/9/12. - */ -BI.SingleSliderLabel = BI.inherit(BI.Widget, { - _constant: { - EDITOR_WIDTH: 90, - EDITOR_HEIGHT: 20, - HEIGHT: 20, - SLIDER_WIDTH_HALF: 15, - SLIDER_WIDTH: 30, - SLIDER_HEIGHT: 30, - TRACK_HEIGHT: 24 - }, - _defaultConfig: function () { - return BI.extend(BI.SingleSliderLabel.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-slider-label bi-slider-track", - digit: false, - unit: "" - }); - }, - _init: function () { - BI.SingleSliderLabel.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - var c = this._constant; - this.enable = false; - this.value = ""; - - this.grayTrack = BI.createWidget({ - type: "bi.layout", - cls: "gray-track", - height: 6 - }); - this.blueTrack = BI.createWidget({ - type: "bi.layout", - cls: "blue-track bi-high-light-background", - height: 6 - }); - this.track = this._createTrackWrapper(); - - this.slider = BI.createWidget({ - type: "bi.single_slider_button" - }); - this._draggable(this.slider); - var sliderVertical = BI.createWidget({ - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [this.slider] - }], - hgap: c.SLIDER_WIDTH_HALF, - height: c.SLIDER_HEIGHT - }); - sliderVertical.element.click(function (e) { - if (self.enable && self.isEnabled()) { - var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF; - var trackLength = self.track.element[0].scrollWidth; - var percent = 0; - if (offset < 0) { - percent = 0; - } - if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) { - percent = offset * 100 / self._getGrayTrackLength(); - } - if (offset > (trackLength - c.SLIDER_WIDTH)) { - percent = 100; - } - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setAllPosition(significantPercent); - var v = self._getValueByPercent(significantPercent); - v = o.digit === false ? v : v.toFixed(o.digit); - self.label.setText(v + o.unit); - self.value = v; - self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); - } - }); - this.label = BI.createWidget({ - type: "bi.label", - height: c.HEIGHT, - width: c.EDITOR_WIDTH - 2 - }); - - this._setVisible(false); - BI.createWidget({ - type: "bi.absolute", - element: this, - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.track, - width: "100%", - height: c.TRACK_HEIGHT - }] - }], - hgap: 7, - height: c.TRACK_HEIGHT - }, - top: 13, - left: 0, - width: "100%" - }, { - el: sliderVertical, - top: 10, - left: 0, - width: "100%" - }, { - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [this.label] - }], - rgap: c.EDITOR_WIDTH, - height: c.EDITOR_HEIGHT - }, - top: 0, - left: 0, - width: "100%" - }] - }); - }, - - _draggable: function (widget) { - var self = this, o = this.options; - var startDrag = false; - var size = 0, offset = 0, defaultSize = 0; - var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { - if (mouseMoveTracker.isDragging()) { - startDrag = true; - offset += deltaX; - size = optimizeSize(defaultSize + offset); - widget.element.addClass("dragging"); - var percent = size * 100 / (self._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 - self._setBlueTrack(significantPercent); - self._setLabelPosition(significantPercent); - self._setSliderPosition(significantPercent); - var v = self._getValueByPercent(significantPercent); - v = o.digit === false ? v : v.toFixed(o.digit); - self.label.setValue(v); - self.value = v; - self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); - } - }, function () { - if (startDrag === true) { - size = optimizeSize(size); - var percent = size * 100 / (self._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setSliderPosition(significantPercent); - size = 0; - offset = 0; - defaultSize = size; - startDrag = false; - } - widget.element.removeClass("dragging"); - mouseMoveTracker.releaseMouseMoves(); - self.fireEvent(BI.SingleSliderLabel.EVENT_CHANGE); - }, window); - widget.element.on("mousedown", function (event) { - if(!widget.isEnabled()) { - return; - } - defaultSize = this.offsetLeft; - optimizeSize(defaultSize); - mouseMoveTracker.captureMouseMoves(event); - }); - - function optimizeSize (s) { - return BI.clamp(s, 0, self._getGrayTrackLength()); - } - }, - - _createTrackWrapper: function () { - return BI.createWidget({ - type: "bi.absolute", - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.grayTrack, - top: 0, - left: 0, - width: "100%" - }, { - el: this.blueTrack, - top: 0, - left: 0, - width: "0%" - }] - }], - hgap: 8, - height: 8 - }, - top: 8, - left: 0, - width: "100%" - }] - }); - }, - - _checkValidation: function (v) { - return BI.isNumeric(v) && !(BI.isNull(v) || v < this.min || v > this.max); - }, - - _setBlueTrack: function (percent) { - this.blueTrack.element.css({width: percent + "%"}); - }, - - _setLabelPosition: function (percent) { - this.label.element.css({left: percent + "%"}); - }, - - _setSliderPosition: function (percent) { - this.slider.element.css({left: percent + "%"}); - }, - - _setAllPosition: function (percent) { - this._setSliderPosition(percent); - this._setLabelPosition(percent); - this._setBlueTrack(percent); - }, - - _setVisible: function (visible) { - this.slider.setVisible(visible); - this.label.setVisible(visible); - }, - - _getGrayTrackLength: function () { - return this.grayTrack.element[0].scrollWidth; - }, - - _getValueByPercent: function (percent) { - var thousandth = BI.parseInt(percent * 10); - return (((this.max - this.min) * thousandth) / 1000 + this.min); - }, - - _getPercentByValue: function (v) { - return (v - this.min) * 100 / (this.max - this.min); - }, - - _setEnable: function (b) { - BI.SingleSliderLabel.superclass._setEnable.apply(this, [b]); - if(b) { - this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); - } else { - this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); - } - }, - - getValue: function () { - return this.value; - }, - - setValue: function (v) { - var o = this.options; - v = BI.parseFloat(v); - v = o.digit === false ? v : v.toFixed(o.digit); - if ((!isNaN(v))) { - if (this._checkValidation(v)) { - this.value = v; - } - if (v > this.max) { - this.value = this.max; - } - if (v < this.min) { - this.value = this.min; - } - } - }, - - setMinAndMax: function (v) { - var minNumber = BI.parseFloat(v.min); - var maxNumber = BI.parseFloat(v.max); - if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) { - this.min = minNumber; - this.max = maxNumber; - } - }, - - reset: function () { - this._setVisible(false); - this.enable = false; - this.value = ""; - this.min = 0; - this.max = 0; - this._setBlueTrack(0); - }, - - populate: function () { - var o = this.options; - if (!isNaN(this.min) && !isNaN(this.max)) { - this._setVisible(true); - this.enable = true; - if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) { - this.label.setValue(this.value + o.unit); - this._setAllPosition(this._getPercentByValue(this.value)); - } else { - this.label.setValue(this.max + o.unit); - this._setAllPosition(100); - } - } - } -}); -BI.SingleSliderLabel.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_slider_label", BI.SingleSliderLabel);/** - * normal single slider - * Created by Young on 2017/6/21. - */ -BI.SingleSliderNormal = BI.inherit(BI.Widget, { - - _constant: { - HEIGHT: 28, - SLIDER_WIDTH_HALF: 15, - SLIDER_WIDTH: 30, - SLIDER_HEIGHT: 30, - TRACK_HEIGHT: 24 - }, - - props: { - baseCls: "bi-single-slider-normal bi-slider-track", - minMax: { - min: 0, - max: 100 - } - // color: "#3f8ce8" - }, - - render: function () { - var self = this; - var c = this._constant; - var track = this._createTrack(); - this.slider = BI.createWidget({ - type: "bi.single_slider_button" - }); - this._draggable(this.slider); - - var sliderVertical = BI.createWidget({ - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [this.slider] - }], - hgap: c.SLIDER_WIDTH_HALF, - height: c.SLIDER_HEIGHT - }); - sliderVertical.element.click(function (e) { - if (self.enable && self.isEnabled()) { - var offset = e.clientX - self.element.offset().left - c.SLIDER_WIDTH_HALF; - var trackLength = self.track.element[0].scrollWidth; - var percent = 0; - if (offset < 0) { - percent = 0; - } - if (offset > 0 && offset < (trackLength - c.SLIDER_WIDTH)) { - percent = offset * 100 / self._getGrayTrackLength(); - } - if (offset > (trackLength - c.SLIDER_WIDTH)) { - percent = 100; - } - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setAllPosition(significantPercent); - var v = self._getValueByPercent(significantPercent); - self.value = v; - self.fireEvent(BI.SingleSlider.EVENT_CHANGE); - } - }); - - return { - type: "bi.absolute", - element: this, - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: track, - width: "100%", - height: c.TRACK_HEIGHT - }] - }], - hgap: 7, - height: c.TRACK_HEIGHT - }, - top: 3, - left: 0, - width: "100%" - }, { - el: sliderVertical, - top: 0, - left: 0, - width: "100%" - }] - }; - }, - - _draggable: function (widget) { - var self = this, o = this.options; - var startDrag = false; - var size = 0, offset = 0, defaultSize = 0; - var mouseMoveTracker = new BI.MouseMoveTracker(function (deltaX) { - if (mouseMoveTracker.isDragging()) { - startDrag = true; - offset += deltaX; - size = optimizeSize(defaultSize + offset); - widget.element.addClass("dragging"); - var percent = size * 100 / (self._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1));// 直接对计算出来的百分数保留到小数点后一位,相当于分成了1000份。 - self._setBlueTrack(significantPercent); - self._setSliderPosition(significantPercent); - var v = self._getValueByPercent(significantPercent); - v = o.digit === false ? v : v.toFixed(o.digit); - self.value = v; - self.fireEvent(BI.SingleSliderNormal.EVENT_DRAG, v); - } - }, function () { - if (startDrag === true) { - size = optimizeSize(size); - var percent = size * 100 / (self._getGrayTrackLength()); - var significantPercent = BI.parseFloat(percent.toFixed(1)); - self._setSliderPosition(significantPercent); - size = 0; - offset = 0; - defaultSize = size; - startDrag = false; - } - widget.element.removeClass("dragging"); - mouseMoveTracker.releaseMouseMoves(); - self.fireEvent(BI.SingleSlider.EVENT_CHANGE); - }, window); - widget.element.on("mousedown", function (event) { - if(!widget.isEnabled()) { - return; - } - defaultSize = this.offsetLeft; - optimizeSize(defaultSize); - mouseMoveTracker.captureMouseMoves(event); - }); - - function optimizeSize (s) { - return BI.clamp(s, 0, self._getGrayTrackLength()); - } - }, - - _createTrack: function () { - var self = this; - var c = this._constant; - this.grayTrack = BI.createWidget({ - type: "bi.layout", - cls: "gray-track", - height: 6 - }); - this.blueTrack = BI.createWidget({ - type: "bi.layout", - cls: "blue-track bi-high-light-background", - height: 6 - }); - if (this.options.color) { - this.blueTrack.element.css({"background-color": this.options.color}); - } - - return { - type: "bi.absolute", - items: [{ - el: { - type: "bi.vertical", - items: [{ - type: "bi.absolute", - items: [{ - el: this.grayTrack, - top: 0, - left: 0, - width: "100%" - }, { - el: this.blueTrack, - top: 0, - left: 0, - width: "0%" - }] - }], - hgap: 8, - height: 8 - }, - top: 8, - left: 0, - width: "100%" - }], - ref: function (ref) { - self.track = ref; - } - }; - }, - - _checkValidation: function (v) { - return !(BI.isNull(v) || v < this.min || v > this.max); - }, - - _setBlueTrack: function (percent) { - this.blueTrack.element.css({width: percent + "%"}); - }, - - _setSliderPosition: function (percent) { - this.slider.element.css({left: percent + "%"}); - }, - - _setAllPosition: function (percent) { - this._setSliderPosition(percent); - this._setBlueTrack(percent); - }, - - _setVisible: function (visible) { - this.slider.setVisible(visible); - }, - - _getGrayTrackLength: function () { - return this.grayTrack.element[0].scrollWidth; - }, - - _getValueByPercent: function (percent) { - var thousandth = BI.parseInt(percent * 10); - return (((this.max - this.min) * thousandth) / 1000 + this.min); - }, - - _getPercentByValue: function (v) { - return (v - this.min) * 100 / (this.max - this.min); - }, - - _setEnable: function (b) { - BI.SingleSliderNormal.superclass._setEnable.apply(this, [b]); - if(b) { - this.blueTrack.element.removeClass("disabled-blue-track").addClass("blue-track"); - } else { - this.blueTrack.element.removeClass("blue-track").addClass("disabled-blue-track"); - } - }, - - getValue: function () { - return this.value; - }, - - setValue: function (v) { - var value = BI.parseFloat(v); - if ((!isNaN(value))) { - if (this._checkValidation(value)) { - this.value = value; - } - if (value > this.max) { - this.value = this.max; - } - if (value < this.min) { - this.value = this.min; - } - } - }, - - setMinAndMax: function (v) { - var minNumber = BI.parseFloat(v.min); - var maxNumber = BI.parseFloat(v.max); - if ((!isNaN(minNumber)) && (!isNaN(maxNumber)) && (maxNumber > minNumber )) { - this.min = minNumber; - this.max = maxNumber; - } - }, - - reset: function () { - this._setVisible(false); - this.enable = false; - this.value = ""; - this.min = 0; - this.max = 0; - this._setBlueTrack(0); - }, - - populate: function () { - if (!isNaN(this.min) && !isNaN(this.max)) { - this._setVisible(true); - this.enable = true; - if (BI.isNumeric(this.value) || BI.isNotEmptyString(this.value)) { - this._setAllPosition(this._getPercentByValue(this.value)); - } else { - this._setAllPosition(100); - } - } - } -}); -BI.SingleSliderNormal.EVENT_DRAG = "EVENT_DRAG"; -BI.shortcut("bi.single_slider_normal", BI.SingleSliderNormal);/** - * @class BI.SingleTreeCombo - * @extends BI.Widget - */ -BI.SingleTreeCombo = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SingleTreeCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-tree-combo", - trigger: {}, - height: 24, - text: "", - items: [], - value: "" - }); - }, - - _init: function () { - BI.SingleTreeCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.trigger = BI.createWidget(BI.extend({ - type: "bi.single_tree_trigger", - text: o.text, - height: o.height, - items: o.items, - value: o.value - }, o.trigger)); - - this.popup = BI.createWidget({ - type: "bi.single_level_tree", - items: o.items, - value: o.value - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - element: this, - adjustLength: 2, - el: this.trigger, - popup: { - el: this.popup - } - }); - - this.combo.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.fireEvent(BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW, arguments); - }); - - this.popup.on(BI.SingleTreePopup.EVENT_CHANGE, function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.SingleTreeCombo.EVENT_CHANGE); - }); - }, - - populate: function (items) { - this.combo.populate(items); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.trigger.setValue(v); - this.popup.setValue(v); - }, - - getValue: function () { - return this.popup.getValue(); - } -}); - -BI.SingleTreeCombo.EVENT_CHANGE = "SingleTreeCombo.EVENT_CHANGE"; -BI.SingleTreeCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.single_tree_combo", BI.SingleTreeCombo);/** - * @class BI.SingleTreePopup - * @extends BI.Pane - */ - -BI.SingleTreePopup = BI.inherit(BI.Pane, { - - _defaultConfig: function () { - return BI.extend(BI.SingleTreePopup.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-level-tree", - tipText: BI.i18nText("BI-No_Selected_Item"), - items: [], - value: "" - }); - }, - - _init: function () { - BI.SingleTreePopup.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.tree = BI.createWidget({ - type: "bi.level_tree", - expander: { - isDefaultInit: true - }, - items: o.items, - value: o.value, - chooseType: BI.Selection.Single - }); - - BI.createWidget({ - type: "bi.vertical", - element: this, - vgap: 5, - items: [this.tree] - }); - - this.tree.on(BI.Controller.EVENT_CHANGE, function () { - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - }); - - this.tree.on(BI.LevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.SingleTreePopup.EVENT_CHANGE); - }); - - this.check(); - }, - - getValue: function () { - return this.tree.getValue(); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.tree.setValue(v); - }, - - populate: function (items) { - BI.SingleTreePopup.superclass.populate.apply(this, arguments); - this.tree.populate(items); - } -}); - -BI.SingleTreePopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.single_level_tree", BI.SingleTreePopup);/** - * @class BI.SingleTreeTrigger - * @extends BI.Trigger - */ - -BI.SingleTreeTrigger = BI.inherit(BI.Trigger, { - - _defaultConfig: function () { - return BI.extend(BI.SingleTreeTrigger.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-single-tree-trigger", - height: 24, - text: "", - items: [], - value: "" - }); - }, - - _init: function () { - BI.SingleTreeTrigger.superclass._init.apply(this, arguments); - - var self = this, o = this.options; - - this.trigger = BI.createWidget({ - type: "bi.select_text_trigger", - element: this, - text: o.text, - items: o.items, - height: o.height, - value: o.value - }); - }, - - _checkTitle: function () { - var self = this, val = this.getValue(); - BI.any(this.options.items, function (i, item) { - if (val.contains(item.value)) { - self.trigger.setTitle(item.text || item.value); - return true; - } - }); - }, - - setValue: function (v) { - v = BI.isArray(v) ? v : [v]; - this.options.value = v; - this.trigger.setValue(v); - this._checkTitle(); - }, - - getValue: function () { - return this.options.value || []; - }, - - populate: function (items) { - BI.SingleTreeTrigger.superclass.populate.apply(this, arguments); - this.trigger.populate(items); - } - -}); - -BI.shortcut("bi.single_tree_trigger", BI.SingleTreeTrigger);/** - * 可以单选多选切换的树 - * - * Created by GUY on 2015/12/21. - * @class BI.SwitchTree - * @extends BI.Widget - */ -BI.SwitchTree = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.SwitchTree.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-switch-tree", - items: [] - }); - }, - - _init: function () { - BI.SwitchTree.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.tab = BI.createWidget({ - type: "bi.tab", - element: this, - tab: null, - showIndex: BI.SwitchTree.SelectType.SingleSelect, - cardCreator: BI.bind(this._createTree, this) - }); - }, - - _createTree: function (type) { - var self = this, o = this.options; - switch (type) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree = BI.createWidget({ - type: "bi.multilayer_single_level_tree", - isDefaultInit: true, - items: BI.deepClone(o.items), - value: o.value - }); - this.levelTree.on(BI.LevelTree.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.levelTree; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree = BI.createWidget({ - type: "bi.simple_tree", - items: this._removeIsParent(BI.deepClone(o.items)), - value: o.value - }); - this.tree.on(BI.SimpleTreeView.EVENT_CHANGE, function () { - self.fireEvent(BI.SwitchTree.EVENT_CHANGE, arguments); - }); - return this.tree; - } - }, - - _removeIsParent: function (items) { - BI.each(items, function (i, item) { - BI.isNotNull(item.isParent) && delete item.isParent; - }); - return items; - }, - - switchSelect: function () { - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.setSelect(BI.SwitchTree.SelectType.MultiSelect); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.setSelect(BI.SwitchTree.SelectType.SingleSelect); - break; - } - }, - - setSelect: function (v) { - this.tab.setSelect(v); - }, - - getSelect: function () { - return this.tab.getSelect(); - }, - - setValue: function (v) { - this.storeValue = v; - switch (this.getSelect()) { - case BI.SwitchTree.SelectType.SingleSelect: - this.levelTree.setValue(v); - break; - case BI.SwitchTree.SelectType.MultiSelect: - this.tree.setValue(v); - break; - } - }, - - getValue: function () { - return this.tab.getValue(); - }, - - populate: function (items) { - this.options.items = items; - if (BI.isNotNull(this.levelTree)) { - this.levelTree.populate(BI.deepClone(items)); - } - if (BI.isNotNull(this.tree)) { - this.tree.populate(this._removeIsParent(BI.deepClone(items))); - } - } -}); -BI.SwitchTree.EVENT_CHANGE = "SwitchTree.EVENT_CHANGE"; -BI.SwitchTree.SelectType = { - SingleSelect: BI.Selection.Single, - MultiSelect: BI.Selection.Multi -}; -BI.shortcut("bi.switch_tree", BI.SwitchTree); -/** - * Created by Baron on 2015/10/19. - */ -BI.DateInterval = BI.inherit(BI.Single, { - constants: { - height: 24, - width: 24, - lgap: 15, - offset: -15, - timeErrorCls: "time-error", - DATE_MIN_VALUE: "1900-01-01", - DATE_MAX_VALUE: "2099-12-31" - }, - _defaultConfig: function () { - var conf = BI.DateInterval.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-date-interval" - }); - }, - _init: function () { - var self = this, o = this.options; - BI.DateInterval.superclass._init.apply(this, arguments); - - o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); - this.label = BI.createWidget({ - type: "bi.label", - height: this.constants.height, - width: this.constants.width, - text: "-" - }); - BI.createWidget({ - element: self, - type: "bi.center", - hgap: 15, - height: this.constants.height, - items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: 0, - top: 0, - bottom: 0 - }] - }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: 0, - right: this.constants.offset, - top: 0, - bottom: 0 - }] - }] - }); - BI.createWidget({ - type: "bi.horizontal_auto", - element: this, - items: [ - self.label - ] - }); - }, - - _createCombo: function (v) { - var self = this, o = this.options; - var combo = BI.createWidget({ - type: "bi.dynamic_date_combo", - behaviors: o.behaviors, - value: v - }); - combo.on(BI.DynamicDateCombo.EVENT_ERROR, function () { - self._clearTitle(); - BI.Bubbles.hide("error"); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.DateInterval.EVENT_ERROR); - }); - - combo.on(BI.DynamicDateCombo.EVENT_VALID, function () { - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - offsetStyle: "center" - }); - self.fireEvent(BI.DateInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.DynamicDateCombo.EVENT_FOCUS, function () { - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - offsetStyle: "center" - }); - self.fireEvent(BI.DateInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.DynamicDateCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.left.hidePopupView(); - self.right.hidePopupView(); - }); - - combo.on(BI.DynamicDateCombo.EVENT_CONFIRM, function () { - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - self.fireEvent(BI.DateInterval.EVENT_ERROR); - }else{ - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.DateInterval.EVENT_CHANGE); - } - }); - return combo; - }, - _dateCheck: function (date) { - return BI.parseDateTime(date, "%Y-%x-%d").print("%Y-%x-%d") === date || - BI.parseDateTime(date, "%Y-%X-%d").print("%Y-%X-%d") === date || - BI.parseDateTime(date, "%Y-%x-%e").print("%Y-%x-%e") === date || - BI.parseDateTime(date, "%Y-%X-%e").print("%Y-%X-%e") === date; - }, - _checkVoid: function (obj) { - return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0]; - }, - _check: function (smallDate, bigDate) { - var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g); - return this._dateCheck(smallDate) && BI.checkDateLegal(smallDate) && this._checkVoid({ - year: smallObj[0], - month: smallObj[1], - day: smallObj[2] - }) && this._dateCheck(bigDate) && BI.checkDateLegal(bigDate) && this._checkVoid({ - year: bigObj[0], - month: bigObj[1], - day: bigObj[2] - }); - }, - _compare: function (smallDate, bigDate) { - smallDate = BI.parseDateTime(smallDate, "%Y-%X-%d").print("%Y-%X-%d"); - bigDate = BI.parseDateTime(bigDate, "%Y-%X-%d").print("%Y-%X-%d"); - return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; - }, - _setTitle: function (v) { - this.left.setTitle(v); - this.right.setTitle(v); - this.label.setTitle(v); - }, - _clearTitle: function () { - this.left.setTitle(""); - this.right.setTitle(""); - this.label.setTitle(""); - }, - setValue: function (date) { - date = date || {}; - this.left.setValue(date.start); - this.right.setValue(date.end); - }, - getValue: function () { - return {start: this.left.getValue(), end: this.right.getValue()}; - } -}); -BI.DateInterval.EVENT_VALID = "EVENT_VALID"; -BI.DateInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.DateInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.date_interval", BI.DateInterval);/** - * Created by Baron on 2015/10/19. - */ -BI.TimeInterval = BI.inherit(BI.Single, { - constants: { - height: 24, - width: 24, - lgap: 15, - offset: -15, - timeErrorCls: "time-error", - DATE_MIN_VALUE: "1900-01-01", - DATE_MAX_VALUE: "2099-12-31" - }, - _defaultConfig: function () { - var conf = BI.TimeInterval.superclass._defaultConfig.apply(this, arguments); - return BI.extend(conf, { - extraCls: "bi-time-interval" - }); - }, - _init: function () { - var self = this, o = this.options; - BI.TimeInterval.superclass._init.apply(this, arguments); - - o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); - this.label = BI.createWidget({ - type: "bi.label", - height: this.constants.height, - width: this.constants.width, - text: "-" - }); - BI.createWidget({ - element: self, - type: "bi.center", - hgap: 15, - height: this.constants.height, - items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: 0, - top: 0, - bottom: 0 - }] - }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: 0, - right: this.constants.offset, - top: 0, - bottom: 0 - }] - }] - }); - BI.createWidget({ - type: "bi.horizontal_auto", - element: this, - items: [ - self.label - ] - }); - }, - - _createCombo: function (v) { - var self = this, o = this.options; - var combo = BI.createWidget({ - type: "bi.dynamic_date_time_combo", - behaviors: o.behaviors, - value: v - }); - combo.on(BI.DynamicDateTimeCombo.EVENT_ERROR, function () { - self._clearTitle(); - BI.Bubbles.hide("error"); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.TimeInterval.EVENT_ERROR); - }); - - combo.on(BI.DynamicDateTimeCombo.EVENT_VALID, function () { - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - offsetStyle: "center" - }); - self.fireEvent(BI.TimeInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.DynamicDateTimeCombo.EVENT_FOCUS, function () { - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - offsetStyle: "center" - }); - self.fireEvent(BI.TimeInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }); - - combo.on(BI.DynamicDateTimeCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.left.hidePopupView(); - self.right.hidePopupView(); - }); - - combo.on(BI.DynamicDateTimeCombo.EVENT_CONFIRM, function () { - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - self.fireEvent(BI.TimeInterval.EVENT_ERROR); - }else{ - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.TimeInterval.EVENT_CHANGE); - } - }); - return combo; - }, - _dateCheck: function (date) { - return BI.parseDateTime(date, "%Y-%x-%d %H:%M:%S").print("%Y-%x-%d %H:%M:%S") === date || - BI.parseDateTime(date, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S") === date || - BI.parseDateTime(date, "%Y-%x-%e %H:%M:%S").print("%Y-%x-%e %H:%M:%S") === date || - BI.parseDateTime(date, "%Y-%X-%e %H:%M:%S").print("%Y-%X-%e %H:%M:%S") === date; - }, - _checkVoid: function (obj) { - return !BI.checkDateVoid(obj.year, obj.month, obj.day, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0]; - }, - _check: function (smallDate, bigDate) { - var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g); - return this._dateCheck(smallDate) && BI.checkDateLegal(smallDate) && this._checkVoid({ - year: smallObj[0], - month: smallObj[1], - day: smallObj[2] - }) && this._dateCheck(bigDate) && BI.checkDateLegal(bigDate) && this._checkVoid({ - year: bigObj[0], - month: bigObj[1], - day: bigObj[2] - }); - }, - _compare: function (smallDate, bigDate) { - smallDate = BI.parseDateTime(smallDate, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S"); - bigDate = BI.parseDateTime(bigDate, "%Y-%X-%d %H:%M:%S").print("%Y-%X-%d %H:%M:%S"); - return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; - }, - _setTitle: function (v) { - this.left.setTitle(v); - this.right.setTitle(v); - this.label.setTitle(v); - }, - _clearTitle: function () { - this.left.setTitle(""); - this.right.setTitle(""); - this.label.setTitle(""); - }, - setValue: function (date) { - date = date || {}; - this.left.setValue(date.start); - this.right.setValue(date.end); - }, - getValue: function () { - return {start: this.left.getValue(), end: this.right.getValue()}; - } -}); -BI.TimeInterval.EVENT_VALID = "EVENT_VALID"; -BI.TimeInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.TimeInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.time_interval", BI.TimeInterval);/** - * 年份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.YearCard - * @extends BI.Trigger - */ -BI.DynamicYearCard = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-year-card" - }, - - render: function () { - var self = this; - return { - type: "bi.vertical", - items: [{ - type: "bi.label", - text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), - textAlign: "left", - height: 24 - }, { - type: "bi.dynamic_date_param_item", - ref: function () { - self.item = this; - }, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }] - }], - vgap: 10, - hgap: 10 - }; - }, - - _createValue: function (type, v) { - return { - dateType: type, - value: Math.abs(v), - offset: v > 0 ? 1 : 0 - }; - }, - - setValue: function (v) { - v = v || {year: 0}; - this.item.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); - }, - - getValue: function () { - var value = this.item.getValue(); - return { - year: (value.offset === 0 ? -value.value : value.value) - }; - } -}); -BI.DynamicYearCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.dynamic_year_card", BI.DynamicYearCard);/** - * 年份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.StaticYearCard - * @extends BI.Trigger - */ -BI.StaticYearCard = BI.inherit(BI.Widget, { - - _defaultConfig: function () { - return BI.extend(BI.StaticYearCard.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-year-card", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31" // 最大日期 - }); - }, - - _createYearCalendar: function (v) { - var o = this.options, y = this._year; - - var calendar = BI.createWidget({ - type: "bi.year_calendar", - behaviors: o.behaviors, - min: o.min, - max: o.max, - logic: { - dynamic: true - }, - year: y + v * 12 - }); - calendar.setValue(this._year); - return calendar; - }, - - _init: function () { - BI.StaticYearCard.superclass._init.apply(this, arguments); - var self = this, o = this.options; - - this.selectedYear = this._year = BI.getDate().getFullYear(); - - this.backBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "pre-page-h-font", - width: 25, - height: 25, - value: -1, - listeners: [{ - eventName: BI.IconButton.EVENT_CHANGE, - action: function () { - self.navigation.setSelect(self.navigation.getSelect() - 1); - self._checkLeftValid(); - self._checkRightValid(); - } - }] - }); - - this.preBtn = BI.createWidget({ - type: "bi.icon_button", - cls: "next-page-h-font", - width: 25, - height: 25, - value: 1, - listeners: [{ - eventName: BI.IconButton.EVENT_CHANGE, - action: function () { - self.navigation.setSelect(self.navigation.getSelect() + 1); - self._checkLeftValid(); - self._checkRightValid(); - } - }] - }); - - this.navigation = BI.createWidget({ - type: "bi.navigation", - direction: "top", - element: this, - single: true, - logic: { - dynamic: true - }, - tab: { - type: "bi.htape", - cls: "bi-border-top bi-border-bottom", - height: 30, - items: [{ - el: { - type: "bi.center_adapt", - items: [self.backBtn] - }, - width: 25 - }, { - type: "bi.layout" - }, { - el: { - type: "bi.center_adapt", - items: [self.preBtn] - }, - width: 25 - }] - }, - cardCreator: BI.bind(this._createYearCalendar, this), - - afterCardShow: function () { - this.setValue(self.selectedYear); - var calendar = this.getSelectedCard(); - self.backBtn.setEnable(!calendar.isFrontYear()); - self.preBtn.setEnable(!calendar.isFinalYear()); - } - }); - - this.navigation.on(BI.Navigation.EVENT_CHANGE, function () { - self.selectedYear = this.getValue(); - self.fireEvent(BI.Controller.EVENT_CHANGE, arguments); - self.fireEvent(BI.StaticYearCard.EVENT_CHANGE, self.selectedYear); - }); - - if(BI.isKey(o.value)){ - this.setValue(o.value); - } - }, - - _checkLeftValid: function () { - var o = this.options; - var valid = true; - this.backBtn.setEnable(valid); - return valid; - }, - - _checkRightValid: function () { - var o = this.options; - var valid = true; - this.preBtn.setEnable(valid); - return valid; - }, - - getValue: function () { - return { - year: this.selectedYear - }; - }, - - setValue: function (obj) { - var o = this.options; - obj = obj || {}; - var v = obj.year; - if (BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]) { - v = BI.getDate().getFullYear(); - this.selectedYear = ""; - this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); - this.navigation.setValue(""); - } else { - this.selectedYear = BI.parseInt(v); - this.navigation.setSelect(BI.YearCalendar.getPageByYear(v)); - this.navigation.setValue(this.selectedYear); - } - this._checkLeftValid(); - this._checkRightValid(); - } -}); -BI.StaticYearCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.static_year_card", BI.StaticYearCard);BI.DynamicYearCombo = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-year-combo bi-border", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }, - - _init: function () { - BI.DynamicYearCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = o.value; - this.trigger = BI.createWidget({ - type: "bi.dynamic_year_trigger", - min: o.min, - max: o.max, - value: o.value || "" - }); - this.trigger.on(BI.DynamicYearTrigger.EVENT_FOCUS, function () { - self.storeTriggerValue = this.getKey(); - }); - this.trigger.on(BI.DynamicYearTrigger.EVENT_START, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.DynamicYearTrigger.EVENT_STOP, function () { - self.combo.showView(); - }); - this.trigger.on(BI.DynamicYearTrigger.EVENT_ERROR, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.DynamicYearTrigger.EVENT_CONFIRM, function () { - if (self.combo.isViewVisible()) { - return; - } - if (this.getKey() && this.getKey() !== self.storeTriggerValue) { - self.storeValue = self.trigger.getValue(); - self.setValue(self.storeValue); - } else if (!this.getKey()) { - self.storeValue = null; - self.setValue(); - } - self._checkDynamicValue(self.storeValue); - self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - stopPropagation: false, - el: { - type: "bi.dynamic_year_popup", - ref: function () { - self.popup = this; - }, - listeners: [{ - eventName: BI.DynamicYearPopup.EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE, - action: function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.DynamicYearCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE, - action: function () { - var date = BI.getDate(); - self.setValue({type: BI.DynamicYearCombo.Static, value: {year: date.getFullYear()}}); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }], - behaviors: o.behaviors, - min: o.min, - max: o.max - }, - value: o.value || "" - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - ref: function () { - self.comboWrapper = this; - }, - items: [{ - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: 24, - ref: function () { - self.changeIcon = this; - } - }, - width: 24 - }, this.combo] - }); - this._checkDynamicValue(o.value); - }, - - _checkDynamicValue: function (v) { - var type = null; - if (BI.isNotNull(v)) { - type = v.type; - } - switch (type) { - case BI.DynamicYearCombo.Dynamic: - this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; - this.comboWrapper.resize(); - break; - default: - this.comboWrapper.attr("items")[0].width = 0; - this.comboWrapper.resize(); - this.changeIcon.setVisible(false); - break; - } - }, - - setValue: function (v) { - this.storeValue = v; - this.trigger.setValue(v); - this._checkDynamicValue(v); - }, - - getValue: function () { - return this.storeValue; - } - -}); -BI.DynamicYearCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicYearCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.dynamic_year_combo", BI.DynamicYearCombo); - -BI.extend(BI.DynamicYearCombo, { - Static: 1, - Dynamic: 2 -});/** - * 年份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.DynamicYearPopup - * @extends BI.Trigger - */ -BI.DynamicYearPopup = BI.inherit(BI.Widget, { - constants: { - tabHeight: 30, - buttonHeight: 24 - }, - - props: { - baseCls: "bi-year-popup", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期, - width: 180, - height: 240 - }, - - render: function () { - var self = this, opts = this.options, c = this.constants; - this.storeValue = {type: BI.DynamicYearCombo.Static}; - return { - type: "bi.vtape", - items: [{ - el: this._getTabJson() - }, { - el: { - type: "bi.grid", - items: [[{ - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-top bi-high-light", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_Clear"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - textHeight: c.buttonHeight - 1, - cls: "bi-border-left bi-border-right bi-high-light bi-border-top", - shadow: true, - text: BI.i18nText("BI-Basic_Current_Year"), - ref: function () { - self.textButton = this; - }, - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-top bi-high-light", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_OK"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE); - } - }] - }]] - }, - height: 24 - }] - }; - }, - - _setInnerValue: function () { - if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); - this.textButton.setEnable(true); - } else { - var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); - date = date.print("%Y"); - this.textButton.setValue(date); - this.textButton.setEnable(false); - } - }, - - _getTabJson: function () { - var self = this, o = this.options; - return { - type: "bi.tab", - ref: function () { - self.dateTab = this; - }, - tab: { - type: "bi.linear_segment", - cls: "bi-border-bottom", - height: this.constants.tabHeight, - items: BI.createItems([{ - text: BI.i18nText("BI-Basic_Year_Fen"), - value: BI.DynamicYearCombo.Static - }, { - text: BI.i18nText("BI-Basic_Dynamic_Title"), - value: BI.DynamicYearCombo.Dynamic - }], { - textAlign: "center" - }) - }, - cardCreator: function (v) { - switch (v) { - case BI.DynamicYearCombo.Dynamic: - return { - type: "bi.dynamic_year_card", - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self._setInnerValue(self.year, v); - } - }], - ref: function () { - self.dynamicPane = this; - } - }; - case BI.DynamicYearCombo.Static: - default: - return { - type: "bi.static_year_card", - behaviors: o.behaviors, - min: self.options.min, - max: self.options.max, - listeners: [{ - eventName: BI.StaticYearCard.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearPopup.EVENT_CHANGE); - } - }], - ref: function () { - self.year = this; - } - }; - } - }, - listeners: [{ - eventName: BI.Tab.EVENT_CHANGE, - action: function () { - var v = self.dateTab.getSelect(); - switch (v) { - case BI.DynamicYearCombo.Static: - var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); - self.year.setValue({year: date.getFullYear()}); - self._setInnerValue(); - break; - case BI.DynamicYearCombo.Dynamic: - default: - if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) { - self.dynamicPane.setValue(self.storeValue.value); - }else{ - self.dynamicPane.setValue({ - year: 0 - }); - } - self._setInnerValue(); - break; - } - } - }] - }; - }, - - setValue: function (v) { - this.storeValue = v; - var self = this; - var type, value; - v = v || {}; - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - this.dateTab.setSelect(type); - switch (type) { - case BI.DynamicDateCombo.Dynamic: - this.dynamicPane.setValue(value); - self._setInnerValue(); - break; - case BI.DynamicDateCombo.Static: - default: - this.year.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Year")); - this.textButton.setEnable(true); - break; - } - }, - - getValue: function () { - return { - type: this.dateTab.getSelect(), - value: this.dateTab.getValue() - }; - } - -}); -BI.DynamicYearPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; -BI.DynamicYearPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; -BI.DynamicYearPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.DynamicYearPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.dynamic_year_popup", BI.DynamicYearPopup);BI.DynamicYearTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2 - }, - - _defaultConfig: function () { - return BI.extend(BI.DynamicYearTrigger.superclass._defaultConfig.apply(this, arguments), { - extraCls: "bi-year-trigger", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }); - }, - - beforeInit: function (callback) { - var o = this.options; - o.title = BI.bind(this._titleCreator, this); - callback(); - }, - - _init: function () { - BI.DynamicYearTrigger.superclass._init.apply(this, arguments); - var self = this, o = this.options, c = this._const; - this.editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - validationChecker: function (v) { - return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]); - }, - quitChecker: function (v) { - return false; - }, - hgap: c.hgap, - vgap: c.vgap, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - allowBlank: true, - errorText: function () { - return BI.i18nText("BI-Year_Trigger_Invalid_Text"); - } - }); - this.editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.DynamicYearTrigger.EVENT_FOCUS); - }); - this.editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.DynamicYearTrigger.EVENT_STOP); - }); - this.editor.on(BI.SignEditor.EVENT_CONFIRM, function () { - var value = self.editor.getValue(); - if (BI.isNotNull(value)) { - self.editor.setValue(value); - } - if (BI.isNotEmptyString(value)) { - self.storeValue = { - type: BI.DynamicDateCombo.Static, - value: { - year: value - } - }; - } - - self.fireEvent(BI.DynamicYearTrigger.EVENT_CONFIRM); - }); - this.editor.on(BI.SignEditor.EVENT_SPACE, function () { - if (self.editor.isValid()) { - self.editor.blur(); - } - }); - this.editor.on(BI.SignEditor.EVENT_START, function () { - self.fireEvent(BI.DynamicYearTrigger.EVENT_START); - }); - this.editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.DynamicYearTrigger.EVENT_ERROR); - }); - BI.createWidget({ - element: this, - type: "bi.htape", - items: [{ - el: this.editor - }, { - el: { - type: "bi.text_button", - baseCls: "bi-trigger-year-text", - text: BI.i18nText("BI-Multi_Date_Year"), - width: o.height - }, - width: o.height - }, { - el: { - type: "bi.trigger_icon_button", - width: o.height - }, - width: o.height - }] - }); - this.setValue(o.value); - }, - - _getText: function (obj) { - var value = ""; - if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) { - value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - return value; - }, - - _setInnerValue: function (date, text) { - var dateStr = date.print("%Y"); - this.editor.setState(dateStr); - this.editor.setValue(dateStr); - }, - - _titleCreator: function () { - var storeValue = this.storeValue || {}; - var type = storeValue.type || BI.DynamicDateCombo.Static; - var value = storeValue.value; - if(!this.editor.isValid()) { - return ""; - } - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = this._getText(value); - var date = BI.getDate(); - date = BI.DynamicDateHelper.getCalculation(value); - var dateStr = date.print("%Y"); - return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); - case BI.DynamicDateCombo.Static: - default: - value = value || {}; - return value.year; - } - }, - - setValue: function (v) { - var type, value; - var date = BI.getDate(); - this.storeValue = v; - if (BI.isNotNull(v)) { - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - } - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = this._getText(value); - date = BI.DynamicDateHelper.getCalculation(value); - this._setInnerValue(date, text); - break; - case BI.DynamicDateCombo.Static: - default: - value = value || {}; - this.editor.setState(value.year); - this.editor.setValue(value.year); - break; - } - }, - - getValue: function () { - return this.storeValue; - }, - - getKey: function () { - return this.editor.getValue() | 0; - } -}); -BI.DynamicYearTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicYearTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicYearTrigger.EVENT_START = "EVENT_START"; -BI.DynamicYearTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicYearTrigger.EVENT_STOP = "EVENT_STOP"; -BI.shortcut("bi.dynamic_year_trigger", BI.DynamicYearTrigger);/** - * 年份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.YearCard - * @extends BI.Trigger - */ -BI.DynamicYearMonthCard = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-year-month-card" - }, - - render: function () { - var self = this; - return { - type: "bi.vertical", - items: [{ - type: "bi.label", - text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), - textAlign: "left", - height: 24 - }, { - type: "bi.dynamic_date_param_item", - ref: function () { - self.year = this; - }, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }] - }, { - type: "bi.dynamic_date_param_item", - dateType: BI.DynamicDateCard.TYPE.MONTH, - ref: function () { - self.month = this; - }, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }] - }], - vgap: 10, - hgap: 10 - }; - }, - - _createValue: function (type, v) { - return { - dateType: type, - value: Math.abs(v), - offset: v > 0 ? 1 : 0 - }; - }, - - setValue: function (v) { - v = v || {year: 0, month: 0}; - this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); - this.month.setValue(this._createValue(BI.DynamicDateCard.TYPE.MONTH, v.month)); - }, - - getValue: function () { - var year = this.year.getValue(); - var month = this.month.getValue(); - return { - year: (year.offset === 0 ? -year.value : year.value), - month: (month.offset === 0 ? -month.value : month.value) - }; - } -}); -BI.DynamicYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.dynamic_year_month_card", BI.DynamicYearMonthCard);BI.StaticYearMonthCard = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-static-year-month-card", - behaviors: {} - }, - - _createMonths: function () { - // 纵向排列月 - var month = [1, 7, 2, 8, 3, 9, 4, 10, 5, 11, 6, 12]; - var items = []; - items.push(month.slice(0, 2)); - items.push(month.slice(2, 4)); - items.push(month.slice(4, 6)); - items.push(month.slice(6, 8)); - items.push(month.slice(8, 10)); - items.push(month.slice(10, 12)); - return BI.map(items, function (i, item) { - return BI.map(item, function (j, td) { - return { - type: "bi.text_item", - cls: "bi-list-item-active", - textAlign: "center", - whiteSpace: "nowrap", - once: false, - forceSelected: true, - height: 23, - width: 38, - value: td, - text: td - }; - }); - }); - }, - - render: function () { - var self = this, o = this.options; - return { - type: "bi.vertical", - items: [{ - type: "bi.year_picker", - ref: function () { - self.yearPicker = this; - }, - behaviors: o.behaviors, - height: 30, - listeners: [{ - eventName: BI.YearPicker.EVENT_CHANGE, - action: function () { - var value = this.getValue(); - self.setValue({ - year: value, - month: self.selectedMonth - }); - } - }] - }, { - type: "bi.button_group", - cls: "bi-border-top", - behaviors: o.behaviors, - ref: function () { - self.month = this; - }, - items: this._createMonths(), - layouts: [BI.LogicFactory.createLogic("table", BI.extend({ - dynamic: true - }, { - columns: 2, - rows: 6, - columnSize: [1 / 2, 1 / 2], - rowSize: 25 - })), { - type: "bi.center_adapt", - vgap: 1, - hgap: 2 - }], - value: o.value, - listeners: [{ - eventName: BI.ButtonGroup.EVENT_CHANGE, - action: function () { - self.selectedYear = self.yearPicker.getValue(); - self.selectedMonth = this.getValue()[0]; - self.fireEvent(BI.StaticYearMonthCard.EVENT_CHANGE); - } - }] - }] - }; - }, - - - getValue: function () { - return { - year: this.selectedYear, - month: this.selectedMonth - }; - }, - - setValue: function (obj) { - var o = this.options; - var newObj = {}; - newObj.year = obj.year || 0; - newObj.month = obj.month || 0; - if (newObj.year === 0 || newObj.month === 0 || BI.checkDateVoid(newObj.year, newObj.month, 1, o.min, o.max)[0]) { - var year = newObj.year || BI.getDate().getFullYear(); - this.selectedYear = year; - this.selectedMonth = ""; - this.yearPicker.setValue(year); - this.month.setValue(); - } else { - this.selectedYear = BI.parseInt(newObj.year); - this.selectedMonth = BI.parseInt(newObj.month); - this.yearPicker.setValue(this.selectedYear); - this.month.setValue(this.selectedMonth); - } - } -}); -BI.StaticYearMonthCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.static_year_month_card", BI.StaticYearMonthCard); -BI.DynamicYearMonthCombo = BI.inherit(BI.Single, { - - props: { - baseCls: "bi-year-month-combo bi-border", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }, - - _init: function () { - BI.DynamicYearMonthCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = o.value; - this.storeTriggerValue = ""; - this.trigger = BI.createWidget({ - type: "bi.dynamic_year_month_trigger", - min: o.min, - max: o.max, - value: o.value || "" - }); - this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_START, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_STOP, function () { - self.combo.showView(); - }); - this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_ERROR, function () { - self.combo.isViewVisible() && self.combo.hideView(); - self.fireEvent(BI.DynamicYearMonthCombo.EVENT_ERROR); - }); - this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_VALID, function () { - self.fireEvent(BI.DynamicYearMonthCombo.EVENT_VALID); - }); - this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_CONFIRM, function () { - // 没看出来干啥的,先去掉 - // if (self.combo.isViewVisible()) { - // return; - // } - var dateStore = self.storeTriggerValue; - var dateObj = self.trigger.getKey(); - if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { - self.storeValue = self.trigger.getValue(); - self.setValue(self.trigger.getValue()); - } - self._checkDynamicValue(self.storeValue); - self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM); - }); - this.trigger.on(BI.DynamicYearMonthTrigger.EVENT_FOCUS, function () { - self.storeTriggerValue = self.trigger.getKey(); - self.fireEvent(BI.DynamicYearMonthCombo.EVENT_FOCUS); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 100, - stopPropagation: false, - el: { - type: "bi.dynamic_year_month_popup", - ref: function () { - self.popup = this; - }, - listeners: [{ - eventName: BI.DynamicYearMonthPopup.EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE, - action: function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.DynamicYearMonthCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE, - action: function () { - var date = BI.getDate(); - self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), month: date.getMonth() + 1}}); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }], - behaviors: o.behaviors, - min: o.min, - max: o.max - }, - value: o.value || "" - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - ref: function () { - self.comboWrapper = this; - }, - items: [{ - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: 24, - ref: function () { - self.changeIcon = this; - } - }, - width: 24 - }, this.combo] - }); - this._checkDynamicValue(o.value); - }, - - _checkDynamicValue: function (v) { - var type = null; - if (BI.isNotNull(v)) { - type = v.type; - } - switch (type) { - case BI.DynamicYearMonthCombo.Dynamic: - this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; - this.comboWrapper.resize(); - break; - default: - this.comboWrapper.attr("items")[0].width = 0; - this.comboWrapper.resize(); - this.changeIcon.setVisible(false); - break; - } - }, - - hideView: function () { - this.combo.hideView(); - }, - - setValue: function (v) { - this.storeValue = v; - this.trigger.setValue(v); - this._checkDynamicValue(v); - }, - - getValue: function () { - return this.storeValue; - }, - - getKey: function () { - return this.trigger.getKey(); - }, - - isValid: function () { - return this.trigger.isValid(); - } - -}); -BI.DynamicYearMonthCombo.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicYearMonthCombo.EVENT_VALID = "EVENT_VALID"; -BI.DynamicYearMonthCombo.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicYearMonthCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.dynamic_year_month_combo", BI.DynamicYearMonthCombo); - -BI.extend(BI.DynamicYearMonthCombo, { - Static: 1, - Dynamic: 2 -});/** - * 年月 - * - * Created by GUY on 2015/9/2. - * @class BI.DynamicYearMonthPopup - * @extends BI.Trigger - */ -BI.DynamicYearMonthPopup = BI.inherit(BI.Widget, { - constants: { - tabHeight: 30, - buttonHeight: 24 - }, - - props: { - baseCls: "bi-year-month-popup", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期, - width: 180, - height: 240 - }, - - render: function () { - var self = this, opts = this.options, c = this.constants; - this.storeValue = {type: BI.DynamicYearMonthCombo.Static}; - return { - type: "bi.vtape", - items: [{ - el: this._getTabJson() - }, { - el: { - type: "bi.grid", - items: [[{ - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-top bi-high-light", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_Clear"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-left bi-border-right bi-high-light bi-border-top", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_Current_Month"), - ref: function () { - self.textButton = this; - }, - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-top bi-high-light", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_OK"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE); - } - }] - }]] - }, - height: 24 - }] - }; - }, - - _setInnerValue: function () { - if (this.dateTab.getSelect() === BI.DynamicDateCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); - this.textButton.setEnable(true); - } else { - var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); - date = date.print("%Y-%x"); - this.textButton.setValue(date); - this.textButton.setEnable(false); - } - }, - - _getTabJson: function () { - var self = this, o = this.options; - return { - type: "bi.tab", - ref: function () { - self.dateTab = this; - }, - tab: { - type: "bi.linear_segment", - cls: "bi-border-bottom", - height: this.constants.tabHeight, - items: BI.createItems([{ - text: BI.i18nText("BI-Basic_Year_Month"), - value: BI.DynamicYearCombo.Static - }, { - text: BI.i18nText("BI-Basic_Dynamic_Title"), - value: BI.DynamicYearCombo.Dynamic - }], { - textAlign: "center" - }) - }, - cardCreator: function (v) { - switch (v) { - case BI.DynamicYearCombo.Dynamic: - return { - type: "bi.dynamic_year_month_card", - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self._setInnerValue(self.year, v); - } - }], - ref: function () { - self.dynamicPane = this; - } - }; - case BI.DynamicYearCombo.Static: - default: - return { - type: "bi.static_year_month_card", - behaviors: o.behaviors, - min: self.options.min, - max: self.options.max, - listeners: [{ - eventName: BI.StaticYearMonthCard.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearMonthPopup.EVENT_CHANGE); - } - }], - ref: function () { - self.year = this; - } - }; - } - }, - listeners: [{ - eventName: BI.Tab.EVENT_CHANGE, - action: function () { - var v = self.dateTab.getSelect(); - switch (v) { - case BI.DynamicYearCombo.Static: - var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); - self.year.setValue({year: date.getFullYear(), month: date.getMonth() + 1}); - self._setInnerValue(); - break; - case BI.DynamicYearCombo.Dynamic: - default: - if(self.storeValue && self.storeValue.type === BI.DynamicYearCombo.Dynamic) { - self.dynamicPane.setValue(self.storeValue.value); - }else{ - self.dynamicPane.setValue({ - year: 0 - }); - } - self._setInnerValue(); - break; - } - } - }] - }; - }, - - setValue: function (v) { - this.storeValue = v; - var self = this; - var type, value; - v = v || {}; - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - this.dateTab.setSelect(type); - switch (type) { - case BI.DynamicDateCombo.Dynamic: - this.dynamicPane.setValue(value); - self._setInnerValue(); - break; - case BI.DynamicDateCombo.Static: - default: - this.year.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Month")); - this.textButton.setEnable(true); - break; - } - }, - - getValue: function () { - return { - type: this.dateTab.getSelect(), - value: this.dateTab.getValue() - }; - } - -}); -BI.DynamicYearMonthPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; -BI.DynamicYearMonthPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; -BI.DynamicYearMonthPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.DynamicYearMonthPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.dynamic_year_month_popup", BI.DynamicYearMonthPopup);BI.DynamicYearMonthTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2 - }, - - props: { - extraCls: "bi-year-month-trigger", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }, - - beforeInit: function (callback) { - var o = this.options; - o.title = BI.bind(this._titleCreator, this); - callback(); - }, - - _init: function () { - BI.DynamicYearMonthTrigger.superclass._init.apply(this, arguments); - var o = this.options; - - this.yearEditor = this._createEditor(true); - this.monthEditor = this._createEditor(false); - - BI.createWidget({ - element: this, - type: "bi.htape", - items: [{ - type: "bi.center", - items: [{ - type: "bi.htape", - items: [this.yearEditor, { - el: { - type: "bi.text_button", - text: BI.i18nText("BI-Multi_Date_Year"), - width: o.height - }, - width: o.height - }] - }, { - type: "bi.htape", - items: [this.monthEditor, { - el: { - type: "bi.text_button", - text: BI.i18nText("BI-Multi_Date_Month"), - width: o.height - }, - width: o.height}] - }] - }, { - el: { - type: "bi.trigger_icon_button", - width: o.height - }, - width: o.height - }] - }); - this.setValue(o.value); - }, - - _createEditor: function (isYear) { - var self = this, o = this.options, c = this._const; - var editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - validationChecker: function (v) { - if(isYear) { - return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]); - } - return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 12) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]); - }, - quitChecker: function () { - return false; - }, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - errorText: function (v) { - return BI.i18nText("BI-Year_Trigger_Invalid_Text"); - }, - hgap: c.hgap, - vgap: c.vgap, - allowBlank: true - }); - editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { - self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN); - }); - editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_FOCUS); - }); - editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_STOP); - }); - editor.on(BI.SignEditor.EVENT_CONFIRM, function () { - self._doEditorConfirm(editor); - self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM); - }); - editor.on(BI.SignEditor.EVENT_SPACE, function () { - if (editor.isValid()) { - editor.blur(); - } - }); - editor.on(BI.SignEditor.EVENT_START, function () { - self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_START); - }); - editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_ERROR); - }); - editor.on(BI.SignEditor.EVENT_VALID, function () { - var year = self.yearEditor.getValue(); - var month = self.monthEditor.getValue(); - if(BI.isNotEmptyString(year) && BI.isNotEmptyString(month)) { - if(BI.isPositiveInteger(year) && month >= 1 && month <= 12 && !BI.checkDateVoid(year, month, 1, o.min, o.max)[0]) { - self.fireEvent(BI.DynamicYearMonthTrigger.EVENT_VALID); - } - } - }); - editor.on(BI.SignEditor.EVENT_CHANGE, function () { - if(isYear) { - self._autoSwitch(editor); - } - }); - - return editor; - }, - - _titleCreator: function () { - var storeValue = this.storeValue || {}; - var type = storeValue.type || BI.DynamicDateCombo.Static; - var value = storeValue.value; - if(!this.monthEditor.isValid() || !this.yearEditor.isValid()) { - return ""; - } - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = this._getText(value); - var date = BI.getDate(); - date = BI.DynamicDateHelper.getCalculation(value); - var dateStr = date.print("%Y-%x"); - return BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr); - case BI.DynamicDateCombo.Static: - default: - value = value || {}; - return this._getStaticTitle(value); - } - }, - - _doEditorConfirm: function (editor) { - var value = editor.getValue(); - if (BI.isNotNull(value)) { - editor.setValue(value); - } - var monthValue = this.monthEditor.getValue(); - this.storeValue = { - type: BI.DynamicDateCombo.Static, - value: { - year: this.yearEditor.getValue(), - month: BI.isEmptyString(this.monthEditor.getValue()) ? "" : monthValue - } - }; - }, - - _yearCheck: function (v) { - var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); - return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; - }, - - _autoSwitch: function (editor) { - var v = editor.getValue(); - if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) { - if (v.length === 4 && this._yearCheck(v)) { - this._doEditorConfirm(editor); - this.fireEvent(BI.DynamicYearMonthTrigger.EVENT_CONFIRM); - this.monthEditor.focus(); - } - } - }, - - _getText: function (obj) { - var value = ""; - if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) { - value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - if(BI.isNotNull(obj.month) && BI.parseInt(obj.month) !== 0) { - value += Math.abs(obj.month) + BI.i18nText("BI-Basic_Month") + (obj.month < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - return value; - }, - - _setInnerValue: function (date, text) { - this.yearEditor.setValue(date.getFullYear()); - this.monthEditor.setValue(date.getMonth() + 1); - }, - - _getStaticTitle: function (value) { - value = value || {}; - var yearStr = (BI.isNull(value.year) || BI.isEmptyString(value.year)) ? "" : value.year; - var monthStr = (BI.isNull(value.month) || BI.isEmptyString(value.month)) ? "" : "-" + value.month; - return yearStr + monthStr; - }, - - setValue: function (v) { - var type, value; - var date = BI.getDate(); - this.storeValue = v; - if (BI.isNotNull(v)) { - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - } - switch (type) { - case BI.DynamicDateCombo.Dynamic: - var text = this._getText(value); - date = BI.DynamicDateHelper.getCalculation(value); - this._setInnerValue(date, text); - break; - case BI.DynamicDateCombo.Static: - default: - value = value || {}; - var month = BI.isNull(value.month) ? null : value.month; - this.yearEditor.setValue(value.year); - this.monthEditor.setValue(month); - break; - } - }, - - getValue: function () { - return this.storeValue; - }, - - getKey: function () { - return this.yearEditor.getValue() + "-" + this.monthEditor.getValue(); - }, - - isValid: function () { - return this.yearEditor.isValid() && this.monthEditor.isValid(); - } -}); -BI.DynamicYearMonthTrigger.EVENT_VALID = "EVENT_VALID"; -BI.DynamicYearMonthTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicYearMonthTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicYearMonthTrigger.EVENT_START = "EVENT_START"; -BI.DynamicYearMonthTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicYearMonthTrigger.EVENT_STOP = "EVENT_STOP"; -BI.DynamicYearMonthTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.shortcut("bi.dynamic_year_month_trigger", BI.DynamicYearMonthTrigger);BI.YearMonthInterval = BI.inherit(BI.Single, { - constants: { - height: 26, - width: 25, - lgap: 15, - offset: -15, - timeErrorCls: "time-error", - DATE_MIN_VALUE: "1900-01-01", - DATE_MAX_VALUE: "2099-12-31" - }, - - props: { - extraCls: "bi-year-month-interval" - }, - - _init: function () { - var self = this, o = this.options; - BI.YearMonthInterval.superclass._init.apply(this, arguments); - - o.value = o.value || {}; - this.left = this._createCombo(o.value.start); - this.right = this._createCombo(o.value.end); - this.label = BI.createWidget({ - type: "bi.label", - height: this.constants.height, - width: this.constants.width, - text: "-" - }); - BI.createWidget({ - element: self, - type: "bi.center", - hgap: 15, - height: this.constants.height, - items: [{ - type: "bi.absolute", - items: [{ - el: self.left, - left: this.constants.offset, - right: 0, - top: 0, - bottom: 0 - }] - }, { - type: "bi.absolute", - items: [{ - el: self.right, - left: 0, - right: this.constants.offset, - top: 0, - bottom: 0 - }] - }] - }); - BI.createWidget({ - type: "bi.horizontal_auto", - element: this, - items: [ - self.label - ] - }); - }, - - _createCombo: function (v) { - var self = this, o = this.options; - var combo = BI.createWidget({ - type: "bi.dynamic_year_month_combo", - behaviors: o.behaviors, - value: v, - listeners: [{ - eventName: BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, - action: function () { - self.fireEvent(BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW); - } - }] - }); - combo.on(BI.DynamicYearMonthCombo.EVENT_ERROR, function () { - self._clearTitle(); - BI.Bubbles.hide("error"); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); - }); - - combo.on(BI.DynamicYearMonthCombo.EVENT_VALID, function () { - self._checkValid(); - }); - - combo.on(BI.DynamicYearMonthCombo.EVENT_FOCUS, function () { - self._checkValid(); - }); - - combo.on(BI.DynamicYearMonthCombo.EVENT_BEFORE_POPUPVIEW, function () { - self.left.hideView(); - self.right.hideView(); - }); - - combo.on(BI.DynamicYearMonthCombo.EVENT_CONFIRM, function () { - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); - }else{ - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - self.fireEvent(BI.YearMonthInterval.EVENT_CHANGE); - } - }); - return combo; - }, - - - _dateCheck: function (date) { - return BI.parseDateTime(date, "%Y-%x").print("%Y-%x") === date || BI.parseDateTime(date, "%Y-%X").print("%Y-%X") === date; - }, - - - // 判是否在最大最小之间 - _checkVoid: function (obj) { - return !BI.checkDateVoid(obj.year, obj.month, 1, this.constants.DATE_MIN_VALUE, this.constants.DATE_MAX_VALUE)[0]; - }, - - // 判格式合法 - _check: function (smallDate, bigDate) { - var smallObj = smallDate.match(/\d+/g), bigObj = bigDate.match(/\d+/g); - - var smallDate4Check = ""; - if (BI.isNotNull(smallObj)) { - smallDate4Check = (smallObj[0] || "") + "-" + (smallObj[1] || 1); - } - - var bigDate4Check = ""; - if (BI.isNotNull(bigObj)) { - bigDate4Check = (bigObj[0] || "") + "-" + (bigObj[1] || 1); - } - - return this._dateCheck(smallDate4Check) && BI.checkDateLegal(smallDate) && this._checkVoid({ - year: smallObj[0], - month: smallObj[1], - day: 1 - }) && this._dateCheck(bigDate4Check) && BI.checkDateLegal(bigDate) && this._checkVoid({ - year: bigObj[0], - month: bigObj[1], - day: 1 - }); - }, - - _compare: function (smallDate, bigDate) { - smallDate = BI.parseDateTime(smallDate, "%Y-%X").print("%Y-%X"); - bigDate = BI.parseDateTime(bigDate, "%Y-%X").print("%Y-%X"); - return BI.isNotNull(smallDate) && BI.isNotNull(bigDate) && smallDate > bigDate; - }, - _setTitle: function (v) { - this.setTitle(v); - }, - _clearTitle: function () { - this.setTitle(""); - }, - _checkValid: function () { - var self = this; - - BI.Bubbles.hide("error"); - var smallDate = self.left.getKey(), bigDate = self.right.getKey(); - if (self.left.isValid() && self.right.isValid() && self._check(smallDate, bigDate) && self._compare(smallDate, bigDate)) { - self._setTitle(BI.i18nText("BI-Time_Interval_Error_Text")); - self.element.addClass(self.constants.timeErrorCls); - BI.Bubbles.show("error", BI.i18nText("BI-Time_Interval_Error_Text"), self, { - offsetStyle: "center" - }); - self.fireEvent(BI.YearMonthInterval.EVENT_ERROR); - } else { - self._clearTitle(); - self.element.removeClass(self.constants.timeErrorCls); - } - }, - setValue: function (date) { - date = date || {}; - this.left.setValue(date.start); - this.right.setValue(date.end); - - this._checkValid(); - }, - getValue: function () { - return {start: this.left.getValue(), end: this.right.getValue()}; - } -}); -BI.YearMonthInterval.EVENT_VALID = "EVENT_VALID"; -BI.YearMonthInterval.EVENT_ERROR = "EVENT_ERROR"; -BI.YearMonthInterval.EVENT_CHANGE = "EVENT_CHANGE"; -BI.YearMonthInterval.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.year_month_interval", BI.YearMonthInterval); -/** - * 年份展示面板 - * - * Created by GUY on 2015/9/2. - * @class BI.YearCard - * @extends BI.Trigger - */ -BI.DynamicYearQuarterCard = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-year-month-card" - }, - - render: function () { - var self = this; - return { - type: "bi.vertical", - items: [{ - type: "bi.label", - text: BI.i18nText("BI-Multi_Date_Relative_Current_Time"), - textAlign: "left", - height: 24 - }, { - type: "bi.dynamic_date_param_item", - ref: function () { - self.year = this; - }, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }] - }, { - type: "bi.dynamic_date_param_item", - dateType: BI.DynamicDateCard.TYPE.QUARTER, - ref: function () { - self.quarter = this; - }, - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self.fireEvent("EVENT_CHANGE"); - } - }] - }], - vgap: 10, - hgap: 10 - }; - }, - - _createValue: function (type, v) { - return { - dateType: type, - value: Math.abs(v), - offset: v > 0 ? 1 : 0 - }; - }, - - setValue: function (v) { - v = v || {year: 0, month: 0}; - this.year.setValue(this._createValue(BI.DynamicDateCard.TYPE.YEAR, v.year)); - this.quarter.setValue(this._createValue(BI.DynamicDateCard.TYPE.QUARTER, v.quarter)); - }, - - getValue: function () { - var year = this.year.getValue(); - var quarter = this.quarter.getValue(); - return { - year: (year.offset === 0 ? -year.value : year.value), - quarter: (quarter.offset === 0 ? -quarter.value : quarter.value) - }; - } -}); -BI.DynamicYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.dynamic_year_quarter_card", BI.DynamicYearQuarterCard);BI.StaticYearQuarterCard = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-static-year-quarter-card", - behaviors: {} - }, - - _createQuarter: function () { - - var items = [{ - text: Date._QN[1], - value: 1 - }, { - text: Date._QN[2], - value: 2 - }, { - text: Date._QN[3], - value: 3 - }, { - text: Date._QN[4], - value: 4 - }]; - return BI.map(items, function (j, item) { - return BI.extend(item, { - type: "bi.text_item", - cls: "bi-list-item-active", - textAlign: "center", - whiteSpace: "nowrap", - once: false, - forceSelected: true, - height: 24 - }); - }); - }, - - render: function () { - var self = this, o = this.options; - return { - type: "bi.vertical", - items: [{ - type: "bi.year_picker", - ref: function () { - self.yearPicker = this; - }, - behaviors: o.behaviors, - height: 30, - listeners: [{ - eventName: BI.YearPicker.EVENT_CHANGE, - action: function () { - var value = this.getValue(); - self.setValue({ - year: value, - quarter: self.selectedQuarter - }); - } - }] - }, { - type: "bi.button_group", - behaviors: o.behaviors, - ref: function () { - self.quarter = this; - }, - items: this._createQuarter(), - layouts: [{ - type: "bi.vertical", - vgap: 10 - }], - value: o.value, - listeners: [{ - eventName: BI.ButtonGroup.EVENT_CHANGE, - action: function () { - self.selectedYear = self.yearPicker.getValue(); - self.selectedQuarter = this.getValue()[0]; - self.fireEvent(BI.StaticYearQuarterCard.EVENT_CHANGE); - } - }] - }] - }; - }, - - - getValue: function () { - return { - year: this.selectedYear, - quarter: this.selectedQuarter - }; - }, - - setValue: function (obj) { - var o = this.options; - var newObj = {}; - newObj.year = obj.year || 0; - newObj.quarter = obj.quarter || 0; - if (newObj.quarter === 0 || newObj.year === 0 || BI.checkDateVoid(newObj.year, newObj.quarter, 1, o.min, o.max)[0]) { - var year = newObj.year || BI.getDate().getFullYear(); - this.selectedYear = year; - this.selectedQuarter = ""; - this.yearPicker.setValue(year); - this.quarter.setValue(); - } else { - this.selectedYear = BI.parseInt(newObj.year); - this.selectedQuarter = BI.parseInt(newObj.quarter); - this.yearPicker.setValue(this.selectedYear); - this.quarter.setValue(this.selectedQuarter); - } - } -}); -BI.StaticYearQuarterCard.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.static_year_quarter_card", BI.StaticYearQuarterCard); -BI.DynamicYearQuarterCombo = BI.inherit(BI.Widget, { - - props: { - baseCls: "bi-year-quarter-combo bi-border", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }, - - _init: function () { - BI.DynamicYearQuarterCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.storeValue = o.value; - self.storeTriggerValue = ""; - this.trigger = BI.createWidget({ - type: "bi.dynamic_year_quarter_trigger", - min: o.min, - max: o.max, - value: o.value || "" - }); - this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_START, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_STOP, function () { - self.combo.showView(); - }); - this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_ERROR, function () { - self.combo.isViewVisible() && self.combo.hideView(); - }); - this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM, function () { - // 没看出来干啥的,先去掉 - // if (self.combo.isViewVisible()) { - // return; - // } - var dateStore = self.storeTriggerValue; - var dateObj = self.trigger.getKey(); - if (BI.isNotEmptyString(dateObj) && !BI.isEqual(dateObj, dateStore)) { - self.storeValue = self.trigger.getValue(); - self.setValue(self.trigger.getValue()); - } - self._checkDynamicValue(self.storeValue); - self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM); - }); - this.trigger.on(BI.DynamicYearQuarterTrigger.EVENT_FOCUS, function () { - self.storeTriggerValue = self.trigger.getKey(); - }); - - this.combo = BI.createWidget({ - type: "bi.combo", - isNeedAdjustHeight: false, - isNeedAdjustWidth: false, - el: this.trigger, - popup: { - minWidth: 85, - stopPropagation: false, - el: { - type: "bi.dynamic_year_quarter_popup", - ref: function () { - self.popup = this; - }, - listeners: [{ - eventName: BI.DynamicYearQuarterPopup.EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE, - action: function () { - self.setValue(); - self.combo.hideView(); - self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE, - action: function () { - var date = BI.getDate(); - self.setValue({type: BI.DynamicYearMonthCombo.Static, value: {year: date.getFullYear(), quarter: date.getQuarter()}}); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }, { - eventName: BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE, - action: function () { - self.setValue(self.popup.getValue()); - self.combo.hideView(); - self.fireEvent(BI.DynamicDateCombo.EVENT_CONFIRM); - } - }], - behaviors: o.behaviors, - min: o.min, - max: o.max - }, - value: o.value || "" - } - }); - this.combo.on(BI.Combo.EVENT_BEFORE_POPUPVIEW, function () { - self.popup.setValue(self.storeValue); - self.fireEvent(BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW); - }); - - BI.createWidget({ - type: "bi.htape", - element: this, - ref: function () { - self.comboWrapper = this; - }, - items: [{ - el: { - type: "bi.icon_button", - cls: "bi-trigger-icon-button date-change-h-font", - width: 24, - height: 24, - ref: function () { - self.changeIcon = this; - } - }, - width: 24 - }, this.combo] - }); - this._checkDynamicValue(o.value); - }, - - _checkDynamicValue: function (v) { - var type = null; - if (BI.isNotNull(v)) { - type = v.type; - } - switch (type) { - case BI.DynamicYearQuarterCombo.Dynamic: - this.changeIcon.setVisible(true); - this.comboWrapper.attr("items")[0].width = 24; - this.comboWrapper.resize(); - break; - default: - this.comboWrapper.attr("items")[0].width = 0; - this.comboWrapper.resize(); - this.changeIcon.setVisible(false); - break; - } - }, - - setValue: function (v) { - this.storeValue = v; - this.trigger.setValue(v); - this._checkDynamicValue(v); - }, - - getValue: function () { - return this.storeValue; - } - -}); -BI.DynamicYearQuarterCombo.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicYearQuarterCombo.EVENT_BEFORE_POPUPVIEW = "EVENT_BEFORE_POPUPVIEW"; -BI.shortcut("bi.dynamic_year_quarter_combo", BI.DynamicYearQuarterCombo); - -BI.extend(BI.DynamicYearQuarterCombo, { - Static: 1, - Dynamic: 2 -});BI.DynamicYearQuarterPopup = BI.inherit(BI.Widget, { - constants: { - tabHeight: 30, - buttonHeight: 24 - }, - - props: { - baseCls: "bi-year-quarter-popup", - behaviors: {}, - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期, - width: 180, - height: 240 - }, - - render: function () { - var self = this, opts = this.options, c = this.constants; - this.storeValue = {type: BI.DynamicYearQuarterCombo.Static}; - return { - type: "bi.vtape", - items: [{ - el: this._getTabJson() - }, { - el: { - type: "bi.grid", - items: [[{ - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-top bi-high-light", - shadow: true, - textHeight: c.buttonHeight - 1, - text: BI.i18nText("BI-Basic_Clear"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-left bi-border-right bi-high-light bi-border-top", - textHeight: c.buttonHeight - 1, - shadow: true, - text: BI.i18nText("BI-Basic_Current_Quarter"), - ref: function () { - self.textButton = this; - }, - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE); - } - }] - }, { - type: "bi.text_button", - forceCenter: true, - cls: "bi-border-top bi-high-light", - shadow: true, - textHeight: c.buttonHeight - 1, - text: BI.i18nText("BI-Basic_OK"), - listeners: [{ - eventName: BI.TextButton.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE); - } - }] - }]] - }, - height: 24 - }] - }; - }, - - _setInnerValue: function () { - if (this.dateTab.getSelect() === BI.DynamicYearQuarterCombo.Static) { - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); - this.textButton.setEnable(true); - } else { - var date = BI.DynamicDateHelper.getCalculation(this.dynamicPane.getValue()); - date = date.print("%Y-%Q"); - this.textButton.setValue(date); - this.textButton.setEnable(false); - } - }, - - _getTabJson: function () { - var self = this, o = this.options; - return { - type: "bi.tab", - ref: function () { - self.dateTab = this; - }, - tab: { - type: "bi.linear_segment", - cls: "bi-border-bottom", - height: this.constants.tabHeight, - items: BI.createItems([{ - text: BI.i18nText("BI-Basic_Year_Quarter"), - value: BI.DynamicYearQuarterCombo.Static - }, { - text: BI.i18nText("BI-Basic_Dynamic_Title"), - value: BI.DynamicYearQuarterCombo.Dynamic - }], { - textAlign: "center" - }) - }, - cardCreator: function (v) { - switch (v) { - case BI.DynamicYearQuarterCombo.Dynamic: - return { - type: "bi.dynamic_year_quarter_card", - listeners: [{ - eventName: "EVENT_CHANGE", - action: function () { - self._setInnerValue(self.year, v); - } - }], - ref: function () { - self.dynamicPane = this; - } - }; - case BI.DynamicYearQuarterCombo.Static: - default: - return { - type: "bi.static_year_quarter_card", - behaviors: o.behaviors, - min: self.options.min, - max: self.options.max, - listeners: [{ - eventName: BI.DynamicYearCard.EVENT_CHANGE, - action: function () { - self.fireEvent(BI.DynamicYearQuarterPopup.EVENT_CHANGE); - } - }], - ref: function () { - self.year = this; - } - }; - } - }, - listeners: [{ - eventName: BI.Tab.EVENT_CHANGE, - action: function () { - var v = self.dateTab.getSelect(); - switch (v) { - case BI.DynamicYearQuarterCombo.Static: - var date = BI.DynamicDateHelper.getCalculation(self.dynamicPane.getValue()); - self.year.setValue({year: date.getFullYear(), quarter: date.getQuarter()}); - self._setInnerValue(); - break; - case BI.DynamicYearQuarterCombo.Dynamic: - default: - if(self.storeValue && self.storeValue.type === BI.DynamicYearQuarterCombo.Dynamic) { - self.dynamicPane.setValue(self.storeValue.value); - }else{ - self.dynamicPane.setValue({ - year: 0 - }); - } - self._setInnerValue(); - break; - } - } - }] - }; - }, - - setValue: function (v) { - this.storeValue = v; - var self = this; - var type, value; - v = v || {}; - type = v.type || BI.DynamicDateCombo.Static; - value = v.value || v; - this.dateTab.setSelect(type); - switch (type) { - case BI.DynamicDateCombo.Dynamic: - this.dynamicPane.setValue(value); - self._setInnerValue(); - break; - case BI.DynamicDateCombo.Static: - default: - this.year.setValue(value); - this.textButton.setValue(BI.i18nText("BI-Basic_Current_Quarter")); - this.textButton.setEnable(true); - break; - } - }, - - getValue: function () { - return { - type: this.dateTab.getSelect(), - value: this.dateTab.getValue() - }; - } - -}); -BI.DynamicYearQuarterPopup.BUTTON_CLEAR_EVENT_CHANGE = "BUTTON_CLEAR_EVENT_CHANGE"; -BI.DynamicYearQuarterPopup.BUTTON_lABEL_EVENT_CHANGE = "BUTTON_lABEL_EVENT_CHANGE"; -BI.DynamicYearQuarterPopup.BUTTON_OK_EVENT_CHANGE = "BUTTON_OK_EVENT_CHANGE"; -BI.DynamicYearQuarterPopup.EVENT_CHANGE = "EVENT_CHANGE"; -BI.shortcut("bi.dynamic_year_quarter_popup", BI.DynamicYearQuarterPopup);BI.DynamicYearQuarterTrigger = BI.inherit(BI.Trigger, { - _const: { - hgap: 4, - vgap: 2 - }, - - props: { - extraCls: "bi-year-quarter-trigger", - min: "1900-01-01", // 最小日期 - max: "2099-12-31", // 最大日期 - height: 24 - }, - - _init: function () { - BI.DynamicYearQuarterTrigger.superclass._init.apply(this, arguments); - var o = this.options; - - this.yearEditor = this._createEditor(true); - this.quarterEditor = this._createEditor(false); - - BI.createWidget({ - element: this, - type: "bi.htape", - items: [{ - type: "bi.center", - items: [{ - type: "bi.htape", - items: [this.yearEditor, { - el: { - type: "bi.text_button", - text: BI.i18nText("BI-Multi_Date_Year"), - width: o.height - }, - width: o.height - }] - }, { - type: "bi.htape", - items: [this.quarterEditor, { - el: { - type: "bi.text_button", - text: BI.i18nText("BI-Multi_Date_Quarter"), - width: o.height - }, - width: o.height}] - }] - }, { - el: { - type: "bi.trigger_icon_button", - width: o.height - }, - width: o.height - }] - }); - this.setValue(o.value); - }, - - _createEditor: function (isYear) { - var self = this, o = this.options, c = this._const; - var editor = BI.createWidget({ - type: "bi.sign_editor", - height: o.height, - validationChecker: function (v) { - if(isYear) { - return v === "" || (BI.isPositiveInteger(v) && !BI.checkDateVoid(v, 1, 1, o.min, o.max)[0]); - } - return v === "" || ((BI.isPositiveInteger(v) && v >= 1 && v <= 4) && !BI.checkDateVoid(BI.getDate().getFullYear(), v, 1, o.min, o.max)[0]); - }, - quitChecker: function () { - return false; - }, - errorText: function (v) { - return BI.i18nText("BI-Year_Trigger_Invalid_Text"); - }, - watermark: BI.i18nText("BI-Basic_Unrestricted"), - hgap: c.hgap, - vgap: c.vgap, - title: "", - allowBlank: true - }); - editor.on(BI.SignEditor.EVENT_KEY_DOWN, function () { - self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN); - }); - editor.on(BI.SignEditor.EVENT_FOCUS, function () { - self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_FOCUS); - }); - editor.on(BI.SignEditor.EVENT_STOP, function () { - self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_STOP); - }); - editor.on(BI.SignEditor.EVENT_CONFIRM, function () { - self._doEditorConfirm(editor); - self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM); - }); - editor.on(BI.SignEditor.EVENT_SPACE, function () { - if (editor.isValid()) { - editor.blur(); - } - }); - editor.on(BI.SignEditor.EVENT_START, function () { - self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_START); - }); - editor.on(BI.SignEditor.EVENT_ERROR, function () { - self.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_ERROR); - }); - editor.on(BI.SignEditor.EVENT_CHANGE, function () { - if(isYear) { - self._autoSwitch(editor); - } - }); - - return editor; - }, - - _doEditorConfirm: function (editor) { - var value = editor.getValue(); - if (BI.isNotNull(value)) { - editor.setValue(value); - } - var quarterValue = this.quarterEditor.getValue(); - this.storeValue = { - type: BI.DynamicYearQuarterCombo.Static, - value: { - year: this.yearEditor.getValue(), - quarter: BI.isEmptyString(this.quarterEditor.getValue()) ? "" : quarterValue - } - }; - this.setTitle(this._getStaticTitle(this.storeValue.value)); - }, - - _yearCheck: function (v) { - var date = BI.parseDateTime(v, "%Y-%X-%d").print("%Y-%X-%d"); - return BI.parseDateTime(v, "%Y").print("%Y") === v && date >= this.options.min && date <= this.options.max; - }, - - _autoSwitch: function (editor) { - var v = editor.getValue(); - if (BI.isNotEmptyString(v) && BI.checkDateLegal(v)) { - if (v.length === 4 && this._yearCheck(v)) { - this._doEditorConfirm(editor); - this.fireEvent(BI.DynamicYearQuarterTrigger.EVENT_CONFIRM); - this.quarterEditor.focus(); - } - } - }, - - _getStaticTitle: function (value) { - value = value || {}; - var yearStr = (BI.isNull(value.year) || BI.isEmptyString(value.year)) ? "" : value.year; - var quarterStr = (BI.isNull(value.quarter) || BI.isEmptyString(value.quarter)) ? "" : "-" + value.quarter; - return yearStr + quarterStr; - }, - - _getText: function (obj) { - var value = ""; - if(BI.isNotNull(obj.year) && BI.parseInt(obj.year) !== 0) { - value += Math.abs(obj.year) + BI.i18nText("BI-Basic_Year") + (obj.year < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - if(BI.isNotNull(obj.quarter) && BI.parseInt(obj.quarter) !== 0) { - value += Math.abs(obj.quarter) + BI.i18nText("BI-Basic_Single_Quarter") + (obj.quarter < 0 ? BI.i18nText("BI-Basic_Front") : BI.i18nText("BI-Basic_Behind")); - } - return value; - }, - - _setInnerValue: function (date, text) { - var dateStr = date.print("%Y-%Q"); - this.yearEditor.setValue(date.getFullYear()); - this.quarterEditor.setValue(date.getQuarter()); - this.setTitle(BI.isEmptyString(text) ? dateStr : (text + ":" + dateStr)); - }, - - setValue: function (v) { - var type, value; - var date = BI.getDate(); - this.storeValue = v; - if (BI.isNotNull(v)) { - type = v.type || BI.DynamicYearQuarterCombo.Static; - value = v.value || v; - } - switch (type) { - case BI.DynamicYearQuarterCombo.Dynamic: - var text = this._getText(value); - date = BI.DynamicDateHelper.getCalculation(value); - this._setInnerValue(date, text); - break; - case BI.DynamicYearQuarterCombo.Static: - default: - value = value || {}; - var quarter = BI.isNull(value.quarter) ? null : value.quarter; - this.yearEditor.setValue(value.year); - this.yearEditor.setTitle(value.year); - this.quarterEditor.setValue(quarter); - this.quarterEditor.setTitle(quarter); - this.setTitle(this._getStaticTitle(value)); - break; - } - }, - - getValue: function () { - return this.storeValue; - }, - - getKey: function () { - return this.yearEditor.getValue() + "-" + this.quarterEditor.getValue(); - } -}); -BI.DynamicYearQuarterTrigger.EVENT_FOCUS = "EVENT_FOCUS"; -BI.DynamicYearQuarterTrigger.EVENT_ERROR = "EVENT_ERROR"; -BI.DynamicYearQuarterTrigger.EVENT_START = "EVENT_START"; -BI.DynamicYearQuarterTrigger.EVENT_CONFIRM = "EVENT_CONFIRM"; -BI.DynamicYearQuarterTrigger.EVENT_STOP = "EVENT_STOP"; -BI.DynamicYearQuarterTrigger.EVENT_KEY_DOWN = "EVENT_KEY_DOWN"; -BI.shortcut("bi.dynamic_year_quarter_trigger", BI.DynamicYearQuarterTrigger);/** - * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 - * 封装了字段处理逻辑 - * - * Created by GUY on 2015/10/29. - * @class BI.AbstractAllValueChooser - * @extends BI.Widget - */ -BI.AbstractAllValueChooser = BI.inherit(BI.Widget, { - - _const: { - perPage: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.AbstractAllValueChooser.superclass._defaultConfig.apply(this, arguments), { - width: 200, - height: 30, - items: null, - itemsCreator: BI.emptyFn, - cache: true - }); - }, - - _valueFormatter: function (v) { - var text = v; - if (BI.isNotNull(this.items)) { - BI.some(this.items, function (i, item) { - // 把value都换成字符串 - // 需要考虑到value也可能是数字 - if (item.value === v || item.value + "" === v) { - text = item.text; - return true; - } - }); - } - return text; - }, - - _itemsCreator: function (options, callback) { - var self = this, o = this.options; - if (!o.cache || !this.items) { - o.itemsCreator({}, function (items) { - self.items = items; - call(items); - }); - } else { - call(this.items); - } - function call (items) { - var keywords = (options.keywords || []).slice(); - if (options.keyword) { - keywords.push(options.keyword); - } - BI.each(keywords, function (i, kw) { - var search = BI.Func.getSearchResult(items, kw); - items = search.match.concat(search.find); - }); - if (options.selectedValues) {// 过滤 - var filter = BI.makeObject(options.selectedValues, true); - items = BI.filter(items, function (i, ob) { - return !filter[ob.value]; - }); - } - if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) { - callback({ - items: items - }); - return; - } - if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { - callback({count: items.length}); - return; - } - callback({ - items: items, - hasNext: false - }); - } - } -});/** - * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 - * 封装了字段处理逻辑 - * - * Created by GUY on 2015/10/29. - * @class BI.AllValueChooserCombo - * @extends BI.AbstractAllValueChooser - */ -BI.AllValueChooserCombo = BI.inherit(BI.AbstractAllValueChooser, { - - _defaultConfig: function () { - return BI.extend(BI.AllValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-all-value-chooser-combo", - width: 200, - height: 30, - items: null, - itemsCreator: BI.emptyFn, - cache: true - }); - }, - - _init: function () { - BI.AllValueChooserCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - if (BI.isNotNull(o.items)) { - this.items = o.items; - } - this.combo = BI.createWidget({ - type: "bi.multi_select_combo", - text: o.text, - element: this, - itemsCreator: BI.bind(this._itemsCreator, this), - valueFormatter: BI.bind(this._valueFormatter, this), - width: o.width, - height: o.height, - value: { - type: BI.Selection.Multi, - value: o.value || [] - } - }); - - this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.AllValueChooserCombo.EVENT_CONFIRM); - }); - }, - - setValue: function (v) { - this.combo.setValue({ - type: BI.Selection.Multi, - value: v || [] - }); - }, - - getValue: function () { - var val = this.combo.getValue() || {}; - if (val.type === BI.Selection.All) { - return val.assist; - } - return val.value || []; - }, - - populate: function (items) { - // 直接用combo的populate不会作用到AbstractValueChooser上 - this.items = items; - this.combo.populate.apply(this, arguments); - } -}); -BI.AllValueChooserCombo.EVENT_CONFIRM = "AllValueChooserCombo.EVENT_CONFIRM"; -BI.shortcut("bi.all_value_chooser_combo", BI.AllValueChooserCombo);/** - * 简单的复选下拉框控件, 适用于数据量少的情况, 与valuechooser的区别是allvaluechooser setValue和getValue返回的是所有值 - * 封装了字段处理逻辑 - * - * Created by GUY on 2015/10/29. - * @class BI.AllValueChooserPane - * @extends BI.AbstractAllValueChooser - */ -BI.AllValueChooserPane = BI.inherit(BI.AbstractAllValueChooser, { - - _defaultConfig: function () { - return BI.extend(BI.AllValueChooserPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-all-value-chooser-pane", - width: 200, - height: 30, - items: null, - itemsCreator: BI.emptyFn, - cache: true - }); - }, - - _init: function () { - BI.AllValueChooserPane.superclass._init.apply(this, arguments); - var self = this, o = this.options; - if (BI.isNotNull(o.items)) { - this.items = o.items; - } - this.list = BI.createWidget({ - type: "bi.multi_select_list", - element: this, - itemsCreator: BI.bind(this._itemsCreator, this), - valueFormatter: BI.bind(this._valueFormatter, this), - width: o.width, - height: o.height - }); - - this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.AllValueChooserPane.EVENT_CHANGE); - }); - }, - - setValue: function (v) { - this.list.setValue({ - type: BI.Selection.Multi, - value: v || [] - }); - }, - - getValue: function () { - var val = this.list.getValue() || {}; - if (val.type === BI.Selection.All) { - return val.assist; - } - return val.value || []; - }, - - populate: function (items) { - // 直接用combo的populate不会作用到AbstractValueChooser上 - this.items = items; - this.list.populate.apply(this.list, arguments); - } -}); -BI.AllValueChooserPane.EVENT_CHANGE = "AllValueChooserPane.EVENT_CHANGE"; -BI.shortcut("bi.all_value_chooser_pane", BI.AllValueChooserPane);BI.AbstractTreeValueChooser = BI.inherit(BI.Widget, { - - _const: { - perPage: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.AbstractTreeValueChooser.superclass._defaultConfig.apply(this, arguments), { - items: null, - itemsCreator: BI.emptyFn - }); - }, - - _valueFormatter: function (v) { - var text = v; - if (BI.isNotNull(this.items)) { - BI.some(this.items, function (i, item) { - if (item.value + "" === v) { - text = item.text; - return true; - } - }); - } - return text; - }, - - _initData: function (items) { - this.items = items; - var nodes = BI.Tree.treeFormat(items); - this.tree = new BI.Tree(); - this.tree.initTree(nodes); - }, - - _itemsCreator: function (options, callback) { - var self = this, o = this.options; - if (!this.items) { - o.itemsCreator({}, function (items) { - self._initData(items); - call(); - }); - } else { - call(); - } - function call () { - switch (options.type) { - case BI.TreeView.REQ_TYPE_INIT_DATA: - self._reqInitTreeNode(options, callback); - break; - case BI.TreeView.REQ_TYPE_ADJUST_DATA: - self._reqAdjustTreeNode(options, callback); - break; - case BI.TreeView.REQ_TYPE_SELECT_DATA: - self._reqSelectedTreeNode(options, callback); - break; - case BI.TreeView.REQ_TYPE_GET_SELECTED_DATA: - self._reqDisplayTreeNode(options, callback); - break; - default : - self._reqTreeNode(options, callback); - break; - } - } - }, - - _reqDisplayTreeNode: function (op, callback) { - var self = this; - var result = []; - var selectedValues = op.selectedValues; - - if (selectedValues == null || BI.isEmpty(selectedValues)) { - callback({}); - return; - } - - doCheck([], this.tree.getRoot(), selectedValues); - - callback({ - items: result - }); - - function doCheck (parentValues, node, selected) { - if (selected == null || BI.isEmpty(selected)) { - BI.each(node.getChildren(), function (i, child) { - var newParents = BI.clone(parentValues); - newParents.push(child.value); - var llen = self._getChildCount(newParents); - createOneJson(child, node.id, llen); - doCheck(newParents, child, {}); - }); - return; - } - BI.each(selected, function (k) { - var node = self._getTreeNode(parentValues, k); - var newParents = BI.clone(parentValues); - newParents.push(node.value); - createOneJson(node, node.parent && node.parent.id, getCount(selected[k], newParents)); - doCheck(newParents, node, selected[k]); - }); - } - - function getCount (jo, parentValues) { - if (jo == null) { - return 0; - } - if (BI.isEmpty(jo)) { - return self._getChildCount(parentValues); - } - - return BI.size(jo); - } - - function createOneJson (node, pId, llen) { - result.push({ - id: node.id, - pId: pId, - text: node.text + (llen > 0 ? ("(" + BI.i18nText("BI-Basic_Altogether") + llen + BI.i18nText("BI-Basic_Count") + ")") : ""), - value: node.value, - open: true - }); - } - }, - - _reqSelectedTreeNode: function (op, callback) { - var self = this; - var selectedValues = BI.deepClone(op.selectedValues); - var notSelectedValue = op.notSelectedValue || {}; - var keyword = op.keyword || ""; - var parentValues = op.parentValues || []; - - if (selectedValues == null || BI.isEmpty(selectedValues)) { - callback({}); - return; - } - - dealWithSelectedValues(selectedValues); - callback(selectedValues); - - - function dealWithSelectedValues (selectedValues) { - var p = parentValues.concat(notSelectedValue); - // 存储的值中存在这个值就把它删掉 - // 例如选中了中国-江苏-南京, 取消中国或江苏或南京 - if (canFindKey(selectedValues, p)) { - // 如果搜索的值在父亲链中 - if (isSearchValueInParent(p)) { - // 例如选中了 中国-江苏, 搜索江苏, 取消江苏 - // 例如选中了 中国-江苏, 搜索江苏, 取消中国 - self._deleteNode(selectedValues, p); - } else { - var searched = []; - var find = search(parentValues, notSelectedValue, [], searched); - if (find && BI.isNotEmptyArray(searched)) { - BI.each(searched, function (i, arr) { - var node = self._getNode(selectedValues, arr); - if (node) { - // 例如选中了 中国-江苏-南京,搜索南京,取消中国 - self._deleteNode(selectedValues, arr); - } else { - // 例如选中了 中国-江苏,搜索南京,取消中国 - expandSelectedValue(selectedValues, arr, BI.last(arr)); - } - }); - } - } - } - - // 存储的值中不存在这个值,但父亲节点是全选的情况 - // 例如选中了中国-江苏,取消南京 - // important 选中了中国-江苏,取消了江苏,但是搜索的是南京 - if (isChild(selectedValues, p)) { - var result = [], find = false; - // 如果parentValues中有匹配的值,说明搜索结果不在当前值下 - if (isSearchValueInParent(p)) { - find = true; - } else { - // 从当前值开始搜 - find = search(parentValues, notSelectedValue, result); - p = parentValues; - } - - if (find === true) { - // 去掉点击的节点之后的结果集 - expandSelectedValue(selectedValues, p, notSelectedValue); - // 添加去掉搜索的结果集 - if (result.length > 0) { - BI.each(result, function (i, strs) { - self._buildTree(selectedValues, strs); - }); - } - } - } - - } - - function expandSelectedValue (selectedValues, parents, notSelectedValue) { - var next = selectedValues; - var childrenCount = []; - var path = []; - // 去掉点击的节点之后的结果集 - BI.some(parents, function (i, v) { - var t = next[v]; - if (t == null) { - if (i === 0) { - return true; - } - if (BI.isEmpty(next)) { - var split = parents.slice(0, i); - var expanded = self._getChildren(split); - path.push(split); - childrenCount.push(expanded.length); - // 如果只有一个值且取消的就是这个值 - if (i === parents.length - 1 && expanded.length === 1 && expanded[0] === notSelectedValue) { - for (var j = childrenCount.length - 1; j >= 0; j--) { - if (childrenCount[j] === 1) { - self._deleteNode(selectedValues, path[j]); - } else { - break; - } - } - } else { - BI.each(expanded, function (m, child) { - if (i === parents.length - 1 && child.value === notSelectedValue) { - return true; - } - next[child.value] = {}; - }); - } - next = next[v]; - } else { - return true; - // next = {}; - // next[v] = {}; - } - } else { - next = t; - } - }); - } - - function search (parents, current, result, searched) { - var newParents = BI.clone(parents); - newParents.push(current); - if (self._isMatch(parents, current, keyword)) { - searched && searched.push(newParents); - return true; - } - - var children = self._getChildren(newParents); - - var notSearch = []; - var can = false; - - BI.each(children, function (i, child) { - if (search(newParents, child.value, result, searched)) { - can = true; - } else { - notSearch.push(child.value); - } - }); - if (can === true) { - BI.each(notSearch, function (i, v) { - var next = BI.clone(newParents); - next.push(v); - result.push(next); - }); - } - return can; - } - - function isSearchValueInParent (parentValues) { - for (var i = 0, len = parentValues.length; i < len; i++) { - if (self._isMatch(parentValues.slice(0, parentValues.length - 1), parentValues[i], keyword)) { - return true; - } - } - return false; - } - - function canFindKey (selectedValues, parents) { - var t = selectedValues; - for (var i = 0; i < parents.length; i++) { - var v = parents[i]; - t = t[v]; - if (t == null) { - return false; - } - } - return true; - } - - function isChild (selectedValues, parents) { - var t = selectedValues; - for (var i = 0; i < parents.length; i++) { - var v = parents[i]; - if (!BI.has(t, v)) { - return false; - } - t = t[v]; - if (BI.isEmpty(t)) { - return true; - } - } - return false; - } - }, - - _reqAdjustTreeNode: function (op, callback) { - var self = this; - var result = []; - var selectedValues = op.selectedValues; - if (selectedValues == null || BI.isEmpty(selectedValues)) { - callback({}); - return; - } - BI.each(selectedValues, function (k, v) { - result.push([k]); - }); - - dealWithSelectedValues(selectedValues, []); - - var jo = {}; - BI.each(result, function (i, strs) { - self._buildTree(jo, strs); - }); - callback(jo); - - function dealWithSelectedValues (selected, parents) { - if (selected == null || BI.isEmpty(selected)) { - return true; - } - var can = true; - BI.each(selected, function (k, v) { - var p = BI.clone(parents); - p.push(k); - if (!dealWithSelectedValues(selected[k], p)) { - BI.each(selected[k], function (nk, nv) { - var t = BI.clone(p); - t.push(nk); - result.push(t); - }); - can = false; - } - }); - return can && isAllSelected(selected, parents); - } - - function isAllSelected (selected, parents) { - return BI.isEmpty(selected) || self._getChildCount(parents) === BI.size(selected); - } - }, - - _reqInitTreeNode: function (op, callback) { - var self = this; - var result = []; - var keyword = op.keyword || ""; - var selectedValues = op.selectedValues; - var lastSearchValue = op.lastSearchValue || ""; - var output = search(); - BI.nextTick(function () { - callback({ - hasNext: output.length > self._const.perPage, - items: result, - lastSearchValue: BI.last(output) - }); - }); - - function search () { - var children = self._getChildren([]); - var start = children.length; - if (lastSearchValue !== "") { - for (var j = 0, len = start; j < len; j++) { - if (children[j].value === lastSearchValue) { - start = j + 1; - break; - } - } - } else { - start = 0; - } - var output = []; - for (var i = start, len = children.length; i < len; i++) { - if (output.length < self._const.perPage) { - var find = nodeSearch(1, [], children[i].value, false, result); - } else if (output.length === self._const.perPage) { - var find = nodeSearch(1, [], children[i].value, false, []); - } - if (find[0] === true) { - output.push(children[i].value); - } - if (output.length > self._const.perPage) { - break; - } - } - return output; - } - - function nodeSearch (deep, parentValues, current, isAllSelect, result) { - if (self._isMatch(parentValues, current, keyword)) { - var checked = isAllSelect || isSelected(parentValues, current); - createOneJson(parentValues, current, false, checked, !isAllSelect && isHalf(parentValues, current), true, result); - return [true, checked]; - } - var newParents = BI.clone(parentValues); - newParents.push(current); - var children = self._getChildren(newParents); - - var can = false, checked = false; - - var isCurAllSelected = isAllSelect || isAllSelected(parentValues, current); - BI.each(children, function (i, child) { - var state = nodeSearch(deep + 1, newParents, child.value, isCurAllSelected, result); - if (state[1] === true) { - checked = true; - } - if (state[0] === true) { - can = true; - } - }); - if (can === true) { - checked = isCurAllSelected || (isSelected(parentValues, current) && checked); - createOneJson(parentValues, current, true, checked, false, false, result); - } - return [can, checked]; - } - - function createOneJson (parentValues, value, isOpen, checked, half, flag, result) { - var node = self._getTreeNode(parentValues, value); - result.push({ - id: node.id, - pId: node.pId, - text: node.text, - value: node.value, - title: node.title, - isParent: node.getChildrenLength() > 0, - open: isOpen, - checked: checked, - halfCheck: half, - flag: flag - }); - } - - function isHalf (parentValues, value) { - var find = findSelectedObj(parentValues); - if (find == null) { - return null; - } - return BI.any(find, function (v, ob) { - if (v === value) { - if (ob != null && !BI.isEmpty(ob)) { - return true; - } - } - }); - } - - function isAllSelected (parentValues, value) { - var find = findSelectedObj(parentValues); - if (find == null) { - return null; - } - return BI.any(find, function (v, ob) { - if (v === value) { - if (ob != null && BI.isEmpty(ob)) { - return true; - } - } - }); - } - - function isSelected (parentValues, value) { - var find = findSelectedObj(parentValues); - if (find == null) { - return false; - } - return BI.any(find, function (v) { - if (v === value) { - return true; - } - }); - } - - function findSelectedObj (parentValues) { - var find = selectedValues; - if (find == null) { - return null; - } - BI.every(parentValues, function (i, v) { - find = find[v]; - if (find == null) { - return false; - } - return true; - }); - return find; - } - }, - - _reqTreeNode: function (op, callback) { - var self = this; - var result = []; - var times = op.times; - var checkState = op.checkState || {}; - var parentValues = op.parentValues || []; - var selectedValues = op.selectedValues || {}; - var valueMap = {}; - // if (judgeState(parentValues, selectedValues, checkState)) { - valueMap = dealWidthSelectedValue(parentValues, selectedValues); - // } - var nodes = this._getChildren(parentValues); - for (var i = (times - 1) * this._const.perPage; nodes[i] && i < times * this._const.perPage; i++) { - var state = getCheckState(nodes[i].value, parentValues, valueMap, checkState); - result.push({ - id: nodes[i].id, - pId: nodes[i].pId, - value: nodes[i].value, - text: nodes[i].text, - times: 1, - isParent: nodes[i].getChildrenLength() > 0, - checked: state[0], - halfCheck: state[1] - }); - } - BI.nextTick(function () { - callback({ - items: result, - hasNext: nodes.length > times * self._const.perPage - }); - }); - - function judgeState (parentValues, selected_value, checkState) { - var checked = checkState.checked, half = checkState.half; - if (parentValues.length > 0 && !checked) { - return false; - } - return (parentValues.length === 0 || (checked && half) && !BI.isEmpty(selected_value)); - } - - function dealWidthSelectedValue (parentValues, selectedValues) { - var valueMap = {}; - BI.each(parentValues, function (i, v) { - selectedValues = selectedValues[v] || {}; - }); - BI.each(selectedValues, function (value, obj) { - if (BI.isNull(obj)) { - valueMap[value] = [0, 0]; - return; - } - if (BI.isEmpty(obj)) { - valueMap[value] = [2, 0]; - return; - } - var nextNames = {}; - BI.each(obj, function (t, o) { - if (BI.isNull(o) || BI.isEmpty(o)) { - nextNames[t] = true; - } - }); - valueMap[value] = [1, BI.size(nextNames)]; - }); - return valueMap; - } - - function getCheckState (current, parentValues, valueMap, checkState) { - var checked = checkState.checked, half = checkState.half; - var tempCheck = false, halfCheck = false; - if (BI.has(valueMap, current)) { - // 可能是半选 - if (valueMap[current][0] === 1) { - var values = BI.clone(parentValues); - values.push(current); - var childCount = self._getChildCount(values); - if (childCount > 0 && childCount !== valueMap[current][1]) { - halfCheck = true; - } - } else if (valueMap[current][0] === 2) { - tempCheck = true; - } - } - var check; - if (!checked && !halfCheck && !tempCheck) { - check = BI.has(valueMap, current); - } else { - check = ((tempCheck || checked) && !half) || BI.has(valueMap, current); - } - return [check, halfCheck]; - } - }, - - _getNode: function (selectedValues, parentValues) { - var pNode = selectedValues; - for (var i = 0, len = parentValues.length; i < len; i++) { - if (pNode == null) { - return null; - } - pNode = pNode[parentValues[i]]; - } - return pNode; - }, - - _deleteNode: function (selectedValues, values) { - var name = values[values.length - 1]; - var p = values.slice(0, values.length - 1); - var pNode = this._getNode(selectedValues, p); - if (pNode != null && pNode[name]) { - delete pNode[name]; - // 递归删掉空父节点 - while (p.length > 0 && BI.isEmpty(pNode)) { - name = p[p.length - 1]; - p = p.slice(0, p.length - 1); - pNode = this._getNode(selectedValues, p); - if (pNode != null) { - delete pNode[name]; - } - } - } - }, - - _buildTree: function (jo, values) { - var t = jo; - BI.each(values, function (i, v) { - if (!BI.has(t, v)) { - t[v] = {}; - } - t = t[v]; - }); - }, - - _isMatch: function (parentValues, value, keyword) { - var node = this._getTreeNode(parentValues, value); - if (!node) { - return false; - } - var find = BI.Func.getSearchResult([node.text || node.value], keyword); - return find.find.length > 0 || find.match.length > 0; - }, - - _getTreeNode: function (parentValues, v) { - var self = this; - var findParentNode; - var index = 0; - this.tree.traverse(function (node) { - if (self.tree.isRoot(node)) { - return; - } - if (index > parentValues.length) { - return false; - } - if (index === parentValues.length && node.value === v) { - findParentNode = node; - return false; - } - if (node.value === parentValues[index]) { - index++; - return; - } - return true; - }); - return findParentNode; - }, - - _getChildren: function (parentValues) { - if (parentValues.length > 0) { - var value = BI.last(parentValues); - var parent = this._getTreeNode(parentValues.slice(0, parentValues.length - 1), value); - } else { - var parent = this.tree.getRoot(); - } - return parent.getChildren(); - }, - - _getChildCount: function (parentValues) { - return this._getChildren(parentValues).length; - } -});/** - * 简单的复选下拉树控件, 适用于数据量少的情况 - * - * Created by GUY on 2015/10/29. - * @class BI.TreeValueChooserCombo - * @extends BI.Widget - */ -BI.TreeValueChooserCombo = BI.inherit(BI.AbstractTreeValueChooser, { - - _defaultConfig: function () { - return BI.extend(BI.TreeValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-tree-value-chooser-combo", - width: 200, - height: 30, - items: null, - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.TreeValueChooserCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - if (BI.isNotNull(o.items)) { - this._initData(o.items); - } - this.combo = BI.createWidget({ - type: "bi.multi_tree_combo", - element: this, - itemsCreator: BI.bind(this._itemsCreator, this), - valueFormatter: BI.bind(this._valueFormatter, this), - width: o.width, - height: o.height - }); - - this.combo.on(BI.MultiTreeCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.TreeValueChooserCombo.EVENT_CONFIRM); - }); - }, - - setValue: function (v) { - this.combo.setValue(v); - }, - - getValue: function () { - return this.combo.getValue(); - }, - - populate: function (items) { - this._initData(items); - this.combo.populate.apply(this.combo, arguments); - } -}); -BI.TreeValueChooserCombo.EVENT_CONFIRM = "TreeValueChooserCombo.EVENT_CONFIRM"; -BI.shortcut("bi.tree_value_chooser_combo", BI.TreeValueChooserCombo);/** - * 简单的复选下拉树控件, 适用于数据量少的情况 - * - * Created by GUY on 2015/10/29. - * @class BI.TreeValueChooserPane - * @extends BI.AbstractTreeValueChooser - */ -BI.TreeValueChooserPane = BI.inherit(BI.AbstractTreeValueChooser, { - - _defaultConfig: function () { - return BI.extend(BI.TreeValueChooserPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-tree-value-chooser-pane", - items: null, - itemsCreator: BI.emptyFn - }); - }, - - _init: function () { - BI.TreeValueChooserPane.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.pane = BI.createWidget({ - type: "bi.multi_select_tree", - element: this, - itemsCreator: BI.bind(this._itemsCreator, this) - }); - - this.pane.on(BI.MultiSelectTree.EVENT_CHANGE, function () { - self.fireEvent(BI.TreeValueChooserPane.EVENT_CHANGE); - }); - if (BI.isNotNull(o.items)) { - this._initData(o.items); - this.populate(); - } - }, - - setSelectedValue: function (v) { - this.pane.setSelectedValue(v); - }, - - setValue: function (v) { - this.pane.setValue(v); - }, - - getValue: function () { - return this.pane.getValue(); - }, - - populate: function () { - this.pane.populate.apply(this.pane, arguments); - } -}); -BI.TreeValueChooserPane.EVENT_CHANGE = "TreeValueChooserPane.EVENT_CHANGE"; -BI.shortcut("bi.tree_value_chooser_pane", BI.TreeValueChooserPane);/** - * 简单的复选下拉框控件, 适用于数据量少的情况 - * 封装了字段处理逻辑 - * - * Created by GUY on 2015/10/29. - * @class BI.AbstractValueChooser - * @extends BI.Widget - */ -BI.AbstractValueChooser = BI.inherit(BI.Widget, { - - _const: { - perPage: 100 - }, - - _defaultConfig: function () { - return BI.extend(BI.AbstractValueChooser.superclass._defaultConfig.apply(this, arguments), { - items: null, - itemsCreator: BI.emptyFn, - cache: true - }); - }, - - _valueFormatter: function (v) { - var text = v; - if (BI.isNotNull(this.items)) { - BI.some(this.items, function (i, item) { - // 把value都换成字符串 - if (item.value + "" === v) { - text = item.text; - return true; - } - }); - } - return text; - }, - - _getItemsByTimes: function (items, times) { - var res = []; - for (var i = (times - 1) * this._const.perPage; items[i] && i < times * this._const.perPage; i++) { - res.push(items[i]); - } - return res; - }, - - _hasNextByTimes: function (items, times) { - return times * this._const.perPage < items.length; - }, - - _itemsCreator: function (options, callback) { - var self = this, o = this.options; - if (!o.cache || !this.items) { - o.itemsCreator({}, function (items) { - self.items = items; - call(items); - }); - } else { - call(this.items); - } - function call (items) { - var keywords = (options.keywords || []).slice(); - BI.each(keywords, function (i, kw) { - var search = BI.Func.getSearchResult(items, kw); - items = search.match.concat(search.find); - }); - if (options.selectedValues) {// 过滤 - var filter = BI.makeObject(options.selectedValues, true); - items = BI.filter(items, function (i, ob) { - return !filter[ob.value]; - }); - } - if (options.type === BI.MultiSelectCombo.REQ_GET_ALL_DATA) { - callback({ - items: items - }); - return; - } - if (options.type === BI.MultiSelectCombo.REQ_GET_DATA_LENGTH) { - callback({count: items.length}); - return; - } - callback({ - items: self._getItemsByTimes(items, options.times), - hasNext: self._hasNextByTimes(items, options.times) - }); - } - } -});/** - * 简单的复选下拉框控件, 适用于数据量少的情况 - * 封装了字段处理逻辑 - * - * Created by GUY on 2015/10/29. - * @class BI.ValueChooserCombo - * @extends BI.Widget - */ -BI.ValueChooserCombo = BI.inherit(BI.AbstractValueChooser, { - - _defaultConfig: function () { - return BI.extend(BI.ValueChooserCombo.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-value-chooser-combo", - width: 200, - height: 30, - items: null, - itemsCreator: BI.emptyFn, - cache: true - }); - }, - - _init: function () { - BI.ValueChooserCombo.superclass._init.apply(this, arguments); - var self = this, o = this.options; - if (BI.isNotNull(o.items)) { - this.items = o.items; - } - this.combo = BI.createWidget({ - type: "bi.multi_select_combo", - element: this, - text: o.text, - itemsCreator: BI.bind(this._itemsCreator, this), - valueFormatter: BI.bind(this._valueFormatter, this), - width: o.width, - height: o.height - }); - - this.combo.on(BI.MultiSelectCombo.EVENT_CONFIRM, function () { - self.fireEvent(BI.ValueChooserCombo.EVENT_CONFIRM); - }); - }, - - setValue: function (v) { - this.combo.setValue(v); - }, - - getValue: function () { - var val = this.combo.getValue() || {}; - return { - type: val.type, - value: val.value - }; - }, - - populate: function (items) { - // 直接用combo的populate不会作用到AbstractValueChooser上 - this.items = items; - this.combo.populate.apply(this, arguments); - } -}); -BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM"; -BI.shortcut("bi.value_chooser_combo", BI.ValueChooserCombo);/** - * 简单的复选下拉框控件, 适用于数据量少的情况 - * 封装了字段处理逻辑 - * - * Created by GUY on 2015/10/29. - * @class BI.ValueChooserPane - * @extends BI.Widget - */ -BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, { - - _defaultConfig: function () { - return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), { - baseCls: "bi-value-chooser-pane", - items: null, - itemsCreator: BI.emptyFn, - cache: true - }); - }, - - _init: function () { - BI.ValueChooserPane.superclass._init.apply(this, arguments); - var self = this, o = this.options; - this.list = BI.createWidget({ - type: "bi.multi_select_list", - element: this, - itemsCreator: BI.bind(this._itemsCreator, this), - valueFormatter: BI.bind(this._valueFormatter, this) - }); - - this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () { - self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE); - }); - if (BI.isNotNull(o.items)) { - this.items = o.items; - this.list.populate(); - } - }, - - setValue: function (v) { - this.list.setValue(v); - }, - - getValue: function () { - var val = this.list.getValue() || {}; - return { - type: val.type, - value: val.value - }; - }, - - populate: function (items) { - // 直接用combo的populate不会作用到AbstractValueChooser上 - items && (this.items = items); - this.list.populate.apply(this.list, arguments); - } -}); -BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; +BI.ValueChooserCombo.EVENT_CONFIRM = "ValueChooserCombo.EVENT_CONFIRM"; +BI.shortcut("bi.value_chooser_combo", BI.ValueChooserCombo);/** + * 简单的复选下拉框控件, 适用于数据量少的情况 + * 封装了字段处理逻辑 + * + * Created by GUY on 2015/10/29. + * @class BI.ValueChooserPane + * @extends BI.Widget + */ +BI.ValueChooserPane = BI.inherit(BI.AbstractValueChooser, { + + _defaultConfig: function () { + return BI.extend(BI.ValueChooserPane.superclass._defaultConfig.apply(this, arguments), { + baseCls: "bi-value-chooser-pane", + items: null, + itemsCreator: BI.emptyFn, + cache: true + }); + }, + + _init: function () { + BI.ValueChooserPane.superclass._init.apply(this, arguments); + var self = this, o = this.options; + this.list = BI.createWidget({ + type: "bi.multi_select_list", + element: this, + itemsCreator: BI.bind(this._itemsCreator, this), + valueFormatter: BI.bind(this._valueFormatter, this) + }); + + this.list.on(BI.MultiSelectList.EVENT_CHANGE, function () { + self.fireEvent(BI.ValueChooserPane.EVENT_CHANGE); + }); + if (BI.isNotNull(o.items)) { + this.items = o.items; + this.list.populate(); + } + }, + + setValue: function (v) { + this.list.setValue(v); + }, + + getValue: function () { + var val = this.list.getValue() || {}; + return { + type: val.type, + value: val.value + }; + }, + + populate: function (items) { + // 直接用combo的populate不会作用到AbstractValueChooser上 + items && (this.items = items); + this.list.populate.apply(this.list, arguments); + } +}); +BI.ValueChooserPane.EVENT_CHANGE = "ValueChooserPane.EVENT_CHANGE"; BI.shortcut("bi.value_chooser_pane", BI.ValueChooserPane); \ No newline at end of file