Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

separate values and text #405

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 26 additions & 7 deletions js/ion.rangeSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@
decorate_both: true,
values_separator: " — ",

input_values: [],
input_values_separator: ";",

disable: false,
Expand Down Expand Up @@ -375,11 +376,13 @@
decorate_both: $inp.data("decorateBoth"),
values_separator: $inp.data("valuesSeparator"),

input_values: $inp.data("input-values"),
input_values_separator: $inp.data("inputValuesSeparator"),

disable: $inp.data("disable")
};
config_from_data.values = config_from_data.values && config_from_data.values.split(",");
config_from_data.input_values = config_from_data.input_values && config_from_data.input_values.split(",");

for (prop in config_from_data) {
if (config_from_data.hasOwnProperty(prop)) {
Expand All @@ -402,12 +405,18 @@
val[1] = +val[1];
}

if (options && options.values && options.values.length) {
if (config_from_data.input_values && config_from_data.input_values.length) {
config.from = val[0] && config_from_data.input_values.indexOf(''+val[0]);
config.to = val[1] && config_from_data.input_values.indexOf(''+val[1]);
} else if (options && options.values && options.values.length) {
config.from = val[0] && options.values.indexOf(val[0]);
config.to = val[1] && options.values.indexOf(val[1]);
config.to = val[1] && options.values.indexOf(val[1]);
} else if (config_from_data && config_from_data.values && config_from_data.values.length) {
config.from = val[0] && config_from_data.values.indexOf(''+val[0]);
config.to = val[1] && config_from_data.values.indexOf(''+val[1]);
} else {
config.from = val[0] && +val[0];
config.to = val[1] && +val[1];
config.to = val[1] && +val[1];
}
}

Expand Down Expand Up @@ -439,10 +448,12 @@
from: this.options.from,
from_percent: 0,
from_value: null,
from_input_value: null,

to: this.options.to,
to_percent: 0,
to_value: null
to_value: null,
to_input_value: null,
};


Expand Down Expand Up @@ -745,7 +756,7 @@
this.is_finish = true;
this.callOnFinish();
}

this.dragging = false;
},

Expand Down Expand Up @@ -1100,6 +1111,8 @@

if (this.options.values.length) {
this.result.from_value = this.options.values[this.result.from];
this.result.from_input_value = this.options.input_values[this.result.from];
if (this.result.from_input_value == undefined) this.result.from_input_value = this.result.from_value
}
} else {
this.coords.p_bar_x = this.toFixed(this.coords.p_from_fake + (this.coords.p_handle / 2));
Expand All @@ -1112,7 +1125,11 @@

if (this.options.values.length) {
this.result.from_value = this.options.values[this.result.from];
this.result.from_input_value = this.options.input_values[this.result.from];
if (this.result.from_input_value == undefined) this.result.from_input_value = this.result.from_value
this.result.to_value = this.options.values[this.result.to];
this.result.to_input_value = this.options.input_values[this.result.to];
if (this.result.to_input_value == undefined) this.result.to_input_value = this.result.to_value
}
}

Expand Down Expand Up @@ -1321,7 +1338,7 @@
this.$cache.single[0].style.left = this.labels.p_single_left + "%";

if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value);
this.$cache.input.prop("value", this.result.from_input_value);
} else {
this.$cache.input.prop("value", this.result.from);
}
Expand All @@ -1340,7 +1357,7 @@
this.$cache.single[0].style.left = this.labels.p_single_left + "%";

if (this.options.values.length) {
this.$cache.input.prop("value", this.result.from_value + this.options.input_values_separator + this.result.to_value);
this.$cache.input.prop("value", this.result.from_input_value + this.options.input_values_separator + this.result.to_input_value);
} else {
this.$cache.input.prop("value", this.result.from + this.options.input_values_separator + this.result.to);
}
Expand Down Expand Up @@ -2015,6 +2032,7 @@
this.result.from_percent = this.convertToPercent(this.result.from);
if (this.options.values) {
this.result.from_value = this.options.values[this.result.from];
this.result.from_input_value = this.options.input_values[this.result.from];
}
},

Expand All @@ -2023,6 +2041,7 @@
this.result.to_percent = this.convertToPercent(this.result.to);
if (this.options.values) {
this.result.to_value = this.options.values[this.result.to];
this.result.to_input_value = this.options.input_values[this.result.to];
}
},

Expand Down