blacklight_range_limit 2.3.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +2 -2
- data/.travis.yml +7 -13
- data/Gemfile +8 -34
- data/LICENSE +15 -0
- data/README.rdoc +25 -7
- data/Rakefile +3 -4
- data/VERSION +1 -1
- data/app/assets/javascripts/blacklight_range_limit.js +5 -2
- data/app/assets/javascripts/blacklight_range_limit/range_limit_distro_facets.js +144 -68
- data/app/assets/javascripts/blacklight_range_limit/range_limit_slider.js +68 -36
- data/app/assets/stylesheets/blacklight_range_limit.css.scss +1 -46
- data/app/assets/stylesheets/blacklight_range_limit/blacklight_range_limit.css +12 -2
- data/app/helpers/range_limit_helper.rb +7 -1
- data/app/views/blacklight_range_limit/_range_limit_panel.html.erb +27 -11
- data/app/views/blacklight_range_limit/_range_segments.html.erb +13 -8
- data/blacklight_range_limit.gemspec +9 -12
- data/config/jetty.yml +7 -2
- data/lib/blacklight_range_limit/controller_override.rb +4 -13
- data/lib/blacklight_range_limit/route_sets.rb +21 -4
- data/lib/blacklight_range_limit/view_helper_override.rb +27 -11
- data/lib/generators/blacklight_range_limit/assets_generator.rb +9 -2
- data/spec/features/blacklight_range_limit_spec.rb +5 -5
- data/spec/spec_helper.rb +7 -1
- data/spec/test_app_templates/Gemfile.extra +14 -1
- data/spec/test_app_templates/lib/generators/test_app_generator.rb +4 -15
- data/spec/test_app_templates/lib/tasks/blacklight_test_app.rake +0 -6
- data/vendor/assets/javascripts/bootstrap-slider.js +388 -0
- data/vendor/assets/javascripts/flot/excanvas.min.js +1 -1
- data/vendor/assets/javascripts/flot/jquery.flot.js +1328 -790
- data/vendor/assets/javascripts/flot/jquery.flot.selection.js +76 -60
- data/vendor/assets/stylesheets/slider.css +138 -0
- metadata +74 -110
- checksums.yaml +0 -7
- data/.rspec +0 -1
- data/MIT-LICENSE +0 -20
- data/solr/sample_solr_documents.yml +0 -641
- data/vendor/assets/javascripts/jquery-ui-1.9.2.custom.js +0 -1654
@@ -1,1654 +0,0 @@
|
|
1
|
-
/*! jQuery UI - v1.9.2 - 2012-11-28
|
2
|
-
* http://jqueryui.com
|
3
|
-
* Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.slider.js
|
4
|
-
* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
|
5
|
-
|
6
|
-
(function( $, undefined ) {
|
7
|
-
|
8
|
-
var uuid = 0,
|
9
|
-
runiqueId = /^ui-id-\d+$/;
|
10
|
-
|
11
|
-
// prevent duplicate loading
|
12
|
-
// this is only a problem because we proxy existing functions
|
13
|
-
// and we don't want to double proxy them
|
14
|
-
$.ui = $.ui || {};
|
15
|
-
if ( $.ui.version ) {
|
16
|
-
return;
|
17
|
-
}
|
18
|
-
|
19
|
-
$.extend( $.ui, {
|
20
|
-
version: "1.9.2",
|
21
|
-
|
22
|
-
keyCode: {
|
23
|
-
BACKSPACE: 8,
|
24
|
-
COMMA: 188,
|
25
|
-
DELETE: 46,
|
26
|
-
DOWN: 40,
|
27
|
-
END: 35,
|
28
|
-
ENTER: 13,
|
29
|
-
ESCAPE: 27,
|
30
|
-
HOME: 36,
|
31
|
-
LEFT: 37,
|
32
|
-
NUMPAD_ADD: 107,
|
33
|
-
NUMPAD_DECIMAL: 110,
|
34
|
-
NUMPAD_DIVIDE: 111,
|
35
|
-
NUMPAD_ENTER: 108,
|
36
|
-
NUMPAD_MULTIPLY: 106,
|
37
|
-
NUMPAD_SUBTRACT: 109,
|
38
|
-
PAGE_DOWN: 34,
|
39
|
-
PAGE_UP: 33,
|
40
|
-
PERIOD: 190,
|
41
|
-
RIGHT: 39,
|
42
|
-
SPACE: 32,
|
43
|
-
TAB: 9,
|
44
|
-
UP: 38
|
45
|
-
}
|
46
|
-
});
|
47
|
-
|
48
|
-
// plugins
|
49
|
-
$.fn.extend({
|
50
|
-
_focus: $.fn.focus,
|
51
|
-
focus: function( delay, fn ) {
|
52
|
-
return typeof delay === "number" ?
|
53
|
-
this.each(function() {
|
54
|
-
var elem = this;
|
55
|
-
setTimeout(function() {
|
56
|
-
$( elem ).focus();
|
57
|
-
if ( fn ) {
|
58
|
-
fn.call( elem );
|
59
|
-
}
|
60
|
-
}, delay );
|
61
|
-
}) :
|
62
|
-
this._focus.apply( this, arguments );
|
63
|
-
},
|
64
|
-
|
65
|
-
scrollParent: function() {
|
66
|
-
var scrollParent;
|
67
|
-
if (($.ui.ie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
|
68
|
-
scrollParent = this.parents().filter(function() {
|
69
|
-
return (/(relative|absolute|fixed)/).test($.css(this,'position')) && (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
|
70
|
-
}).eq(0);
|
71
|
-
} else {
|
72
|
-
scrollParent = this.parents().filter(function() {
|
73
|
-
return (/(auto|scroll)/).test($.css(this,'overflow')+$.css(this,'overflow-y')+$.css(this,'overflow-x'));
|
74
|
-
}).eq(0);
|
75
|
-
}
|
76
|
-
|
77
|
-
return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
|
78
|
-
},
|
79
|
-
|
80
|
-
zIndex: function( zIndex ) {
|
81
|
-
if ( zIndex !== undefined ) {
|
82
|
-
return this.css( "zIndex", zIndex );
|
83
|
-
}
|
84
|
-
|
85
|
-
if ( this.length ) {
|
86
|
-
var elem = $( this[ 0 ] ), position, value;
|
87
|
-
while ( elem.length && elem[ 0 ] !== document ) {
|
88
|
-
// Ignore z-index if position is set to a value where z-index is ignored by the browser
|
89
|
-
// This makes behavior of this function consistent across browsers
|
90
|
-
// WebKit always returns auto if the element is positioned
|
91
|
-
position = elem.css( "position" );
|
92
|
-
if ( position === "absolute" || position === "relative" || position === "fixed" ) {
|
93
|
-
// IE returns 0 when zIndex is not specified
|
94
|
-
// other browsers return a string
|
95
|
-
// we ignore the case of nested elements with an explicit value of 0
|
96
|
-
// <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
|
97
|
-
value = parseInt( elem.css( "zIndex" ), 10 );
|
98
|
-
if ( !isNaN( value ) && value !== 0 ) {
|
99
|
-
return value;
|
100
|
-
}
|
101
|
-
}
|
102
|
-
elem = elem.parent();
|
103
|
-
}
|
104
|
-
}
|
105
|
-
|
106
|
-
return 0;
|
107
|
-
},
|
108
|
-
|
109
|
-
uniqueId: function() {
|
110
|
-
return this.each(function() {
|
111
|
-
if ( !this.id ) {
|
112
|
-
this.id = "ui-id-" + (++uuid);
|
113
|
-
}
|
114
|
-
});
|
115
|
-
},
|
116
|
-
|
117
|
-
removeUniqueId: function() {
|
118
|
-
return this.each(function() {
|
119
|
-
if ( runiqueId.test( this.id ) ) {
|
120
|
-
$( this ).removeAttr( "id" );
|
121
|
-
}
|
122
|
-
});
|
123
|
-
}
|
124
|
-
});
|
125
|
-
|
126
|
-
// selectors
|
127
|
-
function focusable( element, isTabIndexNotNaN ) {
|
128
|
-
var map, mapName, img,
|
129
|
-
nodeName = element.nodeName.toLowerCase();
|
130
|
-
if ( "area" === nodeName ) {
|
131
|
-
map = element.parentNode;
|
132
|
-
mapName = map.name;
|
133
|
-
if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
|
134
|
-
return false;
|
135
|
-
}
|
136
|
-
img = $( "img[usemap=#" + mapName + "]" )[0];
|
137
|
-
return !!img && visible( img );
|
138
|
-
}
|
139
|
-
return ( /input|select|textarea|button|object/.test( nodeName ) ?
|
140
|
-
!element.disabled :
|
141
|
-
"a" === nodeName ?
|
142
|
-
element.href || isTabIndexNotNaN :
|
143
|
-
isTabIndexNotNaN) &&
|
144
|
-
// the element and all of its ancestors must be visible
|
145
|
-
visible( element );
|
146
|
-
}
|
147
|
-
|
148
|
-
function visible( element ) {
|
149
|
-
return $.expr.filters.visible( element ) &&
|
150
|
-
!$( element ).parents().andSelf().filter(function() {
|
151
|
-
return $.css( this, "visibility" ) === "hidden";
|
152
|
-
}).length;
|
153
|
-
}
|
154
|
-
|
155
|
-
$.extend( $.expr[ ":" ], {
|
156
|
-
data: $.expr.createPseudo ?
|
157
|
-
$.expr.createPseudo(function( dataName ) {
|
158
|
-
return function( elem ) {
|
159
|
-
return !!$.data( elem, dataName );
|
160
|
-
};
|
161
|
-
}) :
|
162
|
-
// support: jQuery <1.8
|
163
|
-
function( elem, i, match ) {
|
164
|
-
return !!$.data( elem, match[ 3 ] );
|
165
|
-
},
|
166
|
-
|
167
|
-
focusable: function( element ) {
|
168
|
-
return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
|
169
|
-
},
|
170
|
-
|
171
|
-
tabbable: function( element ) {
|
172
|
-
var tabIndex = $.attr( element, "tabindex" ),
|
173
|
-
isTabIndexNaN = isNaN( tabIndex );
|
174
|
-
return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
|
175
|
-
}
|
176
|
-
});
|
177
|
-
|
178
|
-
// support
|
179
|
-
$(function() {
|
180
|
-
var body = document.body,
|
181
|
-
div = body.appendChild( div = document.createElement( "div" ) );
|
182
|
-
|
183
|
-
// access offsetHeight before setting the style to prevent a layout bug
|
184
|
-
// in IE 9 which causes the element to continue to take up space even
|
185
|
-
// after it is removed from the DOM (#8026)
|
186
|
-
div.offsetHeight;
|
187
|
-
|
188
|
-
$.extend( div.style, {
|
189
|
-
minHeight: "100px",
|
190
|
-
height: "auto",
|
191
|
-
padding: 0,
|
192
|
-
borderWidth: 0
|
193
|
-
});
|
194
|
-
|
195
|
-
$.support.minHeight = div.offsetHeight === 100;
|
196
|
-
$.support.selectstart = "onselectstart" in div;
|
197
|
-
|
198
|
-
// set display to none to avoid a layout bug in IE
|
199
|
-
// http://dev.jquery.com/ticket/4014
|
200
|
-
body.removeChild( div ).style.display = "none";
|
201
|
-
});
|
202
|
-
|
203
|
-
// support: jQuery <1.8
|
204
|
-
if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
|
205
|
-
$.each( [ "Width", "Height" ], function( i, name ) {
|
206
|
-
var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
|
207
|
-
type = name.toLowerCase(),
|
208
|
-
orig = {
|
209
|
-
innerWidth: $.fn.innerWidth,
|
210
|
-
innerHeight: $.fn.innerHeight,
|
211
|
-
outerWidth: $.fn.outerWidth,
|
212
|
-
outerHeight: $.fn.outerHeight
|
213
|
-
};
|
214
|
-
|
215
|
-
function reduce( elem, size, border, margin ) {
|
216
|
-
$.each( side, function() {
|
217
|
-
size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
|
218
|
-
if ( border ) {
|
219
|
-
size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
|
220
|
-
}
|
221
|
-
if ( margin ) {
|
222
|
-
size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
|
223
|
-
}
|
224
|
-
});
|
225
|
-
return size;
|
226
|
-
}
|
227
|
-
|
228
|
-
$.fn[ "inner" + name ] = function( size ) {
|
229
|
-
if ( size === undefined ) {
|
230
|
-
return orig[ "inner" + name ].call( this );
|
231
|
-
}
|
232
|
-
|
233
|
-
return this.each(function() {
|
234
|
-
$( this ).css( type, reduce( this, size ) + "px" );
|
235
|
-
});
|
236
|
-
};
|
237
|
-
|
238
|
-
$.fn[ "outer" + name] = function( size, margin ) {
|
239
|
-
if ( typeof size !== "number" ) {
|
240
|
-
return orig[ "outer" + name ].call( this, size );
|
241
|
-
}
|
242
|
-
|
243
|
-
return this.each(function() {
|
244
|
-
$( this).css( type, reduce( this, size, true, margin ) + "px" );
|
245
|
-
});
|
246
|
-
};
|
247
|
-
});
|
248
|
-
}
|
249
|
-
|
250
|
-
// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
|
251
|
-
if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
|
252
|
-
$.fn.removeData = (function( removeData ) {
|
253
|
-
return function( key ) {
|
254
|
-
if ( arguments.length ) {
|
255
|
-
return removeData.call( this, $.camelCase( key ) );
|
256
|
-
} else {
|
257
|
-
return removeData.call( this );
|
258
|
-
}
|
259
|
-
};
|
260
|
-
})( $.fn.removeData );
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
// deprecated
|
268
|
-
|
269
|
-
(function() {
|
270
|
-
var uaMatch = /msie ([\w.]+)/.exec( navigator.userAgent.toLowerCase() ) || [];
|
271
|
-
$.ui.ie = uaMatch.length ? true : false;
|
272
|
-
$.ui.ie6 = parseFloat( uaMatch[ 1 ], 10 ) === 6;
|
273
|
-
})();
|
274
|
-
|
275
|
-
$.fn.extend({
|
276
|
-
disableSelection: function() {
|
277
|
-
return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
|
278
|
-
".ui-disableSelection", function( event ) {
|
279
|
-
event.preventDefault();
|
280
|
-
});
|
281
|
-
},
|
282
|
-
|
283
|
-
enableSelection: function() {
|
284
|
-
return this.unbind( ".ui-disableSelection" );
|
285
|
-
}
|
286
|
-
});
|
287
|
-
|
288
|
-
$.extend( $.ui, {
|
289
|
-
// $.ui.plugin is deprecated. Use the proxy pattern instead.
|
290
|
-
plugin: {
|
291
|
-
add: function( module, option, set ) {
|
292
|
-
var i,
|
293
|
-
proto = $.ui[ module ].prototype;
|
294
|
-
for ( i in set ) {
|
295
|
-
proto.plugins[ i ] = proto.plugins[ i ] || [];
|
296
|
-
proto.plugins[ i ].push( [ option, set[ i ] ] );
|
297
|
-
}
|
298
|
-
},
|
299
|
-
call: function( instance, name, args ) {
|
300
|
-
var i,
|
301
|
-
set = instance.plugins[ name ];
|
302
|
-
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
|
303
|
-
return;
|
304
|
-
}
|
305
|
-
|
306
|
-
for ( i = 0; i < set.length; i++ ) {
|
307
|
-
if ( instance.options[ set[ i ][ 0 ] ] ) {
|
308
|
-
set[ i ][ 1 ].apply( instance.element, args );
|
309
|
-
}
|
310
|
-
}
|
311
|
-
}
|
312
|
-
},
|
313
|
-
|
314
|
-
contains: $.contains,
|
315
|
-
|
316
|
-
// only used by resizable
|
317
|
-
hasScroll: function( el, a ) {
|
318
|
-
|
319
|
-
//If overflow is hidden, the element might have extra content, but the user wants to hide it
|
320
|
-
if ( $( el ).css( "overflow" ) === "hidden") {
|
321
|
-
return false;
|
322
|
-
}
|
323
|
-
|
324
|
-
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
|
325
|
-
has = false;
|
326
|
-
|
327
|
-
if ( el[ scroll ] > 0 ) {
|
328
|
-
return true;
|
329
|
-
}
|
330
|
-
|
331
|
-
// TODO: determine which cases actually cause this to happen
|
332
|
-
// if the element doesn't have the scroll set, see if it's possible to
|
333
|
-
// set the scroll
|
334
|
-
el[ scroll ] = 1;
|
335
|
-
has = ( el[ scroll ] > 0 );
|
336
|
-
el[ scroll ] = 0;
|
337
|
-
return has;
|
338
|
-
},
|
339
|
-
|
340
|
-
// these are odd functions, fix the API or move into individual plugins
|
341
|
-
isOverAxis: function( x, reference, size ) {
|
342
|
-
//Determines when x coordinate is over "b" element axis
|
343
|
-
return ( x > reference ) && ( x < ( reference + size ) );
|
344
|
-
},
|
345
|
-
isOver: function( y, x, top, left, height, width ) {
|
346
|
-
//Determines when x, y coordinates is over "b" element
|
347
|
-
return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
|
348
|
-
}
|
349
|
-
});
|
350
|
-
|
351
|
-
})( jQuery );
|
352
|
-
(function( $, undefined ) {
|
353
|
-
|
354
|
-
var uuid = 0,
|
355
|
-
slice = Array.prototype.slice,
|
356
|
-
_cleanData = $.cleanData;
|
357
|
-
$.cleanData = function( elems ) {
|
358
|
-
for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
|
359
|
-
try {
|
360
|
-
$( elem ).triggerHandler( "remove" );
|
361
|
-
// http://bugs.jquery.com/ticket/8235
|
362
|
-
} catch( e ) {}
|
363
|
-
}
|
364
|
-
_cleanData( elems );
|
365
|
-
};
|
366
|
-
|
367
|
-
$.widget = function( name, base, prototype ) {
|
368
|
-
var fullName, existingConstructor, constructor, basePrototype,
|
369
|
-
namespace = name.split( "." )[ 0 ];
|
370
|
-
|
371
|
-
name = name.split( "." )[ 1 ];
|
372
|
-
fullName = namespace + "-" + name;
|
373
|
-
|
374
|
-
if ( !prototype ) {
|
375
|
-
prototype = base;
|
376
|
-
base = $.Widget;
|
377
|
-
}
|
378
|
-
|
379
|
-
// create selector for plugin
|
380
|
-
$.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
|
381
|
-
return !!$.data( elem, fullName );
|
382
|
-
};
|
383
|
-
|
384
|
-
$[ namespace ] = $[ namespace ] || {};
|
385
|
-
existingConstructor = $[ namespace ][ name ];
|
386
|
-
constructor = $[ namespace ][ name ] = function( options, element ) {
|
387
|
-
// allow instantiation without "new" keyword
|
388
|
-
if ( !this._createWidget ) {
|
389
|
-
return new constructor( options, element );
|
390
|
-
}
|
391
|
-
|
392
|
-
// allow instantiation without initializing for simple inheritance
|
393
|
-
// must use "new" keyword (the code above always passes args)
|
394
|
-
if ( arguments.length ) {
|
395
|
-
this._createWidget( options, element );
|
396
|
-
}
|
397
|
-
};
|
398
|
-
// extend with the existing constructor to carry over any static properties
|
399
|
-
$.extend( constructor, existingConstructor, {
|
400
|
-
version: prototype.version,
|
401
|
-
// copy the object used to create the prototype in case we need to
|
402
|
-
// redefine the widget later
|
403
|
-
_proto: $.extend( {}, prototype ),
|
404
|
-
// track widgets that inherit from this widget in case this widget is
|
405
|
-
// redefined after a widget inherits from it
|
406
|
-
_childConstructors: []
|
407
|
-
});
|
408
|
-
|
409
|
-
basePrototype = new base();
|
410
|
-
// we need to make the options hash a property directly on the new instance
|
411
|
-
// otherwise we'll modify the options hash on the prototype that we're
|
412
|
-
// inheriting from
|
413
|
-
basePrototype.options = $.widget.extend( {}, basePrototype.options );
|
414
|
-
$.each( prototype, function( prop, value ) {
|
415
|
-
if ( $.isFunction( value ) ) {
|
416
|
-
prototype[ prop ] = (function() {
|
417
|
-
var _super = function() {
|
418
|
-
return base.prototype[ prop ].apply( this, arguments );
|
419
|
-
},
|
420
|
-
_superApply = function( args ) {
|
421
|
-
return base.prototype[ prop ].apply( this, args );
|
422
|
-
};
|
423
|
-
return function() {
|
424
|
-
var __super = this._super,
|
425
|
-
__superApply = this._superApply,
|
426
|
-
returnValue;
|
427
|
-
|
428
|
-
this._super = _super;
|
429
|
-
this._superApply = _superApply;
|
430
|
-
|
431
|
-
returnValue = value.apply( this, arguments );
|
432
|
-
|
433
|
-
this._super = __super;
|
434
|
-
this._superApply = __superApply;
|
435
|
-
|
436
|
-
return returnValue;
|
437
|
-
};
|
438
|
-
})();
|
439
|
-
}
|
440
|
-
});
|
441
|
-
constructor.prototype = $.widget.extend( basePrototype, {
|
442
|
-
// TODO: remove support for widgetEventPrefix
|
443
|
-
// always use the name + a colon as the prefix, e.g., draggable:start
|
444
|
-
// don't prefix for widgets that aren't DOM-based
|
445
|
-
widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
|
446
|
-
}, prototype, {
|
447
|
-
constructor: constructor,
|
448
|
-
namespace: namespace,
|
449
|
-
widgetName: name,
|
450
|
-
// TODO remove widgetBaseClass, see #8155
|
451
|
-
widgetBaseClass: fullName,
|
452
|
-
widgetFullName: fullName
|
453
|
-
});
|
454
|
-
|
455
|
-
// If this widget is being redefined then we need to find all widgets that
|
456
|
-
// are inheriting from it and redefine all of them so that they inherit from
|
457
|
-
// the new version of this widget. We're essentially trying to replace one
|
458
|
-
// level in the prototype chain.
|
459
|
-
if ( existingConstructor ) {
|
460
|
-
$.each( existingConstructor._childConstructors, function( i, child ) {
|
461
|
-
var childPrototype = child.prototype;
|
462
|
-
|
463
|
-
// redefine the child widget using the same prototype that was
|
464
|
-
// originally used, but inherit from the new version of the base
|
465
|
-
$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
|
466
|
-
});
|
467
|
-
// remove the list of existing child constructors from the old constructor
|
468
|
-
// so the old child constructors can be garbage collected
|
469
|
-
delete existingConstructor._childConstructors;
|
470
|
-
} else {
|
471
|
-
base._childConstructors.push( constructor );
|
472
|
-
}
|
473
|
-
|
474
|
-
$.widget.bridge( name, constructor );
|
475
|
-
};
|
476
|
-
|
477
|
-
$.widget.extend = function( target ) {
|
478
|
-
var input = slice.call( arguments, 1 ),
|
479
|
-
inputIndex = 0,
|
480
|
-
inputLength = input.length,
|
481
|
-
key,
|
482
|
-
value;
|
483
|
-
for ( ; inputIndex < inputLength; inputIndex++ ) {
|
484
|
-
for ( key in input[ inputIndex ] ) {
|
485
|
-
value = input[ inputIndex ][ key ];
|
486
|
-
if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
|
487
|
-
// Clone objects
|
488
|
-
if ( $.isPlainObject( value ) ) {
|
489
|
-
target[ key ] = $.isPlainObject( target[ key ] ) ?
|
490
|
-
$.widget.extend( {}, target[ key ], value ) :
|
491
|
-
// Don't extend strings, arrays, etc. with objects
|
492
|
-
$.widget.extend( {}, value );
|
493
|
-
// Copy everything else by reference
|
494
|
-
} else {
|
495
|
-
target[ key ] = value;
|
496
|
-
}
|
497
|
-
}
|
498
|
-
}
|
499
|
-
}
|
500
|
-
return target;
|
501
|
-
};
|
502
|
-
|
503
|
-
$.widget.bridge = function( name, object ) {
|
504
|
-
var fullName = object.prototype.widgetFullName || name;
|
505
|
-
$.fn[ name ] = function( options ) {
|
506
|
-
var isMethodCall = typeof options === "string",
|
507
|
-
args = slice.call( arguments, 1 ),
|
508
|
-
returnValue = this;
|
509
|
-
|
510
|
-
// allow multiple hashes to be passed on init
|
511
|
-
options = !isMethodCall && args.length ?
|
512
|
-
$.widget.extend.apply( null, [ options ].concat(args) ) :
|
513
|
-
options;
|
514
|
-
|
515
|
-
if ( isMethodCall ) {
|
516
|
-
this.each(function() {
|
517
|
-
var methodValue,
|
518
|
-
instance = $.data( this, fullName );
|
519
|
-
if ( !instance ) {
|
520
|
-
return $.error( "cannot call methods on " + name + " prior to initialization; " +
|
521
|
-
"attempted to call method '" + options + "'" );
|
522
|
-
}
|
523
|
-
if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
|
524
|
-
return $.error( "no such method '" + options + "' for " + name + " widget instance" );
|
525
|
-
}
|
526
|
-
methodValue = instance[ options ].apply( instance, args );
|
527
|
-
if ( methodValue !== instance && methodValue !== undefined ) {
|
528
|
-
returnValue = methodValue && methodValue.jquery ?
|
529
|
-
returnValue.pushStack( methodValue.get() ) :
|
530
|
-
methodValue;
|
531
|
-
return false;
|
532
|
-
}
|
533
|
-
});
|
534
|
-
} else {
|
535
|
-
this.each(function() {
|
536
|
-
var instance = $.data( this, fullName );
|
537
|
-
if ( instance ) {
|
538
|
-
instance.option( options || {} )._init();
|
539
|
-
} else {
|
540
|
-
$.data( this, fullName, new object( options, this ) );
|
541
|
-
}
|
542
|
-
});
|
543
|
-
}
|
544
|
-
|
545
|
-
return returnValue;
|
546
|
-
};
|
547
|
-
};
|
548
|
-
|
549
|
-
$.Widget = function( /* options, element */ ) {};
|
550
|
-
$.Widget._childConstructors = [];
|
551
|
-
|
552
|
-
$.Widget.prototype = {
|
553
|
-
widgetName: "widget",
|
554
|
-
widgetEventPrefix: "",
|
555
|
-
defaultElement: "<div>",
|
556
|
-
options: {
|
557
|
-
disabled: false,
|
558
|
-
|
559
|
-
// callbacks
|
560
|
-
create: null
|
561
|
-
},
|
562
|
-
_createWidget: function( options, element ) {
|
563
|
-
element = $( element || this.defaultElement || this )[ 0 ];
|
564
|
-
this.element = $( element );
|
565
|
-
this.uuid = uuid++;
|
566
|
-
this.eventNamespace = "." + this.widgetName + this.uuid;
|
567
|
-
this.options = $.widget.extend( {},
|
568
|
-
this.options,
|
569
|
-
this._getCreateOptions(),
|
570
|
-
options );
|
571
|
-
|
572
|
-
this.bindings = $();
|
573
|
-
this.hoverable = $();
|
574
|
-
this.focusable = $();
|
575
|
-
|
576
|
-
if ( element !== this ) {
|
577
|
-
// 1.9 BC for #7810
|
578
|
-
// TODO remove dual storage
|
579
|
-
$.data( element, this.widgetName, this );
|
580
|
-
$.data( element, this.widgetFullName, this );
|
581
|
-
this._on( true, this.element, {
|
582
|
-
remove: function( event ) {
|
583
|
-
if ( event.target === element ) {
|
584
|
-
this.destroy();
|
585
|
-
}
|
586
|
-
}
|
587
|
-
});
|
588
|
-
this.document = $( element.style ?
|
589
|
-
// element within the document
|
590
|
-
element.ownerDocument :
|
591
|
-
// element is window or document
|
592
|
-
element.document || element );
|
593
|
-
this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
|
594
|
-
}
|
595
|
-
|
596
|
-
this._create();
|
597
|
-
this._trigger( "create", null, this._getCreateEventData() );
|
598
|
-
this._init();
|
599
|
-
},
|
600
|
-
_getCreateOptions: $.noop,
|
601
|
-
_getCreateEventData: $.noop,
|
602
|
-
_create: $.noop,
|
603
|
-
_init: $.noop,
|
604
|
-
|
605
|
-
destroy: function() {
|
606
|
-
this._destroy();
|
607
|
-
// we can probably remove the unbind calls in 2.0
|
608
|
-
// all event bindings should go through this._on()
|
609
|
-
this.element
|
610
|
-
.unbind( this.eventNamespace )
|
611
|
-
// 1.9 BC for #7810
|
612
|
-
// TODO remove dual storage
|
613
|
-
.removeData( this.widgetName )
|
614
|
-
.removeData( this.widgetFullName )
|
615
|
-
// support: jquery <1.6.3
|
616
|
-
// http://bugs.jquery.com/ticket/9413
|
617
|
-
.removeData( $.camelCase( this.widgetFullName ) );
|
618
|
-
this.widget()
|
619
|
-
.unbind( this.eventNamespace )
|
620
|
-
.removeAttr( "aria-disabled" )
|
621
|
-
.removeClass(
|
622
|
-
this.widgetFullName + "-disabled " +
|
623
|
-
"ui-state-disabled" );
|
624
|
-
|
625
|
-
// clean up events and states
|
626
|
-
this.bindings.unbind( this.eventNamespace );
|
627
|
-
this.hoverable.removeClass( "ui-state-hover" );
|
628
|
-
this.focusable.removeClass( "ui-state-focus" );
|
629
|
-
},
|
630
|
-
_destroy: $.noop,
|
631
|
-
|
632
|
-
widget: function() {
|
633
|
-
return this.element;
|
634
|
-
},
|
635
|
-
|
636
|
-
option: function( key, value ) {
|
637
|
-
var options = key,
|
638
|
-
parts,
|
639
|
-
curOption,
|
640
|
-
i;
|
641
|
-
|
642
|
-
if ( arguments.length === 0 ) {
|
643
|
-
// don't return a reference to the internal hash
|
644
|
-
return $.widget.extend( {}, this.options );
|
645
|
-
}
|
646
|
-
|
647
|
-
if ( typeof key === "string" ) {
|
648
|
-
// handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
|
649
|
-
options = {};
|
650
|
-
parts = key.split( "." );
|
651
|
-
key = parts.shift();
|
652
|
-
if ( parts.length ) {
|
653
|
-
curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
|
654
|
-
for ( i = 0; i < parts.length - 1; i++ ) {
|
655
|
-
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
|
656
|
-
curOption = curOption[ parts[ i ] ];
|
657
|
-
}
|
658
|
-
key = parts.pop();
|
659
|
-
if ( value === undefined ) {
|
660
|
-
return curOption[ key ] === undefined ? null : curOption[ key ];
|
661
|
-
}
|
662
|
-
curOption[ key ] = value;
|
663
|
-
} else {
|
664
|
-
if ( value === undefined ) {
|
665
|
-
return this.options[ key ] === undefined ? null : this.options[ key ];
|
666
|
-
}
|
667
|
-
options[ key ] = value;
|
668
|
-
}
|
669
|
-
}
|
670
|
-
|
671
|
-
this._setOptions( options );
|
672
|
-
|
673
|
-
return this;
|
674
|
-
},
|
675
|
-
_setOptions: function( options ) {
|
676
|
-
var key;
|
677
|
-
|
678
|
-
for ( key in options ) {
|
679
|
-
this._setOption( key, options[ key ] );
|
680
|
-
}
|
681
|
-
|
682
|
-
return this;
|
683
|
-
},
|
684
|
-
_setOption: function( key, value ) {
|
685
|
-
this.options[ key ] = value;
|
686
|
-
|
687
|
-
if ( key === "disabled" ) {
|
688
|
-
this.widget()
|
689
|
-
.toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
|
690
|
-
.attr( "aria-disabled", value );
|
691
|
-
this.hoverable.removeClass( "ui-state-hover" );
|
692
|
-
this.focusable.removeClass( "ui-state-focus" );
|
693
|
-
}
|
694
|
-
|
695
|
-
return this;
|
696
|
-
},
|
697
|
-
|
698
|
-
enable: function() {
|
699
|
-
return this._setOption( "disabled", false );
|
700
|
-
},
|
701
|
-
disable: function() {
|
702
|
-
return this._setOption( "disabled", true );
|
703
|
-
},
|
704
|
-
|
705
|
-
_on: function( suppressDisabledCheck, element, handlers ) {
|
706
|
-
var delegateElement,
|
707
|
-
instance = this;
|
708
|
-
|
709
|
-
// no suppressDisabledCheck flag, shuffle arguments
|
710
|
-
if ( typeof suppressDisabledCheck !== "boolean" ) {
|
711
|
-
handlers = element;
|
712
|
-
element = suppressDisabledCheck;
|
713
|
-
suppressDisabledCheck = false;
|
714
|
-
}
|
715
|
-
|
716
|
-
// no element argument, shuffle and use this.element
|
717
|
-
if ( !handlers ) {
|
718
|
-
handlers = element;
|
719
|
-
element = this.element;
|
720
|
-
delegateElement = this.widget();
|
721
|
-
} else {
|
722
|
-
// accept selectors, DOM elements
|
723
|
-
element = delegateElement = $( element );
|
724
|
-
this.bindings = this.bindings.add( element );
|
725
|
-
}
|
726
|
-
|
727
|
-
$.each( handlers, function( event, handler ) {
|
728
|
-
function handlerProxy() {
|
729
|
-
// allow widgets to customize the disabled handling
|
730
|
-
// - disabled as an array instead of boolean
|
731
|
-
// - disabled class as method for disabling individual parts
|
732
|
-
if ( !suppressDisabledCheck &&
|
733
|
-
( instance.options.disabled === true ||
|
734
|
-
$( this ).hasClass( "ui-state-disabled" ) ) ) {
|
735
|
-
return;
|
736
|
-
}
|
737
|
-
return ( typeof handler === "string" ? instance[ handler ] : handler )
|
738
|
-
.apply( instance, arguments );
|
739
|
-
}
|
740
|
-
|
741
|
-
// copy the guid so direct unbinding works
|
742
|
-
if ( typeof handler !== "string" ) {
|
743
|
-
handlerProxy.guid = handler.guid =
|
744
|
-
handler.guid || handlerProxy.guid || $.guid++;
|
745
|
-
}
|
746
|
-
|
747
|
-
var match = event.match( /^(\w+)\s*(.*)$/ ),
|
748
|
-
eventName = match[1] + instance.eventNamespace,
|
749
|
-
selector = match[2];
|
750
|
-
if ( selector ) {
|
751
|
-
delegateElement.delegate( selector, eventName, handlerProxy );
|
752
|
-
} else {
|
753
|
-
element.bind( eventName, handlerProxy );
|
754
|
-
}
|
755
|
-
});
|
756
|
-
},
|
757
|
-
|
758
|
-
_off: function( element, eventName ) {
|
759
|
-
eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
|
760
|
-
element.unbind( eventName ).undelegate( eventName );
|
761
|
-
},
|
762
|
-
|
763
|
-
_delay: function( handler, delay ) {
|
764
|
-
function handlerProxy() {
|
765
|
-
return ( typeof handler === "string" ? instance[ handler ] : handler )
|
766
|
-
.apply( instance, arguments );
|
767
|
-
}
|
768
|
-
var instance = this;
|
769
|
-
return setTimeout( handlerProxy, delay || 0 );
|
770
|
-
},
|
771
|
-
|
772
|
-
_hoverable: function( element ) {
|
773
|
-
this.hoverable = this.hoverable.add( element );
|
774
|
-
this._on( element, {
|
775
|
-
mouseenter: function( event ) {
|
776
|
-
$( event.currentTarget ).addClass( "ui-state-hover" );
|
777
|
-
},
|
778
|
-
mouseleave: function( event ) {
|
779
|
-
$( event.currentTarget ).removeClass( "ui-state-hover" );
|
780
|
-
}
|
781
|
-
});
|
782
|
-
},
|
783
|
-
|
784
|
-
_focusable: function( element ) {
|
785
|
-
this.focusable = this.focusable.add( element );
|
786
|
-
this._on( element, {
|
787
|
-
focusin: function( event ) {
|
788
|
-
$( event.currentTarget ).addClass( "ui-state-focus" );
|
789
|
-
},
|
790
|
-
focusout: function( event ) {
|
791
|
-
$( event.currentTarget ).removeClass( "ui-state-focus" );
|
792
|
-
}
|
793
|
-
});
|
794
|
-
},
|
795
|
-
|
796
|
-
_trigger: function( type, event, data ) {
|
797
|
-
var prop, orig,
|
798
|
-
callback = this.options[ type ];
|
799
|
-
|
800
|
-
data = data || {};
|
801
|
-
event = $.Event( event );
|
802
|
-
event.type = ( type === this.widgetEventPrefix ?
|
803
|
-
type :
|
804
|
-
this.widgetEventPrefix + type ).toLowerCase();
|
805
|
-
// the original event may come from any element
|
806
|
-
// so we need to reset the target on the new event
|
807
|
-
event.target = this.element[ 0 ];
|
808
|
-
|
809
|
-
// copy original event properties over to the new event
|
810
|
-
orig = event.originalEvent;
|
811
|
-
if ( orig ) {
|
812
|
-
for ( prop in orig ) {
|
813
|
-
if ( !( prop in event ) ) {
|
814
|
-
event[ prop ] = orig[ prop ];
|
815
|
-
}
|
816
|
-
}
|
817
|
-
}
|
818
|
-
|
819
|
-
this.element.trigger( event, data );
|
820
|
-
return !( $.isFunction( callback ) &&
|
821
|
-
callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
|
822
|
-
event.isDefaultPrevented() );
|
823
|
-
}
|
824
|
-
};
|
825
|
-
|
826
|
-
$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
|
827
|
-
$.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
|
828
|
-
if ( typeof options === "string" ) {
|
829
|
-
options = { effect: options };
|
830
|
-
}
|
831
|
-
var hasOptions,
|
832
|
-
effectName = !options ?
|
833
|
-
method :
|
834
|
-
options === true || typeof options === "number" ?
|
835
|
-
defaultEffect :
|
836
|
-
options.effect || defaultEffect;
|
837
|
-
options = options || {};
|
838
|
-
if ( typeof options === "number" ) {
|
839
|
-
options = { duration: options };
|
840
|
-
}
|
841
|
-
hasOptions = !$.isEmptyObject( options );
|
842
|
-
options.complete = callback;
|
843
|
-
if ( options.delay ) {
|
844
|
-
element.delay( options.delay );
|
845
|
-
}
|
846
|
-
if ( hasOptions && $.effects && ( $.effects.effect[ effectName ] || $.uiBackCompat !== false && $.effects[ effectName ] ) ) {
|
847
|
-
element[ method ]( options );
|
848
|
-
} else if ( effectName !== method && element[ effectName ] ) {
|
849
|
-
element[ effectName ]( options.duration, options.easing, callback );
|
850
|
-
} else {
|
851
|
-
element.queue(function( next ) {
|
852
|
-
$( this )[ method ]();
|
853
|
-
if ( callback ) {
|
854
|
-
callback.call( element[ 0 ] );
|
855
|
-
}
|
856
|
-
next();
|
857
|
-
});
|
858
|
-
}
|
859
|
-
};
|
860
|
-
});
|
861
|
-
|
862
|
-
// DEPRECATED
|
863
|
-
if ( $.uiBackCompat !== false ) {
|
864
|
-
$.Widget.prototype._getCreateOptions = function() {
|
865
|
-
return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
|
866
|
-
};
|
867
|
-
}
|
868
|
-
|
869
|
-
})( jQuery );
|
870
|
-
(function( $, undefined ) {
|
871
|
-
|
872
|
-
var mouseHandled = false;
|
873
|
-
$( document ).mouseup( function( e ) {
|
874
|
-
mouseHandled = false;
|
875
|
-
});
|
876
|
-
|
877
|
-
$.widget("ui.mouse", {
|
878
|
-
version: "1.9.2",
|
879
|
-
options: {
|
880
|
-
cancel: 'input,textarea,button,select,option',
|
881
|
-
distance: 1,
|
882
|
-
delay: 0
|
883
|
-
},
|
884
|
-
_mouseInit: function() {
|
885
|
-
var that = this;
|
886
|
-
|
887
|
-
this.element
|
888
|
-
.bind('mousedown.'+this.widgetName, function(event) {
|
889
|
-
return that._mouseDown(event);
|
890
|
-
})
|
891
|
-
.bind('click.'+this.widgetName, function(event) {
|
892
|
-
if (true === $.data(event.target, that.widgetName + '.preventClickEvent')) {
|
893
|
-
$.removeData(event.target, that.widgetName + '.preventClickEvent');
|
894
|
-
event.stopImmediatePropagation();
|
895
|
-
return false;
|
896
|
-
}
|
897
|
-
});
|
898
|
-
|
899
|
-
this.started = false;
|
900
|
-
},
|
901
|
-
|
902
|
-
// TODO: make sure destroying one instance of mouse doesn't mess with
|
903
|
-
// other instances of mouse
|
904
|
-
_mouseDestroy: function() {
|
905
|
-
this.element.unbind('.'+this.widgetName);
|
906
|
-
if ( this._mouseMoveDelegate ) {
|
907
|
-
$(document)
|
908
|
-
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
909
|
-
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
910
|
-
}
|
911
|
-
},
|
912
|
-
|
913
|
-
_mouseDown: function(event) {
|
914
|
-
// don't let more than one widget handle mouseStart
|
915
|
-
if( mouseHandled ) { return; }
|
916
|
-
|
917
|
-
// we may have missed mouseup (out of window)
|
918
|
-
(this._mouseStarted && this._mouseUp(event));
|
919
|
-
|
920
|
-
this._mouseDownEvent = event;
|
921
|
-
|
922
|
-
var that = this,
|
923
|
-
btnIsLeft = (event.which === 1),
|
924
|
-
// event.target.nodeName works around a bug in IE 8 with
|
925
|
-
// disabled inputs (#7620)
|
926
|
-
elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
|
927
|
-
if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
|
928
|
-
return true;
|
929
|
-
}
|
930
|
-
|
931
|
-
this.mouseDelayMet = !this.options.delay;
|
932
|
-
if (!this.mouseDelayMet) {
|
933
|
-
this._mouseDelayTimer = setTimeout(function() {
|
934
|
-
that.mouseDelayMet = true;
|
935
|
-
}, this.options.delay);
|
936
|
-
}
|
937
|
-
|
938
|
-
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
939
|
-
this._mouseStarted = (this._mouseStart(event) !== false);
|
940
|
-
if (!this._mouseStarted) {
|
941
|
-
event.preventDefault();
|
942
|
-
return true;
|
943
|
-
}
|
944
|
-
}
|
945
|
-
|
946
|
-
// Click event may never have fired (Gecko & Opera)
|
947
|
-
if (true === $.data(event.target, this.widgetName + '.preventClickEvent')) {
|
948
|
-
$.removeData(event.target, this.widgetName + '.preventClickEvent');
|
949
|
-
}
|
950
|
-
|
951
|
-
// these delegates are required to keep context
|
952
|
-
this._mouseMoveDelegate = function(event) {
|
953
|
-
return that._mouseMove(event);
|
954
|
-
};
|
955
|
-
this._mouseUpDelegate = function(event) {
|
956
|
-
return that._mouseUp(event);
|
957
|
-
};
|
958
|
-
$(document)
|
959
|
-
.bind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
960
|
-
.bind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
961
|
-
|
962
|
-
event.preventDefault();
|
963
|
-
|
964
|
-
mouseHandled = true;
|
965
|
-
return true;
|
966
|
-
},
|
967
|
-
|
968
|
-
_mouseMove: function(event) {
|
969
|
-
// IE mouseup check - mouseup happened when mouse was out of window
|
970
|
-
if ($.ui.ie && !(document.documentMode >= 9) && !event.button) {
|
971
|
-
return this._mouseUp(event);
|
972
|
-
}
|
973
|
-
|
974
|
-
if (this._mouseStarted) {
|
975
|
-
this._mouseDrag(event);
|
976
|
-
return event.preventDefault();
|
977
|
-
}
|
978
|
-
|
979
|
-
if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
|
980
|
-
this._mouseStarted =
|
981
|
-
(this._mouseStart(this._mouseDownEvent, event) !== false);
|
982
|
-
(this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
|
983
|
-
}
|
984
|
-
|
985
|
-
return !this._mouseStarted;
|
986
|
-
},
|
987
|
-
|
988
|
-
_mouseUp: function(event) {
|
989
|
-
$(document)
|
990
|
-
.unbind('mousemove.'+this.widgetName, this._mouseMoveDelegate)
|
991
|
-
.unbind('mouseup.'+this.widgetName, this._mouseUpDelegate);
|
992
|
-
|
993
|
-
if (this._mouseStarted) {
|
994
|
-
this._mouseStarted = false;
|
995
|
-
|
996
|
-
if (event.target === this._mouseDownEvent.target) {
|
997
|
-
$.data(event.target, this.widgetName + '.preventClickEvent', true);
|
998
|
-
}
|
999
|
-
|
1000
|
-
this._mouseStop(event);
|
1001
|
-
}
|
1002
|
-
|
1003
|
-
return false;
|
1004
|
-
},
|
1005
|
-
|
1006
|
-
_mouseDistanceMet: function(event) {
|
1007
|
-
return (Math.max(
|
1008
|
-
Math.abs(this._mouseDownEvent.pageX - event.pageX),
|
1009
|
-
Math.abs(this._mouseDownEvent.pageY - event.pageY)
|
1010
|
-
) >= this.options.distance
|
1011
|
-
);
|
1012
|
-
},
|
1013
|
-
|
1014
|
-
_mouseDelayMet: function(event) {
|
1015
|
-
return this.mouseDelayMet;
|
1016
|
-
},
|
1017
|
-
|
1018
|
-
// These are placeholder methods, to be overriden by extending plugin
|
1019
|
-
_mouseStart: function(event) {},
|
1020
|
-
_mouseDrag: function(event) {},
|
1021
|
-
_mouseStop: function(event) {},
|
1022
|
-
_mouseCapture: function(event) { return true; }
|
1023
|
-
});
|
1024
|
-
|
1025
|
-
})(jQuery);
|
1026
|
-
(function( $, undefined ) {
|
1027
|
-
|
1028
|
-
// number of pages in a slider
|
1029
|
-
// (how many times can you page up/down to go through the whole range)
|
1030
|
-
var numPages = 5;
|
1031
|
-
|
1032
|
-
$.widget( "ui.slider", $.ui.mouse, {
|
1033
|
-
version: "1.9.2",
|
1034
|
-
widgetEventPrefix: "slide",
|
1035
|
-
|
1036
|
-
options: {
|
1037
|
-
animate: false,
|
1038
|
-
distance: 0,
|
1039
|
-
max: 100,
|
1040
|
-
min: 0,
|
1041
|
-
orientation: "horizontal",
|
1042
|
-
range: false,
|
1043
|
-
step: 1,
|
1044
|
-
value: 0,
|
1045
|
-
values: null
|
1046
|
-
},
|
1047
|
-
|
1048
|
-
_create: function() {
|
1049
|
-
var i, handleCount,
|
1050
|
-
o = this.options,
|
1051
|
-
existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
|
1052
|
-
handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
|
1053
|
-
handles = [];
|
1054
|
-
|
1055
|
-
this._keySliding = false;
|
1056
|
-
this._mouseSliding = false;
|
1057
|
-
this._animateOff = true;
|
1058
|
-
this._handleIndex = null;
|
1059
|
-
this._detectOrientation();
|
1060
|
-
this._mouseInit();
|
1061
|
-
|
1062
|
-
this.element
|
1063
|
-
.addClass( "ui-slider" +
|
1064
|
-
" ui-slider-" + this.orientation +
|
1065
|
-
" ui-widget" +
|
1066
|
-
" ui-widget-content" +
|
1067
|
-
" ui-corner-all" +
|
1068
|
-
( o.disabled ? " ui-slider-disabled ui-disabled" : "" ) );
|
1069
|
-
|
1070
|
-
this.range = $([]);
|
1071
|
-
|
1072
|
-
if ( o.range ) {
|
1073
|
-
if ( o.range === true ) {
|
1074
|
-
if ( !o.values ) {
|
1075
|
-
o.values = [ this._valueMin(), this._valueMin() ];
|
1076
|
-
}
|
1077
|
-
if ( o.values.length && o.values.length !== 2 ) {
|
1078
|
-
o.values = [ o.values[0], o.values[0] ];
|
1079
|
-
}
|
1080
|
-
}
|
1081
|
-
|
1082
|
-
this.range = $( "<div></div>" )
|
1083
|
-
.appendTo( this.element )
|
1084
|
-
.addClass( "ui-slider-range" +
|
1085
|
-
// note: this isn't the most fittingly semantic framework class for this element,
|
1086
|
-
// but worked best visually with a variety of themes
|
1087
|
-
" ui-widget-header" +
|
1088
|
-
( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
|
1089
|
-
}
|
1090
|
-
|
1091
|
-
handleCount = ( o.values && o.values.length ) || 1;
|
1092
|
-
|
1093
|
-
for ( i = existingHandles.length; i < handleCount; i++ ) {
|
1094
|
-
handles.push( handle );
|
1095
|
-
}
|
1096
|
-
|
1097
|
-
this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
|
1098
|
-
|
1099
|
-
this.handle = this.handles.eq( 0 );
|
1100
|
-
|
1101
|
-
this.handles.add( this.range ).filter( "a" )
|
1102
|
-
.click(function( event ) {
|
1103
|
-
event.preventDefault();
|
1104
|
-
})
|
1105
|
-
.mouseenter(function() {
|
1106
|
-
if ( !o.disabled ) {
|
1107
|
-
$( this ).addClass( "ui-state-hover" );
|
1108
|
-
}
|
1109
|
-
})
|
1110
|
-
.mouseleave(function() {
|
1111
|
-
$( this ).removeClass( "ui-state-hover" );
|
1112
|
-
})
|
1113
|
-
.focus(function() {
|
1114
|
-
if ( !o.disabled ) {
|
1115
|
-
$( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
|
1116
|
-
$( this ).addClass( "ui-state-focus" );
|
1117
|
-
} else {
|
1118
|
-
$( this ).blur();
|
1119
|
-
}
|
1120
|
-
})
|
1121
|
-
.blur(function() {
|
1122
|
-
$( this ).removeClass( "ui-state-focus" );
|
1123
|
-
});
|
1124
|
-
|
1125
|
-
this.handles.each(function( i ) {
|
1126
|
-
$( this ).data( "ui-slider-handle-index", i );
|
1127
|
-
});
|
1128
|
-
|
1129
|
-
this._on( this.handles, {
|
1130
|
-
keydown: function( event ) {
|
1131
|
-
var allowed, curVal, newVal, step,
|
1132
|
-
index = $( event.target ).data( "ui-slider-handle-index" );
|
1133
|
-
|
1134
|
-
switch ( event.keyCode ) {
|
1135
|
-
case $.ui.keyCode.HOME:
|
1136
|
-
case $.ui.keyCode.END:
|
1137
|
-
case $.ui.keyCode.PAGE_UP:
|
1138
|
-
case $.ui.keyCode.PAGE_DOWN:
|
1139
|
-
case $.ui.keyCode.UP:
|
1140
|
-
case $.ui.keyCode.RIGHT:
|
1141
|
-
case $.ui.keyCode.DOWN:
|
1142
|
-
case $.ui.keyCode.LEFT:
|
1143
|
-
event.preventDefault();
|
1144
|
-
if ( !this._keySliding ) {
|
1145
|
-
this._keySliding = true;
|
1146
|
-
$( event.target ).addClass( "ui-state-active" );
|
1147
|
-
allowed = this._start( event, index );
|
1148
|
-
if ( allowed === false ) {
|
1149
|
-
return;
|
1150
|
-
}
|
1151
|
-
}
|
1152
|
-
break;
|
1153
|
-
}
|
1154
|
-
|
1155
|
-
step = this.options.step;
|
1156
|
-
if ( this.options.values && this.options.values.length ) {
|
1157
|
-
curVal = newVal = this.values( index );
|
1158
|
-
} else {
|
1159
|
-
curVal = newVal = this.value();
|
1160
|
-
}
|
1161
|
-
|
1162
|
-
switch ( event.keyCode ) {
|
1163
|
-
case $.ui.keyCode.HOME:
|
1164
|
-
newVal = this._valueMin();
|
1165
|
-
break;
|
1166
|
-
case $.ui.keyCode.END:
|
1167
|
-
newVal = this._valueMax();
|
1168
|
-
break;
|
1169
|
-
case $.ui.keyCode.PAGE_UP:
|
1170
|
-
newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
|
1171
|
-
break;
|
1172
|
-
case $.ui.keyCode.PAGE_DOWN:
|
1173
|
-
newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
|
1174
|
-
break;
|
1175
|
-
case $.ui.keyCode.UP:
|
1176
|
-
case $.ui.keyCode.RIGHT:
|
1177
|
-
if ( curVal === this._valueMax() ) {
|
1178
|
-
return;
|
1179
|
-
}
|
1180
|
-
newVal = this._trimAlignValue( curVal + step );
|
1181
|
-
break;
|
1182
|
-
case $.ui.keyCode.DOWN:
|
1183
|
-
case $.ui.keyCode.LEFT:
|
1184
|
-
if ( curVal === this._valueMin() ) {
|
1185
|
-
return;
|
1186
|
-
}
|
1187
|
-
newVal = this._trimAlignValue( curVal - step );
|
1188
|
-
break;
|
1189
|
-
}
|
1190
|
-
|
1191
|
-
this._slide( event, index, newVal );
|
1192
|
-
},
|
1193
|
-
keyup: function( event ) {
|
1194
|
-
var index = $( event.target ).data( "ui-slider-handle-index" );
|
1195
|
-
|
1196
|
-
if ( this._keySliding ) {
|
1197
|
-
this._keySliding = false;
|
1198
|
-
this._stop( event, index );
|
1199
|
-
this._change( event, index );
|
1200
|
-
$( event.target ).removeClass( "ui-state-active" );
|
1201
|
-
}
|
1202
|
-
}
|
1203
|
-
});
|
1204
|
-
|
1205
|
-
this._refreshValue();
|
1206
|
-
|
1207
|
-
this._animateOff = false;
|
1208
|
-
},
|
1209
|
-
|
1210
|
-
_destroy: function() {
|
1211
|
-
this.handles.remove();
|
1212
|
-
this.range.remove();
|
1213
|
-
|
1214
|
-
this.element
|
1215
|
-
.removeClass( "ui-slider" +
|
1216
|
-
" ui-slider-horizontal" +
|
1217
|
-
" ui-slider-vertical" +
|
1218
|
-
" ui-slider-disabled" +
|
1219
|
-
" ui-widget" +
|
1220
|
-
" ui-widget-content" +
|
1221
|
-
" ui-corner-all" );
|
1222
|
-
|
1223
|
-
this._mouseDestroy();
|
1224
|
-
},
|
1225
|
-
|
1226
|
-
_mouseCapture: function( event ) {
|
1227
|
-
var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
|
1228
|
-
that = this,
|
1229
|
-
o = this.options;
|
1230
|
-
|
1231
|
-
if ( o.disabled ) {
|
1232
|
-
return false;
|
1233
|
-
}
|
1234
|
-
|
1235
|
-
this.elementSize = {
|
1236
|
-
width: this.element.outerWidth(),
|
1237
|
-
height: this.element.outerHeight()
|
1238
|
-
};
|
1239
|
-
this.elementOffset = this.element.offset();
|
1240
|
-
|
1241
|
-
position = { x: event.pageX, y: event.pageY };
|
1242
|
-
normValue = this._normValueFromMouse( position );
|
1243
|
-
distance = this._valueMax() - this._valueMin() + 1;
|
1244
|
-
this.handles.each(function( i ) {
|
1245
|
-
var thisDistance = Math.abs( normValue - that.values(i) );
|
1246
|
-
if ( distance > thisDistance ) {
|
1247
|
-
distance = thisDistance;
|
1248
|
-
closestHandle = $( this );
|
1249
|
-
index = i;
|
1250
|
-
}
|
1251
|
-
});
|
1252
|
-
|
1253
|
-
// workaround for bug #3736 (if both handles of a range are at 0,
|
1254
|
-
// the first is always used as the one with least distance,
|
1255
|
-
// and moving it is obviously prevented by preventing negative ranges)
|
1256
|
-
if( o.range === true && this.values(1) === o.min ) {
|
1257
|
-
index += 1;
|
1258
|
-
closestHandle = $( this.handles[index] );
|
1259
|
-
}
|
1260
|
-
|
1261
|
-
allowed = this._start( event, index );
|
1262
|
-
if ( allowed === false ) {
|
1263
|
-
return false;
|
1264
|
-
}
|
1265
|
-
this._mouseSliding = true;
|
1266
|
-
|
1267
|
-
this._handleIndex = index;
|
1268
|
-
|
1269
|
-
closestHandle
|
1270
|
-
.addClass( "ui-state-active" )
|
1271
|
-
.focus();
|
1272
|
-
|
1273
|
-
offset = closestHandle.offset();
|
1274
|
-
mouseOverHandle = !$( event.target ).parents().andSelf().is( ".ui-slider-handle" );
|
1275
|
-
this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
|
1276
|
-
left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
|
1277
|
-
top: event.pageY - offset.top -
|
1278
|
-
( closestHandle.height() / 2 ) -
|
1279
|
-
( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
|
1280
|
-
( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
|
1281
|
-
( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
|
1282
|
-
};
|
1283
|
-
|
1284
|
-
if ( !this.handles.hasClass( "ui-state-hover" ) ) {
|
1285
|
-
this._slide( event, index, normValue );
|
1286
|
-
}
|
1287
|
-
this._animateOff = true;
|
1288
|
-
return true;
|
1289
|
-
},
|
1290
|
-
|
1291
|
-
_mouseStart: function() {
|
1292
|
-
return true;
|
1293
|
-
},
|
1294
|
-
|
1295
|
-
_mouseDrag: function( event ) {
|
1296
|
-
var position = { x: event.pageX, y: event.pageY },
|
1297
|
-
normValue = this._normValueFromMouse( position );
|
1298
|
-
|
1299
|
-
this._slide( event, this._handleIndex, normValue );
|
1300
|
-
|
1301
|
-
return false;
|
1302
|
-
},
|
1303
|
-
|
1304
|
-
_mouseStop: function( event ) {
|
1305
|
-
this.handles.removeClass( "ui-state-active" );
|
1306
|
-
this._mouseSliding = false;
|
1307
|
-
|
1308
|
-
this._stop( event, this._handleIndex );
|
1309
|
-
this._change( event, this._handleIndex );
|
1310
|
-
|
1311
|
-
this._handleIndex = null;
|
1312
|
-
this._clickOffset = null;
|
1313
|
-
this._animateOff = false;
|
1314
|
-
|
1315
|
-
return false;
|
1316
|
-
},
|
1317
|
-
|
1318
|
-
_detectOrientation: function() {
|
1319
|
-
this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
|
1320
|
-
},
|
1321
|
-
|
1322
|
-
_normValueFromMouse: function( position ) {
|
1323
|
-
var pixelTotal,
|
1324
|
-
pixelMouse,
|
1325
|
-
percentMouse,
|
1326
|
-
valueTotal,
|
1327
|
-
valueMouse;
|
1328
|
-
|
1329
|
-
if ( this.orientation === "horizontal" ) {
|
1330
|
-
pixelTotal = this.elementSize.width;
|
1331
|
-
pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
|
1332
|
-
} else {
|
1333
|
-
pixelTotal = this.elementSize.height;
|
1334
|
-
pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
|
1335
|
-
}
|
1336
|
-
|
1337
|
-
percentMouse = ( pixelMouse / pixelTotal );
|
1338
|
-
if ( percentMouse > 1 ) {
|
1339
|
-
percentMouse = 1;
|
1340
|
-
}
|
1341
|
-
if ( percentMouse < 0 ) {
|
1342
|
-
percentMouse = 0;
|
1343
|
-
}
|
1344
|
-
if ( this.orientation === "vertical" ) {
|
1345
|
-
percentMouse = 1 - percentMouse;
|
1346
|
-
}
|
1347
|
-
|
1348
|
-
valueTotal = this._valueMax() - this._valueMin();
|
1349
|
-
valueMouse = this._valueMin() + percentMouse * valueTotal;
|
1350
|
-
|
1351
|
-
return this._trimAlignValue( valueMouse );
|
1352
|
-
},
|
1353
|
-
|
1354
|
-
_start: function( event, index ) {
|
1355
|
-
var uiHash = {
|
1356
|
-
handle: this.handles[ index ],
|
1357
|
-
value: this.value()
|
1358
|
-
};
|
1359
|
-
if ( this.options.values && this.options.values.length ) {
|
1360
|
-
uiHash.value = this.values( index );
|
1361
|
-
uiHash.values = this.values();
|
1362
|
-
}
|
1363
|
-
return this._trigger( "start", event, uiHash );
|
1364
|
-
},
|
1365
|
-
|
1366
|
-
_slide: function( event, index, newVal ) {
|
1367
|
-
var otherVal,
|
1368
|
-
newValues,
|
1369
|
-
allowed;
|
1370
|
-
|
1371
|
-
if ( this.options.values && this.options.values.length ) {
|
1372
|
-
otherVal = this.values( index ? 0 : 1 );
|
1373
|
-
|
1374
|
-
if ( ( this.options.values.length === 2 && this.options.range === true ) &&
|
1375
|
-
( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
|
1376
|
-
) {
|
1377
|
-
newVal = otherVal;
|
1378
|
-
}
|
1379
|
-
|
1380
|
-
if ( newVal !== this.values( index ) ) {
|
1381
|
-
newValues = this.values();
|
1382
|
-
newValues[ index ] = newVal;
|
1383
|
-
// A slide can be canceled by returning false from the slide callback
|
1384
|
-
allowed = this._trigger( "slide", event, {
|
1385
|
-
handle: this.handles[ index ],
|
1386
|
-
value: newVal,
|
1387
|
-
values: newValues
|
1388
|
-
} );
|
1389
|
-
otherVal = this.values( index ? 0 : 1 );
|
1390
|
-
if ( allowed !== false ) {
|
1391
|
-
this.values( index, newVal, true );
|
1392
|
-
}
|
1393
|
-
}
|
1394
|
-
} else {
|
1395
|
-
if ( newVal !== this.value() ) {
|
1396
|
-
// A slide can be canceled by returning false from the slide callback
|
1397
|
-
allowed = this._trigger( "slide", event, {
|
1398
|
-
handle: this.handles[ index ],
|
1399
|
-
value: newVal
|
1400
|
-
} );
|
1401
|
-
if ( allowed !== false ) {
|
1402
|
-
this.value( newVal );
|
1403
|
-
}
|
1404
|
-
}
|
1405
|
-
}
|
1406
|
-
},
|
1407
|
-
|
1408
|
-
_stop: function( event, index ) {
|
1409
|
-
var uiHash = {
|
1410
|
-
handle: this.handles[ index ],
|
1411
|
-
value: this.value()
|
1412
|
-
};
|
1413
|
-
if ( this.options.values && this.options.values.length ) {
|
1414
|
-
uiHash.value = this.values( index );
|
1415
|
-
uiHash.values = this.values();
|
1416
|
-
}
|
1417
|
-
|
1418
|
-
this._trigger( "stop", event, uiHash );
|
1419
|
-
},
|
1420
|
-
|
1421
|
-
_change: function( event, index ) {
|
1422
|
-
if ( !this._keySliding && !this._mouseSliding ) {
|
1423
|
-
var uiHash = {
|
1424
|
-
handle: this.handles[ index ],
|
1425
|
-
value: this.value()
|
1426
|
-
};
|
1427
|
-
if ( this.options.values && this.options.values.length ) {
|
1428
|
-
uiHash.value = this.values( index );
|
1429
|
-
uiHash.values = this.values();
|
1430
|
-
}
|
1431
|
-
|
1432
|
-
this._trigger( "change", event, uiHash );
|
1433
|
-
}
|
1434
|
-
},
|
1435
|
-
|
1436
|
-
value: function( newValue ) {
|
1437
|
-
if ( arguments.length ) {
|
1438
|
-
this.options.value = this._trimAlignValue( newValue );
|
1439
|
-
this._refreshValue();
|
1440
|
-
this._change( null, 0 );
|
1441
|
-
return;
|
1442
|
-
}
|
1443
|
-
|
1444
|
-
return this._value();
|
1445
|
-
},
|
1446
|
-
|
1447
|
-
values: function( index, newValue ) {
|
1448
|
-
var vals,
|
1449
|
-
newValues,
|
1450
|
-
i;
|
1451
|
-
|
1452
|
-
if ( arguments.length > 1 ) {
|
1453
|
-
this.options.values[ index ] = this._trimAlignValue( newValue );
|
1454
|
-
this._refreshValue();
|
1455
|
-
this._change( null, index );
|
1456
|
-
return;
|
1457
|
-
}
|
1458
|
-
|
1459
|
-
if ( arguments.length ) {
|
1460
|
-
if ( $.isArray( arguments[ 0 ] ) ) {
|
1461
|
-
vals = this.options.values;
|
1462
|
-
newValues = arguments[ 0 ];
|
1463
|
-
for ( i = 0; i < vals.length; i += 1 ) {
|
1464
|
-
vals[ i ] = this._trimAlignValue( newValues[ i ] );
|
1465
|
-
this._change( null, i );
|
1466
|
-
}
|
1467
|
-
this._refreshValue();
|
1468
|
-
} else {
|
1469
|
-
if ( this.options.values && this.options.values.length ) {
|
1470
|
-
return this._values( index );
|
1471
|
-
} else {
|
1472
|
-
return this.value();
|
1473
|
-
}
|
1474
|
-
}
|
1475
|
-
} else {
|
1476
|
-
return this._values();
|
1477
|
-
}
|
1478
|
-
},
|
1479
|
-
|
1480
|
-
_setOption: function( key, value ) {
|
1481
|
-
var i,
|
1482
|
-
valsLength = 0;
|
1483
|
-
|
1484
|
-
if ( $.isArray( this.options.values ) ) {
|
1485
|
-
valsLength = this.options.values.length;
|
1486
|
-
}
|
1487
|
-
|
1488
|
-
$.Widget.prototype._setOption.apply( this, arguments );
|
1489
|
-
|
1490
|
-
switch ( key ) {
|
1491
|
-
case "disabled":
|
1492
|
-
if ( value ) {
|
1493
|
-
this.handles.filter( ".ui-state-focus" ).blur();
|
1494
|
-
this.handles.removeClass( "ui-state-hover" );
|
1495
|
-
this.handles.prop( "disabled", true );
|
1496
|
-
this.element.addClass( "ui-disabled" );
|
1497
|
-
} else {
|
1498
|
-
this.handles.prop( "disabled", false );
|
1499
|
-
this.element.removeClass( "ui-disabled" );
|
1500
|
-
}
|
1501
|
-
break;
|
1502
|
-
case "orientation":
|
1503
|
-
this._detectOrientation();
|
1504
|
-
this.element
|
1505
|
-
.removeClass( "ui-slider-horizontal ui-slider-vertical" )
|
1506
|
-
.addClass( "ui-slider-" + this.orientation );
|
1507
|
-
this._refreshValue();
|
1508
|
-
break;
|
1509
|
-
case "value":
|
1510
|
-
this._animateOff = true;
|
1511
|
-
this._refreshValue();
|
1512
|
-
this._change( null, 0 );
|
1513
|
-
this._animateOff = false;
|
1514
|
-
break;
|
1515
|
-
case "values":
|
1516
|
-
this._animateOff = true;
|
1517
|
-
this._refreshValue();
|
1518
|
-
for ( i = 0; i < valsLength; i += 1 ) {
|
1519
|
-
this._change( null, i );
|
1520
|
-
}
|
1521
|
-
this._animateOff = false;
|
1522
|
-
break;
|
1523
|
-
case "min":
|
1524
|
-
case "max":
|
1525
|
-
this._animateOff = true;
|
1526
|
-
this._refreshValue();
|
1527
|
-
this._animateOff = false;
|
1528
|
-
break;
|
1529
|
-
}
|
1530
|
-
},
|
1531
|
-
|
1532
|
-
//internal value getter
|
1533
|
-
// _value() returns value trimmed by min and max, aligned by step
|
1534
|
-
_value: function() {
|
1535
|
-
var val = this.options.value;
|
1536
|
-
val = this._trimAlignValue( val );
|
1537
|
-
|
1538
|
-
return val;
|
1539
|
-
},
|
1540
|
-
|
1541
|
-
//internal values getter
|
1542
|
-
// _values() returns array of values trimmed by min and max, aligned by step
|
1543
|
-
// _values( index ) returns single value trimmed by min and max, aligned by step
|
1544
|
-
_values: function( index ) {
|
1545
|
-
var val,
|
1546
|
-
vals,
|
1547
|
-
i;
|
1548
|
-
|
1549
|
-
if ( arguments.length ) {
|
1550
|
-
val = this.options.values[ index ];
|
1551
|
-
val = this._trimAlignValue( val );
|
1552
|
-
|
1553
|
-
return val;
|
1554
|
-
} else {
|
1555
|
-
// .slice() creates a copy of the array
|
1556
|
-
// this copy gets trimmed by min and max and then returned
|
1557
|
-
vals = this.options.values.slice();
|
1558
|
-
for ( i = 0; i < vals.length; i+= 1) {
|
1559
|
-
vals[ i ] = this._trimAlignValue( vals[ i ] );
|
1560
|
-
}
|
1561
|
-
|
1562
|
-
return vals;
|
1563
|
-
}
|
1564
|
-
},
|
1565
|
-
|
1566
|
-
// returns the step-aligned value that val is closest to, between (inclusive) min and max
|
1567
|
-
_trimAlignValue: function( val ) {
|
1568
|
-
if ( val <= this._valueMin() ) {
|
1569
|
-
return this._valueMin();
|
1570
|
-
}
|
1571
|
-
if ( val >= this._valueMax() ) {
|
1572
|
-
return this._valueMax();
|
1573
|
-
}
|
1574
|
-
var step = ( this.options.step > 0 ) ? this.options.step : 1,
|
1575
|
-
valModStep = (val - this._valueMin()) % step,
|
1576
|
-
alignValue = val - valModStep;
|
1577
|
-
|
1578
|
-
if ( Math.abs(valModStep) * 2 >= step ) {
|
1579
|
-
alignValue += ( valModStep > 0 ) ? step : ( -step );
|
1580
|
-
}
|
1581
|
-
|
1582
|
-
// Since JavaScript has problems with large floats, round
|
1583
|
-
// the final value to 5 digits after the decimal point (see #4124)
|
1584
|
-
return parseFloat( alignValue.toFixed(5) );
|
1585
|
-
},
|
1586
|
-
|
1587
|
-
_valueMin: function() {
|
1588
|
-
return this.options.min;
|
1589
|
-
},
|
1590
|
-
|
1591
|
-
_valueMax: function() {
|
1592
|
-
return this.options.max;
|
1593
|
-
},
|
1594
|
-
|
1595
|
-
_refreshValue: function() {
|
1596
|
-
var lastValPercent, valPercent, value, valueMin, valueMax,
|
1597
|
-
oRange = this.options.range,
|
1598
|
-
o = this.options,
|
1599
|
-
that = this,
|
1600
|
-
animate = ( !this._animateOff ) ? o.animate : false,
|
1601
|
-
_set = {};
|
1602
|
-
|
1603
|
-
if ( this.options.values && this.options.values.length ) {
|
1604
|
-
this.handles.each(function( i ) {
|
1605
|
-
valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
|
1606
|
-
_set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
|
1607
|
-
$( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
|
1608
|
-
if ( that.options.range === true ) {
|
1609
|
-
if ( that.orientation === "horizontal" ) {
|
1610
|
-
if ( i === 0 ) {
|
1611
|
-
that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
|
1612
|
-
}
|
1613
|
-
if ( i === 1 ) {
|
1614
|
-
that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
|
1615
|
-
}
|
1616
|
-
} else {
|
1617
|
-
if ( i === 0 ) {
|
1618
|
-
that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
|
1619
|
-
}
|
1620
|
-
if ( i === 1 ) {
|
1621
|
-
that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
|
1622
|
-
}
|
1623
|
-
}
|
1624
|
-
}
|
1625
|
-
lastValPercent = valPercent;
|
1626
|
-
});
|
1627
|
-
} else {
|
1628
|
-
value = this.value();
|
1629
|
-
valueMin = this._valueMin();
|
1630
|
-
valueMax = this._valueMax();
|
1631
|
-
valPercent = ( valueMax !== valueMin ) ?
|
1632
|
-
( value - valueMin ) / ( valueMax - valueMin ) * 100 :
|
1633
|
-
0;
|
1634
|
-
_set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
|
1635
|
-
this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
|
1636
|
-
|
1637
|
-
if ( oRange === "min" && this.orientation === "horizontal" ) {
|
1638
|
-
this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
|
1639
|
-
}
|
1640
|
-
if ( oRange === "max" && this.orientation === "horizontal" ) {
|
1641
|
-
this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
|
1642
|
-
}
|
1643
|
-
if ( oRange === "min" && this.orientation === "vertical" ) {
|
1644
|
-
this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
|
1645
|
-
}
|
1646
|
-
if ( oRange === "max" && this.orientation === "vertical" ) {
|
1647
|
-
this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
|
1648
|
-
}
|
1649
|
-
}
|
1650
|
-
}
|
1651
|
-
|
1652
|
-
});
|
1653
|
-
|
1654
|
-
}(jQuery));
|