diff options
author | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-11-21 16:33:46 +0100 |
---|---|---|
committer | Jörn Zaefferer <joern.zaefferer@gmail.com> | 2012-11-26 10:28:25 +0100 |
commit | a09f5c07f591d0ef198f1a36fab9d4b6061ecbc6 (patch) | |
tree | f783e68c0e2d23096da35a6c32746a69f7f4ddcc /ui/jquery.ui.dialog.js | |
parent | f3525afe0ec8d6599e2c54571b005b4c3d754352 (diff) | |
download | jquery-ui-a09f5c07f591d0ef198f1a36fab9d4b6061ecbc6.tar.gz jquery-ui-a09f5c07f591d0ef198f1a36fab9d4b6061ecbc6.zip |
Dialog: Follow-up to 9fe3a62d8 - also deprecate string notation for position option.
Diffstat (limited to 'ui/jquery.ui.dialog.js')
-rw-r--r-- | ui/jquery.ui.dialog.js | 101 |
1 files changed, 41 insertions, 60 deletions
diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index b998c2558..b9f73e954 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -495,33 +495,12 @@ $.widget("ui.dialog", { }, _position: function() { - var position = this.options.position, - myAt = [], - isVisible; - - if ( position ) { - if ( typeof position === "string" ) { - myAt = position.split( " " ); - if ( myAt.length === 1 ) { - myAt[ 1 ] = myAt[ 0 ]; - } - position = { - my: myAt[0] + " " + myAt[1], - at: myAt.join( " " ) - }; - position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); - } - - } else { - position = $.ui.dialog.prototype.options.position; - } - // need to show the dialog to get the actual offset in the position plugin - isVisible = this.uiDialog.is( ":visible" ); + var isVisible = this.uiDialog.is( ":visible" ); if ( !isVisible ) { this.uiDialog.show(); } - this.uiDialog.position( position ); + this.uiDialog.position( this.options.position ); if ( !isVisible ) { this.uiDialog.hide(); } @@ -719,48 +698,50 @@ $.ui.dialog.overlay = { if ( $.uiBackCompat !== false ) { // position option with array notation // just override with old implementation - $.ui.dialog.prototype._position = function() { - var position = this.options.position, - myAt = [], - offset = [ 0, 0 ], - isVisible; - - if ( position ) { - if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) { - myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ]; - if ( myAt.length === 1 ) { - myAt[ 1 ] = myAt[ 0 ]; - } - - $.each( [ "left", "top" ], function( i, offsetPosition ) { - if ( +myAt[ i ] === myAt[ i ] ) { - offset[ i ] = myAt[ i ]; - myAt[ i ] = offsetPosition; + $.widget( "ui.dialog", $.ui.dialog, { + _position: function() { + var position = this.options.position, + myAt = [], + offset = [ 0, 0 ], + isVisible; + + if ( position ) { + if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) { + myAt = position.split ? position.split( " " ) : [ position[ 0 ], position[ 1 ] ]; + if ( myAt.length === 1 ) { + myAt[ 1 ] = myAt[ 0 ]; } - }); - position = { - my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " + - myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]), - at: myAt.join( " " ) - }; - } + $.each( [ "left", "top" ], function( i, offsetPosition ) { + if ( +myAt[ i ] === myAt[ i ] ) { + offset[ i ] = myAt[ i ]; + myAt[ i ] = offsetPosition; + } + }); - position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); - } else { - position = $.ui.dialog.prototype.options.position; - } + position = { + my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " + + myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]), + at: myAt.join( " " ) + }; + } - // need to show the dialog to get the actual offset in the position plugin - isVisible = this.uiDialog.is( ":visible" ); - if ( !isVisible ) { - this.uiDialog.show(); - } - this.uiDialog.position( position ); - if ( !isVisible ) { - this.uiDialog.hide(); + position = $.extend( {}, $.ui.dialog.prototype.options.position, position ); + } else { + position = $.ui.dialog.prototype.options.position; + } + + // need to show the dialog to get the actual offset in the position plugin + isVisible = this.uiDialog.is( ":visible" ); + if ( !isVisible ) { + this.uiDialog.show(); + } + this.uiDialog.position( position ); + if ( !isVisible ) { + this.uiDialog.hide(); + } } - }; + }); } }( jQuery ) ); |