diff --git a/dist/query-builder.js b/dist/query-builder.js index bc221f53..4973a8db 100644 --- a/dist/query-builder.js +++ b/dist/query-builder.js @@ -7,13 +7,119 @@ // Modules: bt-selectpicker, bt-tooltip-errors, filter-description, loopback-support, mongodb-support, sortable, sql-support (function(root, factory) { if (typeof define === 'function' && define.amd) { - define(['jquery', 'microevent', 'jQuery.extendext'], factory); + define(['jquery', 'microevent'], factory); } else { factory(root.jQuery, root.MicroEvent); } }(this, function($, MicroEvent) { "use strict"; + + $.extendext = function() { + + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false, + arrayMode = 'default'; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + + // Skip the boolean and the target + target = arguments[ i++ ] || {}; + } + + // Handle array mode parameter + if ( typeof target === "string" ) { + arrayMode = $([target.toLowerCase(), 'default']).filter(['default','concat','replace','extend'])[0]; + + // Skip the string param + target = arguments[ i++ ] || {}; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !$.isFunction(target) ) { + target = {}; + } + + // Extend jQuery itself if only one argument is passed + if ( i === length ) { + target = this; + i--; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) !== null ) { + // Special operations for arrays + if ($.isArray(options) && arrayMode !== 'default') { + clone = target && $.isArray(target) ? target : []; + + switch (arrayMode) { + case 'concat': + target = clone.concat( $.extend( deep, [], options ) ); + break; + + case 'replace': + target = $.extend( deep, [], options ); + break; + + case 'extend': + options.forEach(function(e, i) { + if (typeof e === 'object') { + var type = $.isArray(e) ? [] : {}; + clone[i] = $.extendext( deep, arrayMode, clone[i] || type, e ); + + } else if (clone.indexOf(e) === -1) { + clone.push(e); + } + }); + + target = clone; + break; + } + + } else { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( $.isPlainObject(copy) || + (copyIsArray = $.isArray(copy)) ) ) { + + if ( copyIsArray ) { + copyIsArray = false; + clone = src && $.isArray(src) ? src : []; + + } else { + clone = src && $.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = $.extendext( deep, arrayMode, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + } + + // Return the modified object + return target; + }; var types = [ 'string', @@ -2586,4 +2692,4 @@ $.fn.queryBuilder.defaults.set({ .replace(/\t/g, '\\t') .replace(/\x1a/g, '\\Z'); } -})); \ No newline at end of file +})); diff --git a/package.json b/package.json index 2e454c2b..18426955 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,14 @@ "url": "http://www.strangeplanet.fr" }, "description": "jQuery plugin for user friendly query/filter creator", - "main": "dist/query-builder.js", + "main": "dist/query-builder", + "registry": "jspm", + "dependencies": { + "jquery": "~1.11", + "bootstrap": "^3.1.0", + "moment": "^2.6.0", + "npm:microevent-mistic100": "^2.1.0" + }, "devDependencies": { "grunt": "~0.4.5", "grunt-contrib-qunit": "~0.5.0", @@ -39,5 +46,10 @@ }, "scripts": { "test": "grunt test" - } + }, + "files": [ + "dist", + "Gruntfile.js", + "LICENSE" + ] }