Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- This is what I have so far for my "Unobtrusive Object Oriented Javascript Plugin Startup Template"
- include <script type="text/javascript" src="js/k8r-UOOJPST.javascript"></script>
- and you'll get a roll out of the properties.
- Next I have to make the DOM API
- That way the system is unobtrusive but can still be dynamically accessed by your custom code.
- 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
- */
- // K8r
- (function(){
- options = (function(){
- function options(){
- var Plugin, r;
- this.r = {
- // /////////////////////////////////////////// START: Options
- 'ns':'unique',
- 'pluginOption':'optionValue',
- // /////////////////////////////////////////// END: Options
- }
- }
- return options;
- })();
- Plugin = (function(){
- function Plugin(options){
- this.k8 = options;
- this.buildAPI();
- // //////////////////////////////////////////////// START: MEAT
- this.other_initial_variables = 'initial variable';
- this.initializing_function();
- }
- Plugin.prototype.initializing_function = function(){
- /* your plugin's unqiue stuff */
- };
- // ///////////////////////////////////////////////////// END: MEAT
- Plugin.prototype.buildAPI = function(){
- var k8 = this.k8;
- for (var key in k8.r) {
- if (k8.r.hasOwnProperty(key)) {
- alert(key + " -> " + k8.r[key]);
- }
- }
- };
- return Plugin;
- })();
- function initiate(){
- var plugin;
- return plugin = new Plugin(new options);
- }
- if(window.addEventListener){
- window.addEventListener('load',initiate,false);
- }else{
- window.attachEvent('onload',initiate);
- }
- }).call(this);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement