@lenne.tech/ng-base 0.3.2 → 0.3.6

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 (32) hide show
  1. package/bundles/lenne.tech-ng-base-src-lib-base.umd.js +781 -749
  2. package/bundles/lenne.tech-ng-base-src-lib-base.umd.js.map +1 -1
  3. package/bundles/lenne.tech-ng-base.umd.js +781 -749
  4. package/bundles/lenne.tech-ng-base.umd.js.map +1 -1
  5. package/esm2015/lib/base/classes/helper.class.js +19 -1
  6. package/esm2015/lib/base/directives/match-height.directive.js +19 -14
  7. package/esm2015/lib/base/factories/apollo-options.factory.js +3 -2
  8. package/esm2015/lib/base/services/image.service.js +24 -38
  9. package/esm2015/lib/base/services/scroll.service.js +8 -29
  10. package/esm2015/lib/base/services/seo.service.js +70 -14
  11. package/esm2015/src/lib/base/classes/helper.class.js +19 -1
  12. package/esm2015/src/lib/base/directives/match-height.directive.js +19 -14
  13. package/esm2015/src/lib/base/factories/apollo-options.factory.js +3 -2
  14. package/esm2015/src/lib/base/services/image.service.js +24 -38
  15. package/esm2015/src/lib/base/services/scroll.service.js +8 -29
  16. package/esm2015/src/lib/base/services/seo.service.js +70 -14
  17. package/fesm2015/lenne.tech-ng-base-src-lib-base.js +517 -473
  18. package/fesm2015/lenne.tech-ng-base-src-lib-base.js.map +1 -1
  19. package/fesm2015/lenne.tech-ng-base.js +517 -473
  20. package/fesm2015/lenne.tech-ng-base.js.map +1 -1
  21. package/lib/base/classes/helper.class.d.ts +7 -0
  22. package/lib/base/directives/match-height.directive.d.ts +7 -7
  23. package/lib/base/services/image.service.d.ts +1 -2
  24. package/lib/base/services/scroll.service.d.ts +1 -2
  25. package/lib/base/services/seo.service.d.ts +36 -3
  26. package/package.json +1 -1
  27. package/src/lib/base/classes/helper.class.d.ts +7 -0
  28. package/src/lib/base/directives/match-height.directive.d.ts +7 -7
  29. package/src/lib/base/lenne.tech-ng-base-src-lib-base.metadata.json +1 -1
  30. package/src/lib/base/services/image.service.d.ts +1 -2
  31. package/src/lib/base/services/scroll.service.d.ts +1 -2
  32. package/src/lib/base/services/seo.service.d.ts +36 -3
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-angular'), require('apollo-angular/http'), require('@angular/core'), require('rxjs'), require('@apollo/client/core'), require('@apollo/client/cache'), require('@apollo/client/link/ws'), require('@apollo/client/utilities'), require('@angular/platform-browser'), require('@angular/router'), require('graphql'), require('rxjs/operators')) :
3
- typeof define === 'function' && define.amd ? define('@lenne.tech/ng-base', ['exports', 'apollo-angular', 'apollo-angular/http', '@angular/core', 'rxjs', '@apollo/client/core', '@apollo/client/cache', '@apollo/client/link/ws', '@apollo/client/utilities', '@angular/platform-browser', '@angular/router', 'graphql', 'rxjs/operators'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lenne = global.lenne || {}, global.lenne.tech = global.lenne.tech || {}, global.lenne.tech["ng-base"] = {}), global.i1$1, global.http, global.ng.core, global.rxjs, global.core, global.cache, global.ws, global.utilities, global.ng.platformBrowser, global.ng.router, global.graphql, global.rxjs.operators));
5
- })(this, (function (exports, i1$1, http, i0, rxjs, core, cache, ws, utilities, i1, i1$2, graphql, operators) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('apollo-angular'), require('apollo-angular/http'), require('@angular/core'), require('rxjs'), require('@apollo/client/core'), require('@apollo/client/cache'), require('@apollo/client/link/ws'), require('@apollo/client/utilities'), require('@angular/common'), require('@angular/platform-browser'), require('@angular/router'), require('graphql'), require('rxjs/operators')) :
3
+ typeof define === 'function' && define.amd ? define('@lenne.tech/ng-base', ['exports', 'apollo-angular', 'apollo-angular/http', '@angular/core', 'rxjs', '@apollo/client/core', '@apollo/client/cache', '@apollo/client/link/ws', '@apollo/client/utilities', '@angular/common', '@angular/platform-browser', '@angular/router', 'graphql', 'rxjs/operators'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.lenne = global.lenne || {}, global.lenne.tech = global.lenne.tech || {}, global.lenne.tech["ng-base"] = {}), global.i1$1, global.http, global.ng.core, global.rxjs, global.core, global.cache, global.ws, global.utilities, global.ng.common, global.ng.platformBrowser, global.ng.router, global.graphql, global.rxjs.operators));
5
+ })(this, (function (exports, i1$1, http, i0, rxjs, core, cache, ws, utilities, common, i1, i1$2, graphql, operators) { 'use strict';
6
6
 
7
7
  function _interopNamespace(e) {
8
8
  if (e && e.__esModule) return e;
@@ -572,8 +572,9 @@
572
572
  */
573
573
  function apolloOptionsFactory(baseModuleConfig, httpLink, authService) {
574
574
  var links = [];
575
+ var defaultUrl = 'api.' + window.location.href + '/graphql';
575
576
  var http = httpLink.create({
576
- uri: baseModuleConfig.apiUrl,
577
+ uri: baseModuleConfig.apiUrl ? baseModuleConfig.apiUrl : 'https://' + defaultUrl,
577
578
  });
578
579
  var authMiddleware = new core.ApolloLink(function (operation, forward) {
579
580
  var headers = {};
@@ -786,804 +787,801 @@
786
787
  };
787
788
 
788
789
  /**
789
- * Image service
790
+ * Helper class
790
791
  */
791
- var ImageService = /** @class */ (function () {
792
- function ImageService() {
792
+ var Helper = /** @class */ (function () {
793
+ function Helper() {
793
794
  }
794
795
  /**
795
- * Preaload images (for lazy handling)
796
- *
797
- * @param options
798
- * @protected
796
+ * Simple filter function for plain objects
799
797
  */
800
- ImageService.prototype.preLoadImages = function (options) {
801
- var _this = this;
802
- // Init configuration
803
- var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined, timeout: undefined }, options);
804
- return new Promise(function (resolve) {
805
- var e_1, _b;
806
- var _a;
807
- // Init variables
808
- var resolved = false;
809
- var timeoutId;
810
- // HTMLCollection to array
811
- if (config.elements instanceof HTMLCollection) {
812
- config.elements = Array.from(config.elements);
813
- }
814
- // Single element to array
815
- if (!Array.isArray(config.elements)) {
816
- config.elements = [config.elements];
817
- }
818
- // Init loading
819
- var promises = [];
820
- // Get all images
821
- var images = [];
822
- config.elements.forEach(function (element) {
823
- images = images.concat(Array.from(element.getElementsByTagName('img')));
824
- });
825
- var _loop_1 = function (image) {
826
- var src = image.getAttribute('src');
827
- // Check if changes are necessary and possible
828
- if ((image.complete && image.naturalHeight !== 0) || // already laoded
829
- image.getAttribute('loading') !== 'lazy' || // loading attribute !== lazy
830
- !src || // Image has no src
831
- ((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
832
- ) {
833
- return "continue";
834
- }
835
- // Replace lazy loading image with immediately loading image
836
- var newImage = document.createElement('img');
837
- Array.from(image.attributes).forEach(function (attr) {
838
- if (attr.name !== 'loading' && attr.name !== 'src') {
839
- newImage.setAttribute(attr.name, attr.value);
840
- }
841
- });
842
- image.replaceWith(newImage);
843
- // Wait for laoding
844
- promises.push(_this.loadImage(newImage, src));
845
- };
798
+ Helper.filter = function (objects, filter) {
799
+ return ((objects === null || objects === void 0 ? void 0 : objects.filter(function (element) {
800
+ var e_1, _d, e_2, _e;
846
801
  try {
847
- // Prepare images
848
- for (var images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
849
- var image = images_1_1.value;
850
- _loop_1(image);
802
+ for (var _f = __values(Object.entries(filter)), _g = _f.next(); !_g.done; _g = _f.next()) {
803
+ var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
804
+ if (Array.isArray(element[key])) {
805
+ try {
806
+ for (var _j = (e_2 = void 0, __values(element[key])), _k = _j.next(); !_k.done; _k = _j.next()) {
807
+ var item = _k.value;
808
+ if (!element[key].includs(value)) {
809
+ return false;
810
+ }
811
+ }
812
+ }
813
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
814
+ finally {
815
+ try {
816
+ if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
817
+ }
818
+ finally { if (e_2) throw e_2.error; }
819
+ }
820
+ }
821
+ else if (element[key] !== value) {
822
+ return false;
823
+ }
851
824
  }
852
825
  }
853
826
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
854
827
  finally {
855
828
  try {
856
- if (images_1_1 && !images_1_1.done && (_b = images_1.return)) _b.call(images_1);
829
+ if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
857
830
  }
858
831
  finally { if (e_1) throw e_1.error; }
859
832
  }
860
- if (config.timeout) {
861
- timeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
862
- return __generator(this, function (_b) {
863
- switch (_b.label) {
864
- case 0:
865
- resolved = true;
866
- if (!config.doneFunnction) return [3 /*break*/, 2];
867
- return [4 /*yield*/, config.doneFunction()];
868
- case 1:
869
- _b.sent();
870
- _b.label = 2;
871
- case 2:
872
- resolve(undefined);
873
- return [2 /*return*/];
874
- }
875
- });
876
- }); });
877
- }
878
- // Wait until all images loaded
879
- Promise.all(promises)
880
- .catch(function (e) { return console.error('Error during image loading', e); })
881
- .finally(function () { return __awaiter(_this, void 0, void 0, function () {
882
- var result;
883
- return __generator(this, function (_b) {
884
- switch (_b.label) {
885
- case 0:
886
- // Check if already resolved
887
- if (resolved) {
888
- return [2 /*return*/];
889
- }
890
- // Stop timeout
891
- if (timeoutId) {
892
- clearTimeout(timeoutId);
833
+ return true;
834
+ })) || []);
835
+ };
836
+ /**
837
+ * Convert to a url/uri conform string
838
+ * Only:
839
+ * - lower case
840
+ * - chars, numbers and hyphens
841
+ */
842
+ Helper.urlString = function (str, options) {
843
+ if (options === void 0) { options = {}; }
844
+ // Config
845
+ var config = Object.assign({ allowAll: false }, options);
846
+ // To string
847
+ str = str + '';
848
+ // Trim
849
+ str = str.trim();
850
+ // Lower case
851
+ str = str.toLowerCase();
852
+ if (!config.allowAll) {
853
+ // Replace spaces
854
+ str = str.trim().replace(/\s+/g, '-');
855
+ // Replace some special chars
856
+ str = str.replace('ä', 'ae');
857
+ str = str.replace('ö', 'oe');
858
+ str = str.replace('ü', 'ue');
859
+ str = str.replace('ß', 'ss');
860
+ // Remove other special chars
861
+ str = str.replace(/[^a-zA-Z0-9-]/g, '');
862
+ }
863
+ // Return url conform string
864
+ return encodeURI(str);
865
+ };
866
+ /**
867
+ * Simple map function
868
+ */
869
+ Helper.map = function (source, target, options) {
870
+ var e_3, _d;
871
+ if (options === void 0) { options = {}; }
872
+ // Set config
873
+ var config = Object.assign({ funcAllowed: false, dateStringToDate: true }, options);
874
+ // Check source
875
+ if (!source || typeof source !== 'object' || Array.isArray(source)) {
876
+ return target;
877
+ }
878
+ try {
879
+ // Update properties
880
+ for (var _e = __values(Object.keys(target)), _f = _e.next(); !_f.done; _f = _e.next()) {
881
+ var key = _f.value;
882
+ if (source[key] !== undefined && (config.funcAllowed || typeof (source[key] !== 'function'))) {
883
+ if (typeof source[key] === 'string' && config.dateStringToDate) {
884
+ if (Array.isArray(config.dateStringToDate)) {
885
+ if (config.dateStringToDate.includes(key)) {
886
+ target[key] = Helper.parseDate(source[key]);
893
887
  }
894
- if (!config.doneFunnction) return [3 /*break*/, 2];
895
- return [4 /*yield*/, config.doneFunction()];
896
- case 1:
897
- result = _b.sent();
898
- _b.label = 2;
899
- case 2:
900
- resolve(result);
901
- return [2 /*return*/];
888
+ }
889
+ else {
890
+ target[key] = Helper.parseDate(source[key]);
891
+ }
902
892
  }
903
- });
904
- }); });
905
- });
893
+ else {
894
+ target[key] = source[key];
895
+ }
896
+ }
897
+ }
898
+ }
899
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
900
+ finally {
901
+ try {
902
+ if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
903
+ }
904
+ finally { if (e_3) throw e_3.error; }
905
+ }
906
+ // Return target
907
+ return target;
906
908
  };
907
909
  /**
908
- * Load image for image element
909
- *
910
- * @param imageElement
911
- * @param src
912
- * @protected
910
+ * Create Object or Objects of specified type with specified data
913
911
  */
914
- ImageService.prototype.loadImage = function (imageElement, src) {
915
- return __awaiter(this, void 0, void 0, function () {
916
- return __generator(this, function (_b) {
917
- src = src || imageElement.src;
918
- return [2 /*return*/, new Promise(function (resolve, reject) {
919
- imageElement.onload = function () { return resolve(imageElement); };
920
- imageElement.onerror = reject;
921
- imageElement.src = src;
922
- })];
923
- });
912
+ Helper.maps = function (data, targetClass) {
913
+ // Check data
914
+ if (!data || typeof data !== 'object') {
915
+ return undefined;
916
+ }
917
+ // Check array
918
+ if (!Array.isArray(data)) {
919
+ data = [data];
920
+ }
921
+ // Map
922
+ return data.map(function (item) {
923
+ return targetClass.map(item);
924
924
  });
925
925
  };
926
- return ImageService;
927
- }());
928
- ImageService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ImageService_Factory() { return new ImageService(); }, token: ImageService, providedIn: "root" });
929
- ImageService.decorators = [
930
- { type: i0.Injectable, args: [{
931
- providedIn: 'root',
932
- },] }
933
- ];
934
-
935
- /**
936
- * Set same height (maximum) to different elements
937
- */
938
- var MatchHeightDirective = /** @class */ (function () {
939
- function MatchHeightDirective(el, imageService, zone) {
940
- this.el = el;
941
- this.imageService = imageService;
942
- this.zone = zone;
943
- this.loadLazyImages = true;
944
- }
945
- MatchHeightDirective.prototype.onResize = function () {
946
- this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
926
+ /**
927
+ * Get plain parameter
928
+ */
929
+ Helper.getPlainParameter = function (parameter) {
930
+ var _a, _b, _c;
931
+ if (!parameter) {
932
+ return parameter;
933
+ }
934
+ return (_c = (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.split('?')) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.split('#')) === null || _c === void 0 ? void 0 : _c.shift();
947
935
  };
948
- MatchHeightDirective.prototype.ngAfterViewChecked = function () {
949
- this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
936
+ /**
937
+ * Get ID of an url parameter
938
+ */
939
+ Helper.getParameterId = function (parameter) {
940
+ var _a;
941
+ if (!parameter) {
942
+ return parameter;
943
+ }
944
+ return (_a = Helper.getPlainParameter(parameter)) === null || _a === void 0 ? void 0 : _a.split('-').pop();
950
945
  };
951
- MatchHeightDirective.prototype.matchHeight = function (parent, target) {
952
- var _this = this;
953
- // Timeout is set to force Angular to wait for all actions and only continue once the process has run through.
954
- // Otherwise, an infinite loop will occur.
955
- setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
956
- var classNames, _loop_1, this_1, classNames_1, classNames_1_1, className, e_1_1;
957
- var e_1, _a;
958
- return __generator(this, function (_b) {
959
- switch (_b.label) {
960
- case 0:
961
- if (!parent) {
962
- return [2 /*return*/];
963
- }
964
- if (!Array.isArray(target)) {
965
- classNames = [target];
966
- }
967
- else {
968
- classNames = target;
969
- }
970
- _loop_1 = function (className) {
971
- var children, itemHeights, maxHeight;
972
- return __generator(this, function (_c) {
973
- switch (_c.label) {
974
- case 0:
975
- children = parent.getElementsByClassName(className);
976
- if (!children || children.length < 2) {
977
- return [2 /*return*/, "continue"];
978
- }
979
- if (!this_1.loadLazyImages) return [3 /*break*/, 2];
980
- return [4 /*yield*/, this_1.imageService.preLoadImages({ elements: children })];
981
- case 1:
982
- _c.sent();
983
- _c.label = 2;
984
- case 2:
985
- // reset all children height
986
- Array.from(children).forEach(function (element) {
987
- element.style.height = 'initial';
988
- });
989
- itemHeights = Array.from(children).map(function (x) { return x.getBoundingClientRect().height; });
990
- maxHeight = itemHeights.reduce(function (prev, curr) { return (curr > prev ? curr : prev); }, 0);
991
- // update the child structureElements height to the tallest one
992
- Array.from(children).forEach(function (element) { return (element.style.height = maxHeight + "px"); });
993
- return [2 /*return*/];
994
- }
995
- });
996
- };
997
- this_1 = this;
998
- _b.label = 1;
999
- case 1:
1000
- _b.trys.push([1, 6, 7, 8]);
1001
- classNames_1 = __values(classNames), classNames_1_1 = classNames_1.next();
1002
- _b.label = 2;
1003
- case 2:
1004
- if (!!classNames_1_1.done) return [3 /*break*/, 5];
1005
- className = classNames_1_1.value;
1006
- return [5 /*yield**/, _loop_1(className)];
1007
- case 3:
1008
- _b.sent();
1009
- _b.label = 4;
1010
- case 4:
1011
- classNames_1_1 = classNames_1.next();
1012
- return [3 /*break*/, 2];
1013
- case 5: return [3 /*break*/, 8];
1014
- case 6:
1015
- e_1_1 = _b.sent();
1016
- e_1 = { error: e_1_1 };
1017
- return [3 /*break*/, 8];
1018
- case 7:
1019
- try {
1020
- if (classNames_1_1 && !classNames_1_1.done && (_a = classNames_1.return)) _a.call(classNames_1);
1021
- }
1022
- finally { if (e_1) throw e_1.error; }
1023
- return [7 /*endfinally*/];
1024
- case 8: return [2 /*return*/];
1025
- }
1026
- });
1027
- }); }, 1);
1028
- };
1029
- return MatchHeightDirective;
1030
- }());
1031
- MatchHeightDirective.decorators = [
1032
- { type: i0.Directive, args: [{
1033
- selector: '[ltMatchHeight]',
1034
- },] }
1035
- ];
1036
- MatchHeightDirective.ctorParameters = function () { return [
1037
- { type: i0.ElementRef },
1038
- { type: ImageService },
1039
- { type: i0.NgZone }
1040
- ]; };
1041
- MatchHeightDirective.propDecorators = {
1042
- ltMatchHeight: [{ type: i0.Input }],
1043
- loadLazyImages: [{ type: i0.Input }],
1044
- onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
1045
- };
1046
-
1047
- /**
1048
- * Reszise detection
1049
- * (inpsired by: https://stackblitz.com/edit/angular-resizable)
1050
- */
1051
- var ResizableDirective = /** @class */ (function () {
1052
- function ResizableDirective(el) {
1053
- this.el = el;
1054
- this.resizableGrabWidth = 8;
1055
- this.resizableMinWidth = 10;
1056
- this.dragging = false;
1057
- }
1058
- ResizableDirective.prototype.ngOnInit = function () {
1059
- this.addListenerToDocument();
1060
- this.addListenerToElement();
946
+ /**
947
+ * Delay
948
+ */
949
+ Helper.delay = function (ms) {
950
+ var promise = new Promise(function (resolve) { return setTimeout(resolve, ms); });
951
+ return promise;
1061
952
  };
1062
- ResizableDirective.prototype.mouseMoveG = function (evt) {
1063
- if (!this.dragging) {
1064
- return;
953
+ /**
954
+ * Deep freeze
955
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#What_is_shallow_freeze
956
+ */
957
+ Helper.deepFreeze = function (object, preparedObjects) {
958
+ var e_4, _d;
959
+ if (preparedObjects === void 0) { preparedObjects = []; }
960
+ // Prevent infinit regress
961
+ if (preparedObjects.includes(object)) {
962
+ return object;
1065
963
  }
1066
- this.newWidth(evt.clientX - this.el.nativeElement.offsetLeft);
1067
- evt.stopPropagation();
1068
- };
1069
- ResizableDirective.prototype.newWidth = function (wid) {
1070
- var result = Math.max(this.resizableMinWidth, wid);
1071
- this.el.nativeElement.style.width = result + 'px';
1072
- };
1073
- ResizableDirective.prototype.mouseDown = function (evt) {
1074
- if (this.inDragRegion(evt)) {
1075
- this.dragging = true;
1076
- this.preventGlobalMouseEvents();
1077
- evt.stopPropagation();
964
+ preparedObjects.push(object);
965
+ // Retrieve the property names defined on object
966
+ var propNames = Object.getOwnPropertyNames(object);
967
+ try {
968
+ // Freeze properties before freezing self
969
+ for (var propNames_1 = __values(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
970
+ var name = propNames_1_1.value;
971
+ var value = object[name];
972
+ if (value && typeof value === 'object') {
973
+ Helper.deepFreeze(value, preparedObjects);
974
+ }
975
+ }
976
+ }
977
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
978
+ finally {
979
+ try {
980
+ if (propNames_1_1 && !propNames_1_1.done && (_d = propNames_1.return)) _d.call(propNames_1);
981
+ }
982
+ finally { if (e_4) throw e_4.error; }
1078
983
  }
984
+ return Object.freeze(object);
1079
985
  };
1080
- ResizableDirective.prototype.restoreGlobalMouseEvents = function () {
1081
- document.body.style['pointer-events'] = 'auto';
986
+ /**
987
+ * Generates an unique identifier with 24 characters
988
+ */
989
+ Helper.getUID = function () {
990
+ var dt = new Date().getTime();
991
+ var uuid = 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
992
+ // eslint-disable-next-line no-bitwise
993
+ var r = (dt + Math.random() * 16) % 16 | 0;
994
+ dt = Math.floor(dt / 16);
995
+ // eslint-disable-next-line no-bitwise
996
+ return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
997
+ });
998
+ return uuid;
1082
999
  };
1083
- ResizableDirective.prototype.mouseUpG = function (evt) {
1084
- if (!this.dragging) {
1085
- return;
1000
+ /**
1001
+ * Parse date string to date object
1002
+ */
1003
+ Helper.parseDate = function (dateString) {
1004
+ var reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
1005
+ var reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
1006
+ if (typeof dateString === 'string') {
1007
+ var isoExec = reISO.exec(dateString);
1008
+ if (isoExec) {
1009
+ return new Date(dateString);
1010
+ }
1011
+ var msAjaxExec = reMsAjax.exec(dateString);
1012
+ if (msAjaxExec) {
1013
+ var cleaned = msAjaxExec[1].split(/[-+,.]/);
1014
+ return new Date(cleaned[0] ? +cleaned[0] : 0 - +cleaned[1]);
1015
+ }
1086
1016
  }
1087
- this.restoreGlobalMouseEvents();
1088
- this.dragging = false;
1089
- evt.stopPropagation();
1017
+ return dateString;
1090
1018
  };
1091
- ResizableDirective.prototype.mouseMove = function (evt) {
1092
- if (this.inDragRegion(evt) || this.dragging) {
1093
- this.el.nativeElement.style.cursor = 'col-resize';
1019
+ /**
1020
+ * Get browser name and version
1021
+ */
1022
+ Helper.getBrowser = function () {
1023
+ var userAgent = navigator.userAgent;
1024
+ var data = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
1025
+ var version;
1026
+ if (/trident/i.test(data[1])) {
1027
+ version = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
1028
+ return { name: 'IE', version: version[1] || '' };
1094
1029
  }
1095
- else {
1096
- this.el.nativeElement.style.cursor = 'default';
1030
+ if (data[1] === 'Chrome') {
1031
+ version = userAgent.match(/\bOPR|Edge\/(\d+)/);
1032
+ if (version != null) {
1033
+ return { name: 'Opera', version: version[1] };
1034
+ }
1097
1035
  }
1098
- };
1099
- ResizableDirective.prototype.preventGlobalMouseEvents = function () {
1100
- document.body.style['pointer-events'] = 'none';
1101
- };
1102
- ResizableDirective.prototype.inDragRegion = function (evt) {
1103
- return this.el.nativeElement.clientWidth - evt.clientX + this.el.nativeElement.offsetLeft < this.resizableGrabWidth;
1104
- };
1105
- ResizableDirective.prototype.addListenerToDocument = function () {
1106
- var _this = this;
1107
- document.addEventListener('mousemove', function (e) {
1108
- _this.mouseMoveG(e);
1109
- }, true);
1110
- document.addEventListener('mouseup', function (e) {
1111
- _this.mouseUpG(e);
1112
- }, true);
1113
- };
1114
- ResizableDirective.prototype.addListenerToElement = function () {
1115
- var _this = this;
1116
- this.el.nativeElement.addEventListener('mousedown', function (e) {
1117
- _this.mouseDown(e);
1118
- }, true);
1119
- this.el.nativeElement.addEventListener('mousemove', function (e) {
1120
- _this.mouseMove(e);
1121
- }, true);
1122
- };
1123
- return ResizableDirective;
1124
- }());
1125
- ResizableDirective.decorators = [
1126
- { type: i0.Directive, args: [{
1127
- selector: '[ltResizable]',
1128
- },] }
1129
- ];
1130
- ResizableDirective.ctorParameters = function () { return [
1131
- { type: i0.ElementRef }
1132
- ]; };
1133
- ResizableDirective.propDecorators = {
1134
- resizableGrabWidth: [{ type: i0.Input }],
1135
- resizableMinWidth: [{ type: i0.Input }]
1136
- };
1137
-
1138
- /**
1139
- * Truncate string with ellipses
1140
- */
1141
- var EllipsesPipe = /** @class */ (function () {
1142
- function EllipsesPipe() {
1143
- }
1144
- EllipsesPipe.prototype.transform = function (value, limit) {
1145
- if (!value) {
1146
- return null;
1036
+ data = data[2] ? [data[1], data[2]] : [navigator.appName, navigator.appVersion, '-?'];
1037
+ version = userAgent.match(/version\/(\d+)/i);
1038
+ if (version !== null) {
1039
+ data.splice(1, 1, version[1]);
1147
1040
  }
1148
- return value.length > limit ? value.substring(0, limit) + '...' : value;
1041
+ return {
1042
+ name: data[0],
1043
+ version: data[1],
1044
+ };
1149
1045
  };
1150
- return EllipsesPipe;
1151
- }());
1152
- EllipsesPipe.decorators = [
1153
- { type: i0.Pipe, args: [{
1154
- name: 'ltEllipses',
1155
- },] }
1156
- ];
1157
-
1158
- /**
1159
- * Declarate html as safe
1160
- */
1161
- var SafeHtmlPipe = /** @class */ (function () {
1162
- function SafeHtmlPipe(sanitized) {
1163
- this.sanitized = sanitized;
1164
- }
1165
- SafeHtmlPipe.prototype.transform = function (value) {
1166
- return this.sanitized.bypassSecurityTrustHtml(value);
1167
- };
1168
- return SafeHtmlPipe;
1169
- }());
1170
- SafeHtmlPipe.decorators = [
1171
- { type: i0.Pipe, args: [{ name: 'ltSafeHtml' },] }
1172
- ];
1173
- SafeHtmlPipe.ctorParameters = function () { return [
1174
- { type: i1.DomSanitizer }
1175
- ]; };
1176
-
1177
- // Imported and exported elements
1178
- var elements = [
1179
- // Directives
1180
- ContextMenuDirective,
1181
- LazyLoadDirective,
1182
- MatchHeightDirective,
1183
- ResizableDirective,
1184
- // Pipes
1185
- EllipsesPipe,
1186
- SafeHtmlPipe,
1187
- ];
1188
- /**
1189
- * Base module
1190
- */
1191
- var BaseModule = /** @class */ (function () {
1192
- function BaseModule() {
1193
- }
1194
1046
  /**
1195
- * Set configuration of base module in root module of the app
1047
+ * Whether first parameter is a deep subset of second parameter
1048
+ * Hint: functions will be ignored
1196
1049
  */
1197
- BaseModule.forRoot = function (baseModuleConfig) {
1198
- if (baseModuleConfig === void 0) { baseModuleConfig = {}; }
1199
- // Default config
1200
- var config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
1201
- // Prepare providers
1202
- var providers = [
1203
- {
1204
- provide: BASE_MODULE_CONFIG,
1205
- useValue: baseModuleConfig,
1206
- },
1207
- ];
1208
- // Add apollo features if API URL is set
1209
- if (baseModuleConfig.apiUrl) {
1210
- providers.push({
1211
- provide: i1$1.APOLLO_OPTIONS,
1212
- useFactory: apolloOptionsFactory,
1213
- deps: [BASE_MODULE_CONFIG, http.HttpLink, AuthService],
1214
- });
1050
+ Helper.isSubset = function (a, b) {
1051
+ var e_5, _d, e_6, _e;
1052
+ // Equal
1053
+ if (a === b) {
1054
+ return true;
1215
1055
  }
1216
- else if (config.logging) {
1217
- console.log('apiUrl is missing, ApolloLink is not initialized');
1056
+ // Different type
1057
+ if (typeof a !== typeof b) {
1058
+ return false;
1218
1059
  }
1219
- // Return root module
1220
- return {
1221
- ngModule: BaseModule,
1222
- providers: providers,
1223
- };
1224
- };
1225
- return BaseModule;
1226
- }());
1227
- BaseModule.decorators = [
1228
- { type: i0.NgModule, args: [{
1229
- declarations: elements,
1230
- exports: elements,
1231
- },] }
1232
- ];
1233
-
1234
- /**
1235
- * Helper class
1236
- */
1237
- var Helper = /** @class */ (function () {
1238
- function Helper() {
1239
- }
1240
- /**
1241
- * Simple filter function for plain objects
1242
- */
1243
- Helper.filter = function (objects, filter) {
1244
- return ((objects === null || objects === void 0 ? void 0 : objects.filter(function (element) {
1245
- var e_1, _d, e_2, _e;
1060
+ // Process array
1061
+ if (Array.isArray(a)) {
1246
1062
  try {
1247
- for (var _f = __values(Object.entries(filter)), _g = _f.next(); !_g.done; _g = _f.next()) {
1063
+ for (var _f = __values(Object.entries(a)), _g = _f.next(); !_g.done; _g = _f.next()) {
1248
1064
  var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
1249
- if (Array.isArray(element[key])) {
1250
- try {
1251
- for (var _j = (e_2 = void 0, __values(element[key])), _k = _j.next(); !_k.done; _k = _j.next()) {
1252
- var item = _k.value;
1253
- if (!element[key].includs(value)) {
1254
- return false;
1255
- }
1256
- }
1257
- }
1258
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
1259
- finally {
1260
- try {
1261
- if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
1262
- }
1263
- finally { if (e_2) throw e_2.error; }
1264
- }
1265
- }
1266
- else if (element[key] !== value) {
1065
+ if (Helper.isSubset(value, b[key])) {
1267
1066
  return false;
1268
1067
  }
1269
1068
  }
1270
1069
  }
1271
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
1070
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
1272
1071
  finally {
1273
1072
  try {
1274
1073
  if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
1275
1074
  }
1276
- finally { if (e_1) throw e_1.error; }
1075
+ finally { if (e_5) throw e_5.error; }
1277
1076
  }
1278
1077
  return true;
1279
- })) || []);
1078
+ }
1079
+ // Process object
1080
+ if (typeof a === 'object') {
1081
+ var plain = JSON.parse(JSON.stringify(a));
1082
+ try {
1083
+ for (var _j = __values(Object.entries(plain)), _k = _j.next(); !_k.done; _k = _j.next()) {
1084
+ var _l = __read(_k.value, 2), key = _l[0], value = _l[1];
1085
+ if (Helper.isSubset(value, b[key])) {
1086
+ return false;
1087
+ }
1088
+ }
1089
+ }
1090
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
1091
+ finally {
1092
+ try {
1093
+ if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
1094
+ }
1095
+ finally { if (e_6) throw e_6.error; }
1096
+ }
1097
+ return true;
1098
+ }
1099
+ // Else
1100
+ return true;
1280
1101
  };
1281
1102
  /**
1282
- * Convert to a url/uri conform string
1283
- * Only:
1284
- * - lower case
1285
- * - chars, numbers and hyphens
1103
+ * Whether parameters are equal (have equal properties)
1104
+ * Hint: functions will be ignored
1286
1105
  */
1287
- Helper.urlString = function (str, options) {
1288
- if (options === void 0) { options = {}; }
1289
- // Config
1290
- var config = Object.assign({ allowAll: false }, options);
1291
- // To string
1292
- str = str + '';
1293
- // Trim
1294
- str = str.trim();
1295
- // Lower case
1296
- str = str.toLowerCase();
1297
- if (!config.allowAll) {
1298
- // Replace spaces
1299
- str = str.trim().replace(/\s+/g, '-');
1300
- // Replace some special chars
1301
- str = str.replace('ä', 'ae');
1302
- str = str.replace('ö', 'oe');
1303
- str = str.replace('ü', 'ue');
1304
- str = str.replace('ß', 'ss');
1305
- // Remove other special chars
1306
- str = str.replace(/[^a-zA-Z0-9-]/g, '');
1307
- }
1308
- // Return url conform string
1309
- return encodeURI(str);
1106
+ Helper.isEqual = function (a, b) {
1107
+ return Helper.isSubset(a, b) && Helper.isSubset(b, a);
1310
1108
  };
1311
1109
  /**
1312
- * Simple map function
1110
+ * First level difference of two objects
1111
+ * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
1112
+ *
1113
+ * @returns Record<string, any> Object with properties from first object
1313
1114
  */
1314
- Helper.map = function (source, target, options) {
1315
- var e_3, _d;
1316
- if (options === void 0) { options = {}; }
1317
- // Set config
1318
- var config = Object.assign({ funcAllowed: false, dateStringToDate: true }, options);
1319
- // Check source
1320
- if (!source || typeof source !== 'object' || Array.isArray(source)) {
1321
- return target;
1115
+ Helper.getDiff = function (a, b, clone) {
1116
+ var e_7, _d;
1117
+ if (clone === void 0) { clone = true; }
1118
+ var result = {};
1119
+ var firstObject = a;
1120
+ if (clone) {
1121
+ firstObject = JSON.parse(JSON.stringify(a));
1322
1122
  }
1323
1123
  try {
1324
- // Update properties
1325
- for (var _e = __values(Object.keys(target)), _f = _e.next(); !_f.done; _f = _e.next()) {
1326
- var key = _f.value;
1327
- if (source[key] !== undefined && (config.funcAllowed || typeof (source[key] !== 'function'))) {
1328
- if (typeof source[key] === 'string' && config.dateStringToDate) {
1329
- if (Array.isArray(config.dateStringToDate)) {
1330
- if (config.dateStringToDate.includes(key)) {
1331
- target[key] = Helper.parseDate(source[key]);
1332
- }
1333
- }
1334
- else {
1335
- target[key] = Helper.parseDate(source[key]);
1336
- }
1337
- }
1338
- else {
1339
- target[key] = source[key];
1340
- }
1124
+ for (var _e = __values(Object.entries(firstObject)), _f = _e.next(); !_f.done; _f = _e.next()) {
1125
+ var _g = __read(_f.value, 2), key = _g[0], value = _g[1];
1126
+ if (!Helper.isSubset(value, b[key])) {
1127
+ result[key] = value;
1341
1128
  }
1342
1129
  }
1343
1130
  }
1344
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
1131
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
1345
1132
  finally {
1346
1133
  try {
1347
1134
  if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
1348
1135
  }
1349
- finally { if (e_3) throw e_3.error; }
1136
+ finally { if (e_7) throw e_7.error; }
1350
1137
  }
1351
- // Return target
1352
- return target;
1138
+ return result;
1353
1139
  };
1354
1140
  /**
1355
- * Create Object or Objects of specified type with specified data
1141
+ * Check if propertie is type of HTMLCollection or NodeList
1142
+ * See https://stackoverflow.com/a/7238344
1143
+ *
1144
+ * @param nodes
1356
1145
  */
1357
- Helper.maps = function (data, targetClass) {
1358
- // Check data
1359
- if (!data || typeof data !== 'object') {
1360
- return undefined;
1146
+ Helper.isNodeList = function (nodes) {
1147
+ try {
1148
+ var stringRepr = Object.prototype.toString.call(nodes);
1149
+ return (typeof nodes === 'object' &&
1150
+ /^\[object (HTMLCollection|NodeList|Object)\]$/.test(stringRepr) &&
1151
+ typeof nodes.length === 'number' &&
1152
+ (nodes.length === 0 || (typeof nodes[0] === 'object' && nodes[0].nodeType > 0)));
1361
1153
  }
1362
- // Check array
1363
- if (!Array.isArray(data)) {
1364
- data = [data];
1154
+ catch (e) {
1155
+ return false;
1365
1156
  }
1366
- // Map
1367
- return data.map(function (item) {
1368
- return targetClass.map(item);
1369
- });
1370
1157
  };
1158
+ return Helper;
1159
+ }());
1160
+
1161
+ /**
1162
+ * Image service
1163
+ */
1164
+ var ImageService = /** @class */ (function () {
1165
+ function ImageService() {
1166
+ }
1371
1167
  /**
1372
- * Get plain parameter
1168
+ * Preaload images (for lazy handling)
1169
+ *
1170
+ * @param options
1171
+ * @protected
1373
1172
  */
1374
- Helper.getPlainParameter = function (parameter) {
1375
- var _a, _b, _c;
1376
- if (!parameter) {
1377
- return parameter;
1378
- }
1379
- return (_c = (_b = (_a = parameter === null || parameter === void 0 ? void 0 : parameter.split('?')) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.split('#')) === null || _c === void 0 ? void 0 : _c.shift();
1380
- };
1381
- /**
1382
- * Get ID of an url parameter
1383
- */
1384
- Helper.getParameterId = function (parameter) {
1385
- var _a;
1386
- if (!parameter) {
1387
- return parameter;
1388
- }
1389
- return (_a = Helper.getPlainParameter(parameter)) === null || _a === void 0 ? void 0 : _a.split('-').pop();
1390
- };
1391
- /**
1392
- * Delay
1393
- */
1394
- Helper.delay = function (ms) {
1395
- var promise = new Promise(function (resolve) { return setTimeout(resolve, ms); });
1396
- return promise;
1397
- };
1398
- /**
1399
- * Deep freeze
1400
- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#What_is_shallow_freeze
1401
- */
1402
- Helper.deepFreeze = function (object, preparedObjects) {
1403
- var e_4, _d;
1404
- if (preparedObjects === void 0) { preparedObjects = []; }
1405
- // Prevent infinit regress
1406
- if (preparedObjects.includes(object)) {
1407
- return object;
1408
- }
1409
- preparedObjects.push(object);
1410
- // Retrieve the property names defined on object
1411
- var propNames = Object.getOwnPropertyNames(object);
1412
- try {
1413
- // Freeze properties before freezing self
1414
- for (var propNames_1 = __values(propNames), propNames_1_1 = propNames_1.next(); !propNames_1_1.done; propNames_1_1 = propNames_1.next()) {
1415
- var name = propNames_1_1.value;
1416
- var value = object[name];
1417
- if (value && typeof value === 'object') {
1418
- Helper.deepFreeze(value, preparedObjects);
1173
+ ImageService.prototype.preLoadImages = function (options) {
1174
+ var _this = this;
1175
+ // Init configuration
1176
+ var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined }, options);
1177
+ return new Promise(function (resolve) {
1178
+ var e_1, _b;
1179
+ var _a;
1180
+ // Convert element(s) into array
1181
+ if (!Array.isArray(config.elements)) {
1182
+ // NodeList or HTMLCollection
1183
+ if (Helper.isNodeList(config.elements)) {
1184
+ config.elements = Array.from(config.elements);
1185
+ }
1186
+ // Single element
1187
+ else {
1188
+ config.elements = [config.elements];
1419
1189
  }
1420
1190
  }
1421
- }
1422
- catch (e_4_1) { e_4 = { error: e_4_1 }; }
1423
- finally {
1191
+ // Init loading
1192
+ var promises = [];
1193
+ // Get all images
1194
+ var images = [];
1195
+ config.elements.forEach(function (element) {
1196
+ images = images.concat(Array.from(element.getElementsByTagName('img')));
1197
+ });
1198
+ var _loop_1 = function (image) {
1199
+ var src = image.getAttribute('src');
1200
+ // Check if changes are necessary and possible
1201
+ if ((image.complete && image.naturalHeight !== 0) || // already laoded
1202
+ !src || // Image has no src
1203
+ ((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
1204
+ ) {
1205
+ return "continue";
1206
+ }
1207
+ // Replace lazy loading image with immediately loading image
1208
+ if (image.getAttribute('loading') === 'lazy') {
1209
+ var newImage_1 = document.createElement('img');
1210
+ Array.from(image.attributes).forEach(function (attr) {
1211
+ if (attr.name !== 'loading' && attr.name !== 'src') {
1212
+ newImage_1.setAttribute(attr.name, attr.value);
1213
+ }
1214
+ });
1215
+ image.replaceWith(newImage_1);
1216
+ image = newImage_1;
1217
+ }
1218
+ // Wait for laoding
1219
+ promises.push(_this.loadImage(image, src));
1220
+ };
1424
1221
  try {
1425
- if (propNames_1_1 && !propNames_1_1.done && (_d = propNames_1.return)) _d.call(propNames_1);
1222
+ // Prepare images
1223
+ for (var images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
1224
+ var image = images_1_1.value;
1225
+ _loop_1(image);
1226
+ }
1426
1227
  }
1427
- finally { if (e_4) throw e_4.error; }
1428
- }
1429
- return Object.freeze(object);
1228
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
1229
+ finally {
1230
+ try {
1231
+ if (images_1_1 && !images_1_1.done && (_b = images_1.return)) _b.call(images_1);
1232
+ }
1233
+ finally { if (e_1) throw e_1.error; }
1234
+ }
1235
+ // Wait until all images loaded
1236
+ Promise.all(promises)
1237
+ .catch(function (e) { return console.error('Error during image loading', e); })
1238
+ .finally(function () { return __awaiter(_this, void 0, void 0, function () {
1239
+ var result;
1240
+ return __generator(this, function (_b) {
1241
+ switch (_b.label) {
1242
+ case 0:
1243
+ if (!config.doneFunnction) return [3 /*break*/, 2];
1244
+ return [4 /*yield*/, config.doneFunction()];
1245
+ case 1:
1246
+ result = _b.sent();
1247
+ _b.label = 2;
1248
+ case 2:
1249
+ resolve(result);
1250
+ return [2 /*return*/];
1251
+ }
1252
+ });
1253
+ }); });
1254
+ });
1430
1255
  };
1431
1256
  /**
1432
- * Generates an unique identifier with 24 characters
1257
+ * Load image for image element
1258
+ *
1259
+ * @param imageElement
1260
+ * @param src
1261
+ * @protected
1433
1262
  */
1434
- Helper.getUID = function () {
1435
- var dt = new Date().getTime();
1436
- var uuid = 'xxxxxxxxxxxxxxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1437
- // eslint-disable-next-line no-bitwise
1438
- var r = (dt + Math.random() * 16) % 16 | 0;
1439
- dt = Math.floor(dt / 16);
1440
- // eslint-disable-next-line no-bitwise
1441
- return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
1263
+ ImageService.prototype.loadImage = function (imageElement, src) {
1264
+ return __awaiter(this, void 0, void 0, function () {
1265
+ return __generator(this, function (_b) {
1266
+ src = src || imageElement.src;
1267
+ return [2 /*return*/, new Promise(function (resolve, reject) {
1268
+ imageElement.onload = function () { return resolve(imageElement); };
1269
+ imageElement.onerror = reject;
1270
+ imageElement.src = src;
1271
+ })];
1272
+ });
1442
1273
  });
1443
- return uuid;
1444
1274
  };
1445
- /**
1446
- * Parse date string to date object
1447
- */
1448
- Helper.parseDate = function (dateString) {
1449
- var reISO = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*))(?:Z|(\+|-)([\d|:]*))?$/;
1450
- var reMsAjax = /^\/Date\((d|-|.*)\)[\/|\\]$/;
1451
- if (typeof dateString === 'string') {
1452
- var isoExec = reISO.exec(dateString);
1453
- if (isoExec) {
1454
- return new Date(dateString);
1455
- }
1456
- var msAjaxExec = reMsAjax.exec(dateString);
1457
- if (msAjaxExec) {
1458
- var cleaned = msAjaxExec[1].split(/[-+,.]/);
1459
- return new Date(cleaned[0] ? +cleaned[0] : 0 - +cleaned[1]);
1460
- }
1461
- }
1462
- return dateString;
1275
+ return ImageService;
1276
+ }());
1277
+ ImageService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ImageService_Factory() { return new ImageService(); }, token: ImageService, providedIn: "root" });
1278
+ ImageService.decorators = [
1279
+ { type: i0.Injectable, args: [{
1280
+ providedIn: 'root',
1281
+ },] }
1282
+ ];
1283
+
1284
+ /**
1285
+ * Set same height (maximum) to different elements
1286
+ */
1287
+ var MatchHeightDirective = /** @class */ (function () {
1288
+ function MatchHeightDirective(el, imageService, platformId) {
1289
+ this.el = el;
1290
+ this.imageService = imageService;
1291
+ // Replace lazy loading images with immediate loading images
1292
+ this.loadImages = true;
1293
+ this.isBrowser = common.isPlatformBrowser(platformId);
1294
+ }
1295
+ MatchHeightDirective.prototype.onResize = function () {
1296
+ this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
1463
1297
  };
1464
- /**
1465
- * Get browser name and version
1466
- */
1467
- Helper.getBrowser = function () {
1468
- var userAgent = navigator.userAgent;
1469
- var data = userAgent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];
1470
- var version;
1471
- if (/trident/i.test(data[1])) {
1472
- version = /\brv[ :]+(\d+)/g.exec(userAgent) || [];
1473
- return { name: 'IE', version: version[1] || '' };
1474
- }
1475
- if (data[1] === 'Chrome') {
1476
- version = userAgent.match(/\bOPR|Edge\/(\d+)/);
1477
- if (version != null) {
1478
- return { name: 'Opera', version: version[1] };
1479
- }
1480
- }
1481
- data = data[2] ? [data[1], data[2]] : [navigator.appName, navigator.appVersion, '-?'];
1482
- version = userAgent.match(/version\/(\d+)/i);
1483
- if (version !== null) {
1484
- data.splice(1, 1, version[1]);
1298
+ MatchHeightDirective.prototype.ngOnInit = function () {
1299
+ this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
1300
+ };
1301
+ MatchHeightDirective.prototype.matchHeight = function (parent, target) {
1302
+ return __awaiter(this, void 0, void 0, function () {
1303
+ var classNames, _loop_1, this_1, classNames_1, classNames_1_1, className, e_1_1;
1304
+ var e_1, _a;
1305
+ return __generator(this, function (_b) {
1306
+ switch (_b.label) {
1307
+ case 0:
1308
+ if (!parent) {
1309
+ return [2 /*return*/];
1310
+ }
1311
+ if (!Array.isArray(target)) {
1312
+ classNames = [target];
1313
+ }
1314
+ else {
1315
+ classNames = target;
1316
+ }
1317
+ _loop_1 = function (className) {
1318
+ var children, itemHeights, maxHeight;
1319
+ return __generator(this, function (_c) {
1320
+ switch (_c.label) {
1321
+ case 0:
1322
+ children = parent.getElementsByClassName(className);
1323
+ if (!children || children.length < 2) {
1324
+ return [2 /*return*/, "continue"];
1325
+ }
1326
+ if (!this_1.loadImages) return [3 /*break*/, 2];
1327
+ return [4 /*yield*/, this_1.imageService.preLoadImages({ elements: children })];
1328
+ case 1:
1329
+ _c.sent();
1330
+ _c.label = 2;
1331
+ case 2:
1332
+ // reset all children height
1333
+ Array.from(children).forEach(function (element) {
1334
+ element.style.height = 'initial';
1335
+ });
1336
+ itemHeights = Array.from(children).map(function (element) {
1337
+ if (element.getBoundingClientRect) {
1338
+ return element.getBoundingClientRect().height;
1339
+ }
1340
+ return 0;
1341
+ });
1342
+ maxHeight = itemHeights.reduce(function (prev, curr) { return (curr > prev ? curr : prev); }, 0);
1343
+ // update the child structureElements height to the tallest one
1344
+ Array.from(children).forEach(function (element) { return (element.style.height = maxHeight + "px"); });
1345
+ return [2 /*return*/];
1346
+ }
1347
+ });
1348
+ };
1349
+ this_1 = this;
1350
+ _b.label = 1;
1351
+ case 1:
1352
+ _b.trys.push([1, 6, 7, 8]);
1353
+ classNames_1 = __values(classNames), classNames_1_1 = classNames_1.next();
1354
+ _b.label = 2;
1355
+ case 2:
1356
+ if (!!classNames_1_1.done) return [3 /*break*/, 5];
1357
+ className = classNames_1_1.value;
1358
+ return [5 /*yield**/, _loop_1(className)];
1359
+ case 3:
1360
+ _b.sent();
1361
+ _b.label = 4;
1362
+ case 4:
1363
+ classNames_1_1 = classNames_1.next();
1364
+ return [3 /*break*/, 2];
1365
+ case 5: return [3 /*break*/, 8];
1366
+ case 6:
1367
+ e_1_1 = _b.sent();
1368
+ e_1 = { error: e_1_1 };
1369
+ return [3 /*break*/, 8];
1370
+ case 7:
1371
+ try {
1372
+ if (classNames_1_1 && !classNames_1_1.done && (_a = classNames_1.return)) _a.call(classNames_1);
1373
+ }
1374
+ finally { if (e_1) throw e_1.error; }
1375
+ return [7 /*endfinally*/];
1376
+ case 8: return [2 /*return*/];
1377
+ }
1378
+ });
1379
+ });
1380
+ };
1381
+ return MatchHeightDirective;
1382
+ }());
1383
+ MatchHeightDirective.decorators = [
1384
+ { type: i0.Directive, args: [{
1385
+ selector: '[ltMatchHeight]',
1386
+ },] }
1387
+ ];
1388
+ MatchHeightDirective.ctorParameters = function () { return [
1389
+ { type: i0.ElementRef },
1390
+ { type: ImageService },
1391
+ { type: String, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] }
1392
+ ]; };
1393
+ MatchHeightDirective.propDecorators = {
1394
+ ltMatchHeight: [{ type: i0.Input }],
1395
+ loadImages: [{ type: i0.Input }],
1396
+ onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
1397
+ };
1398
+
1399
+ /**
1400
+ * Reszise detection
1401
+ * (inpsired by: https://stackblitz.com/edit/angular-resizable)
1402
+ */
1403
+ var ResizableDirective = /** @class */ (function () {
1404
+ function ResizableDirective(el) {
1405
+ this.el = el;
1406
+ this.resizableGrabWidth = 8;
1407
+ this.resizableMinWidth = 10;
1408
+ this.dragging = false;
1409
+ }
1410
+ ResizableDirective.prototype.ngOnInit = function () {
1411
+ this.addListenerToDocument();
1412
+ this.addListenerToElement();
1413
+ };
1414
+ ResizableDirective.prototype.mouseMoveG = function (evt) {
1415
+ if (!this.dragging) {
1416
+ return;
1417
+ }
1418
+ this.newWidth(evt.clientX - this.el.nativeElement.offsetLeft);
1419
+ evt.stopPropagation();
1420
+ };
1421
+ ResizableDirective.prototype.newWidth = function (wid) {
1422
+ var result = Math.max(this.resizableMinWidth, wid);
1423
+ this.el.nativeElement.style.width = result + 'px';
1424
+ };
1425
+ ResizableDirective.prototype.mouseDown = function (evt) {
1426
+ if (this.inDragRegion(evt)) {
1427
+ this.dragging = true;
1428
+ this.preventGlobalMouseEvents();
1429
+ evt.stopPropagation();
1485
1430
  }
1486
- return {
1487
- name: data[0],
1488
- version: data[1],
1489
- };
1490
1431
  };
1491
- /**
1492
- * Whether first parameter is a deep subset of second parameter
1493
- * Hint: functions will be ignored
1494
- */
1495
- Helper.isSubset = function (a, b) {
1496
- var e_5, _d, e_6, _e;
1497
- // Equal
1498
- if (a === b) {
1499
- return true;
1432
+ ResizableDirective.prototype.restoreGlobalMouseEvents = function () {
1433
+ document.body.style['pointer-events'] = 'auto';
1434
+ };
1435
+ ResizableDirective.prototype.mouseUpG = function (evt) {
1436
+ if (!this.dragging) {
1437
+ return;
1500
1438
  }
1501
- // Different type
1502
- if (typeof a !== typeof b) {
1503
- return false;
1439
+ this.restoreGlobalMouseEvents();
1440
+ this.dragging = false;
1441
+ evt.stopPropagation();
1442
+ };
1443
+ ResizableDirective.prototype.mouseMove = function (evt) {
1444
+ if (this.inDragRegion(evt) || this.dragging) {
1445
+ this.el.nativeElement.style.cursor = 'col-resize';
1504
1446
  }
1505
- // Process array
1506
- if (Array.isArray(a)) {
1507
- try {
1508
- for (var _f = __values(Object.entries(a)), _g = _f.next(); !_g.done; _g = _f.next()) {
1509
- var _h = __read(_g.value, 2), key = _h[0], value = _h[1];
1510
- if (Helper.isSubset(value, b[key])) {
1511
- return false;
1512
- }
1513
- }
1514
- }
1515
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
1516
- finally {
1517
- try {
1518
- if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
1519
- }
1520
- finally { if (e_5) throw e_5.error; }
1521
- }
1522
- return true;
1447
+ else {
1448
+ this.el.nativeElement.style.cursor = 'default';
1523
1449
  }
1524
- // Process object
1525
- if (typeof a === 'object') {
1526
- var plain = JSON.parse(JSON.stringify(a));
1527
- try {
1528
- for (var _j = __values(Object.entries(plain)), _k = _j.next(); !_k.done; _k = _j.next()) {
1529
- var _l = __read(_k.value, 2), key = _l[0], value = _l[1];
1530
- if (Helper.isSubset(value, b[key])) {
1531
- return false;
1532
- }
1533
- }
1534
- }
1535
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
1536
- finally {
1537
- try {
1538
- if (_k && !_k.done && (_e = _j.return)) _e.call(_j);
1539
- }
1540
- finally { if (e_6) throw e_6.error; }
1541
- }
1542
- return true;
1450
+ };
1451
+ ResizableDirective.prototype.preventGlobalMouseEvents = function () {
1452
+ document.body.style['pointer-events'] = 'none';
1453
+ };
1454
+ ResizableDirective.prototype.inDragRegion = function (evt) {
1455
+ return this.el.nativeElement.clientWidth - evt.clientX + this.el.nativeElement.offsetLeft < this.resizableGrabWidth;
1456
+ };
1457
+ ResizableDirective.prototype.addListenerToDocument = function () {
1458
+ var _this = this;
1459
+ document.addEventListener('mousemove', function (e) {
1460
+ _this.mouseMoveG(e);
1461
+ }, true);
1462
+ document.addEventListener('mouseup', function (e) {
1463
+ _this.mouseUpG(e);
1464
+ }, true);
1465
+ };
1466
+ ResizableDirective.prototype.addListenerToElement = function () {
1467
+ var _this = this;
1468
+ this.el.nativeElement.addEventListener('mousedown', function (e) {
1469
+ _this.mouseDown(e);
1470
+ }, true);
1471
+ this.el.nativeElement.addEventListener('mousemove', function (e) {
1472
+ _this.mouseMove(e);
1473
+ }, true);
1474
+ };
1475
+ return ResizableDirective;
1476
+ }());
1477
+ ResizableDirective.decorators = [
1478
+ { type: i0.Directive, args: [{
1479
+ selector: '[ltResizable]',
1480
+ },] }
1481
+ ];
1482
+ ResizableDirective.ctorParameters = function () { return [
1483
+ { type: i0.ElementRef }
1484
+ ]; };
1485
+ ResizableDirective.propDecorators = {
1486
+ resizableGrabWidth: [{ type: i0.Input }],
1487
+ resizableMinWidth: [{ type: i0.Input }]
1488
+ };
1489
+
1490
+ /**
1491
+ * Truncate string with ellipses
1492
+ */
1493
+ var EllipsesPipe = /** @class */ (function () {
1494
+ function EllipsesPipe() {
1495
+ }
1496
+ EllipsesPipe.prototype.transform = function (value, limit) {
1497
+ if (!value) {
1498
+ return null;
1543
1499
  }
1544
- // Else
1545
- return true;
1500
+ return value.length > limit ? value.substring(0, limit) + '...' : value;
1546
1501
  };
1547
- /**
1548
- * Whether parameters are equal (have equal properties)
1549
- * Hint: functions will be ignored
1550
- */
1551
- Helper.isEqual = function (a, b) {
1552
- return Helper.isSubset(a, b) && Helper.isSubset(b, a);
1502
+ return EllipsesPipe;
1503
+ }());
1504
+ EllipsesPipe.decorators = [
1505
+ { type: i0.Pipe, args: [{
1506
+ name: 'ltEllipses',
1507
+ },] }
1508
+ ];
1509
+
1510
+ /**
1511
+ * Declarate html as safe
1512
+ */
1513
+ var SafeHtmlPipe = /** @class */ (function () {
1514
+ function SafeHtmlPipe(sanitized) {
1515
+ this.sanitized = sanitized;
1516
+ }
1517
+ SafeHtmlPipe.prototype.transform = function (value) {
1518
+ return this.sanitized.bypassSecurityTrustHtml(value);
1553
1519
  };
1520
+ return SafeHtmlPipe;
1521
+ }());
1522
+ SafeHtmlPipe.decorators = [
1523
+ { type: i0.Pipe, args: [{ name: 'ltSafeHtml' },] }
1524
+ ];
1525
+ SafeHtmlPipe.ctorParameters = function () { return [
1526
+ { type: i1.DomSanitizer }
1527
+ ]; };
1528
+
1529
+ // Imported and exported elements
1530
+ var elements = [
1531
+ // Directives
1532
+ ContextMenuDirective,
1533
+ LazyLoadDirective,
1534
+ MatchHeightDirective,
1535
+ ResizableDirective,
1536
+ // Pipes
1537
+ EllipsesPipe,
1538
+ SafeHtmlPipe,
1539
+ ];
1540
+ /**
1541
+ * Base module
1542
+ */
1543
+ var BaseModule = /** @class */ (function () {
1544
+ function BaseModule() {
1545
+ }
1554
1546
  /**
1555
- * First level difference of two objects
1556
- * Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
1557
- *
1558
- * @returns Record<string, any> Object with properties from first object
1547
+ * Set configuration of base module in root module of the app
1559
1548
  */
1560
- Helper.getDiff = function (a, b, clone) {
1561
- var e_7, _d;
1562
- if (clone === void 0) { clone = true; }
1563
- var result = {};
1564
- var firstObject = a;
1565
- if (clone) {
1566
- firstObject = JSON.parse(JSON.stringify(a));
1567
- }
1568
- try {
1569
- for (var _e = __values(Object.entries(firstObject)), _f = _e.next(); !_f.done; _f = _e.next()) {
1570
- var _g = __read(_f.value, 2), key = _g[0], value = _g[1];
1571
- if (!Helper.isSubset(value, b[key])) {
1572
- result[key] = value;
1573
- }
1574
- }
1549
+ BaseModule.forRoot = function (baseModuleConfig) {
1550
+ if (baseModuleConfig === void 0) { baseModuleConfig = {}; }
1551
+ // Default config
1552
+ var config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
1553
+ // Prepare providers
1554
+ var providers = [
1555
+ {
1556
+ provide: BASE_MODULE_CONFIG,
1557
+ useValue: baseModuleConfig,
1558
+ },
1559
+ ];
1560
+ // Add apollo features if API URL is set
1561
+ if (baseModuleConfig.apiUrl) {
1562
+ providers.push({
1563
+ provide: i1$1.APOLLO_OPTIONS,
1564
+ useFactory: apolloOptionsFactory,
1565
+ deps: [BASE_MODULE_CONFIG, http.HttpLink, AuthService],
1566
+ });
1575
1567
  }
1576
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
1577
- finally {
1578
- try {
1579
- if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
1580
- }
1581
- finally { if (e_7) throw e_7.error; }
1568
+ else if (config.logging) {
1569
+ console.log('apiUrl is missing, ApolloLink is not initialized');
1582
1570
  }
1583
- return result;
1571
+ // Return root module
1572
+ return {
1573
+ ngModule: BaseModule,
1574
+ providers: providers,
1575
+ };
1584
1576
  };
1585
- return Helper;
1577
+ return BaseModule;
1586
1578
  }());
1579
+ BaseModule.decorators = [
1580
+ { type: i0.NgModule, args: [{
1581
+ declarations: elements,
1582
+ exports: elements,
1583
+ },] }
1584
+ ];
1587
1585
 
1588
1586
  /**
1589
1587
  * Standard class
@@ -2917,48 +2915,26 @@
2917
2915
  * Scroll done promise
2918
2916
  */
2919
2917
  ScrollService.prototype.scrollDone = function (options) {
2920
- var _this = this;
2921
2918
  if (options === void 0) { options = {}; }
2922
- // Init configuration
2923
- var config = Object.assign({ doneFunction: undefined, timeout: undefined }, options);
2924
- // Return promise for scroll done
2925
- return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
2926
- var rejected, timeoutId, result;
2919
+ return __awaiter(this, void 0, void 0, function () {
2920
+ var config;
2927
2921
  return __generator(this, function (_a) {
2928
2922
  switch (_a.label) {
2929
2923
  case 0:
2930
- rejected = false;
2931
- // Set timeout handling if necessary
2932
- if (config.timeout) {
2933
- timeoutId = window.setTimeout(function () {
2934
- rejected = true;
2935
- reject(new Error('Timeout for scrollDone after:' + config.timeout));
2936
- }, config.timeout);
2937
- }
2924
+ config = Object.assign({ doneFunction: undefined }, options);
2938
2925
  // Wait for scroll done
2939
2926
  return [4 /*yield*/, this.scrollDoneDetection()];
2940
2927
  case 1:
2941
2928
  // Wait for scroll done
2942
2929
  _a.sent();
2943
- if (!!rejected) return [3 /*break*/, 4];
2944
- // Stop timeout if set
2945
- if (timeoutId) {
2946
- window.clearTimeout(timeoutId);
2930
+ // Get result
2931
+ if (config.doneFunction) {
2932
+ return [2 /*return*/, config.doneFunction()];
2947
2933
  }
2948
- result = void 0;
2949
- if (!config.doneFunction) return [3 /*break*/, 3];
2950
- return [4 /*yield*/, config.doneFunction()];
2951
- case 2:
2952
- result = _a.sent();
2953
- _a.label = 3;
2954
- case 3:
2955
- // Scroll done
2956
- resolve(result);
2957
- _a.label = 4;
2958
- case 4: return [2 /*return*/];
2934
+ return [2 /*return*/];
2959
2935
  }
2960
2936
  });
2961
- }); });
2937
+ });
2962
2938
  };
2963
2939
  /**
2964
2940
  * Scroll done detecton
@@ -3010,23 +2986,79 @@
3010
2986
  this.titleService = titleService;
3011
2987
  this.metaTagService = metaTagService;
3012
2988
  }
3013
- SEOService.prototype.initPageForSEO = function (title, description, keywords) {
3014
- this.setPageTitle(title);
3015
- this.setPageDescription(description);
3016
- if (keywords) {
3017
- this.setPageKeywords(keywords);
2989
+ SEOService.prototype.initPageForSEO = function (input) {
2990
+ this.setGeneralData(input);
2991
+ this.setTwitterData(input);
2992
+ this.setTwitterData(input);
2993
+ this.setFacebookData(input);
2994
+ if (input.keywords) {
2995
+ this.setPageKeywords(input.keywords);
3018
2996
  }
3019
2997
  };
3020
- SEOService.prototype.setPageTitle = function (title) {
3021
- this.titleService.setTitle(title);
3022
- this.metaTagService.updateTag({ property: 'og:title', content: title });
3023
- this.metaTagService.updateTag({ name: 'twitter:title', content: title });
2998
+ /**
2999
+ * Set general metadata
3000
+ *
3001
+ * @param data
3002
+ * @private
3003
+ */
3004
+ SEOService.prototype.setGeneralData = function (data) {
3005
+ this.titleService.setTitle(data.title);
3006
+ this.metaTagService.updateTag({ name: 'description', content: data.description });
3007
+ };
3008
+ /**
3009
+ * Set metadata for twitter
3010
+ *
3011
+ * @param data
3012
+ * @private
3013
+ */
3014
+ SEOService.prototype.setTwitterData = function (data) {
3015
+ this.metaTagService.updateTag({ name: 'twitter:title', content: data.title });
3016
+ this.metaTagService.updateTag({ name: 'twitter:description', content: data.description });
3017
+ this.metaTagService.updateTag({
3018
+ property: 'twitter:url',
3019
+ content: data.url ? data.url : window.location.href,
3020
+ });
3021
+ if (data.image) {
3022
+ this.metaTagService.updateTag({
3023
+ property: 'twitter:image',
3024
+ content: data.image,
3025
+ });
3026
+ this.metaTagService.updateTag({
3027
+ property: 'twitter:card',
3028
+ content: 'summary_large_image',
3029
+ });
3030
+ }
3024
3031
  };
3025
- SEOService.prototype.setPageDescription = function (description) {
3026
- this.metaTagService.updateTag({ name: 'description', content: description });
3027
- this.metaTagService.updateTag({ property: 'og:description', content: description });
3028
- this.metaTagService.updateTag({ name: 'twitter:description', content: description });
3032
+ /**
3033
+ * Set metadata for facebook
3034
+ *
3035
+ * @param data
3036
+ * @private
3037
+ */
3038
+ SEOService.prototype.setFacebookData = function (data) {
3039
+ this.metaTagService.updateTag({ property: 'og:title', content: data.title });
3040
+ this.metaTagService.updateTag({ property: 'og:description', content: data.description });
3041
+ this.metaTagService.updateTag({
3042
+ property: 'og:type',
3043
+ content: 'website',
3044
+ });
3045
+ this.metaTagService.updateTag({
3046
+ property: 'og:url',
3047
+ content: data.url ? data.url : window.location.href,
3048
+ });
3049
+ if (data.image) {
3050
+ this.metaTagService.updateTag({
3051
+ property: 'og:image',
3052
+ content: data.image,
3053
+ });
3054
+ }
3029
3055
  };
3056
+ /**
3057
+ * Set page keywords
3058
+ *
3059
+ * @param keywords
3060
+ * @private
3061
+ */
3030
3062
  SEOService.prototype.setPageKeywords = function (keywords) {
3031
3063
  this.metaTagService.updateTag({ name: 'keywords', content: keywords });
3032
3064
  };