-
Notifications
You must be signed in to change notification settings - Fork 532
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⭐ new: change slider to ion.rangeSlider
- Loading branch information
Showing
7 changed files
with
904 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,63 @@ | ||
<template lang="jade"> | ||
input.form-control(type="text", number, v-model="value", :data-slider-value="value", :data-slider-min="schema.min", :data-slider-max="schema.max", :disabled="disabled", :placeholder="schema.placeholder") | ||
input(type="text", :data-min="schema.min", :data-max="schema.max", :data-step="schema.step", :data-disable="disabled") | ||
</template> | ||
|
||
<script> | ||
import abstractField from "./abstractField"; | ||
import { defaults, isArray } from "lodash"; | ||
export default { | ||
mixins: [ abstractField ], | ||
watch: { | ||
model: function() { | ||
if ($.fn.slider) | ||
$(this.$el).slider("setValue", this.value); | ||
if ($.fn.ionRangeSlider) { | ||
let valueFrom, valueTo; | ||
if (isArray(this.value)) { | ||
[ valueFrom, valueTo ] = this.value; | ||
} else | ||
valueFrom = this.value; | ||
$(this.$el).data("ionRangeSlider").update({ | ||
from: valueFrom, | ||
to: valueTo | ||
}); | ||
} | ||
} | ||
}, | ||
ready() { | ||
if ($.fn.slider) | ||
$(this.$el).slider(this.schema.sliderOptions); | ||
if ($.fn.ionRangeSlider) { | ||
let valueFrom, valueTo; | ||
if (isArray(this.value)) { | ||
[ valueFrom, valueTo ] = this.value; | ||
} else | ||
valueFrom = this.value; | ||
$(this.$el).ionRangeSlider(defaults(this.schema.sliderOptions || {}, { | ||
type: "single", | ||
grid: true, | ||
hide_min_max: true, | ||
from: valueFrom, | ||
to: valueTo, | ||
onChange: (slider) => { | ||
if (this.schema.sliderOptions.type == "double") { | ||
this.value = [ slider.from, slider.to ]; | ||
} else { | ||
this.value = slider.from; | ||
} | ||
} | ||
})); | ||
} | ||
else | ||
console.warn("ion.rangeSlider library is missing. Please download from https://github.com/IonDen/ion.rangeSlider and load the script and CSS in the HTML head section!"); | ||
} | ||
}; | ||
</script> | ||
|
||
|
||
<style lang="sass"> | ||
.slider.slider-horizontal { | ||
width: 100% !important; | ||
.irs { | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters