diff --git a/.gitignore b/.gitignore index 8d6f7c26c..1c0d103f3 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ npm-debug.log* yarn-error.log yarn.lock style/.sass-cache/ +stats.json img/ images/ diff --git a/dist/grapes.js b/dist/grapes.js index f5ec39526..2cb6064db 100644 --- a/dist/grapes.js +++ b/dist/grapes.js @@ -70,7 +70,7 @@ return /******/ (function(modules) { // webpackBootstrap /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 59); +/******/ return __webpack_require__(__webpack_require__.s = 61); /******/ }) /************************************************************************/ /******/ ([ @@ -93,7 +93,7 @@ return /******/ (function(modules) { // webpackBootstrap // Set up Backbone appropriately for the environment. Start with AMD. if (true) { - !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1), __webpack_require__(9), exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function(_, $, exports) { + !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(1), __webpack_require__(10), exports], __WEBPACK_AMD_DEFINE_RESULT__ = (function(_, $, exports) { // Export global even in AMD case in case this script is loaded with // others that may still expect a global Backbone. root.Backbone = factory(root, exports, _, $); @@ -1999,15 +1999,15 @@ return /******/ (function(modules) { // webpackBootstrap return Backbone; }); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(10))) +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7))) /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { -var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscore.js 1.8.3 +/* WEBPACK VAR INJECTION */(function(global, module) {var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscore.js 1.9.0 // http://underscorejs.org -// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors +// (c) 2009-2018 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. (function() { @@ -2015,29 +2015,32 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Baseline setup // -------------- - // Establish the root object, `window` in the browser, or `exports` on the server. - var root = this; + // Establish the root object, `window` (`self`) in the browser, `global` + // on the server, or `this` in some virtual machines. We use `self` + // instead of `window` for `WebWorker` support. + var root = typeof self == 'object' && self.self === self && self || + typeof global == 'object' && global.global === global && global || + this || + {}; // Save the previous value of the `_` variable. var previousUnderscore = root._; // Save bytes in the minified (but not gzipped) version: - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; + var ArrayProto = Array.prototype, ObjProto = Object.prototype; + var SymbolProto = typeof Symbol !== 'undefined' ? Symbol.prototype : null; // Create quick reference variables for speed access to core prototypes. - var - push = ArrayProto.push, - slice = ArrayProto.slice, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; + var push = ArrayProto.push, + slice = ArrayProto.slice, + toString = ObjProto.toString, + hasOwnProperty = ObjProto.hasOwnProperty; // All **ECMAScript 5** native function implementations that we hope to use // are declared here. - var - nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeBind = FuncProto.bind, - nativeCreate = Object.create; + var nativeIsArray = Array.isArray, + nativeKeys = Object.keys, + nativeCreate = Object.create; // Naked function reference for surrogate-prototype-swapping. var Ctor = function(){}; @@ -2050,10 +2053,12 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }; // Export the Underscore object for **Node.js**, with - // backwards-compatibility for the old `require()` API. If we're in + // backwards-compatibility for their old module API. If we're in // the browser, add `_` as a global object. - if (true) { - if (typeof module !== 'undefined' && module.exports) { + // (`nodeType` is checked to ensure that `module` + // and `exports` are not HTML elements.) + if (typeof exports != 'undefined' && !exports.nodeType) { + if (typeof module != 'undefined' && !module.nodeType && module.exports) { exports = module.exports = _; } exports._ = _; @@ -2062,7 +2067,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor } // Current version. - _.VERSION = '1.8.3'; + _.VERSION = '1.9.0'; // Internal function that returns an efficient (for current engines) version // of the passed-in callback, to be repeatedly applied in other Underscore @@ -2073,9 +2078,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor case 1: return function(value) { return func.call(context, value); }; - case 2: return function(value, other) { - return func.call(context, value, other); - }; + // The 2-argument case is omitted because we’re not using it. case 3: return function(value, index, collection) { return func.call(context, value, index, collection); }; @@ -2088,34 +2091,51 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }; }; - // A mostly-internal function to generate callbacks that can be applied - // to each element in a collection, returning the desired result — either - // identity, an arbitrary callback, a property matcher, or a property accessor. + var builtinIteratee; + + // An internal function to generate callbacks that can be applied to each + // element in a collection, returning the desired result — either `identity`, + // an arbitrary callback, a property matcher, or a property accessor. var cb = function(value, context, argCount) { + if (_.iteratee !== builtinIteratee) return _.iteratee(value, context); if (value == null) return _.identity; if (_.isFunction(value)) return optimizeCb(value, context, argCount); - if (_.isObject(value)) return _.matcher(value); + if (_.isObject(value) && !_.isArray(value)) return _.matcher(value); return _.property(value); }; - _.iteratee = function(value, context) { + + // External wrapper for our callback generator. Users may customize + // `_.iteratee` if they want additional predicate/iteratee shorthand styles. + // This abstraction hides the internal-only argCount argument. + _.iteratee = builtinIteratee = function(value, context) { return cb(value, context, Infinity); }; - // An internal function for creating assigner functions. - var createAssigner = function(keysFunc, undefinedOnly) { - return function(obj) { - var length = arguments.length; - if (length < 2 || obj == null) return obj; - for (var index = 1; index < length; index++) { - var source = arguments[index], - keys = keysFunc(source), - l = keys.length; - for (var i = 0; i < l; i++) { - var key = keys[i]; - if (!undefinedOnly || obj[key] === void 0) obj[key] = source[key]; - } - } - return obj; + // Some functions take a variable number of arguments, or a few expected + // arguments at the beginning and then a variable number of values to operate + // on. This helper accumulates all remaining arguments past the function’s + // argument length (or an explicit `startIndex`), into an array that becomes + // the last argument. Similar to ES6’s "rest parameter". + var restArguments = function(func, startIndex) { + startIndex = startIndex == null ? func.length - 1 : +startIndex; + return function() { + var length = Math.max(arguments.length - startIndex, 0), + rest = Array(length), + index = 0; + for (; index < length; index++) { + rest[index] = arguments[index + startIndex]; + } + switch (startIndex) { + case 0: return func.call(this, rest); + case 1: return func.call(this, arguments[0], rest); + case 2: return func.call(this, arguments[0], arguments[1], rest); + } + var args = Array(startIndex + 1); + for (index = 0; index < startIndex; index++) { + args[index] = arguments[index]; + } + args[startIndex] = rest; + return func.apply(this, args); }; }; @@ -2129,18 +2149,27 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return result; }; - var property = function(key) { + var shallowProperty = function(key) { return function(obj) { return obj == null ? void 0 : obj[key]; }; }; + var deepGet = function(obj, path) { + var length = path.length; + for (var i = 0; i < length; i++) { + if (obj == null) return void 0; + obj = obj[path[i]]; + } + return length ? obj : void 0; + }; + // Helper for collection methods to determine whether a collection - // should be iterated as an array or as an object + // should be iterated as an array or as an object. // Related: http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength // Avoids a very nasty iOS 8 JIT bug on ARM-64. #2094 var MAX_ARRAY_INDEX = Math.pow(2, 53) - 1; - var getLength = property('length'); + var getLength = shallowProperty('length'); var isArrayLike = function(collection) { var length = getLength(collection); return typeof length == 'number' && length >= 0 && length <= MAX_ARRAY_INDEX; @@ -2182,30 +2211,29 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }; // Create a reducing function iterating left or right. - function createReduce(dir) { - // Optimized iterator function as using arguments.length - // in the main function will deoptimize the, see #1991. - function iterator(obj, iteratee, memo, keys, index, length) { + var createReduce = function(dir) { + // Wrap code that reassigns argument variables in a separate function than + // the one that accesses `arguments.length` to avoid a perf hit. (#1991) + var reducer = function(obj, iteratee, memo, initial) { + var keys = !isArrayLike(obj) && _.keys(obj), + length = (keys || obj).length, + index = dir > 0 ? 0 : length - 1; + if (!initial) { + memo = obj[keys ? keys[index] : index]; + index += dir; + } for (; index >= 0 && index < length; index += dir) { var currentKey = keys ? keys[index] : index; memo = iteratee(memo, obj[currentKey], currentKey, obj); } return memo; - } + }; return function(obj, iteratee, memo, context) { - iteratee = optimizeCb(iteratee, context, 4); - var keys = !isArrayLike(obj) && _.keys(obj), - length = (keys || obj).length, - index = dir > 0 ? 0 : length - 1; - // Determine the initial value if none is provided. - if (arguments.length < 3) { - memo = obj[keys ? keys[index] : index]; - index += dir; - } - return iterator(obj, iteratee, memo, keys, index, length); + var initial = arguments.length >= 3; + return reducer(obj, optimizeCb(iteratee, context, 4), memo, initial); }; - } + }; // **Reduce** builds up a single result from a list of values, aka `inject`, // or `foldl`. @@ -2216,12 +2244,8 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Return the first value which passes a truth test. Aliased as `detect`. _.find = _.detect = function(obj, predicate, context) { - var key; - if (isArrayLike(obj)) { - key = _.findIndex(obj, predicate, context); - } else { - key = _.findKey(obj, predicate, context); - } + var keyFinder = isArrayLike(obj) ? _.findIndex : _.findKey; + var key = keyFinder(obj, predicate, context); if (key !== void 0 && key !== -1) return obj[key]; }; @@ -2276,14 +2300,26 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }; // Invoke a method (with arguments) on every item in a collection. - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - var func = isFunc ? method : value[method]; - return func == null ? func : func.apply(value, args); + _.invoke = restArguments(function(obj, path, args) { + var contextPath, func; + if (_.isFunction(path)) { + func = path; + } else if (_.isArray(path)) { + contextPath = path.slice(0, -1); + path = path[path.length - 1]; + } + return _.map(obj, function(context) { + var method = func; + if (!method) { + if (contextPath && contextPath.length) { + context = deepGet(context, contextPath); + } + if (context == null) return void 0; + method = context[path]; + } + return method == null ? method : method.apply(context, args); }); - }; + }); // Convenience version of a common use case of `map`: fetching a property. _.pluck = function(obj, key) { @@ -2306,20 +2342,20 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor _.max = function(obj, iteratee, context) { var result = -Infinity, lastComputed = -Infinity, value, computed; - if (iteratee == null && obj != null) { + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { obj = isArrayLike(obj) ? obj : _.values(obj); for (var i = 0, length = obj.length; i < length; i++) { value = obj[i]; - if (value > result) { + if (value != null && value > result) { result = value; } } } else { iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); + _.each(obj, function(v, index, list) { + computed = iteratee(v, index, list); if (computed > lastComputed || computed === -Infinity && result === -Infinity) { - result = value; + result = v; lastComputed = computed; } }); @@ -2331,20 +2367,20 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor _.min = function(obj, iteratee, context) { var result = Infinity, lastComputed = Infinity, value, computed; - if (iteratee == null && obj != null) { + if (iteratee == null || typeof iteratee == 'number' && typeof obj[0] != 'object' && obj != null) { obj = isArrayLike(obj) ? obj : _.values(obj); for (var i = 0, length = obj.length; i < length; i++) { value = obj[i]; - if (value < result) { + if (value != null && value < result) { result = value; } } } else { iteratee = cb(iteratee, context); - _.each(obj, function(value, index, list) { - computed = iteratee(value, index, list); + _.each(obj, function(v, index, list) { + computed = iteratee(v, index, list); if (computed < lastComputed || computed === Infinity && result === Infinity) { - result = value; + result = v; lastComputed = computed; } }); @@ -2352,21 +2388,13 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return result; }; - // Shuffle a collection, using the modern version of the - // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). + // Shuffle a collection. _.shuffle = function(obj) { - var set = isArrayLike(obj) ? obj : _.values(obj); - var length = set.length; - var shuffled = Array(length); - for (var index = 0, rand; index < length; index++) { - rand = _.random(0, index); - if (rand !== index) shuffled[index] = shuffled[rand]; - shuffled[rand] = set[index]; - } - return shuffled; + return _.sample(obj, Infinity); }; - // Sample **n** random values from a collection. + // Sample **n** random values from a collection using the modern version of the + // [Fisher-Yates shuffle](http://en.wikipedia.org/wiki/Fisher–Yates_shuffle). // If **n** is not specified, returns a single random element. // The internal `guard` argument allows it to work with `map`. _.sample = function(obj, n, guard) { @@ -2374,17 +2402,28 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor if (!isArrayLike(obj)) obj = _.values(obj); return obj[_.random(obj.length - 1)]; } - return _.shuffle(obj).slice(0, Math.max(0, n)); + var sample = isArrayLike(obj) ? _.clone(obj) : _.values(obj); + var length = getLength(sample); + n = Math.max(Math.min(n, length), 0); + var last = length - 1; + for (var index = 0; index < n; index++) { + var rand = _.random(index, last); + var temp = sample[index]; + sample[index] = sample[rand]; + sample[rand] = temp; + } + return sample.slice(0, n); }; // Sort the object's values by a criterion produced by an iteratee. _.sortBy = function(obj, iteratee, context) { + var index = 0; iteratee = cb(iteratee, context); - return _.pluck(_.map(obj, function(value, index, list) { + return _.pluck(_.map(obj, function(value, key, list) { return { value: value, - index: index, - criteria: iteratee(value, index, list) + index: index++, + criteria: iteratee(value, key, list) }; }).sort(function(left, right) { var a = left.criteria; @@ -2398,9 +2437,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }; // An internal function used for aggregate "group by" operations. - var group = function(behavior) { + var group = function(behavior, partition) { return function(obj, iteratee, context) { - var result = {}; + var result = partition ? [[], []] : {}; iteratee = cb(iteratee, context); _.each(obj, function(value, index) { var key = iteratee(value, index, obj); @@ -2429,10 +2468,15 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor if (_.has(result, key)) result[key]++; else result[key] = 1; }); + var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g; // Safely create a real, live array from anything iterable. _.toArray = function(obj) { if (!obj) return []; if (_.isArray(obj)) return slice.call(obj); + if (_.isString(obj)) { + // Keep surrogate pair characters together + return obj.match(reStrSymbol); + } if (isArrayLike(obj)) return _.map(obj, _.identity); return _.values(obj); }; @@ -2445,14 +2489,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Split a collection into two arrays: one whose elements all satisfy the given // predicate, and one whose elements all do not satisfy the predicate. - _.partition = function(obj, predicate, context) { - predicate = cb(predicate, context); - var pass = [], fail = []; - _.each(obj, function(value, key, obj) { - (predicate(value, key, obj) ? pass : fail).push(value); - }); - return [pass, fail]; - }; + _.partition = group(function(result, value, pass) { + result[pass ? 0 : 1].push(value); + }, true); // Array Functions // --------------- @@ -2461,7 +2500,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // values in the array. Aliased as `head` and `take`. The **guard** check // allows it to work with `_.map`. _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; + if (array == null || array.length < 1) return void 0; if (n == null || guard) return array[0]; return _.initial(array, array.length - n); }; @@ -2476,7 +2515,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Get the last element of an array. Passing **n** will return the last N // values in the array. _.last = function(array, n, guard) { - if (array == null) return void 0; + if (array == null || array.length < 1) return void 0; if (n == null || guard) return array[array.length - 1]; return _.rest(array, Math.max(0, array.length - n)); }; @@ -2490,21 +2529,23 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Trim out all falsy values from an array. _.compact = function(array) { - return _.filter(array, _.identity); + return _.filter(array, Boolean); }; // Internal implementation of a recursive `flatten` function. - var flatten = function(input, shallow, strict, startIndex) { - var output = [], idx = 0; - for (var i = startIndex || 0, length = getLength(input); i < length; i++) { + var flatten = function(input, shallow, strict, output) { + output = output || []; + var idx = output.length; + for (var i = 0, length = getLength(input); i < length; i++) { var value = input[i]; if (isArrayLike(value) && (_.isArray(value) || _.isArguments(value))) { - //flatten current level of array or arguments object - if (!shallow) value = flatten(value, shallow, strict); - var j = 0, len = value.length; - output.length += len; - while (j < len) { - output[idx++] = value[j++]; + // Flatten current level of array or arguments object. + if (shallow) { + var j = 0, len = value.length; + while (j < len) output[idx++] = value[j++]; + } else { + flatten(value, shallow, strict, output); + idx = output.length; } } else if (!strict) { output[idx++] = value; @@ -2519,12 +2560,15 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }; // Return a version of the array that does not contain the specified value(s). - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; + _.without = restArguments(function(array, otherArrays) { + return _.difference(array, otherArrays); + }); // Produce a duplicate-free version of the array. If the array has already // been sorted, you have the option of using a faster algorithm. + // The faster algorithm will not work with an iteratee if the iteratee + // is not a one-to-one function, so providing an iteratee will disable + // the faster algorithm. // Aliased as `unique`. _.uniq = _.unique = function(array, isSorted, iteratee, context) { if (!_.isBoolean(isSorted)) { @@ -2538,7 +2582,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor for (var i = 0, length = getLength(array); i < length; i++) { var value = array[i], computed = iteratee ? iteratee(value, i, array) : value; - if (isSorted) { + if (isSorted && !iteratee) { if (!i || seen !== computed) result.push(value); seen = computed; } else if (iteratee) { @@ -2555,9 +2599,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Produce an array that contains the union: each distinct element from all of // the passed-in arrays. - _.union = function() { - return _.uniq(flatten(arguments, true, true)); - }; + _.union = restArguments(function(arrays) { + return _.uniq(flatten(arrays, true, true)); + }); // Produce an array that contains every item shared between all the // passed-in arrays. @@ -2567,7 +2611,8 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor for (var i = 0, length = getLength(array); i < length; i++) { var item = array[i]; if (_.contains(result, item)) continue; - for (var j = 1; j < argsLength; j++) { + var j; + for (j = 1; j < argsLength; j++) { if (!_.contains(arguments[j], item)) break; } if (j === argsLength) result.push(item); @@ -2577,21 +2622,15 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Take the difference between one array and a number of other arrays. // Only the elements present in just the first array will remain. - _.difference = function(array) { - var rest = flatten(arguments, true, true, 1); + _.difference = restArguments(function(array, rest) { + rest = flatten(rest, true, true); return _.filter(array, function(value){ return !_.contains(rest, value); }); - }; - - // Zip together multiple lists into a single array -- elements that share - // an index go together. - _.zip = function() { - return _.unzip(arguments); - }; + }); // Complement of _.zip. Unzip accepts an array of arrays and groups - // each array's elements on shared indices + // each array's elements on shared indices. _.unzip = function(array) { var length = array && _.max(array, getLength).length || 0; var result = Array(length); @@ -2602,9 +2641,13 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return result; }; + // Zip together multiple lists into a single array -- elements that share + // an index go together. + _.zip = restArguments(_.unzip); + // Converts lists into objects. Pass either a single array of `[key, value]` // pairs, or two parallel arrays of the same length -- one of keys, and one of - // the corresponding values. + // the corresponding values. Passing by pairs is the reverse of _.pairs. _.object = function(list, values) { var result = {}; for (var i = 0, length = getLength(list); i < length; i++) { @@ -2617,8 +2660,8 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return result; }; - // Generator function to create the findIndex and findLastIndex functions - function createPredicateIndexFinder(dir) { + // Generator function to create the findIndex and findLastIndex functions. + var createPredicateIndexFinder = function(dir) { return function(array, predicate, context) { predicate = cb(predicate, context); var length = getLength(array); @@ -2628,9 +2671,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor } return -1; }; - } + }; - // Returns the first index on an array-like that passes a predicate test + // Returns the first index on an array-like that passes a predicate test. _.findIndex = createPredicateIndexFinder(1); _.findLastIndex = createPredicateIndexFinder(-1); @@ -2647,15 +2690,15 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return low; }; - // Generator function to create the indexOf and lastIndexOf functions - function createIndexFinder(dir, predicateFind, sortedIndex) { + // Generator function to create the indexOf and lastIndexOf functions. + var createIndexFinder = function(dir, predicateFind, sortedIndex) { return function(array, item, idx) { var i = 0, length = getLength(array); if (typeof idx == 'number') { if (dir > 0) { - i = idx >= 0 ? idx : Math.max(idx + length, i); + i = idx >= 0 ? idx : Math.max(idx + length, i); } else { - length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; + length = idx >= 0 ? Math.min(idx + 1, length) : idx + length + 1; } } else if (sortedIndex && idx && length) { idx = sortedIndex(array, item); @@ -2670,7 +2713,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor } return -1; }; - } + }; // Return the position of the first occurrence of an item in an array, // or -1 if the item is not included in the array. @@ -2687,7 +2730,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor stop = start || 0; start = 0; } - step = step || 1; + if (!step) { + step = stop < start ? -1 : 1; + } var length = Math.max(Math.ceil((stop - start) / step), 0); var range = Array(length); @@ -2699,11 +2744,23 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return range; }; + // Chunk a single array into multiple arrays, each containing `count` or fewer + // items. + _.chunk = function(array, count) { + if (count == null || count < 1) return []; + var result = []; + var i = 0, length = array.length; + while (i < length) { + result.push(slice.call(array, i, i += count)); + } + return result; + }; + // Function (ahem) Functions // ------------------ // Determines whether to execute a function as a constructor - // or a normal function with the provided arguments + // or a normal function with the provided arguments. var executeBound = function(sourceFunc, boundFunc, context, callingContext, args) { if (!(callingContext instanceof boundFunc)) return sourceFunc.apply(context, args); var self = baseCreate(sourceFunc.prototype); @@ -2715,45 +2772,46 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Create a function bound to a given object (assigning `this`, and arguments, // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if // available. - _.bind = function(func, context) { - if (nativeBind && func.bind === nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + _.bind = restArguments(function(func, context, args) { if (!_.isFunction(func)) throw new TypeError('Bind must be called on a function'); - var args = slice.call(arguments, 2); - var bound = function() { - return executeBound(func, bound, context, this, args.concat(slice.call(arguments))); - }; + var bound = restArguments(function(callArgs) { + return executeBound(func, bound, context, this, args.concat(callArgs)); + }); return bound; - }; + }); // Partially apply a function by creating a version that has had some of its // arguments pre-filled, without changing its dynamic `this` context. _ acts - // as a placeholder, allowing any combination of arguments to be pre-filled. - _.partial = function(func) { - var boundArgs = slice.call(arguments, 1); + // as a placeholder by default, allowing any combination of arguments to be + // pre-filled. Set `_.partial.placeholder` for a custom placeholder argument. + _.partial = restArguments(function(func, boundArgs) { + var placeholder = _.partial.placeholder; var bound = function() { var position = 0, length = boundArgs.length; var args = Array(length); for (var i = 0; i < length; i++) { - args[i] = boundArgs[i] === _ ? arguments[position++] : boundArgs[i]; + args[i] = boundArgs[i] === placeholder ? arguments[position++] : boundArgs[i]; } while (position < arguments.length) args.push(arguments[position++]); return executeBound(func, bound, this, this, args); }; return bound; - }; + }); + + _.partial.placeholder = _; // Bind a number of an object's methods to that object. Remaining arguments // are the method names to be bound. Useful for ensuring that all callbacks // defined on an object belong to it. - _.bindAll = function(obj) { - var i, length = arguments.length, key; - if (length <= 1) throw new Error('bindAll must be passed function names'); - for (i = 1; i < length; i++) { - key = arguments[i]; + _.bindAll = restArguments(function(obj, keys) { + keys = flatten(keys, false, false); + var index = keys.length; + if (index < 1) throw new Error('bindAll must be passed function names'); + while (index--) { + var key = keys[index]; obj[key] = _.bind(obj[key], obj); } - return obj; - }; + }); // Memoize an expensive function by storing its results. _.memoize = function(func, hasher) { @@ -2769,12 +2827,11 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Delays a function for the given number of milliseconds, and then calls // it with the arguments supplied. - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ + _.delay = restArguments(function(func, wait, args) { + return setTimeout(function() { return func.apply(null, args); }, wait); - }; + }); // Defers a function, scheduling it to run after the current call stack has // cleared. @@ -2786,17 +2843,18 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // but if you'd like to disable the execution on the leading edge, pass // `{leading: false}`. To disable execution on the trailing edge, ditto. _.throttle = function(func, wait, options) { - var context, args, result; - var timeout = null; + var timeout, context, args, result; var previous = 0; if (!options) options = {}; + var later = function() { previous = options.leading === false ? 0 : _.now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; - return function() { + + var throttled = function() { var now = _.now(); if (!previous && options.leading === false) previous = now; var remaining = wait - (now - previous); @@ -2815,6 +2873,14 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor } return result; }; + + throttled.cancel = function() { + clearTimeout(timeout); + previous = 0; + timeout = context = args = null; + }; + + return throttled; }; // Returns a function, that, as long as it continues to be invoked, will not @@ -2822,35 +2888,32 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // N milliseconds. If `immediate` is passed, trigger the function on the // leading edge, instead of the trailing. _.debounce = function(func, wait, immediate) { - var timeout, args, context, timestamp, result; + var timeout, result; - var later = function() { - var last = _.now() - timestamp; - - if (last < wait && last >= 0) { - timeout = setTimeout(later, wait - last); - } else { - timeout = null; - if (!immediate) { - result = func.apply(context, args); - if (!timeout) context = args = null; - } - } + var later = function(context, args) { + timeout = null; + if (args) result = func.apply(context, args); }; - return function() { - context = this; - args = arguments; - timestamp = _.now(); - var callNow = immediate && !timeout; - if (!timeout) timeout = setTimeout(later, wait); - if (callNow) { - result = func.apply(context, args); - context = args = null; + var debounced = restArguments(function(args) { + if (timeout) clearTimeout(timeout); + if (immediate) { + var callNow = !timeout; + timeout = setTimeout(later, wait); + if (callNow) result = func.apply(this, args); + } else { + timeout = _.delay(later, wait, this, args); } return result; + }); + + debounced.cancel = function() { + clearTimeout(timeout); + timeout = null; }; + + return debounced; }; // Returns the first function passed as an argument to the second, @@ -2905,18 +2968,20 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // often you call it. Useful for lazy initialization. _.once = _.partial(_.before, 2); + _.restArguments = restArguments; + // Object Functions // ---------------- // Keys in IE < 9 that won't be iterated by `for key in ...` and thus missed. var hasEnumBug = !{toString: null}.propertyIsEnumerable('toString'); var nonEnumerableProps = ['valueOf', 'isPrototypeOf', 'toString', - 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - function collectNonEnumProps(obj, keys) { + var collectNonEnumProps = function(obj, keys) { var nonEnumIdx = nonEnumerableProps.length; var constructor = obj.constructor; - var proto = (_.isFunction(constructor) && constructor.prototype) || ObjProto; + var proto = _.isFunction(constructor) && constructor.prototype || ObjProto; // Constructor is a special case. var prop = 'constructor'; @@ -2928,10 +2993,10 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor keys.push(prop); } } - } + }; // Retrieve the names of an object's own properties. - // Delegates to **ECMAScript 5**'s native `Object.keys` + // Delegates to **ECMAScript 5**'s native `Object.keys`. _.keys = function(obj) { if (!_.isObject(obj)) return []; if (nativeKeys) return nativeKeys(obj); @@ -2963,22 +3028,22 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return values; }; - // Returns the results of applying the iteratee to each element of the object - // In contrast to _.map it returns an object + // Returns the results of applying the iteratee to each element of the object. + // In contrast to _.map it returns an object. _.mapObject = function(obj, iteratee, context) { iteratee = cb(iteratee, context); - var keys = _.keys(obj), - length = keys.length, - results = {}, - currentKey; - for (var index = 0; index < length; index++) { - currentKey = keys[index]; - results[currentKey] = iteratee(obj[currentKey], currentKey, obj); - } - return results; + var keys = _.keys(obj), + length = keys.length, + results = {}; + for (var index = 0; index < length; index++) { + var currentKey = keys[index]; + results[currentKey] = iteratee(obj[currentKey], currentKey, obj); + } + return results; }; // Convert an object into a list of `[key, value]` pairs. + // The opposite of _.object. _.pairs = function(obj) { var keys = _.keys(obj); var length = keys.length; @@ -3000,7 +3065,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }; // Return a sorted list of the function names available on the object. - // Aliased as `methods` + // Aliased as `methods`. _.functions = _.methods = function(obj) { var names = []; for (var key in obj) { @@ -3009,14 +3074,33 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return names.sort(); }; + // An internal function for creating assigner functions. + var createAssigner = function(keysFunc, defaults) { + return function(obj) { + var length = arguments.length; + if (defaults) obj = Object(obj); + if (length < 2 || obj == null) return obj; + for (var index = 1; index < length; index++) { + var source = arguments[index], + keys = keysFunc(source), + l = keys.length; + for (var i = 0; i < l; i++) { + var key = keys[i]; + if (!defaults || obj[key] === void 0) obj[key] = source[key]; + } + } + return obj; + }; + }; + // Extend a given object with all the properties in passed-in object(s). _.extend = createAssigner(_.allKeys); - // Assigns a given object with all the own properties in the passed-in object(s) + // Assigns a given object with all the own properties in the passed-in object(s). // (https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) _.extendOwn = _.assign = createAssigner(_.keys); - // Returns the first key on an object that passes a predicate test + // Returns the first key on an object that passes a predicate test. _.findKey = function(obj, predicate, context) { predicate = cb(predicate, context); var keys = _.keys(obj), key; @@ -3026,16 +3110,21 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor } }; + // Internal pick helper function to determine if `obj` has key `key`. + var keyInObj = function(value, key, obj) { + return key in obj; + }; + // Return a copy of the object only containing the whitelisted properties. - _.pick = function(object, oiteratee, context) { - var result = {}, obj = object, iteratee, keys; + _.pick = restArguments(function(obj, keys) { + var result = {}, iteratee = keys[0]; if (obj == null) return result; - if (_.isFunction(oiteratee)) { + if (_.isFunction(iteratee)) { + if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]); keys = _.allKeys(obj); - iteratee = optimizeCb(oiteratee, context); } else { - keys = flatten(arguments, false, false, 1); - iteratee = function(value, key, obj) { return key in obj; }; + iteratee = keyInObj; + keys = flatten(keys, false, false); obj = Object(obj); } for (var i = 0, length = keys.length; i < length; i++) { @@ -3044,20 +3133,22 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor if (iteratee(value, key, obj)) result[key] = value; } return result; - }; + }); - // Return a copy of the object without the blacklisted properties. - _.omit = function(obj, iteratee, context) { + // Return a copy of the object without the blacklisted properties. + _.omit = restArguments(function(obj, keys) { + var iteratee = keys[0], context; if (_.isFunction(iteratee)) { iteratee = _.negate(iteratee); + if (keys.length > 1) context = keys[1]; } else { - var keys = _.map(flatten(arguments, false, false, 1), String); + keys = _.map(flatten(keys, false, false), String); iteratee = function(value, key) { return !_.contains(keys, key); }; } return _.pick(obj, iteratee, context); - }; + }); // Fill in a given object with default properties. _.defaults = createAssigner(_.allKeys, true); @@ -3099,12 +3190,23 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Internal recursive comparison function for `isEqual`. - var eq = function(a, b, aStack, bStack) { + var eq, deepEq; + eq = function(a, b, aStack, bStack) { // Identical objects are equal. `0 === -0`, but they aren't identical. // See the [Harmony `egal` proposal](http://wiki.ecmascript.org/doku.php?id=harmony:egal). if (a === b) return a !== 0 || 1 / a === 1 / b; - // A strict comparison is necessary because `null == undefined`. - if (a == null || b == null) return a === b; + // `null` or `undefined` only equal to itself (strict comparison). + if (a == null || b == null) return false; + // `NaN`s are equivalent, but non-reflexive. + if (a !== a) return b !== b; + // Exhaust primitive checks + var type = typeof a; + if (type !== 'function' && type !== 'object' && typeof b != 'object') return false; + return deepEq(a, b, aStack, bStack); + }; + + // Internal recursive comparison function for `isEqual`. + deepEq = function(a, b, aStack, bStack) { // Unwrap any wrapped objects. if (a instanceof _) a = a._wrapped; if (b instanceof _) b = b._wrapped; @@ -3121,7 +3223,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return '' + a === '' + b; case '[object Number]': // `NaN`s are equivalent, but non-reflexive. - // Object(NaN) is equivalent to NaN + // Object(NaN) is equivalent to NaN. if (+a !== +a) return +b !== +b; // An `egal` comparison is performed for other numeric values. return +a === 0 ? 1 / +a === 1 / b : +a === +b; @@ -3131,6 +3233,8 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // millisecond representations. Note that invalid dates with millisecond representations // of `NaN` are not equivalent. return +a === +b; + case '[object Symbol]': + return SymbolProto.valueOf.call(a) === SymbolProto.valueOf.call(b); } var areArrays = className === '[object Array]'; @@ -3221,8 +3325,8 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return type === 'function' || type === 'object' && !!obj; }; - // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError. - _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function(name) { + // Add some isType methods: isArguments, isFunction, isString, isNumber, isDate, isRegExp, isError, isMap, isWeakMap, isSet, isWeakSet. + _.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet'], function(name) { _['is' + name] = function(obj) { return toString.call(obj) === '[object ' + name + ']'; }; @@ -3237,8 +3341,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor } // Optimize `isFunction` if appropriate. Work around some typeof bugs in old v8, - // IE 11 (#1621), and in Safari 8 (#1929). - if (typeof /./ != 'function' && typeof Int8Array != 'object') { + // IE 11 (#1621), Safari 8 (#1929), and PhantomJS (#2236). + var nodelist = root.document && root.document.childNodes; + if (typeof /./ != 'function' && typeof Int8Array != 'object' && typeof nodelist != 'function') { _.isFunction = function(obj) { return typeof obj == 'function' || false; }; @@ -3246,12 +3351,12 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Is a given object a finite number? _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); + return !_.isSymbol(obj) && isFinite(obj) && !isNaN(parseFloat(obj)); }; - // Is the given value `NaN`? (NaN is the only number which does not equal itself). + // Is the given value `NaN`? _.isNaN = function(obj) { - return _.isNumber(obj) && obj !== +obj; + return _.isNumber(obj) && isNaN(obj); }; // Is a given value a boolean? @@ -3271,8 +3376,19 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Shortcut function for checking if an object has a given property directly // on itself (in other words, not on a prototype). - _.has = function(obj, key) { - return obj != null && hasOwnProperty.call(obj, key); + _.has = function(obj, path) { + if (!_.isArray(path)) { + return obj != null && hasOwnProperty.call(obj, path); + } + var length = path.length; + for (var i = 0; i < length; i++) { + var key = path[i]; + if (obj == null || !hasOwnProperty.call(obj, key)) { + return false; + } + obj = obj[key]; + } + return !!length; }; // Utility Functions @@ -3299,12 +3415,24 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor _.noop = function(){}; - _.property = property; + // Creates a function that, when passed an object, will traverse that object’s + // properties down the given `path`, specified as an array of keys or indexes. + _.property = function(path) { + if (!_.isArray(path)) { + return shallowProperty(path); + } + return function(obj) { + return deepGet(obj, path); + }; + }; // Generates a function for a given object that returns a given property. _.propertyOf = function(obj) { - return obj == null ? function(){} : function(key) { - return obj[key]; + if (obj == null) { + return function(){}; + } + return function(path) { + return !_.isArray(path) ? obj[path] : deepGet(obj, path); }; }; @@ -3339,7 +3467,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor return new Date().getTime(); }; - // List of HTML entities for escaping. + // List of HTML entities for escaping. var escapeMap = { '&': '&', '<': '<', @@ -3355,7 +3483,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor var escaper = function(match) { return map[match]; }; - // Regexes for identifying a key that needs to be escaped + // Regexes for identifying a key that needs to be escaped. var source = '(?:' + _.keys(map).join('|') + ')'; var testRegexp = RegExp(source); var replaceRegexp = RegExp(source, 'g'); @@ -3367,14 +3495,24 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor _.escape = createEscaper(escapeMap); _.unescape = createEscaper(unescapeMap); - // If the value of the named `property` is a function then invoke it with the - // `object` as context; otherwise, return it. - _.result = function(object, property, fallback) { - var value = object == null ? void 0 : object[property]; - if (value === void 0) { - value = fallback; + // Traverses the children of `obj` along `path`. If a child is a function, it + // is invoked with its parent as context. Returns the value of the final + // child, or `fallback` if any child is undefined. + _.result = function(obj, path, fallback) { + if (!_.isArray(path)) path = [path]; + var length = path.length; + if (!length) { + return _.isFunction(fallback) ? fallback.call(obj) : fallback; } - return _.isFunction(value) ? value.call(object) : value; + for (var i = 0; i < length; i++) { + var prop = obj == null ? void 0 : obj[path[i]]; + if (prop === void 0) { + prop = fallback; + i = length; // Ensure we don't continue iterating. + } + obj = _.isFunction(prop) ? prop.call(obj) : prop; + } + return obj; }; // Generate a unique integer id (unique within the entire client session). @@ -3388,9 +3526,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // By default, Underscore uses ERB-style template delimiters, change the // following template settings to use alternative delimiters. _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g + evaluate: /<%([\s\S]+?)%>/g, + interpolate: /<%=([\s\S]+?)%>/g, + escape: /<%-([\s\S]+?)%>/g }; // When customizing `templateSettings`, if you don't want to define an @@ -3401,15 +3539,15 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // Certain characters need to be escaped so that they can be put into a // string literal. var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', '\u2028': 'u2028', '\u2029': 'u2029' }; - var escaper = /\\|'|\r|\n|\u2028|\u2029/g; + var escapeRegExp = /\\|'|\r|\n|\u2028|\u2029/g; var escapeChar = function(match) { return '\\' + escapes[match]; @@ -3434,7 +3572,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor var index = 0; var source = "__p+='"; text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset).replace(escaper, escapeChar); + source += text.slice(index, offset).replace(escapeRegExp, escapeChar); index = offset + match.length; if (escape) { @@ -3445,7 +3583,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor source += "';\n" + evaluate + "\n__p+='"; } - // Adobe VMs need the match returned to produce the correct offest. + // Adobe VMs need the match returned to produce the correct offset. return match; }); source += "';\n"; @@ -3457,8 +3595,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor "print=function(){__p+=__j.call(arguments,'');};\n" + source + 'return __p;\n'; + var render; try { - var render = new Function(settings.variable || 'obj', '_', source); + render = new Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; @@ -3489,7 +3628,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor // underscore functions. Wrapped objects may be chained. // Helper function to continue chaining intermediate results. - var result = function(instance, obj) { + var chainResult = function(instance, obj) { return instance._chain ? _(obj).chain() : obj; }; @@ -3500,9 +3639,10 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor _.prototype[name] = function() { var args = [this._wrapped]; push.apply(args, arguments); - return result(this, func.apply(_, args)); + return chainResult(this, func.apply(_, args)); }; }); + return _; }; // Add all of the Underscore functions to the wrapper object. @@ -3515,7 +3655,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor var obj = this._wrapped; method.apply(obj, arguments); if ((name === 'shift' || name === 'splice') && obj.length === 0) delete obj[0]; - return result(this, obj); + return chainResult(this, obj); }; }); @@ -3523,7 +3663,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor _.each(['concat', 'join', 'slice'], function(name) { var method = ArrayProto[name]; _.prototype[name] = function() { - return result(this, method.apply(this._wrapped, arguments)); + return chainResult(this, method.apply(this._wrapped, arguments)); }; }); @@ -3537,7 +3677,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor _.prototype.valueOf = _.prototype.toJSON = _.prototype.value; _.prototype.toString = function() { - return '' + this._wrapped; + return String(this._wrapped); }; // AMD registration happens at the end for compatibility with AMD loaders @@ -3553,8 +3693,9 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); } -}.call(this)); +}()); +/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(7), __webpack_require__(65)(module))) /***/ }), /* 2 */ @@ -3566,7 +3707,7 @@ var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// Underscor Object.defineProperty(exports, "__esModule", { value: true }); -exports.getUnitFromValue = exports.normalizeFloat = exports.shallowDiff = exports.camelCase = exports.matches = exports.upFirst = exports.hasDnd = exports.off = exports.on = undefined; +exports.getUnitFromValue = exports.normalizeFloat = exports.shallowDiff = exports.getElement = exports.camelCase = exports.matches = exports.upFirst = exports.hasDnd = exports.off = exports.on = undefined; var _underscore = __webpack_require__(1); @@ -3677,12 +3818,26 @@ var hasDnd = function hasDnd(em) { return 'draggable' in document.createElement('i') && (em ? em.get('Config').nativeDnD : 1); }; +/** + * Ensure to fetch the element from the input argument + * @param {HTMLElement|Component} el Component or HTML element + * @return {HTMLElement} + */ +var getElement = function getElement(el) { + if ((0, _underscore.isElement)(el)) { + return el; + } else if (el.getEl) { + return el.getEl(); + } +}; + exports.on = on; exports.off = off; exports.hasDnd = hasDnd; exports.upFirst = upFirst; exports.matches = matches; exports.camelCase = camelCase; +exports.getElement = getElement; exports.shallowDiff = shallowDiff; exports.normalizeFloat = normalizeFloat; exports.getUnitFromValue = getUnitFromValue; @@ -3692,13 +3847,19 @@ exports.getUnitFromValue = getUnitFromValue; /***/ (function(module, exports, __webpack_require__) { "use strict"; -/* WEBPACK VAR INJECTION */(function(Backbone) { + + +var _backbone = __webpack_require__(0); + +var _backbone2 = _interopRequireDefault(_backbone); var _underscore = __webpack_require__(1); -var ComponentsView = __webpack_require__(50); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -module.exports = Backbone.View.extend({ +var ComponentsView = __webpack_require__(52); + +module.exports = _backbone2.default.View.extend({ className: function className() { return this.getClasses(); }, @@ -3735,7 +3896,7 @@ module.exports = Backbone.View.extend({ this.init(); }, remove: function remove() { - Backbone.View.prototype.remove.apply(this); + _backbone2.default.View.prototype.remove.apply(this); var children = this.childrenView; children && children.stopListening(); }, @@ -3798,7 +3959,10 @@ module.exports = Backbone.View.extend({ * @param {Event} e * @private * */ - updateStatus: function updateStatus(e) { + updateStatus: function updateStatus() { + var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var em = this.em; var el = this.el; var status = this.model.get('status'); var pfx = this.pfx; @@ -3806,7 +3970,9 @@ module.exports = Backbone.View.extend({ var selectedCls = pfx + 'selected'; var selectedParentCls = selectedCls + '-parent'; var freezedCls = ppfx + 'freezed'; - this.$el.removeClass(selectedCls + ' ' + selectedParentCls + ' ' + freezedCls); + var hoveredCls = ppfx + 'hovered'; + var toRemove = [selectedCls, selectedParentCls, freezedCls, hoveredCls]; + this.$el.removeClass(toRemove.join(' ')); var actualCls = el.getAttribute('class') || ''; var cls = ''; @@ -3823,13 +3989,13 @@ module.exports = Backbone.View.extend({ case 'freezed-selected': cls = actualCls + ' ' + freezedCls + ' ' + selectedCls; break; + case 'hovered': + cls = !opts.avoidHover ? actualCls + ' ' + hoveredCls : ''; + break; } cls = cls.trim(); - - if (cls) { - el.setAttribute('class', cls); - } + cls && el.setAttribute('class', cls); }, @@ -3911,7 +4077,7 @@ module.exports = Backbone.View.extend({ * */ updateAttributes: function updateAttributes() { var model = this.model; - var attrs = {}; + var attrs = { 'data-gjs-type': model.get('type') || 'default' }; var attr = model.get('attributes'); var src = model.get('src'); @@ -4050,7 +4216,6 @@ module.exports = Backbone.View.extend({ }, onRender: function onRender() {} }); -/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(0))) /***/ }), /* 4 */ @@ -4065,17 +4230,17 @@ var _underscore = __webpack_require__(1); var _mixins = __webpack_require__(2); -var _Styleable = __webpack_require__(46); +var _Styleable = __webpack_require__(48); var _Styleable2 = _interopRequireDefault(_Styleable); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var Backbone = __webpack_require__(0); -var Components = __webpack_require__(49); -var Selector = __webpack_require__(7); +var Components = __webpack_require__(51); +var Selector = __webpack_require__(8); var Selectors = __webpack_require__(11); -var Traits = __webpack_require__(151); +var Traits = __webpack_require__(154); var componentList = {}; var componentIndex = 0; @@ -4973,17 +5138,23 @@ module.exports = Component; /***/ (function(module, exports, __webpack_require__) { "use strict"; -/* WEBPACK VAR INJECTION */(function(Backbone) { + + +var _backbone = __webpack_require__(0); + +var _backbone2 = _interopRequireDefault(_backbone); var _underscore = __webpack_require__(1); var _mixins = __webpack_require__(2); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var clearProp = 'data-clear-style'; -module.exports = Backbone.View.extend({ +module.exports = _backbone2.default.View.extend({ template: function template(model) { var pfx = this.pfx; return '\n