@@ -495,33 +495,12 @@ $.widget("ui.dialog", {
495495 } ,
496496
497497 _position : function ( ) {
498- var position = this . options . position ,
499- myAt = [ ] ,
500- isVisible ;
501-
502- if ( position ) {
503- if ( typeof position === "string" ) {
504- myAt = position . split ( " " ) ;
505- if ( myAt . length === 1 ) {
506- myAt [ 1 ] = myAt [ 0 ] ;
507- }
508- position = {
509- my : myAt [ 0 ] + " " + myAt [ 1 ] ,
510- at : myAt . join ( " " )
511- } ;
512- position = $ . extend ( { } , $ . ui . dialog . prototype . options . position , position ) ;
513- }
514-
515- } else {
516- position = $ . ui . dialog . prototype . options . position ;
517- }
518-
519498 // need to show the dialog to get the actual offset in the position plugin
520- isVisible = this . uiDialog . is ( ":visible" ) ;
499+ var isVisible = this . uiDialog . is ( ":visible" ) ;
521500 if ( ! isVisible ) {
522501 this . uiDialog . show ( ) ;
523502 }
524- this . uiDialog . position ( position ) ;
503+ this . uiDialog . position ( this . options . position ) ;
525504 if ( ! isVisible ) {
526505 this . uiDialog . hide ( ) ;
527506 }
@@ -719,48 +698,50 @@ $.ui.dialog.overlay = {
719698if ( $ . uiBackCompat !== false ) {
720699 // position option with array notation
721700 // just override with old implementation
722- $ . ui . dialog . prototype . _position = function ( ) {
723- var position = this . options . position ,
724- myAt = [ ] ,
725- offset = [ 0 , 0 ] ,
726- isVisible ;
727-
728- if ( position ) {
729- if ( typeof position === "string" || ( typeof position === "object" && "0" in position ) ) {
730- myAt = position . split ? position . split ( " " ) : [ position [ 0 ] , position [ 1 ] ] ;
731- if ( myAt . length === 1 ) {
732- myAt [ 1 ] = myAt [ 0 ] ;
733- }
734-
735- $ . each ( [ "left" , "top" ] , function ( i , offsetPosition ) {
736- if ( + myAt [ i ] === myAt [ i ] ) {
737- offset [ i ] = myAt [ i ] ;
738- myAt [ i ] = offsetPosition ;
701+ $ . widget ( "ui.dialog" , $ . ui . dialog , {
702+ _position : function ( ) {
703+ var position = this . options . position ,
704+ myAt = [ ] ,
705+ offset = [ 0 , 0 ] ,
706+ isVisible ;
707+
708+ if ( position ) {
709+ if ( typeof position === "string" || ( typeof position === "object" && "0" in position ) ) {
710+ myAt = position . split ? position . split ( " " ) : [ position [ 0 ] , position [ 1 ] ] ;
711+ if ( myAt . length === 1 ) {
712+ myAt [ 1 ] = myAt [ 0 ] ;
739713 }
740- } ) ;
741714
742- position = {
743- my : myAt [ 0 ] + ( offset [ 0 ] < 0 ? offset [ 0 ] : "+" + offset [ 0 ] ) + " " +
744- myAt [ 1 ] + ( offset [ 1 ] < 0 ? offset [ 1 ] : "+" + offset [ 1 ] ) ,
745- at : myAt . join ( " " )
746- } ;
747- }
715+ $ . each ( [ "left" , "top" ] , function ( i , offsetPosition ) {
716+ if ( + myAt [ i ] === myAt [ i ] ) {
717+ offset [ i ] = myAt [ i ] ;
718+ myAt [ i ] = offsetPosition ;
719+ }
720+ } ) ;
748721
749- position = $ . extend ( { } , $ . ui . dialog . prototype . options . position , position ) ;
750- } else {
751- position = $ . ui . dialog . prototype . options . position ;
752- }
722+ position = {
723+ my : myAt [ 0 ] + ( offset [ 0 ] < 0 ? offset [ 0 ] : "+" + offset [ 0 ] ) + " " +
724+ myAt [ 1 ] + ( offset [ 1 ] < 0 ? offset [ 1 ] : "+" + offset [ 1 ] ) ,
725+ at : myAt . join ( " " )
726+ } ;
727+ }
753728
754- // need to show the dialog to get the actual offset in the position plugin
755- isVisible = this . uiDialog . is ( ":visible" ) ;
756- if ( ! isVisible ) {
757- this . uiDialog . show ( ) ;
758- }
759- this . uiDialog . position ( position ) ;
760- if ( ! isVisible ) {
761- this . uiDialog . hide ( ) ;
729+ position = $ . extend ( { } , $ . ui . dialog . prototype . options . position , position ) ;
730+ } else {
731+ position = $ . ui . dialog . prototype . options . position ;
732+ }
733+
734+ // need to show the dialog to get the actual offset in the position plugin
735+ isVisible = this . uiDialog . is ( ":visible" ) ;
736+ if ( ! isVisible ) {
737+ this . uiDialog . show ( ) ;
738+ }
739+ this . uiDialog . position ( position ) ;
740+ if ( ! isVisible ) {
741+ this . uiDialog . hide ( ) ;
742+ }
762743 }
763- } ;
744+ } ) ;
764745}
765746
766747} ( jQuery ) ) ;
0 commit comments