1/*! 2 * Copyright (c) 2012 Ben Olson (https://github.com/bseth99/jquery-ui-extensions) 3 * 4 * Permission is hereby granted, free of charge, to any person 5 * obtaining a copy of this software and associated documentation 6 * files (the "Software"), to deal in the Software without 7 * restriction, including without limitation the rights to use, 8 * copy, modify, merge, publish, distribute, sublicense, and/or sell 9 * copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following 11 * conditions: 12 * 13 * The above copyright notice and this permission notice shall be 14 * included in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 * OTHER DEALINGS IN THE SOFTWARE. 24 * 25 * Depends: 26 * jquery.ui.core.js 27 * jquery.ui.widget.js 28 * jquery.ui.mouse.js 29 * jquery.ui.slider.js 30 */ 31 32(function( $, undefined ) { 33 34 35 $.widget( "ui.slider", $.ui.slider, { 36 37 options: { 38 tickInterval: 0, 39 tickLabels: null 40 }, 41 42 uiSlider: null, 43 tickInterval: 0, 44 45 _create: function( ) { 46 this._detectOrientation(); 47 this.uiSlider = 48 this.element 49 .prepend( '<div class="ui-slider-labels"></div>' ) 50 .addClass( this.orientation ); 51 52 this._super(); 53 54 if (this.options.ticks) { 55 this._alignWithStep(); 56 57 this._drawLabels(); 58 } 59 }, 60 61 _drawLabels: function () { 62 var $lbl = this.uiSlider.children( '.ui-slider-labels' ); 63 if (this.options.ticks) { 64 var labels = this.options.tickLabels || {}, 65 dir = this.orientation == 'horizontal' ? 'left' : 'bottom', 66 min = this.options.min, 67 max = this.options.max, 68 inr = this.tickInterval, 69 cnt = parseInt(( max - min ) / inr), 70 i = 0; 71 $lbl.html(''); 72 73 var html = ''; 74 75 for (;i<=cnt & cnt < 100;i++) { 76 html += '<div class="ui-slider-label-ticks" style="' +dir +':' + (Math.round( i / cnt * 10000 ) / 100) + '%;">' + 77 '<span>'+( labels[i*inr+min] ? labels[i*inr+min] : i )+'</span>'+ 78 '</div>'; 79 } 80 $lbl.html(html); 81 } else { 82 $lbl.html(''); 83 } 84 85 }, 86 87 _setOption: function( key, value ) { 88 89 this._super( key, value ); 90 91 if (this.options.ticks) { 92 switch ( key ) { 93 case 'min': 94 case 'max': 95 this._setStepSize(); 96 break; 97 case 'tickInterval': 98 case 'tickLabels': 99 case 'step': 100 case 'ticks': 101 this._alignWithStep(); 102 this._drawLabels(); 103 break; 104 105 case 'orientation': 106 107 this.element 108 .removeClass( 'horizontal vertical' ) 109 .addClass( this.orientation ); 110 111 this._drawLabels(); 112 break; 113 } 114 } 115 }, 116 117 _setStepSize: function(){ 118 if (this.options.ticks) { 119 var max = this.options.max; 120 var min = this.options.min; 121 var maxVal = max-min; 122 var stp = parseFloat(maxVal / 50); 123 124 this.options.step = stp; 125 } 126 }, 127 128 _alignWithStep: function () { 129 if ( this.options.tickInterval < this.options.step ) 130 this.tickInterval = this.options.step; 131 else 132 this.tickInterval = this.options.tickInterval; 133 }, 134 135 _destroy: function() { 136 this._super(); 137 this.uiSlider.replaceWith( this.element ); 138 }, 139 widget: function() { 140 return this.uiSlider; 141 } 142 143 }); 144 145}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.