mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Dialog: Use new uniqueId method for generating id's
This commit is contained in:
parent
9f59d01fdc
commit
240b22b143
@ -89,26 +89,11 @@ function margin(el, side) {
|
|||||||
module("dialog: core");
|
module("dialog: core");
|
||||||
|
|
||||||
test("title id", function() {
|
test("title id", function() {
|
||||||
expect(3);
|
expect(1);
|
||||||
|
|
||||||
var titleId;
|
|
||||||
|
|
||||||
// reset the uuid so we know what values to expect
|
|
||||||
$.ui.dialog.uuid = 0;
|
|
||||||
|
|
||||||
el = $('<div></div>').dialog();
|
el = $('<div></div>').dialog();
|
||||||
titleId = dlg().find('.ui-dialog-title').attr('id');
|
var titleId = dlg().find('.ui-dialog-title').attr('id');
|
||||||
equal(titleId, 'ui-dialog-title-1', 'auto-numbered title id');
|
ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id');
|
||||||
el.remove();
|
|
||||||
|
|
||||||
el = $('<div></div>').dialog();
|
|
||||||
titleId = dlg().find('.ui-dialog-title').attr('id');
|
|
||||||
equal(titleId, 'ui-dialog-title-2', 'auto-numbered title id');
|
|
||||||
el.remove();
|
|
||||||
|
|
||||||
el = $('<div id="foo">').dialog();
|
|
||||||
titleId = dlg().find('.ui-dialog-title').attr('id');
|
|
||||||
equal(titleId, 'ui-dialog-title-foo', 'carried over title id');
|
|
||||||
el.remove();
|
el.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
12
ui/jquery.ui.dialog.js
vendored
12
ui/jquery.ui.dialog.js
vendored
@ -87,7 +87,6 @@ $.widget("ui.dialog", {
|
|||||||
options = this.options,
|
options = this.options,
|
||||||
|
|
||||||
title = options.title || " ",
|
title = options.title || " ",
|
||||||
titleId = $.ui.dialog.getTitleId( this.element ),
|
|
||||||
|
|
||||||
uiDialog = ( this.uiDialog = $( "<div>" ) )
|
uiDialog = ( this.uiDialog = $( "<div>" ) )
|
||||||
.addClass( uiDialogClasses + options.dialogClass )
|
.addClass( uiDialogClasses + options.dialogClass )
|
||||||
@ -105,10 +104,6 @@ $.widget("ui.dialog", {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.attr({
|
|
||||||
role: "dialog",
|
|
||||||
"aria-labelledby": titleId
|
|
||||||
})
|
|
||||||
.mousedown(function( event ) {
|
.mousedown(function( event ) {
|
||||||
that.moveToTop( false, event );
|
that.moveToTop( false, event );
|
||||||
})
|
})
|
||||||
@ -140,8 +135,8 @@ $.widget("ui.dialog", {
|
|||||||
.appendTo( uiDialogTitlebarClose ),
|
.appendTo( uiDialogTitlebarClose ),
|
||||||
|
|
||||||
uiDialogTitle = $( "<span>" )
|
uiDialogTitle = $( "<span>" )
|
||||||
|
.uniqueId()
|
||||||
.addClass( "ui-dialog-title" )
|
.addClass( "ui-dialog-title" )
|
||||||
.attr( "id", titleId )
|
|
||||||
.html( title )
|
.html( title )
|
||||||
.prependTo( uiDialogTitlebar ),
|
.prependTo( uiDialogTitlebar ),
|
||||||
|
|
||||||
@ -152,6 +147,11 @@ $.widget("ui.dialog", {
|
|||||||
.addClass( "ui-dialog-buttonset" )
|
.addClass( "ui-dialog-buttonset" )
|
||||||
.appendTo( uiDialogButtonPane );
|
.appendTo( uiDialogButtonPane );
|
||||||
|
|
||||||
|
uiDialog.attr({
|
||||||
|
role: "dialog",
|
||||||
|
"aria-labelledby": uiDialogTitle.attr( "id" )
|
||||||
|
});
|
||||||
|
|
||||||
uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
|
uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
|
||||||
this._hoverable( uiDialogTitlebarClose );
|
this._hoverable( uiDialogTitlebarClose );
|
||||||
this._focusable( uiDialogTitlebarClose );
|
this._focusable( uiDialogTitlebarClose );
|
||||||
|
Loading…
Reference in New Issue
Block a user