Skip to content
Permalink
Browse files

Dialog: Use new uniqueId method for generating id's

  • Loading branch information...
kborchers committed May 30, 2012
1 parent 9f59d01 commit 240b22b1439df22408c5782e640e98cb335c7a2e
Showing with 9 additions and 24 deletions.
  1. +3 −18 tests/unit/dialog/dialog_core.js
  2. +6 −6 ui/jquery.ui.dialog.js
@@ -89,26 +89,11 @@ function margin(el, side) {
module("dialog: core");

test("title id", function() {
expect(3);

var titleId;

// reset the uuid so we know what values to expect
$.ui.dialog.uuid = 0;
expect(1);

el = $('<div></div>').dialog();
titleId = dlg().find('.ui-dialog-title').attr('id');
equal(titleId, 'ui-dialog-title-1', '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');
var titleId = dlg().find('.ui-dialog-title').attr('id');
ok( /ui-id-\d+$/.test( titleId ), 'auto-numbered title id');
el.remove();
});

@@ -87,7 +87,6 @@ $.widget("ui.dialog", {
options = this.options,

title = options.title || "&#160;",
titleId = $.ui.dialog.getTitleId( this.element ),

uiDialog = ( this.uiDialog = $( "<div>" ) )
.addClass( uiDialogClasses + options.dialogClass )
@@ -105,10 +104,6 @@ $.widget("ui.dialog", {
event.preventDefault();
}
})
.attr({
role: "dialog",
"aria-labelledby": titleId
})
.mousedown(function( event ) {
that.moveToTop( false, event );
})
@@ -140,8 +135,8 @@ $.widget("ui.dialog", {
.appendTo( uiDialogTitlebarClose ),

uiDialogTitle = $( "<span>" )
.uniqueId()
.addClass( "ui-dialog-title" )
.attr( "id", titleId )
.html( title )
.prependTo( uiDialogTitlebar ),

@@ -152,6 +147,11 @@ $.widget("ui.dialog", {
.addClass( "ui-dialog-buttonset" )
.appendTo( uiDialogButtonPane );

uiDialog.attr({
role: "dialog",
"aria-labelledby": uiDialogTitle.attr( "id" )
});

uiDialogTitlebar.find( "*" ).add( uiDialogTitlebar ).disableSelection();
this._hoverable( uiDialogTitlebarClose );
this._focusable( uiDialogTitlebarClose );

0 comments on commit 240b22b

Please sign in to comment.
You can’t perform that action at this time.