jquery-popover 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +107 -0
- data/Rakefile +2 -0
- data/jquery-popover.gemspec +19 -0
- data/lib/jquery-popover.rb +7 -0
- data/lib/jquery-popover/engine.rb +7 -0
- data/lib/jquery-popover/version.rb +5 -0
- data/vendor/assets/javascripts/jquery-popover.js +229 -0
- data/vendor/assets/javascripts/jquery-popover.min.js +9 -0
- data/vendor/assets/javascripts/jquery-ui/position.js +9 -0
- metadata +69 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Andrei Misarca
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# jQuery Popover
|
2
|
+
|
3
|
+
A lightweight framework for positioning popovers against triggers links. It's a pretty thin wrapper for jQuery UI Position, which does most of the heavy lifting. It is a Rails ger version for https://github.com/crowdfavorite/jquery-popover
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
- jquery-rails (>= 2.0.0)
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile in the assets group:
|
11
|
+
|
12
|
+
gem 'jquery-popover'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
You need to include the jQuery library jQuery UI position library, to be able to use this one
|
19
|
+
|
20
|
+
//= require jquery
|
21
|
+
//= require jquery-ui
|
22
|
+
|
23
|
+
or
|
24
|
+
|
25
|
+
//= require jquery
|
26
|
+
//= require jquery-ui/popover
|
27
|
+
|
28
|
+
In your application.js file add *after* including jQuery and jQuery UI
|
29
|
+
|
30
|
+
//= require jquery-popover
|
31
|
+
|
32
|
+
## What it Does
|
33
|
+
|
34
|
+
- Visually positions the popover against the trigger element, regardless of where they are in the source order.
|
35
|
+
- Toggles the Popover with a fade effect when you click the trigger
|
36
|
+
- When clicking outside of the popover area, hides the popover.
|
37
|
+
- Repositions the popover after a window resize to make sure it stays pinned to the right place.
|
38
|
+
- Adds `.before` and `.after` empty elements to the popover. You can use these to create comic-bubble pointers using background images, or that type of thing.
|
39
|
+
|
40
|
+
## How to Use It
|
41
|
+
|
42
|
+
Include the script and it's requirements.
|
43
|
+
|
44
|
+
Popover markup consist of two parts:
|
45
|
+
|
46
|
+
- The popover element which must have an ID
|
47
|
+
- A trigger link, with an anchor to the ID of the popover element.
|
48
|
+
|
49
|
+
Sample markup:
|
50
|
+
|
51
|
+
<a class="trigger" href="#popover1">Open Popover</a>
|
52
|
+
<div id="popover1">Popover FTW!</div>
|
53
|
+
|
54
|
+
The popover element can live anywhere on the page. The script will automatically position the popover against the trigger.
|
55
|
+
|
56
|
+
You will also typically want to add `position: absolute;` to your popover element, otherwise jQuery UI Position will try to use relative positioning.
|
57
|
+
|
58
|
+
#popover1 {
|
59
|
+
position: absolute;
|
60
|
+
}
|
61
|
+
|
62
|
+
Or better yet, use a generic class:
|
63
|
+
|
64
|
+
.popover {
|
65
|
+
position: absolute;
|
66
|
+
}
|
67
|
+
|
68
|
+
Invoke the script on the trigger elements:
|
69
|
+
|
70
|
+
$('.trigger').popover();
|
71
|
+
|
72
|
+
The popover script will find the associated popover for a trigger by looking at the value of the `href` attribute.
|
73
|
+
|
74
|
+
You can also pass options. This would make the popover appear at the right-top edge of the trigger:
|
75
|
+
|
76
|
+
$('.trigger').popover({
|
77
|
+
my: 'left bottom', // of popover
|
78
|
+
at: 'right top', // of trigger
|
79
|
+
});
|
80
|
+
|
81
|
+
### Options
|
82
|
+
|
83
|
+
- `my`: position of popover. Can be [anything UI Position accepts](http://jqueryui.com/demos/position/).
|
84
|
+
- `at`: position of popover against trigger. Can be [anything UI Position accepts](http://jqueryui.com/demos/position/).
|
85
|
+
- `offset`: any tweaks you would like to make to the position. Can be [anything UI Position accepts](http://jqueryui.com/demos/position/).
|
86
|
+
- `collision`: the type of collision logic to run. Default "flop flop" -- a custom positioning plugin similar to "flip". Adds a `flopped-x` or `flopped-y` class to the popover when collision is in action. Can be [anything UI Position accepts](http://jqueryui.com/demos/position/).
|
87
|
+
- `using`: a functional option for tweaking positioning of the popover. Can be [anything UI Position accepts](http://jqueryui.com/demos/position/).
|
88
|
+
- `popover`: by default, the popover is found via the trigger's href attribute. If you absolutely have to, you can override this by setting the popover property. Pass in a selector, jQuery object or anything else `$()` accepts.
|
89
|
+
|
90
|
+
### Advanced Use
|
91
|
+
|
92
|
+
You can access methods and data for a popover after it's been initialized via the data API.
|
93
|
+
|
94
|
+
$('.trigger').data('popover').hide(); // .hidePopover(event) can be used, but will stop propagation of the event
|
95
|
+
$('.trigger').data('popover').opts.my // value of 'my' option for this instance
|
96
|
+
|
97
|
+
Duck-typing the constructor function for popovers is possible by changing:
|
98
|
+
|
99
|
+
$.fn.popover.Popover
|
100
|
+
|
101
|
+
## Contributing
|
102
|
+
|
103
|
+
1. Fork it
|
104
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
105
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
106
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
107
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/jquery-popover/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Andrei Misarca"]
|
6
|
+
gem.email = ["andrei.misarca@gmail.com"]
|
7
|
+
gem.description = %q{Add popovers to your applications with only a few lines of code}
|
8
|
+
gem.summary = %q{jQuery popover}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "jquery-popover"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Jquery::Popover::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'jquery-rails', '>= 2.0.0'
|
19
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
/*!
|
2
|
+
* CF Popover v1.1
|
3
|
+
* A lightweight framework for positioning iPad-style popover elements against triggers.
|
4
|
+
*
|
5
|
+
* Copyright 2011-2012, Crowd Favorite (http://crowdfavorite.com)
|
6
|
+
* Released under the MIT license.
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
*/
|
9
|
+
;(function ($) {
|
10
|
+
/* Proxy this once to save computation */
|
11
|
+
var uiPosition = $.ui.position;
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Constructor function for popovers
|
15
|
+
*/
|
16
|
+
var Popover = function ($trigger, opts) {
|
17
|
+
this.opts = $.extend({}, this.opts, opts);
|
18
|
+
this.$trigger = $($trigger.get(0));
|
19
|
+
|
20
|
+
this.$popover = $(( this.opts.popover || this.$trigger.attr('href') ));
|
21
|
+
this.$popover = $(this.$popover.get(0));
|
22
|
+
|
23
|
+
if (!this.$popover.hasClass('popover-before-after-applied')) {
|
24
|
+
this.$popover.addClass('popover-before-after-applied')
|
25
|
+
.prepend('<span role="presentation" class="before"/>')
|
26
|
+
.append('<span role="presentation" class="after"/>')
|
27
|
+
.hide();
|
28
|
+
}
|
29
|
+
};
|
30
|
+
|
31
|
+
Popover.prototype = {
|
32
|
+
timeout: null,
|
33
|
+
$win: $(window),
|
34
|
+
|
35
|
+
opts: {
|
36
|
+
my: 'center bottom',
|
37
|
+
at: 'center top',
|
38
|
+
offset: '0 0',
|
39
|
+
collision: 'flop flop',
|
40
|
+
popover: null,
|
41
|
+
thereCanBeOnlyOne: true
|
42
|
+
},
|
43
|
+
|
44
|
+
/**
|
45
|
+
* Custom collision handling for popovers (access via "flop" keyword)
|
46
|
+
* Identical to "flip", but adds class to element being flipped to let
|
47
|
+
* you know when it has been changed from default position.
|
48
|
+
* Functions get bound to this.$popover in the constructor.
|
49
|
+
* Used as a monkey patch below.
|
50
|
+
*/
|
51
|
+
flop: {
|
52
|
+
left: function (position, data) {
|
53
|
+
var cPosition = data.collisionPosition,
|
54
|
+
$popover = $(this),
|
55
|
+
c = 'flopped-x',
|
56
|
+
out;
|
57
|
+
|
58
|
+
/* Run the original first -- it modifies position
|
59
|
+
and data by reference. Store return value
|
60
|
+
anyway, since we want to make sure if they do
|
61
|
+
decide to return something in future the API
|
62
|
+
isn't broken */
|
63
|
+
out = uiPosition.flip.left(position, data);
|
64
|
+
|
65
|
+
(cPosition.left !== position.left) ? $popover.addClass(c) : $popover.removeClass(c);
|
66
|
+
|
67
|
+
return out;
|
68
|
+
},
|
69
|
+
top: function (position, data) {
|
70
|
+
var cPosition = data.collisionPosition,
|
71
|
+
$popover = $(this),
|
72
|
+
c = 'flopped-y',
|
73
|
+
out;
|
74
|
+
|
75
|
+
/* Run the original first -- it modifies position
|
76
|
+
and data by reference. Store return value
|
77
|
+
anyway, since we want to make sure if they do
|
78
|
+
decide to return something in future the API
|
79
|
+
isn't broken */
|
80
|
+
out = uiPosition.flip.top(position, data);
|
81
|
+
|
82
|
+
(cPosition.top !== position.top) ? $popover.addClass(c) : $popover.removeClass(c);
|
83
|
+
|
84
|
+
return out;
|
85
|
+
}
|
86
|
+
},
|
87
|
+
|
88
|
+
bindEvents: function () {
|
89
|
+
this.$trigger.click($.proxy(function (e) {
|
90
|
+
if (this.popoverIsOpen()) {
|
91
|
+
this.hidePopover(e);
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
this.showPopover(e);
|
95
|
+
};
|
96
|
+
if (this.opts.thereCanBeOnlyOne) {
|
97
|
+
$('body').trigger('popover-hide-all');
|
98
|
+
};
|
99
|
+
}, this));
|
100
|
+
|
101
|
+
$('body').click($.proxy(function (e) {
|
102
|
+
if (this.popoverIsOpen()) {
|
103
|
+
if (!$(this.$popover).has($(e.target)).size() && !$(this.$popover).filter($(e.target)).size()) {
|
104
|
+
this.hide();
|
105
|
+
}
|
106
|
+
};
|
107
|
+
}, this)).bind('popover-hide-all', $.proxy(function() {
|
108
|
+
if (this.popoverIsOpen() && !this.currentTrigger()) {
|
109
|
+
this.hide(true);
|
110
|
+
};
|
111
|
+
}, this));
|
112
|
+
|
113
|
+
this.$win.resize($.proxy(this.pinToTargetDebounced, this));
|
114
|
+
},
|
115
|
+
|
116
|
+
/* is the popover the this trigger open? */
|
117
|
+
popoverIsOpen: function() {
|
118
|
+
var opener = (this.$trigger.length == this.$trigger.filter(this.$popover.data('opener')).length);
|
119
|
+
return (this.$popover.is(':visible') && opener);
|
120
|
+
},
|
121
|
+
|
122
|
+
/* is this trigger the last trigger clicked? */
|
123
|
+
currentTrigger: function() {
|
124
|
+
return (this.$trigger.length == this.$trigger.filter($.fn.popover.lastTrigger).length);
|
125
|
+
},
|
126
|
+
|
127
|
+
/* Method for showing the popover */
|
128
|
+
show: function (e) {
|
129
|
+
$.fn.popover.lastTrigger = this.$trigger;
|
130
|
+
this.$popover.fadeIn('medium', $.proxy(function () {
|
131
|
+
this.$trigger.trigger('popover-show-animation-complete');
|
132
|
+
}, this)).data('opener', this.$trigger);
|
133
|
+
this.pinToTarget();
|
134
|
+
this.$trigger.trigger('popover-show');
|
135
|
+
},
|
136
|
+
|
137
|
+
/* Method for hiding the popover */
|
138
|
+
hide: function (immediate) {
|
139
|
+
var callback = $.proxy(function () {
|
140
|
+
this.$trigger.trigger('popover-hide-animation-complete');
|
141
|
+
}, this);
|
142
|
+
if (immediate) {
|
143
|
+
this.$popover.hide(0, callback);
|
144
|
+
}
|
145
|
+
else {
|
146
|
+
this.$popover.fadeOut('fast', callback);
|
147
|
+
};
|
148
|
+
this.$trigger.trigger('popover-hide');
|
149
|
+
},
|
150
|
+
|
151
|
+
toggle: function(immediate) {
|
152
|
+
if (this.popoverIsOpen()) {
|
153
|
+
this.hide(immediate);
|
154
|
+
}
|
155
|
+
else {
|
156
|
+
this.show();
|
157
|
+
}
|
158
|
+
},
|
159
|
+
|
160
|
+
/* Event handler for showing popover */
|
161
|
+
showPopover: function (e) {
|
162
|
+
e.preventDefault();
|
163
|
+
e.stopPropagation();
|
164
|
+
this.show(e);
|
165
|
+
},
|
166
|
+
|
167
|
+
/* Event handler for hiding popover */
|
168
|
+
hidePopover: function (e) {
|
169
|
+
e.preventDefault();
|
170
|
+
e.stopPropagation();
|
171
|
+
this.hide();
|
172
|
+
},
|
173
|
+
|
174
|
+
/* Calculate and position against trigger */
|
175
|
+
pinToTarget: function () {
|
176
|
+
if (!this.popoverIsOpen()) {
|
177
|
+
return;
|
178
|
+
}
|
179
|
+
var $popover = this.$popover,
|
180
|
+
posOpts = $.extend({
|
181
|
+
of: this.$trigger
|
182
|
+
}, this.opts),
|
183
|
+
|
184
|
+
/* Monkey-patch in our custom collision handling */
|
185
|
+
flop = {
|
186
|
+
/* Bind our custom collision handling to the popover element */
|
187
|
+
left: $.proxy(this.flop.left, this.$popover),
|
188
|
+
top: $.proxy(this.flop.top, this.$popover)
|
189
|
+
};
|
190
|
+
|
191
|
+
uiPosition.flop = flop;
|
192
|
+
$popover.position(posOpts);
|
193
|
+
uiPosition.flop = undefined;
|
194
|
+
},
|
195
|
+
|
196
|
+
/* Debounced to prevent hitting lots of times while resizing happens.
|
197
|
+
Will fire a maximum of 20x per second. Useful for binding to the window
|
198
|
+
resize event. */
|
199
|
+
pinToTargetDebounced: function () {
|
200
|
+
clearTimeout(this.timeout);
|
201
|
+
this.timeout = setTimeout($.proxy(this.pinToTarget, this), 50);
|
202
|
+
}
|
203
|
+
};
|
204
|
+
|
205
|
+
var fn = $.fn;
|
206
|
+
|
207
|
+
fn.popover = function (opts) {
|
208
|
+
var Popover = fn.popover.Popover;
|
209
|
+
|
210
|
+
this.each(function() {
|
211
|
+
var $this = $(this);
|
212
|
+
var popover = new Popover($this, opts);
|
213
|
+
popover.bindEvents();
|
214
|
+
|
215
|
+
/* Store Popover instance for easy method access.
|
216
|
+
See: http://alexsexton.com/?p=51
|
217
|
+
|
218
|
+
Example: $('.trigger').data('popover').hidePopover(); */
|
219
|
+
$this.data('popover', popover);
|
220
|
+
});
|
221
|
+
|
222
|
+
return this;
|
223
|
+
};
|
224
|
+
|
225
|
+
fn.popover.lastTrigger = null;
|
226
|
+
|
227
|
+
/* Expose constructor function for folks to duck-type when necessary */
|
228
|
+
fn.popover.Popover = Popover;
|
229
|
+
})(jQuery);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*!
|
2
|
+
* CF Popover v1.1
|
3
|
+
* A lightweight framework for positioning iPad-style popover elements against triggers.
|
4
|
+
*
|
5
|
+
* Copyright 2011-2012, Crowd Favorite (http://crowdfavorite.com)
|
6
|
+
* Released under the MIT license.
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
*/
|
9
|
+
(function(d){var a=d.ui.position;var c=function(e,f){this.opts=d.extend({},this.opts,f);this.$trigger=d(e.get(0));this.$popover=d((this.opts.popover||this.$trigger.attr("href")));this.$popover=d(this.$popover.get(0));if(!this.$popover.hasClass("popover-before-after-applied")){this.$popover.addClass("popover-before-after-applied").prepend('<span role="presentation" class="before"/>').append('<span role="presentation" class="after"/>').hide();}};c.prototype={timeout:null,$win:d(window),opts:{my:"center bottom",at:"center top",offset:"0 0",collision:"flop flop",popover:null,thereCanBeOnlyOne:true},flop:{left:function(f,i){var e=i.collisionPosition,h=d(this),j="flopped-x",g;g=a.flip.left(f,i);(e.left!==f.left)?h.addClass(j):h.removeClass(j);return g;},top:function(f,i){var e=i.collisionPosition,h=d(this),j="flopped-y",g;g=a.flip.top(f,i);(e.top!==f.top)?h.addClass(j):h.removeClass(j);return g;}},bindEvents:function(){this.$trigger.click(d.proxy(function(f){if(this.popoverIsOpen()){this.hidePopover(f);}else{this.showPopover(f);}if(this.opts.thereCanBeOnlyOne){d("body").trigger("popover-hide-all");}},this));d("body").click(d.proxy(function(f){if(this.popoverIsOpen()){if(!d(this.$popover).has(d(f.target)).size()&&!d(this.$popover).filter(d(f.target)).size()){this.hide();}}},this)).bind("popover-hide-all",d.proxy(function(){if(this.popoverIsOpen()&&!this.currentTrigger()){this.hide(true);}},this));this.$win.resize(d.proxy(this.pinToTargetDebounced,this));},popoverIsOpen:function(){var e=(this.$trigger.length==this.$trigger.filter(this.$popover.data("opener")).length);return(this.$popover.is(":visible")&&e);},currentTrigger:function(){return(this.$trigger.length==this.$trigger.filter(d.fn.popover.lastTrigger).length);},show:function(f){d.fn.popover.lastTrigger=this.$trigger;this.$popover.fadeIn("medium",d.proxy(function(){this.$trigger.trigger("popover-show-animation-complete");},this)).data("opener",this.$trigger);this.pinToTarget();this.$trigger.trigger("popover-show");},hide:function(e){var f=d.proxy(function(){this.$trigger.trigger("popover-hide-animation-complete");},this);if(e){this.$popover.hide(0,f);}else{this.$popover.fadeOut("fast",f);}this.$trigger.trigger("popover-hide");},toggle:function(e){if(this.popoverIsOpen()){this.hide(e);}else{this.show();}},showPopover:function(f){f.preventDefault();f.stopPropagation();this.show(f);},hidePopover:function(f){f.preventDefault();f.stopPropagation();this.hide();},pinToTarget:function(){if(!this.popoverIsOpen()){return;}var e=this.$popover,g=d.extend({of:this.$trigger},this.opts),f={left:d.proxy(this.flop.left,this.$popover),top:d.proxy(this.flop.top,this.$popover)};a.flop=f;e.position(g);a.flop=undefined;},pinToTargetDebounced:function(){clearTimeout(this.timeout);this.timeout=setTimeout(d.proxy(this.pinToTarget,this),50);}};var b=d.fn;b.popover=function(f){var e=b.popover.Popover;this.each(function(){var h=d(this);var g=new e(h,f);g.bindEvents();h.data("popover",g);});return this;};b.popover.lastTrigger=null;b.popover.Popover=c;})(jQuery);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery UI Position 1.8.16
|
3
|
+
*
|
4
|
+
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
5
|
+
* Dual licensed under the MIT or GPL Version 2 licenses.
|
6
|
+
* http://jquery.org/license
|
7
|
+
*
|
8
|
+
* http://docs.jquery.com/UI/Position
|
9
|
+
*/(function(a,b){a.ui=a.ui||{};var c=/left|center|right/,d=/top|center|bottom/,e="center",f=a.fn.position,g=a.fn.offset;a.fn.position=function(b){if(!b||!b.of)return f.apply(this,arguments);b=a.extend({},b);var g=a(b.of),h=g[0],i=(b.collision||"flip").split(" "),j=b.offset?b.offset.split(" "):[0,0],k,l,m;return h.nodeType===9?(k=g.width(),l=g.height(),m={top:0,left:0}):h.setTimeout?(k=g.width(),l=g.height(),m={top:g.scrollTop(),left:g.scrollLeft()}):h.preventDefault?(b.at="left top",k=l=0,m={top:b.of.pageY,left:b.of.pageX}):(k=g.outerWidth(),l=g.outerHeight(),m=g.offset()),a.each(["my","at"],function(){var a=(b[this]||"").split(" ");a.length===1&&(a=c.test(a[0])?a.concat([e]):d.test(a[0])?[e].concat(a):[e,e]),a[0]=c.test(a[0])?a[0]:e,a[1]=d.test(a[1])?a[1]:e,b[this]=a}),i.length===1&&(i[1]=i[0]),j[0]=parseInt(j[0],10)||0,j.length===1&&(j[1]=j[0]),j[1]=parseInt(j[1],10)||0,b.at[0]==="right"?m.left+=k:b.at[0]===e&&(m.left+=k/2),b.at[1]==="bottom"?m.top+=l:b.at[1]===e&&(m.top+=l/2),m.left+=j[0],m.top+=j[1],this.each(function(){var c=a(this),d=c.outerWidth(),f=c.outerHeight(),g=parseInt(a.curCSS(this,"marginLeft",!0))||0,h=parseInt(a.curCSS(this,"marginTop",!0))||0,n=d+g+(parseInt(a.curCSS(this,"marginRight",!0))||0),o=f+h+(parseInt(a.curCSS(this,"marginBottom",!0))||0),p=a.extend({},m),q;b.my[0]==="right"?p.left-=d:b.my[0]===e&&(p.left-=d/2),b.my[1]==="bottom"?p.top-=f:b.my[1]===e&&(p.top-=f/2),p.left=Math.round(p.left),p.top=Math.round(p.top),q={left:p.left-g,top:p.top-h},a.each(["left","top"],function(c,e){a.ui.position[i[c]]&&a.ui.position[i[c]][e](p,{targetWidth:k,targetHeight:l,elemWidth:d,elemHeight:f,collisionPosition:q,collisionWidth:n,collisionHeight:o,offset:j,my:b.my,at:b.at})}),a.fn.bgiframe&&c.bgiframe(),c.offset(a.extend(p,{using:b.using}))})},a.ui.position={fit:{left:function(b,c){var d=a(window),e=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft();b.left=e>0?b.left-e:Math.max(b.left-c.collisionPosition.left,b.left)},top:function(b,c){var d=a(window),e=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop();b.top=e>0?b.top-e:Math.max(b.top-c.collisionPosition.top,b.top)}},flip:{left:function(b,c){if(c.at[0]===e)return;var d=a(window),f=c.collisionPosition.left+c.collisionWidth-d.width()-d.scrollLeft(),g=c.my[0]==="left"?-c.elemWidth:c.my[0]==="right"?c.elemWidth:0,h=c.at[0]==="left"?c.targetWidth:-c.targetWidth,i=-2*c.offset[0];b.left+=c.collisionPosition.left<0?g+h+i:f>0?g+h+i:0},top:function(b,c){if(c.at[1]===e)return;var d=a(window),f=c.collisionPosition.top+c.collisionHeight-d.height()-d.scrollTop(),g=c.my[1]==="top"?-c.elemHeight:c.my[1]==="bottom"?c.elemHeight:0,h=c.at[1]==="top"?c.targetHeight:-c.targetHeight,i=-2*c.offset[1];b.top+=c.collisionPosition.top<0?g+h+i:f>0?g+h+i:0}}},a.offset.setOffset||(a.offset.setOffset=function(b,c){/static/.test(a.curCSS(b,"position"))&&(b.style.position="relative");var d=a(b),e=d.offset(),f=parseInt(a.curCSS(b,"top",!0),10)||0,g=parseInt(a.curCSS(b,"left",!0),10)||0,h={top:c.top-e.top+f,left:c.left-e.left+g};"using"in c?c.using.call(b,h):d.css(h)},a.fn.offset=function(b){var c=this[0];return!c||!c.ownerDocument?null:b?this.each(function(){a.offset.setOffset(this,b)}):g.call(this)})})(jQuery)
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-popover
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Andrei Misarca
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: jquery-rails
|
16
|
+
requirement: &76512230 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *76512230
|
25
|
+
description: Add popovers to your applications with only a few lines of code
|
26
|
+
email:
|
27
|
+
- andrei.misarca@gmail.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- .gitignore
|
33
|
+
- Gemfile
|
34
|
+
- LICENSE
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- jquery-popover.gemspec
|
38
|
+
- lib/jquery-popover.rb
|
39
|
+
- lib/jquery-popover/engine.rb
|
40
|
+
- lib/jquery-popover/version.rb
|
41
|
+
- vendor/assets/javascripts/jquery-popover.js
|
42
|
+
- vendor/assets/javascripts/jquery-popover.min.js
|
43
|
+
- vendor/assets/javascripts/jquery-ui/position.js
|
44
|
+
homepage: ''
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 1.8.11
|
65
|
+
signing_key:
|
66
|
+
specification_version: 3
|
67
|
+
summary: jQuery popover
|
68
|
+
test_files: []
|
69
|
+
has_rdoc:
|