1 | /*
|
---|
2 | * resizable_core.js
|
---|
3 | */
|
---|
4 |
|
---|
5 | var el;
|
---|
6 |
|
---|
7 | var drag = function(el, dx, dy, complete) {
|
---|
8 |
|
---|
9 | // speed = sync -> Drag syncrhonously.
|
---|
10 | // speed = fast|slow -> Drag asyncrhonously - animated.
|
---|
11 |
|
---|
12 | //this mouseover is to work around a limitation in resizable
|
---|
13 | //TODO: fix resizable so handle doesn't require mouseover in order to be used
|
---|
14 | $(el).simulate("mouseover");
|
---|
15 |
|
---|
16 | return $(el).simulate("drag", {
|
---|
17 | dx: dx||0, dy: dy||0, speed: 'sync', complete: complete
|
---|
18 | });
|
---|
19 | };
|
---|
20 |
|
---|
21 | (function($) {
|
---|
22 |
|
---|
23 | module("resizable: core");
|
---|
24 |
|
---|
25 | /*
|
---|
26 | test("element types", function() {
|
---|
27 | var typeNames = ('p,h1,h2,h3,h4,h5,h6,blockquote,ol,ul,dl,div,form'
|
---|
28 | + ',table,fieldset,address,ins,del,em,strong,q,cite,dfn,abbr'
|
---|
29 | + ',acronym,code,samp,kbd,var,img,object,hr'
|
---|
30 | + ',input,button,label,select,iframe').split(',');
|
---|
31 |
|
---|
32 | $.each(typeNames, function(i) {
|
---|
33 | var typeName = typeNames[i];
|
---|
34 | el = $(document.createElement(typeName)).appendTo('body');
|
---|
35 | (typeName == 'table' && el.append("<tr><td>content</td></tr>"));
|
---|
36 | el.resizable();
|
---|
37 | ok(true, '$("<' + typeName + '/>").resizable()');
|
---|
38 | el.resizable("destroy");
|
---|
39 | el.remove();
|
---|
40 | });
|
---|
41 | });
|
---|
42 | */
|
---|
43 |
|
---|
44 | test("n", function() {
|
---|
45 | expect(2);
|
---|
46 |
|
---|
47 | var handle = '.ui-resizable-n', target = $('#resizable1').resizable({ handles: 'all' });
|
---|
48 |
|
---|
49 | drag(handle, 0, -50);
|
---|
50 | equals( target.height(), 150, "compare height" );
|
---|
51 |
|
---|
52 | drag(handle, 0, 50);
|
---|
53 | equals( target.height(), 100, "compare height" );
|
---|
54 | });
|
---|
55 |
|
---|
56 | test("s", function() {
|
---|
57 | expect(2);
|
---|
58 |
|
---|
59 | var handle = '.ui-resizable-s', target = $('#resizable1').resizable({ handles: 'all' });
|
---|
60 |
|
---|
61 | drag(handle, 0, 50);
|
---|
62 | equals( target.height(), 150, "compare height" );
|
---|
63 |
|
---|
64 | drag(handle, 0, -50);
|
---|
65 | equals( target.height(), 100, "compare height" );
|
---|
66 | });
|
---|
67 |
|
---|
68 | test("e", function() {
|
---|
69 | expect(2);
|
---|
70 |
|
---|
71 | var handle = '.ui-resizable-e', target = $('#resizable1').resizable({ handles: 'all' });
|
---|
72 |
|
---|
73 | drag(handle, 50);
|
---|
74 | equals( target.width(), 150, "compare width");
|
---|
75 |
|
---|
76 | drag(handle, -50);
|
---|
77 | equals( target.width(), 100, "compare width" );
|
---|
78 | });
|
---|
79 |
|
---|
80 | test("w", function() {
|
---|
81 | expect(2);
|
---|
82 |
|
---|
83 | var handle = '.ui-resizable-w', target = $('#resizable1').resizable({ handles: 'all' });
|
---|
84 |
|
---|
85 | drag(handle, -50);
|
---|
86 | equals( target.width(), 150, "compare width" );
|
---|
87 |
|
---|
88 | drag(handle, 50);
|
---|
89 | equals( target.width(), 100, "compare width" );
|
---|
90 | });
|
---|
91 |
|
---|
92 | test("ne", function() {
|
---|
93 | expect(4);
|
---|
94 |
|
---|
95 | var handle = '.ui-resizable-ne', target = $('#resizable1').css({ overflow: 'hidden' }).resizable({ handles: 'all' });
|
---|
96 |
|
---|
97 | drag(handle, -50, -50);
|
---|
98 | equals( target.width(), 50, "compare width" );
|
---|
99 | equals( target.height(), 150, "compare height" );
|
---|
100 |
|
---|
101 | drag(handle, 50, 50);
|
---|
102 | equals( target.width(), 100, "compare width" );
|
---|
103 | equals( target.height(), 100, "compare height" );
|
---|
104 | });
|
---|
105 |
|
---|
106 | test("se", function() {
|
---|
107 | expect(4);
|
---|
108 |
|
---|
109 | var handle = '.ui-resizable-se', target = $('#resizable1').resizable({ handles: 'all' });
|
---|
110 |
|
---|
111 | drag(handle, 50, 50);
|
---|
112 | equals( target.width(), 150, "compare width" );
|
---|
113 | equals( target.height(), 150, "compare height" );
|
---|
114 |
|
---|
115 | drag(handle, -50, -50);
|
---|
116 | equals( target.width(), 100, "compare width" );
|
---|
117 | equals( target.height(), 100, "compare height" );
|
---|
118 | });
|
---|
119 |
|
---|
120 | test("sw", function() {
|
---|
121 | expect(4);
|
---|
122 |
|
---|
123 | var handle = '.ui-resizable-sw', target = $('#resizable1').resizable({ handles: 'all' });
|
---|
124 |
|
---|
125 | drag(handle, -50, -50);
|
---|
126 | equals( target.width(), 150, "compare width" );
|
---|
127 | equals( target.height(), 50, "compare height" );
|
---|
128 |
|
---|
129 | drag(handle, 50, 50);
|
---|
130 | equals( target.width(), 100, "compare width" );
|
---|
131 | equals( target.height(), 100, "compare height" );
|
---|
132 | });
|
---|
133 |
|
---|
134 | test("nw", function() {
|
---|
135 | expect(4);
|
---|
136 |
|
---|
137 | var handle = '.ui-resizable-nw', target = $('#resizable1').resizable({ handles: 'all' });
|
---|
138 |
|
---|
139 | drag(handle, -50, -50);
|
---|
140 | equals( target.width(), 150, "compare width" );
|
---|
141 | equals( target.height(), 150, "compare height" );
|
---|
142 |
|
---|
143 | drag(handle, 50, 50);
|
---|
144 | equals( target.width(), 100, "compare width" );
|
---|
145 | equals( target.height(), 100, "compare height" );
|
---|
146 | });
|
---|
147 |
|
---|
148 | })(jQuery);
|
---|