tao_popover 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11910f354c5a3281102d2c6793bdc6aa995b5ce2
4
- data.tar.gz: 502d748e06c6f3e97dd2c139b9003487800a429c
3
+ metadata.gz: 90ab53b8171ac4d35fe35daea50748361bff76c4
4
+ data.tar.gz: a1471bc1edcdd311307795655668140e406b5816
5
5
  SHA512:
6
- metadata.gz: b4c1c238f6bc82b6926054ebb0bf9618b522bb31cce132c3775d821e7e13f1c1eb1db68529644cbddc593c7d85619992d00c13398378afb922c8c04de28d1452
7
- data.tar.gz: 185b7c3e8e969e045e4a255abb770d860603646cafdcdf235c17f62f214789ee4b1e98054d49bff5091516a95e0bfd239fe7ba010980756609523cf6c70f7abc
6
+ metadata.gz: 530631e363b85b23449e5347e13c961b097712f2f9afe49d02943a3321e0d63bef4bd53812b7fe4fb10b60e58938ce570ef042851b453a05a373ac43ab8307b5
7
+ data.tar.gz: d4facfcdb608da919dd1ddc04b796f803ab0713d33fa1e17a2cfc6721cf3429b53b74db264bb3c99042881696d424329e6e7be8ced82e6ed6a4f915e698cdf29
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
- task :default => :spec
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.pattern = 'test/**/*_test.rb'
8
+ end
9
+
10
+ task :default => :test
@@ -1,7 +1,7 @@
1
1
 
2
2
  class TaoPopover.Direction extends TaoModule
3
3
 
4
- @attribute 'popover', 'target', 'boundarySelector'
4
+ @property 'popover', 'target', 'boundarySelector'
5
5
 
6
6
  _init: ->
7
7
  @boundary = if @boundarySelector
@@ -7,25 +7,50 @@ class TaoPopover.Element extends TaoComponent
7
7
 
8
8
  @tag: 'tao-popover'
9
9
 
10
- @attribute 'active', 'targetSelector', 'targetTraversal', 'boundarySelector', 'direction', 'arrowAlign', 'arrowVerticalAlign', observe: true
10
+ @attribute 'active', type: 'boolean', observe: true
11
11
 
12
- @attribute 'offset', observe: true, default: 5
12
+ @attribute 'targetSelector', 'targetTraversal', 'triggerSelector', 'triggerTraversal'
13
13
 
14
- @attribute 'autoHide', default: true
14
+ @attribute 'triggerAction', default: 'click'
15
+
16
+ @attribute 'boundarySelector', 'direction', 'arrowAlign', 'arrowVerticalAlign'
17
+
18
+ @attribute 'offset', default: 0
19
+
20
+ @attribute 'autoHide', type: 'boolean', default: true
15
21
 
16
22
  _init: ->
17
- @jq.wrapInner '<div class="tao-popover-content">'
18
- .append '''
19
- <div class="tao-popover-arrow">
20
- <i class="arrow arrow-shadow"></i>
21
- <i class="arrow arrow-border"></i>
22
- <i class="arrow arrow-basic"></i>
23
- </div>
24
- '''
23
+ @target = if @targetTraversal && @targetSelector
24
+ @jq[@targetTraversal]?(@targetSelector)
25
+ else if @targetSelector
26
+ $ @targetSelector
27
+
28
+ unless @target.length > 0
29
+ throw new Error 'tao-popover: targetSelector attribute is required.'
30
+ return
31
+
32
+ @trigger = if @triggerTraversal && @triggerSelector
33
+ @jq[@triggerTraversal]?(@triggerSelector)
34
+ else if @triggerSelector
35
+ $ @triggerSelector
36
+ else
37
+ @target
38
+
39
+ @_bind()
25
40
 
26
41
  _connected: ->
27
- @_autoHideChanged()
28
42
  @refresh() if @active
43
+ @_enableAutoHide() if @autoHide && @active
44
+
45
+ _bind: ->
46
+ if @triggerAction == 'click'
47
+ @trigger.on 'click.tao-popover', (e) =>
48
+ @toggleActive()
49
+ else if @triggerAction == 'hover'
50
+ @trigger.on 'mouseenter.tao-popover', (e) =>
51
+ @active = true
52
+ .on 'mouseleave.tao-popover', (e) =>
53
+ @active = false
29
54
 
30
55
  _activeChanged: ->
31
56
  if @active
@@ -34,10 +59,6 @@ class TaoPopover.Element extends TaoComponent
34
59
  else
35
60
  @_disableAutoHide() if @autoHide
36
61
 
37
- _autoHideChanged: ->
38
- @_disableAutoHide()
39
- @_enableAutoHide() if @autoHide && @active
40
-
41
62
  _enableAutoHide: ->
42
63
  $(document).on "mousedown.tao-popover-#{@taoId}", (e) =>
43
64
  return unless @active
@@ -49,18 +70,12 @@ class TaoPopover.Element extends TaoComponent
49
70
  $(document).off "mousedown.tao-popover-#{@taoId}"
50
71
 
51
72
  refresh: ->
52
- @target = if @targetTraversal && @targetSelector
53
- @jq[@targetTraversal]?(@targetSelector)
54
- else if @targetSelector
55
- $ @targetSelector
56
-
57
- return unless @target && @target.length > 0
58
-
59
- direction = new Direction
60
- popover: @jq
61
- target: @target
62
- boundarySelector: @boundarySelector
63
- @direction = direction.toString()
73
+ unless @direction
74
+ direction = new Direction
75
+ popover: @jq
76
+ target: @target
77
+ boundarySelector: @boundarySelector
78
+ @direction = direction.toString()
64
79
 
65
80
  @position = new Position
66
81
  popover: @jq
@@ -78,6 +93,7 @@ class TaoPopover.Element extends TaoComponent
78
93
  @active = !@active
79
94
 
80
95
  _disconnected: ->
81
- @_disableAutoHide()
96
+ @trigger.off '.tao-popover'
97
+ $(document).off ".tao-popover-#{@taoId}"
82
98
 
83
99
  TaoComponent.register TaoPopover.Element
@@ -1,13 +1,13 @@
1
1
 
2
2
  class TaoPopover.Position extends TaoModule
3
3
 
4
- @attribute 'direction', 'popover', 'target'
4
+ @property 'direction', 'popover', 'target'
5
5
 
6
- @attribute 'arrowAlign', default: 'center'
6
+ @property 'arrowAlign', default: 'center'
7
7
 
8
- @attribute 'arrowVerticalAlign', default: 'middle'
8
+ @property 'arrowVerticalAlign', default: 'middle'
9
9
 
10
- @attribute 'offset', default: 0
10
+ @property 'offset', default: 0
11
11
 
12
12
  ARROW_OFFSET: 16
13
13
 
@@ -1,4 +1,4 @@
1
1
  #= require_self
2
- #= require_tree ./
2
+ #= require ./tao_popover/element
3
3
 
4
4
  window.TaoPopover = {}
@@ -1,13 +1,14 @@
1
1
  $arrowSize: 16px;
2
2
 
3
- tao-popover {
3
+ tao-popover,
4
+ .tao-popover {
4
5
  display: none;
5
6
  position: absolute;
6
7
  left: -9999px;
7
8
  top: -9999px;
8
9
  z-index: 200;
9
10
 
10
- &[active] {
11
+ &[active='true'] {
11
12
  display: block;
12
13
  }
13
14
 
@@ -0,0 +1,30 @@
1
+ module TaoPopover
2
+ module ActionView
3
+ module Helpers
4
+
5
+ include ::ActionView::Helpers
6
+ include ::ActionView::Context
7
+
8
+ def tao_popover(attributes = {}, &block)
9
+ if attributes[:class].present?
10
+ attributes[:class] += ' tao-popover'
11
+ else
12
+ attributes[:class] = 'tao-popover'
13
+ end
14
+
15
+ content = %Q{
16
+ <div class="tao-popover-content">
17
+ #{capture(&block)}
18
+ </div>
19
+ <div class="tao-popover-arrow">
20
+ <i class="arrow arrow-shadow"></i>
21
+ <i class="arrow arrow-border"></i>
22
+ <i class="arrow arrow-basic"></i>
23
+ </div>
24
+ }.html_safe
25
+ content_tag('tao-popover', content, attributes)
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,14 @@
1
+ require 'tao_on_rails'
2
+ require 'tao_popover/action_view/helpers'
3
+
4
+ module TaoPopover
5
+ class Engine < Rails::Engine
6
+
7
+ initializer "tao_popover.view_helpers" do |app|
8
+ ActiveSupport.on_load :action_view do
9
+ include TaoPopover::ActionView::Helpers
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module TaoPopover
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/tao_popover.rb CHANGED
@@ -1,7 +1,5 @@
1
- require "tao_popover/rails"
1
+ require 'tao_popover/version'
2
+ require 'tao_popover/engine'
2
3
 
3
4
  module TaoPopover
4
- def self.root
5
- File.dirname __dir__
6
- end
7
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tao_popover
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - farthinker
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-04 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tao_on_rails
@@ -16,56 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.6.1
19
+ version: 0.6.6
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.6.1
26
+ version: 0.6.6
27
27
  - !ruby/object:Gem::Dependency
28
- name: bundler
28
+ name: sqlite3
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.13'
33
+ version: '1.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.13'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '10.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '10.0'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '5.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '5.0'
40
+ version: '1.3'
69
41
  - !ruby/object:Gem::Dependency
70
42
  name: blade
71
43
  requirement: !ruby/object:Gem::Requirement
@@ -101,33 +73,18 @@ executables: []
101
73
  extensions: []
102
74
  extra_rdoc_files: []
103
75
  files:
104
- - ".blade.yml"
105
- - ".gitignore"
106
- - ".travis.yml"
107
- - CODE_OF_CONDUCT.md
108
- - Gemfile
109
76
  - LICENSE
110
- - LICENSE.txt
111
77
  - README.md
112
78
  - Rakefile
113
- - bin/console
114
- - bin/setup
115
- - dist/tao.css
116
- - dist/tao.js
117
- - dist/tao_popover.css
118
- - dist/tao_popover.js
119
- - index.html
120
79
  - lib/assets/javascripts/tao_popover.coffee
121
80
  - lib/assets/javascripts/tao_popover/direction.coffee
122
81
  - lib/assets/javascripts/tao_popover/element.coffee
123
82
  - lib/assets/javascripts/tao_popover/position.coffee
124
- - lib/assets/javascripts/tao_popover/trigger.coffee
125
83
  - lib/assets/stylesheets/tao_popover.scss
126
84
  - lib/tao_popover.rb
127
- - lib/tao_popover/rails.rb
128
- - lib/tao_popover/rails/engine.rb
129
- - lib/tao_popover/rails/version.rb
130
- - tao_popover.gemspec
85
+ - lib/tao_popover/action_view/helpers.rb
86
+ - lib/tao_popover/engine.rb
87
+ - lib/tao_popover/version.rb
131
88
  homepage: https://github.com/mycolorway/tao_popover
132
89
  licenses:
133
90
  - MIT
@@ -151,5 +108,5 @@ rubyforge_project:
151
108
  rubygems_version: 2.5.1
152
109
  signing_key:
153
110
  specification_version: 4
154
- summary: A popover component based on Tao Framework.
111
+ summary: An easy to use popover component for Rails.
155
112
  test_files: []
data/.blade.yml DELETED
@@ -1,47 +0,0 @@
1
- load_paths:
2
- - lib/assets/javascripts
3
- - lib/assets/stylesheets
4
- - test/javascripts/
5
- - turbolinks-source: lib/assets/javascripts
6
- - jquery-rails: vendor/assets/javascripts
7
- - lodash-rails: vendor/assets/javascripts
8
- - tao_on_rails:
9
- - lib/assets/javascripts
10
- - lib/assets/stylesheets
11
- - vendor/assets/javascripts
12
- - vendor/assets/stylesheets
13
-
14
- logical_paths:
15
- - tao.js
16
- - tao.css
17
- - tao_popover.css
18
- - tao_popover.js
19
- - tao_popover_test.js
20
-
21
- build:
22
- logical_paths:
23
- - tao.js
24
- - tao.css
25
- - tao_popover.css
26
- - tao_popover.js
27
- path: dist
28
-
29
- plugins:
30
- sauce_labs:
31
- tunnel_timeout: 120
32
- browsers:
33
- Google Chrome:
34
- os: Mac, Windows
35
- version: -2
36
- Firefox:
37
- os: Mac, Windows
38
- version: -2
39
- Safari:
40
- platform: Mac
41
- version: -3
42
- Microsoft Edge:
43
- version: -2
44
- iPhone:
45
- version: [9.3]
46
- Motorola Droid 4 Emulator:
47
- version: [5.1, 4.4]
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.gem
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.3.1
6
-
7
- before_install: gem install bundler -v 1.13.1
8
-
9
- script:
10
- - bundle exec blade ci
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at farthinker@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in tao_popover.gemspec
4
- gemspec
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 farthinker
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all 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,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "tao_popover"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here