From f83e780249d55dd3d463cd0f21faf92b4215a508 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Fri, 12 Sep 2014 11:35:32 +0000 Subject: add URL filter input for dimension and filesize + batch_manager_url_filter trigger + fixes in doubleSlider.js git-svn-id: http://piwigo.org/svn/trunk@29505 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/themes/default/js/doubleSlider.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'admin/themes/default/js') diff --git a/admin/themes/default/js/doubleSlider.js b/admin/themes/default/js/doubleSlider.js index 490331feb..c03c3d52f 100644 --- a/admin/themes/default/js/doubleSlider.js +++ b/admin/themes/default/js/doubleSlider.js @@ -20,14 +20,33 @@ $.fn.pwgDoubleSlider = function(options) { )); } + function findClosest(array, value) { + var closest = null, index = -1; + $.each(array, function(i, v){ + if (closest == null || Math.abs(v - value) < Math.abs(closest - value)) { + closest = v; + index = i; + } + }); + return index; + } + + var values = [ + options.values.indexOf(options.selected.min), + options.values.indexOf(options.selected.max) + ]; + if (values[0] == -1) { + values[0] = findClosest(options.values, options.selected.min); + } + if (values[1] == -1) { + values[1] = findClosest(options.values, options.selected.max); + } + var slider = this.find('.slider-slider').slider({ range: true, min: 0, max: options.values.length - 1, - values: [ - options.values.indexOf(options.selected.min), - options.values.indexOf(options.selected.max) - ], + values: values, slide: onChange, change: onChange }); -- cgit v1.2.3