fixed the resizable text area with IE problem fixed the ad space with IE problem merged the 7.2.0 and 7.1.4 change logs
1098 lines
47 KiB
HTML
1098 lines
47 KiB
HTML
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>JavaScript Documentation - Slider.js</title>
|
|
|
|
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
|
|
|
|
</head>
|
|
|
|
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="header">
|
|
|
|
<h1>JavaScript Documentation</h1>
|
|
|
|
<h3><a href="./index.html">Slider</a></h3>
|
|
|
|
|
|
|
|
<div class="breadcrumbs">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href="./index.html">Slider</a>
|
|
|
|
>
|
|
|
|
<strong>Slider.js</strong>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="body">
|
|
|
|
|
|
|
|
|
|
|
|
<div class="nav">
|
|
|
|
<div class="module resources">
|
|
|
|
<ul class="content">
|
|
|
|
<li><a href="overview-tree.html">Tree View</a></li>
|
|
|
|
<li><a href="index-all.html">Element Index</a></li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="module">
|
|
|
|
<h4><a href="./allclasses-noframe.html">Classes</a></h4>
|
|
|
|
<ul class="content">
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.html">
|
|
|
|
YAHOO.widget</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.Slider.html">
|
|
|
|
YAHOO.widget.Slider</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="YAHOO.widget.SliderThumb.html">
|
|
|
|
YAHOO.widget.SliderThumb</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="module">
|
|
|
|
<h4><a href="./overview-summary.html">Files</a></h4>
|
|
|
|
<ul class="content">
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<a href="overview-summary-Slider.js.html">
|
|
|
|
Slider.js</a>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="main">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<h2>Slider.js</h2>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="quick-links">
|
|
|
|
<strong>Quick Links:</strong>
|
|
|
|
|
|
|
|
|
|
|
|
<a href="#classSummary">Class Summary</a> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a href="#source">Source Code</a>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="section class summaries">
|
|
|
|
<h3><a name="classSummary">Class Summary</a> <span class="top">[<a href="#top">top</a>]</span></h3>
|
|
|
|
|
|
|
|
<div class="content">
|
|
|
|
<table border="1" cellpadding="3" cellspacing="0">
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="name">
|
|
|
|
<a href="YAHOO.widget.Slider.html">YAHOO.widget.Slider</a>
|
|
|
|
</td>
|
|
|
|
<td class="overview"> </td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="name">
|
|
|
|
<a href="YAHOO.widget.SliderThumb.html">YAHOO.widget.SliderThumb</a>
|
|
|
|
</td>
|
|
|
|
<td class="overview"> </td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="section source">
|
|
|
|
<h3><a name="source">Souce Code</a> <span class="top">[<a href="#top">top</a>]</span></h3>
|
|
|
|
<pre class="sourceview"><span class="comment">/**
|
|
* A DragDrop implementation that can be used as a background for a
|
|
* slider. It takes a reference to the thumb instance
|
|
* so it can delegate some of the events to it. The goal is to make the
|
|
* thumb jump to the location on the background when the background is
|
|
* clicked.
|
|
*
|
|
* <span class="attrib">@extends</span> YAHOO.util.DragDrop
|
|
* <span class="attrib">@constructor</span>
|
|
* <span class="attrib">@param</span> {String} id The id of the element linked to this instance
|
|
* <span class="attrib">@param</span> {String} sGroup The group of related DragDrop items
|
|
* <span class="attrib">@param</span> {String} sType The type of slider (horiz, vert, region)
|
|
*/</span>
|
|
YAHOO.widget.Slider = <span class="reserved">function</span>(sElementId, sGroup, oThumb, sType) {
|
|
<span class="reserved">if</span> (sElementId) {
|
|
|
|
<span class="comment">/**
|
|
* The type of the slider (horiz, vert, region)
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
<span class="reserved">this</span>.type = sType;
|
|
|
|
<span class="reserved">this</span>.init(sElementId, sGroup, true);
|
|
|
|
<span class="reserved">this</span>.logger = new YAHOO.widget.LogWriter(<span class="reserved">this</span>.toString());
|
|
|
|
var self = <span class="reserved">this</span>;
|
|
|
|
<span class="comment">/**
|
|
* a YAHOO.widget.SliderThumb instance that we will use to
|
|
* reposition the thumb when the background is clicked
|
|
*
|
|
* <span class="attrib">@type</span> Slider
|
|
*/</span>
|
|
<span class="reserved">this</span>.thumb = oThumb;
|
|
<span class="comment">
|
|
// add handler for the handle onchange event</span>
|
|
oThumb.onChange = <span class="reserved">function</span>() {
|
|
self.onThumbChange();
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Overrides the isTarget property in YAHOO.util.DragDrop
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
<span class="reserved">this</span>.isTarget = false;
|
|
|
|
<span class="comment">/**
|
|
* Flag that determines if the thumb will animate when moved
|
|
* <span class="attrib">@type</span> boolean
|
|
*/</span>
|
|
<span class="reserved">this</span>.animate = YAHOO.widget.Slider.ANIM_AVAIL;
|
|
|
|
<span class="comment">/**
|
|
* Set to false to disable a background click thumb move
|
|
*/</span>
|
|
<span class="reserved">this</span>.backgroundEnabled = true;
|
|
|
|
<span class="comment">/**
|
|
* Adjustment factor for tick animation, the more ticks, the
|
|
* faster the animation (by default)
|
|
*
|
|
* <span class="attrib">@type</span> int
|
|
*/</span>
|
|
<span class="reserved">this</span>.tickPause = 40;
|
|
<span class="reserved">if</span> (oThumb._isHoriz && oThumb.xTicks && oThumb.xTicks.length) {
|
|
<span class="reserved">this</span>.tickPause = Math.round(360 / oThumb.xTicks.length);
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (oThumb.yTicks && oThumb.yTicks.length) {
|
|
<span class="reserved">this</span>.tickPause = Math.round(360 / oThumb.yTicks.length);
|
|
}
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"tickPause: "</span> + <span class="reserved">this</span>.tickPause);
|
|
<span class="comment">
|
|
// delegate thumb methods</span>
|
|
oThumb.onMouseDown = <span class="reserved">function</span> () { <span class="reserved">return</span> self.focus(); };
|
|
<span class="comment"> //oThumb.b4MouseDown = function () { return self.b4MouseDown(); };</span>
|
|
<span class="comment"> // oThumb.lock = function() { self.lock(); };</span>
|
|
<span class="comment"> // oThumb.unlock = function() { self.unlock(); };</span>
|
|
oThumb.onMouseUp = <span class="reserved">function</span>() { self.thumbMouseUp(); };
|
|
oThumb.onDrag = <span class="reserved">function</span>() { self.fireEvents(); };
|
|
oThumb.onAvailable = <span class="reserved">function</span>() { <span class="reserved">return</span> self.setStartSliderState(); };
|
|
}
|
|
};
|
|
<span class="comment">
|
|
//YAHOO.widget.Slider.prototype = new YAHOO.util.DragDrop();</span>
|
|
YAHOO.extend(YAHOO.widget.Slider, YAHOO.util.DragDrop);
|
|
<span class="comment">
|
|
// YAHOO.widget.Slider.prototype.onAvailable = function() {</span>
|
|
<span class="comment"> // this.logger.log("bg avail");</span>
|
|
<span class="comment">// };</span>
|
|
|
|
<span class="comment">/**
|
|
* Factory method for creating a horizontal slider
|
|
*
|
|
* <span class="attrib">@param</span> {String} sBGElId the id of the slider's background element
|
|
* <span class="attrib">@param</span> {String} sHandleElId the id of the thumb element
|
|
* <span class="attrib">@param</span> {int} iLeft the number of pixels the element can move left
|
|
* <span class="attrib">@param</span> {int} iRight the number of pixels the element can move right
|
|
* <span class="attrib">@param</span> {int} iTickSize optional parameter for specifying that the element
|
|
* should move a certain number pixels at a time.
|
|
* <span class="attrib">@return</span> {Slider} a horizontal slider control
|
|
*/</span>
|
|
YAHOO.widget.Slider.getHorizSlider =
|
|
<span class="reserved">function</span> (sBGElId, sHandleElId, iLeft, iRight, iTickSize) {
|
|
<span class="reserved">return</span> new YAHOO.widget.Slider(sBGElId, sBGElId,
|
|
new YAHOO.widget.SliderThumb(sHandleElId, sBGElId,
|
|
iLeft, iRight, 0, 0, iTickSize), <span class="literal">"horiz"</span>);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Factory method for creating a vertical slider
|
|
*
|
|
* <span class="attrib">@param</span> {String} sBGElId the id of the slider's background element
|
|
* <span class="attrib">@param</span> {String} sHandleElId the id of the thumb element
|
|
* <span class="attrib">@param</span> {int} iUp the number of pixels the element can move up
|
|
* <span class="attrib">@param</span> {int} iDown the number of pixels the element can move down
|
|
* <span class="attrib">@param</span> {int} iTickSize optional parameter for specifying that the element
|
|
* should move a certain number pixels at a time.
|
|
* <span class="attrib">@return</span> {Slider} a vertical slider control
|
|
*/</span>
|
|
YAHOO.widget.Slider.getVertSlider =
|
|
<span class="reserved">function</span> (sBGElId, sHandleElId, iUp, iDown, iTickSize) {
|
|
<span class="reserved">return</span> new YAHOO.widget.Slider(sBGElId, sBGElId,
|
|
new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, 0, 0,
|
|
iUp, iDown, iTickSize), <span class="literal">"vert"</span>);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Factory method for creating a slider region like the one in the color
|
|
* picker example
|
|
*
|
|
* <span class="attrib">@param</span> {String} sBGElId the id of the slider's background element
|
|
* <span class="attrib">@param</span> {String} sHandleElId the id of the thumb element
|
|
* <span class="attrib">@param</span> {int} iLeft the number of pixels the element can move left
|
|
* <span class="attrib">@param</span> {int} iRight the number of pixels the element can move right
|
|
* <span class="attrib">@param</span> {int} iUp the number of pixels the element can move up
|
|
* <span class="attrib">@param</span> {int} iDown the number of pixels the element can move down
|
|
* <span class="attrib">@param</span> {int} iTickSize optional parameter for specifying that the element
|
|
* should move a certain number pixels at a time.
|
|
* <span class="attrib">@return</span> {Slider} a slider region control
|
|
*/</span>
|
|
YAHOO.widget.Slider.getSliderRegion =
|
|
<span class="reserved">function</span> (sBGElId, sHandleElId, iLeft, iRight, iUp, iDown, iTickSize) {
|
|
<span class="reserved">return</span> new YAHOO.widget.Slider(sBGElId, sBGElId,
|
|
new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, iLeft, iRight,
|
|
iUp, iDown, iTickSize), <span class="literal">"region"</span>);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* By default, animation is available if the animation library is detected.
|
|
* <span class="attrib">@type</span> boolean
|
|
*/</span>
|
|
YAHOO.widget.Slider.ANIM_AVAIL = true;
|
|
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.setStartSliderState = <span class="reserved">function</span>() {
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Fixing state"</span>);
|
|
|
|
<span class="reserved">this</span>.setThumbCenterPoint();
|
|
|
|
<span class="comment">/**
|
|
* The basline position of the background element, used
|
|
* to determine if the background has moved since the last
|
|
* operation.
|
|
* <span class="attrib">@type</span> int[]
|
|
*/</span>
|
|
<span class="reserved">this</span>.baselinePos = YAHOO.util.Dom.getXY(<span class="reserved">this</span>.getEl());
|
|
|
|
<span class="reserved">this</span>.thumb.startOffset = <span class="reserved">this</span>.thumb.getOffsetFromParent(<span class="reserved">this</span>.baselinePos);
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.thumb._isRegion) {
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.deferredSetRegionValue) {
|
|
<span class="reserved">this</span>.setRegionValue.apply(<span class="reserved">this</span>, <span class="reserved">this</span>.deferredSetRegionValue, true);
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.setRegionValue(0, 0, true);
|
|
}
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.deferredSetValue) {
|
|
<span class="reserved">this</span>.setValue.apply(<span class="reserved">this</span>, <span class="reserved">this</span>.deferredSetValue, true);
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.setValue(0, true, true);
|
|
}
|
|
}
|
|
};
|
|
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.setThumbCenterPoint = <span class="reserved">function</span>() {
|
|
|
|
var el = <span class="reserved">this</span>.thumb.getEl();
|
|
|
|
<span class="reserved">if</span> (el) {
|
|
<span class="comment">/**
|
|
* the center of the slider element is stored so we can position
|
|
* place it in the correct position when the background is clicked
|
|
*
|
|
* <span class="attrib">@type</span> Coordinate
|
|
*/</span>
|
|
<span class="reserved">this</span>.thumbCenterPoint = {
|
|
x: parseInt(el.offsetWidth/2, 10),
|
|
y: parseInt(el.offsetHeight/2, 10)
|
|
};
|
|
}
|
|
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Lock the slider, overrides YAHOO.util.DragDrop
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.lock = <span class="reserved">function</span>() {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"locking"</span>);
|
|
<span class="reserved">this</span>.thumb.lock();
|
|
<span class="reserved">this</span>.locked = true;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Unlock the slider, overrides YAHOO.util.DragDrop
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.unlock = <span class="reserved">function</span>() {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"unlocking"</span>);
|
|
<span class="reserved">this</span>.thumb.unlock();
|
|
<span class="reserved">this</span>.locked = false;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* handles mouseup event on the slider background
|
|
*
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.thumbMouseUp = <span class="reserved">function</span>() {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"bg mouseup"</span>);
|
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.isLocked() && !<span class="reserved">this</span>.moveComplete) {
|
|
<span class="reserved">this</span>.endMove();
|
|
}
|
|
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns a reference to this slider's thumb
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.getThumb = <span class="reserved">function</span>() {
|
|
<span class="reserved">return</span> <span class="reserved">this</span>.thumb;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Try to focus the element when clicked so we can add
|
|
* accessibility features
|
|
*
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.focus = <span class="reserved">function</span>() {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"focus"</span>);
|
|
<span class="comment">
|
|
// Focus the background element if possible</span>
|
|
var el = <span class="reserved">this</span>.getEl();
|
|
|
|
<span class="reserved">if</span> (el.focus) {
|
|
el.focus();
|
|
}
|
|
|
|
<span class="reserved">this</span>.verifyOffset();
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.isLocked()) {
|
|
<span class="reserved">return</span> false;
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.onSlideStart();
|
|
<span class="reserved">return</span> true;
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Event that fires when the value of the slider has changed
|
|
*
|
|
* <span class="attrib">@param</span> {int} offsetFromStart the number of pixels the thumb has moved
|
|
* from its start position. Normal horizontal and vertical sliders will only
|
|
* have the firstOffset. Regions will have both, the first is the horizontal
|
|
* offset, the second the vertical.
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.onChange = <span class="reserved">function</span> (firstOffset, secondOffset) {
|
|
<span class="comment">/* override me */</span>
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"onChange: "</span> + firstOffset + <span class="literal">", "</span> + secondOffset);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Event that fires when the at the beginning of the slider thumb move
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.onSlideStart = <span class="reserved">function</span> () {
|
|
<span class="comment">/* override me */</span>
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"onSlideStart"</span>);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Event that fires at the end of a slider thumb move
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.onSlideEnd = <span class="reserved">function</span> () {
|
|
<span class="comment">/* override me */</span>
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"onSlideEnd"</span>);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns the slider's thumb offset from the start position
|
|
*
|
|
* <span class="attrib">@return</span> {int} the current value
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.getValue = <span class="reserved">function</span> () {
|
|
<span class="reserved">return</span> <span class="reserved">this</span>.thumb.getValue();
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns the slider's thumb X offset from the start position
|
|
*
|
|
* <span class="attrib">@return</span> {int} the current horizontal offset
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.getXValue = <span class="reserved">function</span> () {
|
|
<span class="reserved">return</span> <span class="reserved">this</span>.thumb.getXValue();
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns the slider's thumb Y offset from the start position
|
|
*
|
|
* <span class="attrib">@return</span> {int} the current vertical offset
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.getYValue = <span class="reserved">function</span> () {
|
|
<span class="reserved">return</span> <span class="reserved">this</span>.thumb.getYValue();
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Internal handler for the slider thumb's onChange event
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.onThumbChange = <span class="reserved">function</span> () {
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
<span class="reserved">if</span> (t._isRegion) {
|
|
t.onChange(t.getXValue(), t.getYValue());
|
|
} <span class="reserved">else</span> {
|
|
t.onChange(t.getValue());
|
|
}
|
|
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Provides a way to set the value of the slider in code.
|
|
*
|
|
* <span class="attrib">@param</span> {int} newOffset the number of pixels the thumb should be
|
|
* positioned away from the initial start point
|
|
* <span class="attrib">@param</span> {boolean} skipAnim set to true to disable the animation
|
|
* for this move action (but not others).
|
|
* <span class="attrib">@param</span> {boolean} force ignore the locked setting and set value anyway
|
|
* <span class="attrib">@return</span> {boolean} true if the move was performed, false if it failed
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.setValue = <span class="reserved">function</span>(newOffset, skipAnim, force) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"setValue "</span> + newOffset);
|
|
|
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.thumb.available) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"defer setValue until after onAvailble"</span>);
|
|
<span class="reserved">this</span>.deferredSetValue = arguments;
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.isLocked() && !force) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Can't set the value, the control is locked"</span>);
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
|
|
<span class="reserved">if</span> ( isNaN(newOffset) ) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"setValue, Illegal argument: "</span> + newOffset);
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
var newX, newY;
|
|
<span class="reserved">this</span>.verifyOffset();
|
|
<span class="reserved">if</span> (t._isRegion) {
|
|
<span class="reserved">return</span> false;
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (t._isHoriz) {
|
|
<span class="reserved">this</span>.onSlideStart();
|
|
newX = t.initPageX + newOffset + <span class="reserved">this</span>.thumbCenterPoint.x;
|
|
<span class="reserved">this</span>.moveThumb(newX, t.initPageY, skipAnim);
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.onSlideStart();
|
|
newY = t.initPageY + newOffset + <span class="reserved">this</span>.thumbCenterPoint.y;
|
|
<span class="reserved">this</span>.moveThumb(t.initPageX, newY, skipAnim);
|
|
}
|
|
|
|
<span class="reserved">return</span> true;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Provides a way to set the value of the region slider in code.
|
|
*
|
|
* <span class="attrib">@param</span> {int} newOffset the number of pixels the thumb should be
|
|
* positioned away from the initial start point
|
|
* <span class="attrib">@param</span> {int} newOffset2 the number of pixels the thumb should be
|
|
* positioned away from the initial start point (y axis for region)
|
|
* <span class="attrib">@param</span> {boolean} skipAnim set to true to disable the animation
|
|
* for this move action (but not others).
|
|
* <span class="attrib">@param</span> {boolean} force ignore the locked setting and set value anyway
|
|
* <span class="attrib">@return</span> {boolean} true if the move was performed, false if it failed
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.setRegionValue = <span class="reserved">function</span>(newOffset, newOffset2, skipAnim) {
|
|
|
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.thumb.available) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"defer setRegionValue until after onAvailble"</span>);
|
|
<span class="reserved">this</span>.deferredSetRegionValue = arguments;
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.isLocked() && !force) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Can't set the value, the control is locked"</span>);
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
|
|
<span class="reserved">if</span> ( isNaN(newOffset) ) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"setRegionValue, Illegal argument: "</span> + newOffset);
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
<span class="reserved">if</span> (t._isRegion) {
|
|
<span class="reserved">this</span>.onSlideStart();
|
|
var newX = t.initPageX + newOffset + <span class="reserved">this</span>.thumbCenterPoint.x;
|
|
var newY = t.initPageY + newOffset2 + <span class="reserved">this</span>.thumbCenterPoint.y;
|
|
<span class="reserved">this</span>.moveThumb(newX, newY, skipAnim);
|
|
<span class="reserved">return</span> true;
|
|
}
|
|
|
|
<span class="reserved">return</span> false;
|
|
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Checks the background position element position. If it has moved from the
|
|
* baseline position, the constraints for the thumb are reset
|
|
* <span class="attrib">@return</span> {boolean} True if the offset is the same as the baseline.
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.verifyOffset = <span class="reserved">function</span>() {
|
|
|
|
var newPos = YAHOO.util.Dom.getXY(<span class="reserved">this</span>.getEl());
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"newPos: "</span> + newPos);
|
|
|
|
<span class="reserved">if</span> (newPos[0] != <span class="reserved">this</span>.baselinePos[0] || newPos[1] != <span class="reserved">this</span>.baselinePos[1]) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"background moved, resetting constraints"</span>);
|
|
<span class="reserved">this</span>.thumb.resetConstraints();
|
|
<span class="reserved">this</span>.baselinePos = newPos;
|
|
<span class="reserved">return</span> false;
|
|
}
|
|
|
|
<span class="reserved">return</span> true;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Move the associated slider moved to a timeout to try to get around the
|
|
* mousedown stealing moz does when I move the slider element between the
|
|
* cursor and the background during the mouseup event
|
|
*
|
|
* <span class="attrib">@param</span> {int} x the X coordinate of the click
|
|
* <span class="attrib">@param</span> {int} y the Y coordinate of the click
|
|
* <span class="attrib">@param</span> {boolean} skipAnim don't animate if the move happend onDrag
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.moveThumb = <span class="reserved">function</span>(x, y, skipAnim) {
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"move thumb"</span>, <span class="literal">"warn"</span>);
|
|
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
var self = <span class="reserved">this</span>;
|
|
|
|
<span class="reserved">if</span> (!t.available) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"thumb is not available yet, aborting move"</span>);
|
|
<span class="reserved">return</span>;
|
|
}
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"move thumb, x: "</span> + x + <span class="literal">", y: "</span> + y);
|
|
<span class="comment">
|
|
// this.verifyOffset();</span>
|
|
|
|
t.setDelta(<span class="reserved">this</span>.thumbCenterPoint.x, <span class="reserved">this</span>.thumbCenterPoint.y);
|
|
|
|
var _p = t.getTargetCoord(x, y);
|
|
var p = [_p.x, _p.y];
|
|
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.animate && YAHOO.widget.Slider.ANIM_AVAIL && t._graduated && !skipAnim) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"graduated"</span>);
|
|
<span class="comment"> // this.thumb._animating = true;</span>
|
|
<span class="reserved">this</span>.lock();
|
|
|
|
setTimeout( <span class="reserved">function</span>() { self.moveOneTick(p); }, <span class="reserved">this</span>.tickPause );
|
|
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.animate && YAHOO.widget.Slider.ANIM_AVAIL && !skipAnim) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"animating to "</span> + p);
|
|
<span class="comment">
|
|
// this.thumb._animating = true;</span>
|
|
<span class="reserved">this</span>.lock();
|
|
|
|
var oAnim = new YAHOO.util.Motion(
|
|
t.id, { points: { to: p } }, 0.4, YAHOO.util.Easing.easeOut );
|
|
|
|
oAnim.onComplete.subscribe( <span class="reserved">function</span>() { self.endMove(); } );
|
|
oAnim.animate();
|
|
} <span class="reserved">else</span> {
|
|
t.setDragElPos(x, y);
|
|
<span class="comment"> // this.fireEvents();</span>
|
|
<span class="reserved">this</span>.endMove();
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Move the slider one tick mark towards its final coordinate. Used
|
|
* for the animation when tick marks are defined
|
|
*
|
|
* <span class="attrib">@param</span> {int[]} the destination coordinate
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.moveOneTick = <span class="reserved">function</span>(finalCoord) {
|
|
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
var curCoord = YAHOO.util.Dom.getXY(t.getEl());
|
|
var tmp;
|
|
<span class="comment">
|
|
// var thresh = Math.min(t.tickSize + (Math.floor(t.tickSize/2)), 10);</span>
|
|
<span class="comment"> // var thresh = 10;</span>
|
|
<span class="comment"> // var thresh = t.tickSize + (Math.floor(t.tickSize/2));</span>
|
|
|
|
var nextCoord = null;
|
|
|
|
<span class="reserved">if</span> (t._isRegion) {
|
|
nextCoord = <span class="reserved">this</span>._getNextX(curCoord, finalCoord);
|
|
var tmpX = (nextCoord) ? nextCoord[0] : curCoord[0];
|
|
nextCoord = <span class="reserved">this</span>._getNextY([tmpX, curCoord[1]], finalCoord);
|
|
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (t._isHoriz) {
|
|
nextCoord = <span class="reserved">this</span>._getNextX(curCoord, finalCoord);
|
|
} <span class="reserved">else</span> {
|
|
nextCoord = <span class="reserved">this</span>._getNextY(curCoord, finalCoord);
|
|
}
|
|
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"moveOneTick: "</span> +
|
|
<span class="literal">" finalCoord: "</span> + finalCoord +
|
|
<span class="literal">" curCoord: "</span> + curCoord +
|
|
<span class="literal">" nextCoord: "</span> + nextCoord);
|
|
|
|
<span class="reserved">if</span> (nextCoord) {
|
|
<span class="comment">
|
|
// move to the next coord</span>
|
|
<span class="comment"> // YAHOO.util.Dom.setXY(t.getEl(), nextCoord);</span>
|
|
<span class="comment">
|
|
// var el = t.getEl();</span>
|
|
<span class="comment"> // YAHOO.util.Dom.setStyle(el, "left", (nextCoord[0] + this.thumb.deltaSetXY[0]) + "px");</span>
|
|
<span class="comment"> // YAHOO.util.Dom.setStyle(el, "top", (nextCoord[1] + this.thumb.deltaSetXY[1]) + "px");</span>
|
|
|
|
<span class="reserved">this</span>.thumb.alignElWithMouse(t.getEl(), nextCoord[0], nextCoord[1]);
|
|
<span class="comment">
|
|
// check if we are in the final position, if not make a recursive call</span>
|
|
<span class="reserved">if</span> (!(nextCoord[0] == finalCoord[0] && nextCoord[1] == finalCoord[1])) {
|
|
var self = <span class="reserved">this</span>;
|
|
setTimeout(<span class="reserved">function</span>() { self.moveOneTick(finalCoord); },
|
|
<span class="reserved">this</span>.tickPause);
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.endMove();
|
|
}
|
|
} <span class="reserved">else</span> {
|
|
<span class="reserved">this</span>.endMove();
|
|
}
|
|
<span class="comment">
|
|
//this.tickPause = Math.round(this.tickPause/2);</span>
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns the next X tick value based on the current coord and the target coord.
|
|
* <span class="attrib">@private</span>/
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>._getNextX = <span class="reserved">function</span>(curCoord, finalCoord) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"getNextX: "</span> + curCoord + <span class="literal">", "</span> + finalCoord);
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
var thresh;
|
|
var tmp = [];
|
|
var nextCoord = null;
|
|
<span class="reserved">if</span> (curCoord[0] > finalCoord[0]) {
|
|
thresh = t.tickSize - <span class="reserved">this</span>.thumbCenterPoint.x;
|
|
tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] );
|
|
nextCoord = [tmp.x, tmp.y];
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (curCoord[0] < finalCoord[0]) {
|
|
thresh = t.tickSize + <span class="reserved">this</span>.thumbCenterPoint.x;
|
|
tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] );
|
|
nextCoord = [tmp.x, tmp.y];
|
|
} <span class="reserved">else</span> {
|
|
<span class="comment"> // equal, do nothing</span>
|
|
}
|
|
|
|
<span class="reserved">return</span> nextCoord;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Returns the next Y tick value based on the current coord and the target coord.
|
|
* <span class="attrib">@private</span>/
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>._getNextY = <span class="reserved">function</span>(curCoord, finalCoord) {
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
<span class="comment"> // var thresh = t.tickSize;</span>
|
|
<span class="comment"> // var thresh = t.tickSize + this.thumbCenterPoint.y;</span>
|
|
var thresh;
|
|
var tmp = [];
|
|
var nextCoord = null;
|
|
|
|
<span class="reserved">if</span> (curCoord[1] > finalCoord[1]) {
|
|
thresh = t.tickSize - <span class="reserved">this</span>.thumbCenterPoint.y;
|
|
tmp = t.getTargetCoord( curCoord[0], curCoord[1] - thresh );
|
|
nextCoord = [tmp.x, tmp.y];
|
|
} <span class="reserved">else</span> <span class="reserved">if</span> (curCoord[1] < finalCoord[1]) {
|
|
thresh = t.tickSize + <span class="reserved">this</span>.thumbCenterPoint.y;
|
|
tmp = t.getTargetCoord( curCoord[0], curCoord[1] + thresh );
|
|
nextCoord = [tmp.x, tmp.y];
|
|
} <span class="reserved">else</span> {
|
|
<span class="comment"> // equal, do nothing</span>
|
|
}
|
|
|
|
<span class="reserved">return</span> nextCoord;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Resets the constraints before moving the thumb.
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.b4MouseDown = <span class="reserved">function</span>(e) {
|
|
<span class="reserved">this</span>.thumb.autoOffset();
|
|
<span class="reserved">this</span>.thumb.resetConstraints();
|
|
};
|
|
|
|
|
|
<span class="comment">/**
|
|
* Handles the mousedown event for the slider background
|
|
*
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.onMouseDown = <span class="reserved">function</span>(e) {
|
|
<span class="comment"> // this.resetConstraints(true);</span>
|
|
<span class="comment"> // this.thumb.resetConstraints(true);</span>
|
|
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.isLocked() && <span class="reserved">this</span>.backgroundEnabled) {
|
|
var x = YAHOO.util.Event.getPageX(e);
|
|
var y = YAHOO.util.Event.getPageY(e);
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"bg mousedown: "</span> + x + <span class="literal">","</span> + y);
|
|
|
|
<span class="reserved">this</span>.focus();
|
|
<span class="reserved">this</span>.moveThumb(x, y);
|
|
}
|
|
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Handles the onDrag event for the slider background
|
|
*
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.onDrag = <span class="reserved">function</span>(e) {
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.isLocked()) {
|
|
var x = YAHOO.util.Event.getPageX(e);
|
|
var y = YAHOO.util.Event.getPageY(e);
|
|
<span class="reserved">this</span>.moveThumb(x, y, true);
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Fired when the slider movement ends
|
|
*
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.endMove = <span class="reserved">function</span> () {
|
|
<span class="comment"> // this._animating = false;</span>
|
|
<span class="reserved">this</span>.unlock();
|
|
<span class="reserved">this</span>.moveComplete = true;
|
|
<span class="reserved">this</span>.fireEvents();
|
|
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Fires the change event if the value has been changed. Ignored if we are in
|
|
* the middle of an animation as the event will fire when the animation is
|
|
* complete
|
|
*
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.fireEvents = <span class="reserved">function</span> () {
|
|
|
|
var t = <span class="reserved">this</span>.thumb;
|
|
<span class="comment"> // this.logger.log("FireEvents: " + t._isRegion);</span>
|
|
|
|
t.cachePosition();
|
|
|
|
<span class="reserved">if</span> (! <span class="reserved">this</span>.isLocked()) {
|
|
<span class="reserved">if</span> (t._isRegion) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"region"</span>);
|
|
var newX = t.getXValue();
|
|
var newY = t.getYValue();
|
|
|
|
<span class="reserved">if</span> (newX != <span class="reserved">this</span>.previousX || newY != <span class="reserved">this</span>.previousY) {
|
|
<span class="comment"> // this.logger.log("Firing onchange");</span>
|
|
<span class="reserved">this</span>.onChange( newX, newY );
|
|
}
|
|
|
|
<span class="reserved">this</span>.previousX = newX;
|
|
<span class="reserved">this</span>.previousY = newY;
|
|
|
|
} <span class="reserved">else</span> {
|
|
var newVal = t.getValue();
|
|
<span class="reserved">if</span> (newVal != <span class="reserved">this</span>.previousVal) {
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"Firing onchange: "</span> + newVal);
|
|
<span class="reserved">this</span>.onChange( newVal );
|
|
}
|
|
<span class="reserved">this</span>.previousVal = newVal;
|
|
}
|
|
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.moveComplete) {
|
|
<span class="reserved">this</span>.onSlideEnd();
|
|
<span class="reserved">this</span>.moveComplete = false;
|
|
}
|
|
|
|
}
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* toString
|
|
* <span class="attrib">@return</span> {string} string representation of the instance
|
|
*/</span>
|
|
YAHOO.widget.Slider.<span class="reserved">prototype</span>.toString = <span class="reserved">function</span> () {
|
|
<span class="reserved">return</span> (<span class="literal">"Slider ("</span> + <span class="reserved">this</span>.type +<span class="literal">") "</span> + <span class="reserved">this</span>.id);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* A drag and drop implementation to be used as the thumb of a slider.
|
|
*
|
|
* <span class="attrib">@extends</span> YAHOO.util.DD
|
|
* <span class="attrib">@constructor</span>
|
|
* <span class="attrib">@param</span> {String} id the id of the slider html element
|
|
* <span class="attrib">@param</span> {String} sGroup the group of related DragDrop items
|
|
* <span class="attrib">@param</span> {int} iLeft the number of pixels the element can move left
|
|
* <span class="attrib">@param</span> {int} iRight the number of pixels the element can move right
|
|
* <span class="attrib">@param</span> {int} iUp the number of pixels the element can move up
|
|
* <span class="attrib">@param</span> {int} iDown the number of pixels the element can move down
|
|
* <span class="attrib">@param</span> {int} iTickSize optional parameter for specifying that the element
|
|
* should move a certain number pixels at a time.
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb = <span class="reserved">function</span>(id, sGroup, iLeft, iRight, iUp, iDown, iTickSize) {
|
|
|
|
<span class="reserved">if</span> (id) {
|
|
<span class="reserved">this</span>.init(id, sGroup);
|
|
|
|
<span class="comment">/**
|
|
* The id of the thumbs parent HTML element (the slider background element).
|
|
* <span class="attrib">@type</span> string
|
|
*/</span>
|
|
<span class="reserved">this</span>.parentElId = sGroup;
|
|
}
|
|
|
|
<span class="reserved">this</span>.logger = new YAHOO.widget.LogWriter(<span class="reserved">this</span>.toString());
|
|
|
|
<span class="comment">/**
|
|
* Overrides the isTarget property in YAHOO.util.DragDrop
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
<span class="reserved">this</span>.isTarget = false;
|
|
|
|
<span class="comment">/**
|
|
* The tick size for this slider
|
|
* <span class="attrib">@type</span> int
|
|
*/</span>
|
|
<span class="reserved">this</span>.tickSize = iTickSize;
|
|
|
|
<span class="comment">/**
|
|
* Informs the drag and drop util that the offsets should remain when
|
|
* resetting the constraints. This preserves the slider value when
|
|
* the constraints are reset
|
|
* <span class="attrib">@type</span> boolean
|
|
*/</span>
|
|
<span class="reserved">this</span>.maintainOffset = true;
|
|
|
|
<span class="reserved">this</span>.initSlider(iLeft, iRight, iUp, iDown, iTickSize);
|
|
|
|
<span class="reserved">this</span>.scroll = false;
|
|
|
|
};
|
|
<span class="comment">
|
|
// YAHOO.widget.SliderThumb.prototype = new YAHOO.util.DD();</span>
|
|
YAHOO.extend(YAHOO.widget.SliderThumb, YAHOO.util.DD);
|
|
|
|
<span class="comment">/**
|
|
* Returns the difference between the location of the thumb and its parent.
|
|
* <span class="attrib">@param</span> {Array} Optionally accepts the position of the parent
|
|
* <span class="attrib">@type</span> int[]
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.getOffsetFromParent = <span class="reserved">function</span>(parentPos) {
|
|
var myPos = YAHOO.util.Dom.getXY(<span class="reserved">this</span>.getEl());
|
|
var ppos = parentPos || YAHOO.util.Dom.getXY(<span class="reserved">this</span>.parentElId);
|
|
|
|
<span class="reserved">return</span> [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ];
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* The (X and Y) difference between the thumb location and its parent
|
|
* (the slider background) when the control is instantiated.
|
|
* <span class="attrib">@type</span> int[]
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.startOffset = null;
|
|
|
|
<span class="comment">/**
|
|
* Flag used to figure out if this is a horizontal or vertical slider
|
|
*
|
|
* <span class="attrib">@type</span> boolean
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>._isHoriz = false;
|
|
|
|
<span class="comment">/**
|
|
* Cache the last value so we can check for change
|
|
*
|
|
* <span class="attrib">@type</span> int
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>._prevVal = 0;
|
|
|
|
<span class="comment">/**
|
|
* initial element X
|
|
*
|
|
* <span class="attrib">@type</span> int
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
<span class="comment">// YAHOO.widget.SliderThumb.prototype._initX = 0;</span>
|
|
|
|
<span class="comment">/**
|
|
* initial element Y
|
|
*
|
|
* <span class="attrib">@type</span> int
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
<span class="comment">// YAHOO.widget.SliderThumb.prototype._initY = 0;</span>
|
|
|
|
<span class="comment">/**
|
|
* The slider is _graduated if there is a tick interval defined
|
|
*
|
|
* <span class="attrib">@type</span> boolean
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>._graduated = false;
|
|
|
|
<span class="comment">/**
|
|
* Set up the slider, must be called in the constructor of all subclasses
|
|
*
|
|
* <span class="attrib">@param</span> {int} iLeft the number of pixels the element can move left
|
|
* <span class="attrib">@param</span> {int} iRight the number of pixels the element can move right
|
|
* <span class="attrib">@param</span> {int} iUp the number of pixels the element can move up
|
|
* <span class="attrib">@param</span> {int} iDown the number of pixels the element can move down
|
|
* <span class="attrib">@param</span> {int} iTickSize the width of the tick interval.
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.initSlider = <span class="reserved">function</span> (iLeft, iRight, iUp, iDown,
|
|
iTickSize) {
|
|
|
|
<span class="reserved">this</span>.setXConstraint(iLeft, iRight, iTickSize);
|
|
<span class="reserved">this</span>.setYConstraint(iUp, iDown, iTickSize);
|
|
|
|
<span class="reserved">if</span> (iTickSize && iTickSize > 1) {
|
|
<span class="reserved">this</span>._graduated = true;
|
|
}
|
|
|
|
<span class="reserved">this</span>._isHoriz = (iLeft > 0 || iRight > 0);
|
|
<span class="reserved">this</span>._isVert = (iUp > 0 || iDown > 0);
|
|
<span class="reserved">this</span>._isRegion = (<span class="reserved">this</span>._isHoriz && <span class="reserved">this</span>._isVert);
|
|
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Clear's the slider's ticks
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.clearTicks = <span class="reserved">function</span> () {
|
|
YAHOO.widget.SliderThumb.superclass.clearTicks.call(<span class="reserved">this</span>);
|
|
<span class="reserved">this</span>._graduated = false;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Gets the current offset from the element's start position in
|
|
* pixels.
|
|
*
|
|
* <span class="attrib">@return</span> {int} the number of pixels (positive or negative) the
|
|
* slider has moved from the start position.
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.getValue = <span class="reserved">function</span> () {
|
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.available) { <span class="reserved">return</span> 0; }
|
|
var val = (<span class="reserved">this</span>._isHoriz) ? <span class="reserved">this</span>.getXValue() : <span class="reserved">this</span>.getYValue();
|
|
<span class="reserved">this</span>.logger.log(<span class="literal">"getVal: "</span> + val);
|
|
<span class="reserved">return</span> val;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Gets the current X offset from the element's start position in
|
|
* pixels.
|
|
*
|
|
* <span class="attrib">@return</span> {int} the number of pixels (positive or negative) the
|
|
* slider has moved horizontally from the start position.
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.getXValue = <span class="reserved">function</span> () {
|
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.available) { <span class="reserved">return</span> 0; }
|
|
var newOffset = <span class="reserved">this</span>.getOffsetFromParent();
|
|
<span class="reserved">return</span> (newOffset[0] - <span class="reserved">this</span>.startOffset[0]);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* Gets the current Y offset from the element's start position in
|
|
* pixels.
|
|
*
|
|
* <span class="attrib">@return</span> {int} the number of pixels (positive or negative) the
|
|
* slider has moved vertically from the start position.
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.getYValue = <span class="reserved">function</span> () {
|
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.available) { <span class="reserved">return</span> 0; }
|
|
var newOffset = <span class="reserved">this</span>.getOffsetFromParent();
|
|
<span class="reserved">return</span> (newOffset[1] - <span class="reserved">this</span>.startOffset[1]);
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* toString
|
|
* <span class="attrib">@return</span> {string} string representation of the instance
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.toString = <span class="reserved">function</span> () {
|
|
<span class="reserved">return</span> <span class="literal">"SliderThumb "</span> + <span class="reserved">this</span>.id;
|
|
};
|
|
|
|
<span class="comment">/**
|
|
* The onchange event for the handle/thumb is delegated to the YAHOO.widget.Slider
|
|
* instance it belongs to.
|
|
*
|
|
* <span class="attrib">@private</span>
|
|
*/</span>
|
|
YAHOO.widget.SliderThumb.<span class="reserved">prototype</span>.onChange = <span class="reserved">function</span> (x, y) { };
|
|
|
|
<span class="reserved">if</span> (<span class="literal">"undefined"</span> == typeof YAHOO.util.Anim) {
|
|
YAHOO.widget.Slider.ANIM_AVAIL = false;
|
|
}
|
|
|
|
</pre>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div id="footer">
|
|
|
|
<hr />
|
|
|
|
Copyright © 2004 - 2006 Yahoo! Inc. All rights reserved.
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|