Created
March 18, 2010 17:39
-
-
Save timnovinger/336618 to your computer and use it in GitHub Desktop.
A basic mootools/jquery class template. See http://ryanflorence.com/object-oriented-jquery-with-mootools-pigs-take-flight/ for more information.
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
// =========================================================================================================== | |
// NAME | |
// | |
// DESCRIPTION GOES HERE | |
// | |
// Example | |
// Mootools style: var *name* = new *NAME*('.tooltip', {'options':'hash', 'syntax':'example'}); | |
// jQuery style: $(element).*name*({'options':'hash', 'syntax':'example'}); | |
// | |
// Options | |
// debug: boolean, Turns on/off debugging console.log() messages | |
// | |
// More information | |
// http://ryanflorence.com/object-oriented-jquery-with-mootools-pigs-take-flight/ | |
// | |
// Requirements | |
// jQuery | |
// Mootools (only Native, Class, and Class Extras) | |
// =========================================================================================================== | |
*NAME* = new Class({ | |
Implements: [Options, Debugger], | |
jQuery: '*NAME*', | |
// Set default options | |
options: { | |
debug: false | |
}, | |
// ========================================================================================================= | |
// Called once class instantiated because it's a "magical" name of "initalize" | |
// ========================================================================================================= | |
initialize: function (element, options) | |
{ | |
// Set options defined by defaults or user overwritten values | |
this.setOptions(options); | |
// Save the passed in element object for later manipulation | |
this.element = $(element); | |
// Turn on debugging if options declare it TRUE | |
if (this.options.debug === true) | |
{ | |
this.debugger_initial_run = true; | |
this.debug('searches for => '+ $(this.element).selector +' (FOUND '+ this.element.length +')'); | |
this.debug(); | |
} | |
// Return itself, thus allowing chaining | |
return this; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment