/* CryptoJS v3.1.2 code.google.com/p/crypto-js (c) 2009-2013 by Jeff Mott. All rights reserved. code.google.com/p/crypto-js/wiki/License */ var CryptoJS=CryptoJS||function(u,p){var d={},l=d.lib={},s=function(){},t=l.Base={extend:function(a){s.prototype=this;var c=new s;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, r=l.WordArray=t.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=p?c:4*a.length},toString:function(a){return(a||v).stringify(this)},concat:function(a){var c=this.words,e=a.words,j=this.sigBytes;a=a.sigBytes;this.clamp();if(j%4)for(var k=0;k>>2]|=(e[k>>>2]>>>24-8*(k%4)&255)<<24-8*((j+k)%4);else if(65535>>2]=e[k>>>2];else c.push.apply(c,e);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 32-8*(c%4);a.length=u.ceil(c/4)},clone:function(){var a=t.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],e=0;e>>2]>>>24-8*(j%4)&255;e.push((k>>>4).toString(16));e.push((k&15).toString(16))}return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j>>3]|=parseInt(a.substr(j, 2),16)<<24-4*(j%8);return new r.init(e,c/2)}},b=w.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var e=[],j=0;j>>2]>>>24-8*(j%4)&255));return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j>>2]|=(a.charCodeAt(j)&255)<<24-8*(j%4);return new r.init(e,c)}},x=w.Utf8={stringify:function(a){try{return decodeURIComponent(escape(b.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return b.parse(unescape(encodeURIComponent(a)))}}, q=l.BufferedBlockAlgorithm=t.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=x.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,e=c.words,j=c.sigBytes,k=this.blockSize,b=j/(4*k),b=a?u.ceil(b):u.max((b|0)-this._minBufferSize,0);a=b*k;j=u.min(4*a,j);if(a){for(var q=0;q>>2]>>>24-8*(r%4)&255)<<16|(l[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|l[r+2>>>2]>>>24-8*((r+2)%4)&255,v=0;4>v&&r+0.75*v>>6*(3-v)&63));if(l=t.charAt(64))for(;d.length%4;)d.push(l);return d.join("")},parse:function(d){var l=d.length,s=this._map,t=s.charAt(64);t&&(t=d.indexOf(t),-1!=t&&(l=t));for(var t=[],r=0,w=0;w< l;w++)if(w%4){var v=s.indexOf(d.charAt(w-1))<<2*(w%4),b=s.indexOf(d.charAt(w))>>>6-2*(w%4);t[r>>>2]|=(v|b)<<24-8*(r%4);r++}return p.create(t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})(); (function(u){function p(b,n,a,c,e,j,k){b=b+(n&a|~n&c)+e+k;return(b<>>32-j)+n}function d(b,n,a,c,e,j,k){b=b+(n&c|a&~c)+e+k;return(b<>>32-j)+n}function l(b,n,a,c,e,j,k){b=b+(n^a^c)+e+k;return(b<>>32-j)+n}function s(b,n,a,c,e,j,k){b=b+(a^(n|~c))+e+k;return(b<>>32-j)+n}for(var t=CryptoJS,r=t.lib,w=r.WordArray,v=r.Hasher,r=t.algo,b=[],x=0;64>x;x++)b[x]=4294967296*u.abs(u.sin(x+1))|0;r=r.MD5=v.extend({_doReset:function(){this._hash=new w.init([1732584193,4023233417,2562383102,271733878])}, _doProcessBlock:function(q,n){for(var a=0;16>a;a++){var c=n+a,e=q[c];q[c]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360}var a=this._hash.words,c=q[n+0],e=q[n+1],j=q[n+2],k=q[n+3],z=q[n+4],r=q[n+5],t=q[n+6],w=q[n+7],v=q[n+8],A=q[n+9],B=q[n+10],C=q[n+11],u=q[n+12],D=q[n+13],E=q[n+14],x=q[n+15],f=a[0],m=a[1],g=a[2],h=a[3],f=p(f,m,g,h,c,7,b[0]),h=p(h,f,m,g,e,12,b[1]),g=p(g,h,f,m,j,17,b[2]),m=p(m,g,h,f,k,22,b[3]),f=p(f,m,g,h,z,7,b[4]),h=p(h,f,m,g,r,12,b[5]),g=p(g,h,f,m,t,17,b[6]),m=p(m,g,h,f,w,22,b[7]), f=p(f,m,g,h,v,7,b[8]),h=p(h,f,m,g,A,12,b[9]),g=p(g,h,f,m,B,17,b[10]),m=p(m,g,h,f,C,22,b[11]),f=p(f,m,g,h,u,7,b[12]),h=p(h,f,m,g,D,12,b[13]),g=p(g,h,f,m,E,17,b[14]),m=p(m,g,h,f,x,22,b[15]),f=d(f,m,g,h,e,5,b[16]),h=d(h,f,m,g,t,9,b[17]),g=d(g,h,f,m,C,14,b[18]),m=d(m,g,h,f,c,20,b[19]),f=d(f,m,g,h,r,5,b[20]),h=d(h,f,m,g,B,9,b[21]),g=d(g,h,f,m,x,14,b[22]),m=d(m,g,h,f,z,20,b[23]),f=d(f,m,g,h,A,5,b[24]),h=d(h,f,m,g,E,9,b[25]),g=d(g,h,f,m,k,14,b[26]),m=d(m,g,h,f,v,20,b[27]),f=d(f,m,g,h,D,5,b[28]),h=d(h,f, m,g,j,9,b[29]),g=d(g,h,f,m,w,14,b[30]),m=d(m,g,h,f,u,20,b[31]),f=l(f,m,g,h,r,4,b[32]),h=l(h,f,m,g,v,11,b[33]),g=l(g,h,f,m,C,16,b[34]),m=l(m,g,h,f,E,23,b[35]),f=l(f,m,g,h,e,4,b[36]),h=l(h,f,m,g,z,11,b[37]),g=l(g,h,f,m,w,16,b[38]),m=l(m,g,h,f,B,23,b[39]),f=l(f,m,g,h,D,4,b[40]),h=l(h,f,m,g,c,11,b[41]),g=l(g,h,f,m,k,16,b[42]),m=l(m,g,h,f,t,23,b[43]),f=l(f,m,g,h,A,4,b[44]),h=l(h,f,m,g,u,11,b[45]),g=l(g,h,f,m,x,16,b[46]),m=l(m,g,h,f,j,23,b[47]),f=s(f,m,g,h,c,6,b[48]),h=s(h,f,m,g,w,10,b[49]),g=s(g,h,f,m, E,15,b[50]),m=s(m,g,h,f,r,21,b[51]),f=s(f,m,g,h,u,6,b[52]),h=s(h,f,m,g,k,10,b[53]),g=s(g,h,f,m,B,15,b[54]),m=s(m,g,h,f,e,21,b[55]),f=s(f,m,g,h,v,6,b[56]),h=s(h,f,m,g,x,10,b[57]),g=s(g,h,f,m,t,15,b[58]),m=s(m,g,h,f,D,21,b[59]),f=s(f,m,g,h,z,6,b[60]),h=s(h,f,m,g,C,10,b[61]),g=s(g,h,f,m,j,15,b[62]),m=s(m,g,h,f,A,21,b[63]);a[0]=a[0]+f|0;a[1]=a[1]+m|0;a[2]=a[2]+g|0;a[3]=a[3]+h|0},_doFinalize:function(){var b=this._data,n=b.words,a=8*this._nDataBytes,c=8*b.sigBytes;n[c>>>5]|=128<<24-c%32;var e=u.floor(a/ 4294967296);n[(c+64>>>9<<4)+15]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360;n[(c+64>>>9<<4)+14]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;b.sigBytes=4*(n.length+1);this._process();b=this._hash;n=b.words;for(a=0;4>a;a++)c=n[a],n[a]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return b},clone:function(){var b=v.clone.call(this);b._hash=this._hash.clone();return b}});t.MD5=v._createHelper(r);t.HmacMD5=v._createHmacHelper(r)})(Math); (function(){var u=CryptoJS,p=u.lib,d=p.Base,l=p.WordArray,p=u.algo,s=p.EvpKDF=d.extend({cfg:d.extend({keySize:4,hasher:p.MD5,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,r){for(var p=this.cfg,s=p.hasher.create(),b=l.create(),u=b.words,q=p.keySize,p=p.iterations;u.length>>2]&255}};d.BlockCipher=v.extend({cfg:v.cfg.extend({mode:b,padding:q}),reset:function(){v.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a, this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var n=d.CipherParams=l.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),b=(p.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;return(a?s.create([1398893684, 1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=s.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return n.create({ciphertext:a,salt:c})}},a=d.SerializableCipher=l.extend({cfg:l.extend({format:b}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var l=a.createEncryptor(c,d);b=l.finalize(b);l=l.cfg;return n.create({ciphertext:b,key:c,iv:l.iv,algorithm:a,mode:l.mode,padding:l.padding,blockSize:a.blockSize,formatter:d.format})}, decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),p=(p.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=s.random(8));a=w.create({keySize:b+c}).compute(a,d);c=s.create(a.words.slice(b),4*c);a.sigBytes=4*b;return n.create({key:a,iv:c,salt:d})}},c=d.PasswordBasedCipher=a.extend({cfg:a.cfg.extend({kdf:p}),encrypt:function(b,c,d,l){l=this.cfg.extend(l);d=l.kdf.execute(d, b.keySize,b.ivSize);l.iv=d.iv;b=a.encrypt.call(this,b,c,d.key,l);b.mixIn(d);return b},decrypt:function(b,c,d,l){l=this.cfg.extend(l);c=this._parse(c,l.format);d=l.kdf.execute(d,b.keySize,b.ivSize,c.salt);l.iv=d.iv;return a.decrypt.call(this,b,c,d.key,l)}})}(); (function(){for(var u=CryptoJS,p=u.lib.BlockCipher,d=u.algo,l=[],s=[],t=[],r=[],w=[],v=[],b=[],x=[],q=[],n=[],a=[],c=0;256>c;c++)a[c]=128>c?c<<1:c<<1^283;for(var e=0,j=0,c=0;256>c;c++){var k=j^j<<1^j<<2^j<<3^j<<4,k=k>>>8^k&255^99;l[e]=k;s[k]=e;var z=a[e],F=a[z],G=a[F],y=257*a[k]^16843008*k;t[e]=y<<24|y>>>8;r[e]=y<<16|y>>>16;w[e]=y<<8|y>>>24;v[e]=y;y=16843009*G^65537*F^257*z^16843008*e;b[k]=y<<24|y>>>8;x[k]=y<<16|y>>>16;q[k]=y<<8|y>>>24;n[k]=y;e?(e=z^a[a[a[G^z]]],j^=a[a[j]]):e=j=1}var H=[0,1,2,4,8, 16,32,64,128,27,54],d=d.AES=p.extend({_doReset:function(){for(var a=this._key,c=a.words,d=a.sigBytes/4,a=4*((this._nRounds=d+6)+1),e=this._keySchedule=[],j=0;j>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255]):(k=k<<8|k>>>24,k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255],k^=H[j/d|0]<<24);e[j]=e[j-d]^k}c=this._invKeySchedule=[];for(d=0;dd||4>=j?k:b[l[k>>>24]]^x[l[k>>>16&255]]^q[l[k>>> 8&255]]^n[l[k&255]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,t,r,w,v,l)},decryptBlock:function(a,c){var d=a[c+1];a[c+1]=a[c+3];a[c+3]=d;this._doCryptBlock(a,c,this._invKeySchedule,b,x,q,n,s);d=a[c+1];a[c+1]=a[c+3];a[c+3]=d},_doCryptBlock:function(a,b,c,d,e,j,l,f){for(var m=this._nRounds,g=a[b]^c[0],h=a[b+1]^c[1],k=a[b+2]^c[2],n=a[b+3]^c[3],p=4,r=1;r>>24]^e[h>>>16&255]^j[k>>>8&255]^l[n&255]^c[p++],s=d[h>>>24]^e[k>>>16&255]^j[n>>>8&255]^l[g&255]^c[p++],t= d[k>>>24]^e[n>>>16&255]^j[g>>>8&255]^l[h&255]^c[p++],n=d[n>>>24]^e[g>>>16&255]^j[h>>>8&255]^l[k&255]^c[p++],g=q,h=s,k=t;q=(f[g>>>24]<<24|f[h>>>16&255]<<16|f[k>>>8&255]<<8|f[n&255])^c[p++];s=(f[h>>>24]<<24|f[k>>>16&255]<<16|f[n>>>8&255]<<8|f[g&255])^c[p++];t=(f[k>>>24]<<24|f[n>>>16&255]<<16|f[g>>>8&255]<<8|f[h&255])^c[p++];n=(f[n>>>24]<<24|f[g>>>16&255]<<16|f[h>>>8&255]<<8|f[k&255])^c[p++];a[b]=q;a[b+1]=s;a[b+2]=t;a[b+3]=n},keySize:8});u.AES=p._createHelper(d)})(); var px = { uiSettings: { "Theme": "Green", "Language": "Bd", "DefaultDateFormat": "dd/mm/yy", "CurrencySymbol": "£", "Currency": "GBP", "InvoiceRequestAllowedGroups": "24,25" }, versionInfo: { "PatchId": 12, "Year": "Azolve 2015", "Version": "2015", "BuildNo": "1", "PatchNo": "001", "PatchDate": "\/Date(1427625847773+0600)\/", "PatchDetails": "Azolve Invoicing" }, appPath: '/' }; // jQuery formatCurrency plugin... see http://code.google.com/p/jquery-formatcurrency/ (function ($) { $.formatCurrency = {}; $.formatCurrency.regions = []; $.formatCurrency.regions[""] = { symbol: "$", positiveFormat: "%s%n", negativeFormat: "(%s%n)", decimalSymbol: ".", digitGroupSymbol: ",", groupDigits: true }; $.fn.formatCurrency = function (destination, settings) { if (arguments.length == 1 && typeof destination !== "string") { settings = destination; destination = false } var defaults = { name: "formatCurrency", colorize: false, region: "", global: true, roundToDecimalPlace: 2, eventOnDecimalsEntered: false }; defaults = $.extend(defaults, $.formatCurrency.regions[""]); settings = $.extend(defaults, settings); if (settings.region.length > 0) { settings = $.extend(settings, getRegionOrCulture(settings.region)) } settings.regex = generateRegex(settings); return this.each(function () { $this = $(this); var num = "0"; num = $this[$this.is("input, select, textarea") ? "val" : "html"](); if (num.search("\\(") >= 0) { num = "-" + num } if (num === "" || (num === "-" && settings.roundToDecimalPlace === -1)) { return } if (isNaN(num)) { num = num.replace(settings.regex, ""); if (num === "" || (num === "-" && settings.roundToDecimalPlace === -1)) { return } if (settings.decimalSymbol != ".") { num = num.replace(settings.decimalSymbol, ".") } if (isNaN(num)) { num = "0" } } var numParts = String(num).split("."); var isPositive = (num == Math.abs(num)); var hasDecimals = (numParts.length > 1); var decimals = (hasDecimals ? numParts[1].toString() : "0"); var originalDecimals = decimals; num = Math.abs(numParts[0]); num = isNaN(num) ? 0 : num; if (settings.roundToDecimalPlace >= 0) { decimals = parseFloat("1." + decimals); decimals = decimals.toFixed(settings.roundToDecimalPlace); if (decimals.substring(0, 1) == "2") { num = Number(num) + 1 } decimals = decimals.substring(2) } num = String(num); if (settings.groupDigits) { for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) { num = num.substring(0, num.length - (4 * i + 3)) + settings.digitGroupSymbol + num.substring(num.length - (4 * i + 3)) } } if ((hasDecimals && settings.roundToDecimalPlace == -1) || settings.roundToDecimalPlace > 0) { num += settings.decimalSymbol + decimals } var format = isPositive ? settings.positiveFormat : settings.negativeFormat; var money = format.replace(/%s/g, settings.symbol); money = money.replace(/%n/g, num); var $destination = $([]); if (!destination) { $destination = $this } else { $destination = $(destination) } $destination[$destination.is("input, select, textarea") ? "val" : "html"](money); if (hasDecimals && settings.eventOnDecimalsEntered && originalDecimals.length > settings.roundToDecimalPlace) { $destination.trigger("decimalsEntered", originalDecimals) } if (settings.colorize) { $destination.css("color", isPositive ? "black" : "red") } }) }; $.fn.toNumber = function (settings) { var defaults = $.extend({ name: "toNumber", region: "", global: true }, $.formatCurrency.regions[""]); settings = jQuery.extend(defaults, settings); if (settings.region.length > 0) { settings = $.extend(settings, getRegionOrCulture(settings.region)) } settings.regex = generateRegex(settings); return this.each(function () { var method = $(this).is("input, select, textarea") ? "val" : "html"; $(this)[method]($(this)[method]().replace("(", "(-").replace(settings.regex, "")) }) }; $.fn.asNumber = function (settings) { var defaults = $.extend({ name: "asNumber", region: "", parse: true, parseType: "Float", global: true }, $.formatCurrency.regions[""]); settings = jQuery.extend(defaults, settings); if (settings.region.length > 0) { settings = $.extend(settings, getRegionOrCulture(settings.region)) } settings.regex = generateRegex(settings); settings.parseType = validateParseType(settings.parseType); var method = $(this).is("input, select, textarea") ? "val" : "html"; var num = $(this)[method](); num = num ? num : ""; num = num.replace("(", "(-"); num = num.replace(settings.regex, ""); if (!settings.parse) { return num } if (num.length == 0) { num = "0" } if (settings.decimalSymbol != ".") { num = num.replace(settings.decimalSymbol, ".") } return window["parse" + settings.parseType](num) }; function getRegionOrCulture(region) { var regionInfo = $.formatCurrency.regions[region]; if (regionInfo) { return regionInfo } else { if (/(\w+)-(\w+)/g.test(region)) { var culture = region.replace(/(\w+)-(\w+)/g, "$1"); return $.formatCurrency.regions[culture] } } return null } function validateParseType(parseType) { switch (parseType.toLowerCase()) { case "int": return "Int"; case "float": return "Float"; default: throw "invalid parseType" } } function generateRegex(settings) { if (settings.symbol === "") { return new RegExp("[^\\d" + settings.decimalSymbol + "-]", "g") } else { var symbol = settings.symbol.replace("$", "\\$").replace(".", "\\."); return new RegExp(symbol + "|[^\\d" + settings.decimalSymbol + "-]", "g") } } })(jQuery); //IE<9 doesn't have an .indexOf() function for Array if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (elt /*, from*/) { var len = this.length >>> 0; var from = Number(arguments[1]) || 0; from = (from < 0) ? Math.ceil(from) : Math.floor(from); if (from < 0) from += len; for (; from < len; from++) { if (from in this && this[from] === elt) return from; } return -1; }; } Array.prototype.swap = function(a, b){ this[a] = this.splice(b, 1, this[a])[0]; return this; } if (!Array.prototype.find) { Array.prototype.find = function (fn /*, from*/) { var len = this.length >>> 0; var res = []; for (var i = 0; i < len; i++) { if (fn(this[i])) res.push(this[i]); } return res.length > 0 ? (res.length > 1 ? res : res[0]) : undefined; }; } (function () { var $rootPath = 'https://weblet.azolve.com/'; var $client = 'JustGoClubPlus'; var $client_api_code = 'AzolveCentral-E840D183-FE0D-4E7F-5B76-C59055D87AF2'; var autoIdSeed = 1000; var toString = Object.prototype.toString; var initQueue = []; $(function () { for (var i = 0, j = initQueue.length; i < j; i++) { initQueue[i](); } delete az.__addToInitQueue; delete initQueue; }); var htmlRegEx = /^(?:<\/?[^>]+(>|$))$/; az = { $rootPath:function(){ return $rootPath; }, $client:function(){ return $client; }, $client_api_code:function(){ return $client_api_code; }, $emptyStr:'', basePrefix: 'az', __addToInitQueue: function (fn) { initQueue.push(fn); }, version: '0.0.1', uid: function () { return autoIdSeed++; }, emptyFn: function () { }, doNothingFn: function (param) { return param; }, format: function (formatableStr, data) { if (!formatableStr) return ''; return formatableStr.replace(/\{(\$[a-zA-z.0-9]+|[a-zA-z.0-9]+)\}/g, function (matchStr, replacePropName) { if (replacePropName.indexOf('.') != -1) { var props = replacePropName.split('.'); var i = 1; var tmp = data[props[0]]; while (i < props.length) { tmp = tmp[props[i]]; i++; } return tmp || ''; } return data[replacePropName] || ''; }); }, array: { uniq: function (array) { }, remove: function (array, item) { } }, chk: { ifFunction: function (v) { return toString.call(v) === '[object Function]'; }, ifArray: function (v) { return toString.call(v) === '[object Array]'; }, ifDefined: function (v) { return typeof v !== 'undefined'; }, ifEmptyObj: function (v) { return $.isEmptyObject(v); }, ifEmpty: function (v, allowBlank) { return v === null || v === undefined || ((az.chk.ifArray(v) && !v.length)) || (!allowBlank ? v === '' : false); }, ifDate: function (v) { return toString.apply(v) === '[object Date]'; }, ifObject: function (v) { return !!v && toString.call(v) === '[object Object]'; }, ifPrimitive: function (v) { return az.chk.ifString(v) || az.chk.ifNumber(v) || az.chk.ifBoolean(v); }, ifNumber: function (v) { return typeof v === 'number' && isFinite(v); }, ifBoolean:function(v) { return typeof v === 'boolean'; }, ifString: function (v) { return typeof v === 'string'; }, ifDomEl: function (v) { return v ? !!v.tagName : false; }, ifHtmlTag:function (v) { return htmlRegEx.test(v); } }, absorb: function (obj1, obj2, skipProps) { skipProps += ','; if(az.chk.ifArray(obj1) && az.chk.ifArray(obj2)) { for(var i=0;i 1 && index + 1 <= ln - 1) array.swap(index, index + 1); return array; }, swapWithPrevious: function(array, index) { var ln = array.length; if ( ln>1 && index - 1 != -1) array.swap(index, index-1); return array; }, FocusManager: { FocusedElementId:'' } }; })(); /*Scripts/libs/Astral/Core/browser.js*/ (function () { var userAgent = navigator.userAgent.toLowerCase(); var check = function(regex) { return regex.test(userAgent); }, isStrict = document.compatMode == "CSS1Compat", version = function(is, regex) { var m; return (is && (m = regex.exec(userAgent))) ? parseFloat(m[1]) : 0; }, docMode = document.documentMode, isEdge = check(/\bedge\b/), isOpera = check( /opera/ ), isOpera10_5 = isOpera && check( /version\/10\.5/ ), isChrome = check( /\bchrome\b/ ), isWebKit = check( /webkit/ ), isSafari = !isChrome && check( /safari/ ), isSafari2 = isSafari && check( /applewebkit\/4/ ), // unique to Safari 2 isSafari3 = isSafari && check( /version\/3/ ), isSafari4 = isSafari && check( /version\/4/ ), isSafari5_0 = isSafari && check( /version\/5\.0/ ), isSafari5 = isSafari && check( /version\/5/ ), isIE= typeof document.documentMode == "number" || new Function("return/*@cc_on!@*/!1")(), //isIE = !isOpera && check( /msie/ ), isIE10 = isIE && ((check(/msie 10/) && docMode != 7 && docMode != 9) || docMode != 8 || docMode != 9 || docMode == 10), isIE9 = isIE && ((check(/msie 9/) && docMode != 7 && docMode != 9) || docMode != 8 || docMode == 9), isIE7 = isIE && ((check( /msie 7/ ) && docMode != 8 && docMode != 9) || docMode == 7), isIE8 = isIE && ((check( /msie 8/ ) && docMode != 7 && docMode != 9) || docMode == 8), isIE9 = isIE && ((check( /msie 9/ ) && docMode != 7 && docMode != 8) || docMode == 9), isIE6 = isIE && check( /msie 6/ ), isGecko = !isWebKit && check( /gecko/ ), isGecko3 = isGecko && check( /rv:1\.9/ ), isGecko4 = isGecko && check( /rv:2\.0/ ), isGecko5 = isGecko && check( /rv:5\./ ), isGecko10 = isGecko && check( /rv:10\./ ), isFF3_0 = isGecko3 && check( /rv:1\.9\.0/ ), isFF3_5 = isGecko3 && check( /rv:1\.9\.1/ ), isFF3_6 = isGecko3 && check( /rv:1\.9\.2/ ), isWindows = check( /windows|win32/ ), isMac = check( /macintosh|mac os x/ ), isLinux = check( /linux/ ), chromeVersion = version(true, /\bchrome\/(\d+\.\d+)/ ), firefoxVersion = version(true, /\bfirefox\/(\d+\.\d+)/ ), ieVersion = version(isIE, /msie (\d+\.\d+)/ ), operaVersion = version(isOpera, /version\/(\d+\.\d+)/ ), safariVersion = version(isSafari, /version\/(\d+\.\d+)/ ), webKitVersion = version(isWebKit, /webkit\/(\d+\.\d+)/ ), isSecure = /^https/i .test(window.location.protocol); az.browser = {}; az.copy(az.browser, { isStrict: isStrict, isWindows: isWindows, isLinux: isLinux, isSecure: isSecure, isOpera: isOpera, operaVersion: operaVersion, isOpera10_5: isOpera10_5, isMac: isMac, isWebKit: isWebKit, webKitVersion: webKitVersion, isGecko: isGecko, isGecko3: isGecko3, isGecko4: isGecko4, isGecko5: isGecko5, isGecko10: isGecko10, isChrome: isChrome, chromeVersion: chromeVersion, isSafari: isSafari, isSafari2: isSafari2, isSafari3: isSafari3, isSafari4: isSafari4, isSafari5_0: isSafari5_0, isSafari5: isSafari5, safariVersion: safariVersion, isFF3_0: isFF3_0, isFF3_5: isFF3_5, isFF3_6: isFF3_6, firefoxVersion: firefoxVersion, isIE: isIE, isIE6: isIE6, isIE7: isIE7, isIE8: isIE8, isIE9: isIE9, isIE10: isIE10, ieVersion: ieVersion, isEdge: isEdge }); })(); /*Scripts/libs/Astral/Core/class.js*/ (function () { var classes = {}; var classeAlias = {}; var classMeta = {}; var staticClasses = {}; var features = {}; var fnTest = function (fn) { return fn.toString().indexOf('this.$super') != -1; }; var Base = function () { }; var createNamespace = function (className, type) { var accesor = className.split('.'); if (accesor.length == 1) { if (az.hasOwnProperty(className)) throw new Error('Unable to create namespace for ' + className + ' its already Occupied'); az[className] = type; return; } var item = az[accesor[0]] = az[accesor[0]] || {}; for (var i = 1; i < accesor.length - 1; i++) { item = item[accesor[i]] = item[accesor[i]] || {}; } var propName = accesor[accesor.length - 1]; if (item && item.hasOwnProperty(propName) && (item[propName]) == 'function') throw new Error('Invalid namespace, its already been occupied'); item[propName] = type; }; var initMixins = function (instance, name) { var mixins = name ? name.split(',') : classMeta[instance.$class].includes; if (mixins) { for (var i = 0, j = mixins.length; i < j; i++) if (features[mixins[i]].init) features[mixins[i]].init.call(instance); } }; var destroyMixins = function (instance, name) { var mixins = name ? name.split(',') : classMeta[instance.$class].includes; if (mixins) { for (var i = 0, j = mixins.length; i < j; i++) if (features[mixins[i]].destroy) features[mixins[i]].destroy.call(instance); } }; az.copy(az, { defineClass: function (className, config, afterDefine) { if (arguments.length < 2) throw new Error("az.defineClass requires 2 parameters"); var baseClassName = config.$extends, mixins = config.$includes, statics = config.$static, override = config.$override, alias = config.$alias; delete config.$extends; delete config.$includes; delete config.$statics; var baseClass = (baseClassName ? classes[baseClassName] : Base); if (!baseClass) throw new Error(baseClassName + " not loaded"); baseClass.prototype.__initializing = true; var proto = new baseClass(); delete baseClass.prototype.__initializing; if (mixins) { if (typeof (mixins) == 'string') mixins = mixins.split(','); for (var i = 0; i < mixins.length; i++) { if (features.hasOwnProperty(mixins[i])) { az.copy(proto, features[mixins[i]], 'init,destroy'); } } } if (baseClassName) { var baseMixins = classMeta[baseClassName].includes; if (baseMixins) { if (mixins) { for (var j = 0; j < baseMixins.length; j++) { mixins.splice(0, 0, baseMixins[j]); } } else { mixins = baseMixins; } } } for (var i in config) { if (typeof config[i] == "function" && fnTest(config[i])) { if (i == '$super') throw '$super method name is not allowed'; proto[i] = (function (superClassName, method, fn) { return function () { var tmp = this.$super; this.$super = classes[superClassName].prototype[method]; var ret = fn.apply(this, arguments); this.$super = tmp; return ret; }; })(baseClassName, i, config[i]); } else { if (az.chk.ifObject(config[i])) { if (!proto.hasOwnProperty(i)) proto[i] = {}; az.absorb(proto[i], config[i]); } else if (az.chk.ifArray(config[i])) { if (!proto.hasOwnProperty(i)) proto[i] = []; az.absorb(proto[i], config[i]); } else { proto[i] = config[i]; } } } if (override) az.copy(proto, override); proto.__props = {}; for (var i in proto) { if (!proto.hasOwnProperty(i) || az.chk.ifFunction(proto[i]) || i == '__props') continue; proto.__props[i] = proto[i]; delete proto[i]; } if (!az.chk.ifEmptyObj(proto.__props)) proto.__props = JSON.stringify(proto.__props); else delete proto.__props; proto.$class = className; classes[className] = function () { if (this.__props) az.copy(this, JSON.parse(this.__props)); this.__props = undefined; delete this.__props; if (!this.__initializing && this.init) this.init.apply(this, arguments); if (!this.__initializing && this.$autoInitMixin != false) { initMixins(this); delete this.$autoInitMixin; } }; createNamespace(className, classes[className]); classes[className].prototype = proto; classes[className].prototype.constructor = classes[className]; classMeta[className] = { name: className, _extends: baseClassName, includes: mixins }; az.copy(classes[className], statics); if (alias) { alias = alias.split(','); i = alias.length; while (i--) { if (classeAlias.hasOwnProperty(alias[i])) throw alias[i] + " alias is already used for " + classeAlias[alias[i]]; classeAlias[alias[i]] = className; } } if (afterDefine && az.chk.ifFunction(afterDefine)) { afterDefine(classes[className], classMeta[className]); } return classes[className]; }, defineSingleton: function (name, config) { createNamespace(name, config); staticClasses[name] = config; }, defineMixin: function (mixinName, config) { if (!features.hasOwnProperty(name)) features[mixinName] = config; }, initMixins: function (instance, mixins) { initMixins(instance, mixins); }, initAllMixinsExcept: function (instance, mixins) { var allmixins = classMeta[instance.$class].includes; var excludeList = mixins.split(','); var selectedMixin = []; for (var i = 0; i < allmixins.length; i++) { var found = false; for (var j = 0; j < excludeList.length; j++) if (excludeList[j] == allmixins[i]) { found = true; break; } if (!found) selectedMixin.push(allmixins[i]); } initMixins(instance, selectedMixin.join(',')); }, destroyMixins: function (instance, mixins) { destroyMixins(instance, mixins); }, isSubclassOf: function (name, parent) { var superClass = az.getParentOf(name); while (superClass != parent && superClass) { superClass = az.getParentOf(superClass); } if (!superClass) return false; return true; }, getParentOf: function (name) { if (az.chk.ifString(name)) if (classMeta.hasOwnProperty(name)) return classMeta[name]._extends; if (name instanceof Base) return classMeta[name.$class]._extends; }, existsClass: function (name) { return classes.hasOwnProperty(name); }, $class: function (name) { if (!classes.hasOwnProperty(name) && !classeAlias.hasOwnProperty(name)) return null; return classes.hasOwnProperty(name) ? classes[name] : classes[classeAlias[name]]; }, create: function (name, config) { if (!classes.hasOwnProperty(name) && !classeAlias.hasOwnProperty(name)) return null; return classes.hasOwnProperty(name) ? new (classes[name])(config) : new (classes[classeAlias[name]])(config); }, instanceOf: function (instance, name) { if (az.chk.ifString(name) && !classes.hasOwnProperty(name)) return false; return instance instanceof classes[name]; } }); })(); /*Scripts/libs/Astral/Core/componentMgr.js*/ (function () { var componentInstances = {}; var compIdPrefix = 'az-com-'; var compNameRegistry = {}; var compClassRegistry = {}; function getChildsOf(items) { var childs = []; for (var i = 0; i < items.length; i++) { childs.push.apply(childs, filters.byOwner(items[i])); } return childs; } function readBetween(start, end, str) { var depth = -1; var expression = ''; for (var i = 0; i < str.length; i++) { if (str[i] == end && depth == 0) break; if (str[i] == start) depth++; if (str[i] == end) depth--; if (depth >= 0) expression += str[i]; } return expression.substr(1); } function isChildOf(item, parent) { var owner = item.owner; while (owner && owner != parent) { owner = owner.owner; } if (owner == parent) return true; return false; } var filters = { createExpressionFn: function (str) { var expression = readBetween('[', ']', str); if (az.browser.isSafari) return new Function("ctx", " with(ctx){ try{ return " + expression + "} catch(e){ if(e.message.indexOf('find variable')>-1){return false;} else throw e } }"); else if (az.browser.isIE || az.browser.isEdge) return new Function("ctx", " with(ctx){ try{ return " + expression + "} catch(e){ if(e.message.indexOf('undefined')>-1){return false;} else throw e } }"); else return new Function("ctx", " with(ctx){ try{ return " + expression + "} catch(e){ if(e.message.indexOf('not defined')>-1){return false;} else throw e } }"); }, byOwner: function (owner, filterItems) { var items = []; if (filterItems) { for (var i = 0; i < filterItems.length; i++) { if (isChildOf(filterItems[i], owner)) items.push(filterItems[i]); } } else for (var i in componentInstances) { if (componentInstances[i].owner == owner) items.push(componentInstances[i]); } return items; }, byName: function (name, items, expressionFn) { if (!items && !expressionFn) az.getCmpByName(name); var itemsToFilter = items ? items : az.getCmpByName(name); var filteredItems = []; for (var i = 0; i < itemsToFilter.length; i++) { if (itemsToFilter[i].name == name) { if (expressionFn) { if (expressionFn(itemsToFilter[i])) filteredItems.push(itemsToFilter[i]); } else filteredItems.push(itemsToFilter[i]); } } return filteredItems; }, byClass: function (className, items, expressionFn) { if (!items && !expressionFn) return compClassRegistry[className]; var itemsToFilter = items ? items : compClassRegistry[className]; var filteredItems = []; for (var i = 0; i < itemsToFilter.length; i++) { if (itemsToFilter[i].$class == className) { if (expressionFn) { if (expressionFn(itemsToFilter[i])) filteredItems.push(itemsToFilter[i]); } else filteredItems.push(itemsToFilter[i]); } } return filteredItems; } }; az.copy(az, { register: function (instance) { instance.cid = compIdPrefix + az.uid(); componentInstances[instance.cid] = instance; if (az.chk.ifDefined(instance.name)) { if (!compNameRegistry.hasOwnProperty(instance.name)) { compNameRegistry[instance.name] = []; } compNameRegistry[instance.name].push(instance.cid); } if (!compClassRegistry.hasOwnProperty(instance.$class)) { compClassRegistry[instance.$class] = []; } compClassRegistry[instance.$class].push(instance); }, findCmp: function (query, owner) { var tockens = query.split('>'); //todo use regex to split var items; for (var i = 0; i < tockens.length; i++) { if (items && items.length > 0) { items = getChildsOf(items); } var expressionFn = undefined; if (tockens[i].indexOf('[') != -1) { expressionFn = filters.createExpressionFn(tockens[i]); } if (tockens[i].trim()[0] == '$') { var className; if (tockens[i].indexOf('[') != -1) className = tockens[i].substr(tockens[i].indexOf('$') + 1, tockens[i].indexOf('[') - 1).trim(); else className = tockens[i].substr(1).trim(); items = filters.byClass(className, items, expressionFn); continue; } items = filters.byName(tockens[i].trim(), items, expressionFn); if (owner && i == 0) { items = filters.byOwner(owner, items); } } return items; }, getCmpByName: function (name) { if (compNameRegistry.hasOwnProperty(name)) { var items = []; for (var i = 0; i < compNameRegistry[name].length; i++) items.push(componentInstances[compNameRegistry[name][i]]); return items; } }, unregister: function (instance) { delete componentInstances[instance.cid]; if (az.chk.ifDefined(instance.name)) { if (compNameRegistry.hasOwnProperty(instance.name)) { for (var i = 0; i < compNameRegistry[instance.name].length; i++) { if (compNameRegistry[instance.name][i] == instance.cid) { compNameRegistry[instance.name].splice(i, 1); if (compNameRegistry[instance.name].length == 0) delete compNameRegistry[instance.name]; break; } } } } for (var i = 0; i < compClassRegistry[instance.$class].length; i++) { if (compClassRegistry[instance.$class][i].cid == instance.cid) { compClassRegistry[instance.$class].splice(i, 1); break; } } }, getCmp: function (id) { return componentInstances[id]; }, getCmpByElId: function (elementId) { return az.getCmp(elementId.match(/az-com-\d+/)[0]); } }); })(); /*Scripts/libs/Astral/Core/eventMgr.js*/ (function () { var domEvtsRe = /click|dblclick|mousedown|mouseenter|mouseleave|mousemove|mouseover|mouseout|mouseup|keydown|keypress|keyup|load|unload|resize|scroll|mousewheel|blur|change|focus|reset|select|submit|focusin|focusout/i; var deligatableEvtRe = /click|dblclick|mousedown|mouseover|mouseup|keydown|keypress|keyup|resize|change|select/i; var globalChannel = {}; var domChannels = {}; var customChannels = {}; var interceptors = {}; var nonDeligatedChannel = {}; var elIdToCid = {}; var btnMap = az.browser.isIE ? { 1: 0, 4: 1, 2: 2} : { 0: 0, 1: 1, 2: 2 }; var clickRe = /(dbl)?click/; var safariKeys = { 3: 13, // enter 63234: 37, // left 63235: 39, // right 63232: 38, // up 63233: 40, // down 63276: 33, // page up 63277: 34, // page down 63272: 46, // delete 63273: 36, // home 63275: 35 // end }; var keyEnum = { BACKSPACE: 8, TAB: 9, NUM_CENTER: 12, ENTER: 13, RETURN: 13, SHIFT: 16, CTRL: 17, ALT: 18, PAUSE: 19, CAPS_LOCK: 20, ESC: 27, SPACE: 32, PAGE_UP: 33, PAGE_DOWN: 34, END: 35, HOME: 36, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, PRINT_SCREEN: 44, INSERT: 45, DELETE: 46, ZERO: 48, ONE: 49, TWO: 50, THREE: 51, FOUR: 52, FIVE: 53, SIX: 54, SEVEN: 55, EIGHT: 56, NINE: 57, CONTEXT_MENU: 93, NUM_ZERO: 96, NUM_ONE: 97, NUM_TWO: 98, NUM_THREE: 99, NUM_FOUR: 100, NUM_FIVE: 101, NUM_SIX: 102, NUM_SEVEN: 103, NUM_EIGHT: 104, NUM_NINE: 105, NUM_MULTIPLY: 106, NUM_PLUS: 107, NUM_MINUS: 109, NUM_PERIOD: 110, NUM_DIVISION: 111, F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118, F8: 119, F9: 120, F10: 121, F11: 122, F12: 123 }; function dispatchGlobalEventHandlers(event) { var handlers = globalChannel[event.type]; if (handlers && handlers.length > 0) { var i = 0, j = handlers.length; if (j > 0) setTimeout(function () { for (; i < j; i++) { handlers[i].fn.apply(handlers[i].scope || null, event); } }, 10); } } function dispatchCustomEventHandler(cid, event, args) { var handlers = customChannels[cid][event]; var i = 0, j = handlers.length; if (j > 0) setTimeout(function () { for (; i < j; i++) { handlers[i].fn.apply(handlers[i].scope || null, args); } }, 10); } function dispatchDomEventHandler(elId, browserEvent) { if (!elIdToCid.hasOwnProperty(elId)) return true; var event = browserEvent.type; var cid = elIdToCid[elId]; var hasInterceptor = interceptors.hasOwnProperty(cid) && interceptors[cid].hasOwnProperty(elId) && interceptors[cid][elId].hasOwnProperty(event); if (hasInterceptor) { var interceptorHandler = interceptors[cid][elId][event]; if (!interceptorHandler.fn.call(interceptorHandler.scope || null, new az.Event(elId, browserEvent))) { if (browserEvent.preventDefault) browserEvent.preventDefault(); return false; } } if (!domChannels.hasOwnProperty(cid)) return true; if (!domChannels[cid].hasOwnProperty(elId)) return true; if (!domChannels[cid][elId].hasOwnProperty(event)) return true; var handlers = domChannels[cid][elId][event]; var i = 0, j = handlers.length; if (j > 0) setTimeout(function () { for (; i < j; i++) { handlers[i].fn.call(handlers[i].scope || null, az.getCmp(cid), new az.Event(elId, browserEvent)); } // todo remove one time handlers }, 10); return true; } az.__addToInitQueue(function () { var events = 'click|dblclick|mousedown|mouseover|mouseup|keydown|keypress|keyup|resize|change|select'.split('|'); var bodyEl = $(document), i = events.length; while (i--) { bodyEl.on(events[i], function (event) { var el = event.target; var idAttr = $(el).attr('id'); while (el && (idAttr == undefined || idAttr[0] == '!')) { el = el.parentNode; idAttr = $(el).attr('id'); } dispatchGlobalEventHandlers(event); return dispatchDomEventHandler(idAttr || az.FocusManager.FocusedElementId, event); }); }; }); az.copy(az, { eventUtil: { key: keyEnum, getPageXY: function (event) { var x = event.pageX, y = event.pageY, docEl = document.documentElement, body = document.body; // pageX/pageY not available (undefined, not null), use clientX/clientY instead if (!x && x !== 0) { x = event.clientX + (docEl && docEl.scrollLeft || body && body.scrollLeft || 0) - (docEl && docEl.clientLeft || body && body.clientLeft || 0); y = event.clientY + (docEl && docEl.scrollTop || body && body.scrollTop || 0) - (docEl && docEl.clientTop || body && body.clientTop || 0); } if (isNaN(x)) return null; return [x, y]; }, normalizeKey: function (key) { return az.browser.isWebKit ? (safariKeys[key] || key) : key; }, normalizeButton: function (btnCode) { return btnMap[btnCode]; }, isClickEvent: function (evetType) { return clickRe.test(evetType); } }, destoryEventHandlers: function (cid) { delete customChannels[cid]; delete domChannels[cid]; delete nonDeligatedChannel[cid]; delete interceptors[cid]; }, interceptEvent: function (cid, domElementId, event, handler, scope) { if (!interceptors.hasOwnProperty(cid)) interceptors[cid] = {}; if (!interceptors[cid].hasOwnProperty(domElementId)) interceptors[cid][domElementId] = {}; if (!interceptors[cid][domElementId].hasOwnProperty(event)) interceptors[cid][domElementId][event] = {}; interceptors[cid][domElementId][event] = { fn: handler, scope: scope }; }, suspendEvents: function (cid, suspend) { if (customChannels.hasOwnProperty(cid)) customChannels[cid].suspend = suspend; if (domChannels.hasOwnProperty(cid)) domChannels[cid].suspend = suspend; if (nonDeligatedChannel.hasOwnProperty(cid)) nonDeligatedChannel[cid].suspend = suspend; }, isListening: function (cid, event, fn, scope) { if (!az.hasListener(cid, event)) return false; var handlers = customChannels[cid][event]; for (var i = 0; i < handlers.length; i++) { if (handlers[i].fn == fn && handlers[i].scope == scope) return true; } return false; }, isDelegatedDomListening: function (cid, domElementId, event, fn, scope) { if (!az.hasDeligatedDomListener(cid, domElementId, event)) return false; var handlers = domChannels[cid][domElementId][event]; for (var i = 0; i < handlers.length; i++) { if (handlers[i].fn == fn && handlers[i].scope == scope) return true; } return false; }, isNonDeligatedDomListening: function (cid, domElementId, event, fn, scope) { if (!az.hasNonDeligatedDomListener(cid, domElementId, event)) return false; var handlers = nonDeligatedChannel[cid][domElementId][event]; for (var i = 0; i < handlers.length; i++) { if (handlers[i].fn == fn && handlers[i].scope == scope) return true; } return false; }, hasDeligatedDomListener: function (cid, domElementId, event) { if (!domChannels.hasOwnProperty(cid)) return false; if (!domChannels[cid].hasOwnProperty(domElementId)) return false; ; if (!domChannels[cid][domElementId].hasOwnProperty(event)) return false; return true; }, hasNonDeligatedDomListener: function (cid, domElementId, event) { if (!nonDeligatedChannel.hasOwnProperty(cid)) return false; if (!nonDeligatedChannel[cid].hasOwnProperty(domElementId)) return false; if (!nonDeligatedChannel[cid][domElementId].hasOwnProperty(event)) return false; return true; }, hasListener: function (cid, event) { if (!customChannels.hasOwnProperty(cid)) return false; if (!customChannels[cid].hasOwnProperty(event)) return false; return customChannels[cid][event].length > 0; }, forwardEvent: function (elementId, event) { var el = $('#' + elementId); var idAttr = el.attr('id'); while (idAttr == undefined) { el = el.parentNode; idAttr = $(el).attr('id'); } return dispatchDomEventHandler(idAttr, event); }, fireEvent: function (cid, event, args) { if (az.hasListener(cid, event)) dispatchCustomEventHandler(cid, event, args); }, addListener: function (cid, event, handler, scope) { if (!customChannels.hasOwnProperty(cid)) customChannels[cid] = {}; if (!customChannels[cid].hasOwnProperty(event)) customChannels[cid][event] = []; if (!az.isListening(cid, event, handler, scope)) customChannels[cid][event].push({ fn: handler, scope: scope }); }, removeListener: function (cid, event, handler, scope) { if (!customChannels.hasOwnProperty(cid)) return null; if (!customChannels[cid].hasOwnProperty(event)) return null; var handlers = customChannels[cid][event]; var i = handlers.length; while (i--) { if (handlers[i].fn == handler && handlers[i].scope == scope) { return handlers.splice(i, 1); } } }, addGloablEventHandler: function (event, handler, scope) { if (!globalChannel.hasOwnProperty(event)) { globalChannel[event] = []; } globalChannel[event].push({ fn: handler, scope: scope }); }, removeGloablEventHandler: function (event, handler, scope) { if (!globalChannel.hasOwnProperty(event)) return null; var handlers = globalChannel[event]; var i = handlers.length; while (i--) { if (handlers[i].fn == handler && handlers[i].scope == scope) { return handlers.splice(i, 1); } } }, addDomEventHandlers: function (cid, domElementId, event, handler, scope) { if (!domEvtsRe.test(event)) return; if (deligatableEvtRe.test(event)) { if (az.isDelegatedDomListening(cid, domElementId, event, handler, scope)) return; if (!domChannels.hasOwnProperty(cid)) domChannels[cid] = { suspend: false }; if (!domChannels[cid].hasOwnProperty(domElementId)) domChannels[cid][domElementId] = {}; if (!domChannels[cid][domElementId].hasOwnProperty(event)) domChannels[cid][domElementId][event] = []; domChannels[cid][domElementId][event].push({ fn: handler, scope: scope }); } else { if (!nonDeligatedChannel.hasOwnProperty(cid)) nonDeligatedChannel[cid] = { suspend: false }; if (!nonDeligatedChannel[cid].hasOwnProperty(domElementId)) nonDeligatedChannel[cid][domElementId] = {}; if (!nonDeligatedChannel[cid][domElementId].hasOwnProperty(event)) nonDeligatedChannel[cid][domElementId][event] = []; if (az.isNonDeligatedDomListening(cid, domElementId, event, handler, scope)) { var handlers = nonDeligatedChannel[cid][domElementId][event]; for (var i = 0; i < handler.length; i++) { if (handlers[i].fn == handler && handlers[i].scope == scope) { $('#' + domElementId).off(event, handlers[i].newFn); $('#' + domElementId).on(event, handlers[i].newFn); break; } } } else { var handlerCfg = { fn: handler, scope: scope, newFn: (function (id) { return function (evt) { if (!nonDeligatedChannel[id].suspend) return handler.call(scope || null, new az.Event(domElementId, evt)); }; })(cid) }; nonDeligatedChannel[cid][domElementId][event].push(handlerCfg); $('#' + domElementId).on(event, handlerCfg.newFn); } } elIdToCid[domElementId] = cid; }, removeAllDomEventHandler: function (cid, domElementId) { if (domChannels.hasOwnProperty(cid) && domChannels[cid].hasOwnProperty(domElementId)) { delete domChannels[cid][domElementId]; } if (nonDeligatedChannel.hasOwnProperty(cid) && nonDeligatedChannel[cid].hasOwnProperty(domElementId)) { delete nonDeligatedChannel[cid][domElementId]; $('#' + domElementId).off(); } delete elIdToCid[domElementId]; }, removeDomEventHandler: function (cid, domElementId, event, handler, scope) { var handlers, i, deletedHandler = null, removeDomDirect = false; if (deligatableEvtRe.test(event)) { if (!domChannels.hasOwnProperty(cid)) return null; if (!domChannels[cid].hasOwnProperty(domElementId)) return null; if (!domChannels[cid][domElementId].hasOwnProperty(event)) return null; handlers = domChannels[cid][domElementId][event]; } else { if (!nonDeligatedChannel[cid].hasOwnProperty(domElementId)) return null; if (!nonDeligatedChannel[cid][domElementId].hasOwnProperty(event)) return null; handlers = nonDeligatedChannel[cid][domElementId][event]; removeDomDirect = true; } i = handlers.length; while (i--) { if (handlers[i].fn == handler && handlers[i].scope == scope) { deletedHandler = handlers.splice(i, 1); break; } } if (removeDomDirect && deletedHandler.newFn) $('#' + domElementId).off(event, deletedHandler.newFn); return deletedHandler; } }); })(); /*Scripts/libs/Astral/Core/Event.js*/ az.defineClass('Event', { init: function (elementId, event) { this.elementId = elementId; var button, options; this.browserEvent = event; // normalize buttons button = event.button ? az.eventUtil.normalizeButton(event.button) : (event.which ? event.which - 1 : -1); if (az.eventUtil.isClickEvent(event.type) && button == -1) { button = 0; } options = { type: event.type, button: button, shiftKey: event.shiftKey, // mac metaKey behaves like ctrlKey ctrlKey: event.ctrlKey || event.metaKey || false, altKey: event.altKey, // in getKey these will be normalized for the mac keyCode: az.eventUtil.normalizeKey(event.keyCode), charCode: event.charCode, xy: az.eventUtil.getPageXY(event) }; az.copy(this, options); }, getKey: function () { return this.keyCode || this.charCode; }, getCharCode: function () { return this.charCode || this.keyCode; }, stopPropagation: function () { this.browserEvent.stopPropagation(); }, stopEvent: function () { this.browserEvent.stopPropagation(); this.browserEvent.preventDefault(); return false; }, preventDefault: function () { this.browserEvent.preventDefault(); return false; }, hasModifier: function () { return this.ctrlKey || this.altKey || this.shiftKey || this.metaKey; }, ifNavKeyPress: function () { var k = this.keyCode, keyEnum = az.eventUtil.key; return (k >= 33 && k <= 40) || k == keyEnum.RETURN || k == keyEnum.TAB || k == keyEnum.ESC; }, ifSpecialKey: function () { var k = this.keyCode, keyEnum = az.eventUtil.key; return (this.type == 'keypress' && this.ctrlKey) || this.ifNavKeyPress() || (k == keyEnum.BACKSPACE) || // Backspace (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock (k >= 44 && k <= 46); // Print Screen, Insert, Delete } }); /*Scripts/libs/Astral/Core/date.js*/ (function () { az.date = {}; az.copy(az.date, { /* Standard date formats. */ ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601) COOKIE: "D, dd M yy", ISO_8601: "yy-mm-dd", RFC_822: "D, d M y", RFC_850: "DD, dd-M-y", RFC_1036: "D, d M y", RFC_1123: "D, d M yy", RFC_2822: "D, d M yy", RSS: "D, d M y", // RFC 822 TICKS: "!", TIMESTAMP: "@", W3C: "yy-mm-dd", // ISO 8601 _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) + Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000), monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], // Names of months for drop-down and formatting monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], // Column headings for days starting at Sunday shortYearCutoff: "+10", // Short year values < this are in the current century, /* Format a date object into a string value. * The format can be combinations of the following: * d - day of month (no leading zero) * dd - day of month (two digit) * o - day of year (no leading zeros) * oo - day of year (three digit) * D - day name short * DD - day name long * m - month of year (no leading zero) * mm - month of year (two digit) * M - month name short * MM - month name long * y - year (two digit) * yy - year (four digit) * @ - Unix timestamp (ms since 01/01/1970) * ! - Windows ticks (100ns since 01/01/0001) * "..." - literal text * '' - single quote * * @param format string - the desired format of the date * @param date Date - the date value to format * @param settings Object - attributes include: * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) * dayNames string[7] - names of the days from Sunday (optional) * monthNamesShort string[12] - abbreviated names of the months (optional) * monthNames string[12] - names of the months (optional) * @return string - the date in the above format */ formatDate: function (format, date) { if (!date || !(date instanceof Date)) { return ""; } var iFormat, // Check whether a format character is doubled lookAhead = function (match) { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); if (matches) { iFormat++; } return matches; }, // Format a number, with leading zero if necessary formatNumber = function (match, value, len) { var num = "" + value; if (lookAhead(match)) { while (num.length < len) { num = "0" + num; } } return num; }, // Format a name, short or long as requested formatName = function (match, value, shortNames, longNames) { return (lookAhead(match) ? longNames[value] : shortNames[value]); }, output = "", literal = false; if (date) { for (iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) === "'" && !lookAhead("'")) { literal = false; } else { output += format.charAt(iFormat); } } else { switch (format.charAt(iFormat)) { case "d": output += formatNumber("d", date.getDate(), 2); break; case "D": output += formatName("D", date.getDay(), this.dayNamesShort, this.dayNames); break; case "o": output += formatNumber("o", Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3); break; case "m": output += formatNumber("m", date.getMonth() + 1, 2); break; case "M": output += formatName("M", date.getMonth(), this.monthNamesShort, this.monthNames); break; case "y": output += (lookAhead("y") ? date.getFullYear() : (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100); break; case "@": output += date.getTime(); break; case "!": output += date.getTime() * 10000 + this._ticksTo1970; break; case "'": if (lookAhead("'")) { output += "'"; } else { literal = true; } break; default: output += format.charAt(iFormat); } } } } return output; }, /* Parse a string value into a date object. * See formatDate below for the possible formats. * * @param format string - the expected format of the date * @param value string - the date in the above format * @param settings Object - attributes include: * shortYearCutoff number - the cutoff year for determining the century (optional) * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional) * dayNames string[7] - names of the days from Sunday (optional) * monthNamesShort string[12] - abbreviated names of the months (optional) * monthNames string[12] - names of the months (optional) * @return Date - the extracted date value or null if value is blank */ parseDate: function (format, value) { if (format == null || value == null) { throw "Invalid arguments"; } value = (typeof value === "object" ? value.toString() : value + ""); if (value === "") { return null; } var shortYearCutoffTemp = this.shortYearCutoff; var shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp : new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)); var iFormat, dim, extra, iValue = 0, year = -1, month = -1, day = -1, doy = -1, literal = false, date, // Check whether a format character is doubled lookAhead = function (match) { var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match); if (matches) { iFormat++; } return matches; }, // Extract a number from the string value getNumber = function (match) { var isDoubled = lookAhead(match), size = (match === "@" ? 14 : (match === "!" ? 20 : (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))), digits = new RegExp("^\\d{1," + size + "}"), num = value.substring(iValue).match(digits); if (!num) { throw "Missing number at position " + iValue; } iValue += num[0].length; return parseInt(num[0], 10); }, // Extract a name from the string value and convert to an index getName = function (match, shortNames, longNames) { var index = -1, names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) { return [[k, v]]; }).sort(function (a, b) { return -(a[1].length - b[1].length); }); $.each(names, function (i, pair) { var name = pair[1]; if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) { index = pair[0]; iValue += name.length; return false; } }); if (index !== -1) { return index + 1; } else { throw "Unknown name at position " + iValue; } }, // Confirm that a literal character matches the string value checkLiteral = function () { if (value.charAt(iValue) !== format.charAt(iFormat)) { throw "Unexpected literal at position " + iValue; } iValue++; }; for (iFormat = 0; iFormat < format.length; iFormat++) { if (literal) { if (format.charAt(iFormat) === "'" && !lookAhead("'")) { literal = false; } else { checkLiteral(); } } else { switch (format.charAt(iFormat)) { case "d": day = getNumber("d"); break; case "D": getName("D", this.dayNamesShort, this.dayNames); break; case "o": doy = getNumber("o"); break; case "m": month = getNumber("m"); break; case "M": month = getName("M", this.monthNamesShort, this.monthNames); break; case "y": year = getNumber("y"); break; case "@": date = new Date(getNumber("@")); year = date.getFullYear(); month = date.getMonth() + 1; day = date.getDate(); break; case "!": date = new Date((getNumber("!") - this._ticksTo1970) / 10000); year = date.getFullYear(); month = date.getMonth() + 1; day = date.getDate(); break; case "'": if (lookAhead("'")) { checkLiteral(); } else { literal = true; } break; default: checkLiteral(); } } } if (iValue < value.length) { extra = value.substr(iValue); if (!/^\s+/.test(extra)) { throw "Extra/unparsed characters found in date: " + extra; } } if (year === -1) { year = new Date().getFullYear(); } else if (year < 100) { year += new Date().getFullYear() - new Date().getFullYear() % 100 + (year <= shortYearCutoff ? 0 : -100); } if (doy > -1) { month = 1; day = doy; do { dim = this.getDaysInMonth(year, month - 1); if (day <= dim) { break; } month++; day -= dim; } while (true); } date = this.daylightSavingAdjust(new Date(year, month - 1, day)); if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) { throw "Invalid date"; // E.g. 31/02/00 } // date.setMinutes(date.getTimezoneOffset()*-1); return date; }, /* Find the number of days in a given month. */ getDaysInMonth: function (year, month) { return 32 - this.daylightSavingAdjust(new Date(year, month, 32)).getDate(); }, /* Handle switch to/from daylight saving. * Hours may be non-zero on daylight saving cut-over: * > 12 when midnight changeover, but then cannot generate * midnight datetime, so jump to 1AM, otherwise reset. * @param date (Date) the date to check * @return (Date) the corrected date */ daylightSavingAdjust: function (date) { if (!date) { return null; } date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0); return date; }, /* A date may be specified as an exact value or a relative one. */ determineDate: function (date, defaultDate) { var me = this; var offsetNumeric = function (offset) { var date = new Date(); date.setDate(date.getDate() + offset); return date; }, offsetString = function (offset) { try { return az.date.parseDate(me.dateFormat, offset); } catch (e) { // Ignore } var date = (offset.toLowerCase().match(/^c/) ? me._getDate() : null) || new Date(), year = date.getFullYear(), month = date.getMonth(), day = date.getDate(), pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, matches = pattern.exec(offset); while (matches) { switch (matches[2] || "d") { case "d": case "D": day += parseInt(matches[1], 10); break; case "w": case "W": day += parseInt(matches[1], 10) * 7; break; case "m": case "M": month += parseInt(matches[1], 10); day = Math.min(day, az.date.getDaysInMonth(year, month)); break; case "y": case "Y": year += parseInt(matches[1], 10); day = Math.min(day,az.date.getDaysInMonth(year, month)); break; } matches = pattern.exec(offset); } return new Date(year, month, day); }, newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) : (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime())))); newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate); if (newDate) { newDate.setHours(0); newDate.setMinutes(0); newDate.setSeconds(0); newDate.setMilliseconds(0); } return az.date.daylightSavingAdjust(newDate); } }); })(); /*Scripts/libs/Astral/Core/template.js*/ (function () { function skipSpaces(str, fromIndex) { while (str.charAt(fromIndex) == ' ' && fromIndex < str.length) fromIndex++; return fromIndex; } function isChar(str, index) { var charCode = str.charCodeAt(index); return (charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123); } function readWord(str, fromIndex) { var word = ''; fromIndex = skipSpaces(str, fromIndex); while (str.charAt(fromIndex) != ' ' && isChar(str, fromIndex) && fromIndex < str.length) { word += str.charAt(fromIndex); fromIndex++; } return word; } function readBlock(str, index, blockStart, blockEnd) { var blockStr = ''; var i = index + 2; var blockDepth = 0; while (i < str.length) { if (str.charAt(i) == blockEnd && blockDepth == 0) break; if (str.charAt(i) == blockStart) blockDepth++; if (str.charAt(i) == blockEnd) blockDepth--; blockStr += str.charAt(i); i++; } return { txt: blockStr, next: i + 1 }; } function readUpto(str, index, uptoChar) { var tmp = ''; while (str.charAt(index) != uptoChar && index < str.length) if (str.charAt(index) != '') tmp += str.charAt(index++); return { txt: tmp, next: index + 1 }; } function readStatement(str, index) { var stmt = readWord(str, index + 1), data; if (stmt == '') { var d = readBlock(str, index, '{', '}'); return { name: 'block', type: 'block', data: d, end: '' }; } if (stmt == 'case' || stmt == 'default') { data = readUpto(str, index + 1, '{'); return { name: 'case', data: data, end: '' }; } if (stmt != 'for') { var i = index + 1; while (!(str.charAt(i) == ';' || str.charAt(i) == '{') && i < str.length) i++; if (str.charAt(i) == ';') { data = readUpto(str, index + 1, ';'); data.txt += ';'; return { name: stmt, type: 'block', data: data, end: '' }; } } data = readUpto(str, index + 1, '{'); data.txt += '{'; return { name: stmt, data: data, end: '}' }; } function compile(tmplStr) { var i = 0, len = tmplStr.length, tmp = '', fnBody = '', stack = [], stmt; while (i < len) { if (tmplStr.indexOf('%{', i) == i) { tmp += '{'; i += 2; continue; } if (tmplStr.indexOf('}%', i) == i) { tmp += '}'; i += 2; continue; } if (tmplStr.charAt(i) == '@') { if ($.trim(tmp)) //tmp.trim() todo: not sure. chamge made by mehedi fnBody += '\np.push(\'' + tmp + '\');\n'; stmt = readStatement(tmplStr, i); fnBody += stmt.data.txt; i = stmt.data.next; tmp = ''; if (stmt.type != 'block') stack.push(stmt); if (tmplStr.charAt(i) == '@') continue; } if (tmplStr.charAt(i) == '}' && stack.length > 0) { stmt = stack.pop(); if ($.trim(tmp)) fnBody += '\np.push(\'' + tmp + '\');\n'; fnBody += stmt.end + '\n'; tmp = ''; i++; continue; } if (tmplStr.charAt(i) == '{') { var d = readUpto(tmplStr, i + 1, '}'); if (d) { if (d.txt.indexOf('[') != -1) { tmp += '\'+( (ctx.' + d.txt + ' ? ctx.' + d.txt + ' : az.$emptyStr) )+\''; } else tmp += '\'+( (ctx.' + d.txt + ' ? ctx.' + d.txt + ' : (global.' + d.txt + '? global.' + d.txt + ' : az.$emptyStr )) )+\''; i = d.next; continue; } } if (tmplStr.charAt(i) == '\'') tmp += "\\"; tmp += tmplStr.charAt(i); i++; }; if ($.trim(tmp)) fnBody += '\np.push(\'' + tmp + '\');\n'; var finalFn = " var ctx=ctx||{}; if(override)az.absorb(ctx,override); var p=[];" + (fnBody.indexOf('$emit') != -1 ? "function $emit(str){p.push(str);};" : '') + fnBody + " \nreturn p.join('');"; return new Function("global", "ctx", "override", finalFn); }; function compileMeta(metaTplStr, tpls) { var templates = az.transform(metaTplStr.match(/@[\w]+/gi), function (item) { return item.replace("@", ''); }); for (var tpl in tpls) if (templates.indexOf(tpl) == -1) throw tpl + " template not found"; metaTplStr = metaTplStr.replace(/@(\w+)\(/gi, 'tpls.$1(owner,tplData.$1 ,'); metaTplStr = metaTplStr.replace(/@(\w+)/gi, ' tpls.$1(owner,tplData.$1) '); return { fn: new Function("tpls", "tplData", "owner", 'return ' + metaTplStr + ';'), tplNames: templates }; }; var tplCache = {}; az.copy(az, { cacheTpl:true, createTpl: function (tplStr, id) { if (!az.cacheTpl) return compile(tplStr); if (id && tplCache.hasOwnProperty(id)) return tplCache[id]; var tplFn = compile(tplStr); if (id) tplCache[id] = tplFn; return tplFn; }, createMetaTpl: function (metaStr, tpls) { return compileMeta(metaStr, tpls); }, defaultMetaTpl: function (tpls) { var templates = []; var fnBody = []; for (var i in tpls) { templates.push(i); fnBody.push('tpls.' + i + '(owner,tplData.' + i + ')'); } return { fn: new Function("tpls", "tplData", "owner", 'return ' + fnBody.join('+') + ';'), tplNames: templates }; } }); })(); /*Scripts/libs/Astral/Core/dom.js*/ (function () { az.__addToInitQueue(function () { var db = document.body, div = document.createElement('div'); div.style.width = div.style.height = '100px'; div.style.overflow = 'scroll'; div.style.position = 'absolute'; db.appendChild(div); // now we can measure the div... // at least in iE9 the div is not 100px - the scrollbar size is removed! az.dom.SCROLLBAR = { HEIGHT: (div.offsetWidth - div.clientWidth), //+2 WIDTH: div.offsetHeight - div.clientHeight }; db.removeChild(div); }); az.dom = {}; az.copy(az.dom, { SCROLLBAR: { HEIGHT:20, WIDTH:20 } }); })(); /*Scripts/libs/Astral/Core/formatters.js*/ (function () { az.defineSingleton('formatter', { _readBetween: function (str, start, end) { var blockStr = ''; var i = str.indexOf(start) + 1; var depth = 0; while (i < str.length) { if (str.charAt(i) == end && depth == 0) break; if (str.charAt(i) == start) depth++; if (str.charAt(i) == end) end--; blockStr += str.charAt(i); i++; } return blockStr; }, _format: { number: function (value, formatKey) { var tempValue = parseFloat(value); if (isNaN(tempValue)) return ''; var tempKey = formatKey.split('.'); if (tempKey.length == 1) { return tempValue.toFixed(0); } else { return tempValue.toFixed(tempKey[1].length); } }, date: function (value, formatKey) { return az.date.formatDate(formatKey, value); }, bool: function (value, formatKey) { formatKey = formatKey || 'No|Yes'; return formatKey.split('|')[Number(value)]; } }, format: function (pattern, value) { var type = this._readBetween(pattern, '@', '[').toLowerCase(); var formatKey = this._readBetween(pattern, '[', ']'); if (this._format[type]) return this._format[type](value, formatKey); else return value; } }); })(); /*Scripts/libs/Astral/Util/observable.js*/ az.defineMixin('observable', { init: function () { this.channels = {}; if (this.listeners) this.monitor(this.listeners); }, monitor: function (eventCfg) { for (var eventName in eventCfg) { if (az.chk.ifFunction(eventCfg[eventName])) this.on(eventName, eventCfg[eventName]); else this.on(eventName, eventCfg[eventName].fn, eventCfg[eventName].scope); } }, on: function (event, fn, scope) { if (!this.channels.hasOwnProperty(event)) this.channels[event] = []; this.channels[event].push({ fn: fn, scope: scope }); }, addListener: function () { this.on.apply(this, arguments); }, removeListener: function () { this.off.apply(this, arguments); }, off: function (event, fn, scope) { if (arguments.length == 0) { this.channels = {}; return; } if (!this.channels.hasOwnProperty(event)) return; var i = this.channels[event].length; while (i--) { if (this.channels[event][i].fn == fn && this.channels[event][i].scope == scope) { return this.channels[event].splice(i, 1); } } }, fire: function () { if (!this.channels.hasOwnProperty(arguments[0])) return; var args = []; for (var i = 1; i < arguments.length; i++) args.push(arguments[i]); var handlers = this.channels[arguments[0]]; if (this.delayHandlers) setTimeout(function () { for (var i = 0; i < handlers.length; i++) { handlers[i].fn.apply(handlers[i].scope || null, args); } }, 10); else { for (var i = 0; i < handlers.length; i++) { handlers[i].fn.apply(handlers[i].scope || null, args); } } }, fireExcluding:function (event,args,excludeList) { if (!this.channels.hasOwnProperty(event)) return; var handlers = this.channels[event]; if (this.delayHandlers) setTimeout(function () { for (var i = 0; i < handlers.length; i++) { if (excludeList.indexOf(handlers[i].scope) == -1) handlers[i].fn.apply(handlers[i].scope || null, args); } }, 10); else { for (var i = 0; i < handlers.length; i++) { if (excludeList.indexOf(handlers[i].scope) == -1) handlers[i].fn.apply(handlers[i].scope || null, args); } } } }); /*Scripts/libs/Astral/Data/DataReader.js*/ az.defineClass('DataReader', { source: [], readAs: 'objectArray', //array map: {}, init: function (config, source, store) { az.copy(this, config); this.store = store; if (az.chk.ifString(config) && az.Schema.exists(config)) { az.copy(this, az.Schema.get(config.schema)); } else { if (az.chk.ifString(this.schema)) { this.schema = az.Schema.get(this.schema); } } this.source = source; }, _prepare: function (callback) { var me = this; if (az.chk.ifArray(this.source)) { this.rawData = this.source; callback.call(me); } if (az.chk.ifObject(this.source) && this.source.fn) { this.source.fn.call(this.source.scope || null, this.store, function (result) { me.rawData = result; callback.call(me); }); } if (az.chk.ifFunction(this.source)) this.source(this.store, function (result) { me.rawData = result; callback.call(me); }); }, readItem: function (rawData) { var fields = this.schema; if (this.mode == 'objectArray') { var data = {}; for (var i = 0; i < fields.length; i++) { if (az.chk.ifObject(fields[i])) { if (this.map.hasOwnProperty(fields[i].name)) { data[fields[i].name] = rawData[this.map[fields[i].name]]; } else { data[fields[i].name] = rawData[fields[i].name]; } } if (az.chk.ifString(fields[i])) { data[fields[i]] = rawData[fields[i]]; } } data.originalSource = rawData; return new az.DataRecord({ data: data, type: this.schema.name }); } if (this.mode == 'array') { var data = {}; for (var i = 0; i < fields.length; i++) { if (fields[i].name) data[fields[i].name] = rawData[i]; else data[fields[i]] = rawData[i]; } data.originalSource = rawData; return new az.DataRecord({ data: data, type: this.schema.name }); } }, read: function (pageIndex, pageSize, afterRead) { this._prepare(function () { var records = []; if (az.chk.ifArray(this.rawData)) { var start = (pageIndex * pageSize) || 0; var end = (this.rawData.length > (start + pageSize) ? start + pageSize : this.rawData.length) for (var i = start; i < end; i++) { records.push(this.readItem(this.rawData[i])); } afterRead({ totalCount: this.rawData.length, records: records, pageCount: this.rawData.length / pageSize, pageIndex: pageIndex }) } if (az.chk.ifObject(this.rawData)) { for (var i = 0; i < this.rawData.Data.length; i++) { records.push(this.readItem(this.rawData.Data[i])); } afterRead({ totalCount: this.rawData.TotalCount, records: records, pageCount: this.rawData.TotalPages, pageIndex: this.rawData.PageIndex }); } if(!az.chk.ifDefined(this.rawData)) { afterRead({ totalCount: 0, records: [], pageCount: 0, pageIndex: -1}); } }); } }); /*Scripts/libs/Astral/Data/DataRecord.js*/ az.defineClass('DataRecord', { $static: { recordId: 0 }, $autoInitMixin: true, $includes: 'observable', tmp: {}, data: {}, isDirty: false, type: 'none', init: function (config) { az.copy(this, config); this.rid = az.DataRecord.recordId++; }, forEach: function (fn) { var data = (this.isDirty ? this.tmp : this.data); for (var i in data) { fn(data[i], i); } }, update: function (data) { az.copy(this.tmp, data); this.isDirty = true; this.fire('update', this, data, this.data); }, set: function (field, value) { if (az.chk.ifObject(field)) { az.copy(this.tmp, field); } if (az.chk.ifString(field)) { this.tmp[field] = value; } this.isDirty = true; this.fire('change', this, field, value, this.tmp, this.data); }, get: function (field) { if (az.chk.ifString(field)) { if (this.isDirty && this.tmp.hasOwnProperty(field)) return this.tmp[field]; return this.data[field]; } }, commit: function () { az.copy(this.data, this.tmp); this.isDirty = false; this.fire('commit', this); }, rollback: function () { az.copy(this.tmp, this.data); this.isDirty = false; this.fire('rollback', this); }, destroy: function () { this.fire('destroy', this); for (var prop in this) { if (prop != 'destroy') continue; this[prop] = null; delete this[prop]; } } }); /*Scripts/libs/Astral/Data/Schema.js*/ az.defineSingleton('Schema', { regrstry: {}, destroy: function (name) { delete this.registry[name]; }, define: function (name, config) { if (this.registry.hasOwnProperty(name)) throw "A schema called " + name + " already exists"; for (var i = 0; i < config.fields.length; i++) { if (az.chk.ifString(config.fields[i])) { config.fields[i] = { name: config.fields[i], type: 'auto' }; } if (!config.fields[i].type) config.fields[i].type = 'auto'; } config.name = name; this.registry[name] = config; }, exists: function (name) { return this.registry.hasOwnProperty(name); }, get: function (name) { return this.registry[name]; } }); /*Scripts/libs/Astral/Data/Store.js*/ az.defineClass('DataStore', { $includes: 'observable', records: null, totalCount: 0, pageCount: 0, pageIndex: 0, pageSize: Number.MAX_VALUE, autoLoad: true, mode: 'objectArray', sorter: null, init: function (config) { az.copy(this, config); if (this.fields) { this.reader = new az.DataReader({ schema: this.fields, mode: this.mode }, this.source, this); } }, sort: function (field, sortDir, comparator) { if (this.sorter != null) { this.sorter(field, sortDir, this) return; } this.records.sort(function (record1, record2) { var val1 = record1.get(field + ''); var val2 = record2.get(field + ''); if (sortDir == 'asc') { if (comparator) return comparator(val1, val2); if (val1 == val2) return 0; if (val1 > val2) return 1; if (val1 < val2) return -1; } else { if (comparator) return comparator(val2, val1); if (val2 == val1) return 0; if (val2 > val1) return 1; if (val2 < val1) return -1; } }) }, setPageSize: function (pageSize) { this.pageSize = pageSize || Number.MAX_VALUE; this.pageIndex = 0; }, onRecordChange: function (record) { this.fire('update', record); }, count: function () { return this.totalCount; }, forEach: function (fn) { az.each(this.records, fn); }, getAt: function (index) { return this.records[index]; }, find: function (fn) { return az.find(this.records, fn); }, findAll: function (fn) { return az.select(this.records, fn); }, indexOf: function (fn, all) { return az.indexOf(this.records, fn, all); }, _insertAt: function (record, index) { if (index != undefined && index < this.records.length) { this.records.splice(index, 0, record); } else { this.records.push(record); } }, _setUpRecordListeners: function () { for (var i = 0; i < this.records.length; i++) { this.records[i].on('commit', this.onRecordChange, this); } }, add: function (record, index) { if (record instanceof az.DataRecord) { record.on('commit', this.onRecordChange, this); this._insertAt(record, index); } else { var r = this.reader.readItem(record); r.on('commit', this.onRecordChange, this); this._insertAt(r, index); } this.totalCount++; this.fire('add', record); return record; }, remove: function (recordOrIndex) { if (az.chk.ifNumber(recordOrIndex)) { var record = this.records.splice(recordOrIndex, 1); this.totalCount--; this.fire('remove', record); } if (recordOrIndex instanceof az.DataRecord) { for (var i = 0; i < this.records.length; i++) { if (this.records[i].rid == recordOrIndex.rid) { this.records.splice(i, 1); this.totalCount--; this.fire('remove', recordOrIndex); recordOrIndex.destroy(); } } } }, clear: function () { for (var i = 0; i < this.records.length; i++) this.records[i].destroy(); this.records = []; this.fire('clear'); }, load: function (pageIndex, callback) { var me = this; me.fire('beforeload'); if (az.chk.ifNumber(pageIndex)) { this.pageIndex = pageIndex; if (this.pageIndex >= this.pageCount) this.pageIndex = this.pageCount - 1; if (this.pageIndex < 0) this.pageIndex = 0; } if (this.records && this.records.length > 0) this.clear(); if (this.reader) this.reader.read(this.pageIndex, this.pageSize, function (result) { me.totalCount = result.totalCount; me.pageCount = result.pageCount; me.records = result.records; me._setUpRecordListeners(); me.fire('load'); }); if (callback) callback.call(me); }, loadData: function (data) { this.reader.source = data; this.load(0); } }); /*Scripts/libs/Astral/Core/util.js*/ (function () { var htmlEscapeMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; var idRegex = /id\s*=\s*["'](\S+)["']/gi; az.util = {}; az.copy(az.util, { margeStyleStr: function (origianl, current) { if (!origianl) return current; var oritialItems = origianl.split(';'); var currentItems = current.split(';'); for (var i = 0; i < oritialItems.length; i++) { if (!oritialItems[i] || oritialItems[i].length == 0) { oritialItems.splice(i, 1); i--; continue; } for (var j = 0; j < currentItems.length; j++) { if (!currentItems[j] || currentItems[j].length == 0) { currentItems.splice(j, 1); j--; continue; } if (oritialItems[i].split(':')[0].indexOf(currentItems[j].split(':')[0]) == 0 || currentItems[j].split(':')[0].indexOf(oritialItems[i].split(':')[0]) == 0) { oritialItems.splice(i, 1); i--; break; } } } return oritialItems.join(';') + ';' + currentItems.join(';') }, extractIdByPattern: function (str, pattern) { var patternRe = new RegExp(pattern); var result; var ids = []; while ((result = idRegex.exec(str)) !== null) { if (patternRe.test(result[1])) ids.push(result[1]); } return ids; }, extractIdProp: function (str, noPrefix) { var result; var ids = []; while ((result = idRegex.exec(str)) !== null) { ids.push((noPrefix ? result[1] : '#' + result[1])); } return ids.join(','); }, escapeId: function (id) { return id.replace(/(:|\.|\[|\])/g, "\\$1"); }, strToObj: function (str, propDelimeter, keyValueDelimeter) { var obj = {}; var items = str.split(propDelimeter); for (var i = 0, j = items.length; i < j; i++) { var kv = items[i].split(keyValueDelimeter); obj[kv[0]] = kv[1]; } return obj; }, objToStr: function (obj, propDelimeter, keyValueDelimeter) { var str = []; for (var i in obj) { str.push(i + keyValueDelimeter + obj[i]); } return str.join(propDelimeter); }, escapeHtml: function (string) { return String(string).replace(/[&<>"'\/]/g, function (s) { return htmlEscapeMap[s]; }); }, stripScriptTagsFromStr: function (s) { var div = document.createElement('div'); div.innerHTML = s; var scripts = div.getElementsByTagName('script'); var i = scripts.length; while (i--) { scripts[i].parentNode.removeChild(scripts[i]); } return div.innerHTML; }, evalJson : function (s) { var json = "o = " + (s || 'null') + ";"; json = json.replace(/"\\?\/Date\((-?[\d]+).*?\)\\?\/"/gi, "new Date($1)"); var o = eval(json); // console.log(json) // console.log(s) return o; }, clone: function (obj) { // Handle the 3 simple types, and null or undefined if (null == obj || "object" != typeof obj) return obj; // Handle Date var copy; if (obj instanceof Date) { copy = new Date(); copy.setTime(obj.getTime()); return copy; } // Handle Array if (obj instanceof Array) { copy = []; for (var i = 0, len = obj.length; i < len; i++) { copy[i] = az.util.clone(obj[i]); } return copy; } // Handle Object if (obj instanceof Object) { copy = {}; for (var attr in obj) { if (obj.hasOwnProperty(attr)) copy[attr] = az.util.clone(obj[attr]); } return copy; } throw new Error("Unable to copy obj! Its type isn't supported."); }, validURL: function (str) { var pattern = new RegExp('^(https?:\\/\\/)?' + // protocol '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.?)+[a-z]{2,}|' + // domain name '((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path '(\\?[;&a-z\\d%_.~+=-]*)?' + // query string '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator return pattern.test(str); }, loadImg: function (src, successCallback,errorCallback) { $("") .on('load', successCallback) .on('error',errorCallback) .attr("src", src); }, resolveDownloadSrc: function (path, splitDelm, entityType, queryParams, dontUseAppPath, isPrivate) { path = (path || '').toLowerCase(); if (!path) { return ''; } else if ((path.indexOf('store/download') > -1) || ((/^http(s?):\/\//.test(path)) && path.indexOf(splitDelm) == -1)) { return path; } queryParams = queryParams || {}; /* { p: 1, p1: 2, p2: 0 } */ splitDelm = splitDelm || 'repository/'; entityType = entityType || 'repo'; isPrivate = isPrivate ? '' : 'public'; var downLoadPath = !dontUseAppPath ? px.appPath + '' : ''; if (path.indexOf('temp/') > -1) { downLoadPath += 'store/downloadTemp?path=' + path.split('temp/')[1]; } else { var dirParts = (path.split(splitDelm)[1] || '').split('/'); var fileName = dirParts[dirParts.length - 1]; var nums = dirParts.filter(function (item) { return !Number.isNaN(Number(item)) }); downLoadPath += 'store/download' + isPrivate + '?f=' + fileName + '&t=' + entityType; for (param in queryParams) { downLoadPath += '&' + param + '=' + nums[queryParams[param]]; } ///downLoadPath = az.format('store/downloadpublic?f={file}&t={type}&p={entityId}&p1={fieldSetId}&p2={repositoryId}', { file: dirParts[dirParts.length - 1], type: entityType, entityId: nums[1], fieldSetId: nums[2], repositoryId: nums[0] }); } return downLoadPath; }, escapeScriptTag: function (string) { if (!az.chk.ifString(string)) return string; var reScript = /]*>([\s\S]*?)<\/script>/gm; var reImage1 = /]*>/gm; var result1 = String(string).replace(reScript, ''); var result2 = String(result1).replace(reImage1, ''); return result2; }, }); })(); /*Scripts/libs/Astral/Util/draggable.js*/ az.defineMixin('draggable', { init: function() { if (this.draggable) { if (!this.dragConfig) this.dragConfig = { }; if (!this.events) this.events = { }; if (!this.events.custom) this.events.custom = []; this.events.custom.push('dragstart', 'dragstop', 'drag', 'dragcreate', 'dragenable', 'dragdisable'); var me = this; this.addListener('postrender', function() { var rootEl = me.getRootEl(); az.copy(me.dragConfig, { create: function (event) { me.fireEvent('dragcreate', new az.Event(rootEl, event)); }, drag: function(event, ui) { me.fireEvent('drag', new az.Event(rootEl, event)); if (me.onDrag) me.onDrag(event, ui); }, start: function (event, ui) { me.fireEvent('dragstart', new az.Event(rootEl, event), ui); if (me.activate) me.activate(); if (me.onDragStart) me.onDragStart(event, ui); }, stop: function (event, ui) { me.fireEvent('dragstop', new az.Event(rootEl, event), ui); if (me.onDragStop) me.onDragStop(event, ui); } }); $(rootEl).draggable(me.dragConfig); }); } }, setDragDisable: function(diabled, notify) { $(this.getRootEl()).draggable((diabled ? "disable" : 'enable')); if (notify) { this.fireEvent((diabled ? "dragdisable" : 'dragenable')); } }, dragDisable: function(notify) { this.setDragDisable(true, notify); }, dragEnable: function (notify) { this.setDragDisable(false, notify); }, destroy: function() { $(this.getRootEl()).draggable("destroy"); } }); /*Scripts/libs/Astral/Util/resizable.js*/ az.defineMixin('resizable', { init: function () { if (this.resizable) { if (!this.resizeConfig) this.resizeConfig = {}; if (!this.events) this.events = {}; if (!this.events.custom) this.events.custom = []; this.events.custom.push('resizestart', 'resizestop', 'resize', 'resizecreate', 'resizeenable', 'resizedisable'); var me = this; this.addListener('postrender', function () { var rootEl = me.getRootEl(); az.copy(me.resizeConfig, { create: function (event) { me.fireEvent('resizecreate', new az.Event(rootEl, event)); }, resize: function (event, ui) { if (!me.resizing) { me.fireEvent('resize', new az.Event(rootEl, event)); me.onResize(event, ui); } }, start: function (event, ui) { me.fireEvent('resizestart', new az.Event(rootEl, event)); if (me.activate) me.activate(); me.onResizeStart(event, ui); me.resizing = true; }, stop: function (event, ui) { me.fireEvent('resizestop', new az.Event(rootEl, event)); me.onResizeStop(event, ui); me.resizing = false; } }); $(rootEl).resizable(me.resizeConfig); }); } }, setResizeDisable: function (diabled, notify) { $(this.getRootEl()).resizable((diabled ? "disable" : 'enable')); if (notify) { this.fireEvent((diabled ? "resizedisable" : 'resizeenable')); } }, resizeDisable: function (notify) { this.setResizeDisable(true, notify); }, resizeEnable: function (notify) { this.setResizeDisable(false, notify); }, destroy: function () { $(this.getRootEl()).resizable("destroy"); } }); /*Scripts/libs/Astral/Util/maskable.js*/ az.defineMixin('maskable', { init: function () { if (this.masked) { this.addListener('postrender', this.mask, this, true); } var me = this; this.addListener('resize', function () { if (!this.masked) return; var rooEl = $(this.getRootEl()); if (me.masked) $('#mask-' + me.cid).css({ height: rooEl.outerHeight(), width: rooEl.outerWidth() }); }, this, true); }, mask: function (message) { this.tmpMsg =message || this.maskMsg; this.setMaskVisible(true); }, unmask: function () { // this.maskMsg = ''; this.setMaskVisible(false); }, setMaskVisible: function (visible) { var maskCls = this.maskCls ? this.maskCls : 'az-mask'; if (this.masked == visible) return; this.masked = visible; if (!this.rendered) return; var rooEl = this.maskTargetDom? $(this.dom[this.maskTargetDom]) : $(this.getRootEl()); if (visible) { //this.setStyle('root', 'overflow', 'hidden'); rooEl.prepend($(az.format('
' + this.getMaskMsgHtml(az.LayerManager.getTopZindex()), { cid: this.cid, style: 'height:' + (rooEl.height() - 1 + this._getPadding('top') + this._getPadding('bottom')) + 'px;' + 'width:' + (rooEl.width() - 1 + this._getPadding('left') + this._getPadding('right')) + 'px;' + 'z-index:' + az.LayerManager.getTopZindex() }))); if (rooEl.css('position') == undefined || rooEl.css('position') == 'static') { rooEl.css('position', 'relative'); } var msg = $('#mask-msg-' + this.cid); msg.css('margin-left', -(msg.outerWidth() / 2)); msg.css('margin-top', -(msg.outerHeight() / 2)); } else { //this.setStyle('root', 'overflow', 'auto'); $('#mask-' + this.cid).remove(); $('#mask-msg-' + this.cid).remove(); } }, getMaskMsgHtml: function ( zi) { if (this.tmpMsg) { var maskingBlaesLength = 12; return '
' + ((new Array(maskingBlaesLength+1).join('0').split('')).map(function() {return '
'}).join('')) + this.tmpMsg + '
'; } return ''; } }); /*Scripts/libs/Astral/Util/Msg.js*/ az.defineSingleton('Msg', { icon: { QUESTION: 'az-icon-question', INFO: 'az-msg-info', ERROR: 'az-msg-error', WARNING: 'az-msg-warning' }, button: { OK: 'OK', YES: 'Yes', NO: 'No', CANCEL: 'Cancel' }, show: function (options) { this.msgWin = this._createMsgWindow(options); this.msgWin.show(); }, hide: function () { this.msgWin.destroy(); delete this.msgWin; }, _createMsgWindow: function (options) { var me = this; var win = new az.Window({ modal: true, padding: { top: 5, left: 5, right: 5, bottom: 15 }, dragable: true, collapsible: false, maximizable: false, closable: true, resizable: false, title: options.title || '', content: this.contentHtml(options.text, options.iconCls), bbar: this.createBbar(options), bbarCenterAlign: true, width: options.width || 350, listeners: { close: function () { if (options.handler) options.handler(me.button.CANCEL.toString()); } } }); delete win.height; //delete default height return win; }, createBbar: function (options) { if (!options.buttons) return null; var bbar = []; var me = this; $.each(options.buttons, function () { var btnText = this.toString(); bbar.push({ text: btnText, width: options.btnWidth || 80, listeners: { click: function () { if (options.handler) options.handler(btnText); me.msgWin.destroy(); } } }); }); return bbar; }, contentHtml: function (text, iconCls) { if(iconCls) { var iconHtml = '
' ; return '
' + iconHtml + '
' + text + '
'; } else { return '
' + text +'
'; } } }); /*Scripts/libs/Astral/Layout/LayoutManager.js*/ az.defineSingleton('LayoutManager', { layouts: {}, register: function (name, layoutClass) { if (this.layouts.hasOwnProperty(name)) throw "A layout named " + name + " already exists"; this.layouts[name] = layoutClass; }, create: function (name, config,owner) { return new this.layouts[name](config,owner); } }); /*Scripts/libs/Astral/Core/LayerManager.js*/ az.defineSingleton('LayerManager', { MAX_VALUE: 2147483647, MIN_VALUE: 1000, currentTopValue: 6000, add: function (instance) { instance.zIndex = ++this.currentTopValue; }, bringToTop: function (item) { /* if (item.modal) { // todo do modal processing } else*/ item.setStyle('root', { postion: 'absolute', 'z-index': ++this.currentTopValue }); }, bringToTopBy: function (item, offset) { /* if (item.modal) { // todo do modal processing } else {*/ this.currentTopValue += offset; item.setStyle('root', { postion: 'absolute', 'z-index': this.currentTopValue }); // } }, getTopZindex: function () { return ++this.currentTopValue; } }); /*Scripts/libs/Astral/Core/Theme.js*/ az.defineSingleton('Theme', { DEFAULT_THEME: 'Green', themes: {}, define: function (name, properties) { if (this.themes.hasOwnProperty(name)) { throw "already a theme exists by this name"; } this.themes[name] = { $properties: properties, classThemes: {} }; }, _getThemeData: function (themeName, className) { var themeProps = this.themes[themeName].$properties; for (var i = 0; i < themeProps.length; i++) { if (themeProps[i].$class == className) { return themeProps[i]; } } }, _prepareThemeData: function (themeName, className) { var props = [], parent; props.push(this._getThemeData(themeName, className)); parent = className; while (true) { parent = az.getParentOf(parent); props.push(this._getThemeData(themeName, parent)) if (parent == 'UIComponent') break; } var themeProperties = {}; var tplData = {}; for (var i = props.length; i > -1; i--) { if (props[i]) { if (props[i].properties) az.absorb(themeProperties, props[i].properties); if (props[i].tplData) az.absorb(tplData, props[i].tplData); } } this.themes[themeName].classThemes[className] = { properties: themeProperties, tplData: tplData }; }, getValue: function (themeName, className, propertyName) { if (!this.themes.hasOwnProperty(themeName)) { return this.getValue(this.DEFAULT_THEME, className, propertyName); } if (!this.themes[themeName].classThemes.hasOwnProperty(className)) { this._prepareThemeData(themeName, className); } if (this.themes[themeName].classThemes.hasOwnProperty(className)) { if (this.themes[themeName].classThemes[className].properties) { return this.themes[themeName].classThemes[className].properties[propertyName]; } } }, getTplData: function (className, themeName) { if (!this.themes.hasOwnProperty(themeName)) { return this.getTplData(className, this.DEFAULT_THEME); } if (!this.themes[themeName].classThemes.hasOwnProperty(className)) { this._prepareThemeData(themeName, className); } return this.themes[themeName].classThemes[className].tplData; } }); /*Scripts/libs/Astral/Themes/GreenTheme.js*/ az.Theme.define('Green', [ { $class: 'Button', properties: { borderWidth: 1 } }, { $class: 'Field', properties: { inputHeight: 24, inputBorder: 1, inputPadding: 5, helperSize:16 } }, { $class: 'Checkbox', properties: { // inputHeight: 24, // inputBorder: 1, inputPadding: 0 // helperSize:24 } }, { $class: 'CheckboxGroup', properties: { inputHeight: 22, inputBorder: 1, inputPadding: 0 } }, { $class: 'TriggerField', properties: { triggerWidth: 22, triggerHeight: 22 } }, { $class: 'Combobox', properties: { optionItemHeight: 22, } }, { $class: 'ComboboxOption', properties: { optionBorder: 1 } }, { $class: 'FileField', properties: { inputBorder: 1, inputPadding: 0 } }, { $class: 'Panel', properties: { headerHeight: 37, defaultPadding: 5, defaultBorder: 0, frameSpan:5, accordionItemHeaderHeight:32, accordionPadding:5, accordionItemGap:5 } }, { $class: 'FieldSet', properties: { legendHeight: 22, padding: 10 } }, { $class: 'Window', properties: { headerHeight: 31, frameSpan: 5, defaultPadding: 5, defaultBorder: 0, } }, { $class: 'Tab', properties: { defaultBorder: 0, itemBorder: 0, tabHeight: 39, tabScrollerHeight: 31, tabitemInitialGap: 4 } }, { $class: 'Header', properties: { colResizeMarkerOffsetLeft: 2 } }, { $class: 'Calendar', properties: { defaultWidth: 205 } }, { $class: 'Grid', properties: { defaultBorder: {top:1}, pagerHeight: 31, headerHeight:29, pagerPadding: 3, pagerBoderTop: 1 } }, { $class: 'HTMLEditor', properties: { editorPanelPadding: 5 } } ]); /*Scripts/libs/Astral/UIComponent.js*/ az.defineClass('UIComponent', { _decorators: [], _plugins: [], _elWithHandlers: [], dom: {}, disabled: false, visible: true, events: { custom: ['render', 'destroy', 'prerender', 'postrender', 'show', 'hide', 'move', 'resize', 'enable', 'disable'] }, initDecorators: function () { if (this.decorate) { for (var i = 0; i < this.decorate.length; i++) { var decor = az.create(this.decorate[i].$class, this.decorate[i]); this._decorators.push(decor); } delete this.decorate; } }, initPlugins: function () { if (this.plugins) { for (var i = 0; i < this.plugins.length; i++) { this.plugins[i].owner = this; var plugin = az.create(this.plugins[i].$class, this.plugins[i]); this._plugins.push(plugin); } delete this.plugins; } }, getRootEl: az.emptyFn, onDisabled: az.emptyFn, onEnabled: az.emptyFn, setDisabled: function (disabled, noNotification) { if (disabled) { this.disabled = true; this.onDisabled(); if (this.maskOnDisable && this.mask) this.mask(); this.suspendEvents(true); } else { this.disabled = false; this.onEnabled(); if (this.maskOnDisable && this.unmask) this.unmask(); this.suspendEvents(false); } if (!noNotification) this.fireEvent(disabled ? 'disable' : 'enable'); }, disable: function (noNotification) { this.setDisabled(true, noNotification); }, enable: function (noNotification) { this.setDisabled(false, noNotification); }, setVisible: function (val, noNotification) { this.visible = !!val; var rootElId = this.getRootEl(); if (rootElId[0] != '#') rootElId = '#' + rootElId; if (!!val) { if (this.rendered) $(rootElId).show(); } else { if (this.rendered) $(rootElId).hide(); } if (!noNotification) this.fireEvent(this.visible ? 'show' : 'hide'); }, show: function (noNotification) { this.setVisible(true, noNotification); }, hide: function (noNotification) { this.setVisible(false, noNotification); }, getFocusEl: az.emptyFn, focus: function () { var focusEl = this.getFocusEl(); if (focusEl) $(focusEl).focus(); az.FocusManager.FocusedElementId = focusEl.replace('#', ''); }, initTplData: az.emptyFn, onResize: az.emptyFn, onPositionChange: az.emptyFn, __formatStyleValues: function (propName, value) { if (this.rendered) { if (az.chk.ifObject(propName)) return [propName]; if (!value && propName.indexOf(':') != -1) { return [az.util.strToObj(propName, ';', ':')]; } if (value) { return [propName, value]; } } else { if (az.chk.ifObject(propName)) return az.util.objToStr(propName, ';', ':'); if (!value && propName.indexOf(':') != -1) return propName; return propName + ':' + value; } }, setStyle: function (domRef, propName, value) { if (!propName) return; if (az.chk.ifString(propName) && propName.length == 0) return; if (!this.dom.hasOwnProperty(domRef)) return; if (this.rendered) { var domEl = $( az.util.escapeId(this.dom[domRef])); domEl.css.apply(domEl, this.__formatStyleValues(propName, value)); } else { if (!this.tplData) this.tplData = {}; if (!this.tplData[domRef]) this.tplData[domRef] = {}; var style = this.tplData[domRef].style; this.tplData[domRef].style = az.util.margeStyleStr(style, this.__formatStyleValues(propName, value)); } }, getStyle: function (domRef, propName) { if (!this.dom.hasOwnProperty(domRef)) return ''; if (this.rendered) { return $(az.util.escapeId(this.dom[domRef])).css(propName); } else { if (!this.tplData) return ''; if (!this.tplData[domRef]) return ''; var style = this.tplData[domRef].style; if (!style) return ''; var items = style.split(';'); var i = items.length; while (i--) { if (items[i].indexOf(propName + ':') != -1) return items[i].split(':')[1]; } } }, getAttr: function (domRef, attr) { if (!this.dom.hasOwnProperty(domRef)) return; if (this.rendered) { $( az.util.escapeId(this.dom[domRef])).attr(attr); } else { if (!this.tplData) return; if (!this.tplData[domRef]) return; var currentAttrs = this.tplData[domRef].attr; var items; if (!currentAttrs) items = []; else items = currentAttrs.split(' '); var i = items.length; while (i--) { if (items[i].indexOf(attr) != -1) return items[i].split('=')[1]; } } }, addAttr: function (domRef, attr) { if (!this.dom.hasOwnProperty(domRef)) return; if (this.rendered) { $( az.util.escapeId(this.dom[domRef])).attr((az.chk.ifObject(attr) ? attr : az.util.strToObj(attr, ' ', '='))); } else { if (!this.tplData) return ''; if (!this.tplData[domRef]) return ''; var currentAttrs = this.tplData[domRef].attr; var items; if (!currentAttrs) items = []; else items = currentAttrs.split(' '); var i = items.length; while (i--) { if (items[i].indexOf(attr) != -1) return; } items.push(attr); this.tplData[domRef].attr = items.join(' '); } }, removeAttr: function (domRef, attr) { if (!this.dom.hasOwnProperty(domRef)) return; if (this.rendered) { $( az.util.escapeId(this.dom[domRef])).removeAttr(attr); } else { if (!this.tplData) return ''; if (!this.tplData[domRef]) return ''; var currentAttr = this.tplData[domRef].attr; if (!currentAttr) return ''; var items = currentAttr.split(' '); var i = items.length; while (i--) { if (items[i].indexOf(attr) != -1) { items.splice(i, 1); break; } } this.tplData[domRef].attr = items.join(' '); } }, addCls: function (domRef, cls) { if (!this.dom.hasOwnProperty(domRef)) return; cls = cls.split(',').join(' '); if (this.rendered) { $( az.util.escapeId(this.dom[domRef])).addClass(cls); } else { if (!this.tplData) return ''; if (!this.tplData[domRef]) return ''; var css = this.tplData[domRef].css; var items; if (!css) items = []; else items = css.split(' '); var i = items.length; while (i--) { if (items[i].indexOf(cls) != -1) return; } items.push(cls); this.tplData[domRef].css = items.join(' '); } }, removeCls: function (domRef, cls) { if (!this.dom.hasOwnProperty(domRef)) return; cls = cls.split(',').join(' '); if (this.rendered) { $( az.util.escapeId(this.dom[domRef])).removeClass(cls); } else { if (!this.tplData) return ''; if (!this.tplData[domRef]) return ''; var css = this.tplData[domRef].css; if (!css) return; var items = css.split(' '); var i = items.length; while (i--) { if (items[i].indexOf(cls) != -1) { items.splice(i, 1); break; } } this.tplData[domRef].css = items.join(' '); } }, setHeight: function (height, noNotification, forceResize) { if (forceResize || this.height != height) { this.height = height; this.onResize(); } if (!noNotification) this.fireEvent('resize', this.height, this.width); }, setWidth: function (width, noNotification, forceResize) { if (forceResize || this.width != width) { this.width = width; this.onResize(); } if (!noNotification) this.fireEvent('resize', this.height, this.width); }, setSize: function (height, width, noNotification, forceResize ) { if (forceResize || (this.height != height || this.width != width)) { this.height = height; this.width = width; this.onResize(); } if (!noNotification) this.fireEvent('resize', this.height, this.width); }, setLeft: function (left, noNotification) { this.left = left; this.onPositionChange(); if (!noNotification) this.fireEvent('move', this.left, this.top); }, setTop: function (top, noNotification) { this.top = top; this.onPositionChange(); if (!noNotification) this.fireEvent('move', this.left, this.top); }, setPosition: function (left, top, noNotification) { this.left = left; this.top = top; this.onPositionChange(); if (!noNotification) this.fireEvent('move', this.left, this.top); }, setMargin: function (margin) { if (az.chk.ifString(margin)) { var vals = margin.split(' '); margin = vals.length == 1 ? vals[0] : { top: vals[0] || 0, right: vals[1] || 0, bottom: vals[2] || 0, left: vals[3] || 0 }; } this.margin = margin; this.setStyle(this.dom.root ? 'root' : 'wrapper', this._getMarginStyle()); }, _getSizeStyle: function () { return (this.height != undefined ? 'height:' + (this.height - (this._getBorder('top') + this._getBorder('bottom') + this._getPadding('top') + this._getPadding('bottom'))) + 'px;' : '') + (this.width != undefined ? 'width:' + (this.width - (this._getBorder('left') + this._getBorder('right') + this._getPadding('left') + this._getPadding('right'))) + 'px;' : ''); // width: auto }, _getPositionStyle: function () { return (this.top != undefined ? 'top:' + this.top + 'px;' : '') + (this.left != undefined ? 'left:' + this.left + 'px;' : ''); }, _getBorder: function (side) { if (!this.border) return 0; if (az.chk.ifNumber(this.border)) return this.border; if (side) { if (az.chk.ifObject(this.border)) return (this.border[side] ? parseInt(this.border[side]) : 0); if (az.chk.ifString(this.border)) { var borders = this.border.split(' '); if (borders.length == 1) { return parseInt(borders[0]); } if (side == 'top') return borders[0] ? parseInt(borders[0]) : 0; if (side == 'right') return borders[1] ? parseInt(borders[1]) : 0; if (side == 'bottom') return borders[2] ? parseInt(borders[2]) : 0; if (side == 'left') return borders[3] ? parseInt(borders[3]) : 0; } } return parseInt(this.border); }, _getBorderStyle: function () { if (this.border == undefined) return ''; if (az.chk.ifNumber(this.border)) return 'border-width:' + this.border + 'px;'; if (az.chk.ifObject(this.border)) { //return (this.border.top ? 'border-top-width:' + this.border.top + 'px;' : '') + (this.border.right ? 'border-right-width:' + this.border.right + 'px;' : '') + (this.border.bottom ? 'border-bottom-width:' + this.border.bottom + 'px;' : '') + (this.border.left ? 'border-left-width:' + this.border.left + 'px;' : ''); return 'border-width:' + (this.border.top || 0) + 'px ' + (this.border.right || 0) + 'px ' + (this.border.bottom || 0) + 'px ' + (this.border.left || 0) + 'px;' } if (az.chk.ifString(this.border)) { var borders = this.border.split(' '); if (borders.length == 1) { return 'border-width:' + borders[0] + 'px;'; } else { return 'border-width:' + (borders[0] || 0) + 'px ' + (borders[1] || 0) + 'px ' + (borders[2] || borders[0] || 0) + 'px ' + (borders[3] || borders[1] || 0) + 'px;' } //return (borders[0] ? 'border-top-width:' + borders[0] + 'px;' : '') + (borders[1] ? 'border-right-width:' + borders[1] + 'px;' : '') + (borders[2] ? 'border-bottom-width:' + borders[2] + 'px;' : '') + (borders[3] ? 'border-left-width:' + borders[3] + 'px;' : ''); } }, _getPadding: function (side) { if (!this.padding) return 0; if (az.chk.ifNumber(this.padding)) return this.padding; if (side) { if (az.chk.ifObject(this.padding)) return ((this.padding[side] ? parseInt(this.padding[side]) : 0)); if (az.chk.ifString(this.padding)) { var paddings = this.padding.split(' '); if (paddings.length == 1) { return parseInt(paddings[0]); } if (side == 'top') return paddings[0] ? parseInt(paddings[0]) : 0; if (side == 'right') return paddings[1] ? parseInt(paddings[1]) : 0; if (side == 'bottom') return paddings[2] ? parseInt(paddings[2]) : 0; if (side == 'left') return paddings[3] ? parseInt(paddings[3]) : 0; } } return parseInt(this.padding); }, _getPaddingStyle: function () { if (this.padding == undefined) return ''; if (az.chk.ifNumber(this.padding)) return 'padding:' + this.padding + 'px;'; if (az.chk.ifObject(this.padding)) { return (this.padding.top ? 'padding-top:' + this.padding.top + 'px;' : '') + (this.padding.right ? 'padding-right:' + this.padding.right + 'px;' : '') + (this.padding.bottom ? 'padding-bottom:' + this.padding.bottom + 'px;' : '') + (this.padding.left ? 'padding-left:' + this.padding.left + 'px;' : ''); } if (az.chk.ifString(this.padding)) { var paddings = this.padding.split(' '); if (paddings.length == 1) { return 'padding:' + paddings[0] + 'px;'; } else { return (paddings[0] ? 'padding-top:' + paddings[0] + 'px;' : '') + (paddings[1] ? 'padding-right:' + paddings[1] + 'px;' : '') + (paddings[2] ? 'padding-bottom:' + paddings[2] + 'px;' : '') + (paddings[3] ? 'padding-left:' + paddings[3] + 'px;' : ''); } } }, _getMargin: function (side) { if (!this.margin) return 0; if (az.chk.ifNumber(this.margin)) return this.margin; if (side) { if (az.chk.ifObject(this.margin)) return ((this.margin[side] ? parseInt(this.margin[side]) : 0)); if (az.chk.ifString(this.margin)) { var margins = this.margin.split(' '); if (margins.length == 1) { return parseInt(margins[0]); } if (side == 'top') return margins[0] ? parseInt(margins[0]) : 0; if (side == 'right') return margins[1] ? parseInt(margins[1]) : 0; if (side == 'bottom') return margins[2] ? parseInt(margins[2]) : 0; if (side == 'left') return margins[3] ? parseInt(margins[3]) : 0; } } return parseInt(this.margin); }, _getMarginStyle: function () { if (this.margin == undefined) return ''; if (az.chk.ifNumber(this.margin)) return 'margin:' + this.margin + 'px;'; if (az.chk.ifObject(this.margin)) { return (this.margin.top ? 'margin-top:' + this.margin.top + 'px;' : '') + (this.margin.right ? 'margin-right:' + this.margin.right + 'px;' : '') + (this.margin.bottom ? 'margin-bottom:' + this.margin.bottom + 'px;' : '') + (this.margin.left ? 'margin-left:' + this.margin.left + 'px;' : ''); } if (az.chk.ifString(this.margin)) { var margins = this.margin.split(' '); if (margins.length == 1) { return 'margin:' + margins[0] + 'px;'; } else { return (margins[0] ? 'margin-top:' + margins[0] + 'px;' : '') + (margins[1] ? 'margin-right:' + margins[1] + 'px;' : '') + (margins[2] ? 'margin-bottom:' + margins[2] + 'px;' : '') + (margins[3] ? 'margin-left:' + margins[3] + 'px;' : ''); } } }, _formatTplData: function () { if (!this.tplData) return; for (var i in this.tplData) for (var j in this.tplData[i]) { if (az.chk.ifString(this.tplData[i][j])) this.tplData[i][j] = az.format(this.tplData[i][j], this); } }, __resolveElIds: function (elIdArray) { var resolvedElIds = []; for (var i = 0; i < elIdArray.length; i++) { if (elIdArray[i].indexOf('@') != -1) { var pattern = elIdArray[i].replace('@', ''); var ids; if ($(this.getRootEl()).length > 0) ids = az.util.extractIdByPattern($(this.getRootEl())[0].outerHTML, pattern); if (ids) for (var i = 0; i < ids.length; i++) resolvedElIds.push(ids[i]); } else { resolvedElIds.push(elIdArray[i]); } } return resolvedElIds; }, _isForwaredEvent: function (elementId, eventType) { if (!this.forwaredEvents) return false; for (var i = 0; i < this.forwaredEvents.length; i += 2) { for (var j = 0; j < this.forwaredEvents[i].length; j++) { if (az.chk.ifString(this.forwaredEvents[i][j])) { if (this.forwaredEvents[i][j].indexOf('@') != -1) { this.forwaredEvents[i][j] = new RegExp(this.forwaredEvents[i][j].replace('@', '')); if (this.forwaredEvents[i][j].test(elementId)) return this.forwaredEvents[i + 1].indexOf(eventType) != -1; } else { if (this.forwaredEvents[i][j] == elementId) return this.forwaredEvents[i + 1].indexOf(eventType) != -1; } } else { if (this.forwaredEvents[i][j].test(elementId)) return this.forwaredEvents[i + 1].indexOf(eventType) != -1; } } } return false; }, getThemeValue: function (propertyName) { return az.Theme.getValue(this.theme, this.$class, propertyName); }, getlayoutSize: az.emptyFn, initEvents: function () { if (!this.events) return; var forward = this.events.forward; if (forward) { this.forwaredEvents = []; for (eventCfg in forward) { this.forwaredEvents.push(az.format(eventCfg, this).split(',')); this.forwaredEvents.push(forward[eventCfg].split(',')); } } var intercept = this.events.intercept; var eventCfg, elId; if (intercept) { for (eventCfg in intercept) { elId = az.format(eventCfg.substring(eventCfg.indexOf(':') + 1), this); elId = this.__resolveElIds(elId.split(',')); for (var i = 0; i < elId.length; i++) { az.interceptEvent(this.cid, elId[i], eventCfg.substring(0, eventCfg.indexOf(':')), this[intercept[eventCfg]], this); } } } var handle = this.events.handle; if (handle) { for (eventCfg in handle) { elId = az.format(eventCfg.substring(eventCfg.indexOf(':') + 1), this); elId = this.__resolveElIds(elId.split(',')); for (var i = 0; i < elId.length; i++) { if (this._elWithHandlers.indexOf(elId[i]) == -1) this._elWithHandlers.push(elId[i]); az.addDomEventHandlers(this.cid, elId[i], eventCfg.substring(0, eventCfg.indexOf(':')), this[handle[eventCfg]], this); } } } //delete this.events.handle; var autoEventConfig = this.events.auto; var transformedConfig = {}; if (autoEventConfig) { for (var elementId in autoEventConfig) { var evts = autoEventConfig[elementId].split(','); var i = evts.length; while (i--) { if (transformedConfig.hasOwnProperty(evts[i])) transformedConfig[evts[i]] += ',' + az.format(elementId, this); else { transformedConfig[evts[i]] = az.format(elementId, this); } } } this.events.auto = transformedConfig; } }, suspendEvents: function (suspend) { az.suspendEvents(this.cid, suspend); }, hasListener: function (event) { return az.hasListener(this.cid, event); }, monitor: function (eventCfg) { for (var eventName in eventCfg) { if (az.chk.ifFunction(eventCfg[eventName])) this.addListener(eventName, eventCfg[eventName]); else this.addListener(eventName, eventCfg[eventName].fn, eventCfg[eventName].scope, eventCfg[eventName].onces); } }, addListener: function (event, fn, scope, once) { if (!this.listeners) this.listeners = {}; if (this.events.custom && this.events.custom.indexOf(event) != -1) { if (az.chk.ifFunction(fn)) scope ? az.addListener(this.cid, event, fn, scope, once) : az.addListener(this.cid, event, fn); if (az.chk.ifObject(fn)) { fn.scope ? az.addListener(this.cid, event, fn.fn, fn.scope, fn.once) : az.addListener(this.cid, event, fn.fn); } if (az.chk.ifArray(fn)) { for (var i = 0; i < fn.length; i++) { fn[i].scope ? az.addListener(this.cid, event, fn[i].fn, fn[i].scope, fn[i].once) : az.addListener(this.cid, event, fn[i].fn); } } } else { if (this.events.auto && this.events.auto.hasOwnProperty(event)) { var elements = this.events.auto[event].split(','); var i = elements.length; while (i--) { if (this._elWithHandlers.indexOf(elements[i]) == -1) this._elWithHandlers.push(elements[i]); if (az.chk.ifFunction(fn)) scope ? az.addDomEventHandlers(this.cid, elements[i], event, fn, scope, onces) : az.addDomEventHandlers(this.cid, elements[i], event, fn); if (az.chk.ifObject(fn)) { scope ? az.addDomEventHandlers(this.cid, elements[i], event, fn.fn, fn.scope, fn.onces) : az.addDomEventHandlers(this.cid, elements[i], event, fn.fn); } if (az.chk.ifArray(fn)) { for (var i = 0; i < fn.length; i++) { scope ? az.addDomEventHandlers(this.cid, elements[i], event, fn[i].fn, fn[i].scope, fn[i].onces) : az.addDomEventHandlers(this.cid, elements[i], event, fn[i].fn); } } } } } }, removeListener: function (event, fn, scope) { if (this.events.custom.indexOf(event) != -1) { scope ? az.removeListener(this.cid, event, fn, scope) : az.removeListener(this.cid, event, fn); } else { if (this.events.auto.hasOwnProperty(event)) { var elements = this.events.auto[event].split(','); var i = elements.length; while (i--) { az.array.remove(this._elWithHandlers, elements[i]); scope ? az.removeDomEventHandler(this.cid, elements[i], event, fn, scope) : az.removeDomEventHandler(this.cid, elements[i], event, fn); } } } }, addDomEventHandler: function (elementId, event, fn, scope) { if (this._elWithHandlers.indexOf(elementId) == -1) this._elWithHandlers.push(elementId); az.addDomEventHandlers(this.cid, elementId, event, fn, scope); }, removeDomEventHandler: function (elementId, event, fn, scope) { az.array.remove(this._elWithHandlers, elementId); az.removeDomEventHandler(this.cid, elementId, event, fn, scope); }, fireEvent: function () { var args = [this]; for (var i = 1, j = arguments.length; i < j; i++) args.push(arguments[i]); az.fireEvent(this.cid, arguments[0], args); }, preRender: function () { var i; for (i = 0; i < this._plugins.length; i++) if (this._plugins[i].preRender) this._plugins[i].preRender(this); for (i = 0; i < this._decorators.length; i++) if (this._decorators[i].preRender) this._decorators[i].preRender(this); this._formatTplData(); this.initTplData(); var metaTpl = null; if (this.renderPattern) metaTpl = az.createMetaTpl(this.renderPattern, this.tpls); if (!metaTpl) { metaTpl = az.defaultMetaTpl(this.tpls); } var tpls = {}; for (i = 0; i < metaTpl.tplNames.length; i++) { tpls[metaTpl.tplNames[i]] = az.createTpl(this.tpls[metaTpl.tplNames[i]], metaTpl.tplNames[i] + this.$class); } this._renderContent = function (tplData) { this.__renderedContent = metaTpl.fn(tpls, tplData, this); return this.__renderedContent; }; this.fireEvent('prerender'); }, render: function () { if (!this.rendered) { if (this.owner) { var data = this._renderContent(this.tplData); this.fireEvent('render'); return data; } if (this.renderTo) { $('#' + this.renderTo).append(this._renderContent(this.tplData)); } this.rendered = true; this.fireEvent('render'); this.postRender(); delete this.tplData; } }, postRender: function () { this.rendered = true; this.initEvents(); var i; for (i = 0; i < this._plugins.length; i++) if (this._plugins[i].postRender) this._plugins[i].postRender(this); for (i = 0; i < this._decorators.length; i++) if (this._decorators[i].postRender) this._decorators[i].decoreate(this); if (this.listeners) { this.monitor(this.listeners); delete this.listeners; } this.fireEvent('postrender'); delete this.__renderedContent; }, init: function (config) { az.copy(this, config); az.register(this); var themeTplData = az.Theme.getTplData(this.$class, this.theme).tplData; if (themeTplData) { if (!this.tplData) this.tplData = {}; az.copy(this.tplData, themeTplData); } this.initPlugins(); this.initDecorators(); for (var i in this.tpls) { this.dom[i] = az.format(az.util.extractIdProp(this.tpls[i]), this); } if (!this.owner && this.renderTo) { this.preRender(); } }, destroy: function () { az.unregister(this); var i; for (i = 0; i < this._plugins.length; i++) if (this._plugins[i].destory) this._plugins[i].destory(); for (i = 0; i < this._decorators.length; i++) if (this._decorators[i].destory) this._decorators[i].destory(); i = this._elWithHandlers.length; while (i--) $('#' + az.util.escapeId(this._elWithHandlers[i])).off(); var els = this.getRootEl(); if (az.chk.ifArray(els)) { i = els.length; while (i--) $(els[i]).remove(); } else { $(els).remove(); } for (var prop in this) { if (prop != 'destroy') continue; this[prop] = null; delete this[prop]; } this.fireEvent('destroy'); az.destoryEventHandlers(this.cid); delete this.destroy; } }); /*Scripts/libs/Astral/Container/Container.js*/ az.defineClass('Container', { isContainer: true, $extends: 'UIComponent', $includes: 'maskable', rootTag: 'div', layout: 'auto', maskMsgIconCls: 'az-icon-loading', layoutTarget: 'root', suspendLayout: false, rootElement: 'root', items: [], visible: true, panelCls: 'az-panel az-container', tpls: { root: '<{rootTag} id="{$class}-{cid}" class="{css}" style="{style}" @if(global.tabIndex){tabindex="{tabIndex}"} {attr}>{content}' }, tplData: { root: { css: '{panelCls} {css}', style: '{style}', attr: '{attr}', content: '{content}' } }, events: { handle: { 'focusout:{$class}-{cid}': 'onFocusOut' }, custom: ['focusout', 'collapse', 'expand'] }, onFocusOut: function (event) { this.fireEvent('focusout', event); }, defaultClass: '', defaults: { }, setContent: function (content) { this.content = content; if (this.rendered) { $(this.getRootEl()).html(content); } }, getLayoutSize: function () { return { boxSize: { height: (this.rendered ? $(this.getRootEl()).outerHeight() : this.height), width: (this.rendered ? $(this.getRootEl()).outerWidth() : this.width) }, contentAreaSize: ( this.rendered ? { height: $(az.util.escapeId(this.dom[this.layoutTarget])).height(), width: $(az.util.escapeId(this.dom[this.layoutTarget])).width()} : { height: this.height - (this._getBorder('top') + this._getBorder('bottom') + this._getPadding('top') + this._getPadding('bottom')), width: this.width - (this._getBorder('left') + this._getBorder('right') + this._getPadding('left') + this._getPadding('right')) } ) }; }, getRootEl: function () { return az.util.escapeId(this.dom.root); }, getFocusEl: function () { return az.util.escapeId(this.dom.root); }, serFocus: function () { $(this.getFocusEl()).focus(); }, initTplData: function () { if (this.border) this.addCls(this.rootElement, 'az-border'); if (!az.chk.ifDefined(this.visible)) this.visible = true; this.setStyle(this.rootElement, this._getSizeStyle() + this._getBorderStyle() + (!this.visible ? ('display: none;') : '')); }, preRender: function () { this.$super.apply(this, arguments); if (az.chk.ifString(this.layout)) this.layout = az.LayoutManager.create(this.layout, this.layoutConfig, this); this.initChildren(); this.layout.initTplData(); this.layout.preRender(); var i = 0, j = this.items.length, items = this.items; while (i < j) { items[i].preRender(); i++; } }, setPadding: function (padding) { if (az.chk.ifString(padding)) { var vals = padding.split(' '); padding = vals.length == 1 ? vals[0] : { top: vals[0] || 0, right: vals[1] || 0, bottom: vals[2] || 0, left: vals[3] || 0 }; } this.padding = padding; this.setStyle(this.layoutTarget, this._getPaddingStyle()); this.onResize(); }, setBorder: function (border) { if (az.chk.ifString(border)) { var vals = border.split(' '); border = vals.length == 1 ? vals[0] : { top: vals[0] || 0, right: vals[1] || 0, bottom: vals[2] || 0, left: vals[3] || 0 }; } this.border = border; this.setStyle('root', this._getBorderStyle()); this.onResize(); }, onResize: function () { this.setStyle('root', this._getSizeStyle()); if (this.rendered && !this.suspendLayout) { this.layout.update(); } }, onPositionChange: function () { this.setStyle('root', this._getPositionStyle()); }, render: function () { if (this.items.length > 0) this.tplData[this.layoutTarget].content = this.layout.getContent(); return this.$super.apply(this, arguments); }, postRender: function () { var items = this.items; for (var i = 0; i < items.length; i++) { items[i].rendered = true; items[i].postRender(); } this.$super.apply(this, arguments); this.layout.postRender(); }, _createChild: function (config) { var type = config.$class || this.defaultClass; delete config.$class; az.copyIf(config, this.defaults); return az.create(type, config); }, onInitChildren: az.emptyFn, initChildren: function () { var i = 0, j = this.items.length, items = this.items; while (i < j) { if (items[i] instanceof az.UIComponent) { } else if (az.chk.ifObject(items[i])) { var item = this._createChild(items[i]); if (!item) { items.splice(i, 1); i--; j--; } items[i] = item; } else { throw "invalid child found in component " + this.cid; } items[i].owner = this; if (!items[i].tabIndex) items[i].tabIndex = (items[i].isContainer) ? '-1' : '0'; this.onInitChildren(items[i]); i++; } }, updateLayout: function () { if (this.rendered && !this.suspendLayout) { this.layout.update(); } }, _insertItem: function (item, index) { if (arguments.length > 1 && (index >= 0 && index < this.items.length)) { this.items.splice(index, 0, item); } else { this.items.push(item); } }, addRange: function (comps, index) { if (az.chk.ifArray) { this.suspendLayout = true; for (var i = 0; i < comps.length; i++) { if (arguments.length > 1) this.add(comps[i], index + i); else { this.add(comps[i]); } } this.suspendLayout = false; this.updateLayout(); } else { throw "invalid parameter in component " + this.cid; } }, add: function (comp, index) { if (comp.cid == this.cid) return; comp.owner = this; if (comp instanceof az.UIComponent) { this._insertItem(comp, index); } else if (az.chk.ifObject(comp)) { this._insertItem(this._createChild(comp), index); } else { throw "invalid child found in component " + this.cid; } if (!comp.tabIndex) comp.tabIndex = (comp.isContainer) ? '-1' : '0'; this.updateLayout(); }, removeAll: function () { var i = this.items.length; while (i--) { if (this.items[i].rendered) this.items[i].destroy(); } this.items = []; this.updateLayout(); }, removeAt: function (index) { if (this.items.length == 0 || (index < 0 && index > this.items.length)) return; var comp = this.items.splice(index, 1)[0]; if (comp.rendered) comp.destroy(); this.updateLayout(); }, remove: function (comp) { var cid = az.chk.ifString(comp) ? comp : comp.cid; if (!cid) return; var i = this.items.length; while (i--) { if (this.items[i].cid == cid) { if (this.items[i].rendered) this.items[i].destroy(); this.items.splice(i, 1); break; } } this.updateLayout(); }, // todo Justify Panael and COntainer collase methoes==d collapse: function (notify) { var me = this; this.collapsed = true; this.expandWidthTo = this.collapseVertically ? me.width : me.height; this.expandHeightTo = this.collapseVertically ? me.height : me.width; me.hide(); if (notify) this.fireEvent('collapse'); }, expand: function (notify) { var me = this; this.collapsed = false; me.show(); me.setSize(me.expandHeightTo, me.expandWidthTo); if (notify) this.fireEvent('expand'); }, destroy: function () { if (this.layout && this.layout.destroy) this.layout.destroy(); for (var i = 0; i < this.items.length; i++) { this.items[i].destroy(); } this.$super(); }, setTitle: function (title) { this.title = title; } }); /*Scripts/libs/Astral/Layout/Layout.js*/ az.defineClass('Layout', { init: function (config, container) { az.copy(this, config); this.owner = container; if (!this.owner.layoutTarget) throw "layout target not defined"; }, getBorder: function (side) { var padding = +this.owner._getBorder(side); if (isNaN(padding)) padding = 0; return padding; }, getPadding: function (side) { var padding = +this.owner._getPadding(side); if (isNaN(padding)) padding = 0; return padding; }, getMargin: function (side) { var margin = +this.owner._getMargin(side); if (isNaN(margin)) margin = 0; return margin; }, setOwnerStyle: function (propName, value) { this.owner.setStyle(this.owner.layoutTarget, propName, value); }, getOwnerStyle: function (propName) { return this.owner.getStyle(this.owner.layoutTarget, propName); }, addOwnerCls: function (cls) { this.owner.addClass(this.owner.layoutTarget, cls); }, removeOwnerCls: function (cls) { this.owner.removeClass(this.owner.layoutTarget, cls); }, setChildStyle: function (child, propName, value) { child.setStyle(child.rootElement, propName, value); }, getChildStyle: function (child, propName) { return child.getStyle(child.rootElement, propName); }, addChildCls: function (child, cls) { child.addCls(child.rootElement, cls); }, removeChildCls: function (child, cls) { child.removeClass(child.rootElement, cls); }, initTplData: az.emptyFn, preRender: function () { if(this.owner.padding) this.setOwnerStyle(this.owner._getPaddingStyle()); }, postRender: az.emptyFn, getContent: az.emptyFn, update: az.emptyFn, destroy: function () { } }); /*Scripts/libs/Astral/Layout/AutoLayout.js*/ az.defineClass('AutoLayout', { $extends: 'Layout', applyMargin: true, applyDisplayType: true, getContent: function () { var buffer = []; var items = this.owner.items; for (var i = 0; i < items.length; i++) { if (this.applyDisplayType && items[i].displayType && items[i].displayType == 'inline') { items[i].addCls(items[i].dom.root? 'root': 'wrapper' , 'az-inline-item'); } if (this.applyMargin && items[i].margin) { items[i].setStyle(items[i].dom.root ? 'root' : 'wrapper', this.getChildMarginStyle(items[i])); } buffer[i] = items[i].render(); } return buffer.join(''); }, update: function () { var items = this.owner.items, htmlContent, target = this.owner.dom[this.owner.layoutTarget]; if (items.length == 0) { return; } for (var i = 0; i < items.length; i++) { if (items[i].rendered) { items[i].onResize(); //items[i].layout.update(); continue; } if (!items[i].rendered) { items[i].preRender(); if (this.applyDisplayType && items[i].displayType && items[i].displayType == 'inline') { items[i].addCls(items[i].dom.root ? 'root' : 'wrapper', 'az-inline-item'); } if (this.applyMargin && items[i].margin) { items[i].setStyle(items[i].dom.root ? 'root' : 'wrapper', this.getChildMarginStyle(items[i])); } htmlContent = items[i].render(); if (i == 0) { $(target).prepend(htmlContent); } else { var prevEls = items[i - 1].getRootEl(); if (az.chk.ifArray(prevEls)) prevEls = prevEls[prevEls.length - 1]; $(prevEls).after(htmlContent); } items[i].postRender(); } } }, getChildMargin: function (side) { if (!this.margin) return 0; if (az.chk.ifNumber(this.margin)) return this.margin; if (side) { if (az.chk.ifObject(this.margin)) return ((this.margin[side] ? parseInt(this.margin[side]) : 0)); if (az.chk.ifString(this.margin)) { var margins = this.margin.split(' '); if (margins.length == 1) { return parseInt(margins[0]); } if (side == 'top') return margins[0] ? parseInt(margins[0]) : 0; if (side == 'right') return margins[1] ? parseInt(margins[1]) : 0; if (side == 'bottom') return margins[2] ? parseInt(margins[2]) : 0; if (side == 'left') return margins[3] ? parseInt(margins[3]) : 0; } } return parseInt(this.margin); }, getChildMarginStyle: function (item) { if (item.margin == undefined) return ''; if (az.chk.ifNumber(item.margin)) return 'margin:' + item.margin + 'px;'; if (az.chk.ifObject(item.margin)) { return (item.margin.top ? 'margin-top:' + item.margin.top + 'px;' : '') + (item.margin.right ? 'margin-right:' + item.margin.right + 'px;' : '') + (item.margin.bottom ? 'margin-bottom:' + item.margin.bottom + 'px;' : '') + (item.margin.left ? 'margin-left:' + item.margin.left + 'px;' : ''); } if (az.chk.ifString(item.margin)) { var margins = item.margin.split(' '); if (margins.length == 1) { return 'margin:' + margins[0] + 'px;'; } else { return (margins[0] ? 'margin-top:' + margins[0] + 'px;' : '') + (margins[1] ? 'margin-right:' + margins[1] + 'px;' : '') + (margins[2] ? 'margin-bottom:' + margins[2] + 'px;' : '') + (margins[3] ? 'margin-left:' + margins[3] + 'px;' : ''); } } } }, function ($class) { az.LayoutManager.register('auto', $class); }); /*Scripts/libs/Astral/Layout/AccordionLayout.js*/ az.defineClass('AccordionLayout', { $extends: 'AutoLayout', applyMargin: true, applyDisplayType: false, collapseOther: true, headerToolbar:true, init: function () { this.$super.apply(this, arguments); this.owner.defaultClass = this.owner.defaultClass|| 'Panel'; this.owner.activeItem = this.owner.activeItem == undefined ? -1 : this.owner.activeItem; this.owner.padding = this.owner.getThemeValue('accordionPadding'); this._postInit(); }, _postInit: function () { var items = this.owner.items; for (var i = 0; i < items.length; i++) { if (items[i].$class == 'Container') items[i].$class = 'Panel'; else if (items[i].$class && items[i].$class != 'Panel') { items[i] = { $class: 'Panel', items: [items[i]] }; } if (!items[i].$class || items[i].$class == this.owner.defaultClass) { delete items[i].width; // delete items[i].height; items[i].index = i; items[i].collapsible = true; items[i].accordion = true; items[i].margin = { bottom: (i == items.length - 1) ? 0 : this.owner.getThemeValue('accordionItemGap') }; items[i].headerAsHandler = true; items[i].headerToolbar = this.headerToolbar; items[i].collapsed = this.owner.activeItem != i; items[i].css = 'az-accordion' + ((i == 0) ? ' az-accordion-first-item' : ''); // items[i].border = { top: 1, bottom: 1 }, items[i].border = 0; items[i].listeners = { 'expand': { fn: this.onItemExpand, scope: this }, 'collapse': { fn: this.onItemCollapsed, scope: this } }; } } }, update: function () { var items = this.owner.items, htmlContent, target = this.owner.dom[this.owner.layoutTarget]; if (items.length == 0) { return; } for (var i = 0; i < items.length; i++) { if (items[i].rendered && items[i].layout) { items[i].layout.update(); continue; } if (!items[i].rendered) { if (!items[i].$class || items[i].$class == this.owner.defaultClass) { delete items[i].width; // delete items[i].height; items[i].index = i; items[i].accordion = true; items[i].collapsible = true; items[i].headerAsHandler = true; items[i].headerAsHandler = true; items[i].headerToolbar = this.headerToolbar; items[i].collapsed = this.owner.activeItem != i; items[i].margin = { bottom: (i==items.length-1)? 0 : this.owner.getThemeValue('accordionItemGap') }; items[i].listeners = { 'expand': { fn: this.onItemExpand, scope: this }, 'collapse': { fn: this.onItemCollapsed, scope: this } }; items[i].css = 'az-accordion' + ((i == 0) ? ' az-accordion-first-item' : ''); // items[i].border = { top: 1, bottom: 1 }; items[i].border = 0; } items[i].preRender(); htmlContent = items[i].render(); if (i == 0) { $(target).prepend(htmlContent); } else { var prevEls = items[i - 1].getRootEl(); if (az.chk.ifArray(prevEls)) prevEls = prevEls[prevEls.length - 1]; $(prevEls).after(htmlContent); } items[i].postRender(); } } }, onItemExpand: function (control, event) { if (this.owner.activeItem > -1 && this.collapseOther) { this.owner.items[this.owner.activeItem].collapse(false,true); } this.owner.activeItem = control.index; }, onItemCollapsed: function (control, event) { if (control.index == this.owner.activeItem) this.owner.activeItem = -1; } }, function ($class) { az.LayoutManager.register('accordion', $class); }); /*Scripts/libs/Astral/Layout/AbsoluteLayout.js*/ az.defineClass('AbsoluteLayout', { $extends: 'AutoLayout', applyMargin: false, applyDisplayType: false, preRender: function () { this.$super(); var currentPos = this.getOwnerStyle('position'); if (currentPos != 'absolute' && currentPos != 'relative') this.setOwnerStyle('position', 'relative'); var i = this.owner.items.length; while (i--) { this.setChildStyle(this.owner.items[i], this.owner.items[i]._getPositionStyle()+'position:absolute'); } }, getContent: function () { var buffer = []; var items = this.owner.items; for (var i = 0; i < items.length; i++) { this.setChildStyle(items[i],items[i]._getPositionStyle()+'position:absolute'); buffer[i] = items[i].render(); } return buffer.join(''); }, update: function () { var items = this.owner.items, htmlContent, target = this.owner.dom[this.owner.layoutTarget]; if (items.length == 0) { return; } for (var i = 0; i < items.length; i++) { /*if (items[i].rendered && items[i].layout) { items[i].layout.update(); continue; }*/ if (items[i].rendered) { items[i].onResize(); continue; } if (!items[i].rendered) { items[i].preRender(); this.setChildStyle(items[i],items[i]._getPositionStyle()+'position:absolute'); htmlContent = items[i].render(); if (i == 0) { $(target).prepend(htmlContent); } else { var prevEls = items[i - 1].getRootEl(); if (az.chk.ifArray(prevEls)) prevEls = prevEls[prevEls.length - 1]; $(prevEls).after(htmlContent); } items[i].postRender(); } } } }, function ($class) { az.LayoutManager.register('absolute', $class); }); /*Scripts/libs/Astral/Layout/CardLayout.js*/ az.defineClass('CardLayout', { $extends: 'AutoLayout', applyMargin: false, applyDisplayType: false, updating: false, init: function () { this.$super.apply(this, arguments); if (!az.chk.ifDefined(this.owner.activeItem)) this.owner.activeItem = 0; }, preRender: function () { this.$super.apply(this, arguments); var layoutSize = this.owner.getLayoutSize(); var height = layoutSize.contentAreaSize.height; var width = layoutSize.contentAreaSize.width; var i = this.owner.items.length; while (i--) { this.owner.items[i].setSize(height, width); this.setChildStyle(this.owner.items[i], 'display', (i == this.owner.activeItem && !this.owner.items[i].disabled ? 'block' : 'none')); } this.setOwnerStyle({ 'overflow': 'hidden' }); }, update: function () { var layoutSize = this.owner.getLayoutSize(); var height = layoutSize.contentAreaSize.height; var width = layoutSize.contentAreaSize.width; var i = this.owner.items.length, target = this.owner.dom[this.owner.layoutTarget]; var activeIndex = this.owner.activeItem || 0; while (i--) { var item = this.owner.items[i]; if (item.rendered) { var itemDisplayStyle = this.getChildStyle(item, 'display'); if (itemDisplayStyle == 'none' && activeIndex == i && !this.owner.items[i].disabled) this.setChildStyle(item, 'display', 'block'); if (itemDisplayStyle == 'block' && activeIndex != i) this.setChildStyle(item, 'display', 'none'); if (activeIndex == i) { item.setSize(height, width, false, true); } } else { if (activeIndex == i) { this.setChildStyle(item, 'display', 'block'); item.preRender(); $(target).append(item.render()); item.postRender(); //item.setSize(height, width); } } //item.setSize(height, width); } this.setOwnerStyle({ 'overflow': 'hidden' }); } }, function ($class) { az.LayoutManager.register('card', $class); }); /*Scripts/libs/Astral/Layout/FormLayout.js*/ az.defineClass('FormLayout', { $extends: 'Layout', applyMargin: false, applyDisplayType: false, gap: 4, _tableTpl: '{content}
', _rowFieldTpl: '{label}{content}', _rowContainerTpl: '{content}', labelWidth: 100, init: function () { this.$super.apply(this, arguments); var i = this.owner.items.length; while (i--) { var item = this.owner.items[i]; if (!item.isContainer) { item.hideFormLabel = item.hideLabel; if (item.labelPosition != 'top') item.hideLabel = true; item.labelWidth = this.labelWidth; this._addListener(item, 'labelchange', this.onLabelChange); if (item.width) item.width = item.width; } this._addListener(item, 'show', this.onShow); this._addListener(item, 'hide', this.onHide); this._addListener(item, 'destroy', this.onDestroy); } }, _addListener: function (item, event, fn) { if (az.chk.ifObject(item)) { if (!item.listeners) item.listeners = []; if (!item.listeners[event]) { item.listeners[event] = { fn: fn, scope: this }; } else { if (az.chk.ifArray(item.listeners[event])) { item.listeners[event].push({ fn: fn, scope: this }); } else { var handler = item.listeners[event]; item.listeners[event] = []; item.listeners[event].push({ fn: fn, scope: this }); item.listeners[event].push(handler); } } } }, onShow: function (item) { $('#row-' + item.cid).show(); }, onHide: function (item) { $('#row-' + item.cid).hide(); }, onDestroy: function (item) { $('#row-' + item.cid).remove(); }, onLabelChange: function (item) { $('#row-' + item.cid + '-label').html(item.label + item.labelSeparator); }, getContent: function () { var buffer = []; var items = this.owner.items; for (var i = 0; i < items.length; i++) { if (items[i].isContainer || items[i].labelPosition == 'top') buffer[i] = az.format(this._rowContainerTpl, { id: "row-" + items[i].cid, padding: (this.gap / 2) + 'px 0', content: items[i].render() }); else { buffer[i] = az.format(this._rowFieldTpl, { id: "row-" + items[i].cid, padding: (this.gap / 2) +'px 0' , label: (items[i].hideFormLabel ? '' : items[i].label + items[i].labelSeparator), labelWidth: this.labelWidth, content: items[i].render() }); } } return az.format(this._tableTpl, { content: buffer.join('') }); }, update: function () { var items = this.owner.items, htmlContent, target = this.owner.dom[this.owner.layoutTarget]; if (items.length == 0) { $(target).html(this.owner.content || ''); return; } for (var i = 0; i < items.length; i++) { //if (items[i].rendered && items[i].layout) { if (items[i].rendered) { items[i].onResize(); //items[i].layout.update(); continue; } if (!items[i].rendered) { if (!items[i].isContainer) { items[i].hideFormLabel = items[i].hideLabel; if( items[i].labelPosition != 'top') items[i].hideLabel = true ; items[i].labelWidth = this.labelWidth; this._addListener(items[i], 'labelchange', this.onLabelChange); } this._addListener(items[i], 'show', this.onShow); this._addListener(items[i], 'hide', this.onHide); this._addListener(items[i], 'destroy', this.onDestroy); items[i].preRender(); htmlContent = (items[i].isContainer || items[i].labelPosition == 'top') ? az.format(this._rowContainerTpl, { id: "row-" + items[i].cid, padding: (this.gap / 2) + 'px 0', content: items[i].render() }) : az.format(this._rowFieldTpl, { id: "row-" + items[i].cid, padding: (this.gap / 2) + 'px 0', label: (items[i].hideFormLabel ? '' : items[i].label + items[i].labelSeparator), labelWidth: this.labelWidth, content: items[i].render() }); if ($(target + ' table').length == 0) { $(target).html(az.format(this._tableTpl, { content: '' })); } if (i == 0) { $(target + ' table').prepend(htmlContent); } else { $("#row-" + items[i - 1].cid).after(htmlContent); } items[i].postRender(); } } } }, function ($class) { az.LayoutManager.register('form', $class); }); /*Scripts/libs/Astral/Layout/FitLayout.js*/ az.defineClass('FitLayout', { $extends: 'Layout', applyMargin: false, applyDisplayType: false, getContent: function () { if (this.owner.items.length == 0) return ''; return this.owner.items[0].render(); }, preRender: function() { this.setOwnerStyle({ 'overflow': 'hidden' }); this.$super.apply(this, arguments); }, update: function () { if (this.owner.items.length == 0) return; var layoutSize = this.owner.getLayoutSize(); var target = this.owner.dom[this.owner.layoutTarget]; if (!this.owner.items[0].rendered) { this.owner.items[0].preRender(); $(target).html(this.owner.items[0].render()); this.owner.items[0].rendered = true; this.owner.items[0].postRender(); } this.owner.items[0].setSize(layoutSize.contentAreaSize.height,layoutSize.contentAreaSize.width, false, true); } }, function ($class) { az.LayoutManager.register('fit', $class); }); /*Scripts/libs/Astral/Layout/ColumnLayout.js*/ az.defineClass('ColumnLayout', { $extends: 'AutoLayout', applyMargin: false, applyDisplayType: false, minColumnWidth: 50, size: 5, init: function () { this.$super.apply(this, arguments); var layoutSize = this.owner.getLayoutSize(); var items = this.owner.items; for (var i = 0; i < items.length; i++) { if (items[i].split) { items[i].split.targetControlCollapsed = items[i].collapsed; items[i].split = az.create(items[i].split.$class, items[i].split); items[i].split.addListener('click', this.splitterBtnClick, this); items[i].split.minSpan = !items[i].split.minSpan ? this.minColumnWidth : (items[i].split.minSpan < this.minColumnWidth ? this.minColumnWidth : items[i].split.minSpan); items[i].split.maxSpan = !items[i].split.maxSpan ? layoutSize.contentAreaSize.width : items[i].split.maxSpan; items[i].split.owner = this.owner; if (items[i].split.canCollapse) items[i].collapseVertically = true; } } }, splitterBtnClick: function (control, tCt) { this.update(); }, calculate: function (items, width, forceNewWidths) { var itemColumnWidths = [], itemWidth; var itemTotalWidths = 0; var remainingItems = []; var totalGapSize = this._getTotalGapSize(items); var totalSplitterSize = this._getTotalSplitterSize(items); for (var i = 0; i < items.length; i++) { if (items[i].collapsed) { items[i].collapse(); itemColumnWidths[i] = 0; continue; } if (!az.chk.ifDefined(items[i].columnWidth)) { if (!az.chk.ifDefined(items[i].width) || forceNewWidths) { remainingItems.push(i); } else { itemWidth = items[i].width; if (items[i].columnWidth < this.mincolumnWidth) itemWidth = this.mincolumnWidth; itemTotalWidths += itemWidth; itemColumnWidths[i] = itemWidth; } } else { if (items[i].columnWidth < 1) itemWidth = Math.floor((width - (totalGapSize + totalSplitterSize)) * items[i].columnWidth); else { itemWidth = items[i].columnWidth; } if (items[i].height < this.mincolumnWidth) itemWidth = this.mincolumnWidth; itemColumnWidths[i] = itemWidth; itemTotalWidths += itemWidth; } } var remainingItemWidth = 0; if (remainingItems.length) { var widthToBeFilled= (width - (itemTotalWidths + totalGapSize + totalSplitterSize)) remainingItemWidth = widthToBeFilled / remainingItems.length; var roundedWidth = Math.floor(remainingItemWidth); var makeupWidth = widthToBeFilled - roundedWidth * remainingItems.length; if (roundedWidth < this.minColumnWidth) roundedWidth = this.minColumnWidth; for (var i = 0; i < remainingItems.length; i++) { itemColumnWidths[remainingItems[i]] = roundedWidth + (makeupWidth > 0 ? 1 : 0); if (makeupWidth > 0) makeupWidth--; } } return { widths: itemColumnWidths, overflow: (width - (itemTotalWidths + totalGapSize + totalSplitterSize - this.getPadding('right') + (remainingItemWidth * remainingItems.length))) < 0 }; }, getContent: function () { var buffer = []; var items = this.owner.items; for (var i = 0; i < items.length; i++) { buffer[i] = items[i].render(); if (items[i].split) { buffer[i] += items[i].split.render(); }; } return buffer.join(''); }, preRender: function () { var ownerStyle = { 'overflow-x': 'auto', 'overflow-y': 'hidden' }; var currentPos = this.getOwnerStyle('position'); if (currentPos != 'absolute' && currentPos != 'relative') ownerStyle.position = 'relative'; var items = this.owner.items; this._setItemSizes(items); for (var i = 0; i < items.length; i++) { if (items[i].split) items[i].split.preRender(); } this.setOwnerStyle(ownerStyle); this.$super.apply(this, arguments); }, postRender: function () { this.$super.apply(this, arguments); var items = this.owner.items; for (var i = 0; i < items.length; i++) { if (items[i].split) { items[i].split.targetCt = items[i]; items[i].split.targetCtindex = i; items[i].split.postRender(); this.owner.addCls(this.owner.layoutTarget, 'az-splitter-parent'); } } // var ownerStyle = { 'overflow-x': 'auto', 'overflow-y': 'hidden' }; // this.setOwnerStyle(ownerStyle); }, update: function () { this._setItemSizes(this.owner.items, true); this.$super.apply(this, arguments); }, _getTotalGapSize: function (items) { var count = 0; if (this.getSplitCount() >= (items.length - 1)) return count; for (var i = 1; i < items.length; i++) { if (!items[i-1].split) count++; if (items[i].split && items[i].split.placeAt == 'left') count--; } return count * this.gap || 0; }, _setItemSizes: function (items, recalculate) { var layoutSize = this.owner.getLayoutSize(); var height = layoutSize.contentAreaSize.height, width = layoutSize.contentAreaSize.width, gap = this.gap || 0; var calcuationResult = this.calculate(items, width, recalculate); var scrollerHeight = calcuationResult.overflow ? az.dom.SCROLLBAR.HEIGHT : 0; height -= scrollerHeight; var initLeft = this.getPadding('left'); var itemTop = this.getPadding('top'); var itemStyle = 'position:absolute;top:' + itemTop + 'px'; var left = initLeft; for (var i = 0; i < items.length; i++) { items[i].suspendLayout = true; this.setChildStyle(items[i], itemStyle); var splitterPlaced = false; if (items[i].split && items[i].split.placeAt == 'left') { left += this.size; splitterPlaced = true; } items[i].setLeft(left); items[i].setSize(height, calcuationResult.widths[i]); left += calcuationResult.widths[i]; if (items[i].split && !splitterPlaced) { left += this.size; } if (!items[i].split && (items[i + 1] && !items[i + 1].split)) { left += (gap || 0); } else if(!items[i].split && (items[i + 1] && items[i + 1].split && items[i + 1].split.placeAt=='right' ) ) { left += (gap || 0); } if (items[i].split) { if (recalculate) { items[i].split.resset(); } } items[i].suspendLayout = false; } }, _getTotalSplitterSize: function (items) { var length = items.length; var count = 0; for (var i = 0; i < length; i++) { if (items[i].split) count++; } return count * this.size; }, getSplitCount: function () { var length = this.owner.items.length; var count = 0; for (var i = 0; i < length; i++) { if (this.owner.items[i].split) count++; } return count; }, getItemsWidthTotal: function () { var length = this.owner.items.length; var widthTotal = 0; for (var i = 0; i < length; i++) { widthTotal += (this.owner.items[i].columnWidth || 0) + (i > 0 ? this.gap : 0); } return widthTotal; } }, function ($class) { az.LayoutManager.register('column', $class); }); /*Scripts/libs/Astral/Layout/RowLayout.js*/ az.defineClass('RowLayout', { $extends: 'AutoLayout', applyMargin: false, applyDisplayType: false, minRowHeight: 50, size: 5, init: function () { this.$super.apply(this, arguments); var items = this.owner.items; var layoutSize = this.owner.getLayoutSize(); for (var i = 0; i < items.length; i++) { if (items[i].split) { if (!items[i].split.minSpan) { if (items[i].minHeight) { items[i].split.minSpan = items[i].minHeight; } } if (!items[i].split.maxSpan) { if (items[i].maxHeight) { items[i].split.maxSpan = items[i].maxHeight; } } items[i].split.targetControlCollapsed = items[i].collapsed; items[i].split.width = layoutSize.contentAreaSize.width; items[i].split.orientation = 'hor'; items[i].split = az.create(items[i].split.$class, items[i].split); items[i].split.addListener('click', this.splitterBtnClick, this); items[i].split.minSpan = !items[i].split.minSpan ? this.minRowHeight : (items[i].split.minSpan < this.minRowHeight ? this.minRowHeight : items[i].split.minSpan); items[i].split.maxSpan = !items[i].split.maxSpan ? layoutSize.contentAreaSize.height : items[i].split.maxSpan; items[i].split.owner = this.owner; } } }, calculate: function (items, height, forceNewHeights) { var itemRowHeights = [], itemHeight; var itemTotalHeights = 0; var remainingItems = []; var totalGapSize = this._getTotalGapSize(items); var totalSplitterSize = this._getTotalSplitterSize(items); for (var i = 0; i < items.length; i++) { if (items[i].collapsed) { itemRowHeights[i] = 0; continue; } if (!az.chk.ifDefined(items[i].rowHeight)) { if (!az.chk.ifDefined(items[i].height) || forceNewHeights) { remainingItems.push(i); } else { itemHeight = items[i].height; if (items[i].rowHeight < this.minRowHeight) itemHeight = this.minRowHeight; itemTotalHeights += itemHeight; itemRowHeights[i] = itemHeight; } } else { if (items[i].rowHeight < 1) itemHeight = Math.floor(( height- (totalGapSize + totalSplitterSize)) * items[i].rowHeight); else { itemHeight = items[i].rowHeight; } if (items[i].height < this.minRowHeight) itemHeight = this.minRowHeight; itemRowHeights[i] = itemHeight; itemTotalHeights += itemHeight; } } var remainingItemHeight = 0 if (remainingItems.length) { var heightTobefilled = (height - (itemTotalHeights + totalGapSize + totalSplitterSize)); remainingItemHeight = heightTobefilled / remainingItems.length; var roundedHeight = Math.floor(remainingItemHeight); var makeupHeight = heightTobefilled - roundedHeight * remainingItems.length; if (roundedHeight < this.minRowHeight) roundedHeight = this.minRowHeight; for (var i = 0; i < remainingItems.length; i++) { itemRowHeights[remainingItems[i]] = roundedHeight + (makeupHeight>0 ? 1 : 0); if (makeupHeight > 0) makeupHeight--; } } return { heights: itemRowHeights, overflow: (height - (itemTotalHeights + totalGapSize + totalSplitterSize + (remainingItemHeight * remainingItems.length))) < 0 }; }, x_getTotalGapSize: function (items) { var count = 0; for (var i = 1; i < items.length; i++) { if (!items[i - 1].split) count++; } return count * this.gap || 0; }, _getTotalGapSize: function (items) { var count = 0; if (this.getSplitCount() >= (items.length - 1)) return count; for (var i = 1; i < items.length; i++) { if (!items[i - 1].split) count++; if (items[i].split && items[i].split.placeAt == 'top') count--; } return count * this.gap || 0; }, getContent: function () { var buffer = []; var items = this.owner.items; for (var i = 0; i < items.length; i++) { if (items[i].split && items[i].split.placeAt == 'top') { buffer[i] = items[i].split.render(); buffer[i] += items[i].render(); } else { buffer[i] = items[i].render(); if (items[i].split) { buffer[i] += items[i].split.render(); }; } } return buffer.join(''); }, splitterBtnClick: function (control, isCollapsed, tCt, sCt) { this.update(); }, _setItemSizes: function (items, recalculate) { var layoutSize = this.owner.getLayoutSize(); var height = layoutSize.contentAreaSize.height, width = layoutSize.contentAreaSize.width, gap = this.gap || 0; var calcuationResult = this.calculate(items, height, recalculate); var scrollerWidth = calcuationResult.overflow ? az.dom.SCROLLBAR.WIDTH : 0; width -= scrollerWidth; for (var i = 0; i < items.length; i++) { if (i > 0 && gap > 0) { if (!items[i - 1].split && !(items[i].split && items[i].split.placeAt == 'top')) this.setChildStyle(items[i], 'margin-top:' + (i == 0 ? '0' : gap) + 'px;display:block'); } items[i].suspendLayout = true; items[i].setSize(calcuationResult.heights[i], width); // items[i].setWidth(width); if (items[i].split) { if (recalculate) { items[i].split.resset(); } } items[i].suspendLayout = false; } }, preRender: function () { var items = this.owner.items; this._setItemSizes(items); for (var i = 0; i < items.length; i++) { if (items[i].split) items[i].split.preRender(); } /***********/ var ownerStyle = { 'overflow-x': 'hidden', 'overflow-y': 'auto' }; var currentPos = this.getOwnerStyle('position'); if (currentPos != 'absolute' && currentPos != 'relative') ownerStyle.position = 'relative'; this.setOwnerStyle(ownerStyle); /********************/ // this.setOwnerStyle({ 'overflow-x': 'hidden', 'overflow-y': 'auto', 'position': 'relative' }); this.$super.apply(this, arguments); }, postRender: function () { this.$super.apply(this, arguments); var items = this.owner.items; for (var i = 0; i < items.length; i++) { if (items[i].split) { items[i].split.targetCt = items[i]; items[i].split.postRender(); this.owner.addCls(this.owner.layoutTarget, 'az-splitter-parent'); } } }, update: function () { this._setItemSizes(this.owner.items, true); this.$super.apply(this, arguments); }, _getTotalSplitterSize: function (items) { var length = items.length; var count = 0; for (var i = 0; i < length; i++) { if (items[i].split) count++; } return count * this.size; }, getSplitCount: function () { var length = this.owner.items.length; var count = 0; for (var i = 0; i < length; i++) { if (this.owner.items[i].split) count++; } return count; }, getItemsHeightTotal: function () { var length = this.owner.items.length; var hieghtTotal = 0; for (var i = 0; i < length; i++) { hieghtTotal += this.owner.items[i].rowHeight + (i > 0 && i < length - 1 ? this.gap || 0 : 0); } return hieghtTotal; } }, function ($class) { az.LayoutManager.register('row', $class); }); /*Scripts/libs/Astral/Layout/ToolBarLayout.js*/ az.defineClass('ToolbarLayout', { $extends: 'AutoLayout', applyMargin: false, applyDisplayType: false, preRender: function () { this.$super.apply(this, arguments); var i = this.owner.items.length; while (i--) { if (this.owner.items[i] instanceof az.Button) { this.owner.items[i].plain = this.owner.bbar ? false : true; } this.addChildCls(this.owner.items[i], this.owner.getItemCls(i)); } }, postRender: function () { this.$super.apply(this, arguments); this._showitemPanelBtns(); this.wrapItems(); }, update: function () { this.$super.apply(this, arguments); this._showitemPanelBtns(); this.sortItems(this.owner.dom.itemPanel); this.sortItems(this.owner.__getOverflowMenuEl()); this.wrapItems(); }, wrapItems: function () { $.each($(this.owner.__getOverflowMenuEl()).children(), function () { if ($(this).html().length == 0) $(this).remove(); $(this).wrap('
'); }); // $(this.owner.__getOverflowMenuEl()).find('.az-control').wrap('
'); }, sortItems: function (elem) { var r = $(elem).children().sort(function (a, b) { // convert to integers from strings a = parseInt($(a).attr("data-index"), 10); b = parseInt($(b).attr("data-index"), 10); // compare if (a > b) { return 1; } else if (a < b) { return -1; } else { return 0; } }); $(elem).append(r); }, _showitemPanelBtns: function () { if (this.owner.items.length > 0) { for (var i = 0; i < this.owner.items.length; i++) { $(this.owner.items[i].getRootEl()).attr('data-index', i); } var overflowBtnPanel = $(this.owner.dom.overflowBtnPanel); var itemsWidthTotal = 0; var itemPanel = $(this.owner.dom.itemPanel); var leftItems, rightItems, itmLn = this.owner.items.length; var items = []; if (this.owner.rlsIndex > -1) { rightItems = this.owner.items.slice(this.owner.rlsIndex); leftItems = this.owner.items.slice(0, this.owner.rlsIndex); // leftItems.push('->'); items = leftItems.concat(rightItems.reverse()); } else { items = this.owner.items; } // var items = this.owner.items; var availableWidth = $(this.owner.getRootEl()).width(); var menuEls = $(this.owner.dom.itemPanel).children(); var tempTotal = 0; var tobeHide = []; /*$.each(menuEls, function (i, item) { tempTotal += $(this).outerWidth(true); if (tempTotal > availableWidth-25) { tobeHide.push('#'+$(this).attr('id')); //az.getCmpByElId($(this).attr('id')).hide(); } });*/ var overflowIndex = -1; for (var i = 0; i < items.length; i++) { // console.log(items[i].getRootEl()); tempTotal += $(items[i].getRootEl()).outerWidth(true); // if (i == (this.owner.rlsIndex - 1)) tempTotal +=10; if (tempTotal > availableWidth-28) { overflowIndex = i; // tobeHide.push(items[i].getRootEl()); break; //az.getCmpByElId($(this).attr('id')).hide(); } } //console.log(tobeHide); // console.log(overflowIndex); var btns = [];//this.owner.hiddenMenuBtn.menu.items; for (var i = 0; i < items.length; i++) { var rootEl = items[i].getRootEl(); var comp = $(rootEl); //console.log(items[i].$class, items[i].text); itemsWidthTotal +=comp.outerWidth(true); /*if (tobeHide.indexOf(rootEl) > -1) { comp.hide(); // btns[i].show(); } else { comp.show(); // btns[i].hide(); }*/ if (itemsWidthTotal > (availableWidth-30)) { // items[i].hide(); } else { // items[i].show(); } if ( overflowIndex > -1 && i >= overflowIndex) { //comp.hide(); /*if (btns[i]) btns[i].show(); if (btns[i]) $(btns[i].getRootEl()).parent().show();*/ $(this.owner.__getOverflowMenuEl()).append(comp); } else { // comp.show(); /*if (btns[i]) btns[i].hide(); if (btns[i]) $(btns[i].getRootEl()).parent().hide();*/ $(this.owner.dom.itemPanel).append(comp); } } //if (itemsWidthTotal > (availableWidth-22)) { if (overflowIndex>-1) { overflowBtnPanel.show(); itemPanel.css({ 'left': 0, 'width': (availableWidth-28) }); } else { overflowBtnPanel.hide(); itemPanel.css({ 'left': 0, 'width': availableWidth }); } // this.owner.enableDisableditemPanelBtns(); } } }, function ($class) { az.LayoutManager.register('toolbar', $class); }); /*Scripts/libs/Astral/Layout/MenuLayout.js*/ az.defineClass('MenuLayout', { $extends: 'AutoLayout', applyMargin: false, applyDisplayType: false, preRender: function () { this.$super(); if (this.root) { this.root.isRoot = true; } }, getContent: function () { var buffer = []; var items = this.owner.items; for (var i = 0; i < items.length; i++) { var cls = ''; if (items[i] instanceof az.Field) cls = 'az-menu-item-field'; if (items[i] instanceof az.Button) cls = 'az-menu-item-btn'; if (items[i] instanceof az.ToolbarSeparator) cls = 'az-menu-item-sep'; if (items[i] instanceof az.Panel) cls = 'az-menu-item-sep-panel'; buffer[i] = '
' + items[i].render() + '
'; } return '
' + buffer.join(''); } }, function ($class) { az.LayoutManager.register('menu', $class); }); /*Scripts/libs/Astral/Control/Control.js*/ az.defineClass('Control', { $extends: 'UIComponent', focusable: true, wrapTag: 'div', layoutTarget: 'wrapper', visible: true, rootElement: 'wrapper', clsPrefix: 'control', style: '', tpls: { wrapper: '<{wrapTag} id="{$class}-{cid}" @if(ctx.title){title="{title}"} class="az-control {css}" style="{style}" {attr} @if(global.tabIndex){tabindex="{tabIndex}"} >{content}' }, tplData: { wrapper: { css: '{css}', style: '', attr: '{attr}', title: '{title}', content: '' } }, onPositionChange: function () { this.setStyle('wrapper', this._getPositionStyle()); }, onResize: function () { if (this.rendered) { this.setStyle('wrapper', this._getSizeStyle()); } }, getLayoutSize:function () { return { boxSize: { height:(this.rendered ? $(this.getRootEl()).outerHeight() : this.height), width:(this.rendered ? $(this.getRootEl()).outerWidth() : this.width) } } }, getRootEl: function () { return az.util.escapeId(this.dom.wrapper); }, getFocusEl: function () { return az.util.escapeId(this.dom.wrapper); }, initTplData: function () { var style = this._getSizeStyle() + this._getPositionStyle() + this._getBorderStyle() + this._getPaddingStyle() +(!this.visible ? 'display:none;' : ''); this.setStyle('wrapper', style + this.style); }, setTabIndex: function (domRef, index) { if (this.rendered) { var domEl = $( az.util.escapeId(this.dom[domRef])); domEl.attr('tabIndex', index); } else { if (!this.tplData) this.tplData = {}; if (!this.tplData[domRef]) this.tplData[domRef] = {}; this.tplData[domRef].tabIndex = index; } } }); /*Scripts/libs/Astral/Control/Label.js*/ az.defineClass('Label', { $extends: 'Control', wrapTag: 'span', text: 'Label Text', tplData: { wrapper: { css: 'az-label {css}', style: '{style}', content: '{text}' } }, setText: function (txt) { this.text = txt; $(this.dom.wrapper).html(az.util.stripScriptTagsFromStr(this.text)); } }); /*Scripts/libs/Astral/Control/Button.js*/ az.defineClass('Button', { $extends: 'Control', wrapTag: 'a', text: '', title: '', iconAlign: 'left', textAlign: 'center', focusCls: az.basePrefix + '-btn-focused', plainFocusCls: az.basePrefix + '-btn-plain-focused', btnCls: az.basePrefix + '-btn', iconCls: '', iconPositionCls: az.basePrefix + '-btn-icon-', innerCls: az.basePrefix + '-btn-left', textCls: az.basePrefix + '-btn-text az-unselectable', disabledCls: az.basePrefix + '-btn-disabled', disabled: false, scale: 'small', renderPattern: '@wrapper({content:@button})', plain: false, plainCls: az.basePrefix + '-btn-plain', plainHoverCls: 'az-btn-plain-hover', hoverCls: 'az-btn-hover', plainPressedCls: 'az-btn-plain-pressed', pressedCls: 'az-btn-pressed', split: false, toggle: false, onToggle: az.emptyFn, pressed: false, events: { handle: { 'click:{$class}-{cid}': '__onClick', 'mousedown:{$class}-{cid}': '__onMouseDown', 'mouseup:{$class}-{cid}': '__onMouseUp', 'mouseenter:{$class}-{cid}': '__onMouseOver', 'mouseleave:{$class}-{cid}': '__onMouseOut', 'focus:{$class}-{cid}': '__onFocus', 'blur:{$class}-{cid}': '__onBlur', 'focusout:{$class}-{cid}': '__onFoucsOut' }, custom: ['click', 'splitclick', 'toggle', 'focus', 'blur', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'focusout'] }, tpls: { button: '{text}' }, tplData: { wrapper: { css: '{btnCls} {css}', tabIndex: '{tabIndex}', attr: ' href="javascript:void(0)" ' }, button: { textCls: '{textCls}', textElStyle: '{textElStyle}', innerCls: '{innerCls}' } }, initTplData: function () { this.$super.apply(this, arguments); this.text = (this.text.length + this.iconCls.length) == 0 ? (this.title.length == 0 ? 'Button' : '') : this.text; this.tplData.button.textCls = this.textCls + ' ' + (this.iconCls.length > 0 ? ' ' + this.iconCls : ''); if (this.text.length > 0) { this.tplData.button.textCls += this.iconCls.length > 0 ? ' ' + this.iconPositionCls + this.iconAlign : ''; } else { this.tplData.button.textCls += this.iconCls.length > 0 ? ' az-btn-icon-only' : ''; } if (this.iconAlign == 'top') this.addCls('wrapper', 'az-btn-vertical'); if (this.plain) this.addCls('wrapper', this.plainCls); if (this.disabled) this.addCls('wrapper', this.disabledCls); if (this.textAlign != 'center') this.tplData.button.textElStyle = 'text-align:' + this.textAlign; }, onDisabled: function () { this.addCls('wrapper', this.disabledCls); this.removeCls('wrapper', this.getHoverCls()); this.removeCls('wrapper', this.getFocusCls()); }, onEnabled: function () { this.removeCls('wrapper', this.disabledCls); }, setPressed: function (bool) { if (!this.disabled) { this.pressed = bool; if (bool) this.addCls('wrapper', this.getPressedCls()); else this.removeCls('wrapper', this.getPressedCls()); } }, __onMouseOver: function (event) { if (!this.disabled) { this.addCls('wrapper', this.getHoverCls()); this.fireEvent('mouseenter', event); } }, __onMouseOut: function (event) { this.removeCls('wrapper', this.getHoverCls()); this.removeCls('wrapper', this.getFocusCls()); if (!this.toggle) this.setPressed(false); this.fireEvent('mouseleave', event); }, __onMouseDown: function (control, event) { if (!this.disabled) { if (this.toggle) { this.setPressed(!this.pressed); this.onToggle(this.pressed); this.fireEvent('toggle', event, this.pressed); } else this.setPressed(true); this.fireEvent('mousedown', event); } }, __onMouseUp: function (event) { //if (!this.toggle) this.removeCls('wrapper', this.getPressedCls()); if (!this.toggle || (this.toggle && !this.pressed )) this.setPressed(false); this.fireEvent('mouseup', event); }, __onClick: function (control, event) { if (!this.disabled) { if (this.toggle) { //this.pressed = !this.pressed; // this.setPressed(!this.pressed); // this.onToggle(this.pressed); // this.fireEvent('toggle', event, this.pressed); } this.fireEvent('click', event); } }, __onFocus: function (event) { if (!this.disabled) { this.addCls('wrapper', this.getFocusCls()); az.FocusManager.FocusedElementId = this.getFocusEl().replace('#', ''); } this.fireEvent('focus', event); }, __onBlur: function (event) { this.removeCls('wrapper', this.getFocusCls()); if (this.toggle && !this.pressed) { this.removeCls('wrapper', this.getPressedCls()); } this.fireEvent('blur', event); }, __onFoucsOut: function (event) { this.fireEvent('focusout', event); }, setText: function (btnText) { this.text = btnText; var innerHtml = $('#' + az.format('{$class}-{cid}', this)).find('span.az-btn-text').find('span'); $('#' + az.format('{$class}-{cid}', this)).find('span.az-btn-text').html(btnText).append(innerHtml); }, setTitle: function (title) { this.title = title; $(this.getRootEl()).attr('title', this.title); }, _getSizeStyle: function () { return (this.height != undefined ? 'height:' + (this.height - (this.getThemeValue('borderWidth')) * 2) + 'px;' : '') + (this.width != undefined ? 'width:' + (this.width - (this.getThemeValue('borderWidth')) * 2) + 'px;' : ''); // width: auto }, getFocusEl: function () { return this.dom.wrapper; }, getFocusCls: function () { return this.plain ? this.plainFocusCls : this.focusCls; }, getHoverCls: function () { return this.plain ? this.plainHoverCls : this.hoverCls; }, getPressedCls: function () { return this.plain ? this.plainPressedCls : this.pressedCls; } }); /*Scripts/libs/Astral/Control/MenuItem.js*/ az.defineClass('MenuItem', { $extends: 'Button', toggle: true, isRoot: true, arrow: 'down', plainItem: true, tplData: { button: { text: '{text}' } }, events: { custom: ['menushow', 'menuhide'] }, initTplData: function () { this.$super.apply(this, arguments); this.tplData.button.text = this.text + (this.arrow ? ' ':''); }, init: function () { this.$super.apply(this, arguments); this.menu = new az.Menu({ items: (this.menu || []), owner: this, css: (this.menuCls || ''), itemCls: (this.itemCls || ''), plainItem: this.plainItem }); this.menu.addListener('hide', this.onMenuHide, this); if(!(this.owner instanceof az.Menu)) az.MenuManager.register(this); }, render: function () { if (this.menu) this.menu.render(); return this.$super.apply(this, arguments); }, onToggle: function (pressed) { this.menu[pressed ? 'show' : 'hide'](); this.fireEvent((pressed ? 'menushow' : 'menuhide'), this.menu); }, setMenuVisible: function (visible) { this.pressed = visible; this.setPressed(visible); this.menu[visible ? 'show' : 'hide'](); }, destroy: function () { if (this.menu) this.menu.destroy(); this.$super.apply(this, arguments); }, onMenuHide: function () { $.each(this.menu.items, function (i, item) { if (item instanceof az.MenuItem && item.pressed) item.setMenuVisible(false); }); } }); /*Scripts/libs/Astral/Control/SplitButton.js*/ az.defineClass('SplitButton', { $extends: 'MenuItem', toggle: false, init: function () { this.$super.apply(this, arguments); this._createMenu(); }, _createMenu: function () { if (this.items && az.chk.ifArray(this.items)) { var me = this; $.each(this.items, function (index, item) { me.menu.items.push(item); }); } }, initTplData: function () { this.$super.apply(this, arguments); this.tplData.button.text = this.text + az.format(' ', this); }, events: { handle: { 'click:button-{cid}-arrow': '__onArrowClick' }, custom: ['handler'] }, __onArrowClick: function (control, event) { this.setMenuVisible(!this.pressed); }, __onMouseOut: function (event) { this.removeCls('wrapper', this.getHoverCls()); this.removeCls('wrapper', this.getFocusCls()); if (!this.pressed) this.setPressed(false); this.fireEvent('mouseleave', event); }, __onMouseDown: function (event) { if (!this.disabled) { if (this.pressed) this.setMenuVisible(false); else this.setPressed(false); this.fireEvent('mousedown', event); } }, __onMouseUp: function (event) { if (!this.pressed) this.setPressed(false); this.fireEvent('mouseup', event); } }); /*Scripts/libs/Astral/Control/ButtonGroup.js*/ az.defineClass('ButtonGroup', { $extends: 'Container', layoutTarget: 'body', layout: 'buttongroup', defaultClass: 'Button', renderPattern: '@root({content:@header+@body})', padding: 1, border: 1, spanSize:24, title: 'Button Group', tpls: { header: '
{title}
', body: '
{content}
' }, tplData: { root: { style: '{style}', css: 'az-panel az-btn-group {css}', content: '' } }, initTplData: function () { this.__initStyle(); this.$super.apply(this, arguments); }, _isValidClass: function (comp) { return comp instanceof az.Button || comp instanceof az.ButtonGroup || comp instanceof az.MenuItem || comp instanceof az.Field; }, __initStyle: function () { var rootBoderStyle = this._getBorder('top') + 'px ' + this._getBorder('right') + 'px ' + this._getBorder('bottom') + 'px ' + this._getBorder('left') + 'px;'; this.setStyle('root', 'border-width:' + rootBoderStyle); }, _createChild: function (config) { var type = config.$class || this.defaultClass; delete config.$class; az.copyIf(config, this.defaults); return az.create(type, config); }, initChildren: function () { var i = 0, j = this.items.length, items = this.items; while (i < j) { if (az.chk.ifString(items[i])) { if (items[i] == '->') { this.rlsIndex = i; items.splice(i, 1); j = this.items.length, items = this.items; i = i; } else if (items[i] == '-') { items[i] = new az.ToolbarSeparator(); items[i].owner = this; i++; } else { i++; } continue; } else { if (items[i].menu) { items[i].$class = 'MenuItem'; items[i].menu = new az.Menu(items[i].menu); } var item = (items[i] instanceof az.UIComponent) ? items[i] : this._createChild(items[i]); if (this._isValidClass(item)) { items[i] = item; items[i].owner = this; if (items[i].menu) { items[i].menu.parentNode = items[i]; items[i].isRoot = true; mbh.add(items[i]); } } else { throw "invalid child found in component " + this.cid; } i++; continue; } } }, add: function (comp, index, notify) { if (az.chk.ifString(comp) && comp == '-') { comp = new az.ToolbarSeparator(); } if (!comp instanceof az.UIComponent && !this._isValidClass(comp)) return; this.$super.apply(this, arguments); } }); /*Scripts/libs/Astral/Control/ToolBarSeparator.js*/ az.defineClass('ToolbarSeparator', { $extends: 'Control', wrapTag: 'span', renderPattern: '@wrapper', sepCls: 'az-toolbar-sep-hor', tplData: { wrapper: { css: 'az-toolbar-sep {sepCls}', content: ' ' } } }); /*Scripts/libs/Astral/Container/Layer.js*/ az.defineClass('Layer', { $extends: 'Container', css: 'az-layer', visible: true, init: function () { this.$super.apply(this, arguments); az.LayerManager.add(this); }, preRender: function () { this.$super.apply(this, arguments); this.setStyle('root', { position: 'absolute', top: (this.top ? this.top + 'px' : '0px'), left: (this.left ? this.left + 'px' : '0px') ,overflow: 'visible', display: (this.visible? 'block' : 'none') }); }, render: function () { this.preRender(); if (this.items.length > 0) this.tplData[this.layoutTarget].content = this.layout.getContent(); $('body').append(this._renderContent(this.tplData)); this.rendered = true; this.postRender(); }, onResize: function () { this.setStyle('root', { height: (this.height ? this.height + 'px' : '0px'), width: (this.width ? this.width + 'px' : '0px') }); if(this.rendered)this.layout.update(); }, onPositionChange: function () { this.setStyle('root', { position: 'absolute', top: (this.top ? this.top + 'px' : '0px'), left: (this.left ? this.left + 'px' : '0px') }); }, activate: function () { az.LayerManager.bringToTop(this); } }); /*Scripts/libs/Astral/Control/Menu.js*/ az.defineClass('Menu', { $extends: 'Layer', layout: 'menu', renderPattern: '@root+@shadow', defaultClass: 'Button', visible: false, rolling: false, tpls: { shadow: '' }, tplData: { root: { css: 'az-menu {css}', content: '' } }, events: { handle: { 'mouseenter:Menu-{cid}': '__onMouseEnter', 'mouseleave:Menu-{cid}': '__onMouseLeave', 'keydown:Menu-{cid}': '__onKeyDown' }, custom: ['mouseenter', 'mouseleave'] }, _isValidClass: function (comp) { return comp instanceof az.Button || comp instanceof az.ButtonGroup || comp instanceof az.Panel || comp instanceof az.ToolbarSeparator || comp instanceof az.Field || comp instanceof az.ColorPanel; }, _createChild: function (config) { var type = config.$class || this.defaultClass; delete config.$class; az.copyIf(config, this.defaults); return az.create(type, config); }, init: function () { this.$super.apply(this, arguments); this.attr = "tabindex=" + this.cid.replace('az-com-', ''); }, initChildren: function () { var i = 0, j = this.items.length, items = this.items; while (i < j) { if (az.chk.ifString(items[i])) { if (items[i] == '-') { items[i] = new az.ToolbarSeparator(); items[i].owner = this; i++; } else { i++; } continue; } else if (items[i].$class == 'ToolbarSeparator') { if (!(items[i] instanceof az.ToolbarSeparator)) items[i] = new az.ToolbarSeparator(); items[i].owner = this; i++; continue; } else { if (items[i].menu) items[i].$class = 'MenuItem'; var item = (items[i] instanceof az.UIComponent) ? items[i] : this._createChild(items[i]); if (this._isValidClass(item)) { items[i] = item; if (items[i] instanceof az.Button) { items[i].plain = az.chk.ifDefined(this.plainItem)? this.plainItem : true; items[i].arrow = 'right'; items[i].textAlign = 'left'; if (items[i].$class == 'Button') items[i].addListener('click', this.onButtonClick, this); } if (items[i].menu) { items[i].isRoot = false; items[i].addListener('menushow', this.onMenuItemMenuShow, this); } items[i].addListener('mouseenter', this.onMenuItemMouseEnter, this); items[i].addListener('mouseleave', this.onMenuItemMouseLeave, this); items[i].owner = this; if (this.itemCls) items[i].css = this.itemCls; items[i].tabIdx = (items[i].isContainer) ? '-1' : '0'; } else { throw "invalid child found in component " + this.cid; } i++; continue; } } }, preRender: function () { this.$super.apply(this, arguments); this.setStyle('root', { 'overflow': 'hidden' }); }, show: function (control, event) { this.$super.apply(this, arguments); var mBtn = $(this.owner.dom.wrapper), menu = $(this.dom.root), zindex = az.LayerManager.getTopZindex(), top = this.owner.arrow == 'right' ? mBtn.offset().top : mBtn.offset().top + mBtn.outerHeight(), left = this.owner.arrow == 'right' ? mBtn.offset().left + mBtn.outerWidth() + 3 : mBtn.offset().left; if ((mBtn.offset().top + menu.outerHeight()) > $(window).height()) { top = mBtn.offset().top - menu.outerHeight(); } if ((mBtn.offset().left + menu.outerWidth()) > $(window).width()) { left = (mBtn.outerWidth() + mBtn.offset().left) - menu.outerWidth(); } menu.css({ 'top': top, 'left': left, 'zIndex': zindex }); $(this.dom.shadow).css({ 'width': menu.outerWidth(), 'height': menu.outerHeight(), 'top': menu.offset().top, 'left': menu.offset().left, 'zIndex': zindex - 1 }).show(); //this.focus(); $(this.getRootEl()).find('.az-menu-init-focus').focus(); }, hide: function (control, event) { this.$super.apply(this, arguments); $('#menu-shadow-' + this.cid).hide(); }, add: function (comp, index, notify) { if (az.chk.ifString(comp) && comp == '-') { comp = new az.ToolbarSeparator(); } if (comp instanceof az.Button) { comp.plain = true; } if (!comp instanceof az.UIComponent && !this._isValidClass(comp)) return; this.$super.apply(this, arguments); }, __onMouseEnter: function (event) { this.fireEvent('mouseenter', event); }, __onMouseLeave: function (event) { this.fireEvent('mouseleave', event); }, onMenuItemMenuShow: function (control) { $.each(this.items, function (i, item) { if (control.cid != item.cid && (item instanceof az.MenuItem) && item.pressed) item.setMenuVisible(false); }); }, onMenuItemMouseEnter: function (control) { var me = this; $.each(this.items, function (i, item) { if (control.cid == item.cid && item instanceof az.MenuItem) item.setMenuVisible(true); else if (item instanceof az.MenuItem && item.pressed) { item.setMenuVisible(false); } }); }, onButtonClick: function (control) { this.getRoot(control).setMenuVisible(false); az.MenuManager.lastPop = undefined; }, getRoot: function (control) { return control.isRoot ? control : this.getRoot(control.owner.owner); }, /*onFocusOut: function () { this.$super.apply(this, arguments); },*/ destroy: function () { $('#menu-shadow-' + this.cid).remove(); this.$super.apply(this, arguments); } }); /*Scripts/libs/Astral/Control/MenuManager.js*/ az.defineSingleton('MenuManager', { menuItems: [], lastPop: undefined, register: function(mi) { this.menuItems.push(mi); var me = this; mi.addListener('toggle', function (control, event, pressed) { if (pressed) { if (me.lastPop) me.lastPop.setMenuVisible(false); me.lastPop = control; } else { me.lastPop = undefined; } }); mi.addListener('focus', function (e) { console.log('focus', arguments); }); mi.addListener('blur', function (e) { console.log('blur', arguments); }); }, init: function () { var me = this; }, toolbarItems: [], currentActiveMenu:undefined, add: function (item) { this.toolbarItems.push(item); if (item instanceof az.MenuItem) { //-- item.addListener('menushow', this.onMenuItemMenuShow, this); //-- item.addListener('menuhide', this.onMenuItemMenuHide, this); item.isRoot = true; } else { //-- item.addListener('focus', this.onItemFocus, this); } }, onMenuItemMenuShow: function (control) { this.currentActiveMenu = control; $.each(this.toolbarItems, function (i, item) { //-- if (control.cid != item.cid && (item instanceof az.MenuItem) && item.pressed) item.setMenuVisible(false); }); }, onMenuItemMenuHide: function () { this.currentActiveMenu = undefined; }, onItemFocus: function (control) { var me = this; $.each(this.toolbarItems, function (i, item) { if (control.cid == item.cid && item instanceof az.MenuItem) item.setMenuVisible(true); else if (item instanceof az.MenuItem && item.pressed) { //-- item.setMenuVisible(false); } }); }, hideMenu: function () { var me= this; $.each(this.toolbarItems, function (i, item) { if (item.pressed) item.setMenuVisible(false); //-- me.currentActiveMenu =undefined; }); } }); az.__addToInitQueue(function () { $("body").bind("click", function(e) { if (az.MenuManager.lastPop) { var control = az.MenuManager.lastPop; console.log(e.target, control.getRootEl()); var r = control.getRootEl().replace('#', ''); var p = $(e.target).parents(); for (var i = 0; i < p.length; i++) { if ($(p[i]).attr('id') == r) return; } if (!$(e.target).parents().hasClass('az-menu')) { az.MenuManager.lastPop.setMenuVisible(false); az.MenuManager.lastPop = undefined; } } }); $(document).keyup(function (e) { if (e.keyCode == 27) { // handle scape // az.MenuManager.hideMenu(); if (az.MenuManager.lastPop) { az.MenuManager.lastPop.setMenuVisible(false); az.MenuManager.lastPop = undefined; } } if (e.keyCode == 9) { console.log(e); if (az.MenuManager.lastPop) { if( $(az.MenuManager.lastPop.menu.getRootEl()).hasClass('az-focus')) az.MenuManager.lastPop.menu.items[0].focus(); // az.MenuManager.lastPop.setMenuVisible(false); // az.MenuManager.lastPop = undefined; } } if (e.keyCode == 40) { // me.onDownArrowPress(); } }); $(document).mouseup(function (e) { // console.log($(e.target).parents()); // var menuRootElmId =az.MenuManager.currentActiveMenu? az.MenuManager.currentActiveMenu.getRootEl().replace('#', '') : '' ; // console.log(menuRootElmId); // var prs = $(e.target).parents(); }); $(document).focusout(function (e) { setTimeout(function () { /*if (e.target.id != undefined && e.target.id.indexOf('MenuItem', '') > 0 ) { $.each(az.MenuManager.toolbarItems, function (i, item) { // if (az.MenuManager.currentActiveMenu.cid!= item.cid && item.pressed) item.setMenuVisible(false); }); }*/ }, 200); /*if (e.target.id != undefined && $(e.target.id).parents('.az-menu-item').length > 0) { $.each(az.MenuManager.toolbarItems, function (i, item) { if (item.pressed) item.setMenuVisible(false); }); } else { az.MenuManager.hideMenu(); }*/ }); }); /*Scripts/libs/Astral/Control/Toolbar.js*/ az.defineClass('Toolbar', { $extends: 'Container', padding: { top:3, left:1, right:1, bottom:3}, border: 1, layout: 'toolbar', defaultClass: 'Button', renderPattern: '@root({content:@overflowBtnPanel+@itemPanel})', layoutTarget: 'itemPanel', itemCls: 'az-toolbar-item', leftAlignCls: 'az-toolbar-item-l', rightAlignCls: 'az-toolbar-item-r', centerAlignCls: 'az-toolbar-item-c', centerAlign: false, rlsIndex: -1, tpls: { itemPanel: '
{content}
', overflowBtnPanel: '
{content}
', }, overflowMenuPanelTpl: az.createTpl('
{content}
'), tplData: { root: { style: '{style}', css: 'az-toolbar az-border {css}', content: '' }, overflowBtnPanel: { content: '' }, itemPanel: { content: '', itemPanelCls: '{itemPanelCls}' }, overflowMenuPanel: { content: '' } }, events: { handle: { 'click:toolbar-{cid}-slideBtn-next': 'slideNextClick', 'click:toolbar-{cid}-slideBtn-prev': 'slidePrevClick' } }, init: function() { this.$super.apply(this, arguments); var me = this; /* var _menu = []; for (var i = 0; i < this.items.length; i++) { if (this.items[i] == '->') continue; if (this.items[i] == '-') { _menu.push('-'); continue; } var item = {}; az.copy(item, this.items[i]); _menu.push(item); if (this.items[i].menu || this.items[i].items) this.__copyChild(item, this.items[i]); }*/ this.hiddenMenuBtn = new az.Button({ owner: this, plain: true, arrow: false, title: 'Hidden Menu Items', iconCls: 'az-icon-tbar-more', toggle: true, listeners: { toggle: function(control, event, toggled) { var btn = $(control.getRootEl()); $(me.__getOverflowMenuEl())[toggled ? 'show' : 'hide'](); if (toggled) { $(me.__getOverflowMenuEl()).css({ top: btn.offset().top + btn.outerHeight(), left: btn.offset().left, zIndex: az.LayerManager.getTopZindex() }); } } } }); this.hiddenMenuBtn.preRender(); this.tplData.overflowBtnPanel.content = this.hiddenMenuBtn.render(); // az.MenuManager.add(this.hiddenMenuBtn); var splitIndex = this.items.indexOf('->'); var leftItems, rightItems, itmLn = this.items.length; if (splitIndex > -1) { rightItems = this.items.slice(splitIndex + 1); leftItems = this.items.slice(0, splitIndex); leftItems.push('->'); this.items = leftItems.concat(rightItems.reverse()); } this.setStyle('root', this._getPaddingStyle()); }, __getOverflowMenuEl: function() { return '#' + this.$class + '-' + this.cid + '-overflow-menu-panel'; }, __copyChild: function(item, originalComp) { var _items = []; var items = originalComp.menu || originalComp.items; for (var i = 0; i < items.length; i++) { if (items[i] == '->') continue; if (items[i] == '-') { _items.push('-'); continue; } var _item = {}; az.copy(_item, items[i]); _items.push(_item); if (items[i].menu || items[i].items) this.__copyChild(_item, items[i]); } item[originalComp.menu ? 'menu' : 'items'] = _items; }, initTplData: function() { this.$super.apply(this, arguments); if (this.centerAlign) this.tplData.itemPanel.itemPanelCls = 'az-toolbar-center-align'; }, _isValidClass: function(comp) { return comp instanceof az.Button || comp instanceof az.ButtonGroup || comp instanceof az.MenuItem || comp instanceof az.Field || comp instanceof az.Pager; }, _createChild: function(config) { var type = config.$class || this.defaultClass; delete config.$class; az.copyIf(config, this.defaults); return az.create(type, config); }, render: function(){ $('body').append(this.overflowMenuPanelTpl(this)); return this.$super.apply(this, arguments); }, postRender: function() { this.$super.apply(this, arguments); this.hiddenMenuBtn.postRender(); }, initChildren: function () { var i = 0, j = this.items.length, items = this.items; while (i < j) { if (az.chk.ifString(items[i])) { if (items[i] == '->') { this.rlsIndex = i; items.splice(i, 1); j = this.items.length, items = this.items; i = i; } else if (items[i] == '-') { items[i] = new az.ToolbarSeparator(); items[i].owner = this; i++; } else { i++; } continue; } else if (items[i].$class == 'ToolbarSeparator') { if (!(items[i] instanceof az.ToolbarSeparator)) items[i] = new az.ToolbarSeparator(); items[i].owner = this; i++; continue; } else { if (items[i].menu && !items[i].$class) items[i].$class = 'MenuItem'; var item = (items[i] instanceof az.UIComponent) ? items[i] : this._createChild(items[i]); if (this._isValidClass(item)) { items[i] = item; items[i].owner = this; items[i].tabIdx = (items[i].isContainer) ? '-1' : '0'; az.MenuManager.add(items[i]); } else { throw "invalid child found in component " + this.cid; } i++; continue; } } }, getItemCls: function (index) { return this.centerAlign ? (this.itemCls + ' ' + this.centerAlignCls) : this.itemCls + ' ' + ((index < this.rlsIndex || this.rlsIndex == -1) ? this.leftAlignCls : this.rightAlignCls); }, add: function (comp, index, notify,alignment) { if (!az.chk.ifString(comp) && !(comp instanceof az.Control)) { comp = comp.$class == 'ToolbarSeparator' ? new az.ToolbarSeparator() : this._createChild(comp); } if (az.chk.ifString(comp) && comp == '-') { comp = new az.ToolbarSeparator(); } if (comp instanceof az.Button) { comp.plain = this.bbar ? false : true; } if ((comp instanceof az.UIComponent) && !this._isValidClass(comp)) return; if (!alignment && this.rlsIndex > -1 ) { index = this.rlsIndex; } this.$super.apply(this, arguments); var cls = (alignment && alignment == 'right') ? this.rightAlignCls : this.leftAlignCls; if (cls == this.leftAlignCls) this.rlsIndex++; comp.addCls(comp.rootElement,cls ); az.MenuManager.add(comp); this.owner._adjustBody(); }, addRange: function() { this.$super.apply(this, arguments); this.owner._adjustBody(); }, onResize: function() { this.$super.apply(this, arguments); if (this.hiddenMenuBtn.toggled) this.hiddenMenuBtn.setPressed(false); }, // slideNextClick: function (control, event) { // if (this.items.length > 0 && $('#' + event.elementId).hasClass('az-toolbar-slideBtn-active')) { // var me = this; // var toolbarWidth = $(this.dom.root).width(), slider = $(this.dom.itemPanel); // var maxLeft = ((slider.width() + 20) - toolbarWidth); // var currentleft = Math.abs(parseInt(slider.css('left').replace('px', ''))); // var offsetLeft = ((maxLeft - currentleft) > 100) ? (currentleft + 100) : maxLeft; // slider.animate({ left: -offsetLeft }, function () { // me.enableDisabledSliderBtns(); // }); // }; // }, // slidePrevClick: function (control, event) { // if (this.items.length > 0 && $('#' + event.elementId).hasClass('az-toolbar-slideBtn-active')) { // var me = this; // var slider = $(this.dom.itemPanel), minLeft = 20; // var currentleft = parseInt(slider.css('left').replace('px', '')); // console.log(currentleft); // var offsetLeft = ((currentleft + minLeft) < -100) ? (currentleft + 100) : minLeft; // slider.animate({ left: offsetLeft }, function () { // me.enableDisabledSliderBtns(); // }); // } // }, enableDisabledSliderBtns: function () { if (this.items.length > 0) { var toolbarWidth = $(this.dom.root).width(); var itemPanel = $(this.dom.itemPanel); if (itemPanel.length > 0) { var maxLeft = ((itemPanel.width() + 20) - toolbarWidth); var currentleft = parseInt(itemPanel.css('left').replace('px', '')); if (currentleft <= (-maxLeft)) { this.addCls('overflowBtnPanel', 'az-toolbar-slideBtn-disabled'); this.removeCls('overflowBtnPanel', 'az-toolbar-slideBtn-active'); } else { this.removeCls('overflowBtnPanel', 'az-toolbar-slideBtn-disabled'); this.addCls('overflowBtnPanel', 'az-toolbar-slideBtn-active'); } } } }, getlayoutSize: function () { return { boxSize: { height: (this.rendered ? $(this.getRootEl()).outerHeight() : this.height), width: (this.rendered ? $(this.getRootEl()).outerWidth() : this.width) }, contentAreaSize: ( this.rendered ? { height: $(this.dom[this.layoutTarget]).height(), width: $(this.dom[this.layoutTarget]).width()} : { height: this.height - (this._getBorder('top') + this._getBorder('bottom') + this._getPadding('top') + this._getPadding('bottom')), width: this.width - (this._getBorder('left') + this._getBorder('right') + this._getPadding('left') + this._getPadding('right')) } ) }; } }); /*Scripts/libs/Astral/Control/Field/Field.js*/ az.defineClass('Field', { $extends: 'Control', hideLabel: false, labelPosition: 'left', labelSeparator: ':', labelWidth: 100, labelGap: 3, labelStyle: '', inputStyle: '', fieldCls: az.basePrefix + '-field', focusCls: az.basePrefix + '-field-focused', isValid: true, invalidCls: '', disabledCls: '', textAlign: 'left', required: false, tooltip: false, tooltipTitle: '', labelIcon: false, events: { auto: { 'input-{cid}': 'mouseenter,mouseleave,focusout' }, handle: { 'change:input-{cid}': 'onChange', 'focus:input-{cid}': 'onFocus', 'blur:input-{cid}': 'onBlur', 'keydown:input-{cid}': 'onKeyDown' }, custom: ['change', 'focus', 'blur', 'labelchange', 'keydown'], intercept: { // 'focus:input-{cid}': 'onBeforeFocus' } }, tpls: { wrapper: '<{wrapTag} id="{$class}-{cid}" @if(ctx.title){title="{title}"} class="az-control {css}" style="{style}" {attr} >{content}', label: '@if(!global.hideLabel){}', input: '' }, tplData: { wrapper: { css: '{fieldCls} {css}' }, label: { css: '{labelCls}', style: '{labelStyle}', content: '{label}', forEl: '', labelPosition: '{labelPosition}' }, input: { disabled: '{disabled}', readOnly: '{readOnly}', value: '{value}', otherAttr: '', style: '{inputStyle}', css: '{inputCls}', textAlign: '{textAlign}' } }, getLayoutSize: function () { var height, width; if (this.rendered) { width = $(this.getRootEl()).outerWidth(); height = $(this.getRootEl()).outerHeight(); } else { if (this.labelPosition == 'top' || this.hideLabel) { width = this.width; } else { width = this.width + this.labelWidth + this.labelGap; } height = this.height || this.getThemeValue('inputHeight'); } return { boxSize: { height: height, width: width} }; }, validate: az.emptyFn, setRequired: function(required) { this.required=required; this.initTooltipAndValidation(); this.onResize(); }, setTooltip: function(text) { this.tooltip = text; this.initTooltip(); this.initTooltipAndValidation(); this.onResize(); }, initTooltipAndValidation: az.emptyFn, _getInputBorderPadding: function () { return (this.getThemeValue('inputPadding') + this.getThemeValue('inputBorder')) * 2; }, init: function () { this.$super.apply(this, arguments); // this.tabIdx = this.cid.replace('az-com-', ''); }, initTplData: function () { this.tplData.label.forEl = this.getFocusEl(); if (!this.hideLabel) { this.setStyle('label', this.labelStyle); this.setStyle('label', 'width', this.labelWidth + 'px'); this.setStyle('label', 'margin-right', this.labelGap + 'px'); } //if (this.disabled) this.addCls('input', this.disabledCls); this.setStyle('wrapper', 'width:' + ((this.hideLabel || this.labelPosition == 'top' ? 0 : this.labelWidth + this.labelGap) + this.width) + 'px;' + this.style+ (!this.visible ? 'display:none;' : '')); this.initTooltipAndValidation(); }, getFocusEl: function () { return this.dom.input; }, setLabel: function (labelText) { this.label = labelText; if (this.rendered && !this.hideLabel) $(this.dom.label).html(labelText + this.labelSeparator); this.fireEvent('labelchange'); }, hasChanged: function () { return this.__oldValue == this.getValue(); }, onBeforeFocus: function (event) { return this.isValid; }, onFocus: function (event) { var focusEl = this.getFocusEl(); this.clearInvalid(); if (this.isValid && !this.readOnly) { this.addCls('wrapper', this.focusCls) this.focused = true; az.FocusManager.FocusedElementId = focusEl.replace('#', ''); } this.fireEvent('focus', event); }, onBlur: function (event) { this.removeCls('wrapper', this.focusCls); this.focused = false; this.validate(); this.fireEvent('blur', event); }, onChange: function (control, event) { this.__oldValue = this.value; this.value = this.getValue(); this.fireEvent('change', event, this.value, this.__oldValue); }, onResize: function () { var inputWidth = this.width; if (this.rendered) { this.setStyle('wrapper', 'width', ((this.hideLabel || this.labelPosition == 'top' ? 0 : this.labelWidth + this.labelGap) + inputWidth) + 'px'); this.setStyle('input', 'width', (this.width - this._getInputBorderPadding()- (this.required? this.getThemeValue('helperSize'): 0 ) -(this.tooltip?this.getThemeValue('helperSize'): 0 ) ) + 'px'); } }, onKeyDown: function (control, event) { // this.__oldValue = this.value; // this.value = this.getValue(); this.fireEvent('keydown', event); }, setDisabled: function (val, notify) { this.disabled = val; if (this.rendered) { if (this.disabled) { $(this.dom.input).attr('disabled', 'disabled'); this.addCls('input', this.disabledCls); if (notify) this.fireEvent('disable'); } else { this.removeAttr('input', 'disabled'); this.removeCls('input', this.disabledCls); if (notify) this.fireEvent('enable'); } } }, setReadOnly: function(readOnly){ this.readOnly= readOnly; if(this.readOnly)$(this.dom.input).attr('readonly', 'readonly'); else $(this.dom.input).removeAttr('readonly'); }, enable: function (notify) { this.setDisabled(false, notify); }, disable: function (notify) { this.setDisabled(true, notify); }, formatValue: az.doNothingFn, parseValue: az.doNothingFn, getRawValue: az.emptyFn, setRawValue: az.emptyFn, setValue: function (val, notify) { this._oldValue = this.value; this.value = val; this.setRawValue(this.formatValue(val)); if (notify){ this.fireEvent('change', null, this.value, this.__oldValue); this.validate(); } }, getValue: function () { return this.parseValue(this.getRawValue()); }, markInvalid: function () { if (!this.isValid) return; this.isValid = false; this.addCls('wrapper', this.invalidCls); }, clearInvalid: function () { if (this.isValid) return; this.isValid = true; this.removeCls('wrapper', this.invalidCls); }, postRender: function () { this.$super.apply(this, arguments); this.initTooltip(); }, initTooltip: function() { if (this.tooltip) { var config = { style: 'qtip-bootstrap', hide: { fixed: true, delay: 300 }, content: { text: this.tooltip, title: { button: false, } } }; if (this.tooltipTitle) { config.content.title.text = this.tooltipTitle; } $(this.dom.tooltip).qtip(config); } } }); /*Scripts/libs/Astral/Control/Field/TextField.js*/ az.defineClass('TextField', { $extends: 'Field', readOnly: false, renderPattern: '@wrapper({content:@label+ @tooltip + @validationHelper + @inputWrapper({input:@input}) })', autocomplete: 'off', blankText: '', type: 'text', invalidCls: az.basePrefix + '-field-text-invalid', disabledCls: az.basePrefix + '-field-text-disabled', maxLength: 100, tplData: { input: { css: '{inputCls}' }, inputWrapper: { input: '' }, validationHelper: { style: '' }, tooltip: { style: '', content: '{tooltip}' } }, tpls: { inputWrapper: '
{input}
', validationHelper: '', tooltip: ' ' }, events: { auto: { 'input-{cid}': 'mouseenter,mouseleave' }, handle: { 'keypress:input-{cid}': 'onKeyPress', 'keyup:input-{cid}': 'onKeyUp', 'focusout:input-{cid}': 'onFocus' }, intercept: { 'keypress:input-{cid}': 'interceptKeyPress' }, custom: ['keypress', 'keyup'] }, interceptKeyPress: function (event) { if (event.charCode > 0 && this.allowedCharsRe) return this.allowedCharsRe.test(String.fromCharCode(event.charCode)); return true; }, onKeyPress: function (control, event) { this.fireEvent('keypress', event); }, onKeyUp: function (control, event) { // this.validate(); this.fireEvent('keyup', event); }, init: function () { this.$super.apply(this, arguments); if (this.allowedCharsRe && this.allowedCharsRe.length > 0) this.allowedCharsRe = new RegExp(this.allowedCharsRe); }, onResize: function () { this.$super.apply(this, arguments); this._adjustLabelPositioning(); }, initTplData: function () { this.$super.apply(this, arguments); this.addCls('wrapper', 'az-field-text'); /*if ((this.waterMarkText && this.waterMarkText.length > 0) && this.tplData.input.value.length == 0) { this.tplData.input.value = this.type == 'password' ? '' : this.waterMarkText; this.addCls('input', 'az-field-text-watermark'); }*/ // if (this.disabled) { this.addCls('inputWrapper', this.disabledCls); } this.setStyle('input', 'width', (this.width - this._getInputBorderPadding() - (this.required ? this.getThemeValue('helperSize') : 0) - (this.tooltip ? this.getThemeValue('helperSize') : 0)) + 'px'); }, initTooltipAndValidation: function () { this.setStyle('tooltip', { 'display': (this.tooltip ? 'block' : 'none') }); this.setStyle('validationHelper', { 'display': (this.required ? 'block' : 'none') }); }, getRawValue: function () { if (this.rendered) return (this.waterMarkText && $(this.dom.input).val() == this.waterMarkText) ? '' : $(this.dom.input).val(); else return this.value; }, setRawValue: function (val) { val = val == undefined ? '' : val; $(this.dom.input).val(val); if (this.waterMarkText && this.waterMarkText == val && this.type != 'password') { this.addCls('input', 'az-field-text-watermark'); } else this.removeCls('input', 'az-field-text-watermark'); }, setDisabled: function (val, notify) { this.disabled = val; if (this.rendered) { if (this.disabled) { $(this.dom.input).attr('disabled', 'disabled'); this.addCls('inputWrapper', this.disabledCls); if (notify) this.fireEvent('disable'); } else { this.removeAttr('input', 'disabled'); this.removeCls('inputWrapper', this.disabledCls); if (notify) this.fireEvent('enable'); } } }, onFocus: function () { this.$super.apply(this, arguments); /* if (this.type == 'password') { this.removeCls('input', 'az-field-text-watermark'); }; if (this.waterMarkText && this.waterMarkText.length > 0 && $(this.dom.input).val() == this.waterMarkText) { $(this.dom.input).val(''); this.removeCls('input', 'az-field-text-watermark'); }*/ }, onBlur: function () { this.$super.apply(this, arguments); /* if (this.type == 'password') { if ($(this.dom.input).val().length == 0) this.addCls('input', 'az-field-text-watermark'); else { this.removeCls('input', 'az-field-text-watermark'); } } else if (this.waterMarkText && this.waterMarkText.length > 0 && ($(this.dom.input).val() == this.waterMarkText || $(this.dom.input).val().length == 0)) { $(this.dom.input).val(this.waterMarkText); this.addCls('input', 'az-field-text-watermark'); }*/ }, validate: function () { if (this.required) { if (this.getRawValue().length > 0) { this.clearInvalid(); return true; } else { this.markInvalid(); return false; } } }, markInvalid: function () { this.$super.apply(this, arguments); this.addCls('validationHelper', 'az-icon-cross'); }, clearInvalid: function () { this.$super.apply(this, arguments); this.removeCls('validationHelper', 'az-icon-cross'); }, postRender: function () { this.$super.apply(this, arguments); this._adjustLabelPositioning(); }, _adjustLabelPositioning: function () { if (this.label && !this.hideLabel) { var lblEl = $(this.dom.label), inputEl = $(this.dom.input); if (lblEl.innerHeight() > this.getThemeValue('inputHeight')) { this.setStyle('label', { padding: '0px' }); this.setStyle('inputWrapper', { "margin-top": (lblEl.outerHeight() - this.getThemeValue('inputHeight')) / 2 }); this.setStyle('tooltip', { "margin-top": (lblEl.outerHeight() - this.getThemeValue('inputHeight')) / 2 }); this.setStyle('validationHelper', { "margin-top": (lblEl.outerHeight() - this.getThemeValue('inputHeight')) / 2 }); } } } }); /*Scripts/libs/Astral/Control/Field/Checkbox.js*/ az.defineClass('Checkbox', { $extends: 'TextField', renderPattern: '@wrapper({content:@label+ @tooltip + @validationHelper + @inputWrapper({input:@input({ checkbox: @checkbox, caption: @caption }) }) })', wrapTag: 'div', type: 'checkbox', css: 'az-field-checkbox', autocomplete: 'off', disabled: false, // from filed value: false, // from field disabledCls: az.basePrefix + '-field-text-disabled', checked: false, caption: '', checkedCls: az.basePrefix + '-field-cb-checked', events: { handle: { 'change:input-{cid}': 'onChange' } }, tpls: { input: '', checkbox: '', caption: '{content}' }, tplData: { inputWrapper: { css: az.basePrefix + '-field-checkbox' }, caption: { content: '{caption}' }, wrapper: { css: 'az-field-text az-field-checkbox {fieldCls} {css}' } }, // todo wrong : no need to over write setDisabled: function (val, notify) { this.disabled = val; if (this.rendered) { if (this.disabled) { $(this.dom.checkbox).attr('disabled', 'disabled'); this.addCls('input', this.disabledCls); if (notify) this.fireEvent('disable'); } else { // this.removeAttr('input', 'disabled'); $(this.dom.checkbox).removeAttr('disabled'); this.removeCls('input', this.disabledCls); if (notify) this.fireEvent('enable'); } } }, validate: function () { if (this.required) { var checked = this.rendered ? $(this.dom.checkbox).prop("checked") : this.value; if (checked) { this.clearInvalid(); return true; } else { this.markInvalid(); return false; } } }, onChange: function (control, event) { var val = $(this.dom.checkbox).prop("checked"); this.value = val; this.checked = this.value; this.fireEvent('change', event, this.value); }, getRawValue: function () { return $(this.dom.checkbox).prop("checked"); }, setRawValue: function (val) { $(this.dom.checkbox).val(val); $(this.dom.checkbox).prop("checked", val); }, setValue: function (val, notify) { this.__oldValue = $(this.dom.checkbox).prop("checked"); this.value = Boolean(val); this.checked = this.value; this.setRawValue(this.value); if (notify) { this.fireEvent('change', null, this.value, this.__oldValue); this.validate(); } }, xgetFocusEl: function () { return this.dom.checkBox; }, setReadOnly: function (readOnly) { this.readOnly = readOnly; if (this.readOnly) $(this.dom.checkbox).attr('onclick', 'return false'); else $(this.dom.checkbox).removeAttr('onclick'); } }); /*Scripts/libs/Astral/Control/Field/CheckboxGroup.js*/ az.defineClass('CheckboxGroup', { $extends: 'TextField', wrap: true, wrapTag: 'div', columns: 1, vertical: true, type: 'checkbox', //renderPattern: '@wrapper({content:@label+@input({checkBoxes:@checkBoxes} )})', renderPattern: '@wrapper({content:@label+ @tooltip + @validationHelper + @inputWrapper({input:@input({checkBoxes:@checkBoxes} ) }) })', data: [], tpls: { input: '
{checkBoxes}
', checkBoxes: '' + '@var nextIndex=0;' + '@var cellCount = global.columns >= global.data.length ? global.data.length : ((((global.data.length - (global.data.length%global.columns))/global.columns)+(global.data.length%global.columns>0 ? 1 : 0))*global.columns);' + '@var rowCount = (global.vertical && global.columns==1)? global.data.length : (global.columns==1 ? 1 : cellCount/global.columns ) ;' + '@for(var r=0; r' + '@var cols = (global.columns == 1 && !global.vertical) ? global.data.length : global.columns;' + '@for(var c=0; c' + '@if(global.data[nextIndex]!=null){}' + '@nextIndex = global.vertical ? nextIndex + rowCount : nextIndex + 1;' + '}' + '@if(global.vertical) nextIndex=r+1;' + '}' + '
' }, tplData: { wrapper: { css: 'az-field-checkbox-group {css}' }, input: { tableStyle: '{}', }, label: { style: 'float:left; {style}' }, checkBoxes:{ inputCls: '{inputCls}' } }, events: { handle: { 'change:@input-{cid}-\\d': 'onChange', 'blur:@input-{cid}-\\d': 'onBlur', //'click:@caption-{cid}-\\d': 'onCaptionClick' } }, tryParseData: function () { var parsedData = []; // if data is in array if (az.chk.ifArray(this.data)) { $.each(this.data, function (i, item) { var _key = ''; var _cap = ''; var _value = false; if (item.key) _key = item.key; if (item.cap) _cap = item.cap; else _cap = item.key; _value = item.value === undefined ? false : item.value; var cbData = { key: _key, cap: _cap, value: _value }; parsedData.push(cbData); }); } else { var arr = this.data.split(','); $.each(arr, function () { var item = { key: this.toString(), cap: this.toString(), value: false }; parsedData.push(item); }); } this.value = parsedData; }, initTplData: function () { this.$super(); this.tryParseData(); if (!this.columnWidth) { this.columnWidth = Math.floor((this.width - this._getInputBorderPadding()- (this.required? this.getThemeValue('helperSize'): 0 ) -(this.tooltip?this.getThemeValue('helperSize'): 0 )) / ( this.columns>1 ? this.columns : ( this.vertical? 1 : this.data.length))); } var cellCount = this.columns >= this.data.length ? this.data.length : ((((this.data.length - (this.data.length % this.columns)) / this.columns) + (this.data.length % this.columns > 0 ? 1 : 0)) * this.columns); var rowCount = (this.vertical && this.columns == 1) ? this.data.length : (this.columns == 1 ? 1 : cellCount / this.columns); this.setStyle('input', 'width', (this.width - this._getInputBorderPadding()- (this.required? this.getThemeValue('helperSize'): 0 ) -(this.tooltip?this.getThemeValue('helperSize'): 0 ) ) + 'px'); var tblCols = this.columns == 1 && !this.vertical ? this.data.length : this.columns; this.tplData.input.tableStyle = 'width:' + tblCols * this.columnWidth + 'px'; }, setValue: function (val, notify) { this.__oldValue= this.value; var me = this; for(var i =0; i < this.value.length; i++){ this.value[i].value=false; $('#input-' + me.cid + '-' + i).prop('checked', false); } if(val==null || !az.chk.ifDefined(val)){ // do nothing } else if (az.chk.ifArray(val)) { $.each(val, function () { var i = me.__getMatchedItem(me.value, 'key', this.key); if (i > -1) { if(this.cap){ // $('#input-' + me.cid + '-' + i).nextAll().remove(); // $('#caption-' + me.cid + '-' + i).after(this.cap); // me.value[i].cap = this.cap; } $('#input-' + me.cid + '-' + i).prop('checked', this.value); me.value[i].key = this.key; me.value[i].value = this.value; } }); } else if (me.__isWholeNumber(val)) { var arr1 = val.split(','); $.each(arr1, function (i) { var bool = parseInt(arr1[i]); me.value[i].value = Boolean(bool); $('#input-' + me.cid + '-' + i).prop('checked', Boolean(bool)); }); } else { var arr2 = val.split(','); $.each(arr2, function (inx) { var i = me.__getMatchedItem(me.value, 'key', this.toString()); if (i > -1) { $('#input-' + me.cid + '-' + i).prop('checked', true); me.value[i].value = true; } }); } if (notify){ this.fireEvent('change', null, this.value, this.__oldValue); this.validate(); } }, __isWholeNumber: function (val) { var n = val.replace(/[,]/gi, ''); console.log(n); var reg = new RegExp(/^\d+$/); return reg.test(n); }, __getMatchedItem: function (obj, key, val) { var index = -1; var found = false; $.each(obj, function (i) { if (!found && this[key] == val) { index = i; found = true; } }); return found ? index : -1; }, getValue: function () { return this.value; }, onChange: function (control, event) { var index = event.elementId.replace('input-' + this.cid + '-', ''); var checked = $('#' + event.elementId).prop('checked'); this._onChange(event, index, checked); }, onCaptionClick: function (control, event) { if (!this.disabled) { var index = event.elementId.replace('caption-' + this.cid + '-', ''); var checked = $('#input-' + this.cid + '-' + index).prop('checked'); $('#input-' + this.cid + '-' + index).prop('checked', !checked); this._onChange(event, index, !checked); } }, _onChange: function (event, checkedIndex, checked) { var oldvalue = JSON.parse(JSON.stringify(this.value)); if (this.type == 'radio') { $.each(this.value, function (i) { if (checkedIndex != i) this.value = false; }); } this.value[checkedIndex].value = checked; this.fireEvent('change', event, this.value, oldvalue); }, validate: function () { if (this.required) { var checkedCount = $.grep(this.getValue(), function (e) { return !!e.value; }).length; if (checkedCount==0) { this.markInvalid(); return false; } else { this.clearInvalid(); return true; } } }, setDisabled: function (disabled) { this.disabled = disabled; if (this.disabled) $(this.dom.input).find('input').attr('disabled', 'disabled'); else { $(this.dom.input).find('input').removeAttr('disabled'); } }, setReadOnly: function(readOnly){ this.readOnly= readOnly; for(var i=0; i< this.data.length; i++ ){ var el= $('#input-' + this.cid+'-'+ i); if(this.readOnly) el.attr('onclick', 'return false'); else el.removeAttr('onclick'); } } }); /*Scripts/libs/Astral/Control/Field/RichTextField.js*/ az.defineClass('RichTextField', { $extends: 'Field', renderPattern: '@wrapper({content:@label+@input})', tpls: { input: '{content}' }, tplData: { input: { content: '' } }, init: function () { this.$super.apply(this, arguments); }, initTplData: function () { this.$super.apply(this, arguments); if (!this.height) this.height = 200; var me = this; this.setStyle('input', 'height:' + this.height + 'px;'); this.editor = new az.HTMLEditor({ owner: this, border: 1, width: this.width, height: this.height, listeners: { contentchange: function (control, value) { me.__oldValue = me.value; me.value = value; me.fireEvent('change',null, me.value, me.__oldValue); } } }); this.editor.setStyle('wrapper', 'display', 'inline-block'); this.setStyle('label', 'float', 'left'); this.editor.preRender(); this.tplData.input.content = this.editor.render(); }, onResize: function () { var inputWidth = this.width; if (this.rendered) { this.setStyle('wrapper', 'width', ((this.hideLabel || this.labelPosition == 'top' ? 0 : this.labelWidth + this.labelGap) + inputWidth) + 'px'); this.editor.setSize(this.height, inputWidth - 4, false, true); } }, getValue: function () { this.value = this.editor.getContent(); return this.value; }, setValue: function (value, notify) { this.value = value; this.editor.setContent(value); if (notify) { this.fireEvent('change', null, this.value, this.__oldValue); this.validate(); } }, postRender: function () { this.$super.apply(this, arguments); this.editor.postRender(); } }); /*Scripts/libs/Astral/Container/FieldSet.js*/ az.defineClass('FieldSet', { $extends: 'Container', rootTag: 'fieldset', renderPattern: '@root({content:@legend + @fieldsetBody})', layoutTarget: 'fieldsetBody', controlCls: 'az-panel az-border az-fieldset', legendCls: 'az-fieldset-legend', padding: { bottom: 3 }, border: 1, tpls: { root: '<{rootTag} id="{$class}-{cid}" class="{css}" style="{style}" {attr} @if(global.tabIndex){tabindex="{tabIndex}"} >{content}', fieldsetBody: '
{content}
', legend: '{title}' }, tplData: { root: { css: '{controlCls} {css}' }, fieldsetBody: { content: '', style: '{style}' } }, initTplData: function () { this.$super.apply(this, arguments); this.setStyle('fieldsetBody', { height: this.__getBodyHeight() + 'px', width: this.__getBodyWidth() }); }, onResize: function () { this.setStyle('root', this._getSizeStyle()); this.setStyle('fieldsetBody', { height: this.__getBodyHeight() + 'px', width: this.__getBodyWidth(), padding: this._getPaddingStyle() }); if (this.rendered && !this.suspendLayout) { this.layout.update(); } }, _getSizeStyle: function () { return (this.height ? 'height:' + (this.height - (0 + this._getBorder('top') + this._getBorder('bottom'))) + 'px;' : '') + (this.width ? 'width:' + (this.width - (this._getBorder('left') + this._getBorder('right') + this.getThemeValue('padding-left') * 1)) + 'px;' : 'width:auto;'); }, __getBodyWidth: function () { return (this.width != undefined ? (this.width - this._getBorder('left') - this._getBorder('right') - this._getPadding('left') - this._getPadding('right') - this.getThemeValue('padding') * 1) + 'px' : 'auto'); }, __getBodyHeight: function () { var outerHeight = this.getThemeValue('legendHeight') + +this._getBorder('bottom') + this._getPadding('top') + this._getPadding('bottom'); return (this.height && this.height != 0 && this.height > outerHeight) ? (this.height - outerHeight) : 0; }, setTitle: function (title) { this.title = title; if (this.rendered) { $(this.dom.legend).html(title); } }, setContent: function (content) { this.content = content; if (this.rendered) { $(this.dom.fieldsetBody).html(content); } }, }); /*Scripts/libs/Astral/Container/Panel.js*/ az.defineClass('Panel', { $extends: 'Container', layoutTarget: 'body', $includes: 'maskable', renderPattern: '@root({content:@header({tools:@triggerButtons+@collapseButton})+@toolbar+@body+@bottombar})', collapsible: false, collapsed: false, headerToolbar: true, title: 'Panel', border: 1, padding: 3, hideHeader: false, events: { handle: { 'click:collapseButton-{cid}': 'onCollapse', 'click:headerTitle-{cid},{$class}-{cid}-header': 'onHeaderClick', 'click:@{$class}-{cid}-trigger-\\d': 'onTriggerButtonClick', 'mousedown:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseDown', 'mousedown:collapseButton-{cid}': 'onHeaderToolbarButtonMouseDown', 'mouseup:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseUp', 'mouseup:collapseButton-{cid}': 'onHeaderToolbarButtonMouseUp', 'mouseenter:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseEnter', 'mouseenter:collapseButton-{cid}': 'onHeaderToolbarButtonMouseEnter', 'mouseleave:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseLeave', 'mouseleave:collapseButton-{cid}': 'onHeaderToolbarButtonMouseLeave' } }, tpls: { header: ' @if(!global.hideHeader){
{title}
{tools}
}', body: '
{content}
', collapseButton: '@if(global.collapsible && global.headerToolbar){}', triggerButtons: '@if(ctx.triggers){@for(var i=0; i< ctx.triggers.length; i++ ){}}', toolbar: '{tcontent}', bottombar: '{bcontent}' }, tplData: { header: { headerCls: '{headerCls}', headerStyle: '{headerStyle}', content: '' }, body: { bodyCls: '{bodyCls}', style: '{bodyStyle}', content: '' }, toolbar: { tcontent: '' }, bottombar: { bcontent: '' }, triggerButtons: { } }, preRender: function () { this.$super.apply(this, arguments); if (this.tbar) this.tbar.preRender(); if (this.bbar) this.bbar.preRender(); }, postRender: function () { this.$super.apply(this, arguments); if (this.tbar) this.tbar.postRender(); if (this.bbar) this.bbar.postRender(); if (this.collapsed) this.collapse(); // possiblely change impliment in template this._adjustBody(); }, _adjustBody: function () { var tbarHeight = 0, bbarHeight = 0; if (this.tbar && this.tbar.items.length == 0) this.tbar.hide(); else { tbarHeight = (this.tbar ? $(this.tbar.dom.root).outerHeight() : 0); if (this.tbar && !this.tbar.visible) this.tbar.show(); } if (this.bbar && this.bbar.items.length == 0) this.bbar.hide(); else { bbarHeight = (this.bbar ? $(this.bbar.dom.root).outerHeight() : 0); if (this.bbar && !this.bbar.visible) this.bbar.show(); } var bodyHeight = this.__getBodyHeight() - tbarHeight - bbarHeight; this.setStyle('body', this._getPaddingStyle()); this.setStyle('body', 'height:' + (bodyHeight == 0 ? 'auto' : bodyHeight + 'px;')); this.updateLayout(); }, render: function () { if (this.tbar) { this.tplData.toolbar.tcontent = this.tbar.render(); } if (this.bbar) { this.tplData.bottombar.bcontent = this.bbar.render(); } return this.$super.apply(this, arguments); }, init: function (config) { this.padding = this.getThemeValue('defaultPadding'); this.border = this.getThemeValue('defaultBorder'); if (config) { if (config.tbar) { if (az.chk.ifObject(config.tbar)) az.copy(this.tbar, config.tbar); else if (!this.tbar) this.tbar = config.tbar; delete config.tbar; } if (config.bbar) { if (az.chk.ifObject(config.bbar)) az.copy(this.bbar, config.bbar); else if (!this.bbar) this.bbar = config.bbar; delete config.bbar; } } this.$super.apply(this, arguments); if (this.tbar && az.chk.ifArray(this.tbar)) { this.tbar = new az.Toolbar({ owner: this, css: 'az-tbar', border: { left: 0, right: 0, bottom: 1 }, items: this.tbar, xwidth: this.width }); } if (this.bbar && az.chk.ifArray(this.bbar)) { this.bbar = new az.Toolbar({ owner: this, css: 'az-bbar', bbar: true, centerAlign: this.bbarCenterAlign, border: 0, padding: 5, items: this.bbar }); } this.triggers = this.triggers || []; this.tplData.triggerButtons.triggers = this.triggers; }, initTplData: function () { this.$super.apply(this, arguments); if (this.framed) this.addCls('root', 'az-panel-framed'); if (this.accordion && !this.collapsed) this.addCls('root', 'az-accordion-open'); }, onTriggerButtonClick: function (control, event) { var iIndex = event.elementId.split('-')[5]; if (this.triggers[iIndex].handle && !this.triggers[iIndex].disabled) { this.triggers[iIndex].handle(event); } }, onHeaderToolbarButtonMouseDown: function (control, event) { $('#' + event.elementId).addClass('az-panel-trigger-pressed'); $('#' + event.elementId).removeClass('az-panel-trigger-hover'); }, onHeaderToolbarButtonMouseUp: function (control, event) { $('#' + event.elementId).removeClass('az-panel-trigger-pressed'); $('#' + event.elementId).addClass('az-panel-trigger-hover'); }, onHeaderToolbarButtonMouseEnter: function (event) { $('#' + event.elementId).addClass('az-panel-trigger-hover'); }, onHeaderToolbarButtonMouseLeave: function (event) { $('#' + event.elementId).removeClass('az-panel-trigger-hover'); }, setTriggerDisabled: function (triggerIndex, disabled) { this.triggers[triggerIndex].disabled = disabled; if (disabled) { $(az.format('#{$class}-{cid}-trigger-' + triggerIndex, this)).addClass('az-panel-trigger-button-disabled'); } else { $(az.format('#{$class}-{cid}-trigger-' + triggerIndex, this)).removeClass('az-panel-trigger-button-disabled'); } }, getLayoutSize: function () { return { boxSize: { height: (this.rendered ? $(this.getRootEl()).outerHeight() : this.height), width: (this.rendered ? $(this.getRootEl()).outerWidth() : this.width) }, contentAreaSize: ( this.rendered ? { height: $(this.dom[this.layoutTarget]).height(), width: $(this.dom[this.layoutTarget]).width()} : { height: this.__getBodyHeight(), width: this.width - (this._getBorder('left') + this._getBorder('right') + this._getPadding('left') + this._getPadding('right')) } ) }; }, onResize: function () { if (this.rendered) { this.setStyle('root', this._getSizeStyle()); if (this.tbar) this.tbar.onResize(); if (this.bbar) this.bbar.onResize(); this._adjustBody(); } }, onHeaderClick: function () { if (this.headerAsHandler) this.onCollapse(); }, onCollapse: function () { if (this.collapsed) { this.expand(true); } else { this.collapse(true); } }, collapse: function (notify) { this.addCls('collapseButton', 'az-panel-tool-expand'); // change these .. this.removeCls('collapseButton', 'az-panel-tool-collapse'); // change these .. $(this.dom.body).hide(); if (this.collapseMode == 'vertical') $(this.dom.header).hide(); if (this.tbar) this.tbar.hide(); if (this.bbar) this.bbar.hide(); this.setStyle('root', 'height', ((this.hideHeader ? 0 : this.__getHeaderHeight()) - this._getBorder('bottom') /*- this._getBorder('bottom')*/) + 'px'); this.addCls('root', 'az-panel-header-collapsed'); if (this.accordion) { this.addCls('root', 'az-accordion-collapsed'); this.removeCls('root', 'az-accordion-open'); } this.collapsed = true; this.expandWidthTo = this.collapseMode == 'vertical' ? this.width : this.height; this.expandHeightTo = this.collapseMode == 'vertical' ? this.height : this.width; if (notify) this.fireEvent('collapse'); }, expand: function (notify) { this.setStyle('root', 'height', (this.height ? this.height - (this._getBorder('top') + this._getBorder('bottom') + this.__getFrameSpan()) + 'px' : 'auto')); this.removeCls('root', 'az-panel-header-collapsed'); if (this.accordion) { this.addCls('root', 'az-accordion-open'); this.removeCls('root', 'az-accordion-collapsed'); } $(this.dom.body).show(); if (this.tbar) this.tbar.show(); if (this.bbar) this.bbar.show(); $(this.dom.header).show(); this.addCls('collapseButton', 'az-panel-tool-collapse'); // change these .. this.removeCls('collapseButton', 'az-panel-tool-expand'); // change these .. this.collapsed = false; if (notify) this.fireEvent('expand'); }, setTitle: function (title) { this.title = title; if (this.rendered) { $(this.dom.header).find('.az-panel-title').html(title); } }, getTitle: function () { return this.title; }, _getSizeStyle: function () { return (this.height ? 'height:' + (this.height - (this._getBorder('top') + this._getBorder('bottom') + this.__getFrameSpan())) + 'px;' : '') + (this.width ? 'width:' + (this.width - (this._getBorder('left') + this._getBorder('right')) - this.__getFrameSpan() * 2) + 'px;' : 'width:auto;'); }, __getBodyHeight: function () { var outerHeight = (this.hideHeader ? 0 : this.__getHeaderHeight()) + this._getBorder('top') + this._getBorder('bottom') + this._getPadding('top') + this._getPadding('bottom') + this.__getFrameSpan(); return (this.height && this.height != 0 && this.height > outerHeight) ? (this.height - outerHeight) : 0; }, __getFrameSpan: function () { return this.framed ? this.getThemeValue('frameSpan') : 0; }, __getHeaderHeight: function () { return this.accordion ? this.getThemeValue('accordionItemHeaderHeight') : this.getThemeValue('headerHeight'); }, destroy: function () { if (this.tbar) this.tbar.destroy(); if (this.bbar) this.bbar.destroy(); this.$super.apply(this, arguments); } }); /*Scripts/libs/Astral/Container/Tab.js*/ az.defineClass('Tab', { $extends: 'Container', layoutTarget: 'tabBody', defaults: { padding: 5 }, activeItem: 0, __tabId: 0, border: 1, warnBeforeClose: false, closeWarningMsg: 'Do Really want to close this tab?', renderPattern: '@root({content:@tabHeader({tabScroller:@tabScroller,content:@tabWrap({tabItems:@tabItems}),headerBorder: @tabHeaderBorder})+@tabBody})', events: { handle: { 'click:@tabItem-{cid}-\\d': 'onTabClick', 'click:@tabItem-closeBtn-{cid}-\\d': 'onTabClose', 'click:tabScrollerleft-{cid},tabScrollerRight-{cid}': 'onScroll' }, custom: ['activate', 'tabclose', 'tabadd'] }, tpls: { tabHeader: '
{tabScroller}{content}{headerBorder}
', tabScroller: '
', tabWrap: '
    {tabItems}
', tabItems: '@if(ctx.items && ctx.items.length>0) {@for(var i=0;i @if(ctx.items[i].iconCls){} {items[i].title}}}', tabBody: '
{content}
', tabHeaderBorder: '
' }, __createNewTab: function (comp) { this.__tabId++; comp.tabItemId = '#tabItem-' + this.cid + '-' + this.__tabId; comp.tabItemCloseBtn = '#tabItem-closeBtn-' + this.cid + '-' + this.__tabId; return az.format(this.__tabItemTpl, { title: comp.title || '', cid: this.cid, tabId: this.__tabId, tabIcon: comp.tabIcon || '', closableCls: comp.closable ? 'az-tabs-closable' : '', closableStyle: comp.closable ? '' : 'display:none', disabledCls: comp.disabled ? 'az-tabs-disabled' : '' }); }, __tabItemTpl: '
  • \ \ {title}\ \ \
  • ', defaultClass: 'Container', tplData: { tabItems: { items: [] }, tabScroller: { style: '' }, tabWrap: { style: '' }, tabBody: { style: '' }, root: { style: '{style}', content: '{content}', } }, scrollUnit: 20, _scrollPos: 0, _maxScrollLimit: 0, totalNoOfScrollStep: 0, scrollToTab: function (compOrNameOrIndex) { var index = this.__getTabIndex(compOrNameOrIndex); if (this._maxScrollLimit < 0) return; var widthUptoItem = 0; var itemWidth = $(this.items[index].tabItemId).width(); if (index > 0) for (var i = 0; i < index; i++) { widthUptoItem += $(this.items[i].tabItemId).width(); } var currentScrollLength = this._scrollPos; var moveRight = currentScrollLength + this.availableTabSpace > widthUptoItem; var offsetWidth = 0; if (this.availableTabSpace + currentScrollLength > widthUptoItem) offsetWidth = currentScrollLength - widthUptoItem; else { offsetWidth = (widthUptoItem + itemWidth) - (this.availableTabSpace + currentScrollLength); } var noOfSteps = Math.ceil(offsetWidth / this.scrollUnit); if (noOfSteps > 0) while (noOfSteps--) { this.scrollTab(moveRight); } }, scrollTab: function (moveRight) { if (this._maxScrollLimit <= 0) return; if (moveRight && this._scrollPos <= 0) return; if (!moveRight && this._scrollPos >= this._maxScrollLimit) return; this._scrollPos += (moveRight ? -1 : 1) * this.scrollUnit; var currentPos = +$(this.dom.tabWrap + ' ul').css('margin-left').replace('px', ''); $(this.dom.tabWrap + ' ul').css('margin-left', (moveRight ? (currentPos + this.scrollUnit) + 'px' : (currentPos - this.scrollUnit) + 'px')); }, _showScroller: function (visible) { if (visible) { $(this.dom.tabScroller).show(); $(this.dom.tabWrap + ' ul').css('margin-left', '20px'); } else { $(this.dom.tabScroller).hide(); $(this.dom.tabWrap + ' ul').css('margin-left', '0px'); } }, _updateScroller: function () { this.availableTabSpace = $(this.dom.tabWrap).width() - 40; this.totalTabItemsWidth = this._calculateTabItemScrollWidth(); this._maxScrollLimit = this.totalTabItemsWidth - this.availableTabSpace; this.totalNoOfScrollStep = Math.ceil(this._maxScrollLimit / this.scrollUnit); this._showScroller(this.availableTabSpace < this.totalTabItemsWidth); }, _calculateTabItemScrollWidth: function () { var width = 0; var me = this; $(this.dom.tabWrap + ' li').each(function (index, tabitem) { width += tabitem.scrollWidth; }); return width; }, __setTabIcons: function () { var tabs = $(this.dom.tabHeader).find('.az-tabs').children(); for (var i = 0; i < tabs.length; i++) { if(!this.items[i]) break; if (!this.items[i].iconActive && !this.items[i].iconInActive ) continue; var li = $(tabs[i]); if (li.hasClass('az-tabs-selected')) { li.find('.az-tab-icon').css('background-image', 'url(' + px.appPath + (this.items[i].iconActive|| this.items[i].iconInActive) + ')'); } else { li.find('.az-tab-icon').css('background-image', 'url(' + px.appPath + (this.items[i].iconInActive || this.items[i].iconActive) + ')'); } } }, __getTabIndex: function (compOrNameOrIndex) { var index = -1; if (az.chk.ifObject(compOrNameOrIndex)) { for (var i = 0; i < this.items.length; i++) { if (this.items[i].cid == compOrNameOrIndex.cid) { index = i; break; } } } else if (az.chk.ifString(compOrNameOrIndex)) { for (var i = 0; i < this.items.length; i++) { if (this.items[i].name == compOrNameOrIndex) { index = i; break; } } } else if (az.chk.ifNumber(compOrNameOrIndex) && (compOrNameOrIndex >= 0 && compOrNameOrIndex < this.items.length)) { index = compOrNameOrIndex; } return index; }, shiftTab: function (compOrNameOrIndex, noOfPlaces) { if (this.items.length == 1) return; var currentIndex = this.__getTabIndex(compOrNameOrIndex); if (currentIndex < 0) return; var newIndex = currentIndex + noOfPlaces; if (newIndex < 0) newIndex = 0; if (newIndex > this.items.length - 1) newIndex = this.items.length - 1; if (newIndex == currentIndex) return; if (newIndex > currentIndex) { $(this.items[newIndex].tabItemId).after($(this.items[currentIndex].tabItemId)); } else { $(this.items[newIndex].tabItemId).before($(this.items[currentIndex].tabItemId)); } var item = this.items.splice(currentIndex, 1)[0]; this.items.splice(newIndex, 0, item); }, setDisabledTab: function (compOrNameOrIndex, disabled) { var index = this.__getTabIndex(compOrNameOrIndex); this.items[index].disabled = disabled; $(this.items[index].tabItemId)[disabled ? 'addClass' : 'removeClass']('az-tabs-disabled'); if (index == this.activeItem) { this.items[index].setVisible(!disabled); } }, disableTab: function (compOrNameOrIndex) { this.setDisabledTab(compOrNameOrIndex, true); }, enableTab: function (compOrNameOrIndex) { this.setDisabledTab(compOrNameOrIndex, false); }, setVisibleTab: function (compOrNameOrIndex, visible) { var index = this.__getTabIndex(compOrNameOrIndex); $(this.items[index].tabItemId)[visible ? 'show' : 'hide'](); if (this.activeItem == index) { if (this.activeItem == index) if (this.items.length >= 1) { if (index == 0) this.activate(1); else { this.activate(index - 1); } } } }, showTab: function (compOrNameOrIndex) { this.setVisibleTab(compOrNameOrIndex, true); }, hideTab: function (compOrNameOrIndex) { this.setVisibleTab(compOrNameOrIndex, false); }, setActiveTab: function (compOrNameOrIndex, notify) { var index = this.__getTabIndex(compOrNameOrIndex); if (index < 0) return; this.activate(index, notify); }, activate: function (index, notify) { if (this.rendered) { $(this.items[this.activeItem].tabItemId).removeClass('az-tabs-selected'); $(this.items[index].tabItemId).addClass('az-tabs-selected'); } this.activeItem = index; if (notify) this.fireEvent('activate', index); this.scrollToTab(index); this.layout.update(); //this.items[this.activeItem].serFocus(); this.__setTabIcons(); }, validateBeforeTabClose: function () { return true; }, onScroll: function (me, event) { this.scrollTab(event.elementId != "tabScrollerRight-" + this.cid); }, onTabClick: function (me, event) { for (var i = 0; i < this.items.length; i++) { if (!this.items[i].disabled && this.items[i].tabItemId == '#' + event.elementId) { this.activate(i, true); break; } } }, onTabClose: function (me, event) { if (!this.validateBeforeTabClose()) return; if (this.warnBeforeClose && !confirm(this.closeWarningMsg)) return; for (var i = 0; i < this.items.length; i++) { if (this.items[i].tabItemCloseBtn == '#' + event.elementId) { this.remove(i); break; } } }, onResize: function () { this.setStyle(this.layoutTarget, 'height', this.__getBodyHeight() + 'px'); this.$super.apply(this, arguments); }, _getSizeStyle: function () { return (this.height ? 'height:' + (this.height - (this._getBorder('top') + this._getBorder('bottom'))) + 'px;' : '') + (this.width ? 'width:' + (this.width - (this._getBorder('left') + this._getBorder('right'))) + 'px;' : ''); // width: auto }, updateLayout: function () { this.$super.apply(this, arguments); this._updateScroller(); }, postRender: function () { this.$super.apply(this, arguments); this._updateScroller(); this.__setTabIcons(); }, onInitChildren: function (child) { child.border = this.getThemeValue('itemBorder'); child.css = 'az-tab-container'; }, init: function (config) { this.border = this.getThemeValue('defaultBorder'); if (!config) config = {}; az.copy(config, { padding: false, layout: 'card' }); this.$super(config); }, initTplData: function () { this.$super.apply(this, arguments); this.addCls('root', 'az-tab'); this.tplData.tabItems.items = this.items; for (var i = 0; i < this.items.length; i++) { this.items[i].tabItemId = '#tabItem-' + this.cid + '-' + i; this.items[i].tabItemCloseBtn = '#tabItem-closeBtn-' + this.cid + '-' + i; if(this.items[i].iconActive ||this.items[i].iconInActive) this.items[i].iconCls= 'az-icon-blank'; } this.__tabId = this.items.length; this.__initStyle(); }, __initStyle: function () { this.tplData.tabScroller.style = 'height:' + this.getThemeValue('tabScrollerHeight') + 'px; z-index:10;'; // this.tplData.tabWrap.style = 'height:' + this.getThemeValue('tabHeight') + 'px;'; // this.setStyle('tabWrap', 'height', this.getThemeValue('tabHeight') + 'px'); if (this.height) this.setStyle(this.layoutTarget, 'height', this.__getBodyHeight() + 'px'); }, add: function (comp, index, notify) { if (comp instanceof az.UIComponent && !(comp instanceof az.Container)) throw "only container can be added as a child item of tab"; if (!index) index = this.items.length; if (index == 0) $(this.dom.tabWrap + ' ul').append($(this.__createNewTab(comp))); else { $(this.__createNewTab(comp)).insertAfter(this.items[index - 1].tabItemId); } this.addDomEventHandler(comp.tabItemId.replace('#', ''), 'click', this.onTabClick, this); this.addDomEventHandler(comp.tabItemCloseBtn.replace('#', ''), 'click', this.onTabClose, this); this.$super.apply(this, arguments); this.updateLayout(); if (notify) this.fireEvent('tabadd'); }, removeAll: function (notify) { while (this.items.length > 0) this.remove(0, notify); }, removeAt: function () { this.remove.apply(this, arguments); }, remove: function (compOrNameOrIndex, notify) { var index = this.__getTabIndex(compOrNameOrIndex); if (index < 0) return; var deletedComp = this.items.splice(index, 1)[0]; if (this.activeItem == index) if (this.items.length >= 1) { if (index == 0) this.activate(0); else { this.activeItem = this.activeItem - 1; this.activate(index - 1); } } if (this.rendered) { $(deletedComp.tabItemId).remove(); az.removeAllDomEventHandler(this.cid, deletedComp.tabItemId); az.removeAllDomEventHandler(this.cid, deletedComp.tabItemCloseBtn); } if (deletedComp.destroy) deletedComp.destroy(); this.updateLayout(); if (notify) this.fireEvent('tabclose', index); }, getLayoutSize: function () { return { boxSize: { height: (this.rendered ? $(this.getRootEl()).outerHeight() : this.height), width: (this.rendered ? $(this.getRootEl()).outerWidth() : this.width) }, contentAreaSize: ( this.rendered ? { height: $(this.dom[this.layoutTarget]).height(), width: $(this.dom[this.layoutTarget]).width()} : { height: this.__getBodyHeight(), width: this.__getBodyWidth() } ) }; }, __getBodyHeight: function () { var outerHeight = this.getThemeValue('tabHeight') + this._getBorder('top') + this._getBorder('bottom'); //todo: here 1 px may come from theme. return (this.height && this.height != 0 && this.height > outerHeight) ? (this.height - outerHeight) : 0; }, __getBodyWidth: function () { var outerWidth = this._getBorder('left') + this._getBorder('right'); return (this.width && this.width != 0 && this.width > outerWidth) ? (this.width - outerWidth) : 0; } }); /*Scripts/libs/Astral/Control/Calendar.js*/ az.defineClass('Calendar', { $extends: 'Control', border: 1, //height: 200, xwidth: 177, //renderPattern: '@wrapper({content:@header({back:@backBtn, next: @nextBtn, mmyy:@mmyyBtn })+@body})', //renderPattern: '@wrapper({content:@header({back:@backBtn, next: @nextBtn, mmyy:@mmyyBtn })+@body})', _keyEvent: false, // If the last event was a key event _disabledInputs: [], // List of date picker inputs that have been disabled _datepickerShowing: false, // True if the popup picker is showing , false if not _inDialog: false, // True if showing within a "dialog", false if not _mainDivId: "ui-datepicker-div", // The ID of the main datepicker division _inlineClass: "ui-datepicker-inline", // The name of the inline marker class _appendClass: "ui-datepicker-append", // The name of the append marker class _triggerClass: "ui-datepicker-trigger", // The name of the trigger marker class _dialogClass: "ui-datepicker-dialog", // The name of the dialog marker class _disableClass: "ui-datepicker-disabled", // The name of the disabled covering marker class _unselectableClass: "az-calendar-unselectable", // The name of the unselectable cell marker class _dayClass: 'az-calendar-day-cell', _currentClass: "az-calendar-selected-day", // The name of the current day marker class _dayOverClass: "az-calendar-days-cell-over", // The name of the day hover marker class closeText: "Done", // Display text for close link prevText: "Prev", // Display text for previous month link nextText: "Next", // Display text for next month link currentText: "Today", // Display text for current month link weekHeader: "Wk", // Column header for week of the year dateFormat: "dd/mm/yy", // See format options on parseDate firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... isRTL: false, // True if right-to-left language, false if left-to-right showMonthAfterYear: false, // True if the year select precedes month, false for month then year yearSuffix: "", // Additional text to append to the year in the month headers showOn: "focus", // "focus" for popup on focus, // "button" for trigger button, or "both" for either showAnim: "fadeIn", // Name of jQuery animation for popup showOptions: {}, // Options for enhanced animations defaultDate: null, // Used when field is blank: actual date, // +/-number for offset from today, null for today appendText: "", // Display text following the input box, e.g. showing the format buttonText: "...", // Text for trigger button buttonImage: "", // URL for trigger button image buttonImageOnly: false, // True if the image appears alone, false if it appears on a button hideIfNoPrevNext: false, // True to hide next/previous month links // if not applicable, false to just disable them navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links gotoCurrent: false, // True if today link goes back to current selection instead changeMonth: false, // True if month can be selected directly, false if only prev/next changeYear: false, // True if year can be selected directly, false if only prev/next yearRange: "c-10:c+10", // Range of years to display in drop-down, // either relative to today's year (-nn:+nn), relative to currently displayed year // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n) showOtherMonths: true, // True to show dates in other months, false to leave blank selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable showWeek: false, // True to show week of the year, false to not show it calculateWeek: this.iso8601Week, // How to calculate the week of the year, // takes a Date and returns the number of the week for it // > this are in the previous century, // string value starting with "+" for current year + value minDate: null, // The earliest selectable date, or null for no limit maxDate: null, // The latest selectable date, or null for no limit duration: "fast", // Duration of display/closure beforeShowDay: null, // Function that takes a date and returns an array with // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "", // [2] = cell title (optional), e.g. $.datepicker.noWeekends beforeShow: null, // Function that takes an input field and // returns a set of custom settings for the date picker onSelect: null, // Define a callback function when a date is selected onChangeMonthYear: null, // Define a callback function when the month or year is changed onClose: null, // Define a callback function when the datepicker is closed numberOfMonths: 1, // Number of months to show at a time showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0) stepMonths: 1, // Number of months to step back/forward stepBigMonths: 12, // Number of months to step back/forward for the big links altField: "", // Selector for an alternate field to store selected dates into altFormat: "", // The date format to use for the alternate field constrainInput: true, // The input is constrained by the current date format showButtonPanel: false, // True to show button panel, false to not show it autoSize: false, // True to size the input for the date format, false to leave as is disabled: false, // The initial disabled state view: 'D', /* Parse existing date and initialise date picker. */ _setDateFromField: function (inst, noDefault) { if (inst.input.val() === inst.lastVal) { return; } var dateFormat = this._get(inst, "dateFormat"), dates = inst.lastVal = inst.input ? inst.input.val() : null, defaultDate = this._getDefaultDate(inst), date = defaultDate, settings = this._getFormatConfig(inst); try { date = az.date.parseDate(dateFormat, dates) || defaultDate; } catch (event) { dates = (noDefault ? "" : dates); } inst.selectedDay = date.getDate(); inst.drawMonth = inst.selectedMonth = date.getMonth(); inst.drawYear = inst.selectedYear = date.getFullYear(); inst.currentDay = (dates ? date.getDate() : 0); inst.currentMonth = (dates ? date.getMonth() : 0); inst.currentYear = (dates ? date.getFullYear() : 0); this._adjustInstDate(); }, /* Retrieve the default date shown on opening. */ _getDefaultDate: function () { return this._restrictMinMax(az.date.determineDate(this.defaultDate, new Date())); }, /* A date may be specified as an exact value or a relative one. */ x_determineDate: function (date, defaultDate) { var me = this; var offsetNumeric = function (offset) { var date = new Date(); date.setDate(date.getDate() + offset); return date; }, offsetString = function (offset) { try { return az.date.parseDate(me.dateFormat, offset); } catch (e) { // Ignore } var date = (offset.toLowerCase().match(/^c/) ? me._getDate() : null) || new Date(), year = date.getFullYear(), month = date.getMonth(), day = date.getDate(), pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g, matches = pattern.exec(offset); while (matches) { switch (matches[2] || "d") { case "d": case "D": day += parseInt(matches[1], 10); break; case "w": case "W": day += parseInt(matches[1], 10) * 7; break; case "m": case "M": month += parseInt(matches[1], 10); day = Math.min(day, me._getDaysInMonth(year, month)); break; case "y": case "Y": year += parseInt(matches[1], 10); day = Math.min(day, me._getDaysInMonth(year, month)); break; } matches = pattern.exec(offset); } return new Date(year, month, day); }, newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) : (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime())))); newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate); if (newDate) { newDate.setHours(0); newDate.setMinutes(0); newDate.setSeconds(0); newDate.setMilliseconds(0); } return az.date.daylightSavingAdjust(newDate); }, /* Set the date(s) directly. */ _setDate: function (date, noChange) { var clear = !date, origMonth = this.selectedMonth, origYear = this.selectedYear, newDate = this._restrictMinMax(az.date.determineDate(date, new Date())); this.selectedDay = this.currentDay = newDate.getDate(); this.drawMonth = this.selectedMonth = this.currentMonth = newDate.getMonth(); this.drawYear = this.selectedYear = this.currentYear = newDate.getFullYear(); if ((origMonth !== this.selectedMonth || origYear !== this.selectedYear) && !noChange) { // this._notifyChange(this); } this._adjustInstDate(); if (this.input) { this.input.val(clear ? "" : this._formatDate()); } }, /* Retrieve the date(s) directly. */ _getDate: function () { var startDate = (!this.currentYear || (this.input && this.input.val() === "") ? null : az.date.daylightSavingAdjust(new Date( this.currentYear, this.currentMonth, this.currentDay))); return startDate; }, /* Generate the month and year header. */ _generateMonthYearHeader: function (drawMonth, drawYear, minDate, maxDate, secondary, monthNames, monthNamesShort) { var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear, changeMonth = this.changeMonth, changeYear = this.changeYear, showMonthAfterYear = this.showMonthAfterYear, html = "", monthHtml = ""; // month selection if (secondary || !changeMonth) { monthHtml += "" + monthNames[drawMonth] + ""; } else { inMinYear = (minDate && minDate.getFullYear() === drawYear); inMaxYear = (maxDate && maxDate.getFullYear() === drawYear); monthHtml += ""; } if (!showMonthAfterYear) { html += monthHtml + (secondary || !(changeMonth && changeYear) ? " " : ""); } // year selection if (!this.yearshtml) { this.yearshtml = ""; if (secondary || !changeYear) { html += "" + drawYear + ""; } else { // determine range of years to display years = this.yearRange.split(":"); thisYear = new Date().getFullYear(); determineYear = function (value) { var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) : (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) : parseInt(value, 10))); return (isNaN(year) ? thisYear : year); }; year = determineYear(years[0]); endYear = Math.max(year, determineYear(years[1] || "")); year = (minDate ? Math.max(year, minDate.getFullYear()) : year); endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); this.yearshtml += ""; html += this.yearshtml; this.yearshtml = null; } } html += this.yearSuffix; if (showMonthAfterYear) { html += (secondary || !(changeMonth && changeYear) ? " " : "") + monthHtml; } html += ""; // Close datepicker_header return az.format(html, this); }, /* Generate the date picker content. */ _updateDatepicker: function () { this.maxRows = 4; //Reset the max number of rows being displayed (see #7043) // instActive = inst; // for delegate hover events // inst.dpDiv.empty().append(this._generateHTML(inst)); //this._attachHandlers(inst); //inst.dpDiv.find("." + this._dayOverClass + " a").mouseover(); if (this.rendered) { $(this.dom.calendarHtml).empty().append(this._generateHTML()); } else { this.tplData.calendarHtml.content = this._generateHTML(); } var origyearshtml, numMonths = this._getNumberOfMonths(), cols = numMonths[1], width = 17; // deffered render of the years select (to avoid flashes on Firefox) if (this.yearshtml) { origyearshtml = this.yearshtml; setTimeout(function () { //assure that inst.yearshtml didn't change. if (origyearshtml === this.yearshtml && this.yearshtml) { // inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml); } origyearshtml = this.yearshtml = null; }, 0); } }, /* Adjust one of the date sub-fields. */ _adjustInstDate: function (offset, period) { var year = this.drawYear + (period === "Y" ? offset : 0), month = this.drawMonth + (period === "M" ? offset : 0), day = Math.min(this.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0), date = this._restrictMinMax(az.date.daylightSavingAdjust(new Date(year, month, day))); this.selectedDay = date.getDate(); this.drawMonth = this.selectedMonth = date.getMonth(); this.drawYear = this.selectedYear = date.getFullYear(); if (period === "M" || period === "Y") { //this._notifyChange(inst); } }, /* Ensure a date is within any min/max bounds. */ _restrictMinMax: function (date) { var minDate = this._getMinMaxDate("min"), maxDate = this._getMinMaxDate("max"), newDate = (minDate && date < minDate ? minDate : date); return (maxDate && newDate > maxDate ? maxDate : newDate); }, /* Notify change of month/year. */ _notifyChange: function (inst) { var onChange = this._get(inst, "onChangeMonthYear"); if (onChange) { onChange.apply((this.input ? this.input[0] : null), [this.selectedYear, this.selectedMonth + 1, inst]); } }, /* Determine the number of months to show. */ _getNumberOfMonths: function () { var numMonths = this.numberOfMonths; return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths)); }, /* Determine the current maximum date - ensure no time components are set. */ _getMinMaxDate: function (minMax) { return az.date.determineDate(this[minMax + "Date"], null); }, /* Find the number of days in a given month. */ _getDaysInMonth: function (year, month) { return 32 - az.date.daylightSavingAdjust(new Date(year, month, 32)).getDate(); }, /* Find the day of the week of the first of a month. */ _getFirstDayOfMonth: function (year, month) { return new Date(year, month, 1).getDay(); }, /* Determines if we should allow a "next/prev" month display change. */ _canAdjustMonth: function (offset, curYear, curMonth) { var numMonths = this._getNumberOfMonths(), date = az.date.daylightSavingAdjust(new Date(curYear, curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1)); if (offset < 0) { date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); } return this._isInRange(date); }, /* Is the given date in the accepted range? */ _isInRange: function (date) { var yearSplit, currentYear, minDate = this._getMinMaxDate("min"), maxDate = this._getMinMaxDate("max"), minYear = null, maxYear = null, years = this.yearRange; if (years) { yearSplit = years.split(":"); currentYear = new Date().getFullYear(); minYear = parseInt(yearSplit[0], 10); maxYear = parseInt(yearSplit[1], 10); if (yearSplit[0].match(/[+\-].*/)) { minYear += currentYear; } if (yearSplit[1].match(/[+\-].*/)) { maxYear += currentYear; } } return ((!minDate || date.getTime() >= minDate.getTime()) && (!maxDate || date.getTime() <= maxDate.getTime()) && (!minYear || date.getFullYear() >= minYear) && (!maxYear || date.getFullYear() <= maxYear)); }, /* Provide the configuration settings for formatting/parsing. */ _getFormatConfig: function () { var shortYearCutoff = az.date.shortYearCutoff; shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff : new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10)); return { shortYearCutoff: shortYearCutoff, dayNamesShort: az.date.dayNamesShort, dayNames: az.date.dayNames, monthNamesShort: az.date.monthNamesShort, monthNames: az.date.monthNames }; }, /* Format the given date for display. */ _formatDate: function (day, month, year) { if (!day) { this.currentDay = this.selectedDay; this.currentMonth = this.selectedMonth; this.currentYear = this.selectedYear; } var date = (day ? (typeof day === "object" ? day : az.date.daylightSavingAdjust(new Date(year, month, day))) : az.date.daylightSavingAdjust(new Date(this.currentYear, this.currentMonth, this.currentDay))); return az.date.formatDate(this.dateFormat, date); }, /* Adjust one of the date sub-fields. */ _adjustDate: function (offset, period) { if (this.disabled) { return; } this._adjustInstDate(offset + (period === "M" ? this.showCurrentAtPos : 0), // undo positioning period); this._updateDatepicker(); }, /* Action for current link. */ _gotoToday: function () { var date; if (this.gotoCurrent && this.currentDay) { this.selectedDay = this.currentDay; this.drawMonth = this.selectedMonth = this.currentMonth; this.drawYear = this.selectedYear = this.currentYear; } else { date = new Date(); this.selectedDay = date.getDate(); this.drawMonth = this.selectedMonth = date.getMonth(); this.drawYear = this.selectedYear = date.getFullYear(); } //this._notifyChange(); this._adjustDate(this.stepMonths); }, /* Generate the HTML for the current state of the date picker. */ _generateHTML: function () { var maxDraw, prevText, prev, nextText, next, currentText, gotoDate, controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin, monthNames, monthNamesShort, beforeShowDay, showOtherMonths, selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate, cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows, printDate, dRow, tbody, daySettings, otherMonth, unselectable, tempDate = new Date(), today = az.date.daylightSavingAdjust( new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time isRTL = this.isRTL, showButtonPanel = this.showButtonPanel, hideIfNoPrevNext = this.hideIfNoPrevNext, navigationAsDateFormat = this.navigationAsDateFormat, numMonths = this._getNumberOfMonths(), showCurrentAtPos = this.showCurrentAtPos, stepMonths = this.stepMonths, isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1), currentDate = az.date.daylightSavingAdjust((!this.currentDay ? new Date(9999, 9, 9) : new Date(this.currentYear, this.currentMonth, this.currentDay))), minDate = this._getMinMaxDate("min"), maxDate = this._getMinMaxDate("max"), drawMonth = this.drawMonth - showCurrentAtPos, drawYear = this.drawYear; if (drawMonth < 0) { drawMonth += 12; drawYear--; } if (maxDate) { maxDraw = az.date.daylightSavingAdjust(new Date(maxDate.getFullYear(), maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate())); maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw); while (az.date.daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) { drawMonth--; if (drawMonth < 0) { drawMonth = 11; drawYear--; } } } this.drawMonth = drawMonth; this.drawYear = drawYear; prevText = this.prevText; prevText = (!navigationAsDateFormat ? prevText : az.date.formatDate(prevText, az.date.daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)))); prev = (this._canAdjustMonth(-1, drawYear, drawMonth) ? "" + prevText + "" : (hideIfNoPrevNext ? "" : "" + prevText + "")); nextText = this.nextText; nextText = (!navigationAsDateFormat ? nextText : az.date.formatDate(nextText, az.date.daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)), this._getFormatConfig())); next = (this._canAdjustMonth(+1, drawYear, drawMonth) ? "" + nextText + "" : (hideIfNoPrevNext ? "" : "" + nextText + "")); currentText = this.currentText; gotoDate = (this.gotoCurrent && this.currentDay) ? currentDate : today; currentText = (!navigationAsDateFormat ? currentText : az.date.formatDate(currentText, gotoDate, this._getFormatConfig())); controls = (!this.inline ? "" : ""); buttonPanel = (showButtonPanel) ? "
    " + (isRTL ? controls : "") + (this._isInRange(gotoDate) ? "" : "") + (isRTL ? "" : controls) + "
    " : ""; firstDay = parseInt(this.firstDay, 10); firstDay = (isNaN(firstDay) ? 0 : firstDay); showWeek = this.showWeek; dayNames = az.date.dayNames; dayNamesMin = az.date.dayNamesMin; monthNames = az.date.monthNames; monthNamesShort = az.date.monthNamesShort; beforeShowDay = this.beforeShowDay; showOtherMonths = this.showOtherMonths; selectOtherMonths = this.selectOtherMonths; defaultDate = this._getDefaultDate(); html = ""; prev = az.format(prev, this); next = az.format(next, this); dow; for (row = 0; row < numMonths[0]; row++) { group = ""; this.maxRows = 4; for (col = 0; col < numMonths[1]; col++) { selectedDate = az.date.daylightSavingAdjust(new Date(drawYear, drawMonth, this.selectedDay)); cornerClass = " ui-corner-all"; calender = ""; if (isMultiMonth) { calender += "
    "; } calender += "" + '' + '' + // draw month headers '' + "
    ' + (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") + '' + this._generateMonthYearHeader(drawMonth, drawYear, minDate, maxDate, row > 0 || col > 0, monthNames, monthNamesShort) + '' + (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") + '
    " + "" + ""; thead = (showWeek ? "" : ""); for (dow = 0; dow < 7; dow++) { // days of the week day = (dow + firstDay) % 7; thead += "= 5 ? " class='ui-datepicker-week-end'" : "") + ">" + "" + dayNamesMin[day] + ""; } calender += thead + ""; daysInMonth = this._getDaysInMonth(drawYear, drawMonth); if (drawYear === this.selectedYear && drawMonth === this.selectedMonth) { this.selectedDay = Math.min(this.selectedDay, daysInMonth); } leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7; curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043) this.maxRows = numRows; printDate = az.date.daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays)); for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows calender += ""; tbody = (!showWeek ? "" : ""); for (dow = 0; dow < 7; dow++) { // create date picker days daySettings = (beforeShowDay ? beforeShowDay.apply((this.input ? this.input[0] : null), [printDate]) : [true, ""]); otherMonth = (printDate.getMonth() !== drawMonth); unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] || (minDate && printDate < minDate) || (maxDate && printDate > maxDate); tbody += ""; // display selectable date printDate.setDate(printDate.getDate() + 1); printDate = az.date.daylightSavingAdjust(printDate); } calender += tbody + ""; } drawMonth++; if (drawMonth > 11) { drawMonth = 0; drawYear++; } calender += "
    " + this.weekHeader + "
    " + this.calculateWeek(printDate) + "" + // actions (otherMonth && !showOtherMonths ? " " : // display for other months (unselectable ? "" + printDate.getDate() + "" : "" + printDate.getDate() + "")) + "
    " + (isMultiMonth ? "
    " + ((numMonths[0] > 0 && col === numMonths[1] - 1) ? "
    " : "") : ""); group += calender; } html += group; } // html += ; this._keyEvent = false; // var y =this.flgNext? this._getStartYear return az.format(html, { cid: this.cid }) + this._monthHtml() + this._getYearSpanHtml() /*+ this.cancelBtnPanel()*/ + buttonPanel; ; }, _getYearSpanHtml: function () { if (this.flgNext) { this.flgNext = false; return this._yearHtml(this.yearSpanFrom + 20); } if (this.flgPrev) { this.flgPrev = false; return this._yearHtml(this.yearSpanFrom - 20); } return this._yearHtml(this._getStartYearSpanByDrawnYear(this.drawYear)); }, renderPattern: '@wrapper({content:@calendarHtml+@bottmButtonPanel})', tpls: { calendarHtml: '
    {content}
    ', bottmButtonPanel: '
    {content}
    ' }, tplData: { wrapper: { css: 'az-calendar {css}', style: "display:inline-block; {style}" }, calendarHtml: { content: '' }, bottmButtonPanel: { content: '' } /* mmyyBtn: { text: '' }*/ }, init: function () { this.width = this.getThemeValue('defaultWidth'); this.$super.apply(this, arguments); this._setDate(this.date); this.tplData.calendarHtml.content = this._generateHTML(); }, initTplData: function () { var me = this; this._initStyle(); this.$super.apply(this, arguments); this.cancelBtn = new az.Button({ owner: this, visible: false, text: 'Cancel', listeners: { click: { fn: me.onCancel, scope: this } } }); this.goTodayBtn = new az.Button({ owner: this, visible: true, text: 'Today', listeners: { click: { fn: me._gotoToday, scope: this } } }); this.cancelBtn.preRender(); this.goTodayBtn.preRender(); this.tplData.bottmButtonPanel.content = this.cancelBtn.render() + this.goTodayBtn.render(); }, _initStyle: function () { // this.setStyle('wrapper', 'padding:' + this.getThemeValue('padding') + 'px'); this.addAttr('wrapper', 'tabindex=-1'); if (this.height) this.setStyle('wrapper', 'height:' + (this.height - (this.border)) + 'px'); this.setStyle('wrapper', 'width:' + (this.width - (this.border)) + 'px'); }, events: { handle: { 'click:calendar-{cid}-next': 'onNext', 'click:calendar-{cid}-prev': 'onPrev', 'click:@calendar-{cid}-day-\\d': 'onDaySelect', 'click:calendar-{cid}-title': 'onTitleClick', 'click:@calendar-{cid}-month-\\d': 'onMonthSelect', 'click:@calendar-{cid}-year-\\d': 'onYearSelect', 'click:calendar-{cid}-btn-cancel': 'onCancel' }, custom: ['select'] }, postRender: function () { this.$super.apply(this, arguments); this.cancelBtn.postRender(); this.goTodayBtn.postRender(); }, onNext: function () { if (this.view == 'Y') { this.flgNext = true; this._updateDatepicker(); } else { this._adjustDate(this.stepMonths, "M"); } this.displayCalenderTableByView(); }, onPrev: function () { if (this.view == 'Y') { this.flgPrev = true; this._updateDatepicker(); } else { this._adjustDate(-this.stepMonths, "M"); } this.displayCalenderTableByView(); }, onDaySelect: function (control, event) { var drawDay = event.elementId.split('-')[5]; var date = new Date(this.drawYear, this.drawMonth, drawDay); this.fireEvent('select', date); this.view = 'D'; this.setDate(date); }, onMonthSelect: function (control, event) { this.drawMonth = event.elementId.split('-')[5]; this.view = 'D'; this._updateDatepicker(); this.displayCalenderTableByView(); }, onYearSelect: function (control, event) { this.drawYear = parseInt($('#' + event.elementId).text()); this.view = 'M'; this._updateDatepicker(); this.displayCalenderTableByView(); }, onTitleClick: function (control, event) { if (this.view == 'D') { this.view = 'M'; this.displayCalenderTableByView(); } else if (this.view == 'M') { this.view = 'Y'; this.displayCalenderTableByView(); } }, onCancel: function () { if (this.view == 'Y') { this.view = 'M'; this._updateDatepicker(); this.displayCalenderTableByView(); } else if (this.view == 'M') { this.view = 'D'; this._updateDatepicker(); this.displayCalenderTableByView(); } }, getCalendarTableElm: function (tableName) { return '#calendar-' + this.cid + '-' + tableName + '-table'; }, setDate: function (date) { this._setDate(date); this._updateDatepicker(); }, _monthHtml: function () { var html = ''; var mIndex = 0; for (var tr = 0; tr < 4; tr++) { html += ''; for (var td = 0; td < 3; td++) { // var index = (td == 1) ? (6 + mIndex) : mIndex html += ''; mIndex++; } html += ''; } html += '
    ' + az.date.monthNames[mIndex] + '
    '; return az.format(html, this); ; }, _yearHtml: function (startYear) { this.yearSpanFrom = startYear; var html = ''; var mIndex = 0; for (var tr = 0; tr < 4; tr++) { html += ''; for (var td = 0; td < 5; td++) { // var index = (td > 0) ? (5 * td + mIndex) : mIndex; html += ''; mIndex++; } // mIndex++; html += ''; } html += '
    ' + (startYear + mIndex) + '
    '; return az.format(html, this); ; }, _getStartYearSpanByDrawnYear: function (drwaYear) { var year = drwaYear.toString().substr(2, 2); year = parseInt(year); var start = (year < 20 && year > 0) ? 1 : (year % 20 == 0 ? ((year / 20) - 1) * 20 : ((year - (year % 20)) / 20) * 20) + 1; var century = drwaYear - year; return century + start; }, displayCalenderTableByView: function () { $(this.getCalendarTableElm('day'))[this.view == 'D' ? 'show' : 'hide'](); $(this.getCalendarTableElm('month'))[this.view == 'M' ? 'show' : 'hide'](); $(this.getCalendarTableElm('year'))[this.view == 'Y' ? 'show' : 'hide'](); if (this.view == 'M') $('#calendar-' + this.cid + '-title').text(this.drawYear); if (this.view == 'Y') $('#calendar-' + this.cid + '-title').text(this.yearSpanFrom.toString() + '-' + (this.yearSpanFrom + 19).toString()); //$('#calendar-' + this.cid + '-cancel-btn-panel')[(this.view == 'M' || this.view == 'Y') ? 'show' : 'hide'](); this.cancelBtn[(this.view == 'M' || this.view == 'Y') ? 'show' : 'hide'](); this.goTodayBtn[(this.view == 'M' || this.view == 'Y') ? 'hide' : 'show'](); this.initEvents(); } }); /*Scripts/libs/Astral/Control/Tree.js*/ az.defineClass('TreeNode', { $extends: 'Control', $includes: 'draggable', draggable: false, dragConfig: { containment: 'document', appendTo: "body", helper: 'clone', cursorAt: { top: 20, left: 20 } }, onDragStart: function (e, ui) { ui.helper.children('span.az-tree-line').remove(); ui.helper.children('span.az-tree-checkbox').remove(); ui.helper.children('span.az-tree-indent').remove(); ui.helper.children('span.az-tree-joinbottom').remove(); }, indent: 0, checked: false, hasChildren: false, defaultIconCls: 'az-tree-file', defaultOpenIconCls: 'az-tree-folder-open', defaultCloseIconCls: 'az-tree-folder', openIconCls: 'az-tree-folder-open', closeIconCls: 'az-tree-folder', isClosed: false, line:false, lineJoinCls: 'az-tree-join', renderPattern: '@wrapper({content:@indent+@join+@joinBottom+@hit+@icon+@check+@title})', tpls: { indent: '@for(var i=0; i<(global.indent); i++){}', join: '@if(global.join){}', joinBottom: '@if(global.joinBottom){}', hit: '@if(global.children){}', icon: '', check: '@if(global.checkbox){}', title: '{text}' }, tplData: { wrapper: { css: 'az-tree-node {css}' }, title: { text: '{text}', titleCls: '{titleCls}' } }, events: { handle: { 'click:{$class}-{cid}-hit': 'onHitClick', 'click:{$class}-{cid}-checkbox': 'onCheckboxClick', 'click:{$class}-{cid}-title': 'onTitleClick', 'dblclick:{$class}-{cid}-title': 'onTitleDblClick', 'mouseenter:{$class}-{cid}': 'onMouseEnter', 'mouseleave:{$class}-{cid}': 'onMouseLeave' }, custom: ['check', 'hit', 'click', 'dblclick'] }, initTplData: function () { this.$super.apply(this, arguments); if (this.children) { this.openIconCls = this.openIconCls || this.defaultOpenIconCls; this.iconCls = this.iconCls || this.defaultCloseIconCls; this.closeIconCls = this.iconCls; } else { this.iconCls = this.iconCls || this.defaultIconCls; } this.setCloseState(this.isClosed); if (this.isLast) { this.lineJoinCls = 'az-tree-joinbottom'; } }, onMouseEnter: function () { this.addCls('wrapper', 'az-tree-node-hover'); }, onMouseLeave: function () { this.removeCls('wrapper', 'az-tree-node-hover'); }, onHitClick: function () { this.setCloseState(!this.isClosed, true); }, setCloseState: function (isClosed, notify) { this.isClosed = isClosed; if (this.rendered) { this.removeCls('hit', 'az-tree-' + (isClosed ? 'expanded' : 'collapsed')); this.addCls('hit', 'az-tree-' + (isClosed ? 'collapsed' : 'expanded')); if (this.children && this.children.length > 0 && this.openIconCls != this.closeIconCls) { if (isClosed) { this.removeCls('icon', this.openIconCls); this.addCls('icon', this.closeIconCls); } else { this.addCls('icon', this.openIconCls); this.removeCls('icon', this.closeIconCls); } } } else { if (this.children) { this.iconCls = (isClosed ? this.iconCls : this.openIconCls); } } if (notify) this.fireEvent('hit', isClosed); }, onCheckboxClick: function () { if(!this.checkDisabled) this.markChecked(!this.checked, true); }, onTitleClick: function (control, event) { this.fireEvent('click', event); }, onTitleDblClick: function () { this.fireEvent('dblclick'); }, markChecked: function (checked, notify) { this.checked = checked; if (this.indeterminate) { this.removeCls('check', 'az-tree-checkbox2'); this.indeterminate = false; } if (checked) { this.removeCls('check', 'az-tree-checkbox0'); this.addCls('check', 'az-tree-checkbox1'); } else { this.removeCls('check', 'az-tree-checkbox1'); this.addCls('check', 'az-tree-checkbox0'); } if (notify) this.fireEvent('check', this.checked); }, markIndeterminate: function () { this.checked = false; this.indeterminate = true; this.addCls('check', 'az-tree-checkbox2'); this.removeCls('check', 'az-tree-checkbox0'); this.removeCls('check', 'az-tree-checkbox1'); }, markHighlight: function () { this.addCls('title', 'az-tree-node-selected'); }, clearHighlight: function () { this.removeCls('title', 'az-tree-node-selected'); }, setTitle: function (text) { this.text = text; $(this.dom.title).html(this.text); } }); az.defineClass('Tree', { $extends: 'Control', cascadeCheck: false, onlyLeafeCheck: false, showLines: false, nodeDraggable: false, wrapTag: 'ul', checkbox: false, idField: 'id', checkedFiled: 'checked', parentField: 'parent', titleField: 'text', rootTitle: 'Root', iconClsField: 'iconCls', openIconClsField: 'openIconCls', hideRoot: false, selectMode: 'single', // multi //autoCollapse: false, // Automatically collapse all siblings, when a node is expanded. minCloseLevel: 1, closeAll: false, openAll: true, border:0, selectedNodes: [], _treeTpl: az.createTpl('{node}
      {children}
    '), tplData: { }, events: { custom: ['select', 'collapse', 'expand', 'check', 'nodedblclick', 'nodedragstart', 'nodedragstop'] }, init: function () { this.$super.apply(this, arguments); this._postInit(); }, _postInit: function () { if (!this.data) return; var data = this.data; this.nodes = []; //create rootNode if (!this.hideRoot) this.nodes.push(this.createTreeNode({ id: 'root', parent: '0', text: this.rootTitle, nodeId: 0 })); for (var i = 0; i < data.length; i++) { if (data[i][this.idField]) { data[i].nodeId = (this.hideRoot ? i : i + 1); this.nodes.push(this.createTreeNode(data[i])); } } this._parents = az.group(this.nodes, this.parentField, this); }, createTreeNode: function (nodeData) { var tn = new az.TreeNode({ owner: this, id: $.trim(nodeData[this.idField]), parent: (nodeData[this.parentField] ? $.trim(nodeData[this.parentField]) : 'root'), text: nodeData[this.titleField], nodeId: nodeData.nodeId, nodeData: nodeData, draggable: this.nodeDraggable, checked: nodeData[this.checkedFiled], css: nodeData.css || '' }); if (nodeData[this.iconClsField]) tn.iconCls = nodeData[this.iconClsField]; if (nodeData[this.openIconClsField]) tn.openIconCls = nodeData[this.openIconClsField]; tn.addListener('hit', this.onNodeParentHit, this); tn.addListener('click', this.onNodeClick, this); tn.addListener('check', this.onNodeCheck, this); tn.addListener('dblclick', this.onNodeDblClick, this); tn.checkDisabled = nodeData.checkDisabled; if (this.nodeDraggable) { var me = this; tn.addListener('dragstart', function (control, event, ui) { me.fireEvent('nodedragstart', tn, ui); }); tn.addListener('dragstop', function (control, event, ui) { me.fireEvent('nodedragstop', tn, ui); }); } return tn; }, render: function () { if (this.nodes) { var chindren = []; if (this.hideRoot) { chindren.push(this.createChildren()); } else { this._preRenderNodes(this.nodes[0], chindren); } if (!this.rendered) this.tplData.wrapper.content = chindren[0]; else { $(this.dom.wrapper).html(chindren[0]); } } return this.$super.apply(this, arguments); }, setChildChecked: function (parent) { var checked = parent.children[parent.children.length - 1].checked || false; this.onNodeCheck(parent.children[parent.children.length - 1], !checked); this.onNodeCheck(parent.children[parent.children.length - 1], checked); if (parent.children) this.setChildChecked(parent); }, getChildren: function (parent) { return this._parents[parent]; }, createChildren: function (parent) { var _html = []; var children = !parent ? this.getChildren('root') : parent.children; if (children) { for (var i = 0; i < children.length; i++) { children[i].childOrder = !parent ? i : (parent.childOrder || '0') + '-' + i; ; children[i].indent = parent ? parent.indent + 1 : 0; children[i].line = this.showLines ? [] : false; children[i].isLast = (i == children.length - 1); children[i].parent = parent; this._preRenderNodes(children[i], _html); } } return _html.join(''); }, _preRenderNodes: function (node, bufferHtml) { node.children = this.getChildren(node ? node.id : 'root'); node.indent = !node.children ? node.indent + 1 : node.indent; node.checkbox = this.checkbox ? (this.onlyLeafeCheck ? !node.children : true) : false; node.isClosed = this.openAll ? false : (this.closeAll || (this.minCloseLevel <= node.indent)); if (node.id == this.selectedId) { node.markHighlight(); } if (node.line) { node.line = node.parent ? (node.parent.line || "0") : ''; node.line += node.isLast ? '0' : "1"; } if (!node.rendered) node.preRender(); bufferHtml.push('
  • ' + this._treeTpl({ node: node.render(), cid: this.cid, treeId: (node.childOrder || '0'), children: this.createChildren(node), visible: (node.isClosed ? 'display:none' : 'display:block') }) + '
  • '); }, postRender: function () { this.$super.apply(this, arguments); if (this.nodes) { for (var i = 0; i < this.nodes.length; i++) { this.nodes[i].postRender(); } var checkedNds = this.getCheckedNodes(); for (var j = 0; j < checkedNds.length; j++) { var node = checkedNds[j]; this.onNodeCheck(node, false); this.onNodeCheck(node, true); } } }, initTplData: function () { this.$super.apply(this, arguments); this.addCls('wrapper', 'az-tree az-border' + (this.showLines ? ' az-tree-lines' : '')); this.setStyle('wrapper', this._getBorderStyle()); } , onNodeParentHit: function (control, collapsed) { $('#tree-' + this.cid + '-' + (control.childOrder || '0'))[collapsed ? 'hide' : 'show']('fast'); this.fireEvent(collapsed ? 'collapse' : 'expand', control); }, onNodeClick: function (control, event) { if (this.selectMode == 'multi' && event.browserEvent.ctrlKey) { var index = this.checkExisting(control); if (index == -1) { this.selectedNodes.push(control); } else { this.selectedNodes[index].clearHighlight(); this.selectedNodes.splice(index, 1); } for (var i = 0; i < this.selectedNodes.length; i++) { this.selectedNodes[i].markHighlight(); } this.fireEvent('select', this.selectedNodes); } else { this.select(control, true); } }, select: function (node, notify) { for (var j = 0; j < this.selectedNodes.length; j++) { this.selectedNodes[j].clearHighlight(); } this.selectedNodes = [node]; this.selectedNodes[0].markHighlight(); if (notify) this.fireEvent('select', this.selectedNodes[0]); }, setSelectionById: function (id, select) { var node = this.getNodeById(id); if (node) { if (select) { this.selectedNodes.push(node); node.markHighlight(); } else { var index = this.nodes.indexOf(node); this.selectedNodes.splice(index, 1); node.clearHighlight(); } } }, checkExisting: function (node) { for (var i = 0; i < this.selectedNodes.length; i++) { if (this.selectedNodes[i] === node) return i; } return -1; }, onNodeDblClick: function (control) { this.fireEvent('nodedblclick', control); }, onNodeCheck: function (control, checked) { this.fireEvent('check', control, checked); if (this.cascadeCheck) { this.markCheckOnChildren(control); this.markIndeterminateOnParent(control); } }, markCheckOnChildren: function (parent) { if (parent.children) { for (var i = 0; i < parent.children.length; i++) { parent.children[i].markChecked(parent.checked); this.markCheckOnChildren(parent.children[i]); } } }, markIndeterminateOnParent: function (child) { if (child.parent && child.parent != '0') { var siblingCheckedCount = 0; var siblingIndeterminateCount = 0; if (child.parent.children) { for (var i = 0; i < child.parent.children.length; i++) { siblingCheckedCount += (child.parent.children[i].checked ? 1 : 0); siblingIndeterminateCount += (child.parent.children[i].indeterminate ? 1 : 0); } } if (siblingIndeterminateCount > 0) { child.parent.markIndeterminate(); } else if (siblingCheckedCount == 0) { child.parent.markChecked(false); } else if (siblingCheckedCount == child.parent.children.length) { child.parent.markChecked(true); } else { child.parent.markIndeterminate(); } this.markIndeterminateOnParent(child.parent); } }, getCheckedNodes: function () { var checked = []; for (var i = 0; i < this.nodes.length; i++) { if (this.nodes[i].checked) checked.push(this.nodes[i]); } return checked; }, getNodeById: function (id) { var node = undefined; for (var i = 0; i < this.nodes.length; i++) { if (this.nodes[i].id == id) { node = this.nodes[i]; break; } } return node; }, updateTree: function () { this._postInit(); if (!this.rendered) this.preRender(); this.render(); this.postRender(); }, addNode: function (node, updateTree) { this.data.push(node); if (updateTree) this.updateTree(); }, removeNode: function (id) { for (var i = 0; i < this.data.length; i++) { if (this.data[i][this.idField] == id || this.data[i][this.parentField] == id) { this.data.splice(i, 1); break; } } this.updateTree(); }, move: function (id, newParentId) { var node = undefined; for (var i = 0; i < this.data.length; i++) { if (this.data[i][this.idField] == id) { node = this.data[i]; break; } } if (node) node[this.parentField] = newParentId; this.updateTree(); } }); /* dblclick select/multiselect/hover/selected/ draggable defaul root node=> show hide showlines/ icnCls=> leafe + parentNode Move Node, idField+ parentIdField+ titleField, icomField check=> cascade+ leafeonly */ /*Scripts/libs/Astral/Control/Image.js*/ az.defineClass('Image', { $extends: 'Control', height: 100, width: 100, wrapTag: 'img', border: 1, padding: 3, src: '', alt: '', initTplData: function () { this.$super.apply(this, arguments); this.addCls('wrapper', 'az-img az-border'); if (!this.src) this.addCls('wrapper', 'az-img-no-src'); this.tplData.wrapper.attr = 'alt="' + this.alt + '" src="' + this.src+ '"'; }, setSrc: function (src) { this.src = src; this.addAttr('wrapper', { 'src': src }); this.removeCls('wrapper', 'az-img-no-src'); }, setPadding: function (padding) { if (az.chk.ifString(padding)) { var vals = padding.split(' '); padding = vals.length == 1 ? vals[0] : { top: vals[0] || 0, right: vals[1] || 0, bottom: vals[2] || 0, left: vals[3] || 0 }; } this.padding = padding; this.setStyle('wrapper', this._getPaddingStyle()); this.onResize(); }, setBorder: function (border) { if (az.chk.ifString(border)) { var vals = border.split(' '); border = vals.length == 1 ? vals[0] : { top: vals[0] || 0, right: vals[1] || 0, bottom: vals[2] || 0, left: vals[3] || 0 }; } this.border = border; this.setStyle('wrapper', this._getBorderStyle()); this.onResize(); }, }); /*Scripts/libs/Astral/Util/Resizer.js*/ az.defineClass('Resizer', { $extends: 'Layer', $includes: 'draggable', visible: false, border: false, padding: 0, _dragging: false, events: { handle: { 'mouseleave:{$class}-{cid}': 'hideResizer' }, custom: ['resize'] }, draggable: true, initialX: -1, initialY: -1, init: function (config) { az.copy(config, { dragConfig: { axis: config.axis } }); this.$super(config); }, initTplData: function () { this.$super.apply(this, arguments); if (this.axis == 'x') this.setStyle('root', 'cursor', 'col-resize'); else this.setStyle('root', 'cursor', 'row-resize'); this.setStyle('root', 'background-color', 'transparent'); }, setupProxy: function () { if (az.chk.ifString(this.proxy)) this.setContent(this.proxy); if (az.chk.ifFunction(this.proxy)) this.setContent(this.proxy()); if (az.chk.ifObject(this.proxy) && this.proxy.fn) this.setContent(this.proxy.fn.call(this.proxy.scope)); }, show: function (elementId, left, top, constraint) { this.sourceEl = elementId; if (!this.rendered) this.render(); this.setupProxy(); this.setPosition(left, top); this.$super(); this.activate(); }, hideResizer: function () { if (!this._dragging) { this.hide(); } }, onDragStart: function (event) { if (!this.isContainmentSet) { $(this.getRootEl()).draggable("option", "containment", this.containment); this.isContainmentSet = true; } this.initialX = event.pageX; this.initialY = event.pageY; this.addCls('root', 'az-datagrid-resize-resizing'); this._dragging = true; }, onDragStop: function (event) { this._dragging = false; this.removeCls('root', 'az-datagrid-resize-resizing'); if (this.axis == 'x') this.fireEvent('resize', this.sourceEl, -1 * (this.initialX - event.pageX), 'x'); else this.fireEvent('resize', this.sourceEl, -1 * (this.initialY - event.pageY), 'y'); this.hide(); } }); /*Scripts/libs/Astral/Util/Dragger.js*/ az.defineClass('Dragger', { $extends: 'Layer', $includes: 'draggable', visible: false, border: 2, padding: 0, _dragging: false, events: { handle: { 'mouseup:{$class}-{cid}': 'hideDragger', 'mouseout:{$class}-{cid}': 'hideDragger' }, custom: ['draggerMove'] }, draggable: true, initTplData: function () { this.$super.apply(this, arguments); this.setStyle('root', 'cursor', 'row-drag'); }, setBoundary: function (boundaryEl) { $(this.getRootEl()).draggable("option", "containment", boundaryEl); }, show: function (elementId) { this.sourceEl = elementId; if (!this.rendered) this.render(); this.setSize($(elementId).height(), $(elementId).width()); var offset = $(elementId).offset(); this.elPos = $(elementId).position(); this.setPosition(offset.left, offset.top); this.$super(); this.activate(); //$(this.getRootEl()).trigger('mousedown'); }, hideDragger: function () { if (!this._dragging) { this.hide(); } }, onDragStart: function (event) { this.initalDraggerPos = $(this.getRootEl()).position(); this._dragging = true; }, onDragStop: function (event) { if (!this.sourceEl) return; this._dragging = false; var currentDraggerPos = $(this.getRootEl()).position(); var leftOffset = currentDraggerPos.left - this.initalDraggerPos.left; var topOffset = currentDraggerPos.top - this.initalDraggerPos.top; var newLeft = this.elPos.left + leftOffset; var newTop = this.elPos.top + topOffset; if (newLeft < 0) newLeft = 0; if (newTop < 0) newTop = 0; this.fireEvent('draggerMove', newLeft, newTop); this.hide(); } }); /*Scripts/libs/Astral/Container/Window.js*/ az.defineClass('Window', { $extends: 'Layer', $includes: 'draggable,maskable,resizable', draggable: true, resizable: true, visible: true, layoutTarget: 'body', headerToolbar: true, renderPattern: '@root({content:@header({controlBox:@controlBox({triggers:@triggerButtons})})+@toolbar+@body+@bottombar})', collapsed: false, collapsible: true, maximizable: true, maximized: false, maximizeOnShow: false, closable: true, border: 0, maskOnDisable: true, maskTargetDom: 'body', resizeConfig: { helper: "resizable-helper" }, dragConfig: { handle: '.az-panel-title' }, modal: false, hideOnClose: false, height: 400, width: 500, events: { handle: { 'mousedown:{$class}-{cid},windowHeader-{cid},windowBody-{cid}': 'activate', 'click:collapse-{cid}': '_toggleCollapse', 'click:maxMin-{cid}': '_toggleMaxMin', 'click:close-{cid}': 'onClose', 'click:@{$class}-{cid}-trigger-\\d': 'onTriggerButtonClick', 'mousedown:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseDown', 'mousedown:collapse-{cid},maxMin-{cid},close-{cid}': 'onHeaderToolbarButtonMouseDown', 'mouseup:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseUp', 'mouseup:collapse-{cid},maxMin-{cid},close-{cid}': 'onHeaderToolbarButtonMouseUp', 'mouseenter:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseEnter', 'mouseenter:collapse-{cid},maxMin-{cid},close-{cid}': 'onHeaderToolbarButtonMouseEnter', 'mouseleave:@{$class}-{cid}-trigger-\\d': 'onHeaderToolbarButtonMouseLeave', 'mouseleave:collapse-{cid},maxMin-{cid},close-{cid}': 'onHeaderToolbarButtonMouseLeave' }, custom: ['close', 'maximize'] }, tpls: { header: '
    {title}
    {controlBox}
    ', controlBox: '
    {triggers}{content}
    ', body: '
    {content}
    ', toolbar: '{tcontent}', bottombar: '{bcontent}', triggerButtons: '@for(var i=0; i< ctx.triggers.length; i++ ){}', }, shadowTpl: az.createTpl(''), overlayTpl: az.createTpl(''), tplData: { controlBox: { }, header: { dragableCls: '' }, root: { css: 'az-panel az-window {css}' }, body: { css: '{bodyCls} ' }, toolbar: { tcontent: '' }, bottombar: { bcontent: '' }, triggerButtons: { triggers: '' } }, onHeaderToolbarButtonMouseDown: function (control,event) { $('#' + event.elementId).addClass('az-panel-trigger-pressed'); $('#' + event.elementId).removeClass('az-panel-trigger-hover'); }, onHeaderToolbarButtonMouseUp: function (control, event) { $('#' + event.elementId).removeClass('az-panel-trigger-pressed'); $('#' + event.elementId).addClass('az-panel-trigger-hover'); }, onHeaderToolbarButtonMouseEnter: function (event) { $('#' + event.elementId).addClass('az-panel-trigger-hover'); }, onHeaderToolbarButtonMouseLeave: function (event) { $('#' + event.elementId).removeClass('az-panel-trigger-hover'); }, setTriggerDisabled: function (triggerIndex, disabled) { this.triggers[triggerIndex].disabled = disabled; if (disabled) { $(az.format('#{$class}-{cid}-trigger-' + triggerIndex, this)).addClass('az-panel-trigger-button-disabled'); } else { $(az.format('#{$class}-{cid}-trigger-' + triggerIndex, this)).removeClass('az-panel-trigger-button-disabled'); } }, _toggleMaxMin: function () { if (this.maximized) this.restore(); else { if (this.collapsed) { this.collapsed = false; $(this.dom.body).fadeTo(50, 1); if (this.tbar) this.tbar.show(); if (this.bbar) this.bbar.show(); }; this.maximize(); } }, maximize: function () { this.tempObj = { height: this.height, width: this.width, left: this.left, top: this.top }; if (this.zIndex < az.LayerManager.currentTopValue) az.LayerManager.bringToTopBy(this, 3); this.setPosition(0, 0); this.setSize($(window).height(), $(window).width()); $('body').addClass('az-window-maximized'); $('#maxMin-' + this.cid).removeClass('az-panel-tool-max'); // change these .. $('#maxMin-' + this.cid).addClass('az-panel-tool-restore'); // change these .. this.fireEvent('maximize'); var me = this; setTimeout(function () { me.dragDisable(); me.resizeDisable(); }, 200); this.collapsed = false; this.maximized = true; }, restore: function () { this.maximized = false; this.setPosition(this.tempObj.left, this.tempObj.top); this.setSize(this.tempObj.height, this.tempObj.width, true); $('body').removeClass('az-window-maximized'); $('#maxMin-' + this.cid).removeClass('az-panel-tool-restore'); // change these .. $('#maxMin-' + this.cid).addClass('az-panel-tool-max'); // change these .. this.dragEnable(); this.resizeEnable(); delete this.tempObj; }, _toggleCollapse: function () { if (this.maximized) return false; // check if collapsible first then proceed.. fix bug var collapseBtn = $('#collapse-' + this.cid); var shadow = $(this.getShadowEl()); var me = this; if (this.collapsed) { $(this.dom.root).animate({ height: this.__innerHeight(), width: this.__innerWidth() }, 140, function () { $(me.dom.body).fadeTo(50, 1); }); shadow.animate({ height: this.height, width: this.width }, 140); collapseBtn.addClass('az-panel-tool-collapse'); collapseBtn.removeClass('az-panel-tool-expand'); if (this.tbar) this.tbar.show(); if (this.bbar) this.bbar.show(); this.resizeEnable(); } else { $(this.dom.body).fadeTo(50, 0, function () { $(me.dom.body).hide(); $(me.dom.root).animate({ height: me.getThemeValue('headerHeight')- me._getBorder('bottom')-me.getThemeValue('frameSpan'), width: me.__innerWidth() }, 140); shadow.animate({ height: 29, width: me.width }, 140); collapseBtn.addClass('az-panel-tool-expand'); collapseBtn.removeClass('az-panel-tool-collapse'); if (me.tbar) me.tbar.hide(); if (me.bbar) me.bbar.hide(); me.fireEvent('collapse'); }); this.resizeDisable(); } this.collapsed = !this.collapsed; }, init: function (config) { this.padding = this.getThemeValue('defaultPadding'); this.border = this.getThemeValue('defaultBorder'); if(config) { if (config.tbar) { if( az.chk.ifObject(config.tbar)) az.copy(this.tbar, config.tbar); else if(!this.tbar) this.tbar = config.tbar; delete config.tbar; } if (config.bbar) { if(az.chk.ifObject(config.bbar)) az.copy(this.bbar, config.bbar); else if( !this.bbar)this.bbar = config.bbar; delete config.bbar; } } this.$super.apply(this, arguments); if (this.tbar && az.chk.ifArray(this.tbar)) { this.tbar = new az.Toolbar({ owner: this, css: 'az-tbar', border: { left: 1, right: 1, top: 1 }, items: this.tbar, xwidth: this.width }); } if (this.bbar && az.chk.ifArray(this.bbar)) { this.bbar = new az.Toolbar({ owner: this, css: 'az-bbar', bbar: true, centerAlign: this.bbarCenterAlign, border: 0, padding: 5, items: this.bbar }); } this.triggers = this.triggers || []; this.tplData.triggerButtons.triggers = this.triggers; }, onTriggerButtonClick: function (control, event) { var iIndex = event.elementId.split('-')[5]; if (this.triggers[iIndex].handle && !this.triggers[iIndex].disabled) { this.triggers[iIndex].handle(event); } }, initTplData: function () { this.$super.apply(this, arguments); if (this.headerToolbar) { var htBarBuffer = []; if (this.collapsible) htBarBuffer.push(az.format('', this)); if (this.maximizable) { htBarBuffer.push(az.format('', this)); } if (this.closable) htBarBuffer.push(az.format('', this)); this.tplData.controlBox.content = htBarBuffer.join(''); } this.setStyle('body', { height: this.__windowBodyHeight() + 'px' }); this.setStyle('body', this._getBorderStyle()); this.setStyle('root', { height: this.__innerHeight() + 'px', width: this.__innerWidth() + 'px', 'z-index': this.zIndex }); if (this.draggable) { this.tplData.header.dragableCls = 'az-draggableWin'; } }, onClose: function () { $('body').css('overflow', 'auto'); this.fireEvent('close'); if (this.hideOnClose) { if (this.maximized) this.restore(); this.hide(); } else { this.destroy(); } }, destroy: function () { if (this.tbar) this.tbar.destroy(); if (this.bbar) this.bbar.destroy(); $(this.getShadowEl()).remove(); $(this.getOverlayEl()).remove(); $('body').css('overflow', 'auto'); this.$super.apply(this, arguments); }, show: function () { var renderAndShow = false; this.layout.suspendLayout = true; if (!this.rendered) { this.render(); renderAndShow = true; } if (this.modal) { var calcTop = $(window).height() * .4 - $(this.getRootEl()).outerHeight() / 2; this.top = calcTop < 0 ? 10 : calcTop; this.left = $(window).width() * .5 - $(this.getRootEl()).outerWidth() / 2; this.setPosition(this.left, $(window).scrollTop()+ this.top); $('body').css('overflow', 'hidden'); } this.$super.apply(this, arguments); if (this.maximizeOnShow) this.maximize(); if(renderAndShow) this.onResize(); this.activate(); }, getShadowEl: function () { return '#windowShadow-' + this.cid; }, getOverlayEl: function () { return '#window-' + this.cid + '-overlay'; // use $class name }, activate: function () { var offest = this.zIndex == 1001 ? 1 : (this.zIndex < az.LayerManager.currentTopValue ? 3 : 0); if (offest > 0) az.LayerManager.bringToTopBy(this, offest); this.zIndex = az.LayerManager.currentTopValue; this._adjustShadow(); }, hide: function () { this.$super.apply(this, arguments); $(this.getShadowEl()).hide(); $(this.getOverlayEl()).hide(); }, _adjustBody: function () { var tbarHeight = 0, bbarHeight = 0; if (this.rendered) { if (this.tbar && this.tbar.items.length == 0) this.tbar.hide(); else { tbarHeight = (this.tbar ? $(this.tbar.dom.root).outerHeight() : 0); if (this.tbar && !this.tbar.visible) this.tbar.show(); } if (this.bbar && this.bbar.items.length == 0) this.bbar.hide(); else { bbarHeight = (this.bbar ? $(this.bbar.dom.root).outerHeight() : 0); if (this.bbar && !this.bbar.visible) this.bbar.show(); } } var bodyHeight = this.__windowBodyHeight() - tbarHeight - bbarHeight; this.setStyle('body', 'height:' + (bodyHeight == 0 ? 'auto' : bodyHeight + 'px;')); this.layout.update(); }, _adjustShadow: function () { var win = $(this.dom.root); var zIndex= parseInt(win.css('z-index')); $(this.getShadowEl()).css({ 'width': win.outerWidth(), 'height': win.outerHeight(), 'top': win.offset().top, 'left': win.offset().left, 'zIndex': zIndex - 1 })[this.isDragging ? 'hide' : 'show'](); if (this.modal) $(this.getOverlayEl()).css('zIndex',zIndex - 1).show(); }, postRender: function () { this.$super.apply(this, arguments); if (this.tbar) this.tbar.postRender(); if (this.bbar) this.bbar.postRender(); this._adjustBody(); }, render: function () { if (this.tbar) { this.tbar.preRender(); this.tplData.toolbar.tcontent = this.tbar.render(); } if (this.bbar) { this.bbar.preRender(); this.tplData.bottombar.bcontent = this.bbar.render(); } this.$super.apply(this, arguments); $('body').append(this.shadowTpl(this)); if (this.modal) { $('body').append(this.overlayTpl(this)); } this.hide(true); }, setTitle: function (title) { this.title = title; $(this.dom.header).find('.az-panel-title').text(this.title); }, onDragStart: function () { this.isDragging = true; $(this.getShadowEl()).hide(); }, onDragStop: function (event, ui) { this.isDragging = false; this.top = ui.position.top; this.left = ui.position.left; this._adjustShadow(); }, onResize: function (event, ui) { if (arguments.length == 0 && this.rendered) { this.setStyle('root', { height: this.__innerHeight() + 'px', width: this.__innerWidth() + 'px' }); if (this.tbar) this.tbar.onResize(); if (this.bbar) this.bbar.onResize(); this._adjustShadow(); this._adjustBody(); } this.updateLayout(); }, onResizeStart: function (event, ui) { $('.resizable-helper').css('zIndex', az.LayerManager.currentTopValue + 1); }, onResizeStop: function (event, ui) { this.setSize(ui.size.height, ui.size.width); this._adjustShadow(); this._adjustBody(); }, __innerHeight: function () { return this.height - (this.__windowBorderAndPadding()); }, __innerWidth: function () { return this.width - (this.__windowBorderAndPadding()); }, getLayoutSize: function () { return { boxSize: { height: (this.rendered ? $(this.getRootEl()).outerHeight() : this.height), width: (this.rendered ? $(this.getRootEl()).outerWidth() : this.width) }, contentAreaSize: ( this.rendered ? { height: $(this.dom[this.layoutTarget]).height(), width: $(this.dom[this.layoutTarget]).width()} : { height: this.__windowBodyHeight(), width: this.width - (this.__windowBorderAndPadding() + this._getBorder('left') + this._getBorder('right') + this._getPadding('left') + this._getPadding('right')) } ) }; }, __windowBodyHeight: function () { var tbarHeight = 0, bbarHeight = 0; tbarHeight = (this.tbar ? $(this.tbar.dom.root).outerHeight() : 0); bbarHeight = (this.bbar ? $(this.bbar.dom.root).outerHeight() : 0); var innerHeight = this.maximized ? $(window).height() - (this._getBorder('top') + this._getBorder('bottom') + tbarHeight + bbarHeight) : this.__innerHeight(); return innerHeight - (this.getThemeValue('headerHeight') + (this._getBorder('top') + this._getBorder('bottom')) + (this._getPadding('top') + this._getPadding('bottom'))); }, __windowBorderAndPadding: function () { return (this.getThemeValue('frameSpan') + this._getBorder('top') + this._getBorder('bottom')); }, __headerHeight: function () { return (this.getThemeValue('headerHeight')); } }); /*Scripts/libs/Astral/Control/Field/NumberField.js*/ az.defineClass('NumberField', { $extends: 'TextField', maxLength: 12, decimalPrecision: 0, allowDecimal: true, allowNegative: true, defaultValue: 0, maxValue: Number.MAX_VALUE, minValue: Number.MIN_VALUE, decimalSeparator: '.', _escapeRegexChars: function (str) { str = str.replace('.', '\\.'); return str; }, onKeyUp: function (event) { var val = this.getRawValue(); if (val == undefined || val.length == 0 || val == 0) { this.clearInvalid(); this.fireEvent('keyup', event); return; } this[(this.allowedNumberFormatRe.test(val) && (+val > this.minValue && +val < this.maxValue) ? 'clear' : 'mark') + 'Invalid'](); this.fireEvent('keyup', event); }, xonKeyPress: function (control, event) { this.setValue(this.getRawValue().replace(/[^0-9\.]/g, '')); // $(this).val($(this).val().replace(/[^0-9\.]/g, '')); if ((event.browserEvent.which != 46 || this.getValue().indexOf('.') != -1) && (event.browserEvent.which < 48 || event.browserEvent.which > 57)) { event.browserEvent.preventDefault(); } this.$super.apply(this, arguments); }, interceptKeyPress: function (event) { // return true; // if(!this.getRawValue() || this.getRawValue().legnth== 0 ) return true; if (event.ctrlKey) return true; if (event.charCode > 0) { var valueToBe = (this.getValue() || '') + ''; valueToBe = valueToBe.split(""); valueToBe.splice($(this.dom.input).getCursorPosition(), 0, String.fromCharCode(event.charCode)); return this.allowedCharsRe.test(String.fromCharCode(event.charCode)) && this.allowedNumberFormatRe.test(valueToBe.join("")); } return true; }, _initNumberRegex: function () { var regExTxt = '^'; var allowedRegex = '\\d'; if (this.allowNegative) { allowedRegex += '|-'; regExTxt += '-?'; } regExTxt += '\\d{0,' + this.maxLength + '}'; if (this.allowDecimal) { allowedRegex += '|' + this._escapeRegexChars(this.decimalSeparator); regExTxt += '(' + this._escapeRegexChars(this.decimalSeparator) + '\\d{0,' + this.decimalPrecision + '})?'; } regExTxt += '$'; this.allowedNumberFormatRe = new RegExp(regExTxt); this.allowedCharsRe = new RegExp(allowedRegex); }, init: function () { this.value = this.value || this.defaultValue; this.$super.apply(this, arguments); this._initNumberRegex(); }, onChange: function () { if (this.getRawValue() == undefined || isNaN(parseFloat(this.getRawValue()))) this.setRawValue(parseFloat('0')); else this.setRawValue(parseFloat(this.getRawValue() || '0')); var val = this.getRawValue(); this.$super.apply(this, arguments); if (val == undefined || val.length == 0 || val == 0) { this.clearInvalid(); return; } this[(this.allowedNumberFormatRe.test(val) && (+val > this.minValue && +val < this.maxValue) ? 'clear' : 'mark') + 'Invalid'](); }, initTplData: function () { this.$super.apply(this, arguments); this.value = this.parseValue(this.value || this.defaultValue).toFixed(this.decimalPrecision); this.tplData.input.value = this.value; }, setRawValue: function (val) { if (this.decimalPrecision > 0 && val != undefined && az.chk.ifNumber(val)) val = val.toFixed(this.decimalPrecision); else if (!isNaN(parseFloat(val))) { val = parseFloat(val).toFixed(this.decimalPrecision); } else { val = undefined; } this.$super.apply(this, arguments); }, getRawValue: function () { return $(this.dom.input).val(); }, parseValue: function (rawValue) { var temp = parseFloat(rawValue); return isNaN(temp) ? undefined : temp; }, getValue: function () { return this.parseValue(this.getRawValue()); } }); /*Scripts/libs/Astral/Control/Field/DisplayField.js*/ az.defineClass('DisplayField', { $extends: 'Field', renderPattern: '@wrapper({content:@label+@input})', tpls: { // todo mehedi need to adjust css for this display field input: '{value}' }, initTplData: function () { this.$super.apply(this, arguments); this.setStyle('input', 'width', this.width + 'px'); }, onResize: function () { var inputWidth = this.width; if (this.rendered) { this.setStyle('wrapper', 'width', ((this.hideLabel || this.labelPosition == 'top' ? 0 : this.labelWidth + this.labelGap) + inputWidth) + 'px'); this.setStyle('input', 'width', this.width + 'px'); } }, getRawValue: function () { return $(this.dom.input).text(); }, setRawValue: function (val) { $(this.dom.input).text(val); } }); /*Scripts/libs/Astral/Control/Field/TextArea.js*/ az.defineClass('TextArea', { $extends: 'TextField', rows: 2, height: 50, columns: 3, maxLength: 500, tpls: { input: '' }, tplData: { input: { style: '{style}' } }, initTplData: function () { this.$super.apply(this, arguments); this.addCls('wrapper', 'az-field-textarea'); if (this.height) this.setStyle('input', 'height:' + this.height + 'px;'); this.setStyle('input', 'width', (this.width - this._getInputBorderPadding() - (this.required ? this.getThemeValue('helperSize') : 0) - (this.tooltip ? this.getThemeValue('helperSize') : 0)) + 'px'); }, onResize: function () { var inputWidth = this.width; if (this.rendered) { this.setStyle('wrapper', 'width', ((this.hideLabel || this.labelPosition == 'top' ? 0 : this.labelWidth + this.labelGap) + inputWidth) + 'px'); this.setStyle('input', { width: (inputWidth - this._getInputBorderPadding() - (this.required ? this.getThemeValue('helperSize') : 0) - (this.tooltip ? this.getThemeValue('helperSize') : 0)) + 'px', height: this.height - this._getInputBorderPadding() + 'px' }); } } }); /*Scripts/libs/Astral/Control/Field/TriggerField.js*/ az.defineClass('TriggerField', { $extends: 'TextField', renderPattern: '@wrapper({content:@label+ @tooltip + @validationHelper + @inputWrapper({input:@input({triggers:@triggers})})})', //renderPattern: '@wrapper({content:@label+ @tooltip + @validationHelper + @inputWrapper({input:@input}) })', tpls: { input: '{triggers}', triggers: '
    @for(var i=0;i}
    ' }, events: { handle: { 'click:@trigger-{cid}-\\d': 'onTrigger' }, custom: ['trigger'] }, tplData: { triggers: { items: [] } }, onTrigger: function (obj, event) { var triggerIndex = event.elementId.split('-')[4]; if (!this.triggers[triggerIndex].disabled) { var handler = this.triggers[triggerIndex].handler; if (handler) { if (az.chk.ifFunction(handler)) handler(obj, event); if (az.chk.ifObject(handler) && handler.fn) { handler.fn.call(handler.scope || null, obj, event); } } this.fireEvent('trigger', event, triggerIndex); } }, _getInputBorderPadding: function () { return (this.getThemeValue('inputPadding') + this.getThemeValue('inputBorder') * 2); }, initTplData: function () { this.$super.apply(this, arguments); this.addCls('wrapper', 'az-trigger-field'); if (this.triggers && this.triggers.length > 0) { this.tplData.triggers.items = this.triggers; var me = this; var visibleCount = 0; $.each(this.tplData.triggers.items, function (index, item) { item.visible = (typeof item.visible == 'undefined') ? true : item.visible; item.triggerStyle = 'height:' + me.getThemeValue('triggerHeight') + 'px;' + (item.visible ? 'display: block;' : 'display:none;'); visibleCount += (item.visible ? 1 : 0); }); this.setStyle('input', 'width', (this.width - (this._getInputBorderPadding() + ((this.getThemeValue('triggerWidth') * visibleCount))) - (this.required ? this.getThemeValue('helperSize') : 0) - (this.tooltip ? this.getThemeValue('helperSize') : 0)) + 'px'); } }, onResize: function () { var inputWidth = this.width; if (this.rendered) { this.setStyle('wrapper', 'width', ((this.hideLabel || this.labelPosition == 'top' ? 0 : this.labelWidth + this.labelGap) + inputWidth) + 'px'); this.setStyle('input', 'width', (inputWidth - (this._getInputBorderPadding() + ((this.getThemeValue('triggerWidth') * this.getVisibleTriggerCount()))) - (this.required ? this.getThemeValue('helperSize') : 0) - (this.tooltip ? this.getThemeValue('helperSize') : 0)) + 'px'); } this._adjustLabelPositioning(); }, setTriggerVisible: function (index, visible) { this.triggers[index].visible = visible; $('#trigger-' + this.cid + '-' + index)[visible ? 'show' : 'hide'](); this.setStyle('input', 'width', (this.width - (this._getInputBorderPadding() + ((this.getThemeValue('triggerWidth') * this.getVisibleTriggerCount())))) + 'px'); }, getVisibleTriggerCount: function () { var visibleCount = 0; $.each(this.triggers, function (index, item) { visibleCount += (item.visible ? 1 : 0); }); return visibleCount; }, setTriggerDisabled: function (index, disabled) { this.triggers[index].disabled = disabled; $('#trigger-' + this.cid + '-' + index)[disabled ? 'addClass' : 'removeClass']('az-trigger-btn-disabled'); } }); /*Scripts/libs/Astral/Control/Field/DateField.js*/ az.defineClass('DateField', { $extends: 'TriggerField', format: 'dd/mm/yy', defaultValue: '', //'today' '+1y +1m +1w +5d' popupCfg: { visible: false, calendar: { $class: 'Calendar' }, border: 0, layout: 'auto' }, showCalender: function () { this.clearInvalid(); this.addCls('wrapper', this.focusCls); var inputPosition = $(this.calendarPopupTriggerId).offset(), triggerWidth = $(this.calendarPopupTriggerId).outerWidth(), triggerHeight = $(this.calendarPopupTriggerId).outerHeight(); if (!this.calendarPopup.rendered) this.calendarPopup.render(); var popup = $(this.calendarPopup.getRootEl()); this.calendarPopup.setPosition(inputPosition.left - (popup.outerWidth() - triggerWidth), inputPosition.top + triggerHeight); this.calendarPopup.show(); //$(this.calendarPopup.calendar.getRootEl()).focus(); $(this.dom.input).focus(); }, onTrigger: function () { if (!this.disabled && !this.readOnly) { if (!this.calendarPopup.visible) { this.showCalender(); } else { this.hideCalender(); } } }, xonBlur: function () { // if (this.isDirty) this.onChange(); this.$super.apply(this, arguments); var me = this; this.timeout = setTimeout(function () { var focusedElmIsItemOrTrigger = $(':focus').hasClass('az-trigger-btn') //|| $(':focus').hasClass('az-combobox-item') // || $(':focus').hasClass('az-combo-panel') || $(':focus').parents().hasClass('az-calendar'); if (!focusedElmIsItemOrTrigger && me.calendarPopup.visible) { // me.setRawValue(me.selectedIndex == -1 ? '' : me.optionsPanel.options[me.selectedIndex].name); // if (me.selectedIndex > -1) // me.optionsPanel.select(me.selectedIndex); // else { // me.optionsPanel.clearSelection(); // } me.hideCalender(); // if (me.selectedIndex == -1) me.setValue(undefined); clearTimeout(me.timeout); } }, 200); }, onDateSelect: function (control, date) { control.hide(); this.setValue(date, true); $(this.dom.input).focus(); }, validate: function () { if (this.disabledValidation) return true; if (this.required) { if (this.value) { if (this._chkMinMax(this.value)) { this.clearInvalid(); return true; } else { this.markInvalid(); return false; } } else { this.markInvalid(); return false; } } if (this._chkMinMax(this.value)) { this.clearInvalid(); return true; } else { this.markInvalid(); return false; } }, onChange: function (control, event) { this.__oldValue = this.value; if (this.getRawValue().length > 0) { var res = this._tryParse(this.getRawValue()); this.value = res.getFullYear() > 0 ? res : undefined; if (this.value) { this.setRawValue(this.formatValue(this.value)); this.calendarPopup.calendar.setDate(this.value); } else { this.setRawValue(''); this.calendarPopup.calendar._gotoToday(); } } else { this.value = undefined; this.calendarPopup.calendar._gotoToday(); } this.validate(); this.fireEvent('change', event, this.value, this.__oldValue); }, _chkMinMax: function (date) { return this._chkkMinDate(date) && this._chkkMaxDate(date); }, _chkkMinDate: function (date) { if (!this.minDate) return true; var minDate = az.date.determineDate(this.minDate, null); return minDate && minDate < date; }, _chkkMaxDate: function (date) { if (!this.maxDate) return true; var maxDate = az.date.determineDate(this.maxDate, null); return maxDate && maxDate >= date; }, _tryParse: function (stringDate) { var noSepLong = /^\d{8}$/, noSepShort = /^\d{6}$/, slash = /^\d{2}\/\d{2}\/\d{2,4}/, dot = /^\d{2}\.\d{2}\.\d{2,4}/, hyphen = /^\d{2}-\d{2}-\d{2,4}/; // todo var rawStr = $.trim(stringDate); rawStr = rawStr.split(' ').join(''); var res; try { if (noSepLong.test(rawStr) || noSepShort.test(rawStr)) { res = az.date.parseDate('ddmmyy', rawStr) } else if (slash.test(rawStr)) { res = az.date.parseDate('dd/mm/yy', rawStr) } else if (dot.test(rawStr)) { res = az.date.parseDate('dd.mm.yy', rawStr) } else if (hyphen.test(rawStr)) { res = az.date.parseDate('dd-mm-yy', rawStr) } else { res = new Date(); res.setFullYear(0); } } catch (e) { res = new Date(); res.setFullYear(0); } return res; }, hideCalender: function () { this.calendarPopup.hide(); $(this.getFocusEl()).focus(); }, formatValue: function (val) { return az.date.formatDate(this.format, val); }, parseValue: function (val) { return val ? az.date.parseDate(this.format, val) : ''; }, setValue: function (val, notify) { if (val instanceof Date) { val = (val.getFullYear() > 1) ? val : undefined; this.$super(val, notify); } else { this.$super(this.parseValue(val), notify); } this.calendarPopup.calendar.setDate(this.value); }, getValue: function () { return this.value; }, onKeyUp: function (event) { /* var me = this; if (this.validationDealyTimer) { clearTimeout(this.validationDealyTimer); } this.validationDealyTimer = setTimeout(function () { me.validate(); }, 100);*/ this.fireEvent('keyup', event); }, interceptKeyPress: function (event) { /* if (event.charCode > 0) { var val = String.fromCharCode(event.charCode); for (var i = 0; i < this.allowedChars.length; i++) { if (this.allowedChars[i] == 'numeric' && az.chk.ifNumber(+val)) return true; if (this.allowedChars[i].indexOf(val) != -1) return true; } return false; }*/ return true; }, _createRegExFromFormat: function (format) { var tockens = []; var tocken = format[0]; for (var i = 1; i < format.length; i++) { if (tocken[tocken.length - 1] == format[i]) { tocken += format[i]; } else { tockens.push(tocken); tocken = format[i]; } } var shortDateNames = az.date.dayNamesShort.join('|'), dayNames = az.date.dayNames.join('|'), shortMonthNames = az.date.monthNamesShort.join('|'), monthNames = az.date.monthNames.join('|'), space = '\\s+'; tockens.push(tocken); var regexStr = ''; var allowedChars = []; for (var i = 0; i < tockens.length; i++) { switch (tockens[i]) { case 'd': case 'dd': case 'o': case 'oo': case 'm': case 'mm': case 'y': case 'yy': regexStr += '\\d{1,2}'; if (allowedChars.indexOf('numeric') == -1) allowedChars.push('numeric'); break; case 'D': regexStr += shortDateNames; if (allowedChars.indexOf(shortDateNames) == -1) allowedChars.push(shortDateNames); break; case 'DD': regexStr += dayNames; if (allowedChars.indexOf(dayNames) == -1) allowedChars.push(dayNames); break; case 'M': regexStr += shortMonthNames; if (allowedChars.indexOf(shortMonthNames) == -1) allowedChars.push(shortMonthNames); break; case 'MM': regexStr += monthNames; if (allowedChars.indexOf(monthNames) == -1) allowedChars.push(monthNames); break; default: if (allowedChars.indexOf(tockens[i]) == -1) allowedChars.push(tockens[i]); if (tockens[i].indexOf(' ') != -1) regexStr += space else regexStr += tockens[i].replace(this.escapeRegex, "\\$&"); } } this.validationRegex = new RegExp(regexStr); this.allowedChars = allowedChars; }, initTplData: function () { this.$super.apply(this, arguments); this.calendarPopupTriggerId = '#trigger-' + this.cid + '-0'; if (this.value) { this.value = this.value instanceof Date ? this.value : this.parseValue(this.value); this.tplData.input.value = this.formatValue(this.value); } }, init: function () { this.$super.apply(this, arguments); if (!this.triggers) this.triggers = []; this.triggers.splice(0, 0, { iconCls: 'az-icon-datepicker', handler: { fn: function () { this.onTrigger(); }, scope: this } }); var me = this; /* this.popupCfg.listeners = { select: function (pop, date) { pop.hide(); me.setValue(date, true); me.clearInvalid(); } };*/ if (!this.value && this.defaultValue) { this.defaultValue = this.defaultValue.toLowerCase(); if (this.defaultValue == 'today') { this.value = new Date(); } else if (this.defaultValue.indexOf('+') > -1 || this.defaultValue.indexOf('-') > -1) { this.value = az.date.determineDate(this.defaultValue, new Date()); } else { this.value = az.date.determineDate(this.defaultValue, new Date()); } } if (this.value) this.popupCfg.calendar.date = this.value instanceof Date ? this.value : this.parseValue(this.value); this.popupCfg.calendar.minDate = this.minDate; this.popupCfg.calendar.maxDate = this.maxDate; this.popupCfg.owner = this; this.calendarPopup = new az.CalendarPopup(this.popupCfg); this.calendarPopup.addListener('select', { fn: this.onDateSelect, scope: this }) this.escapeReged = escapeRegex = /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g; this._createRegExFromFormat(this.format); }, destroy: function () { if (this.calendarPopup) this.calendarPopup.destroy(); this.$super.apply(this, arguments); } }); az.defineClass('CalendarPopup', { $extends: 'Layer', css: 'az-date-field-calendar-popup', layout: 'auto', border: 0, events: { custom: ['select'] }, show: function () { this.$super.apply(this, arguments); this.owner.disabledValidation = true; this._initFocusLostFn(); this.calendar.setDate(this.owner.getValue()); this.activate(); }, init: function () { var me = this; this.$super.apply(this, arguments); var calenderClass = this.calendar.$class; delete this.calendar.$class; this.calendar.listeners = { select: function (cal, date) { me.fireEvent('select', date); } }; this.calendar = az.create(calenderClass, this.calendar); this.items = [this.calendar]; this.calendar.preRender(); }, destroy: function () { this.$super.apply(this, arguments); $('body').off('focusin').off('mousedown'); }, hide: function () { this.$super.apply(this, arguments); this.owner.disabledValidation = false; this.owner.validate(); $('body').off('focusin').off('mousedown'); }, _initFocusLostFn: function () { var me = this; $('body').on('mousedown', function (e) { if (me.visible) me._hideIfNonRelevantEl(e.target); }); $('body').on('focusin', function (e) { if (me.visible) me._hideIfNonRelevantEl(e.target); }); }, _hideIfNonRelevantEl: function (targerEl) { var _focusinCid = this._findCIDByTargetId($(targerEl)); if (_focusinCid != this.owner.cid && this.calendar.cid != _focusinCid && this.calendar.cancelBtn.cid != _focusinCid && this.calendar.goTodayBtn.cid != _focusinCid) this.hide(); }, _findCIDByTargetId: function (target) { if (target.hasClass('az-control') || target.hasClass('az-container') || target.hasClass('az-panel') || target.hasClass('az-window')) return 'az-com-' + target.attr('id').split('az-com-')[1]; else return this._findCIDByTargetId(target.parent()); } }); /*Scripts/libs/Astral/Control/Field/Combobox.js*/ az.defineClass('Combobox', { $extends: 'TriggerField', optionRenderer: 'ComboboxOption', oldIndex: -1, selectedIndex: -1, _options: [], valueField: 'value', displayField: 'name', readOnly: true, autoComplete: true, pageSize: 15, fcount: 0, events: { custom: ['select'] }, showOptions: function () { if (this.timeout) clearTimeout(this.timeout); var inputWidth = $(this.dom.inputWrapper).outerWidth(), inputPosition = $(this.dom.inputWrapper).offset(), inputHeight = $(this.dom.inputWrapper).outerHeight(); if (this.optionsRendered) { this.optionsPanel.setPosition(inputPosition.left, inputPosition.top + inputHeight); if (!this.optionsPanel.pager.visible) this.optionsPanel.setWidth(inputWidth - 2); else this.optionsPanel.setStyle('root', { width: 'auto' }); // this.optionsPanel.setHeight((this._options.length > 10 ? 10 : this._options.length) * this.getThemeValue('optionItemHeight') +22 ); if (this._options.length > this.pageSize) this.optionsPanel.setHeight(this.pageSize * this.getThemeValue('optionItemHeight') + 30); else { this.optionsPanel.setStyle('root', { height: 'auto' }); this.optionsPanel.pager.hide(); } } if (!this.optionsPanel.rendered) { this.optionsRendered = true; this.optionsPanel.render(); //this.optionsPanel.activate(); // this.optionsPanel.focus(); // this.optionsPanel.setHeight((this._options.length > 10 ? 10 : this._options.length) * this.getThemeValue('optionItemHeight')); if (this._options.length > this.pageSize) this.optionsPanel.setHeight(this.pageSize * this.getThemeValue('optionItemHeight') + 30); else { this.optionsPanel.setStyle('root', { height: 'auto' }); this.optionsPanel.pager.hide(); } if (!this.optionsPanel.pager.visible) this.optionsPanel.setWidth(inputWidth - 2); else this.optionsPanel.setStyle('root', { width: 'auto' }); var optionsHeight = $(this.optionsPanel.getRootEl()).outerHeight(); if ((inputPosition.top + inputHeight + optionsHeight) > $(window).height()) { this.optionsPanel.setPosition(inputPosition.left, inputPosition.top - optionsHeight); } else { this.optionsPanel.setPosition(inputPosition.left, inputPosition.top + inputHeight); } // this.optionsPanel.setWidth(inputWidth); this.optionsPanel.show(); this.optionsPanel.setStyle('root', { height: 'auto' }); } else { if (this.optionsPanel.visible) { this.optionsPanel.hide(); // if (this.optionsPanel.interval) clearInterval(this.optionsPanel.interval); } else { this.optionsPanel.show(); this.optionsPanel.activate(); this.optionsPanel.setStyle('root', { height: 'auto' }); } } $(this.getFocusEl()).focus(); if (this.selectedIndex > -1) this.optionsPanel.select(this.selectedIndex); this.fcount = 0; }, hideOptions: function () { this.optionsPanel.hide(); }, initOptions: function (data, dataLength) { var items; if (az.chk.ifString(data)) { items = data.split(','); for (var i = 0; i < items.length; i++) { this._options.push({ value: items[i], name: items[i] }); } } if (az.chk.ifArray(data)) { items = data; for (var i = 0; i < items.length; i++) { if (az.chk.ifString(items[i])) this._options.push({ value: items[i], name: items[i] }); if (az.chk.ifObject(items[i])) { this._options.push({ value: items[i][this.valueField], name: items[i][this.displayField], originalData: items[i] }); } } } if (az.chk.ifObject(data)) { for (var i in data) { this._options.push({ value: i, name: data[i] }); } } if (az.chk.ifFunction(data)) { this.initOptions(data()); } for (var i = 0; i < this._options.length; i++) { if (this.value != undefined && this._options[i].value == this.value) { this.selectedIndex = i; break; } } this.fullDataLength = dataLength; if (this.optionsPanel && this.optionsPanel.rendered) this.optionsPanel.destroy(); this.optionsPanel = az.create(this.optionRenderer, this); this.optionsPanel.addListener('optionclick', this.onOptionClick, this); }, onKeyPress: function (control, event) { var e = event.browserEvent; if (e.keyCode == 27) { this.setRawValue(this.selectedIndex == -1 ? '' : this.optionsPanel.options[this.selectedIndex].name); if (this.selectedIndex > -1) this.optionsPanel.select(this.selectedIndex); else { this.optionsPanel.clearSelection(); } this.hideOptions(); } else if (e.keyCode == 13) { this.optionsPanel.select(this.optionsPanel.selectedOptionIndex, true); if (this.isDirty) this.onChange(); } else if (e.keyCode == 38) { if (this.optionsPanel.visible) { this.optionsPanel.selectPrevious(); this.setRawValue(this.optionsPanel.options[this.optionsPanel.selectedOptionIndex].name); } } else if (e.keyCode == 40) { if (!this.optionsPanel.visible) { this.showOptions(); return; } this.optionsPanel.selectNext(); this.setRawValue(this.optionsPanel.options[this.optionsPanel.selectedOptionIndex].name); } this.$super.apply(this, arguments); }, onKeyUp: function (control, event) { if (this.autoComplete) { var e = event.browserEvent; if (control.getRawValue().length > 1 && e.keyCode == 32) { this.optionsPanel.search($.trim(control.getRawValue())); if (!this.optionsPanel.visible) this.showOptions(); } /*else if (control.getRawValue().length == 0) { this.optionsPanel.renderOptions(); if (!this.optionsPanel.visible) this.showOptions(); }*/ } this.fireEvent('keyup', event); // }, hasChanged: function () { return this.oldIndex == this.selectedIndex; }, onChange: function (evt) { // this.fireEvent('change', evt, this._options[this.selectedIndex].value, (this.oldIndex > -1 ? this._options[this.oldIndex].value : undefined), this.selectedIndex, this.oldIndex, this._options[this.selectedIndex]); this.fireEvent('change', evt, this.value, this.oldValue, this.selectedIndex, this.oldIndex, this.selectedData); this.isDirty = false; }, onOptionClick: function (optionPanel, optionIndex, data) { $(this.dom.input).focus(); // if (optionIndex == this.selectedIndex) return; this.oldIndex = this.selectedIndex; this.selectedIndex = optionIndex; if (!data) return; // this.setRawValue(this._options[this.selectedIndex].name); data.name = $('
    ').html(data.name).text(); this.setRawValue(data.name); this.selectedData = data; this.oldValue = this.value; // new this.value = data.value; //new //this.fireEvent('select', this._options[this.selectedIndex].value, this.selectedIndex, this._options[this.selectedIndex]); this.fireEvent('select', data.value, this.selectedIndex, data); this.isDirty = true; this.hideOptions(); this.validate(); }, onBlur: function () { if (this.isDirty) this.onChange(); this.$super.apply(this, arguments); /* var me = this; this.timeout = setTimeout(function () { var focusedElmIsItemOrTrigger = $(':focus').hasClass('az-trigger-btn') || $(':focus').hasClass('az-combobox-item') || $(':focus').hasClass('az-combo-panel') || $(':focus').parents().hasClass('comboOption-pager'); if (!focusedElmIsItemOrTrigger && me.optionsPanel.visible) { me.setRawValue(me.selectedIndex == -1 ? '' : me.optionsPanel.options[me.selectedIndex].name); if (me.selectedIndex > -1) me.optionsPanel.select(me.selectedIndex); else { me.optionsPanel.clearSelection(); } me.hideOptions(); if (me.selectedIndex == -1) me.setValue(undefined); clearTimeout(me.timeout); } }, 200);*/ }, getValue: function () { return this.value; }, setValue: function (val) { if (val == undefined) { this.selectedIndex = -1; this.value = undefined; this.setRawValue(this.value); if (this.optionPanel) this.optionPanel.clearSelection(); return; } for (var i = 0; i < this._options.length; i++) { if (this._options[i].value == val) { this.oldIndex = this.selectedIndex; this.selectedIndex = i; this.value = this._options[this.selectedIndex].value; this.setRawValue(this._options[this.selectedIndex].name); return; } } this.setValue(undefined); }, initTplData: function () { this.$super.apply(this, arguments); this.combTriggerId = '#trigger-' + this.cid + '-0'; }, init: function () { this.$super.apply(this, arguments); if (!this.triggers) this.triggers = []; this.triggers.splice(0, 0, { iconCls: 'az-icon-combo-arrow', disabled: this.disabled, handler: { fn: this.showOptions, scope: this } }); this.initOptions(this.data); this.tplData.input.value = (this.selectedIndex > -1) ? this._options[this.selectedIndex].name : ""; }, destroy: function () { if (this.optionPanel) this.optionPanel.destroy(); this.$super.apply(this, arguments); }, setData: function (data, dataLength) { this._options = []; this.data = data; this.initOptions(this.data); }, setDisabled: function () { this.$super.apply(this, arguments); this.setTriggerDisabled(0, this.disabled); } }); az.defineClass('ComboboxOption', { $extends: 'Layer', renderPattern: '@root({content:@options + @pager})', selectedOptionIndex: -1, options: [], visible: false, border: 1, events: { handle: { 'mouseenter:@comboOption-{cid}-\\d': 'onMouseEnter', 'mouseleave:@comboOption-{cid}-\\d': 'onMouseLeave', 'click:@comboOption-{cid}-\\d': 'onMouseClick' }, custom: ['optionclick'] }, show: function () { this.$super.apply(this, arguments); this._initFocusLostFn(); this.activate(); }, hide: function () { this.$super.apply(this, arguments); $('body').off('focusin').off('mousedown'); }, destroy: function () { this.$super.apply(this, arguments); $('body').off('focusin').off('mousedown'); }, onMouseClick: function (me, event) { this.select(parseInt(event.elementId.split('-')[4]), true); }, onMouseEnter: function (event) { $('#' + event.elementId).addClass('az-combobox-item-hover'); }, onMouseLeave: function (event) { $('#' + event.elementId).removeClass('az-combobox-item-hover'); }, tplData: { root: { css: ' az-container az-combo-panel az-panel-body az-panel-body-noheader ' }, options: { // width: '{width}', content: '' }, pager: { content: '' } }, initTplData: function () { this.$super.apply(this, arguments); this.tplData.options.content = this.renderOptions(this.options); // this.tplData.options.items = this.options; this.pager.preRender(); this.tplData.pager.content = this.pager.render(); this.setStyle('root', 'overflow:auto'); }, itemTpl: az.createTpl('
    {name}
    '), tpls: { //options: '@for(var i=0;i{items[i].name}
    }', options: '
    {content}
    ', pager: '
    {content}
    ' }, init: function (combobox) { var me = this; this.border = this.getThemeValue('optionBorder'); this.combobox = combobox; this.pager = new az.Pager({ owner: this, padding: 3, pageSize: combobox.pageSize, pageIndex: 0, totalCount: combobox._options.length, displayText: '', listeners: { pagechange: function (pager, index) { me.options = me.getDataByPage(index, me.combobox.pageSize); $(me.dom.options).empty(); $(me.dom.options).append(me.renderOptions(me.options)); me.initEvents(); }, refresh: function (paged) { me.pager.gotoPage(0); me.options = me.getDataByPage(0, me.combobox.pageSize); $(me.dom.options).empty(); $(me.dom.options).append(me.renderOptions(me.options)); me.initEvents(); } } }); //this.options =combobox._options; this.options = this.getDataByPage(0, combobox.pageSize); //combobox._options.splice(0, combobox.pageSize); this.selectedOptionIndex = combobox.selectedIndex; this.$super(); this.attr = 'tabindex=' + this.cid.replace('az-com-', ''); }, search: function (key) { this.options = this.getDataByKey(key.toLowerCase()); $(this.dom.options).empty(); $(this.dom.options).append(this.renderOptions(this.options)); this.initEvents(); }, getDataByKey: function (key) { var result = []; for (var i = 0; i < this.combobox._options.length; i++) { if (this.combobox._options[i].name.toLowerCase().indexOf(key) > -1) { result.push(this.combobox._options[i]); } } return result; }, getDataByPage: function (pageIndex, pageSize) { var result = []; for (var i = 0; i < this.combobox._options.length; i++) { if (i >= pageIndex * pageSize && i < pageIndex * pageSize + pageSize) result.push(this.combobox._options[i]); } return result; }, renderOptions: function (data, selectedIndex) { var html = []; if (data) for (var i = 0; i < data.length; i++) html.push(this.itemTpl(this, { name: data[i].name, index: i.toString(), selectedCls: (selectedIndex == i ? ' az-combobox-item-selected' : '') })); return html.join(''); }, xonFocusOut: function () { this.$super.apply(this, arguments); var me = this; this.interval = setTimeout(function () { if (az.FocusManager.FocusedElementId != me.getFocusEl()); me.hide(); }, 150); }, postRender: function () { this.$super.apply(this, arguments); this.pager.postRender(); }, clearSelection: function () { if (this.selectedOptionIndex > -1) { $('#comboOption-' + this.cid + '-' + this.selectedOptionIndex).removeClass('az-combobox-item-selected'); this.selectedOptionIndex = -1; } }, preRender: function () { this.$super.apply(this, arguments); this.setStyle('root', { 'overflow': 'auto' }); }, select: function (index, notify) { if (this.selectedOptionIndex > -1) { var oldSeletionEl = az.format('#comboOption-{cid}-' + this.selectedOptionIndex, { cid: this.cid }); $(oldSeletionEl).removeClass('az-combobox-item-selected'); } this.selectedOptionIndex = index; // + this.pager.pageIndex * this.pager.pageSize; var seletionEl = az.format('#comboOption-{cid}-' + this.selectedOptionIndex, { cid: this.cid }); $(seletionEl).addClass('az-combobox-item-selected'); // $(this.getRootEl()).scrollTop($(this.getRootEl()).scrollTop() + $(seletionEl).position().top); if (notify) this.fireEvent('optionclick', index, this.options[index]); }, selectNext: function () { if (this.selectedOptionIndex == this.options.length - 1) { this.select(0); return; } this.select(this.selectedOptionIndex + 1); }, selectPrevious: function () { if (this.selectedOptionIndex == 0) { this.select(this.options.length - 1); return; } this.select(this.selectedOptionIndex - 1); }, _initFocusLostFn: function () { var me = this; $('body').on('mousedown', function (e) { if (me.visible) me._hideIfNonRelevantEl(e.target); }); $('body').on('focusin', function (e) { if (me.visible) me._hideIfNonRelevantEl(e.target); }); $('body').on('mousewheel', function () { if (me.visible) { me.hide(); $('body').off('mousewheel'); } }); }, _hideIfNonRelevantEl: function (targerEl) { var _focusinCid = this._findCIDByTargetId($(targerEl)); if (_focusinCid != this.combobox.cid && this.cid != _focusinCid && !this._isCIDOfPager(_focusinCid) ) this.hide(); }, _findCIDByTargetId: function (target) { if (target.hasClass('az-control') || target.hasClass('az-container') || target.hasClass('az-panel') || target.hasClass('az-window')) return 'az-com-' + target.attr('id').split('az-com-')[1]; else return this._findCIDByTargetId(target.parent()); }, _isCIDOfPager: function (cid) { for (var i = 0; i < this.pager.items.length; i++) if (this.pager.items[i].cid == cid) return true; return false; } }); /*Scripts/libs/Astral/Control/Grid/Table.js*/ az.defineClass('Table', { $extends: 'Control', cellspacing: 0, cellpadding: 0, columns: [], columnWidth: 100, data: [], tableTpl: az.createTpl('{trSize}{trs}
    '), thSizeTpl: az.createTpl(''), trSizeTpl: az.createTpl('{content}'), trTpl: az.createTpl('{content}'), tdTpl: az.createTpl('{content}'), cellRenderer: az.doNothingFn, rowRenderer: function (tds, rowIndex, rowData, tableData) { return tds.join(''); }, tpls: { wrapper: '{content}' }, refresh: function () { $('#table-' + this.cid).html('' + this._getTableSizeRowHtml() + this._getTableRowsHtml() + ''); }, getRowEl: function (rowIndex) { return $('#table-tr-' + this.cid + '-' + rowIndex); }, getCellEl: function (rowIndex, columnIndex) { return $('#table-td-' + this.cid + '-' + rowIndex + '-' + columnIndex); }, setRowStyle: function (rowIndex, style) { this.getRowEl(rowIndex).css(style); }, setColumnStyle: function (rowIndex, columnIndex, style) { this.getCellEl(rowIndex, columnIndex).css(style); }, addRowCls: function (rowIndex, cls) { this.getRowEl(rowIndex).addClass(cls); }, removeRowCls: function (rowIndex, cls) { this.getRowEl(rowIndex).removeClass(cls); }, addColumnCls: function (rowIndex, columnIndex, cls) { this.getCellEl(rowIndex, columnIndex).addClass(cls); }, removeColumnCls: function (rowIndex, columnIndex, cls) { this.getCellEl(rowIndex, columnIndex).removeClass(cls); }, addRowAttr: function (rowIndex, columnIndex, attr) { this.getRowEl(rowIndex).addAttr(attr); }, removeRowAttr: function (rowIndex, columnIndex, attr) { this.getRowEl(rowIndex).removeAttr(attr); }, addColumnAttr: function (rowIndex, columnIndex, attr) { this.getCellEl(rowIndex, columnIndex).addAttr(attr); }, removeColumnAttr: function (rowIndex, columnIndex, attr) { this.getCellEl(rowIndex, columnIndex).removeAttr(attr); }, setColumnWidth: function (columnIndex, width) { $('#thSize-' + this.cid + '-' + columnIndex).css('width', width + 'px'); }, getColumnWidth: function (columnIndex) { if (this.rendered) { return parseInt($('#thSize-' + this.cid + '-' + columnIndex).css('width')); } }, setCellHtml: function (rowIndex, colIndex, content) { this.getCellEl(rowIndex, colIndex).html(content); }, getCellHtml: function (rowIndex, colIndex) { return this.getCellEl(rowIndex, colIndex).html(); }, setCellValue: function (rowIndex, colIndex, value) { this.getCellEl(rowIndex, colIndex).html(this.cellRenderer(value, colIndex, this.columns[colIndex], undefined, rowIndex, undefined, this.columns, this)); }, hideRow: function (rowIndex) { this.setVisibleRow(rowIndex, false); }, showRow: function (rowIndex) { this.setVisibleRow(rowIndex, true); }, setVisibleRow: function (rowIndex, visible) { this.getRowEl(rowIndex)[visible ? 'show' : 'hide'](); }, hideColumn: function (columnIndex) { this.setVisibleColumn(columnIndex, false); }, showColumn: function (columnIndex) { this.setVisibleColumn(columnIndex, true); }, setVisibleColumn: function (columnIndex, visible) { var rowCount = $('#table-' + this.cid + ' tr').length - 1; var tdIds = []; for (var i = 0; i < rowCount; i++) tdIds.push('#table-td-' + this.cid + '-' + i + '-' + columnIndex); $(tdIds.join(',')).css('display', (visible ? '' : 'none')); }, _getCellValue: function (rowIndex, columnIndex, tableData) { return (az.instanceOf(tableData[rowIndex], 'DataRecord') ? tableData[rowIndex].get(this.columns[columnIndex].field + '') : tableData[rowIndex][columnIndex]); }, _getTableStyle: function () { if (!this.tableStyle) return ''; if (az.chk.ifString(this.tableStyle)) return this.tableStyle; if (az.chk.ifObject(this.tableStyle)) return az.util.objToStr(this.tableStyle, ';', ':'); if (az.chk.ifFunction(this.tableStyle)) { return this.tableStyle(this.data, this) || ''; } return ''; }, _getTableCss: function () { if (!this.tableCss) return ''; if (az.chk.ifString(this.tableCss)) return this.tableCss; if (az.chk.ifArray(this.tableCss)) return this.tableCss.join(' '); if (az.chk.ifFunction(this.tableCss)) { return this.tableCss(this.data, this) || ''; } return ''; }, _getTableAttr: function () { if (!this.tableAttr) return ''; if (az.chk.ifString(this.tableAttr)) return this.tableAttr; if (az.chk.ifArray(this.tableAttr)) return this.tableAttr.join(' '); if (az.chk.ifFunction(this.tableAttr)) { return this.tableAttr(this.data, this) || ''; } return ''; }, _getRowStyle: function (rowIndex, tableData) { if (!this.rowStyle) return ''; if (az.chk.ifString(this.rowStyle)) return this.rowStyle; if (az.chk.ifObject(this.rowStyle)) return az.util.objToStr(this.rowStyle, ';', ':'); if (az.chk.ifFunction(this.rowStyle)) { return this.rowStyle(rowIndex, tableData[rowIndex], tableData, this) || ''; } return ''; }, _getRowCss: function (rowIndex, tableData) { if (!this.rowCss) return ''; if (az.chk.ifString(this.rowCss)) return this.rowCss; if (az.chk.ifArray(this.rowCss)) return this.rowCss.join(' '); if (az.chk.ifFunction(this.rowCss)) { return this.rowCss(rowIndex, tableData[rowIndex], tableData, this) || ''; } return ''; }, _getRowAttr: function (rowIndex, tableData) { if (!this.rowAttr) return ''; if (az.chk.ifString(this.rowAttr)) return this.rowAttr; if (az.chk.ifArray(this.rowAttr)) return this.rowAttr.join(' '); if (az.chk.ifFunction(this.rowAttr)) { return this.rowAttr(rowIndex, tableData[rowIndex], tableData, this) || ''; } return ''; }, _getColumnStyle: function (rowIndex, columnIndex, tableData) { if (!this.columnStyle) return ''; if (az.chk.ifString(this.columnStyle)) return this.columnStyle; if (az.chk.ifObject(this.columnStyle)) return az.util.objToStr(this.columnStyle, ';', ':'); if (az.chk.ifFunction(this.columnStyle)) { return this.columnStyle(columnIndex, this._getCellValue(rowIndex, columnIndex, tableData), rowIndex, tableData[rowIndex], tableData, this) || ''; } return ''; }, _getColumnCss: function (rowIndex, columnIndex, tableData) { if (!this.columnCss) return ''; if (az.chk.ifString(this.columnCss)) return this.columnCss; if (az.chk.ifArray(this.columnCss)) return this.columnCss.join(' '); if (az.chk.ifFunction(this.columnCss)) { return this.columnCss(columnIndex, this._getCellValue(rowIndex, columnIndex, tableData), rowIndex, tableData[rowIndex], tableData, this) || ''; } return ''; }, _getColumnAttr: function (rowIndex, columnIndex, tableData) { if (!this.columnAttr) return ''; if (az.chk.ifString(this.columnAttr)) return this.columnAttr; if (az.chk.ifArray(this.columnAttr)) return this.columnAttr.join(' '); if (az.chk.ifFunction(this.columnAttr)) { return this.columnAttr(columnIndex, this._getCellValue(rowIndex, columnIndex, tableData), rowIndex, tableData[rowIndex], tableData, this) || ''; } return ''; }, _getTableSizeRowHtml: function () { var thSize = []; for (var k = 0; k < this.columns.length; k++) { thSize.push(this.thSizeTpl(this, { width: (this.columns[k].hidden ? 0 + '' : this.columns[k].width || this.columnWidth), index: '' + k })); } return this.trSizeTpl(this, { content: thSize.join('') }); }, _getTableRowsHtml: function () { var trs = []; var tableData; if (this.store) { tableData = this.store.records; } else { if (az.chk.ifArray(this.data)) tableData = this.data; if (az.chk.ifFunction(this.data)) tableData = this.data(); if (az.chk.ifObject(this.data) && this.data.fn) tableData = this.data.fn.call(this.data.scope || null); } if (!tableData) return ''; for (var i = 0; i < tableData.length; i++) { var tds = []; for (var j = 0; j < this.columns.length; j++) { tds.push(this.tdTpl(this, { rowIndex: '' + i, colIndex: '' + j, style: this._getColumnStyle(i, j, tableData), css: this._getColumnCss(i, j, tableData), attr: this._getColumnAttr(i, j, tableData), content: this.cellRenderer(this._getCellValue(i, j, tableData), j, this.columns[j], tableData[i], i, tableData, this.columns, this) })); } trs.push(this.trTpl(this, { rowIndex: '' + i, style: this._getRowStyle(i, tableData), css: this._getRowCss(i, tableData), attr: this._getRowAttr(i, tableData), content: this.rowRenderer(tds, i, tableData[i],tableData) })); } return trs.join(''); }, _getTableHtml: function () { return this.tableTpl(this, { style: this._getTableStyle(), css: this._getTableCss(), attr: this._getTableAttr(), trSize: this._getTableSizeRowHtml(), trs: this._getTableRowsHtml() }); }, initTplData: function () { this.$super.apply(this, arguments); this.tplData.wrapper.content = this._getTableHtml(); this.dom.wrapper = '#table-' + this.cid; } }); /*Scripts/libs/Astral/Control/Grid/GridEditor.js*/ az.defineClass('GridEditor', { $autoInitMixin: true, mode: 'inline', showOn: 'dblclick', $includes: 'observable', fieldColumn: {}, fieldEditors: {}, fieldListeners: {}, addFieldListeners: function (fieldName, event, _fn, _scope) { if (!az.chk.ifDefined(this.fieldListeners[fieldName])) this.fieldListeners[fieldName] = {}; if (!az.chk.ifDefined(this.fieldListeners[fieldName][event])) this.fieldListeners[fieldName][event] = []; this.fieldListeners[fieldName][event].push({ fn: _fn, scope: _scope }); }, setupFieldListeners: function (fieldName) { for (var event in this.fieldListeners[fieldName]) { for (var i = 0; i < this.fieldListeners[fieldName][event].length; i++) { var handler = this.fieldListeners[fieldName][event][i]; this.fieldEditors[fieldName].addListener(event, handler.fn, handler.scope); } } }, createOnce: true, init: function (grid) { var me = this; this.grid = grid; az.copy(this, grid.editing); for (var i = 0; i < this.grid.columns.length; i++) { if (this.grid.columns[i].field != undefined) { this.fieldColumn[this.grid.columns[i].field + ''] = this.grid.columns[i]; } } // var listenerName = this.showOn.indexOf('click') > -1 ? this.grid.selectBy + this.showOn : this.showOn; var listenerName = this.showOn; //this.showOn.indexOf('click') > -1 ? this.grid.selectBy + this.showOn : this.showOn; this.grid.addListener(listenerName, function (grd, rowIndex, colIndex) { if (me.editorCt && me.editorCt.visible) { if (me.record && me.record.isDirty) me.save(); else { me.cancel(); } } if (az.chk.ifArray(rowIndex)) me.edit(rowIndex[0], colIndex); else me.edit(rowIndex, colIndex); }); }, _destroyFields: function () { for (var field in this.fieldEditors) { this.fieldEditors[field].destroy(); } this.fieldEditors = {}; this.fieldInstances = []; }, validate: function () { return true; }, _initFields: function () { var me = this; if (!az.chk.ifDefined(this.fields)) return; for (var field in this.fields) { var fieldEditor; if (!az.chk.ifDefined(this.fieldColumn[field])) throw field + " field not defined in grid"; if (az.chk.ifString(this.fields[field]) && az.existsClass(this.fields[field]) && az.isSubclassOf(this.fields[field], 'Field')) { this.fieldEditors[field] = az.create(this.fields[field], { hideLabel: true, width: this.fieldColumn[field].width }); } if (az.chk.ifObject(this.fields[field])) { if (az.chk.ifDefined(this.fields[field].$class)) { var config = {}; az.copy(config, this.fields[field]); // config.hideLabel = true; config.width = this.fieldColumn[field].width; fieldEditor = az.create(this.fields[field].$class, config); } else { fieldEditor = this.fields[field].create(this, this.fieldColumn[field], this.grid); } } if (!fieldEditor) continue; this.fieldEditors[field] = fieldEditor; this.fieldEditors[field].field = field; this.fieldEditors[field].hideLabel = true; this.fieldEditors[field].addListener('change', function (control, evt, val) { if (me.record) { if (me.fields[control.field].get) { me.record.set(control.field, me.fields[control.field].get(control, val)); } else { me.record.set(control.field, val); } } me.fire('change', me, control.field, me.record.get(control.field)); }); this.fieldEditors[field].addListener('keydown', function (control, event) { var old = me.record.get(control.field); if (event.keyCode == 13) {//enter // if (old != control.getValue()) { if (me.record) me.record.set(control.field, control.getValue()); me.fire('change', me, control.field, control.getValue()); me.save(); // } else { // me.cancel(); // } me.grid.focus(); } if (event.keyCode == 27) {//escape if (old != control.getValue()) { control.setValue(old); } me.cancel(); me.grid.focus(); } if (event.keyCode == 9) {//tab if (me.editStyle == 'row') { if (me.getLastField().field == control.field) { // if last item // if (old != control.getValue()) { if (me.record) me.record.set(control.field, control.getValue()); me.fire('change', me, control.field, control.getValue()); me.save(); // } else { // me.cancel(); // } me.grid.focus(); me.grid.selectNextRow(); me.edit(me.grid.selectedRowIndex); } else { $(me.grid.getRootEl()).scrollLeft(0); var nextField = me.nextField(control.field); var nextEl = $(nextField.getRootEl()); me.grid.bottomScrollBar.setScrollOffset(nextEl.position().left - me.grid.width + nextEl.outerWidth() + 18); } } else {//cell var nextCell = me.nextEditableCell(); var cellEl = me.grid.body.getCellEl(nextCell.row, nextCell.col); var cellPostion = cellEl.position(); if (me.getLastField().field == control.field) { // if last item me.grid.selectCell(nextCell.row, nextCell.col); me.edit(me.grid.selectedRowIndex, me.grid.selectedColumnIndex); if (cellPostion.left < 0) { me.grid.bottomScrollBar.setScrollOffset(0); } } else { if (me.record && me.record.isDirty) me.save(); else { me.cancel(); } me.grid.selectCell(nextCell.row, nextCell.col); me.edit(me.grid.selectedRowIndex, me.grid.selectedColumnIndex); } } } }); this.setupFieldListeners(field); } }, _createInlineEditor: function () { var me = this; this._initFields(); var xPos = 0; for (var i = 0; i < this.grid.columns.length; i++) { if (this.grid.columns[i].field && this.fieldEditors.hasOwnProperty(this.grid.columns[i].field)) { this.fieldEditors[this.grid.columns[i].field].setPosition(xPos, 0); } xPos += this.grid.columns[i].width || 100; } var items = []; for (var i in this.fieldEditors) { items.push(this.fieldEditors[i]); } this.editorCt = new az.Container({ owner: this.grid, padding: 0, border: 0, //height: 22, width: xPos, layout: 'absolute', style: 'z-index:9; overflow:hidden;', items: items, visible: false, attr: 'tabindex=100' }); this.editorCt.addCls('root', 'az-datagrid-editor-panel'); this.editorCt.preRender(); $(this.grid.getRootEl()).append(this.editorCt.render()); this.editorCt.postRender(); this.editorCt.setStyle('root', 'position', 'absolute'); this.grid.addListener('columnresize', this.setFieldPositions, this); this.grid.leftScrollBar.addListener('scroll', function (scroller, offset) { me.setEditorSizePosition(); }); this.grid.bottomScrollBar.addListener('scroll', function (scroller, offset) { if (offset == 0) me.editorCt.setStyle('root', 'left:0px'); me.setEditorSizePosition(); }); }, _createSlideEditor: function () { }, _createPopupEditor: function () { }, _createEditor: function () { switch (this.mode) { case 'inline': this._createInlineEditor(); break; case 'slide': this._createSlideEditor(); break; case 'popup': this._createPopupEditor(); break; } }, setEditorSizePosition: function () { if (this.editStyle == 'cell') { var cellEl = this.grid.body.getCellEl(this.rowIndex, this.colIndex); var cellPostion = cellEl.position(); this.editorCt.setWidth(cellEl.width()); this.editorCt.setPosition(cellPostion.left, cellPostion.top); } else { var rowEl = this.grid.body.getRowEl(this.rowIndex); var rowPostion = rowEl.position(); this.editorCt.setPosition(rowPostion.left, rowPostion.top); this.editorCt.setWidth(rowEl.width()); } }, setFieldPositions: function () { var xPos = 0; for (var i = 0; i < this.grid.columns.length; i++) { if (this.grid.columns[i].field && this.fieldEditors.hasOwnProperty(this.grid.columns[i].field)) { this.fieldEditors[this.grid.columns[i].field].setLeft(xPos); this.fieldEditors[this.grid.columns[i].field].setStyle('wrapper', { top: 'auto' }) this.fieldEditors[this.grid.columns[i].field].setWidth(this.grid.columns[i].width); } xPos += this.grid.columns[i].width + 0; } }, setFieldValue: function (field, value) { if (!this.fieldEditors[field]) return; if (this.fields[field].set) { this.fields[field].set(this.fieldEditors[field], value); } else { this.fieldEditors[field].setValue(value, true); } }, getFieldEditor: function (field) { if (this.fields[field].get) { return this.fields[field].get(this.fieldEditors[field]); } else { return this.fieldEditors[field]; } }, getFieldValue: function (field) { if (this.fields[field].get) { return this.fields[field].get(this.fieldEditors[field]); } else { return this.fieldEditors[field].getValue(); } }, getFirstField: function () { var field = null; for (var i = 0; i < this.grid.columns.length; i++) { var f = this.grid.columns[i].field; if (f && this.fields[f.toString()]) { for (var _field in this.fields) { if (this.fieldEditors[_field].field.toString() == f.toString()) { field = this.fieldEditors[_field]; break; } } break; } } return field; }, getLastField: function () { var field = null; var cols = this.grid.columns.length; while (--cols) { var f = this.grid.columns[cols].field; if (f && this.fields[f.toString()]) { for (var _field in this.fields) { if (this.fieldEditors[_field].field.toString() == f.toString()) { field = this.fieldEditors[_field]; break; } } break; } } return field; }, hasFieldInColumn: function (colIndex) { var column = this.grid.columns[colIndex]; if (column.field && this.fields[column.field.toString()]) { return true; } return false; }, nextEditableCell: function () { var cell = {}; var isLast = this.getLastField().field.toString() == this.grid.columns[this.grid.selectedColumnIndex].field.toString(); cell.row = isLast ? this.grid.selectedRowIndex + 1 : this.grid.selectedRowIndex; var colStart = isLast ? 0 : this.grid.selectedColumnIndex + 1; for (var i = colStart; i < this.grid.columns.length; i++) { if (this.hasFieldInColumn(i)) { cell.col = i; break; } } return cell; }, nextField: function (current) { var field = null; for (var i = 0; i < this.grid.columns.length; i++) { var currentFound; if (!currentFound && this.hasFieldInColumn(i) && this.grid.columns[i].field == current) { currentFound = true; continue; } if (currentFound && this.hasFieldInColumn(i)) { field = this.fieldEditors[this.grid.columns[i].field]; break; } } return field; }, isVisible: function () { if (this.editorCt) return this.editorCt.visible; return false; }, isDirty: function () { return (this.record && this.record.isDirty); }, edit: function (rowIndex, colIndex) { if (az.chk.ifEmptyObj(this.fields)) { if (this.editorCt) this.editorCt.hide(); return false; } if (this.editStyle == 'cell' && !this.hasFieldInColumn(colIndex)) return false; this.rowIndex = rowIndex; this.colIndex = colIndex; if (!this.createOnce && this.editorCt) { this._destroyFields(); this.editorCt.destroy(); this.editorCt = undefined; } if (!this.editorCt) { this._createEditor(); this.setFieldPositions(); } this.record = this.grid.store.getAt(rowIndex); var activeField; var fieldIndex = 1, count = 0; for (var field in this.fields) { if (count == 0) activeField = field; this.setFieldValue(field, this.record.get(field)); if (this.editStyle == 'cell' && this.hasFieldInColumn(colIndex) && fieldIndex != this.grid.columns[colIndex].field) { this.fieldEditors[field].setStyle('wrapper', 'left:-1000px'); } else if (this.editStyle == 'cell') { this.fieldEditors[field].setStyle('wrapper', 'left:0'); activeField = field; } fieldIndex++; count++; } this.setEditorSizePosition(); if (this.beforeedit) { this.beforeedit(this, this.record); } this.editorCt.show(true); if (activeField) { $(this.fieldEditors[activeField].getFocusEl()).focus(); $(this.fieldEditors[activeField].getFocusEl()).select(); } this.fire('edit'); }, save: function () { if (this.validate() === false) return; /*if (this.beforeedit) { this.beforeedit(this.record, this); }*/ this.record.commit(); if (this.afteredit) this.afteredit(this.record); this.editorCt.hide(); this.fire('save'); }, cancel: function () { if (this.record && this.record.isDirty) this.record.rollback(); if (this.editorCt) this.editorCt.hide(); this.fire('cancel'); }, destroy: function () { this._destroyFields(); } }); /*Scripts/libs/Astral/Control/Grid/Scroller.js*/ az.defineClass('Scroller', { $extends: 'Control', vertical: true, scrollSize: 0, rootElement:'wrapper', renderPattern: '@wrapper({content:@streacher})', events: { handle: { 'scroll:{$class}-{cid}': 'onScroll', }, custom: ['scroll'] }, initTplData: function () { if (this.vertical) delete this.width; else delete this.height; this.$super.apply(this, arguments); }, onScroll: function () { this.fireEvent('scroll', this.getScrollOffset()); }, tpls: { streacher: '
    ' }, _updateScroller: function () { if (this.vertical) { this.setStyle('streacher', { 'height': this.scrollSize, width: 1 }); this.setStyle('wrapper', { height: this.size, width: az.dom.SCROLLBAR.WIDTH, overflow: 'auto', padding: 0, margin: 0 }); } else { this.setStyle('streacher', { width: this.scrollSize, height: 1 }); this.setStyle('wrapper', { width: this.size, height: az.dom.SCROLLBAR.HEIGHT, overflow: 'auto', padding: 0, margin: 0 }); } this.setStyle('wrapper', this.style); this[(this.size>this.scrollSize? 'hide':'show')](); }, getScrollOffset: function () { if (this.vertical) return $(this.dom.wrapper).scrollTop(); else return $(this.dom.wrapper).scrollLeft(); }, setScrollOffset: function (offset) { if (this.vertical) return $(this.dom.wrapper).scrollTop(offset); else return $(this.dom.wrapper).scrollLeft(offset); }, setScrollSize: function (size) { this.scrollSize = size; this._updateScroller(); }, setSize: function (size) { this.size = size; this._updateScroller(); }, postRender: function () { this.$super.apply(this, arguments); this._updateScroller(); }, getMaxOffset: function(){ if (this.vertical) return $(this.dom.streacher).height() - $(this.dom.wrapper).height(); else return $(this.dom.streacher).width() - $(this.dom.wrapper).width(); } }); /*Scripts/libs/Astral/Control/Grid/Header.js*/ az.defineClass('Header', { $extends: 'Table', resizeHandleWidth: 3, minColumnWidth: 50, renderPattern: '@wrapper({content:@inner})', events: { handle: { 'mouseenter:@headerResizeHandle-{cid}-\\d': 'showResizer', 'change:headerCheck-{cid}': 'headerCheck' }, custom: ['headerresize', 'headerchecked'] }, tpls: { wrapper: '
    {content}
    ', inner: '{content}' }, tableCss: 'az-datagrid-htable', rowCss: 'az-datagrid-header-row', headerItemTpl: az.createTpl('
    \ {iconHtml}{checkbox}\ {header}\  \
    \ @if(ctx.resizable){
    }\ '), checkboxTpl: az.createTpl(''), cellRenderer: function (value, columnIndex, columnDef, rowData, rowIndex, allData, allColumns, owner) { var _iconHtml = columnDef.iconCls ? ' ' : ''; var _checkbox = (this.checkboxSelection && columnIndex==0) ? this.checkboxTpl(this, { value: '' }) : ''; return this.headerItemTpl(this, { header: value, iconHtml: _iconHtml,checkbox: _checkbox, resizable: columnDef.resizable, index: columnIndex + '' }); }, headerCheck: function() { var val = this.getCheckbox().prop("checked"); this.fireEvent('headerchecked', val); }, getCheckbox: function() { return $('#headerCheck-' + this.cid); }, showResizer: function (event) { if (this.resizer) { var position = $('#' + event.elementId).offset(); this.resizer.show(event.elementId, (position.left + this.resizeHandleWidth / 2 - this.getThemeValue('colResizeMarkerOffsetLeft')), position.top); } }, onHeaderResize: function (columnIndex, offset, dir) { var currentWidth = this.columns[columnIndex].width; currentWidth += offset; if (this.minColumnWidth > currentWidth || (this.columns[columnIndex].minWidth && this.columns[columnIndex] > currentWidth)) { currentWidth = this.columns[columnIndex].minWidth || this.minColumnWidth; }; this.columns[columnIndex].width = currentWidth; this.setColumnWidth(columnIndex, this.columns[columnIndex].width); this.fireEvent('headerresize', columnIndex, this.columns[columnIndex].width); }, tplData: { inner: {} }, initTplData: function () { this.$super.apply(this, arguments); this.tplData.inner.content = this._getTableHtml(); }, init: function () { this.$super.apply(this, arguments); var me = this; this.data = [[]]; var hasResizable = false; for (var i = 0; i < this.columns.length; i++) { if (!hasResizable) hasResizable = this.columns[i].resizable; this.data[0].push(this.columns[i].header || ''); } if (hasResizable) { az.copy(this.resizerConfig || {}, { width: 5, axis: 'x', listeners: { resize: function (resizer, element, offset, dir) { me.onHeaderResize(+element.split('-')[4], offset, dir); } } }); this.resizer = new az.Resizer(this.resizerConfig); } } }); /*Scripts/libs/Astral/Control/Grid/Grid.js*/ az.defineClass('Grid', { $extends: 'Control', $includes: 'maskable', controls: [], columns: [], border: 1, store: {}, scrollOffsetTop: 0, scrollOffsetLeft: 0, autoLoad: true, selectable: false, multiSelect: false, //todo impliment multi selection selectBy: 'row', selectedCells: [], selectedRows: [], selectedRowIndex: -1, selectedColumnIndex: -1, maskOnDisable: true, maskCls: 'az-datagrid-mask', maskMsg: 'Please wait. Loading...', maskMsgIconCls: 'az-icon-loading', rowCss: 'az-datagrid-row', columnCss: '', cellHeight:14, draggable: true, pagerCfg: { displayText: 'Displaying {displayFrom}-{displayTo} of {totalCount}' }, tpls: { wrapper: '<{wrapTag} id="{$class}-{cid}" @if(ctx.title){title="{title}"} class="az-control az-datagrid az-border {css}" style="{style}" {attr}>{content}{pager}' }, tplData: { wrapper: { content: '', pager: '' } }, cellTpl: az.createTpl('
    {content}
    '), checkboxTpl: az.createTpl(''), bodyWrapper: az.createTpl('
    {content}
    '), css: 'az-datagrid-wrap az-panel-body', events: { handle: { 'mouseenter:@table-td-{body.cid}-\\d+-\\d+': 'onMouseEnter', 'mouseleave:@table-td-{body.cid}-\\d+-\\d+': 'onMouseLeave', 'click:@table-td-{body.cid}-\\d+-\\d+': 'onClick', 'dblclick:@table-td-{body.cid}-\\d+-\\d+': 'onDblClick', 'mouseenter:@table-td-{header.cid}-\\d+-\\d+': 'onHeaderMouseEnter', 'mouseleave:@table-td-{header.cid}-\\d+-\\d+': 'onHeaderMouseLeave', 'click:@table-td-{header.cid}-\\d+-\\d+': 'onHeaderClick', 'dblclick:@table-td-{header.cid}-\\d+-\\d+': 'onHeaderDblClick', 'mousewheel:Grid-{cid}': 'onMouseWheel', 'keydown:{$class}-{cid}': 'onKeyDown', 'change:@cellCheck-{body.cid}-\\d': 'onCellCheck' }, custom: ['select', 'rowclick', 'rowdblclick', 'cellclick', 'celldblclick', 'columnresize', 'headerclick', 'headerdblclick', 'beforeload', 'load', 'add', 'remove', 'update'] }, _getCheckboxEl: function (rowIndex) { return $('#cellCheck-' + this.body.cid + '-' + rowIndex); }, _getRowColumnIndexFromEl: function (elementId) { var parts = elementId.split('-'); return [+parts[5], +parts[6]]; }, _formatValue: function (format, value, columnIndex, columnDef, rowData, rowIndex, allData, allColumns, owner) { if (value === undefined) return ''; if (format) { if (az.chk.ifString(format)) return az.formatter.format(format, value); if (az.chk.ifFunction(format)) return format(value, columnIndex, columnDef, rowData, rowIndex, allData, allColumns, owner) + ''; } return value; }, selectRow: function (selectedRowIndex, notify) { this._selectRow(selectedRowIndex, false, false, notify); }, _clearAllRowSelect: function () { var rows = this.store.records.length; for (var i = 0; i < rows; i++) { this._clearRowSelect(i); if (this.selectBy == 'check') this._getCheckboxEl(i).prop("checked", false); } }, _clearRowSelect: function (rowIndex) { this.body.removeRowCls(rowIndex, 'az-datagrid-row-selected'); this.body.removeRowCls(rowIndex, 'az-unselectable'); }, _clearAllCellSelect: function () { var rows = this.store.records.length; for (var i = 0; i < rows; i++) { for (var j = 0; j < this.columns.length; j++) { this.body.removeColumnCls(i, j, 'az-datagrid-cell-selected'); this.body.removeColumnCls(i, j, 'az-unselectable'); } } }, _selectRow: function (selectedRowIndex, ctrlKey, shiftKey, notify) { if (ctrlKey) { var exsitingIndex = this.selectedRows.indexOf(selectedRowIndex); if (exsitingIndex == -1) { this.selectedRows.push(selectedRowIndex); } else { this.selectedRows.splice(exsitingIndex, 1); } } else { this.selectedRows = [selectedRowIndex]; } this._clearAllRowSelect(); this.selectedRowIndex = selectedRowIndex; this.selectedColumnIndex = -1; for (var i = 0; i < this.selectedRows.length; i++) { this.body.addRowCls(this.selectedRows[i], 'az-datagrid-row-selected' + (this.doubleClicked ? '' : ' az-unselectable')); } for (var i = 0; i < this.selectedRows.length; i++) { this._getCheckboxEl(this.selectedRows[i]).prop("checked", true); } this.header.getCheckbox().prop('checked', this.selectedRows.length == this.store.records.length); if (notify) this.fireEvent('select', this.selectedRows); }, selectCell: function (selectedRowIndex, selectedColumnIndex, notify) { this._selectCell(selectedRowIndex, selectedColumnIndex, false, false, notify); }, _selectCell: function (selectedRowIndex, selectedColumnIndex, ctrlKey, shiftKey, notify) { var grid = this; var curentSelectedRowIndex = this.selectedRowIndex; if (ctrlKey) { if (curentSelectedRowIndex != selectedRowIndex) { this.selectedCells = []; } var exsitingIndex = this.selectedCells.indexOf(selectedColumnIndex); if (exsitingIndex == -1) { this.selectedCells.push(selectedColumnIndex); } else { this.selectedCells.splice(exsitingIndex, 1); } } else { this.selectedCells = [selectedColumnIndex]; } this._clearAllCellSelect(); this.selectedRowIndex = selectedRowIndex; this.selectedColumnIndex = selectedColumnIndex; for (var i = 0; i < this.selectedCells.length; i++) { this.body.addColumnCls(this.selectedRowIndex, this.selectedCells[i], 'az-datagrid-cell-selected' + (this.doubleClicked ? '' : ' az-unselectable')); } if (notify) this.fireEvent('select', this.selectedRowIndex, this.selectedCells); }, onClick: function (grid, event) { var rowCol = this._getRowColumnIndexFromEl(event.elementId); if (this.selectBy == 'check' && rowCol[1] == 0) { var chkEl = $('#cellCheck-' + this.body.cid + '-' + rowCol[0]); var tobeChked = !chkEl.is(':checked'); chkEl.prop('checked', tobeChked); chkEl.change(); return; } var me = this; if (this.clicked) return; me.clicked = true; setTimeout(function () { if (me.doubleClicked) { delete me.doubleClicked; delete me.clicked; return; } var rowCol = me._getRowColumnIndexFromEl(event.elementId); if (me.selectBy == 'cell') { me.fireEvent('cellclick', rowCol[0], rowCol[1]); if (me.selectable) { me._selectCell(rowCol[0], rowCol[1], event.browserEvent.ctrlKey, event.browserEvent.shiftKey, true); } } else { me.fireEvent('rowclick', rowCol[0]); if (me.selectable) { me._selectRow(rowCol[0], event.browserEvent.ctrlKey, event.browserEvent.shiftKey, true); } } // if (me.selectBy == 'check') { // /*if (rowCol[1] == 0) { // me.fireEvent('cellclick', rowCol[0], rowCol[1]); // if (me.selectable) { // me._selectRow(rowCol[0], event.browserEvent.ctrlKey, event.browserEvent.shiftKey, true); // } // }*/ // } else if (me.selectBy == 'cell') { // // } delete me.clicked; }, 100); }, onDblClick: function (grid, event) { var rowCol = this._getRowColumnIndexFromEl(event.elementId); if (this.selectBy == 'check' && rowCol[1] == 0) return; this.doubleClicked = true; var rowCol = this._getRowColumnIndexFromEl(event.elementId); if (this.selectBy === 'cell') { this.fireEvent('celldblclick', rowCol[0], rowCol[1]); if (this.selectable) { this.selectCell(rowCol[0], rowCol[1], false, false, false); } } else { this.fireEvent('rowdblclick', rowCol[0]); if (this.selectable) { this.selectRow(rowCol[0], false, false, false); } } }, onHeaderClick: function (grid, event) { var rowCol = this._getRowColumnIndexFromEl(event.elementId); if (this.selectBy == 'check' && rowCol[1] == 0) { var chkEl = $('#headerCheck-' + this.header.cid); var tobeChked = !chkEl.is(':checked'); chkEl.prop('checked', tobeChked); chkEl.change(); return; } var columnIndex = rowCol[1]; var me = this; if (this.clicked) return; me.clicked = true; var timer = setTimeout(function () { if (me.doubleClicked) { delete me.doubleClicked; delete me.clicked; return; } delete me.clicked; if (me.columns[columnIndex].sortable) { me.sort(columnIndex, (!me.sortDir ? 'asc' : (me.sortDir == 'asc' ? 'desc' : 'asc'))); } me.fireEvent('headerclick', columnIndex); }, 100); }, onHeaderDblClick: function (grid, event) { this.doubleClicked = true; var rowCol = this._getRowColumnIndexFromEl(event.elementId); this.fireEvent('headerdblclick', rowCol[1]); }, onHeaderMouseEnter: function (event) { var rowCol = this._getRowColumnIndexFromEl(event.elementId); this.header.addColumnCls(rowCol[0], rowCol[1], 'az-datagrid-header-over'); }, onHeaderMouseLeave: function (event) { var rowCol = this._getRowColumnIndexFromEl(event.elementId); this.header.removeColumnCls(rowCol[0], rowCol[1], 'az-datagrid-header-over'); }, onMouseEnter: function (event) { var rowCol = this._getRowColumnIndexFromEl(event.elementId); this.body.addRowCls(rowCol[0], 'az-datagrid-row-over'); }, onMouseLeave: function (event) { var rowCol = this._getRowColumnIndexFromEl(event.elementId); this.body.removeRowCls(rowCol[0], 'az-datagrid-row-over'); }, onCellCheck: function (body, event) { var checked = $('#' + event.elementId).prop('checked'); var rowIndex = event.elementId.split('-')[4]; if (checked) { // this.selectRow(rowIndex, true); if (this.selectedRows.indexOf(parseInt(rowIndex)) == -1) { this.body.addRowCls(rowIndex, 'az-datagrid-row-selected az-unselectable'); if (this.selectedRows.indexOf(parseInt(rowIndex)) == -1) this.selectedRows.push(parseInt(rowIndex)); this.fireEvent('select', this.selectedRows); var recs = this.store.records; var allChecked = true; for (var i = 0; i < recs.length; i++) { if (!this._getCheckboxEl(i).prop('checked')) { allChecked = false; break; } } if (allChecked) this.header.getCheckbox().prop('checked', true); } } else { this.selectedRows.splice(this.selectedRows.indexOf(parseInt(rowIndex)), 1); this.fireEvent('select', this.selectedRows); this._clearRowSelect(rowIndex); this.header.getCheckbox().prop('checked', false); } }, onKeyDown: function (control, event) { switch (event.keyCode) { case 9: //tab if (this.editor && this.editor.editorCt && this.editor.editorCt.visible) { // this.editor.editorCt.focus(); this.editor.getFirstField().focus(); console.log(this.editor.getFirstField()); } else { this.focus(); if (this.selectBy == "row") this.selectNextRow(); else { this.selectNextCell(); } } break; case 40: //down { if (this.selectBy == "row") this.selectNextRow(); else { this.selectNextCell(true); } if (this.editor && this.editor.editorCt && this.editor.editorCt.visible) { this.editor.cancel(); this.editor.edit(this.selectedRowIndex); } } break; case 39: //right { if (this.editor && this.editor.editorCt && this.editor.editorCt.visible) { this.editor.getFirstField().focus(); } else { if (this.selectBy == "row") this.selectNextRow(); else { this.selectNextCell(); } } } break; case 38: //up { if (this.selectBy == "row") this.selectPrevRow(); else { this.selectPrevCell(true); } if (this.editor && this.editor.editorCt && this.editor.editorCt.visible) { this.editor.cancel(); this.editor.edit(this.selectedRowIndex); } } break; case 37: //left { if (this.editor && this.editor.editorCt && this.editor.editorCt.visible) { this.editor.getFirstField().focus(); } else { if (this.selectBy == "row") this.selectPrevRow(); else { this.selectPrevCell(); } } } break; case 13: //enter if (this.editor) { if (this.editor.editorCt && this.editor.editorCt.visible) { this.editor.cancel(); this.focus(); } else { if (this.editor.editStyle == 'cell') { this.editor.edit(this.selectedRowIndex, this.selectedColumnIndex); } else { this.editor.edit(this.selectedRowIndex); } } } break; case 27: //esc if (this.editor) { this.editor.cancel(); this.focus(); } break; default: break; } }, selectNextRow: function () { if (this.selectedRowIndex < (this.store.records.length - 1)) this.selectRow(this.selectedRowIndex + 1, true); }, selectPrevRow: function () { if (this.selectedRowIndex > 0) this.selectRow(this.selectedRowIndex - 1, true); }, selectNextCell: function (byColumn) { var rIdx = byColumn ? (this.selectedRowIndex == -1 ? 0 : this.selectedRowIndex + 1) : (this.selectedRowIndex == -1 ? 0 : (this.selectedColumnIndex == (this.columns.length - 1) ? this.selectedRowIndex + 1 : this.selectedRowIndex)); var cIdx = byColumn ? (this.selectedColumnIndex == -1 ? 0 : this.selectedColumnIndex) : (this.selectedColumnIndex == -1 ? 0 : (this.selectedColumnIndex == (this.columns.length - 1) ? 0 : this.selectedColumnIndex + 1)); if (rIdx < (this.store.records.length) && cIdx < (this.columns.length)) this.selectCell(rIdx, cIdx); }, selectPrevCell: function (byColumn) { var rIdx = byColumn ? (this.selectedRowIndex == -1 ? 0 : this.selectedRowIndex - 1) : (this.selectedRowIndex == -1 ? 0 : (this.selectedColumnIndex == 0 ? this.selectedRowIndex - 1 : this.selectedRowIndex)); var cIdx = byColumn ? (this.selectedColumnIndex == -1 ? 0 : this.selectedColumnIndex) : (this.selectedColumnIndex == -1 ? 0 : (this.selectedColumnIndex == 0 ? this.columns.length - 1 : this.selectedColumnIndex - 1)); if (rIdx > -1) this.selectCell(rIdx, cIdx); }, _destroyControls: function () { for (var i = 0; i < this.controls.length; i++) { this.controls[i].destroy(); } this.controls = []; }, refresh: function () { var me = this; if (this.editor) this.editor.cancel(); if (this.pager) this.pager.setOptions({ pageSize: this.store.pageSize, totalCount: this.store.totalCount }); if (this.header) { this.header.refresh(); }; if (this.body) { this._refreshGridBody(); this.initEvents(); this.header.initEvents(); $(this.body.dom.wrapper).css({ 'margin-top': 0, 'margin-left': 0 }); return; } if (this.columns.length == 0) return; if (this.selectBy == 'check') { this.columns.splice(0, 0, { align: 'center', width: 40 }); } this.header = new az.Header({ resizerConfig: { proxy: { fn: function () { return '
     
    '; }, scope: this }, containment: az.format('#{$class}-{cid}', this) }, owner: this, visible: this.headerVisible, checkboxSelection: this.selectBy == 'check', columns: this.columns, columnStyle: function (columnIndex) { if (me.columns[columnIndex].hidden) return 'display:none'; }, columnAttr: function (columnIndex) { if (me.columns[columnIndex].headerAlign) return ' align="' + me.columns[columnIndex].headerAlign + '" '; if (me.columns[columnIndex].align) return ' align="' + me.columns[columnIndex].align + '" '; }, listeners: { headerresize: function (header, columnIndex, width) { me.body.setColumnWidth(columnIndex, width); me._resizeColumnCells(columnIndex); me.resetColumnWidth(columnIndex, true); //me._updateScroller(); me.fireEvent('columnresize', columnIndex, width); }, show: function () { me.body.setTop(25); }, hide: function () { me.body.setTop(0); }, headerchecked: function (header, checked) { me.selectedRowIndex = -1; me.selectedColumnIndex = -1; me._clearAllRowSelect(); me.selectedRows = []; if (checked) { for (var i = 0; i < me.store.records.length; i++) { me.selectedRows.push(i); me.body.addRowCls(i, 'az-datagrid-row-selected az-unselectable'); me._getCheckboxEl(i).prop("checked", true); } me.fireEvent('select', me.selectedRows); } else { me.selectedRows = []; me.fireEvent('select', me.selectedRows); } } } }); this.body = new az.Table({ owner: this, columns: this.columns, store: this.store, rowCss: this.rowCss, //,'az-datagrid-row', columnStyle: function (columnIndex) { if (me.columns[columnIndex].hidden) return 'display:none'; }, columnAttr: function (columnIndex) { if (me.columns[columnIndex].align) return ' align="' + me.columns[columnIndex].align + '" '; }, columnCss: this.columnCss || function (columnIndex) { if (az.chk.ifString(me.columns[columnIndex].css)) return me.columns[columnIndex].css; if (az.chk.ifFunction(me.columns[columnIndex].css)) return me.columns[columnIndex].css.apply(null, arguments); return ''; }, cellRenderer: function (value, columnIndex, columnDef, rowData, rowIndex, allData, allColumns, owner) { if (me.selectBy == 'check' && columnIndex == 0) { return me.cellTpl(this, { content: me.checkboxTpl(this, { value: false, index: rowIndex || '0' }) }); } if (columnDef.controls) { var buffer = []; for (var i = 0; i < columnDef.controls.length; i++) { if (columnDef.controls[i] instanceof az.UIComponent) { throw "Only Control definition allowed not an instnace"; } var setup = columnDef.controls[i].setup; var listeners = columnDef.controls[i].listeners; delete columnDef.controls[i].setup; delete columnDef.controls[i].listeners; var controlConfig = az.util.clone(columnDef.controls[i]); columnDef.controls[i].setup = setup; columnDef.controls[i].listeners = listeners; controlConfig.listeners = listeners; controlConfig.owner = me; controlConfig.name = az.format((controlConfig.name ? controlConfig.name : 'Control_{cid}_{no}_{rowIndex}_{columnIndex}'), { cid: me.cid, no: i + '', rowIndex: rowIndex + '', columnIndex: columnIndex + '' }); var $class = controlConfig.$class; delete controlConfig.$class; var control = az.create($class, controlConfig); me.controls.push(control); if (setup) { if (az.chk.ifFunction(setup)) setup(control, rowData, columnIndex, columnDef, rowIndex, allData, allColumns, owner); if (az.chk.ifObject(setup)) { setup.fn.apply(setup.scope, [control, rowData, columnIndex, columnDef, rowIndex, allData, allColumns, owner]); } } control.preRender(); control.rowIndex = rowIndex; control.columnIndex = columnIndex; control.controlIndex = i; buffer.push(control.render()); } return buffer.join(''); } if (columnDef.renderer) { return columnDef.renderer(me._formatValue(me.columns[columnIndex].format, value, columnIndex, columnDef, rowData, rowIndex, allData, allColumns, owner), columnIndex, columnDef, rowData, rowIndex, allData, allColumns, owner); } return me.cellTpl(this, { content: me._formatValue(me.columns[columnIndex].format, value, columnIndex, columnDef, rowData, rowIndex, allData, allColumns, owner), width: columnDef.width - 8, cellHeight: az.chk.ifNumber(me.cellHeight) ? (me.cellHeight + 'px') : me.cellHeight }); } }); if (this.rendered) { if (this.header) this.header.preRender(); this.body.preRender(); this.leftScrollBar.preRender(); this.bottomScrollBar.preRender(); $(this.dom.wrapper).html((this.header ? this.header.render() : '') + this.bodyWrapper(this, { content: this.body.render() })); if (this.header) this.header.postRender(); this.body.postRender(); for (var i = 0; i < this.controls.length; i++) this.controls[i].postRender(); } }, onBodyFocusOut: function (control, event) { console.log(event); }, render: function () { if (this.header) this.header.preRender(); if (this.pager) this.pager.preRender(); this.body.preRender(); this.leftScrollBar.preRender(); this.bottomScrollBar.preRender(); this.tplData.wrapper.content = (this.header ? this.header.render() : '') + this.bodyWrapper(this, { content: this.body.render() }) + this.leftScrollBar.render() + this.bottomScrollBar.render(); if (this.pager) { this.tplData.wrapper.pager = this.pager.render(); } return this.$super.apply(this, arguments); }, onResize: function () { this.$super.apply(this, arguments); if (this.editor) this.editor.cancel(); if (this.pager && (this.owner.layout && (this.owner.layout instanceof az.FitLayout || this.owner.layout instanceof az.ColumnLayout || this.owner.layout instanceof az.RowLayout || this.owner.layout instanceof az.CardLayout) )) this.pager.setWidth($(this.getRootEl()).width()); this.resetColumnWidth(); this._updateScroller(); }, _updateLeftScrollBar: function () { this.leftScrollBar.setStyle(this.leftScrollBar.rootElement, { position: 'absolute', 'z-index': 100, top: this.getThemeValue('headerHeight') + 'px', left: 'auto', right: 0 }); var _contentHeight = $(this.body.getRootEl()).height(); var _visibleHeight = this.height - this.getThemeValue('headerHeight') - (this._getBorder('top') + this._getBorder('bottom')) - (this.pager ? this.getThemeValue('pagerHeight') : 0); this.leftScrollBar.setSize(_visibleHeight - ((this.bottomScrollBar.visible && this.width) ? az.dom.SCROLLBAR.HEIGHT : 0)); this.leftScrollBar.setScrollSize(_contentHeight + 0); }, _updateBottomScrollBar: function () { this.bottomScrollBar.setStyle(this.bottomScrollBar.rootElement, { position: (this.height ? 'absolute' : 'static'), 'z-index': 100, bottom: (this.pager ? this.getThemeValue('pagerHeight') + 'px' : 0), left: '0px' }); this.bottomScrollBar.setSize(this.width - (this._getBorder('left') + this._getBorder('right')) - ((this.leftScrollBar.visible && this.height) ? az.dom.SCROLLBAR.WIDTH : 0)); this.bottomScrollBar.setScrollSize($(this.body.getRootEl()).width() - 0); }, _updateScroller: function () { this._updateLeftScrollBar(); this._updateBottomScrollBar(); }, setBorder: function (border) { if (az.chk.ifString(border)) { var vals = border.split(' '); border = vals.length == 1 ? vals[0] : { top: vals[0] || 0, right: vals[1] || 0, bottom: vals[2] || 0, left: vals[3] || 0 }; } this.border = border; this.setStyle('wrapper', this._getBorderStyle()); this.onResize(); }, postRender: function () { this.$super.apply(this, arguments); if (this.header) this.header.postRender(); this.body.postRender(); this.leftScrollBar.postRender(); this.bottomScrollBar.postRender(); if (this.pager) this.pager.postRender(); this.resetColumnWidth(); this._updateScroller(); for (var i = 0; i < this.controls.length; i++) this.controls[i].postRender(); if ((this.owner.layout instanceof az.FitLayout || this.owner.layout instanceof az.ColumnLayout || this.owner.layout instanceof az.RowLayout || this.owner.layout instanceof az.CardLayout) && this.pager) { this.pager.setStyle('root', { 'position': 'absolute' }); } if (this.pager && !(this.owner.layout && this.owner.layout instanceof az.AutoLayout)) this.pager.setWidth($(this.getRootEl()).width()); }, resetColumnWidth: function (resizingColIndex, headerResizing) { resizingColIndex = resizingColIndex || -1; var start = (resizingColIndex == this.columns.length - 1) ? 0 : resizingColIndex == -1 ? 0 : resizingColIndex; var definedWidth = 0; var undefindedCount = 0; var cols = this.columns; var availableWidth = (this.width || this.owner.getLayoutSize().contentAreaSize.width) - (this._getBorder('left') + this._getBorder('right')) - az.dom.SCROLLBAR.WIDTH; //- cols.length; for (var i = 0; i < cols.length; i++) { if (resizingColIndex > -1 && resizingColIndex == i && cols[i].autoWidth) { cols[i].autoWidth = false; definedWidth += this.body.getColumnWidth(i); continue; } if (headerResizing && i <= start && cols[i].autoWidth) { cols[i].autoWidth = false; definedWidth += this.body.getColumnWidth(i); continue; } if (!cols[i].autoWidth && cols[i].width) { if (cols[i].width < 1 && cols[i].width > 0) { cols[i].width = availableWidth * cols[i].width; this.body.setColumnWidth(i, cols[i].width); this.header.setColumnWidth(i, cols[i].width); } definedWidth += this.body.getColumnWidth(i); //(cols[i].width+1); } else { cols[i].autoWidth = true; undefindedCount++; } } var toBeFiled = Math.abs(availableWidth - definedWidth); var agvWidth = Math.floor(toBeFiled / undefindedCount); var occupied = agvWidth * undefindedCount; var autoWidthCount = 0; for (var i = 0; i < cols.length; i++) { if (cols[i].autoWidth) { autoWidthCount++; cols[i].width = (undefindedCount == autoWidthCount && toBeFiled == occupied) ? agvWidth - 1 : agvWidth; this.body.setColumnWidth(i, cols[i].width); this.header.setColumnWidth(i, cols[i].width); } if (resizingColIndex > -1 && resizingColIndex == i && cols[i].autoWidth) { cols[i].autoWidth = true; } if (headerResizing && i <= start && cols[i].autoWidth) { cols[i].autoWidth = false; } } if (resizingColIndex > -1) { this._updateScroller(); } }, initTplData: function () { this.$super.apply(this, arguments); this.setStyle('wrapper', { 'position': 'relative', 'overflow': 'hidden' }); }, getControls: function (rowIndex, columnIndex, controlIndex) { var selectedItems = []; for (var i = 0; i < this.controls.length; i++) { if (this.controls[i].rowIndex == rowIndex) { if (columnIndex > -1) { if (this.controls[i].columnIndex == columnIndex) { if (controlIndex > -1) { if (this.controls[i].controlIndex == controlIndex) { selectedItems.push(this.controls[i]); } } else { selectedItems.push(this.controls[i]); } } } else { selectedItems.push(this.controls[i]); } } } return selectedItems; }, getRowCount: function () { return this.store.count(); }, load: function (pageIndex) { this.store.load(pageIndex); if (az.chk.ifNumber(pageIndex)) { this.pager.setOptions({ pageIndex: pageIndex }); } this.body.refresh(); this._updateScroller(); this.selectedRows = []; this.selectedRowIndex = -1; this.selectedColumnIndex = -1; }, _refreshGridBody: function () { if (!this.body) return; this._destroyControls(); this.body.refresh(); for (var i = 0; i < this.controls.length; i++) this.controls[i].postRender(); this._updateScroller(); }, sort: function (columnIndex, sortDir) { if (this.editor) this.editor.cancel(); if (this.sortByColumn == columnIndex && sortDir == this.sortDir) return; if (!this.columns[columnIndex].sortable) return; if (az.chk.ifNumber(this.sortByColumn)) { this.header.removeColumnCls(0, this.sortByColumn, 'az-datagrid-sort-asc'); this.header.removeColumnCls(0, this.sortByColumn, 'az-datagrid-sort-desc'); } this.store.sort(this.columns[columnIndex].field, sortDir, this.columns[columnIndex].compareBy) this._refreshGridBody(); this.sortByColumn = columnIndex; this.sortDir = sortDir; this.header.addColumnCls(0, this.sortByColumn, this.sortDir == 'asc' ? 'az-datagrid-sort-asc' : 'az-datagrid-sort-desc'); }, showColumn: function (columnIndex) { this.setColumnVisible(columnIndex, true); }, hideColumn: function (columnIndex) { this.setColumnVisible(columnIndex, false); }, setColumnVisible: function (columnIndex, visible) { this.header.setVisibleColumn(columnIndex, visible); this.body.setVisibleColumn(columnIndex, visible); }, setValue: function (rowIndex, colIndex, value) { if (this.columns[colIndex].field) { this.body.setCellValue(rowIndex, colIndex, value); this.store.getAt(rowIndex).set(this.columns[colIndex].field, value); } }, getValue: function (rowIndex, colIndex) { if (this.columns[colIndex].field) { return this.store.getAt(rowIndex).get(this.columns[colIndex].field + ''); } return this.body.getCellContent(rowIndex, colIndex); }, updateRow: function (rowIndex, data) { var record = this.store.getAt(rowIndex); record.update(data); record.commit(); }, addRow: function (data, index, showEditing) { var record = this.store.add(data, index); if (showEditing && this.editor) { var _index = az.chk.ifDefined(index) ? index : this.store.records.length - 1; this.selectRow(_index); this.editor.edit(this.selectedRowIndex); } return record; }, removeRow: function (dataOrIndex) { this.store.remove(dataOrIndex); }, init: function () { this.border = this.getThemeValue('defaultBorder'); this.$super.apply(this, arguments); this.attr = "tabindex=" + this.cid.replace('az-com-', ''); var me = this; az.copy(this.store, { listeners: { beforeload: function () { if (me.rendered) me.setDisabled(true); me.fireEvent('beforeload'); }, load: function () { me.refresh(); me.setDisabled(false); me.fireEvent('load'); }, add: function (record) { me.refresh(); me.fireEvent('add', record); }, remove: function (record) { me.refresh(); me.fireEvent('remove', record); }, update: function (record) { me.refresh(); me.fireEvent('update', record); } } }); this.store.pageSize = this.store.paged ? this.store.pageSize : undefined; this.store = new az.DataStore(this.store); if (this.autoLoad) this.store.load(); this.leftScrollBar = new az.Scroller({ owner: this, listeners: { scroll: function (scroller, offset) { $(me.body.dom.wrapper).css('margin-top', (offset == 0 ? '0px' : '-' + offset + 'px')); me.scrollOffsetTop = offset; } } }); this.bottomScrollBar = new az.Scroller({ vertical: false, owner: this, listeners: { scroll: function (scroller, offset) { $(me.body.dom.wrapper).css('margin-left', '-' + offset + 'px'); $(me.header.dom.wrapper).css('margin-left', '-' + offset + 'px'); } } }); if (this.store.paged) { az.copy(this.pagerCfg, { owner: this, height: this.getThemeValue('pagerHeight') - this.getThemeValue('pagerBoderTop'), pageSize: this.store.pageSize, totalCount: this.store.totalCount, pageCount: this.store.pageCount, pageIndex: this.store.pageIndex, pageSizeList: this.store.pageSizeList, style: 'z-index:100;bottom:0;' + (this.height ? 'position:absolute;' : ''), listeners: { pagechange: function (pager, pageIndex) { me.store.load(pageIndex); }, pagesizechange: function (pager, pageSize, pageIndex) { me.store.pageSize = pageSize; me.store.load(pageIndex); }, refresh: function (pager, pageIndex) { me.store.load(pageIndex); } } }); this.pager = new az.Pager(this.pagerCfg); this.pager.padding = { top: 3, left: 0, bottom: 3, right: 0 }; if (this.pager.listPageSize) this.pager.listPageSize.setStyle('wrapper', 'margin-left', '4px'); } if (this.editing) { this.editor = new az.GridEditor(this); } this.refresh(); }, destroy: function () { this.body.destroy(); //if (this.header) this.header.destory(); this._destroyControls(); this.$super.apply(this, arguments); }, onMouseWheel: function (event) { event.browserEvent.preventDefault(); event.browserEvent.stopPropagation(); var delFactor = 10; // event.browserEvent.deltaFactor var maxOffset = this.leftScrollBar.getMaxOffset(); this.scrollOffsetTop += delFactor * (-1) * event.browserEvent.deltaY; this.scrollOffsetTop = this.scrollOffsetTop < 0 ? 0 : this.scrollOffsetTop; this.scrollOffsetTop = this.scrollOffsetTop > maxOffset ? maxOffset : this.scrollOffsetTop; this.leftScrollBar.setScrollOffset(this.scrollOffsetTop); }, _resizeColumnCells: function (columnIndex) { for (var i = 0; i <= this.store.records.length; i++) { var d = this.body.getCellEl(i, columnIndex); } } }); /*Scripts/libs/Astral/Control/Pager.js*/ az.defineClass('Pager', { $extends: 'Container', pageSize: 10, pageIndex: -1, onlyNextPrev: false, displayText: 'Displaying {displayFrom}-{displayTo} of {totalCount}', tplData: { root: { css: 'az-pager {css}', style: '{style}', content: '' } }, padding: 0, events: { custom: ['pagechange', 'pagesizechange', 'refresh'] }, initPagerControls: function () { var btnListeners = { click: { fn: this.onPagerBtnClick, scope: this} }; var btnRefreshListeners = { click: { fn: this.handleRefreshBtnClick, scope: this} }; var textpageListeners = { change: { fn: this.onTextPageIndexChange, scope: this} }; var pageSizeListeners = { select: { fn: this.onPageSizeChange, scope: this} }; this.btnFirst = new az.Button({ owner: this, title: 'First', plain: true, disabled: this.pageIndex == 0, lastFirst: 0, iconCls: 'az-pagination-first', listeners: btnListeners }); this.btnPrev = new az.Button({ owner: this, title: 'Prev', plain: true, disabled: this.pageIndex == 0, deltaP: -1, iconCls: 'az-pagination-prev', listeners: btnListeners }); var sep1 = new az.ToolbarSeparator({ owner: this }); this.textPage = new az.NumberField({ owner: this, value: (this.pageIndex + 1), label: 'Page', labelWidth:33, width: 40, style: 'display:inline-block', listeners: textpageListeners }); this.label = new az.Label({ owner: this, text: 'of ' + this.pageCount }); var sep2 = new az.ToolbarSeparator({ owner: this }); this.btnNext = new az.Button({ owner: this, title: 'Next', plain: true, disabled: !(this.pageIndex < (this.pageCount - 1)), deltaP: 1, iconCls: 'az-pagination-next', listeners: btnListeners }); this.btnLast = new az.Button({ owner: this, title: 'Last', plain: true, disabled: !(this.pageIndex < (this.pageCount - 1)), lastFirst: 1, iconCls: 'az-pagination-last', listeners: btnListeners }); var sep3 = new az.ToolbarSeparator({ owner: this }); this.btnRefresh = new az.Button({ owner: this, title: 'Refresh', plain: true, iconCls: 'az-pagination-load', listeners: btnRefreshListeners }); this.labelDisplayInfo = new az.Label({ owner: this, text: az.format(this.displayText, this), css: 'az-pager-display-info' }); this.labelDisplayInfo.addCls('wrapper', 'az-pager-display-info'); this.items.splice(0, 0, this.btnFirst, this.btnPrev, sep1, this.textPage, this.label, sep2, this.btnNext, this.btnLast, sep3, this.btnRefresh, this.labelDisplayInfo); if (this.pageSizeList) { var _sizeList = this.pageSizeList.join(','); this.listPageSize = new az.Combobox({ owner: this, data: _sizeList, value: this.pageSizeList[0], width: 55, style: 'display:inline-block;position: relative;', hideLabel: true, listeners: pageSizeListeners }); this.items.splice(0, 0, this.listPageSize); } if (!this.owner && this.renderTo) { $.each(this.items, function () { this.preRender(); }); } if (this.onlyNextPrev) { this.btnFirst.hide(); this.btnLast.hide(); } if (!this.displayText) { this.labelDisplayInfo.hide(); } }, init: function () { this.$super.apply(this, arguments); this.__setInitialValues(); this.initPagerControls(); }, __setInitialValues: function () { if (this.totalCount) { var extra = this.totalCount % this.pageSize; this.pageCount = extra > 0 ? ((this.totalCount - extra) / this.pageSize) + 1 : (this.totalCount / this.pageSize); this.pageIndex = this.pageIndex == -1 ? 0 : this.pageIndex; } else { this.pageCount = 1; } this.__setDisplayText(); }, __setDisplayText: function () { if (this.labelDisplayInfo) { if (this.totalCount == 0) { this.labelDisplayInfo.setText('No record to display'); } else { this.displayFrom = this.pageIndex * this.pageSize + 1; this.displayTo = this.pageIndex + 1 == this.pageCount ? this.totalCount : (this.pageIndex + 1) * this.pageSize; this.labelDisplayInfo.setText(az.format(this.displayText, this)); } } }, onPagerBtnClick: function (control, event) { if (control.lastFirst != undefined) { this.pageIndex = control.lastFirst * (this.pageCount - 1); } else if (control.deltaP != undefined) { this.pageIndex += control.deltaP; } this.textPage.setRawValue(this.pageIndex + 1); this.__enableDisableBtns(); this.__setDisplayText(); this.fireEvent('pagechange', this.pageIndex); }, onPageSizeChange: function (control, value, index) { this.pageSize = parseInt(value); this.pageIndex = -1; this.__setInitialValues(); this.textPage.setRawValue(this.pageIndex + 1); this.label.setText('of ' + this.pageCount); this.__enableDisableBtns(); this.__setDisplayText(); this.fireEvent('pagesizechange', this.pageSize, this.pageIndex); }, handleRefreshBtnClick: function () { this.textPage.setRawValue(this.pageIndex + 1); this.fireEvent('refresh', this.pageIndex); }, onTextPageIndexChange: function (control, event, newVal) { this.gotoPage(newVal, true); }, gotoPage: function (pageNum, notify) { pageNum = pageNum < 1 ? 1 : pageNum; pageNum = (pageNum > this.pageCount) ? this.pageCount : pageNum; this.pageIndex = pageNum - 1; this.textPage.setRawValue(this.pageIndex + 1); this.__enableDisableBtns(); this.__setDisplayText(); if (notify) { this.fireEvent('pagechange', this.pageIndex); } }, __enableDisableBtns: function () { this.btnFirst.setDisabled(this.pageIndex == 0); this.btnPrev.setDisabled(this.pageIndex == 0); this.btnLast.setDisabled(!(this.pageIndex < (this.pageCount - 1))); this.btnNext.setDisabled(!(this.pageIndex < (this.pageCount - 1))); }, setOptions: function (options) { az.copy(this, options); if (this.pageSizeList) { var sizeList = this.pageSizeList.join(','); this.pageSize = options.pageSize ? options.pageSize : this.pageSizeList[0]; this.listPageSize.setData(sizeList); this.listPageSize.setValue(this.pageSize); } this.__setInitialValues(); this.textPage.setRawValue(this.pageIndex + 1); this.label.setText('of ' + this.pageCount); this.__enableDisableBtns(); } }); /*Scripts/libs/Astral/Control/Splitter.js*/ az.defineClass('Splitter', { $extends: 'Control', $includes: 'draggable', dragConfig: { scroll: false }, draggable: true, renderPattern: '@wrapper({content:@button})+@containment', canCollapse: true, canResize: true, targetControlCollapsed: false, orientation: 'ver', // h size: 5, init: function () { this.$super.apply(this, arguments); if (!this.canResize) this.draggable = false; this.dragConfig.containment = '#' + az.format("{$class}-{cid}-containment", this); this.dragConfig.disabled = this.targetControlCollapsed || !this.canResize; this.dragConfig.axis = this.orientation == 'ver' ? 'x' : 'y'; }, initTplData: function () { this.$super.apply(this, arguments); var cls = 'az-splitter-' + this.orientation; cls += !this.targetControlCollapsed ? ' az-splitter-' + this.orientation + '-cursor' : ''; cls += this.targetControlCollapsed ? ' az-splitter-targetCt-collapsed' : ''; this.addCls('wrapper', cls); if (this.orientation == 'hor') { this.setHeight(this.size); this.placeAt = (this.placeAt || 'bottom'); this.setStyle('wrapper', 'position:relative'); } else { this.setWidth(this.size); this.placeAt = (this.placeAt || 'right'); } this.tplData.button.dirClsPostfix = this.getDirection(); }, tpls: { button: '@if(global.canCollapse){
    }', containment: '
    ' }, tplData: { wrapper: { css: 'az-splitter {css}', style: '{style}', content: '' }, button: { dirClsPostfix: '' } }, getReverseDirection: function (dir) { if (dir == 'left') return 'right'; else if (dir == 'right') return 'left'; else if (dir == 'top') return 'bottom'; else if (dir == 'bottom') return 'top'; }, events: { handle: { 'click:{$class}-{cid}-button': 'onButtonClick' }, custom: ['change', 'expand', 'collapse', 'resizestart', 'click'] }, onDragStart: function () { this.addCls('wrapper', 'az-splitter-moving'); this.removeCls('wrapper', 'az-splitter-' + this.orientation + '-cursor'); }, setColumnWidth: function (change, contentAreaSize) { if (!az.chk.ifDefined(this.targetCt.columnWidth)) this.targetCt.columnWidth = $(this.targetCt.getRootEl()).outerWidth(); if (this.targetCt.columnWidth < 1) { change = change / contentAreaSize.width; } this.targetCt.columnWidth += change; }, setRowHeight: function (change, contentAreaSize) { if (!az.chk.ifDefined(this.targetCt.rowHeight)) this.targetCt.rowHeight = $(this.targetCt.getRootEl()).outerHeight(); if (this.targetCt.rowHeight < 1) { change = change / contentAreaSize.height; } this.targetCt.rowHeight += change; this.setStyle('wrapper', 'top:auto'); }, onDragStop: function (control, ui) { this.removeCls('wrapper', 'az-splitter-moving'); this.addCls('wrapper', 'az-splitter-' + this.orientation + '-cursor'); var change = 0; var contentAreaSize = this.owner.getLayoutSize().contentAreaSize; if (this.owner.layout instanceof az.ColumnLayout) { var changeX = (this.placeAt == 'right') ? (ui.position.left - ui.originalPosition.left) : (ui.originalPosition.left - ui.position.left); this.setColumnWidth(changeX, contentAreaSize); } else { var changeY = (this.placeAt == 'bottom') ? (ui.position.top - ui.originalPosition.top) : (ui.originalPosition.top - ui.position.top); this.setRowHeight(changeY, contentAreaSize); } this.owner.layout.update(); this.fireEvent('change', change); }, getDirection: function () { return this.targetControlCollapsed ? this.placeAt : this.getReverseDirection(this.placeAt); }, onButtonClick: function () { this.targetControlCollapsed = !this.targetControlCollapsed; var dir = this.getDirection(); var cursorCls = 'az-splitter-' + this.orientation + '-cursor'; this.removeCls('button', 'az-splitter-btn-' + this.getReverseDirection(dir)); this.addCls('button', 'az-splitter-btn-' + dir); if (this.targetControlCollapsed) { this.addCls('wrapper', 'az-splitter-targetCt-collapsed'); this.removeCls('wrapper', cursorCls); this.targetCt.collapse(); } else { this.removeCls('wrapper', 'az-splitter-targetCt-collapsed'); this.addCls('wrapper', cursorCls); this.targetCt.expand(); } this.resset(); if (this.draggable) this.setDragDisable(!this.canResize || this.targetControlCollapsed); this.fireEvent('click', this.targetCt); }, postRender: function () { this.$super.apply(this, arguments); this.resset(); }, resset: function () { var contentAreaSize = this.owner.getLayoutSize().contentAreaSize; if (this.owner.layout instanceof az.ColumnLayout) { var _left = isNaN(this.targetCt.left) ? $(this.targetCt.getRootEl()).position().left : this.targetCt.left; if (this.placeAt == 'right') { this.setStyle('containment', { width: (this.maxSpan - this.minSpan + this.size), left: _left + this.minSpan }); this.setPosition(_left + (this.targetCt.collapsed ? 0 : this.targetCt.width), this.owner._getPadding('top')); } else { var r = contentAreaSize.width - _left - this.targetCt.width + this.owner._getPadding('right'); r = r + this.minSpan + this.owner._getPadding('right'); this.setStyle('containment', { width: (this.maxSpan - this.minSpan + this.size), left: 'auto', right: r }); this.setPosition(_left - this.size, this.owner._getPadding('top')); } this.setHeight(contentAreaSize.height); } else { var _top = $(this.targetCt.getRootEl()).offset().top; if (this.placeAt == 'bottom') { this.setStyle('containment', { width: '0px', height: (this.maxSpan - this.minSpan + this.size), left: '0px', top: _top }); } else { var _bottom = contentAreaSize.height - _top - this.targetCt.height + this.owner._getPadding('top'); _bottom = _bottom + 2 * this.minSpan + this.owner._getPadding('bottom') - this.targetCt._getBorder('top'); var containmentHeight = this.maxSpan - this.minSpan + this.size; this.setStyle('containment', { width: '0px', height: containmentHeight, left: '0px', top: 'auto', bottom: _bottom }); } this.setWidth(contentAreaSize.width); } this.dragConfig.disabled = this.targetControlCollapsed || !this.canResize; }, getButton: function () { return $(this.dom.button); } }); /*Form/FlexControl.js*/ az.defineClass('FlexControl', { $extends: 'Control', ctrls: {}, groupCtrls: {}, init: function (config) { var me = this; this.dom = { set: function (name, value) { $(me.dom[name]).html(value); }, setImg: function (name) { $(me.dom[name]).css({ backgroundImage: "url('" + value + "')" }); }, setVisible: function (name, visible) { $(me.dom[name])[visible ? 'show' : 'hide'](); } }; this.initCtrls(config); this.$super.apply(this, arguments); this.applyVisibility(); }, initCtrl: function (name, control) { control.owner = this; this.ctrls[name] = control; this.tpls[name] = '{content}', this.tplData[name] = { content: '' }; }, $el: function (name) { return $('#' + this.$class + '-' + this.cid + '-' + name); }, $dom: function (name) { if (name == '.') { return $('#' + this.$class + '-' + this.cid); } else return $('#' + this.cid + '-' + name); }, initGroupCtrl: function (groupName, control) { control.owner = this; if (!this.groupCtrls[groupName]) this.groupCtrls[groupName] = []; this.groupCtrls[groupName].push(control); if (!this.tpls[groupName]) { this.tpls[groupName] = '{content}', this.tplData[groupName] = { content: '' }; } }, applyVisibility: function () { if (this.visibility) { for (var i in this.visibility) { // this.ctrls[this.visibility[i]]. for (var c in this.visibilityGroups[i]) { var v = this.visibilityGroups[i][c]; if (this.ctrls.hasOwnProperty(v.name)) { if (!this.visibility[i]) this.ctrls[v.name].setVisible(false); else this.ctrls[v.name].setVisible(v.visibleIn.indexOf(this.visibility[i]) > -1); } else if (this.dom.hasOwnProperty(v.name)) { if (!this.visibility[i]) this.setStyle(v.name, 'display', 'none'); else { this.setStyle(v.name, 'display', v.visibleIn.indexOf(this.visibility[i]) > -1 ? 'block' : 'none'); } } } } } }, addCtrl: function (name, control) { control.owner = this; this.ctrls[name] = control; }, renderCtrlTo: function (name, targetDom, control) { if (this.ctrls[name]) this.ctrls[name].destroy(); this.addCtrl(name, control); this.ctrls[name].preRender(); if (az.chk.ifObject(targetDom)) { targetDom.empty().append(this.ctrls[name].render()); } else $(this.dom[targetDom]).empty().append(this.ctrls[name].render()); this.ctrls[name].postRender(); }, appendCtrlTo: function (name, targetDom, control) { if (this.ctrls[name]) this.ctrls[name].destroy(); this.addCtrl(name, control); this.ctrls[name].preRender(); $(this.dom[targetDom]).append(this.ctrls[name].render()); this.ctrls[name].postRender(); }, replaceCtrl: function (newCtrl, currentCtrl) { for (var c in this.ctrls) { if (this.ctrls[c].cid == currentCtrl.cid) { newCtrl.owner = this; var ctrlRoot = this.ctrls[c].getRootEl(); $(ctrlRoot).after('
    '); this.ctrls[c].destroy(); this.ctrls[c] = newCtrl; this.ctrls[c].preRender(); $('#' + this.cid + '-temp').after(this.ctrls[c].render()); this.ctrls[c].postRender(); $('#' + this.cid + '-temp').remove(); break; } } }, renderGroupCtrlTo: function (groupName, targetDom, controls, wrapperTplName) { if (!this.groupCtrls[groupName]) this.groupCtrls[groupName] = []; var len = this.groupCtrls[groupName].length; while (len > 0) { this.groupCtrls[groupName].pop().destroy(); len--; } this.groupCtrls[groupName] = []; var buffer = []; for (var i = 0; i < controls.length; i++) { controls[i].owner = this; this.groupCtrls[groupName].push(controls[i]); controls[i].preRender(); if (wrapperTplName) buffer.push(this[wrapperTplName](this, this.prepWrapperTplData(controls[i].render(), i, controls))); else buffer.push(controls[i].render()); } $(this.dom[targetDom]).empty().append(buffer.join('')); for (var i = 0; i < controls.length; i++) controls[i].postRender(); }, prepWrapperTplData: function (content) { return { content: content } }, initCtrls: az.emptyFn, preRender: function () { for (var ctrl in this.ctrls) this.ctrls[ctrl].preRender(); for (var group in this.groupCtrls) { for (var i = 0; i < this.groupCtrls[group].length; i++) { this.groupCtrls[group][i].preRender(); } } this.$super.apply(this, arguments); }, render: function () { for (var ctrl in this.ctrls) this.tplData[ctrl].content = this.ctrls[ctrl].render(); for (var group in this.groupCtrls) { var buffer = []; for (var i = 0; i < this.groupCtrls[group].length; i++) { buffer.push(this.groupCtrls[group][i].render()); } this.tplData[group].content = buffer.join(''); } return this.$super.apply(this, arguments); }, postRender: function () { this.$super.apply(this, arguments); for (var ctrl in this.ctrls) this.ctrls[ctrl].postRender(); for (var group in this.groupCtrls) { for (var i = 0; i < this.groupCtrls[group].length; i++) { this.groupCtrls[group][i].postRender(); } } }, destroy: function () { for (var ctrl in this.ctrls) this.ctrls[ctrl].destroy(); for (var group in this.groupCtrls) { for (var i = 0; i < this.groupCtrls[group].length; i++) { this.groupCtrls[group][i].destroy(); } } this.$super.apply(this, arguments); } }); az.defineClass('FlexModel', { $includes: 'observable', originalSrc: {}, workingSrc: {}, versionData: {}, version: -1, init: function (config) { this.originalSrc = config.model; this.workingSrc = az.util.clone(config.model); this.listeners = config.listeners; }, set: function (name, value, noNotify) { this.workingSrc[name] = value; if (!this.originalSrc.hasOwnProperty(name)) { this.originalSrc[name] = value; } if (this.originalSrc[name] != value) { this.version++; this.versionData[this.version] = az.util.clone(this.workingSrc); } if (!noNotify) this.fire('update', name, value); }, get: function (name) { return this.workingSrc[name]; }, getDataModel: function () { return this.workingSrc; }, reset: function () { this.originalSrc = az.util.clone(this.workingSrc); this.version = -1; this.versionData = {}; }, clear: function () { this.version = -1; this.versionData = {}; }, isDirty: function () { return this.version > -1; } }); az.defineClass('FlexView', { $extends: 'FlexControl', events: { custom: ['$change'] }, $bind: {}, initBindMapping: function () { var me = this; for (var ctrl in this.ctrls) { var c = this.ctrls[ctrl]; c.name = c.name || '$_' + az.uid(); if (c.$bind) { this.$bind[c.$bind] = ctrl; if (this.ctrls[ctrl] instanceof az.Field || this.ctrls[ctrl].events.custom.indexOf('change') > -1) { this.ctrls[ctrl].addListener('change', function (control, event, value) { me.fireEvent('$change', control.$bind, value); }); } } } }, init: function () { this.$super.apply(this, arguments); this.initBindMapping(); }, setViewData: function (name, value) { if (this.$bind[name] && this.ctrls[this.$bind[name]]) { if (!az.chk.ifEmpty(this.ctrls[this.$bind[name]].defaultValue) && az.chk.ifEmpty(value)) { this.$vm.set(name, this.ctrls[this.$bind[name]].defaultValue); } else this.ctrls[this.$bind[name]].setValue(value); } }, reset: function (resetNested) { for (var name in this.$bind) { if (this.ctrls[this.$bind[name]].$vm && resetNested) { this.ctrls[this.$bind[name]].$vm.view.reset(resetNested); } else this.ctrls[this.$bind[name]].setValue(undefined); } }, getCtrlByField: function (field) { for (var c in this.ctrls) { if (!this.ctrls[c].$bind) continue; if (field == this.ctrls[c].$bind.toString()) { return this.ctrls[c]; } } } }); az.defineClass('FlexViewModel', { view: {}, init: function (config) { var me = this; /* this.view = config.view; this.validation = config.validation; if (config.onValidateFailure) this.onValidateFailure = config.onValidateFailure;*/ az.copy(this, config) this.view.$vm = this; this.view.addListener('$change', function (control, name, value) { var v = config.onViewDataUpdate ? config.onViewDataUpdate(name, az.util.escapeScriptTag(value)) : me.onViewDataUpdate(name, az.util.escapeScriptTag(value)); if (me.validateItem(name, v)) { me.model.set(name, v, true); me.exeViewRule(); } }); this.view.addListener('postrender', function (control) { for (var i in control.$bind) { var data = me.get(i); if (az.chk.ifObject(data)) { if (!az.chk.ifEmptyObj(data)) control.setViewData(i, data); else continue; } else if (az.chk.ifArray(data)) { if (!az.chk.ifEmpty(data)) control.setViewData(i, data); else continue; } else if (!az.chk.ifEmpty(data)) { control.setViewData(i, data); } } }); this.model = new az.FlexModel({ model: config.model, listeners: { update: function (name, value) { me.view.setViewData(name, value); } } }); }, fireValidation: function (name) { var array = this.validation[name]; var invalidCount = 0; for (var i = 0; i < array.length; i++) { invalidCount += this.validateItemByFn(array[i], name) ? 0 : 1; } return invalidCount == 0; }, validate: function () { if (this.validation) { var invalidCount = 0; for (var fn in this.validation) { invalidCount += this.fireValidation(fn) ? 0 : 1; } return invalidCount == 0; } else return true; }, validateItemByFn: function (name, validateFn) { var ctrl = this.view.$bind[name]; if (!this.view.ctrls[ctrl].visible) return true; var value = this.view.ctrls[ctrl].getValue(); if (this.validation) { var feedback = {}; var valid = this[validateFn](value, feedback); if (az.chk.ifDefined(this.view.ctrls[ctrl].__$isValid) && this.view.ctrls[ctrl].__$isValid == false) { } else this.view.ctrls[ctrl][valid ? 'clearInvalid' : 'markInvalid'](); this.view.ctrls[ctrl].__$isValid = valid; if (!valid) this.onValidateFailure(validateFn, feedback); return valid; } else return true; }, validateItem: function (name, value) { var ctrl = this.view.$bind[name]; if (!this.view.ctrls[ctrl].getValue) return true; if (!value) value = this.view.ctrls[ctrl].getValue(); if (this.validation) { var invalidCount = 0; for (var fn in this.validation) { if (this.validation[fn].indexOf(name) > -1) { var feedback = {}; var valid = this[fn](value, feedback); this.view.ctrls[ctrl][valid ? 'clearInvalid' : 'markInvalid'](); if (!valid) this.onValidateFailure(fn, feedback); invalidCount += valid ? 0 : 1; } } return invalidCount == 0; } else return true; }, reset: function (data) { this.set(data); this.model.reset(); }, set: function (name, value) { if (az.chk.ifObject(name)) { for (var prop in name) { this.model.set(prop, name[prop]); } } else this.model.set(name, value); this.exeViewRule(); }, get: function (nameOrFn) { if (!nameOrFn) return this.model.getDataModel(); else if (az.chk.ifFunction(nameOrFn)) { return nameOrFn(this.model.getDataModel()); } else return this.model.get(nameOrFn); }, onViewDataUpdate: function (name, value) { return value; }, onValidateFailure: function () { }, notEmpty: function (value) { return !!value; }, validEmail: function (value) { if (value.length) { var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(String(value).toLowerCase()); } else return true; }, viewRules: { visible: { }, data: { }, value: { } }, exeViewRule: function () { var sequence = ['value', 'data', 'visible']; for (var r in this.viewRules) { var ruleType = this.viewRules[r]; switch (r) { case 'visible': for (var m in ruleType) { var isNonBind = m.indexOf('$nb') > -1; var res = isNonBind ? this.evaluateVisibleRuleNF(m.split('$nb_')[1], ruleType[m]) : this.evaluateVisibleRule(m, ruleType[m]); if (az.chk.ifDefined(res)) { var ctrl; try { ctrl = isNonBind ? az.getCmpByName(m.split('$nb_')[1])[0] : this.view.getCtrlByField(m); } catch (ex) { console.log('exeViewRule', ex); } if (ctrl) ctrl.setVisible(res); } } break; } } }, evaluateVisibleRuleNF: function (compName, conditionGroup) { if (conditionGroup.rules.length == 0) return true; for (var c in this.view.ctrls) { if (this.view.ctrls[c].$bind && !this.view.ctrls[c].$vm) continue; if (compName == this.view.ctrls[c].name.toString()) { var rules = conditionGroup.rules; var trueCount = 0; for (var i = 0; i < rules.length; i++) { var rule = rules[i]; if (rule.condition) { trueCount += this.evaluateVisibleRuleNF(compName, rule); } else trueCount += this.resolveCondition(rule.type, rule.operator, rule.value, this.get(rule.field)) ? 1 : 0; } if (conditionGroup.condition == 'and') { return trueCount == rules.length; } return trueCount > 0; } } }, evaluateVisibleRule: function (field, conditionGroup) { if (conditionGroup.rules.length == 0) return true; for (var c in this.view.ctrls) { if (!this.view.ctrls[c].$bind) continue; if (field == this.view.ctrls[c].$bind.toString()) { var rules = conditionGroup.rules; var trueCount = 0; for (var i = 0; i < rules.length; i++) { var rule = rules[i]; if (rule.condition) { trueCount += this.evaluateVisibleRule(field, rule); } else trueCount += this.resolveCondition(rule.type, rule.operator, rule.value, this.get(rule.field)) ? 1 : 0; } if (conditionGroup.condition == 'and') { return trueCount == rules.length; } return trueCount > 0; } } }, resolveCondition: function (type, oparatorName, configValue, fieldValue) { var operators = { NUMBER: { 'equal': function (a, b) { return a == b }, 'notEqual': function (a, b) { return a != b }, 'lessThan': function (a, b) { return a < b }, 'lessThanEqual': function (a, b) { return a <= b }, 'greaterThan': function (a, b) { return a > b }, 'greaterThanEqual': function (a, b) { return a >= b }, 'between': function (a, b) { var parts = b.split('||'); return a > parseInt(parts[0]) && a <= parseInt(parts[1]); }, 'notBetween': function (a, b) { var parts = b.split('||'); return a < parseInt(parts[0]) || a >= parseInt(parts[1]); } }, STRING: { 'equal': function (a, b) { return a == b }, 'notEqual': function (a, b) { return a != b }, 'begins': function (a, b) { return b.indexOf(a) > -1 }, 'ends': function (a, b) { return b.indexOf(a) > -1 }, 'contains': function (a, b) { if (!az.chk.ifEmpty(a)) { var hasPipedConfigVal = b.indexOf('|') > -1; if (hasPipedConfigVal) { var configParts = b.split('|'); var hasPippedValue = a.indexOf('|') > -1; if (hasPippedValue) { var valueparts = a.split('|'); var matchcount = 0; for (var i = 0; i < configParts.length; i++) { matchcount += az.indexOf(valueparts, function (e) { return e == configParts[i]; }) > -1 ? 1 : 0; } return matchcount > 0; } else return az.indexOf(configParts, function (e) { return e == a; }) > -1; } else { var hasPippedValue = a.indexOf('|') > -1; if (hasPippedValue) { var valueparts = a.split('|'); var matchcount = 0; matchcount += az.indexOf(valueparts, function (e) { return e == b; }) > -1 ? 1 : 0; return matchcount > 0; } else return ('[' + b + ']').indexOf(('[' + a + ']')) > -1; } //return b.indexOf(a) > -1; } else return false; } }, DATE: { 'equal': function (a, b) { return a == b }, 'notEqual': function (a, b) { return a != b }, 'lessThan': function (a, b) { return a < b }, 'lessThanEqual': function (a, b) { return a <= b }, 'greaterThan': function (a, b) { return a > b }, 'greaterThanEqual': function (a, b) { return a >= b }, 'between': function (a, b) { var parts = b.split('||'); return a > new Date(parts[0]) && a <= new Date(parts[1]); }, 'notBetween': function (a, b) { var parts = b.split('||'); return a < new Date(parts[0]) || a >= new Date(parts[1]); } }, BOOLEAN: { 'equal': function (a, b) { return a == b } } } var fn = operators[type.toUpperCase()][oparatorName]; if (type == 'date') { configValue = new Date(configValue).setHours(0, 0, 0, 0); if (fieldValue) fieldValue = fieldValue.setHours(0, 0, 0, 0); else fieldValue = 0; } if (type == 'boolean') { configValue = JSON.parse(configValue); fieldValue = !!parseInt(fieldValue); } return fn(fieldValue, configValue); } }); /*Form/CustomControls/CurrencyField.js*/ az.defineClass('CurrencyField', { $extends: 'TextField', currencyData: [{ name: 'Britain Pound', code: 'GBP', symbol: '£'},{ name: 'US Dollar', code: 'USD', symbol: '$' }], renderPattern: '@wrapper({content:@label+ @tooltip + @validationHelper + @inputWrapper({ symbol: @symbol({trigger: @trigger }), input:@input}) })', thousandSeparator: true, decimalPrecision: 2, currency: 'GBP', _triggerWidth: { symbol: 24, code: 41, both: 66 }, currencyReadOnly: false, _allowedSpecialCharKeyCodes : [46,8,37,39,35,36,9], // _ _numberKeyCodes : [44, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105], _commaKeyCode : [188], _decimalKeyCode : [190,110], currencyDisplayMode: 'symbol', _formatPriceConfig: {digitGroupSymbol : ',', symbol: '', roundToDecimalPlace: 2 }, lookupConfig: { fetched: false, defaultQuery:[], fields:[{ FieldId:823, ComponentId:0}, { FieldId:824, ComponentId:1473}, { FieldId:825, ComponentId:1473}], lookupId:44, provider :"Default" }, tpls: { inputWrapper: '
    {symbol}{input}{options}
    ', symbol: '
    {trigger}{options}
    ', trigger: '{content}' // options: '
      {content}
    ', }, optionsTpl: az.createTpl(''), tplData: { wrapper: { css: 'az-currency-field {css}' }, inputWrapper: { style: '', }, symbol: { content: '' }, trigger: { content: '' }, options: { content: '', style: '' } }, events: { handle: { 'click:{$class}-{cid}-currency-trigger': '_toggleOptions', // 'blur:{$class}-{cid}-currency-trigger': '_toggleOptions', // 'mousedown:@{$class}-{cid}-currency-option-\\d': 'optionClick' }, custom: ['currencychange', 'load'], }, _formatCurrency: function(currencyData){ if(!currencyData) return ''; return this.currencyDisplayMode=='both'? currencyData.code + ' '+ currencyData.symbol : currencyData[this.currencyDisplayMode]; }, _fetchData:function(calback){ var me = this, fieldsToBeFetched = [], fields = this.lookupConfig.fields; for (var i = 0; i < fields.length; i++) { fieldsToBeFetched.push(fields[i].FieldId); } Lookup.GetLookupData(this.lookupConfig.lookupId, fieldsToBeFetched, 0, 100, '', '', JSON.stringify([]), function (result) { if (result.error) { alert(result.error.message); if(calback)calback(undefined); } else { if(result.rows.length == 0) return; var data= []; var name= 'f_' + me.lookupConfig.fields[0].FieldId; var code= 'f_' + me.lookupConfig.fields[1].FieldId; var symbol='f_' + me.lookupConfig.fields[2].FieldId; for(var i=0; i-1 && !this.lookupConfig.fetched && visible){ var me = this; this.setDisabled(true); this.options.showLoader(); this._fetchData(function(data){ me.setDisabled(false); if(az.chk.ifArray(data)){ me.lookupConfig.fetched= true; me.setCurrencyData(data); me._resetOptionsPanelHeight(); me._resetPosition(); me.fireEvent('load',data); } }); } }, _resetPosition: function(){ var triggerEl= $(this.dom.trigger); var wrapper= $(this.dom.wrapper); var opsPnlEl= $('#'+ this.options.$class+'-'+this.options.cid+'-currency-options-panel'); var top,left; if((triggerEl.offset().top +22+ opsPnlEl.outerHeight() )>$(window).height()){ left=triggerEl.offset().left; top=triggerEl.offset().top - opsPnlEl.outerHeight() ; } else{ left= triggerEl.offset().left; top=triggerEl.offset().top + 22; } if((triggerEl.offset().left + opsPnlEl.outerWidth() )>$(window).width()){ left=wrapper.offset().left+wrapper.outerWidth() -opsPnlEl.outerWidth(); } this.options.setPosition(left,top); }, _resetOptionsPanelHeight: function(){ var opsPnlEl= $('#'+ this.options.$class+'-'+this.options.cid+'-currency-options-panel'); if(this.currencyData.length>5) opsPnlEl.css({height: 100, 'overflow-y': 'scroll'}); else opsPnlEl.css({height: 'auto', 'overflow-y': 'auto'}); }, onKeyDown: function(control ,event){ if(!this._isCharcterAllowed(event.browserEvent)){ var res= this.getRawValue().replace(event.browserEvent.key, ''); this.setRawValue(res); } this.$super.apply(this, arguments); }, init: function () { this._formatPriceConfig= {digitGroupSymbol :this.thousandSeparator? ',' : '', symbol: '', roundToDecimalPlace: this.decimalPrecision }; this.$super.apply(this, arguments); }, initTplData: function () { this.tplData.options.content= this.optionsTpl(this, { }); this.$super.apply(this, arguments); var me = this; var selectedCurrency= az.find(this.currencyData, function(e){ return e.code==me.currency;}); this.tplData.trigger.content= this._formatCurrency(selectedCurrency); this.setStyle('input', 'width', (this.width - this._getInputBorderPadding()- (this.required? this.getThemeValue('helperSize'): 0 ) - (this.tooltip?this.getThemeValue('helperSize'): 0 ) - this._triggerWidth[this.currencyDisplayMode] ) + 'px'); }, onResize: function () { var inputWidth = this.width; if (this.rendered) { this.setStyle('wrapper', 'width', ((this.hideLabel || this.labelPosition == 'top' ? 0 : this.labelWidth + this.labelGap) + inputWidth) + 'px'); this.setStyle('input', 'width', (this.width - this._getInputBorderPadding()- (this.required? this.getThemeValue('helperSize'): 0 ) -(this.tooltip?this.getThemeValue('helperSize'): 0 ) - this._triggerWidth[this.currencyDisplayMode] ) + 'px'); } }, formatRawValue: function(){ this._formatPriceConfig= {digitGroupSymbol :this.thousandSeparator? ',' : '', symbol: '', roundToDecimalPlace: this.decimalPrecision }; $(this.dom.input).formatCurrency(this._formatPriceConfig); }, serCurrencyReadOnly: function(fixed){ ///serCurrencyReadOnly this.currencyReadOnly=fixed; }, setCurrency: function (currency, notify) { this.oldCurrency= this.currency; this.currency= currency || this.currency; var me = this; var index= az.indexOf(this.currencyData, function(e){ return e.code==me.currency;}); $(this.dom.trigger).text(this._formatCurrency(this.currencyData[index])); // this._resetSelection(index); if(notify) this.fireEvent('currencychange', this.currency, this.oldCurrency, this.currencyData[index]); }, setCurrencyDisplayMode: function(mode){ this.currencyDisplayMode= mode; this.removeCls('symbol', 'az-currency-field-symbol-both'); this.removeCls('symbol', 'az-currency-field-symbol-code'); if( this.currencyDisplayMode!='symbol') this.addCls('symbol', 'az-currency-field-symbol-'+this.currencyDisplayMode ); var me = this; var index= az.indexOf(this.currencyData, function(e){ return e.code==me.currency;}); $(this.dom.trigger).text(this._formatCurrency(this.currencyData[index])); this.onResize(); }, getCurrency: function () { return this.currency; }, getValue: function () { return this.value; }, setCurrencyData: function(data){// setCurrencyData this.currencyData= data; if(this.options){ this.options.setOptions(this.currencyData); this.options.initEvents(); this.options._resetSelection(); } }, setValue: function (value, notify) { var temp= parseFloat(value); value = isNaN(temp)? undefined: temp; this.$super.apply(this, arguments); this.formatRawValue(); }, onChange: function(control, event){ /// todo this.oldValue= this.value; this.value= this.getRawValue().length>0 ?$(this.dom.input).asNumber() : ""; $(this.dom.input).formatCurrency(this._formatPriceConfig); this.fireEvent('change', event, this.value, this.__oldValue); }, validate: function () { if (this.required) { var val= this.getRawValue(); if ((az.chk.ifString(val) && val.length>0 )|| az.chk.ifNumber(val)) { this.clearInvalid(); return true; } else { this.markInvalid(); return false; } } }, _isCharcterAllowed : function(event) {//isCharcterAllowed var legalKeyCode = (!event.shiftKey && !event.ctrlKey && !event.altKey) && (jQuery.inArray(event.keyCode, this._allowedSpecialCharKeyCodes) >= 0 || jQuery.inArray(event.keyCode, this._numberKeyCodes) >= 0 || jQuery.inArray(event.keyCode, this._commaKeyCode) >= 0 || jQuery.inArray(event.keyCode, this._decimalKeyCode) >= 0); return legalKeyCode; }, postRender: function(){ this.$super.apply(this, arguments); this.formatRawValue(); }, destroy: function(){ if(this.options) this.options.destroy(); this.$super.apply(this, arguments); } }); az.defineClass('CurrencyOptions', { $extends: 'Layer', optionsTpl: az.createTpl(''), loadingTpl: az.createTpl(''), setOptions: function(options){ this.options= options; this.setContent (this.optionsTpl(this, { })); }, initTplData: function(){ this.$super.apply(this, arguments); this.setOptions(this.options); }, showLoader: function(){ this.setContent (this.loadingTpl(this, { })); }, events: { handle: { 'click:@{$class}-{cid}-currency-option-\\d': '_optionSelect' }, custom: ['optionselect'], }, _optionSelect: function(control, event){ var index= event.elementId.split('-')[6]; this.oldIndex= this.selectedIndex; this.selectedIndex=index; this.fireEvent('optionselect', this.selectedIndex, this.oldIndex); }, postRender: function(){ this.$super.apply(this, arguments); this._resetSelection(this.selectedIndex); this._initFocusLostFn(); }, show: function () { this.$super.apply(this, arguments); this._resetSelection(this.selectedIndex); this.activate(); this._initFocusLostFn(); }, hide: function () { this.$super.apply(this, arguments); $('body').off('focusin').off('mousedown'); }, _resetSelection: function(index){//_ index=index || this.selectedIndex; $('.az-currency-field-option').removeClass('az-currency-field-options-selected'); var elId= '#'+this.$class + '-'+ this.cid+ '-currency-option-'+index; $(elId).addClass('az-currency-field-options-selected'); }, _initFocusLostFn: function () { var me = this; $('body').on('mousedown', function (e) { if (me.visible) me._hideIfNonRelevantEl(e.target); }); $('body').on('focusin', function (e) { if (me.visible) me._hideIfNonRelevantEl(e.target); }); }, _hideIfNonRelevantEl: function (targerEl) { var _focusinCid = this._findCIDByTargetId($(targerEl)); if (_focusinCid != this.cid && this.owner.dom.trigger.split('#')[1]!=targerEl.id) this.hide(); }, _findCIDByTargetId: function (target) { if (target.hasClass('az-control') || target.hasClass('az-container') || target.hasClass('az-panel') || target.hasClass('az-window')) return 'az-com-' + target.attr('id').split('az-com-')[1]; else return this._findCIDByTargetId(target.parent()); }, _isCIDOfPager: function(cid){ for(var i=0; i < this.pager.items.length; i++) if (this.pager.items[i].cid == cid) return true; return false; } }) /*Form/CustomControls/CardNavigation.js*/ az.defineClass('CardNavigation', { $extends: 'Control', css: 'az-card-navigation az-border', _srcRoot: location.protocol + '//' + location.host + '' + px.appPath, _iconSizeCls: 'az-card-navigation-icon-', _orientationCls: 'az-card-navigation-flow-', _iconAlignCls: 'az-card-navigation-icon-align-', _textAlignCls: 'az-card-navigation-text-align-', _textHiddenCls: 'az-card-navigation-text-hidden', _itemTextWidth: 50, _dimentions: { small: 32, medium: 48, large: 64 }, _itemTextPadding: 4, activeItem: 0, itemGap: 0, backgroundSolid: true, baseIconURL: 'media/images/Icons/', iconSize: 'medium', // 'small/large' flowHorizontally: false, iconAlignRight: false, hideText: false, itemTextAlign: 'center', width: 60, height: 400, border: 1, itemPadding: 5, targetContainer: '', itemWidth: 120, navigations: [{ title: 'Profile', cardIndex: 0, icon: 'profileIcon.png' }, { title: 'Payment', cardIndex: 1, icon: 'paymentIcon.png', disabled: true }, { title: 'Clubs', cardIndex: 2, icon: 'clubIcon.png' }, { title: 'Attachent', cardIndex: 3, icon: 'attachmentIcon.png'}], renderPattern: '@wrapper({content:@items})', tpls: { items: '{content}' }, _itemsTpl: az.createTpl('@for(var i=0; i< global.navigations.length; i++){
    @{$emit(global.navigations[i].title);}
    }'), tplData: { wrapper: { css: '{css} {_iconSizeCls}{iconSize} {_textAlignCls}{itemTextAlign}' }, items: { content: '' } }, events: { handle: { 'click:@{$class}-{cid}-item-\\d': '_onNavItemClick', 'mouseenter:@{$class}-{cid}-item-\\d': '_onNavItemMouseEnterLeave', 'mouseleave:@{$class}-{cid}-item-\\d': '_onNavItemMouseEnterLeave' }, custom: ['select'] }, _onNavItemClick: function (control, event) { this.select(event.elementId.split('-')[5], true); }, _onNavItemMouseEnterLeave: function (event) { var index = event.elementId.split('-')[5]; if (this.activeItem == index) return; if (this.navigations[index].disabled) return; $('#' + this.$class + '-' + this.cid + '-item-' + index.toString())[event.type == 'mouseleave' ? 'removeClass' : 'addClass']('az-card-navigation-item-hover'); }, initTplData: function () { this._itemTextWidth = this._getItemTextWidth(); this.tplData.items.content = this._itemsTpl(this, {}); this.$super.apply(this, arguments); this.setStyle('wrapper', this._getSizeStyle() + ' ' + this._getBorderStyle()); this._orientationCls = this._orientationCls + (this.flowHorizontally ? 'hor' : 'ver'); this._iconAlignCls = this._iconAlignCls + (this.iconAlignRight ? 'right' : 'left'); this.addCls('wrapper', this._iconAlignCls + ' ' + this._orientationCls + (this.hideText ? ' ' + this._textHiddenCls : '')); if (this.backgroundSolid || !this.hasOwnProperty('backgroundSolid') ) this.addCls('wrapper', 'az-card-navigation-bg-solid'); }, onResize: function () { this.setStyle('wrapper', this._getSizeStyle()); this._reRenderItems(); }, validate: function () { return true; }, select: function (index, notify) { if (!this.validate) return; if (this.activeItem == index) return; if (this.navigations[index].disabled) return; var oldIndex = this.activeItem; var navEl = $('#' + this.$class + '-' + this.cid + '-item-' + this.activeItem.toString()); navEl.removeClass('az-card-navigation-item-selected'); navEl.removeClass('az-card-navigation-item-hover'); this.activeItem = index; $('#' + this.$class + '-' + this.cid + '-item-' + this.activeItem.toString()).addClass('az-card-navigation-item-selected'); this.showCard(this.navigations[this.activeItem].cardIndex); if (notify) this.fireEvent('select', this.activeItem, oldIndex); }, setNavigationDisabled: function (index, disabled) { this.navigations[index].disabled = disabled; $('#' + this.$class + '-' + this.cid + '-item-' + index.toString())[disabled ? 'addClass' : 'removeClass']('az-card-navigation-item-disabled'); }, setNavigationVisible: function (index, visible) { this.navigations[index].visible = visible; $('#' + this.$class + '-' + this.cid + '-item-' + index.toString())[visible ? 'show' : 'hide'](); }, setDisabled: function (disabled) { for (var i = 0; i < this.navigations.length; i++) { this.setNavigationDisabled(i, disabled); } }, showCard: function (index) { if (!this.targetContainer) return; var comps = this.$form ? this.$form.shell.ui(this.targetContainer) : az.getCmpByName(this.targetContainer); if (!comps) return; var conttainer = comps[0]; if (conttainer.layout instanceof az.CardLayout) { conttainer.activeItem = index; conttainer.updateLayout(); } }, add: function (navItem, index) { if (az.chk.ifDefined(index)) this.navigations.splice(index, 0, navItem); else this.navigations.push(navItem); this._reRenderItems(); }, remove: function (index) { if (az.chk.ifDefined(index)) this.navigations.splice(index, 1); this._reRenderItems(); }, setBorder: function (border) { if (az.chk.ifString(border)) { var vals = border.split(' '); border = vals.length == 1 ? vals[0] : { top: vals[0] || 0, right: vals[1] || 0, bottom: vals[2] || 0, left: vals[3] || 0 }; } this.border = border; this.setStyle('wrapper', this._getBorderStyle()); this.onResize(); }, _reRenderItems: function () { this._iconSizeCls = 'az-card-navigation-icon-' + this.iconSize; this._orientationCls = 'az-card-navigation-flow-' + (this.flowHorizontally ? 'hor' : 'ver'); this._iconAlignCls = 'az-card-navigation-icon-align-' + (this.iconAlignRight ? 'right' : 'left'); this._textAlignCls = 'az-card-navigation-text-align-' + this.itemTextAlign var extCls = this._iconSizeCls + ' ' + this._orientationCls + ' ' + this._iconAlignCls + ' ' + this._textAlignCls + (this.hideText ? ' ' + this._textHiddenCls : ''); $(this.dom.wrapper).attr('class', 'az-control az-card-navigation az-border ' + extCls); this._itemTextWidth = this._getItemTextWidth(); $(this.dom.wrapper).empty().append(this._itemsTpl(this, {})); if (this.backgroundSolid || !this.hasOwnProperty('backgroundSolid')) this.addCls('wrapper', 'az-card-navigation-bg-solid'); this.initEvents(); }, _getItemTextWidth: function () { return (this.flowHorizontally ? this.itemWidth : (this.width - this.itemPadding * 2 - this._getBorder("left") - this._getBorder("right"))) - this._itemTextPadding * 2 - this._dimentions[this.iconSize]; }, postRender: function () { this.$super.apply(this, arguments); if (this.activeItem > -1) this.showCard(this.navigations[this.activeItem].cardIndex); } }); /*Form/CustomControls/Heading1.js*/ az.defineClass('Heading1', { $extends: 'Control', css: 'az-heading1', title: 'Title', desc: 'Description', coloring: 'forest', // 'green', 'aqua-r', 'aqua-v', 'red', 'orange', 'violet', 'yellow' renderPattern: '@wrapper({ content: @inner({title: @title, desc: @desc}) })', tpls: { inner: '
    {title}{desc}
    ', title: '

    {title}

    ', desc: '@if(global.desc && global.desc.length>0){

    {desc}

    }' }, initTplData: function () { this.$super.apply(this, arguments); this.addCls('wrapper', 'az-heading1-coloring-' + this.coloring) }, setTitle: function (title) { this.title = title; $(this.dom.title).text(title); }, setDesc: function (desc) { this.desc = desc; $(this.dom.desc).text(desc); }, setColoring: function (coloring) { this.removeCls('wrapper', 'az-heading1-coloring-' + this.coloring); this.coloring = coloring; this.addCls('wrapper', 'az-heading1-coloring-' + this.coloring); } }); /*Scripts/libs/Astral/qtip.js*/ /* * qTip2 - Pretty powerful tooltips - v2.2.1 * http://qtip2.com * * Copyright (c) 2014 * Released under the MIT licenses * http://jquery.org/license * * Date: Mon Sep 8 2014 10:07 EDT-0400 * Plugins: tips * Styles: core */ /*global window: false, jQuery: false, console: false, define: false */ /* Cache window, document, undefined */ (function (window, document, undefined) { // Uses AMD or browser globals to create a jQuery plugin. (function (factory) { "use strict"; if (typeof define === 'function' && define.amd) { define(['jquery'], factory); } else if (jQuery && !jQuery.fn.qtip) { factory(jQuery); } } (function ($) { "use strict"; // Enable ECMAScript "strict" operation for this function. See more: http://ejohn.org/blog/ecmascript-5-strict-mode-json-and-more/ ; // Munge the primitives - Paul Irish tip var TRUE = true, FALSE = false, NULL = null, // Common variables X = 'x', Y = 'y', WIDTH = 'width', HEIGHT = 'height', // Positioning sides TOP = 'top', LEFT = 'left', BOTTOM = 'bottom', RIGHT = 'right', CENTER = 'center', // Position adjustment types FLIP = 'flip', FLIPINVERT = 'flipinvert', SHIFT = 'shift', // Shortcut vars QTIP, PROTOTYPE, CORNER, CHECKS, PLUGINS = {}, NAMESPACE = 'qtip', ATTR_HAS = 'data-hasqtip', ATTR_ID = 'data-qtip-id', WIDGET = ['ui-widget', 'ui-tooltip'], SELECTOR = '.' + NAMESPACE, INACTIVE_EVENTS = 'click dblclick mousedown mouseup mousemove mouseleave mouseenter'.split(' '), CLASS_FIXED = NAMESPACE + '-fixed', CLASS_DEFAULT = NAMESPACE + '-default', CLASS_FOCUS = NAMESPACE + '-focus', CLASS_HOVER = NAMESPACE + '-hover', CLASS_DISABLED = NAMESPACE + '-disabled', replaceSuffix = '_replacedByqTip', oldtitle = 'oldtitle', trackingBound, // Browser detection BROWSER = { /* * IE version detection * * Adapted from: http://ajaxian.com/archives/attack-of-the-ie-conditional-comment * Credit to James Padolsey for the original implemntation! */ ie: (function () { for ( var v = 4, i = document.createElement("div"); (i.innerHTML = "") && i.getElementsByTagName("i")[0]; v += 1 ) { } return v > 4 ? v : NaN; } ()), /* * iOS version detection */ iOS: parseFloat( ('' + (/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent) || [0, ''])[1]) .replace('undefined', '3_2').replace('_', '.').replace('_', '') ) || FALSE }; ; function QTip(target, options, id, attr) { // Elements and ID this.id = id; this.target = target; this.tooltip = NULL; this.elements = { target: target }; // Internal constructs this._id = NAMESPACE + '-' + id; this.timers = { img: {} }; this.options = options; this.plugins = {}; // Cache object this.cache = { event: {}, target: $(), disabled: FALSE, attr: attr, onTooltip: FALSE, lastClass: '' }; // Set the initial flags this.rendered = this.destroyed = this.disabled = this.waiting = this.hiddenDuringWait = this.positioning = this.triggering = FALSE; } PROTOTYPE = QTip.prototype; PROTOTYPE._when = function (deferreds) { return $.when.apply($, deferreds); }; PROTOTYPE.render = function (show) { if (this.rendered || this.destroyed) { return this; } // If tooltip has already been rendered, exit var self = this, options = this.options, cache = this.cache, elements = this.elements, text = options.content.text, title = options.content.title, button = options.content.button, posOptions = options.position, namespace = '.' + this._id + ' ', deferreds = [], tooltip; // Add ARIA attributes to target $.attr(this.target[0], 'aria-describedby', this._id); // Create public position object that tracks current position corners cache.posClass = this._createPosClass( (this.position = { my: posOptions.my, at: posOptions.at }).my ); // Create tooltip element this.tooltip = elements.tooltip = tooltip = $('
    ', { 'id': this._id, 'class': [NAMESPACE, CLASS_DEFAULT, options.style.classes, cache.posClass].join(' '), 'width': options.style.width || '', 'height': options.style.height || '', 'tracking': posOptions.target === 'mouse' && posOptions.adjust.mouse, /* ARIA specific attributes */ 'role': 'alert', 'aria-live': 'polite', 'aria-atomic': FALSE, 'aria-describedby': this._id + '-content', 'aria-hidden': TRUE }) .toggleClass(CLASS_DISABLED, this.disabled) .attr(ATTR_ID, this.id) .data(NAMESPACE, this) .appendTo(posOptions.container) .append( // Create content element elements.content = $('
    ', { 'class': NAMESPACE + '-content', 'id': this._id + '-content', 'aria-atomic': TRUE }) ); // Set rendered flag and prevent redundant reposition calls for now this.rendered = -1; this.positioning = TRUE; // Create title... if (title) { this._createTitle(); // Update title only if its not a callback (called in toggle if so) if (!$.isFunction(title)) { deferreds.push(this._updateTitle(title, FALSE)); } } // Create button if (button) { this._createButton(); } // Set proper rendered flag and update content if not a callback function (called in toggle) if (!$.isFunction(text)) { deferreds.push(this._updateContent(text, FALSE)); } this.rendered = TRUE; // Setup widget classes this._setWidget(); // Initialize 'render' plugins $.each(PLUGINS, function (name) { var instance; if (this.initialize === 'render' && (instance = this(self))) { self.plugins[name] = instance; } }); // Unassign initial events and assign proper events this._unassignEvents(); this._assignEvents(); // When deferreds have completed this._when(deferreds).then(function () { // tooltiprender event self._trigger('render'); // Reset flags self.positioning = FALSE; // Show tooltip if not hidden during wait period if (!self.hiddenDuringWait && (options.show.ready || show)) { self.toggle(TRUE, cache.event, FALSE); } self.hiddenDuringWait = FALSE; }); // Expose API QTIP.api[this.id] = this; return this; }; PROTOTYPE.destroy = function (immediate) { // Set flag the signify destroy is taking place to plugins // and ensure it only gets destroyed once! if (this.destroyed) { return this.target; } function process() { if (this.destroyed) { return; } this.destroyed = TRUE; var target = this.target, title = target.attr(oldtitle), timer; // Destroy tooltip if rendered if (this.rendered) { this.tooltip.stop(1, 0).find('*').remove().end().remove(); } // Destroy all plugins $.each(this.plugins, function (name) { this.destroy && this.destroy(); }); // Clear timers for (timer in this.timers) { clearTimeout(this.timers[timer]); } // Remove api object and ARIA attributes target.removeData(NAMESPACE) .removeAttr(ATTR_ID) .removeAttr(ATTR_HAS) .removeAttr('aria-describedby'); // Reset old title attribute if removed if (this.options.suppress && title) { target.attr('title', title).removeAttr(oldtitle); } // Remove qTip events associated with this API this._unassignEvents(); // Remove ID from used id objects, and delete object references // for better garbage collection and leak protection this.options = this.elements = this.cache = this.timers = this.plugins = this.mouse = NULL; // Delete epoxsed API object delete QTIP.api[this.id]; } // If an immediate destory is needed if ((immediate !== TRUE || this.triggering === 'hide') && this.rendered) { this.tooltip.one('tooltiphidden', $.proxy(process, this)); !this.triggering && this.hide(); } // If we're not in the process of hiding... process else { process.call(this); } return this.target; }; ; function invalidOpt(a) { return a === NULL || $.type(a) !== 'object'; } function invalidContent(c) { return !($.isFunction(c) || (c && c.attr) || c.length || ($.type(c) === 'object' && (c.jquery || c.then))); } // Option object sanitizer function sanitizeOptions(opts) { var content, text, ajax, once; if (invalidOpt(opts)) { return FALSE; } if (invalidOpt(opts.metadata)) { opts.metadata = { type: opts.metadata }; } if ('content' in opts) { content = opts.content; if (invalidOpt(content) || content.jquery || content.done) { content = opts.content = { text: (text = invalidContent(content) ? FALSE : content) }; } else { text = content.text; } // DEPRECATED - Old content.ajax plugin functionality // Converts it into the proper Deferred syntax if ('ajax' in content) { ajax = content.ajax; once = ajax && ajax.once !== FALSE; delete content.ajax; content.text = function (event, api) { var loading = text || $(this).attr(api.options.content.attr) || 'Loading...', deferred = $.ajax( $.extend({}, ajax, { context: api }) ) .then(ajax.success, NULL, ajax.error) .then(function (content) { if (content && once) { api.set('content.text', content); } return content; }, function (xhr, status, error) { if (api.destroyed || xhr.status === 0) { return; } api.set('content.text', status + ': ' + error); }); return !once ? (api.set('content.text', loading), deferred) : loading; }; } if ('title' in content) { if ($.isPlainObject(content.title)) { content.button = content.title.button; content.title = content.title.text; } if (invalidContent(content.title || FALSE)) { content.title = FALSE; } } } if ('position' in opts && invalidOpt(opts.position)) { opts.position = { my: opts.position, at: opts.position }; } if ('show' in opts && invalidOpt(opts.show)) { opts.show = opts.show.jquery ? { target: opts.show} : opts.show === TRUE ? { ready: TRUE} : { event: opts.show }; } if ('hide' in opts && invalidOpt(opts.hide)) { opts.hide = opts.hide.jquery ? { target: opts.hide} : { event: opts.hide }; } if ('style' in opts && invalidOpt(opts.style)) { opts.style = { classes: opts.style }; } // Sanitize plugin options $.each(PLUGINS, function () { this.sanitize && this.sanitize(opts); }); return opts; } // Setup builtin .set() option checks CHECKS = PROTOTYPE.checks = { builtin: { // Core checks '^id$': function (obj, o, v, prev) { var id = v === TRUE ? QTIP.nextid : v, new_id = NAMESPACE + '-' + id; if (id !== FALSE && id.length > 0 && !$('#' + new_id).length) { this._id = new_id; if (this.rendered) { this.tooltip[0].id = this._id; this.elements.content[0].id = this._id + '-content'; this.elements.title[0].id = this._id + '-title'; } } else { obj[o] = prev; } }, '^prerender': function (obj, o, v) { v && !this.rendered && this.render(this.options.show.ready); }, // Content checks '^content.text$': function (obj, o, v) { this._updateContent(v); }, '^content.attr$': function (obj, o, v, prev) { if (this.options.content.text === this.target.attr(prev)) { this._updateContent(this.target.attr(v)); } }, '^content.title$': function (obj, o, v) { // Remove title if content is null if (!v) { return this._removeTitle(); } // If title isn't already created, create it now and update v && !this.elements.title && this._createTitle(); this._updateTitle(v); }, '^content.button$': function (obj, o, v) { this._updateButton(v); }, '^content.title.(text|button)$': function (obj, o, v) { this.set('content.' + o, v); // Backwards title.text/button compat }, // Position checks '^position.(my|at)$': function (obj, o, v) { 'string' === typeof v && (this.position[o] = obj[o] = new CORNER(v, o === 'at')); }, '^position.container$': function (obj, o, v) { this.rendered && this.tooltip.appendTo(v); }, // Show checks '^show.ready$': function (obj, o, v) { v && (!this.rendered && this.render(TRUE) || this.toggle(TRUE)); }, // Style checks '^style.classes$': function (obj, o, v, p) { this.rendered && this.tooltip.removeClass(p).addClass(v); }, '^style.(width|height)': function (obj, o, v) { this.rendered && this.tooltip.css(o, v); }, '^style.widget|content.title': function () { this.rendered && this._setWidget(); }, '^style.def': function (obj, o, v) { this.rendered && this.tooltip.toggleClass(CLASS_DEFAULT, !!v); }, // Events check '^events.(render|show|move|hide|focus|blur)$': function (obj, o, v) { this.rendered && this.tooltip[($.isFunction(v) ? '' : 'un') + 'bind']('tooltip' + o, v); }, // Properties which require event reassignment '^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)': function () { if (!this.rendered) { return; } // Set tracking flag var posOptions = this.options.position; this.tooltip.attr('tracking', posOptions.target === 'mouse' && posOptions.adjust.mouse); // Reassign events this._unassignEvents(); this._assignEvents(); } } }; // Dot notation converter function convertNotation(options, notation) { var i = 0, obj, option = options, // Split notation into array levels = notation.split('.'); // Loop through while (option = option[levels[i++]]) { if (i < levels.length) { obj = option; } } return [obj || options, levels.pop()]; } PROTOTYPE.get = function (notation) { if (this.destroyed) { return this; } var o = convertNotation(this.options, notation.toLowerCase()), result = o[0][o[1]]; return result.precedance ? result.string() : result; }; function setCallback(notation, args) { var category, rule, match; for (category in this.checks) { for (rule in this.checks[category]) { if (match = (new RegExp(rule, 'i')).exec(notation)) { args.push(match); if (category === 'builtin' || this.plugins[category]) { this.checks[category][rule].apply( this.plugins[category] || this, args ); } } } } } var rmove = /^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i, rrender = /^prerender|show\.ready/i; PROTOTYPE.set = function (option, value) { if (this.destroyed) { return this; } var rendered = this.rendered, reposition = FALSE, options = this.options, checks = this.checks, name; // Convert singular option/value pair into object form if ('string' === typeof option) { name = option; option = {}; option[name] = value; } else { option = $.extend({}, option); } // Set all of the defined options to their new values $.each(option, function (notation, value) { if (rendered && rrender.test(notation)) { delete option[notation]; return; } // Set new obj value var obj = convertNotation(options, notation.toLowerCase()), previous; previous = obj[0][obj[1]]; obj[0][obj[1]] = value && value.nodeType ? $(value) : value; // Also check if we need to reposition reposition = rmove.test(notation) || reposition; // Set the new params for the callback option[notation] = [obj[0], obj[1], value, previous]; }); // Re-sanitize options sanitizeOptions(options); /* * Execute any valid callbacks for the set options * Also set positioning flag so we don't get loads of redundant repositioning calls. */ this.positioning = TRUE; $.each(option, $.proxy(setCallback, this)); this.positioning = FALSE; // Update position if needed if (this.rendered && this.tooltip[0].offsetWidth > 0 && reposition) { this.reposition(options.position.target === 'mouse' ? NULL : this.cache.event); } return this; }; ; PROTOTYPE._update = function (content, element, reposition) { var self = this, cache = this.cache; // Make sure tooltip is rendered and content is defined. If not return if (!this.rendered || !content) { return FALSE; } // Use function to parse content if ($.isFunction(content)) { content = content.call(this.elements.target, cache.event, this) || ''; } // Handle deferred content if ($.isFunction(content.then)) { cache.waiting = TRUE; return content.then(function (c) { cache.waiting = FALSE; return self._update(c, element); }, NULL, function (e) { return self._update(e, element); }); } // If content is null... return false if (content === FALSE || (!content && content !== '')) { return FALSE; } // Append new content if its a DOM array and show it if hidden if (content.jquery && content.length > 0) { element.empty().append( content.css({ display: 'block', visibility: 'visible' }) ); } // Content is a regular string, insert the new content else { element.html(content); } // Wait for content to be loaded, and reposition return this._waitForContent(element).then(function (images) { if (self.rendered && self.tooltip[0].offsetWidth > 0) { self.reposition(cache.event, !images.length); } }); }; PROTOTYPE._waitForContent = function (element) { var cache = this.cache; // Set flag cache.waiting = TRUE; // If imagesLoaded is included, ensure images have loaded and return promise return ($.fn.imagesLoaded ? element.imagesLoaded() : $.Deferred().resolve([])) .done(function () { cache.waiting = FALSE; }) .promise(); }; PROTOTYPE._updateContent = function (content, reposition) { this._update(content, this.elements.content, reposition); }; PROTOTYPE._updateTitle = function (content, reposition) { if (this._update(content, this.elements.title, reposition) === FALSE) { this._removeTitle(FALSE); } }; PROTOTYPE._createTitle = function () { var elements = this.elements, id = this._id + '-title'; // Destroy previous title element, if present if (elements.titlebar) { this._removeTitle(); } // Create title bar and title elements elements.titlebar = $('
    ', { 'class': NAMESPACE + '-titlebar ' + (this.options.style.widget ? createWidgetClass('header') : '') }) .append( elements.title = $('
    ', { 'id': id, 'class': NAMESPACE + '-title', 'aria-atomic': TRUE }) ) .insertBefore(elements.content) // Button-specific events .delegate('.qtip-close', 'mousedown keydown mouseup keyup mouseout', function (event) { $(this).toggleClass('ui-state-active ui-state-focus', event.type.substr(-4) === 'down'); }) .delegate('.qtip-close', 'mouseover mouseout', function (event) { $(this).toggleClass('ui-state-hover', event.type === 'mouseover'); }); // Create button if enabled if (this.options.content.button) { this._createButton(); } }; PROTOTYPE._removeTitle = function (reposition) { var elements = this.elements; if (elements.title) { elements.titlebar.remove(); elements.titlebar = elements.title = elements.button = NULL; // Reposition if enabled if (reposition !== FALSE) { this.reposition(); } } }; ; PROTOTYPE._createPosClass = function (my) { return NAMESPACE + '-pos-' + (my || this.options.position.my).abbrev(); }; PROTOTYPE.reposition = function (event, effect) { if (!this.rendered || this.positioning || this.destroyed) { return this; } // Set positioning flag this.positioning = TRUE; var cache = this.cache, tooltip = this.tooltip, posOptions = this.options.position, target = posOptions.target, my = posOptions.my, at = posOptions.at, viewport = posOptions.viewport, container = posOptions.container, adjust = posOptions.adjust, method = adjust.method.split(' '), tooltipWidth = tooltip.outerWidth(FALSE), tooltipHeight = tooltip.outerHeight(FALSE), targetWidth = 0, targetHeight = 0, type = tooltip.css('position'), position = { left: 0, top: 0 }, visible = tooltip[0].offsetWidth > 0, isScroll = event && event.type === 'scroll', win = $(window), doc = container[0].ownerDocument, mouse = this.mouse, pluginCalculations, offset, adjusted, newClass; // Check if absolute position was passed if ($.isArray(target) && target.length === 2) { // Force left top and set position at = { x: LEFT, y: TOP }; position = { left: target[0], top: target[1] }; } // Check if mouse was the target else if (target === 'mouse') { // Force left top to allow flipping at = { x: LEFT, y: TOP }; // Use the mouse origin that caused the show event, if distance hiding is enabled if ((!adjust.mouse || this.options.hide.distance) && cache.origin && cache.origin.pageX) { event = cache.origin; } // Use cached event for resize/scroll events else if (!event || (event && (event.type === 'resize' || event.type === 'scroll'))) { event = cache.event; } // Otherwise, use the cached mouse coordinates if available else if (mouse && mouse.pageX) { event = mouse; } // Calculate body and container offset and take them into account below if (type !== 'static') { position = container.offset(); } if (doc.body.offsetWidth !== (window.innerWidth || doc.documentElement.clientWidth)) { offset = $(document.body).offset(); } // Use event coordinates for position position = { left: event.pageX - position.left + (offset && offset.left || 0), top: event.pageY - position.top + (offset && offset.top || 0) }; // Scroll events are a pain, some browsers if (adjust.mouse && isScroll && mouse) { position.left -= (mouse.scrollX || 0) - win.scrollLeft(); position.top -= (mouse.scrollY || 0) - win.scrollTop(); } } // Target wasn't mouse or absolute... else { // Check if event targetting is being used if (target === 'event') { if (event && event.target && event.type !== 'scroll' && event.type !== 'resize') { cache.target = $(event.target); } else if (!event.target) { cache.target = this.elements.target; } } else if (target !== 'event') { cache.target = $(target.jquery ? target : this.elements.target); } target = cache.target; // Parse the target into a jQuery object and make sure there's an element present target = $(target).eq(0); if (target.length === 0) { return this; } // Check if window or document is the target else if (target[0] === document || target[0] === window) { targetWidth = BROWSER.iOS ? window.innerWidth : target.width(); targetHeight = BROWSER.iOS ? window.innerHeight : target.height(); if (target[0] === window) { position = { top: (viewport || target).scrollTop(), left: (viewport || target).scrollLeft() }; } } // Check if the target is an element else if (PLUGINS.imagemap && target.is('area')) { pluginCalculations = PLUGINS.imagemap(this, target, at, PLUGINS.viewport ? method : FALSE); } // Check if the target is an SVG element else if (PLUGINS.svg && target && target[0].ownerSVGElement) { pluginCalculations = PLUGINS.svg(this, target, at, PLUGINS.viewport ? method : FALSE); } // Otherwise use regular jQuery methods else { targetWidth = target.outerWidth(FALSE); targetHeight = target.outerHeight(FALSE); position = target.offset(); } // Parse returned plugin values into proper variables if (pluginCalculations) { targetWidth = pluginCalculations.width; targetHeight = pluginCalculations.height; offset = pluginCalculations.offset; position = pluginCalculations.position; } // Adjust position to take into account offset parents position = this.reposition.offset(target, position, container); // Adjust for position.fixed tooltips (and also iOS scroll bug in v3.2-4.0 & v4.3-4.3.2) if ((BROWSER.iOS > 3.1 && BROWSER.iOS < 4.1) || (BROWSER.iOS >= 4.3 && BROWSER.iOS < 4.33) || (!BROWSER.iOS && type === 'fixed') ) { position.left -= win.scrollLeft(); position.top -= win.scrollTop(); } // Adjust position relative to target if (!pluginCalculations || (pluginCalculations && pluginCalculations.adjustable !== FALSE)) { position.left += at.x === RIGHT ? targetWidth : at.x === CENTER ? targetWidth / 2 : 0; position.top += at.y === BOTTOM ? targetHeight : at.y === CENTER ? targetHeight / 2 : 0; } } // Adjust position relative to tooltip position.left += adjust.x + (my.x === RIGHT ? -tooltipWidth : my.x === CENTER ? -tooltipWidth / 2 : 0); position.top += adjust.y + (my.y === BOTTOM ? -tooltipHeight : my.y === CENTER ? -tooltipHeight / 2 : 0); // Use viewport adjustment plugin if enabled if (PLUGINS.viewport) { adjusted = position.adjusted = PLUGINS.viewport( this, position, posOptions, targetWidth, targetHeight, tooltipWidth, tooltipHeight ); // Apply offsets supplied by positioning plugin (if used) if (offset && adjusted.left) { position.left += offset.left; } if (offset && adjusted.top) { position.top += offset.top; } // Apply any new 'my' position if (adjusted.my) { this.position.my = adjusted.my; } } // Viewport adjustment is disabled, set values to zero else { position.adjusted = { left: 0, top: 0 }; } // Set tooltip position class if it's changed if (cache.posClass !== (newClass = this._createPosClass(this.position.my))) { tooltip.removeClass(cache.posClass).addClass((cache.posClass = newClass)); } // tooltipmove event if (!this._trigger('move', [position, viewport.elem || viewport], event)) { return this; } delete position.adjusted; // If effect is disabled, target it mouse, no animation is defined or positioning gives NaN out, set CSS directly if (effect === FALSE || !visible || isNaN(position.left) || isNaN(position.top) || target === 'mouse' || !$.isFunction(posOptions.effect)) { tooltip.css(position); } // Use custom function if provided else if ($.isFunction(posOptions.effect)) { posOptions.effect.call(tooltip, this, $.extend({}, position)); tooltip.queue(function (next) { // Reset attributes to avoid cross-browser rendering bugs $(this).css({ opacity: '', height: '' }); if (BROWSER.ie) { this.style.removeAttribute('filter'); } next(); }); } // Set positioning flag this.positioning = FALSE; return this; }; // Custom (more correct for qTip!) offset calculator PROTOTYPE.reposition.offset = function (elem, pos, container) { if (!container[0]) { return pos; } var ownerDocument = $(elem[0].ownerDocument), quirks = !!BROWSER.ie && document.compatMode !== 'CSS1Compat', parent = container[0], scrolled, position, parentOffset, overflow; function scroll(e, i) { pos.left += i * e.scrollLeft(); pos.top += i * e.scrollTop(); } // Compensate for non-static containers offset do { if ((position = $.css(parent, 'position')) !== 'static') { if (position === 'fixed') { parentOffset = parent.getBoundingClientRect(); scroll(ownerDocument, -1); } else { parentOffset = $(parent).position(); parentOffset.left += (parseFloat($.css(parent, 'borderLeftWidth')) || 0); parentOffset.top += (parseFloat($.css(parent, 'borderTopWidth')) || 0); } pos.left -= parentOffset.left + (parseFloat($.css(parent, 'marginLeft')) || 0); pos.top -= parentOffset.top + (parseFloat($.css(parent, 'marginTop')) || 0); // If this is the first parent element with an overflow of "scroll" or "auto", store it if (!scrolled && (overflow = $.css(parent, 'overflow')) !== 'hidden' && overflow !== 'visible') { scrolled = $(parent); } } } while ((parent = parent.offsetParent)); // Compensate for containers scroll if it also has an offsetParent (or in IE quirks mode) if (scrolled && (scrolled[0] !== ownerDocument[0] || quirks)) { scroll(scrolled, 1); } return pos; }; // Corner class var C = (CORNER = PROTOTYPE.reposition.Corner = function (corner, forceY) { corner = ('' + corner).replace(/([A-Z])/, ' $1').replace(/middle/gi, CENTER).toLowerCase(); this.x = (corner.match(/left|right/i) || corner.match(/center/) || ['inherit'])[0].toLowerCase(); this.y = (corner.match(/top|bottom|center/i) || ['inherit'])[0].toLowerCase(); this.forceY = !!forceY; var f = corner.charAt(0); this.precedance = (f === 't' || f === 'b' ? Y : X); }).prototype; C.invert = function (z, center) { this[z] = this[z] === LEFT ? RIGHT : this[z] === RIGHT ? LEFT : center || this[z]; }; C.string = function (join) { var x = this.x, y = this.y; var result = x !== y ? (x === 'center' || y !== 'center' && (this.precedance === Y || this.forceY) ? [y, x] : [x, y] ) : [x]; return join !== false ? result.join(' ') : result; }; C.abbrev = function () { var result = this.string(false); return result[0].charAt(0) + (result[1] && result[1].charAt(0) || ''); }; C.clone = function () { return new CORNER(this.string(), this.forceY); }; ; PROTOTYPE.toggle = function (state, event) { var cache = this.cache, options = this.options, tooltip = this.tooltip; // Try to prevent flickering when tooltip overlaps show element if (event) { if ((/over|enter/).test(event.type) && cache.event && (/out|leave/).test(cache.event.type) && options.show.target.add(event.target).length === options.show.target.length && tooltip.has(event.relatedTarget).length) { return this; } // Cache event cache.event = $.event.fix(event); } // If we're currently waiting and we've just hidden... stop it this.waiting && !state && (this.hiddenDuringWait = TRUE); // Render the tooltip if showing and it isn't already if (!this.rendered) { return state ? this.render(1) : this; } else if (this.destroyed || this.disabled) { return this; } var type = state ? 'show' : 'hide', opts = this.options[type], otherOpts = this.options[!state ? 'show' : 'hide'], posOptions = this.options.position, contentOptions = this.options.content, width = this.tooltip.css('width'), visible = this.tooltip.is(':visible'), animate = state || opts.target.length === 1, sameTarget = !event || opts.target.length < 2 || cache.target[0] === event.target, identicalState, allow, showEvent, delay, after; // Detect state if valid one isn't provided if ((typeof state).search('boolean|number')) { state = !visible; } // Check if the tooltip is in an identical state to the new would-be state identicalState = !tooltip.is(':animated') && visible === state && sameTarget; // Fire tooltip(show/hide) event and check if destroyed allow = !identicalState ? !!this._trigger(type, [90]) : NULL; // Check to make sure the tooltip wasn't destroyed in the callback if (this.destroyed) { return this; } // If the user didn't stop the method prematurely and we're showing the tooltip, focus it if (allow !== FALSE && state) { this.focus(event); } // If the state hasn't changed or the user stopped it, return early if (!allow || identicalState) { return this; } // Set ARIA hidden attribute $.attr(tooltip[0], 'aria-hidden', !!!state); // Execute state specific properties if (state) { // Store show origin coordinates this.mouse && (cache.origin = $.event.fix(this.mouse)); // Update tooltip content & title if it's a dynamic function if ($.isFunction(contentOptions.text)) { this._updateContent(contentOptions.text, FALSE); } if ($.isFunction(contentOptions.title)) { this._updateTitle(contentOptions.title, FALSE); } // Cache mousemove events for positioning purposes (if not already tracking) if (!trackingBound && posOptions.target === 'mouse' && posOptions.adjust.mouse) { $(document).bind('mousemove.' + NAMESPACE, this._storeMouse); trackingBound = TRUE; } // Update the tooltip position (set width first to prevent viewport/max-width issues) if (!width) { tooltip.css('width', tooltip.outerWidth(FALSE)); } this.reposition(event, arguments[2]); if (!width) { tooltip.css('width', ''); } // Hide other tooltips if tooltip is solo if (!!opts.solo) { (typeof opts.solo === 'string' ? $(opts.solo) : $(SELECTOR, opts.solo)) .not(tooltip).not(opts.target).qtip('hide', $.Event('tooltipsolo')); } } else { // Clear show timer if we're hiding clearTimeout(this.timers.show); // Remove cached origin on hide delete cache.origin; // Remove mouse tracking event if not needed (all tracking qTips are hidden) if (trackingBound && !$(SELECTOR + '[tracking="true"]:visible', opts.solo).not(tooltip).length) { $(document).unbind('mousemove.' + NAMESPACE); trackingBound = FALSE; } // Blur the tooltip this.blur(event); } // Define post-animation, state specific properties after = $.proxy(function () { if (state) { // Prevent antialias from disappearing in IE by removing filter if (BROWSER.ie) { tooltip[0].style.removeAttribute('filter'); } // Remove overflow setting to prevent tip bugs tooltip.css('overflow', ''); // Autofocus elements if enabled if ('string' === typeof opts.autofocus) { $(this.options.show.autofocus, tooltip).focus(); } // If set, hide tooltip when inactive for delay period this.options.show.target.trigger('qtip-' + this.id + '-inactive'); } else { // Reset CSS states tooltip.css({ display: '', visibility: '', opacity: '', left: '', top: '' }); } // tooltipvisible/tooltiphidden events this._trigger(state ? 'visible' : 'hidden'); }, this); // If no effect type is supplied, use a simple toggle if (opts.effect === FALSE || animate === FALSE) { tooltip[type](); after(); } // Use custom function if provided else if ($.isFunction(opts.effect)) { tooltip.stop(1, 1); opts.effect.call(tooltip, this); tooltip.queue('fx', function (n) { after(); n(); }); } // Use basic fade function by default else { tooltip.fadeTo(90, state ? 1 : 0, after); } // If inactive hide method is set, active it if (state) { opts.target.trigger('qtip-' + this.id + '-inactive'); } return this; }; PROTOTYPE.show = function (event) { return this.toggle(TRUE, event); }; PROTOTYPE.hide = function (event) { return this.toggle(FALSE, event); }; ; PROTOTYPE.focus = function (event) { if (!this.rendered || this.destroyed) { return this; } var qtips = $(SELECTOR), tooltip = this.tooltip, curIndex = parseInt(tooltip[0].style.zIndex, 10), newIndex = QTIP.zindex + qtips.length, focusedElem; // Only update the z-index if it has changed and tooltip is not already focused if (!tooltip.hasClass(CLASS_FOCUS)) { // tooltipfocus event if (this._trigger('focus', [newIndex], event)) { // Only update z-index's if they've changed if (curIndex !== newIndex) { // Reduce our z-index's and keep them properly ordered qtips.each(function () { if (this.style.zIndex > curIndex) { this.style.zIndex = this.style.zIndex - 1; } }); // Fire blur event for focused tooltip qtips.filter('.' + CLASS_FOCUS).qtip('blur', event); } // Set the new z-index tooltip.addClass(CLASS_FOCUS)[0].style.zIndex = newIndex; } } return this; }; PROTOTYPE.blur = function (event) { if (!this.rendered || this.destroyed) { return this; } // Set focused status to FALSE this.tooltip.removeClass(CLASS_FOCUS); // tooltipblur event this._trigger('blur', [this.tooltip.css('zIndex')], event); return this; }; ; PROTOTYPE.disable = function (state) { if (this.destroyed) { return this; } // If 'toggle' is passed, toggle the current state if (state === 'toggle') { state = !(this.rendered ? this.tooltip.hasClass(CLASS_DISABLED) : this.disabled); } // Disable if no state passed else if ('boolean' !== typeof state) { state = TRUE; } if (this.rendered) { this.tooltip.toggleClass(CLASS_DISABLED, state) .attr('aria-disabled', state); } this.disabled = !!state; return this; }; PROTOTYPE.enable = function () { return this.disable(FALSE); }; ; PROTOTYPE._createButton = function () { var self = this, elements = this.elements, tooltip = elements.tooltip, button = this.options.content.button, isString = typeof button === 'string', close = isString ? button : 'Close tooltip'; if (elements.button) { elements.button.remove(); } // Use custom button if one was supplied by user, else use default if (button.jquery) { elements.button = button; } else { elements.button = $('', { 'class': 'qtip-close ' + (this.options.style.widget ? '' : NAMESPACE + '-icon'), 'title': close, 'aria-label': close }) .prepend( $('', { 'class': 'ui-icon ui-icon-close', 'html': '×' }) ); } // Create button and setup attributes elements.button.appendTo(elements.titlebar || tooltip) .attr('role', 'button') .click(function (event) { if (!tooltip.hasClass(CLASS_DISABLED)) { self.hide(event); } return FALSE; }); }; PROTOTYPE._updateButton = function (button) { // Make sure tooltip is rendered and if not, return if (!this.rendered) { return FALSE; } var elem = this.elements.button; if (button) { this._createButton(); } else { elem.remove(); } }; ; // Widget class creator function createWidgetClass(cls) { return WIDGET.concat('').join(cls ? '-' + cls + ' ' : ' '); } // Widget class setter method PROTOTYPE._setWidget = function () { var on = this.options.style.widget, elements = this.elements, tooltip = elements.tooltip, disabled = tooltip.hasClass(CLASS_DISABLED); tooltip.removeClass(CLASS_DISABLED); CLASS_DISABLED = on ? 'ui-state-disabled' : 'qtip-disabled'; tooltip.toggleClass(CLASS_DISABLED, disabled); tooltip.toggleClass('ui-helper-reset ' + createWidgetClass(), on).toggleClass(CLASS_DEFAULT, this.options.style.def && !on); if (elements.content) { elements.content.toggleClass(createWidgetClass('content'), on); } if (elements.titlebar) { elements.titlebar.toggleClass(createWidgetClass('header'), on); } if (elements.button) { elements.button.toggleClass(NAMESPACE + '-icon', !on); } }; ; function delay(callback, duration) { // If tooltip has displayed, start hide timer if (duration > 0) { return setTimeout( $.proxy(callback, this), duration ); } else { callback.call(this); } } function showMethod(event) { if (this.tooltip.hasClass(CLASS_DISABLED)) { return; } // Clear hide timers clearTimeout(this.timers.show); clearTimeout(this.timers.hide); // Start show timer this.timers.show = delay.call(this, function () { this.toggle(TRUE, event); }, this.options.show.delay ); } function hideMethod(event) { if (this.tooltip.hasClass(CLASS_DISABLED) || this.destroyed) { return; } // Check if new target was actually the tooltip element var relatedTarget = $(event.relatedTarget), ontoTooltip = relatedTarget.closest(SELECTOR)[0] === this.tooltip[0], ontoTarget = relatedTarget[0] === this.options.show.target[0]; // Clear timers and stop animation queue clearTimeout(this.timers.show); clearTimeout(this.timers.hide); // Prevent hiding if tooltip is fixed and event target is the tooltip. // Or if mouse positioning is enabled and cursor momentarily overlaps if (this !== relatedTarget[0] && (this.options.position.target === 'mouse' && ontoTooltip) || (this.options.hide.fixed && ( (/mouse(out|leave|move)/).test(event.type) && (ontoTooltip || ontoTarget)) )) { try { event.preventDefault(); event.stopImmediatePropagation(); } catch (e) { } return; } // If tooltip has displayed, start hide timer this.timers.hide = delay.call(this, function () { this.toggle(FALSE, event); }, this.options.hide.delay, this ); } function inactiveMethod(event) { if (this.tooltip.hasClass(CLASS_DISABLED) || !this.options.hide.inactive) { return; } // Clear timer clearTimeout(this.timers.inactive); this.timers.inactive = delay.call(this, function () { this.hide(event); }, this.options.hide.inactive ); } function repositionMethod(event) { if (this.rendered && this.tooltip[0].offsetWidth > 0) { this.reposition(event); } } // Store mouse coordinates PROTOTYPE._storeMouse = function (event) { (this.mouse = $.event.fix(event)).type = 'mousemove'; return this; }; // Bind events PROTOTYPE._bind = function (targets, events, method, suffix, context) { if (!targets || !method || !events.length) { return; } var ns = '.' + this._id + (suffix ? '-' + suffix : ''); $(targets).bind( (events.split ? events : events.join(ns + ' ')) + ns, $.proxy(method, context || this) ); return this; }; PROTOTYPE._unbind = function (targets, suffix) { targets && $(targets).unbind('.' + this._id + (suffix ? '-' + suffix : '')); return this; }; // Global delegation helper function delegate(selector, events, method) { $(document.body).delegate(selector, (events.split ? events : events.join('.' + NAMESPACE + ' ')) + '.' + NAMESPACE, function () { var api = QTIP.api[$.attr(this, ATTR_ID)]; api && !api.disabled && method.apply(api, arguments); } ); } // Event trigger PROTOTYPE._trigger = function (type, args, event) { var callback = $.Event('tooltip' + type); callback.originalEvent = (event && $.extend({}, event)) || this.cache.event || NULL; this.triggering = type; this.tooltip.trigger(callback, [this].concat(args || [])); this.triggering = FALSE; return !callback.isDefaultPrevented(); }; PROTOTYPE._bindEvents = function (showEvents, hideEvents, showTargets, hideTargets, showMethod, hideMethod) { // Get tasrgets that lye within both var similarTargets = showTargets.filter(hideTargets).add(hideTargets.filter(showTargets)), toggleEvents = []; // If hide and show targets are the same... if (similarTargets.length) { // Filter identical show/hide events $.each(hideEvents, function (i, type) { var showIndex = $.inArray(type, showEvents); // Both events are identical, remove from both hide and show events // and append to toggleEvents showIndex > -1 && toggleEvents.push(showEvents.splice(showIndex, 1)[0]); }); // Toggle events are special case of identical show/hide events, which happen in sequence if (toggleEvents.length) { // Bind toggle events to the similar targets this._bind(similarTargets, toggleEvents, function (event) { var state = this.rendered ? this.tooltip[0].offsetWidth > 0 : false; (state ? hideMethod : showMethod).call(this, event); }); // Remove the similar targets from the regular show/hide bindings showTargets = showTargets.not(similarTargets); hideTargets = hideTargets.not(similarTargets); } } // Apply show/hide/toggle events this._bind(showTargets, showEvents, showMethod); this._bind(hideTargets, hideEvents, hideMethod); }; PROTOTYPE._assignInitialEvents = function (event) { var options = this.options, showTarget = options.show.target, hideTarget = options.hide.target, showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [], hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : []; // Catch remove/removeqtip events on target element to destroy redundant tooltips this._bind(this.elements.target, ['remove', 'removeqtip'], function (event) { this.destroy(true); }, 'destroy'); /* * Make sure hoverIntent functions properly by using mouseleave as a hide event if * mouseenter/mouseout is used for show.event, even if it isn't in the users options. */ if (/mouse(over|enter)/i.test(options.show.event) && !/mouse(out|leave)/i.test(options.hide.event)) { hideEvents.push('mouseleave'); } /* * Also make sure initial mouse targetting works correctly by caching mousemove coords * on show targets before the tooltip has rendered. Also set onTarget when triggered to * keep mouse tracking working. */ this._bind(showTarget, 'mousemove', function (event) { this._storeMouse(event); this.cache.onTarget = TRUE; }); // Define hoverIntent function function hoverIntent(event) { // Only continue if tooltip isn't disabled if (this.disabled || this.destroyed) { return FALSE; } // Cache the event data this.cache.event = event && $.event.fix(event); this.cache.target = event && $(event.target); // Start the event sequence clearTimeout(this.timers.show); this.timers.show = delay.call(this, function () { this.render(typeof event === 'object' || options.show.ready); }, options.prerender ? 0 : options.show.delay ); } // Filter and bind events this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, hoverIntent, function () { if (!this.timers) { return FALSE; } clearTimeout(this.timers.show); }); // Prerendering is enabled, create tooltip now if (options.show.ready || options.prerender) { hoverIntent.call(this, event); } }; // Event assignment method PROTOTYPE._assignEvents = function () { var self = this, options = this.options, posOptions = options.position, tooltip = this.tooltip, showTarget = options.show.target, hideTarget = options.hide.target, containerTarget = posOptions.container, viewportTarget = posOptions.viewport, documentTarget = $(document), bodyTarget = $(document.body), windowTarget = $(window), showEvents = options.show.event ? $.trim('' + options.show.event).split(' ') : [], hideEvents = options.hide.event ? $.trim('' + options.hide.event).split(' ') : []; // Assign passed event callbacks $.each(options.events, function (name, callback) { self._bind(tooltip, name === 'toggle' ? ['tooltipshow', 'tooltiphide'] : ['tooltip' + name], callback, null, tooltip); }); // Hide tooltips when leaving current window/frame (but not select/option elements) if (/mouse(out|leave)/i.test(options.hide.event) && options.hide.leave === 'window') { this._bind(documentTarget, ['mouseout', 'blur'], function (event) { if (!/select|option/.test(event.target.nodeName) && !event.relatedTarget) { this.hide(event); } }); } // Enable hide.fixed by adding appropriate class if (options.hide.fixed) { hideTarget = hideTarget.add(tooltip.addClass(CLASS_FIXED)); } /* * Make sure hoverIntent functions properly by using mouseleave to clear show timer if * mouseenter/mouseout is used for show.event, even if it isn't in the users options. */ else if (/mouse(over|enter)/i.test(options.show.event)) { this._bind(hideTarget, 'mouseleave', function () { clearTimeout(this.timers.show); }); } // Hide tooltip on document mousedown if unfocus events are enabled if (('' + options.hide.event).indexOf('unfocus') > -1) { this._bind(containerTarget.closest('html'), ['mousedown', 'touchstart'], function (event) { var elem = $(event.target), enabled = this.rendered && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0, isAncestor = elem.parents(SELECTOR).filter(this.tooltip[0]).length > 0; if (elem[0] !== this.target[0] && elem[0] !== this.tooltip[0] && !isAncestor && !this.target.has(elem[0]).length && enabled ) { this.hide(event); } }); } // Check if the tooltip hides when inactive if ('number' === typeof options.hide.inactive) { // Bind inactive method to show target(s) as a custom event this._bind(showTarget, 'qtip-' + this.id + '-inactive', inactiveMethod, 'inactive'); // Define events which reset the 'inactive' event handler this._bind(hideTarget.add(tooltip), QTIP.inactiveEvents, inactiveMethod); } // Filter and bind events this._bindEvents(showEvents, hideEvents, showTarget, hideTarget, showMethod, hideMethod); // Mouse movement bindings this._bind(showTarget.add(tooltip), 'mousemove', function (event) { // Check if the tooltip hides when mouse is moved a certain distance if ('number' === typeof options.hide.distance) { var origin = this.cache.origin || {}, limit = this.options.hide.distance, abs = Math.abs; // Check if the movement has gone beyond the limit, and hide it if so if (abs(event.pageX - origin.pageX) >= limit || abs(event.pageY - origin.pageY) >= limit) { this.hide(event); } } // Cache mousemove coords on show targets this._storeMouse(event); }); // Mouse positioning events if (posOptions.target === 'mouse') { // If mouse adjustment is on... if (posOptions.adjust.mouse) { // Apply a mouseleave event so we don't get problems with overlapping if (options.hide.event) { // Track if we're on the target or not this._bind(showTarget, ['mouseenter', 'mouseleave'], function (event) { if (!this.cache) { return FALSE; } this.cache.onTarget = event.type === 'mouseenter'; }); } // Update tooltip position on mousemove this._bind(documentTarget, 'mousemove', function (event) { // Update the tooltip position only if the tooltip is visible and adjustment is enabled if (this.rendered && this.cache.onTarget && !this.tooltip.hasClass(CLASS_DISABLED) && this.tooltip[0].offsetWidth > 0) { this.reposition(event); } }); } } // Adjust positions of the tooltip on window resize if enabled if (posOptions.adjust.resize || viewportTarget.length) { this._bind($.event.special.resize ? viewportTarget : windowTarget, 'resize', repositionMethod); } // Adjust tooltip position on scroll of the window or viewport element if present if (posOptions.adjust.scroll) { this._bind(windowTarget.add(posOptions.container), 'scroll', repositionMethod); } }; // Un-assignment method PROTOTYPE._unassignEvents = function () { var options = this.options, showTargets = options.show.target, hideTargets = options.hide.target, targets = $.grep([ this.elements.target[0], this.rendered && this.tooltip[0], options.position.container[0], options.position.viewport[0], options.position.container.closest('html')[0], // unfocus window, document ], function (i) { return typeof i === 'object'; }); // Add show and hide targets if they're valid if (showTargets && showTargets.toArray) { targets = targets.concat(showTargets.toArray()); } if (hideTargets && hideTargets.toArray) { targets = targets.concat(hideTargets.toArray()); } // Unbind the events this._unbind(targets) ._unbind(targets, 'destroy') ._unbind(targets, 'inactive'); }; // Apply common event handlers using delegate (avoids excessive .bind calls!) $(function () { delegate(SELECTOR, ['mouseenter', 'mouseleave'], function (event) { var state = event.type === 'mouseenter', tooltip = $(event.currentTarget), target = $(event.relatedTarget || event.target), options = this.options; // On mouseenter... if (state) { // Focus the tooltip on mouseenter (z-index stacking) this.focus(event); // Clear hide timer on tooltip hover to prevent it from closing tooltip.hasClass(CLASS_FIXED) && !tooltip.hasClass(CLASS_DISABLED) && clearTimeout(this.timers.hide); } // On mouseleave... else { // When mouse tracking is enabled, hide when we leave the tooltip and not onto the show target (if a hide event is set) if (options.position.target === 'mouse' && options.position.adjust.mouse && options.hide.event && options.show.target && !target.closest(options.show.target[0]).length) { this.hide(event); } } // Add hover class tooltip.toggleClass(CLASS_HOVER, state); }); // Define events which reset the 'inactive' event handler delegate('[' + ATTR_ID + ']', INACTIVE_EVENTS, inactiveMethod); }); ; // Initialization method function init(elem, id, opts) { var obj, posOptions, attr, config, title, // Setup element references docBody = $(document.body), // Use document body instead of document element if needed newTarget = elem[0] === document ? docBody : elem, // Grab metadata from element if plugin is present metadata = (elem.metadata) ? elem.metadata(opts.metadata) : NULL, // If metadata type if HTML5, grab 'name' from the object instead, or use the regular data object otherwise metadata5 = opts.metadata.type === 'html5' && metadata ? metadata[opts.metadata.name] : NULL, // Grab data from metadata.name (or data-qtipopts as fallback) using .data() method, html5 = elem.data(opts.metadata.name || 'qtipopts'); // If we don't get an object returned attempt to parse it manualyl without parseJSON try { html5 = typeof html5 === 'string' ? $.parseJSON(html5) : html5; } catch (e) { } // Merge in and sanitize metadata config = $.extend(TRUE, {}, QTIP.defaults, opts, typeof html5 === 'object' ? sanitizeOptions(html5) : NULL, sanitizeOptions(metadata5 || metadata)); // Re-grab our positioning options now we've merged our metadata and set id to passed value posOptions = config.position; config.id = id; // Setup missing content if none is detected if ('boolean' === typeof config.content.text) { attr = elem.attr(config.content.attr); // Grab from supplied attribute if available if (config.content.attr !== FALSE && attr) { config.content.text = attr; } // No valid content was found, abort render else { return FALSE; } } // Setup target options if (!posOptions.container.length) { posOptions.container = docBody; } if (posOptions.target === FALSE) { posOptions.target = newTarget; } if (config.show.target === FALSE) { config.show.target = newTarget; } if (config.show.solo === TRUE) { config.show.solo = posOptions.container.closest('body'); } if (config.hide.target === FALSE) { config.hide.target = newTarget; } if (config.position.viewport === TRUE) { config.position.viewport = posOptions.container; } // Ensure we only use a single container posOptions.container = posOptions.container.eq(0); // Convert position corner values into x and y strings posOptions.at = new CORNER(posOptions.at, TRUE); posOptions.my = new CORNER(posOptions.my); // Destroy previous tooltip if overwrite is enabled, or skip element if not if (elem.data(NAMESPACE)) { if (config.overwrite) { elem.qtip('destroy', true); } else if (config.overwrite === FALSE) { return FALSE; } } // Add has-qtip attribute elem.attr(ATTR_HAS, id); // Remove title attribute and store it if present if (config.suppress && (title = elem.attr('title'))) { // Final attr call fixes event delegatiom and IE default tooltip showing problem elem.removeAttr('title').attr(oldtitle, title).attr('title', ''); } // Initialize the tooltip and add API reference obj = new QTip(elem, config, id, !!attr); elem.data(NAMESPACE, obj); return obj; } // jQuery $.fn extension method QTIP = $.fn.qtip = function (options, notation, newValue) { var command = ('' + options).toLowerCase(), // Parse command returned = NULL, args = $.makeArray(arguments).slice(1), event = args[args.length - 1], opts = this[0] ? $.data(this[0], NAMESPACE) : NULL; // Check for API request if ((!arguments.length && opts) || command === 'api') { return opts; } // Execute API command if present else if ('string' === typeof options) { this.each(function () { var api = $.data(this, NAMESPACE); if (!api) { return TRUE; } // Cache the event if possible if (event && event.timeStamp) { api.cache.event = event; } // Check for specific API commands if (notation && (command === 'option' || command === 'options')) { if (newValue !== undefined || $.isPlainObject(notation)) { api.set(notation, newValue); } else { returned = api.get(notation); return FALSE; } } // Execute API command else if (api[command]) { api[command].apply(api, args); } }); return returned !== NULL ? returned : this; } // No API commands. validate provided options and setup qTips else if ('object' === typeof options || !arguments.length) { // Sanitize options first opts = sanitizeOptions($.extend(TRUE, {}, options)); return this.each(function (i) { var api, id; // Find next available ID, or use custom ID if provided id = $.isArray(opts.id) ? opts.id[i] : opts.id; id = !id || id === FALSE || id.length < 1 || QTIP.api[id] ? QTIP.nextid++ : id; // Initialize the qTip and re-grab newly sanitized options api = init($(this), id, opts); if (api === FALSE) { return TRUE; } else { QTIP.api[id] = api; } // Initialize plugins $.each(PLUGINS, function () { if (this.initialize === 'initialize') { this(api); } }); // Assign initial pre-render events api._assignInitialEvents(event); }); } }; // Expose class $.qtip = QTip; // Populated in render method QTIP.api = {}; ; $.each({ /* Allow other plugins to successfully retrieve the title of an element with a qTip applied */ attr: function (attr, val) { if (this.length) { var self = this[0], title = 'title', api = $.data(self, 'qtip'); if (attr === title && api && 'object' === typeof api && api.options.suppress) { if (arguments.length < 2) { return $.attr(self, oldtitle); } // If qTip is rendered and title was originally used as content, update it if (api && api.options.content.attr === title && api.cache.attr) { api.set('content.text', val); } // Use the regular attr method to set, then cache the result return this.attr(oldtitle, val); } } return $.fn['attr' + replaceSuffix].apply(this, arguments); }, /* Allow clone to correctly retrieve cached title attributes */ clone: function (keepData) { var titles = $([]), title = 'title', // Clone our element using the real clone method elems = $.fn['clone' + replaceSuffix].apply(this, arguments); // Grab all elements with an oldtitle set, and change it to regular title attribute, if keepData is false if (!keepData) { elems.filter('[' + oldtitle + ']').attr('title', function () { return $.attr(this, oldtitle); }) .removeAttr(oldtitle); } return elems; } }, function (name, func) { if (!func || $.fn[name + replaceSuffix]) { return TRUE; } var old = $.fn[name + replaceSuffix] = $.fn[name]; $.fn[name] = function () { return func.apply(this, arguments) || old.apply(this, arguments); }; }); /* Fire off 'removeqtip' handler in $.cleanData if jQuery UI not present (it already does similar). * This snippet is taken directly from jQuery UI source code found here: * http://code.jquery.com/ui/jquery-ui-git.js */ if (!$.ui) { $['cleanData' + replaceSuffix] = $.cleanData; $.cleanData = function (elems) { for (var i = 0, elem; (elem = $(elems[i])).length; i++) { if (elem.attr(ATTR_HAS)) { try { elem.triggerHandler('removeqtip'); } catch (e) { } } } $['cleanData' + replaceSuffix].apply(this, arguments); }; } ; // qTip version QTIP.version = '2.2.1'; // Base ID for all qTips QTIP.nextid = 0; // Inactive events array QTIP.inactiveEvents = INACTIVE_EVENTS; // Base z-index for all qTips QTIP.zindex = 15000; // Define configuration defaults QTIP.defaults = { prerender: FALSE, id: FALSE, overwrite: TRUE, suppress: TRUE, content: { text: TRUE, attr: 'title', title: FALSE, button: FALSE }, position: { my: 'top left', at: 'bottom right', target: FALSE, container: FALSE, viewport: FALSE, adjust: { x: 0, y: 0, mouse: TRUE, scroll: TRUE, resize: TRUE, method: 'flipinvert flipinvert' }, effect: function (api, pos, viewport) { $(this).animate(pos, { duration: 200, queue: FALSE }); } }, show: { target: FALSE, event: 'mouseenter', effect: TRUE, delay: 90, solo: FALSE, ready: FALSE, autofocus: FALSE }, hide: { target: FALSE, event: 'mouseleave', effect: TRUE, delay: 0, fixed: FALSE, inactive: FALSE, leave: 'window', distance: FALSE }, style: { classes: '', widget: FALSE, width: FALSE, height: FALSE, def: TRUE }, events: { render: NULL, move: NULL, show: NULL, hide: NULL, toggle: NULL, visible: NULL, hidden: NULL, focus: NULL, blur: NULL } }; ; var TIP, // .bind()/.on() namespace TIPNS = '.qtip-tip', // Common CSS strings MARGIN = 'margin', BORDER = 'border', COLOR = 'color', BG_COLOR = 'background-color', TRANSPARENT = 'transparent', IMPORTANT = ' !important', // Check if the browser supports elements HASCANVAS = !!document.createElement('canvas').getContext, // Invalid colour values used in parseColours() INVALID = /rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i; // Camel-case method, taken from jQuery source // http://code.jquery.com/jquery-1.8.0.js function camel(s) { return s.charAt(0).toUpperCase() + s.slice(1); } /* * Modified from Modernizr's testPropsAll() * http://modernizr.com/downloads/modernizr-latest.js */ var cssProps = {}, cssPrefixes = ["Webkit", "O", "Moz", "ms"]; function vendorCss(elem, prop) { var ucProp = prop.charAt(0).toUpperCase() + prop.slice(1), props = (prop + ' ' + cssPrefixes.join(ucProp + ' ') + ucProp).split(' '), cur, val, i = 0; // If the property has already been mapped... if (cssProps[prop]) { return elem.css(cssProps[prop]); } while ((cur = props[i++])) { if ((val = elem.css(cur)) !== undefined) { return cssProps[prop] = cur, val; } } } // Parse a given elements CSS property into an int function intCss(elem, prop) { return Math.ceil(parseFloat(vendorCss(elem, prop))); } // VML creation (for IE only) if (!HASCANVAS) { var createVML = function (tag, props, style) { return ''; }; } // Canvas only definitions else { var PIXEL_RATIO = window.devicePixelRatio || 1, BACKING_STORE_RATIO = (function () { var context = document.createElement('canvas').getContext('2d'); return context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || 1; } ()), SCALE = PIXEL_RATIO / BACKING_STORE_RATIO; } function Tip(qtip, options) { this._ns = 'tip'; this.options = options; this.offset = options.offset; this.size = [options.width, options.height]; // Initialize this.init((this.qtip = qtip)); } $.extend(Tip.prototype, { init: function (qtip) { var context, tip; // Create tip element and prepend to the tooltip tip = this.element = qtip.elements.tip = $('
    ', { 'class': NAMESPACE + '-tip' }).prependTo(qtip.tooltip); // Create tip drawing element(s) if (HASCANVAS) { // save() as soon as we create the canvas element so FF2 doesn't bork on our first restore()! context = $('').appendTo(this.element)[0].getContext('2d'); // Setup constant parameters context.lineJoin = 'miter'; context.miterLimit = 100000; context.save(); } else { context = createVML('shape', 'coordorigin="0,0"', 'position:absolute;'); this.element.html(context + context); // Prevent mousing down on the tip since it causes problems with .live() handling in IE due to VML qtip._bind($('*', tip).add(tip), ['click', 'mousedown'], function (event) { event.stopPropagation(); }, this._ns); } // Bind update events qtip._bind(qtip.tooltip, 'tooltipmove', this.reposition, this._ns, this); // Create it this.create(); }, _swapDimensions: function () { this.size[0] = this.options.height; this.size[1] = this.options.width; }, _resetDimensions: function () { this.size[0] = this.options.width; this.size[1] = this.options.height; }, _useTitle: function (corner) { var titlebar = this.qtip.elements.titlebar; return titlebar && ( corner.y === TOP || (corner.y === CENTER && this.element.position().top + (this.size[1] / 2) + this.options.offset < titlebar.outerHeight(TRUE)) ); }, _parseCorner: function (corner) { var my = this.qtip.options.position.my; // Detect corner and mimic properties if (corner === FALSE || my === FALSE) { corner = FALSE; } else if (corner === TRUE) { corner = new CORNER(my.string()); } else if (!corner.string) { corner = new CORNER(corner); corner.fixed = TRUE; } return corner; }, _parseWidth: function (corner, side, use) { var elements = this.qtip.elements, prop = BORDER + camel(side) + 'Width'; return (use ? intCss(use, prop) : ( intCss(elements.content, prop) || intCss(this._useTitle(corner) && elements.titlebar || elements.content, prop) || intCss(elements.tooltip, prop) )) || 0; }, _parseRadius: function (corner) { var elements = this.qtip.elements, prop = BORDER + camel(corner.y) + camel(corner.x) + 'Radius'; return BROWSER.ie < 9 ? 0 : intCss(this._useTitle(corner) && elements.titlebar || elements.content, prop) || intCss(elements.tooltip, prop) || 0; }, _invalidColour: function (elem, prop, compare) { var val = elem.css(prop); return !val || (compare && val === elem.css(compare)) || INVALID.test(val) ? FALSE : val; }, _parseColours: function (corner) { var elements = this.qtip.elements, tip = this.element.css('cssText', ''), borderSide = BORDER + camel(corner[corner.precedance]) + camel(COLOR), colorElem = this._useTitle(corner) && elements.titlebar || elements.content, css = this._invalidColour, color = []; // Attempt to detect the background colour from various elements, left-to-right precedance color[0] = css(tip, BG_COLOR) || css(colorElem, BG_COLOR) || css(elements.content, BG_COLOR) || css(elements.tooltip, BG_COLOR) || tip.css(BG_COLOR); // Attempt to detect the correct border side colour from various elements, left-to-right precedance color[1] = css(tip, borderSide, COLOR) || css(colorElem, borderSide, COLOR) || css(elements.content, borderSide, COLOR) || css(elements.tooltip, borderSide, COLOR) || elements.tooltip.css(borderSide); // Reset background and border colours $('*', tip).add(tip).css('cssText', BG_COLOR + ':' + TRANSPARENT + IMPORTANT + ';' + BORDER + ':0' + IMPORTANT + ';'); return color; }, _calculateSize: function (corner) { var y = corner.precedance === Y, width = this.options['width'], height = this.options['height'], isCenter = corner.abbrev() === 'c', base = (y ? width : height) * (isCenter ? 0.5 : 1), pow = Math.pow, round = Math.round, bigHyp, ratio, result, smallHyp = Math.sqrt(pow(base, 2) + pow(height, 2)), hyp = [(this.border / base) * smallHyp, (this.border / height) * smallHyp]; hyp[2] = Math.sqrt(pow(hyp[0], 2) - pow(this.border, 2)); hyp[3] = Math.sqrt(pow(hyp[1], 2) - pow(this.border, 2)); bigHyp = smallHyp + hyp[2] + hyp[3] + (isCenter ? 0 : hyp[0]); ratio = bigHyp / smallHyp; result = [round(ratio * width), round(ratio * height)]; return y ? result : result.reverse(); }, // Tip coordinates calculator _calculateTip: function (corner, size, scale) { scale = scale || 1; size = size || this.size; var width = size[0] * scale, height = size[1] * scale, width2 = Math.ceil(width / 2), height2 = Math.ceil(height / 2), // Define tip coordinates in terms of height and width values tips = { br: [0, 0, width, height, width, 0], bl: [0, 0, width, 0, 0, height], tr: [0, height, width, 0, width, height], tl: [0, 0, 0, height, width, height], tc: [0, height, width2, 0, width, height], bc: [0, 0, width, 0, width2, height], rc: [0, 0, width, height2, 0, height], lc: [width, 0, width, height, 0, height2] }; // Set common side shapes tips.lt = tips.br; tips.rt = tips.bl; tips.lb = tips.tr; tips.rb = tips.tl; return tips[corner.abbrev()]; }, // Tip coordinates drawer (canvas) _drawCoords: function (context, coords) { context.beginPath(); context.moveTo(coords[0], coords[1]); context.lineTo(coords[2], coords[3]); context.lineTo(coords[4], coords[5]); context.closePath(); }, create: function () { // Determine tip corner var c = this.corner = (HASCANVAS || BROWSER.ie) && this._parseCorner(this.options.corner); // If we have a tip corner... if ((this.enabled = !!this.corner && this.corner.abbrev() !== 'c')) { // Cache it this.qtip.cache.corner = c.clone(); // Create it this.update(); } // Toggle tip element this.element.toggle(this.enabled); return this.corner; }, update: function (corner, position) { if (!this.enabled) { return this; } var elements = this.qtip.elements, tip = this.element, inner = tip.children(), options = this.options, curSize = this.size, mimic = options.mimic, round = Math.round, color, precedance, context, coords, bigCoords, translate, newSize, border, BACKING_STORE_RATIO; // Re-determine tip if not already set if (!corner) { corner = this.qtip.cache.corner || this.corner; } // Use corner property if we detect an invalid mimic value if (mimic === FALSE) { mimic = corner; } // Otherwise inherit mimic properties from the corner object as necessary else { mimic = new CORNER(mimic); mimic.precedance = corner.precedance; if (mimic.x === 'inherit') { mimic.x = corner.x; } else if (mimic.y === 'inherit') { mimic.y = corner.y; } else if (mimic.x === mimic.y) { mimic[corner.precedance] = corner[corner.precedance]; } } precedance = mimic.precedance; // Ensure the tip width.height are relative to the tip position if (corner.precedance === X) { this._swapDimensions(); } else { this._resetDimensions(); } // Update our colours color = this.color = this._parseColours(corner); // Detect border width, taking into account colours if (color[1] !== TRANSPARENT) { // Grab border width border = this.border = this._parseWidth(corner, corner[corner.precedance]); // If border width isn't zero, use border color as fill if it's not invalid (1.0 style tips) if (options.border && border < 1 && !INVALID.test(color[1])) { color[0] = color[1]; } // Set border width (use detected border width if options.border is true) this.border = border = options.border !== TRUE ? options.border : border; } // Border colour was invalid, set border to zero else { this.border = border = 0; } // Determine tip size newSize = this.size = this._calculateSize(corner); tip.css({ width: newSize[0], height: newSize[1], lineHeight: newSize[1] + 'px' }); // Calculate tip translation if (corner.precedance === Y) { translate = [ round(mimic.x === LEFT ? border : mimic.x === RIGHT ? newSize[0] - curSize[0] - border : (newSize[0] - curSize[0]) / 2), round(mimic.y === TOP ? newSize[1] - curSize[1] : 0) ]; } else { translate = [ round(mimic.x === LEFT ? newSize[0] - curSize[0] : 0), round(mimic.y === TOP ? border : mimic.y === BOTTOM ? newSize[1] - curSize[1] - border : (newSize[1] - curSize[1]) / 2) ]; } // Canvas drawing implementation if (HASCANVAS) { // Grab canvas context and clear/save it context = inner[0].getContext('2d'); context.restore(); context.save(); context.clearRect(0, 0, 6000, 6000); // Calculate coordinates coords = this._calculateTip(mimic, curSize, SCALE); bigCoords = this._calculateTip(mimic, this.size, SCALE); // Set the canvas size using calculated size inner.attr(WIDTH, newSize[0] * SCALE).attr(HEIGHT, newSize[1] * SCALE); inner.css(WIDTH, newSize[0]).css(HEIGHT, newSize[1]); // Draw the outer-stroke tip this._drawCoords(context, bigCoords); context.fillStyle = color[1]; context.fill(); // Draw the actual tip context.translate(translate[0] * SCALE, translate[1] * SCALE); this._drawCoords(context, coords); context.fillStyle = color[0]; context.fill(); } // VML (IE Proprietary implementation) else { // Calculate coordinates coords = this._calculateTip(mimic); // Setup coordinates string coords = 'm' + coords[0] + ',' + coords[1] + ' l' + coords[2] + ',' + coords[3] + ' ' + coords[4] + ',' + coords[5] + ' xe'; // Setup VML-specific offset for pixel-perfection translate[2] = border && /^(r|b)/i.test(corner.string()) ? BROWSER.ie === 8 ? 2 : 1 : 0; // Set initial CSS inner.css({ coordsize: (newSize[0] + border) + ' ' + (newSize[1] + border), antialias: '' + (mimic.string().indexOf(CENTER) > -1), left: translate[0] - (translate[2] * Number(precedance === X)), top: translate[1] - (translate[2] * Number(precedance === Y)), width: newSize[0] + border, height: newSize[1] + border }) .each(function (i) { var $this = $(this); // Set shape specific attributes $this[$this.prop ? 'prop' : 'attr']({ coordsize: (newSize[0] + border) + ' ' + (newSize[1] + border), path: coords, fillcolor: color[0], filled: !!i, stroked: !i }) .toggle(!!(border || i)); // Check if border is enabled and add stroke element !i && $this.html(createVML( 'stroke', 'weight="' + (border * 2) + 'px" color="' + color[1] + '" miterlimit="1000" joinstyle="miter"' )); }); } // Opera bug #357 - Incorrect tip position // https://github.com/Craga89/qTip2/issues/367 window.opera && setTimeout(function () { elements.tip.css({ display: 'inline-block', visibility: 'visible' }); }, 1); // Position if needed if (position !== FALSE) { this.calculate(corner, newSize); } }, calculate: function (corner, size) { if (!this.enabled) { return FALSE; } var self = this, elements = this.qtip.elements, tip = this.element, userOffset = this.options.offset, isWidget = elements.tooltip.hasClass('ui-widget'), position = {}, precedance, corners; // Inherit corner if not provided corner = corner || this.corner; precedance = corner.precedance; // Determine which tip dimension to use for adjustment size = size || this._calculateSize(corner); // Setup corners and offset array corners = [corner.x, corner.y]; if (precedance === X) { corners.reverse(); } // Calculate tip position $.each(corners, function (i, side) { var b, bc, br; if (side === CENTER) { b = precedance === Y ? LEFT : TOP; position[b] = '50%'; position[MARGIN + '-' + b] = -Math.round(size[precedance === Y ? 0 : 1] / 2) + userOffset; } else { b = self._parseWidth(corner, side, elements.tooltip); bc = self._parseWidth(corner, side, elements.content); br = self._parseRadius(corner); position[side] = Math.max(-self.border, i ? bc : (userOffset + (br > b ? br : -b))); } }); // Adjust for tip size position[corner[precedance]] -= size[precedance === X ? 0 : 1]; // Set and return new position tip.css({ margin: '', top: '', bottom: '', left: '', right: '' }).css(position); return position; }, reposition: function (event, api, pos, viewport) { if (!this.enabled) { return; } var cache = api.cache, newCorner = this.corner.clone(), adjust = pos.adjusted, method = api.options.position.adjust.method.split(' '), horizontal = method[0], vertical = method[1] || method[0], shift = { left: FALSE, top: FALSE, x: 0, y: 0 }, offset, css = {}, props; function shiftflip(direction, precedance, popposite, side, opposite) { // Horizontal - Shift or flip method if (direction === SHIFT && newCorner.precedance === precedance && adjust[side] && newCorner[popposite] !== CENTER) { newCorner.precedance = newCorner.precedance === X ? Y : X; } else if (direction !== SHIFT && adjust[side]) { newCorner[precedance] = newCorner[precedance] === CENTER ? (adjust[side] > 0 ? side : opposite) : (newCorner[precedance] === side ? opposite : side); } } function shiftonly(xy, side, opposite) { if (newCorner[xy] === CENTER) { css[MARGIN + '-' + side] = shift[xy] = offset[MARGIN + '-' + side] - adjust[side]; } else { props = offset[opposite] !== undefined ? [adjust[side], -offset[side]] : [-adjust[side], offset[side]]; if ((shift[xy] = Math.max(props[0], props[1])) > props[0]) { pos[side] -= adjust[side]; shift[side] = FALSE; } css[offset[opposite] !== undefined ? opposite : side] = shift[xy]; } } // If our tip position isn't fixed e.g. doesn't adjust with viewport... if (this.corner.fixed !== TRUE) { // Perform shift/flip adjustments shiftflip(horizontal, X, Y, LEFT, RIGHT); shiftflip(vertical, Y, X, TOP, BOTTOM); // Update and redraw the tip if needed (check cached details of last drawn tip) if (newCorner.string() !== cache.corner.string() || cache.cornerTop !== adjust.top || cache.cornerLeft !== adjust.left) { this.update(newCorner, FALSE); } } // Setup tip offset properties offset = this.calculate(newCorner); // Readjust offset object to make it left/top if (offset.right !== undefined) { offset.left = -offset.right; } if (offset.bottom !== undefined) { offset.top = -offset.bottom; } offset.user = this.offset; // Perform shift adjustments if (shift.left = (horizontal === SHIFT && !!adjust.left)) { shiftonly(X, LEFT, RIGHT); } if (shift.top = (vertical === SHIFT && !!adjust.top)) { shiftonly(Y, TOP, BOTTOM); } /* * If the tip is adjusted in both dimensions, or in a * direction that would cause it to be anywhere but the * outer border, hide it! */ this.element.css(css).toggle( !((shift.x && shift.y) || (newCorner.x === CENTER && shift.y) || (newCorner.y === CENTER && shift.x)) ); // Adjust position to accomodate tip dimensions pos.left -= offset.left.charAt ? offset.user : horizontal !== SHIFT || shift.top || !shift.left && !shift.top ? offset.left + this.border : 0; pos.top -= offset.top.charAt ? offset.user : vertical !== SHIFT || shift.left || !shift.left && !shift.top ? offset.top + this.border : 0; // Cache details cache.cornerLeft = adjust.left; cache.cornerTop = adjust.top; cache.corner = newCorner.clone(); }, destroy: function () { // Unbind events this.qtip._unbind(this.qtip.tooltip, this._ns); // Remove the tip element(s) if (this.qtip.elements.tip) { this.qtip.elements.tip.find('*') .remove().end().remove(); } } }); TIP = PLUGINS.tip = function (api) { return new Tip(api, api.options.style.tip); }; // Initialize tip on render TIP.initialize = 'render'; // Setup plugin sanitization options TIP.sanitize = function (options) { if (options.style && 'tip' in options.style) { var opts = options.style.tip; if (typeof opts !== 'object') { opts = options.style.tip = { corner: opts }; } if (!(/string|boolean/i).test(typeof opts.corner)) { opts.corner = TRUE; } } }; // Add new option checks for the plugin CHECKS.tip = { '^position.my|style.tip.(corner|mimic|border)$': function () { // Make sure a tip can be drawn this.create(); // Reposition the tooltip this.qtip.reposition(); }, '^style.tip.(height|width)$': function (obj) { // Re-set dimensions and redraw the tip this.size = [obj.width, obj.height]; this.update(); // Reposition the tooltip this.qtip.reposition(); }, '^content.title|style.(classes|widget)$': function () { this.update(); } }; // Extend original qTip defaults $.extend(TRUE, QTIP.defaults, { style: { tip: { corner: TRUE, mimic: FALSE, width: 6, height: 6, border: TRUE, offset: 0 } } }); ; })); } (window, document)); (function () { var serviceUrlBase = az.$rootPath() + 'Gateway/'; var serviceRegistry = {} var evalJson = function (s, enc) { if(az.chk.ifObject(s)) { s=s.payload; } else{ s=s.replace("{\"payload\":\"",""); s=s.replace("\"}",""); } if (az.chk.ifBoolean(s) ||az.chk.ifObject(s)||az.chk.ifArray(s)) return s; if (enc) { s = CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(s)); s = s.substring(9); } var json = "o = " + (s || 'null') + ";"; json = json.replace(/"\\?\/Date\((-?[\d]+).*?\)\\?\/"/gi, "new Date($1)"); //json = json.replace(/"\\?\/Date\((\d+,\d+,\d+)\)\\?\/"/gi, "new Date($1)"); json = json.replace(/"(Date\(\d+,\d+,\d+\))"/gi, "new $1"); //json = json.replace(/\\?\"(Date\(\d+,\d+,\d+\))\\?\"/, "new $1"); var o = eval(json); return o; }; /*var prepareArgs = function (command, parameters) { var params = []; if (parameters == null || parameters == undefined) return params; for (var i = 0; i < command.Arguments.length; i++) { var found = false; for (var j in parameters) { if (j.toString().toLowerCase() == command.Arguments[i].Name.toLowerCase()) { params[params.length] = parameters[j]; found = true; break; } } if (!found) { params[params.length] = null; } } return params; };*/ var prepareArgs = function (parameters) { var params = []; if (parameters == null || parameters == undefined) return params; for (var j in parameters) { params[params.length] = parameters[j]; } return params; }; var createCommands = function (commands, parameters) { var id = 1; var wcommands = []; for (var i = 0; i < commands.length; i++) { var service_method = commands[i].split('/'); wcommands.push({ Id: id++, Client: az.$client(), ApiAccessCode: az.$client_api_code(), Service: service_method[0], Method: service_method[1], Arguments: (parameters && parameters.length > 0 ? prepareArgs(parameters[i]) : []) }); } return wcommands; }; var callAjax = function(url, data, onsuccess, onerror) { console.log(data); var isAsync = !!(onsuccess); var res = jQuery.ajax({ type: "POST", url: url, data: data, // dataType: 'text', async: isAsync, beforeSend: function(xhr) { //xhr.setRequestHeader("content-type", "application/json"); xhr.setRequestHeader("content-type", "application/x-www-form-urlencoded"); }, success: function(s) { if (!isAsync) return; if (!onsuccess) return; if (typeof onsuccess == "function") onsuccess(evalJson(s, true)); else { onsuccess.fn.call(onsuccess.scope, evalJson(s, true)); } }, error: function(jqXHR, textStatus, errorThrown) { if (!onerror) return; if (typeof onerror == "function") onerror.apply(null, [textStatus, errorThrown]); else { onerror.fn.apply(onerror.scope || null, [textStatus, errorThrown]); } } }); if (isAsync) return; return az.evalJson(res.responseText, true); }; az.evalJson = evalJson; var encrptJs = function (str) { var key = CryptoJS.enc.Utf8.parse('8eda7ac99a6cb78b'); var iv = CryptoJS.enc.Utf8.parse('9efb63d3f958418d'); var encrypted = CryptoJS.AES.encrypt(CryptoJS.enc.Utf8.parse(str), key, { keySize: 128 / 8, iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }).toString(); return encrypted; //return CryptoJS.AES.encrypt(str, "test").toString(); }; var executeCommand = function (commands, onsuccess, onerror) { var toJsonOld = Date.prototype.toJSON; Date.prototype.toJSON = function () { return az.date.formatDate('yy-mm-dd', this); }; var strCmds = encrptJs(JSON.stringify(commands)); Date.prototype.toJSON = toJsonOld; return callAjax(serviceUrlBase + az.Service.CommandUrl, { "commands": strCmds }, onsuccess, onerror); }; az.defineSingleton('Service', { CommandUrl: 'ExecuteCommand', register: function (config, override) { if (config.name && serviceRegistry.hasOwnProperty(config.name) && !override) { throw "A service by name " + config.name + " already exists"; return; } serviceRegistry[config.Name] = config; }, unregister: function (name) { delete serviceRegistry[name]; }, callSync: function (command, parameter) { return executeCommand(createCommands([command], [parameter]))[0]; }, getWebletInfo:function (weblet) { var rs = callAjax(serviceUrlBase + 'GetWebletInfo', { "weblet": weblet, "client": az.$client() }); if (rs.error) { alert('Error loading weblet ' +weblet ); return null; } return rs; }, call: function (coms, parameters, callbackConfig, errorCallbackConfig) { var commands = createCommands(coms, parameters); if (!commands) return; executeCommand(commands, function (result) { var cmdResult = []; for (var i = 0; i < commands.length; i++) { var rs = az.find(result, function (item) { return item.Command.Id == commands[i].Id; }); if (rs.IsSuccess) cmdResult[cmdResult.length] = rs.Result; else { cmdResult[cmdResult.length] = { error: { message: rs.ErrorMessage} }; } } if (az.chk.ifFunction(callbackConfig)) { callbackConfig.apply(null, cmdResult); } else callbackConfig.fn.apply(callbackConfig.scope, cmdResult); }, function (er) { if (errorCallbackConfig) { if (az.chk.ifFunction(errorCallbackConfig)) { errorCallbackConfig.apply(null, arguments); } else errorCallbackConfig.fn.apply(errorCallbackConfig.scope, arguments); } else { console.log(arguments); alert("Something went wrong..."); } }); } }); })(); /*var $chkLoad= function(index, paths, callback){ debugger; $.get(paths[index],function(){ debugger; if(index < (paths.length-1)){ $chkLoad(index+ 1,paths, callback ); } else callback(); }); }*/ var loaded = []; function Load(weblet,config) { var weblteInfo = az.Service.getWebletInfo(weblet); var scriptText=''; $('',{ rel: 'stylesheet', type:"text/css", href: 'https://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300ita‌​lic,400italic,500,500italic,700,700italic,900italic,900' }).appendTo('head'); for(var i=0;i', { type: "text/javascript", src: weblteInfo.Resources[i].Path }).appendTo('head'); } loaded.push(weblteInfo.Resources[i].Path); } if(weblteInfo.Resources[i].Type=="css" && loaded.indexOf(weblteInfo.Resources[i].Path)==-1) { $('',{ rel: 'stylesheet', type:"text/css", href: az.$rootPath()+'Clients/'+ az.$client()+ '/' +weblteInfo.Resources[i].Path }).appendTo('head'); loaded.push(weblteInfo.Resources[i].Path); } } /*$chkLoad(0, loaded, function(){ debugger; });*/ $('