sn-jquery-ui-rails 6.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.gitmodules +3 -0
  4. data/.travis.yml +2 -0
  5. data/Gemfile +3 -0
  6. data/History.md +168 -0
  7. data/License.txt +2 -0
  8. data/README.md +311 -0
  9. data/Rakefile +258 -0
  10. data/VERSIONS.md +39 -0
  11. data/app/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  12. data/app/assets/images/jquery-ui/ui-icons_444444_256x240.png +0 -0
  13. data/app/assets/images/jquery-ui/ui-icons_555555_256x240.png +0 -0
  14. data/app/assets/images/jquery-ui/ui-icons_777620_256x240.png +0 -0
  15. data/app/assets/images/jquery-ui/ui-icons_777777_256x240.png +0 -0
  16. data/app/assets/images/jquery-ui/ui-icons_cc0000_256x240.png +0 -0
  17. data/app/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
  18. data/app/assets/javascripts/jquery-ui/core.js +15 -0
  19. data/app/assets/javascripts/jquery-ui/data.js +41 -0
  20. data/app/assets/javascripts/jquery-ui/disable-selection.js +48 -0
  21. data/app/assets/javascripts/jquery-ui/effect.all.js +15 -0
  22. data/app/assets/javascripts/jquery-ui/effect.js +1637 -0
  23. data/app/assets/javascripts/jquery-ui/effects/effect-blind.js +73 -0
  24. data/app/assets/javascripts/jquery-ui/effects/effect-bounce.js +113 -0
  25. data/app/assets/javascripts/jquery-ui/effects/effect-clip.js +68 -0
  26. data/app/assets/javascripts/jquery-ui/effects/effect-drop.js +72 -0
  27. data/app/assets/javascripts/jquery-ui/effects/effect-explode.js +114 -0
  28. data/app/assets/javascripts/jquery-ui/effects/effect-fade.js +50 -0
  29. data/app/assets/javascripts/jquery-ui/effects/effect-fold.js +92 -0
  30. data/app/assets/javascripts/jquery-ui/effects/effect-highlight.js +60 -0
  31. data/app/assets/javascripts/jquery-ui/effects/effect-puff.js +46 -0
  32. data/app/assets/javascripts/jquery-ui/effects/effect-pulsate.js +67 -0
  33. data/app/assets/javascripts/jquery-ui/effects/effect-scale.js +60 -0
  34. data/app/assets/javascripts/jquery-ui/effects/effect-shake.js +77 -0
  35. data/app/assets/javascripts/jquery-ui/effects/effect-size.js +194 -0
  36. data/app/assets/javascripts/jquery-ui/effects/effect-slide.js +79 -0
  37. data/app/assets/javascripts/jquery-ui/effects/effect-transfer.js +43 -0
  38. data/app/assets/javascripts/jquery-ui/escape-selector.js +23 -0
  39. data/app/assets/javascripts/jquery-ui/focusable.js +86 -0
  40. data/app/assets/javascripts/jquery-ui/form-reset-mixin.js +80 -0
  41. data/app/assets/javascripts/jquery-ui/form.js +22 -0
  42. data/app/assets/javascripts/jquery-ui/i18n/datepicker-af.js +37 -0
  43. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ar-DZ.js +39 -0
  44. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ar.js +39 -0
  45. data/app/assets/javascripts/jquery-ui/i18n/datepicker-az.js +37 -0
  46. data/app/assets/javascripts/jquery-ui/i18n/datepicker-be.js +37 -0
  47. data/app/assets/javascripts/jquery-ui/i18n/datepicker-bg.js +38 -0
  48. data/app/assets/javascripts/jquery-ui/i18n/datepicker-bs.js +37 -0
  49. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ca.js +37 -0
  50. data/app/assets/javascripts/jquery-ui/i18n/datepicker-cs.js +37 -0
  51. data/app/assets/javascripts/jquery-ui/i18n/datepicker-cy-GB.js +45 -0
  52. data/app/assets/javascripts/jquery-ui/i18n/datepicker-da.js +37 -0
  53. data/app/assets/javascripts/jquery-ui/i18n/datepicker-de.js +37 -0
  54. data/app/assets/javascripts/jquery-ui/i18n/datepicker-el.js +37 -0
  55. data/app/assets/javascripts/jquery-ui/i18n/datepicker-en-AU.js +37 -0
  56. data/app/assets/javascripts/jquery-ui/i18n/datepicker-en-GB.js +37 -0
  57. data/app/assets/javascripts/jquery-ui/i18n/datepicker-en-NZ.js +37 -0
  58. data/app/assets/javascripts/jquery-ui/i18n/datepicker-eo.js +37 -0
  59. data/app/assets/javascripts/jquery-ui/i18n/datepicker-es.js +37 -0
  60. data/app/assets/javascripts/jquery-ui/i18n/datepicker-et.js +45 -0
  61. data/app/assets/javascripts/jquery-ui/i18n/datepicker-eu.js +36 -0
  62. data/app/assets/javascripts/jquery-ui/i18n/datepicker-fa.js +73 -0
  63. data/app/assets/javascripts/jquery-ui/i18n/datepicker-fi.js +37 -0
  64. data/app/assets/javascripts/jquery-ui/i18n/datepicker-fo.js +45 -0
  65. data/app/assets/javascripts/jquery-ui/i18n/datepicker-fr-CA.js +37 -0
  66. data/app/assets/javascripts/jquery-ui/i18n/datepicker-fr-CH.js +37 -0
  67. data/app/assets/javascripts/jquery-ui/i18n/datepicker-fr.js +39 -0
  68. data/app/assets/javascripts/jquery-ui/i18n/datepicker-gl.js +37 -0
  69. data/app/assets/javascripts/jquery-ui/i18n/datepicker-he.js +37 -0
  70. data/app/assets/javascripts/jquery-ui/i18n/datepicker-hi.js +37 -0
  71. data/app/assets/javascripts/jquery-ui/i18n/datepicker-hr.js +37 -0
  72. data/app/assets/javascripts/jquery-ui/i18n/datepicker-hu.js +36 -0
  73. data/app/assets/javascripts/jquery-ui/i18n/datepicker-hy.js +37 -0
  74. data/app/assets/javascripts/jquery-ui/i18n/datepicker-id.js +37 -0
  75. data/app/assets/javascripts/jquery-ui/i18n/datepicker-is.js +45 -0
  76. data/app/assets/javascripts/jquery-ui/i18n/datepicker-it-CH.js +37 -0
  77. data/app/assets/javascripts/jquery-ui/i18n/datepicker-it.js +37 -0
  78. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ja.js +37 -0
  79. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ka.js +48 -0
  80. data/app/assets/javascripts/jquery-ui/i18n/datepicker-kk.js +37 -0
  81. data/app/assets/javascripts/jquery-ui/i18n/datepicker-km.js +37 -0
  82. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ko.js +37 -0
  83. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ky.js +38 -0
  84. data/app/assets/javascripts/jquery-ui/i18n/datepicker-lb.js +45 -0
  85. data/app/assets/javascripts/jquery-ui/i18n/datepicker-lt.js +45 -0
  86. data/app/assets/javascripts/jquery-ui/i18n/datepicker-lv.js +45 -0
  87. data/app/assets/javascripts/jquery-ui/i18n/datepicker-mk.js +37 -0
  88. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ml.js +37 -0
  89. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ms.js +37 -0
  90. data/app/assets/javascripts/jquery-ui/i18n/datepicker-nb.js +49 -0
  91. data/app/assets/javascripts/jquery-ui/i18n/datepicker-nl-BE.js +37 -0
  92. data/app/assets/javascripts/jquery-ui/i18n/datepicker-nl.js +37 -0
  93. data/app/assets/javascripts/jquery-ui/i18n/datepicker-nn.js +49 -0
  94. data/app/assets/javascripts/jquery-ui/i18n/datepicker-no.js +50 -0
  95. data/app/assets/javascripts/jquery-ui/i18n/datepicker-pl.js +37 -0
  96. data/app/assets/javascripts/jquery-ui/i18n/datepicker-pt-BR.js +45 -0
  97. data/app/assets/javascripts/jquery-ui/i18n/datepicker-pt.js +44 -0
  98. data/app/assets/javascripts/jquery-ui/i18n/datepicker-rm.js +61 -0
  99. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ro.js +40 -0
  100. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ru.js +37 -0
  101. data/app/assets/javascripts/jquery-ui/i18n/datepicker-sk.js +37 -0
  102. data/app/assets/javascripts/jquery-ui/i18n/datepicker-sl.js +38 -0
  103. data/app/assets/javascripts/jquery-ui/i18n/datepicker-sq.js +37 -0
  104. data/app/assets/javascripts/jquery-ui/i18n/datepicker-sr-SR.js +37 -0
  105. data/app/assets/javascripts/jquery-ui/i18n/datepicker-sr.js +37 -0
  106. data/app/assets/javascripts/jquery-ui/i18n/datepicker-sv.js +37 -0
  107. data/app/assets/javascripts/jquery-ui/i18n/datepicker-ta.js +53 -0
  108. data/app/assets/javascripts/jquery-ui/i18n/datepicker-th.js +37 -0
  109. data/app/assets/javascripts/jquery-ui/i18n/datepicker-tj.js +37 -0
  110. data/app/assets/javascripts/jquery-ui/i18n/datepicker-tr.js +37 -0
  111. data/app/assets/javascripts/jquery-ui/i18n/datepicker-uk.js +38 -0
  112. data/app/assets/javascripts/jquery-ui/i18n/datepicker-vi.js +37 -0
  113. data/app/assets/javascripts/jquery-ui/i18n/datepicker-zh-CN.js +37 -0
  114. data/app/assets/javascripts/jquery-ui/i18n/datepicker-zh-HK.js +37 -0
  115. data/app/assets/javascripts/jquery-ui/i18n/datepicker-zh-TW.js +37 -0
  116. data/app/assets/javascripts/jquery-ui/ie.js +17 -0
  117. data/app/assets/javascripts/jquery-ui/jquery-1-7.js +91 -0
  118. data/app/assets/javascripts/jquery-ui/keycode.js +47 -0
  119. data/app/assets/javascripts/jquery-ui/labels.js +65 -0
  120. data/app/assets/javascripts/jquery-ui/plugin.js +46 -0
  121. data/app/assets/javascripts/jquery-ui/position.js +500 -0
  122. data/app/assets/javascripts/jquery-ui/safe-active-element.js +42 -0
  123. data/app/assets/javascripts/jquery-ui/safe-blur.js +23 -0
  124. data/app/assets/javascripts/jquery-ui/scroll-parent.js +47 -0
  125. data/app/assets/javascripts/jquery-ui/tabbable.js +38 -0
  126. data/app/assets/javascripts/jquery-ui/unique-id.js +51 -0
  127. data/app/assets/javascripts/jquery-ui/version.js +17 -0
  128. data/app/assets/javascripts/jquery-ui/widget.js +735 -0
  129. data/app/assets/javascripts/jquery-ui/widgets/accordion.js +618 -0
  130. data/app/assets/javascripts/jquery-ui/widgets/autocomplete.js +689 -0
  131. data/app/assets/javascripts/jquery-ui/widgets/button.js +391 -0
  132. data/app/assets/javascripts/jquery-ui/widgets/checkboxradio.js +291 -0
  133. data/app/assets/javascripts/jquery-ui/widgets/controlgroup.js +300 -0
  134. data/app/assets/javascripts/jquery-ui/widgets/datepicker.js +2123 -0
  135. data/app/assets/javascripts/jquery-ui/widgets/dialog.js +954 -0
  136. data/app/assets/javascripts/jquery-ui/widgets/draggable.js +1259 -0
  137. data/app/assets/javascripts/jquery-ui/widgets/droppable.js +502 -0
  138. data/app/assets/javascripts/jquery-ui/widgets/menu.js +680 -0
  139. data/app/assets/javascripts/jquery-ui/widgets/mouse.js +230 -0
  140. data/app/assets/javascripts/jquery-ui/widgets/progressbar.js +181 -0
  141. data/app/assets/javascripts/jquery-ui/widgets/resizable.js +1207 -0
  142. data/app/assets/javascripts/jquery-ui/widgets/selectable.js +314 -0
  143. data/app/assets/javascripts/jquery-ui/widgets/selectmenu.js +697 -0
  144. data/app/assets/javascripts/jquery-ui/widgets/slider.js +757 -0
  145. data/app/assets/javascripts/jquery-ui/widgets/sortable.js +1561 -0
  146. data/app/assets/javascripts/jquery-ui/widgets/spinner.js +581 -0
  147. data/app/assets/javascripts/jquery-ui/widgets/tabs.js +931 -0
  148. data/app/assets/javascripts/jquery-ui/widgets/tooltip.js +526 -0
  149. data/app/assets/javascripts/jquery-ui.js +56 -0
  150. data/app/assets/stylesheets/jquery-ui/accordion.css +26 -0
  151. data/app/assets/stylesheets/jquery-ui/all.css +14 -0
  152. data/app/assets/stylesheets/jquery-ui/autocomplete.css +19 -0
  153. data/app/assets/stylesheets/jquery-ui/base.css +32 -0
  154. data/app/assets/stylesheets/jquery-ui/button.css +85 -0
  155. data/app/assets/stylesheets/jquery-ui/checkboxradio.css +37 -0
  156. data/app/assets/stylesheets/jquery-ui/controlgroup.css +68 -0
  157. data/app/assets/stylesheets/jquery-ui/core.css +100 -0
  158. data/app/assets/stylesheets/jquery-ui/datepicker.css +188 -0
  159. data/app/assets/stylesheets/jquery-ui/dialog.css +104 -0
  160. data/app/assets/stylesheets/jquery-ui/draggable.css +15 -0
  161. data/app/assets/stylesheets/jquery-ui/menu.css +67 -0
  162. data/app/assets/stylesheets/jquery-ui/progressbar.css +31 -0
  163. data/app/assets/stylesheets/jquery-ui/resizable.css +81 -0
  164. data/app/assets/stylesheets/jquery-ui/selectable.css +20 -0
  165. data/app/assets/stylesheets/jquery-ui/selectmenu.css +53 -0
  166. data/app/assets/stylesheets/jquery-ui/slider.css +78 -0
  167. data/app/assets/stylesheets/jquery-ui/sortable.css +15 -0
  168. data/app/assets/stylesheets/jquery-ui/spinner.css +55 -0
  169. data/app/assets/stylesheets/jquery-ui/tabs.css +54 -0
  170. data/app/assets/stylesheets/jquery-ui/theme.css.erb +453 -0
  171. data/app/assets/stylesheets/jquery-ui/tooltip.css +22 -0
  172. data/app/assets/stylesheets/jquery-ui.css +1 -0
  173. data/lib/jquery/ui/rails/engine.rb +8 -0
  174. data/lib/jquery/ui/rails/version.rb +8 -0
  175. data/lib/jquery/ui/rails.rb +2 -0
  176. data/lib/jquery-ui-rails.rb +1 -0
  177. metadata +248 -0
@@ -0,0 +1,581 @@
1
+ //= require jquery-ui/widgets/button
2
+ //= require jquery-ui/version
3
+ //= require jquery-ui/keycode
4
+ //= require jquery-ui/safe-active-element
5
+ //= require jquery-ui/widget
6
+
7
+ /*!
8
+ * jQuery UI Spinner 1.12.1
9
+ * http://jqueryui.com
10
+ *
11
+ * Copyright jQuery Foundation and other contributors
12
+ * Released under the MIT license.
13
+ * http://jquery.org/license
14
+ */
15
+
16
+ //>>label: Spinner
17
+ //>>group: Widgets
18
+ //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
19
+ //>>docs: http://api.jqueryui.com/spinner/
20
+ //>>demos: http://jqueryui.com/spinner/
21
+ //>>css.structure: ../../themes/base/core.css
22
+ //>>css.structure: ../../themes/base/spinner.css
23
+ //>>css.theme: ../../themes/base/theme.css
24
+
25
+ ( function( factory ) {
26
+ if ( typeof define === "function" && define.amd ) {
27
+
28
+ // AMD. Register as an anonymous module.
29
+ define( [
30
+ "jquery",
31
+ "./button",
32
+ "../version",
33
+ "../keycode",
34
+ "../safe-active-element",
35
+ "../widget"
36
+ ], factory );
37
+ } else {
38
+
39
+ // Browser globals
40
+ factory( jQuery );
41
+ }
42
+ }( function( $ ) {
43
+
44
+ function spinnerModifer( fn ) {
45
+ return function() {
46
+ var previous = this.element.val();
47
+ fn.apply( this, arguments );
48
+ this._refresh();
49
+ if ( previous !== this.element.val() ) {
50
+ this._trigger( "change" );
51
+ }
52
+ };
53
+ }
54
+
55
+ $.widget( "ui.spinner", {
56
+ version: "1.12.1",
57
+ defaultElement: "<input>",
58
+ widgetEventPrefix: "spin",
59
+ options: {
60
+ classes: {
61
+ "ui-spinner": "ui-corner-all",
62
+ "ui-spinner-down": "ui-corner-br",
63
+ "ui-spinner-up": "ui-corner-tr"
64
+ },
65
+ culture: null,
66
+ icons: {
67
+ down: "ui-icon-triangle-1-s",
68
+ up: "ui-icon-triangle-1-n"
69
+ },
70
+ incremental: true,
71
+ max: null,
72
+ min: null,
73
+ numberFormat: null,
74
+ page: 10,
75
+ step: 1,
76
+
77
+ change: null,
78
+ spin: null,
79
+ start: null,
80
+ stop: null
81
+ },
82
+
83
+ _create: function() {
84
+
85
+ // handle string values that need to be parsed
86
+ this._setOption( "max", this.options.max );
87
+ this._setOption( "min", this.options.min );
88
+ this._setOption( "step", this.options.step );
89
+
90
+ // Only format if there is a value, prevents the field from being marked
91
+ // as invalid in Firefox, see #9573.
92
+ if ( this.value() !== "" ) {
93
+
94
+ // Format the value, but don't constrain.
95
+ this._value( this.element.val(), true );
96
+ }
97
+
98
+ this._draw();
99
+ this._on( this._events );
100
+ this._refresh();
101
+
102
+ // Turning off autocomplete prevents the browser from remembering the
103
+ // value when navigating through history, so we re-enable autocomplete
104
+ // if the page is unloaded before the widget is destroyed. #7790
105
+ this._on( this.window, {
106
+ beforeunload: function() {
107
+ this.element.removeAttr( "autocomplete" );
108
+ }
109
+ } );
110
+ },
111
+
112
+ _getCreateOptions: function() {
113
+ var options = this._super();
114
+ var element = this.element;
115
+
116
+ $.each( [ "min", "max", "step" ], function( i, option ) {
117
+ var value = element.attr( option );
118
+ if ( value != null && value.length ) {
119
+ options[ option ] = value;
120
+ }
121
+ } );
122
+
123
+ return options;
124
+ },
125
+
126
+ _events: {
127
+ keydown: function( event ) {
128
+ if ( this._start( event ) && this._keydown( event ) ) {
129
+ event.preventDefault();
130
+ }
131
+ },
132
+ keyup: "_stop",
133
+ focus: function() {
134
+ this.previous = this.element.val();
135
+ },
136
+ blur: function( event ) {
137
+ if ( this.cancelBlur ) {
138
+ delete this.cancelBlur;
139
+ return;
140
+ }
141
+
142
+ this._stop();
143
+ this._refresh();
144
+ if ( this.previous !== this.element.val() ) {
145
+ this._trigger( "change", event );
146
+ }
147
+ },
148
+ mousewheel: function( event, delta ) {
149
+ if ( !delta ) {
150
+ return;
151
+ }
152
+ if ( !this.spinning && !this._start( event ) ) {
153
+ return false;
154
+ }
155
+
156
+ this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
157
+ clearTimeout( this.mousewheelTimer );
158
+ this.mousewheelTimer = this._delay( function() {
159
+ if ( this.spinning ) {
160
+ this._stop( event );
161
+ }
162
+ }, 100 );
163
+ event.preventDefault();
164
+ },
165
+ "mousedown .ui-spinner-button": function( event ) {
166
+ var previous;
167
+
168
+ // We never want the buttons to have focus; whenever the user is
169
+ // interacting with the spinner, the focus should be on the input.
170
+ // If the input is focused then this.previous is properly set from
171
+ // when the input first received focus. If the input is not focused
172
+ // then we need to set this.previous based on the value before spinning.
173
+ previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
174
+ this.previous : this.element.val();
175
+ function checkFocus() {
176
+ var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
177
+ if ( !isActive ) {
178
+ this.element.trigger( "focus" );
179
+ this.previous = previous;
180
+
181
+ // support: IE
182
+ // IE sets focus asynchronously, so we need to check if focus
183
+ // moved off of the input because the user clicked on the button.
184
+ this._delay( function() {
185
+ this.previous = previous;
186
+ } );
187
+ }
188
+ }
189
+
190
+ // Ensure focus is on (or stays on) the text field
191
+ event.preventDefault();
192
+ checkFocus.call( this );
193
+
194
+ // Support: IE
195
+ // IE doesn't prevent moving focus even with event.preventDefault()
196
+ // so we set a flag to know when we should ignore the blur event
197
+ // and check (again) if focus moved off of the input.
198
+ this.cancelBlur = true;
199
+ this._delay( function() {
200
+ delete this.cancelBlur;
201
+ checkFocus.call( this );
202
+ } );
203
+
204
+ if ( this._start( event ) === false ) {
205
+ return;
206
+ }
207
+
208
+ this._repeat( null, $( event.currentTarget )
209
+ .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
210
+ },
211
+ "mouseup .ui-spinner-button": "_stop",
212
+ "mouseenter .ui-spinner-button": function( event ) {
213
+
214
+ // button will add ui-state-active if mouse was down while mouseleave and kept down
215
+ if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
216
+ return;
217
+ }
218
+
219
+ if ( this._start( event ) === false ) {
220
+ return false;
221
+ }
222
+ this._repeat( null, $( event.currentTarget )
223
+ .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
224
+ },
225
+
226
+ // TODO: do we really want to consider this a stop?
227
+ // shouldn't we just stop the repeater and wait until mouseup before
228
+ // we trigger the stop event?
229
+ "mouseleave .ui-spinner-button": "_stop"
230
+ },
231
+
232
+ // Support mobile enhanced option and make backcompat more sane
233
+ _enhance: function() {
234
+ this.uiSpinner = this.element
235
+ .attr( "autocomplete", "off" )
236
+ .wrap( "<span>" )
237
+ .parent()
238
+
239
+ // Add buttons
240
+ .append(
241
+ "<a></a><a></a>"
242
+ );
243
+ },
244
+
245
+ _draw: function() {
246
+ this._enhance();
247
+
248
+ this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
249
+ this._addClass( "ui-spinner-input" );
250
+
251
+ this.element.attr( "role", "spinbutton" );
252
+
253
+ // Button bindings
254
+ this.buttons = this.uiSpinner.children( "a" )
255
+ .attr( "tabIndex", -1 )
256
+ .attr( "aria-hidden", true )
257
+ .button( {
258
+ classes: {
259
+ "ui-button": ""
260
+ }
261
+ } );
262
+
263
+ // TODO: Right now button does not support classes this is already updated in button PR
264
+ this._removeClass( this.buttons, "ui-corner-all" );
265
+
266
+ this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
267
+ this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
268
+ this.buttons.first().button( {
269
+ "icon": this.options.icons.up,
270
+ "showLabel": false
271
+ } );
272
+ this.buttons.last().button( {
273
+ "icon": this.options.icons.down,
274
+ "showLabel": false
275
+ } );
276
+
277
+ // IE 6 doesn't understand height: 50% for the buttons
278
+ // unless the wrapper has an explicit height
279
+ if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
280
+ this.uiSpinner.height() > 0 ) {
281
+ this.uiSpinner.height( this.uiSpinner.height() );
282
+ }
283
+ },
284
+
285
+ _keydown: function( event ) {
286
+ var options = this.options,
287
+ keyCode = $.ui.keyCode;
288
+
289
+ switch ( event.keyCode ) {
290
+ case keyCode.UP:
291
+ this._repeat( null, 1, event );
292
+ return true;
293
+ case keyCode.DOWN:
294
+ this._repeat( null, -1, event );
295
+ return true;
296
+ case keyCode.PAGE_UP:
297
+ this._repeat( null, options.page, event );
298
+ return true;
299
+ case keyCode.PAGE_DOWN:
300
+ this._repeat( null, -options.page, event );
301
+ return true;
302
+ }
303
+
304
+ return false;
305
+ },
306
+
307
+ _start: function( event ) {
308
+ if ( !this.spinning && this._trigger( "start", event ) === false ) {
309
+ return false;
310
+ }
311
+
312
+ if ( !this.counter ) {
313
+ this.counter = 1;
314
+ }
315
+ this.spinning = true;
316
+ return true;
317
+ },
318
+
319
+ _repeat: function( i, steps, event ) {
320
+ i = i || 500;
321
+
322
+ clearTimeout( this.timer );
323
+ this.timer = this._delay( function() {
324
+ this._repeat( 40, steps, event );
325
+ }, i );
326
+
327
+ this._spin( steps * this.options.step, event );
328
+ },
329
+
330
+ _spin: function( step, event ) {
331
+ var value = this.value() || 0;
332
+
333
+ if ( !this.counter ) {
334
+ this.counter = 1;
335
+ }
336
+
337
+ value = this._adjustValue( value + step * this._increment( this.counter ) );
338
+
339
+ if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
340
+ this._value( value );
341
+ this.counter++;
342
+ }
343
+ },
344
+
345
+ _increment: function( i ) {
346
+ var incremental = this.options.incremental;
347
+
348
+ if ( incremental ) {
349
+ return $.isFunction( incremental ) ?
350
+ incremental( i ) :
351
+ Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
352
+ }
353
+
354
+ return 1;
355
+ },
356
+
357
+ _precision: function() {
358
+ var precision = this._precisionOf( this.options.step );
359
+ if ( this.options.min !== null ) {
360
+ precision = Math.max( precision, this._precisionOf( this.options.min ) );
361
+ }
362
+ return precision;
363
+ },
364
+
365
+ _precisionOf: function( num ) {
366
+ var str = num.toString(),
367
+ decimal = str.indexOf( "." );
368
+ return decimal === -1 ? 0 : str.length - decimal - 1;
369
+ },
370
+
371
+ _adjustValue: function( value ) {
372
+ var base, aboveMin,
373
+ options = this.options;
374
+
375
+ // Make sure we're at a valid step
376
+ // - find out where we are relative to the base (min or 0)
377
+ base = options.min !== null ? options.min : 0;
378
+ aboveMin = value - base;
379
+
380
+ // - round to the nearest step
381
+ aboveMin = Math.round( aboveMin / options.step ) * options.step;
382
+
383
+ // - rounding is based on 0, so adjust back to our base
384
+ value = base + aboveMin;
385
+
386
+ // Fix precision from bad JS floating point math
387
+ value = parseFloat( value.toFixed( this._precision() ) );
388
+
389
+ // Clamp the value
390
+ if ( options.max !== null && value > options.max ) {
391
+ return options.max;
392
+ }
393
+ if ( options.min !== null && value < options.min ) {
394
+ return options.min;
395
+ }
396
+
397
+ return value;
398
+ },
399
+
400
+ _stop: function( event ) {
401
+ if ( !this.spinning ) {
402
+ return;
403
+ }
404
+
405
+ clearTimeout( this.timer );
406
+ clearTimeout( this.mousewheelTimer );
407
+ this.counter = 0;
408
+ this.spinning = false;
409
+ this._trigger( "stop", event );
410
+ },
411
+
412
+ _setOption: function( key, value ) {
413
+ var prevValue, first, last;
414
+
415
+ if ( key === "culture" || key === "numberFormat" ) {
416
+ prevValue = this._parse( this.element.val() );
417
+ this.options[ key ] = value;
418
+ this.element.val( this._format( prevValue ) );
419
+ return;
420
+ }
421
+
422
+ if ( key === "max" || key === "min" || key === "step" ) {
423
+ if ( typeof value === "string" ) {
424
+ value = this._parse( value );
425
+ }
426
+ }
427
+ if ( key === "icons" ) {
428
+ first = this.buttons.first().find( ".ui-icon" );
429
+ this._removeClass( first, null, this.options.icons.up );
430
+ this._addClass( first, null, value.up );
431
+ last = this.buttons.last().find( ".ui-icon" );
432
+ this._removeClass( last, null, this.options.icons.down );
433
+ this._addClass( last, null, value.down );
434
+ }
435
+
436
+ this._super( key, value );
437
+ },
438
+
439
+ _setOptionDisabled: function( value ) {
440
+ this._super( value );
441
+
442
+ this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
443
+ this.element.prop( "disabled", !!value );
444
+ this.buttons.button( value ? "disable" : "enable" );
445
+ },
446
+
447
+ _setOptions: spinnerModifer( function( options ) {
448
+ this._super( options );
449
+ } ),
450
+
451
+ _parse: function( val ) {
452
+ if ( typeof val === "string" && val !== "" ) {
453
+ val = window.Globalize && this.options.numberFormat ?
454
+ Globalize.parseFloat( val, 10, this.options.culture ) : +val;
455
+ }
456
+ return val === "" || isNaN( val ) ? null : val;
457
+ },
458
+
459
+ _format: function( value ) {
460
+ if ( value === "" ) {
461
+ return "";
462
+ }
463
+ return window.Globalize && this.options.numberFormat ?
464
+ Globalize.format( value, this.options.numberFormat, this.options.culture ) :
465
+ value;
466
+ },
467
+
468
+ _refresh: function() {
469
+ this.element.attr( {
470
+ "aria-valuemin": this.options.min,
471
+ "aria-valuemax": this.options.max,
472
+
473
+ // TODO: what should we do with values that can't be parsed?
474
+ "aria-valuenow": this._parse( this.element.val() )
475
+ } );
476
+ },
477
+
478
+ isValid: function() {
479
+ var value = this.value();
480
+
481
+ // Null is invalid
482
+ if ( value === null ) {
483
+ return false;
484
+ }
485
+
486
+ // If value gets adjusted, it's invalid
487
+ return value === this._adjustValue( value );
488
+ },
489
+
490
+ // Update the value without triggering change
491
+ _value: function( value, allowAny ) {
492
+ var parsed;
493
+ if ( value !== "" ) {
494
+ parsed = this._parse( value );
495
+ if ( parsed !== null ) {
496
+ if ( !allowAny ) {
497
+ parsed = this._adjustValue( parsed );
498
+ }
499
+ value = this._format( parsed );
500
+ }
501
+ }
502
+ this.element.val( value );
503
+ this._refresh();
504
+ },
505
+
506
+ _destroy: function() {
507
+ this.element
508
+ .prop( "disabled", false )
509
+ .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
510
+
511
+ this.uiSpinner.replaceWith( this.element );
512
+ },
513
+
514
+ stepUp: spinnerModifer( function( steps ) {
515
+ this._stepUp( steps );
516
+ } ),
517
+ _stepUp: function( steps ) {
518
+ if ( this._start() ) {
519
+ this._spin( ( steps || 1 ) * this.options.step );
520
+ this._stop();
521
+ }
522
+ },
523
+
524
+ stepDown: spinnerModifer( function( steps ) {
525
+ this._stepDown( steps );
526
+ } ),
527
+ _stepDown: function( steps ) {
528
+ if ( this._start() ) {
529
+ this._spin( ( steps || 1 ) * -this.options.step );
530
+ this._stop();
531
+ }
532
+ },
533
+
534
+ pageUp: spinnerModifer( function( pages ) {
535
+ this._stepUp( ( pages || 1 ) * this.options.page );
536
+ } ),
537
+
538
+ pageDown: spinnerModifer( function( pages ) {
539
+ this._stepDown( ( pages || 1 ) * this.options.page );
540
+ } ),
541
+
542
+ value: function( newVal ) {
543
+ if ( !arguments.length ) {
544
+ return this._parse( this.element.val() );
545
+ }
546
+ spinnerModifer( this._value ).call( this, newVal );
547
+ },
548
+
549
+ widget: function() {
550
+ return this.uiSpinner;
551
+ }
552
+ } );
553
+
554
+ // DEPRECATED
555
+ // TODO: switch return back to widget declaration at top of file when this is removed
556
+ if ( $.uiBackCompat !== false ) {
557
+
558
+ // Backcompat for spinner html extension points
559
+ $.widget( "ui.spinner", $.ui.spinner, {
560
+ _enhance: function() {
561
+ this.uiSpinner = this.element
562
+ .attr( "autocomplete", "off" )
563
+ .wrap( this._uiSpinnerHtml() )
564
+ .parent()
565
+
566
+ // Add buttons
567
+ .append( this._buttonHtml() );
568
+ },
569
+ _uiSpinnerHtml: function() {
570
+ return "<span>";
571
+ },
572
+
573
+ _buttonHtml: function() {
574
+ return "<a></a><a></a>";
575
+ }
576
+ } );
577
+ }
578
+
579
+ return $.ui.spinner;
580
+
581
+ } ) );