"auto":function(str){return$.serializeJSON.parseValue(str,null,null,{parseNumbers:true,parseBooleans:true,parseNulls:true});},// try again with something like "parseAll"
"skip":null// skip is a special type that makes it easy to ignore elements
// Make sure that the user didn't misspell an option
validOpts=['checkboxUncheckedValue','parseNumbers','parseBooleans','parseNulls','parseAll','parseWithFunction','skipFalsyValuesForTypes','skipFalsyValuesForFields','customTypes','defaultTypes','useIntKeysAsArrayIndex'];// re-define because the user may override the defaultOptions
for(optinoptions){
if(validOpts.indexOf(opt)===-1){
thrownewError("serializeJSON ERROR: invalid option '"+opt+"'. Please use one of "+validOpts.join(', '));
}
}
// Helper to get the default value for this option if none is specified by the user
isObject:function(obj){returnobj===Object(obj);},// is it an Object?
isUndefined:function(obj){returnobj===void0;},// safe check for undefined values
isValidArrayIndex:function(val){return/^[0-9]+$/.test(String(val));},// 1,2,3,4 ... are valid array indexes
isNumeric:function(obj){returnobj-parseFloat(obj)>=0;},// taken from jQuery.isNumeric implementation. Not using jQuery.isNumeric to support old jQuery and Zepto versions
optionKeys:function(obj){if(Object.keys){returnObject.keys(obj);}else{varkey,keys=[];for(keyinobj){keys.push(key);}returnkeys;}},// polyfill Object.keys to get option keys in IE<9
// Fill the formAsArray object with values for the unchecked checkbox inputs,
// using the same format as the jquery.serializeArray function.
// The value of the unchecked values is determined from the opts.checkboxUncheckedValue
// and/or the data-unchecked-value attribute of the inputs.
// If there's an uncheckedValue, push it into the serialized formAsArray
if(uncheckedValue!=null){
if(el.name&&el.name.indexOf("[][")!==-1){// identify a non-supported
thrownewError("serializeJSON ERROR: checkbox unchecked values are not supported on nested arrays of objects like '"+el.name+"'. See https://github.com/marioizquierdo/jquery.serializeJSON/issues/67");
escapedName=name.replace(/(:|\.|\[|\]|\s)/g,'\\$1');// every non-standard character need to be escaped by \\
selector='[name="'+escapedName+'"]';
$input=$form.find(selector).add($form.filter(selector));// NOTE: this returns only the first $input element if multiple are matched with the same name (i.e. an "array[]"). So, arrays with different element types specified through the data-value-type attr is not supported.
if(f.isUndefined(o)){thrownewError("ArgumentError: param 'o' expected to be an object or array, found undefined");}
if(!keys||keys.length===0){thrownewError("ArgumentError: param 'keys' expected to be an array with least one element");}
key=keys[0];
// Only one key, then it's not a deepSet, just assign the value.
if(keys.length===1){
if(key===''){
o.push(value);// '' is used to push values into the array (assume o is an array)
}else{
o[key]=value;// other keys can be used as object keys or array indexes
}
// With more keys is a deepSet. Apply recursively.
}else{
nextKey=keys[1];
// '' is used to push values into the array,
// with nextKey, set the value into the same object, in object[nextKey].
// Covers the case of ['', 'foo'] and ['', 'var'] to push the object {foo, var}, and the case of nested arrays.
if(key===''){
lastIdx=o.length-1;// asume o is array
lastVal=o[lastIdx];
if(f.isObject(lastVal)&&(f.isUndefined(lastVal[nextKey])||keys.length>2)){// if nextKey is not present in the last object element, or there are more keys to deep set
key=lastIdx;// then set the new value in the same object element
}else{
key=lastIdx+1;// otherwise, point to set the next index in the array
}
}
// '' is used to push values into the array "array[]"
if(nextKey===''){
if(f.isUndefined(o[key])||!$.isArray(o[key])){
o[key]=[];// define (or override) as array to push values
}
}else{
if(opts.useIntKeysAsArrayIndex&&f.isValidArrayIndex(nextKey)){// if 1, 2, 3 ... then use an array, where nextKey is the index
if(f.isUndefined(o[key])||!$.isArray(o[key])){
o[key]=[];// define (or override) as array, to insert values using int keys as array indexes
}
}else{// for anything else, use an object, where nextKey is going to be the attribute name
if(f.isUndefined(o[key])||!f.isObject(o[key])){
o[key]={};// define (or override) as object, to set nested properties
Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*/
!function(a){if("function"==typeofdefine&&define.amd)define(["jquery"],a);elseif("object"==typeofexports){varb=require("jquery");module.exports=a(b)}elsea(window.jQuery||window.Zepto||window.$)}(function(a){"use strict";a.fn.serializeJSON=function(b){varc,d,e,f,g,h,i,j,k,l,m,n,o;returnc=a.serializeJSON,d=this,e=c.setupOpts(b),f=d.serializeArray(),c.readCheckboxUncheckedValues(f,e,d),g={},a.each(f,function(a,b){h=b.name,i=b.value,k=c.extractTypeAndNameWithNoType(h),l=k.nameWithNoType,m=k.type,m||(m=c.attrFromInputWithName(d,h,"data-value-type")),c.validateType(h,m,e),"skip"!==m&&(n=c.splitInputNameIntoKeysArray(l),j=c.parseValue(i,h,m,e),o=!j&&c.shouldSkipFalsy(d,h,l,m,e),o||c.deepSet(g,n,j,e))}),g},a.serializeJSON={defaultOptions:{checkboxUncheckedValue:void0,parseNumbers:!1,parseBooleans:!1,parseNulls:!1,parseAll:!1,parseWithFunction:null,skipFalsyValuesForTypes:[],skipFalsyValuesForFields:[],customTypes:{},defaultTypes:{string:function(a){returnString(a)},number:function(a){returnNumber(a)},boolean:function(a){varb=["false","null","undefined","","0"];returnb.indexOf(a)===-1},null:function(a){varb=["false","null","undefined","","0"];returnb.indexOf(a)===-1?a:null},array:function(a){returnJSON.parse(a)},object:function(a){returnJSON.parse(a)},auto:function(b){returna.serializeJSON.parseValue(b,null,null,{parseNumbers:!0,parseBooleans:!0,parseNulls:!0})},skip:null},useIntKeysAsArrayIndex:!1},setupOpts:function(b){varc,d,e,f,g,h;h=a.serializeJSON,null==b&&(b={}),e=h.defaultOptions||{},d=["checkboxUncheckedValue","parseNumbers","parseBooleans","parseNulls","parseAll","parseWithFunction","skipFalsyValuesForTypes","skipFalsyValuesForFields","customTypes","defaultTypes","useIntKeysAsArrayIndex"];for(cinb)if(d.indexOf(c)===-1)thrownewError("serializeJSON ERROR: invalid option '"+c+"'. Please use one of "+d.join(", "));returnf=function(a){returnb[a]!==!1&&""!==b[a]&&(b[a]||e[a])},g=f("parseAll"),{checkboxUncheckedValue:f("checkboxUncheckedValue"),parseNumbers:g||f("parseNumbers"),parseBooleans:g||f("parseBooleans"),parseNulls:g||f("parseNulls"),parseWithFunction:f("parseWithFunction"),skipFalsyValuesForTypes:f("skipFalsyValuesForTypes"),skipFalsyValuesForFields:f("skipFalsyValuesForFields"),typeFunctions:a.extend({},f("defaultTypes"),f("customTypes")),useIntKeysAsArrayIndex:f("useIntKeysAsArrayIndex")}},parseValue:function(b,c,d,e){varf,g;returnf=a.serializeJSON,g=b,e.typeFunctions&&d&&e.typeFunctions[d]?g=e.typeFunctions[d](b):e.parseNumbers&&f.isNumeric(b)?g=Number(b):!e.parseBooleans||"true"!==b&&"false"!==b?e.parseNulls&&"null"==b&&(g=null):g="true"===b,e.parseWithFunction&&!d&&(g=e.parseWithFunction(g,c)),g},isObject:function(a){returna===Object(a)},isUndefined:function(a){returnvoid0===a},isValidArrayIndex:function(a){return/^[0-9]+$/.test(String(a))},isNumeric:function(a){returna-parseFloat(a)>=0},optionKeys:function(a){if(Object.keys)returnObject.keys(a);varb,c=[];for(bina)c.push(b);returnc},readCheckboxUncheckedValues:function(b,c,d){vare,f,g,h,i;null==c&&(c={}),i=a.serializeJSON,e="input[type=checkbox][name]:not(:checked):not([disabled])",f=d.find(e).add(d.filter(e)),f.each(function(d,e){if(g=a(e),h=g.attr("data-unchecked-value"),null==h&&(h=c.checkboxUncheckedValue),null!=h){if(e.name&&e.name.indexOf("[][")!==-1)thrownewError("serializeJSON ERROR: checkbox unchecked values are not supported on nested arrays of objects like '"+e.name+"'. See https://github.com/marioizquierdo/jquery.serializeJSON/issues/67");b.push({name:e.name,value:h})}})},extractTypeAndNameWithNoType:function(a){varb;return(b=a.match(/(.*):([^:]+)$/))?{nameWithNoType:b[1],type:b[2]}:{nameWithNoType:a,type:null}},shouldSkipFalsy:function(b,c,d,e,f){varg=a.serializeJSON,h=g.attrFromInputWithName(b,c,"data-skip-falsy");if(null!=h)return"false"!==h;vari=f.skipFalsyValuesForFields;if(i&&(i.indexOf(d)!==-1||i.indexOf(c)!==-1))return!0;varj=f.skipFalsyValuesForTypes;returnnull==e&&(e="string"),!(!j||j.indexOf(e)===-1)},attrFromInputWithName:function(a,b,c){vard,e,f;returnd=b.replace(/(:|\.|\[|\]|\s)/g,"\\$1"),e='[name="'+d+'"]',f=a.find(e).add(a.filter(e)),f.attr(c)},validateType:function(b,c,d){vare,f;if(f=a.serializeJSON,e=f.optionKeys(d?d.typeFunctions:f.defaultOptions.defaultTypes),c&&e.indexOf(c)===-1)thrownewError("serializeJSON ERROR: Invalid type "+c+" found in input name '"+b+"', please use one of "+e.join(", "));return!0},splitInputNameIntoKeysArray:function(b){varc,d;returnd=a.serializeJSON,c=b.split("["),c=a.map(c,function(a){returna.replace(/\]/g,"")}),""===c[0]&&c.shift(),c},deepSet:function(b,c,d,e){varf,g,h,i,j,k;if(null==e&&(e={}),k=a.serializeJSON,k.isUndefined(b))thrownewError("ArgumentError: param 'o' expected to be an object or array, found undefined");if(!c||0===c.length)thrownewError("ArgumentError: param 'keys' expected to be an array with least one element");f=c[0],1===c.length?""===f?b.push(d):b[f]=d:(g=c[1],""===f&&(i=b.length-1,j=b[i],f=k.isObject(j)&&(k.isUndefined(j[g])||c.length>2)?i:i+1),""===g?!k.isUndefined(b[f])&&a.isArray(b[f])||(b[f]=[]):e.useIntKeysAsArrayIndex&&k.isValidArrayIndex(g)?!k.isUndefined(b[f])&&a.isArray(b[f])||(b[f]=[]):!k.isUndefined(b[f])&&k.isObject(b[f])||(b[f]={}),h=c.slice(1),k.deepSet(b[f],h,d,e))}}});
!function(e,i){if("function"==typeofdefine&&define.amd)define(["exports","jquery"],function(e,r){returni(e,r)});elseif("undefined"!=typeofexports){varr=require("jquery");i(exports,r)}elsei(e,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,i){functionr(e,r){functionn(e,i,r){returne[i]=r,e}functiona(e,i){for(varr,a=e.match(t.key);void0!==(r=a.pop());)if(t.push.test(r)){varu=s(e.replace(/\[\]$/,""));i=n([],u,i)}elset.fixed.test(r)?i=n([],r,i):t.named.test(r)&&(i=n({},r,i));returni}functions(e){returnvoid0===h[e]&&(h[e]=0),h[e]++}functionu(e){switch(i('[name="'+e.name+'"]',r).attr("type")){case"checkbox":return"on"===e.value?!0:e.value;default:returne.value}}functionf(i){if(!t.validate.test(i.name))returnthis;varr=a(i.name,u(i));returnl=e.extend(!0,l,r),this}functiond(i){if(!e.isArray(i))thrownewError("formSerializer.addPairs expects an Array");for(varr=0,t=i.length;t>r;r++)this.addPair(i[r]);returnthis}functiono(){returnl}functionc(){returnJSON.stringify(o())}varl={},h={};this.addPair=f,this.addPairs=d,this.serialize=o,this.serializeJSON=c}vart={validate:/^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,key:/[a-z0-9_]+|(?=\[\])/gi,push:/^$/,fixed:/^\d+$/,named:/^[a-z0-9_]+$/i};returnr.patterns=t,r.serializeObject=function(){returnnewr(i,this).addPairs(this.serializeArray()).serialize()},r.serializeJSON=function(){returnnewr(i,this).addPairs(this.serializeArray()).serializeJSON()},"undefined"!=typeofi.fn&&(i.fn.serializeObject=r.serializeObject,i.fn.serializeJSON=r.serializeJSON),e.FormSerializer=r,r});
throw"Could not find the placeholder element: "+this.settings.button_placeholder_id;
}
// Append the container and load the flash
tempParent=document.createElement("div");
tempParent.innerHTML=this.getFlashHTML();// Using innerHTML is non-standard but the only sensible way to dynamically add Flash in IE (and maybe other browsers)