hover_popover 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 87f38dec9a61681c2cf650e5dcc2f85545632c0f
4
+ data.tar.gz: ab7391d46f8cf9e23ad8c13d1ac461a3f5a4dd22
5
+ SHA512:
6
+ metadata.gz: e1310e853aa476f18c422f2a6d049af4caef0bfd12a92daa91c95378d866362cada6d118411b15983f2503cba78e0ee600ded8cac58adbb0a3b1dd2253e2e7b7
7
+ data.tar.gz: 861c805a212ab99a8cf1401ce43a0f413cba961467dab7a368e58d954aec25cb90bd44bd5e78b0c1cfbadaf3481caa01e90d5331d6b5d3ce5ba144399b8f92f7
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Amitree
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,56 @@
1
+ hover\_popover
2
+ ================
3
+
4
+ Extension of Bootstrap 3.1.1 popover.js. It allows for popovers to be hovered over without disappearing. Hover popover works very similiar to the standard popover and takes all of the same options.
5
+
6
+ Installation
7
+ -----
8
+
9
+ Add to your Gemfile:
10
+
11
+ ```ruby
12
+ gem 'hover_popover'
13
+ ```
14
+
15
+ Usage
16
+ -----
17
+
18
+ With default options:
19
+ ```js
20
+ $('#myPopover').hoverPopover()
21
+ ```
22
+
23
+ with custom options:
24
+ ```js
25
+ $('#myPopover').hoverPopover({title: 'Hello', content: 'This is a awesome popover', placement: 'bottom'})
26
+ ```
27
+
28
+ You can also set options in data attributes
29
+ ```html
30
+ <a href="#" id="myPopover" data-title="Hello" data-content="Hovering">Hover Popover</a>
31
+ ```
32
+
33
+ Docs
34
+ -----
35
+
36
+ Default options:
37
+ ```js
38
+ html: false,
39
+ ajax: false,
40
+ container: 'body',
41
+ trigger: 'manual',
42
+ content: '',
43
+ title: '',
44
+ placement: 'top',
45
+ delay: { show: 0, hide: 400 }
46
+ ```
47
+
48
+ See Bootstrap popover documentation for more options.
49
+
50
+ For elements that are not initially added to the DOM set ajax: true.
51
+ This will bind the hover event listener to the document.
52
+
53
+
54
+
55
+
56
+ Note: trigger needs to be set to manual or not overriden in order to function appropriately.
@@ -0,0 +1,6 @@
1
+ module HoverPopover
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ require 'sprockets'
2
+
3
+ ::Sprockets.append_path File.expand_path("../../../vendor/assets/javascripts", __FILE__)
@@ -0,0 +1,9 @@
1
+ module HoverPopover
2
+ module Rails
3
+ if defined? ::Rails::Engine
4
+ require 'hover_popover/engine'
5
+ elsif defined? ::Sprockets
6
+ require 'hover_popover/sprockets'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,101 @@
1
+ +function ($) {
2
+ 'use strict';
3
+
4
+ var HoverPopover = function (element, options) {
5
+ this.options =
6
+ this.enabled =
7
+ this.timeout =
8
+ this.popover =
9
+ this.$element = null
10
+
11
+ this.init(element, options)
12
+ }
13
+
14
+ if (!$.fn.popover) throw new Error('Hover Popover requires popover.js')
15
+
16
+ HoverPopover.DEFAULTS = {
17
+ html: false,
18
+ container: 'body',
19
+ trigger: 'manual',
20
+ content: '',
21
+ title: '',
22
+ placement: 'top',
23
+ ajax: false
24
+ delay: { show: 0, hide: 400 }
25
+ }
26
+
27
+ HoverPopover.prototype.constructor = HoverPopover
28
+
29
+ HoverPopover.prototype.init = function (element, options) {
30
+ this.$element = $(element)
31
+ this.options = this.getOptions(options)
32
+ this.$element.popover(this.options)
33
+ this.popover = this.$element.data('bs.popover')
34
+
35
+ var ajax = this.options.ajax
36
+ var trigger = this.options.trigger
37
+ if (trigger == 'manual') {
38
+
39
+ if (ajax) {
40
+ $(document).on('mouseenter', this.$element, $.proxy(this.enter, this))
41
+ $(document).on('mouseleave', this.$element, $.proxy(this.enter, this))
42
+ } else {
43
+ this.$element.on('mouseenter', $.proxy(this.enter, this))
44
+ this.$element.on('mouseleave', $.proxy(this.leave, this))
45
+ }
46
+ }
47
+ }
48
+
49
+ HoverPopover.prototype.getDefaults = function () {
50
+ return HoverPopover.DEFAULTS
51
+ }
52
+
53
+ HoverPopover.prototype.getOptions = function (options) {
54
+ options = $.extend({}, this.getDefaults(), this.$element.data(), options)
55
+ return options
56
+ }
57
+
58
+ HoverPopover.prototype.enter = function () {
59
+ clearTimeout(this.timeout)
60
+
61
+ if (!this.enabled) {
62
+ this.enabled = true
63
+ this.popover.enter(this.popover)
64
+ this.popover.$tip.on('mouseenter', $.proxy(this.enter, this))
65
+ this.popover.$tip.on('mouseleave', $.proxy(this.leave, this))
66
+ }
67
+ }
68
+
69
+ HoverPopover.prototype.leave = function () {
70
+ var self = this
71
+
72
+ clearTimeout(self.timeout)
73
+ self.timeout = setTimeout(function () {
74
+ self.enabled = false
75
+ self.popover.$tip.off('mouseenter')
76
+ self.popover.$tip.off('mouseleave')
77
+ self.popover.leave(self.popover)
78
+ }, self.options.delay.hide)
79
+
80
+ };
81
+
82
+ var old = $.fn.hoverPopover
83
+
84
+ $.fn.hoverPopover = function(option) {
85
+ return this.each(function () {
86
+ var $this = $(this)
87
+ var data = $this.data('hp.hoverPopover')
88
+ var options = typeof option == 'object' && option
89
+
90
+ if (!data) $this.data('hp.hoverPopover', (data = new HoverPopover(this, options)))
91
+ })
92
+ }
93
+
94
+ $.fn.hoverPopover.Constructor = HoverPopover
95
+
96
+ $.fn.hoverPopover.noConflict = function () {
97
+ $.fn.hoverPopover = old
98
+ return this
99
+ }
100
+
101
+ }(jQuery);
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hover_popover
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick Wargnier
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-22 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'Hover Popover '
14
+ email: nick@amitree.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - lib/hover_popover.rb
22
+ - lib/hover_popover/engine.rb
23
+ - lib/hover_popover/sprockets.rb
24
+ - vendor/assets/javascripts/hover_popover.js
25
+ homepage: http://rubygems.org/gems/hover_popover
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.2.2
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Hover Popover
49
+ test_files: []