PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 0ms app.codeStats 0ms

/ext-4.1.0_b3/docs/extjs/examples/resizer/basic.html

https://bitbucket.org/srogerf/javascript
HTML | 138 lines | 127 code | 10 blank | 1 comment | 0 complexity | 5e49a9cb4b60958e24a6669defb3f175 MD5 | raw file
  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    <!-- GC -->
 12
 13
 14    <script type="text/javascript" src="../../ext-all.js"></script>
 15    <script src="basic.js"></script>
 16
 17</head>
 18
 19<body>
 20
 21<h1>Resizable Examples</h1>
 22<p>These examples show how to apply a floating (default) and pinned Resizable component to a standard element.</p>
 23<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>
 24
 25<p>
 26    <b>Basic Example</b><br />
 27    This is a basic as you get. To resize the box, position your mouse anywhere near the bottom,
 28    right or border right edge of the box. This example uses the default "floating" handles.
 29</p>
 30<div id="basic">Resize Me!</div>
 31<pre class="code"><code>var basic = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
 32        target: 'basic',
 33        width: 200,
 34        height: 100,
 35        minWidth:100,
 36        minHeight:50
 37});</code></pre>
 38<hr>
 39<p>
 40    <b>Wrapped Elements</b><br />
 41    Some elements such as images and textareas don't allow child elements. Prior to Ext JS 3.x, you had
 42    to wrap these elements and set up a Resizable with resize child. With Ext JS 3.x we made it a little
 43    easier for you and all you had to do was set "wrap:true". Now with Ext JS 4.x we go a step further
 44    and automatically detect if the element needs a wrap and wrap it for you.
 45</p><p>
 46    <b>Pinned Handles</b><br />
 47    Notice this example has the resize handles "pinned". This is done by setting "pinned:true".
 48</p><p>
 49    <b>Dynamic Sizing</b><br />
 50    If you don't like the proxy resizing, you can also turn on dynamic sizing. Just set "dynamic:true".
 51</p>
 52<p>
 53    Here's a textarea that is wrapped (automatically), has pinned handles and has dynamic sizing turned on.
 54</p>
 55<textarea id="dwrapped" style="resize: none;">
 56Lorem 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.
 57Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit. Quisque dolor magna, ornare sed, elementum porta, luctus in, leo.
 58</textarea><br /><br />
 59And look how simple the code is, even my grandma could write it.
 60<pre class="code"><code>var dwrapped = Ext.create('Ext.resizer.Resizer', {
 61    target: 'dwrapped',
 62    pinned:true,
 63    width:450,
 64    height:150,
 65    minWidth:200,
 66    minHeight: 50,
 67    dynamic: true
 68});</code></pre>
 69<hr>
 70<p>
 71<b>Preserve Ratio</b><br />
 72    For some things like images, you will probably want to preserve the ratio of width to height. Just set preserveRatio:true.
 73</p>
 74<img id="wrapped" src="flower.jpg" width="200" height="133"/>
 75<pre class="code"><code>var wrapped = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
 76    target: 'wrapped',
 77    pinned:true,
 78    minWidth:50,
 79    minHeight: 50,
 80    preserveRatio: true
 81});</code></pre>
 82<p>
 83<b>Snapping</b><br />
 84    To resize in fixed increments, specify the <code>widthIncrement</code> or <code>heightIncrement</code> options. The image below
 85    resizes (maintaining its aspect ratio) in increments of 20 pixels in both directions.
 86</p>
 87<img id="croix-de-fer" src="CroixDeFer.jpg" width="160" height="120"/>
 88<pre class="code"><code>var snapping = Ext.create('Ext.resizer.Resizer', {
 89    target: 'croix-de-fer',
 90    width: 160,
 91    height: 120,
 92    minWidth: 160,
 93    minHeight: 120,
 94    preserveRatio: true,
 95    heightIncrement: 20,
 96    widthIncrement: 20
 97});
 98</code></pre>
 99<hr>
100<p>
101<b>Transparent Handles</b><br />
102    If you just want the element to be resizable without any fancy handles, set transparent to true.
103</p>
104<img id="transparent" src="grass.jpg" width="200" height="133"/>
105<pre class="code"><code>var transparent = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
106    target: 'transparent',
107    minWidth:50,
108    minHeight: 50,
109    preserveRatio: true,
110    transparent:true
111});</code></pre>
112<hr>
113<p>
114    <b>Customizable Handles</b><br />
115    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
116    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.
117    The handles are styled using CSS so they can be customized to look however you would like them to.
118</p>
119<p>
120    This image has 8 way resizing, custom handles and preserved aspect ratio.<br />
121    <b>Double click anywhere on the image to hide it when you are done.</b>
122</p>
123<img id="custom" src="stones.jpg" width="200" height="150" style="position:absolute;left:0;top:0;"/>
124<div style="padding:8px;border:1px solid #c3daf9;background:#d9e8fb;width:150px;text-align:center;"><button id="showMe">Show Me</button></div>
125<pre class="code"><code>var custom = Ext.create('Ext.create', 'Ext.resizer.Resizer', {
126    target: 'custom',
127    pinned:true,
128    minWidth:50,
129    minHeight: 50,
130    preserveRatio: true,
131    dynamic:true,
132    handles: 'all' // shorthand for 'n s e w ne nw se sw'
133});</code></pre>
134
135<p>Images: graur codrin, Matt Banks, Lavoview (FreeDigitalPhotos.net)</p>
136
137</body>
138</html>