jquery-qtip2-rails 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. data/.gitignore +2 -0
  2. data/README.md +31 -16
  3. data/lib/jquery-qtip2-rails/version.rb +1 -1
  4. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/ajax/ajax.js +0 -0
  5. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/bgiframe/bgiframe.js +0 -0
  6. data/vendor/assets/{stylesheets/jquery-qtip → jquery-qtip/jquery-qtip/src}/core.css +0 -0
  7. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/core.js +1927 -1923
  8. data/vendor/assets/{stylesheets/jquery-qtip → jquery-qtip/jquery-qtip/src}/extra.css +0 -0
  9. data/vendor/assets/{stylesheets/jquery-qtip → jquery-qtip/jquery-qtip/src}/header.txt +3 -3
  10. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/imagemap/imagemap.js +0 -0
  11. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/intro.js +0 -0
  12. data/vendor/assets/{stylesheets/jquery-qtip → jquery-qtip/jquery-qtip/src}/modal/modal.css +0 -0
  13. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/modal/modal.js +55 -20
  14. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/outro.js +0 -0
  15. data/vendor/assets/{stylesheets/jquery-qtip → jquery-qtip/jquery-qtip/src}/styles.css +0 -0
  16. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/svg/svg.js +4 -0
  17. data/vendor/assets/{stylesheets/jquery-qtip → jquery-qtip/jquery-qtip/src}/tips/tips.css +0 -0
  18. data/vendor/assets/{javascripts/jquery-qtip → jquery-qtip/jquery-qtip/src}/tips/tips.js +2 -4
  19. data/vendor/assets/jquery-qtip/jquery.qtip.basic.js +4 -0
  20. data/vendor/assets/jquery-qtip/jquery.qtip.css +8 -0
  21. data/vendor/assets/jquery-qtip/jquery.qtip.js +10 -0
  22. metadata +23 -35
  23. data/vendor/assets/javascripts/jquery-qtip/header.txt +0 -14
  24. data/vendor/assets/javascripts/jquery.qtip.basic.js +0 -4
  25. data/vendor/assets/javascripts/jquery.qtip.js +0 -10
  26. data/vendor/assets/stylesheets/jquery.qtip.css +0 -8
@@ -1,14 +1,14 @@
1
- /*
1
+ /*!
2
2
  * qTip2 - Pretty powerful tooltips
3
3
  * http://craigsworks.com/projects/qtip2/
4
4
  *
5
- * Version: 2.0.0pre
5
+ * Version: @VERSION
6
6
  * Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com
7
7
  *
8
8
  * Dual licensed under MIT or GPLv2 licenses
9
9
  * http://en.wikipedia.org/wiki/MIT_License
10
10
  * http://en.wikipedia.org/wiki/GNU_General_Public_License
11
11
  *
12
- * Date: Sun May 13 20:10:51 2012 +0100
12
+ * Date:
13
13
  */
14
14
 
@@ -9,7 +9,8 @@ function Modal(api)
9
9
  namespace = globalNamespace + api.id,
10
10
  attr = 'is-modal-qtip',
11
11
  docBody = $(document.body),
12
- overlay;
12
+ focusableSelector = PLUGINS.modal.focusable.join(','),
13
+ focusableElems = {}, overlay;
13
14
 
14
15
  // Setup option set checks
15
16
  api.checks.modal = {
@@ -19,9 +20,41 @@ function Modal(api)
19
20
 
20
21
  // Show the modal if not visible already and tooltip is visible
21
22
  elems.overlay.toggle( tooltip.is(':visible') );
22
- }
23
+ },
24
+ '^content.text$': updateFocusable
23
25
  };
24
26
 
27
+ function updateFocusable() {
28
+ focusableElems = $(focusableSelector, tooltip).not('[disabled]').map(function() {
29
+ return typeof this.focus === 'function' ? this : null;
30
+ });
31
+ }
32
+
33
+ function focusInputs(blurElems) {
34
+ // Blurring body element in IE causes window.open windows to unfocus!
35
+ if(focusableElems.length < 1 && blurElems.length) { blurElems.not('body').blur(); }
36
+
37
+ // Focus the inputs
38
+ else { focusableElems.first().focus(); }
39
+ }
40
+
41
+ function stealFocus(event) {
42
+ var target = $(event.target),
43
+ container = target.closest('.qtip'),
44
+ targetOnTop;
45
+
46
+ // Determine if input container target is above this
47
+ targetOnTop = container.length < 1 ? FALSE :
48
+ (parseInt(container[0].style.zIndex, 10) > parseInt(tooltip[0].style.zIndex, 10));
49
+
50
+ // If we're showing a modal, but focus has landed on an input below
51
+ // this modal, divert focus to the first visible input in this modal
52
+ // or if we can't find one... the tooltip itself
53
+ if(!targetOnTop && ($(event.target).closest(selector)[0] !== tooltip[0])) {
54
+ focusInputs(target);
55
+ }
56
+ }
57
+
25
58
  $.extend(self, {
26
59
  init: function()
27
60
  {
@@ -67,7 +100,7 @@ function Modal(api)
67
100
  curIndex = parseInt(tooltip[0].style.zIndex, 10);
68
101
 
69
102
  // Set overlay z-index
70
- overlay[0].style.zIndex = newIndex - 1;
103
+ overlay[0].style.zIndex = newIndex - 2;
71
104
 
72
105
  // Reduce modal z-index's and keep them properly ordered
73
106
  qtips.each(function() {
@@ -95,7 +128,7 @@ function Modal(api)
95
128
 
96
129
  // Apply keyboard "Escape key" close handler
97
130
  if(options.escape) {
98
- $(window).unbind(namespace).bind('keydown'+namespace, function(event) {
131
+ $(document).unbind(namespace).bind('keydown'+namespace, function(event) {
99
132
  if(event.keyCode === 27 && tooltip.hasClass(focusClass)) {
100
133
  api.hide(event);
101
134
  }
@@ -109,6 +142,9 @@ function Modal(api)
109
142
  });
110
143
  }
111
144
 
145
+ // Update focusable elements
146
+ updateFocusable();
147
+
112
148
  return self;
113
149
  },
114
150
 
@@ -128,6 +164,7 @@ function Modal(api)
128
164
  html: '<div></div>',
129
165
  mousedown: function() { return FALSE; }
130
166
  })
167
+ .hide()
131
168
  .insertAfter( $(selector).last() );
132
169
 
133
170
  // Update position on window resize or scroll
@@ -168,25 +205,18 @@ function Modal(api)
168
205
  // Toggle backdrop cursor style on show
169
206
  overlay.toggleClass('blurs', options.blur);
170
207
 
171
- // Make sure we can't focus anything outside the tooltip
172
- docBody.bind('focusin'+namespace, function(event) {
173
- var target = $(event.target),
174
- container = target.closest('.qtip'),
208
+ // IF the modal can steal the focus
209
+ if(options.stealfocus !== FALSE) {
210
+ // Make sure we can't focus anything outside the tooltip
211
+ docBody.bind('focusin'+namespace, stealFocus);
175
212
 
176
- // Determine if input container target is above this
177
- targetOnTop = container.length < 1 ? FALSE :
178
- (parseInt(container[0].style.zIndex, 10) > parseInt(tooltip[0].style.zIndex, 10));
179
-
180
- // If we're showing a modal, but focus has landed on an input below
181
- // this modal, divert focus to the first visible input in this modal
182
- if(!targetOnTop && ($(event.target).closest(selector)[0] !== tooltip[0])) {
183
- tooltip.find('input:visible').filter(':first').focus();
184
- }
185
- });
213
+ // Blur the current item and focus anything in the modal we an
214
+ focusInputs( $('body *') );
215
+ }
186
216
  }
187
217
  else {
188
218
  // Undelegate focus handler
189
- docBody.undelegate('*', 'focusin'+namespace);
219
+ docBody.unbind('focusin'+namespace);
190
220
  }
191
221
 
192
222
  // Stop all animations
@@ -234,7 +264,7 @@ function Modal(api)
234
264
  // Remove overlay if needed
235
265
  if(delBlanket) {
236
266
  elems.overlay.remove();
237
- $(window).unbind(globalNamespace);
267
+ $(document).unbind(globalNamespace);
238
268
  }
239
269
  else {
240
270
  elems.overlay.unbind(globalNamespace+api.id);
@@ -272,6 +302,10 @@ PLUGINS.modal.sanitize = function(opts) {
272
302
  // Base z-index for all modal tooltips (use qTip core z-index as a base)
273
303
  PLUGINS.modal.zindex = QTIP.zindex + 1000;
274
304
 
305
+ // Defines the selector used to select all 'focusable' elements within the modal when using the show.modal.stealfocus option.
306
+ // Selectors initially taken from http://stackoverflow.com/questions/7668525/is-there-a-jquery-selector-to-get-all-elements-that-can-get-focus
307
+ PLUGINS.modal.focusable = ['a[href]', 'area[href]', 'input', 'select', 'textarea', 'button', 'iframe', 'object', 'embed', '[tabindex]', '[contenteditable]']
308
+
275
309
  // Extend original api defaults
276
310
  $.extend(TRUE, QTIP.defaults, {
277
311
  show: {
@@ -279,6 +313,7 @@ $.extend(TRUE, QTIP.defaults, {
279
313
  on: FALSE,
280
314
  effect: TRUE,
281
315
  blur: TRUE,
316
+ stealfocus: TRUE,
282
317
  escape: TRUE
283
318
  }
284
319
  }
@@ -8,6 +8,10 @@ PLUGINS.svg = function(svg, corner)
8
8
  },
9
9
  box, mtx, root, point, tPoint;
10
10
 
11
+ // Ascend the parentNode chain until we find an element with getBBox()
12
+ while(!elem.getBBox) { elem = elem.parentNode; }
13
+
14
+ // Check for a valid bounding box method
11
15
  if (elem.getBBox && elem.parentNode) {
12
16
  box = elem.getBBox();
13
17
  mtx = elem.getScreenCTM();
@@ -552,12 +552,10 @@ function Tip(qTip, command)
552
552
  position['margin-' + b] = -Math.round(dimensions[ precedance === 'y' ? 'width' : 'height' ] / 2) + userOffset;
553
553
  }
554
554
  else {
555
- b = borderWidth(corner, side, TRUE);
555
+ b = borderWidth(corner, side);
556
556
  br = borderRadius(corner);
557
557
 
558
- position[ side ] = i ?
559
- border ? borderWidth(corner, side) : 0 :
560
- userOffset + (br > b ? br : -b);
558
+ position[ side ] = i ? 0 : (userOffset + (br > b ? br : -b));
561
559
  }
562
560
  });
563
561
 
@@ -0,0 +1,4 @@
1
+ //= include jquery-qtip/src/header.txt
2
+ //= include jquery-qtip/src/intro.js
3
+ //= include jquery-qtip/src/core.js
4
+ //= include jquery-qtip/src/outro.js
@@ -0,0 +1,8 @@
1
+ /*
2
+ *= include jquery-qtip/src/header.txt
3
+ *= include jquery-qtip/src/core.css
4
+ *= include jquery-qtip/src/modal/modal.css
5
+ *= include jquery-qtip/src/tips/tips.css
6
+ *= include jquery-qtip/src/styles.css
7
+ *= include jquery-qtip/src/extra.css
8
+ */
@@ -0,0 +1,10 @@
1
+ //= include jquery-qtip/src/header.txt
2
+ //= include jquery-qtip/src/intro.js
3
+ //= include jquery-qtip/src/core.js
4
+ //= include jquery-qtip/src/ajax/ajax.js
5
+ //= include jquery-qtip/src/bgiframe/bgiframe.js
6
+ //= include jquery-qtip/src/imagemap/imagemap.js
7
+ //= include jquery-qtip/src/modal/modal.js
8
+ //= include jquery-qtip/src/svg/svg.js
9
+ //= include jquery-qtip/src/tips/tips.js
10
+ //= include jquery-qtip/src/outro.js
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-qtip2-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-23 00:00:00.000000000 Z
12
+ date: 2012-06-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &70320569829180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,12 +21,7 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: 3.1.0
24
+ version_requirements: *70320569829180
30
25
  description: qTip2 jQuery plugin
31
26
  email:
32
27
  - tkrotoff@gmail.com
@@ -42,25 +37,24 @@ files:
42
37
  - jquery-qtip2-rails.gemspec
43
38
  - lib/jquery-qtip2-rails.rb
44
39
  - lib/jquery-qtip2-rails/version.rb
45
- - vendor/assets/javascripts/jquery-qtip/ajax/ajax.js
46
- - vendor/assets/javascripts/jquery-qtip/bgiframe/bgiframe.js
47
- - vendor/assets/javascripts/jquery-qtip/core.js
48
- - vendor/assets/javascripts/jquery-qtip/header.txt
49
- - vendor/assets/javascripts/jquery-qtip/imagemap/imagemap.js
50
- - vendor/assets/javascripts/jquery-qtip/intro.js
51
- - vendor/assets/javascripts/jquery-qtip/modal/modal.js
52
- - vendor/assets/javascripts/jquery-qtip/outro.js
53
- - vendor/assets/javascripts/jquery-qtip/svg/svg.js
54
- - vendor/assets/javascripts/jquery-qtip/tips/tips.js
55
- - vendor/assets/javascripts/jquery.qtip.basic.js
56
- - vendor/assets/javascripts/jquery.qtip.js
57
- - vendor/assets/stylesheets/jquery-qtip/core.css
58
- - vendor/assets/stylesheets/jquery-qtip/extra.css
59
- - vendor/assets/stylesheets/jquery-qtip/header.txt
60
- - vendor/assets/stylesheets/jquery-qtip/modal/modal.css
61
- - vendor/assets/stylesheets/jquery-qtip/styles.css
62
- - vendor/assets/stylesheets/jquery-qtip/tips/tips.css
63
- - vendor/assets/stylesheets/jquery.qtip.css
40
+ - vendor/assets/jquery-qtip/jquery-qtip/src/ajax/ajax.js
41
+ - vendor/assets/jquery-qtip/jquery-qtip/src/bgiframe/bgiframe.js
42
+ - vendor/assets/jquery-qtip/jquery-qtip/src/core.css
43
+ - vendor/assets/jquery-qtip/jquery-qtip/src/core.js
44
+ - vendor/assets/jquery-qtip/jquery-qtip/src/extra.css
45
+ - vendor/assets/jquery-qtip/jquery-qtip/src/header.txt
46
+ - vendor/assets/jquery-qtip/jquery-qtip/src/imagemap/imagemap.js
47
+ - vendor/assets/jquery-qtip/jquery-qtip/src/intro.js
48
+ - vendor/assets/jquery-qtip/jquery-qtip/src/modal/modal.css
49
+ - vendor/assets/jquery-qtip/jquery-qtip/src/modal/modal.js
50
+ - vendor/assets/jquery-qtip/jquery-qtip/src/outro.js
51
+ - vendor/assets/jquery-qtip/jquery-qtip/src/styles.css
52
+ - vendor/assets/jquery-qtip/jquery-qtip/src/svg/svg.js
53
+ - vendor/assets/jquery-qtip/jquery-qtip/src/tips/tips.css
54
+ - vendor/assets/jquery-qtip/jquery-qtip/src/tips/tips.js
55
+ - vendor/assets/jquery-qtip/jquery.qtip.basic.js
56
+ - vendor/assets/jquery-qtip/jquery.qtip.css
57
+ - vendor/assets/jquery-qtip/jquery.qtip.js
64
58
  homepage: http://github.com/tkrotoff/jquery-qtip2-rails/
65
59
  licenses: []
66
60
  post_install_message:
@@ -73,21 +67,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
67
  - - ! '>='
74
68
  - !ruby/object:Gem::Version
75
69
  version: '0'
76
- segments:
77
- - 0
78
- hash: 4440104230482699963
79
70
  required_rubygems_version: !ruby/object:Gem::Requirement
80
71
  none: false
81
72
  requirements:
82
73
  - - ! '>='
83
74
  - !ruby/object:Gem::Version
84
75
  version: '0'
85
- segments:
86
- - 0
87
- hash: 4440104230482699963
88
76
  requirements: []
89
77
  rubyforge_project:
90
- rubygems_version: 1.8.24
78
+ rubygems_version: 1.8.15
91
79
  signing_key:
92
80
  specification_version: 3
93
81
  summary: qTip2 packaged for the Rails 3.1+ asset pipeline
@@ -1,14 +0,0 @@
1
- /*
2
- * qTip2 - Pretty powerful tooltips
3
- * http://craigsworks.com/projects/qtip2/
4
- *
5
- * Version: 2.0.0pre
6
- * Copyright 2009-2010 Craig Michael Thompson - http://craigsworks.com
7
- *
8
- * Dual licensed under MIT or GPLv2 licenses
9
- * http://en.wikipedia.org/wiki/MIT_License
10
- * http://en.wikipedia.org/wiki/GNU_General_Public_License
11
- *
12
- * Date: Sun May 13 20:10:51 2012 +0100
13
- */
14
-
@@ -1,4 +0,0 @@
1
- //= include ./jquery-qtip/header.txt
2
- //= include ./jquery-qtip/intro.js
3
- //= include ./jquery-qtip/core.js
4
- //= include ./jquery-qtip/outro.js
@@ -1,10 +0,0 @@
1
- //= include ./jquery-qtip/header.txt
2
- //= include ./jquery-qtip/intro.js
3
- //= include ./jquery-qtip/core.js
4
- //= include ./jquery-qtip/ajax/ajax.js
5
- //= include ./jquery-qtip/bgiframe/bgiframe.js
6
- //= include ./jquery-qtip/imagemap/imagemap.js
7
- //= include ./jquery-qtip/modal/modal.js
8
- //= include ./jquery-qtip/svg/svg.js
9
- //= include ./jquery-qtip/tips/tips.js
10
- //= include ./jquery-qtip/outro.js
@@ -1,8 +0,0 @@
1
- /*
2
- *= include ./jquery-qtip/header.txt
3
- *= include ./jquery-qtip/core.css
4
- *= include ./jquery-qtip/modal/modal.css
5
- *= include ./jquery-qtip/tips/tips.css
6
- *= include ./jquery-qtip/styles.css
7
- *= include ./jquery-qtip/extra.css
8
- */