Sha256: 35e19e352386a6957d09fc3fa343b0ff041f182a23baeae1a1d9a02d3f99b48c

Contents?: true

Size: 1.18 KB

Versions: 34

Compression:

Stored size: 1.18 KB

Contents

/**
 * Duplication of $.extend(), so whole jQuery dont have to be loaded
 * @param {boolean|Object} deep
 * @param {Object} target
 * @param {Object} [source]
 * @return {Object}
 */
EasyGem.extend = function (deep, target, source) {
  var copyIsArray;
  if (typeof deep !== "boolean") {
    source = target;
    target = deep;
    deep = false;
  }
  if (source === undefined) return target;
  if (typeof target !== "object") {
    target = {};
  }
  for (var name in source) {
    if (!source.hasOwnProperty(name)) continue;
    var trg = target[name];
    var src = source[name];

    // Prevent never-ending loop
    if (trg === src) continue;
    if (deep && src && typeof src === "object") {
      copyIsArray = Array.isArray(src);
      if (copyIsArray) {
        copyIsArray = false;
        var clone = trg && Array.isArray(trg) ? trg : [];

      } else {
        clone = trg && (typeof trg === "object") ? trg : {};
      }

      // Never move original objects, clone them
      target[name] = EasyGem.extend(deep, clone, src);

      // Don't bring in undefined values
    } else if (src !== undefined) {
      target[name] = src;
    }
  }
  return target;
};
EASY.extend = EasyGem.extend;

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
redmine_extensions-1.2.0 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-1.1.2 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-1.1.1 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-1.1.0 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-1.0.0 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.6.3 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.6.2 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.6.1 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.6.0 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.4.5 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.5.1 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.4.4 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.4.3 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.4.1 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.4.0 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.4.0.beta app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.3.11 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.3.10 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.3.9 app/assets/javascripts/redmine_extensions/blocking_utils.js
redmine_extensions-0.3.8 app/assets/javascripts/redmine_extensions/blocking_utils.js