Skip to content

Commit c4bffba

Browse files
committed
Dialog: Add icons option to support titlebar icons
Fixes #15121
1 parent ee55efb commit c4bffba

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

tests/unit/dialog/common.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ common.testWidget( "dialog", {
1818
draggable: true,
1919
height: "auto",
2020
hide: null,
21+
icons: {
22+
title: null
23+
},
2124
maxHeight: null,
2225
maxWidth: null,
2326
minHeight: 150,

themes/base/dialog.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@
2727
overflow: hidden;
2828
text-overflow: ellipsis;
2929
}
30+
.ui-dialog .ui-dialog-title-icon {
31+
position: absolute;
32+
left: 0.3em;
33+
top: 50%;
34+
margin-top: -10px;
35+
}
36+
.ui-dialog-title-icon + .ui-dialog-title {
37+
padding-left: 10px;
38+
}
3039
.ui-dialog .ui-dialog-titlebar-close {
3140
position: absolute;
3241
right: .3em;

ui/widgets/dialog.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ $.widget( "ui.dialog", {
5858
draggable: true,
5959
hide: null,
6060
height: "auto",
61+
icons: {
62+
title: null
63+
},
6164
maxHeight: null,
6265
maxWidth: null,
6366
minHeight: 150,
@@ -404,7 +407,7 @@ $.widget( "ui.dialog", {
404407
},
405408

406409
_createTitlebar: function() {
407-
var uiDialogTitle;
410+
var uiDialogTitle, uiDialogTitleIcon;
408411

409412
this.uiDialogTitlebar = $( "<div>" );
410413
this._addClass( this.uiDialogTitlebar,
@@ -446,6 +449,12 @@ $.widget( "ui.dialog", {
446449
this._addClass( uiDialogTitle, "ui-dialog-title" );
447450
this._title( uiDialogTitle );
448451

452+
if (this.options.icons.title) {
453+
uiDialogTitleIcon = $( "<span>" ).prependTo( this.uiDialogTitlebar );
454+
this._addClass( uiDialogTitleIcon, "ui-dialog-title-icon",
455+
"ui-icon " + this.options.icons.title );
456+
}
457+
449458
this.uiDialogTitlebar.prependTo( this.uiDialog );
450459

451460
this.uiDialog.attr( {

0 commit comments

Comments
 (0)