Created
August 17, 2013 04:06
-
-
Save edwardhotchkiss/6255203 to your computer and use it in GitHub Desktop.
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
// compatible with (if available) RequireJS/AMD | |
(function(root) { | |
'use strict'; | |
/* ---- private ---- */ | |
/** | |
* @private _hasConsole | |
*/ | |
var _hasConsole = (typeof(window.console) === 'object'); | |
/** | |
* @private _log | |
* @description check for console, log | |
* @param {String} args console.log arguments | |
*/ | |
function _log(msg) { | |
if (!_hasConsole) { | |
return; | |
} | |
var log, args; | |
args = Array.prototype.slice.call(arguments); | |
log = Function.prototype.bind.call(console.log, console); | |
log.apply(console, args); | |
} | |
/** | |
* @constructor Skeleton | |
*/ | |
var Skeleton = function Skeleton(name) { | |
params = params || {}; | |
this.name = params.name || 'default'; | |
this.initialize(); | |
} | |
/* ---- instance prototypes ---- */ | |
Skeleton.prototype = { | |
/** | |
* @method initialize | |
* @description called on instantiation | |
*/ | |
initialize: function() { | |
_log('this skeleton\'s name is "%s"', this.name); | |
} | |
}; | |
/** | |
* @description check if RequireJS/AMD is available, | |
* and `define` it within RequireJS. Otherwise, use the | |
* standard window.<MyModule> approach | |
*/ | |
if (typeof(require) === 'function' && typeof(define) === 'function' && define.amd) { | |
define('skeleton', [], function() { | |
return Skeleton; | |
}); | |
} else { | |
root.Skeleton = Skeleton; | |
} | |
// "root" | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment