tao_popover 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/dist/tao_popover.js CHANGED
@@ -209,8 +209,6 @@
209
209
 
210
210
  Element.tag = 'tao-popover';
211
211
 
212
- Element.count = 0;
213
-
214
212
  Element.attribute('active', 'targetSelector', 'targetTraversal', 'boundarySelector', 'direction', 'arrowAlign', 'arrowVerticalAlign', {
215
213
  observe: true
216
214
  });
@@ -225,15 +223,10 @@
225
223
  });
226
224
 
227
225
  Element.prototype._init = function() {
228
- this.id || (this.id = "tao-popover-" + (++this.constructor.count));
229
- return this._render();
230
- };
231
-
232
- Element.prototype._render = function() {
233
226
  return this.jq.wrapInner('<div class="tao-popover-content">').append('<div class="tao-popover-arrow">\n <i class="arrow arrow-shadow"></i>\n <i class="arrow arrow-border"></i>\n <i class="arrow arrow-basic"></i>\n</div>');
234
227
  };
235
228
 
236
- Element.prototype._connect = function() {
229
+ Element.prototype._connected = function() {
237
230
  this._autoHideChanged();
238
231
  if (this.active) {
239
232
  return this.refresh();
@@ -261,7 +254,7 @@
261
254
  };
262
255
 
263
256
  Element.prototype._enableAutoHide = function() {
264
- return $(document).on("mousedown." + this.id, (function(_this) {
257
+ return $(document).on("mousedown.tao-popover-" + this.taoId, (function(_this) {
265
258
  return function(e) {
266
259
  var target;
267
260
  if (!_this.active) {
@@ -277,7 +270,7 @@
277
270
  };
278
271
 
279
272
  Element.prototype._disableAutoHide = function() {
280
- return $(document).off("mousedown." + this.id);
273
+ return $(document).off("mousedown.tao-popover-" + this.taoId);
281
274
  };
282
275
 
283
276
  Element.prototype.refresh = function() {
@@ -310,7 +303,7 @@
310
303
  return this.active = !this.active;
311
304
  };
312
305
 
313
- Element.prototype._disconnect = function() {
306
+ Element.prototype._disconnected = function() {
314
307
  return this._disableAutoHide();
315
308
  };
316
309
 
@@ -344,26 +337,26 @@
344
337
  "default": 'a, button'
345
338
  });
346
339
 
347
- Trigger.get('popover', function() {
348
- if (this._popover != null) {
349
- return this._popover;
340
+ Trigger.prototype._init = function() {
341
+ this.popover = this.jq.children('tao-popover').get(0);
342
+ this.popover.active = false;
343
+ this.popover.autoHide = this.triggerAction === 'click';
344
+ if (!this.popover.targetSelector) {
345
+ this.popover.targetSelector = '*';
350
346
  }
351
- this._popover = this.jq.children('tao-popover').get(0);
352
- this._popover.active = false;
353
- this._popover.autoHide = this.triggerAction === 'click';
354
- if (!this._popover.targetSelector) {
355
- this._popover.targetSelector = '*';
347
+ if (!this.popover.targetTraversal) {
348
+ return this.popover.targetTraversal = 'prev';
356
349
  }
357
- if (!this._popover.targetTraversal) {
358
- this._popover.targetTraversal = 'prev';
359
- }
360
- return this._popover;
361
- });
350
+ };
362
351
 
363
- Trigger.prototype._connect = function() {
352
+ Trigger.prototype._connected = function() {
364
353
  return this._bindTriggerEvent();
365
354
  };
366
355
 
356
+ Trigger.prototype._disconnected = function() {
357
+ return this.off('.tao-popover-trigger');
358
+ };
359
+
367
360
  Trigger.prototype._bindTriggerEvent = function() {
368
361
  this.off('.tao-popover-trigger');
369
362
  if (this.triggerAction === 'click') {
@@ -395,10 +388,6 @@
395
388
  return this._bindTriggerEvent();
396
389
  };
397
390
 
398
- Trigger.prototype._disconnect = function() {
399
- return this.off('.tao-popover-trigger');
400
- };
401
-
402
391
  return Trigger;
403
392
 
404
393
  })(TaoComponent);
@@ -7,8 +7,6 @@ class TaoPopover.Element extends TaoComponent
7
7
 
8
8
  @tag: 'tao-popover'
9
9
 
10
- @count: 0
11
-
12
10
  @attribute 'active', 'targetSelector', 'targetTraversal', 'boundarySelector', 'direction', 'arrowAlign', 'arrowVerticalAlign', observe: true
13
11
 
14
12
  @attribute 'offset', observe: true, default: 5
@@ -16,10 +14,6 @@ class TaoPopover.Element extends TaoComponent
16
14
  @attribute 'autoHide', default: true
17
15
 
18
16
  _init: ->
19
- @id ||= "tao-popover-#{++@constructor.count}"
20
- @_render()
21
-
22
- _render: ->
23
17
  @jq.wrapInner '<div class="tao-popover-content">'
24
18
  .append '''
25
19
  <div class="tao-popover-arrow">
@@ -29,7 +23,7 @@ class TaoPopover.Element extends TaoComponent
29
23
  </div>
30
24
  '''
31
25
 
32
- _connect: ->
26
+ _connected: ->
33
27
  @_autoHideChanged()
34
28
  @refresh() if @active
35
29
 
@@ -45,14 +39,14 @@ class TaoPopover.Element extends TaoComponent
45
39
  @_enableAutoHide() if @autoHide && @active
46
40
 
47
41
  _enableAutoHide: ->
48
- $(document).on "mousedown.#{@id}", (e) =>
42
+ $(document).on "mousedown.tao-popover-#{@taoId}", (e) =>
49
43
  return unless @active
50
44
  target = $ e.target
51
45
  return if target.is(@target) or @jq.has(target).length or target.is(@)
52
46
  @active = false
53
47
 
54
48
  _disableAutoHide: ->
55
- $(document).off "mousedown.#{@id}"
49
+ $(document).off "mousedown.tao-popover-#{@taoId}"
56
50
 
57
51
  refresh: ->
58
52
  @target = if @targetTraversal && @targetSelector
@@ -83,7 +77,7 @@ class TaoPopover.Element extends TaoComponent
83
77
  toggleActive: ->
84
78
  @active = !@active
85
79
 
86
- _disconnect: ->
80
+ _disconnected: ->
87
81
  @_disableAutoHide()
88
82
 
89
83
  TaoComponent.register TaoPopover.Element
@@ -8,20 +8,20 @@ class TaoPopover.Trigger extends TaoComponent
8
8
 
9
9
  @attribute 'triggerSelector', observe: true, default: 'a, button'
10
10
 
11
- @get 'popover', ->
12
- return @_popover if @_popover?
11
+ _init: ->
12
+ @popover = @jq.children('tao-popover').get(0)
13
+ @popover.active = false
14
+ @popover.autoHide = @triggerAction == 'click'
13
15
 
14
- @_popover = @jq.children('tao-popover').get(0)
15
- @_popover.active = false
16
- @_popover.autoHide = @triggerAction == 'click'
16
+ @popover.targetSelector = '*' unless @popover.targetSelector
17
+ @popover.targetTraversal = 'prev' unless @popover.targetTraversal
17
18
 
18
- @_popover.targetSelector = '*' unless @_popover.targetSelector
19
- @_popover.targetTraversal = 'prev' unless @_popover.targetTraversal
20
- @_popover
21
-
22
- _connect: ->
19
+ _connected: ->
23
20
  @_bindTriggerEvent()
24
21
 
22
+ _disconnected: ->
23
+ @off '.tao-popover-trigger'
24
+
25
25
  _bindTriggerEvent: ->
26
26
  @off '.tao-popover-trigger'
27
27
 
@@ -42,7 +42,5 @@ class TaoPopover.Trigger extends TaoComponent
42
42
  _triggerSelectorChanged: ->
43
43
  @_bindTriggerEvent()
44
44
 
45
- _disconnect: ->
46
- @off '.tao-popover-trigger'
47
45
 
48
46
  TaoComponent.register TaoPopover.Trigger
@@ -1,3 +1,3 @@
1
1
  module TaoPopover
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
data/tao_popover.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_runtime_dependency "tao_on_rails", '~> 0.5.0'
24
+ spec.add_runtime_dependency "tao_on_rails", '~> 0.6.1'
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.13"
27
27
  spec.add_development_dependency "rake", "~> 10.0"
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.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - farthinker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-12-27 00:00:00.000000000 Z
11
+ date: 2017-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tao_on_rails
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.5.0
19
+ version: 0.6.1
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.5.0
26
+ version: 0.6.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement