tao_ui 0.3.3 → 0.3.4

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: 3288dc02b31c88e6e99f7d47beba2e01d7ec4f2e
4
- data.tar.gz: 89f554782002b6f03dc210431323a90c6868fb20
3
+ metadata.gz: d701031ac79bef3e9845a54b6f122396a554e827
4
+ data.tar.gz: 87281c106b7756741f9e2ffae41ddb77e035ec37
5
5
  SHA512:
6
- metadata.gz: 1dc06662259b356194e8c68e83b77562f5e5d1c599baeb0f20ab93a5b14bfa996dfc40997c9efbcbfb78642074e6f51b14ba1999c0e6459241b4fb64fb9d5127
7
- data.tar.gz: b84e2af252fd0a2be91f593d8b795f33d84892b89d8ca8d5d900ca4f58fa8afca4b2c04a2176be3d7edb4d6f6fbd0a71296101f68f15fcbb9c3412d28233c8e0
6
+ metadata.gz: 400c6f452e8ad425918e07e5bd74956baae6113a89cd555285d9da29376530a68b187d8ad5f9c1c362a1f3d952b7a132b226563213908f3f084dc69f0d86fc7a
7
+ data.tar.gz: a7c6fcabb4b564ac066466c92e1fb2d1860d97bb7ea3eb80670eed9c714925ed9bead6b5a19aeffc45af78cba0c93cd9473ccba5931e50d0639a2a70e1334859
@@ -1,5 +1,6 @@
1
1
  class Tao.Dialog.Element extends TaoComponent
2
2
 
3
+
3
4
  @tag 'tao-dialog'
4
5
 
5
6
  @attribute 'active', type: 'boolean', observe: true
@@ -11,6 +12,8 @@ class Tao.Dialog.Element extends TaoComponent
11
12
  @attribute 'triggerSelector', 'triggerTraversal', 'size'
12
13
 
13
14
  _connected: ->
15
+ @wrapper = @jq.find('.tao-dialog-wrapper')
16
+ @content = @jq.find('.tao-dialog-content')
14
17
  @triggerEl = if @triggerTraversal && @triggerSelector
15
18
  @jq[@triggerTraversal]?(@triggerSelector)
16
19
  else if @triggerSelector
@@ -31,58 +34,65 @@ class Tao.Dialog.Element extends TaoComponent
31
34
 
32
35
  _initSize: ->
33
36
  if _.isNumber(size = parseFloat @size)
34
- @jq.find('.tao-dialog-wrapper').width size
37
+ @wrapper.width size
35
38
 
36
39
  _bind: ->
37
40
  @on 'click', (e) =>
38
- @active = false if e.target == @
41
+ @active = false if @withCloseButton && e.target == @
39
42
  null
40
43
 
41
44
  @on 'click', ".tao-dialog-wrapper > .link-close, #{@closeSelector}", =>
42
45
  @active = false
43
46
  null
44
47
 
48
+ @on 'transitionend', @_afterTransition.bind(@)
49
+
45
50
  if @triggerEl && @triggerEl.length > 0
46
51
  @triggerEl.on "click.tao-slide-box-#{@taoId}", (e) =>
47
52
  @active = true
48
53
 
49
54
  _beforeActiveChanged: (active) ->
50
55
  if active
51
- @namespacedTrigger 'beforeShow'
52
- @jq.find('.tao-dialog-content').css
53
- maxHeight: $(window).height() - 40
54
- @jq.show()
55
- @reflow()
56
+ @_prepareShowTransition()
56
57
  else
57
- @namespacedTrigger 'beforeHide'
58
- reset = =>
59
- if @autoDestroy
60
- @remove()
61
- else
62
- @jq.hide()
63
- @namespacedTrigger 'afterHide'
64
-
65
- if @jq.is(':visible')
66
- @on 'transitionend', (e) =>
67
- @off 'transitionend'
68
- return unless $(e.target).is('.tao-dialog-wrapper')
69
- reset()
70
- else
71
- reset()
58
+ @_prepareHideTransition()
59
+ null
72
60
 
61
+ _prepareShowTransition: ->
62
+ @namespacedTrigger 'beforeShow'
63
+ @content.css
64
+ maxHeight: $(window).height() - 40
65
+ @jq.show()
66
+ @reflow()
67
+ @_duringTransition = 'show'
68
+
69
+ _prepareHideTransition: ->
70
+ @namespacedTrigger 'beforeHide'
71
+ if @jq.is(':visible') && @wrapper.css('opacity') * 1 > 0
72
+ @_duringTransition = 'hide'
73
+ else
74
+ @reset()
75
+
76
+ _afterTransition: (e) ->
77
+ return unless $(e.target).is(@wrapper) && e.originalEvent.propertyName == 'opacity'
78
+ if @_duringTransition == 'show'
79
+ @namespacedTrigger 'afterShow'
80
+ else if @_duringTransition == 'hide'
81
+ @reset()
82
+ @namespacedTrigger 'afterHide'
83
+ @_duringTransition = false
73
84
  null
74
85
 
75
86
  _activeChanged: ->
76
87
  if @active
77
- $('body, html').addClass('tao-dialog-active')
88
+ $('body').addClass('tao-dialog-active')
78
89
  @namespacedTrigger 'show'
79
90
  else
80
- $('body, html').removeClass('tao-dialog-active')
91
+ $('body').removeClass('tao-dialog-active')
81
92
  @namespacedTrigger 'hide'
82
93
 
83
94
  setContent: (content) ->
84
- @jq.find('.tao-dialog-content').empty()
85
- .append content
95
+ @content.empty().append content
86
96
  @
87
97
 
88
98
  remove: ->
@@ -91,11 +101,15 @@ class Tao.Dialog.Element extends TaoComponent
91
101
  @namespacedTrigger 'remove'
92
102
  @
93
103
 
94
- beforeCache: ->
104
+ reset: ->
95
105
  if @autoDestroy
96
106
  @remove()
97
107
  else
98
108
  @jq.hide()
99
- active = false
109
+ @
110
+
111
+ beforeCache: ->
112
+ @reset()
113
+ active = false
100
114
 
101
115
  TaoComponent.register Tao.Dialog.Element
@@ -17,7 +17,7 @@ class Tao.Popover.Element extends TaoComponent
17
17
 
18
18
  @attribute 'boundarySelector', 'direction', 'size'
19
19
 
20
- @attribute 'offset', type: 'number', default: 0
20
+ @attribute 'offset', type: 'number', default: 5
21
21
 
22
22
  @attribute 'autoHide', 'autoDestroy', 'withArrow', 'autoActivate', type: 'boolean'
23
23
 
@@ -26,6 +26,8 @@ class Tao.Popover.Element extends TaoComponent
26
26
  @_initTrigger()
27
27
  @_initSize()
28
28
 
29
+ @on 'transitionend', @_afterTransition.bind(@)
30
+
29
31
  if @autoActivate
30
32
  @reflow()
31
33
  @active = true
@@ -57,6 +59,12 @@ class Tao.Popover.Element extends TaoComponent
57
59
  @active = true
58
60
  null
59
61
  .on 'mouseleave.tao-popover', (e) =>
62
+ return if @jq.is(e.relatedTarget) || @jq.has(e.relatedTarget).length
63
+ @active = false
64
+ null
65
+
66
+ @jq.on 'mouseleave', (e) =>
67
+ return if @triggerEl.is(e.relatedTarget) || @triggerEl.has(e.relatedTarget).length
60
68
  @active = false
61
69
  null
62
70
 
@@ -67,26 +75,34 @@ class Tao.Popover.Element extends TaoComponent
67
75
  return false if @disabled
68
76
 
69
77
  if active
70
- @namespacedTrigger 'beforeShow'
71
- @jq.show()
72
- @refresh()
73
- @reflow()
78
+ @_prepareShowTransition()
74
79
  else
75
- @namespacedTrigger 'beforeHide'
76
- reset = =>
77
- if @autoDestroy
78
- @remove()
79
- else
80
- @jq.hide()
81
- @namespacedTrigger 'afterHide'
82
-
83
- if @jq.is(':visible')
84
- @on 'transitionend', (e) =>
85
- @off 'transitionend'
86
- return unless e.target == @
87
- reset()
88
- else
89
- reset()
80
+ @_prepareHideTransition()
81
+
82
+ null
83
+
84
+ _prepareShowTransition: ->
85
+ @namespacedTrigger 'beforeShow'
86
+ @jq.show()
87
+ @refresh()
88
+ @reflow()
89
+ @_duringTransition = 'show'
90
+
91
+ _prepareHideTransition: ->
92
+ @namespacedTrigger 'beforeHide'
93
+ if @jq.is(':visible') && @jq.css('opacity') * 1 > 0
94
+ @_duringTransition = 'hide'
95
+ else
96
+ @reset()
97
+
98
+ _afterTransition: (e) ->
99
+ return unless $(e.target).is(@) && e.originalEvent.propertyName == 'opacity'
100
+ if @_duringTransition == 'show'
101
+ @namespacedTrigger 'afterShow'
102
+ else if @_duringTransition == 'hide'
103
+ @reset()
104
+ @namespacedTrigger 'afterHide'
105
+ @_duringTransition = false
90
106
  null
91
107
 
92
108
  _activeChanged: ->
@@ -139,7 +155,7 @@ class Tao.Popover.Element extends TaoComponent
139
155
  @
140
156
 
141
157
  resetAttributes: ->
142
- @active = false
158
+ @active = false if @active
143
159
  @triggerEl?.off '.tao-popover'
144
160
  @target = null
145
161
  @triggerEl = null
@@ -158,11 +174,8 @@ class Tao.Popover.Element extends TaoComponent
158
174
  @
159
175
 
160
176
  beforeCache: ->
161
- if @autoDestroy
162
- @remove()
163
- else
164
- @jq.hide()
165
- @active = false
177
+ @reset()
178
+ @active = false
166
179
 
167
180
  remove: ->
168
181
  @namespacedTrigger 'beforeRemove'
@@ -171,6 +184,13 @@ class Tao.Popover.Element extends TaoComponent
171
184
  @namespacedTrigger 'remove'
172
185
  @
173
186
 
187
+ reset: ->
188
+ if @autoDestroy
189
+ @remove()
190
+ else
191
+ @jq.hide()
192
+ @
193
+
174
194
  _disconnected: ->
175
195
  @triggerEl?.off '.tao-popover'
176
196
  $(document).off ".tao-popover-#{@taoId}"
@@ -13,6 +13,7 @@ class Tao.SlideBox.ElementBase extends TaoComponent
13
13
  @attribute 'size'
14
14
 
15
15
  _connected: ->
16
+ @wrapper = @jq.find('.slide-box-wrapper')
16
17
  @triggerEl = if @triggerTraversal && @triggerSelector
17
18
  @jq[@triggerTraversal]?(@triggerSelector)
18
19
  else if @triggerSelector
@@ -33,7 +34,7 @@ class Tao.SlideBox.ElementBase extends TaoComponent
33
34
  "#{$(window)[sizeProperty]() + size}px"
34
35
  else
35
36
  @size
36
- @jq.find('.slide-box-wrapper').css sizeProperty, size
37
+ @wrapper.css sizeProperty, size
37
38
 
38
39
  _bind: ->
39
40
  @on 'click', (e) =>
@@ -42,42 +43,50 @@ class Tao.SlideBox.ElementBase extends TaoComponent
42
43
  @on 'click', '.slide-box-wrapper > .link-close', =>
43
44
  @active = false
44
45
 
46
+ @on 'transitionend', @_afterTransition.bind(@)
47
+
45
48
  if @triggerEl && @triggerEl.length > 0
46
49
  @triggerEl.on "click.tao-slide-box-#{@taoId}", (e) =>
47
50
  @active = true
48
51
 
49
52
  _beforeActiveChanged: (active) ->
50
53
  if active
51
- @namespacedTrigger 'beforeShow'
52
- @jq.show()
53
- @reflow()
54
+ @_prepareShowTransition()
54
55
  else
55
- @namespacedTrigger 'beforeHide'
56
- reset = =>
57
- if @autoDestroy
58
- @remove()
59
- else
60
- @jq.hide()
61
- @namespacedTrigger 'afterHide'
62
-
63
- # in case the slide box is hidden too fast
64
- if @jq.is(':visible')
65
- @on 'transitionend', (e) =>
66
- @off 'transitionend'
67
- return unless $(e.target).is('.slide-box-wrapper')
68
- reset()
69
- else
70
- reset()
56
+ @_prepareHideTransition()
57
+ null
58
+
59
+ _prepareShowTransition: ->
60
+ @namespacedTrigger 'beforeShow'
61
+ @jq.show()
62
+ @reflow()
63
+ @_duringTransition = 'show'
64
+
65
+ _prepareHideTransition: ->
66
+ @namespacedTrigger 'beforeHide'
67
+ if @jq.is(':visible') && @wrapper.css('opacity') * 1 > 0
68
+ @_duringTransition = 'hide'
69
+ else
70
+ @reset()
71
+
72
+ _afterTransition: (e) ->
73
+ return unless $(e.target).is(@wrapper) && e.originalEvent.propertyName == 'opacity'
74
+ if @_duringTransition == 'show'
75
+ @namespacedTrigger 'afterShow'
76
+ else if @_duringTransition == 'hide'
77
+ @reset()
78
+ @namespacedTrigger 'afterHide'
79
+ @_duringTransition = false
71
80
  null
72
81
 
73
82
  _activeChanged: ->
74
83
  @_unbindAutoHideEvent() if @autoHide
75
84
  if @active
76
85
  @_bindAutoHideEvent() if @autoHide
77
- $('body, html').addClass('slide-box-active')
86
+ $('body').addClass('slide-box-active')
78
87
  @namespacedTrigger 'show'
79
88
  else
80
- $('body, html').removeClass('slide-box-active')
89
+ $('body').removeClass('slide-box-active')
81
90
  @namespacedTrigger 'hide'
82
91
 
83
92
  _autoHideEvent: ''
@@ -98,8 +107,12 @@ class Tao.SlideBox.ElementBase extends TaoComponent
98
107
  @
99
108
 
100
109
  beforeCache: ->
110
+ @reset()
111
+ active = false
112
+
113
+ reset: ->
101
114
  if @autoDestroy
102
115
  @remove()
103
116
  else
104
117
  @jq.hide()
105
- active = false
118
+ @
@@ -1,3 +1,3 @@
1
1
  module TaoUi
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tao_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - farthinker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-04 00:00:00.000000000 Z
11
+ date: 2017-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tao_on_rails
@@ -252,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
252
  version: '0'
253
253
  requirements: []
254
254
  rubyforge_project:
255
- rubygems_version: 2.6.14
255
+ rubygems_version: 2.6.11
256
256
  signing_key:
257
257
  specification_version: 4
258
258
  summary: Tao UI