source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/tests/unit/resizable/resizable_options.js@ 24245

Last change on this file since 24245 was 24245, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

  • Property svn:executable set to *
File size: 6.6 KB
Line 
1/*
2 * resizable_options.js
3 */
4(function($) {
5
6module("resizable: options");
7
8test("aspectRatio: 'preserve' (e)", function() {
9 expect(4);
10
11 var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
12
13 drag(handle, 80);
14 equals( target.width(), 130, "compare maxWidth");
15 equals( target.height(), 130, "compare maxHeight");
16
17 drag(handle, -130);
18 equals( target.width(), 70, "compare minWidth");
19 equals( target.height(), 70, "compare minHeight");
20});
21
22test("aspectRatio: 'preserve' (w)", function() {
23 expect(4);
24
25 var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
26
27 drag(handle, -80);
28 equals( target.width(), 130, "compare maxWidth");
29 equals( target.height(), 130, "compare maxHeight");
30
31 drag(handle, 130);
32 equals( target.width(), 70, "compare minWidth");
33 equals( target.height(), 70, "compare minHeight");
34});
35
36test("aspectRatio: 'preserve' (n)", function() {
37 expect(4);
38
39 var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
40
41 drag(handle, 0, -80);
42 equals( target.width(), 130, "compare maxWidth");
43 equals( target.height(), 130, "compare maxHeight");
44
45 drag(handle, 0, 80);
46 equals( target.width(), 70, "compare minWidth");
47 equals( target.height(), 70, "compare minHeight");
48});
49
50test("aspectRatio: 'preserve' (s)", function() {
51 expect(4);
52
53 var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
54
55 drag(handle, 0, 80);
56 equals( target.width(), 130, "compare maxWidth");
57 equals( target.height(), 130, "compare maxHeight");
58
59 drag(handle, 0, -80);
60 equals( target.width(), 70, "compare minWidth");
61 equals( target.height(), 70, "compare minHeight");
62});
63
64test("aspectRatio: 'preserve' (se)", function() {
65 expect(4);
66
67 var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
68
69 drag(handle, 80, 80);
70 equals( target.width(), 130, "compare maxWidth");
71 equals( target.height(), 130, "compare maxHeight");
72
73 drag(handle, -80, -80);
74 equals( target.width(), 70, "compare minWidth");
75 equals( target.height(), 70, "compare minHeight");
76});
77
78test("aspectRatio: 'preserve' (sw)", function() {
79 expect(4);
80
81 var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
82
83 drag(handle, -80, 80);
84 equals( target.width(), 130, "compare maxWidth");
85 equals( target.height(), 130, "compare maxHeight");
86
87 drag(handle, 80, -80);
88 equals( target.width(), 70, "compare minWidth");
89 equals( target.height(), 70, "compare minHeight");
90});
91
92test("aspectRatio: 'preserve' (ne)", function() {
93 expect(4);
94
95 var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ aspectRatio: 'preserve', handles: 'all', minWidth: 70, minHeight: 50, maxWidth: 150, maxHeight: 130 });
96
97 drag(handle, 80, -80);
98 equals( target.width(), 130, "compare maxWidth");
99 equals( target.height(), 130, "compare maxHeight");
100
101 drag(handle, -80, 80);
102 equals( target.width(), 70, "compare minWidth");
103 equals( target.height(), 70, "compare minHeight");
104});
105
106test("grid", function() {
107 expect(4);
108
109 var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', grid: [0, 20] });
110
111 drag(handle, 3, 9);
112 equals( target.width(), 103, "compare width");
113 equals( target.height(), 100, "compare height");
114
115 drag(handle, 15, 11);
116 equals( target.width(), 118, "compare width");
117 equals( target.height(), 120, "compare height");
118});
119
120test("grid (wrapped)", function() {
121 expect(4);
122
123 var handle = '.ui-resizable-se', target = $('#resizable2').resizable({ handles: 'all', grid: [0, 20] });
124
125 drag(handle, 3, 9);
126 equals( target.width(), 103, "compare width");
127 equals( target.height(), 100, "compare height");
128
129 drag(handle, 15, 11);
130 equals( target.width(), 118, "compare width");
131 equals( target.height(), 120, "compare height");
132});
133
134test("ui-resizable-se { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
135 expect(4);
136
137 var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
138
139 drag(handle, -50, -50);
140 equals( target.width(), 60, "compare minWidth" );
141 equals( target.height(), 60, "compare minHeight" );
142
143 drag(handle, 70, 70);
144 equals( target.width(), 100, "compare maxWidth" );
145 equals( target.height(), 100, "compare maxHeight" );
146});
147
148test("ui-resizable-sw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
149 expect(4);
150
151 var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
152
153 drag(handle, 50, -50);
154 equals( target.width(), 60, "compare minWidth" );
155 equals( target.height(), 60, "compare minHeight" );
156
157 drag(handle, -70, 70);
158 equals( target.width(), 100, "compare maxWidth" );
159 equals( target.height(), 100, "compare maxHeight" );
160});
161
162test("ui-resizable-ne { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
163 expect(4);
164
165 var handle = '.ui-resizable-ne', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
166
167 drag(handle, -50, 50);
168 equals( target.width(), 60, "compare minWidth" );
169 equals( target.height(), 60, "compare minHeight" );
170
171 drag(handle, 70, -70);
172 equals( target.width(), 100, "compare maxWidth" );
173 equals( target.height(), 100, "compare maxHeight" );
174});
175
176test("ui-resizable-nw { handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 }", function() {
177 expect(4);
178
179 var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all', minWidth: 60, minHeight: 60, maxWidth: 100, maxHeight: 100 });
180
181 drag(handle, 70, 70);
182 equals( target.width(), 60, "compare minWidth" );
183 equals( target.height(), 60, "compare minHeight" );
184
185 drag(handle, -70, -70);
186 equals( target.width(), 100, "compare maxWidth" );
187 equals( target.height(), 100, "compare maxHeight" );
188});
189
190})(jQuery);
Note: See TracBrowser for help on using the repository browser.