/*! * jQuery Form Manager 1.0.0 * https://github.com/borgboyone/jquery-form-manager * * Copyright 2014 Anthony Wells * Released under the MIT license. * https://raw.githubusercontent.com/borgboyone/jquery-form-manager/master/LICENSE * * http://borgboyone.github.io/jquery-form-manager/ */ (function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else{factory(jQuery)}}(function($){ /*! * jQuery UI Filter Base 1.0.0 * https://github.com/borgboyone/jquery-form-manager * * Copyright 2014 Anthony Wells * Released under the MIT license. * https://raw.githubusercontent.com/borgboyone/jquery-form-manager/master/LICENSE * * http://borgboyone.github.io/jquery-form-manager/ */ (function($,undefined){$.aw=$.aw||{};if(!$.aw.version||$.aw.version<"1.0.0"){$.extend($.aw,{version:"1.0.0",unique:function(array1){for(var i=array1.length-1;i>=0;i--){for(var j=i-1;j>=0;j--){if(array1[i]===array1[j]){array1.splice(i,1);break}}}return array1},union:function(array1,array2){return $.aw.unique($.merge(array1,array2))},exclude:function(array1,array2){for(var i=array1.length-1;i>=0;i--){if($.inArray(array1[i],array2)!=-1){array1.splice(i,1)}}return array1},intersect:function(array1,array2){for(var i=array1.length-1;i>=0;i--){if($.inArray(array1[i],array2)==-1){array1.splice(i,1)}}return array1}})}$.aw.experimental=$.aw.experimental||{};if(!$.aw.experimental.implement){$.aw.experimental.implement=function(ext,imp){if(!(imp instanceof $.widget.constructor)){throw new Error("Implementable must be instance of $.widget")}ext._create=(function(_create,imp){return function(){if($.isFunction(_create)){_create.apply(this)}else{this._super()}this.element.data(imp.widgetFullName,this)}})(ext._create,imp.prototype);ext._destroy=(function(_destroy,imp){return function(){this.element.data(imp.widgetFullName,null);if($.isFunction(_destroy)){_destroy.apply(this)}else{this._super()}}})(ext._destroy,imp.prototype);return ext}}if(!$.aw.experimental.acquireTraits){$.aw.experimental.acquireTraits=function(to,from){if(!(from instanceof $.widget.constructor)){throw new Error("Trait supplier must be instance of $.widget")}if(!$.isPlainObject(to)){throw new Error("Trait receiver must be a plain object")}var traits=$.aw.exclude(Object.keys(from.prototype),["widgetName","widgetFullName","widgetEventPrefix","namespace","constructor","version","options"]).reduce(function(prev,cur){if(cur.substring(0,1)!=="_"){prev.push(cur)}return prev},[]);traits.forEach(function(trait){if(!(trait in to)){to[trait]=from.prototype[trait]}});var options=from.prototype.options;if($.isPlainObject(options)){if(!("options" in to)){to.options={}}Object.keys(options).forEach(function(option){if(!(option in to)){to.options[option]=options[option]}})}return to}}$.aw.utilities=$.aw.utilities||{};if(!$.aw.utilities.filters){$.aw.utilities.filters=(function(){var filter_cache={};var filterManager={version:"1.0.0",create:function(name,filters){if(!name){throw new Error("Filter name is a required argument.")}if(name in filter_cache){throw new Error("A filter of "+name+" already exists.")}if($.isPlainObject(filters)&&((("properties" in filters)&&$.isPlainObject(filters.properties)&&Object.keys(filters.properties).map(function(key){return filters.properties[key]}).reduce(function(prev,cur){return prev&&$.isFunction(cur)},true))||(("dichotomies" in filters)&&$.isPlainObject(filters.dichotomies)&&Object.keys(filters.dichotomies).map(function(key){return filters.dichotomies[key]}).reduce(function(prev,cur){return prev&&$.isFunction(cur)},true)))){return filter_cache[name]=new Parser({yy:{filters:filters}})}else{throw new Error("Filters is not provided or is not the correct format.")}},get:function(name){return filter_cache[name]?filter_cache[name]:null},getAll:function(){return filter_cache},remove:function(name){if(!(name in filter_cache)){return false}delete filter_cache[name];return true}};Object.freeze(filterManager);return filterManager})();var Parser=(function(){function F(c,a,n,b,g,d,k,m){a=d.length-1;switch(g){case 1:return d[a-1];case 2:case 8:case 17:case 18:this.b=d[a];break;case 3:b=$.merge(d[a-2],d[a]);for(c=b.length-1;0<=c;c--){for(g=c-1;0<=g;g--){if(b[c]===b[g]){b.splice(c,1);break}}}this.b=b;break;case 4:this.b=y(d[a-2],d[a]);break;case 6:this.b=s(b.data.initialInputs.slice(0),d[a].attributes,d[a].t,b.filters);break;case 7:c=s(b.data.initialInputs.slice(0),d[a].attributes,d[a].t,b.filters);this.b=t(b.data.initialInputs.slice(0),c);break;case 9:this.b=t(b.data.initialInputs.slice(0),d[a]);break;case 10:this.b={attributes:d[a]};break;case 11:this.b={t:d[a]};break;case 12:this.b={attributes:d[a-1],t:d[a]};break;case 13:this.b=d[a-1];break;case 14:this.b=[d[a]];break;case 15:d[a-2].push(d[a]);this.b=d[a-2];break;case 16:d[a-2] in b.filters.properties||m("Invalid attribute name ("+d[a-2]+")",{u:!1});this.b={name:d[a-2],value:d[a],operator:d[a-1]};break;case 19:this.b=[d[a]];break;case 20:d[a-1].push(d[a]);this.b=d[a-1];break;case 21:d[a] in b.filters.dichotomies||m("Invalid property name ("+d[a]+")",{u:!1});this.b={name:d[a],negate:!1};break;case 22:d[a] in b.filters.dichotomies||m("Invalid property name ("+d[a]+")",{u:!1});this.b={name:d[a],negate:!0};break;case 23:case 24:this.b=c}}function s(c,a,n,b){$.isArray(a)&&a.forEach(function(a){c=b.properties[a.name](c,a)});$.isArray(n)&&n.forEach(function(a){c=b.dichotomies[a.name](c,a)});return c}function t(c,a){return c.filter(function(c){return -1==a.indexOf(c)})}function y(c,a){return c.filter(function(c){return -1!=a.indexOf(c)})}function q(c){function a(a,b){if(b.u){this.trace(a)}else{throw Error(a)}}var n={},b=new z;if(this instanceof q){c&&"[object Object]"===Object.prototype.toString.call(c)&&(c.yy&&(n=c.yy),c.lexer&&(b=c.lexer),c.error&&(a=c.error))}else{throw Error("Parser called in static context; use new Parser() instead.")}this.__proto__.parse=function(c,d){var k=[0],m=[null],f=[],q="",v=0,s=0,t=0,y=f.slice.call(arguments,1);b.M(c);b.o=n;n.Q=b;n.F=this;n.data=d;"undefined"==typeof b.a&&(b.a={});var A=b.a;f.push(A);for(var z=b.options&&b.options.r,e,B,p,h,r={},w,l;;){p=k[k.length-1];if(C[p]){h=C[p]}else{if(null===e||"undefined"==typeof e){e=void 0,e=b.C()||1,"number"!==typeof e&&(e=G[e]||e)}h=x[p]&&x[p][e]}if("undefined"===typeof h||!h.length||!h[0]){var D="";l=[];for(w in x[p]){u[w]&&2a.length&&(a+=this.c.substr(0,20-a.length));return(a.substr(0,20)+(20a[0].length)){if(a=c,b=d,this.options.A){a=this.G(c,g[d]);if(!1!==a){return a}if(this.p){a=!1}else{return !1}}else{if(!this.options.P){break}}}}return a?(a=this.G(a,g[b]),!1!==a?a:!1):""===this.c?this.v:this.parseError("Lexical error on line "+(this.d+1)+". Unrecognized text.\n"+this.s(),{text:"",H:null,D:this.d})},C:function(){var a=this.next();return a?a:this.C()},J:function(a){this.e.push(a)},I:function(){return this.e.length&&this.e[this.e.length-1]?this.B[this.e[this.e.length-1]].rules:this.B.INITIAL.rules},pushState:function(a){this.J(a)},options:{},L:function(a,c,b){switch(b){case 1:return 8;case 2:return 7;case 3:return 13;case 4:return 10;case 5:return 11;case 6:return 16;case 7:return 18;case 8:return 22;case 9:return 26;case 10:return 27;case 11:return 28;case 12:return 5;case 13:return"INVALID"}},rules:[/^(?:\s+)/,/^(?:&)/,/^(?:\|)/,/^(?:-)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:=)/,/^(?::)/,/^(?:;)/,/^(?:(\\.|[\w-]|[^\x00-\xa0])+)/,/^(?:$)/,/^(?:.)/],B:{INITIAL:{rules:[0,1,2,3,4,5,6,7,8,9,10,11,12,13],inclusive:!0}}};return c.prototype.constructor=c}();q.prototype={trace:function(){},parse:null};return q.prototype.constructor=q})()}})(jQuery); /*! * jQuery UI Input 1.0.0 * https://github.com/borgboyone/jquery-form-manager * * Copyright 2014 Anthony Wells * Released under the MIT license. * https://raw.githubusercontent.com/borgboyone/jquery-form-manager/master/LICENSE * * http://borgboyone.github.io/jquery-form-manager/ */ ;var input=$.widget("aw.input",{version:"1.0.0",widgetEventPrefix:"input",options:{name:null,initialValue:undefined,invalidateClass:null,validation:null,focus:null,change:null},_base:function(){var base=this;while(base.__proto__.widgetName!="widget"){base=base.__proto__}return base},_instanceOf:function(name){var base=this,found=false;while((base.__proto__.widgetName!="widget")&&!(found=(base.__proto__.widgetName==name))){base=base.__proto__}return found},_init:function(){if(this==this._base()){throw Error("Input cannot be instantiated directly but must be extended.")}},_create:function(){this._super();var base=this._base();if(this!=base){this.element.data(base.widgetFullName,this)}this.valid="unset";this.name=""},_destroy:function(){var base=this._base();if(this!=base){this.element.data(base.widgetFullName,null)}this._super()},theName:function(){return this.name},validationState:function(){return this.valid},validate:function(){if($.isFunction(this.options.validation)){if(!this.options.validation()){this.valid="invalid";if($.isFunction(this.invalidate)){this.invalidate()}}else{this.valid="valid"}}},isValid:function(){return this.valid=="valid"},isDisabled:function(){return this.options.disabled},reset:function(){this.clear()},clear:function(){this.valid="unset";if(typeof this.options.invalidateClass=="string"){this.element.removeClass(this.options.invalidateClass)}},invalidate:function(){this.valid="invalid";if(typeof this.options.invalidateClass=="string"){this.element.addClass(this.options.invalidateClass)}},hasChanged:function(){return false},value:function(value){if(typeof value=="undefined"){$noop()}else{return undefined}}}); /*! * jQuery UI InputBasic 1.0.0 * https://github.com/borgboyone/jquery-form-manager * * Copyright 2014 Anthony Wells * Released under the MIT license. * https://raw.githubusercontent.com/borgboyone/jquery-form-manager/master/LICENSE * * http://borgboyone.github.io/jquery-form-manager/ */ ;var inputBasic=$.widget("aw.inputBasic",$.aw.input,{version:"1.0.0",options:{initialValue:undefined,checkboxValues:null,name:null,change:null,maintainInitialDefault:false},_change:function(event){var uiHash={element:this.element,currentValue:this.value(),name:this.name,previousValue:this._lastChangedValue,source:(event!=null?this.element[0]:undefined)};this._lastChangedValue=uiHash.currentValue;this._trigger("change",event,uiHash)},_destroy:function(){this._super()},_create:function(){this._super();var input_filter="input[type=text],input[type=password],input[type=checkbox],input[type=radio],textarea,select";var temp=this.element.filter(input_filter);if(temp.length==0){temp=this.element.find(input_filter)}if(temp.length==0){this._destroy();throw Error("No input elements were found.")}if(temp.length>1){if((temp.filter("[type=radio]").length!=temp.length)&&(temp.filter("[type=checkbox]").length!=temp.length)){this._destroy();throw Error("Multiple input elements were found; only one input or grouped input type allowed.")}var hasSameName=temp.map((function(){var name=null;return function(i,e){if(i==0){name=$(e).attr("name");return true}else{return $(e).attr("name")==name}}})()).get().reduce(function(prev,cur){return prev&&cur},true);if(!hasSameName){this._destroy();throw Error("Grouped radio or checkbox inputs must have the same name.")}}this.input=temp;this.inputType=temp.is("textarea")?"textarea":temp.is("select")?"select":temp.is("[type=text]")?"text":temp.is("[type=radio]")?"radio":temp.is("[type=checkbox]")?(temp.length==1?"checkbox":"checkboxes"):"unknown";if((this.options.name===null)||(typeof this.options.name==="undefined")){var name=this.input.first().attr("name");this.name=(name!=""?name:undefined)}else{this.name=this.options.name.toString()}if(this.inputType=="checkbox"){this.checkboxHasDualValues=false;if(this.options.checkboxValues!=null){if($.isArray(this.options.checkboxValues)){if(this.options.checkboxValues.length==2){this.checkboxHasDualValues=true;this.input.val(join("|",this.options.checkboxValues))}}else{if(typeof this.options.checkboxValues=="string"){if(this.options.checkboxValues.indexOf("|")!=-1){this.checkboxHasDualValues=true;this.input.val(this.options.checkboxValues)}}}}else{if(this.input.val().indexOf("|")!=-1){this.checkboxHasDualValues=true}}}if(typeof this.options.initialValue!=="undefined"){this.value(this.options.initialValue)}else{if(this.options.maintainInitialDefault!==true){this.value(this.value())}}this._lastChangedValue=this.value();if(this.options.disabled){this.disable()}else{this.enable()}this._on(this.input,{change:function(event){this._change(event)}})},invalidate:function(){this._super();this._on(this.input,{focusin:function(event){this.clear();this._off(this.input,"focusin")}})},hasChanged:function(){switch(this.inputType){case"textarea":case"text":case"password":return this.input.val()!=this.input.prop("defaultValue");case"select":return !this.input.find("option").filter(function(i,e){return $(e).prop("selected")&&$(e).prop("defaultSelected")}).length;case"radio":return this.input.filter(function(i,e){return $(e).prop("defaultChecked")!==$(e).prop("checked")}).length!=0;case"checkbox":return this.input.prop("defaultChecked")!=this.input.prop("checked");case"checkboxes":return this.input.filter(function(i,e){return $(e).prop("defaultChecked")!==$(e).prop("checked")}).length!=0}},value:function(value){if(typeof value=="undefined"){switch(this.inputType){case"textarea":case"text":case"password":return this.input.val();case"select":return this.input.find("option:selected").val();case"radio":return this.input.filter(":checked").val();case"checkbox":if(this.checkboxHasDualValues&&((pos=this.input.val().indexOf("|"))!=-1)){return this.input.prop("checked")?this.input.val().substring(0,pos):this.input.val().substring(pos+1)}else{return this.input.prop("checked")?this.input.val():""}case"checkboxes":return this.input.filter(function(i,e){return $(e).prop("checked")}).map(function(i,e){return $(e).val()}).get()}}else{switch(this.inputType){case"textarea":case"text":case"password":this.input.val(value).prop("defaultValue",value);return;case"select":this.input.find("option").each(function(i,e){$(e).prop("defaultSelected",$(e).val()==value)}).each(function(i,e){$(e).prop("selected",$(e).val()==value)});return;case"radio":this.input.each(function(i,e){$(e).prop("defaultChecked",$(e).val()==value)}).each(function(i,e){$(e).prop("checked",$(e).val()==value)});return;case"checkbox":this.input.prop("defaultChecked",this.input.val()==value).prop("checked",this.input.val()==value);return;if(this.checkboxHasDualValues&&((pos=this.input.val().indexOf("|"))!=-1)){this.input.prop("defaultChecked",this.input.val().substring(0,pos)==value).prop("checked",this.input.val().substring(0,pos)==value);return}else{this.input.prop("defaultChecked",this.input.val()==value).prop("checked",this.input.val()==value);return}case"checkboxes":if(!$.isArray(value)){value=[value]}this.input.each(function(i,e){$(e).prop("defaultChecked",$.inArray($(e).val(),value)!=-1)}).each(function(i,e){$(e).prop("checked",$.inArray($(e).val(),value)!=-1)});return}}},reset:function(){switch(this.inputType){case"textarea":case"text":case"password":this.input.val(this.input.prop("defaultValue"));break;case"select":this.input.find("option").filter(function(i,e){return $(e).prop("defaultSelected")}).each(function(i,e){$(e).prop("selected",true)});break;case"radio":this.input.each(function(i,e){$(e).prop("checked",$(e).prop("defaultChecked"))});break;case"checkbox":this.input.prop("checked",this.input.prop("defaultChecked"));break;case"checkboxes":this.input.each(function(i,e){$(e).prop("checked",$(e).prop("defaultChecked"))});break}this.clear()},disable:function(){this._super();this.input.prop("disabled",true)},enable:function(){this._super();this.input.prop("disabled",false)}}); /*! * jQuery UI Form 1.0.0 * https://github.com/borgboyone/jquery-form-manager * * Copyright 2014 Anthony Wells * Released under the MIT license. * https://raw.githubusercontent.com/borgboyone/jquery-form-manager/master/LICENSE * * http://borgboyone.github.io/jquery-form-manager/ */ ;var form=$.widget("aw.form",{version:"1.0.0",options:{},_create:function(){this._super();if($.aw.utilities.filters.get(this.widgetFullName)===null){var filters={properties:{},dichotomies:{}};filters.properties.name=function(inputs,property){return inputs.reduce(function(pass,input){if(input.theName()==property.value){pass.push(input)}return pass},[])};filters.properties.type=function(inputs,property){return inputs.reduce(function(pass,input){if(input._instanceOf(property.value)){pass.push(input)}return pass},[])};filters.properties.valid=function(inputs,property){return inputs.reduce(function(pass,input){if(input.validationState()==property.value){pass.push(input)}return pass},[])};filters.dichotomies.hasChanged=function(inputs,dichotomy){return inputs.reduce(function(pass,input){if(((input.hasChanged()?1:0)^(dichotomy.negate?1:0))){pass.push(input)}return pass},[])};filters.dichotomies.isValid=function(inputs,dichotomy){return inputs.reduce(function(pass,input){if(((input.isValid()?1:0)^(dichotomy.negate?1:0))){pass.push(input)}return pass},[])};filters.dichotomies.isDisabled=function(inputs,dichotomy){return inputs.reduce(function(pass,input){if(((input.isDisabled()?1:0)^(dichotomy.negate?1:0))){pass.push(input)}return pass},[])};$.aw.utilities.filters.create(this.widgetFullName,filters)}},_filter:function(inputs,selector){return $[this.namespace].utilities.filters.get(this.widgetFullName).parse(selector,{initialInputs:inputs})},inputs:function(selector){var namespace=this.namespace;var $form=this.element;var inputs=$form.find(":data("+$[namespace].input.prototype.widgetFullName+")").map(function(i,e){return $(e).data($[namespace].input.prototype.widgetFullName)}).get();if($.isFunction(selector)){inputs=inputs.reduce(function(prev,cur){if(selector(cur)){prev.push(cur)}return prev},[])}else{if($.isArray(selector)&&selector.reduce(function(prev,cur){return prev&&(typeof cur=="string")},true)){inputs=inputs.reduce(function(prev,cur){if($.inArray(cur.name(),temp)){prev.push(cur);return prev}},[])}else{if(typeof selector=="string"){inputs=this._filter(inputs,selector)}else{if(selector===undefined){}else{throw Error("Unusable selector.")}}}}return inputs},hasChanged:function(selector){return this.inputs(selector).reduce(function(prev,input){if(input.hasChanged()){prev.push(input)}return prev},[])},isValid:function(selector){return this.inputs(selector).reduce(function(prev,input){if(input.isValid()){prev.push(input)}return prev},[])},validate:function(selector){this.inputs(selector).forEach(function(input){input.validate()})},reset:function(selector){this.inputs(selector).forEach(function(input){input.reset()})},clear:function(selector){this.inputs(selector).forEach(function(input){input.clear()})},invalidate:function(selector){this.inputs(selector).forEach(function(input){input.invalidate()})},disable:function(selector){this.inputs(selector).forEach(function(input){input.disable()})},enable:function(selector){this.inputs(selector).forEach(function(input){input.enable()})},theNames:function(selector){return this.inputs(selector).reduce(function(prev,input){prev.push(input.theName());return prev},[])},values:function(mixed){var inputs;if((typeof mixed=="string")||$.isArray(mixed)||$.isFunction(mixed)||(typeof mixed==="undefined")){return this.inputs(mixed).reduce(function(prev,cur){prev[cur.theName()]=cur.value();return prev},{})}else{if($.isPlainObject(mixed)){mixed.keys().forEach(function(key){var inputs=this.inputs("[name="+key+"]");if(inputs.length==0){throw new Error("No input with name ("+key+").")}inputs[0].value(mixed[key])})}}}})}));