~rharding/loggerhead/yui3.7.1

« back to all changes in this revision

Viewing changes to loggerhead/static/javascript/yui/build/slider-value-range/slider-value-range-coverage.js

  • Committer: Rick Harding
  • Date: 2012-11-07 15:51:42 UTC
  • Revision ID: rick.harding@canonical.com-20121107155142-56lxp77hopixc9xf
Fix the collapsable

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
YUI 3.7.1 (build 5627)
 
3
Copyright 2012 Yahoo! Inc. All rights reserved.
 
4
Licensed under the BSD License.
 
5
http://yuilibrary.com/license/
 
6
*/
 
7
if (typeof _yuitest_coverage == "undefined"){
 
8
    _yuitest_coverage = {};
 
9
    _yuitest_coverline = function(src, line){
 
10
        var coverage = _yuitest_coverage[src];
 
11
        if (!coverage.lines[line]){
 
12
            coverage.calledLines++;
 
13
        }
 
14
        coverage.lines[line]++;
 
15
    };
 
16
    _yuitest_coverfunc = function(src, name, line){
 
17
        var coverage = _yuitest_coverage[src],
 
18
            funcId = name + ":" + line;
 
19
        if (!coverage.functions[funcId]){
 
20
            coverage.calledFunctions++;
 
21
        }
 
22
        coverage.functions[funcId]++;
 
23
    };
 
24
}
 
25
_yuitest_coverage["build/slider-value-range/slider-value-range.js"] = {
 
26
    lines: {},
 
27
    functions: {},
 
28
    coveredLines: 0,
 
29
    calledLines: 0,
 
30
    coveredFunctions: 0,
 
31
    calledFunctions: 0,
 
32
    path: "build/slider-value-range/slider-value-range.js",
 
33
    code: []
 
34
};
 
35
_yuitest_coverage["build/slider-value-range/slider-value-range.js"].code=["YUI.add('slider-value-range', function (Y, NAME) {","","/**"," * Adds value support for Slider as a range of integers between a configured"," * minimum and maximum value.  For use with <code>Y.Base.build(..)</code> to"," * add the plumbing to <code>Y.SliderBase</code>."," *"," * @module slider"," * @submodule slider-value-range"," */","","// Constants for compression or performance","var MIN       = 'min',","    MAX       = 'max',","    VALUE     = 'value',","//     MINORSTEP = 'minorStep',","//     MAJORSTEP = 'majorStep',","","    round = Math.round;","","/**"," * One class of value algorithm that can be built onto SliderBase.  By default,"," * values range between 0 and 100, but you can configure these on the"," * built Slider class by setting the <code>min</code> and <code>max</code>"," * configurations.  Set the initial value (will cause the thumb to move to the"," * appropriate location on the rail) in configuration as well if appropriate."," *"," * @class SliderValueRange"," */","function SliderValueRange() {","    this._initSliderValueRange();","}","","Y.SliderValueRange = Y.mix( SliderValueRange, {","","    // Prototype properties and methods that will be added onto host class","    prototype: {","","        /**","         * Factor used to translate value -&gt; position -&gt; value.","         *","         * @property _factor","         * @type {Number}","         * @protected","         */","        _factor: 1,","","        /**","         * Stub for construction logic.  Override if extending this class and","         * you need to set something up during the initializer phase.","         *","         * @method _initSliderValueRange","         * @protected","         */","        _initSliderValueRange: function () {},","","        /**","         * Override of stub method in SliderBase that is called at the end of","         * its bindUI stage of render().  Subscribes to internal events to","         * trigger UI and related state updates.","         *","         * @method _bindValueLogic","         * @protected","         */","        _bindValueLogic: function () {","            this.after( {","                minChange  : this._afterMinChange,","                maxChange  : this._afterMaxChange,","                valueChange: this._afterValueChange","            } );","        },","","        /**","         * Move the thumb to appropriate position if necessary.  Also resets","         * the cached offsets and recalculates the conversion factor to","         * translate position to value.","         *","         * @method _syncThumbPosition","         * @protected","         */","        _syncThumbPosition: function () {","            this._calculateFactor();","","            this._setPosition( this.get( VALUE ) );","        },","","        /**","         * Calculates and caches","         * (range between max and min) / (rail length)","         * for fast runtime calculation of position -&gt; value.","         *","         * @method _calculateFactor","         * @protected","         */","        _calculateFactor: function () {","            var length    = this.get( 'length' ),","                thumbSize = this.thumb.getStyle( this._key.dim ),","                min       = this.get( MIN ),","                max       = this.get( MAX );","","            // The default thumb width is based on Sam skin's thumb dimension.","            // This attempts to allow for rendering off-DOM, then attaching","            // without the need to call syncUI().  It is still recommended","            // to call syncUI() in these cases though, just to be sure.","            length = parseFloat( length ) || 150;","            thumbSize = parseFloat( thumbSize ) || 15;","","            this._factor = ( max - min ) / ( length - thumbSize );","","        },","","        /**","         * Dispatch the new position of the thumb into the value setting","         * operations.","         *","         * @method _defThumbMoveFn","         * @param e { EventFacade } The host's thumbMove event","         * @protected","         */","        _defThumbMoveFn: function ( e ) {","            // To prevent set('value', x) from looping back around","            if (e.source !== 'set') {","                this.set(VALUE, this._offsetToValue(e.offset));","            }","        },","","        /**","         * <p>Converts a pixel position into a value.  Calculates current","         * thumb offset from the leading edge of the rail multiplied by the","         * ratio of <code>(max - min) / (constraining dim)</code>.</p>","         *","         * <p>Override this if you want to use a different value mapping","         * algorithm.</p>","         *","         * @method _offsetToValue","         * @param offset { Number } X or Y pixel offset","         * @return { mixed } Value corresponding to the provided pixel offset","         * @protected","         */","        _offsetToValue: function ( offset ) {","","            var value = round( offset * this._factor ) + this.get( MIN );","","            return round( this._nearestValue( value ) );","        },","","        /**","         * Converts a value into a pixel offset for use in positioning","         * the thumb according to the reverse of the","         * <code>_offsetToValue( xy )</code> operation.","         *","         * @method _valueToOffset","         * @param val { Number } The value to map to pixel X or Y position","         * @return { Number } The pixel offset ","         * @protected","         */","        _valueToOffset: function ( value ) {","            var offset = round( ( value - this.get( MIN ) ) / this._factor );","","            return offset;","        },","","        /**","         * Returns the current value.  Override this if you want to introduce","         * output formatting. Otherwise equivalent to slider.get( \"value\" );","         *","         * @method getValue","         * @return {Number}","         */","        getValue: function () {","            return this.get( VALUE );","        },","","        /**","         * Updates the current value.  Override this if you want to introduce","         * input value parsing or preprocessing.  Otherwise equivalent to","         * slider.set( \"value\", v );","         *","         * @method setValue","         * @param val {Number} The new value","         * @return {Slider}","         * @chainable","         */","        setValue: function ( val ) {","            return this.set( VALUE, val );","        },","","        /**","         * Update position according to new min value.  If the new min results","         * in the current value being out of range, the value is set to the","         * closer of min or max.","         *","         * @method _afterMinChange","         * @param e { EventFacade } The <code>min</code> attribute change event.","         * @protected","         */","        _afterMinChange: function ( e ) {","            this._verifyValue();","","            this._syncThumbPosition();","        },","","        /**","         * Update position according to new max value.  If the new max results","         * in the current value being out of range, the value is set to the","         * closer of min or max.","         *","         * @method _afterMaxChange","         * @param e { EventFacade } The <code>max</code> attribute change event.","         * @protected","         */","        _afterMaxChange: function ( e ) {","            this._verifyValue();","","            this._syncThumbPosition();","        },","","        /**","         * Verifies that the current value is within the min - max range.  If","         * not, value is set to either min or max, depending on which is","         * closer.","         *","         * @method _verifyValue","         * @protected","         */","        _verifyValue: function () {","            var value   = this.get( VALUE ),","                nearest = this._nearestValue( value );","","            if ( value !== nearest ) {","                // @TODO Can/should valueChange, minChange, etc be queued","                // events? To make dd.set( 'min', n ); execute after minChange","                // subscribers before on/after valueChange subscribers.","                this.set( VALUE, nearest );","            }","        },","","        /**","         * Propagate change to the thumb position unless the change originated","         * from the thumbMove event.","         *","         * @method _afterValueChange","         * @param e { EventFacade } The <code>valueChange</code> event.","         * @protected","         */","        _afterValueChange: function ( e ) {","            var val = e.newVal;","            this._setPosition( val, { source: 'set' } );","            this.thumb.set('aria-valuenow', val);","            this.thumb.set('aria-valuetext', val);","        },","","        /**","         * Positions the thumb in accordance with the translated value.","         *","         * @method _setPosition","         * @param value {Number} Value to translate to a pixel position","         * @param [options] {Object} Details object to pass to `_uiMoveThumb`","         * @protected","         */","        _setPosition: function ( value, options ) {","            this._uiMoveThumb( this._valueToOffset( value ), options );","        },","","        /**","         * Validates new values assigned to <code>min</code> attribute.  Numbers","         * are acceptable.  Override this to enforce different rules.","         *","         * @method _validateNewMin","         * @param value {Any} Value assigned to <code>min</code> attribute.","         * @return {Boolean} True for numbers.  False otherwise.","         * @protected","         */","        _validateNewMin: function ( value ) {","            return Y.Lang.isNumber( value );","        },","","        /**","         * Validates new values assigned to <code>max</code> attribute.  Numbers","         * are acceptable.  Override this to enforce different rules.","         *","         * @method _validateNewMax","         * @param value { mixed } Value assigned to <code>max</code> attribute.","         * @return { Boolean } True for numbers.  False otherwise.","         * @protected","         */","        _validateNewMax: function ( value ) {","            return Y.Lang.isNumber( value );","        },","","        /**","         * Restricts new values assigned to <code>value</code> attribute to be","         * between the configured <code>min</code> and <code>max</code>.","         * Rounds to nearest integer value.","         *","         * @method _setNewValue","         * @param value { Number } Value assigned to <code>value</code> attribute","         * @return { Number } Normalized and constrained value","         * @protected","         */","        _setNewValue: function ( value ) {","            return round( this._nearestValue( value ) );","        },","","        /**","         * Returns the nearest valid value to the value input.  If the provided","         * value is outside the min - max range, accounting for min > max","         * scenarios, the nearest of either min or max is returned.  Otherwise,","         * the provided value is returned.","         *","         * @method _nearestValue","         * @param value { mixed } Value to test against current min - max range","         * @return { Number } Current min, max, or value if within range","         * @protected","         */","        _nearestValue: function ( value ) {","            var min = this.get( MIN ),","                max = this.get( MAX ),","                tmp;","","            // Account for reverse value range (min > max)","            tmp = ( max > min ) ? max : min;","            min = ( max > min ) ? min : max;","            max = tmp;","","            return ( value < min ) ?","                    min :","                    ( value > max ) ?","                        max :","                        value;","        }","","    },","","    /**","     * Attributes that will be added onto host class.","     *","     * @property ATTRS","     * @type {Object}","     * @static","     * @protected","     */","    ATTRS: {","        /**","         * The value associated with the farthest top, left position of the","         * rail.  Can be greater than the configured <code>max</code> if you","         * want values to increase from right-to-left or bottom-to-top.","         *","         * @attribute min","         * @type { Number }","         * @default 0","         */","        min: {","            value    : 0,","            validator: '_validateNewMin'","        },","","        /**","         * The value associated with the farthest bottom, right position of","         * the rail.  Can be less than the configured <code>min</code> if","         * you want values to increase from right-to-left or bottom-to-top.","         *","         * @attribute max","         * @type { Number }","         * @default 100","         */","        max: {","            value    : 100,","            validator: '_validateNewMax'","        },","        ","        /**","         * amount to increment/decrement the Slider value","         * when the arrow up/down/left/right keys are pressed","         *","         * @attribute minorStep","         * @type {Number}","         * @default 1","         */","        minorStep : {","            value: 1","        },","","        /**","         * amount to increment/decrement the Slider value","         * when the page up/down keys are pressed","         *","         * @attribute majorStep","         * @type {Number}","         * @default 10","         */","        majorStep : {","            value: 10","        },","","        /**","         * The value associated with the thumb's current position on the","         * rail. Defaults to the value inferred from the thumb's current","         * position. Specifying value in the constructor will move the","         * thumb to the position that corresponds to the supplied value.","         *","         * @attribute value","         * @type { Number }","         * @default (inferred from current thumb position)","         */","        value: {","            value : 0,","            setter: '_setNewValue'","        }","    }","}, true );","","","}, '3.7.1', {\"requires\": [\"slider-base\"]});"];
 
36
_yuitest_coverage["build/slider-value-range/slider-value-range.js"].lines = {"1":0,"13":0,"30":0,"31":0,"34":0,"66":0,"82":0,"84":0,"96":0,"105":0,"106":0,"108":0,"122":0,"123":0,"142":0,"144":0,"158":0,"160":0,"171":0,"185":0,"198":0,"200":0,"213":0,"215":0,"227":0,"230":0,"234":0,"247":0,"248":0,"249":0,"250":0,"262":0,"275":0,"288":0,"302":0,"317":0,"322":0,"323":0,"324":0,"326":0};
 
37
_yuitest_coverage["build/slider-value-range/slider-value-range.js"].functions = {"SliderValueRange:30":0,"_bindValueLogic:65":0,"_syncThumbPosition:81":0,"_calculateFactor:95":0,"_defThumbMoveFn:120":0,"_offsetToValue:140":0,"_valueToOffset:157":0,"getValue:170":0,"setValue:184":0,"_afterMinChange:197":0,"_afterMaxChange:212":0,"_verifyValue:226":0,"_afterValueChange:246":0,"_setPosition:261":0,"_validateNewMin:274":0,"_validateNewMax:287":0,"_setNewValue:301":0,"_nearestValue:316":0,"(anonymous 1):1":0};
 
38
_yuitest_coverage["build/slider-value-range/slider-value-range.js"].coveredLines = 40;
 
39
_yuitest_coverage["build/slider-value-range/slider-value-range.js"].coveredFunctions = 19;
 
40
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 1);
 
41
YUI.add('slider-value-range', function (Y, NAME) {
 
42
 
 
43
/**
 
44
 * Adds value support for Slider as a range of integers between a configured
 
45
 * minimum and maximum value.  For use with <code>Y.Base.build(..)</code> to
 
46
 * add the plumbing to <code>Y.SliderBase</code>.
 
47
 *
 
48
 * @module slider
 
49
 * @submodule slider-value-range
 
50
 */
 
51
 
 
52
// Constants for compression or performance
 
53
_yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "(anonymous 1)", 1);
 
54
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 13);
 
55
var MIN       = 'min',
 
56
    MAX       = 'max',
 
57
    VALUE     = 'value',
 
58
//     MINORSTEP = 'minorStep',
 
59
//     MAJORSTEP = 'majorStep',
 
60
 
 
61
    round = Math.round;
 
62
 
 
63
/**
 
64
 * One class of value algorithm that can be built onto SliderBase.  By default,
 
65
 * values range between 0 and 100, but you can configure these on the
 
66
 * built Slider class by setting the <code>min</code> and <code>max</code>
 
67
 * configurations.  Set the initial value (will cause the thumb to move to the
 
68
 * appropriate location on the rail) in configuration as well if appropriate.
 
69
 *
 
70
 * @class SliderValueRange
 
71
 */
 
72
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 30);
 
73
function SliderValueRange() {
 
74
    _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "SliderValueRange", 30);
 
75
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 31);
 
76
this._initSliderValueRange();
 
77
}
 
78
 
 
79
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 34);
 
80
Y.SliderValueRange = Y.mix( SliderValueRange, {
 
81
 
 
82
    // Prototype properties and methods that will be added onto host class
 
83
    prototype: {
 
84
 
 
85
        /**
 
86
         * Factor used to translate value -&gt; position -&gt; value.
 
87
         *
 
88
         * @property _factor
 
89
         * @type {Number}
 
90
         * @protected
 
91
         */
 
92
        _factor: 1,
 
93
 
 
94
        /**
 
95
         * Stub for construction logic.  Override if extending this class and
 
96
         * you need to set something up during the initializer phase.
 
97
         *
 
98
         * @method _initSliderValueRange
 
99
         * @protected
 
100
         */
 
101
        _initSliderValueRange: function () {},
 
102
 
 
103
        /**
 
104
         * Override of stub method in SliderBase that is called at the end of
 
105
         * its bindUI stage of render().  Subscribes to internal events to
 
106
         * trigger UI and related state updates.
 
107
         *
 
108
         * @method _bindValueLogic
 
109
         * @protected
 
110
         */
 
111
        _bindValueLogic: function () {
 
112
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_bindValueLogic", 65);
 
113
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 66);
 
114
this.after( {
 
115
                minChange  : this._afterMinChange,
 
116
                maxChange  : this._afterMaxChange,
 
117
                valueChange: this._afterValueChange
 
118
            } );
 
119
        },
 
120
 
 
121
        /**
 
122
         * Move the thumb to appropriate position if necessary.  Also resets
 
123
         * the cached offsets and recalculates the conversion factor to
 
124
         * translate position to value.
 
125
         *
 
126
         * @method _syncThumbPosition
 
127
         * @protected
 
128
         */
 
129
        _syncThumbPosition: function () {
 
130
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_syncThumbPosition", 81);
 
131
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 82);
 
132
this._calculateFactor();
 
133
 
 
134
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 84);
 
135
this._setPosition( this.get( VALUE ) );
 
136
        },
 
137
 
 
138
        /**
 
139
         * Calculates and caches
 
140
         * (range between max and min) / (rail length)
 
141
         * for fast runtime calculation of position -&gt; value.
 
142
         *
 
143
         * @method _calculateFactor
 
144
         * @protected
 
145
         */
 
146
        _calculateFactor: function () {
 
147
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_calculateFactor", 95);
 
148
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 96);
 
149
var length    = this.get( 'length' ),
 
150
                thumbSize = this.thumb.getStyle( this._key.dim ),
 
151
                min       = this.get( MIN ),
 
152
                max       = this.get( MAX );
 
153
 
 
154
            // The default thumb width is based on Sam skin's thumb dimension.
 
155
            // This attempts to allow for rendering off-DOM, then attaching
 
156
            // without the need to call syncUI().  It is still recommended
 
157
            // to call syncUI() in these cases though, just to be sure.
 
158
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 105);
 
159
length = parseFloat( length ) || 150;
 
160
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 106);
 
161
thumbSize = parseFloat( thumbSize ) || 15;
 
162
 
 
163
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 108);
 
164
this._factor = ( max - min ) / ( length - thumbSize );
 
165
 
 
166
        },
 
167
 
 
168
        /**
 
169
         * Dispatch the new position of the thumb into the value setting
 
170
         * operations.
 
171
         *
 
172
         * @method _defThumbMoveFn
 
173
         * @param e { EventFacade } The host's thumbMove event
 
174
         * @protected
 
175
         */
 
176
        _defThumbMoveFn: function ( e ) {
 
177
            // To prevent set('value', x) from looping back around
 
178
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_defThumbMoveFn", 120);
 
179
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 122);
 
180
if (e.source !== 'set') {
 
181
                _yuitest_coverline("build/slider-value-range/slider-value-range.js", 123);
 
182
this.set(VALUE, this._offsetToValue(e.offset));
 
183
            }
 
184
        },
 
185
 
 
186
        /**
 
187
         * <p>Converts a pixel position into a value.  Calculates current
 
188
         * thumb offset from the leading edge of the rail multiplied by the
 
189
         * ratio of <code>(max - min) / (constraining dim)</code>.</p>
 
190
         *
 
191
         * <p>Override this if you want to use a different value mapping
 
192
         * algorithm.</p>
 
193
         *
 
194
         * @method _offsetToValue
 
195
         * @param offset { Number } X or Y pixel offset
 
196
         * @return { mixed } Value corresponding to the provided pixel offset
 
197
         * @protected
 
198
         */
 
199
        _offsetToValue: function ( offset ) {
 
200
 
 
201
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_offsetToValue", 140);
 
202
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 142);
 
203
var value = round( offset * this._factor ) + this.get( MIN );
 
204
 
 
205
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 144);
 
206
return round( this._nearestValue( value ) );
 
207
        },
 
208
 
 
209
        /**
 
210
         * Converts a value into a pixel offset for use in positioning
 
211
         * the thumb according to the reverse of the
 
212
         * <code>_offsetToValue( xy )</code> operation.
 
213
         *
 
214
         * @method _valueToOffset
 
215
         * @param val { Number } The value to map to pixel X or Y position
 
216
         * @return { Number } The pixel offset 
 
217
         * @protected
 
218
         */
 
219
        _valueToOffset: function ( value ) {
 
220
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_valueToOffset", 157);
 
221
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 158);
 
222
var offset = round( ( value - this.get( MIN ) ) / this._factor );
 
223
 
 
224
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 160);
 
225
return offset;
 
226
        },
 
227
 
 
228
        /**
 
229
         * Returns the current value.  Override this if you want to introduce
 
230
         * output formatting. Otherwise equivalent to slider.get( "value" );
 
231
         *
 
232
         * @method getValue
 
233
         * @return {Number}
 
234
         */
 
235
        getValue: function () {
 
236
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "getValue", 170);
 
237
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 171);
 
238
return this.get( VALUE );
 
239
        },
 
240
 
 
241
        /**
 
242
         * Updates the current value.  Override this if you want to introduce
 
243
         * input value parsing or preprocessing.  Otherwise equivalent to
 
244
         * slider.set( "value", v );
 
245
         *
 
246
         * @method setValue
 
247
         * @param val {Number} The new value
 
248
         * @return {Slider}
 
249
         * @chainable
 
250
         */
 
251
        setValue: function ( val ) {
 
252
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "setValue", 184);
 
253
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 185);
 
254
return this.set( VALUE, val );
 
255
        },
 
256
 
 
257
        /**
 
258
         * Update position according to new min value.  If the new min results
 
259
         * in the current value being out of range, the value is set to the
 
260
         * closer of min or max.
 
261
         *
 
262
         * @method _afterMinChange
 
263
         * @param e { EventFacade } The <code>min</code> attribute change event.
 
264
         * @protected
 
265
         */
 
266
        _afterMinChange: function ( e ) {
 
267
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_afterMinChange", 197);
 
268
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 198);
 
269
this._verifyValue();
 
270
 
 
271
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 200);
 
272
this._syncThumbPosition();
 
273
        },
 
274
 
 
275
        /**
 
276
         * Update position according to new max value.  If the new max results
 
277
         * in the current value being out of range, the value is set to the
 
278
         * closer of min or max.
 
279
         *
 
280
         * @method _afterMaxChange
 
281
         * @param e { EventFacade } The <code>max</code> attribute change event.
 
282
         * @protected
 
283
         */
 
284
        _afterMaxChange: function ( e ) {
 
285
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_afterMaxChange", 212);
 
286
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 213);
 
287
this._verifyValue();
 
288
 
 
289
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 215);
 
290
this._syncThumbPosition();
 
291
        },
 
292
 
 
293
        /**
 
294
         * Verifies that the current value is within the min - max range.  If
 
295
         * not, value is set to either min or max, depending on which is
 
296
         * closer.
 
297
         *
 
298
         * @method _verifyValue
 
299
         * @protected
 
300
         */
 
301
        _verifyValue: function () {
 
302
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_verifyValue", 226);
 
303
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 227);
 
304
var value   = this.get( VALUE ),
 
305
                nearest = this._nearestValue( value );
 
306
 
 
307
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 230);
 
308
if ( value !== nearest ) {
 
309
                // @TODO Can/should valueChange, minChange, etc be queued
 
310
                // events? To make dd.set( 'min', n ); execute after minChange
 
311
                // subscribers before on/after valueChange subscribers.
 
312
                _yuitest_coverline("build/slider-value-range/slider-value-range.js", 234);
 
313
this.set( VALUE, nearest );
 
314
            }
 
315
        },
 
316
 
 
317
        /**
 
318
         * Propagate change to the thumb position unless the change originated
 
319
         * from the thumbMove event.
 
320
         *
 
321
         * @method _afterValueChange
 
322
         * @param e { EventFacade } The <code>valueChange</code> event.
 
323
         * @protected
 
324
         */
 
325
        _afterValueChange: function ( e ) {
 
326
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_afterValueChange", 246);
 
327
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 247);
 
328
var val = e.newVal;
 
329
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 248);
 
330
this._setPosition( val, { source: 'set' } );
 
331
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 249);
 
332
this.thumb.set('aria-valuenow', val);
 
333
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 250);
 
334
this.thumb.set('aria-valuetext', val);
 
335
        },
 
336
 
 
337
        /**
 
338
         * Positions the thumb in accordance with the translated value.
 
339
         *
 
340
         * @method _setPosition
 
341
         * @param value {Number} Value to translate to a pixel position
 
342
         * @param [options] {Object} Details object to pass to `_uiMoveThumb`
 
343
         * @protected
 
344
         */
 
345
        _setPosition: function ( value, options ) {
 
346
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_setPosition", 261);
 
347
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 262);
 
348
this._uiMoveThumb( this._valueToOffset( value ), options );
 
349
        },
 
350
 
 
351
        /**
 
352
         * Validates new values assigned to <code>min</code> attribute.  Numbers
 
353
         * are acceptable.  Override this to enforce different rules.
 
354
         *
 
355
         * @method _validateNewMin
 
356
         * @param value {Any} Value assigned to <code>min</code> attribute.
 
357
         * @return {Boolean} True for numbers.  False otherwise.
 
358
         * @protected
 
359
         */
 
360
        _validateNewMin: function ( value ) {
 
361
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_validateNewMin", 274);
 
362
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 275);
 
363
return Y.Lang.isNumber( value );
 
364
        },
 
365
 
 
366
        /**
 
367
         * Validates new values assigned to <code>max</code> attribute.  Numbers
 
368
         * are acceptable.  Override this to enforce different rules.
 
369
         *
 
370
         * @method _validateNewMax
 
371
         * @param value { mixed } Value assigned to <code>max</code> attribute.
 
372
         * @return { Boolean } True for numbers.  False otherwise.
 
373
         * @protected
 
374
         */
 
375
        _validateNewMax: function ( value ) {
 
376
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_validateNewMax", 287);
 
377
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 288);
 
378
return Y.Lang.isNumber( value );
 
379
        },
 
380
 
 
381
        /**
 
382
         * Restricts new values assigned to <code>value</code> attribute to be
 
383
         * between the configured <code>min</code> and <code>max</code>.
 
384
         * Rounds to nearest integer value.
 
385
         *
 
386
         * @method _setNewValue
 
387
         * @param value { Number } Value assigned to <code>value</code> attribute
 
388
         * @return { Number } Normalized and constrained value
 
389
         * @protected
 
390
         */
 
391
        _setNewValue: function ( value ) {
 
392
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_setNewValue", 301);
 
393
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 302);
 
394
return round( this._nearestValue( value ) );
 
395
        },
 
396
 
 
397
        /**
 
398
         * Returns the nearest valid value to the value input.  If the provided
 
399
         * value is outside the min - max range, accounting for min > max
 
400
         * scenarios, the nearest of either min or max is returned.  Otherwise,
 
401
         * the provided value is returned.
 
402
         *
 
403
         * @method _nearestValue
 
404
         * @param value { mixed } Value to test against current min - max range
 
405
         * @return { Number } Current min, max, or value if within range
 
406
         * @protected
 
407
         */
 
408
        _nearestValue: function ( value ) {
 
409
            _yuitest_coverfunc("build/slider-value-range/slider-value-range.js", "_nearestValue", 316);
 
410
_yuitest_coverline("build/slider-value-range/slider-value-range.js", 317);
 
411
var min = this.get( MIN ),
 
412
                max = this.get( MAX ),
 
413
                tmp;
 
414
 
 
415
            // Account for reverse value range (min > max)
 
416
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 322);
 
417
tmp = ( max > min ) ? max : min;
 
418
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 323);
 
419
min = ( max > min ) ? min : max;
 
420
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 324);
 
421
max = tmp;
 
422
 
 
423
            _yuitest_coverline("build/slider-value-range/slider-value-range.js", 326);
 
424
return ( value < min ) ?
 
425
                    min :
 
426
                    ( value > max ) ?
 
427
                        max :
 
428
                        value;
 
429
        }
 
430
 
 
431
    },
 
432
 
 
433
    /**
 
434
     * Attributes that will be added onto host class.
 
435
     *
 
436
     * @property ATTRS
 
437
     * @type {Object}
 
438
     * @static
 
439
     * @protected
 
440
     */
 
441
    ATTRS: {
 
442
        /**
 
443
         * The value associated with the farthest top, left position of the
 
444
         * rail.  Can be greater than the configured <code>max</code> if you
 
445
         * want values to increase from right-to-left or bottom-to-top.
 
446
         *
 
447
         * @attribute min
 
448
         * @type { Number }
 
449
         * @default 0
 
450
         */
 
451
        min: {
 
452
            value    : 0,
 
453
            validator: '_validateNewMin'
 
454
        },
 
455
 
 
456
        /**
 
457
         * The value associated with the farthest bottom, right position of
 
458
         * the rail.  Can be less than the configured <code>min</code> if
 
459
         * you want values to increase from right-to-left or bottom-to-top.
 
460
         *
 
461
         * @attribute max
 
462
         * @type { Number }
 
463
         * @default 100
 
464
         */
 
465
        max: {
 
466
            value    : 100,
 
467
            validator: '_validateNewMax'
 
468
        },
 
469
        
 
470
        /**
 
471
         * amount to increment/decrement the Slider value
 
472
         * when the arrow up/down/left/right keys are pressed
 
473
         *
 
474
         * @attribute minorStep
 
475
         * @type {Number}
 
476
         * @default 1
 
477
         */
 
478
        minorStep : {
 
479
            value: 1
 
480
        },
 
481
 
 
482
        /**
 
483
         * amount to increment/decrement the Slider value
 
484
         * when the page up/down keys are pressed
 
485
         *
 
486
         * @attribute majorStep
 
487
         * @type {Number}
 
488
         * @default 10
 
489
         */
 
490
        majorStep : {
 
491
            value: 10
 
492
        },
 
493
 
 
494
        /**
 
495
         * The value associated with the thumb's current position on the
 
496
         * rail. Defaults to the value inferred from the thumb's current
 
497
         * position. Specifying value in the constructor will move the
 
498
         * thumb to the position that corresponds to the supplied value.
 
499
         *
 
500
         * @attribute value
 
501
         * @type { Number }
 
502
         * @default (inferred from current thumb position)
 
503
         */
 
504
        value: {
 
505
            value : 0,
 
506
            setter: '_setNewValue'
 
507
        }
 
508
    }
 
509
}, true );
 
510
 
 
511
 
 
512
}, '3.7.1', {"requires": ["slider-base"]});