@@ -92,16 +92,17 @@ $.widget("ui.dialog", {
9292 } ;
9393 var that = this ,
9494 options = this . options ,
95- title = options . title || " " ,
96- uiDialogTitle ,
9795 uiDialogButtonPane ;
9896
9997 // TODO extract into _createWrapper
10098 this . uiDialog = $ ( "<div>" )
10199 . addClass ( uiDialogClasses + options . dialogClass )
102100 . hide ( )
103- // setting tabIndex makes the div focusable
104- . attr ( "tabIndex" , - 1 )
101+ . attr ( {
102+ // setting tabIndex makes the div focusable
103+ tabIndex : - 1 ,
104+ role : "dialog"
105+ } )
105106 . keydown ( function ( event ) {
106107 if ( options . closeOnEscape && ! event . isDefaultPrevented ( ) && event . keyCode &&
107108 event . keyCode === $ . ui . keyCode . ESCAPE ) {
@@ -122,38 +123,7 @@ $.widget("ui.dialog", {
122123 . addClass ( "ui-dialog-content ui-widget-content" )
123124 . appendTo ( this . uiDialog ) ;
124125
125- // TODO extract this and the next two into a _createTitlebar method
126- this . uiDialogTitlebar = $ ( "<div>" )
127- . addClass ( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
128- . prependTo ( this . uiDialog ) ;
129- this . _on ( this . uiDialogTitlebar , {
130- mousedown : function ( ) {
131- // TODO call _focusTabbable or _keepFocus
132- // Dialog isn't getting focus when dragging (#8063)
133- this . uiDialog . focus ( ) ;
134- }
135- } ) ;
136-
137- this . uiDialogTitlebarClose = $ ( "<button></button>" )
138- . button ( {
139- label : options . closeText ,
140- icons : {
141- primary : "ui-icon-closethick"
142- } ,
143- text : false
144- } )
145- . addClass ( "ui-dialog-titlebar-close" )
146- . click ( function ( event ) {
147- event . preventDefault ( ) ;
148- that . close ( event ) ;
149- } )
150- . appendTo ( this . uiDialogTitlebar ) ;
151-
152- uiDialogTitle = $ ( "<span>" )
153- . uniqueId ( )
154- . addClass ( "ui-dialog-title" )
155- . html ( title )
156- . prependTo ( this . uiDialogTitlebar ) ;
126+ this . _createTitlebar ( ) ;
157127
158128 // TODO extract this one and the next into a _createButtonPane method
159129 uiDialogButtonPane = ( this . uiDialogButtonPane = $ ( "<div>" ) )
@@ -163,11 +133,6 @@ $.widget("ui.dialog", {
163133 . addClass ( "ui-dialog-buttonset" )
164134 . appendTo ( uiDialogButtonPane ) ;
165135
166- // TODO move into _createWrapper
167- this . uiDialog . attr ( {
168- role : "dialog" ,
169- "aria-labelledby" : uiDialogTitle . attr ( "id" )
170- } ) ;
171136
172137 // TODO move into _createWrapper
173138 // We assume that any existing aria-describedby attribute means
@@ -358,6 +323,48 @@ $.widget("ui.dialog", {
358323 this . _delay ( checkFocus ) ;
359324 } ,
360325
326+ _createTitlebar : function ( ) {
327+ var uiDialogTitle ;
328+
329+ this . uiDialogTitlebar = $ ( "<div>" )
330+ . addClass ( "ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix" )
331+ . prependTo ( this . uiDialog ) ;
332+ this . _on ( this . uiDialogTitlebar , {
333+ mousedown : function ( ) {
334+ // TODO call _focusTabbable or _keepFocus
335+ // Dialog isn't getting focus when dragging (#8063)
336+ this . uiDialog . focus ( ) ;
337+ }
338+ } ) ;
339+
340+ this . uiDialogTitlebarClose = $ ( "<button></button>" )
341+ . button ( {
342+ label : this . options . closeText ,
343+ icons : {
344+ primary : "ui-icon-closethick"
345+ } ,
346+ text : false
347+ } )
348+ . addClass ( "ui-dialog-titlebar-close" )
349+ . appendTo ( this . uiDialogTitlebar ) ;
350+ this . _on ( this . uiDialogTitlebarClose , {
351+ "click" : function ( event ) {
352+ event . preventDefault ( ) ;
353+ this . close ( event ) ;
354+ }
355+ } ) ;
356+
357+ uiDialogTitle = $ ( "<span>" )
358+ . uniqueId ( )
359+ . addClass ( "ui-dialog-title" )
360+ . html ( this . options . title || " " )
361+ . prependTo ( this . uiDialogTitlebar ) ;
362+
363+ this . uiDialog . attr ( {
364+ "aria-labelledby" : uiDialogTitle . attr ( "id" )
365+ } ) ;
366+ } ,
367+
361368 _createButtons : function ( ) {
362369 var that = this ,
363370 buttons = this . options . buttons ;
0 commit comments