Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / resizer / basic.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4     <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5     <title>Resizable Examples</title>
6
7     <link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
8     <link rel="stylesheet" type="text/css" href="../shared/example.css" />
9     <link rel="stylesheet" type="text/css" href="basic.css" />
10
11     <script type="text/javascript" src="../../bootstrap.js"></script>
12     <script src="basic.js"></script>
13
14 </head>
15
16 <body>
17
18 <h1>Resizable Examples</h1>
19 <p>These examples show how to apply a floating (default) and pinned Resizable component to a standard element.</p>
20 <p>Note that the js is not minified so it is readable. See <a href="basic.js">basic.js</a> for the full source code.</p>
21
22 <p>
23     <b>Basic Example</b><br />
24     This is a basic as you get. To resize the box, position your mouse anywhere near the bottom,
25     right or border right edge of the box. This example uses the default "floating" handles.
26 </p>
27 <div id="basic">Resize Me!</div>
28 <pre class="code"><code>var basic = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
29         target: 'basic',
30         width: 200,
31         height: 100,
32         minWidth:100,
33         minHeight:50
34 });</code></pre>
35 <hr>
36 <p>
37     <b>Wrapped Elements</b><br />
38     Some elements such as images and textareas don't allow child elements. Prior to Ext JS 3.x, you had
39     to wrap these elements and set up a Resizable with resize child. With Ext JS 3.x we made it a little
40     easier for you and all you had to do was set "wrap:true". Now with Ext JS 4.x we go a step further
41     and automatically detect if the element needs a wrap and wrap it for you.
42 </p><p>
43     <b>Pinned Handles</b><br />
44     Notice this example has the resize handles "pinned". This is done by setting "pinned:true".
45 </p><p>
46     <b>Dynamic Sizing</b><br />
47     If you don't like the proxy resizing, you can also turn on dynamic sizing. Just set "dynamic:true".
48 </p>
49 <p>
50     Here's a textarea that is wrapped (automatically), has pinned handles and has dynamic sizing turned on.
51 </p>
52 <textarea id="dwrapped" style="resize: none;">
53 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna. Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa.
54 Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit. Quisque dolor magna, ornare sed, elementum porta, luctus in, leo.
55 </textarea><br /><br />
56 And look how simple the code is, even my grandma could write it.
57 <pre class="code"><code>var dwrapped = Ext.create('Ext.resizer.Resizer', {
58     target: 'dwrapped',
59     pinned:true,
60     width:450,
61     height:150,
62     minWidth:200,
63     minHeight: 50,
64     dynamic: true
65 });</code></pre>
66 <hr>
67 <p>
68 <b>Preserve Ratio</b><br />
69     For some things like images, you will probably want to preserve the ratio of width to height. Just set preserveRatio:true.
70 </p>
71 <img id="wrapped" src="flower.jpg" width="200" height="133"/>
72 <pre class="code"><code>var wrapped = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
73     target: 'wrapped',
74     pinned:true,
75     minWidth:50,
76     minHeight: 50,
77     preserveRatio: true
78 });</code></pre>
79 <hr>
80 <p>
81 <b>Transparent Handles</b><br />
82     If you just want the element to be resizable without any fancy handles, set transparent to true.
83 </p>
84 <img id="transparent" src="grass.jpg" width="200" height="133"/>
85 <pre class="code"><code>var transparent = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
86     target: 'transparent',
87     minWidth:50,
88     minHeight: 50,
89     preserveRatio: true,
90     transparent:true
91 });</code></pre>
92 <hr>
93 <p>
94     <b>Customizable Handles</b><br />
95     Resizable elements are resizable 8 ways. 8 way resizing for a static positioned element will cause the element to be positioned relative and taken out of the document flow. For resizing which adjusts the
96     x and y of the element, the element should be positioned absolute. You can also control which handles are displayed by setting the "handles" attribute.
97     The handles are styled using CSS so they can be customized to look however you would like them to.
98 </p>
99 <p>
100     This image has 8 way resizing, custom handles and preserved aspect ratio.<br />
101     <b>Double click anywhere on the image to hide it when you are done.</b>
102 </p>
103 <img id="custom" src="stones.jpg" width="200" height="150" style="position:absolute;left:0;top:0;"/>
104 <div style="padding:8px;border:1px solid #c3daf9;background:#d9e8fb;width:150px;text-align:center;"><button id="showMe">Show Me</button></div>
105 <pre class="code"><code>var custom = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
106     target: 'custom',
107     pinned:true,
108     minWidth:50,
109     minHeight: 50,
110     preserveRatio: true,
111     dynamic:true,
112     handles: 'all' // shorthand for 'n s e w ne nw se sw'
113 });</code></pre>
114
115 <p>Images: graur codrin, Matt Banks, Lavoview (FreeDigitalPhotos.net)</p>
116
117 </body>
118 </html>