Sha256: 5b25ca5acaa71c99b121d0c35f9e62e4558968e6c304de54293182ed1a3cd7fb

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

"use strict";

var app = (function() {
  var s4 = function () {
    return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
  };

  var singletons = []

  return {
    _singleton: {
      add: function(name, fn) {
        app[name] = fn;
        singletons.push(name);
        app[name].init = function(){
          app[name] = app[name]();
          if(app[name] == undefined) {
            app[name] = {};
          }
          app[name].init = function(){
            return app[name];
          }
          return app[name];
        };
      },
      init: function(name, fn) {
        app._singleton.add(name, fn);
        return app[name].init();
      },
      listAdded: singletons
    },
    // free generator http://ajaxload.info/
    _ajax: {
      addEvent: {
        lockAfterClick: function() {
          $("a[data-remote='true']").bind('ajax:beforeSend', function(){
            window.example = "beforeSend"
          }).bind("ajax:success", function() {
            window.example += 'success';
          }).bind("ajax:complete", function(event, data, status, xhr) {
            window.example += 'complete';
          });
        }
      }
    },
    _config: {
      array: function(){
        Array.prototype.each = function(fn) {
          for(var i=0; i<this.length; i++) {
            fn(this[i]);
          }
        }
        Array.prototype.any = function() {
          return (this.length > 0);
        }
        Array.prototype.empty = function() {
          return (this.length == 0);
        }
        Array.prototype.equal = function(nextArray) {
          return JSON.stringify(this) == JSON.stringify(nextArray);
        }
      }
    },
    _uuid: function(){
      return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
    }
  }
})();

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appjs-rails-1.0.3 app/assets/javascripts/app.js