Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2013
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.99 KB | None | 0 0
  1. $(function(){
  2.     siteName.init(page_name);
  3.     siteName.pageLoad();
  4. });
  5.  
  6. var siteName = function() {
  7.  
  8.     var site_methods = {
  9.  
  10.         home: function() {
  11.  
  12.         }
  13.     };
  14.  
  15.  
  16.     var accordion = function () {
  17.  
  18.         // Check http://css-tricks.com/how-do-you-structure-javascript-the-module-pattern-edition/
  19.  
  20.         return {
  21.  
  22.             init: function(el) {
  23.                 this.setHeights();
  24.                 this.bindUIActions();
  25.             }
  26.  
  27.             bindUIActions: function() {
  28.  
  29.             }
  30.         };
  31.  
  32.     }();
  33.  
  34.  
  35.     var siteWide = {
  36.  
  37.         init: function() {
  38.             this.someMethod();
  39.         },
  40.  
  41.         someMethod: function() {
  42.  
  43.         }
  44.  
  45.     }
  46.  
  47.     return {
  48.  
  49.         init: function(page_name) {
  50.             current_page_name = page_name;
  51.         },
  52.  
  53.         pageLoad: function() {
  54.  
  55.             method_name = current_page_name.replace(/-/g, '_').toLowerCase();
  56.  
  57.             if (site_methods.hasOwnProperty(method_name)) {
  58.                 site_methods[method_name]();
  59.             } else {
  60.                 // No method set up for this page
  61.                 // alert(method_name);
  62.             }
  63.  
  64.             // Run sitewide functions
  65.             siteWide.init();
  66.  
  67.         }
  68.  
  69.     }
  70. }();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement