Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add minimize and restore button in dialog title #1967

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
3a491e9
with minimize and restore button in title
uplusware Jan 24, 2018
cc26b73
With minimize and restore button in dialog title
uplusware Jan 24, 2018
e787969
fix height problem when minimize
uplusware Jan 30, 2018
3030a0d
Merge branch 'jquery:main' into master
uplusware May 28, 2021
b4075e5
Update README.md
uplusware May 31, 2021
46c2dc6
Merge branch 'jquery:main' into master
uplusware Jun 7, 2021
b58cd30
Merge branch 'jquery:main' into master
uplusware Jul 23, 2021
8d21dce
Merge branch 'jquery:main' into master
uplusware Aug 15, 2021
c5204f7
Merge branch 'jquery:main' into master
uplusware Sep 4, 2021
d96af3d
Merge branch 'jquery:main' into master
uplusware Oct 8, 2021
725fe9d
fix title bar width and height issue
uplusware Oct 15, 2021
de7e529
Update README.md
uplusware Oct 15, 2021
b306e59
make minimizable feature can be disabled and enabled and add test case
uplusware Oct 19, 2021
473edf3
add test case into dialog index.html
uplusware Oct 19, 2021
83ae561
Update dialog.js
uplusware Oct 21, 2021
209ae40
Update common-deprecated.js and common.js
uplusware Oct 21, 2021
249bfbb
Merge branch 'jquery:main' into master
uplusware Nov 18, 2021
237f507
Update README.md
uplusware Nov 18, 2021
6381b4a
Merge branch 'jquery:main' into master
uplusware Nov 20, 2021
cc43692
Update README.md
uplusware Nov 22, 2021
8a12b7e
Update README.md
uplusware Nov 22, 2021
ff682f5
Update README.md
uplusware Nov 22, 2021
854b1e4
Merge branch 'jquery:main' into master
uplusware Dec 29, 2021
3b620c5
Merge branch 'jquery:main' into master
uplusware Jan 15, 2022
843d128
Merge branch 'jquery:main' into master
uplusware Feb 5, 2022
8671bcd
Merge branch 'jquery:main' into master
uplusware Mar 24, 2022
7e7b325
Merge branch 'jquery:main' into master
uplusware Aug 2, 2022
c156df5
Merge branch 'jquery:main' into master
uplusware Aug 20, 2022
328bd27
Merge branch 'jquery:main' into master
uplusware Oct 21, 2022
15f4870
Merge branch 'jquery:main' into master
uplusware Dec 9, 2023
7118294
Merge branch 'jquery:main' into master
uplusware Feb 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# jQuery-UI-x

jQuery UI with minimize/restore button for dialog widget.

The PR: https://github.com/jquery/jquery-ui/pull/1967

# [jQuery UI](http://jqueryui.com/) - Interactions and Widgets for the web

_**Note:** jQuery UI is in maintenance-only mode. Please read [the project status blog post](https://blog.jqueryui.com/2021/10/jquery-maintainers-update-and-transition-jquery-ui-as-part-of-overall-modernization-efforts/) for more information._
Expand Down
1 change: 1 addition & 0 deletions demos/dialog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<ul>
<li><a href="default.html">Default functionality</a></li>
<li><a href="minimizable.html">Minimizable dialog</a></li>
<li><a href="modal-message.html">Modal message</a></li>
<li><a href="modal-confirmation.html">Modal confirmation</a></li>
<li><a href="modal-form.html">Modal form</a></li>
Expand Down
26 changes: 26 additions & 0 deletions demos/dialog/minimizable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jQuery UI Dialog - Minimizable dialog</title>
<link rel="stylesheet" href="../../themes/base/all.css">
<link rel="stylesheet" href="../demos.css">
<script src="../../external/requirejs/require.js"></script>
<script src="../bootstrap.js">
$( "#dialog" ).dialog({
minimizable: true
});
</script>
</head>
<body>

<div id="dialog" title="Minimizable dialog">
<p>This is the dialog which can be minimized and restored.</p>
</div>

<div class="demo-description">
<p>This is the dialog which can be minimized and restored.</p>
</div>
</body>
</html>
3 changes: 3 additions & 0 deletions tests/unit/dialog/common-deprecated.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ common.testWidget( "dialog", {
},
closeOnEscape: true,
closeText: "Close",
minimizeText: "Minimize",
restoreText: "Restore",
dialogClass: "",
disabled: false,
draggable: true,
minimizable: false,
height: "auto",
hide: null,
maxHeight: null,
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/dialog/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ common.testWidget( "dialog", {
},
closeOnEscape: true,
closeText: "Close",
minimizeText: "Minimize",
restoreText: "Restore",
disabled: false,
draggable: true,
minimizable: false,
height: "auto",
hide: null,
maxHeight: null,
Expand Down
18 changes: 18 additions & 0 deletions themes/base/dialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,24 @@
padding: 1px;
height: 20px;
}
.ui-dialog .ui-dialog-titlebar-minimize {
position: absolute;
right: 2.1em;
top: 50%;
width: 20px;
margin: -10px 0 0 0;
padding: 1px;
height: 20px;
}
.ui-dialog .ui-dialog-titlebar-restore {
position: absolute;
right: 3.8em;
top: 50%;
width: 20px;
margin: -10px 0 0 0;
padding: 1px;
height: 20px;
}
.ui-dialog .ui-dialog-content {
position: relative;
border: 0;
Expand Down
2 changes: 2 additions & 0 deletions themes/base/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,8 @@ a.ui-button:active,
.ui-icon-minus { background-position: -48px -128px; }
.ui-icon-minusthick { background-position: -64px -128px; }
.ui-icon-close { background-position: -80px -128px; }
.ui-icon-restore { background-position: -176px -128px; }
.ui-icon-minimize { background-position: -48px -128px; }
.ui-icon-closethick { background-position: -96px -128px; }
.ui-icon-key { background-position: -112px -128px; }
.ui-icon-lightbulb { background-position: -128px -128px; }
Expand Down
57 changes: 57 additions & 0 deletions ui/widgets/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ $.widget( "ui.dialog", {
},
closeOnEscape: true,
closeText: "Close",
minimizeText: "Minimize",
restoreText: "Restore",
draggable: true,
minimizable: false,
hide: null,
height: "auto",
maxHeight: null,
Expand Down Expand Up @@ -446,6 +449,60 @@ $.widget( "ui.dialog", {
}
} );

if ( this.options.minimizable ) {
this.uiDialogTitlebarMinimize = $( "<button type='button'></button>" )
.button( {
label: $( "<a>" ).text( this.options.minimizeText ).html(),
icon: "ui-icon ui-icon-minimize",
showLabel: false
} )
.appendTo( this.uiDialogTitlebar );
this._addClass( this.uiDialogTitlebarMinimize, "ui-dialog-titlebar-minimize" );
this._on( this.uiDialogTitlebarMinimize, {
click: function( event ) {
event.preventDefault();
this.options.restoreWidth = this.options.width;
this.options.restoreHeight = this.options.height;
this.uiDialog.width( this.uiDialogTitlebar.outerWidth() > 300 ?
300 :
this.uiDialogTitlebar.outerWidth() );
this.uiDialog.height( this.uiDialogTitlebar.outerHeight() );
this.element.hide();
this.uiDialogButtonPane.hide();
this.uiDialogTitlebarRestore.button( "enable" );
this.uiDialogTitlebarMinimize.button( "disable" );
}
} );
this.uiDialogTitlebarRestore = $( "<button type='button'></button>" )
.button( {
label: $( "<a>" ).text( this.options.restoreText ).html(),
icon: "ui-icon ui-icon-restore",
showLabel: false
} )
.appendTo( this.uiDialogTitlebar );
this._addClass( this.uiDialogTitlebarRestore, "ui-dialog-titlebar-restore" );
this._on( this.uiDialogTitlebarRestore, {
click: function( event ) {
event.preventDefault();
if ( this.options.restoreWidth !== undefined &&
this.options.restoreWidth !== null &&
this.options.restoreWidth !== "" ) {
this.uiDialog.width( this.options.restoreWidth );
}
if ( this.options.restoreHeight !== undefined &&
this.options.restoreHeight !== null &&
this.options.restoreHeight !== "" ) {
this.uiDialog.height( this.options.restoreHeight );
}
this.element.show();
this.uiDialogButtonPane.show();
this.uiDialogTitlebarMinimize.button( "enable" );
this.uiDialogTitlebarRestore.button( "disable" );
}
} );
this.uiDialogTitlebarRestore.button( "disable" );
}

uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
this._addClass( uiDialogTitle, "ui-dialog-title" );
this._title( uiDialogTitle );
Expand Down