forked from madrobby/scriptaculous
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script.aculo.us: Removed Builder code from effects.js, removed Object…
….debug (implemented as Test.Unit.inspect), Added slider unit tests, fixed handling of values to autocalculate min/max, fixed upper/lower boundaries on setting the value programmatically git-svn-id: http://svn.rubyonrails.org/rails/spinoffs/scriptaculous@2704 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
Showing
8 changed files
with
146 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>script.aculo.us Unit test file</title> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<script src="../../lib/prototype.js" type="text/javascript"></script> | ||
<script src="../../src/scriptaculous.js" type="text/javascript"></script> | ||
<script src="../../src/unittest.js" type="text/javascript"></script> | ||
<link rel="stylesheet" href="../test.css" type="text/css" /> | ||
</head> | ||
<body> | ||
<h1>script.aculo.us Unit test file</h1> | ||
<p> | ||
Test of slider.js | ||
</p> | ||
|
||
<div id="track1" style="width:200px;background-color:#aaa;height:5px;"> | ||
<div id="handle1" style="width:5px;height:10px;background-color:#f00;"> </div> | ||
</div> | ||
|
||
<div id="track2-vertical" style="height:100px;background-color:#aaa;width:5px;"> | ||
<div id="handle2-vertical" style="width:10px;height:5px;background-color:#f00;"> </div> | ||
</div> | ||
|
||
<div id="track2-horizontal" style="height:5px;background-color:#aaa;width:300px;"> | ||
<div id="handle2-horizontal" style="width:10px;height:5px;background-color:#f00;"> </div> | ||
</div> | ||
|
||
<!-- Log output --> | ||
<div id="testlog"> </div> | ||
|
||
<!-- Tests follow --> | ||
<script type="text/javascript" language="javascript" charset="utf-8"> | ||
// <![CDATA[ | ||
|
||
var globalValue; | ||
|
||
new Test.Unit.Runner({ | ||
|
||
testSliderBasics: function() { with(this) { | ||
var slider = new Control.Slider('handle1', 'track1'); | ||
assertInstanceOf(Control.Slider, slider); | ||
assertEqual(5, Event.observers.length); | ||
|
||
assertEqual('horizontal', slider.axis); | ||
assertEqual(false, slider.disabled); | ||
assertEqual(0, slider.value); | ||
|
||
slider.dispose(); | ||
}}, | ||
|
||
testSliderValues: function() { with(this) { | ||
['horizontal', 'vertical'].each( function(axis) { | ||
var slider = new Control.Slider('handle2-'+axis, 'track2-'+axis, {values:[10,20,30,40,50],axis:axis}); | ||
assertEqual(axis, slider.axis); | ||
assertEqual(10, slider.value); | ||
|
||
slider.setSliderValue(5); | ||
assertEqual(10, slider.value); | ||
|
||
slider.setSliderValue(22); | ||
assertEqual(20, slider.value); | ||
|
||
slider.setSliderValue(25); | ||
assertEqual(30, slider.value); | ||
|
||
slider.setSliderValue(55555); | ||
assertEqual(50, slider.value); | ||
|
||
// leave active to be able to play around with the sliders | ||
// slider.dispose(); | ||
}); | ||
assertEqual("40px", $('handle2-horizontal').style.left); | ||
assertEqual("40px", $('handle2-vertical').style.top); | ||
}}, | ||
|
||
testSliderOnChange: function() { with(this) { | ||
var slider = new Control.Slider('handle1', 'track1', { onChange:function(v){ globalValue = v; } }); | ||
slider.setSliderValue(100); | ||
assert(100, globalValue); | ||
assert(100, slider.value); | ||
|
||
slider.setDisabled(); | ||
slider.setSliderValue(50); | ||
assert(100, globalValue); | ||
assert(100, slider.value); | ||
|
||
slider.setEnabled(); | ||
slider.setSliderValue(50); | ||
assert(50, globalValue); | ||
assert(50, slider.value); | ||
}} | ||
|
||
}, "testlog"); | ||
// ]]> | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters