Last active
May 9, 2016 18:49
-
-
Save JDMcKinstry/e8c6a26910ba0d4a5b241946c293c6c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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($) { | |
/* OPTIONS */ | |
var defaults = { | |
} | |
/* METHODS */ | |
/* EVENTS */ | |
if (!$.myExample) { | |
$.extend({ | |
myExample: function() { | |
var ele = typeof Array.prototype.slice.call(arguments, 0, 1)[0] == 'string' ? $(Array.prototype.slice.call(arguments, 0, 1)[0]) : Array.prototype.slice.call(arguments, 0, 1)[0], | |
args = Array.prototype.slice.call(arguments, 1); | |
if (ele instanceof jQuery && ele.length) { | |
// first check if this is a recall to pass options, trigger method, or set event | |
if (args.length && typeof args[0] != 'object') { | |
// if option $(ele).myExample("option", "optionName" [, value]) | |
if (/^[23]{1}$/.test(args.length) && args[0] == 'option') { | |
} | |
// is event or method | |
else if (/^[12]{1}$/.test(args.length)) { | |
} | |
} | |
// initialize | |
return ele.each(function(i) { | |
if (!this.hasOwnProperty('myExample')) { | |
var opts = $.extend(true, {}, defaults, args[0]), | |
events = [], // names of event methods previously defined | |
methods = [], // names of methods previously defined | |
eb = {} | |
} | |
}); | |
return ele; | |
} | |
throw new Error('myExample failed! Invalid Selector.'); | |
} | |
}); | |
$.fn.extend({ myExample: function() { return $.myExample.apply($, [$(this)].concat(Array.prototype.slice.call(arguments, 0))); } }); | |
} | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment