luda 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/assets/javascripts/luda-degradation.js +2 -2
  3. data/assets/javascripts/luda-degradation.min.js +2 -2
  4. data/assets/javascripts/luda-sprockets.js +2 -2
  5. data/assets/javascripts/luda.js +719 -250
  6. data/assets/javascripts/luda.js.map +1 -1
  7. data/assets/javascripts/luda.min.js +3 -3
  8. data/assets/javascripts/luda.min.js.map +1 -1
  9. data/assets/javascripts/luda/behaviors/{enter-click.js → enter.js} +8 -6
  10. data/assets/javascripts/luda/behaviors/focus.js +14 -8
  11. data/assets/javascripts/luda/behaviors/readonly.js +4 -4
  12. data/assets/javascripts/luda/behaviors/{radio-tab.js → tabulate.js} +8 -6
  13. data/assets/javascripts/luda/behaviors/toggle.js +72 -18
  14. data/assets/javascripts/luda/dom.js +62 -0
  15. data/assets/javascripts/luda/elements/form-file.js +13 -4
  16. data/assets/javascripts/luda/elements/form-select.js +9 -5
  17. data/assets/javascripts/luda/event.js +11 -3
  18. data/assets/javascripts/luda/{component.js → factory.js} +149 -55
  19. data/assets/javascripts/luda/index.js +4 -4
  20. data/assets/javascripts/luda/install.js +2 -2
  21. data/assets/javascripts/luda/patterns/carousel.js +85 -59
  22. data/assets/javascripts/luda/patterns/dropdown.js +86 -68
  23. data/assets/javascripts/luda/patterns/form-dropdown.js +8 -8
  24. data/assets/javascripts/luda/patterns/tab.js +62 -23
  25. data/assets/javascripts/luda/static.js +224 -0
  26. data/assets/stylesheets/luda/_core/_functions.sass +11 -19
  27. data/assets/stylesheets/luda/_core/_variables.sass +140 -131
  28. data/assets/stylesheets/luda/_core/behaviors/_focus.sass +2 -2
  29. data/assets/stylesheets/luda/_core/elements/_button.sass +1 -1
  30. data/assets/stylesheets/luda/_core/elements/_grid.sass +0 -3
  31. data/assets/stylesheets/luda/_core/elements/_scrollbar.sass +8 -2
  32. data/assets/stylesheets/luda/_core/elements/form/_form-check-radio.sass +22 -31
  33. data/assets/stylesheets/luda/_core/elements/form/_form-element.sass +1 -1
  34. data/assets/stylesheets/luda/_core/elements/form/_form-helper.sass +19 -19
  35. data/assets/stylesheets/luda/_core/elements/form/_form-range.sass +19 -19
  36. data/assets/stylesheets/luda/_core/elements/form/_form-row.sass +43 -59
  37. data/assets/stylesheets/luda/_core/elements/typography/_quote.sass +1 -1
  38. data/assets/stylesheets/luda/_core/elements/typography/_typography.sass +9 -9
  39. data/assets/stylesheets/luda/_core/mixins/_dropdown.sass +8 -6
  40. data/assets/stylesheets/luda/_core/mixins/_form.sass +12 -12
  41. data/assets/stylesheets/luda/_core/mixins/_media-query.sass +12 -12
  42. data/assets/stylesheets/luda/_core/mixins/_typography.sass +4 -4
  43. data/assets/stylesheets/luda/_core/patterns/_breadcrumb.sass +2 -2
  44. data/assets/stylesheets/luda/_core/patterns/_button-group.sass +1 -1
  45. data/assets/stylesheets/luda/_core/patterns/_button-icon.sass +2 -2
  46. data/assets/stylesheets/luda/_core/patterns/_carousel.sass +13 -13
  47. data/assets/stylesheets/luda/_core/patterns/_dropdown.sass +5 -1
  48. data/assets/stylesheets/luda/_core/patterns/_form-dropdown.sass +3 -3
  49. data/assets/stylesheets/luda/_core/patterns/_form-group.sass +11 -11
  50. data/assets/stylesheets/luda/_core/patterns/_form-icon.sass +13 -19
  51. data/assets/stylesheets/luda/_core/patterns/_navigation.sass +5 -5
  52. data/assets/stylesheets/luda/_core/patterns/_search-bar.sass +2 -2
  53. data/assets/stylesheets/luda/_core/patterns/_tab.sass +1 -3
  54. data/assets/stylesheets/luda/_core/utilities/_border.sass +15 -15
  55. data/assets/stylesheets/luda/_core/utilities/_color.sass +4 -1
  56. data/assets/stylesheets/luda/_core/utilities/_display.sass +1 -1
  57. data/assets/stylesheets/luda/_core/utilities/_flex.sass +3 -0
  58. data/assets/stylesheets/luda/_core/utilities/_shadow.sass +12 -12
  59. data/assets/stylesheets/luda/_core/utilities/_spacing.sass +227 -0
  60. data/assets/stylesheets/luda/_core/utilities/_visibility.sass +1 -1
  61. data/assets/stylesheets/luda/_default.sass +1 -1
  62. data/assets/stylesheets/luda/default/_banner.sass +2 -2
  63. data/assets/stylesheets/luda/default/index.sass +1 -1
  64. data/assets/stylesheets/luda/default/utilities/_border.sass +4 -4
  65. data/assets/stylesheets/luda/default/utilities/_shadow.sass +4 -4
  66. data/assets/stylesheets/luda/default/utilities/_spacing.sass +5 -0
  67. data/lib/luda/version.rb +1 -1
  68. metadata +9 -11
  69. data/assets/javascripts/luda/singleton.js +0 -77
  70. data/assets/stylesheets/luda/_core/patterns/_form-button.sass +0 -23
  71. data/assets/stylesheets/luda/_core/patterns/_nav.sass +0 -165
  72. data/assets/stylesheets/luda/default/patterns/_form-button.sass +0 -9
  73. data/assets/stylesheets/luda/default/patterns/_nav.sass +0 -10
@@ -2,57 +2,65 @@
2
2
  //= require ../constants
3
3
  //= require ../dom
4
4
  //= require ../event
5
- //= require ../component
5
+ //= require ../factory
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../install.js'), require('../constants.js'), require('../dom.js'), require('../event.js'), require('../component.js')) :
8
- typeof define === 'function' && define.amd ? define(['../install.js', '../constants.js', '../dom.js', '../event.js', '../component.js'], factory) :
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../install.js'), require('../constants.js'), require('../dom.js'), require('../event.js'), require('../factory.js')) :
8
+ typeof define === 'function' && define.amd ? define(['../install.js', '../constants.js', '../dom.js', '../event.js', '../factory.js'], factory) :
9
9
  (factory());
10
10
  }(this, (function () { 'use strict';
11
11
 
12
12
  luda((function() {
13
13
  var _Class;
14
14
 
15
- _Class = class extends luda.Component {
16
- active() {
15
+ _Class = class extends luda.Factory {
16
+ activate() {
17
17
  var ref;
18
- if (!this._actived()) {
19
- this._$component.classList.add(this.constructor._ACTIVE_CSS_CLASS);
20
- this.constructor._$focused.push(document.activeElement);
21
- if ((ref = this._parent) != null) {
22
- ref.active();
23
- }
24
- return luda.dispatch(this._$component, this.constructor._ACTIVED_EVENT_TYPE);
18
+ if (this._isActive() || this._isTransitioning()) {
19
+ return;
20
+ }
21
+ if (this._activatePrevented(this._$menu)) {
22
+ return;
25
23
  }
24
+ this._$component.classList.add(this.constructor._ACTIVE_CSS_CLASS);
25
+ this.constructor._$focused.push(document.activeElement);
26
+ if ((ref = this._parent) != null) {
27
+ ref.activate();
28
+ }
29
+ return this._handleActivateEnd(this._$menu);
26
30
  }
27
31
 
28
- deactive(focus) {
32
+ deactivate(focus) {
29
33
  var ref;
30
- if (this._actived()) {
31
- this._$component.classList.remove(this.constructor._ACTIVE_CSS_CLASS);
32
- this._children.forEach(function(child) {
33
- return child.deactive();
34
- });
35
- if (focus) {
36
- if ((ref = this.constructor._$focused[this.constructor._$focused.length - 1]) != null) {
37
- ref.focus();
38
- }
34
+ if (!(this._isActive() && !this._isTransitioning())) {
35
+ return;
36
+ }
37
+ if (this._deactivatePrevented(this._$menu)) {
38
+ return;
39
+ }
40
+ this._$component.classList.remove(this.constructor._ACTIVE_CSS_CLASS);
41
+ this._children.forEach(function(child) {
42
+ return child.deactivate();
43
+ });
44
+ if (focus) {
45
+ if ((ref = this.constructor._$focused[this.constructor._$focused.length - 1]) != null) {
46
+ ref.focus();
39
47
  }
40
- this.constructor._$focused.splice(this.constructor._$focused.length - 1, 1);
41
- return luda.dispatch(this._$component, this.constructor._DEACTIVED_EVENT_TYPE);
42
48
  }
49
+ this.constructor._$focused.splice(this.constructor._$focused.length - 1, 1);
50
+ return this._handleDeactivateEnd(this._$menu);
43
51
  }
44
52
 
45
53
  toggle(focus) {
46
- if (this._actived()) {
47
- return this.deactive(focus);
54
+ if (this._isActive()) {
55
+ return this.deactivate(focus);
48
56
  } else {
49
- return this.active();
57
+ return this.activate();
50
58
  }
51
59
  }
52
60
 
53
- prev() {
61
+ _prev() {
54
62
  var focusIndex;
55
- if (this._$items.length && this._actived()) {
63
+ if (this._$items.length && this._isActive()) {
56
64
  focusIndex = this._$items.indexOf(document.activeElement) - 1;
57
65
  if (focusIndex < 0) {
58
66
  focusIndex = 0;
@@ -61,9 +69,9 @@
61
69
  }
62
70
  }
63
71
 
64
- next() {
72
+ _next() {
65
73
  var focusIndex;
66
- if (this._$items.length && this._actived()) {
74
+ if (this._$items.length && this._isActive()) {
67
75
  focusIndex = this._$items.indexOf(document.activeElement) + 1;
68
76
  if (focusIndex > this._$items.length - 1) {
69
77
  focusIndex = this._$items.length - 1;
@@ -79,41 +87,55 @@
79
87
  _$noneSwitches = luda.$unnested(this.constructor._NONE_SWITCHES_SELECTOR, this._$component, this.constructor._SELECTOR).concat(luda.$unnested(this.constructor._NONE_SWITCHES_SELECTOR, _$menu, this.constructor._MENU_SELECTOR));
80
88
  _$items = luda.$unnested(this.constructor._ITEMS_SELECTOR, _$menu, this.constructor._MENU_SELECTOR);
81
89
  _isStandalone = this._$component.hasAttribute(this.constructor._STANDALONE_ATTRIBUTE);
82
- return {_$items, _$switches, _$noneSwitches, _isStandalone};
90
+ return {_$menu, _$items, _$switches, _$noneSwitches, _isStandalone};
83
91
  }
84
92
 
85
93
  _constructor() {
86
- return ({_$items: this._$items, _$switches: this._$switches, _$noneSwitches: this._$noneSwitches, _isStandalone: this._isStandalone} = this._getConfig());
94
+ this._onMutations();
95
+ this._handleActivateCancel(this._$menu);
96
+ return this._handleDeactivateCancel(this._$menu);
87
97
  }
88
98
 
89
99
  _onMutations(mutations) {
90
- return this._constructor();
100
+ return ({_$menu: this._$menu, _$items: this._$items, _$switches: this._$switches, _$noneSwitches: this._$noneSwitches, _isStandalone: this._isStandalone} = this._getConfig());
91
101
  }
92
102
 
93
- _actived() {
103
+ _isActive() {
94
104
  return this._$component.classList.contains(this.constructor._ACTIVE_CSS_CLASS);
95
105
  }
96
106
 
97
- _deactiveChildrenExcept(exceptions) {
107
+ _deactivateChildrenExcept(exceptions) {
98
108
  if (exceptions && !(exceptions instanceof Array)) {
99
109
  exceptions = [exceptions];
100
110
  }
101
111
  if (exceptions) {
102
112
  return this._children.forEach(function(child) {
103
- if (child._actived() && !exceptions.includes(child)) {
104
- return child.deactive();
113
+ if (child._isActive() && !exceptions.includes(child)) {
114
+ return child.deactivate();
105
115
  }
106
116
  });
107
117
  } else {
108
118
  return this._children.forEach(function(child) {
109
- if (child._actived()) {
110
- return child.deactive();
119
+ if (child._isActive()) {
120
+ return child.deactivate();
111
121
  }
112
122
  });
113
123
  }
114
124
  }
115
125
 
116
- static deactiveExcept(instances$dropdowns) {
126
+ static activate($dropdown) {
127
+ return this.query($dropdown).activate();
128
+ }
129
+
130
+ static deactivate($dropdown, focus) {
131
+ return this.query($dropdown).deactivate(focus);
132
+ }
133
+
134
+ static toggle($dropdown, focus) {
135
+ return this.query($dropdown).toggle(focus);
136
+ }
137
+
138
+ static deactivateExcept(instances$dropdowns) {
117
139
  var exceptions;
118
140
  exceptions = [];
119
141
  if (instances$dropdowns && !(instances$dropdowns instanceof Array)) {
@@ -134,14 +156,14 @@
134
156
  instanceHasntExceptionChild = exceptions.every(function(exception) {
135
157
  return !instance._hasDescendant(exception);
136
158
  });
137
- if (instance._actived() && instanceIsntInExceptions && instanceHasntExceptionChild) {
138
- return instance.deactive();
159
+ if (instance._isActive() && instanceIsntInExceptions && instanceHasntExceptionChild) {
160
+ return instance.deactivate();
139
161
  }
140
162
  });
141
163
  } else {
142
164
  return this._instances.forEach(function(instance) {
143
- if (instance._actived()) {
144
- return instance.deactive();
165
+ if (instance._isActive()) {
166
+ return instance.deactivate();
145
167
  }
146
168
  });
147
169
  }
@@ -159,17 +181,17 @@
159
181
  var self;
160
182
  self = this;
161
183
  luda.onOpposite('click', this._SELECTOR, function(e) {
162
- return self.deactiveExcept(self._standaloneInstances());
184
+ return self.deactivateExcept(self._standaloneInstances());
163
185
  });
164
186
  luda.on('click', this._SELECTOR, function(e) {
165
187
  var focus, instance, toggleChecked;
166
188
  if (instance = self.query(this)) {
167
189
  toggleChecked = false;
168
190
  focus = !e.detail;
169
- self.deactiveExcept(self._standaloneInstances().concat(instance));
170
- instance._deactiveChildrenExcept();
191
+ self.deactivateExcept(self._standaloneInstances().concat(instance));
192
+ instance._deactivateChildrenExcept();
171
193
  if (instance._parent) {
172
- instance._parent._deactiveChildrenExcept(instance);
194
+ instance._parent._deactivateChildrenExcept(instance);
173
195
  }
174
196
  if (instance._$switches.length || instance._$noneSwitches.length) {
175
197
  luda.eventPath(e).some(function($path) {
@@ -187,23 +209,23 @@
187
209
  }
188
210
  });
189
211
  luda.onOpposite('keyup', this._SELECTOR, function(e) {
190
- return self.deactiveExcept();
212
+ return self.deactivateExcept();
191
213
  });
192
214
  luda.on('keyup', this._SELECTOR, function(e) {
193
215
  var instance;
194
216
  if (e.keyCode === luda.KEY_TAB && (instance = self.query(this))) {
195
- self.deactiveExcept(instance);
196
- return instance.active();
217
+ self.deactivateExcept(instance);
218
+ return instance.activate();
197
219
  }
198
220
  });
199
221
  luda.on('keydown', this._SELECTOR, function(e) {
200
222
  var instance, ref;
201
223
  if (e.keyCode === luda.KEY_ESC && (instance = self.query(this))) {
202
224
  e.preventDefault();
203
- if (instance._actived()) {
204
- return instance.deactive(true);
225
+ if (instance._isActive()) {
226
+ return instance.deactivate(true);
205
227
  } else {
206
- return (ref = instance._parent) != null ? ref.deactive(true) : void 0;
228
+ return (ref = instance._parent) != null ? ref.deactivate(true) : void 0;
207
229
  }
208
230
  }
209
231
  });
@@ -211,17 +233,17 @@
211
233
  var instance, ref, ref1;
212
234
  if ([luda.KEY_LEFT, luda.KEY_UP].includes(e.keyCode) && (instance = self.query(this))) {
213
235
  e.preventDefault();
214
- if (instance._actived()) {
215
- return instance.prev();
236
+ if (instance._isActive()) {
237
+ return instance._prev();
216
238
  } else {
217
- return (ref = instance._parent) != null ? ref.prev() : void 0;
239
+ return (ref = instance._parent) != null ? ref._prev() : void 0;
218
240
  }
219
241
  } else if ([luda.KEY_RIGHT, luda.KEY_DOWN].includes(e.keyCode) && (instance = self.query(this))) {
220
242
  e.preventDefault();
221
- if (instance._actived()) {
222
- return instance.next();
243
+ if (instance._isActive()) {
244
+ return instance._next();
223
245
  } else {
224
- return (ref1 = instance._parent) != null ? ref1.next() : void 0;
246
+ return (ref1 = instance._parent) != null ? ref1._next() : void 0;
225
247
  }
226
248
  }
227
249
  });
@@ -239,25 +261,21 @@
239
261
 
240
262
  _Class._TOGGLE_ATTRIBUTE = 'data-dropdown-toggle';
241
263
 
242
- _Class._NONE_TOGGLE_ATTRIBUTE = 'data-dropdown-toggle-disabled';
264
+ _Class._TOGGLE_DISABLED_ATTRIBUTE = 'data-dropdown-toggle-disabled';
243
265
 
244
266
  _Class._STANDALONE_ATTRIBUTE = 'data-dropdown-standalone';
245
267
 
246
268
  _Class._SWITCHES_SELECTOR = `[${_Class._TOGGLE_ATTRIBUTE}]`;
247
269
 
248
- _Class._NONE_SWITCHES_SELECTOR = `[${_Class._NONE_TOGGLE_ATTRIBUTE}]`;
270
+ _Class._NONE_SWITCHES_SELECTOR = `[${_Class._TOGGLE_DISABLED_ATTRIBUTE}]`;
249
271
 
250
272
  _Class._ACTIVE_CSS_CLASS = 'dropdown-active';
251
273
 
252
- _Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
253
-
254
- _Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
255
-
256
274
  _Class._observerConfig = {
257
275
  childList: true,
258
276
  attributes: true,
259
277
  subtree: true,
260
- attributeFilter: [_Class._TOGGLE_ATTRIBUTE, _Class._NONE_TOGGLE_ATTRIBUTE, _Class._STANDALONE_ATTRIBUTE]
278
+ attributeFilter: [_Class._TOGGLE_ATTRIBUTE, _Class._TOGGLE_DISABLED_ATTRIBUTE, _Class._STANDALONE_ATTRIBUTE]
261
279
  };
262
280
 
263
281
  _Class._$focused = [];
@@ -1,19 +1,19 @@
1
1
  //= require ../install
2
2
  //= require ../dom
3
3
  //= require ../event
4
- //= require ../component
4
+ //= require ../factory
5
5
  //= require ../behaviors/focus
6
- //= require ../behaviors/enter-click
6
+ //= require ../behaviors/enter
7
7
  (function (global, factory) {
8
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../install.js'), require('../dom.js'), require('../event.js'), require('../component.js'), require('../behaviors/focus.js'), require('../behaviors/enter-click.js')) :
9
- typeof define === 'function' && define.amd ? define(['../install.js', '../dom.js', '../event.js', '../component.js', '../behaviors/focus.js', '../behaviors/enter-click.js'], factory) :
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../install.js'), require('../dom.js'), require('../event.js'), require('../factory.js'), require('../behaviors/focus.js'), require('../behaviors/enter.js')) :
9
+ typeof define === 'function' && define.amd ? define(['../install.js', '../dom.js', '../event.js', '../factory.js', '../behaviors/focus.js', '../behaviors/enter.js'], factory) :
10
10
  (factory());
11
11
  }(this, (function () { 'use strict';
12
12
 
13
13
  luda((function() {
14
14
  var _Class;
15
15
 
16
- _Class = class extends luda.Component {
16
+ _Class = class extends luda.Factory {
17
17
  _getConfig() {
18
18
  var _$defaultValues, _$valueHolder, _$values;
19
19
  _$values = luda.$children(this.constructor._VALUE_SELECTOR, this._$component);
@@ -62,7 +62,7 @@
62
62
  static _init() {
63
63
  var self;
64
64
  self = this;
65
- luda.enterClick._add(this._ENTER_CLICK_VALUE_HOLDER_SELECTOR);
65
+ luda.enter._add(this._ENTER_BEHAVIOR_SELECTOR);
66
66
  luda.on('change', `${this._SELECTOR} ${this._VALUE_SELECTOR}`, function(e) {
67
67
  return self.query(luda.$parent(self._SELECTOR, this))._setValueHolderValue();
68
68
  });
@@ -73,7 +73,7 @@
73
73
  });
74
74
  // prevent ios device pop out wired navigation pannel
75
75
  if (/iphone/i.test(navigator.userAgent) || /ipad/i.test(navigator.userAgent)) {
76
- return luda.on('focusin', this._ENTER_CLICK_VALUE_HOLDER_SELECTOR, function(e) {
76
+ return luda.on('focusin', this._ENTER_BEHAVIOR_SELECTOR, function(e) {
77
77
  this.blur();
78
78
  return this.classList.add(luda.focus._CSS_CLASS);
79
79
  });
@@ -96,7 +96,7 @@
96
96
 
97
97
  _Class._VALUE_HOLDER_SELECTOR = '.fm input';
98
98
 
99
- _Class._ENTER_CLICK_VALUE_HOLDER_SELECTOR = '.fm-dropdown .fm input';
99
+ _Class._ENTER_BEHAVIOR_SELECTOR = '.fm-dropdown .fm input';
100
100
 
101
101
  _Class._observerConfig = {
102
102
  childList: true,
@@ -1,26 +1,29 @@
1
1
  //= require ../install
2
2
  //= require ../dom
3
3
  //= require ../event
4
- //= require ../component
4
+ //= require ../factory
5
5
  (function (global, factory) {
6
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../install.js'), require('../dom.js'), require('../event.js'), require('../component.js')) :
7
- typeof define === 'function' && define.amd ? define(['../install.js', '../dom.js', '../event.js', '../component.js'], factory) :
6
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../install.js'), require('../dom.js'), require('../event.js'), require('../factory.js')) :
7
+ typeof define === 'function' && define.amd ? define(['../install.js', '../dom.js', '../event.js', '../factory.js'], factory) :
8
8
  (factory());
9
9
  }(this, (function () { 'use strict';
10
10
 
11
11
  luda((function() {
12
12
  var _Class;
13
13
 
14
- _Class = class extends luda.Component {
14
+ _Class = class extends luda.Factory {
15
15
 
16
16
  // public
17
- active(index) {
18
- var activedIndex;
19
- if (this._$panes.length) {
20
- activedIndex = this._activeIndex;
17
+ activate(index) {
18
+ var activatedIndex;
19
+ if (this._$panes.length && !this._isTransitioning()) {
20
+ activatedIndex = this._activeIndex;
21
21
  if ((index != null) && index !== this._activeIndex && (0 <= index && index <= this._$panes.length - 1)) {
22
+ if (!this._canTransition(index, activatedIndex)) {
23
+ return;
24
+ }
22
25
  this._activeIndex = index;
23
- return this._active(activedIndex);
26
+ return this._activate(activatedIndex);
24
27
  }
25
28
  }
26
29
  }
@@ -42,38 +45,77 @@
42
45
 
43
46
  _constructor() {
44
47
  ({_$panes: this._$panes, _$indicators: this._$indicators, _activeIndex: this._activeIndex} = this._getConfig());
45
- return this._active();
48
+ this._layout();
49
+ return this._handleTransitionCancel();
46
50
  }
47
51
 
48
52
  _onMutations(mutations) {
49
- return this._constructor();
53
+ ({_$panes: this._$panes, _$indicators: this._$indicators, _activeIndex: this._activeIndex} = this._getConfig());
54
+ return this._setIndicatorsState();
50
55
  }
51
56
 
52
- _active(activedIndex) {
57
+ _layout() {
53
58
  this._$panes.forEach(($pane, index) => {
59
+ $pane.style.transition = 'none';
54
60
  if (index === this._activeIndex) {
55
61
  $pane.classList.add(this.constructor._PANE_ACTIVE_CSS_CLASS);
56
- return luda.dispatch($pane, this.constructor._ACTIVED_EVENT_TYPE, index);
57
62
  } else {
58
63
  $pane.classList.remove(this.constructor._PANE_ACTIVE_CSS_CLASS);
59
- if (index === activedIndex) {
60
- return luda.dispatch($pane, this.constructor._DEACTIVED_EVENT_TYPE, index);
61
- }
62
64
  }
65
+ luda.reflow($pane);
66
+ return $pane.style.transition = '';
63
67
  });
64
68
  return this._setIndicatorsState();
65
69
  }
66
70
 
71
+ _activate(activatedIndex) {
72
+ var $activatedPane, $pane;
73
+ $pane = this._$panes[this._activeIndex];
74
+ $activatedPane = this._$panes[activatedIndex];
75
+ $pane.classList.add(this.constructor._PANE_ACTIVE_CSS_CLASS);
76
+ $activatedPane.classList.remove(this.constructor._PANE_ACTIVE_CSS_CLASS);
77
+ this._handleTransitionEnd(this._activeIndex, activatedIndex);
78
+ return this._setIndicatorsState();
79
+ }
80
+
81
+ _canTransition(activeIndex, activatedIndex) {
82
+ return !this._activatePrevented(this._$panes[activeIndex], activeIndex) && !this._deactivatePrevented(this._$panes[activatedIndex], activatedIndex);
83
+ }
84
+
85
+ _handleTransitionEnd(activeIndex, activatedIndex) {
86
+ var activateDuration, deactivateDuration;
87
+ activateDuration = this._handleActivateEnd(this._$panes[activeIndex], activeIndex);
88
+ return deactivateDuration = this._handleDeactivateEnd(this._$panes[activatedIndex], activatedIndex);
89
+ }
90
+
91
+ _handleTransitionCancel() {
92
+ var activatedIndex, index;
93
+ if (this._isActivating()) {
94
+ index = parseInt(this._getActivatingMark(), 10);
95
+ this._handleActivateCancel(this._$panes[index], index);
96
+ }
97
+ if (this._isDeactivating()) {
98
+ activatedIndex = parseInt(this._getDeactivatingMark(), 10);
99
+ return this._handleDeactivateCancel(this._$panes[activatedIndex], activatedIndex);
100
+ }
101
+ }
102
+
67
103
  _setIndicatorsState() {
68
104
  return this._$indicators.forEach(($indicator, index) => {
69
105
  if (index === this._activeIndex) {
70
- return $indicator.setAttribute('checked', '');
106
+ $indicator.setAttribute('checked', '');
107
+ return $indicator.checked = true;
71
108
  } else {
72
- return $indicator.removeAttribute('checked');
109
+ $indicator.removeAttribute('checked');
110
+ return $indicator.checked = false;
73
111
  }
74
112
  });
75
113
  }
76
114
 
115
+ static activate($tab, index) {
116
+ return this.query($tab).activate(index);
117
+ }
118
+
77
119
  // static private
78
120
  static _init() {
79
121
  var self;
@@ -82,7 +124,8 @@
82
124
  var instance;
83
125
  if (this.checked) {
84
126
  instance = self.query(luda.$parent(self._SELECTOR, this));
85
- return instance.active(instance._$indicators.indexOf(this));
127
+ instance._setIndicatorsState();
128
+ return instance.activate(instance._$indicators.indexOf(this));
86
129
  }
87
130
  });
88
131
  }
@@ -101,10 +144,6 @@
101
144
 
102
145
  _Class._ACTIVE_INDEX = 0;
103
146
 
104
- _Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
105
-
106
- _Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
107
-
108
147
  _Class._observerConfig = {
109
148
  childList: true,
110
149
  subtree: true