Skip to content

Commit 3a491e9

Browse files
committed
with minimize and restore button in title
with minimize and restore button in title
1 parent 74f8a0a commit 3a491e9

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

themes/base/dialog.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,24 @@
3636
padding: 1px;
3737
height: 20px;
3838
}
39+
.ui-dialog .ui-dialog-titlebar-minimize {
40+
position: absolute;
41+
right: 2.1em;
42+
top: 50%;
43+
width: 20px;
44+
margin: -10px 0 0 0;
45+
padding: 1px;
46+
height: 20px;
47+
}
48+
.ui-dialog .ui-dialog-titlebar-restore {
49+
position: absolute;
50+
right: 3.8em;
51+
top: 50%;
52+
width: 20px;
53+
margin: -10px 0 0 0;
54+
padding: 1px;
55+
height: 20px;
56+
}
3957
.ui-dialog .ui-dialog-content {
4058
position: relative;
4159
border: 0;

themes/base/theme.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ a.ui-button:active,
331331
.ui-icon-minus { background-position: -48px -128px; }
332332
.ui-icon-minusthick { background-position: -64px -128px; }
333333
.ui-icon-close { background-position: -80px -128px; }
334+
.ui-icon-restore { background-position: -176px -128px; }
335+
.ui-icon-minimize { background-position: -48px -128px; }
334336
.ui-icon-closethick { background-position: -96px -128px; }
335337
.ui-icon-key { background-position: -112px -128px; }
336338
.ui-icon-lightbulb { background-position: -128px -128px; }

ui/widgets/dialog.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ $.widget( "ui.dialog", {
5555
},
5656
closeOnEscape: true,
5757
closeText: "Close",
58+
minimizeText: "Minimize",
59+
restoreText: "Restore",
5860
draggable: true,
5961
hide: null,
6062
height: "auto",
@@ -441,7 +443,51 @@ $.widget( "ui.dialog", {
441443
this.close( event );
442444
}
443445
} );
444-
446+
447+
this.uiDialogTitlebarMinimize = $( "<button type='button'></button>" )
448+
.button( {
449+
label: $( "<a>" ).text( this.options.minimizeText ).html(),
450+
icon: "ui-icon ui-icon-minimize",
451+
showLabel: false
452+
} )
453+
.appendTo( this.uiDialogTitlebar );
454+
this._addClass( this.uiDialogTitlebarMinimize, "ui-dialog-titlebar-minimize" );
455+
this._on( this.uiDialogTitlebarMinimize, {
456+
click: function( event ) {
457+
event.preventDefault();
458+
this.options.restoreWidth = this.options.width;
459+
this.options.restoreHeight = this.options.height;
460+
this.uiDialog.width(300);
461+
this.uiDialog.height(this.uiDialogButtonPane.height);
462+
this.element.hide();
463+
this.uiDialogButtonPane.hide();
464+
this.uiDialogTitlebarRestore.button("enable");
465+
this.uiDialogTitlebarMinimize.button( "disable" );
466+
}
467+
} );
468+
this.uiDialogTitlebarRestore = $( "<button type='button'></button>" )
469+
.button( {
470+
label: $( "<a>" ).text( this.options.restoreText ).html(),
471+
icon: "ui-icon ui-icon-restore",
472+
showLabel: false
473+
} )
474+
.appendTo( this.uiDialogTitlebar );
475+
this._addClass( this.uiDialogTitlebarRestore, "ui-dialog-titlebar-restore" );
476+
this._on( this.uiDialogTitlebarRestore, {
477+
click: function( event ) {
478+
event.preventDefault();
479+
if(this.options.restoreWidth != undefined && this.options.restoreWidth != null && this.options.restoreWidth != "")
480+
this.uiDialog.width(this.options.restoreWidth);
481+
if(this.options.restoreHeight != undefined && this.options.restoreHeight != null && this.options.restoreHeight != "")
482+
this.uiDialog.height(this.options.restoreHeight);
483+
this.element.show();
484+
this.uiDialogButtonPane.show();
485+
this.uiDialogTitlebarMinimize.button( "enable" );
486+
this.uiDialogTitlebarRestore.button( "disable" );
487+
}
488+
} );
489+
this.uiDialogTitlebarRestore.button( "disable" );
490+
445491
uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
446492
this._addClass( uiDialogTitle, "ui-dialog-title" );
447493
this._title( uiDialogTitle );

0 commit comments

Comments
 (0)