221 lines
7.1 KiB
HTML
221 lines
7.1 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>Yahoo! UI Library - Slider Widget</title>
|
|
<link rel="stylesheet" type="text/css" href="css/screen.css"></link>
|
|
|
|
<!-- Nav and logger start -->
|
|
|
|
<script type="text/javascript" src="../../build/yahoo/yahoo-min.js" ></script>
|
|
<script type="text/javascript" src="../../build/event/event-min.js" ></script>
|
|
<script type="text/javascript" src="../../build/dom/dom-min.js" ></script>
|
|
<script type="text/javascript" src="../../build/logger/logger-min.js" ></script>
|
|
<script type="text/javascript" src="../../build/dragdrop/dragdrop-min.js" ></script>
|
|
|
|
<script type="text/javascript" src="../../build/animation/animation-min.js" ></script>
|
|
<script type="text/javascript" src="js/color.js" ></script>
|
|
<script type="text/javascript" src="js/key.js" ></script>
|
|
|
|
<script type="text/javascript" src="../../build/slider/slider-debug.js" ></script></head>
|
|
<body>
|
|
<div id="pageTitle"><h3>Slider Widget</h3></div>
|
|
|
|
<div id="container">
|
|
<div id="containerTop">
|
|
<div id="header"><img id="ylogo" src="img/logo.gif" /></div>
|
|
<div id="main">
|
|
|
|
<!-- Nav and logger start -->
|
|
|
|
<style type="text/css">
|
|
#logButtonHeader input { font-size: 80% }
|
|
|
|
/* logger default styles */
|
|
/* font size is controlled here: default 77% */
|
|
#yui-log {position:absolute;top:1em;right:1em;font-size:77%;text-align:left;}
|
|
/* width is controlled here: default 31em */
|
|
.yui-log {background-color:#AAA;border:1px solid black;font-family:monospace;z-index:9000;}
|
|
.yui-log p {margin:1px;padding:.1em;}
|
|
.yui-log button {font-family:monospace;}
|
|
.yui-log .yui-log-hd {padding:.5em;background-color:#575757;color:#FFF;}
|
|
/* height is controlled here: default 20em*/
|
|
.yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}
|
|
.yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;}
|
|
.yui-log .yui-log-ft .yui-log-categoryfilters {}
|
|
.yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}
|
|
.yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;}
|
|
.yui-log .yui-log-filtergrp {margin-right:.5em;}
|
|
.yui-log .info {background-color:#A7CC25;} /* A7CC25 green */
|
|
.yui-log .warn {background-color:#F58516;} /* F58516 orange */
|
|
.yui-log .error {background-color:#E32F0B;} /* E32F0B red */
|
|
.yui-log .time {background-color:#A6C9D7;} /* A6C9D7 blue */
|
|
.yui-log .window {background-color:#F2E886;} /* F2E886 tan */
|
|
|
|
|
|
</style>
|
|
|
|
<div id="rightbar">
|
|
<div id="rightBarPad">
|
|
<h3>Links</h3>
|
|
<div id="linkage">
|
|
<ul>
|
|
<li><a href="index.html?mode=dist">Basic Sliders</a></li>
|
|
<li><a href="basic.html?mode=dist">Scale Factor</a></li>
|
|
<li><a href="rgb.html?mode=dist">RGB Slider</a></li>
|
|
<li><a href="rgb2.html?mode=dist">Color Picker</a></li>
|
|
<!--
|
|
<li><a href="dual.html?mode=dist">Dual Thumb Slider</a></li>
|
|
-->
|
|
</ul>
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
//<![CDATA[
|
|
YAHOO.example.logApp = function() {
|
|
return {
|
|
init: function() {
|
|
if (YAHOO.widget.Logger) {
|
|
var reader = new YAHOO.widget.LogReader( "logDiv",
|
|
{ newestOnTop: true, height: "400px" } );
|
|
|
|
reader._onClickPauseBtn(null, reader);
|
|
}
|
|
}
|
|
};
|
|
} ();
|
|
|
|
YAHOO.util.Event.on(window, "load", YAHOO.example.logApp.init);
|
|
//]]>
|
|
</script>
|
|
|
|
<div id="logDiv"></div>
|
|
|
|
</div>
|
|
</div>
|
|
<!-- Nav and logger end -->
|
|
|
|
|
|
<div id="content">
|
|
<div class="newsItem">
|
|
<h3>Slider</h3>
|
|
<p>
|
|
This example uses a scale factor to convert pixels into
|
|
a "real" value.
|
|
</p>
|
|
<p>
|
|
<strong>The logger is paused for performance reasons. Click "Resume" to re-enable it.</strong>
|
|
</p>
|
|
|
|
<div id="vertWrapper">
|
|
<div
|
|
tabindex="-1"
|
|
id="vertBGDiv"
|
|
title="Vertical Slider">
|
|
<div id="vertHandleDiv"><img alt="" src="img/vertSlider.png" /></div>
|
|
</div>
|
|
|
|
<div id="vertValueDiv">
|
|
<form name="formV" id="formV">
|
|
<input autocomplete="off" name="vertVal" id="vertVal" type="text" value="0" size="4" maxlength="4" />
|
|
<input id="vertButton" type="button" value="Update" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<input id="re2" type="button" value="removeTicks" />
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
YAHOO.example.SliderApp = function() {
|
|
var Event = YAHOO.util.Event;
|
|
var Dom = YAHOO.util.Dom;
|
|
var Key = YAHOO.util.Key;
|
|
var slider, bg="vertBGDiv", thumb="vertHandleDiv";
|
|
|
|
// The slider can move 0 pixels up
|
|
var topConstraint = 0;
|
|
|
|
// The slider can move 200 pixels down
|
|
var bottomConstraint = 200;
|
|
|
|
// Custom scale factor for converting the pixel offset into a real value
|
|
var scaleFactor = 1.5;
|
|
|
|
// The amount the slider moves when the value is changed with the arrow
|
|
// keys
|
|
var keyIncrement = 25;
|
|
|
|
return {
|
|
|
|
init: function() {
|
|
|
|
Event.on("formV", "submit", this.updateVert);
|
|
Event.on("vertButton", "click", this.updateVert);
|
|
|
|
slider = YAHOO.widget.Slider.getVertSlider(bg,
|
|
thumb, topConstraint, bottomConstraint, 20);
|
|
|
|
slider.subscribe("change", this.updateUI);
|
|
|
|
slider.subscribe("slideStart", function() {
|
|
YAHOO.log("slideStart fired", "warn");
|
|
});
|
|
|
|
slider.subscribe("slideEnd", function() {
|
|
YAHOO.log("slideEnd fired", "warn");
|
|
});
|
|
|
|
slider.setValue(20);
|
|
|
|
},
|
|
|
|
updateUI: function(offsetFromStart) {
|
|
// use the scale factor to convert the pixel offset into a
|
|
// real value
|
|
var actualValue = parseInt(offsetFromStart * scaleFactor, 10);
|
|
|
|
// update the text box with the actual value
|
|
Dom.get("vertVal").value = actualValue;
|
|
|
|
// update the title attribute on the background
|
|
Dom.get(bg).title =
|
|
"Vertical Slider, value = " + actualValue;
|
|
},
|
|
|
|
updateVert: function() {
|
|
var v = parseFloat(document.forms['formV']['vertVal'].value, 10);
|
|
if ( isNaN(v) ) v = 0;
|
|
|
|
// convert the real value into a pixel offset
|
|
slider.setValue(Math.round(v/scaleFactor));
|
|
return false;
|
|
},
|
|
|
|
clearConstraints: function() {
|
|
slider.getThumb().clearConstraints();
|
|
},
|
|
|
|
clearTicks: function() {
|
|
slider.getThumb().clearTicks();
|
|
}
|
|
|
|
};
|
|
} ();
|
|
|
|
//YAHOO.example.SliderApp.init();
|
|
YAHOO.util.Event.addListener(window, "load", YAHOO.example.SliderApp.init,
|
|
YAHOO.example.SliderApp, true);
|
|
YAHOO.util.Event.addListener("re2", "click", YAHOO.example.SliderApp.clearTicks);
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|