smparkes-envjs 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/bin/envjsrb +157 -73
  2. data/bin/jquery-1.3.2-test.js +11 -4
  3. data/lib/envjs/env.js +935 -11028
  4. data/lib/envjs/net/cgi.rb +94 -0
  5. data/lib/envjs/net/file.rb +4 -4
  6. data/lib/envjs/runtime.rb +80 -24
  7. data/test/call-load-test.js +0 -2
  8. data/test/firebug/errorIcon.png +0 -0
  9. data/test/firebug/firebug.css +209 -0
  10. data/test/firebug/firebug.html +23 -0
  11. data/test/firebug/firebug.js +672 -0
  12. data/test/firebug/firebugx.js +10 -0
  13. data/test/firebug/infoIcon.png +0 -0
  14. data/test/firebug/warningIcon.png +0 -0
  15. data/test/fixtures/html/events.html +171 -0
  16. data/test/fixtures/html/iframe1.html +46 -0
  17. data/test/fixtures/html/iframe1a.html +46 -0
  18. data/test/fixtures/html/iframe2.html +45 -0
  19. data/test/fixtures/html/iframe3.html +28 -0
  20. data/test/fixtures/html/iframeN.html +57 -0
  21. data/test/fixtures/html/malformed.html +181 -0
  22. data/test/fixtures/html/scope.html +81 -0
  23. data/test/fixtures/html/trivial.html +19 -0
  24. data/test/fixtures/html/with_js.html +26 -0
  25. data/test/fixtures/images/icon-blue.png +0 -0
  26. data/test/fixtures/js/external_script.js +1 -0
  27. data/test/fixtures/js/script.js +1 -0
  28. data/test/fixtures/js/script_error.js +2 -0
  29. data/test/html/malformed.html +1 -0
  30. data/test/index.html +21 -19
  31. data/test/{primaryTests.js → primary-tests.js} +1 -3
  32. data/test/{prototype.js → prototype-test.js} +0 -2
  33. data/test/qunit/qunit/qunit.css +0 -0
  34. data/test/qunit/qunit/qunit.js +2 -2
  35. data/test/{qunit/qunit/qunit.js.smp → specs/dist/env.spec.js} +539 -7
  36. data/test/specs/envjs.spec.css +46 -0
  37. data/test/specs/parser/html.js +31 -0
  38. data/test/specs/parser/spec.html +40 -0
  39. data/test/specs/parser/xml.js +31 -0
  40. data/test/specs/qunit.bdd.js +210 -0
  41. data/test/{qunit.smp/qunit → specs}/qunit.css +0 -0
  42. data/test/{qunit.smp/qunit → specs}/qunit.js +2 -2
  43. data/test/specs/template/spec-0.js +31 -0
  44. data/test/specs/template/spec-1.js +31 -0
  45. data/test/specs/template/spec.html +40 -0
  46. data/test/specs/window/css.js +23 -0
  47. data/test/specs/window/dialog.js +25 -0
  48. data/test/specs/window/document.js +23 -0
  49. data/test/specs/window/event.js +25 -0
  50. data/test/specs/window/history.js +34 -0
  51. data/test/specs/window/location.js +34 -0
  52. data/test/specs/window/navigator.js +71 -0
  53. data/test/specs/window/screen.js +42 -0
  54. data/test/specs/window/spec.html +48 -0
  55. data/test/specs/window/timer.js +26 -0
  56. data/test/specs/window/window.js +53 -0
  57. data/test/specs/xhr/spec.html +47 -0
  58. data/test/specs/xhr/xhr.js +31 -0
  59. data/test/test.js +10 -0
  60. data/test/unit/elementmembers.js +31 -0
  61. data/test/unit/nu.validator.js +34 -0
  62. data/test/unit/onload.js +1 -3
  63. data/test/unit/parser.js +106 -98
  64. data/test/unit/prototypecompat.js +2 -2
  65. data/test/vendor/jQuery/1.3.2/ChangeLog.txt +98 -0
  66. data/test/vendor/jQuery/1.3.2/GPL-LICENSE.txt +278 -0
  67. data/test/vendor/jQuery/1.3.2/MIT-LICENSE.txt +20 -0
  68. data/test/vendor/jQuery/1.3.2/Makefile +154 -0
  69. data/test/vendor/jQuery/1.3.2/README +67 -0
  70. data/test/vendor/jQuery/1.3.2/build/ant-contrib-0.6.jar +0 -0
  71. data/test/vendor/jQuery/1.3.2/build/build/min.js +11 -0
  72. data/test/vendor/jQuery/1.3.2/build/build/pack.js +19 -0
  73. data/test/vendor/jQuery/1.3.2/build/js/Packer.js +209 -0
  74. data/test/vendor/jQuery/1.3.2/build/js/ParseMaster.js +106 -0
  75. data/test/vendor/jQuery/1.3.2/build/js/Words.js +62 -0
  76. data/test/vendor/jQuery/1.3.2/build/js/base2.js +978 -0
  77. data/test/vendor/jQuery/1.3.2/build/js/jsmin.js +316 -0
  78. data/test/vendor/jQuery/1.3.2/build/js/json.js +117 -0
  79. data/test/vendor/jQuery/1.3.2/build/js/pack.js +316 -0
  80. data/test/vendor/jQuery/1.3.2/build/js/parse.js +105 -0
  81. data/test/vendor/jQuery/1.3.2/build/js/writeFile.js +19 -0
  82. data/test/vendor/jQuery/1.3.2/build/js/xml.js +25 -0
  83. data/test/vendor/jQuery/1.3.2/build/js.jar +0 -0
  84. data/test/vendor/jQuery/1.3.2/build/runtest/env.js +1 -0
  85. data/test/vendor/jQuery/1.3.2/build/runtest/test.js +106 -0
  86. data/test/vendor/jQuery/1.3.2/build/runtest/testrunner.js +197 -0
  87. data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.css +65 -0
  88. data/test/vendor/jQuery/1.3.2/build/speed/benchmarker.js +181 -0
  89. data/test/vendor/jQuery/1.3.2/build/speed/index.html +72 -0
  90. data/test/vendor/jQuery/1.3.2/build/speed/jquery-basis.js +3549 -0
  91. data/test/vendor/jQuery/1.3.2/build/style.xsl +99 -0
  92. data/test/vendor/jQuery/1.3.2/build/yuicompressor-2.4.2.jar +0 -0
  93. data/test/vendor/jQuery/1.3.2/build.xml +123 -0
  94. data/test/vendor/jQuery/1.3.2/dist/jquery.js +4376 -0
  95. data/test/vendor/jQuery/1.3.2/reminder.txt +3 -0
  96. data/test/vendor/jQuery/1.3.2/src/ajax.js +541 -0
  97. data/test/vendor/jQuery/1.3.2/src/core.js +1255 -0
  98. data/test/vendor/jQuery/1.3.2/src/data.js +145 -0
  99. data/test/vendor/jQuery/1.3.2/src/dimensions.js +49 -0
  100. data/test/vendor/jQuery/1.3.2/src/event.js +684 -0
  101. data/test/vendor/jQuery/1.3.2/src/fx.js +407 -0
  102. data/test/vendor/jQuery/1.3.2/src/intro.js +13 -0
  103. data/test/vendor/jQuery/1.3.2/src/offset.js +155 -0
  104. data/test/vendor/jQuery/1.3.2/src/outro.js +1 -0
  105. data/test/vendor/jQuery/1.3.2/src/selector.js +1015 -0
  106. data/test/vendor/jQuery/1.3.2/src/support.js +112 -0
  107. data/test/vendor/jQuery/1.3.2/test/data/cow.jpg +0 -0
  108. data/test/vendor/jQuery/1.3.2/test/data/dashboard.xml +11 -0
  109. data/test/vendor/jQuery/1.3.2/test/data/echoQuery.php +1 -0
  110. data/test/vendor/jQuery/1.3.2/test/data/iframe.html +8 -0
  111. data/test/vendor/jQuery/1.3.2/test/data/json.php +9 -0
  112. data/test/vendor/jQuery/1.3.2/test/data/json_assigned_obj.js +1 -0
  113. data/test/vendor/jQuery/1.3.2/test/data/json_obj.js +1 -0
  114. data/test/vendor/jQuery/1.3.2/test/data/jsonp.php +10 -0
  115. data/test/vendor/jQuery/1.3.2/test/data/name.html +1 -0
  116. data/test/vendor/jQuery/1.3.2/test/data/name.php +29 -0
  117. data/test/vendor/jQuery/1.3.2/test/data/offset/absolute.html +39 -0
  118. data/test/vendor/jQuery/1.3.2/test/data/offset/body.html +24 -0
  119. data/test/vendor/jQuery/1.3.2/test/data/offset/fixed.html +33 -0
  120. data/test/vendor/jQuery/1.3.2/test/data/offset/relative.html +31 -0
  121. data/test/vendor/jQuery/1.3.2/test/data/offset/scroll.html +39 -0
  122. data/test/vendor/jQuery/1.3.2/test/data/offset/static.html +31 -0
  123. data/test/vendor/jQuery/1.3.2/test/data/offset/table.html +43 -0
  124. data/test/vendor/jQuery/1.3.2/test/data/params_html.php +12 -0
  125. data/test/vendor/jQuery/1.3.2/test/data/test.html +7 -0
  126. data/test/vendor/jQuery/1.3.2/test/data/test.js +3 -0
  127. data/test/vendor/jQuery/1.3.2/test/data/test.php +7 -0
  128. data/test/vendor/jQuery/1.3.2/test/data/test2.html +5 -0
  129. data/test/vendor/jQuery/1.3.2/test/data/test3.html +3 -0
  130. data/test/vendor/jQuery/1.3.2/test/data/testrunner.js +1 -0
  131. data/test/vendor/jQuery/1.3.2/test/data/text.php +12 -0
  132. data/test/vendor/jQuery/1.3.2/test/data/with_fries.xml +25 -0
  133. data/test/vendor/jQuery/1.3.2/test/index.html +229 -0
  134. data/test/vendor/jQuery/1.3.2/test/jqenv-1259090275493.html +247 -0
  135. data/test/vendor/jQuery/1.3.2/test/jqenv-1259091671501.html +247 -0
  136. data/test/vendor/jQuery/1.3.2/test/jqenv-1259175319655.html +247 -0
  137. data/test/vendor/jQuery/1.3.2/test/offset.html +28 -0
  138. data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.1/jquery.js +11 -0
  139. data/test/vendor/jQuery/1.3.2/test/otherlibs/jquery/1.2.3/jquery.js +11 -0
  140. data/test/vendor/jQuery/1.3.2/test/otherlibs/mootools/1.11/mootools.js +1577 -0
  141. data/test/vendor/jQuery/1.3.2/test/otherlibs/prototype/1.6.0.2/prototype.js +4221 -0
  142. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/builder.js +131 -0
  143. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/controls.js +835 -0
  144. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/dragdrop.js +944 -0
  145. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/effects.js +1090 -0
  146. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/scriptaculous.js +51 -0
  147. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/slider.js +278 -0
  148. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.7.0/unittest.js +564 -0
  149. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/builder.js +136 -0
  150. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/controls.js +965 -0
  151. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/dragdrop.js +974 -0
  152. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/effects.js +1122 -0
  153. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/scriptaculous.js +58 -0
  154. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/slider.js +275 -0
  155. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/sound.js +55 -0
  156. data/test/vendor/jQuery/1.3.2/test/otherlibs/scriptaculous/1.8.1/unittest.js +568 -0
  157. data/test/vendor/jQuery/1.3.2/test/polluted.php +64 -0
  158. data/test/vendor/jQuery/1.3.2/test/qunit/testrunner.js +780 -0
  159. data/test/vendor/jQuery/1.3.2/test/qunit/testsuite.css +120 -0
  160. data/test/vendor/jQuery/1.3.2/test/test.js +41 -0
  161. data/test/vendor/jQuery/1.3.2/test/unit/ajax.js +856 -0
  162. data/test/vendor/jQuery/1.3.2/test/unit/core.js +1872 -0
  163. data/test/vendor/jQuery/1.3.2/test/unit/data.js +160 -0
  164. data/test/vendor/jQuery/1.3.2/test/unit/dimensions.js +86 -0
  165. data/test/vendor/jQuery/1.3.2/test/unit/event.js +670 -0
  166. data/test/vendor/jQuery/1.3.2/test/unit/fx.js +451 -0
  167. data/test/vendor/jQuery/1.3.2/test/unit/offset.js +173 -0
  168. data/test/vendor/jQuery/1.3.2/test/unit/selector.js +395 -0
  169. data/test/vendor/jQuery/1.3.2/test/xhtml.php +5 -0
  170. data/test/vendor/jQuery/1.3.2/version.txt +1 -0
  171. metadata +158 -22
  172. data/lib/envjs/runtime.rb.smp +0 -133
  173. data/test/envjs-call-load-test.js +0 -5
  174. data/test/envjs-prototype.js +0 -5
  175. data/test/qunit/package.json +0 -21
  176. data/test/qunit/test/index.html +0 -17
  177. data/test/qunit/test/same.js +0 -1368
  178. data/test/qunit/test/test.js +0 -136
  179. data/test/qunit.smp/package.json +0 -21
  180. data/test/qunit.smp/test/index.html +0 -17
  181. data/test/qunit.smp/test/same.js +0 -1368
  182. data/test/qunit.smp/test/test.js +0 -136
  183. data/test/rhino-call-load-test.js +0 -5
  184. data/test/rhino-prototype.js +0 -5
  185. data/test/test-with-envs-jar.js +0 -8
  186. data/test/test-with-rhino-jar.js +0 -9
@@ -0,0 +1,51 @@
1
+ // script.aculo.us scriptaculous.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
2
+
3
+ // Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
4
+ //
5
+ // Permission is hereby granted, free of charge, to any person obtaining
6
+ // a copy of this software and associated documentation files (the
7
+ // "Software"), to deal in the Software without restriction, including
8
+ // without limitation the rights to use, copy, modify, merge, publish,
9
+ // distribute, sublicense, and/or sell copies of the Software, and to
10
+ // permit persons to whom the Software is furnished to do so, subject to
11
+ // the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be
14
+ // included in all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+ //
24
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
25
+
26
+ var Scriptaculous = {
27
+ Version: '1.7.0',
28
+ require: function(libraryName) {
29
+ // inserting via DOM fails in Safari 2.0, so brute force approach
30
+ document.write('<script type="text/javascript" src="'+libraryName+'"></script>');
31
+ },
32
+ load: function() {
33
+ if((typeof Prototype=='undefined') ||
34
+ (typeof Element == 'undefined') ||
35
+ (typeof Element.Methods=='undefined') ||
36
+ parseFloat(Prototype.Version.split(".")[0] + "." +
37
+ Prototype.Version.split(".")[1]) < 1.5)
38
+ throw("script.aculo.us requires the Prototype JavaScript framework >= 1.5.0");
39
+
40
+ $A(document.getElementsByTagName("script")).findAll( function(s) {
41
+ return (s.src && s.src.match(/scriptaculous\.js(\?.*)?$/))
42
+ }).each( function(s) {
43
+ var path = s.src.replace(/scriptaculous\.js(\?.*)?$/,'');
44
+ var includes = s.src.match(/\?.*load=([a-z,]*)/);
45
+ (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider').split(',').each(
46
+ function(include) { Scriptaculous.require(path+include+'.js') });
47
+ });
48
+ }
49
+ }
50
+
51
+ Scriptaculous.load();
@@ -0,0 +1,278 @@
1
+ // script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007
2
+
3
+ // Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs
4
+ //
5
+ // script.aculo.us is freely distributable under the terms of an MIT-style license.
6
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
7
+
8
+ if(!Control) var Control = {};
9
+ Control.Slider = Class.create();
10
+
11
+ // options:
12
+ // axis: 'vertical', or 'horizontal' (default)
13
+ //
14
+ // callbacks:
15
+ // onChange(value)
16
+ // onSlide(value)
17
+ Control.Slider.prototype = {
18
+ initialize: function(handle, track, options) {
19
+ var slider = this;
20
+
21
+ if(handle instanceof Array) {
22
+ this.handles = handle.collect( function(e) { return $(e) });
23
+ } else {
24
+ this.handles = [$(handle)];
25
+ }
26
+
27
+ this.track = $(track);
28
+ this.options = options || {};
29
+
30
+ this.axis = this.options.axis || 'horizontal';
31
+ this.increment = this.options.increment || 1;
32
+ this.step = parseInt(this.options.step || '1');
33
+ this.range = this.options.range || $R(0,1);
34
+
35
+ this.value = 0; // assure backwards compat
36
+ this.values = this.handles.map( function() { return 0 });
37
+ this.spans = this.options.spans ? this.options.spans.map(function(s){ return $(s) }) : false;
38
+ this.options.startSpan = $(this.options.startSpan || null);
39
+ this.options.endSpan = $(this.options.endSpan || null);
40
+
41
+ this.restricted = this.options.restricted || false;
42
+
43
+ this.maximum = this.options.maximum || this.range.end;
44
+ this.minimum = this.options.minimum || this.range.start;
45
+
46
+ // Will be used to align the handle onto the track, if necessary
47
+ this.alignX = parseInt(this.options.alignX || '0');
48
+ this.alignY = parseInt(this.options.alignY || '0');
49
+
50
+ this.trackLength = this.maximumOffset() - this.minimumOffset();
51
+
52
+ this.handleLength = this.isVertical() ?
53
+ (this.handles[0].offsetHeight != 0 ?
54
+ this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :
55
+ (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :
56
+ this.handles[0].style.width.replace(/px$/,""));
57
+
58
+ this.active = false;
59
+ this.dragging = false;
60
+ this.disabled = false;
61
+
62
+ if(this.options.disabled) this.setDisabled();
63
+
64
+ // Allowed values array
65
+ this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;
66
+ if(this.allowedValues) {
67
+ this.minimum = this.allowedValues.min();
68
+ this.maximum = this.allowedValues.max();
69
+ }
70
+
71
+ this.eventMouseDown = this.startDrag.bindAsEventListener(this);
72
+ this.eventMouseUp = this.endDrag.bindAsEventListener(this);
73
+ this.eventMouseMove = this.update.bindAsEventListener(this);
74
+
75
+ // Initialize handles in reverse (make sure first handle is active)
76
+ this.handles.each( function(h,i) {
77
+ i = slider.handles.length-1-i;
78
+ slider.setValue(parseFloat(
79
+ (slider.options.sliderValue instanceof Array ?
80
+ slider.options.sliderValue[i] : slider.options.sliderValue) ||
81
+ slider.range.start), i);
82
+ Element.makePositioned(h); // fix IE
83
+ Event.observe(h, "mousedown", slider.eventMouseDown);
84
+ });
85
+
86
+ Event.observe(this.track, "mousedown", this.eventMouseDown);
87
+ Event.observe(document, "mouseup", this.eventMouseUp);
88
+ Event.observe(document, "mousemove", this.eventMouseMove);
89
+
90
+ this.initialized = true;
91
+ },
92
+ dispose: function() {
93
+ var slider = this;
94
+ Event.stopObserving(this.track, "mousedown", this.eventMouseDown);
95
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
96
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
97
+ this.handles.each( function(h) {
98
+ Event.stopObserving(h, "mousedown", slider.eventMouseDown);
99
+ });
100
+ },
101
+ setDisabled: function(){
102
+ this.disabled = true;
103
+ },
104
+ setEnabled: function(){
105
+ this.disabled = false;
106
+ },
107
+ getNearestValue: function(value){
108
+ if(this.allowedValues){
109
+ if(value >= this.allowedValues.max()) return(this.allowedValues.max());
110
+ if(value <= this.allowedValues.min()) return(this.allowedValues.min());
111
+
112
+ var offset = Math.abs(this.allowedValues[0] - value);
113
+ var newValue = this.allowedValues[0];
114
+ this.allowedValues.each( function(v) {
115
+ var currentOffset = Math.abs(v - value);
116
+ if(currentOffset <= offset){
117
+ newValue = v;
118
+ offset = currentOffset;
119
+ }
120
+ });
121
+ return newValue;
122
+ }
123
+ if(value > this.range.end) return this.range.end;
124
+ if(value < this.range.start) return this.range.start;
125
+ return value;
126
+ },
127
+ setValue: function(sliderValue, handleIdx){
128
+ if(!this.active) {
129
+ this.activeHandleIdx = handleIdx || 0;
130
+ this.activeHandle = this.handles[this.activeHandleIdx];
131
+ this.updateStyles();
132
+ }
133
+ handleIdx = handleIdx || this.activeHandleIdx || 0;
134
+ if(this.initialized && this.restricted) {
135
+ if((handleIdx>0) && (sliderValue<this.values[handleIdx-1]))
136
+ sliderValue = this.values[handleIdx-1];
137
+ if((handleIdx < (this.handles.length-1)) && (sliderValue>this.values[handleIdx+1]))
138
+ sliderValue = this.values[handleIdx+1];
139
+ }
140
+ sliderValue = this.getNearestValue(sliderValue);
141
+ this.values[handleIdx] = sliderValue;
142
+ this.value = this.values[0]; // assure backwards compat
143
+
144
+ this.handles[handleIdx].style[this.isVertical() ? 'top' : 'left'] =
145
+ this.translateToPx(sliderValue);
146
+
147
+ this.drawSpans();
148
+ if(!this.dragging || !this.event) this.updateFinished();
149
+ },
150
+ setValueBy: function(delta, handleIdx) {
151
+ this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta,
152
+ handleIdx || this.activeHandleIdx || 0);
153
+ },
154
+ translateToPx: function(value) {
155
+ return Math.round(
156
+ ((this.trackLength-this.handleLength)/(this.range.end-this.range.start)) *
157
+ (value - this.range.start)) + "px";
158
+ },
159
+ translateToValue: function(offset) {
160
+ return ((offset/(this.trackLength-this.handleLength) *
161
+ (this.range.end-this.range.start)) + this.range.start);
162
+ },
163
+ getRange: function(range) {
164
+ var v = this.values.sortBy(Prototype.K);
165
+ range = range || 0;
166
+ return $R(v[range],v[range+1]);
167
+ },
168
+ minimumOffset: function(){
169
+ return(this.isVertical() ? this.alignY : this.alignX);
170
+ },
171
+ maximumOffset: function(){
172
+ return(this.isVertical() ?
173
+ (this.track.offsetHeight != 0 ? this.track.offsetHeight :
174
+ this.track.style.height.replace(/px$/,"")) - this.alignY :
175
+ (this.track.offsetWidth != 0 ? this.track.offsetWidth :
176
+ this.track.style.width.replace(/px$/,"")) - this.alignY);
177
+ },
178
+ isVertical: function(){
179
+ return (this.axis == 'vertical');
180
+ },
181
+ drawSpans: function() {
182
+ var slider = this;
183
+ if(this.spans)
184
+ $R(0, this.spans.length-1).each(function(r) { slider.setSpan(slider.spans[r], slider.getRange(r)) });
185
+ if(this.options.startSpan)
186
+ this.setSpan(this.options.startSpan,
187
+ $R(0, this.values.length>1 ? this.getRange(0).min() : this.value ));
188
+ if(this.options.endSpan)
189
+ this.setSpan(this.options.endSpan,
190
+ $R(this.values.length>1 ? this.getRange(this.spans.length-1).max() : this.value, this.maximum));
191
+ },
192
+ setSpan: function(span, range) {
193
+ if(this.isVertical()) {
194
+ span.style.top = this.translateToPx(range.start);
195
+ span.style.height = this.translateToPx(range.end - range.start + this.range.start);
196
+ } else {
197
+ span.style.left = this.translateToPx(range.start);
198
+ span.style.width = this.translateToPx(range.end - range.start + this.range.start);
199
+ }
200
+ },
201
+ updateStyles: function() {
202
+ this.handles.each( function(h){ Element.removeClassName(h, 'selected') });
203
+ Element.addClassName(this.activeHandle, 'selected');
204
+ },
205
+ startDrag: function(event) {
206
+ if(Event.isLeftClick(event)) {
207
+ if(!this.disabled){
208
+ this.active = true;
209
+
210
+ var handle = Event.element(event);
211
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
212
+ var track = handle;
213
+ if(track==this.track) {
214
+ var offsets = Position.cumulativeOffset(this.track);
215
+ this.event = event;
216
+ this.setValue(this.translateToValue(
217
+ (this.isVertical() ? pointer[1]-offsets[1] : pointer[0]-offsets[0])-(this.handleLength/2)
218
+ ));
219
+ var offsets = Position.cumulativeOffset(this.activeHandle);
220
+ this.offsetX = (pointer[0] - offsets[0]);
221
+ this.offsetY = (pointer[1] - offsets[1]);
222
+ } else {
223
+ // find the handle (prevents issues with Safari)
224
+ while((this.handles.indexOf(handle) == -1) && handle.parentNode)
225
+ handle = handle.parentNode;
226
+
227
+ if(this.handles.indexOf(handle)!=-1) {
228
+ this.activeHandle = handle;
229
+ this.activeHandleIdx = this.handles.indexOf(this.activeHandle);
230
+ this.updateStyles();
231
+
232
+ var offsets = Position.cumulativeOffset(this.activeHandle);
233
+ this.offsetX = (pointer[0] - offsets[0]);
234
+ this.offsetY = (pointer[1] - offsets[1]);
235
+ }
236
+ }
237
+ }
238
+ Event.stop(event);
239
+ }
240
+ },
241
+ update: function(event) {
242
+ if(this.active) {
243
+ if(!this.dragging) this.dragging = true;
244
+ this.draw(event);
245
+ // fix AppleWebKit rendering
246
+ if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
247
+ Event.stop(event);
248
+ }
249
+ },
250
+ draw: function(event) {
251
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
252
+ var offsets = Position.cumulativeOffset(this.track);
253
+ pointer[0] -= this.offsetX + offsets[0];
254
+ pointer[1] -= this.offsetY + offsets[1];
255
+ this.event = event;
256
+ this.setValue(this.translateToValue( this.isVertical() ? pointer[1] : pointer[0] ));
257
+ if(this.initialized && this.options.onSlide)
258
+ this.options.onSlide(this.values.length>1 ? this.values : this.value, this);
259
+ },
260
+ endDrag: function(event) {
261
+ if(this.active && this.dragging) {
262
+ this.finishDrag(event, true);
263
+ Event.stop(event);
264
+ }
265
+ this.active = false;
266
+ this.dragging = false;
267
+ },
268
+ finishDrag: function(event, success) {
269
+ this.active = false;
270
+ this.dragging = false;
271
+ this.updateFinished();
272
+ },
273
+ updateFinished: function() {
274
+ if(this.initialized && this.options.onChange)
275
+ this.options.onChange(this.values.length>1 ? this.values : this.value, this);
276
+ this.event = null;
277
+ }
278
+ }