Skip to content

Instantly share code, notes, and snippets.

@nathansmith
Created January 11, 2010 17:08
Show Gist options
  • Select an option

  • Save nathansmith/274388 to your computer and use it in GitHub Desktop.

Select an option

Save nathansmith/274388 to your computer and use it in GitHub Desktop.

Revisions

  1. nathansmith revised this gist Oct 8, 2012. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -36,14 +36,14 @@ var APP = (function($, window, document, undefined) {
    // APP.init.call_automatically_two();
    }
    },
    misc: {
    util: {
    call_specifically_one: function() {
    // Must be called individually, via:
    // APP.misc.call_specifically_one();
    // APP.util.call_specifically_one();
    },
    call_specifically_two: function() {
    // Must be called individually, via:
    // APP.misc.call_specifically_two();
    // APP.util.call_specifically_two();
    }
    }
    };
  2. nathansmith revised this gist Apr 30, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -47,5 +47,5 @@ var APP = (function($, window, document, undefined) {
    }
    }
    };
    // Alias jQuery, window, document.
    })(jQuery, this, this.document);
    // Parameters: Zepto/jQuery, window, document.
    })(typeof Zepto === 'function' ? Zepto : jQuery, this, this.document);
  3. nathansmith revised this gist Apr 30, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // JS Module Pattern:
    // http://j.mp/module-pattern

    // Re-alias: $, window, document, undefined.
    // Redefine: $, window, document, undefined.
    var APP = (function($, window, document, undefined) {
    // Automatically calls all functions in APP.init
    $(document).ready(function() {
  4. nathansmith revised this gist Apr 30, 2012. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    //
    // Module pattern:
    // http://yuiblog.com/blog/2007/06/12/module-pattern
    //
    // JS Module Pattern:
    // http://j.mp/module-pattern

    // Re-alias: $, window, document, undefined.
    var APP = (function($, window, document, undefined) {
    // Automatically calls all functions in APP.init
    $(document).ready(function() {
  5. nathansmith revised this gist Apr 30, 2012. 1 changed file with 6 additions and 8 deletions.
    14 changes: 6 additions & 8 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,11 @@
    // http://yuiblog.com/blog/2007/06/12/module-pattern
    //
    var APP = (function($, window, document, undefined) {
    // Automatically calls all functions in APP.init
    $(document).ready(function() {
    APP.go();
    });

    // For use only inside APP.
    var PRIVATE_CONSTANT_1 = 'foo';
    var PRIVATE_CONSTANT_2 = 'bar';
    @@ -43,11 +48,4 @@ var APP = (function($, window, document, undefined) {
    }
    };
    // Alias jQuery, window, document.
    })(jQuery, this, this.document);

    //
    // Automatically calls all functions in APP.init
    //
    jQuery(document).ready(function() {
    APP.go();
    });
    })(jQuery, this, this.document);
  6. nathansmith revised this gist Dec 24, 2011. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -9,13 +9,16 @@ var APP = (function($, window, document, undefined) {

    // Expose contents of APP.
    return {
    // APP.go
    go: function() {
    var i, j = this.init;

    for (i in j) {
    // Run everything in APP.init
    j.hasOwnProperty(i) && j[i]();
    }
    },
    // APP.init
    init: {
    call_automatically_one: function() {
    // Called on page-load.
  7. nathansmith revised this gist Dec 23, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ var APP = (function($, window, document, undefined) {
    // Expose contents of APP.
    return {
    go: function() {
    var i, j = APP.init;
    var i, j = this.init;

    for (i in j) {
    j.hasOwnProperty(i) && j[i]();
  8. nathansmith revised this gist Dec 23, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -40,11 +40,11 @@ var APP = (function($, window, document, undefined) {
    }
    };
    // Alias jQuery, window, document.
    })(this.jQuery, this, this.document);
    })(jQuery, this, this.document);

    //
    // Automatically calls all functions in APP.init
    //
    this.jQuery(document).ready(function() {
    jQuery(document).ready(function() {
    APP.go();
    });
  9. nathansmith revised this gist Dec 23, 2011. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -10,8 +10,10 @@ var APP = (function($, window, document, undefined) {
    // Expose contents of APP.
    return {
    go: function() {
    for (var i in APP.init) {
    APP.init.hasOwnProperty(i) && APP.init[i]();
    var i, j = APP.init;

    for (i in j) {
    j.hasOwnProperty(i) && j[i]();
    }
    },
    init: {
  10. nathansmith revised this gist Dec 23, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ var APP = (function($, window, document, undefined) {
    return {
    go: function() {
    for (var i in APP.init) {
    APP.init[i]();
    APP.init.hasOwnProperty(i) && APP.init[i]();
    }
    },
    init: {
  11. nathansmith revised this gist Oct 18, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -43,6 +43,6 @@ var APP = (function($, window, document, undefined) {
    //
    // Automatically calls all functions in APP.init
    //
    jQuery(document).ready(function() {
    this.jQuery(document).ready(function() {
    APP.go();
    });
  12. nathansmith revised this gist Jun 6, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -37,7 +37,7 @@ var APP = (function($, window, document, undefined) {
    }
    }
    };
    // Alias window, document.
    // Alias jQuery, window, document.
    })(this.jQuery, this, this.document);

    //
  13. nathansmith revised this gist Jun 6, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    // Module pattern:
    // http://yuiblog.com/blog/2007/06/12/module-pattern
    //
    var APP = (function(window, document, $, undefined) {
    var APP = (function($, window, document, undefined) {
    // For use only inside APP.
    var PRIVATE_CONSTANT_1 = 'foo';
    var PRIVATE_CONSTANT_2 = 'bar';
    @@ -38,7 +38,7 @@ var APP = (function(window, document, $, undefined) {
    }
    };
    // Alias window, document.
    })(this, this.document, this.jQuery);
    })(this.jQuery, this, this.document);

    //
    // Automatically calls all functions in APP.init
  14. nathansmith revised this gist Apr 25, 2011. 1 changed file with 34 additions and 34 deletions.
    68 changes: 34 additions & 34 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -3,46 +3,46 @@
    // http://yuiblog.com/blog/2007/06/12/module-pattern
    //
    var APP = (function(window, document, $, undefined) {
    // For use only inside APP.
    var PRIVATE_CONSTANT_1 = 'foo';
    var PRIVATE_CONSTANT_2 = 'bar';
    // For use only inside APP.
    var PRIVATE_CONSTANT_1 = 'foo';
    var PRIVATE_CONSTANT_2 = 'bar';

    // Expose contents of APP.
    return {
    go: function() {
    for (var i in APP.init) {
    APP.init[i]();
    }
    },
    init: {
    call_automatically_one: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_one();
    },
    call_automatically_two: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
    }
    },
    misc: {
    call_specifically_one: function() {
    // Must be called individually, via:
    // APP.misc.call_specifically_one();
    },
    call_specifically_two: function() {
    // Must be called individually, via:
    // APP.misc.call_specifically_two();
    }
    }
    };
    // Expose contents of APP.
    return {
    go: function() {
    for (var i in APP.init) {
    APP.init[i]();
    }
    },
    init: {
    call_automatically_one: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_one();
    },
    call_automatically_two: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
    }
    },
    misc: {
    call_specifically_one: function() {
    // Must be called individually, via:
    // APP.misc.call_specifically_one();
    },
    call_specifically_two: function() {
    // Must be called individually, via:
    // APP.misc.call_specifically_two();
    }
    }
    };
    // Alias window, document.
    })(this, this.document, this.jQuery);

    //
    // Automatically calls all functions in APP.init
    //
    jQuery(document).ready(function() {
    APP.go();
    APP.go();
    });
  15. nathansmith revised this gist Apr 25, 2011. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,8 @@
    //
    // Automatically calls all functions in APP.init
    //
    jQuery(document).ready(function() {
    APP.go();
    });

    //
    // Module pattern:
    // http://yuiblog.com/blog/2007/06/12/module-pattern
    //
    var APP = (function($, window, document, undefined) {
    var APP = (function(window, document, $, undefined) {
    // For use only inside APP.
    var PRIVATE_CONSTANT_1 = 'foo';
    var PRIVATE_CONSTANT_2 = 'bar';
    @@ -45,4 +38,11 @@ var APP = (function($, window, document, undefined) {
    }
    };
    // Alias window, document.
    })(jQuery, this, this.document);
    })(this, this.document, this.jQuery);

    //
    // Automatically calls all functions in APP.init
    //
    jQuery(document).ready(function() {
    APP.go();
    });
  16. nathansmith revised this gist Nov 3, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -44,5 +44,5 @@ var APP = (function($, window, document, undefined) {
    }
    }
    };
    // Pass in jQuery ref.
    // Alias window, document.
    })(jQuery, this, this.document);
  17. nathansmith revised this gist Nov 3, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ jQuery(document).ready(function() {
    // Module pattern:
    // http://yuiblog.com/blog/2007/06/12/module-pattern
    //
    var APP = (function($, window, undefined) {
    var APP = (function($, window, document, undefined) {
    // For use only inside APP.
    var PRIVATE_CONSTANT_1 = 'foo';
    var PRIVATE_CONSTANT_2 = 'bar';
    @@ -45,4 +45,4 @@ var APP = (function($, window, undefined) {
    }
    };
    // Pass in jQuery ref.
    })(jQuery, this);
    })(jQuery, this, this.document);
  18. nathansmith revised this gist Aug 29, 2010. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ jQuery(document).ready(function() {

    //
    // Module pattern:
    // http://yuiblog.com/blog/2007/06/12/module-pattern/
    // http://yuiblog.com/blog/2007/06/12/module-pattern
    //
    var APP = (function($, window, undefined) {
    // For use only inside APP.
  19. nathansmith revised this gist Jul 30, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,8 @@ jQuery(document).ready(function() {
    //
    var APP = (function($, window, undefined) {
    // For use only inside APP.
    var private_var_one = 'foo';
    var private_var_two = 'bar';
    var PRIVATE_CONSTANT_1 = 'foo';
    var PRIVATE_CONSTANT_2 = 'bar';

    // Expose contents of APP.
    return {
  20. nathansmith revised this gist Jun 28, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -9,7 +9,7 @@ jQuery(document).ready(function() {
    // Module pattern:
    // http://yuiblog.com/blog/2007/06/12/module-pattern/
    //
    var APP = (function($) {
    var APP = (function($, window, undefined) {
    // For use only inside APP.
    var private_var_one = 'foo';
    var private_var_two = 'bar';
    @@ -45,4 +45,4 @@ var APP = (function($) {
    }
    };
    // Pass in jQuery ref.
    })(jQuery);
    })(jQuery, this);
  21. nathansmith revised this gist Apr 6, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -35,11 +35,11 @@ var APP = (function($) {
    },
    misc: {
    call_specifically_one: function() {
    // Must be called individually, via:.
    // Must be called individually, via:
    // APP.misc.call_specifically_one();
    },
    call_specifically_two: function() {
    // Must be called individually, via:.
    // Must be called individually, via:
    // APP.misc.call_specifically_two();
    }
    }
  22. nathansmith revised this gist Apr 6, 2010. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -22,26 +22,22 @@ var APP = (function($) {
    }
    },
    init: {
    // APP.init.call_automatically_one
    call_automatically_one: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_one();
    },
    // APP.init.call_automatically_two
    call_automatically_two: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
    }
    },
    misc: {
    // APP.misc.call_specifically_one
    call_specifically_one: function() {
    // Must be called individually, via:.
    // APP.misc.call_specifically_one();
    },
    // APP.misc.call_specifically_two
    call_specifically_two: function() {
    // Must be called individually, via:.
    // APP.misc.call_specifically_two();
  23. nathansmith revised this gist Apr 6, 2010. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -22,22 +22,26 @@ var APP = (function($) {
    }
    },
    init: {
    // APP.init.call_automatically_one
    call_automatically_one: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_one();
    },
    // APP.init.call_automatically_two
    call_automatically_two: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
    }
    },
    misc: {
    // APP.misc.call_specifically_one
    call_specifically_one: function() {
    // Must be called individually, via:.
    // APP.misc.call_specifically_one();
    },
    // APP.misc.call_specifically_two
    call_specifically_two: function() {
    // Must be called individually, via:.
    // APP.misc.call_specifically_two();
  24. nathansmith revised this gist Jan 12, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,8 @@ jQuery(document).ready(function() {
    //
    var APP = (function($) {
    // For use only inside APP.
    var private_var_1 = 'foo';
    var private_var_2 = 'bar';
    var private_var_one = 'foo';
    var private_var_two = 'bar';

    // Expose contents of APP.
    return {
  25. nathansmith revised this gist Jan 11, 2010. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -36,11 +36,11 @@ var APP = (function($) {
    misc: {
    call_specifically_one: function() {
    // Must be called individually, via:.
    // APP.init.call_specifically_one();
    // APP.misc.call_specifically_one();
    },
    call_specifically_two: function() {
    // Must be called individually, via:.
    // APP.init.call_specifically_two();
    // APP.misc.call_specifically_two();
    }
    }
    };
  26. nathansmith revised this gist Jan 11, 2010. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -24,17 +24,23 @@ var APP = (function($) {
    init: {
    call_automatically_one: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_one();
    },
    call_automatically_two: function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
    }
    },
    misc: {
    call_specifically_one: function() {
    // Must be called individually.
    // Must be called individually, via:.
    // APP.init.call_specifically_one();
    },
    call_specifically_two: function() {
    // Must be called individually.
    // Must be called individually, via:.
    // APP.init.call_specifically_two();
    }
    }
    };
  27. nathansmith revised this gist Jan 11, 2010. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,8 @@ jQuery(document).ready(function() {
    });

    //
    // Module pattern.
    // Module pattern:
    // http://yuiblog.com/blog/2007/06/12/module-pattern/
    //
    var APP = (function($) {
    // For use only inside APP.
  28. nathansmith revised this gist Jan 11, 2010. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -9,9 +9,11 @@ jQuery(document).ready(function() {
    // Module pattern.
    //
    var APP = (function($) {
    // For use only inside APP.
    var private_var_1 = 'foo';
    var private_var_2 = 'bar';

    // Expose contents of APP.
    return {
    go: function() {
    for (var i in APP.init) {
    @@ -35,4 +37,5 @@ var APP = (function($) {
    }
    }
    };
    // Pass in jQuery ref.
    })(jQuery);
  29. nathansmith revised this gist Jan 11, 2010. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    //
    // Automatically calls all functions in APP.init
    //
    jQuery(document).ready(function() {
    APP.go();
    });
  30. nathansmith revised this gist Jan 11, 2010. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -16,11 +16,19 @@ var APP = (function($) {
    }
    },
    init: {
    zebra: function() {
    // Zebra stripe tables.
    call_automatically_one: function() {
    // Called on page-load.
    },
    check_all: function() {
    // Check-all checkbox.
    call_automatically_two: function() {
    // Called on page-load.
    }
    },
    misc: {
    call_specifically_one: function() {
    // Must be called individually.
    },
    call_specifically_two: function() {
    // Must be called individually.
    }
    }
    };