Sha256: 8f9dcaac0a552007b056ef0bd761bf954ca411e884ce5459b01adf15121f05c7

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

Shuriken.defineExtension(function(baseNS) {
  return baseNS.withNS('Mixins', function(ns) {
    var defineMixin, root;
    root = this.getRootNS();
    ns.mixins = {};
    root.mixins = {};
    root.withBase(function(base) {
      return (base.mixin = function(mixins) {
        return ns.mixin(this, mixins);
      });
    });
    defineMixin = function(key, mixin) {
      return (this.mixins[key] = mixin);
    };
    root.defineMixin = defineMixin;
    ns.define = defineMixin;
    ns.lookupMixin = function(mixin) {
      var _a, _b, _c;
      if ((_a = typeof mixin) === "string") {
        if ((typeof (_b = ns.mixins[mixin]) !== "undefined" && _b !== null)) {
          return ns.mixins[mixin];
        } else if ((typeof (_c = root.mixins[mixin]) !== "undefined" && _c !== null)) {
          return root.mixins[mixin];
        } else {
          return {};
        }
      } else {
        return mixin;
      }
    };
    ns.invokeMixin = function(scope, mixin) {
      var _a;
      if ((_a = typeof mixin) === "string") {
        return ns.invokeMixin(scope, ns.lookupMixin(mixin));
      } else if (_a === "function") {
        return mixin.call(scope, scope);
      } else if (_a === "object") {
        return $.extend(scope, mixin);
      }
    };
    return (ns.mixin = function(scope, mixins) {
      var _a, _b, _c, mixin;
      if (!($.isArray(mixins))) {
        mixins = [mixins];
      }
      _b = mixins;
      for (_a = 0, _c = _b.length; _a < _c; _a++) {
        mixin = _b[_a];
        ns.invokeMixin(scope, ns.lookupMixin(mixin));
      }
      return true;
    });
  });
});

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shuriken-0.2.1 javascripts/shuriken/mixins.js