iugu-ux 0.9.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/lib/iugu-ux/version.rb +1 -1
  2. data/sandbox/log/development.log +432 -0
  3. data/sandbox/tmp/cache/assets/BD0/110/sprockets%2F52568313d04166c1237865292979c86d +0 -0
  4. data/sandbox/tmp/cache/assets/C48/D00/sprockets%2F4a51b39094a347e3e325005c7847551c +0 -0
  5. data/sandbox/tmp/cache/assets/C49/3B0/sprockets%2F405c7112191eed23e8b860254281e763 +0 -0
  6. data/sandbox/tmp/cache/assets/C4A/8F0/sprockets%2F736644cea24629d653454c90503a0c45 +0 -0
  7. data/sandbox/tmp/cache/assets/C4F/3A0/sprockets%2F41918e8d7b402652a5649e4b7134d620 +0 -0
  8. data/sandbox/tmp/cache/assets/C5A/0F0/sprockets%2F66317254e81572f5a89184618e3c3b5b +0 -0
  9. data/sandbox/tmp/cache/assets/C7A/F30/sprockets%2F70249181577b261a3ea8851b530f1e7c +0 -0
  10. data/sandbox/tmp/cache/assets/C86/500/sprockets%2F6990a45a256263b7579492ac7a6a626a +0 -0
  11. data/sandbox/tmp/cache/assets/C87/F60/sprockets%2F83b4a89e682705a1d0c1e1327608f968 +0 -0
  12. data/sandbox/tmp/cache/assets/C88/820/sprockets%2Fb50c6382fa02d221d1b29a40402d1641 +0 -0
  13. data/sandbox/tmp/cache/assets/C97/790/sprockets%2Ffa5602401f5500215f5c4555190dcbd2 +0 -0
  14. data/sandbox/tmp/cache/assets/CC3/930/sprockets%2F7e2c9302e5050f66e888725be83f862d +0 -0
  15. data/sandbox/tmp/cache/assets/CC7/EB0/sprockets%2F079d3b368c9e843b78c90079f26d628b +0 -0
  16. data/sandbox/tmp/cache/assets/CC8/510/sprockets%2F868a1670f8822e6b7847dd22e747a66f +0 -0
  17. data/sandbox/tmp/cache/assets/CCA/850/sprockets%2F1d05d32f046ec7313b0d3619a232d73f +0 -0
  18. data/sandbox/tmp/cache/assets/CDB/610/sprockets%2Fb5b20836971a5786ca125712b8e0bf5e +0 -0
  19. data/sandbox/tmp/cache/assets/CDB/E30/sprockets%2F918458a88fec2cd01991c003b2318ab7 +0 -0
  20. data/sandbox/tmp/cache/assets/CEC/760/sprockets%2F2e588fd16989acc60b813afe18471562 +0 -0
  21. data/sandbox/tmp/cache/assets/D08/ED0/sprockets%2Fcb1aee736d3b287a872298b7741b012b +0 -0
  22. data/sandbox/tmp/cache/assets/D1A/B70/sprockets%2F47ae92dd9d034b32098b19bf8f2475a9 +0 -0
  23. data/sandbox/tmp/cache/assets/D34/3E0/sprockets%2F46a73c17c9a561115944df004dbbdd7b +0 -0
  24. data/sandbox/tmp/cache/assets/D3B/BC0/sprockets%2F19510a763bd1521ff5fc70ffe0d837d3 +0 -0
  25. data/sandbox/tmp/cache/assets/D4A/1A0/sprockets%2Fb746360a8b3ce79c57e74a9c15309fdd +0 -0
  26. data/sandbox/tmp/cache/assets/D4A/EB0/sprockets%2F601dc7267b0c9e83e7c9bd2bf94e3564 +0 -0
  27. data/sandbox/tmp/cache/assets/D4F/810/sprockets%2Fa10070d6497ba2b4ea552d4a1bb444cb +0 -0
  28. data/sandbox/tmp/cache/assets/D53/E90/sprockets%2Fb333afe57100a0a8c1bc6c37405e56bb +0 -0
  29. data/sandbox/tmp/cache/assets/D55/310/sprockets%2F2b9be79ca64ec7d294d4825e21696ce9 +0 -0
  30. data/sandbox/tmp/cache/assets/D5C/200/sprockets%2Fcd323e6f7545cee0b3ba1e84d7520b00 +0 -0
  31. data/sandbox/tmp/cache/assets/D66/7C0/sprockets%2F5afbe1fb48c4015a6ffc9085c0519b05 +0 -0
  32. data/sandbox/tmp/cache/assets/D6D/AA0/sprockets%2F1cb4a75912d38d0bdde6ee6770644d0f +0 -0
  33. data/sandbox/tmp/cache/assets/D6E/AE0/sprockets%2Fe193ea7b03f186ad2a9515fc78fa8c21 +0 -0
  34. data/sandbox/tmp/cache/assets/D74/0A0/sprockets%2Fc1392b79af6b88250b634479cbf2bcfc +0 -0
  35. data/sandbox/tmp/cache/assets/D79/5A0/sprockets%2Feb399a6f39a8dcd0bf011768e7153d8d +0 -0
  36. data/sandbox/tmp/cache/assets/D7A/D40/sprockets%2F4d2bc08f2787a3870ff93e0e0f7bc67e +0 -0
  37. data/sandbox/tmp/cache/assets/D7D/A60/sprockets%2Fad3ac10002e5ebc21d911fe229b6ec40 +0 -0
  38. data/sandbox/tmp/cache/assets/D82/480/sprockets%2F8945f20bf64a2469e9edbfb085e4b8c8 +0 -0
  39. data/sandbox/tmp/cache/assets/D92/120/sprockets%2Fbbadd54a208919f24fb50bc9e3d3d107 +0 -0
  40. data/sandbox/tmp/cache/assets/D96/940/sprockets%2F6a2c3af22b173eb975f382b4cdcd8c41 +0 -0
  41. data/sandbox/tmp/cache/assets/D96/E90/sprockets%2F0d5f451deca7e6811663f30afc3a4fd4 +0 -0
  42. data/sandbox/tmp/cache/assets/D97/180/sprockets%2F933323d1c368cfeda7a0cacdbd295933 +0 -0
  43. data/sandbox/tmp/cache/assets/DAD/190/sprockets%2Fbee62a5d7a8cd35a33763f1cd879de59 +0 -0
  44. data/sandbox/tmp/cache/assets/DB8/5B0/sprockets%2F35ed47d3f028fe65e7d4f5f4f8f95e1b +0 -0
  45. data/sandbox/tmp/cache/assets/DC5/340/sprockets%2Fd0dab495f0bbced215dd46e8ca316575 +0 -0
  46. data/sandbox/tmp/cache/assets/DCA/FD0/sprockets%2F0b59a77adfc61bb863e708ba262ce6bd +0 -0
  47. data/sandbox/tmp/cache/assets/DCE/E70/sprockets%2Facff0eeec48ccf1c25a1b968242b7827 +0 -0
  48. data/sandbox/tmp/cache/assets/DD4/040/sprockets%2Fe4c0c08358fdcc373c5f2da767cd08ff +0 -0
  49. data/sandbox/tmp/cache/assets/DD7/9B0/sprockets%2F9f2c0826bd7ae7b745ae8da6db48c26e +0 -0
  50. data/sandbox/tmp/cache/assets/DE0/650/sprockets%2F0f87cd6ed404cdfc99c86bb974d0ca59 +0 -0
  51. data/sandbox/tmp/cache/assets/DE5/390/sprockets%2F24a1cda6893cebd53997dc859def67cd +0 -0
  52. data/sandbox/tmp/cache/assets/DFC/5B0/sprockets%2Fcece55fa8f17c917fcc78cf6113a01bb +0 -0
  53. data/sandbox/tmp/cache/assets/E00/1D0/sprockets%2F571f97ca7b6dfdfefafd03ae735127a1 +0 -0
  54. data/sandbox/tmp/cache/assets/E05/2E0/sprockets%2F92ecbfa92baf6e394ce6c39d731b7cd2 +0 -0
  55. data/sandbox/tmp/cache/assets/E36/F20/sprockets%2Fd3bd4977eec9eca9c55b9a20b81b9cdb +0 -0
  56. data/sandbox/tmp/cache/assets/E37/A20/sprockets%2Fec3ccca6dfe2fc4e8793b0d83398e5ba +0 -0
  57. data/sandbox/tmp/cache/assets/F1C/0B0/sprockets%2Ffb1cb6e9be4bf2cd5aaecfbb1de7d77f +0 -0
  58. data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/components.sassc +0 -0
  59. data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/typography.sassc +0 -0
  60. data/sandbox/tmp/cache/sass/8e0849d701bca2f5a178ed1215813b1316068a4d/variables.sassc +0 -0
  61. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/checkbox.sassc +0 -0
  62. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/combobox.sassc +0 -0
  63. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/container.sassc +0 -0
  64. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/group.sassc +0 -0
  65. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/input.sassc +0 -0
  66. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/radio.sassc +0 -0
  67. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/responsive_box.sassc +0 -0
  68. data/sandbox/tmp/cache/sass/b49d75942b505963eb360d4c3b43ec26f9ded67e/view.sassc +0 -0
  69. data/vendor/assets/javascripts/iugu-ux/components/presenters/iugu-ui-table.jst.eco +1 -1
  70. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-button.js.coffee +15 -3
  71. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-combobox.js.coffee +1 -0
  72. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-table.js.coffee +1 -0
  73. data/vendor/assets/javascripts/iugu-ux/components/usecode/iugu-ui-view.js.coffee +1 -1
  74. data/vendor/assets/javascripts/vendor.js +2 -3
  75. data/vendor/assets/javascripts/vendor/backbone.validation.js +1 -1
  76. data/vendor/assets/javascripts/vendor/numeral.js +2104 -0
  77. data/vendor/assets/javascripts/vendor/numeral.languages.js +96 -0
  78. data/vendor/assets/javascripts/web-app/helpers.coffee +1 -1
  79. data/vendor/assets/stylesheets/iugu-ux/components/combobox.sass +7 -0
  80. data/vendor/assets/stylesheets/iugu-ux/components/input.sass +11 -0
  81. data/vendor/assets/stylesheets/iugu-ux/components/notice.sass +6 -0
  82. metadata +72 -33
  83. data/vendor/assets/javascripts/vendor/mobiscroll.core-2.3.1.js +0 -966
  84. data/vendor/assets/javascripts/vendor/mobiscroll.datetime-2.3.js +0 -656
  85. data/vendor/assets/javascripts/vendor/mobiscroll.select-2.3.1.js +0 -257
@@ -1,966 +0,0 @@
1
- /*jslint eqeq: true, plusplus: true, undef: true, sloppy: true, vars: true, forin: true */
2
- /*!
3
- * jQuery MobiScroll v2.3
4
- * http://mobiscroll.com
5
- *
6
- * Copyright 2010-2011, Acid Media
7
- * Licensed under the MIT license.
8
- *
9
- */
10
- (function ($) {
11
-
12
- function Scroller(elem, settings) {
13
- var that = this,
14
- ms = $.mobiscroll,
15
- e = elem,
16
- elm = $(e),
17
- theme,
18
- lang,
19
- s = extend({}, defaults),
20
- pres = {},
21
- m,
22
- hi,
23
- v,
24
- dw,
25
- warr = [],
26
- iv = {},
27
- input = elm.is('input'),
28
- visible = false;
29
-
30
- // Private functions
31
-
32
- function isReadOnly(wh) {
33
- if ($.isArray(s.readonly)) {
34
- var i = $('.dwwl', dw).index(wh);
35
- return s.readonly[i];
36
- }
37
- return s.readonly;
38
- }
39
-
40
- function generateWheelItems(wIndex) {
41
- var html = '',
42
- j;
43
-
44
- for (j in warr[wIndex]) {
45
- html += '<li class="dw-v" data-val="' + j + '" style="height:' + hi + 'px;line-height:' + hi + 'px;"><div class="dw-i">' + warr[wIndex][j] + '</div></li>';
46
- }
47
- return html;
48
- }
49
-
50
- function getDocHeight() {
51
- var body = document.body,
52
- html = document.documentElement;
53
- return Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
54
- }
55
-
56
- function setGlobals(t) {
57
- min = $('li.dw-v', t).eq(0).index();
58
- max = $('li.dw-v', t).eq(-1).index();
59
- index = $('ul', dw).index(t);
60
- h = hi;
61
- inst = that;
62
- }
63
-
64
- function formatHeader(v) {
65
- var t = s.headerText;
66
- return t ? (typeof (t) == 'function' ? t.call(e, v) : t.replace(/\{value\}/i, v)) : '';
67
- }
68
-
69
- function read() {
70
- that.temp = ((input && (that.val !== null && that.val != elm.val() || !elm.val().length)) || that.values === null) ? s.parseValue(elm.val() || '', that) : that.values.slice(0);
71
- that.setValue(true);
72
- }
73
-
74
- function scrollToPos(time, index, manual, dir) {
75
- // Call validation event
76
- event('validate', [dw, index]);
77
-
78
- // Set scrollers to position
79
- $('.dww ul', dw).each(function (i) {
80
- var t = $(this),
81
- cell = $('li[data-val="' + that.temp[i] + '"]', t),
82
- v = cell.index(),
83
- sc = i == index || index === undefined;
84
-
85
- // Scroll to a valid cell
86
- if (!cell.hasClass('dw-v')) {
87
- var cell1 = cell,
88
- cell2 = cell,
89
- dist1 = 0,
90
- dist2 = 0;
91
- while (cell1.prev().length && !cell1.hasClass('dw-v')) {
92
- cell1 = cell1.prev();
93
- dist1++;
94
- }
95
- while (cell2.next().length && !cell2.hasClass('dw-v')) {
96
- cell2 = cell2.next();
97
- dist2++;
98
- }
99
- // If we have direction (+/- or mouse wheel), the distance does not count
100
- if (((dist2 < dist1 && dist2 && dir !== 2) || !dist1 || !(cell1.hasClass('dw-v')) || dir == 1) && cell2.hasClass('dw-v')) {
101
- cell = cell2;
102
- v = v + dist2;
103
- } else {
104
- cell = cell1;
105
- v = v - dist1;
106
- }
107
- }
108
-
109
- if (!(cell.hasClass('dw-sel')) || sc) {
110
- // Set valid value
111
- that.temp[i] = cell.attr('data-val');
112
-
113
- // Add selected class to cell
114
- $('.dw-sel', t).removeClass('dw-sel');
115
- cell.addClass('dw-sel');
116
-
117
- // Scroll to position
118
- that.scroll(t, i, v, time);
119
- }
120
- });
121
-
122
- // Reformat value if validation changed something
123
- that.change(manual);
124
- }
125
-
126
- function position() {
127
-
128
- if (s.display == 'inline') {
129
- return;
130
- }
131
-
132
- function countWidth() {
133
- $('.dwc', dw).each(function () {
134
- //if ($(this).css('display') != 'none') {
135
- w = $(this).outerWidth(true);
136
- totalw += w;
137
- minw = (w > minw) ? w : minw;
138
- //}
139
- });
140
- w = totalw > ww ? minw : totalw;
141
- w = $('.dwwr', dw).width(w + 1).outerWidth();
142
- h = d.outerHeight();
143
- }
144
-
145
- var totalw = 0,
146
- minw = 0,
147
- ww = $(window).width(),
148
- wh = window.innerHeight,
149
- st = $(window).scrollTop(),
150
- d = $('.dw', dw),
151
- w,
152
- t,
153
- l,
154
- h,
155
- ew,
156
- css = {},
157
- needScroll,
158
- elma = s.anchor === undefined ? elm : s.anchor;
159
-
160
- wh = wh || $(window).height();
161
-
162
- if (s.display == 'modal') {
163
- countWidth();
164
- l = (ww - w) / 2;
165
- t = st + (wh - h) / 2;
166
- } else if (s.display == 'bubble') {
167
- countWidth();
168
- var p = elma.offset(),
169
- poc = $('.dw-arr', dw),
170
- pocw = $('.dw-arrw-i', dw),
171
- wd = d.outerWidth();
172
-
173
- // horizontal positioning
174
- ew = elma.outerWidth();
175
- l = p.left - (d.outerWidth(true) - ew) / 2;
176
- l = l > (ww - wd) ? (ww - (wd + 20)) : l;
177
- l = l >= 0 ? l : 20;
178
-
179
- // vertical positioning
180
- t = p.top - (d.outerHeight() + 3); // above the input
181
- if ((t < st) || (p.top > st + wh)) { // if doesn't fit above or the input is out of the screen
182
- d.removeClass('dw-bubble-top').addClass('dw-bubble-bottom');
183
- t = p.top + elma.outerHeight() + 3; // below the input
184
- needScroll = ((t + d.outerHeight(true) > st + wh) || (p.top > st + wh));
185
- } else {
186
- d.removeClass('dw-bubble-bottom').addClass('dw-bubble-top');
187
- }
188
-
189
- t = t >= st ? t : st;
190
-
191
- // Calculate Arrow position
192
- var pl = p.left + ew / 2 - (l + (wd - pocw.outerWidth()) / 2);
193
-
194
- // Limit Arrow position to [0, pocw.width] intervall
195
- if (pl > pocw.outerWidth()) {
196
- pl = pocw.outerWidth();
197
- }
198
-
199
- poc.css({ left: pl });
200
- } else {
201
- css.width = '100%';
202
- if (s.display == 'top') {
203
- t = st;
204
- } else if (s.display == 'bottom') {
205
- t = st + wh - d.outerHeight();
206
- t = t >= 0 ? t : 0;
207
- }
208
- }
209
- css.top = t;
210
- css.left = l;
211
- d.css(css);
212
-
213
- $('.dwo, .dw-persp', dw).height(0).height(getDocHeight());
214
-
215
- if (needScroll) {
216
- $(window).scrollTop(t + d.outerHeight(true) - wh);
217
- }
218
- }
219
-
220
- function event(name, args) {
221
- var ret;
222
- args.push(that);
223
- $.each([pres, settings], function (i, v) {
224
- if (v[name]) { // Call preset event
225
- ret = v[name].apply(e, args)
226
- }
227
- });
228
- return ret;
229
- }
230
-
231
- function plus(t) {
232
- var p = +t.data('pos'),
233
- val = p + 1;
234
- calc(t, val > max ? min : val, 1);
235
- }
236
-
237
- function minus(t) {
238
- var p = +t.data('pos'),
239
- val = p - 1;
240
- calc(t, val < min ? max : val, 2);
241
- }
242
-
243
- // Public functions
244
-
245
- /**
246
- * Enables the scroller and the associated input.
247
- */
248
- that.enable = function () {
249
- s.disabled = false;
250
- if (input) {
251
- elm.prop('disabled', false);
252
- }
253
- };
254
-
255
- /**
256
- * Disables the scroller and the associated input.
257
- */
258
- that.disable = function () {
259
- s.disabled = true;
260
- if (input) {
261
- elm.prop('disabled', true);
262
- }
263
- };
264
-
265
- /**
266
- * Scrolls target to the specified position
267
- * @param {Object} t - Target wheel jQuery object.
268
- * @param {Number} index - Index of the changed wheel.
269
- * @param {Number} val - Value.
270
- * @param {Number} time - Duration of the animation, optional.
271
- * @param {Number} orig - Original value.
272
- */
273
- that.scroll = function (t, index, val, time, orig, callback) {
274
-
275
- function getVal(t, b, c, d) {
276
- return c * Math.sin(t / d * (Math.PI / 2)) + b;
277
- }
278
-
279
- function ready() {
280
- clearInterval(iv[index]);
281
- iv[index] = undefined;
282
- t.data('pos', val).closest('.dwwl').removeClass('dwa');
283
- }
284
-
285
- var px = (m - val) * hi,
286
- i;
287
-
288
- callback = callback || empty;
289
-
290
- t.attr('style', (time ? (prefix + '-transition:all ' + time.toFixed(1) + 's ease-out;') : '') + (has3d ? (prefix + '-transform:translate3d(0,' + px + 'px,0);') : ('top:' + px + 'px;')));
291
-
292
- if (iv[index]) {
293
- ready();
294
- }
295
-
296
- if (time && orig !== undefined) {
297
- i = 0;
298
- t.closest('.dwwl').addClass('dwa');
299
- iv[index] = setInterval(function () {
300
- i += 0.1;
301
- t.data('pos', Math.round(getVal(i, orig, val - orig, time)));
302
- if (i >= time) {
303
- ready();
304
- callback();
305
- }
306
- }, 100);
307
- // Trigger animation start event
308
- event('onAnimStart', [index, time]);
309
- } else {
310
- t.data('pos', val);
311
- callback();
312
- }
313
- };
314
-
315
- /**
316
- * Gets the selected wheel values, formats it, and set the value of the scroller instance.
317
- * If input parameter is true, populates the associated input element.
318
- * @param {Boolean} sc - Scroll the wheel in position.
319
- * @param {Boolean} fill - Also set the value of the associated input element. Default is true.
320
- * @param {Number} time - Animation time
321
- * @param {Boolean} temp - If true, then only set the temporary value.(only scroll there but not set the value)
322
- */
323
- that.setValue = function (sc, fill, time, temp) {
324
- if (!temp) {
325
- that.values = that.temp.slice(0);
326
- }
327
-
328
- if (visible && sc) {
329
- scrollToPos(time);
330
- }
331
-
332
- if (fill) {
333
- v = s.formatResult(that.temp);
334
- that.val = v;
335
- if (input) {
336
- elm.val(v).trigger('change');
337
- }
338
- }
339
- };
340
-
341
- /**
342
- * Checks if the current selected values are valid together.
343
- * In case of date presets it checks the number of days in a month.
344
- * @param {Number} time - Animation time
345
- * @param {Number} orig - Original value
346
- * @param {Number} i - Currently changed wheel index, -1 if initial validation.
347
- * @param {Number} dir - Scroll direction
348
- */
349
- that.validate = function (i, dir) {
350
- scrollToPos(0.2, i, true, dir);
351
- };
352
-
353
- /**
354
- *
355
- */
356
- that.change = function (manual) {
357
- v = s.formatResult(that.temp);
358
- if (s.display == 'inline') {
359
- that.setValue(false, manual);
360
- } else {
361
- $('.dwv', dw).html(formatHeader(v));
362
- }
363
-
364
- if (manual) {
365
- event('onChange', [v]);
366
- }
367
- };
368
-
369
- /**
370
- * Hides the scroller instance.
371
- */
372
- that.hide = function (prevAnim) {
373
- // If onClose handler returns false, prevent hide
374
- if (event('onClose', [v]) === false) {
375
- return false;
376
- }
377
-
378
- // Re-enable temporary disabled fields
379
- $('.dwtd').prop('disabled', false).removeClass('dwtd');
380
- elm.blur();
381
-
382
- // Hide wheels and overlay
383
- if (dw) {
384
- if (s.display != 'inline' && s.animate && !prevAnim) {
385
- $('.dw', dw).addClass('dw-' + s.animate + ' dw-out');
386
- setTimeout(function () {
387
- dw.remove();
388
- dw = null;
389
- }, 350);
390
- } else {
391
- dw.remove();
392
- dw = null;
393
- }
394
- visible = false;
395
- // Stop positioning on window resize
396
- $(window).unbind('.dw');
397
- }
398
- };
399
-
400
- /**
401
- * Changes the values of a wheel, and scrolls to the correct position
402
- */
403
- that.changeWheel = function (idx, time) {
404
- if (dw) {
405
- var i = 0,
406
- j,
407
- k,
408
- nr = idx.length;
409
-
410
- for (j in s.wheels) {
411
- for (k in s.wheels[j]) {
412
- if ($.inArray(i, idx) > -1) {
413
- warr[i] = s.wheels[j][k];
414
- $('ul', dw).eq(i).html(generateWheelItems(i));
415
- nr--;
416
- if (!nr) {
417
- position();
418
- scrollToPos(time);
419
- return;
420
- }
421
- }
422
- i++;
423
- }
424
- }
425
- }
426
- };
427
-
428
- /**
429
- * Shows the scroller instance.
430
- * @param {Boolean} prevAnim - Prevent animation if true
431
- */
432
- that.show = function (prevAnim) {
433
- if (s.disabled || visible) {
434
- return false;
435
- }
436
-
437
- if (s.display == 'top') {
438
- s.animate = 'slidedown';
439
- }
440
-
441
- if (s.display == 'bottom') {
442
- s.animate = 'slideup';
443
- }
444
-
445
- // Parse value from input
446
- read();
447
-
448
- event('onBeforeShow', [dw]);
449
-
450
- // Create wheels
451
- var l = 0,
452
- i,
453
- label,
454
- mAnim = '',
455
- persPS = '',
456
- persPE = '';
457
-
458
- if (s.animate && !prevAnim) {
459
- persPS = '<div class="dw-persp">';
460
- persPE = '</div>';
461
- mAnim = 'dw-' + s.animate + ' dw-in';
462
- }
463
- // Create wheels containers
464
- var html = '<div class="' + s.theme + ' dw-' + s.display + '">' + (s.display == 'inline' ? '<div class="dw dwbg dwi"><div class="dwwr">' : persPS + '<div class="dwo"></div><div class="dw dwbg ' + mAnim + '"><div class="dw-arrw"><div class="dw-arrw-i"><div class="dw-arr"></div></div></div><div class="dwwr">' + (s.headerText ? '<div class="dwv"></div>' : ''));
465
-
466
- for (i = 0; i < s.wheels.length; i++) {
467
- html += '<div class="dwc' + (s.mode != 'scroller' ? ' dwpm' : ' dwsc') + (s.showLabel ? '' : ' dwhl') + '"><div class="dwwc dwrc"><table cellpadding="0" cellspacing="0"><tr>';
468
- // Create wheels
469
- for (label in s.wheels[i]) {
470
- warr[l] = s.wheels[i][label];
471
- html += '<td><div class="dwwl dwrc dwwl' + l + '">' + (s.mode != 'scroller' ? '<div class="dwwb dwwbp" style="height:' + hi + 'px;line-height:' + hi + 'px;"><span>+</span></div><div class="dwwb dwwbm" style="height:' + hi + 'px;line-height:' + hi + 'px;"><span>&ndash;</span></div>' : '') + '<div class="dwl">' + label + '</div><div class="dww dwrc" style="height:' + (s.rows * hi) + 'px;min-width:' + s.width + 'px;"><ul>';
472
- // Create wheel values
473
- html += generateWheelItems(l);
474
- html += '</ul><div class="dwwo"></div></div><div class="dwwol"></div></div></td>';
475
- l++;
476
- }
477
- html += '</tr></table></div></div>';
478
- }
479
- html += (s.display != 'inline' ? '<div class="dwbc' + (s.button3 ? ' dwbc-p' : '') + '"><span class="dwbw dwb-s"><span class="dwb">' + s.setText + '</span></span>' + (s.button3 ? '<span class="dwbw dwb-n"><span class="dwb">' + s.button3Text + '</span></span>' : '') + '<span class="dwbw dwb-c"><span class="dwb">' + s.cancelText + '</span></span></div>' + persPE : '<div class="dwcc"></div>') + '</div></div></div>';
480
- dw = $(html);
481
-
482
- scrollToPos();
483
-
484
- // Show
485
- if (s.display != 'inline') {
486
- dw.appendTo('body');
487
- } else if (elm.is('div')) {
488
- elm.html(dw);
489
- } else {
490
- dw.insertAfter(elm);
491
- }
492
- visible = true;
493
-
494
- if (s.display != 'inline') {
495
- // Init buttons
496
- $('.dwb-s span', dw).click(function () {
497
- if (that.hide() !== false) {
498
- that.setValue(false, true);
499
- event('onSelect', [that.val]);
500
- }
501
- return false;
502
- });
503
-
504
- $('.dwb-c span', dw).click(function () {
505
- if (that.hide() !== false) {
506
- event('onCancel', [that.val]);
507
- }
508
- return false;
509
- });
510
-
511
- if (s.button3) {
512
- $('.dwb-n span', dw).click(s.button3);
513
- }
514
-
515
- // prevent scrolling if not specified otherwise
516
- if (s.scrollLock) {
517
- dw.bind('touchmove', function (e) {
518
- e.preventDefault();
519
- });
520
- }
521
-
522
- // Disable inputs to prevent bleed through (Android bug)
523
- $('input,select').each(function () {
524
- if (!$(this).prop('disabled')) {
525
- $(this).addClass('dwtd');
526
- }
527
- });
528
- $('input,select').prop('disabled', true);
529
-
530
- // Set position
531
- position();
532
- $(window).bind('resize.dw', position);
533
-
534
- }
535
-
536
- // Events
537
- dw.delegate('.dwwl', 'DOMMouseScroll mousewheel', function (e) {
538
- if (!isReadOnly(this)) {
539
- e.preventDefault();
540
- e = e.originalEvent;
541
- var delta = e.wheelDelta ? (e.wheelDelta / 120) : (e.detail ? (-e.detail / 3) : 0),
542
- t = $('ul', this),
543
- p = +t.data('pos'),
544
- val = Math.round(p - delta);
545
- setGlobals(t);
546
- calc(t, val, delta < 0 ? 1 : 2);
547
- }
548
- }).delegate('.dwb, .dwwb', START_EVENT, function (e) {
549
- // Active button
550
- $(this).addClass('dwb-a');
551
- }).delegate('.dwwb', START_EVENT, function (e) {
552
- var w = $(this).closest('.dwwl');
553
- if (!isReadOnly(w) && !w.hasClass('dwa')) {
554
- // + Button
555
- e.preventDefault();
556
- e.stopPropagation();
557
- var t = w.find('ul'),
558
- func = $(this).hasClass('dwwbp') ? plus : minus;
559
- click = true;
560
- setGlobals(t);
561
- clearInterval(timer);
562
- timer = setInterval(function () { func(t); }, s.delay);
563
- func(t);
564
- }
565
- }).delegate('.dwwl', START_EVENT, function (e) {
566
- // Prevent scroll
567
- e.preventDefault();
568
- // Scroll start
569
- if (!move && !isReadOnly(this) && !click && s.mode != 'clickpick') {
570
- move = true;
571
- target = $('ul', this);
572
- target.closest('.dwwl').addClass('dwa');
573
- pos = +target.data('pos');
574
- setGlobals(target);
575
- moved = iv[index] !== undefined; // Don't allow tap, if still moving
576
- start = getY(e);
577
- startTime = new Date();
578
- stop = start;
579
- that.scroll(target, index, pos);
580
- }
581
- });
582
-
583
- event('onShow', [dw, v]);
584
-
585
- // Theme init
586
- theme.init(dw, that);
587
- };
588
-
589
- /**
590
- * Scroller initialization.
591
- */
592
- that.init = function (ss) {
593
- // Get theme defaults
594
- theme = extend({ defaults: {}, init: empty }, ms.themes[ss.theme || s.theme]);
595
-
596
- // Get language defaults
597
- lang = ms.i18n[ss.lang || s.lang];
598
-
599
- extend(settings, ss); // Update original user settings
600
- extend(s, theme.defaults, lang, settings);
601
-
602
- that.settings = s;
603
-
604
- // Unbind all events (if re-init)
605
- elm.unbind('.dw');
606
-
607
- var preset = ms.presets[s.preset];
608
-
609
- if (preset) {
610
- pres = preset.call(e, that);
611
- extend(s, pres, settings); // Load preset settings
612
- extend(methods, pres.methods); // Extend core methods
613
- }
614
-
615
- // Set private members
616
- m = Math.floor(s.rows / 2);
617
- hi = s.height;
618
-
619
- if (elm.data('dwro') !== undefined) {
620
- e.readOnly = bool(elm.data('dwro'));
621
- }
622
-
623
- if (visible) {
624
- that.hide();
625
- }
626
-
627
- if (s.display == 'inline') {
628
- that.show();
629
- } else {
630
- read();
631
- if (input && s.showOnFocus) {
632
- // Set element readonly, save original state
633
- elm.data('dwro', e.readOnly);
634
- e.readOnly = true;
635
- // Init show datewheel
636
- elm.bind('focus.dw', function () { that.show(); });
637
- }
638
- }
639
- };
640
-
641
- that.values = null;
642
- that.val = null;
643
- that.temp = null;
644
-
645
- that.init(settings);
646
- }
647
-
648
- function testProps(props) {
649
- var i;
650
- for (i in props) {
651
- if (mod[props[i]] !== undefined) {
652
- return true;
653
- }
654
- }
655
- return false;
656
- }
657
-
658
- function testPrefix() {
659
- var prefixes = ['Webkit', 'Moz', 'O', 'ms'],
660
- p;
661
-
662
- for (p in prefixes) {
663
- if (testProps([prefixes[p] + 'Transform'])) {
664
- return '-' + prefixes[p].toLowerCase();
665
- }
666
- }
667
- return '';
668
- }
669
-
670
- function getInst(e) {
671
- return scrollers[e.id];
672
- }
673
-
674
- function getY(e) {
675
- var org = e.originalEvent,
676
- ct = e.changedTouches;
677
- return ct || (org && org.changedTouches) ? (org ? org.changedTouches[0].pageY : ct[0].pageY) : e.pageY;
678
-
679
- }
680
-
681
- function bool(v) {
682
- return (v === true || v == 'true');
683
- }
684
-
685
- function constrain(val, min, max) {
686
- val = val > max ? max : val;
687
- val = val < min ? min : val;
688
- return val;
689
- }
690
-
691
- function calc(t, val, dir, anim, orig) {
692
- val = constrain(val, min, max);
693
-
694
- var cell = $('li', t).eq(val),
695
- idx = index,
696
- time = anim ? (val == orig ? 0.1 : Math.abs((val - orig) * 0.1)) : 0;
697
-
698
- inst.scroll(t, idx, val, time, orig, function() {
699
- // Set selected scroller value
700
- inst.temp[idx] = cell.attr('data-val');
701
- // Validate on animation end
702
- inst.validate(idx, dir);
703
- });
704
- }
705
-
706
- function init(that, method, args) {
707
- if (methods[method]) {
708
- return methods[method].apply(that, Array.prototype.slice.call(args, 1));
709
- }
710
- if (typeof method === 'object') {
711
- return methods.init.call(that, method);
712
- }
713
- return that;
714
- }
715
-
716
- var scrollers = {},
717
- timer,
718
- empty = function () { },
719
- h,
720
- min,
721
- max,
722
- inst, // Current instance
723
- date = new Date(),
724
- uuid = date.getTime(),
725
- move,
726
- click,
727
- target,
728
- index,
729
- start,
730
- stop,
731
- startTime,
732
- pos,
733
- moved,
734
- mod = document.createElement('modernizr').style,
735
- has3d = testProps(['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']),
736
- prefix = testPrefix(),
737
- extend = $.extend,
738
- START_EVENT = 'touchstart mousedown',
739
- MOVE_EVENT = 'touchmove mousemove',
740
- END_EVENT = 'touchend mouseup',
741
- defaults = {
742
- // Options
743
- width: 70,
744
- height: 40,
745
- rows: 3,
746
- delay: 300,
747
- disabled: false,
748
- readonly: false,
749
- showOnFocus: true,
750
- showLabel: true,
751
- wheels: [],
752
- theme: '',
753
- headerText: '{value}',
754
- display: 'modal',
755
- mode: 'scroller',
756
- preset: '',
757
- lang: 'en-US',
758
- setText: 'Set',
759
- cancelText: 'Cancel',
760
- scrollLock: true,
761
- formatResult: function (d) {
762
- return d.join(' ');
763
- },
764
- parseValue: function (value, inst) {
765
- var w = inst.settings.wheels,
766
- val = value.split(' '),
767
- ret = [],
768
- j = 0,
769
- i,
770
- l,
771
- v;
772
-
773
- for (i = 0; i < w.length; i++) {
774
- for (l in w[i]) {
775
- if (w[i][l][val[j]] !== undefined) {
776
- ret.push(val[j]);
777
- } else {
778
- for (v in w[i][l]) { // Select first value from wheel
779
- ret.push(v);
780
- break;
781
- }
782
- }
783
- j++;
784
- }
785
- }
786
- return ret;
787
- }
788
- },
789
-
790
- methods = {
791
- init: function (options) {
792
- if (options === undefined) {
793
- options = {};
794
- }
795
-
796
- return this.each(function () {
797
- if (!this.id) {
798
- uuid += 1;
799
- this.id = 'scoller' + uuid;
800
- }
801
- scrollers[this.id] = new Scroller(this, options);
802
- });
803
- },
804
- enable: function () {
805
- return this.each(function () {
806
- var inst = getInst(this);
807
- if (inst) {
808
- inst.enable();
809
- }
810
- });
811
- },
812
- disable: function () {
813
- return this.each(function () {
814
- var inst = getInst(this);
815
- if (inst) {
816
- inst.disable();
817
- }
818
- });
819
- },
820
- isDisabled: function () {
821
- var inst = getInst(this[0]);
822
- if (inst) {
823
- return inst.settings.disabled;
824
- }
825
- },
826
- option: function (option, value) {
827
- return this.each(function () {
828
- var inst = getInst(this);
829
- if (inst) {
830
- var obj = {};
831
- if (typeof option === 'object') {
832
- obj = option;
833
- } else {
834
- obj[option] = value;
835
- }
836
- inst.init(obj);
837
- }
838
- });
839
- },
840
- setValue: function (d, fill, time, temp) {
841
- return this.each(function () {
842
- var inst = getInst(this);
843
- if (inst) {
844
- inst.temp = d;
845
- inst.setValue(true, fill, time, temp);
846
- }
847
- });
848
- },
849
- getInst: function () {
850
- return getInst(this[0]);
851
- },
852
- getValue: function () {
853
- var inst = getInst(this[0]);
854
- if (inst) {
855
- return inst.values;
856
- }
857
- },
858
- show: function () {
859
- var inst = getInst(this[0]);
860
- if (inst) {
861
- return inst.show();
862
- }
863
- },
864
- hide: function () {
865
- return this.each(function () {
866
- var inst = getInst(this);
867
- if (inst) {
868
- inst.hide();
869
- }
870
- });
871
- },
872
- destroy: function () {
873
- return this.each(function () {
874
- var inst = getInst(this);
875
- if (inst) {
876
- inst.hide();
877
- $(this).unbind('.dw');
878
- delete scrollers[this.id];
879
- if ($(this).is('input')) {
880
- this.readOnly = bool($(this).data('dwro'));
881
- }
882
- }
883
- });
884
- }
885
- };
886
-
887
- $(document).bind(MOVE_EVENT, function (e) {
888
- if (move) {
889
- e.preventDefault();
890
- stop = getY(e);
891
- inst.scroll(target, index, constrain(pos + (start - stop) / h, min - 1, max + 1));
892
- moved = true;
893
- }
894
- });
895
-
896
- $(document).bind(END_EVENT, function (e) {
897
- if (move) {
898
- e.preventDefault();
899
-
900
- var time = new Date() - startTime,
901
- val = constrain(pos + (start - stop) / h, min - 1, max + 1),
902
- speed,
903
- dist,
904
- tindex,
905
- ttop = target.offset().top;
906
-
907
- if (time < 300) {
908
- speed = (stop - start) / time;
909
- dist = (speed * speed) / (2 * 0.0006);
910
- if (stop - start < 0) {
911
- dist = -dist;
912
- }
913
- } else {
914
- dist = stop - start;
915
- }
916
-
917
- if (!dist && !moved) { // this is a "tap"
918
- tindex = Math.floor((stop - ttop) / h);
919
- var li = $('li', target).eq(tindex)
920
- li.addClass('dw-hl'); // Highlight
921
- setTimeout(function() {
922
- li.removeClass('dw-hl');
923
- }, 200);
924
- } else {
925
- tindex = Math.round(pos - dist / h);
926
- }
927
-
928
- calc(target, tindex, 0, true, Math.round(val));
929
- move = false;
930
- target = null;
931
- }
932
- if (click) {
933
- clearInterval(timer);
934
- click = false;
935
- }
936
- $('.dwb-a').removeClass('dwb-a');
937
- });
938
-
939
- $.fn.mobiscroll = function (method) {
940
- extend(this, $.mobiscroll.shorts);
941
- return init(this, method, arguments);
942
- };
943
-
944
- $.mobiscroll = $.mobiscroll || {
945
- /**
946
- * Set settings for all instances.
947
- * @param {Object} o - New default settings.
948
- */
949
- setDefaults: function (o) {
950
- extend(defaults, o);
951
- },
952
- presetShort: function(name) {
953
- this.shorts[name] = function(method) {
954
- return init(this, extend(method, { preset: name }), arguments);
955
- };
956
- },
957
- shorts: {},
958
- presets: {},
959
- themes: {},
960
- i18n: {}
961
- };
962
-
963
- $.scroller = $.scroller || $.mobiscroll;
964
- $.fn.scroller = $.fn.scroller || $.fn.mobiscroll;
965
-
966
- })(jQuery);