SOURCE CODE: Resizable Dialog
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Resizable Dialog | JavaScript Examples | UIZE JavaScript Framework</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="keywords" content="featured drag-and-drop widget Uize.Widgets.Dialog.Widget"/>
<meta name="description" content="See an example of a draggable and resizable modal JavaScript dialog that uses inline HTML (rather than a blockable popup window) and is configurable."/>
<link rel="alternate" type="application/rss+xml" title="UIZE JavaScript Framework - Latest News" href="http://www.uize.com/latest-news.rss"/>
<link rel="stylesheet" href="../css/page.css"/>
<link rel="stylesheet" href="../css/page.example.css"/>
</head>
<body>
<script type="text/javascript" src="../js/Uize.js"></script>
<h1 class="header">
<a id="page-homeLink" href="../index.html" title="UIZE JavaScript Framework home"></a>
<a href="../index.html" class="homeLinkText" title="UIZE JavaScript Framework home">UIZE JavaScript Framework</a>
</h1>
<div class="main">
<h1 class="document-title">
<a href="../javascript-examples.html" class="breadcrumb breadcrumbWithArrow">JAVASCRIPT EXAMPLES</a>
Resizable Dialog
<div class="pageActionsShell">
<div id="page-actions" class="pageActions"><a href="source-code/dialog-resizable.html" class="buttonLink">SOURCE</a></div>
</div>
</h1>
<!-- explanation copy -->
<div class="explanation">
<p>In this example, an instance of the <a href="../reference/Uize.Widgets.Dialog.Widget.html"><code>Uize.Widgets.Dialog.Widget</code></a> class is being used to implement a resizable modal dialog. The dialog can be resized by dragging on any of the corners or sides. Dragging on a side changes the dialog's dimensions in one axis only, while dragging on a corner changes the dimensions in both axes. In any given HTML implementation of a resizable dialog, all drag handles are optional. If you like, you can provide just a lower right corner drag handle. Since resizable dialogs share code with the marquee widget (<a href="../reference/Uize.Widget.Resizer.Marquee.html"><code>Uize.Widget.Resizer.Marquee</code></a>), it is possible to configure a resizable dialog to have a constrained aspect ratio, or to be resizable only in one axis, by setting state for its <code>resizer</code> child widget. The resizable dialog widget has child widgets for the <b>"OK"</b>, <b>"CANCEL"</b>, and <b>"CLOSE"</b> buttons.</p>
<p>To open the dialog, click the <b>"OPEN DIALOG"</b> button below.</p>
</div>
<center id="page-launcherButton" style="margin-bottom: 20px;"></center>
<!-- programmatic interface examples -->
<div class="programmaticInterface">
<ul>
<li>Resizing Configurations
<ul>
<li>FIXED WIDTH ONLY: <a href="javascript://" class="linkedJs">dialog.children.resizer.set ({fixedX:true,fixedY:false}); dialog.set ({shown:true})</a></li>
<li>FIXED HEIGHT ONLY: <a href="javascript://" class="linkedJs">dialog.children.resizer.set ({fixedX:false,fixedY:true}); dialog.set ({shown:true})</a></li>
<li>NOT RESIZABLE: <a href="javascript://" class="linkedJs">dialog.children.resizer.set ({fixedX:true,fixedY:true}); dialog.set ({shown:true})</a></li>
<li>FULLY RESIZABLE: <a href="javascript://" class="linkedJs">dialog.children.resizer.set ({fixedX:false,fixedY:false}); dialog.set ({shown:true})</a></li>
</ul>
</li>
</ul>
</div>
</div>
<!-- JavaScript code to wire up the page -->
<script type="text/javascript">
Uize.require (
[
'UizeSite.Page.Example.library',
'UizeSite.Page.Example',
'Uize.Widgets.Dialog.Widget',
'Uize.Str.Repeat',
'Uize.Widgets.Button.Widget'
],
function () {
'use strict';
/*** create the example page widget ***/
var page = window.page = UizeSite.Page.Example ({evaluator:function (code) {eval (code)}});
/*** create the Uize.Widgets.Dialog.Widget object ***/
var dialog = page.addChild (
'dialog',
Uize.Widgets.Dialog.Widget,
{
mooringNode:'page-openDialogLink',
offsetX:-100,
offsetY:-100,
width:500,
height:300,
built:false,
title:'RESIZABLE DIALOG WINDOW',
children:{
contents:{
html:
'<div style="padding:5px;">' +
Uize.Str.Repeat.repeat ('This is a resizable dialog. ',50) +
'</div>'
}
},
resizable:true
}
);
/*** add the launcher button ***/
page.addChild (
'launcherButton',
Uize.Widgets.Button.Widget,
{
text:'OPEN DIALOG',
action:function () {dialog.set ({shown:true})},
built:false
}
);
/*** wire up the page widget ***/
page.wireUi ();
}
);
</script>
</body>
</html>