Sha256: 1e202ce6e232f2bbfd6e769ad356fb6eebc3820c9696fb027af21503cd399d82

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

/*jshint evil:true*/

minispade = {
  root: null,
  modules: {},
  loaded: {},

  globalEval: function(data) {
    if ( data ) {
      // We use execScript on Internet Explorer
      // We use an anonymous function so that context is window
      // rather than jQuery in Firefox
      ( window.execScript || function( data ) {
        window[ "eval" ].call( window, data );
      } )( data );
    }
  },

  require: function(name) {
    var loaded = minispade.loaded[name];
    var mod = minispade.modules[name];

    if (!loaded) {
      if (mod) {
        minispade.loaded[name] = true;

        if (typeof mod === "string") {
          this.globalEval(mod);
        } else {
          mod();
        }
      } else {
        if (minispade.root && name.substr(0,minispade.root.length) !== minispade.root) {
          return minispade.require(minispade.root+name);
        } else {
          throw "The module '" + name + "' could not be found";
        }
      }
    }

    return loaded;
  },

  requireAll: function(regex) {
    for (var module in this.modules) {
      if (!this.modules.hasOwnProperty(module)) { continue; }
      if (regex && !regex.test(module)) { continue; }
      minispade.require(module);
    }
  },

  register: function(name, callback) {
    minispade.modules[name] = callback;
  }
};

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
perkins-0.0.5 lib/perkins/assets/javascripts/vendor/minispade.js
perkins-0.0.3 lib/perkins/assets/javascripts/vendor/minispade.js
perkins-0.0.2 lib/perkins/assets/javascripts/vendor/minispade.js
perkins-0.0.1 lib/perkins/assets/javascripts/vendor/minispade.js