Skip to content

Commit

Permalink
Namespace to $
Browse files Browse the repository at this point in the history
  • Loading branch information
colintoh committed Sep 17, 2014
1 parent 7fa2585 commit 7b2bb4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
3 changes: 0 additions & 3 deletions app/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
},1500);
});

$(document).skylo({
initialBurst: 50
});

$('#start').on('click',function(){
$(document).skylo('start');
Expand Down
46 changes: 20 additions & 26 deletions vendor/scripts/skylo.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
};

// The actual plugin constructor
function Plugin( element, options ) {
this.element = element;
function Plugin(options ) {

// jQuery has an extend method that merges the
// contents of two or more objects, storing the
Expand Down Expand Up @@ -142,33 +141,28 @@

// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.fn[pluginName] = function ( options ) {
$.skylo = function ( options ) {
var _arguments = arguments;
var retVal = null;

this.each(function () {
if (!$.data(this, 'plugin_' + pluginName)) {
$.data(this, 'plugin_' + pluginName,
new Plugin( this, options ));
}
var data = $.data(this, 'plugin_' + pluginName);
if(data[options]){
retVal = data[options].apply(data,Array.prototype.slice.call(_arguments,1));

} else if(typeof options === 'object' || !options){
data.options = $.extend({},data.options,options);
_validate(data.options);
} else {
$.error('Skylo have no such methods');
}
});


if(typeof retVal === undefined){
retVal = this;
}

return retVal;
if (!$.data(document, 'plugin_' + pluginName)) {
$.data(document, 'plugin_' + pluginName,
new Plugin( options ));
}

var data = $.data(document, 'plugin_'+pluginName);

if(data[options]){
retVal = data[options].apply(data,Array.prototype.slice.call(_arguments,1));
} else if(typeof options === 'object' || !options){
data.options = $.extend({},data.options,options);
_validate(data.options);
} else {
$.error('Skylo have no such methods');
}

return retVal;

}

})( jQuery, window, document );

0 comments on commit 7b2bb4a

Please sign in to comment.