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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 895935589896879f027cb8e39db9a1a4d97e464b15bd48a3e3ce530c51a8e9a7
|
4
|
+
data.tar.gz: a20fad13c1956a9b8bb6945752abdd620ee62cd5bb3e949517017186b841a9bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb6e6295e4a457573cbc334f1b05f5fb91a6883a22aa4eb88134c91bde4e87e308360ec90a2f25723a637d92a1dc732d727f9622c8e8be093e31049a103d7f6a
|
7
|
+
data.tar.gz: 27fde2192338a38a3e1283366480db794946d45a0f280abc9f24bcd54b6af20e3c712b870b529e66c28be109ab3b4219b68d22a2dd31b549c42b4e73f6a9188f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2019 littlstonee
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
/*!
|
2
|
+
* Luda degradation script 0.1.5 | https://luda.dev
|
3
|
+
* Copyright 2018 oatw | https://oatw.blog
|
4
|
+
* MIT license | http://opensource.org/licenses/MIT
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
|
8
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
9
|
+
(factory());
|
10
|
+
}(this, (function () { 'use strict';
|
11
|
+
|
12
|
+
var Degradation;
|
13
|
+
|
14
|
+
Degradation = {
|
15
|
+
_URL_ATTRIBUTE: 'data-degradation-url',
|
16
|
+
_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(''),
|
17
|
+
_CSS_PROPERTIES: [
|
18
|
+
{
|
19
|
+
display: 'flex',
|
20
|
+
position: ['sticky',
|
21
|
+
'fixed']
|
22
|
+
},
|
23
|
+
'transition',
|
24
|
+
'animation'
|
25
|
+
],
|
26
|
+
_JS_PROPERTIES: {
|
27
|
+
es6Class: 'class X {}',
|
28
|
+
es6ArrowFunction: '((x) => x)()'
|
29
|
+
},
|
30
|
+
_NOTIFY_MILLSECONDS: 500,
|
31
|
+
check: function() {
|
32
|
+
this._checkEnv();
|
33
|
+
this._checkJS(this._JS_PROPERTIES);
|
34
|
+
return this._checkCSS(this._CSS_PROPERTIES);
|
35
|
+
},
|
36
|
+
_eval: eval,
|
37
|
+
_checkEnv: function() {
|
38
|
+
if (typeof document !== 'undefined') {
|
39
|
+
if (typeof window !== 'undefined') {
|
40
|
+
return window;
|
41
|
+
}
|
42
|
+
if (typeof global !== 'undefined') {
|
43
|
+
return global;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
throw new Error('Unsupported runtime environment.');
|
47
|
+
},
|
48
|
+
_checkJS: function(properties) {
|
49
|
+
var err, property, results, value;
|
50
|
+
results = [];
|
51
|
+
for (property in properties) {
|
52
|
+
value = properties[property];
|
53
|
+
try {
|
54
|
+
results.push(this._eval(value));
|
55
|
+
} catch (error) {
|
56
|
+
err = error;
|
57
|
+
this._notify();
|
58
|
+
throw new Error(property + ' ' + err);
|
59
|
+
}
|
60
|
+
}
|
61
|
+
return results;
|
62
|
+
},
|
63
|
+
_checkCSS: function(properties) {
|
64
|
+
var ele, i, len, name, property, results, value, valueEle;
|
65
|
+
ele = document.createElement('div');
|
66
|
+
results = [];
|
67
|
+
for (i = 0, len = properties.length; i < len; i++) {
|
68
|
+
property = properties[i];
|
69
|
+
if (typeof property === 'string') {
|
70
|
+
results.push(this._CSSPropertySupported(ele, property));
|
71
|
+
} else {
|
72
|
+
results.push((function() {
|
73
|
+
var results1;
|
74
|
+
results1 = [];
|
75
|
+
for (name in property) {
|
76
|
+
value = property[name];
|
77
|
+
this._CSSPropertySupported(ele, name);
|
78
|
+
if (value instanceof Array) {
|
79
|
+
results1.push((function() {
|
80
|
+
var j, len1, results2;
|
81
|
+
results2 = [];
|
82
|
+
for (j = 0, len1 = value.length; j < len1; j++) {
|
83
|
+
valueEle = value[j];
|
84
|
+
results2.push(this._CSSValueSupported(ele, name, valueEle));
|
85
|
+
}
|
86
|
+
return results2;
|
87
|
+
}).call(this));
|
88
|
+
} else {
|
89
|
+
results1.push(this._CSSValueSupported(ele, name, value));
|
90
|
+
}
|
91
|
+
}
|
92
|
+
return results1;
|
93
|
+
}).call(this));
|
94
|
+
}
|
95
|
+
}
|
96
|
+
return results;
|
97
|
+
},
|
98
|
+
_CSSPropertySupported: function(ele, property) {
|
99
|
+
if (typeof ele.style[property] !== 'string') {
|
100
|
+
this._notify();
|
101
|
+
throw new Error('Unsupported CSS property: ' + property);
|
102
|
+
}
|
103
|
+
},
|
104
|
+
_CSSValueSupported: function(ele, property, value) {
|
105
|
+
ele.style[property] = value;
|
106
|
+
if (ele.style[property] !== value) {
|
107
|
+
this._notify();
|
108
|
+
throw new Error('Unsupported CSS property value: ' + property + ' ' + value);
|
109
|
+
}
|
110
|
+
},
|
111
|
+
_notify: function() {
|
112
|
+
var _self, redirectUrl;
|
113
|
+
redirectUrl = document.documentElement.getAttribute(this._URL_ATTRIBUTE);
|
114
|
+
if (redirectUrl) {
|
115
|
+
return location.href = redirectUrl;
|
116
|
+
}
|
117
|
+
_self = this;
|
118
|
+
return setInterval(function() {
|
119
|
+
if (!document.getElementById('luda-degradation-html')) {
|
120
|
+
if (document.body) {
|
121
|
+
return document.body.innerHTML = _self._HTML;
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}, this._NOTIFY_MILLSECONDS);
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
Degradation.check();
|
129
|
+
|
130
|
+
})));
|
131
|
+
//# sourceMappingURL=luda-degradation.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"luda-degradation.js","sources":["../../src/coffee/degradation.coffee"],"sourcesContent":["Degradation =\r\n\r\n _URL_ATTRIBUTE: 'data-degradation-url'\r\n\r\n _HTML: [\r\n '<div id=\"luda-degradation-html\" '\r\n 'style=\"padding:100px 30px;text-align:center\">'\r\n '<h1>Your Browser Is Too Old!</h1>'\r\n '<p>'\r\n 'Please visit this site with a modern browser '\r\n '<a target=\"_blank\" href=\"https://www.google.com/chrome/\">'\r\n '(Chrome recommended)'\r\n '</a>'\r\n '.</p>'\r\n '</div>'\r\n ].join('')\r\n\r\n _CSS_PROPERTIES: [\r\n display: 'flex'\r\n position: ['sticky', 'fixed']\r\n 'transition'\r\n 'animation'\r\n ]\r\n\r\n _JS_PROPERTIES:\r\n es6Class: 'class X {}'\r\n es6ArrowFunction: '((x) => x)()'\r\n\r\n _NOTIFY_MILLSECONDS: 500\r\n\r\n check: ->\r\n @_checkEnv()\r\n @_checkJS @_JS_PROPERTIES\r\n @_checkCSS @_CSS_PROPERTIES\r\n\r\n _eval: eval\r\n\r\n _checkEnv: ->\r\n if typeof document isnt 'undefined'\r\n return window if typeof window isnt 'undefined'\r\n return global if typeof global isnt 'undefined'\r\n throw new Error 'Unsupported runtime environment.'\r\n\r\n _checkJS: (properties) ->\r\n for property, value of properties\r\n try\r\n @_eval value\r\n catch err\r\n @_notify()\r\n throw new Error property + ' ' + err\r\n\r\n _checkCSS: (properties) ->\r\n ele = document.createElement 'div'\r\n for property in properties\r\n if typeof property is 'string'\r\n @_CSSPropertySupported ele, property\r\n else\r\n for name, value of property\r\n @_CSSPropertySupported ele, name\r\n if value instanceof Array\r\n @_CSSValueSupported ele, name, valueEle for valueEle in value\r\n else\r\n @_CSSValueSupported ele, name, value\r\n\r\n _CSSPropertySupported: (ele, property) ->\r\n unless typeof ele.style[property] is 'string'\r\n @_notify()\r\n throw new Error 'Unsupported CSS property: ' + property\r\n\r\n _CSSValueSupported: (ele, property, value) ->\r\n ele.style[property] = value\r\n unless ele.style[property] is value\r\n @_notify()\r\n throw new Error 'Unsupported CSS property value: ' \\\r\n + property + ' ' + value\r\n\r\n _notify: ->\r\n redirectUrl = document.documentElement.getAttribute @_URL_ATTRIBUTE\r\n return location.href = redirectUrl if redirectUrl\r\n _self = this\r\n setInterval(->\r\n unless document.getElementById 'luda-degradation-html'\r\n document.body.innerHTML = _self._HTML if document.body\r\n , @_NOTIFY_MILLSECONDS)\r\n\r\n\r\n\r\n\r\nDegradation.check()"],"names":[],"mappings":";;;;;;;;;;;EAAA,IAAA;;EAAA,WAAA,GAEE;IAAA,cAAA,EAAgB,sBAAhB;IAEA,KAAA,EAAO,CACL,kCADK,EAEL,+CAFK,EAGL,mCAHK,EAIL,KAJK,EAKL,+CALK,EAML,2DANK,EAOL,sBAPK,EAQL,MARK,EASL,OATK,EAUL,QAVK,CAWJ,CAAC,IAXG,CAWE,EAXF,CAFP;IAeA,eAAA,EAAiB;MACf;QAAA,OAAA,EAAS,MAAT;QACA,QAAA,EAAU,CAAC,QAAD;MAAW,OAAX;OAFK;MAGf,YAHe;MAIf,WAJe;KAfjB;IAsBA,cAAA,EACE;MAAA,QAAA,EAAU,YAAV;MACA,gBAAA,EAAkB;KAxBpB;IA0BA,mBAAA,EAAqB,GA1BrB;IA4BA,KAAA,EAAO;MACL,IAAC,CAAA,SAAD;MACA,IAAC,CAAA,QAAD,CAAU,IAAC,CAAA,cAAX;aACA,IAAC,CAAA,SAAD,CAAW,IAAC,CAAA,eAAZ;KA/BF;IAiCA,KAAA,EAAO,IAjCP;IAmCA,SAAA,EAAW;MACT,IAAG,OAAO,QAAP,KAAqB,WAAxB;QACE,IAAiB,OAAO,MAAP,KAAmB,WAApC;EAAA,eAAO,OAAP;;QACA,IAAiB,OAAO,MAAP,KAAmB,WAApC;EAAA,eAAO,OAAP;SAFF;;MAGA,MAAM,IAAI,KAAJ,CAAU,kCAAV;KAvCR;IAyCA,QAAA,EAAU,SAAC,UAAD;EACR,QAAA,GAAA,EAAA,QAAA,EAAA,OAAA,EAAA;EAAA;MAAA,KAAA,sBAAA;;EACE;uBACE,IAAC,CAAA,KAAD,CAAO,KAAP,GADF;SAAA,aAAA;UAEM;UACJ,IAAC,CAAA,OAAD;UACA,MAAM,IAAI,KAAJ,CAAU,QAAA,GAAW,GAAX,GAAiB,GAA3B,EAJR;;OADF;;KA1CF;IAiDA,SAAA,EAAW,SAAC,UAAD;EACT,QAAA,GAAA,EAAA,CAAA,EAAA,GAAA,EAAA,IAAA,EAAA,QAAA,EAAA,OAAA,EAAA,KAAA,EAAA;MAAA,GAAA,GAAM,QAAQ,CAAC,aAAT,CAAuB,KAAvB;EACN;MAAA,KAAA,4CAAA;;QACE,IAAG,OAAO,QAAP,KAAmB,QAAtB;uBACE,IAAC,CAAA,qBAAD,CAAuB,GAAvB,EAA4B,QAA5B,GADF;SAAA,MAAA;;;EAGE;YAAA,KAAA,gBAAA;;cACE,IAAC,CAAA,qBAAD,CAAuB,GAAvB,EAA4B,IAA5B;cACA,IAAG,KAAA,YAAiB,KAApB;;;EAC0C;kBAAA,KAAA,yCAAA;;kCAAxC,IAAC,CAAA,kBAAD,CAAoB,GAApB,EAAyB,IAAzB,EAA+B,QAA/B;mBAAwC;;+BAD1C;eAAA,MAAA;8BAGE,IAAC,CAAA,kBAAD,CAAoB,GAApB,EAAyB,IAAzB,EAA+B,KAA/B,GAHF;;aAFF;;yBAHF;;OADF;;KAnDF;IA8DA,qBAAA,EAAuB,SAAC,GAAD,EAAM,QAAN;MACrB,IAAO,OAAO,GAAG,CAAC,KAAM,CAAA,QAAA,CAAjB,KAA8B,QAArC;QACE,IAAC,CAAA,OAAD;QACA,MAAM,IAAI,KAAJ,CAAU,4BAAA,GAA+B,QAAzC,EAFR;;KA/DF;IAmEA,kBAAA,EAAoB,SAAC,GAAD,EAAM,QAAN,EAAgB,KAAhB;MAClB,GAAG,CAAC,KAAM,CAAA,QAAA,CAAV,GAAsB;MACtB,IAAO,GAAG,CAAC,KAAM,CAAA,QAAA,CAAV,KAAuB,KAA9B;QACE,IAAC,CAAA,OAAD;QACA,MAAM,IAAI,KAAJ,CAAU,kCAAA,GACd,QADc,GACH,GADG,GACG,KADb,EAFR;;KArEF;IA0EA,OAAA,EAAS;EACP,QAAA,KAAA,EAAA;MAAA,WAAA,GAAc,QAAQ,CAAC,eAAe,CAAC,YAAzB,CAAsC,IAAC,CAAA,cAAvC;MACd,IAAsC,WAAtC;EAAA,aAAO,QAAQ,CAAC,IAAT,GAAgB,YAAvB;;MACA,KAAA,GAAQ;aACR,WAAA,CAAY;QACV,IAAA,CAAO,QAAQ,CAAC,cAAT,CAAwB,uBAAxB,CAAP;UACE,IAAyC,QAAQ,CAAC,IAAlD;mBAAA,QAAQ,CAAC,IAAI,CAAC,SAAd,GAA0B,KAAK,CAAC,MAAhC;WADF;;OADF,EAGE,IAAC,CAAA,mBAHH;;EA9EF;;EAsFF,WAAW,CAAC,KAAZ;;;;"}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* Luda degradation script 0.1.5 | https://luda.dev
|
3
|
+
* Copyright 2018 oatw | https://oatw.blog
|
4
|
+
* MIT license | http://opensource.org/licenses/MIT
|
5
|
+
*/
|
6
|
+
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory():typeof define==="function"&&define.amd?define(factory):factory()})(this,function(){"use strict";var Degradation;Degradation={_URL_ATTRIBUTE:"data-degradation-url",_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(""),_CSS_PROPERTIES:[{display:"flex",position:["sticky","fixed"]},"transition","animation"],_JS_PROPERTIES:{es6Class:"class X {}",es6ArrowFunction:"((x) => x)()"},_NOTIFY_MILLSECONDS:500,check:function(){this._checkEnv();this._checkJS(this._JS_PROPERTIES);return this._checkCSS(this._CSS_PROPERTIES)},_eval:eval,_checkEnv:function(){if(typeof document!=="undefined"){if(typeof window!=="undefined"){return window}if(typeof global!=="undefined"){return global}}throw new Error("Unsupported runtime environment.")},_checkJS:function(properties){var err,property,results,value;results=[];for(property in properties){value=properties[property];try{results.push(this._eval(value))}catch(error){err=error;this._notify();throw new Error(property+" "+err)}}return results},_checkCSS:function(properties){var ele,i,len,name,property,results,value,valueEle;ele=document.createElement("div");results=[];for(i=0,len=properties.length;i<len;i++){property=properties[i];if(typeof property==="string"){results.push(this._CSSPropertySupported(ele,property))}else{results.push(function(){var results1;results1=[];for(name in property){value=property[name];this._CSSPropertySupported(ele,name);if(value instanceof Array){results1.push(function(){var j,len1,results2;results2=[];for(j=0,len1=value.length;j<len1;j++){valueEle=value[j];results2.push(this._CSSValueSupported(ele,name,valueEle))}return results2}.call(this))}else{results1.push(this._CSSValueSupported(ele,name,value))}}return results1}.call(this))}}return results},_CSSPropertySupported:function(ele,property){if(typeof ele.style[property]!=="string"){this._notify();throw new Error("Unsupported CSS property: "+property)}},_CSSValueSupported:function(ele,property,value){ele.style[property]=value;if(ele.style[property]!==value){this._notify();throw new Error("Unsupported CSS property value: "+property+" "+value)}},_notify:function(){var _self,redirectUrl;redirectUrl=document.documentElement.getAttribute(this._URL_ATTRIBUTE);if(redirectUrl){return location.href=redirectUrl}_self=this;return setInterval(function(){if(!document.getElementById("luda-degradation-html")){if(document.body){return document.body.innerHTML=_self._HTML}}},this._NOTIFY_MILLSECONDS)}};Degradation.check()});
|
7
|
+
//# sourceMappingURL=luda-degradation.min.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/coffee/degradation.coffee"],"names":["Degradation","_URL_ATTRIBUTE","_HTML","join","_CSS_PROPERTIES","display","position","_JS_PROPERTIES","es6Class","es6ArrowFunction","_NOTIFY_MILLSECONDS","check","this","_checkEnv","_checkJS","_checkCSS","_eval","eval","document","window","global","Error","properties","err","property","results","value","error","_notify","ele","i","len","name","valueEle","createElement","length","_CSSPropertySupported","results1","Array","results2","j","len1","_CSSValueSupported","style","_self","redirectUrl","documentElement","getAttribute","location","href","setInterval","getElementById","body","innerHTML"],"mappings":";;;;;2LAAA,IAAAA,YAAAA,YAEE,CAAAC,eAAgB,uBAEhBC,MAAO,CACL,mCACA,gDACA,oCACA,MACA,gDACA,4DACA,uBACA,OACA,QACA,UACEC,KAAK,IAETC,gBAAiB,CACf,CAAAC,QAAS,OACTC,SAAU,CAAC,SAAU,UACrB,aACA,aAGFC,eACE,CAAAC,SAAU,aACVC,iBAAkB,gBAEpBC,oBAAqB,IAErBC,MAAO,WACLC,KAACC,YACDD,KAACE,SAASF,KAACL,uBACXK,KAACG,UAAUH,KAACR,kBAEdY,MAAOC,KAEPJ,UAAW,WACT,UAAUK,WAAc,YAAxB,CACE,UAAwBC,SAAY,YAApC,CAAA,OAAOA,OACP,UAAwBC,SAAY,YAApC,CAAA,OAAOA,QACT,MAAM,IAAIC,MAAM,qCAElBP,SAAU,SAACQ,YACT,IAAAC,IAAAC,SAAAC,QAAAC,MAAAD,QAAA,GAAA,IAAAD,YAAAF,WAAA,4BACE,iBACEV,KAACI,MAAMU,QADT,MAAAC,OAEMJ,IAAAI,MACJf,KAACgB,UACD,MAAM,IAAIP,MAAMG,SAAW,IAAMD,sBAEvCR,UAAW,SAACO,YACV,IAAAO,IAAAC,EAAAC,IAAAC,KAAAR,SAAAC,QAAAC,MAAAO,SAAAJ,IAAMX,SAASgB,cAAc,OAC7BT,QAAA,GAAA,IAAAK,EAAA,EAAAC,IAAAT,WAAAa,OAAAL,EAAAC,IAAAD,IAAA,wBACE,UAAUN,WAAY,SAAtB,cACEZ,KAACwB,sBAAsBP,IAAKL,eAD9B,sCAGEa,SAAA,GAAA,IAAAL,QAAAR,SAAA,sBACEZ,KAACwB,sBAAsBP,IAAKG,MAC5B,GAAGN,iBAAiBY,MAApB,8CAC0CC,SAAA,GAAA,IAAAC,EAAA,EAAAC,KAAAf,MAAAS,OAAAK,EAAAC,KAAAD,IAAA,iCAAxC5B,KAAC8B,mBAAmBb,IAAKG,KAAMC,4CADjC,eAGErB,KAAC8B,mBAAmBb,IAAKG,KAAMN,uDAEzCU,sBAAuB,SAACP,IAAKL,UAC3B,UAAcK,IAAIc,MAAMnB,YAAa,SAArC,CACEZ,KAACgB,UACD,MAAM,IAAIP,MAAM,6BAA+BG,YAEnDkB,mBAAoB,SAACb,IAAKL,SAAUE,OAClCG,IAAIc,MAAMnB,UAAYE,MACtB,GAAOG,IAAIc,MAAMnB,YAAaE,MAA9B,CACEd,KAACgB,UACD,MAAM,IAAIP,MAAM,mCACdG,SAAW,IAAME,SAEvBE,QAAS,WACP,IAAAgB,MAAAC,YAAAA,YAAc3B,SAAS4B,gBAAgBC,aAAanC,KAACX,gBACrD,GAAsC4C,YAAtC,CAAA,OAAOG,SAASC,KAAOJ,YACvBD,MAAQhC,YACRsC,YAAY,WACV,IAAOhC,SAASiC,eAAe,yBAA/B,CACE,GAAyCjC,SAASkC,KAAlD,QAAAlC,SAASkC,KAAKC,UAAYT,MAAM1C,SAClCU,KAACF,uBAKPV,YAAYW","sourcesContent":["Degradation =\r\n\r\n _URL_ATTRIBUTE: 'data-degradation-url'\r\n\r\n _HTML: [\r\n '<div id=\"luda-degradation-html\" '\r\n 'style=\"padding:100px 30px;text-align:center\">'\r\n '<h1>Your Browser Is Too Old!</h1>'\r\n '<p>'\r\n 'Please visit this site with a modern browser '\r\n '<a target=\"_blank\" href=\"https://www.google.com/chrome/\">'\r\n '(Chrome recommended)'\r\n '</a>'\r\n '.</p>'\r\n '</div>'\r\n ].join('')\r\n\r\n _CSS_PROPERTIES: [\r\n display: 'flex'\r\n position: ['sticky', 'fixed']\r\n 'transition'\r\n 'animation'\r\n ]\r\n\r\n _JS_PROPERTIES:\r\n es6Class: 'class X {}'\r\n es6ArrowFunction: '((x) => x)()'\r\n\r\n _NOTIFY_MILLSECONDS: 500\r\n\r\n check: ->\r\n @_checkEnv()\r\n @_checkJS @_JS_PROPERTIES\r\n @_checkCSS @_CSS_PROPERTIES\r\n\r\n _eval: eval\r\n\r\n _checkEnv: ->\r\n if typeof document isnt 'undefined'\r\n return window if typeof window isnt 'undefined'\r\n return global if typeof global isnt 'undefined'\r\n throw new Error 'Unsupported runtime environment.'\r\n\r\n _checkJS: (properties) ->\r\n for property, value of properties\r\n try\r\n @_eval value\r\n catch err\r\n @_notify()\r\n throw new Error property + ' ' + err\r\n\r\n _checkCSS: (properties) ->\r\n ele = document.createElement 'div'\r\n for property in properties\r\n if typeof property is 'string'\r\n @_CSSPropertySupported ele, property\r\n else\r\n for name, value of property\r\n @_CSSPropertySupported ele, name\r\n if value instanceof Array\r\n @_CSSValueSupported ele, name, valueEle for valueEle in value\r\n else\r\n @_CSSValueSupported ele, name, value\r\n\r\n _CSSPropertySupported: (ele, property) ->\r\n unless typeof ele.style[property] is 'string'\r\n @_notify()\r\n throw new Error 'Unsupported CSS property: ' + property\r\n\r\n _CSSValueSupported: (ele, property, value) ->\r\n ele.style[property] = value\r\n unless ele.style[property] is value\r\n @_notify()\r\n throw new Error 'Unsupported CSS property value: ' \\\r\n + property + ' ' + value\r\n\r\n _notify: ->\r\n redirectUrl = document.documentElement.getAttribute @_URL_ATTRIBUTE\r\n return location.href = redirectUrl if redirectUrl\r\n _self = this\r\n setInterval(->\r\n unless document.getElementById 'luda-degradation-html'\r\n document.body.innerHTML = _self._HTML if document.body\r\n , @_NOTIFY_MILLSECONDS)\r\n\r\n\r\n\r\n\r\nDegradation.check()"]}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
//= require luda\behaviours\enter-click
|
2
|
+
//= require luda\behaviours\focus
|
3
|
+
//= require luda\behaviours\radio-tab
|
4
|
+
//= require luda\behaviours\readonly
|
5
|
+
//= require luda\behaviours\toggle
|
6
|
+
//= require luda\elements\form-file
|
7
|
+
//= require luda\elements\form-select
|
8
|
+
//= require luda\collections\carousel
|
9
|
+
//= require luda\collections\dropdown
|
10
|
+
//= require luda\collections\form-dropdown
|
11
|
+
//= require luda\collections\tab
|
@@ -0,0 +1,2024 @@
|
|
1
|
+
/*!
|
2
|
+
* Luda 0.1.5 | https://luda.dev
|
3
|
+
* Copyright 2018 oatw | https://oatw.blog
|
4
|
+
* MIT license | http://opensource.org/licenses/MIT
|
5
|
+
*/
|
6
|
+
(function (global, factory) {
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
|
8
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
9
|
+
(factory());
|
10
|
+
}(this, (function () { 'use strict';
|
11
|
+
|
12
|
+
var ENV;
|
13
|
+
|
14
|
+
ENV = (function() {
|
15
|
+
if (typeof document !== 'undefined') {
|
16
|
+
if (typeof window !== 'undefined') {
|
17
|
+
return window;
|
18
|
+
}
|
19
|
+
if (typeof global !== 'undefined') {
|
20
|
+
return global;
|
21
|
+
}
|
22
|
+
}
|
23
|
+
throw new Error('Unsupported runtime environment.');
|
24
|
+
})();
|
25
|
+
|
26
|
+
if (typeof ENV.luda !== 'function') {
|
27
|
+
ENV.luda = function(installer) {
|
28
|
+
var installed, name, property;
|
29
|
+
if (!installer) {
|
30
|
+
throw new Error('Installer cannot be detected.');
|
31
|
+
}
|
32
|
+
if (!['object', 'function'].includes(typeof installer)) {
|
33
|
+
throw new Error('Installer must be object, array or function.');
|
34
|
+
}
|
35
|
+
if (installer.hasOwnProperty('_SCOPE')) {
|
36
|
+
if (typeof installer._SCOPE !== 'string') {
|
37
|
+
throw new Error('_SCOPE must be string');
|
38
|
+
}
|
39
|
+
return ENV.luda._install(installer._SCOPE, installer);
|
40
|
+
}
|
41
|
+
if (installer instanceof Array || typeof installer === 'function') {
|
42
|
+
throw new Error('Unscoped installer must be object.');
|
43
|
+
}
|
44
|
+
installed = {};
|
45
|
+
for (name in installer) {
|
46
|
+
property = installer[name];
|
47
|
+
installed[name] = ENV.luda._install(name, property);
|
48
|
+
}
|
49
|
+
return installed;
|
50
|
+
};
|
51
|
+
ENV.luda._install = function(namespace, installer) {
|
52
|
+
var installedInstaller, installedName, ref;
|
53
|
+
if (ENV.luda[namespace]) {
|
54
|
+
console.warn(`Namespace ${namespace} is ocupied, sikp installation.`);
|
55
|
+
return ENV.luda[namespace];
|
56
|
+
}
|
57
|
+
ref = ENV.luda;
|
58
|
+
for (installedName in ref) {
|
59
|
+
installedInstaller = ref[installedName];
|
60
|
+
if (installer === installedInstaller) {
|
61
|
+
console.warn(`Installer is installed with name ${installedName}, skip installation.`);
|
62
|
+
return ENV.luda[installedName];
|
63
|
+
}
|
64
|
+
}
|
65
|
+
if (installer._install) {
|
66
|
+
if (typeof installer._install === 'function') {
|
67
|
+
return ENV.luda[namespace] = installer._install();
|
68
|
+
}
|
69
|
+
return ENV.luda[namespace] = installer._install;
|
70
|
+
}
|
71
|
+
return ENV.luda[namespace] = installer;
|
72
|
+
};
|
73
|
+
}
|
74
|
+
|
75
|
+
luda({
|
76
|
+
KEY_LEFT: 37,
|
77
|
+
KEY_UP: 38,
|
78
|
+
KEY_RIGHT: 39,
|
79
|
+
KEY_DOWN: 40,
|
80
|
+
KEY_TAB: 9,
|
81
|
+
KEY_ESC: 27,
|
82
|
+
KEY_ENTER: 13
|
83
|
+
});
|
84
|
+
|
85
|
+
luda({
|
86
|
+
$child: function(selector, $ancestor) {
|
87
|
+
if (!$ancestor) {
|
88
|
+
$ancestor = document;
|
89
|
+
}
|
90
|
+
return $ancestor.querySelector(selector);
|
91
|
+
},
|
92
|
+
$children: function(selector, $ancestor) {
|
93
|
+
var $descendant, descendants;
|
94
|
+
if (!$ancestor) {
|
95
|
+
$ancestor = document;
|
96
|
+
}
|
97
|
+
$descendant = this.$child(selector, $ancestor);
|
98
|
+
if ($descendant) {
|
99
|
+
return descendants = Array.from($ancestor.querySelectorAll(selector));
|
100
|
+
} else {
|
101
|
+
return descendants = [];
|
102
|
+
}
|
103
|
+
},
|
104
|
+
$unnested: function(selector, $ancestor, ancestorSelector) {
|
105
|
+
var descendants;
|
106
|
+
descendants = this.$children(selector, $ancestor);
|
107
|
+
return descendants.filter(($descendant) => {
|
108
|
+
if (this.$parent(ancestorSelector, $descendant) === $ancestor) {
|
109
|
+
return $descendant;
|
110
|
+
}
|
111
|
+
});
|
112
|
+
},
|
113
|
+
$parent: function(selector, $descendant) {
|
114
|
+
var $ancestor;
|
115
|
+
$ancestor = $descendant.parentNode;
|
116
|
+
if ($ancestor) {
|
117
|
+
if ($ancestor.matches && $ancestor.matches(selector)) {
|
118
|
+
return $ancestor;
|
119
|
+
} else {
|
120
|
+
return this.$parent(selector, $ancestor);
|
121
|
+
}
|
122
|
+
}
|
123
|
+
},
|
124
|
+
$parents: function(selector, $descendant, _ancestors) {
|
125
|
+
var $ancestor;
|
126
|
+
$ancestor = this.$parent(selector, $descendant);
|
127
|
+
if (!_ancestors) {
|
128
|
+
_ancestors = [];
|
129
|
+
}
|
130
|
+
if ($ancestor) {
|
131
|
+
_ancestors.push($ancestor);
|
132
|
+
return this.$parents(selector, $ancestor, _ancestors);
|
133
|
+
} else {
|
134
|
+
return _ancestors;
|
135
|
+
}
|
136
|
+
},
|
137
|
+
$after: function($node, $target) {
|
138
|
+
var $parent;
|
139
|
+
$parent = $target.parentNode;
|
140
|
+
if ($parent.lastChild === $target) {
|
141
|
+
return $parent.appendChild($node);
|
142
|
+
} else {
|
143
|
+
return $parent.insertBefore($node, $target.nextSibling);
|
144
|
+
}
|
145
|
+
},
|
146
|
+
$prepend: function($node, $target) {
|
147
|
+
if ($target.firstChild) {
|
148
|
+
return $target.insertBefore($node, $target.firstChild);
|
149
|
+
} else {
|
150
|
+
return $target.appendChild($node);
|
151
|
+
}
|
152
|
+
},
|
153
|
+
reflow: function($element) {
|
154
|
+
return $element.offsetHeight;
|
155
|
+
}
|
156
|
+
});
|
157
|
+
|
158
|
+
var splice = [].splice;
|
159
|
+
|
160
|
+
luda({
|
161
|
+
_SWIPE_DISTANCE: 10,
|
162
|
+
_EVENT_TYPE_PREFIX: 'luda',
|
163
|
+
_SWIPE_LEFT: 'swipeleft',
|
164
|
+
_SWIPE_RIGHT: 'swiperight',
|
165
|
+
_SWIPE_UP: 'swipeup',
|
166
|
+
_SWIPE_DOWN: 'swipedown',
|
167
|
+
_SWIPE_LEFT_OR_UP: 'swipeleft or swipeup',
|
168
|
+
_SWIPE_RIGHT_OR_DOWN: 'swiperight or swipedown',
|
169
|
+
_DOC_READY: 'docready',
|
170
|
+
_FORM_RESET: 'reset',
|
171
|
+
eventPath: function(event) {
|
172
|
+
var path;
|
173
|
+
if (event.composedPath) {
|
174
|
+
return path = event.composedPath();
|
175
|
+
} else if (event.path) {
|
176
|
+
return path = event.path;
|
177
|
+
} else {
|
178
|
+
return path = [event.target].concat(luda.$parents('*', event.target));
|
179
|
+
}
|
180
|
+
},
|
181
|
+
on: function(event, ...selector) {
|
182
|
+
var handler, ref;
|
183
|
+
ref = selector, [...selector] = ref, [handler] = splice.call(selector, -1);
|
184
|
+
switch (event) {
|
185
|
+
case this._DOC_READY:
|
186
|
+
return this._onDocReady(handler);
|
187
|
+
case this._FORM_RESET:
|
188
|
+
return this._onReset(selector[0], handler);
|
189
|
+
case this._SWIPE_LEFT:
|
190
|
+
case this._SWIPE_RIGHT:
|
191
|
+
case this._SWIPE_UP:
|
192
|
+
case this._SWIPE_DOWN:
|
193
|
+
case this._SWIPE_LEFT_OR_UP:
|
194
|
+
case this._SWIPE_RIGHT_OR_DOWN:
|
195
|
+
return this._onSwipe(event, selector[0], handler);
|
196
|
+
default:
|
197
|
+
return this._on(event, selector[0], handler);
|
198
|
+
}
|
199
|
+
},
|
200
|
+
onOpposite: function(event, selector, handler) {
|
201
|
+
var _self;
|
202
|
+
_self = this;
|
203
|
+
return document.addEventListener(event, function(e) {
|
204
|
+
var trigger;
|
205
|
+
trigger = _self.eventPath(e).every(function($element) {
|
206
|
+
return !$element.matches || !$element.matches(selector);
|
207
|
+
});
|
208
|
+
if (trigger) {
|
209
|
+
return handler(e);
|
210
|
+
}
|
211
|
+
});
|
212
|
+
},
|
213
|
+
dispatch: function($target, type, detail, options = {}) {
|
214
|
+
var evt;
|
215
|
+
if (typeof options.bubbles !== 'boolean') {
|
216
|
+
options.bubbles = true;
|
217
|
+
}
|
218
|
+
if (typeof options.cancelable !== 'boolean') {
|
219
|
+
options.cancelable = true;
|
220
|
+
}
|
221
|
+
if (typeof options.composed !== 'boolean') {
|
222
|
+
options.composed = true;
|
223
|
+
}
|
224
|
+
evt = new Event(`${this._EVENT_TYPE_PREFIX}:${type}`, options);
|
225
|
+
evt.detail = detail;
|
226
|
+
$target.dispatchEvent(evt);
|
227
|
+
return evt;
|
228
|
+
},
|
229
|
+
_onDocReady: function(handler) {
|
230
|
+
if (document.readyState === 'loading') {
|
231
|
+
return document.addEventListener('DOMContentLoaded', handler);
|
232
|
+
} else {
|
233
|
+
return handler();
|
234
|
+
}
|
235
|
+
},
|
236
|
+
_onReset: function(selector, handler) {
|
237
|
+
return document.addEventListener('reset', function(e) {
|
238
|
+
if (selector != null) {
|
239
|
+
return luda.$children(selector, e.target).forEach(function($element) {
|
240
|
+
return handler.bind($element)(e);
|
241
|
+
});
|
242
|
+
} else {
|
243
|
+
return handler(e);
|
244
|
+
}
|
245
|
+
});
|
246
|
+
},
|
247
|
+
_onSwipe: function(event, selector, handler) {
|
248
|
+
var $touchStartElement, _self, touchStartE, touchStartX, touchStartY, watch;
|
249
|
+
_self = this;
|
250
|
+
watch = false;
|
251
|
+
$touchStartElement = document;
|
252
|
+
touchStartE = null;
|
253
|
+
touchStartX = 0;
|
254
|
+
touchStartY = 0;
|
255
|
+
document.addEventListener('touchstart', function(e) {
|
256
|
+
if (e.touches.length === 1) {
|
257
|
+
touchStartX = e.touches[0].screenX;
|
258
|
+
touchStartY = e.touches[0].screenY;
|
259
|
+
if (selector != null) {
|
260
|
+
return _self.eventPath(e).some(function($element) {
|
261
|
+
if ($element.matches && $element.matches(selector)) {
|
262
|
+
$touchStartElement = $element;
|
263
|
+
touchStartE = e;
|
264
|
+
watch = true;
|
265
|
+
return true;
|
266
|
+
}
|
267
|
+
});
|
268
|
+
} else {
|
269
|
+
return watch = true;
|
270
|
+
}
|
271
|
+
}
|
272
|
+
});
|
273
|
+
return document.addEventListener('touchmove', function(e) {
|
274
|
+
var eventX, eventXOrY, eventY, touchDistanceX, touchDistanceY;
|
275
|
+
if (watch && e.touches.length === 1) {
|
276
|
+
touchDistanceX = e.touches[0].screenX - touchStartX;
|
277
|
+
touchDistanceY = e.touches[0].screenY - touchStartY;
|
278
|
+
eventX = void 0;
|
279
|
+
eventY = void 0;
|
280
|
+
eventXOrY = void 0;
|
281
|
+
if (Math.abs(touchDistanceX) >= _self._SWIPE_DISTANCE) {
|
282
|
+
if (touchDistanceX > 0) {
|
283
|
+
eventX = _self._SWIPE_RIGHT;
|
284
|
+
} else {
|
285
|
+
eventX = _self._SWIPE_LEFT;
|
286
|
+
}
|
287
|
+
}
|
288
|
+
if (Math.abs(touchDistanceY) >= _self._SWIPE_DISTANCE) {
|
289
|
+
if (touchDistanceY > 0) {
|
290
|
+
eventY = _self._SWIPE_DOWN;
|
291
|
+
} else {
|
292
|
+
eventY = _self._SWIPE_UP;
|
293
|
+
}
|
294
|
+
}
|
295
|
+
if (eventX === _self._SWIPE_LEFT || eventY === _self._SWIPE_UP) {
|
296
|
+
eventXOrY = _self._SWIPE_LEFT_OR_UP;
|
297
|
+
}
|
298
|
+
if (eventX === _self._SWIPE_RIGHT || eventY === _self._SWIPE_DOWN) {
|
299
|
+
eventXOrY = _self._SWIPE_RIGHT_OR_DOWN;
|
300
|
+
}
|
301
|
+
if (((eventX != null) && eventX === event) || ((eventY != null) && eventY === event) || eventXOrY === event) {
|
302
|
+
if (selector != null) {
|
303
|
+
return _self.eventPath(e).some(function($element) {
|
304
|
+
if ($element === $touchStartElement) {
|
305
|
+
watch = false;
|
306
|
+
handler.bind($element)(touchStartE, e);
|
307
|
+
return true;
|
308
|
+
}
|
309
|
+
});
|
310
|
+
} else {
|
311
|
+
watch = false;
|
312
|
+
return handler(touchStartE, e);
|
313
|
+
}
|
314
|
+
}
|
315
|
+
}
|
316
|
+
});
|
317
|
+
},
|
318
|
+
_on: function(event, selector, handler) {
|
319
|
+
var _self;
|
320
|
+
if (selector === window) {
|
321
|
+
return window.addEventListener(event, function(e) {
|
322
|
+
return handler(e);
|
323
|
+
});
|
324
|
+
} else {
|
325
|
+
_self = this;
|
326
|
+
return document.addEventListener(event, function(e) {
|
327
|
+
if (selector != null) {
|
328
|
+
return _self.eventPath(e).some(function($element) {
|
329
|
+
if ($element.matches && $element.matches(selector)) {
|
330
|
+
handler.bind($element)(e);
|
331
|
+
return true;
|
332
|
+
}
|
333
|
+
});
|
334
|
+
} else {
|
335
|
+
return handler(e);
|
336
|
+
}
|
337
|
+
});
|
338
|
+
}
|
339
|
+
}
|
340
|
+
});
|
341
|
+
|
342
|
+
luda({
|
343
|
+
except: function(element, arr) {
|
344
|
+
if (arr.includes(element)) {
|
345
|
+
return arr.splice(arr.indexOf(element), 1);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
});
|
349
|
+
|
350
|
+
var Singleton;
|
351
|
+
|
352
|
+
luda(Singleton = (function() {
|
353
|
+
class Singleton {
|
354
|
+
static active() {
|
355
|
+
return this._actived = true;
|
356
|
+
}
|
357
|
+
|
358
|
+
static deactive() {
|
359
|
+
return this._actived = false;
|
360
|
+
}
|
361
|
+
|
362
|
+
static _add(selector) {
|
363
|
+
if (typeof selector !== 'string') {
|
364
|
+
throw new Error(this._SELECTOR_INVALID_ERROR);
|
365
|
+
}
|
366
|
+
if (!this._SELECTORS.includes(selector)) {
|
367
|
+
this._SELECTORS.push(selector);
|
368
|
+
}
|
369
|
+
return this._mergeSelectors();
|
370
|
+
}
|
371
|
+
|
372
|
+
static _remove(selector) {
|
373
|
+
if (typeof selector !== 'string') {
|
374
|
+
throw new Error(this._SELECTOR_INVALID_ERROR);
|
375
|
+
}
|
376
|
+
luda.except(selector, this._SELECTORS);
|
377
|
+
return this._mergeSelectors();
|
378
|
+
}
|
379
|
+
|
380
|
+
static _mergeSelectors() {
|
381
|
+
return this._selector = this._SELECTORS.join(',');
|
382
|
+
}
|
383
|
+
|
384
|
+
static _install() {
|
385
|
+
var exposed;
|
386
|
+
if (this === Singleton) {
|
387
|
+
return this;
|
388
|
+
}
|
389
|
+
if (!this.hasOwnProperty('_SELECTORS')) {
|
390
|
+
this._SELECTORS = [];
|
391
|
+
}
|
392
|
+
this._mergeSelectors();
|
393
|
+
if (typeof this._init === 'function') {
|
394
|
+
exposed = this._init();
|
395
|
+
}
|
396
|
+
if (exposed) {
|
397
|
+
return exposed;
|
398
|
+
} else {
|
399
|
+
return this;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
}
|
404
|
+
Singleton._SCOPE = 'Singleton';
|
405
|
+
|
406
|
+
Singleton._SELECTOR_INVALID_ERROR = '@param selector must be a css selector string';
|
407
|
+
|
408
|
+
Singleton._SELECTORS = [];
|
409
|
+
|
410
|
+
Singleton._selector = '';
|
411
|
+
|
412
|
+
Singleton._actived = true;
|
413
|
+
|
414
|
+
return Singleton;
|
415
|
+
|
416
|
+
}).call(this));
|
417
|
+
|
418
|
+
luda((function() {
|
419
|
+
var _Class;
|
420
|
+
|
421
|
+
_Class = class extends luda.Singleton {
|
422
|
+
static _init() {
|
423
|
+
var self;
|
424
|
+
self = this;
|
425
|
+
return luda.on('keydown', function(e) {
|
426
|
+
if (self._actived && e.keyCode === luda.KEY_ENTER && e.target.matches(self._selector)) {
|
427
|
+
e.preventDefault();
|
428
|
+
return setTimeout(function() {
|
429
|
+
return e.target.click();
|
430
|
+
});
|
431
|
+
}
|
432
|
+
});
|
433
|
+
}
|
434
|
+
|
435
|
+
};
|
436
|
+
|
437
|
+
_Class._SCOPE = 'enterClick';
|
438
|
+
|
439
|
+
_Class._SELECTORS = ['input[type=checkbox]', 'input[type=radio]', '[tabindex]'];
|
440
|
+
|
441
|
+
return _Class;
|
442
|
+
|
443
|
+
}).call(this));
|
444
|
+
|
445
|
+
luda((function() {
|
446
|
+
var _Class;
|
447
|
+
|
448
|
+
_Class = class extends luda.Singleton {
|
449
|
+
static _removeFocusClassExcept($exception) {
|
450
|
+
return Array.from(this._$focus).forEach(($focus) => {
|
451
|
+
if ($focus !== $exception) {
|
452
|
+
return $focus.classList.remove(this._CSS_CLASS);
|
453
|
+
}
|
454
|
+
});
|
455
|
+
}
|
456
|
+
|
457
|
+
static _addFocusClassExceptHtmlAndBody($target) {
|
458
|
+
if ($target !== document.body && $target !== document.documentElement) {
|
459
|
+
return $target.classList.add(this._CSS_CLASS);
|
460
|
+
}
|
461
|
+
}
|
462
|
+
|
463
|
+
static _changeFocusStateOnKeyEvent(e) {
|
464
|
+
if (this._actived) {
|
465
|
+
this._removeFocusClassExcept(e.target);
|
466
|
+
return this._addFocusClassExceptHtmlAndBody(e.target);
|
467
|
+
}
|
468
|
+
}
|
469
|
+
|
470
|
+
static _changeFocusStateOnMouseDownEvent(e) {
|
471
|
+
var target;
|
472
|
+
if (this._actived) {
|
473
|
+
if (e.target.matches(this._PARENT_FOCUS_CHILDREN_SELECTOR)) {
|
474
|
+
target = luda.$parent(this._PARENT_FOCUS_SELECTOR, e.target);
|
475
|
+
} else {
|
476
|
+
target = e.target;
|
477
|
+
}
|
478
|
+
if (target.matches(this._selector)) {
|
479
|
+
this._removeFocusClassExcept(target);
|
480
|
+
return this._addFocusClassExceptHtmlAndBody(target);
|
481
|
+
} else {
|
482
|
+
return this._removeFocusClassExcept();
|
483
|
+
}
|
484
|
+
}
|
485
|
+
}
|
486
|
+
|
487
|
+
static _setElementPrototype() {
|
488
|
+
var blur, focus, self;
|
489
|
+
focus = HTMLElement.prototype.focus;
|
490
|
+
blur = HTMLElement.prototype.blur;
|
491
|
+
self = this;
|
492
|
+
HTMLElement.prototype.focus = function() {
|
493
|
+
focus.apply(this, arguments);
|
494
|
+
if (self._actived && document.activeElement === this) {
|
495
|
+
self._removeFocusClassExcept(this);
|
496
|
+
return self._addFocusClassExceptHtmlAndBody(this);
|
497
|
+
}
|
498
|
+
};
|
499
|
+
return HTMLElement.prototype.blur = function() {
|
500
|
+
blur.apply(this, arguments);
|
501
|
+
if (self._actived) {
|
502
|
+
return this.classList.remove(self._CSS_CLASS);
|
503
|
+
}
|
504
|
+
};
|
505
|
+
}
|
506
|
+
|
507
|
+
static _init() {
|
508
|
+
this._setElementPrototype();
|
509
|
+
luda.on('keydown', this._changeFocusStateOnKeyEvent.bind(this));
|
510
|
+
luda.on('keyup', this._changeFocusStateOnKeyEvent.bind(this));
|
511
|
+
luda.on('mousedown', this._changeFocusStateOnMouseDownEvent.bind(this));
|
512
|
+
luda.on('touchstart', this._TOUCHSTART_FOCUS_SELECTOR, this._changeFocusStateOnMouseDownEvent.bind(this));
|
513
|
+
return luda.on('focusin', this._changeFocusStateOnMouseDownEvent.bind(this));
|
514
|
+
}
|
515
|
+
|
516
|
+
};
|
517
|
+
|
518
|
+
_Class._SCOPE = 'focus';
|
519
|
+
|
520
|
+
_Class._CSS_CLASS = 'focus';
|
521
|
+
|
522
|
+
// mouse focusable selectors
|
523
|
+
_Class._SELECTORS = ['select', 'textarea', ':not(.btn-check):not(.btn-radio):not(.btn-file) > input:not([type=button]):not([type=submit]):not([type=reset])'];
|
524
|
+
|
525
|
+
_Class._TOUCHSTART_FOCUS_SELECTOR = 'input[type=range]';
|
526
|
+
|
527
|
+
_Class._PARENT_FOCUS_SELECTOR = 'select[multiple]';
|
528
|
+
|
529
|
+
_Class._PARENT_FOCUS_CHILDREN_SELECTOR = `${_Class._PARENT_FOCUS_SELECTOR} *`;
|
530
|
+
|
531
|
+
_Class._$focus = document.getElementsByClassName(_Class._CSS_CLASS);
|
532
|
+
|
533
|
+
return _Class;
|
534
|
+
|
535
|
+
}).call(this));
|
536
|
+
|
537
|
+
luda((function() {
|
538
|
+
var _Class;
|
539
|
+
|
540
|
+
_Class = class extends luda.Singleton {
|
541
|
+
static _querySameName$radios($radio) {
|
542
|
+
var $inputs, selector;
|
543
|
+
if ($radio.name) {
|
544
|
+
selector = `${this._selector}[name=${$radio.name}]`;
|
545
|
+
} else {
|
546
|
+
selector = this._selector;
|
547
|
+
}
|
548
|
+
$inputs = luda.$children(selector);
|
549
|
+
return $inputs.filter(function($input) {
|
550
|
+
return $input.tabIndex >= 0;
|
551
|
+
});
|
552
|
+
}
|
553
|
+
|
554
|
+
static _query$prev$next($radio) {
|
555
|
+
var $next, $prev, $sameNameRadios, radioIndex;
|
556
|
+
$sameNameRadios = this._querySameName$radios($radio);
|
557
|
+
radioIndex = $sameNameRadios.indexOf($radio);
|
558
|
+
$prev = $sameNameRadios[radioIndex - 1];
|
559
|
+
$next = $sameNameRadios[radioIndex + 1];
|
560
|
+
return {$prev, $next};
|
561
|
+
}
|
562
|
+
|
563
|
+
static _init() {
|
564
|
+
var self;
|
565
|
+
self = this;
|
566
|
+
return luda.on('keydown', function(e) {
|
567
|
+
var $next, $prev;
|
568
|
+
if (self._actived && e.keyCode === luda.KEY_TAB && e.target.nodeName.toUpperCase() === 'INPUT' && e.target.type === 'radio') {
|
569
|
+
if (e.shiftKey) {
|
570
|
+
if ($prev = self._query$prev$next(e.target).$prev) {
|
571
|
+
e.preventDefault();
|
572
|
+
return $prev.focus();
|
573
|
+
}
|
574
|
+
} else {
|
575
|
+
if ($next = self._query$prev$next(e.target).$next) {
|
576
|
+
e.preventDefault();
|
577
|
+
return $next.focus();
|
578
|
+
}
|
579
|
+
}
|
580
|
+
}
|
581
|
+
});
|
582
|
+
}
|
583
|
+
|
584
|
+
};
|
585
|
+
|
586
|
+
_Class._SCOPE = 'radioTab';
|
587
|
+
|
588
|
+
_Class._SELECTORS = ['input[type=radio]:not([disabled])'];
|
589
|
+
|
590
|
+
return _Class;
|
591
|
+
|
592
|
+
}).call(this));
|
593
|
+
|
594
|
+
var Component;
|
595
|
+
|
596
|
+
luda(Component = (function() {
|
597
|
+
class Component {
|
598
|
+
_hasDescendant(descendant) {
|
599
|
+
if (this._children.length && descendant) {
|
600
|
+
if (this._children.includes(descendant)) {
|
601
|
+
return true;
|
602
|
+
}
|
603
|
+
return this._children.some(function(child) {
|
604
|
+
return child._hasDescendant(descendant);
|
605
|
+
});
|
606
|
+
} else {
|
607
|
+
return false;
|
608
|
+
}
|
609
|
+
}
|
610
|
+
|
611
|
+
_observe() {
|
612
|
+
this._observer = new MutationObserver(this._onMutations.bind(this));
|
613
|
+
return this._observer.observe(this._$component, this.constructor._observerConfig);
|
614
|
+
}
|
615
|
+
|
616
|
+
_disconnect() {
|
617
|
+
this._observer.disconnect();
|
618
|
+
return this._observer = null;
|
619
|
+
}
|
620
|
+
|
621
|
+
static create($component) {
|
622
|
+
var $family, componentIsElementInstance, instance, parent;
|
623
|
+
componentIsElementInstance = $component instanceof Element;
|
624
|
+
if (!componentIsElementInstance) {
|
625
|
+
throw new Error(this._$COMPONENT_INVALID_ERROR);
|
626
|
+
}
|
627
|
+
$family = this._query$family($component);
|
628
|
+
instance = this.query($component);
|
629
|
+
if ($family._$parent) {
|
630
|
+
if (parent = this.query($family._$parent)) {
|
631
|
+
if (!instance) {
|
632
|
+
this._instances.push(instance = this._createInstance($component));
|
633
|
+
}
|
634
|
+
if (instance._parent !== parent) {
|
635
|
+
parent._children.push(instance) && (instance._parent = parent);
|
636
|
+
}
|
637
|
+
$family._$children.forEach(($child) => {
|
638
|
+
return this.create($child);
|
639
|
+
});
|
640
|
+
return instance;
|
641
|
+
} else {
|
642
|
+
this.create($family._$parent);
|
643
|
+
return this.query($component);
|
644
|
+
}
|
645
|
+
} else {
|
646
|
+
if (!instance) {
|
647
|
+
this._instances.push(instance = this._createInstance($component));
|
648
|
+
}
|
649
|
+
$family._$children.forEach(($child) => {
|
650
|
+
return this.create($child);
|
651
|
+
});
|
652
|
+
return instance;
|
653
|
+
}
|
654
|
+
}
|
655
|
+
|
656
|
+
static destroy(instance$component) {
|
657
|
+
var attribute, instance, results, value;
|
658
|
+
instance = this.query(instance$component);
|
659
|
+
if (instance) {
|
660
|
+
if (instance._observer) {
|
661
|
+
instance._disconnect();
|
662
|
+
}
|
663
|
+
if (instance._destroy) {
|
664
|
+
instance._destroy();
|
665
|
+
}
|
666
|
+
while (instance._children.length) {
|
667
|
+
this.destroy(instance._children[0]);
|
668
|
+
}
|
669
|
+
if (instance._parent) {
|
670
|
+
luda.except(instance, instance._parent._children);
|
671
|
+
}
|
672
|
+
luda.except(instance, this._instances);
|
673
|
+
results = [];
|
674
|
+
for (attribute in instance) {
|
675
|
+
value = instance[attribute];
|
676
|
+
results.push(instance[attribute] = null);
|
677
|
+
}
|
678
|
+
return results;
|
679
|
+
}
|
680
|
+
}
|
681
|
+
|
682
|
+
static query(instance$component) {
|
683
|
+
var instance;
|
684
|
+
instance = null;
|
685
|
+
if (instance$component instanceof this && this._instances.includes(instance$component)) {
|
686
|
+
instance = instance$component;
|
687
|
+
} else if (instance$component instanceof Element) {
|
688
|
+
this._instances.some(function(inited) {
|
689
|
+
if (inited._$component === instance$component) {
|
690
|
+
instance = inited;
|
691
|
+
return true;
|
692
|
+
}
|
693
|
+
});
|
694
|
+
}
|
695
|
+
return instance;
|
696
|
+
}
|
697
|
+
|
698
|
+
static _query$family($component) {
|
699
|
+
var _$children, _$parent;
|
700
|
+
_$parent = null;
|
701
|
+
_$children = [];
|
702
|
+
if (this._SELECTOR) {
|
703
|
+
_$parent = luda.$parent(this._SELECTOR, $component);
|
704
|
+
_$children = luda.$unnested(this._SELECTOR, $component, this._SELECTOR);
|
705
|
+
}
|
706
|
+
return {_$parent, _$children};
|
707
|
+
}
|
708
|
+
|
709
|
+
static _createInstance($component) {
|
710
|
+
var instance;
|
711
|
+
instance = new this();
|
712
|
+
instance._$component = $component;
|
713
|
+
instance._parent = null;
|
714
|
+
instance._children = [];
|
715
|
+
instance._observer = null;
|
716
|
+
if (instance._constructor) {
|
717
|
+
instance._constructor();
|
718
|
+
}
|
719
|
+
if (!(instance._observer && instance._onMutations && this._observerConfig)) {
|
720
|
+
instance._observe();
|
721
|
+
}
|
722
|
+
return instance;
|
723
|
+
}
|
724
|
+
|
725
|
+
static _observe(classObj) {
|
726
|
+
if (!Component._observer) {
|
727
|
+
Component._observer = new MutationObserver(function(mutations) {
|
728
|
+
return mutations.forEach(function(mutation) {
|
729
|
+
var $addedNodes, $removedNodes;
|
730
|
+
$removedNodes = Array.from(mutation.removedNodes);
|
731
|
+
$addedNodes = Array.from(mutation.addedNodes);
|
732
|
+
$removedNodes.forEach(function($node) {
|
733
|
+
if ($node instanceof Element) {
|
734
|
+
return Component._Observed.forEach(function(Observed) {
|
735
|
+
var $destroies;
|
736
|
+
if ($node.matches(Observed._SELECTOR)) {
|
737
|
+
return Observed.destroy($node);
|
738
|
+
} else {
|
739
|
+
$destroies = luda.$children(Observed._SELECTOR, $node);
|
740
|
+
return $destroies.forEach(function($destroy) {
|
741
|
+
return Observed.destroy($destroy);
|
742
|
+
});
|
743
|
+
}
|
744
|
+
});
|
745
|
+
}
|
746
|
+
});
|
747
|
+
return $addedNodes.forEach(function($node) {
|
748
|
+
if ($node instanceof Element) {
|
749
|
+
return Component._Observed.forEach(function(Observed) {
|
750
|
+
var $creates;
|
751
|
+
if ($node.matches(Observed._SELECTOR)) {
|
752
|
+
return Observed.create($node);
|
753
|
+
} else {
|
754
|
+
$creates = luda.$children(Observed._SELECTOR, $node);
|
755
|
+
return $creates.forEach(function($create) {
|
756
|
+
return Observed.create($create);
|
757
|
+
});
|
758
|
+
}
|
759
|
+
});
|
760
|
+
}
|
761
|
+
});
|
762
|
+
});
|
763
|
+
});
|
764
|
+
Component._observer.observe(document.documentElement, Component._observerConfig);
|
765
|
+
}
|
766
|
+
if (!Component._Observed.includes(classObj)) {
|
767
|
+
return Component._Observed.push(classObj);
|
768
|
+
}
|
769
|
+
}
|
770
|
+
|
771
|
+
static _install() {
|
772
|
+
var exposed, self;
|
773
|
+
self = this;
|
774
|
+
if (this === Component) {
|
775
|
+
return this;
|
776
|
+
}
|
777
|
+
if (!(this._SELECTOR || typeof this._SELECTOR !== 'string')) {
|
778
|
+
throw new Error(this._COMPONENT_NO_SELECTOR_ERROR);
|
779
|
+
}
|
780
|
+
if (!this.hasOwnProperty('_instances')) {
|
781
|
+
this._instances = [];
|
782
|
+
}
|
783
|
+
if (typeof this._init === 'function') {
|
784
|
+
exposed = this._init();
|
785
|
+
}
|
786
|
+
luda.on(luda._DOC_READY, function() {
|
787
|
+
luda.$children(self._SELECTOR).forEach(function($component) {
|
788
|
+
return self.create($component);
|
789
|
+
});
|
790
|
+
return Component._observe(self);
|
791
|
+
});
|
792
|
+
if (exposed) {
|
793
|
+
return exposed;
|
794
|
+
} else {
|
795
|
+
return this;
|
796
|
+
}
|
797
|
+
}
|
798
|
+
|
799
|
+
}
|
800
|
+
Component._SCOPE = 'Component';
|
801
|
+
|
802
|
+
Component._COMPONENT_NO_SELECTOR_ERROR = 'Extended component must has a css selector';
|
803
|
+
|
804
|
+
Component._$COMPONENT_INVALID_ERROR = '@param $component must be an instance of Element';
|
805
|
+
|
806
|
+
Component._SELECTOR = '';
|
807
|
+
|
808
|
+
Component._instances = [];
|
809
|
+
|
810
|
+
Component._Observed = [];
|
811
|
+
|
812
|
+
Component._observer = null;
|
813
|
+
|
814
|
+
Component._observerConfig = {
|
815
|
+
childList: true,
|
816
|
+
subtree: true
|
817
|
+
};
|
818
|
+
|
819
|
+
return Component;
|
820
|
+
|
821
|
+
}).call(this));
|
822
|
+
|
823
|
+
luda((function() {
|
824
|
+
var _Class;
|
825
|
+
|
826
|
+
_Class = class extends luda.Component {
|
827
|
+
_getConfig() {
|
828
|
+
var _isReadonly, _originalTabIndex, readonly;
|
829
|
+
readonly = this._$component.getAttribute(this.constructor._READONLY_ATTRIBUTE);
|
830
|
+
_isReadonly = readonly !== this.constructor._READONLY_FALSE_VALUE;
|
831
|
+
_originalTabIndex = this._$component.tabIndex;
|
832
|
+
return {_isReadonly, _originalTabIndex};
|
833
|
+
}
|
834
|
+
|
835
|
+
_constructor() {
|
836
|
+
({_isReadonly: this._isReadonly, _originalTabIndex: this._originalTabIndex} = this._getConfig());
|
837
|
+
return this._setTabIndex();
|
838
|
+
}
|
839
|
+
|
840
|
+
_onMutations() {
|
841
|
+
return this._constructor();
|
842
|
+
}
|
843
|
+
|
844
|
+
_setTabIndex() {
|
845
|
+
if (this._isReadonly) {
|
846
|
+
return this._$component.tabIndex = -1;
|
847
|
+
} else {
|
848
|
+
return this._$component.tabIndex = this._originalTabIndex;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
|
852
|
+
};
|
853
|
+
|
854
|
+
_Class._SCOPE = 'readonly';
|
855
|
+
|
856
|
+
_Class._READONLY_ATTRIBUTE = 'data-readonly';
|
857
|
+
|
858
|
+
_Class._READONLY_FALSE_VALUE = 'false';
|
859
|
+
|
860
|
+
_Class._SELECTOR = `[${_Class._READONLY_ATTRIBUTE}]`;
|
861
|
+
|
862
|
+
_Class._observerConfig = {
|
863
|
+
attributes: true,
|
864
|
+
attributeFilter: [_Class._READONLY_ATTRIBUTE]
|
865
|
+
};
|
866
|
+
|
867
|
+
return _Class;
|
868
|
+
|
869
|
+
}).call(this));
|
870
|
+
|
871
|
+
luda((function() {
|
872
|
+
var _Class;
|
873
|
+
|
874
|
+
_Class = class extends luda.Singleton {
|
875
|
+
static active(name$target) {
|
876
|
+
return this._query$targets(name$target).forEach(($target) => {
|
877
|
+
$target.classList.add(this._ACTIVE_CSS_CLASS);
|
878
|
+
return luda.dispatch($target, this._ACTIVED_EVENT_TYPE);
|
879
|
+
});
|
880
|
+
}
|
881
|
+
|
882
|
+
static deactive(name$target) {
|
883
|
+
return this._query$targets(name$target).forEach(($target) => {
|
884
|
+
$target.classList.remove(this._ACTIVE_CSS_CLASS);
|
885
|
+
return luda.dispatch($target, this._DEACTIVED_EVENT_TYPE);
|
886
|
+
});
|
887
|
+
}
|
888
|
+
|
889
|
+
static toggle(name$target) {
|
890
|
+
return this._query$targets(name$target).forEach(($target) => {
|
891
|
+
if ($target.classList.contains(this._ACTIVE_CSS_CLASS)) {
|
892
|
+
return this.deactive($target);
|
893
|
+
} else {
|
894
|
+
return this.active($target);
|
895
|
+
}
|
896
|
+
});
|
897
|
+
}
|
898
|
+
|
899
|
+
static _query$targets(name$target) {
|
900
|
+
if (name$target instanceof Element) {
|
901
|
+
return [name$target];
|
902
|
+
} else {
|
903
|
+
return luda.$children(`[${this._TOGGLE_TARGET_ATTRIBUTE}=${name$target}]`);
|
904
|
+
}
|
905
|
+
}
|
906
|
+
|
907
|
+
static _init() {
|
908
|
+
var self;
|
909
|
+
self = this;
|
910
|
+
return luda.on('click', this._selector, function(e) {
|
911
|
+
var toggleChecked;
|
912
|
+
toggleChecked = false;
|
913
|
+
return luda.eventPath(e).some(function($path) {
|
914
|
+
var $toggle, toggleName;
|
915
|
+
if ($path instanceof Element) {
|
916
|
+
if ($path.hasAttribute(self._TOGGLE_ATTRIBUTE) || $path.hasAttribute(self._TOGGLE_FOR_ATTRIBUTE)) {
|
917
|
+
if (toggleName = $path.getAttribute(self._TOGGLE_FOR_ATTRIBUTE)) {
|
918
|
+
self.toggle(toggleName);
|
919
|
+
toggleChecked = true;
|
920
|
+
}
|
921
|
+
if ($path.hasAttribute(self._TOGGLE_ATTRIBUTE)) {
|
922
|
+
if ($path.hasAttribute(self._TOGGLE_TARGET_ATTRIBUTE)) {
|
923
|
+
$toggle = $path;
|
924
|
+
} else {
|
925
|
+
$toggle = luda.$parent(`[${self._TOGGLE_TARGET_ATTRIBUTE}]`, $path);
|
926
|
+
}
|
927
|
+
if ($toggle) {
|
928
|
+
self.toggle($toggle);
|
929
|
+
return toggleChecked = true;
|
930
|
+
}
|
931
|
+
}
|
932
|
+
} else if ($path.hasAttribute(self._NONE_TOGGLE_ATTRIBUTE)) {
|
933
|
+
return toggleChecked = true;
|
934
|
+
}
|
935
|
+
}
|
936
|
+
});
|
937
|
+
});
|
938
|
+
}
|
939
|
+
|
940
|
+
};
|
941
|
+
|
942
|
+
_Class._SCOPE = 'toggle';
|
943
|
+
|
944
|
+
_Class._TOGGLE_TARGET_ATTRIBUTE = 'data-toggle-target';
|
945
|
+
|
946
|
+
_Class._TOGGLE_ATTRIBUTE = 'data-toggle';
|
947
|
+
|
948
|
+
_Class._TOGGLE_FOR_ATTRIBUTE = 'data-toggle-for';
|
949
|
+
|
950
|
+
_Class._NONE_TOGGLE_ATTRIBUTE = 'data-none-toggle';
|
951
|
+
|
952
|
+
_Class._ACTIVE_CSS_CLASS = 'toggle-active';
|
953
|
+
|
954
|
+
_Class._SELECTORS = [`[${_Class._TOGGLE_FOR_ATTRIBUTE}]`, `[${_Class._TOGGLE_ATTRIBUTE}]`];
|
955
|
+
|
956
|
+
_Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
|
957
|
+
|
958
|
+
_Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
|
959
|
+
|
960
|
+
return _Class;
|
961
|
+
|
962
|
+
}).call(this));
|
963
|
+
|
964
|
+
luda((function() {
|
965
|
+
var _Class;
|
966
|
+
|
967
|
+
_Class = class extends luda.Component {
|
968
|
+
_getConfig() {
|
969
|
+
var _$file, _$simulator;
|
970
|
+
_$file = luda.$child(this.constructor._FILE_SELECTOR, this._$component);
|
971
|
+
_$simulator = luda.$child(this.constructor._SIMULATOR_SELECTOR, this._$component);
|
972
|
+
return {_$file, _$simulator};
|
973
|
+
}
|
974
|
+
|
975
|
+
_constructor() {
|
976
|
+
({_$file: this._$file, _$simulator: this._$simulator} = this._getConfig());
|
977
|
+
return this._init();
|
978
|
+
}
|
979
|
+
|
980
|
+
_onMutations() {
|
981
|
+
return this._constructor();
|
982
|
+
}
|
983
|
+
|
984
|
+
_insertSimulator() {
|
985
|
+
this._$simulator = document.createElement('input');
|
986
|
+
this._$simulator.tabIndex = -1;
|
987
|
+
return luda.$after(this._$simulator, this._$file);
|
988
|
+
}
|
989
|
+
|
990
|
+
_setPlaceholderValue() {
|
991
|
+
return this._$simulator.placeholder = this._$file.getAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE);
|
992
|
+
}
|
993
|
+
|
994
|
+
_setSimulatorValue() {
|
995
|
+
var values;
|
996
|
+
values = [];
|
997
|
+
Array.from(this._$file.files).map(function(file) {
|
998
|
+
return values.push(file.name);
|
999
|
+
});
|
1000
|
+
if (values.length) {
|
1001
|
+
return this._$simulator.value = values.join(this.constructor._VALUE_SPLITOR);
|
1002
|
+
} else if (this._$file.hasAttribute(this.constructor._VALUE_ATTRIBUTE)) {
|
1003
|
+
return this._$simulator.value = this._$file.getAttribute(this.constructor._VALUE_ATTRIBUTE);
|
1004
|
+
}
|
1005
|
+
}
|
1006
|
+
|
1007
|
+
_init() {
|
1008
|
+
if (this._$file) {
|
1009
|
+
if (!this._$simulator) {
|
1010
|
+
this._insertSimulator();
|
1011
|
+
}
|
1012
|
+
if (this._$file.hasAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE)) {
|
1013
|
+
this._setPlaceholderValue();
|
1014
|
+
}
|
1015
|
+
return this._setSimulatorValue();
|
1016
|
+
}
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
static _init() {
|
1020
|
+
var self;
|
1021
|
+
self = this;
|
1022
|
+
luda.on('change', `${this._SELECTOR} ${this._FILE_SELECTOR}`, function(e) {
|
1023
|
+
return self.query(luda.$parent(self._SELECTOR, this))._setSimulatorValue();
|
1024
|
+
});
|
1025
|
+
return luda.on(luda._FORM_RESET, this._SELECTOR, function(e) {
|
1026
|
+
return setTimeout(() => {
|
1027
|
+
return self.query(this)._setSimulatorValue();
|
1028
|
+
});
|
1029
|
+
});
|
1030
|
+
}
|
1031
|
+
|
1032
|
+
};
|
1033
|
+
|
1034
|
+
_Class._SCOPE = 'fmFile';
|
1035
|
+
|
1036
|
+
_Class._VALUE_SPLITOR = ' ';
|
1037
|
+
|
1038
|
+
_Class._SELECTOR = '.fm-file';
|
1039
|
+
|
1040
|
+
_Class._FILE_SELECTOR = 'input[type=file]';
|
1041
|
+
|
1042
|
+
_Class._SIMULATOR_SELECTOR = 'input:not([type=file])';
|
1043
|
+
|
1044
|
+
_Class._PLACEHOLDER_ATTRIBUTE = 'placeholder';
|
1045
|
+
|
1046
|
+
_Class._VALUE_ATTRIBUTE = 'value';
|
1047
|
+
|
1048
|
+
_Class._observerConfig = {
|
1049
|
+
childList: true,
|
1050
|
+
subtree: true
|
1051
|
+
};
|
1052
|
+
|
1053
|
+
return _Class;
|
1054
|
+
|
1055
|
+
}).call(this));
|
1056
|
+
|
1057
|
+
luda((function() {
|
1058
|
+
var _Class;
|
1059
|
+
|
1060
|
+
_Class = class extends luda.Component {
|
1061
|
+
select(indexOrIndexArray) {
|
1062
|
+
var selectedIndexes;
|
1063
|
+
if (this._$select.multiple) {
|
1064
|
+
if (this._$multipleSelectPlaceholder) {
|
1065
|
+
selectedIndexes = indexOrIndexArray;
|
1066
|
+
} else {
|
1067
|
+
selectedIndexes = indexOrIndexArray.map(function(index) {
|
1068
|
+
return index + 1;
|
1069
|
+
});
|
1070
|
+
}
|
1071
|
+
Array.from(this._$select.options).forEach(function($option, index) {
|
1072
|
+
return $option.selected = selectedIndexes.includes(index);
|
1073
|
+
});
|
1074
|
+
return this._markSelectedOption();
|
1075
|
+
} else {
|
1076
|
+
this._$select.selectedIndex = selectedIndex;
|
1077
|
+
this._setSingleSelectSimulatorValue();
|
1078
|
+
return this._markSelectedOption();
|
1079
|
+
}
|
1080
|
+
}
|
1081
|
+
|
1082
|
+
_getConfig() {
|
1083
|
+
var _$defaultSelectedOptions, _$multipleSelectPlaceholder, _$select, _$singleSelectSimulator, _defaultSelectedOptionMarked;
|
1084
|
+
_$select = luda.$child(this.constructor._SELECT_SELECTOR, this._$component);
|
1085
|
+
_$singleSelectSimulator = luda.$child(this.constructor._SINGLE_SELECT_SIMULATOR_SELECTOR, this._$component);
|
1086
|
+
_$multipleSelectPlaceholder = luda.$child(`.${this.constructor._MULTIPLE_SELECT_PLACEHOLDER_CSS_CLASS}`, this._$component);
|
1087
|
+
_$defaultSelectedOptions = luda.$children(`[${this.constructor._DEFAULT_SELECTED_OPTION_ATTRIBUTE}]`, this._$component);
|
1088
|
+
_defaultSelectedOptionMarked = this._$component.hasAttribute(this.constructor._INITED_ATTRIBUTE);
|
1089
|
+
return {_$select, _$singleSelectSimulator, _$multipleSelectPlaceholder, _$defaultSelectedOptions, _defaultSelectedOptionMarked};
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
_constructor() {
|
1093
|
+
({_$select: this._$select, _$singleSelectSimulator: this._$singleSelectSimulator, _$multipleSelectPlaceholder: this._$multipleSelectPlaceholder, _$defaultSelectedOptions: this._$defaultSelectedOptions, _defaultSelectedOptionMarked: this._defaultSelectedOptionMarked} = this._getConfig());
|
1094
|
+
if (this._$select) {
|
1095
|
+
if (this._$select.multiple) {
|
1096
|
+
return this._initMultipleSelect();
|
1097
|
+
} else {
|
1098
|
+
return this._initSingleSelect();
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
}
|
1102
|
+
|
1103
|
+
_onMutations() {
|
1104
|
+
return this._constructor();
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
_markSelectedOption() {
|
1108
|
+
if (this._observer) {
|
1109
|
+
this._disconnect();
|
1110
|
+
}
|
1111
|
+
Array.from(this._$select.options).forEach(function($option) {
|
1112
|
+
if ($option.selected) {
|
1113
|
+
return $option.setAttribute('selected', 'selected');
|
1114
|
+
} else {
|
1115
|
+
return $option.removeAttribute('selected');
|
1116
|
+
}
|
1117
|
+
});
|
1118
|
+
if (!this._observer) {
|
1119
|
+
return this._observe();
|
1120
|
+
}
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
_markDefaultSelectedOption() {
|
1124
|
+
this._$component.setAttribute(this.constructor._INITED_ATTRIBUTE, '');
|
1125
|
+
return Array.from(this._$select.options).forEach(($option) => {
|
1126
|
+
if ($option.selected) {
|
1127
|
+
return $option.setAttribute(this.constructor._DEFAULT_SELECTED_OPTION_ATTRIBUTE, '');
|
1128
|
+
}
|
1129
|
+
});
|
1130
|
+
}
|
1131
|
+
|
1132
|
+
_setSingleSelectedDefaultSelectedOption() {
|
1133
|
+
var hasSelected;
|
1134
|
+
hasSelected = Array.from(this._$select.options).some(function($option) {
|
1135
|
+
return $option.getAttribute('selected') === 'selected';
|
1136
|
+
});
|
1137
|
+
if (!hasSelected) {
|
1138
|
+
return this._$select.selectedIndex = -1;
|
1139
|
+
}
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
_insertSingleSelectSimulator() {
|
1143
|
+
this._$singleSelectSimulator = document.createElement('input');
|
1144
|
+
this._$singleSelectSimulator.tabIndex = -1;
|
1145
|
+
return luda.$after(this._$singleSelectSimulator, this._$select);
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
_setSingleSelectPlaceholderValue() {
|
1149
|
+
return this._$singleSelectSimulator.placeholder = this._$select.getAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE);
|
1150
|
+
}
|
1151
|
+
|
1152
|
+
_setSingleSelectSimulatorValue() {
|
1153
|
+
var $selectedOption;
|
1154
|
+
if ($selectedOption = this._$select.options[this._$select.selectedIndex]) {
|
1155
|
+
return this._$singleSelectSimulator.value = $selectedOption.innerText;
|
1156
|
+
} else {
|
1157
|
+
return this._$singleSelectSimulator.value = '';
|
1158
|
+
}
|
1159
|
+
}
|
1160
|
+
|
1161
|
+
_initSingleSelect() {
|
1162
|
+
if (!this._$singleSelectSimulator) {
|
1163
|
+
this._insertSingleSelectSimulator();
|
1164
|
+
}
|
1165
|
+
if (this._$select.hasAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE)) {
|
1166
|
+
this._setSingleSelectedDefaultSelectedOption();
|
1167
|
+
this._setSingleSelectPlaceholderValue();
|
1168
|
+
}
|
1169
|
+
if (!this._defaultSelectedOptionMarked) {
|
1170
|
+
this._markDefaultSelectedOption();
|
1171
|
+
}
|
1172
|
+
this._setSingleSelectSimulatorValue();
|
1173
|
+
return this._markSelectedOption();
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
_insertMultipleSelectBlankOption() {
|
1177
|
+
this._$multipleSelectPlaceholder = document.createElement('option');
|
1178
|
+
this._$multipleSelectPlaceholder.className = this.constructor._MULTIPLE_SELECT_PLACEHOLDER_CSS_CLASS;
|
1179
|
+
this._$multipleSelectPlaceholder.disabled = true;
|
1180
|
+
return luda.$prepend(this._$multipleSelectPlaceholder, this._$select);
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
_setMultipleSelectPlaceholderValue() {
|
1184
|
+
return this._$multipleSelectPlaceholder.innerText = this._$select.getAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE);
|
1185
|
+
}
|
1186
|
+
|
1187
|
+
_initMultipleSelect() {
|
1188
|
+
if (!this._$multipleSelectPlaceholder) {
|
1189
|
+
if (this._$select.hasAttribute(this.constructor._PLACEHOLDER_ATTRIBUTE)) {
|
1190
|
+
this._insertMultipleSelectBlankOption();
|
1191
|
+
this._setMultipleSelectPlaceholderValue();
|
1192
|
+
}
|
1193
|
+
}
|
1194
|
+
if (!this._defaultSelectedOptionMarked) {
|
1195
|
+
return this._markDefaultSelectedOption();
|
1196
|
+
}
|
1197
|
+
}
|
1198
|
+
|
1199
|
+
_reset() {
|
1200
|
+
if (this._$select) {
|
1201
|
+
Array.from(this._$select.options).forEach(($option) => {
|
1202
|
+
return $option.selected = this._$defaultSelectedOptions.includes($option);
|
1203
|
+
});
|
1204
|
+
if (!this._$select.multiple) {
|
1205
|
+
this._setSingleSelectSimulatorValue();
|
1206
|
+
}
|
1207
|
+
return this._markSelectedOption();
|
1208
|
+
}
|
1209
|
+
}
|
1210
|
+
|
1211
|
+
static _init() {
|
1212
|
+
var self;
|
1213
|
+
self = this;
|
1214
|
+
luda.on('change', `${this._SELECTOR} ${this._SELECT_SELECTOR}`, function(e) {
|
1215
|
+
var instance;
|
1216
|
+
instance = self.query(luda.$parent(self._SELECTOR, this));
|
1217
|
+
if (!this.multiple) {
|
1218
|
+
instance._setSingleSelectSimulatorValue();
|
1219
|
+
}
|
1220
|
+
return instance._markSelectedOption();
|
1221
|
+
});
|
1222
|
+
return luda.on(luda._FORM_RESET, this._SELECTOR, function(e) {
|
1223
|
+
return setTimeout(() => {
|
1224
|
+
return self.query(this)._reset();
|
1225
|
+
});
|
1226
|
+
});
|
1227
|
+
}
|
1228
|
+
|
1229
|
+
};
|
1230
|
+
|
1231
|
+
_Class._SCOPE = 'fmSelect';
|
1232
|
+
|
1233
|
+
_Class._SELECTOR = '.fm-select';
|
1234
|
+
|
1235
|
+
_Class._SELECT_SELECTOR = 'select';
|
1236
|
+
|
1237
|
+
_Class._SINGLE_SELECT_SIMULATOR_SELECTOR = 'input';
|
1238
|
+
|
1239
|
+
_Class._PLACEHOLDER_ATTRIBUTE = 'placeholder';
|
1240
|
+
|
1241
|
+
_Class._MULTIPLE_SELECT_PLACEHOLDER_CSS_CLASS = 'fm-select-multiple-placeholder';
|
1242
|
+
|
1243
|
+
_Class._DEFAULT_SELECTED_OPTION_ATTRIBUTE = 'data-fm-select-default-selected';
|
1244
|
+
|
1245
|
+
_Class._INITED_ATTRIBUTE = 'data-fm-select-inited';
|
1246
|
+
|
1247
|
+
_Class._observerConfig = {
|
1248
|
+
childList: true,
|
1249
|
+
attributes: true,
|
1250
|
+
subtree: true,
|
1251
|
+
attributeFilter: ['selected']
|
1252
|
+
};
|
1253
|
+
|
1254
|
+
return _Class;
|
1255
|
+
|
1256
|
+
}).call(this));
|
1257
|
+
|
1258
|
+
luda((function() {
|
1259
|
+
var _Class;
|
1260
|
+
|
1261
|
+
_Class = class extends luda.Component {
|
1262
|
+
|
1263
|
+
// public
|
1264
|
+
active(index) {
|
1265
|
+
var action, activedIndex;
|
1266
|
+
if (this._$items.length && !this._transiting) {
|
1267
|
+
activedIndex = this._activeIndex;
|
1268
|
+
if ((index != null) && index !== this._activeIndex && (0 <= index && index <= this._$items.length - 1)) {
|
1269
|
+
this._transiting = true;
|
1270
|
+
this._activeIndex = index;
|
1271
|
+
action = index < activedIndex ? '_slidePrev' : '_slideNext';
|
1272
|
+
return this[action](this._$items[activedIndex], activedIndex);
|
1273
|
+
}
|
1274
|
+
}
|
1275
|
+
}
|
1276
|
+
|
1277
|
+
next() {
|
1278
|
+
var activedIndex, index;
|
1279
|
+
if (this._$items.length && !this._transiting) {
|
1280
|
+
activedIndex = this._activeIndex;
|
1281
|
+
index = activedIndex + 1;
|
1282
|
+
if (index > this._$items.length - 1) {
|
1283
|
+
if (!this._wrap) {
|
1284
|
+
return;
|
1285
|
+
}
|
1286
|
+
index = 0;
|
1287
|
+
}
|
1288
|
+
this._transiting = true;
|
1289
|
+
this._activeIndex = index;
|
1290
|
+
this._slideNext(this._$items[activedIndex], activedIndex);
|
1291
|
+
this._playTimeStamp = Date.now();
|
1292
|
+
return this._pausedRemainTime = this._interval;
|
1293
|
+
}
|
1294
|
+
}
|
1295
|
+
|
1296
|
+
prev() {
|
1297
|
+
var activedIndex, index;
|
1298
|
+
if (this._$items.length && !this._transiting) {
|
1299
|
+
activedIndex = this._activeIndex;
|
1300
|
+
index = activedIndex - 1;
|
1301
|
+
if (index < 0) {
|
1302
|
+
if (!this._wrap) {
|
1303
|
+
return;
|
1304
|
+
}
|
1305
|
+
index = this._$items.length - 1;
|
1306
|
+
}
|
1307
|
+
this._transiting = true;
|
1308
|
+
this._activeIndex = index;
|
1309
|
+
this._slidePrev(this._$items[activedIndex], activedIndex);
|
1310
|
+
this._playTimeStamp = Date.now();
|
1311
|
+
return this._pausedRemainTime = this._interval;
|
1312
|
+
}
|
1313
|
+
}
|
1314
|
+
|
1315
|
+
pause() {
|
1316
|
+
if (this._intervaling != null) {
|
1317
|
+
clearInterval(this._intervaling);
|
1318
|
+
this._intervaling = null;
|
1319
|
+
return this._pausedRemainTime = this._pausedRemainTime - (Date.now() - this._playTimeStamp);
|
1320
|
+
}
|
1321
|
+
}
|
1322
|
+
|
1323
|
+
play() {
|
1324
|
+
var execute;
|
1325
|
+
if (this._interval && this._$items.length > 1) {
|
1326
|
+
this._playTimeStamp = Date.now();
|
1327
|
+
this.pause();
|
1328
|
+
execute = () => {
|
1329
|
+
this.next();
|
1330
|
+
return this._intervaling = setInterval(this.next.bind(this), this._interval);
|
1331
|
+
};
|
1332
|
+
return this._intervaling = setTimeout(execute, this._pausedRemainTime);
|
1333
|
+
}
|
1334
|
+
}
|
1335
|
+
|
1336
|
+
// private
|
1337
|
+
_getConfig() {
|
1338
|
+
var _$indicators, _$items, _$nextControl, _$prevControl, _activeIndex, _interval, _wrap;
|
1339
|
+
_$items = luda.$unnested(this.constructor._ITEMS_SELECTOR, this._$component, this.constructor._SELECTOR);
|
1340
|
+
_$indicators = luda.$unnested(this.constructor._INDICATORS_SELECTOR, this._$component, this.constructor._SELECTOR);
|
1341
|
+
_$prevControl = luda.$child(this.constructor._PREV_CONTROL_SELECTOR, this._$component);
|
1342
|
+
_$nextControl = luda.$child(this.constructor._NEXT_CONTROL_SELECTOR, this._$component);
|
1343
|
+
_activeIndex = _$items.indexOf(luda.$child(`.${this.constructor._ITEM_ACTIVE_CSS_CLASS}`, this._$component));
|
1344
|
+
if (_activeIndex === -1) {
|
1345
|
+
_activeIndex = this.constructor._ACTIVE_INDEX;
|
1346
|
+
}
|
1347
|
+
_interval = this._$component.getAttribute(this.constructor._INTERVAL_ATTRIBUTE);
|
1348
|
+
if (_interval === this.constructor._FALSE) {
|
1349
|
+
_interval = false;
|
1350
|
+
} else {
|
1351
|
+
_interval = Math.abs(parseInt(_interval, 10)) || this.constructor._INTERVAL;
|
1352
|
+
}
|
1353
|
+
_wrap = this._$component.getAttribute(this.constructor._WRAP_ATTRIBUTE);
|
1354
|
+
_wrap = _wrap === this.constructor._FALSE ? false : this.constructor._WRAP;
|
1355
|
+
return {_$items, _$indicators, _$prevControl, _$nextControl, _activeIndex, _interval, _wrap};
|
1356
|
+
}
|
1357
|
+
|
1358
|
+
_constructor() {
|
1359
|
+
({_$items: this._$items, _$indicators: this._$indicators, _$prevControl: this._$prevControl, _$nextControl: this._$nextControl, _activeIndex: this._activeIndex, _interval: this._interval, _wrap: this._wrap} = this._getConfig());
|
1360
|
+
this._transiting = false;
|
1361
|
+
this._intervaling = null;
|
1362
|
+
this._playTimeStamp = 0;
|
1363
|
+
this._pausedRemainTime = this._interval;
|
1364
|
+
this._layout();
|
1365
|
+
return this.play();
|
1366
|
+
}
|
1367
|
+
|
1368
|
+
_onMutations(mutations) {
|
1369
|
+
({_$items: this._$items, _$indicators: this._$indicators, _$prevControl: this._$prevControl, _$nextControl: this._$nextControl, _activeIndex: this._activeIndex, _interval: this._interval, _wrap: this._wrap} = this._getConfig());
|
1370
|
+
this._setIndicatorsState();
|
1371
|
+
this._setDirectionControlState();
|
1372
|
+
return this.play();
|
1373
|
+
}
|
1374
|
+
|
1375
|
+
_destroy() {
|
1376
|
+
return this.pause();
|
1377
|
+
}
|
1378
|
+
|
1379
|
+
_layout() {
|
1380
|
+
this._$items.forEach(($item, index) => {
|
1381
|
+
$item.style.transition = 'none';
|
1382
|
+
if (index > this._activeIndex) {
|
1383
|
+
$item.classList.add(this.constructor._ITEM_NEXT_CSS_CLASS);
|
1384
|
+
$item.classList.remove(this.constructor._ITEM_PREV_CSS_CLASS);
|
1385
|
+
$item.classList.remove(this.constructor._ITEM_ACTIVE_CSS_CLASS);
|
1386
|
+
} else if (index < this._activeIndex) {
|
1387
|
+
$item.classList.add(this.constructor._ITEM_PREV_CSS_CLASS);
|
1388
|
+
$item.classList.remove(this.constructor._ITEM_NEXT_CSS_CLASS);
|
1389
|
+
$item.classList.remove(this.constructor._ITEM_ACTIVE_CSS_CLASS);
|
1390
|
+
} else {
|
1391
|
+
luda.dispatch($item, this.constructor._ACTIVED_EVENT_TYPE, index);
|
1392
|
+
$item.classList.add(this.constructor._ITEM_ACTIVE_CSS_CLASS);
|
1393
|
+
$item.classList.remove(this.constructor._ITEM_NEXT_CSS_CLASS);
|
1394
|
+
$item.classList.remove(this.constructor._ITEM_PREV_CSS_CLASS);
|
1395
|
+
}
|
1396
|
+
luda.reflow($item);
|
1397
|
+
return $item.style.transition = '';
|
1398
|
+
});
|
1399
|
+
this._setIndicatorsState();
|
1400
|
+
return this._setDirectionControlState();
|
1401
|
+
}
|
1402
|
+
|
1403
|
+
_slideNext($activedItem, activedIndex) {
|
1404
|
+
var $item;
|
1405
|
+
if (this._$items.length > 1) {
|
1406
|
+
$item = this._$items[this._activeIndex];
|
1407
|
+
luda.dispatch($item, this.constructor._ACTIVE_EVENT_TYPE, this._activeIndex);
|
1408
|
+
$item.style.transition = 'none';
|
1409
|
+
$item.classList.remove(this.constructor._ITEM_PREV_CSS_CLASS);
|
1410
|
+
$item.classList.add(this.constructor._ITEM_NEXT_CSS_CLASS);
|
1411
|
+
luda.reflow($item);
|
1412
|
+
$item.style.transition = '';
|
1413
|
+
$item.classList.remove(this.constructor._ITEM_NEXT_CSS_CLASS);
|
1414
|
+
$item.classList.add(this.constructor._ITEM_ACTIVE_CSS_CLASS);
|
1415
|
+
luda.dispatch($activedItem, this.constructor._DEACTIVE_EVENT_TYPE, activedIndex);
|
1416
|
+
$activedItem.classList.remove(this.constructor._ITEM_ACTIVE_CSS_CLASS);
|
1417
|
+
$activedItem.classList.add(this.constructor._ITEM_PREV_CSS_CLASS);
|
1418
|
+
this._setIndicatorsState();
|
1419
|
+
return this._setDirectionControlState();
|
1420
|
+
}
|
1421
|
+
}
|
1422
|
+
|
1423
|
+
_slidePrev($activedItem, activedIndex) {
|
1424
|
+
var $item;
|
1425
|
+
if (this._$items.length > 1) {
|
1426
|
+
$item = this._$items[this._activeIndex];
|
1427
|
+
luda.dispatch($item, this.constructor._ACTIVE_EVENT_TYPE, this._activeIndex);
|
1428
|
+
$item.style.transition = 'none';
|
1429
|
+
$item.classList.remove(this.constructor._ITEM_NEXT_CSS_CLASS);
|
1430
|
+
$item.classList.add(this.constructor._ITEM_PREV_CSS_CLASS);
|
1431
|
+
luda.reflow($item);
|
1432
|
+
$item.style.transition = '';
|
1433
|
+
$item.classList.remove(this.constructor._ITEM_PREV_CSS_CLASS);
|
1434
|
+
$item.classList.add(this.constructor._ITEM_ACTIVE_CSS_CLASS);
|
1435
|
+
luda.dispatch($activedItem, this.constructor._DEACTIVE_EVENT_TYPE, activedIndex);
|
1436
|
+
$activedItem.classList.remove(this.constructor._ITEM_ACTIVE_CSS_CLASS);
|
1437
|
+
$activedItem.classList.add(this.constructor._ITEM_NEXT_CSS_CLASS);
|
1438
|
+
this._setIndicatorsState();
|
1439
|
+
return this._setDirectionControlState();
|
1440
|
+
}
|
1441
|
+
}
|
1442
|
+
|
1443
|
+
_setIndicatorsState() {
|
1444
|
+
return this._$indicators.forEach(($indicator, index) => {
|
1445
|
+
return $indicator.disabled = index === this._activeIndex;
|
1446
|
+
});
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
_setDirectionControlState() {
|
1450
|
+
var ref, ref1, ref2, ref3;
|
1451
|
+
if (this._$items.length <= 1) {
|
1452
|
+
return (ref = this._$prevControl) != null ? ref.disabled = (ref1 = this._$nextControl) != null ? ref1.disabled = true : void 0 : void 0;
|
1453
|
+
} else {
|
1454
|
+
if ((ref2 = this._$prevControl) != null) {
|
1455
|
+
ref2.disabled = this._activeIndex === 0 && !this._wrap;
|
1456
|
+
}
|
1457
|
+
return (ref3 = this._$nextControl) != null ? ref3.disabled = this._activeIndex === this._$items.length - 1 && !this._wrap : void 0;
|
1458
|
+
}
|
1459
|
+
}
|
1460
|
+
|
1461
|
+
|
1462
|
+
// static private
|
1463
|
+
static _init() {
|
1464
|
+
var self;
|
1465
|
+
self = this;
|
1466
|
+
luda.on('transitionend', this._ITEMS_SELECTOR, function(e) {
|
1467
|
+
var index, instance;
|
1468
|
+
instance = self.query(luda.$parent(self._SELECTOR, this));
|
1469
|
+
instance._transiting = false;
|
1470
|
+
index = instance._$items.indexOf(this);
|
1471
|
+
if (this.classList.contains(self._ITEM_ACTIVE_CSS_CLASS)) {
|
1472
|
+
return luda.dispatch(this, self._ACTIVED_EVENT_TYPE, index);
|
1473
|
+
} else {
|
1474
|
+
return luda.dispatch(this, self._DEACTIVED_EVENT_TYPE, index);
|
1475
|
+
}
|
1476
|
+
});
|
1477
|
+
luda.on('click', this._INDICATORS_SELECTOR, function(e) {
|
1478
|
+
var instance;
|
1479
|
+
instance = self.query(luda.$parent(self._SELECTOR, this));
|
1480
|
+
return instance.active(instance._$indicators.indexOf(this));
|
1481
|
+
});
|
1482
|
+
luda.on('touchstart', this._SELECTOR, function(e) {
|
1483
|
+
return self.query(this).pause();
|
1484
|
+
});
|
1485
|
+
luda.on('touchend', this._SELECTOR, function(e) {
|
1486
|
+
return setTimeout(() => {
|
1487
|
+
return self.query(this).play();
|
1488
|
+
});
|
1489
|
+
});
|
1490
|
+
luda.on('mouseover', this._SELECTOR, function(e) {
|
1491
|
+
return self.query(this).pause();
|
1492
|
+
});
|
1493
|
+
luda.on('mouseout', this._SELECTOR, function(e) {
|
1494
|
+
return self.query(this).play();
|
1495
|
+
});
|
1496
|
+
luda.on(luda._SWIPE_LEFT_OR_UP, this._SELECTOR, function(startE, e) {
|
1497
|
+
return self.query(this).next();
|
1498
|
+
});
|
1499
|
+
luda.on(luda._SWIPE_RIGHT_OR_DOWN, this._SELECTOR, function(startE, e) {
|
1500
|
+
return self.query(this).prev();
|
1501
|
+
});
|
1502
|
+
luda.on('click', this._PREV_CONTROL_SELECTOR, function(e) {
|
1503
|
+
return self.query(luda.$parent(self._SELECTOR, this)).prev();
|
1504
|
+
});
|
1505
|
+
return luda.on('click', this._NEXT_CONTROL_SELECTOR, function(e) {
|
1506
|
+
return self.query(luda.$parent(self._SELECTOR, this)).next();
|
1507
|
+
});
|
1508
|
+
}
|
1509
|
+
|
1510
|
+
};
|
1511
|
+
|
1512
|
+
_Class._SCOPE = 'carousel';
|
1513
|
+
|
1514
|
+
_Class._SELECTOR = '.carousel';
|
1515
|
+
|
1516
|
+
_Class._ITEMS_SELECTOR = '.carousel-item';
|
1517
|
+
|
1518
|
+
_Class._PREV_CONTROL_SELECTOR = '.carousel-prev';
|
1519
|
+
|
1520
|
+
_Class._NEXT_CONTROL_SELECTOR = '.carousel-next';
|
1521
|
+
|
1522
|
+
_Class._INDICATORS_SELECTOR = '.carousel-indicators .btn';
|
1523
|
+
|
1524
|
+
_Class._INTERVAL_ATTRIBUTE = 'data-carousel-interval';
|
1525
|
+
|
1526
|
+
_Class._WRAP_ATTRIBUTE = 'data-carousel-wrap';
|
1527
|
+
|
1528
|
+
_Class._ITEM_ACTIVE_CSS_CLASS = 'carousel-item-active';
|
1529
|
+
|
1530
|
+
_Class._ITEM_NEXT_CSS_CLASS = 'carousel-item-next';
|
1531
|
+
|
1532
|
+
_Class._ITEM_PREV_CSS_CLASS = 'carousel-item-prev';
|
1533
|
+
|
1534
|
+
_Class._ACTIVE_INDEX = 0;
|
1535
|
+
|
1536
|
+
_Class._INTERVAL = 5000;
|
1537
|
+
|
1538
|
+
_Class._WRAP = true;
|
1539
|
+
|
1540
|
+
_Class._FALSE = 'false';
|
1541
|
+
|
1542
|
+
_Class._ACTIVE_EVENT_TYPE = `${_Class._SCOPE}:active`;
|
1543
|
+
|
1544
|
+
_Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
|
1545
|
+
|
1546
|
+
_Class._DEACTIVE_EVENT_TYPE = `${_Class._SCOPE}:deactive`;
|
1547
|
+
|
1548
|
+
_Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
|
1549
|
+
|
1550
|
+
_Class._observerConfig = {
|
1551
|
+
childList: true,
|
1552
|
+
attributes: true,
|
1553
|
+
subtree: true,
|
1554
|
+
attributeFilter: [_Class._INTERVAL_ATTRIBUTE, _Class._WRAP_ATTRIBUTE]
|
1555
|
+
};
|
1556
|
+
|
1557
|
+
return _Class;
|
1558
|
+
|
1559
|
+
}).call(this));
|
1560
|
+
|
1561
|
+
luda((function() {
|
1562
|
+
var _Class;
|
1563
|
+
|
1564
|
+
_Class = class extends luda.Component {
|
1565
|
+
active() {
|
1566
|
+
var ref;
|
1567
|
+
if (!this._actived()) {
|
1568
|
+
this._$component.classList.add(this.constructor._ACTIVE_CSS_CLASS);
|
1569
|
+
this.constructor._$focused.push(document.activeElement);
|
1570
|
+
if ((ref = this._parent) != null) {
|
1571
|
+
ref.active();
|
1572
|
+
}
|
1573
|
+
return luda.dispatch(this._$component, this.constructor._ACTIVED_EVENT_TYPE);
|
1574
|
+
}
|
1575
|
+
}
|
1576
|
+
|
1577
|
+
deactive(focus) {
|
1578
|
+
var ref;
|
1579
|
+
if (this._actived()) {
|
1580
|
+
this._$component.classList.remove(this.constructor._ACTIVE_CSS_CLASS);
|
1581
|
+
this._children.forEach(function(child) {
|
1582
|
+
return child.deactive();
|
1583
|
+
});
|
1584
|
+
if (focus) {
|
1585
|
+
if ((ref = this.constructor._$focused[this.constructor._$focused.length - 1]) != null) {
|
1586
|
+
ref.focus();
|
1587
|
+
}
|
1588
|
+
}
|
1589
|
+
this.constructor._$focused.splice(this.constructor._$focused.length - 1, 1);
|
1590
|
+
return luda.dispatch(this._$component, this.constructor._DEACTIVED_EVENT_TYPE);
|
1591
|
+
}
|
1592
|
+
}
|
1593
|
+
|
1594
|
+
toggle(focus) {
|
1595
|
+
if (this._actived()) {
|
1596
|
+
return this.deactive(focus);
|
1597
|
+
} else {
|
1598
|
+
return this.active();
|
1599
|
+
}
|
1600
|
+
}
|
1601
|
+
|
1602
|
+
prev() {
|
1603
|
+
var focusIndex;
|
1604
|
+
if (this._$items.length && this._actived()) {
|
1605
|
+
focusIndex = this._$items.indexOf(document.activeElement) - 1;
|
1606
|
+
if (focusIndex < 0) {
|
1607
|
+
focusIndex = 0;
|
1608
|
+
}
|
1609
|
+
return this._$items[focusIndex].focus();
|
1610
|
+
}
|
1611
|
+
}
|
1612
|
+
|
1613
|
+
next() {
|
1614
|
+
var focusIndex;
|
1615
|
+
if (this._$items.length && this._actived()) {
|
1616
|
+
focusIndex = this._$items.indexOf(document.activeElement) + 1;
|
1617
|
+
if (focusIndex > this._$items.length - 1) {
|
1618
|
+
focusIndex = this._$items.length - 1;
|
1619
|
+
}
|
1620
|
+
return this._$items[focusIndex].focus();
|
1621
|
+
}
|
1622
|
+
}
|
1623
|
+
|
1624
|
+
_getConfig() {
|
1625
|
+
var _$items, _$menu, _$noneSwitches, _$switches, _isStandalone;
|
1626
|
+
_$menu = luda.$child(this.constructor._MENU_SELECTOR, this._$component);
|
1627
|
+
_$switches = luda.$unnested(this.constructor._SWITCHES_SELECTOR, this._$component, this.constructor._SELECTOR).concat(luda.$unnested(this.constructor._SWITCHES_SELECTOR, _$menu, this.constructor._MENU_SELECTOR));
|
1628
|
+
_$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));
|
1629
|
+
_$items = luda.$unnested(this.constructor._ITEMS_SELECTOR, _$menu, this.constructor._MENU_SELECTOR);
|
1630
|
+
_isStandalone = this._$component.hasAttribute(this.constructor._STANDALONE_ATTRIBUTE);
|
1631
|
+
return {_$items, _$switches, _$noneSwitches, _isStandalone};
|
1632
|
+
}
|
1633
|
+
|
1634
|
+
_constructor() {
|
1635
|
+
return ({_$items: this._$items, _$switches: this._$switches, _$noneSwitches: this._$noneSwitches, _isStandalone: this._isStandalone} = this._getConfig());
|
1636
|
+
}
|
1637
|
+
|
1638
|
+
_onMutations(mutations) {
|
1639
|
+
return this._constructor();
|
1640
|
+
}
|
1641
|
+
|
1642
|
+
_actived() {
|
1643
|
+
return this._$component.classList.contains(this.constructor._ACTIVE_CSS_CLASS);
|
1644
|
+
}
|
1645
|
+
|
1646
|
+
_deactiveChildrenExcept(exceptions) {
|
1647
|
+
if (exceptions && !(exceptions instanceof Array)) {
|
1648
|
+
exceptions = [exceptions];
|
1649
|
+
}
|
1650
|
+
if (exceptions) {
|
1651
|
+
return this._children.forEach(function(child) {
|
1652
|
+
if (child._actived() && !exceptions.includes(child)) {
|
1653
|
+
return child.deactive();
|
1654
|
+
}
|
1655
|
+
});
|
1656
|
+
} else {
|
1657
|
+
return this._children.forEach(function(child) {
|
1658
|
+
if (child._actived()) {
|
1659
|
+
return child.deactive();
|
1660
|
+
}
|
1661
|
+
});
|
1662
|
+
}
|
1663
|
+
}
|
1664
|
+
|
1665
|
+
static deactiveExcept(instances$dropdowns) {
|
1666
|
+
var exceptions;
|
1667
|
+
exceptions = [];
|
1668
|
+
if (instances$dropdowns && !(instances$dropdowns instanceof Array)) {
|
1669
|
+
instances$dropdowns = [instances$dropdowns];
|
1670
|
+
}
|
1671
|
+
if (instances$dropdowns) {
|
1672
|
+
instances$dropdowns.forEach((instance$dropdown) => {
|
1673
|
+
var exception;
|
1674
|
+
if (exception = this.query(instance$dropdown)) {
|
1675
|
+
return exceptions.push(exception);
|
1676
|
+
}
|
1677
|
+
});
|
1678
|
+
}
|
1679
|
+
if (exceptions.length) {
|
1680
|
+
return this._instances.forEach(function(instance) {
|
1681
|
+
var instanceHasntExceptionChild, instanceIsntInExceptions;
|
1682
|
+
instanceIsntInExceptions = !exceptions.includes(instance);
|
1683
|
+
instanceHasntExceptionChild = exceptions.every(function(exception) {
|
1684
|
+
return !instance._hasDescendant(exception);
|
1685
|
+
});
|
1686
|
+
if (instance._actived() && instanceIsntInExceptions && instanceHasntExceptionChild) {
|
1687
|
+
return instance.deactive();
|
1688
|
+
}
|
1689
|
+
});
|
1690
|
+
} else {
|
1691
|
+
return this._instances.forEach(function(instance) {
|
1692
|
+
if (instance._actived()) {
|
1693
|
+
return instance.deactive();
|
1694
|
+
}
|
1695
|
+
});
|
1696
|
+
}
|
1697
|
+
}
|
1698
|
+
|
1699
|
+
static _standaloneInstances() {
|
1700
|
+
return this._instances.filter(function(instance) {
|
1701
|
+
if (instance._isStandalone) {
|
1702
|
+
return instance;
|
1703
|
+
}
|
1704
|
+
});
|
1705
|
+
}
|
1706
|
+
|
1707
|
+
static _init() {
|
1708
|
+
var self;
|
1709
|
+
self = this;
|
1710
|
+
luda.onOpposite('click', this._SELECTOR, function(e) {
|
1711
|
+
return self.deactiveExcept(self._standaloneInstances());
|
1712
|
+
});
|
1713
|
+
luda.on('click', this._SELECTOR, function(e) {
|
1714
|
+
var focus, instance, toggleChecked;
|
1715
|
+
if (instance = self.query(this)) {
|
1716
|
+
toggleChecked = false;
|
1717
|
+
focus = !e.detail;
|
1718
|
+
self.deactiveExcept(self._standaloneInstances().concat(instance));
|
1719
|
+
instance._deactiveChildrenExcept();
|
1720
|
+
if (instance._parent) {
|
1721
|
+
instance._parent._deactiveChildrenExcept(instance);
|
1722
|
+
}
|
1723
|
+
if (instance._$switches.length || instance._$noneSwitches.length) {
|
1724
|
+
luda.eventPath(e).some(function($path) {
|
1725
|
+
if (instance._$switches.includes($path)) {
|
1726
|
+
instance.toggle(focus);
|
1727
|
+
return toggleChecked = true;
|
1728
|
+
} else if (instance._$noneSwitches.includes($path)) {
|
1729
|
+
return toggleChecked = true;
|
1730
|
+
}
|
1731
|
+
});
|
1732
|
+
}
|
1733
|
+
if (!toggleChecked) {
|
1734
|
+
return instance.toggle(focus);
|
1735
|
+
}
|
1736
|
+
}
|
1737
|
+
});
|
1738
|
+
luda.onOpposite('keyup', this._SELECTOR, function(e) {
|
1739
|
+
return self.deactiveExcept();
|
1740
|
+
});
|
1741
|
+
luda.on('keyup', this._SELECTOR, function(e) {
|
1742
|
+
var instance;
|
1743
|
+
if (e.keyCode === luda.KEY_TAB && (instance = self.query(this))) {
|
1744
|
+
self.deactiveExcept(instance);
|
1745
|
+
return instance.active();
|
1746
|
+
}
|
1747
|
+
});
|
1748
|
+
luda.on('keydown', this._SELECTOR, function(e) {
|
1749
|
+
var instance, ref;
|
1750
|
+
if (e.keyCode === luda.KEY_ESC && (instance = self.query(this))) {
|
1751
|
+
e.preventDefault();
|
1752
|
+
if (instance._actived()) {
|
1753
|
+
return instance.deactive(true);
|
1754
|
+
} else {
|
1755
|
+
return (ref = instance._parent) != null ? ref.deactive(true) : void 0;
|
1756
|
+
}
|
1757
|
+
}
|
1758
|
+
});
|
1759
|
+
return luda.on('keydown', this._SELECTOR, function(e) {
|
1760
|
+
var instance, ref, ref1;
|
1761
|
+
if ([luda.KEY_LEFT, luda.KEY_UP].includes(e.keyCode) && (instance = self.query(this))) {
|
1762
|
+
e.preventDefault();
|
1763
|
+
if (instance._actived()) {
|
1764
|
+
return instance.prev();
|
1765
|
+
} else {
|
1766
|
+
return (ref = instance._parent) != null ? ref.prev() : void 0;
|
1767
|
+
}
|
1768
|
+
} else if ([luda.KEY_RIGHT, luda.KEY_DOWN].includes(e.keyCode) && (instance = self.query(this))) {
|
1769
|
+
e.preventDefault();
|
1770
|
+
if (instance._actived()) {
|
1771
|
+
return instance.next();
|
1772
|
+
} else {
|
1773
|
+
return (ref1 = instance._parent) != null ? ref1.next() : void 0;
|
1774
|
+
}
|
1775
|
+
}
|
1776
|
+
});
|
1777
|
+
}
|
1778
|
+
|
1779
|
+
};
|
1780
|
+
|
1781
|
+
_Class._SCOPE = 'dropdown';
|
1782
|
+
|
1783
|
+
_Class._SELECTOR = '.dropdown-fixed,.dropdown-absolute, .dropdown-static,.dropdown-absolute-m';
|
1784
|
+
|
1785
|
+
_Class._MENU_SELECTOR = '.dropdown-menu';
|
1786
|
+
|
1787
|
+
_Class._ITEMS_SELECTOR = 'a[href]:not([disabled]),button:not([disabled]), input:not([disabled]),[tabindex]:not([disabled])';
|
1788
|
+
|
1789
|
+
_Class._TOGGLE_ATTRIBUTE = 'data-dropdown-toggle';
|
1790
|
+
|
1791
|
+
_Class._NONE_TOGGLE_ATTRIBUTE = 'data-dropdown-none-toggle';
|
1792
|
+
|
1793
|
+
_Class._STANDALONE_ATTRIBUTE = 'data-dropdown-standalone';
|
1794
|
+
|
1795
|
+
_Class._SWITCHES_SELECTOR = `[${_Class._TOGGLE_ATTRIBUTE}]`;
|
1796
|
+
|
1797
|
+
_Class._NONE_SWITCHES_SELECTOR = `[${_Class._NONE_TOGGLE_ATTRIBUTE}]`;
|
1798
|
+
|
1799
|
+
_Class._ACTIVE_CSS_CLASS = 'dropdown-active';
|
1800
|
+
|
1801
|
+
_Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
|
1802
|
+
|
1803
|
+
_Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
|
1804
|
+
|
1805
|
+
_Class._observerConfig = {
|
1806
|
+
childList: true,
|
1807
|
+
attributes: true,
|
1808
|
+
subtree: true,
|
1809
|
+
attributeFilter: [_Class._TOGGLE_ATTRIBUTE, _Class._NONE_TOGGLE_ATTRIBUTE, _Class._STANDALONE_ATTRIBUTE]
|
1810
|
+
};
|
1811
|
+
|
1812
|
+
_Class._$focused = [];
|
1813
|
+
|
1814
|
+
return _Class;
|
1815
|
+
|
1816
|
+
}).call(this));
|
1817
|
+
|
1818
|
+
luda((function() {
|
1819
|
+
var _Class;
|
1820
|
+
|
1821
|
+
_Class = class extends luda.Component {
|
1822
|
+
_getConfig() {
|
1823
|
+
var _$defaultValues, _$valueHolder, _$values;
|
1824
|
+
_$values = luda.$children(this.constructor._VALUE_SELECTOR, this._$component);
|
1825
|
+
_$defaultValues = luda.$children(this.constructor._DEFAULT_VALUE_SELECTOR, this._$component);
|
1826
|
+
_$valueHolder = luda.$child(this.constructor._VALUE_HOLDER_SELECTOR, this._$component);
|
1827
|
+
return {_$values, _$valueHolder, _$defaultValues};
|
1828
|
+
}
|
1829
|
+
|
1830
|
+
_constructor() {
|
1831
|
+
({_$values: this._$values, _$valueHolder: this._$valueHolder, _$defaultValues: this._$defaultValues} = this._getConfig());
|
1832
|
+
this._setValueHolderAttribute();
|
1833
|
+
return this._setValueHolderValue();
|
1834
|
+
}
|
1835
|
+
|
1836
|
+
_onMutations() {
|
1837
|
+
return this._constructor();
|
1838
|
+
}
|
1839
|
+
|
1840
|
+
_setValueHolderValue() {
|
1841
|
+
var values;
|
1842
|
+
values = [];
|
1843
|
+
this._$values.forEach(($value, index) => {
|
1844
|
+
var value;
|
1845
|
+
if ($value.checked) {
|
1846
|
+
if ($value.hasAttribute(this.constructor._VALUE_ATTRIBUTE)) {
|
1847
|
+
value = $value.getAttribute(this.constructor._VALUE_ATTRIBUTE);
|
1848
|
+
} else {
|
1849
|
+
value = this._$defaultValues[index].innerText;
|
1850
|
+
}
|
1851
|
+
}
|
1852
|
+
if (value && !values.includes(value)) {
|
1853
|
+
return values.push(value);
|
1854
|
+
}
|
1855
|
+
});
|
1856
|
+
if (this._$valueHolder) {
|
1857
|
+
return this._$valueHolder.value = values.join(this.constructor._VALUE_SPLITOR);
|
1858
|
+
}
|
1859
|
+
}
|
1860
|
+
|
1861
|
+
_setValueHolderAttribute() {
|
1862
|
+
if (this._$valueHolder) {
|
1863
|
+
return this._$valueHolder.setAttribute('readonly', '');
|
1864
|
+
}
|
1865
|
+
}
|
1866
|
+
|
1867
|
+
static _init() {
|
1868
|
+
var self;
|
1869
|
+
self = this;
|
1870
|
+
luda.enterClick._add(this._ENTER_CLICK_VALUE_HOLDER_SELECTOR);
|
1871
|
+
luda.on('change', `${this._SELECTOR} ${this._VALUE_SELECTOR}`, function(e) {
|
1872
|
+
return self.query(luda.$parent(self._SELECTOR, this))._setValueHolderValue();
|
1873
|
+
});
|
1874
|
+
luda.on(luda._FORM_RESET, this._SELECTOR, function(e) {
|
1875
|
+
return setTimeout(() => {
|
1876
|
+
return self.query(this)._setValueHolderValue();
|
1877
|
+
});
|
1878
|
+
});
|
1879
|
+
// prevent ios device pop out wired navigation pannel
|
1880
|
+
if (/iphone/i.test(navigator.userAgent) || /ipad/i.test(navigator.userAgent)) {
|
1881
|
+
return luda.on('focusin', this._ENTER_CLICK_VALUE_HOLDER_SELECTOR, function(e) {
|
1882
|
+
this.blur();
|
1883
|
+
return this.classList.add(luda.focus._CSS_CLASS);
|
1884
|
+
});
|
1885
|
+
}
|
1886
|
+
}
|
1887
|
+
|
1888
|
+
};
|
1889
|
+
|
1890
|
+
_Class._SCOPE = 'fmDropdown';
|
1891
|
+
|
1892
|
+
_Class._SELECTOR = '.fm-dropdown';
|
1893
|
+
|
1894
|
+
_Class._VALUE_SPLITOR = ' ';
|
1895
|
+
|
1896
|
+
_Class._VALUE_ATTRIBUTE = 'data-fm-dropdown-value';
|
1897
|
+
|
1898
|
+
_Class._VALUE_SELECTOR = '.dropdown-items .btn-radio input, .dropdown-items .btn-check input';
|
1899
|
+
|
1900
|
+
_Class._DEFAULT_VALUE_SELECTOR = '.dropdown-items .btn-radio label, .dropdown-items .btn-check label';
|
1901
|
+
|
1902
|
+
_Class._VALUE_HOLDER_SELECTOR = '.fm input';
|
1903
|
+
|
1904
|
+
_Class._ENTER_CLICK_VALUE_HOLDER_SELECTOR = '.fm-dropdown .fm input';
|
1905
|
+
|
1906
|
+
_Class._observerConfig = {
|
1907
|
+
childList: true,
|
1908
|
+
attributes: true,
|
1909
|
+
subtree: true,
|
1910
|
+
attributeFilter: ['checked', _Class._VALUE_ATTRIBUTE]
|
1911
|
+
};
|
1912
|
+
|
1913
|
+
return _Class;
|
1914
|
+
|
1915
|
+
}).call(this));
|
1916
|
+
|
1917
|
+
luda((function() {
|
1918
|
+
var _Class;
|
1919
|
+
|
1920
|
+
_Class = class extends luda.Component {
|
1921
|
+
|
1922
|
+
// public
|
1923
|
+
active(index) {
|
1924
|
+
var activedIndex;
|
1925
|
+
if (this._$panes.length) {
|
1926
|
+
activedIndex = this._activeIndex;
|
1927
|
+
if ((index != null) && index !== this._activeIndex && (0 <= index && index <= this._$panes.length - 1)) {
|
1928
|
+
this._activeIndex = index;
|
1929
|
+
return this._active(activedIndex);
|
1930
|
+
}
|
1931
|
+
}
|
1932
|
+
}
|
1933
|
+
|
1934
|
+
// private
|
1935
|
+
_getConfig() {
|
1936
|
+
var _$indicators, _$panes, _activeIndex;
|
1937
|
+
_$panes = luda.$unnested(this.constructor._PANE_SELECTOR, this._$component, this.constructor._SELECTOR);
|
1938
|
+
_$indicators = luda.$unnested(this.constructor._INDICATOR_SELECTOR, this._$component, this.constructor._SELECTOR);
|
1939
|
+
_activeIndex = this.constructor._ACTIVE_INDEX;
|
1940
|
+
_$indicators.some(function($indicator, index) {
|
1941
|
+
if ($indicator.checked) {
|
1942
|
+
_activeIndex = index;
|
1943
|
+
return true;
|
1944
|
+
}
|
1945
|
+
});
|
1946
|
+
return {_$panes, _$indicators, _activeIndex};
|
1947
|
+
}
|
1948
|
+
|
1949
|
+
_constructor() {
|
1950
|
+
({_$panes: this._$panes, _$indicators: this._$indicators, _activeIndex: this._activeIndex} = this._getConfig());
|
1951
|
+
return this._active();
|
1952
|
+
}
|
1953
|
+
|
1954
|
+
_onMutations(mutations) {
|
1955
|
+
return this._constructor();
|
1956
|
+
}
|
1957
|
+
|
1958
|
+
_active(activedIndex) {
|
1959
|
+
this._$panes.forEach(($pane, index) => {
|
1960
|
+
if (index === this._activeIndex) {
|
1961
|
+
$pane.classList.add(this.constructor._PANE_ACTIVE_CSS_CLASS);
|
1962
|
+
return luda.dispatch($pane, this.constructor._ACTIVED_EVENT_TYPE, index);
|
1963
|
+
} else {
|
1964
|
+
$pane.classList.remove(this.constructor._PANE_ACTIVE_CSS_CLASS);
|
1965
|
+
if (index === activedIndex) {
|
1966
|
+
return luda.dispatch($pane, this.constructor._DEACTIVED_EVENT_TYPE, index);
|
1967
|
+
}
|
1968
|
+
}
|
1969
|
+
});
|
1970
|
+
return this._setIndicatorsState();
|
1971
|
+
}
|
1972
|
+
|
1973
|
+
_setIndicatorsState() {
|
1974
|
+
return this._$indicators.forEach(($indicator, index) => {
|
1975
|
+
if (index === this._activeIndex) {
|
1976
|
+
return $indicator.setAttribute('checked', '');
|
1977
|
+
} else {
|
1978
|
+
return $indicator.removeAttribute('checked');
|
1979
|
+
}
|
1980
|
+
});
|
1981
|
+
}
|
1982
|
+
|
1983
|
+
// static private
|
1984
|
+
static _init() {
|
1985
|
+
var self;
|
1986
|
+
self = this;
|
1987
|
+
return luda.on('change', this._INDICATOR_SELECTOR, function(e) {
|
1988
|
+
var instance;
|
1989
|
+
if (this.checked) {
|
1990
|
+
instance = self.query(luda.$parent(self._SELECTOR, this));
|
1991
|
+
return instance.active(instance._$indicators.indexOf(this));
|
1992
|
+
}
|
1993
|
+
});
|
1994
|
+
}
|
1995
|
+
|
1996
|
+
};
|
1997
|
+
|
1998
|
+
_Class._SCOPE = 'tab';
|
1999
|
+
|
2000
|
+
_Class._SELECTOR = '.tab';
|
2001
|
+
|
2002
|
+
_Class._PANE_SELECTOR = '.tab-pane';
|
2003
|
+
|
2004
|
+
_Class._INDICATOR_SELECTOR = '.tab-indicators .btn-radio input[type=radio]';
|
2005
|
+
|
2006
|
+
_Class._PANE_ACTIVE_CSS_CLASS = 'tab-pane-active';
|
2007
|
+
|
2008
|
+
_Class._ACTIVE_INDEX = 0;
|
2009
|
+
|
2010
|
+
_Class._ACTIVED_EVENT_TYPE = `${_Class._SCOPE}:actived`;
|
2011
|
+
|
2012
|
+
_Class._DEACTIVED_EVENT_TYPE = `${_Class._SCOPE}:deactived`;
|
2013
|
+
|
2014
|
+
_Class._observerConfig = {
|
2015
|
+
childList: true,
|
2016
|
+
subtree: true
|
2017
|
+
};
|
2018
|
+
|
2019
|
+
return _Class;
|
2020
|
+
|
2021
|
+
}).call(this));
|
2022
|
+
|
2023
|
+
})));
|
2024
|
+
//# sourceMappingURL=luda.js.map
|