From c145f1698aa4bfb8b0d1c94e2bfa83399f1de0f3 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 20 Oct 2011 13:28:31 -0400 Subject: Button: Create text span in correct document. --- ui/jquery.ui.button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'ui/jquery.ui.button.js') diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 1d9393d37..63bd1fc73 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -319,7 +319,7 @@ $.widget( "ui.button", { return; } var buttonElement = this.buttonElement.removeClass( typeClasses ), - buttonText = $( "" ) + buttonText = $( "", this.element[0].ownerDocument ) .addClass( "ui-button-text" ) .html( this.options.label ) .appendTo( buttonElement.empty() ) -- cgit v1.2.3 From a0856efef3c392d413aa6cd9bd084dc601a337c6 Mon Sep 17 00:00:00 2001 From: Scott González Date: Thu, 20 Oct 2011 16:57:47 -0400 Subject: Widget: Added window and document properties. Fixes #7801 - Widget: Add document and window properties. --- ui/jquery.ui.autocomplete.js | 11 +++++------ ui/jquery.ui.button.js | 4 ++-- ui/jquery.ui.dialog.js | 7 +++---- ui/jquery.ui.menu.js | 4 ++-- ui/jquery.ui.popup.js | 2 +- ui/jquery.ui.spinner.js | 4 ++-- ui/jquery.ui.tooltip.js | 4 ++-- ui/jquery.ui.widget.js | 2 ++ 8 files changed, 19 insertions(+), 19 deletions(-) (limited to 'ui/jquery.ui.button.js') diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index ab2edfdff..5dda7d970 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -47,7 +47,6 @@ $.widget( "ui.autocomplete", { _create: function() { var self = this, - doc = this.element[ 0 ].ownerDocument, // Some browsers only repeat keydown events, not keypress events, // so we use the suppressKeyPress flag to determine if we've already // handled the keydown event. #7269 @@ -197,7 +196,7 @@ $.widget( "ui.autocomplete", { }; this.menu = $( "" ) .addClass( "ui-autocomplete" ) - .appendTo( $( this.options.appendTo || "body", doc )[0] ) + .appendTo( this.document.find( this.options.appendTo || "body" )[0] ) // prevent the close-on-blur in case of a "slow" click on the menu (long mousedown) .mousedown(function( event ) { // clicking on the scrollbar causes focus to shift to the body @@ -207,7 +206,7 @@ $.widget( "ui.autocomplete", { var menuElement = self.menu.element[ 0 ]; if ( !$( event.target ).closest( ".ui-menu-item" ).length ) { setTimeout(function() { - $( document ).one( 'mousedown', function( event ) { + self.document.one( 'mousedown', function( event ) { if ( event.target !== self.element[ 0 ] && event.target !== menuElement && !$.contains( menuElement, event.target ) ) { @@ -239,7 +238,7 @@ $.widget( "ui.autocomplete", { previous = self.previous; // only trigger when focus was lost (click on menu) - if ( self.element[0] !== doc.activeElement ) { + if ( self.element[0] !== self.document[0].activeElement ) { self.element.focus(); self.previous = previous; // #6109 - IE triggers two focus events and the second @@ -273,7 +272,7 @@ $.widget( "ui.autocomplete", { // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 - this._bind( doc.defaultView, { + this._bind( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } @@ -297,7 +296,7 @@ $.widget( "ui.autocomplete", { this._initSource(); } if ( key === "appendTo" ) { - this.menu.element.appendTo( $( value || "body", this.element[0].ownerDocument )[0] ); + this.menu.element.appendTo( this.document.find( value || "body" )[0] ); } if ( key === "disabled" && value && this.xhr ) { this.xhr.abort(); diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 63bd1fc73..20eb2ca89 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -174,7 +174,7 @@ $.widget( "ui.button", { } $( this ).addClass( "ui-state-active" ); lastActive = this; - $( document ).one( "mouseup", function() { + self.document.one( "mouseup", function() { lastActive = null; }); }) @@ -319,7 +319,7 @@ $.widget( "ui.button", { return; } var buttonElement = this.buttonElement.removeClass( typeClasses ), - buttonText = $( "", this.element[0].ownerDocument ) + buttonText = $( "", this.document[0] ) .addClass( "ui-button-text" ) .html( this.options.label ) .appendTo( buttonElement.empty() ) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 46320426a..9c9a9b6fc 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -372,8 +372,7 @@ $.widget("ui.dialog", { _makeDraggable: function() { var self = this, - options = self.options, - doc = $( document ); + options = self.options; function filteredUi( ui ) { return { @@ -396,8 +395,8 @@ $.widget("ui.dialog", { }, stop: function( event, ui ) { options.position = [ - ui.position.left - doc.scrollLeft(), - ui.position.top - doc.scrollTop() + ui.position.left - self.document.scrollLeft(), + ui.position.top - self.document.scrollTop() ]; $( this ) .removeClass( "ui-dialog-dragging" ); diff --git a/ui/jquery.ui.menu.js b/ui/jquery.ui.menu.js index f2f758d96..bf36a77fe 100644 --- a/ui/jquery.ui.menu.js +++ b/ui/jquery.ui.menu.js @@ -85,7 +85,7 @@ $.widget( "ui.menu", { }, blur: function( event ) { this._delay( function() { - if ( ! $.contains( this.element[0], document.activeElement ) ) { + if ( ! $.contains( this.element[0], this.document[0].activeElement ) ) { this.collapseAll( event ); } }, 0); @@ -207,7 +207,7 @@ $.widget( "ui.menu", { } }); - this._bind( document, { + this._bind( this.document, { click: function( event ) { if ( !$( event.target ).closest( ".ui-menu" ).length ) { this.collapseAll( event ); diff --git a/ui/jquery.ui.popup.js b/ui/jquery.ui.popup.js index 70bf84be0..f6585b761 100644 --- a/ui/jquery.ui.popup.js +++ b/ui/jquery.ui.popup.js @@ -187,7 +187,7 @@ $.widget( "ui.popup", { } }); - this._bind(document, { + this._bind( this.document, { click: function( event ) { if ( this.isOpen && !$( event.target ).closest( this.element.add( this.options.trigger ) ).length ) { this.close( event ); diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 7fc291c00..9c554b2df 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -53,7 +53,7 @@ $.widget( "ui.spinner", { // turning off autocomplete prevents the browser from remembering the // value when navigating through history, so we re-enable autocomplete // if the page is unloaded before the widget is destroyed. #7790 - this._bind( this.element[0].ownerDocument.defaultView, { + this._bind( this.window, { beforeunload: function() { this.element.removeAttr( "autocomplete" ); } @@ -112,7 +112,7 @@ $.widget( "ui.spinner", { "mousedown .ui-spinner-button": function( event ) { // ensure focus is on (or stays on) the text field event.preventDefault(); - if ( document.activeElement !== this.element[ 0 ] ) { + if ( this.document[0].activeElement !== this.element[ 0 ] ) { this.element.focus(); } diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 2f8d92969..35b6f9b50 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -166,7 +166,7 @@ $.widget( "ui.tooltip", { // don't close if the element has focus // this prevents the tooltip from closing if you hover while focused - if ( !force && document.activeElement === target[0] ) { + if ( !force && this.document[0].activeElement === target[0] ) { return; } @@ -200,7 +200,7 @@ $.widget( "ui.tooltip", { $( "
" ) .addClass( "ui-tooltip-content" ) .appendTo( tooltip ); - tooltip.appendTo( document.body ); + tooltip.appendTo( this.document[0].body ); if ( $.fn.bgiframe ) { tooltip.bgiframe(); } diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index b78530dca..4b4d41fb1 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -195,6 +195,8 @@ $.Widget.prototype = { if ( element !== this ) { $.data( element, this.widgetName, this ); this._bind({ remove: "destroy" }); + this.document = $( element.ownerDocument ); + this.window = $( this.document[0].defaultView ); } this._create(); -- cgit v1.2.3 From 66f9e12797c16d8fa9078f45401f08f0f200e1bc Mon Sep 17 00:00:00 2001 From: Jörn Zaefferer Date: Fri, 18 Nov 2011 12:19:32 +0100 Subject: Widget: Remove method argument from _super and _superApply. Was a left-over from first implementation, not necessary anymore. --- demos/widget/default.html | 4 ++-- tests/unit/widget/widget_core.js | 10 +++++----- ui/jquery.ui.accordion.js | 10 +++++----- ui/jquery.ui.autocomplete.js | 2 +- ui/jquery.ui.button.js | 12 ++++++------ ui/jquery.ui.dialog.js | 16 ++++++++-------- ui/jquery.ui.progressbar.js | 2 +- ui/jquery.ui.spinner.js | 6 +++--- ui/jquery.ui.tabs.js | 22 +++++++++++----------- ui/jquery.ui.tooltip.js | 2 +- ui/jquery.ui.widget.js | 8 ++++---- 11 files changed, 47 insertions(+), 47 deletions(-) (limited to 'ui/jquery.ui.button.js') diff --git a/demos/widget/default.html b/demos/widget/default.html index 45cbe3298..3b812ef8e 100644 --- a/demos/widget/default.html +++ b/demos/widget/default.html @@ -106,7 +106,7 @@ // always refresh when changing options _setOptions: function() { // _super and _superApply handle keeping the right this-context - this._superApply( "_setOptions", arguments ); + this._superApply( arguments ); this._refresh(); }, @@ -116,7 +116,7 @@ if ( /red|green|blue/.test(key) && (value < 0 || value > 255) ) { return; } - this._super( "_setOption", key, value ); + this._super( key, value ); } }); diff --git a/tests/unit/widget/widget_core.js b/tests/unit/widget/widget_core.js index 0510da4b4..edf1ae0fc 100644 --- a/tests/unit/widget/widget_core.js +++ b/tests/unit/widget/widget_core.js @@ -346,7 +346,7 @@ test( "._super()", function() { same( this, instance, "this is correct in testWidget2" ); same( a, 5, "parameter passed to testWidget2" ); same( b, 10, "parameter passed to testWidget2" ); - return this._super( "method", a, b*2 ); + return this._super( a, b*2 ); } }); @@ -354,7 +354,7 @@ test( "._super()", function() { method: function( a ) { same( this, instance, "this is correct in testWidget3" ); same( a, 5, "parameter passed to testWidget3" ); - var ret = this._super( "method", a, a*2 ); + var ret = this._super( a, a*2 ); same( ret, 25, "super returned value" ); } }); @@ -382,7 +382,7 @@ test( "._superApply()", function() { same( this, instance, "this is correct in testWidget2" ); same( a, 5, "parameter passed to testWidget2" ); same( b, 10, "second parameter passed to testWidget2" ); - return this._superApply( "method", arguments ); + return this._superApply( arguments ); } }); @@ -391,7 +391,7 @@ test( "._superApply()", function() { same( this, instance, "this is correct in testWidget3" ); same( a, 5, "parameter passed to testWidget3" ); same( b, 10, "second parameter passed to testWidget3" ); - var ret = this._superApply( "method", arguments ); + var ret = this._superApply( arguments ); same( ret, 15, "super returned value" ); } }); @@ -1031,7 +1031,7 @@ test( "redefine", function() { $.widget( "ui.testWidget", $.ui.testWidget, { method: function( str ) { equal( str, "foo", "new invoked with correct parameter" ); - this._super( "method", "bar" ); + this._super(); } }); diff --git a/ui/jquery.ui.accordion.js b/ui/jquery.ui.accordion.js index 8289ee81b..127099d59 100644 --- a/ui/jquery.ui.accordion.js +++ b/ui/jquery.ui.accordion.js @@ -12,7 +12,7 @@ * jquery.ui.widget.js */ (function( $, undefined ) { - + // TODO: use ui-accordion-header-active class and fix styling $.widget( "ui.accordion", { version: "@VERSION", @@ -167,7 +167,7 @@ $.widget( "ui.accordion", { this._setupEvents( value ); } - this._super( "_setOption", key, value ); + this._super( key, value ); // setting collapsible: false while collapsed; open first panel if ( key === "collapsible" && !value && this.options.active === false ) { @@ -244,7 +244,7 @@ $.widget( "ui.accordion", { if ( position === "absolute" || position === "fixed" ) { return; } - maxHeight -= elem.outerHeight( true ); + maxHeight -= elem.outerHeight( true ); }); if ( overflow ) { parent.css( "overflow", overflow ); @@ -437,7 +437,7 @@ $.extend( $.ui.accordion, { options.prevHide.stop( true, true ); options.toHide = options.prevShow; } - + var showOverflow = options.toShow.css( "overflow" ), hideOverflow = options.toHide.css( "overflow" ), percentDone = 0, @@ -449,7 +449,7 @@ $.extend( $.ui.accordion, { easing: "swing", duration: 300 }, options, additions ); - + options.widget.lastToggle = options; if ( !options.toHide.size() ) { diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index 4e528dce4..9871b52d7 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -291,7 +291,7 @@ $.widget( "ui.autocomplete", { }, _setOption: function( key, value ) { - this._super( "_setOption", key, value ); + this._super( key, value ); if ( key === "source" ) { this._initSource(); } diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index 20eb2ca89..18a950563 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -269,7 +269,7 @@ $.widget( "ui.button", { }, _setOption: function( key, value ) { - this._super( "_setOption", key, value ); + this._super( key, value ); if ( key === "disabled" ) { if ( value ) { this.element.prop( "disabled", true ); @@ -326,7 +326,7 @@ $.widget( "ui.button", { .text(), icons = this.options.icons, multipleIcons = icons.primary && icons.secondary, - buttonClasses = []; + buttonClasses = []; if ( icons.primary || icons.secondary ) { if ( this.options.text ) { @@ -365,7 +365,7 @@ $.widget( "ui.buttonset", { _create: function() { this.element.addClass( "ui-buttonset" ); }, - + _init: function() { this.refresh(); }, @@ -375,12 +375,12 @@ $.widget( "ui.buttonset", { this.buttons.button( "option", key, value ); } - this._super( "_setOption", key, value ); + this._super( key, value ); }, - + refresh: function() { var rtl = this.element.css( "direction" ) === "rtl"; - + this.buttons = this.element.find( this.options.items ) .filter( ":ui-button" ) .button( "refresh" ) diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 9c9a9b6fc..49ef8f64b 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -169,7 +169,7 @@ $.widget("ui.dialog", { _destroy: function() { var self = this; - + if ( self.overlay ) { self.overlay.destroy(); } @@ -196,7 +196,7 @@ $.widget("ui.dialog", { var self = this, maxZ, thisZ; - + if ( false === self._trigger( "beforeClose", event ) ) { return; } @@ -493,7 +493,7 @@ $.widget("ui.dialog", { at: myAt.join( " " ), offset: offset.join( " " ) }; - } + } position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); } else { @@ -518,7 +518,7 @@ $.widget("ui.dialog", { $.each( options, function( key, value ) { self._setOption( key, value ); - + if ( key in sizeRelatedOptions ) { resize = true; } @@ -564,7 +564,7 @@ $.widget("ui.dialog", { if ( isDraggable && !value ) { uiDialog.draggable( "destroy" ); } - + if ( !isDraggable && value ) { self._makeDraggable(); } @@ -596,7 +596,7 @@ $.widget("ui.dialog", { break; } - this._super( "_setOption", key, value ); + this._super( key, value ); }, _size: function() { @@ -627,7 +627,7 @@ $.widget("ui.dialog", { }) .height(); minContentHeight = Math.max( 0, options.minHeight - nonContentHeight ); - + if ( options.height === "auto" ) { // only needed for IE6 support if ( $.support.minHeight ) { @@ -704,7 +704,7 @@ $.extend( $.ui.dialog.overlay, { $( document ).bind( "keydown.dialog-overlay", function( event ) { if ( dialog.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode && event.keyCode === $.ui.keyCode.ESCAPE ) { - + dialog.close( event ); event.preventDefault(); } diff --git a/ui/jquery.ui.progressbar.js b/ui/jquery.ui.progressbar.js index 187470681..f754f61a4 100644 --- a/ui/jquery.ui.progressbar.js +++ b/ui/jquery.ui.progressbar.js @@ -68,7 +68,7 @@ $.widget( "ui.progressbar", { } } - this._super( "_setOption", key, value ); + this._super( key, value ); }, _value: function() { diff --git a/ui/jquery.ui.spinner.js b/ui/jquery.ui.spinner.js index 5623722db..b78b4dbea 100644 --- a/ui/jquery.ui.spinner.js +++ b/ui/jquery.ui.spinner.js @@ -318,7 +318,7 @@ $.widget( "ui.spinner", { return; } - this._super( "_setOption", key, value ); + this._super( key, value ); if ( key === "disabled" ) { if ( value ) { @@ -332,7 +332,7 @@ $.widget( "ui.spinner", { }, _setOptions: modifier(function( options ) { - this._super( "_setOptions", options ); + this._super( options ); this._value( this.element.val() ); }), @@ -387,7 +387,7 @@ $.widget( "ui.spinner", { .removeAttr( "aria-valuemin" ) .removeAttr( "aria-valuemax" ) .removeAttr( "aria-valuenow" ); - this._super( "destroy" ); + this._super(); this.uiSpinner.replaceWith( this.element ); }, diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 5eaab1aae..5c9fc1326 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -136,7 +136,7 @@ $.widget( "ui.tabs", { return; } - this._super( "_setOption", key, value); + this._super( key, value); // setting collapsible: false while collapsed; open first panel if ( key === "collapsible" && !value && this.options.active === false ) { @@ -323,7 +323,7 @@ $.widget( "ui.tabs", { if ( tab.hasClass( "ui-state-disabled" ) || // tab is already loading - tab.hasClass( "ui-tabs-loading" ) || + tab.hasClass( "ui-tabs-loading" ) || // can't switch durning an animation that.running || // click on active header, but not collapsible @@ -555,9 +555,9 @@ $.widget( "ui.tabs", { if ( status === "abort" ) { self.panels.stop( false, true ); } - + self.lis.eq( index ).removeClass( "ui-tabs-loading" ); - + if ( jqXHR === self.xhr ) { delete self.xhr; } @@ -674,13 +674,13 @@ if ( $.uiBackCompat !== false ) { spinner: "Loading…" }, _create: function() { - this._super( "_create" ); + this._super(); this._bind({ tabsbeforeload: function( event, ui ) { if ( !this.options.spinner ) { return; } - + var span = ui.tab.find( "span" ), html = span.html(); span.html( this.options.spinner ); @@ -973,7 +973,7 @@ if ( $.uiBackCompat !== false ) { } options.active = active; } - this._super( "_create" ); + this._super(); }, _cookie: function( active ) { var cookie = [ this.cookie || @@ -985,19 +985,19 @@ if ( $.uiBackCompat !== false ) { return $.cookie.apply( null, cookie ); }, _refresh: function() { - this._super( "_refresh" ); + this._super(); if ( this.options.cookie ) { this._cookie( this.options.active, this.options.cookie ); } }, _eventHandler: function( event ) { - this._superApply( "_eventHandler", arguments ); + this._superApply( arguments ); if ( this.options.cookie ) { this._cookie( this.options.active, this.options.cookie ); } }, _destroy: function() { - this._super( "_destroy" ); + this._super(); if ( this.options.cookie ) { this._cookie( null, this.options.cookie ); } @@ -1012,7 +1012,7 @@ if ( $.uiBackCompat !== false ) { _data.panel = _data.panel[ 0 ]; _data.tab = _data.tab[ 0 ]; } - return this._super( "_trigger", type, event, _data ); + return this._super( type, event, _data ); } }); } diff --git a/ui/jquery.ui.tooltip.js b/ui/jquery.ui.tooltip.js index 35b6f9b50..a006f3bf7 100644 --- a/ui/jquery.ui.tooltip.js +++ b/ui/jquery.ui.tooltip.js @@ -54,7 +54,7 @@ $.widget( "ui.tooltip", { // disable element style changes return; } - this._super( "_setOption", key, value ); + this._super( key, value ); }, _disable: function() { diff --git a/ui/jquery.ui.widget.js b/ui/jquery.ui.widget.js index 294e321a9..53cde389e 100644 --- a/ui/jquery.ui.widget.js +++ b/ui/jquery.ui.widget.js @@ -62,11 +62,11 @@ $.widget = function( name, base, prototype ) { $.each( prototype, function( prop, value ) { if ( $.isFunction( value ) ) { prototype[ prop ] = (function() { - var _super = function( method ) { - return base.prototype[ method ].apply( this, slice.call( arguments, 1 ) ); + var _super = function() { + return base.prototype[ prop ].apply( this, arguments ); }; - var _superApply = function( method, args ) { - return base.prototype[ method ].apply( this, args ); + var _superApply = function( args ) { + return base.prototype[ prop ].apply( this, args ); }; return function() { var __super = this._super, -- cgit v1.2.3