@acorex/core 6.5.26 → 6.5.27

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.
Files changed (144) hide show
  1. package/karma.conf.js +32 -0
  2. package/ng-package.json +10 -0
  3. package/package.json +12 -32
  4. package/src/lib/classes/base-page.class.ts +29 -0
  5. package/src/lib/classes/color.class.ts +61 -0
  6. package/src/lib/classes/datetime.class.ts +373 -0
  7. package/src/lib/classes/menu.class.ts +37 -0
  8. package/{lib/classes/navigator.class.d.ts → src/lib/classes/navigator.class.ts} +1 -1
  9. package/{lib/classes/popup.class.d.ts → src/lib/classes/popup.class.ts} +2 -0
  10. package/src/lib/classes/promise.class.ts +25 -0
  11. package/src/lib/classes/select.class.ts +7 -0
  12. package/src/lib/core.module.ts +21 -0
  13. package/src/lib/error/error.module.ts +13 -0
  14. package/src/lib/error/error.service.ts +23 -0
  15. package/src/lib/error/index.ts +3 -0
  16. package/{lib/events/keyboard.d.ts → src/lib/events/keyboard.ts} +3 -0
  17. package/{lib/http/http-error.class.d.ts → src/lib/http/http-error.class.ts} +2 -2
  18. package/{lib/http/http-events.interceptor.d.ts → src/lib/http/http-events.interceptor.ts} +7 -3
  19. package/{lib/http/http-request.class.d.ts → src/lib/http/http-request.class.ts} +5 -5
  20. package/src/lib/http/http-result.class.ts +34 -0
  21. package/src/lib/http/http.module.ts +25 -0
  22. package/src/lib/http/http.service.ts +159 -0
  23. package/{esm2020 → src}/lib/locale/en.json +6 -6
  24. package/{esm2020 → src}/lib/locale/fa.json +7 -7
  25. package/src/lib/pipe/datetime.pipe.ts +20 -0
  26. package/src/lib/pipe/htmlToText.pipe.ts +18 -0
  27. package/src/lib/platform/index.ts +1 -0
  28. package/src/lib/platform/platform.service.ts +223 -0
  29. package/src/lib/services/config.ts +36 -0
  30. package/src/lib/services/event.service.ts +31 -0
  31. package/src/lib/services/navigator.service.ts +8 -0
  32. package/src/lib/services/storage.service.ts +11 -0
  33. package/src/lib/translator/translator.module.ts +19 -0
  34. package/src/lib/translator/translator.pipe.ts +22 -0
  35. package/src/lib/translator/translator.service.ts +19 -0
  36. package/src/lib/translator/translator.ts +31 -0
  37. package/src/lib/utils/array/array-util.ts +140 -0
  38. package/src/lib/utils/html/html-util.ts +264 -0
  39. package/src/lib/utils/html/html.module.ts +11 -0
  40. package/src/lib/utils/math/math-util.ts +5 -0
  41. package/src/lib/utils/object/object-util.ts +87 -0
  42. package/src/lib/utils/render/on-demand-preload-strategy.service.ts +25 -0
  43. package/src/lib/utils/render/render.service.ts +110 -0
  44. package/src/lib/utils/render/rendering.module.ts +25 -0
  45. package/src/lib/utils/scroll/scroll.directive.ts +35 -0
  46. package/src/lib/utils/scroll/scroll.module.ts +11 -0
  47. package/src/lib/utils/separator/separator.module.ts +11 -0
  48. package/src/lib/utils/separator/separator.pipe.ts +27 -0
  49. package/{public-api.d.ts → src/public-api.ts} +10 -0
  50. package/src/test.ts +28 -0
  51. package/tsconfig.lib.json +25 -0
  52. package/tsconfig.lib.prod.json +6 -0
  53. package/tsconfig.spec.json +18 -0
  54. package/tslint.json +17 -0
  55. package/acorex-core.d.ts +0 -5
  56. package/esm2020/acorex-core.mjs +0 -5
  57. package/esm2020/lib/classes/base-page.class.mjs +0 -28
  58. package/esm2020/lib/classes/color.class.mjs +0 -49
  59. package/esm2020/lib/classes/datetime.class.mjs +0 -314
  60. package/esm2020/lib/classes/menu.class.mjs +0 -27
  61. package/esm2020/lib/classes/navigator.class.mjs +0 -2
  62. package/esm2020/lib/classes/popup.class.mjs +0 -2
  63. package/esm2020/lib/classes/promise.class.mjs +0 -19
  64. package/esm2020/lib/classes/sectionlist.class.mjs +0 -2
  65. package/esm2020/lib/classes/select.class.mjs +0 -3
  66. package/esm2020/lib/core.module.mjs +0 -27
  67. package/esm2020/lib/error/error.class.mjs +0 -2
  68. package/esm2020/lib/error/error.module.mjs +0 -19
  69. package/esm2020/lib/error/error.service.mjs +0 -21
  70. package/esm2020/lib/events/keyboard.mjs +0 -2
  71. package/esm2020/lib/http/http-error.class.mjs +0 -2
  72. package/esm2020/lib/http/http-events.interceptor.mjs +0 -3
  73. package/esm2020/lib/http/http-request.class.mjs +0 -2
  74. package/esm2020/lib/http/http-result.class.mjs +0 -21
  75. package/esm2020/lib/http/http.module.mjs +0 -37
  76. package/esm2020/lib/http/http.service.mjs +0 -145
  77. package/esm2020/lib/pipe/datetime.pipe.mjs +0 -25
  78. package/esm2020/lib/pipe/htmlToText.pipe.mjs +0 -25
  79. package/esm2020/lib/platform/index.mjs +0 -2
  80. package/esm2020/lib/platform/platform.service.mjs +0 -150
  81. package/esm2020/lib/services/config.mjs +0 -29
  82. package/esm2020/lib/services/event.service.mjs +0 -36
  83. package/esm2020/lib/services/navigator.service.mjs +0 -10
  84. package/esm2020/lib/services/storage.service.mjs +0 -16
  85. package/esm2020/lib/translator/translator.mjs +0 -26
  86. package/esm2020/lib/translator/translator.module.mjs +0 -25
  87. package/esm2020/lib/translator/translator.pipe.mjs +0 -24
  88. package/esm2020/lib/translator/translator.service.mjs +0 -21
  89. package/esm2020/lib/utils/array/array-util.mjs +0 -133
  90. package/esm2020/lib/utils/html/html-util.mjs +0 -192
  91. package/esm2020/lib/utils/html/html.module.mjs +0 -19
  92. package/esm2020/lib/utils/math/math-util.mjs +0 -6
  93. package/esm2020/lib/utils/object/object-util.mjs +0 -83
  94. package/esm2020/lib/utils/render/on-demand-preload-strategy.service.mjs +0 -20
  95. package/esm2020/lib/utils/render/render.service.mjs +0 -103
  96. package/esm2020/lib/utils/render/rendering.module.mjs +0 -35
  97. package/esm2020/lib/utils/scroll/scroll.directive.mjs +0 -54
  98. package/esm2020/lib/utils/scroll/scroll.module.mjs +0 -19
  99. package/esm2020/lib/utils/separator/separator.module.mjs +0 -19
  100. package/esm2020/lib/utils/separator/separator.pipe.mjs +0 -33
  101. package/esm2020/public-api.mjs +0 -44
  102. package/fesm2015/acorex-core.mjs +0 -2274
  103. package/fesm2015/acorex-core.mjs.map +0 -1
  104. package/fesm2020/acorex-core.mjs +0 -2270
  105. package/fesm2020/acorex-core.mjs.map +0 -1
  106. package/lib/classes/base-page.class.d.ts +0 -13
  107. package/lib/classes/color.class.d.ts +0 -17
  108. package/lib/classes/datetime.class.d.ts +0 -63
  109. package/lib/classes/menu.class.d.ts +0 -34
  110. package/lib/classes/promise.class.d.ts +0 -7
  111. package/lib/classes/select.class.d.ts +0 -7
  112. package/lib/core.module.d.ts +0 -9
  113. package/lib/error/error.module.d.ts +0 -7
  114. package/lib/error/error.service.d.ts +0 -13
  115. package/lib/http/http-result.class.d.ts +0 -11
  116. package/lib/http/http.module.d.ts +0 -10
  117. package/lib/http/http.service.d.ts +0 -23
  118. package/lib/pipe/datetime.pipe.d.ts +0 -8
  119. package/lib/pipe/htmlToText.pipe.d.ts +0 -7
  120. package/lib/platform/index.d.ts +0 -1
  121. package/lib/platform/platform.service.d.ts +0 -26
  122. package/lib/services/config.d.ts +0 -9
  123. package/lib/services/event.service.d.ts +0 -9
  124. package/lib/services/navigator.service.d.ts +0 -8
  125. package/lib/services/storage.service.d.ts +0 -7
  126. package/lib/translator/translator.d.ts +0 -9
  127. package/lib/translator/translator.module.d.ts +0 -8
  128. package/lib/translator/translator.pipe.d.ts +0 -8
  129. package/lib/translator/translator.service.d.ts +0 -8
  130. package/lib/utils/array/array-util.d.ts +0 -6
  131. package/lib/utils/html/html-util.d.ts +0 -62
  132. package/lib/utils/html/html.module.d.ts +0 -8
  133. package/lib/utils/math/math-util.d.ts +0 -3
  134. package/lib/utils/object/object-util.d.ts +0 -7
  135. package/lib/utils/render/on-demand-preload-strategy.service.d.ts +0 -10
  136. package/lib/utils/render/render.service.d.ts +0 -18
  137. package/lib/utils/render/rendering.module.d.ts +0 -8
  138. package/lib/utils/scroll/scroll.directive.d.ts +0 -18
  139. package/lib/utils/scroll/scroll.module.d.ts +0 -8
  140. package/lib/utils/separator/separator.module.d.ts +0 -8
  141. package/lib/utils/separator/separator.pipe.d.ts +0 -8
  142. package/npm +0 -0
  143. /package/{lib/classes/sectionlist.class.d.ts → src/lib/classes/sectionlist.class.ts} +0 -0
  144. /package/{lib/error/error.class.d.ts → src/lib/error/error.class.ts} +0 -0
@@ -0,0 +1,31 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable({ providedIn: 'root' })
4
+ export class AXEventService {
5
+ private list: any[] = [];
6
+
7
+ public broadcast(key: string, options?: any): void {
8
+ const d = this.list.find(c => c.key === key);
9
+ if (d) {
10
+ d.events.forEach(c => {
11
+ c(options);
12
+ });
13
+ }
14
+ }
15
+
16
+ public on(key: string, callback: (options?: any) => void) {
17
+ let d = this.list.find(c => c.key === key);
18
+ if (!d) {
19
+ d = { key, events: [] };
20
+ this.list.push(d);
21
+ }
22
+ d.events.push(callback);
23
+ }
24
+
25
+ public destroy(key: string, callback: (options?: any) => void): void {
26
+ const d = this.list.find(c => c.key === key);
27
+ if (d) {
28
+ d.events = [];
29
+ }
30
+ }
31
+ }
@@ -0,0 +1,8 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { AXNavigatorParam } from '../classes/navigator.class';
3
+
4
+ @Injectable()
5
+ export abstract class AXNavigator {
6
+ abstract navigate(params: AXNavigatorParam);
7
+ abstract popup(params: AXNavigatorParam);
8
+ }
@@ -0,0 +1,11 @@
1
+ import { Injectable } from '@angular/core';
2
+
3
+ @Injectable()
4
+ export class AXStorageService {
5
+ get(key: string): any {
6
+ return localStorage.getItem(key) as any;
7
+ }
8
+ set(key: string, value: any): void {
9
+ localStorage.setItem(key, value as string);
10
+ }
11
+ }
@@ -0,0 +1,19 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { AXTranslatorPipe } from './translator.pipe';
3
+ import * as en from '../locale/en.json';
4
+ import * as fa from '../locale/fa.json';
5
+ import { AXTranslator } from './translator';
6
+
7
+
8
+ @NgModule({
9
+ imports: [],
10
+ exports: [AXTranslatorPipe],
11
+ declarations: [AXTranslatorPipe],
12
+ providers: [],
13
+ })
14
+ export class AXTranslatorModule {
15
+ constructor() {
16
+ AXTranslator.load('en', en);
17
+ AXTranslator.load('fa', fa);
18
+ }
19
+ }
@@ -0,0 +1,22 @@
1
+ import { Pipe, PipeTransform } from '@angular/core';
2
+ import { AXTranslator } from './translator';
3
+
4
+ @Pipe({ name: 'trans', pure: true })
5
+ export class AXTranslatorPipe implements PipeTransform {
6
+
7
+ constructor() { }
8
+
9
+ // transform(value: string, lang?: string): Promise<string> {
10
+ // return new Promise<string>((resolve, reject) => {
11
+ // if (!value) {
12
+ // resolve(value);
13
+ // }
14
+ // resolve(this.translate.get(value, lang));
15
+ // });
16
+
17
+ // }
18
+
19
+ transform(value: string, lang?: string): string {
20
+ return AXTranslator.get(value, lang);
21
+ }
22
+ }
@@ -0,0 +1,19 @@
1
+ import { Injectable } from '@angular/core';
2
+ import { AXTranslator } from './translator';
3
+
4
+ @Injectable({ providedIn: 'platform' })
5
+ export class AXTranslatorService {
6
+
7
+ public load(lang: string, value: any) {
8
+ AXTranslator.load(lang, value);
9
+ }
10
+
11
+ public use(lang: string) {
12
+ AXTranslator.use(lang);
13
+ }
14
+
15
+ public get(key: string, lang?: string): string {
16
+ return AXTranslator.get(lang, lang);
17
+ }
18
+ }
19
+
@@ -0,0 +1,31 @@
1
+ import { Subject, Observable } from 'rxjs';
2
+ import { getPropByPath} from '../utils/object/object-util';
3
+ import merge from 'lodash-es/merge';
4
+
5
+ // @dynamic
6
+ export class AXTranslator {
7
+ private static lang: string = 'en';
8
+ private static dataChangeSubject = new Subject<any>();
9
+
10
+
11
+ static get onChange(): Observable<any> {
12
+ return AXTranslator.dataChangeSubject.asObservable();
13
+ }
14
+
15
+ public static load(lang: string, value: any) {
16
+ if (typeof value === 'object') {
17
+ if (!AXTranslator[`__data__${lang}`]) {
18
+ AXTranslator[`__data__${lang}`] = {};
19
+ }
20
+ AXTranslator[`__data__${lang}`] = merge(AXTranslator[`__data__${lang}`], value);
21
+ }
22
+ }
23
+
24
+ public static use(lang: string) {
25
+ AXTranslator.lang = lang;
26
+ }
27
+
28
+ public static get(key: string, lang?: string): string {
29
+ return getPropByPath(AXTranslator[`__data__${lang || AXTranslator.lang}`], key) || key;
30
+ }
31
+ }
@@ -0,0 +1,140 @@
1
+ import { AXFetchProp } from '../object/object-util';
2
+
3
+ // @dynamic
4
+ export class AXArrayUtil {
5
+
6
+
7
+ static pickRandom(array: any[]): any {
8
+ return array[Math.floor(Math.random() * array.length)];
9
+ }
10
+
11
+
12
+ static insert(array: any[], index, ...rest) {
13
+ array.splice.apply(array, [index, 0].concat(Array.prototype.slice.call(rest, 1)));
14
+ return array;
15
+ }
16
+
17
+ static range(min: number, max: number): number[] {
18
+ return new Array(max - min).fill(1).map((d, i) => i);
19
+ }
20
+
21
+ static filter(array: any[], filters: any[]): any[] {
22
+ if (filters == null || filters.length === 0) {
23
+ return array;
24
+ }
25
+ const lamda = (item) => {
26
+ let result = true;
27
+ for (const key in filters) {
28
+ if (filters.hasOwnProperty(key)) {
29
+ const f = filters[key];
30
+ if (f !== 'AND') {
31
+ const vals = [];
32
+ const mt = f.field.match(/\[\:(.*?)\]/);
33
+ if (mt && mt.length > 1) {
34
+ const p1 = f.field.replace(mt[0], '');
35
+ const p2 = mt[1];
36
+ const prop = AXFetchProp(item, p1);
37
+ if (prop instanceof Array && prop.length) {
38
+ vals.push(...prop.map(m => (AXFetchProp(m, p2))));
39
+ } else {
40
+ result = false;
41
+ }
42
+ } else {
43
+ vals.push(AXFetchProp(item, f.field));
44
+ }
45
+ for (const j in vals) {
46
+ if (vals.hasOwnProperty(j)) {
47
+ let v1 = vals[j];
48
+ const v2 = f.value;
49
+ if (f.dataType === 'string') {
50
+ v1 = v1.toString();
51
+ switch (f.condition) {
52
+ case 'equal':
53
+ result = (v1 && v2) && v1.toLowerCase() === v2.toLowerCase();
54
+ break;
55
+ case 'not-equal':
56
+ result = !((v1 && v2) && v1.toLowerCase() === v2.toLowerCase());
57
+ break;
58
+ case 'contains':
59
+ result = ((v1 && v2) && (v1.toLowerCase().includes(v2.toLowerCase())));
60
+ break;
61
+ case 'not-contains':
62
+ result = !((v1 && v2) && (v1.toLowerCase().includes(v2.toLowerCase())));
63
+ break;
64
+ case 'start-with':
65
+ result = ((v1 && v2) && (v1.toLowerCase().startsWith(v2.toLowerCase())));
66
+ break;
67
+ case 'end-with':
68
+ result = ((v1 && v2) && (v1.toLowerCase().endsWith(v2.toLowerCase())));
69
+ break;
70
+ case 'is-empty':
71
+ result = v1 == null || v1 === undefined;
72
+ break;
73
+ case 'is-not-empty':
74
+ result = !(v1 == null || v1 === undefined);
75
+ break;
76
+ default:
77
+ console.error('The condition is not defined');
78
+ result = false;
79
+ }
80
+ } else if (f.dataType === 'date') {
81
+ } else if (f.dataType === 'number') {
82
+ v1 = Number(v1);
83
+ switch (f.condition) {
84
+ case 'equal':
85
+ result = v1 === v2;
86
+ break;
87
+ case 'not-equal':
88
+ result = v1 !== v2;
89
+ break;
90
+ case 'contains':
91
+ result = v2 && v2 instanceof Array && v2.includes(v1);
92
+ break;
93
+ case 'less-than':
94
+ result = v1 < v2;
95
+ break;
96
+ case 'less-than-equal':
97
+ result = v1 <= v2;
98
+ break;
99
+ case 'greater-than':
100
+ result = v1 > v2;
101
+ break;
102
+ case 'greater-than-equal':
103
+ result = v1 >= v2;
104
+ break;
105
+ case 'is-empty':
106
+ result = v1 == null || v1 === undefined;
107
+ break;
108
+ case 'is-not-empty':
109
+ result = !(v1 == null || v1 === undefined);
110
+ break;
111
+ default:
112
+ console.error('The condition is not defined');
113
+ result = false;
114
+ }
115
+ } else {
116
+ console.error('The datatype is not supported');
117
+ result = false;
118
+ }
119
+ if (result) {
120
+ break;
121
+ }
122
+ }
123
+ }
124
+ }
125
+ if (!result) {
126
+ return false;
127
+ }
128
+ }
129
+ }
130
+ return true;
131
+ };
132
+ return array.filter(lamda);
133
+ }
134
+
135
+ }
136
+
137
+
138
+
139
+
140
+
@@ -0,0 +1,264 @@
1
+ import { AXMathUtil } from '../math/math-util';
2
+
3
+ export type AXPlacement =
4
+ | 'top-start'
5
+ | 'top-middle'
6
+ | 'top-end'
7
+ | 'center-start'
8
+ | 'center-end'
9
+ | 'bottom-start'
10
+ | 'bottom-middle'
11
+ | 'bottom-end';
12
+
13
+ export interface AXIPoint {
14
+ x: number;
15
+ y: number;
16
+ }
17
+
18
+ export interface AXConnectedPosition {
19
+ originX: 'start' | 'center' | 'end';
20
+ originY: 'top' | 'center' | 'bottom';
21
+ overlayX: 'start' | 'center' | 'end';
22
+ overlayY: 'top' | 'center' | 'bottom';
23
+ weight?: number;
24
+ offsetX?: number;
25
+ offsetY?: number;
26
+ }
27
+
28
+ export class AXPoint implements AXIPoint {
29
+ constructor(public x: number, public y: number) {
30
+ }
31
+ }
32
+
33
+ export interface AXClientRecCtor {
34
+ left?: number;
35
+ top?: number;
36
+ width?: number;
37
+ height?: number;
38
+ bottom?: number;
39
+ right?: number;
40
+ }
41
+ export class AXClientRec implements AXClientRecCtor {
42
+
43
+
44
+ private _left: number;
45
+ public get left(): number {
46
+ return this._left;
47
+ }
48
+ public set left(v: number) {
49
+ this._left = v;
50
+ }
51
+
52
+
53
+ private _top: number;
54
+ public get top(): number {
55
+ return this._top;
56
+ }
57
+ public set top(v: number) {
58
+ this._top = v;
59
+ }
60
+
61
+
62
+ private _right: number;
63
+ public get right(): number {
64
+ return this._right;
65
+ }
66
+ public set right(v: number) {
67
+ this._right = v;
68
+ }
69
+
70
+
71
+ private _bottom: number;
72
+ public get bottom(): number {
73
+ return this._bottom;
74
+ }
75
+ public set bottom(v: number) {
76
+ this._bottom = v;
77
+ }
78
+
79
+
80
+
81
+ private _width: number;
82
+ public get width(): number {
83
+ return this._width;
84
+ }
85
+ public set width(v: number) {
86
+ this._width = v;
87
+ }
88
+
89
+
90
+ private _height: number;
91
+ public get height(): number {
92
+ return this._height;
93
+ }
94
+ public set height(v: number) {
95
+ this._height = v;
96
+ }
97
+
98
+
99
+ constructor(rec: AXClientRecCtor) {
100
+ this._left = rec.left;
101
+ this._top = rec.top;
102
+ this._width = rec.width;
103
+ this._height = rec.height;
104
+ this._right = this._left + this._width;
105
+ this._bottom = this._top + this._height;
106
+ }
107
+
108
+ public intersect(rec: AXClientRecCtor): boolean {
109
+ return (this.left < rec.left + rec.width &&
110
+ this.left + this.width > rec.left &&
111
+ this.top < rec.top + rec.height &&
112
+ this.top + this.height > rec.top);
113
+ }
114
+
115
+
116
+ }
117
+ // @dynamic
118
+ export class AXHtmlUtil {
119
+ static getBoundingRectPoint(el: HTMLElement, placement: AXPlacement): AXPoint {
120
+ const rec = el.getBoundingClientRect();
121
+ const width = el.offsetWidth;
122
+ const height = el.offsetHeight;
123
+ switch (placement) {
124
+ case 'top-start':
125
+ return new AXPoint(rec.left, rec.top);
126
+ case 'top-middle':
127
+ return new AXPoint(rec.left + (width / 2), rec.top);
128
+ case 'top-end':
129
+ return new AXPoint(rec.left + (width), rec.top);
130
+ case 'center-end':
131
+ return new AXPoint(rec.left + (width), rec.top + (height / 2));
132
+ case 'bottom-end':
133
+ return new AXPoint(rec.left + (width), rec.top + (height));
134
+ case 'bottom-middle':
135
+ return new AXPoint(rec.left + (width / 2), rec.top + (height));
136
+ case 'bottom-start':
137
+ return new AXPoint(rec.left, rec.top + (height));
138
+ case 'center-start':
139
+ return new AXPoint(rec.left, rec.top + (height / 2));
140
+ default:
141
+ return new AXPoint(rec.left + (width / 2), rec.top + (height));
142
+ }
143
+ }
144
+
145
+ static isInRecPoint(pos: AXIPoint, rec: AXClientRecCtor): boolean {
146
+ return pos.x >= rec.left && pos.x <= (rec.left + rec.width) && pos.y >= rec.top && (pos.y <= (rec.top + rec.height));
147
+ }
148
+
149
+ // static isOverLap(rec1: AXClientRecCtor, rec2: AXClientRecCtor): boolean {
150
+ // const r1: AXClientRec = new AXClientRec(rec1);
151
+ // const r2: AXClientRec = new AXClientRec(rec2);
152
+
153
+ // return ;
154
+ // }
155
+
156
+ static isInElementBound(pos: AXIPoint, element: HTMLElement): boolean {
157
+ const elBound = element.getBoundingClientRect();
158
+ return AXHtmlUtil.isInRecPoint(pos, {
159
+ left: elBound.left,
160
+ width: elBound.width,
161
+ top: elBound.top,
162
+ height: elBound.height
163
+ });
164
+ }
165
+
166
+ static getDimensions(): { width: number, height: number } {
167
+ let winW = 630;
168
+ let winH = 460;
169
+ if (document.body && document.body.offsetWidth) {
170
+ winW = document.body.offsetWidth;
171
+ winH = document.body.offsetHeight;
172
+ }
173
+ if (document.compatMode === 'CSS1Compat' && document.documentElement && document.documentElement.offsetWidth) {
174
+ winW = document.documentElement.offsetWidth;
175
+ winH = document.documentElement.offsetHeight;
176
+ }
177
+ if (window.innerWidth && window.innerHeight) {
178
+ winW = window.innerWidth;
179
+ winH = window.innerHeight;
180
+ }
181
+ return { width: winW, height: winH };
182
+ }
183
+
184
+ static getOffsetRight(elem: HTMLElement): number {
185
+ let element = elem;
186
+ const width = element.offsetWidth;
187
+ let right = 0;
188
+ while (element.offsetParent) {
189
+ right += element.offsetLeft;
190
+ element = element.offsetParent as HTMLElement;
191
+ }
192
+ right += element.offsetLeft;
193
+ right = AXHtmlUtil.getDimensions().width - right;
194
+ right -= width;
195
+ return right;
196
+ }
197
+
198
+ static getUID(): string {
199
+ return 'el-' + AXMathUtil.randomRange(1000000000, 9999999999).toString();
200
+ }
201
+
202
+
203
+ static getRelatedPosition(source: HTMLElement, placement: AXPlacement, target: HTMLElement, alignment: AXPlacement): AXIPoint {
204
+ const result: AXIPoint = { x: 0, y: 0 };
205
+
206
+ const sourcePos: AXPoint = AXHtmlUtil.getBoundingRectPoint(source, placement);
207
+
208
+
209
+ let top: number = 0;
210
+ let left: number = 0;
211
+ switch (alignment) {
212
+ case 'top-start':
213
+ top = sourcePos.y;
214
+ left = sourcePos.x;
215
+ break;
216
+ case 'top-middle':
217
+ top = sourcePos.y;
218
+ left = sourcePos.x - target.offsetWidth / 2;
219
+ break;
220
+ case 'top-end':
221
+ top = sourcePos.y;
222
+ left = sourcePos.x - target.offsetWidth;
223
+ break;
224
+ case 'center-end':
225
+ top = sourcePos.y - target.offsetHeight / 2;
226
+ left = sourcePos.x - target.offsetWidth;
227
+ break;
228
+ case 'bottom-end':
229
+ top = sourcePos.y - target.offsetHeight;
230
+ left = sourcePos.x - target.offsetWidth;
231
+ break;
232
+ case 'bottom-middle':
233
+ top = sourcePos.y - target.offsetHeight;
234
+ left = sourcePos.x - target.offsetWidth / 2;
235
+ break;
236
+ case 'bottom-start':
237
+ top = sourcePos.y - target.offsetHeight;
238
+ left = sourcePos.x;
239
+ break;
240
+ case 'center-start':
241
+ top = sourcePos.y - target.offsetHeight / 2;
242
+ left = sourcePos.x;
243
+ break;
244
+ }
245
+ result.y = top;
246
+ result.x = left;
247
+ return result;
248
+ }
249
+
250
+
251
+ static collision(a: HTMLElement, b: HTMLElement): boolean {
252
+ const ac = a.getBoundingClientRect();
253
+ const bc = b.getBoundingClientRect();
254
+
255
+ if (ac.left < bc.left + bc.width && ac.left + ac.width > bc.left &&
256
+ ac.top < bc.top + bc.height && ac.top + ac.height > bc.top) {
257
+ return true;
258
+ }
259
+ else {
260
+ return false;
261
+ }
262
+ }
263
+
264
+ }
@@ -0,0 +1,11 @@
1
+ import { NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { AXHtmlToTextPipe } from '../../pipe/htmlToText.pipe';
4
+
5
+ @NgModule({
6
+ declarations: [AXHtmlToTextPipe],
7
+ imports: [CommonModule],
8
+ exports: [AXHtmlToTextPipe],
9
+ providers: []
10
+ })
11
+ export class AXHtmlModule { }
@@ -0,0 +1,5 @@
1
+ export class AXMathUtil {
2
+ static randomRange(min: number, max: number): number {
3
+ return Math.floor(Math.random() * (max - min + 1) + min);
4
+ }
5
+ }
@@ -0,0 +1,87 @@
1
+ // @dynamic
2
+ export class AXObjectUtil {
3
+ static deepJSONClone(obj: any): any {
4
+ return obj ? JSON.parse(JSON.stringify(obj)) : null;
5
+ }
6
+
7
+ static deepCopy(obj) {
8
+ let copy;
9
+ // Handle the 3 simple types, and null or undefined
10
+ if (null == obj || 'object' !== typeof obj) { return obj; }
11
+ // Handle Date
12
+ if (obj instanceof Date) {
13
+ copy = new Date();
14
+ copy.setTime(obj.getTime());
15
+ return copy;
16
+ }
17
+ // Handle Array
18
+ if (obj instanceof Array) {
19
+ copy = [];
20
+ for (let i = 0, len = obj.length; i < len; i++) {
21
+ copy[i] = AXObjectUtil.deepCopy(obj[i]);
22
+ }
23
+ return copy;
24
+ }
25
+ // Handle Object
26
+ if (obj instanceof Object) {
27
+ copy = {};
28
+ for (const attr in obj) {
29
+ if (obj.hasOwnProperty(attr)) { copy[attr] = AXObjectUtil.deepCopy(obj[attr]); }
30
+ }
31
+ return copy;
32
+ }
33
+ throw new Error('Unable to copy obj! Its type isn\'t supported.');
34
+ }
35
+ }
36
+
37
+ export function AXFetchProp(obj, prop: string) {
38
+ if (typeof obj === 'undefined') {
39
+ return false;
40
+ }
41
+ const index = prop.indexOf('.');
42
+
43
+ if (index > -1) {
44
+ return AXFetchProp(obj[prop.substring(0, index)], prop.substr(index + 1));
45
+ }
46
+
47
+ return obj[prop];
48
+ }
49
+
50
+
51
+
52
+
53
+ export function getPropByPath(obj, path, defaultVal?) {
54
+ path = path
55
+ .replace(/\[/g, '.')
56
+ .replace(/]/g, '')
57
+ .split('.');
58
+
59
+ path.forEach((level) => {
60
+ if (obj) {
61
+ obj = obj[level];
62
+ }
63
+ });
64
+
65
+ if (obj === undefined) {
66
+ return defaultVal;
67
+ }
68
+ return obj;
69
+ }
70
+
71
+ export function setPropByPath(obj, path, value) {
72
+ if (Object(obj) !== obj) { return obj; } // When obj is not an object
73
+ // If not yet an array, get the keys from the string-path
74
+ if (!Array.isArray(path)) { path = path.toString().match(/[^.[\]]+/g) || []; }
75
+ path.slice(0, -1).reduce((a, c, i) => // Iterate all of them except the last one
76
+ Object(a[c]) === a[c] // Does the key exist and is its value an object?
77
+ // Yes: then follow that path
78
+ ? a[c]
79
+ // No: create the key. Is the next key a potential array-index?
80
+ : a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1]
81
+ ? [] // Yes: assign a new array object
82
+ : {}, // No: assign a new plain object
83
+ obj)[path[path.length - 1]] = value; // Finally assign the value to the last key
84
+ return obj[path[0]]; // Return the top-level object to allow chaining
85
+ }
86
+
87
+
@@ -0,0 +1,25 @@
1
+ import { PreloadingStrategy, Route } from '@angular/router';
2
+ import { Injectable } from '@angular/core';
3
+ import { Subject, Observable, of } from 'rxjs';
4
+ import { mergeMap } from 'rxjs/operators';
5
+ import { AXHtmlUtil } from '../html/html-util';
6
+
7
+
8
+
9
+
10
+ @Injectable()
11
+ export class AXOnDemandPreloadService {
12
+ subject = new Subject<string>();
13
+ tmp: string;
14
+
15
+ constructor() {
16
+ this.tmp = AXHtmlUtil.getUID();
17
+ }
18
+
19
+ startPreload(routePath: string) {
20
+ const slices: string[] = [];
21
+
22
+
23
+ this.subject.next(routePath);
24
+ }
25
+ }