46e1366ad8081d0778293dd628ed88e6d3e1f2ca
[roojs1] / examples / resizable / basic.html
1 <html>
2 <head>
3 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
4 <title>Resizable Examples</title>
5   <link rel="stylesheet" type="text/css" href="../../cssX/roojs-all.css"/>
6     <link rel="stylesheet" type="text/css" href="../../cssX/xtheme-slate.css"/>
7
8      <script type="text/javascript" src="../../roojs-all.js"></script>   
9    <script type="text/javascript" src="../../Roo/Resizable.js"></script>   
10    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
11    
12    
13 <script language="javascript" src="basic.js"></script>
14
15 <!-- Common Styles for the examples -->
16 <link rel="stylesheet" type="text/css" href="../examples.css" />
17 <style type="text/css">
18 #basic, #animated {
19     border:1px solid #c3daf9;
20     color:#1e4e8f;
21     font:bold 14px tahoma,verdana,helvetica;
22     text-align:center;
23     padding-top:20px;
24 }
25 #snap {
26     border:1px solid #c3daf9;
27     overflow:hidden;
28 }
29 #custom {
30     cursor:move;
31 }
32 #custom-rzwrap{
33     z-index: 100;
34 }
35 #custom-rzwrap .x-resizable-handle{
36     width:11px;
37     height:11px;
38     background:transparent url(../../resources/images/default/sizer/square.gif) no-repeat;
39     margin:0px;
40 }
41 #custom-rzwrap .x-resizable-handle-east, #custom-rzwrap .x-resizable-handle-west{
42     top:45%;
43 }
44 #custom-rzwrap .x-resizable-handle-north, #custom-rzwrap .x-resizable-handle-south{
45     left:45%;
46 }
47 </style>
48 </head>
49
50 <body>
51 <script type="text/javascript" src="../examples.js"></script><!-- EXAMPLES -->
52 <h1>Resizable Examples</h1>
53 <p>These examples show how to apply a floating (default) and pinned Resizable component to a standard element.</p>
54 <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>
55
56 <p>
57     <b>Basic Example</b><br />
58     This is a basic as you get. To resize the box, position your mouse anywhere near the bottom,
59     right or border right edge of the box. This example uses the default "floating" handles.
60 </p>
61 <div id="basic">Resize Me!</div>
62 <pre class="code"><code>var basic = new Ext.Resizable('basic', {
63         width: 200,
64         height: 100,
65         minWidth:100,
66         minHeight:50
67 });</code></pre>
68 <hr>
69 <p>
70     <b>Wrapped Elements</b><br />
71
72     Some elements such as images and textareas don't allow child elements. In the past, you had
73     to wrap these elements and set up a Resizable with resize child. As of yui-ext .33 RC2, Resizable will
74     wrap the element, calculate adjustments for borders/padding and offset the handles for you. All you have to
75     do is set "wrap:true". The manual way of specifying a "resizeChild" is still supported as well.
76 </p><p>
77     <b>Pinned Handles</b><br />
78     Notice this example has the resize handles "pinned". This is done by setting "pinned:true".
79 </p><p>
80     <b>Dynamic Sizing</b><br />
81     If you don't like the proxy resizing, you can also turn on dynamic sizing. Just set "dynamic:true".
82 </p>
83 <p>
84     Here's a textarea that is wrapped, has pinned handles and has dynamic sizing turned on.
85
86 </p>
87 <textarea id="dwrapped">
88 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.
89 Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit. Quisque dolor magna, ornare sed, elementum porta, luctus in, leo.
90 </textarea><br /><br />
91 And look how simple the code is, even my grandma could write it.
92 <pre class="code"><code>var dwrapped = new Ext.Resizable('dwrapped', {
93     wrap:true,
94     pinned:true,
95     width:450,
96     height:150,
97     minWidth:200,
98     minHeight: 50,
99     dynamic: true
100 });</code></pre>
101 <hr>
102 <p>
103 <b>Preserve Ratio</b><br />
104     For some things like images, you will probably want to preserve the ratio of width to height. Just set preserveRatio:true.
105 </p>
106 <img id="wrapped" src="sara.jpg" width="200" height="250"/>
107 <pre class="code"><code>var wrapped = new Ext.Resizable('wrapped', {
108     wrap:true,
109     pinned:true,
110     minWidth:50,
111     minHeight: 50,
112     preserveRatio: true
113 });</code></pre>
114 <hr>
115
116 <p>
117 <b>Transparent Handles</b><br />
118     If you just want the element to be resizable without any fancy handles, set transparent to true.
119 </p>
120 <img id="transparent" src="zack.jpg" width="100" height="176"/>
121 <pre class="code"><code>var transparent = new Ext.Resizable('transparent', {
122     wrap:true,
123     minWidth:50,
124     minHeight: 50,
125     preserveRatio: true,
126     transparent:true
127 });</code></pre>
128 <hr>
129 <p>
130     <b>Customizable Handles</b><br />
131     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
132     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.
133     The handles are styled using CSS so they can be customized to look however you would like them to. 
134 </p>
135
136 <p>
137     This image has 8 way resizing, custom handles, is draggable and 8 way preserved ratio (that wasn't easy!).<br />
138     <b>Double click anywhere on the image to hide it when you are done.</b>
139 </p>
140 <img id="custom" src="sara_and_zack.jpg" width="200" height="152" style="position:absolute;left:0;top:0;"/>
141 <div style="padding:8px;border:1px solid #c3daf9;background:#d9e8fb;width:150px;text-align:center;"><button id="showMe">Show Me</button></div>
142 <pre class="code"><code>var custom = new Ext.Resizable('custom', {
143     wrap:true,
144     pinned:true,
145     minWidth:50,
146     minHeight: 50,
147     preserveRatio: true,
148     dynamic:true,
149     handles: 'all', // shorthand for 'n s e w ne nw se sw'
150     draggable:true
151 });</code></pre>
152 <hr>
153 <p>
154     <b>Snapping</b><br />
155
156     Resizable also supports basic snapping in increments. 
157 </p>
158 <div id="snap"></div>
159 <pre class="code"><code>var snap = new Ext.Resizable('snap', {
160     pinned:true,
161     width:250,
162     height:100,
163     handles: 'e',
164     widthIncrement:50,
165     minWidth: 50,
166     dynamic: true
167 });
168 </code></pre>
169 Warning: Snapping and preserveRatio conflict and can not be used together.
170 <hr>
171 <p>
172     <b>Animated Transitions</b><br />
173     Resize operations can also be animated. Animations support configurable easing and duration.
174     Here's a very basic clone of the first element, but with animation turned on. I used a "backIn"
175     easing and made it a little slower than default.
176 </p>
177 <div id="animated">Animate Me!</div>
178
179 <pre class="code"><code>var animated = new Ext.Resizable('animated', {
180     width: 200,
181     height: 100,
182     minWidth:100,
183     minHeight:50,
184     animate:true,
185     easing: 'backIn',
186     duration:.6
187 });</code></pre>
188 Warning: for obvious reasons animate and dynamic resizing can not be used together.
189 <hr>
190
191
192 <div id="box1" style="position:absolute; left:400px;padding:10px;border:1px solid #c3daf9;background:#d9e8fb;width:150px;text-align:center;">Boxes 1</div>
193 <div id="box2" style="position:absolute; left:600px;padding:20px;border:1px solid #c3daf9;background:#d9e8fb;width:150px;text-align:center;">Boxes 2</div>
194 <div id="box3" style="position:absolute; left:830px;padding:30px;border:1px solid #c3daf9;background:#d9e8fb;width:150px;text-align:center;">Boxes 3</div>
195
196 <!--<div id="grouping" style="background: none repeat scroll 0px 0px;height: 200px; left: 400px; opacity: 0.7; position: relative;">-->
197     
198 </div>
199
200
201 <pre class="code">
202 <code>var custom = new Ext.Resizable('custom', {
203     wrap:true,
204     pinned:true,
205     minWidth:50,
206     minHeight: 50,
207     preserveRatio: true,
208     dynamic:true,
209     handles: 'all', // shorthand for 'n s e w ne nw se sw'
210     draggable:true
211 });</code>
212 </pre>
213
214 </body>
215 </html>