summaryrefslogtreecommitdiff
path: root/xstatic/pkg/jquery_ui/data/ui/jquery.ui.slider.js
diff options
context:
space:
mode:
Diffstat (limited to 'xstatic/pkg/jquery_ui/data/ui/jquery.ui.slider.js')
-rw-r--r--xstatic/pkg/jquery_ui/data/ui/jquery.ui.slider.js338
1 files changed, 185 insertions, 153 deletions
diff --git a/xstatic/pkg/jquery_ui/data/ui/jquery.ui.slider.js b/xstatic/pkg/jquery_ui/data/ui/jquery.ui.slider.js
index c3daa7a..039c0ef 100644
--- a/xstatic/pkg/jquery_ui/data/ui/jquery.ui.slider.js
+++ b/xstatic/pkg/jquery_ui/data/ui/jquery.ui.slider.js
@@ -1,8 +1,8 @@
/*!
- * jQuery UI Slider 1.9.2
+ * jQuery UI Slider 1.10.4
* http://jqueryui.com
*
- * Copyright 2012 jQuery Foundation and other contributors
+ * Copyright 2014 jQuery Foundation and other contributors
* Released under the MIT license.
* http://jquery.org/license
*
@@ -20,7 +20,7 @@
var numPages = 5;
$.widget( "ui.slider", $.ui.mouse, {
- version: "1.9.2",
+ version: "1.10.4",
widgetEventPrefix: "slide",
options: {
@@ -32,16 +32,16 @@ $.widget( "ui.slider", $.ui.mouse, {
range: false,
step: 1,
value: 0,
- values: null
+ values: null,
+
+ // callbacks
+ change: null,
+ slide: null,
+ start: null,
+ stop: null
},
_create: function() {
- var i, handleCount,
- o = this.options,
- existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
- handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
- handles = [];
-
this._keySliding = false;
this._mouseSliding = false;
this._animateOff = true;
@@ -54,31 +54,34 @@ $.widget( "ui.slider", $.ui.mouse, {
" ui-slider-" + this.orientation +
" ui-widget" +
" ui-widget-content" +
- " ui-corner-all" +
- ( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
+ " ui-corner-all");
- this.range = $([]);
+ this._refresh();
+ this._setOption( "disabled", this.options.disabled );
- if ( o.range ) {
- if ( o.range === true ) {
- if ( !o.values ) {
- o.values = [ this._valueMin(), this._valueMin() ];
- }
- if ( o.values.length && o.values.length !== 2 ) {
- o.values = [ o.values[0], o.values[0] ];
- }
- }
+ this._animateOff = false;
+ },
- this.range = $( "<div></div>" )
- .appendTo( this.element )
- .addClass( "ui-slider-range" +
- // note: this isn't the most fittingly semantic framework class for this element,
- // but worked best visually with a variety of themes
- " ui-widget-header" +
- ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
- }
+ _refresh: function() {
+ this._createRange();
+ this._createHandles();
+ this._setupEvents();
+ this._refreshValue();
+ },
+
+ _createHandles: function() {
+ var i, handleCount,
+ options = this.options,
+ existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
+ handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
+ handles = [];
- handleCount = ( o.values && o.values.length ) || 1;
+ handleCount = ( options.values && options.values.length ) || 1;
+
+ if ( existingHandles.length > handleCount ) {
+ existingHandles.slice( handleCount ).remove();
+ existingHandles = existingHandles.slice( 0, handleCount );
+ }
for ( i = existingHandles.length; i < handleCount; i++ ) {
handles.push( handle );
@@ -88,124 +91,71 @@ $.widget( "ui.slider", $.ui.mouse, {
this.handle = this.handles.eq( 0 );
- this.handles.add( this.range ).filter( "a" )
- .click(function( event ) {
- event.preventDefault();
- })
- .mouseenter(function() {
- if ( !o.disabled ) {
- $( this ).addClass( "ui-state-hover" );
- }
- })
- .mouseleave(function() {
- $( this ).removeClass( "ui-state-hover" );
- })
- .focus(function() {
- if ( !o.disabled ) {
- $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
- $( this ).addClass( "ui-state-focus" );
- } else {
- $( this ).blur();
- }
- })
- .blur(function() {
- $( this ).removeClass( "ui-state-focus" );
- });
-
this.handles.each(function( i ) {
$( this ).data( "ui-slider-handle-index", i );
});
+ },
- this._on( this.handles, {
- keydown: function( event ) {
- var allowed, curVal, newVal, step,
- index = $( event.target ).data( "ui-slider-handle-index" );
-
- switch ( event.keyCode ) {
- case $.ui.keyCode.HOME:
- case $.ui.keyCode.END:
- case $.ui.keyCode.PAGE_UP:
- case $.ui.keyCode.PAGE_DOWN:
- case $.ui.keyCode.UP:
- case $.ui.keyCode.RIGHT:
- case $.ui.keyCode.DOWN:
- case $.ui.keyCode.LEFT:
- event.preventDefault();
- if ( !this._keySliding ) {
- this._keySliding = true;
- $( event.target ).addClass( "ui-state-active" );
- allowed = this._start( event, index );
- if ( allowed === false ) {
- return;
- }
- }
- break;
- }
-
- step = this.options.step;
- if ( this.options.values && this.options.values.length ) {
- curVal = newVal = this.values( index );
- } else {
- curVal = newVal = this.value();
- }
-
- switch ( event.keyCode ) {
- case $.ui.keyCode.HOME:
- newVal = this._valueMin();
- break;
- case $.ui.keyCode.END:
- newVal = this._valueMax();
- break;
- case $.ui.keyCode.PAGE_UP:
- newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
- break;
- case $.ui.keyCode.PAGE_DOWN:
- newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
- break;
- case $.ui.keyCode.UP:
- case $.ui.keyCode.RIGHT:
- if ( curVal === this._valueMax() ) {
- return;
- }
- newVal = this._trimAlignValue( curVal + step );
- break;
- case $.ui.keyCode.DOWN:
- case $.ui.keyCode.LEFT:
- if ( curVal === this._valueMin() ) {
- return;
- }
- newVal = this._trimAlignValue( curVal - step );
- break;
+ _createRange: function() {
+ var options = this.options,
+ classes = "";
+
+ if ( options.range ) {
+ if ( options.range === true ) {
+ if ( !options.values ) {
+ options.values = [ this._valueMin(), this._valueMin() ];
+ } else if ( options.values.length && options.values.length !== 2 ) {
+ options.values = [ options.values[0], options.values[0] ];
+ } else if ( $.isArray( options.values ) ) {
+ options.values = options.values.slice(0);
}
+ }
- this._slide( event, index, newVal );
- },
- keyup: function( event ) {
- var index = $( event.target ).data( "ui-slider-handle-index" );
+ if ( !this.range || !this.range.length ) {
+ this.range = $( "<div></div>" )
+ .appendTo( this.element );
- if ( this._keySliding ) {
- this._keySliding = false;
- this._stop( event, index );
- this._change( event, index );
- $( event.target ).removeClass( "ui-state-active" );
- }
+ classes = "ui-slider-range" +
+ // note: this isn't the most fittingly semantic framework class for this element,
+ // but worked best visually with a variety of themes
+ " ui-widget-header ui-corner-all";
+ } else {
+ this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
+ // Handle range switching from true to min/max
+ .css({
+ "left": "",
+ "bottom": ""
+ });
}
- });
- this._refreshValue();
+ this.range.addClass( classes +
+ ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
+ } else {
+ if ( this.range ) {
+ this.range.remove();
+ }
+ this.range = null;
+ }
+ },
- this._animateOff = false;
+ _setupEvents: function() {
+ var elements = this.handles.add( this.range ).filter( "a" );
+ this._off( elements );
+ this._on( elements, this._handleEvents );
+ this._hoverable( elements );
+ this._focusable( elements );
},
_destroy: function() {
this.handles.remove();
- this.range.remove();
+ if ( this.range ) {
+ this.range.remove();
+ }
this.element
.removeClass( "ui-slider" +
" ui-slider-horizontal" +
" ui-slider-vertical" +
- " ui-slider-disabled" +
" ui-widget" +
" ui-widget-content" +
" ui-corner-all" );
@@ -233,21 +183,15 @@ $.widget( "ui.slider", $.ui.mouse, {
distance = this._valueMax() - this._valueMin() + 1;
this.handles.each(function( i ) {
var thisDistance = Math.abs( normValue - that.values(i) );
- if ( distance > thisDistance ) {
+ if (( distance > thisDistance ) ||
+ ( distance === thisDistance &&
+ (i === that._lastChangedValue || that.values(i) === o.min ))) {
distance = thisDistance;
closestHandle = $( this );
index = i;
}
});
- // workaround for bug #3736 (if both handles of a range are at 0,
- // the first is always used as the one with least distance,
- // and moving it is obviously prevented by preventing negative ranges)
- if( o.range === true && this.values(1) === o.min ) {
- index += 1;
- closestHandle = $( this.handles[index] );
- }
-
allowed = this._start( event, index );
if ( allowed === false ) {
return false;
@@ -261,7 +205,7 @@ $.widget( "ui.slider", $.ui.mouse, {
.focus();
offset = closestHandle.offset();
- mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
+ mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
top: event.pageY - offset.top -
@@ -378,7 +322,7 @@ $.widget( "ui.slider", $.ui.mouse, {
} );
otherVal = this.values( index ? 0 : 1 );
if ( allowed !== false ) {
- this.values( index, newVal, true );
+ this.values( index, newVal );
}
}
} else {
@@ -419,6 +363,9 @@ $.widget( "ui.slider", $.ui.mouse, {
uiHash.values = this.values();
}
+ //store the last changed value index for reference when handles overlap
+ this._lastChangedValue = index;
+
this._trigger( "change", event, uiHash );
}
},
@@ -471,6 +418,16 @@ $.widget( "ui.slider", $.ui.mouse, {
var i,
valsLength = 0;
+ if ( key === "range" && this.options.range === true ) {
+ if ( value === "min" ) {
+ this.options.value = this._values( 0 );
+ this.options.values = null;
+ } else if ( value === "max" ) {
+ this.options.value = this._values( this.options.values.length-1 );
+ this.options.values = null;
+ }
+ }
+
if ( $.isArray( this.options.values ) ) {
valsLength = this.options.values.length;
}
@@ -478,17 +435,6 @@ $.widget( "ui.slider", $.ui.mouse, {
$.Widget.prototype._setOption.apply( this, arguments );
switch ( key ) {
- case "disabled":
- if ( value ) {
- this.handles.filter( ".ui-state-focus" ).blur();
- this.handles.removeClass( "ui-state-hover" );
- this.handles.prop( "disabled", true );
- this.element.addClass( "ui-disabled" );
- } else {
- this.handles.prop( "disabled", false );
- this.element.removeClass( "ui-disabled" );
- }
- break;
case "orientation":
this._detectOrientation();
this.element
@@ -516,6 +462,11 @@ $.widget( "ui.slider", $.ui.mouse, {
this._refreshValue();
this._animateOff = false;
break;
+ case "range":
+ this._animateOff = true;
+ this._refresh();
+ this._animateOff = false;
+ break;
}
},
@@ -541,7 +492,7 @@ $.widget( "ui.slider", $.ui.mouse, {
val = this._trimAlignValue( val );
return val;
- } else {
+ } else if ( this.options.values && this.options.values.length ) {
// .slice() creates a copy of the array
// this copy gets trimmed by min and max and then returned
vals = this.options.values.slice();
@@ -550,6 +501,8 @@ $.widget( "ui.slider", $.ui.mouse, {
}
return vals;
+ } else {
+ return [];
}
},
@@ -637,6 +590,85 @@ $.widget( "ui.slider", $.ui.mouse, {
this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
}
}
+ },
+
+ _handleEvents: {
+ keydown: function( event ) {
+ var allowed, curVal, newVal, step,
+ index = $( event.target ).data( "ui-slider-handle-index" );
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.HOME:
+ case $.ui.keyCode.END:
+ case $.ui.keyCode.PAGE_UP:
+ case $.ui.keyCode.PAGE_DOWN:
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.RIGHT:
+ case $.ui.keyCode.DOWN:
+ case $.ui.keyCode.LEFT:
+ event.preventDefault();
+ if ( !this._keySliding ) {
+ this._keySliding = true;
+ $( event.target ).addClass( "ui-state-active" );
+ allowed = this._start( event, index );
+ if ( allowed === false ) {
+ return;
+ }
+ }
+ break;
+ }
+
+ step = this.options.step;
+ if ( this.options.values && this.options.values.length ) {
+ curVal = newVal = this.values( index );
+ } else {
+ curVal = newVal = this.value();
+ }
+
+ switch ( event.keyCode ) {
+ case $.ui.keyCode.HOME:
+ newVal = this._valueMin();
+ break;
+ case $.ui.keyCode.END:
+ newVal = this._valueMax();
+ break;
+ case $.ui.keyCode.PAGE_UP:
+ newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
+ break;
+ case $.ui.keyCode.PAGE_DOWN:
+ newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
+ break;
+ case $.ui.keyCode.UP:
+ case $.ui.keyCode.RIGHT:
+ if ( curVal === this._valueMax() ) {
+ return;
+ }
+ newVal = this._trimAlignValue( curVal + step );
+ break;
+ case $.ui.keyCode.DOWN:
+ case $.ui.keyCode.LEFT:
+ if ( curVal === this._valueMin() ) {
+ return;
+ }
+ newVal = this._trimAlignValue( curVal - step );
+ break;
+ }
+
+ this._slide( event, index, newVal );
+ },
+ click: function( event ) {
+ event.preventDefault();
+ },
+ keyup: function( event ) {
+ var index = $( event.target ).data( "ui-slider-handle-index" );
+
+ if ( this._keySliding ) {
+ this._keySliding = false;
+ this._stop( event, index );
+ this._change( event, index );
+ $( event.target ).removeClass( "ui-state-active" );
+ }
+ }
}
});