/*! Alpaca Version 1.1.3 Copyright 2014 Gitana Software, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. For more information, please contact Gitana Software, Inc. at this address: info@gitanasoftware.com */ (function(name,global,definition){global[name]=definition();})("Base",this,function(){var Base=function(){};Base.extend=function(_instance,_static){var extend=Base.prototype.extend;Base._prototyping=true;var proto=new this();extend.call(proto,_instance);proto.base=function(){};delete Base._prototyping;var constructor=proto.constructor;var klass=proto.constructor=function(){if(!Base._prototyping){if(this._constructing||this.constructor===klass){this._constructing=true;constructor.apply(this,arguments);delete this._constructing;}else{if(arguments[0]!==null){return(arguments[0].extend||extend).call(arguments[0],proto);}}}};klass.ancestor=this;klass.extend=this.extend;klass.forEach=this.forEach;klass.implement=this.implement;klass.prototype=proto;klass.toString=this.toString;klass.valueOf=function(type){return(type==="object")?klass:constructor.valueOf();};extend.call(klass,_static);if(typeof klass.init==="function"){klass.init();}return klass;};Base.prototype={extend:function(source,value){if(arguments.length>1){var ancestor=this[source];if(ancestor&&(typeof value==="function")&&(!ancestor.valueOf||ancestor.valueOf()!==value.valueOf())&&/\bbase\b/.test(value)){var method=value.valueOf();value=function(){var previous=this.base||Base.prototype.base;this.base=ancestor;var returnValue=method.apply(this,arguments);this.base=previous;return returnValue;};value.valueOf=function(type){return(type==="object")?value:method;};value.toString=Base.toString;}this[source]=value;}else{if(source){var extend=Base.prototype.extend;if(!Base._prototyping&&typeof this!=="function"){extend=this.extend||extend;}var proto={toSource:null};var hidden=["constructor","toString","valueOf"];for(var i=Base._prototyping?0:1;ischema.maxItems){addError("There must be a maximum of "+schema.maxItems+" in the array");}}else{if(schema.properties||schema.additionalProperties){errors.concat(checkObj(value,schema.properties,path,schema.additionalProperties));}}if(schema.pattern&&typeof value=="string"&&!value.match(schema.pattern)){addError("does not match the regex pattern "+schema.pattern);}if(schema.maxLength&&typeof value=="string"&&value.length>schema.maxLength){addError("may only be "+schema.maxLength+" characters long");}if(schema.minLength&&typeof value=="string"&&value.lengthvalue){addError("must have a minimum value of "+schema.minimum);}if(typeof schema.maximum!==undefined&&typeof value==typeof schema.maximum&&schema.maximum)[^>]*$|\{\{\! /,newTmplItems={},wrappedItems={},appendToTmplItems,topTmplItem={key:0,data:{}},itemKey=0,cloneIndex=0,stack=[];function newTmplItem(options,parentItem,fn,data){var newItem={data:data||(data===0||data===false)?data:(parentItem?parentItem.data:{}),_wrap:parentItem?parentItem._wrap:null,tmpl:null,parent:parentItem||null,nodes:[],calls:tiCalls,nest:tiNest,wrap:tiWrap,html:tiHtml,update:tiUpdate};if(options){jQuery.extend(newItem,options,{nodes:[],parent:parentItem});}if(fn){newItem.tmpl=fn;newItem._ctnt=newItem._ctnt||newItem.tmpl(jQuery,newItem);newItem.key=++itemKey;(stack.length?wrappedItems:newTmplItems)[itemKey]=newItem;}return newItem;}jQuery.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(name,original){jQuery.fn[name]=function(selector){var ret=[],insert=jQuery(selector),elems,i,l,tmplItems,parent=this.length===1&&this[0].parentNode;appendToTmplItems=newTmplItems||{};if(parent&&parent.nodeType===11&&parent.childNodes.length===1&&insert.length===1){insert[original](this[0]);ret=this;}else{for(i=0,l=insert.length;i0?this.clone(true):this).get();jQuery(insert[i])[original](elems);ret=ret.concat(elems);}cloneIndex=0;ret=this.pushStack(ret,name,insert.selector);}tmplItems=appendToTmplItems;appendToTmplItems=null;jQuery.tmpl.complete(tmplItems);return ret;};});jQuery.fn.extend({tmpl:function(data,options,parentItem){return jQuery.tmpl(this[0],data,options,parentItem);},tmplItem:function(){return jQuery.tmplItem(this[0]);},template:function(name){return jQuery.template(name,this[0]);},domManip:function(args,table,callback,options){if(args[0]&&jQuery.isArray(args[0])){var dmArgs=jQuery.makeArray(arguments),elems=args[0],elemsLength=elems.length,i=0,tmplItem;while(i").join(">").split('"').join(""").split("'").join("'");}});jQuery.extend(jQuery.tmpl,{tag:{"tmpl":{_default:{$2:"null"},open:"if($notnull_1){__=__.concat($item.nest($1,$2));}"},"wrap":{_default:{$2:"null"},open:"$item.calls(__,$1,$2);__=[];",close:"call=$item.calls();__=call._.concat($item.wrap(call,__));"},"each":{_default:{$2:"$index, $value"},open:"if($notnull_1){$.each($1a,function($2){with(this){",close:"}});}"},"if":{open:"if(($notnull_1) && $1a){",close:"}"},"else":{_default:{$1:"true"},open:"}else if(($notnull_1) && $1a){"},"html":{open:"if($notnull_1){__.push($1a);}"},"=":{_default:{$1:"$data"},open:"if($notnull_1){__.push($.encode($1a));}"},"!":{open:""}},complete:function(items){newTmplItems={};},afterManip:function afterManip(elem,fragClone,callback){var content=fragClone.nodeType===11?jQuery.makeArray(fragClone.childNodes):fragClone.nodeType===1?[fragClone]:[];callback.call(elem,fragClone);storeTmplItems(content);cloneIndex++;}});function build(tmplItem,nested,content){var frag,ret=content?jQuery.map(content,function(item){return(typeof item==="string")?(tmplItem.key?item.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g,"$1 "+tmplItmAtt+'="'+tmplItem.key+'" $2'):item):build(item,tmplItem,item._ctnt);}):tmplItem;if(nested){return ret;}ret=ret.join("");ret.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/,function(all,before,middle,after){frag=jQuery(middle).get();storeTmplItems(frag);if(before){frag=unencode(before).concat(frag);}if(after){frag=frag.concat(unencode(after));}});return frag?frag:unencode(ret);}function unencode(text){var el=document.createElement("div");el.innerHTML=text;return jQuery.makeArray(el.childNodes);}function buildTmplFn(markup){return new Function("jQuery","$item","var $=jQuery,call,__=[],$data=$item.data;"+"with($data){__.push('"+jQuery.trim(markup).replace(/([\\'])/g,"\\$1").replace(/[\r\t\n]/g," ").replace(/\$\{([^\}]*)\}/g,"{{= $1}}").replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,function(all,slash,type,fnargs,target,parens,args){var tag=jQuery.tmpl.tag[type],def,expr,exprAutoFnDetect;if(!tag){throw"Unknown template tag: "+type;}def=tag._default||[];if(parens&&!/\w$/.test(target)){target+=parens;parens="";}if(target){target=unescape(target);args=args?(","+unescape(args)+")"):(parens?")":"");expr=parens?(target.indexOf(".")>-1?target+unescape(parens):("("+target+").call($item"+args)):target;exprAutoFnDetect=parens?expr:"(typeof("+target+")==='function'?("+target+").call($item):("+target+"))";}else{exprAutoFnDetect=expr=def.$1||"null";}fnargs=unescape(fnargs);return"');"+tag[slash?"close":"open"].split("$notnull_1").join(target?"typeof("+target+")!=='undefined' && ("+target+")!=null":"true").split("$1a").join(exprAutoFnDetect).split("$1").join(expr).split("$2").join(fnargs||def.$2||"")+"__.push('";})+"');}return __;");}function updateWrapped(options,wrapped){options._wrap=build(options,true,jQuery.isArray(wrapped)?wrapped:[htmlExpr.test(wrapped)?wrapped:jQuery(wrapped).html()]).join("");}function unescape(args){return args?args.replace(/\\'/g,"'").replace(/\\\\/g,"\\"):null;}function outerHtml(elem){var div=document.createElement("div");div.appendChild(elem.cloneNode(true));return div.innerHTML;}function storeTmplItems(content){var keySuffix="_"+cloneIndex,elem,elems,newClonedItems={},i,l,m;for(i=0,l=content.length;i=0;m--){processItemKey(elems[m]);}processItemKey(elem);}function processItemKey(el){var pntKey,pntNode=el,pntItem,tmplItem,key;if((key=el.getAttribute(tmplItmAtt))){while(pntNode.parentNode&&(pntNode=pntNode.parentNode).nodeType===1&&!(pntKey=pntNode.getAttribute(tmplItmAtt))){}if(pntKey!==key){pntNode=pntNode.parentNode?(pntNode.nodeType===11?0:(pntNode.getAttribute(tmplItmAtt)||0)):0;if(!(tmplItem=newTmplItems[key])){tmplItem=wrappedItems[key];tmplItem=newTmplItem(tmplItem,newTmplItems[pntNode]||wrappedItems[pntNode]);tmplItem.key=++itemKey;newTmplItems[itemKey]=tmplItem;}if(cloneIndex){cloneTmplItem(key);}}el.removeAttribute(tmplItmAtt);}else{if(cloneIndex&&(tmplItem=jQuery.data(el,"tmplItem"))){cloneTmplItem(tmplItem.key);newTmplItems[tmplItem.key]=tmplItem;pntNode=jQuery.data(el.parentNode,"tmplItem");pntNode=pntNode?pntNode.key:0;}}if(tmplItem){pntItem=tmplItem;while(pntItem&&pntItem.key!=pntNode){pntItem.nodes.push(el);pntItem=pntItem.parent;}delete tmplItem._ctnt;delete tmplItem._wrap;jQuery.data(el,"tmplItem",tmplItem);}function cloneTmplItem(key){key=key+keySuffix;tmplItem=newClonedItems[key]=(newClonedItems[key]||newTmplItem(tmplItem,newTmplItems[tmplItem.parent.key+keySuffix]||tmplItem.parent));}}}function tiCalls(content,tmpl,data,options){if(!content){return stack.pop();}stack.push({_:content,tmpl:tmpl,item:this,data:data,options:options});}function tiNest(tmpl,data,options){return jQuery.tmpl(jQuery.template(tmpl),data,options,this);}function tiWrap(call,wrapped){var options=call.options||{};options.wrapped=wrapped;return jQuery.tmpl(jQuery.template(call.tmpl),call.data,options,call.item);}function tiHtml(filter,textOnly){var wrapped=this._wrap;return jQuery.map(jQuery(jQuery.isArray(wrapped)?wrapped.join(""):wrapped).filter(filter||"*"),function(e){return textOnly?e.innerText||e.textContent:e.outerHTML||outerHtml(e);});}function tiUpdate(){var coll=this.nodes;jQuery.tmpl(null,null,null,this).insertBefore(coll[0]);jQuery(coll).remove();}})(jQuery);function hoozit(o){if(o.constructor===String){return"string";}else{if(o.constructor===Boolean){return"boolean";}else{if(o.constructor===Number){if(isNaN(o)){return"nan";}else{return"number";}}else{if(typeof o==="undefined"){return"undefined";}else{if(o===null){return"null";}else{if(o instanceof Array){return"array";}else{if(o instanceof Date){return"date";}else{if(o instanceof RegExp){return"regexp";}else{if(typeof o==="object"){return"object";}else{if(o instanceof Function){return"function";}else{return undefined;}}}}}}}}}}}function bindCallbacks(o,callbacks,args){var prop=hoozit(o);if(prop){if(hoozit(callbacks[prop])==="function"){return callbacks[prop].apply(callbacks,args);}else{return callbacks[prop];}}}var equiv=function(){var innerEquiv;var callers=[];var callbacks=function(){function useStrictEquality(b,a){if(b instanceof a.constructor||a instanceof b.constructor){return a==b;}else{return a===b;}}return{"string":useStrictEquality,"boolean":useStrictEquality,"number":useStrictEquality,"null":useStrictEquality,"undefined":useStrictEquality,"nan":function(b){return isNaN(b);},"date":function(b,a){return hoozit(b)==="date"&&a.valueOf()===b.valueOf();},"regexp":function(b,a){return hoozit(b)==="regexp"&&a.source===b.source&&a.global===b.global&&a.ignoreCase===b.ignoreCase&&a.multiline===b.multiline;},"function":function(){var caller=callers[callers.length-1];return caller!==Object&&typeof caller!=="undefined";},"array":function(b,a){var i;var len;if(!(hoozit(b)==="array")){return false;}len=a.length;if(len!==b.length){return false;}for(i=0;i0){input=$(this[0]);return input.data($.mask.dataName)();}settings=$.extend({placeholder:$.mask.placeholder,completed:null},settings);defs=$.mask.definitions;tests=[];partialPosition=len=mask.length;firstNonMaskPos=null;$.each(mask.split(""),function(i,c){if(c=="?"){len--;partialPosition=i;}else{if(defs[c]){tests.push(new RegExp(defs[c]));if(firstNonMaskPos===null){firstNonMaskPos=tests.length-1;}}else{tests.push(null);}}});return this.trigger("unmask").each(function(){var input=$(this),buffer=$.map(mask.split(""),function(c,i){if(c!="?"){return defs[c]?settings.placeholder:c;}}),focusText=input.val();function seekNext(pos){while(++pos=0&&!tests[pos]){}return pos;}function shiftL(begin,end){var i,j;if(begin<0){return;}for(i=begin,j=seekNext(end);i=len){settings.completed.call(input);}}}e.preventDefault();}}}function clearBuffer(start,end){var i;for(i=start;itest.length){break;}}else{if(buffer[i]===test.charAt(pos)&&i!==partialPosition){pos++;lastMatch=i;}}}if(allow){writeBuffer();}else{if(lastMatch+1=2){if(Alpaca.isObject(args[1])){data=args[1].data;schema=args[1].schema;options=args[1].options;view=args[1].view;callback=args[1].render;renderedCallback=args[1].postRender;errorCallback=args[1].error;connector=args[1].connector;dataSource=args[1].dataSource;schemaSource=args[1].schemaSource;optionsSource=args[1].optionsSource;viewSource=args[1].viewSource;if(args[1].ui){initialSettings["ui"]=args[1].ui;}if(args[1].type){initialSettings["type"]=args[1].type;}if(!Alpaca.isEmpty(args[1].notTopLevel)){notTopLevel=args[1].notTopLevel;}if(!Alpaca.isEmpty(args[1].isDynamicCreation)){isDynamicCreation=args[1].isDynamicCreation;}}else{data=args[1];if(Alpaca.isFunction(data)){data=data();}}}if(Alpaca.isEmpty(errorCallback)){errorCallback=Alpaca.defaultErrorCallback;}if(Alpaca.isEmpty(connector)){var connectorClass=Alpaca.getConnectorClass("default");connector=new connectorClass("default");}if(el){if(Alpaca.isString(el)){el=$("#"+el);}}var loadAllConnector=connector;if(notTopLevel){var loadAllConnectorClass=Alpaca.getConnectorClass("default");loadAllConnector=new loadAllConnectorClass("default");}if(!options){options={};}if(Alpaca.isUndefined(options.focus)){options.focus=false;}var _renderedCallback=function(control){if(options&&options.focus){window.setTimeout(function(){if(options.focus===true){if(control.children&&control.children.length>0){if(control.children[0].field&&control.children[0].field){control.children[0].field.focus();}}}else{var child=control.getControlByPath(options.focus);if(child&&child.field&&child.field.length>0){child.field.focus();}}},250);}if(renderedCallback){renderedCallback(control);}};loadAllConnector.loadAll({"data":data,"schema":schema,"options":options,"view":view,"dataSource":dataSource,"schemaSource":schemaSource,"optionsSource":optionsSource,"viewSource":viewSource},function(loadedData,loadedOptions,loadedSchema,loadedView){loadedData=loadedData?loadedData:data;loadedSchema=loadedSchema?loadedSchema:schema;loadedOptions=loadedOptions?loadedOptions:options;loadedView=loadedView?loadedView:view;if(Alpaca.isEmpty(loadedData)){if(Alpaca.isEmpty(loadedSchema)&&(Alpaca.isEmpty(loadedOptions)||Alpaca.isEmpty(loadedOptions.type))){loadedData="";if(Alpaca.isEmpty(loadedOptions)){loadedOptions="text";}else{if(options&&Alpaca.isObject(options)){loadedOptions.type="text";}}}}return Alpaca.init(el,loadedData,loadedOptions,loadedSchema,loadedView,initialSettings,callback,_renderedCallback,connector,errorCallback,isDynamicCreation);},function(loadError){errorCallback(loadError);return null;});return $(el);};Alpaca.Fields={};Alpaca.Connectors={};Alpaca.Extend=$.extend;Alpaca.Create=function(){var args=Array.prototype.slice.call(arguments);args.unshift({});return $.extend.apply(this,args);};Alpaca.Extend(Alpaca,{VERSION:"0.1.0",makeArray:function(nonArray){return Array.prototype.slice.call(nonArray);},isFunction:function(obj){return Object.prototype.toString.call(obj)==="[object Function]";},isString:function(obj){return(typeof obj==="string");},isObject:function(obj){return !Alpaca.isUndefined(obj)&&Object.prototype.toString.call(obj)==="[object Object]";},isPlainObject:function(obj){return $.isPlainObject(obj);},isNumber:function(obj){return(typeof obj==="number");},isArray:function(obj){return obj instanceof Array;},isBoolean:function(obj){return(typeof obj==="boolean");},isUndefined:function(obj){return(typeof obj==="undefined");},trim:function(text){var trimmed=text;if(trimmed&&Alpaca.isString(trimmed)){trimmed=trimmed.replace(/^\s+|\s+$/g,"");}return trimmed;},safeDomParse:function(x){if(x&&Alpaca.isString(x)){x=Alpaca.trim(x);var converted=null;try{converted=$(x);}catch(e){x="
"+x+"
";converted=$(x).children();}return converted;}return x;},isEmpty:function(obj){return Alpaca.isUndefined(obj)||obj===null;},copyOf:function(thing){var copy=thing;if(Alpaca.isArray(thing)){copy=[];for(var i=0;i");if(domAttributes){el.attr(domAttributes);}if(styleAttributes){el.css(styleAttributes);}if(classNames){for(var className in classNames){el.addClass(className);}}},elementFromTemplate:function(template,substitutions){var html=template;if(substitutions){for(var x in substitutions){html=Alpaca.replaceAll(html,"${"+x+"}",substitutions[x]);}}return $(html);},generateId:function(){Alpaca.uniqueIdCounter++;return"alpaca"+Alpaca.uniqueIdCounter;},later:function(when,o,fn,data,periodic){when=when||0;o=o||{};var m=fn,d=$.makeArray(data),f,r;if(typeof fn==="string"){m=o[fn];}if(!m){throw {name:"TypeError",message:"The function is undefined."};}f=function(){m.apply(o,d);};r=(periodic)?setInterval(f,when):setTimeout(f,when);return{id:r,interval:periodic,cancel:function(){if(this.interval){clearInterval(r);}else{clearTimeout(r);}}};},endsWith:function(text,suffix){return text.indexOf(suffix,text.length-suffix.length)!==-1;},startsWith:function(text,prefix){return text.substr(0,prefix.length)===prefix;},isUri:function(obj){return Alpaca.isString(obj)&&(Alpaca.startsWith(obj,"http://")||Alpaca.startsWith(obj,"https://")||Alpaca.startsWith(obj,"/")||Alpaca.startsWith(obj,"./")||Alpaca.startsWith(obj,"../"));},traverseObject:function(object,keys,subprop){if(Alpaca.isString(keys)){keys=keys.split(".");}var element=null;var current=object;var key=null;do{key=keys.shift();if(subprop&&key==subprop){key=keys.shift();}if(!Alpaca.isEmpty(current[key])){current=current[key];if(keys.length===0){element=current;}}else{keys=[];}}while(keys.length>0);return element;},each:function(data,func){if(Alpaca.isArray(data)){for(var i=0;i-1){var nt=text.substring(0,x)+args[i]+text.substring(x+3);text=nt;}}}return text;},compareObject:function(obj1,obj2){return equiv(obj1,obj2);},compareArrayContent:function(arr_1,arr_2){var equal=arr_1&&arr_2&&(arr_1.length==arr_2.length);if(equal){$.each(arr_1,function(foo,val){if(!equal){return false;}if($.inArray(val,arr_2)==-1){equal=false;}else{equal=true;}});}return equal;},isValEmpty:function(val){var empty=false;if(Alpaca.isEmpty(val)){empty=true;}else{if(Alpaca.isString(val)&&val===""){empty=true;}if(Alpaca.isObject(val)&&$.isEmptyObject(val)){empty=true;}if(Alpaca.isArray(val)&&val.length===0){empty=true;}if(Alpaca.isNumber(val)&&isNaN(val)){empty=true;}}return empty;},init:function(el,data,options,schema,view,initialSettings,callback,renderedCallback,connector,errorCallback,isDynamicCreation){var self=this;if(Alpaca.isObject(view)){var viewId=view.id;if(!viewId){view.id=this.generateViewId();}var parentId=view.parent;if(!parentId){view.parent="VIEW_WEB_EDIT";}this.registerView(view);view=view.id;}this.compile(function(report){if(report.errors&&report.errors.length>0){for(var i=0;i3){options.type="select";}else{options.type="radio";}}else{options.type=Alpaca.defaultSchemaFieldMapping[schema.type];}if(schema.format&&Alpaca.defaultFormatFieldMapping[schema.format]){options.type=Alpaca.defaultFormatFieldMapping[schema.format];}}var fieldClass=Alpaca.getFieldClass(options.type);if(!fieldClass){errorCallback({"message":"Unable to find field class for type: "+options.type,"reason":"FIELD_INSTANTIATION_ERROR"});return null;}return new fieldClass(el,data,options,schema,view,connector,errorCallback);},parseJSON:function(text){if(!text){return null;}return $.parseJSON(text);},compile:function(cb,errorCallback){var self=this;var report={"errors":[],"count":0,"successCount":0};var finalCallback=function(normalizedViews){if(report.errors.length===0){for(var k in normalizedViews){self.normalizedViews[k]=normalizedViews[k];}}cb(report);};var viewCompileCallback=function(normalizedViews,err,view,compiledTemplateId,cacheKey,totalCalls){var viewId=view.id;report.count++;if(err){report.errors.push({"view":viewId,"template":compiledTemplateId,"err":err});}else{report.successCount++;view.compiledTemplates[compiledTemplateId]=cacheKey;}if(report.count==totalCalls){finalCallback(normalizedViews);}};var compileViewTemplate=function(normalizedViews,view,compiledTemplateId,template,totalCalls){var viewId=view.id;var mightBeUrl=(template&&template.indexOf("/")>-1);if(mightBeUrl){}else{if(template&&((template.indexOf("#")===0)||(template.indexOf(".")===0))){var x=$(template);type=$(x).attr("type");template=$(x).html();}}var type=null;if(Alpaca.isObject(template)){type=template.type;template=template.template;}if(!type){type="text/x-jquery-tmpl";}var engine=Alpaca.TemplateEngineRegistry.find(type);if(!engine){Alpaca.logError("Cannot find template engine for type: "+type);var err=new Error("Cannot find template engine for type: "+type);viewCompileCallback(normalizedViews,err,view,compiledTemplateId,cacheKey,totalCalls);}var cacheKey=viewId+"_"+compiledTemplateId;if(engine.isCached(cacheKey)){viewCompileCallback(normalizedViews,null,view,compiledTemplateId,cacheKey,totalCalls);}else{var previouslyCompiledTemplateCacheKey=view.compiledTemplates["view-"+template];if(previouslyCompiledTemplateCacheKey){template=Alpaca.TemplateCache[previouslyCompiledTemplateCacheKey];}engine.compile(cacheKey,template,function(err,data){viewCompileCallback(normalizedViews,err,view,compiledTemplateId,cacheKey,totalCalls);});}};var compileTemplates=function(normalizedViews){var functionArray=[];for(var viewId in normalizedViews){var view=normalizedViews[viewId];view.compiledTemplates={};if(view.templates){for(var templateId in view.templates){var template=view.templates[templateId];functionArray.push(function(normalizedViews,view,compiledTemplateId,template){return function(totalCalls){compileViewTemplate(normalizedViews,view,compiledTemplateId,template,totalCalls);};}(normalizedViews,view,"view-"+templateId,template));}}if(view.fields){for(var path in view.fields){if(view.fields[path].templates){for(var templateId in view.fields[path].templates){var template=view.fields[path].templates[templateId];functionArray.push(function(normalizedViews,view,compiledTemplateId,template){return function(totalCalls){compileViewTemplate(normalizedViews,view,compiledTemplateId,template,totalCalls);};}(normalizedViews,view,"field-"+path+"-"+templateId,template));}}}}if(view.layout&&view.layout.template){var template=view.layout.template;functionArray.push(function(normalizedViews,view,compiledTemplateId,template){return function(totalCalls){compileViewTemplate(normalizedViews,view,compiledTemplateId,template,totalCalls);};}(normalizedViews,view,"layoutTemplate",template));}if(view.globalTemplate){var template=view.globalTemplate;functionArray.push(function(normalizedViews,view,compiledTemplateId,template){return function(totalCalls){compileViewTemplate(normalizedViews,view,compiledTemplateId,template,totalCalls);};}(normalizedViews,view,"globalTemplate",template));}}var totalCalls=functionArray.length;for(var i=0;i0){compileTemplates(normalizedViews);}else{finalCallback(normalizedViews);}};normalizeViews();},getTemplateDescriptor:function(view,templateId,field){var descriptor={};var _template;var _templateType;if(view.templates&&view.templates[templateId]){_template=view.templates[templateId];_templateType="view";}if(field&&field.path){var path=field.path;if(view&&view.fields&&view.fields[path]&&view.fields[path].templates&&view.fields[path].templates[templateId]){_template=view.fields[path].templates[templateId];_templateType="field";}}if(templateId=="globalTemplate"){_template="globalTemplate";_templateType="global";}if(templateId=="layoutTemplate"){_template="layoutTemplate";_templateType="layout";}descriptor.template={};descriptor.template.id=templateId;descriptor.template.type=_templateType;descriptor.template.value=_template;var type=null;var template=_template;if(Alpaca.isObject(template)){type=template.type;template=template.template;}if(!type){type="text/x-jquery-tmpl";}var engine=Alpaca.TemplateEngineRegistry.find(type);if(!engine){return Alpaca.throwDefaultError("Cannot find template engine for type: "+type);}descriptor.engine={};descriptor.engine.type=type;descriptor.engine.id=engine.id;var compiledTemplateId=null;if(_templateType=="view"){compiledTemplateId="view-"+templateId;}else{if(_templateType=="field"){compiledTemplateId="field-"+field.path+"-"+templateId;}else{if(_templateType=="layout"){compiledTemplateId="layoutTemplate";}else{if(_templateType=="global"){compiledTemplateId="globalTemplate";}}}}descriptor.compiledTemplateId=compiledTemplateId;var cacheKey=view.compiledTemplates[compiledTemplateId];if(!cacheKey||!engine.isCached(cacheKey)){return null;}descriptor.cache={};descriptor.cache.key=cacheKey;return descriptor;},tmpl:function(templateDescriptor,model){var html=Alpaca.tmplHtml(templateDescriptor,model);return Alpaca.safeDomParse(html);},tmplHtml:function(templateDescriptor,model){if(!model){model={};}var engineType=templateDescriptor.engine.type;var compiledTemplateId=templateDescriptor.compiledTemplateId;var engine=Alpaca.TemplateEngineRegistry.find(engineType);if(!engine){return Alpaca.throwDefaultError("Cannot find template engine for type: "+engineType);}var cacheKey=templateDescriptor.cache.key;var html=engine.execute(cacheKey,model,function(err){return Alpaca.throwDefaultError("The compiled template: "+compiledTemplateId+" failed to execute: "+JSON.stringify(err));});return html;}});Alpaca.DEBUG=0;Alpaca.INFO=1;Alpaca.WARN=2;Alpaca.ERROR=3;Alpaca.logLevel=Alpaca.WARN;Alpaca.logDebug=function(obj){Alpaca.log(Alpaca.DEBUG,obj);};Alpaca.logInfo=function(obj){Alpaca.log(Alpaca.INFO,obj);};Alpaca.logWarn=function(obj){Alpaca.log(Alpaca.WARN,obj);};Alpaca.logError=function(obj){Alpaca.log(Alpaca.ERROR,obj);};Alpaca.LOG_METHOD_MAP={0:"debug",1:"info",2:"warn",3:"error"};Alpaca.log=function(level,obj){if(Alpaca.logLevel<=level){var method=Alpaca.LOG_METHOD_MAP[level];if(typeof console!=="undefined"&&console[method]){if("debug"==method){console.debug(obj);}else{if("info"==method){console.info(obj);}else{if("warn"==method){console.warn(obj);}else{if("error"==method){console.error(obj);}else{console.log(obj);}}}}}}};Alpaca.checked=function(el,value){return Alpaca.attrProp(el,"checked",value);};Alpaca.attrProp=function(el,name,value){if(!(typeof(value)==="undefined")){if($(el).prop){$(el).prop(name,value);}else{if(value){$(el).attr(name,value);}else{$(el).removeAttr(name);}}}if($(el).prop){return $(el).prop(name);}return $(el).attr(name);};Alpaca.loadRefSchemaOptions=function(topField,referenceId,callback){if(!referenceId){callback();}else{if(referenceId=="#"){callback(topField.schema,topField.options);}else{if(referenceId.indexOf("#/")==0){var defId=referenceId.substring(2);var tokens=defId.split("/");var defSchema=topField.schema;for(var i=0;i").append(this).html();}else{return $("
").append(this.clone()).html();}};$.fn.swapWith=function(to){return this.each(function(){var copy_to=$(to).clone();var copy_from=$(this).clone();$(to).replaceWith(copy_from);$(this).replaceWith(copy_to);});};$.fn.attrProp=function(name,value){return Alpaca.attrProp($(this),name,value);};$.event.special.destroyed={remove:function(o){if(o.handler){o.handler();}}};Alpaca.CountersMap={};Alpaca.Counters=function(name){if(Alpaca.Counters[name]){return Alpaca.Counters[name];}var types={};var all={count:0,total:0,avg:0,touches:0};var counters={increment:function(type,amount){if(!types[type]){types[type]={count:0,total:0,avg:0,touches:0};}types[type].count++;types[type].total+=amount;types[type].avg=types[type].total/types[type].count;types[type].touches++;all.count++;all.total+=amount;all.avg=all.total/all.count;all.touches++;},read:function(type){return types[type];},each:function(f){for(var type in types){f(type,types[type]);}},all:function(){return all;}};Alpaca.Counters[name]=counters;return counters;};Alpaca.collectTiming=false;Alpaca.pathParts=function(resource){if(typeof(resource)!="string"){return resource;}var resourcePath=resource;var resourceId=null;var i=resourcePath.indexOf("#");if(i>-1){resourceId=resourcePath.substring(i+1);resourcePath=resourcePath.substring(0,i);}if(Alpaca.endsWith(resourcePath,"/")){resourcePath=resourcePath.substring(0,resourcePath.length-1);}var parts={};parts.path=resourcePath;if(resourceId){parts.id=resourceId;}return parts;};Alpaca.resolveField=function(containerField,propertyIdOrReferenceId){var resolvedField=null;if(typeof(propertyIdOrReferenceId)=="string"){if(propertyIdOrReferenceId.indexOf("#/")==0&&propertyId.length>2){}else{if(propertyIdOrReferenceId=="#"||propertyIdOrReferenceId=="#/"){resolvedField=containerField;}else{if(propertyIdOrReferenceId.indexOf("#")==0){var topField=containerField;while(topField.parent){topField=topField.parent;}var referenceId=propertyIdOrReferenceId.substring(1);resolvedField=Alpaca.resolveFieldByReference(topField,referenceId);}else{resolvedField=containerField.childrenByPropertyId[propertyIdOrReferenceId];}}}}return resolvedField;};Alpaca.resolveFieldByReference=function(field,referenceId){if(field.schema&&field.schema.id==referenceId){return field;}else{if(field.children&&field.children.length>0){for(var i=0;i1){var childChain=chain.slice(0);childChain.shift();f(childChain,context);}var previouslyValidated=current._previouslyValidated;current.validate();current._validateCustomValidator(function(){var afterStatus=current.isValid();if(current.isContainer()){afterStatus=current.isValid(true);}entry.after=afterStatus;entry.validated=false;entry.invalidated=false;if(!beforeStatus&&afterStatus){entry.validated=true;}else{if(beforeStatus&&!afterStatus){entry.invalidated=true;}else{if(!previouslyValidated&&!afterStatus){entry.invalidated=true;}}}entry.container=current.isContainer();entry.valid=entry.after;context.push(entry);});};f(chain,context);return context;};Alpaca.updateValidationStateForContext=function(context){for(var i=0;i0){for(var i=0;i=arr.length){callback(null);}}}));});};async.forEach=async.each;async.eachSeries=function(arr,iterator,callback){callback=callback||function(){};if(!arr.length){return callback();}var completed=0;var iterate=function(){iterator(arr[completed],function(err){if(err){callback(err);callback=function(){};}else{completed+=1;if(completed>=arr.length){callback(null);}else{iterate();}}});};iterate();};async.forEachSeries=async.eachSeries;async.eachLimit=function(arr,limit,iterator,callback){var fn=_eachLimit(limit);fn.apply(null,[arr,iterator,callback]);};async.forEachLimit=async.eachLimit;var _eachLimit=function(limit){return function(arr,iterator,callback){callback=callback||function(){};if(!arr.length||limit<=0){return callback();}var completed=0;var started=0;var running=0;(function replenish(){if(completed>=arr.length){return callback();}while(running=arr.length){callback();}else{replenish();}}});}})();};};var doParallel=function(fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[async.each].concat(args));};};var doParallelLimit=function(limit,fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[_eachLimit(limit)].concat(args));};};var doSeries=function(fn){return function(){var args=Array.prototype.slice.call(arguments);return fn.apply(null,[async.eachSeries].concat(args));};};var _asyncMap=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x};});eachfn(arr,function(x,callback){iterator(x.value,function(err,v){results[x.index]=v;callback(err);});},function(err){callback(err,results);});};async.map=doParallel(_asyncMap);async.mapSeries=doSeries(_asyncMap);async.mapLimit=function(arr,limit,iterator,callback){return _mapLimit(limit)(arr,iterator,callback);};var _mapLimit=function(limit){return doParallelLimit(limit,_asyncMap);};async.reduce=function(arr,memo,iterator,callback){async.eachSeries(arr,function(x,callback){iterator(memo,x,function(err,v){memo=v;callback(err);});},function(err){callback(err,memo);});};async.inject=async.reduce;async.foldl=async.reduce;async.reduceRight=function(arr,memo,iterator,callback){var reversed=_map(arr,function(x){return x;}).reverse();async.reduce(reversed,memo,iterator,callback);};async.foldr=async.reduceRight;var _filter=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x};});eachfn(arr,function(x,callback){iterator(x.value,function(v){if(v){results.push(x);}callback();});},function(err){callback(_map(results.sort(function(a,b){return a.index-b.index;}),function(x){return x.value;}));});};async.filter=doParallel(_filter);async.filterSeries=doSeries(_filter);async.select=async.filter;async.selectSeries=async.filterSeries;var _reject=function(eachfn,arr,iterator,callback){var results=[];arr=_map(arr,function(x,i){return{index:i,value:x};});eachfn(arr,function(x,callback){iterator(x.value,function(v){if(!v){results.push(x);}callback();});},function(err){callback(_map(results.sort(function(a,b){return a.index-b.index;}),function(x){return x.value;}));});};async.reject=doParallel(_reject);async.rejectSeries=doSeries(_reject);var _detect=function(eachfn,arr,iterator,main_callback){eachfn(arr,function(x,callback){iterator(x,function(result){if(result){main_callback(x);main_callback=function(){};}else{callback();}});},function(err){main_callback();});};async.detect=doParallel(_detect);async.detectSeries=doSeries(_detect);async.some=function(arr,iterator,main_callback){async.each(arr,function(x,callback){iterator(x,function(v){if(v){main_callback(true);main_callback=function(){};}callback();});},function(err){main_callback(false);});};async.any=async.some;async.every=function(arr,iterator,main_callback){async.each(arr,function(x,callback){iterator(x,function(v){if(!v){main_callback(false);main_callback=function(){};}callback();});},function(err){main_callback(true);});};async.all=async.every;async.sortBy=function(arr,iterator,callback){async.map(arr,function(x,callback){iterator(x,function(err,criteria){if(err){callback(err);}else{callback(null,{value:x,criteria:criteria});}});},function(err,results){if(err){return callback(err);}else{var fn=function(left,right){var a=left.criteria,b=right.criteria;return ab?1:0;};callback(null,_map(results.sort(fn),function(x){return x.value;}));}});};async.auto=function(tasks,callback){callback=callback||function(){};var keys=_keys(tasks);if(!keys.length){return callback(null);}var results={};var listeners=[];var addListener=function(fn){listeners.unshift(fn);};var removeListener=function(fn){for(var i=0;i2){var args=Array.prototype.slice.call(arguments,2);return go.apply(this,args);}else{return go;}};async.applyEach=doParallel(_applyEach);async.applyEachSeries=doSeries(_applyEach);async.forever=function(fn,callback){function next(err){if(err){if(callback){return callback(err);}throw err;}fn(next);}next();};root.async=async;}());})(jQuery);(function(){Alpaca.TemplateEngineRegistry=function(){var registry={};return{register:function(id,engine){registry[id]=engine;},find:function(idOrType){var engine=null;if(registry[idOrType]){engine=registry[idOrType];}else{for(var id in registry){var supportedMimetypes=registry[id].supportedMimetypes();for(var i=0;i"+html+"<\/script>";}Alpaca.logDebug("Compiling template: "+this.id+", cacheKey: "+cacheKey+", template: "+html);this.doCompile(cacheKey,html,callback);},doCompile:function(cacheKey,html,callback){},execute:function(cacheKey,model,callback){Alpaca.logDebug("Executing template for cache key: "+cacheKey);var dom=this.doExecute(cacheKey,model,callback);var strip_script=function(dom){if($(dom).length==1){if($(dom)[0].nodeName.toLowerCase()=="script"){return $(dom).html();}}return html;};dom=strip_script(dom);return dom;},doExecute:function(cacheKey,model,callback){},fileExtension:function(){return"html";},supportedMimetypes:function(){return[];},isCached:function(cacheKey){}});})(jQuery);(function($){Alpaca.JQueryTemplateEngine=Alpaca.AbstractTemplateEngine.extend({fileExtension:function(){return"html";},supportedMimetypes:function(){return["text/x-jquery-template","text/x-jquery-tmpl"];},doCompile:function(cacheKey,html,callback){try{$.template(cacheKey,html);}catch(e){callback(e);return;}Alpaca.TemplateCache[cacheKey]=html;callback();},doExecute:function(cacheKey,model,callback){var self=this;var html=null;try{var dom=$.tmpl(cacheKey,model);var _html=dom.outerHTML();var i=-1;do{i=_html.indexOf("_tmplitem=");if(i>-1){var j=_html.indexOf(" ",i);if(j==-1){j=_html.indexOf(">",i);}if(j==-1){callback({"message":"Should have found closing whitespace or '>' for _tmplitem attribute"});return;}_html=_html.substring(0,i)+_html.substring(j);}}while(i>-1);dom=Alpaca.safeDomParse(_html);html=dom;}catch(e){callback({"message":e.message});return null;}return html;},isCached:function(cacheKey){return(Alpaca.TemplateCache[cacheKey]?true:false);}});Alpaca.TemplateEngineRegistry.register("tmpl",new Alpaca.JQueryTemplateEngine("tmpl"));})(jQuery);(function($){Alpaca.EJSTemplateEngine=Alpaca.AbstractTemplateEngine.extend({fileExtension:function(){return"ejs";},supportedMimetypes:function(){return["text/x-ejs-template","text/x-ejs-tmpl"];},doCompile:function(cacheKey,html,callback){var ejs=null;try{ejs=new EJS({name:cacheKey,text:html});}catch(e){callback(e);return;}Alpaca.TemplateCache[cacheKey]=ejs;callback();},doExecute:function(cacheKey,model,callback){var ejs=Alpaca.TemplateCache[cacheKey];var html=null;try{html=ejs.render(model);}catch(e){callback(e);return null;}return html;},isCached:function(cacheKey){return(Alpaca.TemplateCache[cacheKey]?true:false);}});Alpaca.TemplateEngineRegistry.register("ejs",new Alpaca.EJSTemplateEngine("ejs"));})(jQuery);(function($){Alpaca.HandlebarsTemplateEngine=Alpaca.AbstractTemplateEngine.extend({fileExtension:function(){return"html";},supportedMimetypes:function(){return["text/x-handlebars-template","text/x-handlebars-tmpl"];},doCompile:function(cacheKey,html,callback){var template=null;try{template=Handlebars.compile(html);}catch(e){callback(e);return;}Alpaca.TemplateCache[cacheKey]=template;callback();},doExecute:function(cacheKey,model,callback){var template=Alpaca.TemplateCache[cacheKey];var html=null;try{html=template(model);}catch(e){callback(e);return null;}return html;},isCached:function(cacheKey){return(Alpaca.TemplateCache[cacheKey]?true:false);}});Alpaca.TemplateEngineRegistry.register("handlebars",new Alpaca.HandlebarsTemplateEngine("handlebars"));})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.styleInjections={};Alpaca.registerView({"id":"VIEW_BASE","title":"Abstract base view","description":"Foundation view which provides an abstract view from which all other views extend.","messages":{"countries":{"afg":"Afghanistan","ala":"Aland Islands","alb":"Albania","dza":"Algeria","asm":"American Samoa","and":"Andorra","ago":"Angola","aia":"Anguilla","ata":"Antarctica","atg":"Antigua and Barbuda","arg":"Argentina","arm":"Armenia","abw":"Aruba","aus":"Australia","aut":"Austria","aze":"Azerbaijan","bhs":"Bahamas","bhr":"Bahrain","bgd":"Bangladesh","brb":"Barbados","blr":"Belarus","bel":"Belgium","blz":"Belize","ben":"Benin","bmu":"Bermuda","btn":"Bhutan","bol":"Bolivia","bih":"Bosnia and Herzegovina","bwa":"Botswana","bvt":"Bouvet Island","bra":"Brazil","iot":"British Indian Ocean Territory","brn":"Brunei Darussalam","bgr":"Bulgaria","bfa":"Burkina Faso","bdi":"Burundi","khm":"Cambodia","cmr":"Cameroon","can":"Canada","cpv":"Cape Verde","cym":"Cayman Islands","caf":"Central African Republic","tcd":"Chad","chl":"Chile","chn":"China","cxr":"Christmas Island","cck":"Cocos (Keeling), Islands","col":"Colombia","com":"Comoros","cog":"Congo","cod":"Congo, the Democratic Republic of the","cok":"Cook Islands","cri":"Costa Rica","hrv":"Croatia","cub":"Cuba","cyp":"Cyprus","cze":"Czech Republic","civ":"Cote d'Ivoire","dnk":"Denmark","dji":"Djibouti","dma":"Dominica","dom":"Dominican Republic","ecu":"Ecuador","egy":"Egypt","slv":"El Salvador","gnq":"Equatorial Guinea","eri":"Eritrea","est":"Estonia","eth":"Ethiopia","flk":"Falkland Islands (Malvinas),","fro":"Faroe Islands","fji":"Fiji","fin":"Finland","fra":"France","guf":"French Guiana","pyf":"French Polynesia","atf":"French Southern Territories","gab":"Gabon","gmb":"Gambia","geo":"Georgia","deu":"Germany","gha":"Ghana","gib":"Gibraltar","grc":"Greece","grl":"Greenland","grd":"Grenada","glp":"Guadeloupe","gum":"Guam","gtm":"Guatemala","ggy":"Guernsey","gin":"Guinea","gnb":"Guinea-Bissau","guy":"Guyana","hti":"Haiti","hmd":"Heard Island and McDonald Islands","vat":"Holy See (Vatican City State),","hnd":"Honduras","hkg":"Hong Kong","hun":"Hungary","isl":"Iceland","ind":"India","idn":"Indonesia","irn":"Iran, Islamic Republic of","irq":"Iraq","irl":"Ireland","imn":"Isle of Man","isr":"Israel","ita":"Italy","jam":"Jamaica","jpn":"Japan","jey":"Jersey","jor":"Jordan","kaz":"Kazakhstan","ken":"Kenya","kir":"Kiribati","prk":"Korea, Democratic People's Republic of","kor":"Korea, Republic of","kwt":"Kuwait","kgz":"Kyrgyzstan","lao":"Lao People's Democratic Republic","lva":"Latvia","lbn":"Lebanon","lso":"Lesotho","lbr":"Liberia","lby":"Libyan Arab Jamahiriya","lie":"Liechtenstein","ltu":"Lithuania","lux":"Luxembourg","mac":"Macao","mkd":"Macedonia, the former Yugoslav Republic of","mdg":"Madagascar","mwi":"Malawi","mys":"Malaysia","mdv":"Maldives","mli":"Mali","mlt":"Malta","mhl":"Marshall Islands","mtq":"Martinique","mrt":"Mauritania","mus":"Mauritius","myt":"Mayotte","mex":"Mexico","fsm":"Micronesia, Federated States of","mda":"Moldova, Republic of","mco":"Monaco","mng":"Mongolia","mne":"Montenegro","msr":"Montserrat","mar":"Morocco","moz":"Mozambique","mmr":"Myanmar","nam":"Namibia","nru":"Nauru","npl":"Nepal","nld":"Netherlands","ant":"Netherlands Antilles","ncl":"New Caledonia","nzl":"New Zealand","nic":"Nicaragua","ner":"Niger","nga":"Nigeria","niu":"Niue","nfk":"Norfolk Island","mnp":"Northern Mariana Islands","nor":"Norway","omn":"Oman","pak":"Pakistan","plw":"Palau","pse":"Palestinian Territory, Occupied","pan":"Panama","png":"Papua New Guinea","pry":"Paraguay","per":"Peru","phl":"Philippines","pcn":"Pitcairn","pol":"Poland","prt":"Portugal","pri":"Puerto Rico","qat":"Qatar","rou":"Romania","rus":"Russian Federation","rwa":"Rwanda","reu":"Reunion","blm":"Saint Barthelemy","shn":"Saint Helena","kna":"Saint Kitts and Nevis","lca":"Saint Lucia","maf":"Saint Martin (French part)","spm":"Saint Pierre and Miquelon","vct":"Saint Vincent and the Grenadines","wsm":"Samoa","smr":"San Marino","stp":"Sao Tome and Principe","sau":"Saudi Arabia","sen":"Senegal","srb":"Serbia","syc":"Seychelles","sle":"Sierra Leone","sgp":"Singapore","svk":"Slovakia","svn":"Slovenia","slb":"Solomon Islands","som":"Somalia","zaf":"South Africa","sgs":"South Georgia and the South Sandwich Islands","esp":"Spain","lka":"Sri Lanka","sdn":"Sudan","sur":"Suriname","sjm":"Svalbard and Jan Mayen","swz":"Swaziland","swe":"Sweden","che":"Switzerland","syr":"Syrian Arab Republic","twn":"Taiwan, Province of China","tjk":"Tajikistan","tza":"Tanzania, United Republic of","tha":"Thailand","tls":"Timor-Leste","tgo":"Togo","tkl":"Tokelau","ton":"Tonga","tto":"Trinidad and Tobago","tun":"Tunisia","tur":"Turkey","tkm":"Turkmenistan","tca":"Turks and Caicos Islands","tuv":"Tuvalu","uga":"Uganda","ukr":"Ukraine","are":"United Arab Emirates","gbr":"United Kingdom","usa":"United States","umi":"United States Minor Outlying Islands","ury":"Uruguay","uzb":"Uzbekistan","vut":"Vanuatu","ven":"Venezuela","vnm":"Viet Nam","vgb":"Virgin Islands, British","vir":"Virgin Islands, U.S.","wlf":"Wallis and Futuna","esh":"Western Sahara","yem":"Yemen","zmb":"Zambia","zwe":"Zimbabwe"},"empty":"","required":"This field is required","valid":"","invalid":"This field is invalid","months":["January","February","March","April","May","June","July","August","September","October","November","December"],"timeUnits":{SECOND:"seconds",MINUTE:"minutes",HOUR:"hours",DAY:"days",MONTH:"months",YEAR:"years"}}});Alpaca.EmptyViewTemplates={};})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.styleInjections={};var displayTemplates=Alpaca.Create(Alpaca.EmptyViewTemplates,{"controlField":'
{{if options.label}}
${options.label}
{{/if}}
 ${data}
',"fieldSetOuterEl":'
{{html this.html}}
',"fieldSetLegend":'{{if options.label}}
${options.label}
{{/if}}',"fieldSetItemsContainer":"
{{html this.html}}
","fieldSet":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',"controlFieldContainer":"
{{html this.html}}
"});var editTemplates=Alpaca.Create(Alpaca.EmptyViewTemplates,{"controlFieldOuterEl":"{{html this.html}}","controlFieldMessage":'
${message}
',"controlFieldLabel":'{{if options.label}}
${options.label}
{{/if}}',"controlFieldHelper":'{{if options.helper}}
${options.helper}
{{/if}}',"controlFieldContainer":"
{{html this.html}}
","controlField":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',"fieldSetOuterEl":"
{{html this.html}}
","fieldSetMessage":'
${message}
',"fieldSetLegend":'{{if options.label}}${options.label}{{/if}}',"fieldSetHelper":'{{if options.helper}}
${options.helper}
{{/if}}',"fieldSetItemsContainer":"
{{html this.html}}
","fieldSet":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',"fieldSetItemContainer":"
","formFieldsContainer":"
{{html this.html}}
","formButtonsContainer":'
{{if options.buttons}}{{each(k,v) options.buttons}}{{/each}}{{/if}}
',"form":'
{{html Alpaca.fieldTemplate(this,"formFieldsContainer")}}{{html Alpaca.fieldTemplate(this,"formButtonsContainer")}}
',"wizardStep":'
',"wizardNavBar":"
","wizardPreButton":"","wizardNextButton":"","wizardDoneButton":"","wizardStatusBar":'
    {{each(i,v) titles}}
  1. ${v.title}${v.description}
  2. {{/each}}
'});Alpaca.registerView({"id":"VIEW_WEB_DISPLAY","parent":"VIEW_BASE","title":"Default Web Display View","description":"Default web edit view which goes though field hierarchy.","type":"view","platform":"web","displayReadonly":true,"templates":displayTemplates});Alpaca.registerView({"id":"VIEW_WEB_EDIT","parent":"VIEW_BASE","title":"Default Web Edit View","description":"Default web edit view which goes though field hierarchy.","type":"edit","platform":"web","displayReadonly":true,"templates":editTemplates});Alpaca.registerView({"id":"VIEW_WEB_CREATE","parent":"VIEW_WEB_EDIT","title":"Default Web Create View","description":"Default web create view which doesn't bind initial data.","type":"create","displayReadonly":false});})(jQuery);(function($){var Alpaca=$.alpaca;var displayTemplates=Alpaca.Create(Alpaca.EmptyViewTemplates,{"controlFieldOuterEl":'{{html this.html}}',"controlFieldMessage":'
${message}
',"controlFieldLabel":'{{if options.label}}{{/if}}',"controlFieldHelper":'{{if options.helper}}
${options.helper}
{{/if}}',"controlFieldContainer":"
{{html this.html}}
","controlField":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',"fieldSetOuterEl":'
{{html this.html}}
',"fieldSetMessage":'
${message}
',"fieldSetLegend":'{{if options.label}}${options.label}{{/if}}',"fieldSetHelper":'{{if options.helper}}
${options.helper}
{{/if}}',"fieldSetItemsContainer":"
    {{html this.html}}
","fieldSet":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',"fieldSetItemContainer":'
  • ',"itemLabel":'{{if options.itemLabel}}{{/if}}'});var editTemplates=Alpaca.Create(Alpaca.EmptyViewTemplates,{"controlFieldOuterEl":'{{html this.html}}',"controlFieldMessage":'
    ${message}
    ',"controlFieldLabel":'{{if options.label}}{{/if}}',"controlFieldHelper":'{{if options.helper}}
    ${options.helper}
    {{/if}}',"controlFieldContainer":"
    {{html this.html}}
    ","controlField":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',"fieldSetOuterEl":'
    {{html this.html}}
    ',"fieldSetMessage":'
    ${message}
    ',"fieldSetLegend":'{{if options.label}}${options.label}{{/if}}',"fieldSetHelper":'{{if options.helper}}
    ${options.helper}
    {{/if}}',"fieldSetItemsContainer":"
      {{html this.html}}
    ","fieldSet":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',"fieldSetItemContainer":'
  • ',"itemLabel":'{{if options.itemLabel}}{{/if}}'});Alpaca.registerView({"id":"VIEW_WEB_DISPLAY_LIST","parent":"VIEW_WEB_DISPLAY","title":"Web Display View List Style","description":"Web display view based on list styles.","legendStyle":"link","templates":displayTemplates,"styles":{},"fields":{"/":{"templates":{"fieldSetItemsContainer":'
      {{html this.html}}
    ',"fieldSetItemContainer":'
  • '}}}});Alpaca.registerView({"id":"VIEW_WEB_EDIT_LIST","parent":"VIEW_WEB_EDIT","title":"Web Edit View List Style","description":"Web edit view based on list styles.","legendStyle":"link","templates":editTemplates,"styles":{},"fields":{"/":{"templates":{"fieldSetItemsContainer":'
      {{html this.html}}
    ',"fieldSetItemContainer":'
  • '}}}});Alpaca.registerView({"id":"VIEW_WEB_CREATE_LIST","parent":"VIEW_WEB_CREATE","title":"Web Create View List Style","description":"Web create view based on list styles.","legendStyle":"link","templates":editTemplates,"styles":{},"fields":{"/":{"templates":{"fieldSetItemsContainer":'
      {{html this.html}}
    ',"fieldSetItemContainer":'
  • '}}}});})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.styleInjections["jquery-ui"]={"field":function(targetDiv){targetDiv.addClass("ui-widget");},"required":function(targetDiv){$('').prependTo(targetDiv);},"error":function(targetDiv){targetDiv.addClass("ui-state-error");},"errorMessage":function(targetDiv){targetDiv.addClass("ui-state-error-text");},"removeError":function(targetDiv){targetDiv.removeClass("ui-state-error");},"container":function(targetDiv){targetDiv.addClass("ui-widget-content");},"wizardStatusBar":function(targetDiv){targetDiv.addClass("ui-widget-header ui-corner-all");},"wizardCurrentStep":function(targetDiv){targetDiv.addClass("ui-state-highlight ui-corner-all");},"wizardUnCurrentStep":function(targetDiv){targetDiv.removeClass("ui-state-highlight ui-corner-all");},"containerExpandedIcon":"ui-icon-circle-arrow-s","containerCollapsedIcon":"ui-icon-circle-arrow-e","commonIcon":"ui-icon","addIcon":"ui-icon-circle-plus","removeIcon":"ui-icon-circle-minus","upIcon":"ui-icon-circle-arrow-n","downIcon":"ui-icon-circle-arrow-s","wizardPreIcon":"ui-icon-triangle-1-w","wizardNextIcon":"ui-icon-triangle-1-e","wizardDoneIcon":"ui-icon-triangle-1-e","buttonBeautifier":function(button,iconClass,withText){button.addClass("ui-button ui-widget ui-state-default ui-corner-all");if(withText){button.addClass("ui-button-text-icon-primary");}else{button.addClass("ui-button-icon-only");}var buttonText=button.html();button.attr("title",buttonText);button.empty().append(''+buttonText+"");button.hover(function(){if(!button.hasClass("alpaca-fieldset-array-item-toolbar-disabled")){$(this).addClass("ui-state-hover");}},function(){if(!button.hasClass("alpaca-fieldset-array-item-toolbar-disabled")){$(this).removeClass("ui-state-hover");}});}};Alpaca.registerView({"id":"VIEW_JQUERYUI_DISPLAY","parent":"VIEW_WEB_DISPLAY","title":"Web Display View for jQuery UI","description":"Web Display View for jQuery UI","style":"jquery-ui","ui":"jquery-ui"});Alpaca.registerView({"id":"VIEW_JQUERYUI_EDIT","parent":"VIEW_WEB_EDIT","title":"Web Edit View for jQuery UI","description":"Web Edit View for jQuery UI","style":"jquery-ui","ui":"jquery-ui"});Alpaca.registerView({"id":"VIEW_JQUERYUI_CREATE","parent":"VIEW_WEB_CREATE","title":"Web Create View for jQuery UI","description":"Web Create View for jQuery UI","style":"jquery-ui","ui":"jquery-ui"});Alpaca.registerView({"id":"VIEW_JQUERYUI_EDIT_LIST","parent":"VIEW_WEB_EDIT_LIST","title":"JQuery UI Edit View List Style","description":"JQuery UI edit view based on list styles.","style":"jquery-ui","ui":"jquery-ui"});Alpaca.registerView({"id":"VIEW_JQUERYUI_CREATE_LIST","parent":"VIEW_WEB_CREATE_LIST","title":"JQuery UI Create View List Style","description":"JQuery UI create view based on list styles.","style":"jquery-ui","ui":"jquery-ui"});})(jQuery);(function($){var Alpaca=$.alpaca;var displayTemplates=Alpaca.Create(Alpaca.EmptyViewTemplates,{controlField:'
    • {{if options.label}}

      ${options.label}

      {{/if}}

      ${data}

    ',fieldSetOuterEl:'
    {{html this.html}}
    ',fieldSetMessage:"
    * ${message}
    ",fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}

    ${options.helper}

    {{/if}}',fieldSetItemsContainer:'
    {{html this.html}}
    ',fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:"
    "});var editTemplates=Alpaca.Create(Alpaca.EmptyViewTemplates,{controlFieldOuterEl:'
    {{html this.html}}
    ',controlFieldMessage:"
    * ${message}
    ",controlFieldLabel:'{{if options.label}}{{/if}}',controlFieldHelper:'{{if options.helper}}
    ${options.helper}
    {{/if}}',controlFieldContainer:'
    {{html this.html}}
    ',controlField:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{/wrap}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}',fieldSetOuterEl:'
    {{html this.html}}
    ',fieldSetMessage:"
    * ${message}
    ",fieldSetLegend:'{{if options.label}}${options.label}{{/if}}',fieldSetHelper:'{{if options.helper}}

    ${options.helper}

    {{/if}}',fieldSetItemsContainer:'
    {{html this.html}}
    ',fieldSet:'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',fieldSetItemContainer:"
    ",formFieldsContainer:'
    {{html this.html}}
    ',form:'
    {{html Alpaca.fieldTemplate(this,"formFieldsContainer")}}{{html Alpaca.fieldTemplate(this,"formButtonsContainer")}}
    ',controlFieldRadio:'
    {{each selectOptions}}{{/each}}
    ',controlFieldCheckbox:'
    {{if options.rightLabel}}{{else}}{{if options.label}}{{/if}}{{/if}}
    ',arrayItemToolbar:'
    AddDeleteUpDown
    ',arrayToolbar:'
    Add
    '});Alpaca.styleInjections["jquery-mobile"]={"array":function(containerElem){if(containerElem){if(containerElem.find('[data-role="fieldcontain"]').fieldcontain){containerElem.find('[data-role="fieldcontain"]').fieldcontain();containerElem.find('[data-role="fieldcontain"]').find("[type='radio'], [type='checkbox']").checkboxradio();containerElem.find('[data-role="fieldcontain"]').find("button, [data-role='button'], [type='button'], [type='submit'], [type='reset'], [type='image']").not(".ui-nojs").button();containerElem.find('[data-role="fieldcontain"]').find("input, textarea").not("[type='radio'], [type='checkbox'], button, [type='button'], [type='submit'], [type='reset'], [type='image']").textinput();containerElem.find('[data-role="fieldcontain"]').find("input, select").filter("[data-role='slider'], [data-type='range']").slider();containerElem.find('[data-role="fieldcontain"]').find("select:not([data-role='slider'])").selectmenu();containerElem.find('[data-role="button"]').buttonMarkup();containerElem.find('[data-role="controlgroup"]').controlgroup();}}}};Alpaca.registerView({"id":"VIEW_MOBILE_DISPLAY","parent":"VIEW_WEB_DISPLAY","title":"Mobile DISPLAY View","description":"Mobile display view using JQuery Mobile Library","type":"view","platform":"mobile","style":"jquery-mobile","ui":"mobile","legendStyle":"link","toolbarStyle":"link","buttonType":"link","templates":displayTemplates,"messages":{required:"Required Field",invalid:"Invalid Field"},"render":function(field,renderedCallback){var self=this;field.render(field.view,function(field){refreshPageForField(field.getEl());if(renderedCallback){renderedCallback.call(self,field);}});}});Alpaca.registerView({"id":"VIEW_MOBILE_EDIT","parent":"VIEW_WEB_EDIT","title":"Mobile Edit View","description":"Mobile edit view using JQuery Mobile Library","type":"edit","platform":"mobile","style":"jquery-mobile","ui":"mobile","legendStyle":"link","toolbarStyle":"link","buttonType":"link","toolbarSticky":true,"templates":editTemplates,"messages":{required:"Required Field",invalid:"Invalid Field"},"render":function(field,renderedCallback){var self=this;field.render(function(field){refreshPageForField(field.getEl());if(renderedCallback){renderedCallback.call(self,field);}});}});var refreshPageForField=function(fieldEl){var el=fieldEl;while(!Alpaca.isEmpty(el)&&el.attr("data-role")!=="page"){el=el.parent();}if(!Alpaca.isEmpty(el)){$(el).trigger("pagecreate");}};Alpaca.registerView({"id":"VIEW_MOBILE_CREATE","parent":"VIEW_MOBILE_EDIT","title":"Default Mobile Create View","description":"Default mobile create view which doesn't bind initial data.","type":"create","displayReadonly":false});})(jQuery);(function($){var Alpaca=$.alpaca;var editTemplates=Alpaca.Create(Alpaca.EmptyViewTemplates,{"controlFieldOuterEl":'
    {{html this.html}}
    ',"controlFieldMessage":'${message}',"controlFieldLabel":'{{if options.label}}{{/if}}',"controlFieldHelper":'

    {{if options.helper}}${options.helper}

    {{/if}}',"controlFieldContainer":"
    {{html this.html}}
    ","controlField":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',"fieldSetOuterEl":"
    {{html this.html}}
    ","fieldSetMessage":'${message}',"fieldSetLegend":'{{if options.label}}${options.label}{{/if}}',"fieldSetHelper":'{{if options.helper}}

    ${options.helper}

    {{/if}}',"fieldSetItemsContainer":"
    {{html this.html}}
    ","fieldSet":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',"fieldSetItemContainer":"
    ","formFieldsContainer":"
    {{html this.html}}
    ","formButtonsContainer":'
    {{if options.buttons}}{{each(k,v) options.buttons}}{{/each}}{{/if}}
    ',"form":'
    {{html Alpaca.fieldTemplate(this,"formFieldsContainer")}}{{html Alpaca.fieldTemplate(this,"formButtonsContainer")}}
    ',"wizardStep":'
    ',"wizardNavBar":"
    ","wizardPreButton":"","wizardNextButton":"","wizardDoneButton":"","wizardStatusBar":'
      {{each(i,v) titles}}
    1. ${v.title}${v.description}
    2. {{/each}}
    ',"controlFieldCheckbox":'
    {{if options.rightLabel}}{{/if}}
    ',"controlFieldCheckboxMultiple":'
    {{each(i,o) checkboxOptions}}
    {{/each}}
    ',"controlFieldRadio":'{{if !required && !removeDefaultNone}}
    {{/if}}{{each selectOptions}}
    {{/each}}',"itemLabel":'{{if options.itemLabel}}
    ${options.itemLabel}{{if index}} ${index}{{/if}}
    {{/if}}',"arrayToolbar":'
    ',"arrayItemToolbar":'
    {{each(k,v) buttons}}{{/each}}
    '});var displayTemplates=Alpaca.Create(editTemplates,{"fieldSetOuterEl":"
    {{html this.html}}
    "});Alpaca.styleInjections["bootstrap"]={"field":function(targetDiv){$(targetDiv).find("input").addClass("form-control");$(targetDiv).find("textarea").addClass("form-control");$(targetDiv).find("select").addClass("form-control");$(targetDiv).find("input[type=checkbox]").removeClass("form-control");$(targetDiv).find("input[type=file]").removeClass("form-control");$(targetDiv).find("input[type=radio]").removeClass("form-control");$(targetDiv).find("input[type=radio]").parent().parent().addClass("radio");if($(targetDiv).parents("form").hasClass("form-inline")){$(targetDiv).find("input[type=checkbox]").parent().addClass("checkbox-inline");$(targetDiv).find("input[type=radio]").parent().addClass("radio-inline");}},"commonIcon":"","addIcon":"glyphicon glyphicon-plus-sign","removeIcon":"glyphicon glyphicon-minus-sign","upIcon":"glyphicon glyphicon-chevron-up","downIcon":"glyphicon glyphicon-chevron-down","containerExpandedIcon":"glyphicon glyphicon-circle-arrow-down","containerCollapsedIcon":"glyphicon glyphicon-circle-arrow-right","wizardPreIcon":"glyphicon glyphicon-chevron-left","wizardNextIcon":"glyphicon glyphicon-chevron-right","wizardDoneIcon":"glyphicon glyphicon-ok","required":function(targetDiv){$(' ').prependTo(targetDiv);},"error":function(targetDiv){targetDiv.addClass("has-error");},"removeError":function(targetDiv){targetDiv.removeClass("has-error");},"wizardStatusBar":function(targetDiv){targetDiv.addClass("ui-widget-header ui-corner-all");},"wizardCurrentStep":function(targetDiv){targetDiv.addClass("ui-state-highlight ui-corner-all");},"wizardUnCurrentStep":function(targetDiv){targetDiv.removeClass("ui-state-highlight ui-corner-all");},"buttonBeautifier":function(button,iconClass,withText){var buttonText=button.html();button.attr("title",buttonText);button.empty().append('');var addedButtonText=withText?buttonText:null;if(addedButtonText){button.append(''+addedButtonText+"");}}};var renderFunction=function(field,renderedCallback){var self=this;field.render(function(field){if(renderedCallback){renderedCallback.call(self,field);}});};Alpaca.registerView({"id":"VIEW_BOOTSTRAP_DISPLAY","parent":"VIEW_WEB_DISPLAY","title":"Display View for Bootstrap","description":"Display View for Bootstrap","style":"bootstrap","ui":"bootstrap","templates":displayTemplates,"render":renderFunction,"type":"view"});Alpaca.registerView({"id":"VIEW_BOOTSTRAP_EDIT","parent":"VIEW_WEB_EDIT","title":"Edit View for Bootstrap","description":"Edit View for Bootstrap","style":"bootstrap","ui":"bootstrap","templates":editTemplates,"render":renderFunction,"type":"edit"});Alpaca.registerView({"id":"VIEW_BOOTSTRAP_CREATE","parent":"VIEW_WEB_CREATE","title":"Create View for Bootstrap","description":"Create View for Bootstrap","style":"bootstrap","ui":"bootstrap","templates":editTemplates,"render":renderFunction,"type":"create"});})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.registerView({"id":"VIEW_WEB_EDIT_TABLE","parent":"VIEW_WEB_EDIT","title":"Web Edit View Table Style","description":"Web edit view based on table styles.","type":"edit","displayReadonly":true,"collapsible":false,"legendStyle":"link","templates":{"controlFieldOuterEl":null,"controlFieldLabel":'{{if options.label}}{{/if}}',"controlFieldContainer":'{{html this.html}}',"controlFieldMessage":'
    ${message}
    ',"controlFieldHelper":'{{if options.helper}}
    ${options.helper}
    {{/if}}',"controlField":'{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}'+'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}'+'{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}'+"{{/wrap}}","fieldSetOuterEl":'
    {{html this.html}}
    ',"fieldSetMessage":'
    ${message}
    ',"fieldSetLegend":'{{if options.label}}${options.label}{{/if}}',"fieldSetHelper":'{{if options.helper}}
    ${options.helper}
    {{/if}}',"fieldSetItemsContainer":"{{html this.html}}
    ","fieldSet":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',"fieldSetItemContainer":"","itemLabel":'{{if options.itemLabel}}{{/if}}'},"styles":{},"fields":{"/":{"templates":{"fieldSetItemsContainer":'{{html this.html}}
    ',"fieldSetItemContainer":''}}}});Alpaca.registerView({"id":"VIEW_WEB_CREATE_TABLE","parent":"VIEW_WEB_EDIT_TABLE","title":"Default Web Create View Table Stle","description":"Default web create view (Table Style) which doesn't bind initial data.","type":"create","displayReadonly":false});})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.registerView({"id":"VIEW_WEB_EDIT_YAML","parent":"VIEW_WEB_EDIT","title":"Web Edit View List Style","description":"Web edit list styled to look like a YAML editor.","type":"edit","displayReadonly":true,"collapsible":true,"legendStyle":"link","templates":{"controlFieldOuterEl":'{{html this.html}}',"controlFieldMessage":'
    ${message}
    ',"controlFieldLabel":'{{if options.label}}{{/if}}',"controlFieldHelper":'',"controlFieldContainer":"
    {{html this.html}}
    ","controlField":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldLabel")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"controlFieldContainer",true)}}{{html Alpaca.fieldTemplate(this,"controlFieldHelper")}}{{/wrap}}{{/wrap}}',"fieldSetOuterEl":'
    {{html this.html}}
    ',"fieldSetMessage":'
    ${message}
    ',"fieldSetLegend":'{{if options.label}}${options.label}{{/if}}',"fieldSetHelper":'{{if options.helper}}
    ${options.helper}
    {{/if}}',"fieldSetItemsContainer":"
      {{html this.html}}
    ","fieldSet":'{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetOuterEl",true)}}{{html Alpaca.fieldTemplate(this,"fieldSetLegend")}}{{html Alpaca.fieldTemplate(this,"fieldSetHelper")}}{{wrap(null, {}) Alpaca.fieldTemplate(this,"fieldSetItemsContainer",true)}}{{/wrap}}{{/wrap}}',"fieldSetItemContainer":'
  • ',"itemLabel":'{{if options.itemLabel}}{{/if}}'},"styles":{},"fields":{"/":{"templates":{"fieldSetItemsContainer":'
      {{html this.html}}
    ',"fieldSetItemContainer":'
  • '}}}});})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.registerView({"id":"VIEW_WEB_EDIT_INLINE","parent":"VIEW_WEB_EDIT","title":"Default Web Edit with fields inlining capabilities","description":"Edit template with form fields inlining capabilities, via options.inline level to display some forms parts inline. Useful to display for example an ArrayField containing ObjectField items in a compact manner.","type":"edit","platform":"web","style":"jquery-ui","displayReadonly":true,"templates":{"fieldSetOuterEl":'
    {{html this.html}}
    ',"fieldSetItemContainer":'
    ',"arrayItemToolbar":'
    '+'Add'+'Delete'+'Up'+'Down
    '}});})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.registerView({"id":"VIEW_WEB_EDIT","templates":{"twoColumnLayout":'
    '+"{{if options.label}}

    ${options.label}

    {{/if}}"+"{{if options.helper}}

    ${options.helper}

    {{/if}}"+'
    '+'
    '+"
    "}});Alpaca.registerView({"id":"VIEW_WEB_EDIT_LAYOUT_TWO_COLUMN","parent":"VIEW_WEB_EDIT","title":"Web Edit View with Two-Column Layout","description":"Web edit default view with two-column layout.","layout":{"template":"twoColumnLayout"}});Alpaca.registerView({"id":"VIEW_WEB_EDIT_LIST_LAYOUT_TWO_COLUMN","parent":"VIEW_WEB_EDIT_LIST","title":"Web List Edit View with Two-Column Layout","description":"Web edit list view with two-column layout.","layout":{"template":"twoColumnLayout"}});})(jQuery);(function($){var Alpaca=$.alpaca;Alpaca.NormalizedView=Base.extend({constructor:function(viewId){this.id=viewId;},normalize:function(){var viewObject=Alpaca.views[this.id];if(!viewObject){Alpaca.logError("View compilation failed - view not found: "+this.id);return false;}var chain=[];var current=viewObject;while(current){chain.push(current);var parentId=current.parent;if(parentId){var parent=Alpaca.views[current.parent];if(!parent){Alpaca.logError("View compilation failed - cannot find parent view: "+parentId+" for view: "+current.id);return false;}current=parent;}else{current=null;}}chain=chain.reverse();var setScalar=function(target,source,propertyId){var value=source[propertyId];var currentValue=target[propertyId];if(!Alpaca.isUndefined(currentValue)&&!Alpaca.isUndefined(value)){Alpaca.logDebug("View property: "+propertyId+" already has value: "+currentValue+" and overwriting to: "+value);}if(!Alpaca.isUndefined(value)){target[propertyId]=value;}};var setFunction=function(target,source,propertyId){var value=source[propertyId];var currentValue=target[propertyId];if(!Alpaca.isUndefined(currentValue)&&!Alpaca.isUndefined(value)){Alpaca.logDebug("View property: "+propertyId+" already has function, overwriting");}if(!Alpaca.isUndefined(value)){target[propertyId]=value;}};var mergeMap=function(target,source,propertyId){var sourceMap=source[propertyId];if(sourceMap){if(!target[propertyId]){target[propertyId]={};}Alpaca.mergeObject2(sourceMap,target[propertyId]);}};for(var i=0;i1){renderedDomElement.each(function(k,v){if($(this).attr("data-control")=="append"){newEl=$(this);}});}this.setEl(newEl);if(!this.singleLevelRendering){if(!this.isDisplayOnly()||(!this.isControlField)){this.renderField(function(){if(onSuccess){onSuccess(this);}});}else{if(onSuccess){onSuccess(this);}}}else{if(onSuccess){onSuccess(this);}}},renderField:function(onSuccess){},getStyleInjection:function(key,targetDiv,arg1,arg2){if(this.view.style&&Alpaca.styleInjections[this.view.style]&&Alpaca.styleInjections[this.view.style][key]){Alpaca.styleInjections[this.view.style][key].call(this,targetDiv,arg1,arg2);}},postRender:function(callback){if(this.view.type!="view"){this.getStyleInjection("field",this.getEl());this.getEl().addClass("alpaca-field");if(this.getEl().attr("id")===null){this.getEl().attr("id",this.getId()+"-field-outer");}if(Alpaca.isEmpty(this.getEl().attr("alpaca-field-id"))){this.getEl().attr("alpaca-field-id",this.getId());}if(this.schema.required){this.getEl().addClass("alpaca-field-required");}else{this.getEl().addClass("alpaca-field-optional");}if(this.options.readonly){this.getEl().addClass("alpaca-field-readonly");$(":input",this.getEl()).attr("readonly","readonly");$("select",this.getEl()).attr("disabled","disabled");$(":radio",this.getEl()).attr("disabled","disabled");$(":checkbox",this.getEl()).attr("disabled","disabled");}var applyFieldClass=function(el,thing){if(thing){var i=0;var tokens=null;if(Alpaca.isArray(thing)){for(i=0;i-1){tokens=thing.split(",");for(i=0;i-1){tokens=thing.split(" ");for(i=0;i0){$.each(messages,function(index,message){if(message.length>0){var messageTemplateDescriptor=_this.view.getTemplateDescriptor("controlFieldMessage");if(messageTemplateDescriptor){_this.messageElement=_this.view.tmpl(messageTemplateDescriptor,{"message":message});_this.getStyleInjection("errorMessage",_this.messageElement);if(_this.hideInitValidationError){_this.messageElement.addClass("alpaca-controlfield-message-hidden");}else{_this.messageElement.addClass("alpaca-controlfield-message");}_this.messageElement.addClass("alpaca-controlfield-message-element");_this.messageElement.attr("id",_this.getId()+"-field-message-"+index);if($(".alpaca-controlfield-message-container",_this.getEl()).length){_this.messageElement.appendTo($(".alpaca-controlfield-message-container",_this.getEl()));}else{_this.messageElement.appendTo(_this.getEl());}}_this.getStyleInjection("addErrorMessage",_this.getEl(),message);}});}},refreshValidationState:function(children){if(children){var f=function(field,contexts){if(field.children&&field.children.length>0){for(var i=0;i