diff --git a/assets/js/jquery-serializejson/jquery.serializejson.js b/assets/js/jquery-serializejson/jquery.serializejson.js old mode 100644 new mode 100755 index 8560cc77461..e4259ac91e6 --- a/assets/js/jquery-serializejson/jquery.serializejson.js +++ b/assets/js/jquery-serializejson/jquery.serializejson.js @@ -1,33 +1,55 @@ /*! SerializeJSON jQuery plugin. https://github.com/marioizquierdo/jquery.serializeJSON - version 2.6.1 (May, 2015) + version 2.8.1 (Dec, 2016) - Copyright (c) 2012, 2015 Mario Izquierdo + Copyright (c) 2012, 2017 Mario Izquierdo 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 ($) { +(function (factory) { + if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. + define(['jquery'], factory); + } else if (typeof exports === 'object') { // Node/CommonJS + var jQuery = require('jquery'); + module.exports = factory(jQuery); + } else { // Browser globals (zepto supported) + factory(window.jQuery || window.Zepto || window.$); // Zepto supported on browsers as well + } + +}(function ($) { "use strict"; // jQuery('form').serializeJSON() $.fn.serializeJSON = function (options) { - var serializedObject, formAsArray, keys, type, value, _ref, f, opts; + var f, $form, opts, formAsArray, serializedObject, name, value, parsedValue, _obj, nameWithNoType, type, keys, skipFalsy; f = $.serializeJSON; - opts = f.setupOpts(options); // calculate values for options {parseNumbers, parseBoolens, parseNulls} - formAsArray = this.serializeArray(); // array of objects {name, value} - f.readCheckboxUncheckedValues(formAsArray, this, opts); // add {name, value} of unchecked checkboxes if needed + $form = this; // NOTE: the set of matched elements is most likely a form, but it could also be a group of inputs + opts = f.setupOpts(options); // calculate values for options {parseNumbers, parseBoolens, parseNulls, ...} with defaults + // Use native `serializeArray` function to get an array of {name, value} objects. + formAsArray = $form.serializeArray(); + f.readCheckboxUncheckedValues(formAsArray, opts, $form); // add objects to the array from unchecked checkboxes if needed + + // Convert the formAsArray into a serializedObject with nested keys serializedObject = {}; - $.each(formAsArray, function (i, input) { - keys = f.splitInputNameIntoKeysArray(input.name, opts); - type = keys.pop(); // the last element is always the type ("string" by default) - if (type !== 'skip') { // easy way to skip a value - value = f.parseValue(input.value, type, opts); // string, number, boolean or null - if (opts.parseWithFunction && type === '_') { // allow for custom parsing - value = opts.parseWithFunction(value, input.name); + $.each(formAsArray, function (i, obj) { + name = obj.name; // original input name + value = obj.value; // input value + _obj = f.extractTypeAndNameWithNoType(name); + nameWithNoType = _obj.nameWithNoType; // input name with no type (i.e. "foo:string" => "foo") + type = _obj.type; // type defined from the input name in :type colon notation + if (!type) type = f.attrFromInputWithName($form, name, 'data-value-type'); + f.validateType(name, type, opts); // make sure that the type is one of the valid types if defined + + if (type !== 'skip') { // ignore inputs with type 'skip' + keys = f.splitInputNameIntoKeysArray(nameWithNoType); + parsedValue = f.parseValue(value, name, type, opts); // convert to string, number, boolean, null or customType + + skipFalsy = !parsedValue && f.shouldSkipFalsy($form, name, nameWithNoType, type, opts); // ignore falsy inputs if specified + if (!skipFalsy) { + f.deepSet(serializedObject, keys, parsedValue, opts); } - f.deepSet(serializedObject, keys, value, opts); } }); return serializedObject; @@ -46,6 +68,9 @@ parseAll: false, // all of the above parseWithFunction: null, // to use custom parser, a function like: function(val){ return parsed_val; } + skipFalsyValuesForTypes: [], // skip serialization of falsy values for listed value types + skipFalsyValuesForFields: [], // skip serialization of falsy values for listed field names + customTypes: {}, // override defaultTypes defaultTypes: { "string": function(str) { return String(str); }, @@ -54,7 +79,8 @@ "null": function(str) { var falses = ["false", "null", "undefined", "", "0"]; return falses.indexOf(str) === -1 ? str : null; }, "array": function(str) { return JSON.parse(str); }, "object": function(str) { return JSON.parse(str); }, - "auto": function(str) { return $.serializeJSON.parseValue(str, null, {parseNumbers: true, parseBooleans: true, parseNulls: true}); } // try again with something like "parseAll" + "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 }, useIntKeysAsArrayIndex: false // name="foo[2]" value="v" => {foo: [null, null, "v"]}, instead of {foo: ["2": "v"]} @@ -69,7 +95,7 @@ defaultOptions = f.defaultOptions || {}; // defaultOptions // Make sure that the user didn't misspell an option - validOpts = ['checkboxUncheckedValue', 'parseNumbers', 'parseBooleans', 'parseNulls', 'parseAll', 'parseWithFunction', 'customTypes', 'defaultTypes', 'useIntKeysAsArrayIndex']; // re-define because the user may override the defaultOptions + validOpts = ['checkboxUncheckedValue', 'parseNumbers', 'parseBooleans', 'parseNulls', 'parseAll', 'parseWithFunction', 'skipFalsyValuesForTypes', 'skipFalsyValuesForFields', 'customTypes', 'defaultTypes', 'useIntKeysAsArrayIndex']; // re-define because the user may override the defaultOptions for (opt in options) { if (validOpts.indexOf(opt) === -1) { throw new Error("serializeJSON ERROR: invalid option '" + opt + "'. Please use one of " + validOpts.join(', ')); @@ -89,6 +115,8 @@ parseNulls: parseAll || optWithDefault('parseNulls'), parseWithFunction: optWithDefault('parseWithFunction'), + skipFalsyValuesForTypes: optWithDefault('skipFalsyValuesForTypes'), + skipFalsyValuesForFields: optWithDefault('skipFalsyValuesForFields'), typeFunctions: $.extend({}, optWithDefault('defaultTypes'), optWithDefault('customTypes')), useIntKeysAsArrayIndex: optWithDefault('useIntKeysAsArrayIndex') @@ -96,21 +124,25 @@ }, // Given a string, apply the type or the relevant "parse" options, to return the parsed value - parseValue: function(str, type, opts) { - var typeFunction, f; + parseValue: function(valStr, inputName, type, opts) { + var f, parsedVal; f = $.serializeJSON; + parsedVal = valStr; // if no parsing is needed, the returned value will be the same - // Parse with a type if available - typeFunction = opts.typeFunctions && opts.typeFunctions[type]; - if (typeFunction) { return typeFunction(str); } // use specific type + if (opts.typeFunctions && type && opts.typeFunctions[type]) { // use a type if available + parsedVal = opts.typeFunctions[type](valStr); + } else if (opts.parseNumbers && f.isNumeric(valStr)) { // auto: number + parsedVal = Number(valStr); + } else if (opts.parseBooleans && (valStr === "true" || valStr === "false")) { // auto: boolean + parsedVal = (valStr === "true"); + } else if (opts.parseNulls && valStr == "null") { // auto: null + parsedVal = null; + } + if (opts.parseWithFunction && !type) { // custom parse function (apply after previous parsing options, but not if there's a specific type) + parsedVal = opts.parseWithFunction(parsedVal, inputName); + } - // Otherwise, check if there is any auto-parse option enabled and use it. - if (opts.parseNumbers && f.isNumeric(str)) { return Number(str); } // auto: number - if (opts.parseBooleans && (str === "true" || str === "false")) { return str === "true"; } // auto: boolean - if (opts.parseNulls && str == "null") { return null; } // auto: null - - // If none applies, just return the str - return str; + return parsedVal; }, isObject: function(obj) { return obj === Object(obj); }, // is it an Object? @@ -120,50 +152,115 @@ optionKeys: function(obj) { if (Object.keys) { return Object.keys(obj); } else { var key, keys = []; for(key in obj){ keys.push(key); } return keys;} }, // polyfill Object.keys to get option keys in IE<9 - // Split the input name in programatically readable keys. - // The last element is always the type (default "_"). - // Examples: - // "foo" => ['foo', '_'] - // "foo:string" => ['foo', 'string'] - // "foo:boolean" => ['foo', 'boolean'] - // "[foo]" => ['foo', '_'] - // "foo[inn][bar]" => ['foo', 'inn', 'bar', '_'] - // "foo[inn[bar]]" => ['foo', 'inn', 'bar', '_'] - // "foo[inn][arr][0]" => ['foo', 'inn', 'arr', '0', '_'] - // "arr[][val]" => ['arr', '', 'val', '_'] - // "arr[][val]:null" => ['arr', '', 'val', 'null'] - splitInputNameIntoKeysArray: function(name, opts) { - var keys, nameWithoutType, type, _ref, f; + + // 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. + readCheckboxUncheckedValues: function (formAsArray, opts, $form) { + var selector, $uncheckedCheckboxes, $el, uncheckedValue, f, name; + if (opts == null) { opts = {}; } f = $.serializeJSON; - _ref = f.extractTypeFromInputName(name, opts); nameWithoutType = _ref[0]; type = _ref[1]; - keys = nameWithoutType.split('['); // split string into array - keys = $.map(keys, function (key) { return key.replace(/\]/g, ''); }); // remove closing brackets - if (keys[0] === '') { keys.shift(); } // ensure no opening bracket ("[foo][inn]" should be same as "foo[inn]") - keys.push(type); // add type at the end - return keys; + + selector = 'input[type=checkbox][name]:not(:checked):not([disabled])'; + $uncheckedCheckboxes = $form.find(selector).add($form.filter(selector)); + $uncheckedCheckboxes.each(function (i, el) { + // Check data attr first, then the option + $el = $(el); + uncheckedValue = $el.attr('data-unchecked-value'); + if (uncheckedValue == null) { + uncheckedValue = opts.checkboxUncheckedValue; + } + + // 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 + throw new Error("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"); + } + formAsArray.push({name: el.name, value: uncheckedValue}); + } + }); }, - // Returns [name-without-type, type] from name. - // "foo" => ["foo", '_'] - // "foo:boolean" => ["foo", 'boolean'] - // "foo[bar]:null" => ["foo[bar]", 'null'] - extractTypeFromInputName: function(name, opts) { - var match, validTypes, f; - if (match = name.match(/(.*):([^:]+)$/)){ - f = $.serializeJSON; - - validTypes = f.optionKeys(opts ? opts.typeFunctions : f.defaultOptions.defaultTypes); - validTypes.push('skip'); // skip is a special type that makes it easy to remove - if (validTypes.indexOf(match[2]) !== -1) { - return [match[1], match[2]]; - } else { - throw new Error("serializeJSON ERROR: Invalid type " + match[2] + " found in input name '" + name + "', please use one of " + validTypes.join(', ')); - } + // Returns and object with properties {name_without_type, type} from a given name. + // The type is null if none specified. Example: + // "foo" => {nameWithNoType: "foo", type: null} + // "foo:boolean" => {nameWithNoType: "foo", type: "boolean"} + // "foo[bar]:null" => {nameWithNoType: "foo[bar]", type: "null"} + extractTypeAndNameWithNoType: function(name) { + var match; + if (match = name.match(/(.*):([^:]+)$/)) { + return {nameWithNoType: match[1], type: match[2]}; } else { - return [name, '_']; // no defined type, then use parse options + return {nameWithNoType: name, type: null}; } }, + + // Check if this input should be skipped when it has a falsy value, + // depending on the options to skip values by name or type, and the data-skip-falsy attribute. + shouldSkipFalsy: function($form, name, nameWithNoType, type, opts) { + var f = $.serializeJSON; + + var skipFromDataAttr = f.attrFromInputWithName($form, name, 'data-skip-falsy'); + if (skipFromDataAttr != null) { + return skipFromDataAttr !== 'false'; // any value is true, except if explicitly using 'false' + } + + var optForFields = opts.skipFalsyValuesForFields; + if (optForFields && (optForFields.indexOf(nameWithNoType) !== -1 || optForFields.indexOf(name) !== -1)) { + return true; + } + + var optForTypes = opts.skipFalsyValuesForTypes; + if (type == null) type = 'string'; // assume fields with no type are targeted as string + if (optForTypes && optForTypes.indexOf(type) !== -1) { + return true + } + + return false; + }, + + // Finds the first input in $form with this name, and get the given attr from it. + // Returns undefined if no input or no attribute was found. + attrFromInputWithName: function($form, name, attrName) { + var escapedName, selector, $input, attrValue; + 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. + return $input.attr(attrName); + }, + + // Raise an error if the type is not recognized. + validateType: function(name, type, opts) { + var validTypes, f; + f = $.serializeJSON; + validTypes = f.optionKeys(opts ? opts.typeFunctions : f.defaultOptions.defaultTypes); + if (!type || validTypes.indexOf(type) !== -1) { + return true; + } else { + throw new Error("serializeJSON ERROR: Invalid type " + type + " found in input name '" + name + "', please use one of " + validTypes.join(', ')); + } + }, + + + // Split the input name in programatically readable keys. + // Examples: + // "foo" => ['foo'] + // "[foo]" => ['foo'] + // "foo[inn][bar]" => ['foo', 'inn', 'bar'] + // "foo[inn[bar]]" => ['foo', 'inn', 'bar'] + // "foo[inn][arr][0]" => ['foo', 'inn', 'arr', '0'] + // "arr[][val]" => ['arr', '', 'val'] + splitInputNameIntoKeysArray: function(nameWithNoType) { + var keys, f; + f = $.serializeJSON; + keys = nameWithNoType.split('['); // split string into array + keys = $.map(keys, function (key) { return key.replace(/\]/g, ''); }); // remove closing brackets + if (keys[0] === '') { keys.shift(); } // ensure no opening bracket ("[foo][inn]" should be same as "foo[inn]") + return keys; + }, + // Set a value in an object or array, using multiple keys to set in a nested object or array: // // deepSet(obj, ['foo'], v) // obj['foo'] = v @@ -236,32 +333,8 @@ tail = keys.slice(1); f.deepSet(o[key], tail, value, opts); } - }, - - // 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. - readCheckboxUncheckedValues: function (formAsArray, $form, opts) { - var selector, $uncheckedCheckboxes, $el, dataUncheckedValue, f; - if (opts == null) { opts = {}; } - f = $.serializeJSON; - - selector = 'input[type=checkbox][name]:not(:checked):not([disabled])'; - $uncheckedCheckboxes = $form.find(selector).add($form.filter(selector)); - $uncheckedCheckboxes.each(function (i, el) { - $el = $(el); - dataUncheckedValue = $el.attr('data-unchecked-value'); - if(dataUncheckedValue) { // data-unchecked-value has precedence over option opts.checkboxUncheckedValue - formAsArray.push({name: el.name, value: dataUncheckedValue}); - } else { - if (!f.isUndefined(opts.checkboxUncheckedValue)) { - formAsArray.push({name: el.name, value: opts.checkboxUncheckedValue}); - } - } - }); } }; -}(window.jQuery || window.Zepto || window.$)); +})); diff --git a/assets/js/jquery-serializejson/jquery.serializejson.min.js b/assets/js/jquery-serializejson/jquery.serializejson.min.js old mode 100644 new mode 100755 index 8248d4951f4..4d1e67345a4 --- a/assets/js/jquery-serializejson/jquery.serializejson.min.js +++ b/assets/js/jquery-serializejson/jquery.serializejson.min.js @@ -1,10 +1,10 @@ /*! SerializeJSON jQuery plugin. https://github.com/marioizquierdo/jquery.serializeJSON - version 2.6.1 (May, 2015) + version 2.8.1 (Dec, 2016) - Copyright (c) 2012, 2015 Mario Izquierdo + Copyright (c) 2012, 2017 Mario Izquierdo 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){"use strict";a.fn.serializeJSON=function(b){var c,d,e,f,g,h,i;return h=a.serializeJSON,i=h.setupOpts(b),d=this.serializeArray(),h.readCheckboxUncheckedValues(d,this,i),c={},a.each(d,function(a,b){e=h.splitInputNameIntoKeysArray(b.name,i),f=e.pop(),"skip"!==f&&(g=h.parseValue(b.value,f,i),i.parseWithFunction&&"_"===f&&(g=i.parseWithFunction(g,b.name)),h.deepSet(c,e,g,i))}),c},a.serializeJSON={defaultOptions:{checkboxUncheckedValue:void 0,parseNumbers:!1,parseBooleans:!1,parseNulls:!1,parseAll:!1,parseWithFunction:null,customTypes:{},defaultTypes:{string:function(a){return String(a)},number:function(a){return Number(a)},boolean:function(a){var b=["false","null","undefined","","0"];return b.indexOf(a)===-1},null:function(a){var b=["false","null","undefined","","0"];return b.indexOf(a)===-1?a:null},array:function(a){return JSON.parse(a)},object:function(a){return JSON.parse(a)},auto:function(b){return a.serializeJSON.parseValue(b,null,{parseNumbers:!0,parseBooleans:!0,parseNulls:!0})}},useIntKeysAsArrayIndex:!1},setupOpts:function(b){var c,d,e,f,g,h;h=a.serializeJSON,null==b&&(b={}),e=h.defaultOptions||{},d=["checkboxUncheckedValue","parseNumbers","parseBooleans","parseNulls","parseAll","parseWithFunction","customTypes","defaultTypes","useIntKeysAsArrayIndex"];for(c in b)if(d.indexOf(c)===-1)throw new Error("serializeJSON ERROR: invalid option '"+c+"'. Please use one of "+d.join(", "));return f=function(a){return b[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"),typeFunctions:a.extend({},f("defaultTypes"),f("customTypes")),useIntKeysAsArrayIndex:f("useIntKeysAsArrayIndex")}},parseValue:function(b,c,d){var e,f;return f=a.serializeJSON,e=d.typeFunctions&&d.typeFunctions[c],e?e(b):d.parseNumbers&&f.isNumeric(b)?Number(b):!d.parseBooleans||"true"!==b&&"false"!==b?d.parseNulls&&"null"==b?null:b:"true"===b},isObject:function(a){return a===Object(a)},isUndefined:function(a){return void 0===a},isValidArrayIndex:function(a){return/^[0-9]+$/.test(String(a))},isNumeric:function(a){return a-parseFloat(a)>=0},optionKeys:function(a){if(Object.keys)return Object.keys(a);var b,c=[];for(b in a)c.push(b);return c},splitInputNameIntoKeysArray:function(b,c){var d,e,f,g,h;return h=a.serializeJSON,g=h.extractTypeFromInputName(b,c),e=g[0],f=g[1],d=e.split("["),d=a.map(d,function(a){return a.replace(/\]/g,"")}),""===d[0]&&d.shift(),d.push(f),d},extractTypeFromInputName:function(b,c){var d,e,f;if(d=b.match(/(.*):([^:]+)$/)){if(f=a.serializeJSON,e=f.optionKeys(c?c.typeFunctions:f.defaultOptions.defaultTypes),e.push("skip"),e.indexOf(d[2])!==-1)return[d[1],d[2]];throw new Error("serializeJSON ERROR: Invalid type "+d[2]+" found in input name '"+b+"', please use one of "+e.join(", "))}return[b,"_"]},deepSet:function(b,c,d,e){var f,g,h,i,j,k;if(null==e&&(e={}),k=a.serializeJSON,k.isUndefined(b))throw new Error("ArgumentError: param 'o' expected to be an object or array, found undefined");if(!c||0===c.length)throw new Error("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))},readCheckboxUncheckedValues:function(b,c,d){var e,f,g,h,i;null==d&&(d={}),i=a.serializeJSON,e="input[type=checkbox][name]:not(:checked):not([disabled])",f=c.find(e).add(c.filter(e)),f.each(function(c,e){g=a(e),h=g.attr("data-unchecked-value"),h?b.push({name:e.name,value:h}):i.isUndefined(d.checkboxUncheckedValue)||b.push({name:e.name,value:d.checkboxUncheckedValue})})}}}(window.jQuery||window.Zepto||window.$); \ No newline at end of file +!function(a){if("function"==typeof define&&define.amd)define(["jquery"],a);else if("object"==typeof exports){var b=require("jquery");module.exports=a(b)}else a(window.jQuery||window.Zepto||window.$)}(function(a){"use strict";a.fn.serializeJSON=function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o;return c=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:void 0,parseNumbers:!1,parseBooleans:!1,parseNulls:!1,parseAll:!1,parseWithFunction:null,skipFalsyValuesForTypes:[],skipFalsyValuesForFields:[],customTypes:{},defaultTypes:{string:function(a){return String(a)},number:function(a){return Number(a)},boolean:function(a){var b=["false","null","undefined","","0"];return b.indexOf(a)===-1},null:function(a){var b=["false","null","undefined","","0"];return b.indexOf(a)===-1?a:null},array:function(a){return JSON.parse(a)},object:function(a){return JSON.parse(a)},auto:function(b){return a.serializeJSON.parseValue(b,null,null,{parseNumbers:!0,parseBooleans:!0,parseNulls:!0})},skip:null},useIntKeysAsArrayIndex:!1},setupOpts:function(b){var c,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(c in b)if(d.indexOf(c)===-1)throw new Error("serializeJSON ERROR: invalid option '"+c+"'. Please use one of "+d.join(", "));return f=function(a){return b[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){var f,g;return f=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){return a===Object(a)},isUndefined:function(a){return void 0===a},isValidArrayIndex:function(a){return/^[0-9]+$/.test(String(a))},isNumeric:function(a){return a-parseFloat(a)>=0},optionKeys:function(a){if(Object.keys)return Object.keys(a);var b,c=[];for(b in a)c.push(b);return c},readCheckboxUncheckedValues:function(b,c,d){var e,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)throw new Error("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){var b;return(b=a.match(/(.*):([^:]+)$/))?{nameWithNoType:b[1],type:b[2]}:{nameWithNoType:a,type:null}},shouldSkipFalsy:function(b,c,d,e,f){var g=a.serializeJSON,h=g.attrFromInputWithName(b,c,"data-skip-falsy");if(null!=h)return"false"!==h;var i=f.skipFalsyValuesForFields;if(i&&(i.indexOf(d)!==-1||i.indexOf(c)!==-1))return!0;var j=f.skipFalsyValuesForTypes;return null==e&&(e="string"),!(!j||j.indexOf(e)===-1)},attrFromInputWithName:function(a,b,c){var d,e,f;return d=b.replace(/(:|\.|\[|\]|\s)/g,"\\$1"),e='[name="'+d+'"]',f=a.find(e).add(a.filter(e)),f.attr(c)},validateType:function(b,c,d){var e,f;if(f=a.serializeJSON,e=f.optionKeys(d?d.typeFunctions:f.defaultOptions.defaultTypes),c&&e.indexOf(c)===-1)throw new Error("serializeJSON ERROR: Invalid type "+c+" found in input name '"+b+"', please use one of "+e.join(", "));return!0},splitInputNameIntoKeysArray:function(b){var c,d;return d=a.serializeJSON,c=b.split("["),c=a.map(c,function(a){return a.replace(/\]/g,"")}),""===c[0]&&c.shift(),c},deepSet:function(b,c,d,e){var f,g,h,i,j,k;if(null==e&&(e={}),k=a.serializeJSON,k.isUndefined(b))throw new Error("ArgumentError: param 'o' expected to be an object or array, found undefined");if(!c||0===c.length)throw new Error("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))}}}); \ No newline at end of file diff --git a/includes/admin/class-wc-admin-assets.php b/includes/admin/class-wc-admin-assets.php index 6e566766320..e03a8dc1b10 100644 --- a/includes/admin/class-wc-admin-assets.php +++ b/includes/admin/class-wc-admin-assets.php @@ -101,7 +101,7 @@ class WC_Admin_Assets { wp_register_script( 'zeroclipboard', WC()->plugin_url() . '/assets/js/zeroclipboard/jquery.zeroclipboard' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'qrcode', WC()->plugin_url() . '/assets/js/jquery-qrcode/jquery.qrcode' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'stupidtable', WC()->plugin_url() . '/assets/js/stupidtable/stupidtable' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); - wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.6.1' ); + wp_register_script( 'serializejson', WC()->plugin_url() . '/assets/js/jquery-serializejson/jquery.serializejson' . $suffix . '.js', array( 'jquery' ), '2.8.1' ); wp_register_script( 'flot', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot' . $suffix . '.js', array( 'jquery' ), WC_VERSION ); wp_register_script( 'flot-resize', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.resize' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION ); wp_register_script( 'flot-time', WC()->plugin_url() . '/assets/js/jquery-flot/jquery.flot.time' . $suffix . '.js', array( 'jquery', 'flot' ), WC_VERSION );