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,108 @@
1
+ /**
2
+ * @license
3
+ * jQuery Tools @VERSION History "Back button for AJAX apps"
4
+ *
5
+ * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
6
+ *
7
+ * http://flowplayer.org/tools/toolbox/history.html
8
+ *
9
+ * Since: Mar 2010
10
+ * Date: @DATE
11
+ */
12
+ (function($) {
13
+
14
+ var hash, iframe, links, inited;
15
+
16
+ $.tools = $.tools || {version: '@VERSION'};
17
+
18
+ $.tools.history = {
19
+
20
+ init: function(els) {
21
+
22
+ if (inited) { return; }
23
+
24
+ // IE
25
+ if ($.browser.msie && $.browser.version < '8') {
26
+
27
+ // create iframe that is constantly checked for hash changes
28
+ if (!iframe) {
29
+ iframe = $("<iframe/>").attr("src", "javascript:false;").hide().get(0);
30
+ $("body").prepend(iframe);
31
+
32
+ setInterval(function() {
33
+ var idoc = iframe.contentWindow.document,
34
+ h = idoc.location.hash;
35
+
36
+ if (hash !== h) {
37
+ $(window).trigger("hash", h);
38
+ }
39
+ }, 100);
40
+
41
+ setIframeLocation(location.hash || '#');
42
+ }
43
+
44
+
45
+ // other browsers scans for location.hash changes directly without iframe hack
46
+ } else {
47
+ setInterval(function() {
48
+ var h = location.hash;
49
+ if (h !== hash) {
50
+ $(window).trigger("hash", h);
51
+ }
52
+ }, 100);
53
+ }
54
+
55
+ links = !links ? els : links.add(els);
56
+
57
+ els.click(function(e) {
58
+ var href = $(this).attr("href");
59
+ if (iframe) { setIframeLocation(href); }
60
+
61
+ // handle non-anchor links
62
+ if (href.slice(0, 1) != "#") {
63
+ location.href = "#" + href;
64
+ return e.preventDefault();
65
+ }
66
+
67
+ });
68
+
69
+ inited = true;
70
+ }
71
+ };
72
+
73
+
74
+ function setIframeLocation(h) {
75
+ if (h) {
76
+ var doc = iframe.contentWindow.document;
77
+ doc.open().close();
78
+ doc.location.hash = h;
79
+ }
80
+ }
81
+
82
+ // global histroy change listener
83
+ $(window).bind("hash", function(e, h) {
84
+ if (h) {
85
+ links.filter(function() {
86
+ var href = $(this).attr("href");
87
+ return href == h || href == h.replace("#", "");
88
+ }).trigger("history", [h]);
89
+ } else {
90
+ links.eq(0).trigger("history", [h]);
91
+ }
92
+
93
+ hash = h;
94
+
95
+ });
96
+
97
+
98
+ // jQuery plugin implementation
99
+ $.fn.history = function(fn) {
100
+
101
+ $.tools.history.init(this);
102
+
103
+ // return jQuery
104
+ return this.bind("history", fn);
105
+ };
106
+
107
+ })(jQuery);
108
+
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @license
3
+ * jQuery Tools @VERSION Mousewheel
4
+ *
5
+ * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
6
+ *
7
+ * http://flowplayer.org/tools/toolbox/mousewheel.html
8
+ *
9
+ * based on jquery.event.wheel.js ~ rev 1 ~
10
+ * Copyright (c) 2008, Three Dub Media
11
+ * http://threedubmedia.com
12
+ *
13
+ * Since: Mar 2010
14
+ * Date: @DATE
15
+ */
16
+ (function($) {
17
+
18
+ $.fn.mousewheel = function( fn ){
19
+ return this[ fn ? "bind" : "trigger" ]( "wheel", fn );
20
+ };
21
+
22
+ // special event config
23
+ $.event.special.wheel = {
24
+ setup: function() {
25
+ $.event.add( this, wheelEvents, wheelHandler, {} );
26
+ },
27
+ teardown: function(){
28
+ $.event.remove( this, wheelEvents, wheelHandler );
29
+ }
30
+ };
31
+
32
+ // events to bind ( browser sniffed... )
33
+ var wheelEvents = !$.browser.mozilla ? "mousewheel" : // IE, opera, safari
34
+ "DOMMouseScroll"+( $.browser.version<"1.9" ? " mousemove" : "" ); // firefox
35
+
36
+ // shared event handler
37
+ function wheelHandler( event ) {
38
+
39
+ switch ( event.type ) {
40
+
41
+ // FF2 has incorrect event positions
42
+ case "mousemove":
43
+ return $.extend( event.data, { // store the correct properties
44
+ clientX: event.clientX, clientY: event.clientY,
45
+ pageX: event.pageX, pageY: event.pageY
46
+ });
47
+
48
+ // firefox
49
+ case "DOMMouseScroll":
50
+ $.extend( event, event.data ); // fix event properties in FF2
51
+ event.delta = -event.detail / 3; // normalize delta
52
+ break;
53
+
54
+ // IE, opera, safari
55
+ case "mousewheel":
56
+ event.delta = event.wheelDelta / 120;
57
+ break;
58
+ }
59
+
60
+ event.type = "wheel"; // hijack the event
61
+ return $.event.handle.call( this, event, event.delta );
62
+ }
63
+
64
+ })(jQuery);
65
+
@@ -0,0 +1,154 @@
1
+ /**
2
+ * @license
3
+ * jQuery Tools @VERSION / Tooltip Dynamic Positioning
4
+ *
5
+ * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
6
+ *
7
+ * http://flowplayer.org/tools/tooltip/dynamic.html
8
+ *
9
+ * Since: July 2009
10
+ * Date: @DATE
11
+ */
12
+ (function($) {
13
+
14
+ // version number
15
+ var t = $.tools.tooltip;
16
+
17
+ t.dynamic = {
18
+ conf: {
19
+ classNames: "top right bottom left"
20
+ }
21
+ };
22
+
23
+ /*
24
+ * See if element is on the viewport. Returns an boolean array specifying which
25
+ * edges are hidden. Edges are in following order:
26
+ *
27
+ * [top, right, bottom, left]
28
+ *
29
+ * For example following return value means that top and right edges are hidden
30
+ *
31
+ * [true, true, false, false]
32
+ *
33
+ */
34
+ function getCropping(el) {
35
+
36
+ var w = $(window);
37
+ var right = w.width() + w.scrollLeft();
38
+ var bottom = w.height() + w.scrollTop();
39
+
40
+ return [
41
+ el.offset().top <= w.scrollTop(), // top
42
+ right <= el.offset().left + el.width(), // right
43
+ bottom <= el.offset().top + el.height(), // bottom
44
+ w.scrollLeft() >= el.offset().left // left
45
+ ];
46
+ }
47
+
48
+ /*
49
+ Returns true if all edges of an element are on viewport. false if not
50
+
51
+ @param crop the cropping array returned by getCropping function
52
+ */
53
+ function isVisible(crop) {
54
+ var i = crop.length;
55
+ while (i--) {
56
+ if (crop[i]) { return false; }
57
+ }
58
+ return true;
59
+ }
60
+
61
+ // dynamic plugin
62
+ $.fn.dynamic = function(conf) {
63
+
64
+ if (typeof conf == 'number') { conf = {speed: conf}; }
65
+
66
+ conf = $.extend({}, t.dynamic.conf, conf);
67
+
68
+ var confOrigin = $.extend(true,{},conf),
69
+ cls = conf.classNames.split(/\s/),
70
+ orig;
71
+
72
+ this.each(function() {
73
+
74
+ var api = $(this).tooltip().onBeforeShow(function(e, pos) {
75
+
76
+ // get nessessary variables
77
+ var tip = this.getTip(), tipConf = this.getConf();
78
+
79
+ /*
80
+ We store the original configuration and use it to restore back to the original state.
81
+ */
82
+ if (!orig) {
83
+ orig = [
84
+ tipConf.position[0],
85
+ tipConf.position[1],
86
+ tipConf.offset[0],
87
+ tipConf.offset[1],
88
+ $.extend({}, tipConf)
89
+ ];
90
+ }
91
+
92
+ /*
93
+ display tip in it's default position and by setting visibility to hidden.
94
+ this way we can check whether it will be on the viewport
95
+ */
96
+ $.extend(tipConf, orig[4]);
97
+ tipConf.position = [orig[0], orig[1]];
98
+ tipConf.offset = [orig[2], orig[3]];
99
+
100
+ tip.css({
101
+ visibility: 'hidden',
102
+ position: 'absolute',
103
+ top: pos.top,
104
+ left: pos.left
105
+ }).show();
106
+
107
+ var conf = $.extend(true,{},confOrigin),
108
+
109
+ // now let's see for hidden edges
110
+ crop = getCropping(tip);
111
+
112
+ // possibly alter the configuration
113
+ if (!isVisible(crop)) {
114
+
115
+ // change the position and add class
116
+ if (crop[2]) { $.extend(tipConf, conf.top); tipConf.position[0] = 'top'; tip.addClass(cls[0]); }
117
+ if (crop[3]) { $.extend(tipConf, conf.right); tipConf.position[1] = 'right'; tip.addClass(cls[1]); }
118
+ if (crop[0]) { $.extend(tipConf, conf.bottom); tipConf.position[0] = 'bottom'; tip.addClass(cls[2]); }
119
+ if (crop[1]) { $.extend(tipConf, conf.left); tipConf.position[1] = 'left'; tip.addClass(cls[3]); }
120
+
121
+ // vertical offset
122
+ if (crop[0] || crop[2]) { tipConf.offset[0] *= -1; }
123
+
124
+ // horizontal offset
125
+ if (crop[1] || crop[3]) { tipConf.offset[1] *= -1; }
126
+ }
127
+
128
+ tip.css({visibility: 'visible'}).hide();
129
+
130
+ });
131
+
132
+ // restore positioning as soon as possible
133
+ api.onBeforeShow(function() {
134
+ var c = this.getConf(), tip = this.getTip();
135
+ setTimeout(function() {
136
+ c.position = [orig[0], orig[1]];
137
+ c.offset = [orig[2], orig[3]];
138
+ }, 0);
139
+ });
140
+
141
+ // remove custom class names and restore original effect
142
+ api.onHide(function() {
143
+ var tip = this.getTip();
144
+ tip.removeClass(conf.classNames);
145
+ });
146
+
147
+ ret = api;
148
+
149
+ });
150
+
151
+ return conf.api ? ret : this;
152
+ };
153
+
154
+ }) (jQuery);
@@ -0,0 +1,358 @@
1
+ /**
2
+ * @license
3
+ * jQuery Tools @VERSION Tooltip - UI essentials
4
+ *
5
+ * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
6
+ *
7
+ * http://flowplayer.org/tools/tooltip/
8
+ *
9
+ * Since: November 2008
10
+ * Date: @DATE
11
+ */
12
+ (function($) {
13
+ // static constructs
14
+ $.tools = $.tools || {version: '@VERSION'};
15
+
16
+ $.tools.tooltip = {
17
+
18
+ conf: {
19
+
20
+ // default effect variables
21
+ effect: 'toggle',
22
+ fadeOutSpeed: "fast",
23
+ predelay: 0,
24
+ delay: 30,
25
+ opacity: 1,
26
+ tip: 0,
27
+ fadeIE: false, // enables fade effect in IE
28
+
29
+ // 'top', 'bottom', 'right', 'left', 'center'
30
+ position: ['top', 'center'],
31
+ offset: [0, 0],
32
+ relative: false,
33
+ cancelDefault: true,
34
+
35
+ // type to event mapping
36
+ events: {
37
+ def: "mouseenter,mouseleave",
38
+ input: "focus,blur",
39
+ widget: "focus mouseenter,blur mouseleave",
40
+ tooltip: "mouseenter,mouseleave"
41
+ },
42
+
43
+ // 1.2
44
+ layout: '<div/>',
45
+ tipClass: 'tooltip'
46
+ },
47
+
48
+ addEffect: function(name, loadFn, hideFn) {
49
+ effects[name] = [loadFn, hideFn];
50
+ }
51
+ };
52
+
53
+
54
+ var effects = {
55
+ toggle: [
56
+ function(done) {
57
+ var conf = this.getConf(), tip = this.getTip(), o = conf.opacity;
58
+ if (o < 1) { tip.css({opacity: o}); }
59
+ tip.show();
60
+ done.call();
61
+ },
62
+
63
+ function(done) {
64
+ this.getTip().hide();
65
+ done.call();
66
+ }
67
+ ],
68
+
69
+ fade: [
70
+ function(done) {
71
+ var conf = this.getConf();
72
+ if (!$.browser.msie || conf.fadeIE) {
73
+ this.getTip().fadeTo(conf.fadeInSpeed, conf.opacity, done);
74
+ }
75
+ else {
76
+ this.getTip().show();
77
+ done();
78
+ }
79
+ },
80
+ function(done) {
81
+ var conf = this.getConf();
82
+ if (!$.browser.msie || conf.fadeIE) {
83
+ this.getTip().fadeOut(conf.fadeOutSpeed, done);
84
+ }
85
+ else {
86
+ this.getTip().hide();
87
+ done();
88
+ }
89
+ }
90
+ ]
91
+ };
92
+
93
+
94
+ /* calculate tip position relative to the trigger */
95
+ function getPosition(trigger, tip, conf) {
96
+
97
+
98
+ // get origin top/left position
99
+ var top = conf.relative ? trigger.position().top : trigger.offset().top,
100
+ left = conf.relative ? trigger.position().left : trigger.offset().left,
101
+ pos = conf.position[0];
102
+
103
+ top -= tip.outerHeight() - conf.offset[0];
104
+ left += trigger.outerWidth() + conf.offset[1];
105
+
106
+ // iPad position fix
107
+ if (/iPad/i.test(navigator.userAgent)) {
108
+ top -= $(window).scrollTop();
109
+ }
110
+
111
+ // adjust Y
112
+ var height = tip.outerHeight() + trigger.outerHeight();
113
+ if (pos == 'center') { top += height / 2; }
114
+ if (pos == 'bottom') { top += height; }
115
+
116
+
117
+ // adjust X
118
+ pos = conf.position[1];
119
+ var width = tip.outerWidth() + trigger.outerWidth();
120
+ if (pos == 'center') { left -= width / 2; }
121
+ if (pos == 'left') { left -= width; }
122
+
123
+ return {top: top, left: left};
124
+ }
125
+
126
+
127
+
128
+ function Tooltip(trigger, conf) {
129
+
130
+ var self = this,
131
+ fire = trigger.add(self),
132
+ tip,
133
+ timer = 0,
134
+ pretimer = 0,
135
+ title = trigger.attr("title"),
136
+ tipAttr = trigger.attr("data-tooltip"),
137
+ effect = effects[conf.effect],
138
+ shown,
139
+
140
+ // get show/hide configuration
141
+ isInput = trigger.is(":input"),
142
+ isWidget = isInput && trigger.is(":checkbox, :radio, select, :button, :submit"),
143
+ type = trigger.attr("type"),
144
+ evt = conf.events[type] || conf.events[isInput ? (isWidget ? 'widget' : 'input') : 'def'];
145
+
146
+
147
+ // check that configuration is sane
148
+ if (!effect) { throw "Nonexistent effect \"" + conf.effect + "\""; }
149
+
150
+ evt = evt.split(/,\s*/);
151
+ if (evt.length != 2) { throw "Tooltip: bad events configuration for " + type; }
152
+
153
+
154
+ // trigger --> show
155
+ trigger.bind(evt[0], function(e) {
156
+
157
+ clearTimeout(timer);
158
+ if (conf.predelay) {
159
+ pretimer = setTimeout(function() { self.show(e); }, conf.predelay);
160
+
161
+ } else {
162
+ self.show(e);
163
+ }
164
+
165
+ // trigger --> hide
166
+ }).bind(evt[1], function(e) {
167
+ clearTimeout(pretimer);
168
+ if (conf.delay) {
169
+ timer = setTimeout(function() { self.hide(e); }, conf.delay);
170
+
171
+ } else {
172
+ self.hide(e);
173
+ }
174
+
175
+ });
176
+
177
+
178
+ // remove default title
179
+ if (title && conf.cancelDefault) {
180
+ trigger.removeAttr("title");
181
+ trigger.data("title", title);
182
+ }
183
+
184
+ $.extend(self, {
185
+
186
+ show: function(e) {
187
+
188
+ // tip not initialized yet
189
+ if (!tip) {
190
+
191
+ // data-tooltip
192
+ if (tipAttr) {
193
+ tip = $(tipAttr);
194
+
195
+ // single tip element for all
196
+ } else if (conf.tip) {
197
+ tip = $(conf.tip).eq(0);
198
+
199
+ // autogenerated tooltip
200
+ } else if (title) {
201
+ tip = $(conf.layout).addClass(conf.tipClass).appendTo(document.body)
202
+ .hide().append(title);
203
+
204
+ // manual tooltip
205
+ } else {
206
+ tip = trigger.next();
207
+ if (!tip.length) { tip = trigger.parent().next(); }
208
+ }
209
+
210
+ if (!tip.length) { throw "Cannot find tooltip for " + trigger; }
211
+ }
212
+
213
+ if (self.isShown()) { return self; }
214
+
215
+ // stop previous animation
216
+ tip.stop(true, true);
217
+
218
+ // get position
219
+ var pos = getPosition(trigger, tip, conf);
220
+
221
+ // restore title for single tooltip element
222
+ if (conf.tip) {
223
+ tip.html(trigger.data("title"));
224
+ }
225
+
226
+ // onBeforeShow
227
+ e = $.Event();
228
+ e.type = "onBeforeShow";
229
+ fire.trigger(e, [pos]);
230
+ if (e.isDefaultPrevented()) { return self; }
231
+
232
+
233
+ // onBeforeShow may have altered the configuration
234
+ pos = getPosition(trigger, tip, conf);
235
+
236
+ // set position
237
+ tip.css({position:'absolute', top: pos.top, left: pos.left});
238
+
239
+ shown = true;
240
+
241
+ // invoke effect
242
+ effect[0].call(self, function() {
243
+ e.type = "onShow";
244
+ shown = 'full';
245
+ fire.trigger(e);
246
+ });
247
+
248
+
249
+ // tooltip events
250
+ var event = conf.events.tooltip.split(/,\s*/);
251
+
252
+ if (!tip.data("__set")) {
253
+
254
+ tip.unbind(event[0]).bind(event[0], function() {
255
+ clearTimeout(timer);
256
+ clearTimeout(pretimer);
257
+ });
258
+
259
+ if (event[1] && !trigger.is("input:not(:checkbox, :radio), textarea")) {
260
+ tip.unbind(event[1]).bind(event[1], function(e) {
261
+
262
+ // being moved to the trigger element
263
+ if (e.relatedTarget != trigger[0]) {
264
+ trigger.trigger(evt[1].split(" ")[0]);
265
+ }
266
+ });
267
+ }
268
+
269
+ // bind agein for if same tip element
270
+ if (!conf.tip) tip.data("__set", true);
271
+ }
272
+
273
+ return self;
274
+ },
275
+
276
+ hide: function(e) {
277
+
278
+ if (!tip || !self.isShown()) { return self; }
279
+
280
+ // onBeforeHide
281
+ e = $.Event();
282
+ e.type = "onBeforeHide";
283
+ fire.trigger(e);
284
+ if (e.isDefaultPrevented()) { return; }
285
+
286
+ shown = false;
287
+
288
+ effects[conf.effect][1].call(self, function() {
289
+ e.type = "onHide";
290
+ fire.trigger(e);
291
+ });
292
+
293
+ return self;
294
+ },
295
+
296
+ isShown: function(fully) {
297
+ return fully ? shown == 'full' : shown;
298
+ },
299
+
300
+ getConf: function() {
301
+ return conf;
302
+ },
303
+
304
+ getTip: function() {
305
+ return tip;
306
+ },
307
+
308
+ getTrigger: function() {
309
+ return trigger;
310
+ }
311
+
312
+ });
313
+
314
+ // callbacks
315
+ $.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","), function(i, name) {
316
+
317
+ // configuration
318
+ if ($.isFunction(conf[name])) {
319
+ $(self).bind(name, conf[name]);
320
+ }
321
+
322
+ // API
323
+ self[name] = function(fn) {
324
+ if (fn) { $(self).bind(name, fn); }
325
+ return self;
326
+ };
327
+ });
328
+
329
+ }
330
+
331
+
332
+ // jQuery plugin implementation
333
+ $.fn.tooltip = function(conf) {
334
+
335
+ // return existing instance
336
+ var api = this.data("tooltip");
337
+ if (api) { return api; }
338
+
339
+ conf = $.extend(true, {}, $.tools.tooltip.conf, conf);
340
+
341
+ // position can also be given as string
342
+ if (typeof conf.position == 'string') {
343
+ conf.position = conf.position.split(/,?\s/);
344
+ }
345
+
346
+ // install tooltip for each entry in jQuery object
347
+ this.each(function() {
348
+ api = new Tooltip($(this), conf);
349
+ $(this).data("tooltip", api);
350
+ });
351
+
352
+ return conf.api ? api: this;
353
+ };
354
+
355
+ }) (jQuery);
356
+
357
+
358
+