-
Notifications
You must be signed in to change notification settings - Fork 147
/
jQEditRangeSlider.js
99 lines (75 loc) · 2.03 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
94
95
96
97
98
99
/**
* 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(){
this._super();
this.element.addClass("ui-editRangeSlider");
},
destroy: function(){
this.element.removeClass("ui-editRangeSlider");
this._super();
},
_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);
}
this._super(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 = this._super(label,handle);
if (label === null){
result.on("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 = this._super(label,handle);
return this._addPropertiesToParameter(parameters);
},
_getLabelRefreshParameters: function(label, handle){
var parameters = this._super(label,handle);
return this._addPropertiesToParameter(parameters);
},
_onValueChange: function(event, data){
var changed = false;
if (data.isLeft){
changed = this._values.min !== this.min(data.value);
}else{
changed = this._values.max !== this.max(data.value);
}
if (changed){
this._trigger("userValuesChanged");
}
}
});
}(jQuery));