Created
March 6, 2013 12:51
-
-
Save klovadis/5099102 to your computer and use it in GitHub Desktop.
Configuration of your JavaScript component
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
Namespace.ModuleName = function (opt) { | |
// default configuration values | |
var defaults = { | |
moduleContextSelector: '.select-an-awesome > .module', | |
moduleTitle: 'Some Arbitrary Title', | |
moduleTimeoutSpeed: 3000 | |
} | |
// local config values | |
var config = {}; | |
// overwrite defaults with values in opt | |
if (typeof opt !== 'object') opt = {}; | |
for (var k as v in defaults) { | |
if (typeof config[k] !== 'undefined') | |
opt[k] = config[k]; | |
else opt[k] = defaults[k]; | |
} | |
// return your thing | |
return ({ | |
/* export functionality here | |
use scoped config.moduleContextSelector etc | |
*/ | |
}); | |
} | |
// create an instance | |
var instance = Namespace.Modulename({ moduleTitle: 'another title'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment