luda 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +5 -0
- data/assets/javascripts/luda-degradation.js +131 -0
- data/assets/javascripts/luda-degradation.js.map +1 -0
- data/assets/javascripts/luda-degradation.min.js +7 -0
- data/assets/javascripts/luda-degradation.min.js.map +1 -0
- data/assets/javascripts/luda-sprockets.js +11 -0
- data/assets/javascripts/luda.js +2024 -0
- data/assets/javascripts/luda.js.map +1 -0
- data/assets/javascripts/luda.min.js +7 -0
- data/assets/javascripts/luda.min.js.map +1 -0
- data/assets/javascripts/luda/behaviours/enter-click.js +38 -0
- data/assets/javascripts/luda/behaviours/focus.js +103 -0
- data/assets/javascripts/luda/behaviours/radio-tab.js +69 -0
- data/assets/javascripts/luda/behaviours/readonly.js +57 -0
- data/assets/javascripts/luda/behaviours/toggle.js +104 -0
- data/assets/javascripts/luda/collections/carousel.js +314 -0
- data/assets/javascripts/luda/collections/dropdown.js +269 -0
- data/assets/javascripts/luda/collections/form-dropdown.js +112 -0
- data/assets/javascripts/luda/collections/tab.js +117 -0
- data/assets/javascripts/luda/component.js +240 -0
- data/assets/javascripts/luda/constants.js +18 -0
- data/assets/javascripts/luda/degradation.js +125 -0
- data/assets/javascripts/luda/dom.js +81 -0
- data/assets/javascripts/luda/elements/form-file.js +104 -0
- data/assets/javascripts/luda/elements/form-select.js +212 -0
- data/assets/javascripts/luda/event.js +193 -0
- data/assets/javascripts/luda/index.js +20 -0
- data/assets/javascripts/luda/install.js +75 -0
- data/assets/javascripts/luda/singleton.js +77 -0
- data/assets/javascripts/luda/utilities.js +16 -0
- data/assets/stylesheets/luda/_core/_base.sass +430 -0
- data/assets/stylesheets/luda/_core/_functions.sass +240 -0
- data/assets/stylesheets/luda/_core/_variables.sass +710 -0
- data/assets/stylesheets/luda/_core/behaviours/_disabled.sass +12 -0
- data/assets/stylesheets/luda/_core/behaviours/_focus.sass +7 -0
- data/assets/stylesheets/luda/_core/behaviours/_readonly.sass +16 -0
- data/assets/stylesheets/luda/_core/behaviours/_toggle.sass +4 -0
- data/assets/stylesheets/luda/_core/collections/_alert.sass +24 -0
- data/assets/stylesheets/luda/_core/collections/_avatar.sass +117 -0
- data/assets/stylesheets/luda/_core/collections/_breadcrumb.sass +21 -0
- data/assets/stylesheets/luda/_core/collections/_button-group.sass +67 -0
- data/assets/stylesheets/luda/_core/collections/_button-icon.sass +46 -0
- data/assets/stylesheets/luda/_core/collections/_carousel.sass +132 -0
- data/assets/stylesheets/luda/_core/collections/_dropdown.sass +60 -0
- data/assets/stylesheets/luda/_core/collections/_form-button.sass +23 -0
- data/assets/stylesheets/luda/_core/collections/_form-dropdown.sass +21 -0
- data/assets/stylesheets/luda/_core/collections/_form-group.sass +48 -0
- data/assets/stylesheets/luda/_core/collections/_form-icon.sass +71 -0
- data/assets/stylesheets/luda/_core/collections/_media.sass +55 -0
- data/assets/stylesheets/luda/_core/collections/_modal.sass +12 -0
- data/assets/stylesheets/luda/_core/collections/_nav.sass +162 -0
- data/assets/stylesheets/luda/_core/collections/_tab.sass +18 -0
- data/assets/stylesheets/luda/_core/elements/_badge.sass +19 -0
- data/assets/stylesheets/luda/_core/elements/_baseline.sass +22 -0
- data/assets/stylesheets/luda/_core/elements/_button.sass +136 -0
- data/assets/stylesheets/luda/_core/elements/_container.sass +8 -0
- data/assets/stylesheets/luda/_core/elements/_grid.sass +55 -0
- data/assets/stylesheets/luda/_core/elements/_icon.sass +110 -0
- data/assets/stylesheets/luda/_core/elements/_overlay.sass +11 -0
- data/assets/stylesheets/luda/_core/elements/_progress.sass +31 -0
- data/assets/stylesheets/luda/_core/elements/_scrollbar.sass +21 -0
- data/assets/stylesheets/luda/_core/elements/_table.sass +102 -0
- data/assets/stylesheets/luda/_core/elements/_turbolinks-progress-bar.sass +5 -0
- data/assets/stylesheets/luda/_core/elements/form/_form-check-radio.sass +105 -0
- data/assets/stylesheets/luda/_core/elements/form/_form-element.sass +83 -0
- data/assets/stylesheets/luda/_core/elements/form/_form-helper.sass +66 -0
- data/assets/stylesheets/luda/_core/elements/form/_form-label.sass +20 -0
- data/assets/stylesheets/luda/_core/elements/form/_form-range.sass +92 -0
- data/assets/stylesheets/luda/_core/elements/form/_form-row.sass +214 -0
- data/assets/stylesheets/luda/_core/elements/typography/_code.sass +27 -0
- data/assets/stylesheets/luda/_core/elements/typography/_link.sass +15 -0
- data/assets/stylesheets/luda/_core/elements/typography/_list.sass +14 -0
- data/assets/stylesheets/luda/_core/elements/typography/_mark.sass +7 -0
- data/assets/stylesheets/luda/_core/elements/typography/_quote.sass +68 -0
- data/assets/stylesheets/luda/_core/elements/typography/_sub-sup.sass +16 -0
- data/assets/stylesheets/luda/_core/elements/typography/_typography.sass +52 -0
- data/assets/stylesheets/luda/_core/mixins/_browser.sass +15 -0
- data/assets/stylesheets/luda/_core/mixins/_button.sass +90 -0
- data/assets/stylesheets/luda/_core/mixins/_dropdown.sass +40 -0
- data/assets/stylesheets/luda/_core/mixins/_focus.sass +3 -0
- data/assets/stylesheets/luda/_core/mixins/_form.sass +27 -0
- data/assets/stylesheets/luda/_core/mixins/_install.sass +7 -0
- data/assets/stylesheets/luda/_core/mixins/_media-query.sass +66 -0
- data/assets/stylesheets/luda/_core/mixins/_overlay.sass +14 -0
- data/assets/stylesheets/luda/_core/mixins/_sass-lint-fix.sass +3 -0
- data/assets/stylesheets/luda/_core/mixins/_typography.sass +40 -0
- data/assets/stylesheets/luda/_core/utilities/_align.sass +19 -0
- data/assets/stylesheets/luda/_core/utilities/_background.sass +88 -0
- data/assets/stylesheets/luda/_core/utilities/_color.sass +36 -0
- data/assets/stylesheets/luda/_core/utilities/_display.sass +40 -0
- data/assets/stylesheets/luda/_core/utilities/_flex.sass +114 -0
- data/assets/stylesheets/luda/_core/utilities/_float.sass +21 -0
- data/assets/stylesheets/luda/_core/utilities/_opacity.sass +19 -0
- data/assets/stylesheets/luda/_core/utilities/_overflow.sass +18 -0
- data/assets/stylesheets/luda/_core/utilities/_position.sass +48 -0
- data/assets/stylesheets/luda/_core/utilities/_shape.sass +62 -0
- data/assets/stylesheets/luda/_core/utilities/_size.sass +67 -0
- data/assets/stylesheets/luda/_core/utilities/_space.sass +227 -0
- data/assets/stylesheets/luda/_core/utilities/_text.sass +85 -0
- data/assets/stylesheets/luda/_core/utilities/_visibility.sass +11 -0
- data/assets/stylesheets/luda/_core/utilities/_z-index.sass +19 -0
- data/assets/stylesheets/luda/_default.sass +51 -0
- data/assets/stylesheets/luda/core/_base.sass +430 -0
- data/assets/stylesheets/luda/core/_functions.sass +240 -0
- data/assets/stylesheets/luda/core/_variables.sass +710 -0
- data/assets/stylesheets/luda/core/behaviours/_disabled.sass +12 -0
- data/assets/stylesheets/luda/core/behaviours/_focus.sass +7 -0
- data/assets/stylesheets/luda/core/behaviours/_readonly.sass +16 -0
- data/assets/stylesheets/luda/core/behaviours/_toggle.sass +4 -0
- data/assets/stylesheets/luda/core/collections/_alert.sass +24 -0
- data/assets/stylesheets/luda/core/collections/_avatar.sass +117 -0
- data/assets/stylesheets/luda/core/collections/_breadcrumb.sass +21 -0
- data/assets/stylesheets/luda/core/collections/_button-group.sass +67 -0
- data/assets/stylesheets/luda/core/collections/_button-icon.sass +46 -0
- data/assets/stylesheets/luda/core/collections/_carousel.sass +132 -0
- data/assets/stylesheets/luda/core/collections/_dropdown.sass +60 -0
- data/assets/stylesheets/luda/core/collections/_form-button.sass +23 -0
- data/assets/stylesheets/luda/core/collections/_form-dropdown.sass +21 -0
- data/assets/stylesheets/luda/core/collections/_form-group.sass +48 -0
- data/assets/stylesheets/luda/core/collections/_form-icon.sass +71 -0
- data/assets/stylesheets/luda/core/collections/_media.sass +55 -0
- data/assets/stylesheets/luda/core/collections/_modal.sass +12 -0
- data/assets/stylesheets/luda/core/collections/_nav.sass +162 -0
- data/assets/stylesheets/luda/core/collections/_tab.sass +18 -0
- data/assets/stylesheets/luda/core/elements/_badge.sass +19 -0
- data/assets/stylesheets/luda/core/elements/_baseline.sass +22 -0
- data/assets/stylesheets/luda/core/elements/_button.sass +136 -0
- data/assets/stylesheets/luda/core/elements/_container.sass +8 -0
- data/assets/stylesheets/luda/core/elements/_grid.sass +55 -0
- data/assets/stylesheets/luda/core/elements/_icon.sass +110 -0
- data/assets/stylesheets/luda/core/elements/_overlay.sass +11 -0
- data/assets/stylesheets/luda/core/elements/_progress.sass +31 -0
- data/assets/stylesheets/luda/core/elements/_scrollbar.sass +21 -0
- data/assets/stylesheets/luda/core/elements/_table.sass +102 -0
- data/assets/stylesheets/luda/core/elements/_turbolinks-progress-bar.sass +5 -0
- data/assets/stylesheets/luda/core/elements/form/_form-check-radio.sass +105 -0
- data/assets/stylesheets/luda/core/elements/form/_form-element.sass +83 -0
- data/assets/stylesheets/luda/core/elements/form/_form-helper.sass +66 -0
- data/assets/stylesheets/luda/core/elements/form/_form-label.sass +20 -0
- data/assets/stylesheets/luda/core/elements/form/_form-range.sass +92 -0
- data/assets/stylesheets/luda/core/elements/form/_form-row.sass +214 -0
- data/assets/stylesheets/luda/core/elements/typography/_code.sass +27 -0
- data/assets/stylesheets/luda/core/elements/typography/_link.sass +15 -0
- data/assets/stylesheets/luda/core/elements/typography/_list.sass +14 -0
- data/assets/stylesheets/luda/core/elements/typography/_mark.sass +7 -0
- data/assets/stylesheets/luda/core/elements/typography/_quote.sass +68 -0
- data/assets/stylesheets/luda/core/elements/typography/_sub-sup.sass +16 -0
- data/assets/stylesheets/luda/core/elements/typography/_typography.sass +52 -0
- data/assets/stylesheets/luda/core/mixins/_browser.sass +15 -0
- data/assets/stylesheets/luda/core/mixins/_button.sass +90 -0
- data/assets/stylesheets/luda/core/mixins/_dropdown.sass +40 -0
- data/assets/stylesheets/luda/core/mixins/_focus.sass +3 -0
- data/assets/stylesheets/luda/core/mixins/_form.sass +27 -0
- data/assets/stylesheets/luda/core/mixins/_install.sass +7 -0
- data/assets/stylesheets/luda/core/mixins/_media-query.sass +66 -0
- data/assets/stylesheets/luda/core/mixins/_overlay.sass +14 -0
- data/assets/stylesheets/luda/core/mixins/_sass-lint-fix.sass +3 -0
- data/assets/stylesheets/luda/core/mixins/_typography.sass +40 -0
- data/assets/stylesheets/luda/core/utilities/_align.sass +19 -0
- data/assets/stylesheets/luda/core/utilities/_background.sass +88 -0
- data/assets/stylesheets/luda/core/utilities/_color.sass +36 -0
- data/assets/stylesheets/luda/core/utilities/_display.sass +40 -0
- data/assets/stylesheets/luda/core/utilities/_flex.sass +114 -0
- data/assets/stylesheets/luda/core/utilities/_float.sass +21 -0
- data/assets/stylesheets/luda/core/utilities/_opacity.sass +19 -0
- data/assets/stylesheets/luda/core/utilities/_overflow.sass +18 -0
- data/assets/stylesheets/luda/core/utilities/_position.sass +48 -0
- data/assets/stylesheets/luda/core/utilities/_shape.sass +62 -0
- data/assets/stylesheets/luda/core/utilities/_size.sass +67 -0
- data/assets/stylesheets/luda/core/utilities/_space.sass +227 -0
- data/assets/stylesheets/luda/core/utilities/_text.sass +85 -0
- data/assets/stylesheets/luda/core/utilities/_visibility.sass +11 -0
- data/assets/stylesheets/luda/core/utilities/_z-index.sass +19 -0
- data/assets/stylesheets/luda/default/_banner.sass +7 -0
- data/assets/stylesheets/luda/default/_base.sass +6 -0
- data/assets/stylesheets/luda/default/_functions.sass +1 -0
- data/assets/stylesheets/luda/default/_mixins.sass +10 -0
- data/assets/stylesheets/luda/default/_variables.sass +1 -0
- data/assets/stylesheets/luda/default/behaviours/_disabled.sass +5 -0
- data/assets/stylesheets/luda/default/behaviours/_focus.sass +5 -0
- data/assets/stylesheets/luda/default/behaviours/_readonly.sass +5 -0
- data/assets/stylesheets/luda/default/behaviours/_toggle.sass +5 -0
- data/assets/stylesheets/luda/default/collections/_alert.sass +6 -0
- data/assets/stylesheets/luda/default/collections/_avatar.sass +7 -0
- data/assets/stylesheets/luda/default/collections/_breadcrumb.sass +6 -0
- data/assets/stylesheets/luda/default/collections/_button-group.sass +7 -0
- data/assets/stylesheets/luda/default/collections/_button-icon.sass +8 -0
- data/assets/stylesheets/luda/default/collections/_carousel.sass +7 -0
- data/assets/stylesheets/luda/default/collections/_dropdown.sass +8 -0
- data/assets/stylesheets/luda/default/collections/_form-button.sass +9 -0
- data/assets/stylesheets/luda/default/collections/_form-dropdown.sass +8 -0
- data/assets/stylesheets/luda/default/collections/_form-group.sass +11 -0
- data/assets/stylesheets/luda/default/collections/_form-icon.sass +8 -0
- data/assets/stylesheets/luda/default/collections/_media.sass +7 -0
- data/assets/stylesheets/luda/default/collections/_modal.sass +7 -0
- data/assets/stylesheets/luda/default/collections/_nav.sass +10 -0
- data/assets/stylesheets/luda/default/collections/_tab.sass +9 -0
- data/assets/stylesheets/luda/default/elements/_badge.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_baseline.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_button.sass +7 -0
- data/assets/stylesheets/luda/default/elements/_container.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_form.sass +13 -0
- data/assets/stylesheets/luda/default/elements/_grid.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_icon.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_overlay.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_progress.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_scrollbar.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_table.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_turbolinks-progress-bar.sass +6 -0
- data/assets/stylesheets/luda/default/elements/_typography.sass +12 -0
- data/assets/stylesheets/luda/default/elements/form/_form-check-radio.sass +5 -0
- data/assets/stylesheets/luda/default/elements/form/_form-element.sass +5 -0
- data/assets/stylesheets/luda/default/elements/form/_form-helper.sass +5 -0
- data/assets/stylesheets/luda/default/elements/form/_form-label.sass +5 -0
- data/assets/stylesheets/luda/default/elements/form/_form-range.sass +5 -0
- data/assets/stylesheets/luda/default/elements/form/_form-row.sass +5 -0
- data/assets/stylesheets/luda/default/elements/typography/_code.sass +5 -0
- data/assets/stylesheets/luda/default/elements/typography/_link.sass +5 -0
- data/assets/stylesheets/luda/default/elements/typography/_list.sass +4 -0
- data/assets/stylesheets/luda/default/elements/typography/_mark.sass +5 -0
- data/assets/stylesheets/luda/default/elements/typography/_quote.sass +5 -0
- data/assets/stylesheets/luda/default/elements/typography/_sub-sup.sass +5 -0
- data/assets/stylesheets/luda/default/elements/typography/_typography.sass +5 -0
- data/assets/stylesheets/luda/default/index.sass +56 -0
- data/assets/stylesheets/luda/default/utilities/_align.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_background.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_color.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_display.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_flex.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_float.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_opacity.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_overflow.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_position.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_shape.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_size.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_space.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_text.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_visibility.sass +5 -0
- data/assets/stylesheets/luda/default/utilities/_z-index.sass +5 -0
- data/lib/luda.rb +72 -0
- data/lib/luda/config.rb +3 -0
- data/lib/luda/engine.rb +11 -0
- data/lib/luda/version.rb +3 -0
- metadata +302 -0
@@ -0,0 +1,269 @@
|
|
1
|
+
//= require ../install
|
2
|
+
//= require ../constants
|
3
|
+
//= require ../dom
|
4
|
+
//= require ../event
|
5
|
+
//= require ../component
|
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) :
|
9
|
+
(factory());
|
10
|
+
}(this, (function () { 'use strict';
|
11
|
+
|
12
|
+
luda((function() {
|
13
|
+
var _Class;
|
14
|
+
|
15
|
+
_Class = class extends luda.Component {
|
16
|
+
active() {
|
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);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
deactive(focus) {
|
29
|
+
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
|
+
}
|
39
|
+
}
|
40
|
+
this.constructor._$focused.splice(this.constructor._$focused.length - 1, 1);
|
41
|
+
return luda.dispatch(this._$component, this.constructor._DEACTIVED_EVENT_TYPE);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
toggle(focus) {
|
46
|
+
if (this._actived()) {
|
47
|
+
return this.deactive(focus);
|
48
|
+
} else {
|
49
|
+
return this.active();
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
prev() {
|
54
|
+
var focusIndex;
|
55
|
+
if (this._$items.length && this._actived()) {
|
56
|
+
focusIndex = this._$items.indexOf(document.activeElement) - 1;
|
57
|
+
if (focusIndex < 0) {
|
58
|
+
focusIndex = 0;
|
59
|
+
}
|
60
|
+
return this._$items[focusIndex].focus();
|
61
|
+
}
|
62
|
+
}
|
63
|
+
|
64
|
+
next() {
|
65
|
+
var focusIndex;
|
66
|
+
if (this._$items.length && this._actived()) {
|
67
|
+
focusIndex = this._$items.indexOf(document.activeElement) + 1;
|
68
|
+
if (focusIndex > this._$items.length - 1) {
|
69
|
+
focusIndex = this._$items.length - 1;
|
70
|
+
}
|
71
|
+
return this._$items[focusIndex].focus();
|
72
|
+
}
|
73
|
+
}
|
74
|
+
|
75
|
+
_getConfig() {
|
76
|
+
var _$items, _$menu, _$noneSwitches, _$switches, _isStandalone;
|
77
|
+
_$menu = luda.$child(this.constructor._MENU_SELECTOR, this._$component);
|
78
|
+
_$switches = luda.$unnested(this.constructor._SWITCHES_SELECTOR, this._$component, this.constructor._SELECTOR).concat(luda.$unnested(this.constructor._SWITCHES_SELECTOR, _$menu, this.constructor._MENU_SELECTOR));
|
79
|
+
_$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
|
+
_$items = luda.$unnested(this.constructor._ITEMS_SELECTOR, _$menu, this.constructor._MENU_SELECTOR);
|
81
|
+
_isStandalone = this._$component.hasAttribute(this.constructor._STANDALONE_ATTRIBUTE);
|
82
|
+
return {_$items, _$switches, _$noneSwitches, _isStandalone};
|
83
|
+
}
|
84
|
+
|
85
|
+
_constructor() {
|
86
|
+
return ({_$items: this._$items, _$switches: this._$switches, _$noneSwitches: this._$noneSwitches, _isStandalone: this._isStandalone} = this._getConfig());
|
87
|
+
}
|
88
|
+
|
89
|
+
_onMutations(mutations) {
|
90
|
+
return this._constructor();
|
91
|
+
}
|
92
|
+
|
93
|
+
_actived() {
|
94
|
+
return this._$component.classList.contains(this.constructor._ACTIVE_CSS_CLASS);
|
95
|
+
}
|
96
|
+
|
97
|
+
_deactiveChildrenExcept(exceptions) {
|
98
|
+
if (exceptions && !(exceptions instanceof Array)) {
|
99
|
+
exceptions = [exceptions];
|
100
|
+
}
|
101
|
+
if (exceptions) {
|
102
|
+
return this._children.forEach(function(child) {
|
103
|
+
if (child._actived() && !exceptions.includes(child)) {
|
104
|
+
return child.deactive();
|
105
|
+
}
|
106
|
+
});
|
107
|
+
} else {
|
108
|
+
return this._children.forEach(function(child) {
|
109
|
+
if (child._actived()) {
|
110
|
+
return child.deactive();
|
111
|
+
}
|
112
|
+
});
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
static deactiveExcept(instances$dropdowns) {
|
117
|
+
var exceptions;
|
118
|
+
exceptions = [];
|
119
|
+
if (instances$dropdowns && !(instances$dropdowns instanceof Array)) {
|
120
|
+
instances$dropdowns = [instances$dropdowns];
|
121
|
+
}
|
122
|
+
if (instances$dropdowns) {
|
123
|
+
instances$dropdowns.forEach((instance$dropdown) => {
|
124
|
+
var exception;
|
125
|
+
if (exception = this.query(instance$dropdown)) {
|
126
|
+
return exceptions.push(exception);
|
127
|
+
}
|
128
|
+
});
|
129
|
+
}
|
130
|
+
if (exceptions.length) {
|
131
|
+
return this._instances.forEach(function(instance) {
|
132
|
+
var instanceHasntExceptionChild, instanceIsntInExceptions;
|
133
|
+
instanceIsntInExceptions = !exceptions.includes(instance);
|
134
|
+
instanceHasntExceptionChild = exceptions.every(function(exception) {
|
135
|
+
return !instance._hasDescendant(exception);
|
136
|
+
});
|
137
|
+
if (instance._actived() && instanceIsntInExceptions && instanceHasntExceptionChild) {
|
138
|
+
return instance.deactive();
|
139
|
+
}
|
140
|
+
});
|
141
|
+
} else {
|
142
|
+
return this._instances.forEach(function(instance) {
|
143
|
+
if (instance._actived()) {
|
144
|
+
return instance.deactive();
|
145
|
+
}
|
146
|
+
});
|
147
|
+
}
|
148
|
+
}
|
149
|
+
|
150
|
+
static _standaloneInstances() {
|
151
|
+
return this._instances.filter(function(instance) {
|
152
|
+
if (instance._isStandalone) {
|
153
|
+
return instance;
|
154
|
+
}
|
155
|
+
});
|
156
|
+
}
|
157
|
+
|
158
|
+
static _init() {
|
159
|
+
var self;
|
160
|
+
self = this;
|
161
|
+
luda.onOpposite('click', this._SELECTOR, function(e) {
|
162
|
+
return self.deactiveExcept(self._standaloneInstances());
|
163
|
+
});
|
164
|
+
luda.on('click', this._SELECTOR, function(e) {
|
165
|
+
var focus, instance, toggleChecked;
|
166
|
+
if (instance = self.query(this)) {
|
167
|
+
toggleChecked = false;
|
168
|
+
focus = !e.detail;
|
169
|
+
self.deactiveExcept(self._standaloneInstances().concat(instance));
|
170
|
+
instance._deactiveChildrenExcept();
|
171
|
+
if (instance._parent) {
|
172
|
+
instance._parent._deactiveChildrenExcept(instance);
|
173
|
+
}
|
174
|
+
if (instance._$switches.length || instance._$noneSwitches.length) {
|
175
|
+
luda.eventPath(e).some(function($path) {
|
176
|
+
if (instance._$switches.includes($path)) {
|
177
|
+
instance.toggle(focus);
|
178
|
+
return toggleChecked = true;
|
179
|
+
} else if (instance._$noneSwitches.includes($path)) {
|
180
|
+
return toggleChecked = true;
|
181
|
+
}
|
182
|
+
});
|
183
|
+
}
|
184
|
+
if (!toggleChecked) {
|
185
|
+
return instance.toggle(focus);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
});
|
189
|
+
luda.onOpposite('keyup', this._SELECTOR, function(e) {
|
190
|
+
return self.deactiveExcept();
|
191
|
+
});
|
192
|
+
luda.on('keyup', this._SELECTOR, function(e) {
|
193
|
+
var instance;
|
194
|
+
if (e.keyCode === luda.KEY_TAB && (instance = self.query(this))) {
|
195
|
+
self.deactiveExcept(instance);
|
196
|
+
return instance.active();
|
197
|
+
}
|
198
|
+
});
|
199
|
+
luda.on('keydown', this._SELECTOR, function(e) {
|
200
|
+
var instance, ref;
|
201
|
+
if (e.keyCode === luda.KEY_ESC && (instance = self.query(this))) {
|
202
|
+
e.preventDefault();
|
203
|
+
if (instance._actived()) {
|
204
|
+
return instance.deactive(true);
|
205
|
+
} else {
|
206
|
+
return (ref = instance._parent) != null ? ref.deactive(true) : void 0;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
});
|
210
|
+
return luda.on('keydown', this._SELECTOR, function(e) {
|
211
|
+
var instance, ref, ref1;
|
212
|
+
if ([luda.KEY_LEFT, luda.KEY_UP].includes(e.keyCode) && (instance = self.query(this))) {
|
213
|
+
e.preventDefault();
|
214
|
+
if (instance._actived()) {
|
215
|
+
return instance.prev();
|
216
|
+
} else {
|
217
|
+
return (ref = instance._parent) != null ? ref.prev() : void 0;
|
218
|
+
}
|
219
|
+
} else if ([luda.KEY_RIGHT, luda.KEY_DOWN].includes(e.keyCode) && (instance = self.query(this))) {
|
220
|
+
e.preventDefault();
|
221
|
+
if (instance._actived()) {
|
222
|
+
return instance.next();
|
223
|
+
} else {
|
224
|
+
return (ref1 = instance._parent) != null ? ref1.next() : void 0;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
});
|
228
|
+
}
|
229
|
+
|
230
|
+
};
|
231
|
+
|
232
|
+
_Class._SCOPE = 'dropdown';
|
233
|
+
|
234
|
+
_Class._SELECTOR = '.dropdown-fixed,.dropdown-absolute, .dropdown-static,.dropdown-absolute-m';
|
235
|
+
|
236
|
+
_Class._MENU_SELECTOR = '.dropdown-menu';
|
237
|
+
|
238
|
+
_Class._ITEMS_SELECTOR = 'a[href]:not([disabled]),button:not([disabled]), input:not([disabled]),[tabindex]:not([disabled])';
|
239
|
+
|
240
|
+
_Class._TOGGLE_ATTRIBUTE = 'data-dropdown-toggle';
|
241
|
+
|
242
|
+
_Class._NONE_TOGGLE_ATTRIBUTE = 'data-dropdown-none-toggle';
|
243
|
+
|
244
|
+
_Class._STANDALONE_ATTRIBUTE = 'data-dropdown-standalone';
|
245
|
+
|
246
|
+
_Class._SWITCHES_SELECTOR = `[${_Class._TOGGLE_ATTRIBUTE}]`;
|
247
|
+
|
248
|
+
_Class._NONE_SWITCHES_SELECTOR = `[${_Class._NONE_TOGGLE_ATTRIBUTE}]`;
|
249
|
+
|
250
|
+
_Class._ACTIVE_CSS_CLASS = 'dropdown-active';
|
251
|
+
|
252
|
+
_Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
|
253
|
+
|
254
|
+
_Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
|
255
|
+
|
256
|
+
_Class._observerConfig = {
|
257
|
+
childList: true,
|
258
|
+
attributes: true,
|
259
|
+
subtree: true,
|
260
|
+
attributeFilter: [_Class._TOGGLE_ATTRIBUTE, _Class._NONE_TOGGLE_ATTRIBUTE, _Class._STANDALONE_ATTRIBUTE]
|
261
|
+
};
|
262
|
+
|
263
|
+
_Class._$focused = [];
|
264
|
+
|
265
|
+
return _Class;
|
266
|
+
|
267
|
+
}).call(this));
|
268
|
+
|
269
|
+
})));
|
@@ -0,0 +1,112 @@
|
|
1
|
+
//= require ../install
|
2
|
+
//= require ../dom
|
3
|
+
//= require ../event
|
4
|
+
//= require ../component
|
5
|
+
//= require ../behaviours/focus
|
6
|
+
//= require ../behaviours/enter-click
|
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('../behaviours/focus.js'), require('../behaviours/enter-click.js')) :
|
9
|
+
typeof define === 'function' && define.amd ? define(['../install.js', '../dom.js', '../event.js', '../component.js', '../behaviours/focus.js', '../behaviours/enter-click.js'], factory) :
|
10
|
+
(factory());
|
11
|
+
}(this, (function () { 'use strict';
|
12
|
+
|
13
|
+
luda((function() {
|
14
|
+
var _Class;
|
15
|
+
|
16
|
+
_Class = class extends luda.Component {
|
17
|
+
_getConfig() {
|
18
|
+
var _$defaultValues, _$valueHolder, _$values;
|
19
|
+
_$values = luda.$children(this.constructor._VALUE_SELECTOR, this._$component);
|
20
|
+
_$defaultValues = luda.$children(this.constructor._DEFAULT_VALUE_SELECTOR, this._$component);
|
21
|
+
_$valueHolder = luda.$child(this.constructor._VALUE_HOLDER_SELECTOR, this._$component);
|
22
|
+
return {_$values, _$valueHolder, _$defaultValues};
|
23
|
+
}
|
24
|
+
|
25
|
+
_constructor() {
|
26
|
+
({_$values: this._$values, _$valueHolder: this._$valueHolder, _$defaultValues: this._$defaultValues} = this._getConfig());
|
27
|
+
this._setValueHolderAttribute();
|
28
|
+
return this._setValueHolderValue();
|
29
|
+
}
|
30
|
+
|
31
|
+
_onMutations() {
|
32
|
+
return this._constructor();
|
33
|
+
}
|
34
|
+
|
35
|
+
_setValueHolderValue() {
|
36
|
+
var values;
|
37
|
+
values = [];
|
38
|
+
this._$values.forEach(($value, index) => {
|
39
|
+
var value;
|
40
|
+
if ($value.checked) {
|
41
|
+
if ($value.hasAttribute(this.constructor._VALUE_ATTRIBUTE)) {
|
42
|
+
value = $value.getAttribute(this.constructor._VALUE_ATTRIBUTE);
|
43
|
+
} else {
|
44
|
+
value = this._$defaultValues[index].innerText;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
if (value && !values.includes(value)) {
|
48
|
+
return values.push(value);
|
49
|
+
}
|
50
|
+
});
|
51
|
+
if (this._$valueHolder) {
|
52
|
+
return this._$valueHolder.value = values.join(this.constructor._VALUE_SPLITOR);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
_setValueHolderAttribute() {
|
57
|
+
if (this._$valueHolder) {
|
58
|
+
return this._$valueHolder.setAttribute('readonly', '');
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
static _init() {
|
63
|
+
var self;
|
64
|
+
self = this;
|
65
|
+
luda.enterClick._add(this._ENTER_CLICK_VALUE_HOLDER_SELECTOR);
|
66
|
+
luda.on('change', `${this._SELECTOR} ${this._VALUE_SELECTOR}`, function(e) {
|
67
|
+
return self.query(luda.$parent(self._SELECTOR, this))._setValueHolderValue();
|
68
|
+
});
|
69
|
+
luda.on(luda._FORM_RESET, this._SELECTOR, function(e) {
|
70
|
+
return setTimeout(() => {
|
71
|
+
return self.query(this)._setValueHolderValue();
|
72
|
+
});
|
73
|
+
});
|
74
|
+
// prevent ios device pop out wired navigation pannel
|
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) {
|
77
|
+
this.blur();
|
78
|
+
return this.classList.add(luda.focus._CSS_CLASS);
|
79
|
+
});
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
};
|
84
|
+
|
85
|
+
_Class._SCOPE = 'fmDropdown';
|
86
|
+
|
87
|
+
_Class._SELECTOR = '.fm-dropdown';
|
88
|
+
|
89
|
+
_Class._VALUE_SPLITOR = ' ';
|
90
|
+
|
91
|
+
_Class._VALUE_ATTRIBUTE = 'data-fm-dropdown-value';
|
92
|
+
|
93
|
+
_Class._VALUE_SELECTOR = '.dropdown-items .btn-radio input, .dropdown-items .btn-check input';
|
94
|
+
|
95
|
+
_Class._DEFAULT_VALUE_SELECTOR = '.dropdown-items .btn-radio label, .dropdown-items .btn-check label';
|
96
|
+
|
97
|
+
_Class._VALUE_HOLDER_SELECTOR = '.fm input';
|
98
|
+
|
99
|
+
_Class._ENTER_CLICK_VALUE_HOLDER_SELECTOR = '.fm-dropdown .fm input';
|
100
|
+
|
101
|
+
_Class._observerConfig = {
|
102
|
+
childList: true,
|
103
|
+
attributes: true,
|
104
|
+
subtree: true,
|
105
|
+
attributeFilter: ['checked', _Class._VALUE_ATTRIBUTE]
|
106
|
+
};
|
107
|
+
|
108
|
+
return _Class;
|
109
|
+
|
110
|
+
}).call(this));
|
111
|
+
|
112
|
+
})));
|
@@ -0,0 +1,117 @@
|
|
1
|
+
//= require ../install
|
2
|
+
//= require ../dom
|
3
|
+
//= require ../event
|
4
|
+
//= require ../component
|
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) :
|
8
|
+
(factory());
|
9
|
+
}(this, (function () { 'use strict';
|
10
|
+
|
11
|
+
luda((function() {
|
12
|
+
var _Class;
|
13
|
+
|
14
|
+
_Class = class extends luda.Component {
|
15
|
+
|
16
|
+
// public
|
17
|
+
active(index) {
|
18
|
+
var activedIndex;
|
19
|
+
if (this._$panes.length) {
|
20
|
+
activedIndex = this._activeIndex;
|
21
|
+
if ((index != null) && index !== this._activeIndex && (0 <= index && index <= this._$panes.length - 1)) {
|
22
|
+
this._activeIndex = index;
|
23
|
+
return this._active(activedIndex);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
// private
|
29
|
+
_getConfig() {
|
30
|
+
var _$indicators, _$panes, _activeIndex;
|
31
|
+
_$panes = luda.$unnested(this.constructor._PANE_SELECTOR, this._$component, this.constructor._SELECTOR);
|
32
|
+
_$indicators = luda.$unnested(this.constructor._INDICATOR_SELECTOR, this._$component, this.constructor._SELECTOR);
|
33
|
+
_activeIndex = this.constructor._ACTIVE_INDEX;
|
34
|
+
_$indicators.some(function($indicator, index) {
|
35
|
+
if ($indicator.checked) {
|
36
|
+
_activeIndex = index;
|
37
|
+
return true;
|
38
|
+
}
|
39
|
+
});
|
40
|
+
return {_$panes, _$indicators, _activeIndex};
|
41
|
+
}
|
42
|
+
|
43
|
+
_constructor() {
|
44
|
+
({_$panes: this._$panes, _$indicators: this._$indicators, _activeIndex: this._activeIndex} = this._getConfig());
|
45
|
+
return this._active();
|
46
|
+
}
|
47
|
+
|
48
|
+
_onMutations(mutations) {
|
49
|
+
return this._constructor();
|
50
|
+
}
|
51
|
+
|
52
|
+
_active(activedIndex) {
|
53
|
+
this._$panes.forEach(($pane, index) => {
|
54
|
+
if (index === this._activeIndex) {
|
55
|
+
$pane.classList.add(this.constructor._PANE_ACTIVE_CSS_CLASS);
|
56
|
+
return luda.dispatch($pane, this.constructor._ACTIVED_EVENT_TYPE, index);
|
57
|
+
} else {
|
58
|
+
$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
|
+
}
|
63
|
+
});
|
64
|
+
return this._setIndicatorsState();
|
65
|
+
}
|
66
|
+
|
67
|
+
_setIndicatorsState() {
|
68
|
+
return this._$indicators.forEach(($indicator, index) => {
|
69
|
+
if (index === this._activeIndex) {
|
70
|
+
return $indicator.setAttribute('checked', '');
|
71
|
+
} else {
|
72
|
+
return $indicator.removeAttribute('checked');
|
73
|
+
}
|
74
|
+
});
|
75
|
+
}
|
76
|
+
|
77
|
+
// static private
|
78
|
+
static _init() {
|
79
|
+
var self;
|
80
|
+
self = this;
|
81
|
+
return luda.on('change', this._INDICATOR_SELECTOR, function(e) {
|
82
|
+
var instance;
|
83
|
+
if (this.checked) {
|
84
|
+
instance = self.query(luda.$parent(self._SELECTOR, this));
|
85
|
+
return instance.active(instance._$indicators.indexOf(this));
|
86
|
+
}
|
87
|
+
});
|
88
|
+
}
|
89
|
+
|
90
|
+
};
|
91
|
+
|
92
|
+
_Class._SCOPE = 'tab';
|
93
|
+
|
94
|
+
_Class._SELECTOR = '.tab';
|
95
|
+
|
96
|
+
_Class._PANE_SELECTOR = '.tab-pane';
|
97
|
+
|
98
|
+
_Class._INDICATOR_SELECTOR = '.tab-indicators .btn-radio input[type=radio]';
|
99
|
+
|
100
|
+
_Class._PANE_ACTIVE_CSS_CLASS = 'tab-pane-active';
|
101
|
+
|
102
|
+
_Class._ACTIVE_INDEX = 0;
|
103
|
+
|
104
|
+
_Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
|
105
|
+
|
106
|
+
_Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
|
107
|
+
|
108
|
+
_Class._observerConfig = {
|
109
|
+
childList: true,
|
110
|
+
subtree: true
|
111
|
+
};
|
112
|
+
|
113
|
+
return _Class;
|
114
|
+
|
115
|
+
}).call(this));
|
116
|
+
|
117
|
+
})));
|