forked from ghusse/jQRangeSlider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jQEditRangeSlider.js
93 lines (71 loc) · 2.15 KB
/
jQEditRangeSlider.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* jQRangeSlider
* A javascript slider selector that supports dates
*
* Copyright (C) Guillaume Gautreau 2012
* Dual licensed under the MIT or GPL Version 2 licenses.
*
*/
(function ($, undefined) {
"use strict";
$.widget("ui.editRangeSlider", $.ui.rangeSlider, {
options:{
type: "text",
round: 1
},
_create: function(){
$.ui.rangeSlider.prototype._create.apply(this);
this.element.addClass("ui-editRangeSlider");
},
destroy: function(){
this.element.removeClass("ui-editRangeSlider");
$.ui.rangeSlider.prototype.destroy.apply(this);
},
_setOption: function(key, value){
if (key === "type" || key === "step"){
this._setLabelOption(key, value);
}
if (key === "type"){
this.options[key] = this.labels.left === null ? value : this._leftLabel("option", key);
}
$.ui.rangeSlider.prototype._setOption.apply(this, [key, value]);
},
_setLabelOption: function(key, value){
if (this.labels.left !== null){
this._leftLabel("option", key, value);
this._rightLabel("option", key, value);
}
},
_labelType: function(){
return "editRangeSliderLabel";
},
_createLabel: function(label, handle){
var result = $.ui.rangeSlider.prototype._createLabel.apply(this, [label, handle]);
if (label === null){
result.bind("valueChange", $.proxy(this._onValueChange, this));
}
return result;
},
_addPropertiesToParameter: function(parameters){
parameters.type = this.options.type;
parameters.step = this.options.step;
parameters.id = this.element.attr("id");
return parameters;
},
_getLabelConstructorParameters: function(label, handle){
var parameters = $.ui.rangeSlider.prototype._getLabelConstructorParameters.apply(this, [label, handle]);
return this._addPropertiesToParameter(parameters);
},
_getLabelRefreshParameters: function(label, handle){
var parameters = $.ui.rangeSlider.prototype._getLabelRefreshParameters.apply(this, [label, handle]);
return this._addPropertiesToParameter(parameters);
},
_onValueChange: function(event, data){
if (data.isLeft){
this.min(data.value);
}else{
this.max(data.value);
}
}
});
}(jQuery));