jqtools-rails 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. data/.document +5 -0
  2. data/.rspec +1 -0
  3. data/Gemfile +11 -0
  4. data/Gemfile.lock +37 -0
  5. data/LICENSE.txt +20 -0
  6. data/README.rdoc +34 -0
  7. data/Rakefile +49 -0
  8. data/VERSION +1 -0
  9. data/jqtools-rails.gemspec +81 -0
  10. data/lib/jqtools-rails.rb +5 -0
  11. data/spec/jqtools-rails_spec.rb +7 -0
  12. data/spec/spec_helper.rb +12 -0
  13. data/vendor/assets/javascripts/dateinput/dateinput.js +791 -0
  14. data/vendor/assets/javascripts/jquery.tools.min.js +39 -0
  15. data/vendor/assets/javascripts/overlay/overlay.apple.js +155 -0
  16. data/vendor/assets/javascripts/overlay/overlay.js +293 -0
  17. data/vendor/assets/javascripts/rangeinput/rangeinput.js +471 -0
  18. data/vendor/assets/javascripts/scrollable/scrollable.autoscroll.js +96 -0
  19. data/vendor/assets/javascripts/scrollable/scrollable.js +368 -0
  20. data/vendor/assets/javascripts/scrollable/scrollable.navigator.js +134 -0
  21. data/vendor/assets/javascripts/tabs/tabs.js +319 -0
  22. data/vendor/assets/javascripts/tabs/tabs.slideshow.js +191 -0
  23. data/vendor/assets/javascripts/toolbox/toolbox.expose.js +224 -0
  24. data/vendor/assets/javascripts/toolbox/toolbox.flashembed.js +301 -0
  25. data/vendor/assets/javascripts/toolbox/toolbox.history.js +108 -0
  26. data/vendor/assets/javascripts/toolbox/toolbox.mousewheel.js +65 -0
  27. data/vendor/assets/javascripts/tooltip/tooltip.dynamic.js +154 -0
  28. data/vendor/assets/javascripts/tooltip/tooltip.js +358 -0
  29. data/vendor/assets/javascripts/tooltip/tooltip.slide.js +78 -0
  30. data/vendor/assets/javascripts/validator/validator.js +598 -0
  31. metadata +135 -0
@@ -0,0 +1,471 @@
1
+ /**
2
+ * @license
3
+ * jQuery Tools @VERSION Rangeinput - HTML5 <input type="range" /> for humans
4
+ *
5
+ * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
6
+ *
7
+ * http://flowplayer.org/tools/rangeinput/
8
+ *
9
+ * Since: Mar 2010
10
+ * Date: @DATE
11
+ */
12
+ (function($) {
13
+
14
+ $.tools = $.tools || {version: '@VERSION'};
15
+
16
+ var tool;
17
+
18
+ tool = $.tools.rangeinput = {
19
+
20
+ conf: {
21
+ min: 0,
22
+ max: 100, // as defined in the standard
23
+ step: 'any', // granularity of the value. a non-zero float or int (or "any")
24
+ steps: 0,
25
+ value: 0,
26
+ precision: undefined,
27
+ vertical: 0,
28
+ keyboard: true,
29
+ progress: false,
30
+ speed: 100,
31
+
32
+ // set to null if not needed
33
+ css: {
34
+ input: 'range',
35
+ slider: 'slider',
36
+ progress: 'progress',
37
+ handle: 'handle'
38
+ }
39
+
40
+ }
41
+ };
42
+
43
+ //{{{ fn.drag
44
+
45
+ /*
46
+ FULL featured drag and drop. 0.7 kb minified, 0.3 gzipped. done.
47
+ Who told d'n'd is rocket science? Usage:
48
+
49
+ $(".myelement").drag({y: false}).bind("drag", function(event, x, y) {
50
+ // do your custom thing
51
+ });
52
+
53
+ Configuration:
54
+ x: true, // enable horizontal drag
55
+ y: true, // enable vertical drag
56
+ drag: true // true = perform drag, false = only fire events
57
+
58
+ Events: dragStart, drag, dragEnd.
59
+ */
60
+ var doc, draggable;
61
+
62
+ $.fn.drag = function(conf) {
63
+
64
+ // disable IE specialities
65
+ document.ondragstart = function () { return false; };
66
+
67
+ conf = $.extend({x: true, y: true, drag: true}, conf);
68
+
69
+ doc = doc || $(document).bind("mousedown mouseup", function(e) {
70
+
71
+ var el = $(e.target);
72
+
73
+ // start
74
+ if (e.type == "mousedown" && el.data("drag")) {
75
+
76
+ var offset = el.position(),
77
+ x0 = e.pageX - offset.left,
78
+ y0 = e.pageY - offset.top,
79
+ start = true;
80
+
81
+ doc.bind("mousemove.drag", function(e) {
82
+ var x = e.pageX -x0,
83
+ y = e.pageY -y0,
84
+ props = {};
85
+
86
+ if (conf.x) { props.left = x; }
87
+ if (conf.y) { props.top = y; }
88
+
89
+ if (start) {
90
+ el.trigger("dragStart");
91
+ start = false;
92
+ }
93
+ if (conf.drag) { el.css(props); }
94
+ el.trigger("drag", [y, x]);
95
+ draggable = el;
96
+ });
97
+
98
+ e.preventDefault();
99
+
100
+ } else {
101
+
102
+ try {
103
+ if (draggable) {
104
+ draggable.trigger("dragEnd");
105
+ }
106
+ } finally {
107
+ doc.unbind("mousemove.drag");
108
+ draggable = null;
109
+ }
110
+ }
111
+
112
+ });
113
+
114
+ return this.data("drag", true);
115
+ };
116
+
117
+ //}}}
118
+
119
+
120
+
121
+ function round(value, precision) {
122
+ var n = Math.pow(10, precision);
123
+ return Math.round(value * n) / n;
124
+ }
125
+
126
+ // get hidden element's width or height even though it's hidden
127
+ function dim(el, key) {
128
+ var v = parseInt(el.css(key), 10);
129
+ if (v) { return v; }
130
+ var s = el[0].currentStyle;
131
+ return s && s.width && parseInt(s.width, 10);
132
+ }
133
+
134
+ function hasEvent(el) {
135
+ var e = el.data("events");
136
+ return e && e.onSlide;
137
+ }
138
+
139
+ function RangeInput(input, conf) {
140
+
141
+ // private variables
142
+ var self = this,
143
+ css = conf.css,
144
+ root = $("<div><div/><a href='#'/></div>").data("rangeinput", self),
145
+ vertical,
146
+ value, // current value
147
+ origo, // handle's start point
148
+ len, // length of the range
149
+ pos; // current position of the handle
150
+
151
+ // create range
152
+ input.before(root);
153
+
154
+ var handle = root.addClass(css.slider).find("a").addClass(css.handle),
155
+ progress = root.find("div").addClass(css.progress);
156
+
157
+ // get (HTML5) attributes into configuration
158
+ $.each("min,max,step,value".split(","), function(i, key) {
159
+ var val = input.attr(key);
160
+ if (parseFloat(val)) {
161
+ conf[key] = parseFloat(val, 10);
162
+ }
163
+ });
164
+
165
+ var range = conf.max - conf.min,
166
+ step = conf.step == 'any' ? 0 : conf.step,
167
+ precision = conf.precision;
168
+
169
+ if (precision === undefined) {
170
+ try {
171
+ precision = step.toString().split(".")[1].length;
172
+ } catch (err) {
173
+ precision = 0;
174
+ }
175
+ }
176
+
177
+ // Replace built-in range input (type attribute cannot be changed)
178
+ if (input.attr("type") == 'range') {
179
+ var def = input.clone().wrap("<div/>").parent().html(),
180
+ clone = $(def.replace(/type/i, "type=text data-orig-type"));
181
+
182
+ clone.val(conf.value);
183
+ input.replaceWith(clone);
184
+ input = clone;
185
+ }
186
+
187
+ input.addClass(css.input);
188
+
189
+ var fire = $(self).add(input), fireOnSlide = true;
190
+
191
+
192
+ /**
193
+ The flesh and bone of this tool. All sliding is routed trough this.
194
+
195
+ @param evt types include: click, keydown, blur and api (setValue call)
196
+ @param isSetValue when called trough setValue() call (keydown, blur, api)
197
+
198
+ vertical configuration gives additional complexity.
199
+ */
200
+ function slide(evt, x, val, isSetValue) {
201
+
202
+ // calculate value based on slide position
203
+ if (val === undefined) {
204
+ val = x / len * range;
205
+
206
+ // x is calculated based on val. we need to strip off min during calculation
207
+ } else if (isSetValue) {
208
+ val -= conf.min;
209
+ }
210
+
211
+ // increment in steps
212
+ if (step) {
213
+ val = Math.round(val / step) * step;
214
+ }
215
+
216
+ // count x based on value or tweak x if stepping is done
217
+ if (x === undefined || step) {
218
+ x = val * len / range;
219
+ }
220
+
221
+ // crazy value?
222
+ if (isNaN(val)) { return self; }
223
+
224
+ // stay within range
225
+ x = Math.max(0, Math.min(x, len));
226
+ val = x / len * range;
227
+
228
+ if (isSetValue || !vertical) {
229
+ val += conf.min;
230
+ }
231
+
232
+ // in vertical ranges value rises upwards
233
+ if (vertical) {
234
+ if (isSetValue) {
235
+ x = len -x;
236
+ } else {
237
+ val = conf.max - val;
238
+ }
239
+ }
240
+
241
+ // precision
242
+ val = round(val, precision);
243
+
244
+ // onSlide
245
+ var isClick = evt.type == "click";
246
+ if (fireOnSlide && value !== undefined && !isClick) {
247
+ evt.type = "onSlide";
248
+ fire.trigger(evt, [val, x]);
249
+ if (evt.isDefaultPrevented()) { return self; }
250
+ }
251
+
252
+ // speed & callback
253
+ var speed = isClick ? conf.speed : 0,
254
+ callback = isClick ? function() {
255
+ evt.type = "change";
256
+ fire.trigger(evt, [val]);
257
+ } : null;
258
+
259
+ if (vertical) {
260
+ handle.animate({top: x}, speed, callback);
261
+ if (conf.progress) {
262
+ progress.animate({height: len - x + handle.height() / 2}, speed);
263
+ }
264
+
265
+ } else {
266
+ handle.animate({left: x}, speed, callback);
267
+ if (conf.progress) {
268
+ progress.animate({width: x + handle.width() / 2}, speed);
269
+ }
270
+ }
271
+
272
+ // store current value
273
+ value = val;
274
+ pos = x;
275
+
276
+ // se input field's value
277
+ input.val(val);
278
+
279
+ return self;
280
+ }
281
+
282
+
283
+ $.extend(self, {
284
+
285
+ getValue: function() {
286
+ return value;
287
+ },
288
+
289
+ setValue: function(val, e) {
290
+ init();
291
+ return slide(e || $.Event("api"), undefined, val, true);
292
+ },
293
+
294
+ getConf: function() {
295
+ return conf;
296
+ },
297
+
298
+ getProgress: function() {
299
+ return progress;
300
+ },
301
+
302
+ getHandle: function() {
303
+ return handle;
304
+ },
305
+
306
+ getInput: function() {
307
+ return input;
308
+ },
309
+
310
+ step: function(am, e) {
311
+ e = e || $.Event();
312
+ var step = conf.step == 'any' ? 1 : conf.step;
313
+ self.setValue(value + step * (am || 1), e);
314
+ },
315
+
316
+ // HTML5 compatible name
317
+ stepUp: function(am) {
318
+ return self.step(am || 1);
319
+ },
320
+
321
+ // HTML5 compatible name
322
+ stepDown: function(am) {
323
+ return self.step(-am || -1);
324
+ }
325
+
326
+ });
327
+
328
+ // callbacks
329
+ $.each("onSlide,change".split(","), function(i, name) {
330
+
331
+ // from configuration
332
+ if ($.isFunction(conf[name])) {
333
+ $(self).bind(name, conf[name]);
334
+ }
335
+
336
+ // API methods
337
+ self[name] = function(fn) {
338
+ if (fn) { $(self).bind(name, fn); }
339
+ return self;
340
+ };
341
+ });
342
+
343
+
344
+ // dragging
345
+ handle.drag({drag: false}).bind("dragStart", function() {
346
+
347
+ /* do some pre- calculations for seek() function. improves performance */
348
+ init();
349
+
350
+ // avoid redundant event triggering (= heavy stuff)
351
+ fireOnSlide = hasEvent($(self)) || hasEvent(input);
352
+
353
+
354
+ }).bind("drag", function(e, y, x) {
355
+
356
+ if (input.is(":disabled")) { return false; }
357
+ slide(e, vertical ? y : x);
358
+
359
+ }).bind("dragEnd", function(e) {
360
+ if (!e.isDefaultPrevented()) {
361
+ e.type = "change";
362
+ fire.trigger(e, [value]);
363
+ }
364
+
365
+ }).click(function(e) {
366
+ return e.preventDefault();
367
+ });
368
+
369
+ // clicking
370
+ root.click(function(e) {
371
+ if (input.is(":disabled") || e.target == handle[0]) {
372
+ return e.preventDefault();
373
+ }
374
+ init();
375
+ var fix = vertical ? handle.height() / 2 : handle.width() / 2;
376
+ slide(e, vertical ? len-origo-fix + e.pageY : e.pageX -origo -fix);
377
+ });
378
+
379
+ if (conf.keyboard) {
380
+
381
+ input.keydown(function(e) {
382
+
383
+ if (input.attr("readonly")) { return; }
384
+
385
+ var key = e.keyCode,
386
+ up = $([75, 76, 38, 33, 39]).index(key) != -1,
387
+ down = $([74, 72, 40, 34, 37]).index(key) != -1;
388
+
389
+ if ((up || down) && !(e.shiftKey || e.altKey || e.ctrlKey)) {
390
+
391
+ // UP: k=75, l=76, up=38, pageup=33, right=39
392
+ if (up) {
393
+ self.step(key == 33 ? 10 : 1, e);
394
+
395
+ // DOWN: j=74, h=72, down=40, pagedown=34, left=37
396
+ } else if (down) {
397
+ self.step(key == 34 ? -10 : -1, e);
398
+ }
399
+ return e.preventDefault();
400
+ }
401
+ });
402
+ }
403
+
404
+
405
+ input.blur(function(e) {
406
+ var val = $(this).val();
407
+ if (val !== value) {
408
+ self.setValue(val, e);
409
+ }
410
+ });
411
+
412
+
413
+ // HTML5 DOM methods
414
+ $.extend(input[0], { stepUp: self.stepUp, stepDown: self.stepDown});
415
+
416
+
417
+ // calculate all dimension related stuff
418
+ function init() {
419
+ vertical = conf.vertical || dim(root, "height") > dim(root, "width");
420
+
421
+ if (vertical) {
422
+ len = dim(root, "height") - dim(handle, "height");
423
+ origo = root.offset().top + len;
424
+
425
+ } else {
426
+ len = dim(root, "width") - dim(handle, "width");
427
+ origo = root.offset().left;
428
+ }
429
+ }
430
+
431
+ function begin() {
432
+ init();
433
+ self.setValue(conf.value !== undefined ? conf.value : conf.min);
434
+ }
435
+ begin();
436
+
437
+ // some browsers cannot get dimensions upon initialization
438
+ if (!len) {
439
+ $(window).load(begin);
440
+ }
441
+ }
442
+
443
+ $.expr[':'].range = function(el) {
444
+ var type = el.getAttribute("type");
445
+ return type && type == 'range' || !!$(el).filter("input").data("rangeinput");
446
+ };
447
+
448
+
449
+ // jQuery plugin implementation
450
+ $.fn.rangeinput = function(conf) {
451
+
452
+ // already installed
453
+ if (this.data("rangeinput")) { return this; }
454
+
455
+ // extend configuration with globals
456
+ conf = $.extend(true, {}, tool.conf, conf);
457
+
458
+ var els;
459
+
460
+ this.each(function() {
461
+ var el = new RangeInput($(this), $.extend(true, {}, conf));
462
+ var input = el.getInput().data("rangeinput", el);
463
+ els = els ? els.add(input) : input;
464
+ });
465
+
466
+ return els ? els : this;
467
+ };
468
+
469
+
470
+ }) (jQuery);
471
+