postmark-cli-cz 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/templates/helpers.d.ts +18 -0
- package/dist/commands/templates/helpers.js +101 -0
- package/dist/commands/templates/helpers.js.map +1 -0
- package/dist/commands/templates/preview/assets/images/check.svg +1 -0
- package/dist/commands/templates/preview/assets/images/favicon.ico +0 -0
- package/dist/commands/templates/preview/assets/images/folder.svg +1 -0
- package/dist/commands/templates/preview/assets/images/icon.png +0 -0
- package/dist/commands/templates/preview/assets/images/responsive.svg +1 -0
- package/dist/commands/templates/preview/assets/images/templates.svg +1 -0
- package/dist/commands/templates/preview/assets/js/events.js +50 -0
- package/dist/commands/templates/preview/assets/js/popper.2.5.4.min.js +5 -0
- package/dist/commands/templates/preview/assets/js/preview.js +118 -0
- package/dist/commands/templates/preview/assets/styles/reset.css +351 -0
- package/dist/commands/templates/preview/assets/styles/styles.css +675 -0
- package/dist/commands/templates/preview/index.ejs +81 -0
- package/dist/commands/templates/preview/partials/head.ejs +8 -0
- package/dist/commands/templates/preview/partials/previewScripts.ejs +5 -0
- package/dist/commands/templates/preview/template.ejs +60 -0
- package/dist/commands/templates/preview/template404.ejs +11 -0
- package/dist/commands/templates/preview/templateInvalid.ejs +16 -0
- package/dist/commands/templates/preview/templateText.ejs +9 -0
- package/dist/commands/templates/preview.d.ts +21 -0
- package/dist/commands/templates/preview.js +263 -0
- package/dist/commands/templates/preview.js.map +1 -0
- package/dist/commands/templates/pull.d.ts +26 -0
- package/dist/commands/templates/pull.js +279 -0
- package/dist/commands/templates/pull.js.map +1 -0
- package/dist/commands/templates/push.d.ts +44 -0
- package/dist/commands/templates/push.js +451 -0
- package/dist/commands/templates/push.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { TemplateManifest, MetaFileTraverse, MetaFile } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Parses templates folder and files
|
|
4
|
+
*/
|
|
5
|
+
export declare const createManifest: (path: string) => TemplateManifest[];
|
|
6
|
+
/**
|
|
7
|
+
* Searches for all metadata files and flattens into a collection
|
|
8
|
+
*/
|
|
9
|
+
export declare const findMetaFiles: (path: string) => MetaFileTraverse[];
|
|
10
|
+
/**
|
|
11
|
+
* Gathers the template's content and metadata based on the metadata file location
|
|
12
|
+
*/
|
|
13
|
+
export declare const createManifestItem: (file: MetaFileTraverse) => MetaFile | null;
|
|
14
|
+
type TemplateDifference = 'html' | 'text' | 'subject' | 'name' | 'layout';
|
|
15
|
+
type TemplateDifferences = Set<TemplateDifference>;
|
|
16
|
+
export declare function templatesDiff(t1: TemplateManifest, t2: TemplateManifest): TemplateDifferences;
|
|
17
|
+
export declare function sameContent(str1: string | null | undefined, str2: string | null | undefined): boolean;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.sameContent = exports.templatesDiff = exports.createManifestItem = exports.findMetaFiles = exports.createManifest = void 0;
|
|
18
|
+
var path_1 = require("path");
|
|
19
|
+
var lodash_1 = require("lodash");
|
|
20
|
+
var fs_extra_1 = require("fs-extra");
|
|
21
|
+
var traverse_1 = __importDefault(require("traverse"));
|
|
22
|
+
var directory_tree_1 = __importDefault(require("directory-tree"));
|
|
23
|
+
/**
|
|
24
|
+
* Parses templates folder and files
|
|
25
|
+
*/
|
|
26
|
+
var createManifest = function (path) {
|
|
27
|
+
var manifest = [];
|
|
28
|
+
// Return empty array if path does not exist
|
|
29
|
+
if (!(0, fs_extra_1.existsSync)(path))
|
|
30
|
+
return manifest;
|
|
31
|
+
// Find meta files and flatten into collection
|
|
32
|
+
var list = (0, exports.findMetaFiles)(path);
|
|
33
|
+
// Parse each directory
|
|
34
|
+
list.forEach(function (file) {
|
|
35
|
+
var item = (0, exports.createManifestItem)(file);
|
|
36
|
+
if (item)
|
|
37
|
+
manifest.push(item);
|
|
38
|
+
});
|
|
39
|
+
return manifest;
|
|
40
|
+
};
|
|
41
|
+
exports.createManifest = createManifest;
|
|
42
|
+
/**
|
|
43
|
+
* Searches for all metadata files and flattens into a collection
|
|
44
|
+
*/
|
|
45
|
+
var findMetaFiles = function (path) {
|
|
46
|
+
return (0, traverse_1.default)((0, directory_tree_1.default)(path)).reduce(function (acc, file) {
|
|
47
|
+
if (file.name === 'meta.json')
|
|
48
|
+
acc.push(file);
|
|
49
|
+
return acc;
|
|
50
|
+
}, []);
|
|
51
|
+
};
|
|
52
|
+
exports.findMetaFiles = findMetaFiles;
|
|
53
|
+
/**
|
|
54
|
+
* Gathers the template's content and metadata based on the metadata file location
|
|
55
|
+
*/
|
|
56
|
+
var createManifestItem = function (file) {
|
|
57
|
+
var path = file.path; // Path to meta file
|
|
58
|
+
var rootPath = (0, path_1.dirname)(path); // Folder path
|
|
59
|
+
var htmlPath = (0, path_1.join)(rootPath, 'content.html'); // HTML path
|
|
60
|
+
var textPath = (0, path_1.join)(rootPath, 'content.txt'); // Text path
|
|
61
|
+
// Check if meta file exists
|
|
62
|
+
if ((0, fs_extra_1.existsSync)(path)) {
|
|
63
|
+
var metaFile = (0, fs_extra_1.readJsonSync)(path);
|
|
64
|
+
var htmlFile = (0, fs_extra_1.existsSync)(htmlPath)
|
|
65
|
+
? (0, fs_extra_1.readFileSync)(htmlPath, 'utf-8')
|
|
66
|
+
: '';
|
|
67
|
+
var textFile = (0, fs_extra_1.existsSync)(textPath)
|
|
68
|
+
? (0, fs_extra_1.readFileSync)(textPath, 'utf-8')
|
|
69
|
+
: '';
|
|
70
|
+
return __assign({ HtmlBody: htmlFile, TextBody: textFile }, metaFile);
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
};
|
|
74
|
+
exports.createManifestItem = createManifestItem;
|
|
75
|
+
function templatesDiff(t1, t2) {
|
|
76
|
+
var result = new Set();
|
|
77
|
+
if (!sameContent(t1.HtmlBody, t2.HtmlBody))
|
|
78
|
+
result.add('html');
|
|
79
|
+
if (!sameContent(t1.TextBody, t2.TextBody))
|
|
80
|
+
result.add('text');
|
|
81
|
+
if (t2.TemplateType === 'Standard' && !sameContent(t1.Subject, t2.Subject))
|
|
82
|
+
result.add('subject');
|
|
83
|
+
if (!sameContent(t1.Name, t2.Name))
|
|
84
|
+
result.add('name');
|
|
85
|
+
if (t2.TemplateType === 'Standard' &&
|
|
86
|
+
!sameContent(t1.LayoutTemplate, t2.LayoutTemplate))
|
|
87
|
+
result.add('layout');
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
exports.templatesDiff = templatesDiff;
|
|
91
|
+
function sameContent(str1, str2) {
|
|
92
|
+
if ((0, lodash_1.isEmpty)(str1) && (0, lodash_1.isEmpty)(str2)) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
if ((0, lodash_1.isEmpty)(str1) || (0, lodash_1.isEmpty)(str2)) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return str1 === str2;
|
|
99
|
+
}
|
|
100
|
+
exports.sameContent = sameContent;
|
|
101
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/commands/templates/helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6BAAoC;AACpC,iCAAgC;AAChC,qCAAiE;AACjE,sDAA+B;AAC/B,kEAAoC;AAGpC;;GAEG;AAEI,IAAM,cAAc,GAAG,UAAC,IAAY;IACzC,IAAI,QAAQ,GAAuB,EAAE,CAAA;IAErC,4CAA4C;IAC5C,IAAI,CAAC,IAAA,qBAAU,EAAC,IAAI,CAAC;QAAE,OAAO,QAAQ,CAAA;IAEtC,8CAA8C;IAC9C,IAAM,IAAI,GAAuB,IAAA,qBAAa,EAAC,IAAI,CAAC,CAAA;IAEpD,uBAAuB;IACvB,IAAI,CAAC,OAAO,CAAC,UAAA,IAAI;QACf,IAAM,IAAI,GAAG,IAAA,0BAAkB,EAAC,IAAI,CAAC,CAAA;QACrC,IAAI,IAAI;YAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC/B,CAAC,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AAhBY,QAAA,cAAc,kBAgB1B;AAED;;GAEG;AACI,IAAM,aAAa,GAAG,UAAC,IAAY;IACxC,OAAA,IAAA,kBAAQ,EAAC,IAAA,wBAAO,EAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,UAAC,GAAG,EAAE,IAAI;QACvC,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW;YAAE,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC7C,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC;AAHN,CAGM,CAAA;AAJK,QAAA,aAAa,iBAIlB;AAER;;GAEG;AACI,IAAM,kBAAkB,GAAG,UAAC,IAAsB;IAC/C,IAAA,IAAI,GAAK,IAAI,KAAT,CAAS,CAAC,oBAAoB;IAC1C,IAAM,QAAQ,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,CAAA,CAAC,cAAc;IAC7C,IAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,cAAc,CAAC,CAAA,CAAC,YAAY;IAC5D,IAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,aAAa,CAAC,CAAA,CAAC,YAAY;IAE3D,4BAA4B;IAC5B,IAAI,IAAA,qBAAU,EAAC,IAAI,CAAC,EAAE;QACpB,IAAM,QAAQ,GAAa,IAAA,uBAAY,EAAC,IAAI,CAAC,CAAA;QAC7C,IAAM,QAAQ,GAAW,IAAA,qBAAU,EAAC,QAAQ,CAAC;YAC3C,CAAC,CAAC,IAAA,uBAAY,EAAC,QAAQ,EAAE,OAAO,CAAC;YACjC,CAAC,CAAC,EAAE,CAAA;QACN,IAAM,QAAQ,GAAW,IAAA,qBAAU,EAAC,QAAQ,CAAC;YAC3C,CAAC,CAAC,IAAA,uBAAY,EAAC,QAAQ,EAAE,OAAO,CAAC;YACjC,CAAC,CAAC,EAAE,CAAA;QAEN,kBACE,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,IACf,QAAQ,EACZ;KACF;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAxBY,QAAA,kBAAkB,sBAwB9B;AAKD,SAAgB,aAAa,CAC3B,EAAoB,EACpB,EAAoB;IAEpB,IAAM,MAAM,GAAwB,IAAI,GAAG,EAAsB,CAAA;IAEjE,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC9D,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAC9D,IAAI,EAAE,CAAC,YAAY,KAAK,UAAU,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC;QACxE,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA;IACvB,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;QAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IACtD,IACE,EAAE,CAAC,YAAY,KAAK,UAAU;QAC9B,CAAC,WAAW,CAAC,EAAE,CAAC,cAAc,EAAE,EAAE,CAAC,cAAc,CAAC;QAElD,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;IAEtB,OAAO,MAAM,CAAA;AACf,CAAC;AAlBD,sCAkBC;AAED,SAAgB,WAAW,CACzB,IAA+B,EAC/B,IAA+B;IAE/B,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,EAAE;QAClC,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,IAAI,IAAA,gBAAO,EAAC,IAAI,CAAC,EAAE;QAClC,OAAO,KAAK,CAAA;KACb;IAED,OAAO,IAAI,KAAK,IAAI,CAAA;AACtB,CAAC;AAbD,kCAaC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="14" height="14" xmlns="http://www.w3.org/2000/svg"><path d="M7 0a7 7 0 100 14A7 7 0 007 0zm3.754 6.368l-3.55 3.397a.863.863 0 01-1.184 0L4.245 8.067a.777.777 0 010-1.133.863.863 0 011.184 0l1.184 1.133 2.958-2.832a.863.863 0 011.184 0 .777.777 0 010 1.133h-.001z" fill="#FF7C83" fill-rule="nonzero"/></svg>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="15" height="12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14 8v2a1 1 0 01-1 1H2a1 1 0 01-1-1V2a1 1 0 011-1h3.058c.43 0 .82.275.968.694.312.89.74 2.069 1.138 3.032.197.478.396.928.578 1.268.088.166.191.343.306.491.056.073.142.173.256.265.096.076.34.25.696.25h4a1 1 0 011 1z" fill="#8E91A6" fill-opacity=".3" stroke="#8E91A6" stroke-width="2"/><path d="M7 3h6a1 1 0 011 1v4" stroke="#8E91A6" stroke-width="2"/></svg>
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="29" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M9 18H2v12h7V18zm-7-2a2 2 0 00-2 2v12a2 2 0 002 2h7a2 2 0 002-2V18a2 2 0 00-2-2H2zM14 18h12v8H14v-8zm-2 8v-8a2 2 0 012-2h12a2 2 0 012 2v8h1v2a1 1 0 01-1 1H12a1 1 0 01-1-1v-2h1z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14 2h12v8H14V2zm-2 8V2a2 2 0 012-2h12a2 2 0 012 2v8h1v2a1 1 0 01-1 1H12a1 1 0 01-1-1v-2h1zM9 2H2v12h7V2zM2 0a2 2 0 00-2 2v12a2 2 0 002 2h7a2 2 0 002-2V2a2 2 0 00-2-2H2z" fill="#8E91A6"/><path fill="#8E91A6" fill-opacity=".3" d="M2 2h7v12H2zM14 2h12v8H14z"/><path fill="#fff" fill-opacity=".3" d="M14 18h12v8H14z"/><path fill="#FF7C83" fill-opacity=".3" d="M14 34h12v8H14z"/><path fill="#fff" fill-opacity=".3" d="M2 18h7v12H2z"/><path fill="#FF7C83" fill-opacity=".3" d="M2 34h7v12H2z"/><path fill-rule="evenodd" clip-rule="evenodd" d="M9 34H2v12h7V34zm-7-2a2 2 0 00-2 2v12a2 2 0 002 2h7a2 2 0 002-2V34a2 2 0 00-2-2H2zM14 34h12v8H14v-8zm-2 8v-8a2 2 0 012-2h12a2 2 0 012 2v8h1v2a1 1 0 01-1 1H12a1 1 0 01-1-1v-2h1z" fill="#FF7C83"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="123" height="76" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M79 8h42.11v60H79V8zM1 8h42.11v60H1V8z" fill="#fff" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M34.05 1h54v74h-54V1z" fill="#fff" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M34.05 28h54v25h-54V28z" fill="#FF7C83" stroke="#333" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M35.8 53l15.03-16 16.72 16H35.8z" fill="#333" fill-opacity=".2" stroke="#333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M80.05 52.5L66.78 40.25l-5.75 6.25 5.52 6h13.5z" fill="#333" fill-opacity=".09" stroke="#333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M78.55 38.5a3 3 0 100-6 3 3 0 000 6z" fill="#333" fill-opacity=".2" stroke="#333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path opacity=".2" d="M61.55 15a4.5 4.5 0 100-9 4.5 4.5 0 000 9zM50.05 19h-9a2 2 0 100 4h9a2 2 0 100-4zM81.05 19h-9a2 2 0 100 4h9a2 2 0 100-4zM66.05 19h-9a2 2 0 100 4h9a2 2 0 100-4zM81.05 57h-40a2 2 0 100 4h40a2 2 0 100-4zM81.05 65h-40a2 2 0 100 4h40a2 2 0 100-4z" fill="#333"/><path opacity=".15" d="M33.05 14h-24a2 2 0 100 4h24a2 2 0 100-4zM114.05 14h-24a2 2 0 100 4h24a2 2 0 100-4zM114.05 22h-24a2 2 0 100 4h24a2 2 0 100-4zM114.05 51h-15a2 2 0 100 4h15a2 2 0 100-4zM114.05 58h-15a2 2 0 100 4h15a2 2 0 100-4zM30.05 22h5v4h-5a2 2 0 110-4zM30.05 29h5v4h-5a2 2 0 110-4zM30.05 36h5v4h-5a2 2 0 110-4zM7.05 22h18v18h-18V22zM30.05 44h5v4h-5a2 2 0 110-4zM30.05 51h5v4h-5a2 2 0 110-4zM30.05 58h5v4h-5a2 2 0 110-4zM7.05 44h18v18h-18V44zM97.05 30h18v18h-18V30zM91.05 51h-2a2 2 0 100 4h2a2 2 0 100-4zM91.05 58h-2a2 2 0 100 4h2a2 2 0 100-4zM87.05 30h5.68v18h-5.68V30z" fill="#333"/></svg>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var socket = io()
|
|
2
|
+
|
|
3
|
+
socket.on('change', function () {
|
|
4
|
+
console.log('Templates changed. Reloading preview.')
|
|
5
|
+
document.querySelector('.js-html').contentWindow.location.reload()
|
|
6
|
+
document.querySelector('.js-text').contentWindow.location.reload()
|
|
7
|
+
|
|
8
|
+
var reloaded = document.querySelector('.js-reloaded')
|
|
9
|
+
reloaded.classList.add('is-active')
|
|
10
|
+
|
|
11
|
+
setTimeout(function () {
|
|
12
|
+
reloaded.classList.remove('is-active')
|
|
13
|
+
}, 3000)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
socket.on('subject', function (data) {
|
|
17
|
+
var subjectEl = document.querySelector('.js-subject')
|
|
18
|
+
var subjectErrorTooltip = document.querySelector('.js-subject-error')
|
|
19
|
+
|
|
20
|
+
var errorTooltip = Popper.createPopper(subjectEl, subjectErrorTooltip, {
|
|
21
|
+
placement: 'top-start',
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
if (!isEmptyObject(data)) {
|
|
25
|
+
if (data.ContentIsValid) {
|
|
26
|
+
// Render tooltip if valid
|
|
27
|
+
subjectEl.classList.remove('has-error')
|
|
28
|
+
subjectEl.textContent = data.RenderedContent
|
|
29
|
+
|
|
30
|
+
// Destroy tooltip
|
|
31
|
+
errorTooltip.destroy()
|
|
32
|
+
} else {
|
|
33
|
+
// Show validation error indicator
|
|
34
|
+
subjectEl.classList.add('has-error')
|
|
35
|
+
subjectEl.innerHTML =
|
|
36
|
+
data.rawSubject + ' <span class="syntax-error">Syntax error</span>'
|
|
37
|
+
|
|
38
|
+
// Append each validation error to tooltip
|
|
39
|
+
var subjectError = document.querySelector('.js-subject-error')
|
|
40
|
+
subjectError.innerHTML = ''
|
|
41
|
+
data.ValidationErrors.forEach(function (error) {
|
|
42
|
+
subjectError.innerHTML += '<p>' + error.Message + '</p>'
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
function isEmptyObject(value) {
|
|
49
|
+
return Object.keys(value).length === 0 && value.constructor === Object
|
|
50
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @popperjs/core v2.5.4 - MIT License
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
"use strict";!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).Popper={})}(this,(function(e){function t(e){return{width:(e=e.getBoundingClientRect()).width,height:e.height,top:e.top,right:e.right,bottom:e.bottom,left:e.left,x:e.left,y:e.top}}function n(e){return"[object Window]"!==e.toString()?(e=e.ownerDocument)&&e.defaultView||window:e}function r(e){return{scrollLeft:(e=n(e)).pageXOffset,scrollTop:e.pageYOffset}}function o(e){return e instanceof n(e).Element||e instanceof Element}function i(e){return e instanceof n(e).HTMLElement||e instanceof HTMLElement}function a(e){return e?(e.nodeName||"").toLowerCase():null}function s(e){return((o(e)?e.ownerDocument:e.document)||window.document).documentElement}function f(e){return t(s(e)).left+r(e).scrollLeft}function c(e){return n(e).getComputedStyle(e)}function p(e){return e=c(e),/auto|scroll|overlay|hidden/.test(e.overflow+e.overflowY+e.overflowX)}function l(e,o,c){void 0===c&&(c=!1);var l=s(o);e=t(e);var u=i(o),d={scrollLeft:0,scrollTop:0},m={x:0,y:0};return(u||!u&&!c)&&(("body"!==a(o)||p(l))&&(d=o!==n(o)&&i(o)?{scrollLeft:o.scrollLeft,scrollTop:o.scrollTop}:r(o)),i(o)?((m=t(o)).x+=o.clientLeft,m.y+=o.clientTop):l&&(m.x=f(l))),{x:e.left+d.scrollLeft-m.x,y:e.top+d.scrollTop-m.y,width:e.width,height:e.height}}function u(e){return{x:e.offsetLeft,y:e.offsetTop,width:e.offsetWidth,height:e.offsetHeight}}function d(e){return"html"===a(e)?e:e.assignedSlot||e.parentNode||e.host||s(e)}function m(e,t){void 0===t&&(t=[]);var r=function e(t){return 0<=["html","body","#document"].indexOf(a(t))?t.ownerDocument.body:i(t)&&p(t)?t:e(d(t))}(e);e="body"===a(r);var o=n(r);return r=e?[o].concat(o.visualViewport||[],p(r)?r:[]):r,t=t.concat(r),e?t:t.concat(m(d(r)))}function h(e){if(!i(e)||"fixed"===c(e).position)return null;if(e=e.offsetParent){var t=s(e);if("body"===a(e)&&"static"===c(e).position&&"static"!==c(t).position)return t}return e}function g(e){for(var t=n(e),r=h(e);r&&0<=["table","td","th"].indexOf(a(r))&&"static"===c(r).position;)r=h(r);if(r&&"body"===a(r)&&"static"===c(r).position)return t;if(!r)e:{for(e=d(e);i(e)&&0>["html","body"].indexOf(a(e));){if("none"!==(r=c(e)).transform||"none"!==r.perspective||r.willChange&&"auto"!==r.willChange){r=e;break e}e=e.parentNode}r=null}return r||t}function v(e){var t=new Map,n=new Set,r=[];return e.forEach((function(e){t.set(e.name,e)})),e.forEach((function(e){n.has(e.name)||function e(o){n.add(o.name),[].concat(o.requires||[],o.requiresIfExists||[]).forEach((function(r){n.has(r)||(r=t.get(r))&&e(r)})),r.push(o)}(e)})),r}function b(e){var t;return function(){return t||(t=new Promise((function(n){Promise.resolve().then((function(){t=void 0,n(e())}))}))),t}}function y(e){return e.split("-")[0]}function O(e,t){var r,o=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if((r=o)&&(r=o instanceof(r=n(o).ShadowRoot)||o instanceof ShadowRoot),r)do{if(t&&e.isSameNode(t))return!0;t=t.parentNode||t.host}while(t);return!1}function w(e){return Object.assign(Object.assign({},e),{},{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function x(e,o){if("viewport"===o){o=n(e);var a=s(e);o=o.visualViewport;var p=a.clientWidth;a=a.clientHeight;var l=0,u=0;o&&(p=o.width,a=o.height,/^((?!chrome|android).)*safari/i.test(navigator.userAgent)||(l=o.offsetLeft,u=o.offsetTop)),e=w(e={width:p,height:a,x:l+f(e),y:u})}else i(o)?((e=t(o)).top+=o.clientTop,e.left+=o.clientLeft,e.bottom=e.top+o.clientHeight,e.right=e.left+o.clientWidth,e.width=o.clientWidth,e.height=o.clientHeight,e.x=e.left,e.y=e.top):(u=s(e),e=s(u),l=r(u),o=u.ownerDocument.body,p=Math.max(e.scrollWidth,e.clientWidth,o?o.scrollWidth:0,o?o.clientWidth:0),a=Math.max(e.scrollHeight,e.clientHeight,o?o.scrollHeight:0,o?o.clientHeight:0),u=-l.scrollLeft+f(u),l=-l.scrollTop,"rtl"===c(o||e).direction&&(u+=Math.max(e.clientWidth,o?o.clientWidth:0)-p),e=w({width:p,height:a,x:u,y:l}));return e}function j(e,t,n){return t="clippingParents"===t?function(e){var t=m(d(e)),n=0<=["absolute","fixed"].indexOf(c(e).position)&&i(e)?g(e):e;return o(n)?t.filter((function(e){return o(e)&&O(e,n)&&"body"!==a(e)})):[]}(e):[].concat(t),(n=(n=[].concat(t,[n])).reduce((function(t,n){return n=x(e,n),t.top=Math.max(n.top,t.top),t.right=Math.min(n.right,t.right),t.bottom=Math.min(n.bottom,t.bottom),t.left=Math.max(n.left,t.left),t}),x(e,n[0]))).width=n.right-n.left,n.height=n.bottom-n.top,n.x=n.left,n.y=n.top,n}function M(e){return 0<=["top","bottom"].indexOf(e)?"x":"y"}function E(e){var t=e.reference,n=e.element,r=(e=e.placement)?y(e):null;e=e?e.split("-")[1]:null;var o=t.x+t.width/2-n.width/2,i=t.y+t.height/2-n.height/2;switch(r){case"top":o={x:o,y:t.y-n.height};break;case"bottom":o={x:o,y:t.y+t.height};break;case"right":o={x:t.x+t.width,y:i};break;case"left":o={x:t.x-n.width,y:i};break;default:o={x:t.x,y:t.y}}if(null!=(r=r?M(r):null))switch(i="y"===r?"height":"width",e){case"start":o[r]=Math.floor(o[r])-Math.floor(t[i]/2-n[i]/2);break;case"end":o[r]=Math.floor(o[r])+Math.ceil(t[i]/2-n[i]/2)}return o}function D(e){return Object.assign(Object.assign({},{top:0,right:0,bottom:0,left:0}),e)}function P(e,t){return t.reduce((function(t,n){return t[n]=e,t}),{})}function L(e,n){void 0===n&&(n={});var r=n;n=void 0===(n=r.placement)?e.placement:n;var i=r.boundary,a=void 0===i?"clippingParents":i,f=void 0===(i=r.rootBoundary)?"viewport":i;i=void 0===(i=r.elementContext)?"popper":i;var c=r.altBoundary,p=void 0!==c&&c;r=D("number"!=typeof(r=void 0===(r=r.padding)?0:r)?r:P(r,T));var l=e.elements.reference;c=e.rects.popper,a=j(o(p=e.elements[p?"popper"===i?"reference":"popper":i])?p:p.contextElement||s(e.elements.popper),a,f),p=E({reference:f=t(l),element:c,strategy:"absolute",placement:n}),c=w(Object.assign(Object.assign({},c),p)),f="popper"===i?c:f;var u={top:a.top-f.top+r.top,bottom:f.bottom-a.bottom+r.bottom,left:a.left-f.left+r.left,right:f.right-a.right+r.right};if(e=e.modifiersData.offset,"popper"===i&&e){var d=e[n];Object.keys(u).forEach((function(e){var t=0<=["right","bottom"].indexOf(e)?1:-1,n=0<=["top","bottom"].indexOf(e)?"y":"x";u[e]+=d[n]*t}))}return u}function k(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return!t.some((function(e){return!(e&&"function"==typeof e.getBoundingClientRect)}))}function B(e){void 0===e&&(e={});var t=e.defaultModifiers,n=void 0===t?[]:t,r=void 0===(e=e.defaultOptions)?V:e;return function(e,t,i){function a(){f.forEach((function(e){return e()})),f=[]}void 0===i&&(i=r);var s={placement:"bottom",orderedModifiers:[],options:Object.assign(Object.assign({},V),r),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},f=[],c=!1,p={state:s,setOptions:function(i){return a(),s.options=Object.assign(Object.assign(Object.assign({},r),s.options),i),s.scrollParents={reference:o(e)?m(e):e.contextElement?m(e.contextElement):[],popper:m(t)},i=function(e){var t=v(e);return N.reduce((function(e,n){return e.concat(t.filter((function(e){return e.phase===n})))}),[])}(function(e){var t=e.reduce((function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign(Object.assign(Object.assign({},n),t),{},{options:Object.assign(Object.assign({},n.options),t.options),data:Object.assign(Object.assign({},n.data),t.data)}):t,e}),{});return Object.keys(t).map((function(e){return t[e]}))}([].concat(n,s.options.modifiers))),s.orderedModifiers=i.filter((function(e){return e.enabled})),s.orderedModifiers.forEach((function(e){var t=e.name,n=e.options;n=void 0===n?{}:n,"function"==typeof(e=e.effect)&&(t=e({state:s,name:t,instance:p,options:n}),f.push(t||function(){}))})),p.update()},forceUpdate:function(){if(!c){var e=s.elements,t=e.reference;if(k(t,e=e.popper))for(s.rects={reference:l(t,g(e),"fixed"===s.options.strategy),popper:u(e)},s.reset=!1,s.placement=s.options.placement,s.orderedModifiers.forEach((function(e){return s.modifiersData[e.name]=Object.assign({},e.data)})),t=0;t<s.orderedModifiers.length;t++)if(!0===s.reset)s.reset=!1,t=-1;else{var n=s.orderedModifiers[t];e=n.fn;var r=n.options;r=void 0===r?{}:r,n=n.name,"function"==typeof e&&(s=e({state:s,options:r,name:n,instance:p})||s)}}},update:b((function(){return new Promise((function(e){p.forceUpdate(),e(s)}))})),destroy:function(){a(),c=!0}};return k(e,t)?(p.setOptions(i).then((function(e){!c&&i.onFirstUpdate&&i.onFirstUpdate(e)})),p):p}}function W(e){var t,r=e.popper,o=e.popperRect,i=e.placement,a=e.offsets,f=e.position,c=e.gpuAcceleration,p=e.adaptive,l=window.devicePixelRatio||1;e=Math.round(a.x*l)/l||0,l=Math.round(a.y*l)/l||0;var u=a.hasOwnProperty("x");a=a.hasOwnProperty("y");var d,m="left",h="top",v=window;if(p){var b=g(r);b===n(r)&&(b=s(r)),"top"===i&&(h="bottom",l-=b.clientHeight-o.height,l*=c?1:-1),"left"===i&&(m="right",e-=b.clientWidth-o.width,e*=c?1:-1)}return r=Object.assign({position:f},p&&z),c?Object.assign(Object.assign({},r),{},((d={})[h]=a?"0":"",d[m]=u?"0":"",d.transform=2>(v.devicePixelRatio||1)?"translate("+e+"px, "+l+"px)":"translate3d("+e+"px, "+l+"px, 0)",d)):Object.assign(Object.assign({},r),{},((t={})[h]=a?l+"px":"",t[m]=u?e+"px":"",t.transform="",t))}function A(e){return e.replace(/left|right|bottom|top/g,(function(e){return G[e]}))}function H(e){return e.replace(/start|end/g,(function(e){return J[e]}))}function R(e,t,n){return void 0===n&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function S(e){return["top","right","bottom","left"].some((function(t){return 0<=e[t]}))}var T=["top","bottom","right","left"],q=T.reduce((function(e,t){return e.concat([t+"-start",t+"-end"])}),[]),C=[].concat(T,["auto"]).reduce((function(e,t){return e.concat([t,t+"-start",t+"-end"])}),[]),N="beforeRead read afterRead beforeMain main afterMain beforeWrite write afterWrite".split(" "),V={placement:"bottom",modifiers:[],strategy:"absolute"},I={passive:!0},_={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:function(e){var t=e.state,r=e.instance,o=(e=e.options).scroll,i=void 0===o||o,a=void 0===(e=e.resize)||e,s=n(t.elements.popper),f=[].concat(t.scrollParents.reference,t.scrollParents.popper);return i&&f.forEach((function(e){e.addEventListener("scroll",r.update,I)})),a&&s.addEventListener("resize",r.update,I),function(){i&&f.forEach((function(e){e.removeEventListener("scroll",r.update,I)})),a&&s.removeEventListener("resize",r.update,I)}},data:{}},U={name:"popperOffsets",enabled:!0,phase:"read",fn:function(e){var t=e.state;t.modifiersData[e.name]=E({reference:t.rects.reference,element:t.rects.popper,strategy:"absolute",placement:t.placement})},data:{}},z={top:"auto",right:"auto",bottom:"auto",left:"auto"},F={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:function(e){var t=e.state,n=e.options;e=void 0===(e=n.gpuAcceleration)||e,n=void 0===(n=n.adaptive)||n,e={placement:y(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:e},null!=t.modifiersData.popperOffsets&&(t.styles.popper=Object.assign(Object.assign({},t.styles.popper),W(Object.assign(Object.assign({},e),{},{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:n})))),null!=t.modifiersData.arrow&&(t.styles.arrow=Object.assign(Object.assign({},t.styles.arrow),W(Object.assign(Object.assign({},e),{},{offsets:t.modifiersData.arrow,position:"absolute",adaptive:!1})))),t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-placement":t.placement})},data:{}},X={name:"applyStyles",enabled:!0,phase:"write",fn:function(e){var t=e.state;Object.keys(t.elements).forEach((function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},o=t.elements[e];i(o)&&a(o)&&(Object.assign(o.style,n),Object.keys(r).forEach((function(e){var t=r[e];!1===t?o.removeAttribute(e):o.setAttribute(e,!0===t?"":t)})))}))},effect:function(e){var t=e.state,n={popper:{position:t.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach((function(e){var r=t.elements[e],o=t.attributes[e]||{};e=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce((function(e,t){return e[t]="",e}),{}),i(r)&&a(r)&&(Object.assign(r.style,e),Object.keys(o).forEach((function(e){r.removeAttribute(e)})))}))}},requires:["computeStyles"]},Y={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:function(e){var t=e.state,n=e.name,r=void 0===(e=e.options.offset)?[0,0]:e,o=(e=C.reduce((function(e,n){var o=t.rects,i=y(n),a=0<=["left","top"].indexOf(i)?-1:1,s="function"==typeof r?r(Object.assign(Object.assign({},o),{},{placement:n})):r;return o=(o=s[0])||0,s=((s=s[1])||0)*a,i=0<=["left","right"].indexOf(i)?{x:s,y:o}:{x:o,y:s},e[n]=i,e}),{}))[t.placement],i=o.x;o=o.y,null!=t.modifiersData.popperOffsets&&(t.modifiersData.popperOffsets.x+=i,t.modifiersData.popperOffsets.y+=o),t.modifiersData[n]=e}},G={left:"right",right:"left",bottom:"top",top:"bottom"},J={start:"end",end:"start"},K={name:"flip",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options;if(e=e.name,!t.modifiersData[e]._skip){var r=n.mainAxis;r=void 0===r||r;var o=n.altAxis;o=void 0===o||o;var i=n.fallbackPlacements,a=n.padding,s=n.boundary,f=n.rootBoundary,c=n.altBoundary,p=n.flipVariations,l=void 0===p||p,u=n.allowedAutoPlacements;p=y(n=t.options.placement),i=i||(p!==n&&l?function(e){if("auto"===y(e))return[];var t=A(e);return[H(e),t,H(t)]}(n):[A(n)]);var d=[n].concat(i).reduce((function(e,n){return e.concat("auto"===y(n)?function(e,t){void 0===t&&(t={});var n=t.boundary,r=t.rootBoundary,o=t.padding,i=t.flipVariations,a=t.allowedAutoPlacements,s=void 0===a?C:a,f=t.placement.split("-")[1];0===(i=(t=f?i?q:q.filter((function(e){return e.split("-")[1]===f})):T).filter((function(e){return 0<=s.indexOf(e)}))).length&&(i=t);var c=i.reduce((function(t,i){return t[i]=L(e,{placement:i,boundary:n,rootBoundary:r,padding:o})[y(i)],t}),{});return Object.keys(c).sort((function(e,t){return c[e]-c[t]}))}(t,{placement:n,boundary:s,rootBoundary:f,padding:a,flipVariations:l,allowedAutoPlacements:u}):n)}),[]);n=t.rects.reference,i=t.rects.popper;var m=new Map;p=!0;for(var h=d[0],g=0;g<d.length;g++){var v=d[g],b=y(v),O="start"===v.split("-")[1],w=0<=["top","bottom"].indexOf(b),x=w?"width":"height",j=L(t,{placement:v,boundary:s,rootBoundary:f,altBoundary:c,padding:a});if(O=w?O?"right":"left":O?"bottom":"top",n[x]>i[x]&&(O=A(O)),x=A(O),w=[],r&&w.push(0>=j[b]),o&&w.push(0>=j[O],0>=j[x]),w.every((function(e){return e}))){h=v,p=!1;break}m.set(v,w)}if(p)for(r=function(e){var t=d.find((function(t){if(t=m.get(t))return t.slice(0,e).every((function(e){return e}))}));if(t)return h=t,"break"},o=l?3:1;0<o&&"break"!==r(o);o--);t.placement!==h&&(t.modifiersData[e]._skip=!0,t.placement=h,t.reset=!0)}},requiresIfExists:["offset"],data:{_skip:!1}},Q={name:"preventOverflow",enabled:!0,phase:"main",fn:function(e){var t=e.state,n=e.options;e=e.name;var r=n.mainAxis,o=void 0===r||r;r=void 0!==(r=n.altAxis)&&r;var i=n.tether;i=void 0===i||i;var a=n.tetherOffset,s=void 0===a?0:a;n=L(t,{boundary:n.boundary,rootBoundary:n.rootBoundary,padding:n.padding,altBoundary:n.altBoundary}),a=y(t.placement);var f=t.placement.split("-")[1],c=!f,p=M(a);a="x"===p?"y":"x";var l=t.modifiersData.popperOffsets,d=t.rects.reference,m=t.rects.popper,h="function"==typeof s?s(Object.assign(Object.assign({},t.rects),{},{placement:t.placement})):s;if(s={x:0,y:0},l){if(o){var v="y"===p?"top":"left",b="y"===p?"bottom":"right",O="y"===p?"height":"width";o=l[p];var w=l[p]+n[v],x=l[p]-n[b],j=i?-m[O]/2:0,E="start"===f?d[O]:m[O];f="start"===f?-m[O]:-d[O],m=t.elements.arrow,m=i&&m?u(m):{width:0,height:0};var D=t.modifiersData["arrow#persistent"]?t.modifiersData["arrow#persistent"].padding:{top:0,right:0,bottom:0,left:0};v=D[v],b=D[b],m=Math.max(0,Math.min(d[O],m[O])),E=c?d[O]/2-j-m-v-h:E-m-v-h,c=c?-d[O]/2+j+m+b+h:f+m+b+h,h=t.elements.arrow&&g(t.elements.arrow),d=t.modifiersData.offset?t.modifiersData.offset[t.placement][p]:0,h=l[p]+E-d-(h?"y"===p?h.clientTop||0:h.clientLeft||0:0),c=l[p]+c-d,i=Math.max(i?Math.min(w,h):w,Math.min(o,i?Math.max(x,c):x)),l[p]=i,s[p]=i-o}r&&(r=l[a],i=Math.max(r+n["x"===p?"top":"left"],Math.min(r,r-n["x"===p?"bottom":"right"])),l[a]=i,s[a]=i-r),t.modifiersData[e]=s}},requiresIfExists:["offset"]},Z={name:"arrow",enabled:!0,phase:"main",fn:function(e){var t,n=e.state;e=e.name;var r=n.elements.arrow,o=n.modifiersData.popperOffsets,i=y(n.placement),a=M(i);if(i=0<=["left","right"].indexOf(i)?"height":"width",r&&o){var s=n.modifiersData[e+"#persistent"].padding,f=u(r),c="y"===a?"top":"left",p="y"===a?"bottom":"right",l=n.rects.reference[i]+n.rects.reference[a]-o[a]-n.rects.popper[i];o=o[a]-n.rects.reference[a],l=(r=(r=g(r))?"y"===a?r.clientHeight||0:r.clientWidth||0:0)/2-f[i]/2+(l/2-o/2),i=Math.max(s[c],Math.min(l,r-f[i]-s[p])),n.modifiersData[e]=((t={})[a]=i,t.centerOffset=i-l,t)}},effect:function(e){var t=e.state,n=e.options;e=e.name;var r=n.element;if(r=void 0===r?"[data-popper-arrow]":r,n=void 0===(n=n.padding)?0:n,null!=r){if("string"==typeof r&&!(r=t.elements.popper.querySelector(r)))return;O(t.elements.popper,r)&&(t.elements.arrow=r,t.modifiersData[e+"#persistent"]={padding:D("number"!=typeof n?n:P(n,T))})}},requires:["popperOffsets"],requiresIfExists:["preventOverflow"]},$={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:function(e){var t=e.state;e=e.name;var n=t.rects.reference,r=t.rects.popper,o=t.modifiersData.preventOverflow,i=L(t,{elementContext:"reference"}),a=L(t,{altBoundary:!0});n=R(i,n),r=R(a,r,o),o=S(n),a=S(r),t.modifiersData[e]={referenceClippingOffsets:n,popperEscapeOffsets:r,isReferenceHidden:o,hasPopperEscaped:a},t.attributes.popper=Object.assign(Object.assign({},t.attributes.popper),{},{"data-popper-reference-hidden":o,"data-popper-escaped":a})}},ee=B({defaultModifiers:[_,U,F,X]}),te=[_,U,F,X,Y,K,Q,Z,$],ne=B({defaultModifiers:te});e.applyStyles=X,e.arrow=Z,e.computeStyles=F,e.createPopper=ne,e.createPopperLite=ee,e.defaultModifiers=te,e.detectOverflow=L,e.eventListeners=_,e.flip=K,e.hide=$,e.offset=Y,e.popperGenerator=B,e.popperOffsets=U,e.preventOverflow=Q,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
var activeToggleClass = 'is-active'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Mode toggles
|
|
5
|
+
*/
|
|
6
|
+
var mode = document.querySelectorAll('.js-mode')
|
|
7
|
+
var currentMode = 'html'
|
|
8
|
+
|
|
9
|
+
mode.forEach(function (toggle) {
|
|
10
|
+
toggle.addEventListener('click', function (event) {
|
|
11
|
+
// Reset all classes
|
|
12
|
+
mode.forEach(function (modeToggle) {
|
|
13
|
+
// Remove active class from all toggles
|
|
14
|
+
modeToggle.classList.remove(activeToggleClass)
|
|
15
|
+
|
|
16
|
+
// Hide all views
|
|
17
|
+
document
|
|
18
|
+
.querySelector('.js-' + modeToggle.dataset.mode)
|
|
19
|
+
.classList.add('is-hidden')
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// Add active class
|
|
23
|
+
currentMode = this.dataset.mode
|
|
24
|
+
this.classList.add(activeToggleClass)
|
|
25
|
+
|
|
26
|
+
// Show view
|
|
27
|
+
document
|
|
28
|
+
.querySelector('.js-' + this.dataset.mode)
|
|
29
|
+
.classList.remove('is-hidden')
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* View toggles
|
|
35
|
+
*/
|
|
36
|
+
var view = document.querySelectorAll('.js-view')
|
|
37
|
+
var currentView = 'desktop'
|
|
38
|
+
|
|
39
|
+
view.forEach(function (toggle) {
|
|
40
|
+
// Add click event
|
|
41
|
+
toggle.addEventListener('click', function (event) {
|
|
42
|
+
view.forEach(function (viewToggle) {
|
|
43
|
+
// Remove active class from all toggles
|
|
44
|
+
viewToggle.classList.remove(activeToggleClass)
|
|
45
|
+
|
|
46
|
+
document.querySelectorAll('.preview-iframe').forEach(function (item) {
|
|
47
|
+
item.classList.remove('preview-iframe--mobile')
|
|
48
|
+
})
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
currentView = this.dataset.view
|
|
52
|
+
this.classList.add(activeToggleClass)
|
|
53
|
+
|
|
54
|
+
if (this.dataset.view === 'mobile') {
|
|
55
|
+
document.querySelectorAll('.preview-iframe').forEach(function (item) {
|
|
56
|
+
item.classList.add('preview-iframe--mobile')
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
function keypress(e) {
|
|
63
|
+
var evt = window.event ? event : e
|
|
64
|
+
|
|
65
|
+
// ctrl + v
|
|
66
|
+
if (evt.keyCode == 86 && evt.ctrlKey) {
|
|
67
|
+
var view = currentView === 'desktop' ? 'mobile' : 'desktop'
|
|
68
|
+
document.querySelector('.js-view[data-view="' + view + '"]').click()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ctrl + m
|
|
72
|
+
if (evt.keyCode == 77 && evt.ctrlKey) {
|
|
73
|
+
var mode = currentMode === 'html' ? 'text' : 'html'
|
|
74
|
+
document.querySelector('.js-mode[data-mode="' + mode + '"]').click()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
document.onkeydown = keypress
|
|
79
|
+
|
|
80
|
+
// Manage state when HTML iframe is finished loading
|
|
81
|
+
document.querySelector('.js-html').onload = function () {
|
|
82
|
+
// Hide loading indicator
|
|
83
|
+
document.querySelector('.js-loader').classList.add('is-hidden')
|
|
84
|
+
|
|
85
|
+
// Add state class to HTML iframe
|
|
86
|
+
this.classList.add('is-loaded')
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
// Tooltip handlers
|
|
91
|
+
*/
|
|
92
|
+
var tooltipTrigger = document.querySelectorAll('.js-tooltip-trigger')
|
|
93
|
+
|
|
94
|
+
// Loop through each tooltip trigger
|
|
95
|
+
tooltipTrigger.forEach(function (trigger) {
|
|
96
|
+
var showEvents = ['mouseenter', 'focus']
|
|
97
|
+
var hideEvents = ['mouseleave', 'blur']
|
|
98
|
+
|
|
99
|
+
// Show event
|
|
100
|
+
showEvents.forEach(function (event) {
|
|
101
|
+
trigger.addEventListener(event, function () {
|
|
102
|
+
var selector =
|
|
103
|
+
'.js-tooltip[data-tooltip="' + trigger.dataset.tooltip + '"]'
|
|
104
|
+
var tooltip = document.querySelector(selector)
|
|
105
|
+
tooltip.setAttribute('data-show', '')
|
|
106
|
+
})
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
// Hide event
|
|
110
|
+
hideEvents.forEach(function (event) {
|
|
111
|
+
trigger.addEventListener(event, function () {
|
|
112
|
+
var selector =
|
|
113
|
+
'.js-tooltip[data-tooltip="' + trigger.dataset.tooltip + '"]'
|
|
114
|
+
var tooltip = document.querySelector(selector)
|
|
115
|
+
tooltip.removeAttribute('data-show')
|
|
116
|
+
})
|
|
117
|
+
})
|
|
118
|
+
})
|