source: trunk/admin/themes/default/js/doubleSlider.js @ 29249

Last change on this file since 29249 was 29249, checked in by mistic100, 10 years ago

create a mini jquery plugin for sliders on batch manager + async load

File size: 1021 bytes
Line 
1(function($){
2
3/**
4 * OPTIONS:
5 * values {mixed[]}
6 * selected {object} min and max
7 * text {string}
8 */
9$.fn.pwgDoubleSlider = function(options) {
10  var that = this;
11 
12  function onChange(e, ui) {
13    that.find('[data-input=min]').val(options.values[ui.values[0]]);
14    that.find('[data-input=max]').val(options.values[ui.values[1]]);
15
16    that.find('.slider-info').html(sprintf(
17      options.text,
18      options.values[ui.values[0]],
19      options.values[ui.values[1]]
20    ));
21  }
22
23  var slider = this.find('.slider-slider').slider({
24    range: true,
25    min: 0,
26    max: options.values.length - 1,
27    values: [
28      options.values.indexOf(options.selected.min),
29      options.values.indexOf(options.selected.max)
30    ],
31    slide: onChange,
32    change: onChange
33  });
34
35  this.find('.slider-choice').on('click', function(){
36    slider.slider('values', 0, options.values.indexOf($(this).data('min')));
37    slider.slider('values', 1, options.values.indexOf($(this).data('max')));
38  });
39
40  return this;
41};
42
43}(jQuery));
Note: See TracBrowser for help on using the repository browser.