1 | /*
|
---|
2 | * slider_options.js
|
---|
3 | */
|
---|
4 | (function($) {
|
---|
5 |
|
---|
6 | var el, options;
|
---|
7 |
|
---|
8 | function handle() {
|
---|
9 | return el.find(".ui-slider-handle");
|
---|
10 | }
|
---|
11 |
|
---|
12 | module("slider: options");
|
---|
13 |
|
---|
14 | test("animate", function() {
|
---|
15 | ok(false, "missing test - untested code is broken code.");
|
---|
16 | });
|
---|
17 |
|
---|
18 | test("max", function() {
|
---|
19 | el = $('<div></div>');
|
---|
20 |
|
---|
21 | options = {
|
---|
22 | max: 37,
|
---|
23 | min: 6,
|
---|
24 | orientation: 'horizontal',
|
---|
25 | step: 1,
|
---|
26 | value: 50
|
---|
27 | };
|
---|
28 |
|
---|
29 | el.slider(options);
|
---|
30 | ok(el.slider("option", "value") == options.value, "value option is not contained by max");
|
---|
31 | ok(el.slider("value") == options.max, "value method is contained by max");
|
---|
32 | el.slider('destroy');
|
---|
33 |
|
---|
34 | });
|
---|
35 |
|
---|
36 | test("min", function() {
|
---|
37 | el = $('<div></div>');
|
---|
38 |
|
---|
39 | options = {
|
---|
40 | max: 37,
|
---|
41 | min: 6,
|
---|
42 | orientation: 'vertical',
|
---|
43 | step: 1,
|
---|
44 | value: 2
|
---|
45 | };
|
---|
46 |
|
---|
47 | el.slider(options);
|
---|
48 | ok(el.slider("option", "value") == options.value, "value option is not contained by min");
|
---|
49 | ok(el.slider("value") == options.min, "value method is contained by min");
|
---|
50 | el.slider('destroy');
|
---|
51 |
|
---|
52 | });
|
---|
53 |
|
---|
54 | test("orientation", function() {
|
---|
55 | el = $('<div></div>');
|
---|
56 |
|
---|
57 | options = {
|
---|
58 | max: 2,
|
---|
59 | min: -2,
|
---|
60 | orientation: 'vertical',
|
---|
61 | value: 1
|
---|
62 | };
|
---|
63 |
|
---|
64 | var percentVal = (options.value - options.min) / (options.max - options.min) * 100;
|
---|
65 |
|
---|
66 | el.slider(options).slider("option", "orientation", "horizontal");
|
---|
67 | ok(el.is('.ui-slider-horizontal'), "horizontal slider has class .ui-slider-horizontal");
|
---|
68 | ok(!el.is('.ui-slider-vertical'), "horizontal slider does not have class .ui-slider-vertical");
|
---|
69 | equals(handle().css('left'), percentVal + '%', "horizontal slider handle is positioned with left: %");
|
---|
70 |
|
---|
71 | el.slider('destroy');
|
---|
72 |
|
---|
73 | options = {
|
---|
74 | max: 2,
|
---|
75 | min: -2,
|
---|
76 | orientation: 'horizontal',
|
---|
77 | value: -1
|
---|
78 | };
|
---|
79 |
|
---|
80 | var percentVal = (options.value - options.min) / (options.max - options.min) * 100;
|
---|
81 |
|
---|
82 | el.slider(options).slider("option", "orientation", "vertical");
|
---|
83 | ok(el.is('.ui-slider-vertical'), "vertical slider has class .ui-slider-vertical");
|
---|
84 | ok(!el.is('.ui-slider-horizontal'), "vertical slider does not have class .ui-slider-horizontal");
|
---|
85 | equals(handle().css('bottom'), percentVal + '%', "vertical slider handle is positioned with bottom: %");
|
---|
86 |
|
---|
87 | el.slider('destroy');
|
---|
88 |
|
---|
89 | });
|
---|
90 |
|
---|
91 | test("range", function() {
|
---|
92 | ok(false, "missing test - untested code is broken code.");
|
---|
93 | });
|
---|
94 |
|
---|
95 | test("step", function() {
|
---|
96 | ok(false, "missing test - untested code is broken code.");
|
---|
97 | });
|
---|
98 |
|
---|
99 | test("value", function() {
|
---|
100 | ok(false, "missing test - untested code is broken code.");
|
---|
101 | });
|
---|
102 |
|
---|
103 | test("values", function() {
|
---|
104 | ok(false, "missing test - untested code is broken code.");
|
---|
105 | });
|
---|
106 |
|
---|
107 | })(jQuery);
|
---|