/*! iris - v0.5.7-SNAPSHOT - 2014-02-17 (http://thegameofcode.github.io/iris) licensed New-BSD */ var iris={};window.iris=iris,function(a){function b(){c={},iris.on("iris-reset",b)}var c;iris.on=function(b,d){if(!a.isFunction(d))throw"invalid function";c.hasOwnProperty(b)||(c[b]=[]);var e=c[b],f=a.inArray(d,e);-1===f&&e.push(d)},iris.off=function(b,d){if(c.hasOwnProperty(b))if(void 0!==d){if(!a.isFunction(d))throw"invalid function";var e=a.inArray(d,c[b]);-1!==e&&c[b].splice(e,1)}else delete c[b]},iris.notify=function(a,b){if(void 0===a)throw"event name undefined";if(c[a])for(var d=c[a],e=0;e-1)return!0;return!1}var d,e,f,g,h,i,j=1.5;iris.baseUri=function(a){if(void 0!==a)d=a;else if(void 0===d){var b=document.getElementsByTagName("base");b=b.length>0?b[0].attributes.href.value:"/",d=document.location.protocol+"//"+document.location.host+b}return d},iris.cache=function(a){return void 0===a?e:void(e=a)},iris.cacheVersion=function(a){return void 0===a?f:void(f=a)},iris.log=function(){h&&g&&g.apply(window.console,arguments)},iris.enableLog=function(){if("boolean"==typeof arguments[0])h=arguments[0];else{if(!(arguments.length>0))return h;h=c.apply(this,arguments)}},iris.noCache=function(){return arguments.length>0?void(e=!c.apply(this,arguments)):!e},iris.isLocalhost=function(){return i},b()}(jQuery),function(a){function b(){e={}}function c(b,c){iris.log("[translations]",b,c),void 0===iris.locale()&&iris.locale(b),e.hasOwnProperty(b)||(e[b]={}),a.extend(e[b],c)}function d(a,b,d){iris.log("[translations]",a,b);var e={url:b,dataType:"json",async:!1,cache:iris.cache()};iris.cache()&&iris.cacheVersion()&&(e.data="_="+iris.cacheVersion()),iris.ajax(e).done(function(b){c(a,b),iris.log("[translations]",b),d&&d.hasOwnProperty("success")&&d.success(a)}).fail(function(c){throw d&&d.hasOwnProperty("error")&&d.error(a),"Error "+c.status+" loading lang file["+b+"]"})}var e;iris.translations=function(a,b,e){"object"==typeof b?c(a,b):d(a,b,e)},iris.translate=function(a,b){var c,d=null;d=void 0!==b?b:iris.locale();var f="[translate]";return e.hasOwnProperty(d)?(c=iris.val(e[d],a),void 0===c&&iris.log(f+" label '"+a+"' not found in Locale '"+d+"'",e[d]),"object"==typeof c&&iris.log(f+"label '"+a+"' is an object but must be a property in Locale '"+d+"'",e[d])):iris.log(f+" locale '"+d+"' not loaded",this),void 0!==c?c:"??"+a+"??"},b()}(jQuery),function(){function a(){b=void 0,c={},iris.on("iris-reset",a)}var b,c;iris.locale=function(a,d){if("object"==typeof d)c[a]||(c[a]={}),$.extend(c[a],d),void 0===b&&(b=a);else{if(void 0===a)return b;b=a}},iris.regional=function(a){if(c.hasOwnProperty(b))return"undefined"==typeof a?c[b]:c[b].hasOwnProperty(a)?c[b][a]:void 0;throw"[regional] for locale '"+b+"' not found"},a()}(),function(a){function b(a){a=a.toLowerCase();var b=/(chrome)[ \/]([\w.]+)/.exec(a)||/(webkit)[ \/]([\w.]+)/.exec(a)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(a)||/(msie) ([\w.]+)/.exec(a)||a.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(a)||[];return{name:b[1]||"",version:b[2]||"0"}}function c(a){return 10>a?"0"+a:a}function d(a,b){var d=iris.regional();switch(a){case"y":return String(b.getFullYear()).substring(2);case"Y":return b.getFullYear();case"m":var e=b.getMonth()+1;return c(e);case"n":return b.getMonth()+1;case"M":return d.monthNames[b.getMonth()].substring(0,3);case"b":return d.monthNames[b.getMonth()].substring(0,3).toLowerCase();case"F":return d.monthNames[b.getMonth()];case"d":var f=b.getDate();return c(f);case"D":return d.dayNames[b.getDay()].substring(0,3);case"l":return d.dayNames[b.getDay()];case"s":var g=b.getSeconds();return c(g);case"i":var h=b.getMinutes();return c(h);case"H":var i=b.getHours();return c(i);case"h":var j=b.getHours();return j=j%12===0?12:j%12,c(j);case"a":return b.getHours()>12?"p.m.":"a.m.";case"A":return b.getHours()>12?"PM":"AM";case"U":return Math.floor(.001*b.getTime());default:return a}}var e;iris.date=function(a,b){if(null===a)return"";b||(b=iris.regional("dateFormat")),"object"!=typeof a&&(a=new Date(a));for(var c="",e=0,f=b.length;f>e;e++)c+=d(b[e],a);return c},iris.ajax=function(b){return a.ajax(b)},iris.currency=function(b,c){var d={formatPos:"sn",formatNeg:"(sn)",symbol:"$"};a.extend(d,iris.regional("currency"),c);var e=iris.number(b,d);return e.replace("s",d.symbol)},iris.number=function(b,c){var d={formatPos:"n",formatNeg:"- n",decimal:".",thousand:",",precision:2};a.extend(d,iris.regional("number"),c);for(var e=Number(b),f=e>=0?d.formatPos:d.formatNeg,g=e%1,h=String(Math.abs(e-g)),i=0;i0&&(g=String(Math.abs(g).toFixed(d.precision)),g=g.substr(2),h=h+d.decimal+g),f.replace("n",h)},iris.val=function(a,b){var c;if(b.indexOf(".")>-1){var d,e=b.split("."),f=e.length;for(d=0;f>d&&void 0!==a;d++)a=a[e[d]];c=a}else c=a[b];return c},iris.browser=function(){if(!e){var a=b(navigator.userAgent);e={},a.name&&(e[a.name]=!0,e.version=a.version),e.chrome?e.webkit=!0:e.webkit&&(e.safari=!0)}return e},iris.inherits=function(a,b){var c=function(){};c.prototype=b.prototype,a.prototype=new c}}(jQuery),function(a){var b=function(){iris.Event.call(this),this.cfg={}};iris.inherits(b,iris.Event);var c=b.prototype;c.settings=function(b){return a.extend(this.cfg,b)},c.setting=function(a,b){return void 0===b?(this.cfg.hasOwnProperty(a)||iris.log("setting '"+a+"' missing",this.cfg,this),this.cfg[a]):void(this.cfg[a]=b)},iris.Settable=b}(jQuery),function(a){function b(){B={},O={},N={},C={},D=!1,K={},L=[],M=[],I=!1,J="",G=0,H=[],E=[],P=!1,iris.isLocalhost()&&x(!0),iris.on("iris-reset",function(){a(window).off("hashchange"),document.location.hash="#",b()})}function c(b){if(D)throw"welcome screen already exists";D=!0,O["#"]={js:b,container:a(document.body),navMap:{}},K["#"]={},iris.hasOwnProperty("path")&&d(iris.path),E.length>0?g(E,f):f()}function d(a){if("string"==typeof a)C.hasOwnProperty(a)||E.push(a);else for(var b in a)d(a[b])}function e(b,c,d){if("string"!==a.type(c)||""===c)throw iris.log("[error] path["+c+"]",b),"Invalid path on "+d+" registration";C[c]=b}function f(){if(!("onhashchange"in window))throw"hashchange event unsupported";o(),a(window).on("hashchange",o)}function g(a,b){iris.log("[load-js]",a),F=b;for(var c,d,e=0;e0)){var g=a.match(R);for(d=0;d0){var j,k=i[0].match(new RegExp(S,"g"));for(d=0;do){for(e=t?o+1:o,d=L.length-1;d>=e;d--)if("#"!==L[d]&&B[L[d]].canSleep()===!1)return I=!0,document.location.href=J,!1;for(;L.length>e;){var u=L.pop();if(M.pop(),"#"!==u){var v=B[u];v._sleep(),v.hide()}}}var w,x=M[o]&&M[o]!==q,y=m(g,f,a);if(t)w=B[p],x&&(w.params=y,w._awake(y));else{if(B.hasOwnProperty(p))w=B[p];else{if(!O.hasOwnProperty(p))throw'"'+p+'" not found';w=new Z(p),w.params=y,w.create(),B[p]=w}w.show(),w._awake(y)}o++}J=j,L=s,M=r,iris.log("Navigation finished"),iris.notify(iris.AFTER_NAVIGATION)}function p(a){var b=a,c=b.match(/@@[0-9A-Za-z_\.]+@@/g);if(c){var d,e=c.length;for(d=0;e>d;d++)b=b.replace(c[d],iris.translate(c[d].substring(2,c[d].length-2)))}return b}function q(a,b){C[a]=b.replace(T,"")}function r(a,b){e(a,b,"ui")}function s(a){for(var b,c={},d=a.get(0).attributes,e=0,f=d.length;f>e;e++)b=d[e].name,0===b.indexOf("data-")&&(b=b.substr(5)),c[b]=d[e].value;return c}function t(a,b){e(a,b,"screen")}function u(a){if(B.hasOwnProperty(a)){if("#"===a)throw"Welcome screen cannot be deleted";var b=document.location.hash||"#";if("#"!==b&&(0===a.indexOf(b)||0===b.indexOf(a)))throw"Cannot delete the current screen or its parents";v(a)}else iris.log('[warning] "'+a+'" was not instantiated, nothing to destroy')}function v(a){var b=B[a];if(void 0!==b){if(void 0!==b.screenChilds)for(var c=0;c.iris-debug { position: relative; z-index: 9999; }.iris-debug-ui { outline: 3px dotted blue; }.iris-debug-ui:hover { outline: 3px solid blue; box-shadow: 0px 0px 40px rgba(0, 0, 255, 0.5); }.iris-debug-screen { outline: 3px dotted red; }.iris-debug-screen:hover { outline: 3px solid red; box-shadow: 0px 0px 40px rgba(255, 0, 0, 0.5); }').appendTo(U),c.on("keydown",y)):!b&&d&&(c.off("keydown",y),a(d).remove())}function y(a){if(a.shiftKey&&a.ctrlKey&&a.altKey&&16!==a.keyCode&&68===a.keyCode){P=!P;var b,c;for(b in B)c=B[b],A(c),z(c.uis)}}function z(a){for(var b=0,c=a.length;c>b;b++)A(a[b]),z(a[b].uis)}function A(b){if(b.template.toggleClass("iris-debug iris-debug-"+b.type,P),P){var c,d;"screen"===b.type?(c="red",d="Hash"):(c="blue",d="Data-id");var e={"font-family":"sans-serif","font-size":"14px",color:"white",padding:"4px","white-space":"nowrap","background-color":c},f="Type: "+b.type+"\n"+d+": "+b.id+"\nPresenter: "+b.fileJs+"\nTemplate: "+b.fileTmpl;b.debugElement=a(''+b.id+" ["+b.fileJs+"]").css(e).prependTo(b.template)}else b.debugElement&&b.debugElement.remove()}var B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q=/(date|currency|number)(?:\(([^\)]+)\))/,R=/:[\d\w_\-\.]+/g,S="[;?&][^=]+=[^;/&]+",T=//g,U=document.getElementsByTagName("head")[0],V=function(a,b,c,d){iris.Settable.call(this),this.type=d,this.id=a,this.uis=[],this.uisMap={},this.el={},this.con=b,this.fileJs=c,this.fileTmpl=null,this.template=null,this.sleeping=null,C[c](this)};iris.inherits(V,iris.Settable);var W=V.prototype;W.APPEND="append",W.REPLACE="replace",W.PREPEND="prepend",W._sleep=function(){for(var a=0,b=this.uis.length;b>a;a++)this.uis[a]._sleep();this.sleeping=!0,this.sleep()},W._awake=function(a){this.sleeping=!1,this.awake(a);for(var b=0,c=this.uis.length;c>b;b++)this.uis[b].sleeping!==!1&&this.uis[b]._awake()},W._destroy=function(){this.sleeping||this._sleep();for(var a=0,b=this.uis.length;b>a;a++)this.uis[a]._destroy();for(var c in this.events)iris.destroyEvents(c,this.events[c]);this.destroy(),this.uis=null,this.events=null},W._tmpl=function(b,c){var d,e,f;if(null!==this.template)throw"self.tmpl() has already been called in '"+this.fileJs+"'";if(this.fileTmpl=b,f=a(p(C[b])),this.template=f,f.size()>1)throw"'"+b+"' must have only one root node";switch(c){case this.APPEND:this.con.append(f);break;case this.REPLACE:this.con.replaceWith(f),this.con={selector:this.con.selector};break;case this.PREPEND:this.con.prepend(f);break;default:throw"Unknown template mode '"+c+"'"}for(this.el={},this.inflateTargets={},this._data_attrs(f),e=f.get(0).getElementsByTagName("*"),d=e.length;d--;)this._data_attrs(a(e[d]))},W._data_attrs=function(a){var b,c,d,e,f,g,h,i,j,k=a.get(0).attributes,l={},m={};for(b=k.length;b--;)if(d=k[b],0===d.name.indexOf("data-"))if(c=d.name.substr(5),"id"!==c)if(-1===c.indexOf("-format",c.length-7)){if(0===c.indexOf("jq-"))if(c=c.substr(3),/^(text|html|val|toggle)$/.test(c))f=c;else{if(!/^(prop-|attr-)/.test(c))continue;f=c.substr(0,4),g=c.substr(5)}this.inflateTargets.hasOwnProperty(d.value)||(this.inflateTargets[d.value]=[]),e={target:f,targetParams:g,el:a},this.inflateTargets[d.value].push(e),m[c]=e}else h=d.value,i=void 0,h&&Q.test(h)&&(j=h.match(Q),h=j[1],i=j[2]),l[c.substr(3,c.length-10)]={key:h,params:i};else this.el[d.value]=a;for(c in l)m.hasOwnProperty(c)&&(m[c].format=l[c].key,m[c].formatParams=l[c].params)},W.inflate=function(a){var b,c,d,e,f,g,h;for(b in this.inflateTargets)if(g=iris.val(a,b),void 0!==g)for(e=this.inflateTargets[b],c=0,d=e.length;d>c;c++){switch(f=e[c],f.format){case"date":h=iris.date(g,f.formatParams);break;case"currency":h=iris.currency(g);break;case"number":h=iris.number(g);break;default:h=g}switch(f.target){case"text":f.el.text(h);break;case"html":f.el.html(h);break;case"val":f.el.val(h);break;case"toggle":f.el.toggle(h);break;case"prop":f.el.prop(f.targetParams,h);break;case"attr":f.el.attr(f.targetParams,h)}}},W._checkTmpl=function(){if(null===this.template)throw"Set a template using self.tmpl() in '"+this.fileJs+"'"},W.show=function(){this._checkTmpl(),this.template.show()},W.hide=function(){this._checkTmpl(),this.template.hide()},W.get=function(a){if(this._checkTmpl(),a){if(!this.el.hasOwnProperty(a)){var b="[data-id="+a+"]",c=this.template.filter(b),d=null;if(c.length>0)d=c;else{var e=this.template.find(b);e.size()>0&&(d=e)}if(null===d)throw"[data-id="+a+"] not screenFound in '"+this.fileTmpl+"' used by '"+this.fileJs+"'";if(d.size()>1)throw"[data-id="+a+"] must be unique in '"+this.fileTmpl+"' used by '"+this.fileJs+"'";this.el[a]=d}return this.el[a]}return this.template},W._ui=function(a,b,c,d){if(void 0===b){var e=this.uisMap[a];return void 0===e&&(e=[]),e}return this._createUi(a,b,c,d)},W._createUi=function(a,b,c,d){var e=this.get(a);if(void 0!==e&&1===e.size()){var f=new X(e,e.data("id"),b,c,d,this);return(void 0===f._tmplMode||f._tmplMode===f.REPLACE)&&(this.el[a]=void 0),this.uis.push(f),f._tmplMode===f.REPLACE?this.uisMap[a]=f:(this.uisMap.hasOwnProperty(a)||(this.uisMap[a]=[]),this.uisMap[a].push(f)),f}throw"The container does not exist or has been replaced."},W.destroyUI=function(b){if(void 0===b)this.parentUI.destroyUI(this);else{var c;if(c=a.inArray(b,this.uis),-1!==c&&this.uis.splice(c,1),b._tmplMode===b.REPLACE)this.uisMap[b.id]=null,delete this.uisMap[b.id];else{var d=this.uisMap[b.id];c=a.inArray(b,d),-1!==c&&d.splice(c,1)}b._destroy(),b.get().remove()}},W.destroyUIs=function(b){var c=this.uisMap[b];if(a.isArray(c)){var d;for(d=c.length-1;d>=0;d--)this.destroyUI(c[d])}else c&&c._tmplMode===this.REPLACE&&this.destroyUI(c)},W.container=function(){return this.con},W.create=function(){},W.awake=function(){},W.sleep=function(){},W.destroy=function(){};var X=function(b,c,d,e,f,g){V.call(this,c,b,d,"ui");var h=s(b);this.parentUI=g,this._tmplMode=f||"replace",a.extend(this.cfg,h,e||{}),this.create(),this._awake()};iris.inherits(X,V);var Y=X.prototype;Y.tmplMode=function(a){this._tmplMode=a},Y.tmpl=function(a){this._tmpl(a,this._tmplMode)},Y.ui=function(a,b,c,d){return this._ui(a,b,c,d)};var Z=function(a){var b=O[a];V.call(this,a,b.container,b.js,"screen"),this.params={},this.screenConId=null,this.navMap=null,this.hash=null};iris.inherits(Z,V);var $=Z.prototype;$.param=function(a){return this.params[a]},$.ui=function(a,b,c,d){if(a===this.screenConId)throw"'"+a+"' has already been registered as a screen container";return this._ui(a,b,c,d)},$.tmpl=function(a){this._tmpl(a,this.APPEND)},$.screens=function(a,b){if(this.screenConId=a,this.hasOwnProperty("screenChilds"))throw"Multiple calls to self.screens() are not allowed: "+this.id;if(null===this.template)throw"self.tmpl() must be called before self.screens(): "+this.id;var c=this.get(a);this.screenChilds=[];var d=O[this.id];this.navMap="#"===this.id?K["#"]:d.parentNavMap[d.hashFragment];for(var e,f,g,h,i=0;i