tao_on_rails 0.9.2 → 0.9.3

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: b5cd10cf94e1abe75c759862792a084a403dd9fe
4
- data.tar.gz: 2987b6c9ec002b7fad6a568c0a47029a079e78be
3
+ metadata.gz: 1aec7845926da7ba72c3a2adc0375801cc91465b
4
+ data.tar.gz: dc8dffdd444cf419667b54731aab0c59bfbe3144
5
5
  SHA512:
6
- metadata.gz: b7e6023f2c0336c9adadfb79349ffe1ff6b2275a163a08a5c7820d9792cb64ad1577aa7b5fbaa44c29fe6a1a4b01c2cf91dc6cc19ab89b8958d4c835839d9101
7
- data.tar.gz: cdc4059cf58af554318ccd4a0b101ff731c9b1bc96402fa1abded551f90b8721d1bc61ef7dec665e72e1520fb215a7f5fc32b54eb8abd3395cd558a4ad89de87
6
+ metadata.gz: d6e2dc63d51c677dee8eacc042b725b45f91a286ee350115c6e8cd9dab83c293b113341f682b4715c7e7a4a36b78b1dbd7d38a507c031e0c8bc74c05e850e3c2
7
+ data.tar.gz: f1b51e8276c9b98dd1df1ac5f95f1f98419bfac31e888da57515b00b7b453451364b54ddadea364d202b9aa1f6927f03a94310ee6ceb6f37d1429e827baaef19
@@ -102,16 +102,16 @@ TaoComponentBasedOn = (superClassName = 'HTMLElement') ->
102
102
  @taoId = ++count
103
103
  @_init()
104
104
  @initialized = true
105
- @trigger 'initialized'
105
+ @namespacedTrigger 'initialized'
106
106
 
107
107
  @_connected()
108
- @trigger 'connected'
108
+ @namespacedTrigger 'connected'
109
109
 
110
110
  disconnectedCallback: ->
111
111
  $ =>
112
112
  @connected = false
113
113
  @_disconnected()
114
- @trigger 'disconnected'
114
+ @namespacedTrigger 'disconnected'
115
115
 
116
116
  attributeChangedCallback: (name) ->
117
117
  return unless @connected
@@ -142,15 +142,26 @@ TaoComponentBasedOn = (superClassName = 'HTMLElement') ->
142
142
  beforeCache: ->
143
143
  # called before turbolinks cache pages
144
144
 
145
- findComponent: (selector, readyCallback) ->
146
- component = @jq.find(selector).get(0)
147
- if component.connected
148
- # make sure element is returned before callback
149
- setTimeout -> readyCallback? component
150
- else
151
- @one 'connected', selector, ->
152
- readyCallback? component
153
- component
145
+ findComponent: (selectors...) ->
146
+ readyCallback = selectors.pop() if _.isFunction(_.last(selectors))
147
+ components = selectors.map (s) =>
148
+ deferred = $.Deferred()
149
+ element = @jq.find(s).get(0)
150
+ if element.connected
151
+ # make sure element is returned before callback
152
+ setTimeout -> deferred.resolve()
153
+ else
154
+ @on 'tao:connected', s, (e) ->
155
+ return unless e.target == e.currentTarget
156
+ deferred.resolve()
157
+ @off 'tao:connected', s
158
+ [element, deferred.promise()]
159
+
160
+ elements = components.map (c) -> c[0]
161
+ promises = components.map (c) -> c[1]
162
+ $.when(promises...).then -> readyCallback?(elements...)
163
+
164
+ if elements.length > 1 then elements else elements[0]
154
165
 
155
166
  on: (name, args...) ->
156
167
  if name && name.indexOf('.') < 0
@@ -168,6 +179,10 @@ TaoComponentBasedOn = (superClassName = 'HTMLElement') ->
168
179
  triggerHandler: (args...) ->
169
180
  @jq.triggerHandler(args...)
170
181
 
182
+ namespacedTrigger: (name, params) ->
183
+ @trigger "tao:#{name}", params
184
+ @trigger "#{@constructor._tag}:#{name}", params
185
+
171
186
  one: (args...) ->
172
187
  @jq.one args...
173
188
 
@@ -1,3 +1,3 @@
1
1
  module TaoOnRails
2
- VERSION = "0.9.2"
2
+ VERSION = "0.9.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tao_on_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siyuan Liu
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-07-10 00:00:00.000000000 Z
12
+ date: 2017-07-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: turbolinks
@@ -115,6 +115,20 @@ dependencies:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.7.1
118
+ - !ruby/object:Gem::Dependency
119
+ name: selenium-webdriver
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 3.2.0
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 3.2.0
118
132
  - !ruby/object:Gem::Dependency
119
133
  name: mocha
120
134
  requirement: !ruby/object:Gem::Requirement