/plugin-app-structure.js Secret
Created
March 19, 2013 01:50
Star
You must be signed in to star a gist
Basic structure related to plugin and application layout. Originally this was devised based on how the jQuery team recommend you create plugins. I simply modified it to encompass application related JS. Generally we place this either directly at the bottom, or within a JS file referenced at the bottom of the page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(window,$,undefined){ | |
if(typeof $ == 'boolean' && $ == true) | |
{ | |
return; | |
} | |
//-- basic settings using descriptive prefixes | |
var _settings = | |
{ | |
url_someurl : 'someurl.file', | |
obj_somedesc : $('#someselector'), | |
link_somelink : $('a#somelinkselector'), | |
class_someclass : 'someclass' | |
}; | |
//-- internal | |
var _data = | |
{ | |
mydata : null | |
}; | |
$(document).ready(function() | |
{ | |
//-- do something | |
_somefunction(); | |
}); | |
function _somefunction() | |
{ | |
//-- local references | |
var url_someurl = _settings.url_someurl, | |
obj_somedesc = _settings.obj_somedesc, | |
link_somelink = _settings.link_somelink, | |
class_someclass = _settings.class_someclass; | |
//-- doing stuff | |
} | |
})(this,(typeof jQuery == 'undefined' || jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment