Permalink
Browse files

I just saved 15% on my filesize by switching to tabs.

  • Loading branch information...
1 parent 7a1831d commit 9f949664287bccf58ad822242bbda0d42efda143 @Yuffster committed Apr 16, 2012
Showing with 105 additions and 105 deletions.
  1. +105 −105 eve.js
View
210 eve.js
@@ -1,7 +1,7 @@
/**
* Eve.js <evejs.com> - Version: 0.2 (April 15, 2012)
*
- * A JavaScript meta-framework for scoped event delegation.
+ * A JavaScript meta-framework for scoped event delegation.
*
* Copyright (c) 2012 Michelle Steigerwalt, http://evejs.com/
*
@@ -26,122 +26,122 @@
*/
window.Eve = {
- __registry: {},
+ __registry: {},
- __scopes: {},
+ __scopes: {},
- __attachments: {},
+ __attachments: {},
- __debugging: [],
+ __debugging: [],
- __debugAll: false,
-
- dbug: function(name, message) {
+ __debugAll: false,
+
+ dbug: function(name, message) {
if (!window.console) { return; }
- var debug = this.__debugAll;
- if (!this.__debugAll) {
- debug = false;
- for (var i = 0; i<this.__debugging.length; i++) {
- if (this.__debugging[i]==name) debug = true;
- }
- }
- if (!debug) { return; }
- while (name.length<10) { name=name+' '; }
- name = name.substring(0, 10)+" - ";
- console.info(name, message);
- },
+ var debug = this.__debugAll;
+ if (!this.__debugAll) {
+ debug = false;
+ for (var i = 0; i<this.__debugging.length; i++) {
+ if (this.__debugging[i]==name) debug = true;
+ }
+ }
+ if (!debug) { return; }
+ while (name.length<10) { name=name+' '; }
+ name = name.substring(0, 10)+" - ";
+ console.info(name, message);
+ },
- debug: function(moduleName) {
- if (moduleName) {
- this.__debugging.push(moduleName);
- } else {
- this.__debugAll = true;
- }
- },
+ debug: function(moduleName) {
+ if (moduleName) {
+ this.__debugging.push(moduleName);
+ } else {
+ this.__debugAll = true;
+ }
+ },
- register: function(name, obj) {
- this.dbug(name, "registered");
- if (this.__registry[name]) {
+ register: function(name, obj) {
+ this.dbug(name, "registered");
+ if (this.__registry[name]) {
throw new Error("Module already exists: "+name);
}
- obj.prototype.del = this.delegateScoped;
- this.__registry[name] = obj;
- return this;
- },
+ obj.prototype.del = this.delegateScoped;
+ this.__registry[name] = obj;
+ return this;
+ },
- scope: function(ns, fun) {
- if (this.__scopes[ns]) {
- console.warn("Duplicate namespace: "+ns);
- }
- this.__scopes[ns] = fun.apply({
- name: ns,
- namespace: ns,
- listen: this.delegateScoped,
- attach: this.attachFromScope
- }, [ns]);
- },
+ scope: function(ns, fun) {
+ if (this.__scopes[ns]) {
+ console.warn("Duplicate namespace: "+ns);
+ }
+ this.__scopes[ns] = fun.apply({
+ name: ns,
+ namespace: ns,
+ listen: this.delegateScoped,
+ attach: this.attachFromScope
+ }, [ns]);
+ },
- attach: function(moduleName, namespace) {
- this.dbug(moduleName, "attached to "+namespace);
- //We're delegating off the window, so there's no need to reattach for
- //multiple instances of a single given module.
- if (this.__attachments[moduleName+namespace]) {
- return false;
- }
- if (!this.__registry[moduleName]) {
- console.warn("Module not found: "+moduleName);
- return false;
- }
- var mod = this.__registry[moduleName].apply({
- namespace:namespace,
- listen:this.delegateScoped,
- name:moduleName
- }, [namespace]);
- this.__attachments[moduleName+namespace] = mod;
- return true;
- },
+ attach: function(moduleName, namespace) {
+ this.dbug(moduleName, "attached to "+namespace);
+ //We're delegating off the window, so there's no need to reattach for
+ //multiple instances of a single given module.
+ if (this.__attachments[moduleName+namespace]) {
+ return false;
+ }
+ if (!this.__registry[moduleName]) {
+ console.warn("Module not found: "+moduleName);
+ return false;
+ }
+ var mod = this.__registry[moduleName].apply({
+ namespace:namespace,
+ listen:this.delegateScoped,
+ name:moduleName
+ }, [namespace]);
+ this.__attachments[moduleName+namespace] = mod;
+ return true;
+ },
- //This method is bound to the namespaced closure.
- delegateScoped: function(selector, event, handler) {
- //There's a special hell for putting optional parameters at the
- //beginning. A special and awesome hell.
- if (!handler) {
- handler = event;
- event = selector;
- selector = '';
- }
- var name = this.name,
- sel = (this.namespace+' '+selector).trim(),
- fun = function() {
- Eve.dbug(name, sel);
- //Simple pass-through of scope and arguments.
- handler.apply(this, arguments);
- };
- //JavaScript framework development is so much easier when you let some
- //other framework do most of the work.
- if (window.jQuery) {
- $(window).delegate(sel, event, fun);
- } else if (window.MooTools) {
- //I really hate the MooTools event delegation syntax.
- $(window).addEvent(event+':relay('+sel+')', fun);
- } else if (window.YUI) {
- YUI().use('node', function(Y) {
- Y.one(document.body).delegate(event, fun, sel);
- });
- } else if (window.Prototype) {
- $(document.body).on(event, sel, fun);
- } else if (window.dojo) {
- require(["dojo/on"], function(on){
- on(document, sel+':'+event, fun);
- });
- } else {
- console.error("Eve doesn't support your JavaScript framework.");
- }
- },
+ //This method is bound to the namespaced closure.
+ delegateScoped: function(selector, event, handler) {
+ //There's a special hell for putting optional parameters at the
+ //beginning. A special and awesome hell.
+ if (!handler) {
+ handler = event;
+ event = selector;
+ selector = '';
+ }
+ var name = this.name,
+ sel = (this.namespace+' '+selector).trim(),
+ fun = function() {
+ Eve.dbug(name, sel);
+ //Simple pass-through of scope and arguments.
+ handler.apply(this, arguments);
+ };
+ //JavaScript framework development is so much easier when you let some
+ //other framework do most of the work.
+ if (window.jQuery) {
+ $(window).delegate(sel, event, fun);
+ } else if (window.MooTools) {
+ //I really hate the MooTools event delegation syntax.
+ $(window).addEvent(event+':relay('+sel+')', fun);
+ } else if (window.YUI) {
+ YUI().use('node', function(Y) {
+ Y.one(document.body).delegate(event, fun, sel);
+ });
+ } else if (window.Prototype) {
+ $(document.body).on(event, sel, fun);
+ } else if (window.dojo) {
+ require(["dojo/on"], function(on){
+ on(document, sel+':'+event, fun);
+ });
+ } else {
+ console.error("Eve doesn't support your JavaScript framework.");
+ }
+ },
- //This method is bound to the namespaced closure.
- attachFromScope: function(moduleName, ns) {
- Eve.attach(moduleName, this.namespace+' '+(ns||''));
- }
+ //This method is bound to the namespaced closure.
+ attachFromScope: function(moduleName, ns) {
+ Eve.attach(moduleName, this.namespace+' '+(ns||''));
+ }
};

0 comments on commit 9f94966

Please sign in to comment.