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,240 @@
|
|
1
|
+
//= require ./install
|
2
|
+
//= require ./utilities
|
3
|
+
//= require ./dom
|
4
|
+
//= require ./event
|
5
|
+
(function (global, factory) {
|
6
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./install.js'), require('./utilities.js'), require('./dom.js'), require('./event.js')) :
|
7
|
+
typeof define === 'function' && define.amd ? define(['./install.js', './utilities.js', './dom.js', './event.js'], factory) :
|
8
|
+
(factory());
|
9
|
+
}(this, (function () { 'use strict';
|
10
|
+
|
11
|
+
var Component;
|
12
|
+
|
13
|
+
luda(Component = (function() {
|
14
|
+
class Component {
|
15
|
+
_hasDescendant(descendant) {
|
16
|
+
if (this._children.length && descendant) {
|
17
|
+
if (this._children.includes(descendant)) {
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
return this._children.some(function(child) {
|
21
|
+
return child._hasDescendant(descendant);
|
22
|
+
});
|
23
|
+
} else {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
_observe() {
|
29
|
+
this._observer = new MutationObserver(this._onMutations.bind(this));
|
30
|
+
return this._observer.observe(this._$component, this.constructor._observerConfig);
|
31
|
+
}
|
32
|
+
|
33
|
+
_disconnect() {
|
34
|
+
this._observer.disconnect();
|
35
|
+
return this._observer = null;
|
36
|
+
}
|
37
|
+
|
38
|
+
static create($component) {
|
39
|
+
var $family, componentIsElementInstance, instance, parent;
|
40
|
+
componentIsElementInstance = $component instanceof Element;
|
41
|
+
if (!componentIsElementInstance) {
|
42
|
+
throw new Error(this._$COMPONENT_INVALID_ERROR);
|
43
|
+
}
|
44
|
+
$family = this._query$family($component);
|
45
|
+
instance = this.query($component);
|
46
|
+
if ($family._$parent) {
|
47
|
+
if (parent = this.query($family._$parent)) {
|
48
|
+
if (!instance) {
|
49
|
+
this._instances.push(instance = this._createInstance($component));
|
50
|
+
}
|
51
|
+
if (instance._parent !== parent) {
|
52
|
+
parent._children.push(instance) && (instance._parent = parent);
|
53
|
+
}
|
54
|
+
$family._$children.forEach(($child) => {
|
55
|
+
return this.create($child);
|
56
|
+
});
|
57
|
+
return instance;
|
58
|
+
} else {
|
59
|
+
this.create($family._$parent);
|
60
|
+
return this.query($component);
|
61
|
+
}
|
62
|
+
} else {
|
63
|
+
if (!instance) {
|
64
|
+
this._instances.push(instance = this._createInstance($component));
|
65
|
+
}
|
66
|
+
$family._$children.forEach(($child) => {
|
67
|
+
return this.create($child);
|
68
|
+
});
|
69
|
+
return instance;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
static destroy(instance$component) {
|
74
|
+
var attribute, instance, results, value;
|
75
|
+
instance = this.query(instance$component);
|
76
|
+
if (instance) {
|
77
|
+
if (instance._observer) {
|
78
|
+
instance._disconnect();
|
79
|
+
}
|
80
|
+
if (instance._destroy) {
|
81
|
+
instance._destroy();
|
82
|
+
}
|
83
|
+
while (instance._children.length) {
|
84
|
+
this.destroy(instance._children[0]);
|
85
|
+
}
|
86
|
+
if (instance._parent) {
|
87
|
+
luda.except(instance, instance._parent._children);
|
88
|
+
}
|
89
|
+
luda.except(instance, this._instances);
|
90
|
+
results = [];
|
91
|
+
for (attribute in instance) {
|
92
|
+
value = instance[attribute];
|
93
|
+
results.push(instance[attribute] = null);
|
94
|
+
}
|
95
|
+
return results;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
static query(instance$component) {
|
100
|
+
var instance;
|
101
|
+
instance = null;
|
102
|
+
if (instance$component instanceof this && this._instances.includes(instance$component)) {
|
103
|
+
instance = instance$component;
|
104
|
+
} else if (instance$component instanceof Element) {
|
105
|
+
this._instances.some(function(inited) {
|
106
|
+
if (inited._$component === instance$component) {
|
107
|
+
instance = inited;
|
108
|
+
return true;
|
109
|
+
}
|
110
|
+
});
|
111
|
+
}
|
112
|
+
return instance;
|
113
|
+
}
|
114
|
+
|
115
|
+
static _query$family($component) {
|
116
|
+
var _$children, _$parent;
|
117
|
+
_$parent = null;
|
118
|
+
_$children = [];
|
119
|
+
if (this._SELECTOR) {
|
120
|
+
_$parent = luda.$parent(this._SELECTOR, $component);
|
121
|
+
_$children = luda.$unnested(this._SELECTOR, $component, this._SELECTOR);
|
122
|
+
}
|
123
|
+
return {_$parent, _$children};
|
124
|
+
}
|
125
|
+
|
126
|
+
static _createInstance($component) {
|
127
|
+
var instance;
|
128
|
+
instance = new this();
|
129
|
+
instance._$component = $component;
|
130
|
+
instance._parent = null;
|
131
|
+
instance._children = [];
|
132
|
+
instance._observer = null;
|
133
|
+
if (instance._constructor) {
|
134
|
+
instance._constructor();
|
135
|
+
}
|
136
|
+
if (!(instance._observer && instance._onMutations && this._observerConfig)) {
|
137
|
+
instance._observe();
|
138
|
+
}
|
139
|
+
return instance;
|
140
|
+
}
|
141
|
+
|
142
|
+
static _observe(classObj) {
|
143
|
+
if (!Component._observer) {
|
144
|
+
Component._observer = new MutationObserver(function(mutations) {
|
145
|
+
return mutations.forEach(function(mutation) {
|
146
|
+
var $addedNodes, $removedNodes;
|
147
|
+
$removedNodes = Array.from(mutation.removedNodes);
|
148
|
+
$addedNodes = Array.from(mutation.addedNodes);
|
149
|
+
$removedNodes.forEach(function($node) {
|
150
|
+
if ($node instanceof Element) {
|
151
|
+
return Component._Observed.forEach(function(Observed) {
|
152
|
+
var $destroies;
|
153
|
+
if ($node.matches(Observed._SELECTOR)) {
|
154
|
+
return Observed.destroy($node);
|
155
|
+
} else {
|
156
|
+
$destroies = luda.$children(Observed._SELECTOR, $node);
|
157
|
+
return $destroies.forEach(function($destroy) {
|
158
|
+
return Observed.destroy($destroy);
|
159
|
+
});
|
160
|
+
}
|
161
|
+
});
|
162
|
+
}
|
163
|
+
});
|
164
|
+
return $addedNodes.forEach(function($node) {
|
165
|
+
if ($node instanceof Element) {
|
166
|
+
return Component._Observed.forEach(function(Observed) {
|
167
|
+
var $creates;
|
168
|
+
if ($node.matches(Observed._SELECTOR)) {
|
169
|
+
return Observed.create($node);
|
170
|
+
} else {
|
171
|
+
$creates = luda.$children(Observed._SELECTOR, $node);
|
172
|
+
return $creates.forEach(function($create) {
|
173
|
+
return Observed.create($create);
|
174
|
+
});
|
175
|
+
}
|
176
|
+
});
|
177
|
+
}
|
178
|
+
});
|
179
|
+
});
|
180
|
+
});
|
181
|
+
Component._observer.observe(document.documentElement, Component._observerConfig);
|
182
|
+
}
|
183
|
+
if (!Component._Observed.includes(classObj)) {
|
184
|
+
return Component._Observed.push(classObj);
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
static _install() {
|
189
|
+
var exposed, self;
|
190
|
+
self = this;
|
191
|
+
if (this === Component) {
|
192
|
+
return this;
|
193
|
+
}
|
194
|
+
if (!(this._SELECTOR || typeof this._SELECTOR !== 'string')) {
|
195
|
+
throw new Error(this._COMPONENT_NO_SELECTOR_ERROR);
|
196
|
+
}
|
197
|
+
if (!this.hasOwnProperty('_instances')) {
|
198
|
+
this._instances = [];
|
199
|
+
}
|
200
|
+
if (typeof this._init === 'function') {
|
201
|
+
exposed = this._init();
|
202
|
+
}
|
203
|
+
luda.on(luda._DOC_READY, function() {
|
204
|
+
luda.$children(self._SELECTOR).forEach(function($component) {
|
205
|
+
return self.create($component);
|
206
|
+
});
|
207
|
+
return Component._observe(self);
|
208
|
+
});
|
209
|
+
if (exposed) {
|
210
|
+
return exposed;
|
211
|
+
} else {
|
212
|
+
return this;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
}
|
217
|
+
Component._SCOPE = 'Component';
|
218
|
+
|
219
|
+
Component._COMPONENT_NO_SELECTOR_ERROR = 'Extended component must has a css selector';
|
220
|
+
|
221
|
+
Component._$COMPONENT_INVALID_ERROR = '@param $component must be an instance of Element';
|
222
|
+
|
223
|
+
Component._SELECTOR = '';
|
224
|
+
|
225
|
+
Component._instances = [];
|
226
|
+
|
227
|
+
Component._Observed = [];
|
228
|
+
|
229
|
+
Component._observer = null;
|
230
|
+
|
231
|
+
Component._observerConfig = {
|
232
|
+
childList: true,
|
233
|
+
subtree: true
|
234
|
+
};
|
235
|
+
|
236
|
+
return Component;
|
237
|
+
|
238
|
+
}).call(this));
|
239
|
+
|
240
|
+
})));
|
@@ -0,0 +1,18 @@
|
|
1
|
+
//= require ./install
|
2
|
+
(function (global, factory) {
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./install.js')) :
|
4
|
+
typeof define === 'function' && define.amd ? define(['./install.js'], factory) :
|
5
|
+
(factory());
|
6
|
+
}(this, (function () { 'use strict';
|
7
|
+
|
8
|
+
luda({
|
9
|
+
KEY_LEFT: 37,
|
10
|
+
KEY_UP: 38,
|
11
|
+
KEY_RIGHT: 39,
|
12
|
+
KEY_DOWN: 40,
|
13
|
+
KEY_TAB: 9,
|
14
|
+
KEY_ESC: 27,
|
15
|
+
KEY_ENTER: 13
|
16
|
+
});
|
17
|
+
|
18
|
+
})));
|
@@ -0,0 +1,125 @@
|
|
1
|
+
(function (global, factory) {
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
4
|
+
(factory());
|
5
|
+
}(this, (function () { 'use strict';
|
6
|
+
|
7
|
+
var Degradation;
|
8
|
+
|
9
|
+
Degradation = {
|
10
|
+
_URL_ATTRIBUTE: 'data-degradation-url',
|
11
|
+
_HTML: ['<div id="luda-degradation-html" ', 'style="padding:100px 30px;text-align:center">', '<h1>Your Browser Is Too Old!</h1>', '<p>', 'Please visit this site with a modern browser ', '<a target="_blank" href="https://www.google.com/chrome/">', '(Chrome recommended)', '</a>', '.</p>', '</div>'].join(''),
|
12
|
+
_CSS_PROPERTIES: [
|
13
|
+
{
|
14
|
+
display: 'flex',
|
15
|
+
position: ['sticky',
|
16
|
+
'fixed']
|
17
|
+
},
|
18
|
+
'transition',
|
19
|
+
'animation'
|
20
|
+
],
|
21
|
+
_JS_PROPERTIES: {
|
22
|
+
es6Class: 'class X {}',
|
23
|
+
es6ArrowFunction: '((x) => x)()'
|
24
|
+
},
|
25
|
+
_NOTIFY_MILLSECONDS: 500,
|
26
|
+
check: function() {
|
27
|
+
this._checkEnv();
|
28
|
+
this._checkJS(this._JS_PROPERTIES);
|
29
|
+
return this._checkCSS(this._CSS_PROPERTIES);
|
30
|
+
},
|
31
|
+
_eval: eval,
|
32
|
+
_checkEnv: function() {
|
33
|
+
if (typeof document !== 'undefined') {
|
34
|
+
if (typeof window !== 'undefined') {
|
35
|
+
return window;
|
36
|
+
}
|
37
|
+
if (typeof global !== 'undefined') {
|
38
|
+
return global;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
throw new Error('Unsupported runtime environment.');
|
42
|
+
},
|
43
|
+
_checkJS: function(properties) {
|
44
|
+
var err, property, results, value;
|
45
|
+
results = [];
|
46
|
+
for (property in properties) {
|
47
|
+
value = properties[property];
|
48
|
+
try {
|
49
|
+
results.push(this._eval(value));
|
50
|
+
} catch (error) {
|
51
|
+
err = error;
|
52
|
+
this._notify();
|
53
|
+
throw new Error(property + ' ' + err);
|
54
|
+
}
|
55
|
+
}
|
56
|
+
return results;
|
57
|
+
},
|
58
|
+
_checkCSS: function(properties) {
|
59
|
+
var ele, i, len, name, property, results, value, valueEle;
|
60
|
+
ele = document.createElement('div');
|
61
|
+
results = [];
|
62
|
+
for (i = 0, len = properties.length; i < len; i++) {
|
63
|
+
property = properties[i];
|
64
|
+
if (typeof property === 'string') {
|
65
|
+
results.push(this._CSSPropertySupported(ele, property));
|
66
|
+
} else {
|
67
|
+
results.push((function() {
|
68
|
+
var results1;
|
69
|
+
results1 = [];
|
70
|
+
for (name in property) {
|
71
|
+
value = property[name];
|
72
|
+
this._CSSPropertySupported(ele, name);
|
73
|
+
if (value instanceof Array) {
|
74
|
+
results1.push((function() {
|
75
|
+
var j, len1, results2;
|
76
|
+
results2 = [];
|
77
|
+
for (j = 0, len1 = value.length; j < len1; j++) {
|
78
|
+
valueEle = value[j];
|
79
|
+
results2.push(this._CSSValueSupported(ele, name, valueEle));
|
80
|
+
}
|
81
|
+
return results2;
|
82
|
+
}).call(this));
|
83
|
+
} else {
|
84
|
+
results1.push(this._CSSValueSupported(ele, name, value));
|
85
|
+
}
|
86
|
+
}
|
87
|
+
return results1;
|
88
|
+
}).call(this));
|
89
|
+
}
|
90
|
+
}
|
91
|
+
return results;
|
92
|
+
},
|
93
|
+
_CSSPropertySupported: function(ele, property) {
|
94
|
+
if (typeof ele.style[property] !== 'string') {
|
95
|
+
this._notify();
|
96
|
+
throw new Error('Unsupported CSS property: ' + property);
|
97
|
+
}
|
98
|
+
},
|
99
|
+
_CSSValueSupported: function(ele, property, value) {
|
100
|
+
ele.style[property] = value;
|
101
|
+
if (ele.style[property] !== value) {
|
102
|
+
this._notify();
|
103
|
+
throw new Error('Unsupported CSS property value: ' + property + ' ' + value);
|
104
|
+
}
|
105
|
+
},
|
106
|
+
_notify: function() {
|
107
|
+
var _self, redirectUrl;
|
108
|
+
redirectUrl = document.documentElement.getAttribute(this._URL_ATTRIBUTE);
|
109
|
+
if (redirectUrl) {
|
110
|
+
return location.href = redirectUrl;
|
111
|
+
}
|
112
|
+
_self = this;
|
113
|
+
return setInterval(function() {
|
114
|
+
if (!document.getElementById('luda-degradation-html')) {
|
115
|
+
if (document.body) {
|
116
|
+
return document.body.innerHTML = _self._HTML;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}, this._NOTIFY_MILLSECONDS);
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
Degradation.check();
|
124
|
+
|
125
|
+
})));
|
@@ -0,0 +1,81 @@
|
|
1
|
+
//= require ./install
|
2
|
+
(function (global, factory) {
|
3
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('./install.js')) :
|
4
|
+
typeof define === 'function' && define.amd ? define(['./install.js'], factory) :
|
5
|
+
(factory());
|
6
|
+
}(this, (function () { 'use strict';
|
7
|
+
|
8
|
+
luda({
|
9
|
+
$child: function(selector, $ancestor) {
|
10
|
+
if (!$ancestor) {
|
11
|
+
$ancestor = document;
|
12
|
+
}
|
13
|
+
return $ancestor.querySelector(selector);
|
14
|
+
},
|
15
|
+
$children: function(selector, $ancestor) {
|
16
|
+
var $descendant, descendants;
|
17
|
+
if (!$ancestor) {
|
18
|
+
$ancestor = document;
|
19
|
+
}
|
20
|
+
$descendant = this.$child(selector, $ancestor);
|
21
|
+
if ($descendant) {
|
22
|
+
return descendants = Array.from($ancestor.querySelectorAll(selector));
|
23
|
+
} else {
|
24
|
+
return descendants = [];
|
25
|
+
}
|
26
|
+
},
|
27
|
+
$unnested: function(selector, $ancestor, ancestorSelector) {
|
28
|
+
var descendants;
|
29
|
+
descendants = this.$children(selector, $ancestor);
|
30
|
+
return descendants.filter(($descendant) => {
|
31
|
+
if (this.$parent(ancestorSelector, $descendant) === $ancestor) {
|
32
|
+
return $descendant;
|
33
|
+
}
|
34
|
+
});
|
35
|
+
},
|
36
|
+
$parent: function(selector, $descendant) {
|
37
|
+
var $ancestor;
|
38
|
+
$ancestor = $descendant.parentNode;
|
39
|
+
if ($ancestor) {
|
40
|
+
if ($ancestor.matches && $ancestor.matches(selector)) {
|
41
|
+
return $ancestor;
|
42
|
+
} else {
|
43
|
+
return this.$parent(selector, $ancestor);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
},
|
47
|
+
$parents: function(selector, $descendant, _ancestors) {
|
48
|
+
var $ancestor;
|
49
|
+
$ancestor = this.$parent(selector, $descendant);
|
50
|
+
if (!_ancestors) {
|
51
|
+
_ancestors = [];
|
52
|
+
}
|
53
|
+
if ($ancestor) {
|
54
|
+
_ancestors.push($ancestor);
|
55
|
+
return this.$parents(selector, $ancestor, _ancestors);
|
56
|
+
} else {
|
57
|
+
return _ancestors;
|
58
|
+
}
|
59
|
+
},
|
60
|
+
$after: function($node, $target) {
|
61
|
+
var $parent;
|
62
|
+
$parent = $target.parentNode;
|
63
|
+
if ($parent.lastChild === $target) {
|
64
|
+
return $parent.appendChild($node);
|
65
|
+
} else {
|
66
|
+
return $parent.insertBefore($node, $target.nextSibling);
|
67
|
+
}
|
68
|
+
},
|
69
|
+
$prepend: function($node, $target) {
|
70
|
+
if ($target.firstChild) {
|
71
|
+
return $target.insertBefore($node, $target.firstChild);
|
72
|
+
} else {
|
73
|
+
return $target.appendChild($node);
|
74
|
+
}
|
75
|
+
},
|
76
|
+
reflow: function($element) {
|
77
|
+
return $element.offsetHeight;
|
78
|
+
}
|
79
|
+
});
|
80
|
+
|
81
|
+
})));
|