simple-boot-front 1.0.98 → 1.0.101

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.StorageService = void 0;
13
+ var SimDecorator_1 = require("simple-boot-core/decorators/SimDecorator");
14
+ var SimFrontOption_1 = require("../option/SimFrontOption");
15
+ var StorageUtils_1 = require("dom-render/utils/storage/StorageUtils");
16
+ var StorageService = (function () {
17
+ function StorageService(option) {
18
+ this.option = option;
19
+ }
20
+ StorageService.prototype.setLocalStorageItem = function (k, v, window) {
21
+ if (window === void 0) { window = this.option.window; }
22
+ if (typeof v === 'object') {
23
+ v = JSON.stringify(v);
24
+ }
25
+ window.localStorage.setItem(k, v);
26
+ };
27
+ StorageService.prototype.getLocalStorageItem = function (k, window) {
28
+ if (window === void 0) { window = this.option.window; }
29
+ return window.localStorage.getItem(k);
30
+ };
31
+ StorageService.prototype.cutLocalStorageItem = function (k, window) {
32
+ if (window === void 0) { window = this.option.window; }
33
+ var data = StorageUtils_1.StorageUtils.getLocalStorageItem(k, window);
34
+ StorageUtils_1.StorageUtils.removeLocalStorageItem(k, window);
35
+ return data;
36
+ };
37
+ StorageService.prototype.removeLocalStorageItem = function (k, window) {
38
+ if (window === void 0) { window = this.option.window; }
39
+ return window.localStorage.removeItem(k);
40
+ };
41
+ StorageService.prototype.getLocalStorageJsonItem = function (k, window) {
42
+ if (window === void 0) { window = this.option.window; }
43
+ var item = window.localStorage.getItem(k);
44
+ if (item) {
45
+ return JSON.parse(item);
46
+ }
47
+ else {
48
+ return undefined;
49
+ }
50
+ };
51
+ StorageService.prototype.cutLocalStorageJsonItem = function (k, window) {
52
+ if (window === void 0) { window = this.option.window; }
53
+ var item = StorageUtils_1.StorageUtils.getLocalStorageJsonItem(k, window);
54
+ StorageUtils_1.StorageUtils.removeLocalStorageItem(k, window);
55
+ return item;
56
+ };
57
+ StorageService.prototype.clearLocalStorage = function (window) {
58
+ if (window === void 0) { window = this.option.window; }
59
+ window.localStorage.clear();
60
+ };
61
+ StorageService = __decorate([
62
+ (0, SimDecorator_1.Sim)(),
63
+ __metadata("design:paramtypes", [SimFrontOption_1.SimFrontOption])
64
+ ], StorageService);
65
+ return StorageService;
66
+ }());
67
+ exports.StorageService = StorageService;
@@ -31,11 +31,11 @@ var ViewService = (function () {
31
31
  };
32
32
  ViewService.prototype.eI = function (selector) {
33
33
  var _a;
34
- return (_a = this.e("#" + selector)) !== null && _a !== void 0 ? _a : undefined;
34
+ return (_a = this.e("#".concat(selector))) !== null && _a !== void 0 ? _a : undefined;
35
35
  };
36
36
  ViewService.prototype.eC = function (selector) {
37
37
  var _a;
38
- return (_a = this.e("." + selector)) !== null && _a !== void 0 ? _a : undefined;
38
+ return (_a = this.e(".".concat(selector))) !== null && _a !== void 0 ? _a : undefined;
39
39
  };
40
40
  ViewService = __decorate([
41
41
  (0, SimDecorator_1.Sim)(),
@@ -1,13 +0,0 @@
1
- export declare type Attr = {
2
- name: string;
3
- value: any;
4
- };
5
- export declare class DomUtils {
6
- static selectorElements(selector: string, element?: Element | Document): Element[];
7
- static selectorNodes(selector: string, element?: Element | Document): NodeListOf<Element>;
8
- static removeAttribute(result: HTMLElement, attrs: string[]): void;
9
- static setAttribute(result: HTMLElement, attrs: string[]): void;
10
- static setAttributeAttr(result: HTMLElement, attrs: Attr[]): void;
11
- static getAttributeToObject(input: HTMLElement): any;
12
- static getStyleToObject(input: HTMLElement): any;
13
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DomUtils = void 0;
4
- var DomUtils = (function () {
5
- function DomUtils() {
6
- }
7
- DomUtils.selectorElements = function (selector, element) {
8
- if (element === void 0) { element = document; }
9
- return Array.prototype.slice.call(element.querySelectorAll(selector));
10
- };
11
- DomUtils.selectorNodes = function (selector, element) {
12
- if (element === void 0) { element = document; }
13
- return element.querySelectorAll(selector);
14
- };
15
- DomUtils.removeAttribute = function (result, attrs) {
16
- attrs.forEach(function (it) {
17
- result.removeAttribute(it);
18
- });
19
- };
20
- DomUtils.setAttribute = function (result, attrs) {
21
- attrs.forEach(function (it) {
22
- result.setAttribute(it, '');
23
- });
24
- };
25
- DomUtils.setAttributeAttr = function (result, attrs) {
26
- attrs.forEach(function (it) {
27
- result.setAttribute(it.name, it.value);
28
- });
29
- };
30
- DomUtils.getAttributeToObject = function (input) {
31
- var attribute = {};
32
- input.getAttributeNames().forEach(function (ait) { return attribute[ait] = input.getAttribute(ait); });
33
- return attribute;
34
- };
35
- DomUtils.getStyleToObject = function (input) {
36
- var style = {};
37
- for (var i = 0; i < input.style.length; i++) {
38
- var key = input.style[i];
39
- style[key] = input.style[key];
40
- }
41
- return style;
42
- };
43
- return DomUtils;
44
- }());
45
- exports.DomUtils = DomUtils;
@@ -1,10 +0,0 @@
1
- export declare type Attr = {
2
- name: string;
3
- value: any;
4
- };
5
- export declare class NodeUtils {
6
- static removeAllChildNode(node: Node): void;
7
- static appendChild(parentNode: Node, childNode: Node): Node;
8
- static replaceNode(targetNode: Node, newNode: Node): Node | undefined;
9
- static addNode(targetNode: Node, newNode: Node): Node | undefined;
10
- }
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodeUtils = void 0;
4
- var NodeUtils = (function () {
5
- function NodeUtils() {
6
- }
7
- NodeUtils.removeAllChildNode = function (node) {
8
- while (node === null || node === void 0 ? void 0 : node.firstChild) {
9
- node.firstChild.remove();
10
- }
11
- };
12
- NodeUtils.appendChild = function (parentNode, childNode) {
13
- return parentNode.appendChild(childNode);
14
- };
15
- NodeUtils.replaceNode = function (targetNode, newNode) {
16
- var _a;
17
- return (_a = targetNode.parentNode) === null || _a === void 0 ? void 0 : _a.replaceChild(newNode, targetNode);
18
- };
19
- NodeUtils.addNode = function (targetNode, newNode) {
20
- var _a;
21
- return (_a = targetNode.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(newNode, targetNode.nextSibling);
22
- };
23
- return NodeUtils;
24
- }());
25
- exports.NodeUtils = NodeUtils;
@@ -1,8 +0,0 @@
1
- export declare class LocationUtils {
2
- static hash(): string;
3
- static hashPath(): string;
4
- static hashQueryParams(): Map<string, string>;
5
- static path(): string;
6
- static pathQueryParams(): Map<string, string>;
7
- private static queryStringToMap;
8
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocationUtils = void 0;
4
- var LocationUtils = (function () {
5
- function LocationUtils() {
6
- }
7
- LocationUtils.hash = function () {
8
- return window.location.hash.replace('#', '');
9
- };
10
- LocationUtils.hashPath = function () {
11
- return '/' + window.location.hash.replace('#', '').split('?')[0];
12
- };
13
- LocationUtils.hashQueryParams = function () {
14
- var s = window.location.hash.replace('#', '').split('?')[1] || '';
15
- return this.queryStringToMap(s);
16
- };
17
- LocationUtils.path = function () {
18
- return window.location.pathname;
19
- };
20
- LocationUtils.pathQueryParams = function () {
21
- return this.queryStringToMap(window.location.search.substring(1));
22
- };
23
- LocationUtils.queryStringToMap = function (s) {
24
- var params = new Map();
25
- var vars = s.split('&') || [];
26
- vars.forEach(function (it) {
27
- var kv = it.split('=') || [];
28
- params.set(kv[0], kv[1]);
29
- });
30
- return params;
31
- };
32
- return LocationUtils;
33
- }());
34
- exports.LocationUtils = LocationUtils;