Permalink
Browse files

Namespace to $

  • Loading branch information...
1 parent 7fa2585 commit 7b2bb4ad97522721ed70ab4b2f75a361c9e83230 @colintoh committed Sep 17, 2014
Showing with 20 additions and 29 deletions.
  1. +0 −3 app/assets/index.html
  2. +20 −26 vendor/scripts/skylo.js
@@ -36,9 +36,6 @@
},1500);
});
- $(document).skylo({
- initialBurst: 50
- });
$('#start').on('click',function(){
$(document).skylo('start');
@@ -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
@@ -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.