Skip to content

Instantly share code, notes, and snippets.

@banderson
Forked from nathansmith/module_pattern_init.js
Created January 20, 2010 23:33
Show Gist options
  • Select an option

  • Save banderson/282413 to your computer and use it in GitHub Desktop.

Select an option

Save banderson/282413 to your computer and use it in GitHub Desktop.

Revisions

  1. @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 {
  2. @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();
    }
    }
    };
  3. @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();
    }
    }
    };
  4. @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.
  5. @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);
  6. @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();
    });
  7. @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.
    }
    }
    };
  8. @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: {
  9. @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.
    //
  10. @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);