jqueryui-requirejs-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +3 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/javascripts/jqueryui/accordion.js +575 -0
  5. data/app/assets/javascripts/jqueryui/autocomplete.js +613 -0
  6. data/app/assets/javascripts/jqueryui/button.js +422 -0
  7. data/app/assets/javascripts/jqueryui/core.js +323 -0
  8. data/app/assets/javascripts/jqueryui/datepicker-af.js +26 -0
  9. data/app/assets/javascripts/jqueryui/datepicker-ar-DZ.js +26 -0
  10. data/app/assets/javascripts/jqueryui/datepicker-ar.js +26 -0
  11. data/app/assets/javascripts/jqueryui/datepicker-az.js +26 -0
  12. data/app/assets/javascripts/jqueryui/datepicker-be.js +26 -0
  13. data/app/assets/javascripts/jqueryui/datepicker-bg.js +27 -0
  14. data/app/assets/javascripts/jqueryui/datepicker-bs.js +26 -0
  15. data/app/assets/javascripts/jqueryui/datepicker-ca.js +26 -0
  16. data/app/assets/javascripts/jqueryui/datepicker-cs.js +26 -0
  17. data/app/assets/javascripts/jqueryui/datepicker-cy-GB.js +26 -0
  18. data/app/assets/javascripts/jqueryui/datepicker-da.js +26 -0
  19. data/app/assets/javascripts/jqueryui/datepicker-de.js +26 -0
  20. data/app/assets/javascripts/jqueryui/datepicker-el.js +26 -0
  21. data/app/assets/javascripts/jqueryui/datepicker-en-AU.js +26 -0
  22. data/app/assets/javascripts/jqueryui/datepicker-en-GB.js +26 -0
  23. data/app/assets/javascripts/jqueryui/datepicker-en-NZ.js +26 -0
  24. data/app/assets/javascripts/jqueryui/datepicker-eo.js +26 -0
  25. data/app/assets/javascripts/jqueryui/datepicker-es.js +26 -0
  26. data/app/assets/javascripts/jqueryui/datepicker-et.js +26 -0
  27. data/app/assets/javascripts/jqueryui/datepicker-eu.js +26 -0
  28. data/app/assets/javascripts/jqueryui/datepicker-fa.js +62 -0
  29. data/app/assets/javascripts/jqueryui/datepicker-fi.js +26 -0
  30. data/app/assets/javascripts/jqueryui/datepicker-fo.js +26 -0
  31. data/app/assets/javascripts/jqueryui/datepicker-fr-CA.js +26 -0
  32. data/app/assets/javascripts/jqueryui/datepicker-fr-CH.js +26 -0
  33. data/app/assets/javascripts/jqueryui/datepicker-fr.js +28 -0
  34. data/app/assets/javascripts/jqueryui/datepicker-gl.js +26 -0
  35. data/app/assets/javascripts/jqueryui/datepicker-he.js +26 -0
  36. data/app/assets/javascripts/jqueryui/datepicker-hi.js +26 -0
  37. data/app/assets/javascripts/jqueryui/datepicker-hr.js +26 -0
  38. data/app/assets/javascripts/jqueryui/datepicker-hu.js +26 -0
  39. data/app/assets/javascripts/jqueryui/datepicker-hy.js +26 -0
  40. data/app/assets/javascripts/jqueryui/datepicker-id.js +26 -0
  41. data/app/assets/javascripts/jqueryui/datepicker-is.js +26 -0
  42. data/app/assets/javascripts/jqueryui/datepicker-it.js +26 -0
  43. data/app/assets/javascripts/jqueryui/datepicker-ja.js +26 -0
  44. data/app/assets/javascripts/jqueryui/datepicker-ka.js +24 -0
  45. data/app/assets/javascripts/jqueryui/datepicker-kk.js +26 -0
  46. data/app/assets/javascripts/jqueryui/datepicker-km.js +26 -0
  47. data/app/assets/javascripts/jqueryui/datepicker-ko.js +26 -0
  48. data/app/assets/javascripts/jqueryui/datepicker-ky.js +27 -0
  49. data/app/assets/javascripts/jqueryui/datepicker-lb.js +26 -0
  50. data/app/assets/javascripts/jqueryui/datepicker-lt.js +26 -0
  51. data/app/assets/javascripts/jqueryui/datepicker-lv.js +26 -0
  52. data/app/assets/javascripts/jqueryui/datepicker-mk.js +26 -0
  53. data/app/assets/javascripts/jqueryui/datepicker-ml.js +26 -0
  54. data/app/assets/javascripts/jqueryui/datepicker-ms.js +26 -0
  55. data/app/assets/javascripts/jqueryui/datepicker-nb.js +25 -0
  56. data/app/assets/javascripts/jqueryui/datepicker-nl-BE.js +26 -0
  57. data/app/assets/javascripts/jqueryui/datepicker-nl.js +26 -0
  58. data/app/assets/javascripts/jqueryui/datepicker-nn.js +25 -0
  59. data/app/assets/javascripts/jqueryui/datepicker-no.js +26 -0
  60. data/app/assets/javascripts/jqueryui/datepicker-pl.js +26 -0
  61. data/app/assets/javascripts/jqueryui/datepicker-pt-BR.js +26 -0
  62. data/app/assets/javascripts/jqueryui/datepicker-pt.js +25 -0
  63. data/app/assets/javascripts/jqueryui/datepicker-rm.js +24 -0
  64. data/app/assets/javascripts/jqueryui/datepicker-ro.js +29 -0
  65. data/app/assets/javascripts/jqueryui/datepicker-ru.js +26 -0
  66. data/app/assets/javascripts/jqueryui/datepicker-sk.js +26 -0
  67. data/app/assets/javascripts/jqueryui/datepicker-sl.js +27 -0
  68. data/app/assets/javascripts/jqueryui/datepicker-sq.js +26 -0
  69. data/app/assets/javascripts/jqueryui/datepicker-sr-SR.js +26 -0
  70. data/app/assets/javascripts/jqueryui/datepicker-sr.js +26 -0
  71. data/app/assets/javascripts/jqueryui/datepicker-sv.js +26 -0
  72. data/app/assets/javascripts/jqueryui/datepicker-ta.js +26 -0
  73. data/app/assets/javascripts/jqueryui/datepicker-th.js +26 -0
  74. data/app/assets/javascripts/jqueryui/datepicker-tj.js +26 -0
  75. data/app/assets/javascripts/jqueryui/datepicker-tr.js +26 -0
  76. data/app/assets/javascripts/jqueryui/datepicker-uk.js +27 -0
  77. data/app/assets/javascripts/jqueryui/datepicker-vi.js +26 -0
  78. data/app/assets/javascripts/jqueryui/datepicker-zh-CN.js +26 -0
  79. data/app/assets/javascripts/jqueryui/datepicker-zh-HK.js +26 -0
  80. data/app/assets/javascripts/jqueryui/datepicker-zh-TW.js +26 -0
  81. data/app/assets/javascripts/jqueryui/datepicker.js +2053 -0
  82. data/app/assets/javascripts/jqueryui/dialog.js +811 -0
  83. data/app/assets/javascripts/jqueryui/draggable.js +936 -0
  84. data/app/assets/javascripts/jqueryui/droppable.js +375 -0
  85. data/app/assets/javascripts/jqueryui/effect-blind.js +85 -0
  86. data/app/assets/javascripts/jqueryui/effect-bounce.js +116 -0
  87. data/app/assets/javascripts/jqueryui/effect-clip.js +70 -0
  88. data/app/assets/javascripts/jqueryui/effect-drop.js +68 -0
  89. data/app/assets/javascripts/jqueryui/effect-explode.js +100 -0
  90. data/app/assets/javascripts/jqueryui/effect-fade.js +33 -0
  91. data/app/assets/javascripts/jqueryui/effect-fold.js +79 -0
  92. data/app/assets/javascripts/jqueryui/effect-highlight.js +53 -0
  93. data/app/assets/javascripts/jqueryui/effect-pulsate.js +66 -0
  94. data/app/assets/javascripts/jqueryui/effect-scale.js +321 -0
  95. data/app/assets/javascripts/jqueryui/effect-shake.js +77 -0
  96. data/app/assets/javascripts/jqueryui/effect-slide.js +67 -0
  97. data/app/assets/javascripts/jqueryui/effect-transfer.js +50 -0
  98. data/app/assets/javascripts/jqueryui/effect.js +1292 -0
  99. data/app/assets/javascripts/jqueryui/menu.js +624 -0
  100. data/app/assets/javascripts/jqueryui/mouse.js +172 -0
  101. data/app/assets/javascripts/jqueryui/position.js +500 -0
  102. data/app/assets/javascripts/jqueryui/progressbar.js +148 -0
  103. data/app/assets/javascripts/jqueryui/resizable.js +971 -0
  104. data/app/assets/javascripts/jqueryui/selectable.js +280 -0
  105. data/app/assets/javascripts/jqueryui/slider.js +675 -0
  106. data/app/assets/javascripts/jqueryui/sortable.js +1285 -0
  107. data/app/assets/javascripts/jqueryui/spinner.js +496 -0
  108. data/app/assets/javascripts/jqueryui/tabs.js +849 -0
  109. data/app/assets/javascripts/jqueryui/tooltip.js +405 -0
  110. data/app/assets/javascripts/jqueryui/widget.js +524 -0
  111. data/lib/jqueryui-requirejs-rails.rb +4 -0
  112. data/lib/jqueryui-requirejs-rails/engine.rb +4 -0
  113. data/lib/jqueryui-requirejs-rails/version.rb +3 -0
  114. metadata +196 -0
@@ -0,0 +1,280 @@
1
+ define(['jquery','./core','./mouse','./widget'], function (jQuery) {
2
+ /*!
3
+ * jQuery UI Selectable 1.10.2
4
+ * http://jqueryui.com
5
+ *
6
+ * Copyright 2013 jQuery Foundation and other contributors
7
+ * Released under the MIT license.
8
+ * http://jquery.org/license
9
+ *
10
+ * http://api.jqueryui.com/selectable/
11
+ *
12
+ * Depends:
13
+ * jquery.ui.core.js
14
+ * jquery.ui.mouse.js
15
+ * jquery.ui.widget.js
16
+ */
17
+ (function( $, undefined ) {
18
+
19
+ $.widget("ui.selectable", $.ui.mouse, {
20
+ version: "1.10.2",
21
+ options: {
22
+ appendTo: "body",
23
+ autoRefresh: true,
24
+ distance: 0,
25
+ filter: "*",
26
+ tolerance: "touch",
27
+
28
+ // callbacks
29
+ selected: null,
30
+ selecting: null,
31
+ start: null,
32
+ stop: null,
33
+ unselected: null,
34
+ unselecting: null
35
+ },
36
+ _create: function() {
37
+ var selectees,
38
+ that = this;
39
+
40
+ this.element.addClass("ui-selectable");
41
+
42
+ this.dragged = false;
43
+
44
+ // cache selectee children based on filter
45
+ this.refresh = function() {
46
+ selectees = $(that.options.filter, that.element[0]);
47
+ selectees.addClass("ui-selectee");
48
+ selectees.each(function() {
49
+ var $this = $(this),
50
+ pos = $this.offset();
51
+ $.data(this, "selectable-item", {
52
+ element: this,
53
+ $element: $this,
54
+ left: pos.left,
55
+ top: pos.top,
56
+ right: pos.left + $this.outerWidth(),
57
+ bottom: pos.top + $this.outerHeight(),
58
+ startselected: false,
59
+ selected: $this.hasClass("ui-selected"),
60
+ selecting: $this.hasClass("ui-selecting"),
61
+ unselecting: $this.hasClass("ui-unselecting")
62
+ });
63
+ });
64
+ };
65
+ this.refresh();
66
+
67
+ this.selectees = selectees.addClass("ui-selectee");
68
+
69
+ this._mouseInit();
70
+
71
+ this.helper = $("<div class='ui-selectable-helper'></div>");
72
+ },
73
+
74
+ _destroy: function() {
75
+ this.selectees
76
+ .removeClass("ui-selectee")
77
+ .removeData("selectable-item");
78
+ this.element
79
+ .removeClass("ui-selectable ui-selectable-disabled");
80
+ this._mouseDestroy();
81
+ },
82
+
83
+ _mouseStart: function(event) {
84
+ var that = this,
85
+ options = this.options;
86
+
87
+ this.opos = [event.pageX, event.pageY];
88
+
89
+ if (this.options.disabled) {
90
+ return;
91
+ }
92
+
93
+ this.selectees = $(options.filter, this.element[0]);
94
+
95
+ this._trigger("start", event);
96
+
97
+ $(options.appendTo).append(this.helper);
98
+ // position helper (lasso)
99
+ this.helper.css({
100
+ "left": event.pageX,
101
+ "top": event.pageY,
102
+ "width": 0,
103
+ "height": 0
104
+ });
105
+
106
+ if (options.autoRefresh) {
107
+ this.refresh();
108
+ }
109
+
110
+ this.selectees.filter(".ui-selected").each(function() {
111
+ var selectee = $.data(this, "selectable-item");
112
+ selectee.startselected = true;
113
+ if (!event.metaKey && !event.ctrlKey) {
114
+ selectee.$element.removeClass("ui-selected");
115
+ selectee.selected = false;
116
+ selectee.$element.addClass("ui-unselecting");
117
+ selectee.unselecting = true;
118
+ // selectable UNSELECTING callback
119
+ that._trigger("unselecting", event, {
120
+ unselecting: selectee.element
121
+ });
122
+ }
123
+ });
124
+
125
+ $(event.target).parents().addBack().each(function() {
126
+ var doSelect,
127
+ selectee = $.data(this, "selectable-item");
128
+ if (selectee) {
129
+ doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
130
+ selectee.$element
131
+ .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
132
+ .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
133
+ selectee.unselecting = !doSelect;
134
+ selectee.selecting = doSelect;
135
+ selectee.selected = doSelect;
136
+ // selectable (UN)SELECTING callback
137
+ if (doSelect) {
138
+ that._trigger("selecting", event, {
139
+ selecting: selectee.element
140
+ });
141
+ } else {
142
+ that._trigger("unselecting", event, {
143
+ unselecting: selectee.element
144
+ });
145
+ }
146
+ return false;
147
+ }
148
+ });
149
+
150
+ },
151
+
152
+ _mouseDrag: function(event) {
153
+
154
+ this.dragged = true;
155
+
156
+ if (this.options.disabled) {
157
+ return;
158
+ }
159
+
160
+ var tmp,
161
+ that = this,
162
+ options = this.options,
163
+ x1 = this.opos[0],
164
+ y1 = this.opos[1],
165
+ x2 = event.pageX,
166
+ y2 = event.pageY;
167
+
168
+ if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
169
+ if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
170
+ this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
171
+
172
+ this.selectees.each(function() {
173
+ var selectee = $.data(this, "selectable-item"),
174
+ hit = false;
175
+
176
+ //prevent helper from being selected if appendTo: selectable
177
+ if (!selectee || selectee.element === that.element[0]) {
178
+ return;
179
+ }
180
+
181
+ if (options.tolerance === "touch") {
182
+ hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
183
+ } else if (options.tolerance === "fit") {
184
+ hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
185
+ }
186
+
187
+ if (hit) {
188
+ // SELECT
189
+ if (selectee.selected) {
190
+ selectee.$element.removeClass("ui-selected");
191
+ selectee.selected = false;
192
+ }
193
+ if (selectee.unselecting) {
194
+ selectee.$element.removeClass("ui-unselecting");
195
+ selectee.unselecting = false;
196
+ }
197
+ if (!selectee.selecting) {
198
+ selectee.$element.addClass("ui-selecting");
199
+ selectee.selecting = true;
200
+ // selectable SELECTING callback
201
+ that._trigger("selecting", event, {
202
+ selecting: selectee.element
203
+ });
204
+ }
205
+ } else {
206
+ // UNSELECT
207
+ if (selectee.selecting) {
208
+ if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
209
+ selectee.$element.removeClass("ui-selecting");
210
+ selectee.selecting = false;
211
+ selectee.$element.addClass("ui-selected");
212
+ selectee.selected = true;
213
+ } else {
214
+ selectee.$element.removeClass("ui-selecting");
215
+ selectee.selecting = false;
216
+ if (selectee.startselected) {
217
+ selectee.$element.addClass("ui-unselecting");
218
+ selectee.unselecting = true;
219
+ }
220
+ // selectable UNSELECTING callback
221
+ that._trigger("unselecting", event, {
222
+ unselecting: selectee.element
223
+ });
224
+ }
225
+ }
226
+ if (selectee.selected) {
227
+ if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
228
+ selectee.$element.removeClass("ui-selected");
229
+ selectee.selected = false;
230
+
231
+ selectee.$element.addClass("ui-unselecting");
232
+ selectee.unselecting = true;
233
+ // selectable UNSELECTING callback
234
+ that._trigger("unselecting", event, {
235
+ unselecting: selectee.element
236
+ });
237
+ }
238
+ }
239
+ }
240
+ });
241
+
242
+ return false;
243
+ },
244
+
245
+ _mouseStop: function(event) {
246
+ var that = this;
247
+
248
+ this.dragged = false;
249
+
250
+ $(".ui-unselecting", this.element[0]).each(function() {
251
+ var selectee = $.data(this, "selectable-item");
252
+ selectee.$element.removeClass("ui-unselecting");
253
+ selectee.unselecting = false;
254
+ selectee.startselected = false;
255
+ that._trigger("unselected", event, {
256
+ unselected: selectee.element
257
+ });
258
+ });
259
+ $(".ui-selecting", this.element[0]).each(function() {
260
+ var selectee = $.data(this, "selectable-item");
261
+ selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
262
+ selectee.selecting = false;
263
+ selectee.selected = true;
264
+ selectee.startselected = true;
265
+ that._trigger("selected", event, {
266
+ selected: selectee.element
267
+ });
268
+ });
269
+ this._trigger("stop", event);
270
+
271
+ this.helper.remove();
272
+
273
+ return false;
274
+ }
275
+
276
+ });
277
+
278
+ })(jQuery);
279
+
280
+ });
@@ -0,0 +1,675 @@
1
+ define(['jquery','./core','./mouse','./widget'], function (jQuery) {
2
+ /*!
3
+ * jQuery UI Slider 1.10.2
4
+ * http://jqueryui.com
5
+ *
6
+ * Copyright 2013 jQuery Foundation and other contributors
7
+ * Released under the MIT license.
8
+ * http://jquery.org/license
9
+ *
10
+ * http://api.jqueryui.com/slider/
11
+ *
12
+ * Depends:
13
+ * jquery.ui.core.js
14
+ * jquery.ui.mouse.js
15
+ * jquery.ui.widget.js
16
+ */
17
+ (function( $, undefined ) {
18
+
19
+ // number of pages in a slider
20
+ // (how many times can you page up/down to go through the whole range)
21
+ var numPages = 5;
22
+
23
+ $.widget( "ui.slider", $.ui.mouse, {
24
+ version: "1.10.2",
25
+ widgetEventPrefix: "slide",
26
+
27
+ options: {
28
+ animate: false,
29
+ distance: 0,
30
+ max: 100,
31
+ min: 0,
32
+ orientation: "horizontal",
33
+ range: false,
34
+ step: 1,
35
+ value: 0,
36
+ values: null,
37
+
38
+ // callbacks
39
+ change: null,
40
+ slide: null,
41
+ start: null,
42
+ stop: null
43
+ },
44
+
45
+ _create: function() {
46
+ this._keySliding = false;
47
+ this._mouseSliding = false;
48
+ this._animateOff = true;
49
+ this._handleIndex = null;
50
+ this._detectOrientation();
51
+ this._mouseInit();
52
+
53
+ this.element
54
+ .addClass( "ui-slider" +
55
+ " ui-slider-" + this.orientation +
56
+ " ui-widget" +
57
+ " ui-widget-content" +
58
+ " ui-corner-all");
59
+
60
+ this._refresh();
61
+ this._setOption( "disabled", this.options.disabled );
62
+
63
+ this._animateOff = false;
64
+ },
65
+
66
+ _refresh: function() {
67
+ this._createRange();
68
+ this._createHandles();
69
+ this._setupEvents();
70
+ this._refreshValue();
71
+ },
72
+
73
+ _createHandles: function() {
74
+ var i, handleCount,
75
+ options = this.options,
76
+ existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
77
+ handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
78
+ handles = [];
79
+
80
+ handleCount = ( options.values && options.values.length ) || 1;
81
+
82
+ if ( existingHandles.length > handleCount ) {
83
+ existingHandles.slice( handleCount ).remove();
84
+ existingHandles = existingHandles.slice( 0, handleCount );
85
+ }
86
+
87
+ for ( i = existingHandles.length; i < handleCount; i++ ) {
88
+ handles.push( handle );
89
+ }
90
+
91
+ this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
92
+
93
+ this.handle = this.handles.eq( 0 );
94
+
95
+ this.handles.each(function( i ) {
96
+ $( this ).data( "ui-slider-handle-index", i );
97
+ });
98
+ },
99
+
100
+ _createRange: function() {
101
+ var options = this.options,
102
+ classes = "";
103
+
104
+ if ( options.range ) {
105
+ if ( options.range === true ) {
106
+ if ( !options.values ) {
107
+ options.values = [ this._valueMin(), this._valueMin() ];
108
+ } else if ( options.values.length && options.values.length !== 2 ) {
109
+ options.values = [ options.values[0], options.values[0] ];
110
+ } else if ( $.isArray( options.values ) ) {
111
+ options.values = options.values.slice(0);
112
+ }
113
+ }
114
+
115
+ if ( !this.range || !this.range.length ) {
116
+ this.range = $( "<div></div>" )
117
+ .appendTo( this.element );
118
+
119
+ classes = "ui-slider-range" +
120
+ // note: this isn't the most fittingly semantic framework class for this element,
121
+ // but worked best visually with a variety of themes
122
+ " ui-widget-header ui-corner-all";
123
+ } else {
124
+ this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
125
+ // Handle range switching from true to min/max
126
+ .css({
127
+ "left": "",
128
+ "bottom": ""
129
+ });
130
+ }
131
+
132
+ this.range.addClass( classes +
133
+ ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
134
+ } else {
135
+ this.range = $([]);
136
+ }
137
+ },
138
+
139
+ _setupEvents: function() {
140
+ var elements = this.handles.add( this.range ).filter( "a" );
141
+ this._off( elements );
142
+ this._on( elements, this._handleEvents );
143
+ this._hoverable( elements );
144
+ this._focusable( elements );
145
+ },
146
+
147
+ _destroy: function() {
148
+ this.handles.remove();
149
+ this.range.remove();
150
+
151
+ this.element
152
+ .removeClass( "ui-slider" +
153
+ " ui-slider-horizontal" +
154
+ " ui-slider-vertical" +
155
+ " ui-widget" +
156
+ " ui-widget-content" +
157
+ " ui-corner-all" );
158
+
159
+ this._mouseDestroy();
160
+ },
161
+
162
+ _mouseCapture: function( event ) {
163
+ var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
164
+ that = this,
165
+ o = this.options;
166
+
167
+ if ( o.disabled ) {
168
+ return false;
169
+ }
170
+
171
+ this.elementSize = {
172
+ width: this.element.outerWidth(),
173
+ height: this.element.outerHeight()
174
+ };
175
+ this.elementOffset = this.element.offset();
176
+
177
+ position = { x: event.pageX, y: event.pageY };
178
+ normValue = this._normValueFromMouse( position );
179
+ distance = this._valueMax() - this._valueMin() + 1;
180
+ this.handles.each(function( i ) {
181
+ var thisDistance = Math.abs( normValue - that.values(i) );
182
+ if (( distance > thisDistance ) ||
183
+ ( distance === thisDistance &&
184
+ (i === that._lastChangedValue || that.values(i) === o.min ))) {
185
+ distance = thisDistance;
186
+ closestHandle = $( this );
187
+ index = i;
188
+ }
189
+ });
190
+
191
+ allowed = this._start( event, index );
192
+ if ( allowed === false ) {
193
+ return false;
194
+ }
195
+ this._mouseSliding = true;
196
+
197
+ this._handleIndex = index;
198
+
199
+ closestHandle
200
+ .addClass( "ui-state-active" )
201
+ .focus();
202
+
203
+ offset = closestHandle.offset();
204
+ mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
205
+ this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
206
+ left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
207
+ top: event.pageY - offset.top -
208
+ ( closestHandle.height() / 2 ) -
209
+ ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
210
+ ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
211
+ ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
212
+ };
213
+
214
+ if ( !this.handles.hasClass( "ui-state-hover" ) ) {
215
+ this._slide( event, index, normValue );
216
+ }
217
+ this._animateOff = true;
218
+ return true;
219
+ },
220
+
221
+ _mouseStart: function() {
222
+ return true;
223
+ },
224
+
225
+ _mouseDrag: function( event ) {
226
+ var position = { x: event.pageX, y: event.pageY },
227
+ normValue = this._normValueFromMouse( position );
228
+
229
+ this._slide( event, this._handleIndex, normValue );
230
+
231
+ return false;
232
+ },
233
+
234
+ _mouseStop: function( event ) {
235
+ this.handles.removeClass( "ui-state-active" );
236
+ this._mouseSliding = false;
237
+
238
+ this._stop( event, this._handleIndex );
239
+ this._change( event, this._handleIndex );
240
+
241
+ this._handleIndex = null;
242
+ this._clickOffset = null;
243
+ this._animateOff = false;
244
+
245
+ return false;
246
+ },
247
+
248
+ _detectOrientation: function() {
249
+ this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
250
+ },
251
+
252
+ _normValueFromMouse: function( position ) {
253
+ var pixelTotal,
254
+ pixelMouse,
255
+ percentMouse,
256
+ valueTotal,
257
+ valueMouse;
258
+
259
+ if ( this.orientation === "horizontal" ) {
260
+ pixelTotal = this.elementSize.width;
261
+ pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
262
+ } else {
263
+ pixelTotal = this.elementSize.height;
264
+ pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
265
+ }
266
+
267
+ percentMouse = ( pixelMouse / pixelTotal );
268
+ if ( percentMouse > 1 ) {
269
+ percentMouse = 1;
270
+ }
271
+ if ( percentMouse < 0 ) {
272
+ percentMouse = 0;
273
+ }
274
+ if ( this.orientation === "vertical" ) {
275
+ percentMouse = 1 - percentMouse;
276
+ }
277
+
278
+ valueTotal = this._valueMax() - this._valueMin();
279
+ valueMouse = this._valueMin() + percentMouse * valueTotal;
280
+
281
+ return this._trimAlignValue( valueMouse );
282
+ },
283
+
284
+ _start: function( event, index ) {
285
+ var uiHash = {
286
+ handle: this.handles[ index ],
287
+ value: this.value()
288
+ };
289
+ if ( this.options.values && this.options.values.length ) {
290
+ uiHash.value = this.values( index );
291
+ uiHash.values = this.values();
292
+ }
293
+ return this._trigger( "start", event, uiHash );
294
+ },
295
+
296
+ _slide: function( event, index, newVal ) {
297
+ var otherVal,
298
+ newValues,
299
+ allowed;
300
+
301
+ if ( this.options.values && this.options.values.length ) {
302
+ otherVal = this.values( index ? 0 : 1 );
303
+
304
+ if ( ( this.options.values.length === 2 && this.options.range === true ) &&
305
+ ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
306
+ ) {
307
+ newVal = otherVal;
308
+ }
309
+
310
+ if ( newVal !== this.values( index ) ) {
311
+ newValues = this.values();
312
+ newValues[ index ] = newVal;
313
+ // A slide can be canceled by returning false from the slide callback
314
+ allowed = this._trigger( "slide", event, {
315
+ handle: this.handles[ index ],
316
+ value: newVal,
317
+ values: newValues
318
+ } );
319
+ otherVal = this.values( index ? 0 : 1 );
320
+ if ( allowed !== false ) {
321
+ this.values( index, newVal, true );
322
+ }
323
+ }
324
+ } else {
325
+ if ( newVal !== this.value() ) {
326
+ // A slide can be canceled by returning false from the slide callback
327
+ allowed = this._trigger( "slide", event, {
328
+ handle: this.handles[ index ],
329
+ value: newVal
330
+ } );
331
+ if ( allowed !== false ) {
332
+ this.value( newVal );
333
+ }
334
+ }
335
+ }
336
+ },
337
+
338
+ _stop: function( event, index ) {
339
+ var uiHash = {
340
+ handle: this.handles[ index ],
341
+ value: this.value()
342
+ };
343
+ if ( this.options.values && this.options.values.length ) {
344
+ uiHash.value = this.values( index );
345
+ uiHash.values = this.values();
346
+ }
347
+
348
+ this._trigger( "stop", event, uiHash );
349
+ },
350
+
351
+ _change: function( event, index ) {
352
+ if ( !this._keySliding && !this._mouseSliding ) {
353
+ var uiHash = {
354
+ handle: this.handles[ index ],
355
+ value: this.value()
356
+ };
357
+ if ( this.options.values && this.options.values.length ) {
358
+ uiHash.value = this.values( index );
359
+ uiHash.values = this.values();
360
+ }
361
+
362
+ //store the last changed value index for reference when handles overlap
363
+ this._lastChangedValue = index;
364
+
365
+ this._trigger( "change", event, uiHash );
366
+ }
367
+ },
368
+
369
+ value: function( newValue ) {
370
+ if ( arguments.length ) {
371
+ this.options.value = this._trimAlignValue( newValue );
372
+ this._refreshValue();
373
+ this._change( null, 0 );
374
+ return;
375
+ }
376
+
377
+ return this._value();
378
+ },
379
+
380
+ values: function( index, newValue ) {
381
+ var vals,
382
+ newValues,
383
+ i;
384
+
385
+ if ( arguments.length > 1 ) {
386
+ this.options.values[ index ] = this._trimAlignValue( newValue );
387
+ this._refreshValue();
388
+ this._change( null, index );
389
+ return;
390
+ }
391
+
392
+ if ( arguments.length ) {
393
+ if ( $.isArray( arguments[ 0 ] ) ) {
394
+ vals = this.options.values;
395
+ newValues = arguments[ 0 ];
396
+ for ( i = 0; i < vals.length; i += 1 ) {
397
+ vals[ i ] = this._trimAlignValue( newValues[ i ] );
398
+ this._change( null, i );
399
+ }
400
+ this._refreshValue();
401
+ } else {
402
+ if ( this.options.values && this.options.values.length ) {
403
+ return this._values( index );
404
+ } else {
405
+ return this.value();
406
+ }
407
+ }
408
+ } else {
409
+ return this._values();
410
+ }
411
+ },
412
+
413
+ _setOption: function( key, value ) {
414
+ var i,
415
+ valsLength = 0;
416
+
417
+ if ( key === "range" && this.options.range === true ) {
418
+ if ( value === "min" ) {
419
+ this.options.value = this._values( 0 );
420
+ this.options.values = null;
421
+ } else if ( value === "max" ) {
422
+ this.options.value = this._values( this.options.values.length-1 );
423
+ this.options.values = null;
424
+ }
425
+ }
426
+
427
+ if ( $.isArray( this.options.values ) ) {
428
+ valsLength = this.options.values.length;
429
+ }
430
+
431
+ $.Widget.prototype._setOption.apply( this, arguments );
432
+
433
+ switch ( key ) {
434
+ case "orientation":
435
+ this._detectOrientation();
436
+ this.element
437
+ .removeClass( "ui-slider-horizontal ui-slider-vertical" )
438
+ .addClass( "ui-slider-" + this.orientation );
439
+ this._refreshValue();
440
+ break;
441
+ case "value":
442
+ this._animateOff = true;
443
+ this._refreshValue();
444
+ this._change( null, 0 );
445
+ this._animateOff = false;
446
+ break;
447
+ case "values":
448
+ this._animateOff = true;
449
+ this._refreshValue();
450
+ for ( i = 0; i < valsLength; i += 1 ) {
451
+ this._change( null, i );
452
+ }
453
+ this._animateOff = false;
454
+ break;
455
+ case "min":
456
+ case "max":
457
+ this._animateOff = true;
458
+ this._refreshValue();
459
+ this._animateOff = false;
460
+ break;
461
+ case "range":
462
+ this._animateOff = true;
463
+ this._refresh();
464
+ this._animateOff = false;
465
+ break;
466
+ }
467
+ },
468
+
469
+ //internal value getter
470
+ // _value() returns value trimmed by min and max, aligned by step
471
+ _value: function() {
472
+ var val = this.options.value;
473
+ val = this._trimAlignValue( val );
474
+
475
+ return val;
476
+ },
477
+
478
+ //internal values getter
479
+ // _values() returns array of values trimmed by min and max, aligned by step
480
+ // _values( index ) returns single value trimmed by min and max, aligned by step
481
+ _values: function( index ) {
482
+ var val,
483
+ vals,
484
+ i;
485
+
486
+ if ( arguments.length ) {
487
+ val = this.options.values[ index ];
488
+ val = this._trimAlignValue( val );
489
+
490
+ return val;
491
+ } else if ( this.options.values && this.options.values.length ) {
492
+ // .slice() creates a copy of the array
493
+ // this copy gets trimmed by min and max and then returned
494
+ vals = this.options.values.slice();
495
+ for ( i = 0; i < vals.length; i+= 1) {
496
+ vals[ i ] = this._trimAlignValue( vals[ i ] );
497
+ }
498
+
499
+ return vals;
500
+ } else {
501
+ return [];
502
+ }
503
+ },
504
+
505
+ // returns the step-aligned value that val is closest to, between (inclusive) min and max
506
+ _trimAlignValue: function( val ) {
507
+ if ( val <= this._valueMin() ) {
508
+ return this._valueMin();
509
+ }
510
+ if ( val >= this._valueMax() ) {
511
+ return this._valueMax();
512
+ }
513
+ var step = ( this.options.step > 0 ) ? this.options.step : 1,
514
+ valModStep = (val - this._valueMin()) % step,
515
+ alignValue = val - valModStep;
516
+
517
+ if ( Math.abs(valModStep) * 2 >= step ) {
518
+ alignValue += ( valModStep > 0 ) ? step : ( -step );
519
+ }
520
+
521
+ // Since JavaScript has problems with large floats, round
522
+ // the final value to 5 digits after the decimal point (see #4124)
523
+ return parseFloat( alignValue.toFixed(5) );
524
+ },
525
+
526
+ _valueMin: function() {
527
+ return this.options.min;
528
+ },
529
+
530
+ _valueMax: function() {
531
+ return this.options.max;
532
+ },
533
+
534
+ _refreshValue: function() {
535
+ var lastValPercent, valPercent, value, valueMin, valueMax,
536
+ oRange = this.options.range,
537
+ o = this.options,
538
+ that = this,
539
+ animate = ( !this._animateOff ) ? o.animate : false,
540
+ _set = {};
541
+
542
+ if ( this.options.values && this.options.values.length ) {
543
+ this.handles.each(function( i ) {
544
+ valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
545
+ _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
546
+ $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
547
+ if ( that.options.range === true ) {
548
+ if ( that.orientation === "horizontal" ) {
549
+ if ( i === 0 ) {
550
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
551
+ }
552
+ if ( i === 1 ) {
553
+ that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
554
+ }
555
+ } else {
556
+ if ( i === 0 ) {
557
+ that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
558
+ }
559
+ if ( i === 1 ) {
560
+ that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
561
+ }
562
+ }
563
+ }
564
+ lastValPercent = valPercent;
565
+ });
566
+ } else {
567
+ value = this.value();
568
+ valueMin = this._valueMin();
569
+ valueMax = this._valueMax();
570
+ valPercent = ( valueMax !== valueMin ) ?
571
+ ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
572
+ 0;
573
+ _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
574
+ this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
575
+
576
+ if ( oRange === "min" && this.orientation === "horizontal" ) {
577
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
578
+ }
579
+ if ( oRange === "max" && this.orientation === "horizontal" ) {
580
+ this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
581
+ }
582
+ if ( oRange === "min" && this.orientation === "vertical" ) {
583
+ this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
584
+ }
585
+ if ( oRange === "max" && this.orientation === "vertical" ) {
586
+ this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
587
+ }
588
+ }
589
+ },
590
+
591
+ _handleEvents: {
592
+ keydown: function( event ) {
593
+ /*jshint maxcomplexity:25*/
594
+ var allowed, curVal, newVal, step,
595
+ index = $( event.target ).data( "ui-slider-handle-index" );
596
+
597
+ switch ( event.keyCode ) {
598
+ case $.ui.keyCode.HOME:
599
+ case $.ui.keyCode.END:
600
+ case $.ui.keyCode.PAGE_UP:
601
+ case $.ui.keyCode.PAGE_DOWN:
602
+ case $.ui.keyCode.UP:
603
+ case $.ui.keyCode.RIGHT:
604
+ case $.ui.keyCode.DOWN:
605
+ case $.ui.keyCode.LEFT:
606
+ event.preventDefault();
607
+ if ( !this._keySliding ) {
608
+ this._keySliding = true;
609
+ $( event.target ).addClass( "ui-state-active" );
610
+ allowed = this._start( event, index );
611
+ if ( allowed === false ) {
612
+ return;
613
+ }
614
+ }
615
+ break;
616
+ }
617
+
618
+ step = this.options.step;
619
+ if ( this.options.values && this.options.values.length ) {
620
+ curVal = newVal = this.values( index );
621
+ } else {
622
+ curVal = newVal = this.value();
623
+ }
624
+
625
+ switch ( event.keyCode ) {
626
+ case $.ui.keyCode.HOME:
627
+ newVal = this._valueMin();
628
+ break;
629
+ case $.ui.keyCode.END:
630
+ newVal = this._valueMax();
631
+ break;
632
+ case $.ui.keyCode.PAGE_UP:
633
+ newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
634
+ break;
635
+ case $.ui.keyCode.PAGE_DOWN:
636
+ newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
637
+ break;
638
+ case $.ui.keyCode.UP:
639
+ case $.ui.keyCode.RIGHT:
640
+ if ( curVal === this._valueMax() ) {
641
+ return;
642
+ }
643
+ newVal = this._trimAlignValue( curVal + step );
644
+ break;
645
+ case $.ui.keyCode.DOWN:
646
+ case $.ui.keyCode.LEFT:
647
+ if ( curVal === this._valueMin() ) {
648
+ return;
649
+ }
650
+ newVal = this._trimAlignValue( curVal - step );
651
+ break;
652
+ }
653
+
654
+ this._slide( event, index, newVal );
655
+ },
656
+ click: function( event ) {
657
+ event.preventDefault();
658
+ },
659
+ keyup: function( event ) {
660
+ var index = $( event.target ).data( "ui-slider-handle-index" );
661
+
662
+ if ( this._keySliding ) {
663
+ this._keySliding = false;
664
+ this._stop( event, index );
665
+ this._change( event, index );
666
+ $( event.target ).removeClass( "ui-state-active" );
667
+ }
668
+ }
669
+ }
670
+
671
+ });
672
+
673
+ }(jQuery));
674
+
675
+ });