diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/jquery.effects.scale.js | 31 | ||||
-rw-r--r-- | ui/jquery.ui.autocomplete.js | 14 | ||||
-rw-r--r-- | ui/jquery.ui.button.js | 17 | ||||
-rw-r--r-- | ui/jquery.ui.dialog.js | 16 | ||||
-rw-r--r-- | ui/jquery.ui.mouse.js | 2 | ||||
-rw-r--r-- | ui/jquery.ui.resizable.js | 34 |
6 files changed, 76 insertions, 38 deletions
diff --git a/ui/jquery.effects.scale.js b/ui/jquery.effects.scale.js index b5c49ce7c..00f0151af 100644 --- a/ui/jquery.effects.scale.js +++ b/ui/jquery.effects.scale.js @@ -54,7 +54,9 @@ $.effects.effect.scale = function( o ) { origin = o.origin, original = { height: el.height(), - width: el.width() + width: el.width(), + outerHeight: el.outerHeight(), + outerWidth: el.outerWidth() }, factor = { y: direction != 'horizontal' ? (percent / 100) : 1, @@ -74,7 +76,9 @@ $.effects.effect.scale = function( o ) { options.from = o.from || ( mode == 'show' ? { height: 0, width: 0 } : original ); options.to = { height: original.height * factor.y, - width: original.width * factor.x + width: original.width * factor.x, + outerHeight: original.outerHeight * factor.y, + outerWidth: original.outerWidth * factor.x }; if ( options.fade ) { // Fade option to support puff @@ -122,21 +126,14 @@ $.effects.effect.size = function( o ) { } original = { height: el.height(), - width: el.width() + width: el.width(), + outerHeight: el.outerHeight(), + outerWidth: el.outerWidth() }; el.from = o.from || original; el.to = o.to || original; - // Adjust - if (origin) { // Calculate baseline shifts - baseline = $.effects.getBaseline( origin, original ); - el.from.top = ( original.height - el.from.height ) * baseline.y; - el.from.left = ( original.width - el.from.width ) * baseline.x; - el.to.top = ( original.height - el.to.height ) * baseline.y; - el.to.left = ( original.width - el.to.width ) * baseline.x; - } - // Set scaling factor factor = { from: { @@ -183,6 +180,16 @@ $.effects.effect.size = function( o ) { $.effects.createWrapper( el ); el.css( 'overflow', 'hidden' ).css( el.from ); + // Adjust + if (origin) { // Calculate baseline shifts + baseline = $.effects.getBaseline( origin, original ); + el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y; + el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x; + el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y; + el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x; + } + el.css( el.from ); // set top & left + // Animate if ( scale == 'content' || scale == 'both' ) { // Scale the children diff --git a/ui/jquery.ui.autocomplete.js b/ui/jquery.ui.autocomplete.js index f6573174a..4619949fb 100644 --- a/ui/jquery.ui.autocomplete.js +++ b/ui/jquery.ui.autocomplete.js @@ -63,7 +63,7 @@ $.widget( "ui.autocomplete", { }) .bind( "keydown.autocomplete", function( event ) { if ( self.options.disabled || self.element.attr( "readonly" ) ) { - suppressKeyPress = true; + suppressKeyPress = true; suppressInput = true; return; } @@ -73,21 +73,21 @@ $.widget( "ui.autocomplete", { var keyCode = $.ui.keyCode; switch( event.keyCode ) { case keyCode.PAGE_UP: - suppressKeyPress = true; + suppressKeyPress = true; self._move( "previousPage", event ); break; case keyCode.PAGE_DOWN: - suppressKeyPress = true; + suppressKeyPress = true; self._move( "nextPage", event ); break; case keyCode.UP: - suppressKeyPress = true; + suppressKeyPress = true; self._move( "previous", event ); // prevent moving cursor to beginning of text field in some browsers event.preventDefault(); break; case keyCode.DOWN: - suppressKeyPress = true; + suppressKeyPress = true; self._move( "next", event ); // prevent moving cursor to end of text field in some browsers event.preventDefault(); @@ -122,7 +122,7 @@ $.widget( "ui.autocomplete", { if ( suppressKeyPress ) { suppressKeyPress = false; event.preventDefault(); - return; + return; } // replicate some key handlers to allow them to repeat in Firefox and Opera @@ -144,7 +144,7 @@ $.widget( "ui.autocomplete", { // prevent moving cursor to end of text field in some browsers event.preventDefault(); break; - } + } }) .bind( "input.autocomplete", function(event) { if ( suppressInput ) { diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index a95dddc6c..32e00e9e0 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -95,19 +95,22 @@ $.widget( "ui.button", { } $( this ).removeClass( hoverClass ); }) - .bind( "focus.button", function() { - // no need to check disabled, focus won't be triggered anyway - $( this ).addClass( focusClass ); - }) - .bind( "blur.button", function() { - $( this ).removeClass( focusClass ); - }) .bind( "click.button", function( event ) { if ( options.disabled ) { + event.preventDefault(); event.stopImmediatePropagation(); } }); + this.element + .bind( "focus.button", function() { + // no need to check disabled, focus won't be triggered anyway + self.buttonElement.addClass( focusClass ); + }) + .bind( "blur.button", function() { + self.buttonElement.removeClass( focusClass ); + }); + if ( toggleButton ) { this.element.bind( "change.button", function() { if ( clickDragged ) { diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index dc2849155..84b2dd3b3 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -190,6 +190,10 @@ $.widget("ui.dialog", { }, close: function( event ) { + if ( !this._isOpen ) { + return self; + } + var self = this, maxZ, thisZ; @@ -197,13 +201,13 @@ $.widget("ui.dialog", { return; } + self._isOpen = false; + if ( self.overlay ) { self.overlay.destroy(); } self.uiDialog.unbind( "keypress.ui-dialog" ); - self._isOpen = false; - if ( self.options.hide ) { self.uiDialog.hide( self.options.hide, function() { self._trigger( "close", event ); @@ -369,8 +373,7 @@ $.widget("ui.dialog", { _makeDraggable: function() { var self = this, options = self.options, - doc = $( document ), - heightBeforeDrag; + doc = $( document ); function filteredUi( ui ) { return { @@ -384,9 +387,7 @@ $.widget("ui.dialog", { handle: ".ui-dialog-titlebar", containment: "document", start: function( event, ui ) { - heightBeforeDrag = options.height === "auto" ? "auto" : $( this ).height(); $( this ) - .height( $( this ).height() ) .addClass( "ui-dialog-dragging" ); self._trigger( "dragStart", event, filteredUi( ui ) ); }, @@ -399,8 +400,7 @@ $.widget("ui.dialog", { ui.position.top - doc.scrollTop() ]; $( this ) - .removeClass( "ui-dialog-dragging" ) - .height( heightBeforeDrag ); + .removeClass( "ui-dialog-dragging" ); self._trigger( "dragStop", event, filteredUi( ui ) ); $.ui.dialog.overlay.resize(); } diff --git a/ui/jquery.ui.mouse.js b/ui/jquery.ui.mouse.js index 0bd38db85..2fb1389f2 100644 --- a/ui/jquery.ui.mouse.js +++ b/ui/jquery.ui.mouse.js @@ -58,7 +58,7 @@ $.widget("ui.mouse", { var self = this, btnIsLeft = (event.which == 1), - elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).parents().add(event.target).filter(this.options.cancel).length : false); + elIsCancel = (typeof this.options.cancel == "string" ? $(event.target).closest(this.options.cancel).length : false); if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) { return true; } diff --git a/ui/jquery.ui.resizable.js b/ui/jquery.ui.resizable.js index e0579ef84..de24e94dd 100644 --- a/ui/jquery.ui.resizable.js +++ b/ui/jquery.ui.resizable.js @@ -293,6 +293,8 @@ $.widget("ui.resizable", $.ui.mouse, { // Calculate the attrs that will be change var data = trigger.apply(this, [event, dx, dy]), ie6 = $.browser.msie && $.browser.version < 7, csdif = this.sizeDiff; + // Put this in the mouseDrag handler since the user can start pressing shift while resizing + this._updateVirtualBoundaries(event.shiftKey); if (this._aspectRatio || event.shiftKey) data = this._updateRatio(data, event); @@ -351,6 +353,32 @@ $.widget("ui.resizable", $.ui.mouse, { }, + _updateVirtualBoundaries: function(forceAspectRatio) { + var o = this.options, pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b; + + b = { + minWidth: isNumber(o.minWidth) ? o.minWidth : 0, + maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity, + minHeight: isNumber(o.minHeight) ? o.minHeight : 0, + maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity + }; + + if(this._aspectRatio || forceAspectRatio) { + // We want to create an enclosing box whose aspect ration is the requested one + // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension + pMinWidth = b.minHeight * this.aspectRatio; + pMinHeight = b.minWidth / this.aspectRatio; + pMaxWidth = b.maxHeight * this.aspectRatio; + pMaxHeight = b.maxWidth / this.aspectRatio; + + if(pMinWidth > b.minWidth) b.minWidth = pMinWidth; + if(pMinHeight > b.minHeight) b.minHeight = pMinHeight; + if(pMaxWidth < b.maxWidth) b.maxWidth = pMaxWidth; + if(pMaxHeight < b.maxHeight) b.maxHeight = pMaxHeight; + } + this._vBoundaries = b; + }, + _updateCache: function(data) { var o = this.options; this.offset = this.helper.offset(); @@ -364,8 +392,8 @@ $.widget("ui.resizable", $.ui.mouse, { var o = this.options, cpos = this.position, csize = this.size, a = this.axis; - if (data.height) data.width = (csize.height * this.aspectRatio); - else if (data.width) data.height = (csize.width / this.aspectRatio); + if (isNumber(data.height)) data.width = (data.height * this.aspectRatio); + else if (isNumber(data.width)) data.height = (data.width / this.aspectRatio); if (a == 'sw') { data.left = cpos.left + (csize.width - data.width); @@ -381,7 +409,7 @@ $.widget("ui.resizable", $.ui.mouse, { _respectSize: function(data, event) { - var el = this.helper, o = this.options, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, + var el = this.helper, o = this._vBoundaries, pRatio = this._aspectRatio || event.shiftKey, a = this.axis, ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height), isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height); |