Sha256: c6fbb9caa5c9438a1ba1eff11922247940ea01bdc04174cfde3c16589de9d469

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

/*jshint evil:true*/

if (typeof document !== "undefined") {
  (function() {
    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 );
        }
      },

      requireModule: 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.requireModule(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.requireModule(module);
        }
      },

      require: function(path) {
        if (typeof path === 'string') {
          minispade.requireModule(path);
        } else {
          minispade.requireAll(path);
        }
      },

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
brainstem-js-0.3.0 spec/vendor/minispade.js
brainstem-js-0.2.1 spec/vendor/minispade.js