aboutsummaryrefslogtreecommitdiffstats
path: root/ui/jquery.ui.widget.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/jquery.ui.widget.js')
-rw-r--r--ui/jquery.ui.widget.js30
1 files changed, 25 insertions, 5 deletions
diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js
index 4c538d020..294e321a9 100644
--- a/ui/jquery.ui.widget.js
+++ b/ui/jquery.ui.widget.js
@@ -195,6 +195,12 @@ $.Widget.prototype = {
if ( element !== this ) {
$.data( element, this.widgetName, this );
this._bind({ remove: "destroy" });
+ this.document = $( element.style ?
+ // element within the document
+ element.ownerDocument :
+ // element is window or document
+ element.document || element );
+ this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
}
this._create();
@@ -270,10 +276,11 @@ $.Widget.prototype = {
return this;
},
_setOptions: function( options ) {
- var self = this;
- $.each( options, function( key, value ) {
- self._setOption( key, value );
- });
+ var key;
+
+ for ( key in options ) {
+ this._setOption( key, options[ key ] );
+ }
return this;
},
@@ -326,13 +333,22 @@ $.Widget.prototype = {
eventName = match[1] + "." + instance.widgetName,
selector = match[2];
if ( selector ) {
- element.delegate( selector, eventName, handlerProxy );
+ instance.widget().delegate( selector, eventName, handlerProxy );
} else {
element.bind( eventName, handlerProxy );
}
});
},
+ _delay: function( handler, delay ) {
+ function handlerProxy() {
+ return ( typeof handler === "string" ? instance[ handler ] : handler )
+ .apply( instance, arguments );
+ }
+ var instance = this;
+ return setTimeout( handlerProxy, delay || 0 );
+ },
+
_hoverable: function( element ) {
this.hoverable = this.hoverable.add( element );
this._bind( element, {
@@ -377,6 +393,10 @@ $.Widget.prototype = {
}
}
+ // the original event may come from any element
+ // so we need to reset the target on the new event
+ event.target = this.element[0];
+
this.element.trigger( event, data );
args = $.isArray( data ) ?