Advertisement
keysle

k8r-UOOJPST.js

Oct 23rd, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. This is what I have so far for my "Unobtrusive Object Oriented Javascript Plugin Startup Template"
  3. include <script type="text/javascript" src="js/k8r-UOOJPST.javascript"></script>
  4. and you'll get a roll out of the properties.
  5. Next I have to make the DOM API
  6. That way the system is unobtrusive but can still be dynamically accessed by your custom code.
  7. also 'ns' is for NAMESPACING. so All plugins I make will have this so you can ensure that you don't have DOM namespacing issues
  8. */
  9. // K8r
  10. (function(){
  11.     options = (function(){
  12.         function options(){
  13.             var Plugin, r;
  14.             this.r = {
  15.                 // /////////////////////////////////////////// START: Options
  16.                 'ns':'unique',
  17.                 'pluginOption':'optionValue',
  18.                 // /////////////////////////////////////////// END: Options
  19.             }
  20.         }
  21.         return options;
  22.     })();
  23.     Plugin = (function(){
  24.         function Plugin(options){
  25.             this.k8 = options;
  26.             this.buildAPI();
  27.             // //////////////////////////////////////////////// START: MEAT
  28.             this.other_initial_variables = 'initial variable';
  29.             this.initializing_function();
  30.         }
  31.  
  32.         Plugin.prototype.initializing_function = function(){
  33.             /* your plugin's unqiue stuff */
  34.         };
  35.         // ///////////////////////////////////////////////////// END: MEAT
  36.         Plugin.prototype.buildAPI = function(){
  37.             var k8 = this.k8;
  38.             for (var key in k8.r) {
  39.                 if (k8.r.hasOwnProperty(key)) {
  40.                     alert(key + " -> " + k8.r[key]);
  41.                 }
  42.             }
  43.         };
  44.         return Plugin;
  45.     })();
  46.  
  47.     function initiate(){
  48.         var plugin;
  49.         return plugin = new Plugin(new options);
  50.     }
  51.  
  52.     if(window.addEventListener){
  53.         window.addEventListener('load',initiate,false);
  54.     }else{
  55.         window.attachEvent('onload',initiate);
  56.     }
  57. }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement