PluginProbe
WP Directory Kit / 1.1.8
WP Directory Kit v1.1.8
1.5.9 1.5.7 1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 All 37 releases
wpdirectorykit / public / js / wdk-slider-range.js

wdk-slider-range.js in WP Directory Kit 1.1.8, at public/js/wdk-slider-range.js

220 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // Field slider range
2 // © Denis Ineshin, 2019
3 //
4 // Project page: http://ionden.com/a/plugins/ion.rangeSlider/en.html
5 // GitHub page: https://github.com/IonDen/ion.rangeSlider
6 //
7 // Released under MIT licence:
8 // http://ionden.com/a/plugins/licence-en.html
9 // =====================================================================================================================
10
11 ;(function(factory) {
12 if ((typeof jQuery === 'undefined' || !jQuery) && typeof define === "function" && define.amd) {
13 define(["jquery"], function (jQuery) {
14 return factory(jQuery, document, window, navigator);
15 });
16 } else if ((typeof jQuery === 'undefined' || !jQuery) && typeof exports === "object") {
17 factory(require("jquery"), document, window, navigator);
18 } else {
19 factory(jQuery, document, window, navigator);
20 }
21 } (function ($, document, window, navigator, undefined) {
22 "use strict";
23
24 // =================================================================================================================
25 // Service
26
27 var plugin_count = 0;
28
29 if (!Function.prototype.bind) {
30 Function.prototype.bind = function bind(that) {
31
32 var target = this;
33 var slice = [].slice;
34
35 if (typeof target != "function") {
36 throw new TypeError();
37 }
38
39 var args = slice.call(arguments, 1),
40 bound = function () {
41
42 if (this instanceof bound) {
43
44 var F = function(){};
45 F.prototype = target.prototype;
46 var self = new F();
47
48 var result = target.apply(
49 self,
50 args.concat(slice.call(arguments))
51 );
52 if (Object(result) === result) {
53 return result;
54 }
55 return self;
56
57 } else {
58
59 return target.apply(
60 that,
61 args.concat(slice.call(arguments))
62 );
63
64 }
65
66 };
67
68 return bound;
69 };
70 }
71 if (!Array.prototype.indexOf) {
72 Array.prototype.indexOf = function(searchElement, fromIndex) {
73 var k;
74 if (this == null) {
75 throw new TypeError('"this" is null or not defined');
76 }
77 var O = Object(this);
78 var len = O.length >>> 0;
79 if (len === 0) {
80 return -1;
81 }
82 var n = +fromIndex || 0;
83 if (Math.abs(n) === Infinity) {
84 n = 0;
85 }
86 if (n >= len) {
87 return -1;
88 }
89 k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
90 while (k < len) {
91 if (k in O && O[k] === searchElement) {
92 return k;
93 }
94 k++;
95 }
96 return -1;
97 };
98 }
99
100
101
102 // =================================================================================================================
103 // Template
104
105
106 // =================================================================================================================
107 // Core
108
109 /**
110 * Main plugin constructor
111 *
112 * @param input {Object} link to base input element
113 * @param options {Object} slider config
114 * @param plugin_count {Number}
115 * @constructor
116 */
117 var FieldSliderRange = function (input, options, plugin_count) {
118 this.VERSION = "1";
119 this.input = input;
120 this.plugin_count = plugin_count;
121 this.value_min = '';
122 this.value_max = '';
123 this.infinity = false;
124 this.plugin_count = plugin_count;
125 this.step = '';
126 this.self = $(input) ;
127
128 this.is_key = false;
129 this.is_update = false;
130 this.is_start = true;
131 this.is_finish = false;
132 this.is_active = false;
133 this.is_resize = false;
134 this.is_click = false;
135 var conf_data = this.self.find('.config-range') || '';
136 var config;
137 if(conf_data)
138 var config = {
139 'min' : conf_data.attr('data-min') || '',
140 'max' : conf_data.attr('data-max') || '',
141 'sufix' : conf_data.attr('data-sufix') || '',
142 'prefix' : conf_data.attr('data-prefix') || '',
143 'infinity' : conf_data.attr('data-infinity') || 'false',
144 'predifinedMin' : conf_data.attr('data-predifinedMin') || '',
145 'predifinedMax' : conf_data.attr('data-predifinedMax') || '',
146 'onChange' : ''
147
148 }
149 options = options || {};
150
151 // js config extends default config
152 $.extend(config, options);
153
154 this.options = config;
155
156 // validate config, to be sure that all data types are correct
157 this.update_check = {};
158
159 this.init();
160 };
161
162 FieldSliderRange.prototype = {
163 /**
164 * Starts or updates the plugin instance
165 *
166 * @param [is_update] {boolean}
167 */
168 init: function (is_update) {
169 var that = this;
170
171 if(that.options.predifinedMax == '')
172 that.options.predifinedMax=that.options.max;
173
174 this.self.find('.wdk-slider-range-input').ionRangeSlider({
175 skin: "round",
176 type: "double",
177 grid: true,
178 min: that.options.min,
179 max: that.options.max,
180 from: that.options.predifinedMin,
181 to: that.options.predifinedMax,
182 prefix: that.options.prefix,
183 postfix: that.options.sufix,
184 max_postfix: "+",
185 decorate_both: true,
186 values_separator: '-',
187 onChange: function (data) {
188 that.options.onChange;
189 that.self.find('.value-min').val(data.from);
190 that.self.find('.value-max').val(data.to);
191 if(data.max==data.to)
192 that.self.find('.value-max').val('');
193
194 if(data.min==data.from)
195 that.self.find('.value-min').val('');
196 },
197 });
198
199 },
200
201 /**
202 * Remove slider instance
203 * and unbind all events
204 */
205 remove: function () {
206 this.remove();
207 }
208
209 };
210
211 $.fn.fieldSliderRange = function (options) {
212 return this.each(function() {
213 if (!$.data(this, "fieldSliderRange")) {
214 $.data(this, "fieldSliderRange", new FieldSliderRange(this, options, plugin_count++));
215 }
216 });
217 };
218
219 }));
220