Skip to content

Instantly share code, notes, and snippets.

@codylindley
Forked from nathansmith/module_pattern_init.js
Created January 15, 2010 05:30
Show Gist options
  • Select an option

  • Save codylindley/277836 to your computer and use it in GitHub Desktop.

Select an option

Save codylindley/277836 to your computer and use it in GitHub Desktop.

Revisions

  1. codylindley revised this gist Jan 15, 2010. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ var APP = (function($) {

    // Expose contents of APP.
    return {
    go: function() {
    go: function(funcName) {

    var call_automatically_one = function() {
    // Called on page-load.
    @@ -29,6 +29,8 @@ var APP = (function($) {
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
    }();


    },
    misc: {
    call_specifically_one: function() {
  2. codylindley revised this gist Jan 15, 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
    @@ -24,7 +24,7 @@ var APP = (function($) {
    // APP.init.call_automatically_one();
    }();

    call_automatically_two = function() {
    var call_automatically_two = function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
  3. codylindley revised this gist Jan 15, 2010. 1 changed file with 6 additions and 9 deletions.
    15 changes: 6 additions & 9 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -17,21 +17,18 @@ var APP = (function($) {
    // Expose contents of APP.
    return {
    go: function() {
    for (var i in APP.init) {
    APP.init[i]();
    }
    },
    init: {
    call_automatically_one: function() {

    var call_automatically_one = function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_one();
    },
    call_automatically_two: function() {
    }();

    call_automatically_two = function() {
    // Called on page-load.
    // Can still be called individually, via:
    // APP.init.call_automatically_two();
    }
    }();
    },
    misc: {
    call_specifically_one: function() {
  4. @nathansmith 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 {
  5. @nathansmith 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();
    }
    }
    };
  6. @nathansmith 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();
    }
    }
    };
  7. @nathansmith 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.
  8. @nathansmith 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);
  9. @nathansmith 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();
    });
  10. @nathansmith 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.
    }
    }
    };
  11. @nathansmith 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
    @@ -11,8 +11,8 @@ var APP = (function($) {

    return {
    go: function() {
    for (var i in INF.init) {
    INF.init[i]();
    for (var i in APP.init) {
    APP.init[i]();
    }
    },
    init: {
  12. @nathansmith nathansmith revised this gist Jan 11, 2010. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@ jQuery(document).ready(function() {
    APP.go();
    });


    //
    // Module pattern.
    //
  13. @nathansmith nathansmith created this gist Jan 11, 2010.
    28 changes: 28 additions & 0 deletions module_pattern_init.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    jQuery(document).ready(function() {
    APP.go();
    });


    //
    // Module pattern.
    //
    var APP = (function($) {
    var private_var_1 = 'foo';
    var private_var_2 = 'bar';

    return {
    go: function() {
    for (var i in INF.init) {
    INF.init[i]();
    }
    },
    init: {
    zebra: function() {
    // Zebra stripe tables.
    },
    check_all: function() {
    // Check-all checkbox.
    }
    }
    };
    })(jQuery);