Widget: Prefix variables with component name.

This commit is contained in:
Scott González 2013-10-23 08:14:49 -04:00
parent f64c953497
commit 47db52b9c9

View File

@ -10,18 +10,20 @@
*/ */
(function( $, undefined ) { (function( $, undefined ) {
var uuid = 0, var widget_uuid = 0,
slice = Array.prototype.slice, widget_slice = Array.prototype.slice;
_cleanData = $.cleanData;
$.cleanData = function( elems ) { $.cleanData = (function( orig ) {
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { return function( elems ) {
try { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
$( elem ).triggerHandler( "remove" ); try {
// http://bugs.jquery.com/ticket/8235 $( elem ).triggerHandler( "remove" );
} catch( e ) {} // http://bugs.jquery.com/ticket/8235
} } catch( e ) {}
_cleanData( elems ); }
}; orig( elems );
};
})( $.cleanData );
$.widget = function( name, base, prototype ) { $.widget = function( name, base, prototype ) {
var fullName, existingConstructor, constructor, basePrototype, var fullName, existingConstructor, constructor, basePrototype,
@ -139,7 +141,7 @@ $.widget = function( name, base, prototype ) {
}; };
$.widget.extend = function( target ) { $.widget.extend = function( target ) {
var input = slice.call( arguments, 1 ), var input = widget_slice.call( arguments, 1 ),
inputIndex = 0, inputIndex = 0,
inputLength = input.length, inputLength = input.length,
key, key,
@ -168,7 +170,7 @@ $.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name; var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) { $.fn[ name ] = function( options ) {
var isMethodCall = typeof options === "string", var isMethodCall = typeof options === "string",
args = slice.call( arguments, 1 ), args = widget_slice.call( arguments, 1 ),
returnValue = this; returnValue = this;
// allow multiple hashes to be passed on init // allow multiple hashes to be passed on init
@ -233,7 +235,7 @@ $.Widget.prototype = {
_createWidget: function( options, element ) { _createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ]; element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element ); this.element = $( element );
this.uuid = uuid++; this.uuid = widget_uuid++;
this.eventNamespace = "." + this.widgetName + this.uuid; this.eventNamespace = "." + this.widgetName + this.uuid;
this.options = $.widget.extend( {}, this.options = $.widget.extend( {},
this.options, this.options,