@lenne.tech/ng-base 0.3.0 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/lenne.tech-ng-base-src-lib-base.umd.js +600 -414
- package/bundles/lenne.tech-ng-base-src-lib-base.umd.js.map +1 -1
- package/bundles/lenne.tech-ng-base.umd.js +600 -414
- package/bundles/lenne.tech-ng-base.umd.js.map +1 -1
- package/esm2015/lib/base/classes/helper.class.js +19 -1
- package/esm2015/lib/base/directives/match-height.directive.js +58 -25
- package/esm2015/lib/base/factories/apollo-options.factory.js +3 -2
- package/esm2015/lib/base/public-api.js +2 -1
- package/esm2015/lib/base/services/image.service.js +117 -0
- package/esm2015/lib/base/services/scroll.service.js +9 -84
- package/esm2015/lib/base/services/seo.service.js +70 -14
- package/esm2015/src/lib/base/classes/helper.class.js +19 -1
- package/esm2015/src/lib/base/directives/match-height.directive.js +58 -25
- package/esm2015/src/lib/base/factories/apollo-options.factory.js +3 -2
- package/esm2015/src/lib/base/public-api.js +2 -1
- package/esm2015/src/lib/base/services/image.service.js +117 -0
- package/esm2015/src/lib/base/services/scroll.service.js +9 -84
- package/esm2015/src/lib/base/services/seo.service.js +70 -14
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js +513 -371
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js.map +1 -1
- package/fesm2015/lenne.tech-ng-base.js +513 -371
- package/fesm2015/lenne.tech-ng-base.js.map +1 -1
- package/lib/base/classes/helper.class.d.ts +7 -0
- package/lib/base/directives/match-height.directive.d.ts +7 -2
- package/lib/base/public-api.d.ts +1 -0
- package/lib/base/services/image.service.d.ts +25 -0
- package/lib/base/services/scroll.service.d.ts +5 -21
- package/lib/base/services/seo.service.d.ts +36 -3
- package/package.json +3 -3
- package/src/lib/base/classes/helper.class.d.ts +7 -0
- package/src/lib/base/directives/match-height.directive.d.ts +7 -2
- package/src/lib/base/lenne.tech-ng-base-src-lib-base.metadata.json +1 -1
- package/src/lib/base/public-api.d.ts +1 -0
- package/src/lib/base/services/image.service.d.ts +25 -0
- package/src/lib/base/services/scroll.service.d.ts +5 -21
- 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 = {};
|
|
@@ -785,250 +786,6 @@
|
|
|
785
786
|
src: [{ type: i0.Input }]
|
|
786
787
|
};
|
|
787
788
|
|
|
788
|
-
/**
|
|
789
|
-
* Set same height (maximum) to different elements
|
|
790
|
-
*/
|
|
791
|
-
var MatchHeightDirective = /** @class */ (function () {
|
|
792
|
-
function MatchHeightDirective(el) {
|
|
793
|
-
this.el = el;
|
|
794
|
-
}
|
|
795
|
-
MatchHeightDirective.prototype.onResize = function () {
|
|
796
|
-
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
797
|
-
};
|
|
798
|
-
MatchHeightDirective.prototype.ngAfterViewChecked = function () {
|
|
799
|
-
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
800
|
-
};
|
|
801
|
-
MatchHeightDirective.prototype.matchHeight = function (parent, target) {
|
|
802
|
-
if (!parent) {
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
var classNames;
|
|
806
|
-
if (!Array.isArray(target)) {
|
|
807
|
-
classNames = [target];
|
|
808
|
-
}
|
|
809
|
-
else {
|
|
810
|
-
classNames = target;
|
|
811
|
-
}
|
|
812
|
-
classNames.forEach(function (className) {
|
|
813
|
-
// find all child structureElements with the selected class name
|
|
814
|
-
var children = parent.getElementsByClassName(className);
|
|
815
|
-
if (!children) {
|
|
816
|
-
return;
|
|
817
|
-
}
|
|
818
|
-
// reset all children height
|
|
819
|
-
Array.from(children).forEach(function (x) {
|
|
820
|
-
x.style.height = 'initial';
|
|
821
|
-
});
|
|
822
|
-
// get all the child structureElements heights
|
|
823
|
-
var itemHeights = Array.from(children).map(function (x) { return x.getBoundingClientRect().height; });
|
|
824
|
-
// find out the tallest one
|
|
825
|
-
var maxHeight = itemHeights.reduce(function (prev, curr) { return (curr > prev ? curr : prev); }, 0);
|
|
826
|
-
// update the child structureElements height to the tallest one
|
|
827
|
-
Array.from(children).forEach(function (x) { return (x.style.height = maxHeight + "px"); });
|
|
828
|
-
});
|
|
829
|
-
};
|
|
830
|
-
return MatchHeightDirective;
|
|
831
|
-
}());
|
|
832
|
-
MatchHeightDirective.decorators = [
|
|
833
|
-
{ type: i0.Directive, args: [{
|
|
834
|
-
selector: '[ltMatchHeight]',
|
|
835
|
-
},] }
|
|
836
|
-
];
|
|
837
|
-
MatchHeightDirective.ctorParameters = function () { return [
|
|
838
|
-
{ type: i0.ElementRef }
|
|
839
|
-
]; };
|
|
840
|
-
MatchHeightDirective.propDecorators = {
|
|
841
|
-
ltMatchHeight: [{ type: i0.Input }],
|
|
842
|
-
onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
|
|
843
|
-
};
|
|
844
|
-
|
|
845
|
-
/**
|
|
846
|
-
* Reszise detection
|
|
847
|
-
* (inpsired by: https://stackblitz.com/edit/angular-resizable)
|
|
848
|
-
*/
|
|
849
|
-
var ResizableDirective = /** @class */ (function () {
|
|
850
|
-
function ResizableDirective(el) {
|
|
851
|
-
this.el = el;
|
|
852
|
-
this.resizableGrabWidth = 8;
|
|
853
|
-
this.resizableMinWidth = 10;
|
|
854
|
-
this.dragging = false;
|
|
855
|
-
}
|
|
856
|
-
ResizableDirective.prototype.ngOnInit = function () {
|
|
857
|
-
this.addListenerToDocument();
|
|
858
|
-
this.addListenerToElement();
|
|
859
|
-
};
|
|
860
|
-
ResizableDirective.prototype.mouseMoveG = function (evt) {
|
|
861
|
-
if (!this.dragging) {
|
|
862
|
-
return;
|
|
863
|
-
}
|
|
864
|
-
this.newWidth(evt.clientX - this.el.nativeElement.offsetLeft);
|
|
865
|
-
evt.stopPropagation();
|
|
866
|
-
};
|
|
867
|
-
ResizableDirective.prototype.newWidth = function (wid) {
|
|
868
|
-
var result = Math.max(this.resizableMinWidth, wid);
|
|
869
|
-
this.el.nativeElement.style.width = result + 'px';
|
|
870
|
-
};
|
|
871
|
-
ResizableDirective.prototype.mouseDown = function (evt) {
|
|
872
|
-
if (this.inDragRegion(evt)) {
|
|
873
|
-
this.dragging = true;
|
|
874
|
-
this.preventGlobalMouseEvents();
|
|
875
|
-
evt.stopPropagation();
|
|
876
|
-
}
|
|
877
|
-
};
|
|
878
|
-
ResizableDirective.prototype.restoreGlobalMouseEvents = function () {
|
|
879
|
-
document.body.style['pointer-events'] = 'auto';
|
|
880
|
-
};
|
|
881
|
-
ResizableDirective.prototype.mouseUpG = function (evt) {
|
|
882
|
-
if (!this.dragging) {
|
|
883
|
-
return;
|
|
884
|
-
}
|
|
885
|
-
this.restoreGlobalMouseEvents();
|
|
886
|
-
this.dragging = false;
|
|
887
|
-
evt.stopPropagation();
|
|
888
|
-
};
|
|
889
|
-
ResizableDirective.prototype.mouseMove = function (evt) {
|
|
890
|
-
if (this.inDragRegion(evt) || this.dragging) {
|
|
891
|
-
this.el.nativeElement.style.cursor = 'col-resize';
|
|
892
|
-
}
|
|
893
|
-
else {
|
|
894
|
-
this.el.nativeElement.style.cursor = 'default';
|
|
895
|
-
}
|
|
896
|
-
};
|
|
897
|
-
ResizableDirective.prototype.preventGlobalMouseEvents = function () {
|
|
898
|
-
document.body.style['pointer-events'] = 'none';
|
|
899
|
-
};
|
|
900
|
-
ResizableDirective.prototype.inDragRegion = function (evt) {
|
|
901
|
-
return this.el.nativeElement.clientWidth - evt.clientX + this.el.nativeElement.offsetLeft < this.resizableGrabWidth;
|
|
902
|
-
};
|
|
903
|
-
ResizableDirective.prototype.addListenerToDocument = function () {
|
|
904
|
-
var _this = this;
|
|
905
|
-
document.addEventListener('mousemove', function (e) {
|
|
906
|
-
_this.mouseMoveG(e);
|
|
907
|
-
}, true);
|
|
908
|
-
document.addEventListener('mouseup', function (e) {
|
|
909
|
-
_this.mouseUpG(e);
|
|
910
|
-
}, true);
|
|
911
|
-
};
|
|
912
|
-
ResizableDirective.prototype.addListenerToElement = function () {
|
|
913
|
-
var _this = this;
|
|
914
|
-
this.el.nativeElement.addEventListener('mousedown', function (e) {
|
|
915
|
-
_this.mouseDown(e);
|
|
916
|
-
}, true);
|
|
917
|
-
this.el.nativeElement.addEventListener('mousemove', function (e) {
|
|
918
|
-
_this.mouseMove(e);
|
|
919
|
-
}, true);
|
|
920
|
-
};
|
|
921
|
-
return ResizableDirective;
|
|
922
|
-
}());
|
|
923
|
-
ResizableDirective.decorators = [
|
|
924
|
-
{ type: i0.Directive, args: [{
|
|
925
|
-
selector: '[ltResizable]',
|
|
926
|
-
},] }
|
|
927
|
-
];
|
|
928
|
-
ResizableDirective.ctorParameters = function () { return [
|
|
929
|
-
{ type: i0.ElementRef }
|
|
930
|
-
]; };
|
|
931
|
-
ResizableDirective.propDecorators = {
|
|
932
|
-
resizableGrabWidth: [{ type: i0.Input }],
|
|
933
|
-
resizableMinWidth: [{ type: i0.Input }]
|
|
934
|
-
};
|
|
935
|
-
|
|
936
|
-
/**
|
|
937
|
-
* Truncate string with ellipses
|
|
938
|
-
*/
|
|
939
|
-
var EllipsesPipe = /** @class */ (function () {
|
|
940
|
-
function EllipsesPipe() {
|
|
941
|
-
}
|
|
942
|
-
EllipsesPipe.prototype.transform = function (value, limit) {
|
|
943
|
-
if (!value) {
|
|
944
|
-
return null;
|
|
945
|
-
}
|
|
946
|
-
return value.length > limit ? value.substring(0, limit) + '...' : value;
|
|
947
|
-
};
|
|
948
|
-
return EllipsesPipe;
|
|
949
|
-
}());
|
|
950
|
-
EllipsesPipe.decorators = [
|
|
951
|
-
{ type: i0.Pipe, args: [{
|
|
952
|
-
name: 'ltEllipses',
|
|
953
|
-
},] }
|
|
954
|
-
];
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Declarate html as safe
|
|
958
|
-
*/
|
|
959
|
-
var SafeHtmlPipe = /** @class */ (function () {
|
|
960
|
-
function SafeHtmlPipe(sanitized) {
|
|
961
|
-
this.sanitized = sanitized;
|
|
962
|
-
}
|
|
963
|
-
SafeHtmlPipe.prototype.transform = function (value) {
|
|
964
|
-
return this.sanitized.bypassSecurityTrustHtml(value);
|
|
965
|
-
};
|
|
966
|
-
return SafeHtmlPipe;
|
|
967
|
-
}());
|
|
968
|
-
SafeHtmlPipe.decorators = [
|
|
969
|
-
{ type: i0.Pipe, args: [{ name: 'ltSafeHtml' },] }
|
|
970
|
-
];
|
|
971
|
-
SafeHtmlPipe.ctorParameters = function () { return [
|
|
972
|
-
{ type: i1.DomSanitizer }
|
|
973
|
-
]; };
|
|
974
|
-
|
|
975
|
-
// Imported and exported elements
|
|
976
|
-
var elements = [
|
|
977
|
-
// Directives
|
|
978
|
-
ContextMenuDirective,
|
|
979
|
-
LazyLoadDirective,
|
|
980
|
-
MatchHeightDirective,
|
|
981
|
-
ResizableDirective,
|
|
982
|
-
// Pipes
|
|
983
|
-
EllipsesPipe,
|
|
984
|
-
SafeHtmlPipe,
|
|
985
|
-
];
|
|
986
|
-
/**
|
|
987
|
-
* Base module
|
|
988
|
-
*/
|
|
989
|
-
var BaseModule = /** @class */ (function () {
|
|
990
|
-
function BaseModule() {
|
|
991
|
-
}
|
|
992
|
-
/**
|
|
993
|
-
* Set configuration of base module in root module of the app
|
|
994
|
-
*/
|
|
995
|
-
BaseModule.forRoot = function (baseModuleConfig) {
|
|
996
|
-
if (baseModuleConfig === void 0) { baseModuleConfig = {}; }
|
|
997
|
-
// Default config
|
|
998
|
-
var config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
|
|
999
|
-
// Prepare providers
|
|
1000
|
-
var providers = [
|
|
1001
|
-
{
|
|
1002
|
-
provide: BASE_MODULE_CONFIG,
|
|
1003
|
-
useValue: baseModuleConfig,
|
|
1004
|
-
},
|
|
1005
|
-
];
|
|
1006
|
-
// Add apollo features if API URL is set
|
|
1007
|
-
if (baseModuleConfig.apiUrl) {
|
|
1008
|
-
providers.push({
|
|
1009
|
-
provide: i1$1.APOLLO_OPTIONS,
|
|
1010
|
-
useFactory: apolloOptionsFactory,
|
|
1011
|
-
deps: [BASE_MODULE_CONFIG, http.HttpLink, AuthService],
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
else if (config.logging) {
|
|
1015
|
-
console.log('apiUrl is missing, ApolloLink is not initialized');
|
|
1016
|
-
}
|
|
1017
|
-
// Return root module
|
|
1018
|
-
return {
|
|
1019
|
-
ngModule: BaseModule,
|
|
1020
|
-
providers: providers,
|
|
1021
|
-
};
|
|
1022
|
-
};
|
|
1023
|
-
return BaseModule;
|
|
1024
|
-
}());
|
|
1025
|
-
BaseModule.decorators = [
|
|
1026
|
-
{ type: i0.NgModule, args: [{
|
|
1027
|
-
declarations: elements,
|
|
1028
|
-
exports: elements,
|
|
1029
|
-
},] }
|
|
1030
|
-
];
|
|
1031
|
-
|
|
1032
789
|
/**
|
|
1033
790
|
* Helper class
|
|
1034
791
|
*/
|
|
@@ -1339,49 +1096,532 @@
|
|
|
1339
1096
|
}
|
|
1340
1097
|
return true;
|
|
1341
1098
|
}
|
|
1342
|
-
// Else
|
|
1343
|
-
return true;
|
|
1099
|
+
// Else
|
|
1100
|
+
return true;
|
|
1101
|
+
};
|
|
1102
|
+
/**
|
|
1103
|
+
* Whether parameters are equal (have equal properties)
|
|
1104
|
+
* Hint: functions will be ignored
|
|
1105
|
+
*/
|
|
1106
|
+
Helper.isEqual = function (a, b) {
|
|
1107
|
+
return Helper.isSubset(a, b) && Helper.isSubset(b, a);
|
|
1108
|
+
};
|
|
1109
|
+
/**
|
|
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
|
|
1114
|
+
*/
|
|
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));
|
|
1122
|
+
}
|
|
1123
|
+
try {
|
|
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;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
1132
|
+
finally {
|
|
1133
|
+
try {
|
|
1134
|
+
if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
|
|
1135
|
+
}
|
|
1136
|
+
finally { if (e_7) throw e_7.error; }
|
|
1137
|
+
}
|
|
1138
|
+
return result;
|
|
1139
|
+
};
|
|
1140
|
+
/**
|
|
1141
|
+
* Check if propertie is type of HTMLCollection or NodeList
|
|
1142
|
+
* See https://stackoverflow.com/a/7238344
|
|
1143
|
+
*
|
|
1144
|
+
* @param nodes
|
|
1145
|
+
*/
|
|
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)));
|
|
1153
|
+
}
|
|
1154
|
+
catch (e) {
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
return Helper;
|
|
1159
|
+
}());
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* Image service
|
|
1163
|
+
*/
|
|
1164
|
+
var ImageService = /** @class */ (function () {
|
|
1165
|
+
function ImageService() {
|
|
1166
|
+
}
|
|
1167
|
+
/**
|
|
1168
|
+
* Preaload images (for lazy handling)
|
|
1169
|
+
*
|
|
1170
|
+
* @param options
|
|
1171
|
+
* @protected
|
|
1172
|
+
*/
|
|
1173
|
+
ImageService.prototype.preLoadImages = function (options) {
|
|
1174
|
+
var _this = this;
|
|
1175
|
+
// Init configuration
|
|
1176
|
+
var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined, timeout: undefined }, options);
|
|
1177
|
+
return new Promise(function (resolve) {
|
|
1178
|
+
var e_1, _b;
|
|
1179
|
+
var _a;
|
|
1180
|
+
// Init variables
|
|
1181
|
+
var resolved = false;
|
|
1182
|
+
var timeoutId;
|
|
1183
|
+
// Convert element(s) into array
|
|
1184
|
+
if (!Array.isArray(config.elements)) {
|
|
1185
|
+
// NodeList or HTMLCollection
|
|
1186
|
+
if (Helper.isNodeList(config.elements)) {
|
|
1187
|
+
config.elements = Array.from(config.elements);
|
|
1188
|
+
}
|
|
1189
|
+
// Single element
|
|
1190
|
+
else {
|
|
1191
|
+
config.elements = [config.elements];
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
// Init loading
|
|
1195
|
+
var promises = [];
|
|
1196
|
+
// Get all images
|
|
1197
|
+
var images = [];
|
|
1198
|
+
config.elements.forEach(function (element) {
|
|
1199
|
+
images = images.concat(Array.from(element.getElementsByTagName('img')));
|
|
1200
|
+
});
|
|
1201
|
+
var _loop_1 = function (image) {
|
|
1202
|
+
var src = image.getAttribute('src');
|
|
1203
|
+
// Check if changes are necessary and possible
|
|
1204
|
+
if ((image.complete && image.naturalHeight !== 0) || // already laoded
|
|
1205
|
+
image.getAttribute('loading') !== 'lazy' || // loading attribute !== lazy
|
|
1206
|
+
!src || // Image has no src
|
|
1207
|
+
((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
|
|
1208
|
+
) {
|
|
1209
|
+
return "continue";
|
|
1210
|
+
}
|
|
1211
|
+
// Replace lazy loading image with immediately loading image
|
|
1212
|
+
var newImage = document.createElement('img');
|
|
1213
|
+
Array.from(image.attributes).forEach(function (attr) {
|
|
1214
|
+
if (attr.name !== 'loading' && attr.name !== 'src') {
|
|
1215
|
+
newImage.setAttribute(attr.name, attr.value);
|
|
1216
|
+
}
|
|
1217
|
+
});
|
|
1218
|
+
image.replaceWith(newImage);
|
|
1219
|
+
// Wait for laoding
|
|
1220
|
+
promises.push(_this.loadImage(newImage, src));
|
|
1221
|
+
};
|
|
1222
|
+
try {
|
|
1223
|
+
// Prepare images
|
|
1224
|
+
for (var images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
|
|
1225
|
+
var image = images_1_1.value;
|
|
1226
|
+
_loop_1(image);
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
1230
|
+
finally {
|
|
1231
|
+
try {
|
|
1232
|
+
if (images_1_1 && !images_1_1.done && (_b = images_1.return)) _b.call(images_1);
|
|
1233
|
+
}
|
|
1234
|
+
finally { if (e_1) throw e_1.error; }
|
|
1235
|
+
}
|
|
1236
|
+
if (config.timeout) {
|
|
1237
|
+
timeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1238
|
+
return __generator(this, function (_b) {
|
|
1239
|
+
switch (_b.label) {
|
|
1240
|
+
case 0:
|
|
1241
|
+
resolved = true;
|
|
1242
|
+
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
1243
|
+
return [4 /*yield*/, config.doneFunction()];
|
|
1244
|
+
case 1:
|
|
1245
|
+
_b.sent();
|
|
1246
|
+
_b.label = 2;
|
|
1247
|
+
case 2:
|
|
1248
|
+
resolve(undefined);
|
|
1249
|
+
return [2 /*return*/];
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
}); });
|
|
1253
|
+
}
|
|
1254
|
+
// Wait until all images loaded
|
|
1255
|
+
Promise.all(promises)
|
|
1256
|
+
.catch(function (e) { return console.error('Error during image loading', e); })
|
|
1257
|
+
.finally(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
1258
|
+
var result;
|
|
1259
|
+
return __generator(this, function (_b) {
|
|
1260
|
+
switch (_b.label) {
|
|
1261
|
+
case 0:
|
|
1262
|
+
// Check if already resolved
|
|
1263
|
+
if (resolved) {
|
|
1264
|
+
return [2 /*return*/];
|
|
1265
|
+
}
|
|
1266
|
+
// Stop timeout
|
|
1267
|
+
if (timeoutId) {
|
|
1268
|
+
clearTimeout(timeoutId);
|
|
1269
|
+
}
|
|
1270
|
+
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
1271
|
+
return [4 /*yield*/, config.doneFunction()];
|
|
1272
|
+
case 1:
|
|
1273
|
+
result = _b.sent();
|
|
1274
|
+
_b.label = 2;
|
|
1275
|
+
case 2:
|
|
1276
|
+
resolve(result);
|
|
1277
|
+
return [2 /*return*/];
|
|
1278
|
+
}
|
|
1279
|
+
});
|
|
1280
|
+
}); });
|
|
1281
|
+
});
|
|
1282
|
+
};
|
|
1283
|
+
/**
|
|
1284
|
+
* Load image for image element
|
|
1285
|
+
*
|
|
1286
|
+
* @param imageElement
|
|
1287
|
+
* @param src
|
|
1288
|
+
* @protected
|
|
1289
|
+
*/
|
|
1290
|
+
ImageService.prototype.loadImage = function (imageElement, src) {
|
|
1291
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1292
|
+
return __generator(this, function (_b) {
|
|
1293
|
+
src = src || imageElement.src;
|
|
1294
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
1295
|
+
imageElement.onload = function () { return resolve(imageElement); };
|
|
1296
|
+
imageElement.onerror = reject;
|
|
1297
|
+
imageElement.src = src;
|
|
1298
|
+
})];
|
|
1299
|
+
});
|
|
1300
|
+
});
|
|
1301
|
+
};
|
|
1302
|
+
return ImageService;
|
|
1303
|
+
}());
|
|
1304
|
+
ImageService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ImageService_Factory() { return new ImageService(); }, token: ImageService, providedIn: "root" });
|
|
1305
|
+
ImageService.decorators = [
|
|
1306
|
+
{ type: i0.Injectable, args: [{
|
|
1307
|
+
providedIn: 'root',
|
|
1308
|
+
},] }
|
|
1309
|
+
];
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* Set same height (maximum) to different elements
|
|
1313
|
+
*/
|
|
1314
|
+
var MatchHeightDirective = /** @class */ (function () {
|
|
1315
|
+
function MatchHeightDirective(el, imageService, platformId) {
|
|
1316
|
+
this.el = el;
|
|
1317
|
+
this.imageService = imageService;
|
|
1318
|
+
// Replace lazy loading images with immediate loading images
|
|
1319
|
+
this.loadLazyImages = true;
|
|
1320
|
+
this.isBrowser = common.isPlatformBrowser(platformId);
|
|
1321
|
+
}
|
|
1322
|
+
MatchHeightDirective.prototype.onResize = function () {
|
|
1323
|
+
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
1324
|
+
};
|
|
1325
|
+
MatchHeightDirective.prototype.ngAfterViewChecked = function () {
|
|
1326
|
+
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
1327
|
+
};
|
|
1328
|
+
MatchHeightDirective.prototype.matchHeight = function (parent, target) {
|
|
1329
|
+
var _this = this;
|
|
1330
|
+
if (this.isBrowser) {
|
|
1331
|
+
// Timeout is set to force Angular to wait for all actions and only continue once the process has run through.
|
|
1332
|
+
// Otherwise, an infinite loop will occur.
|
|
1333
|
+
setTimeout(function () {
|
|
1334
|
+
_this.matchHeightHelper(parent, target);
|
|
1335
|
+
}, 1);
|
|
1336
|
+
}
|
|
1337
|
+
else {
|
|
1338
|
+
this.matchHeightHelper(parent, target);
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
MatchHeightDirective.prototype.matchHeightHelper = function (parent, target) {
|
|
1342
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1343
|
+
var classNames, _loop_1, this_1, classNames_1, classNames_1_1, className, e_1_1;
|
|
1344
|
+
var e_1, _a;
|
|
1345
|
+
return __generator(this, function (_b) {
|
|
1346
|
+
switch (_b.label) {
|
|
1347
|
+
case 0:
|
|
1348
|
+
if (!parent) {
|
|
1349
|
+
return [2 /*return*/];
|
|
1350
|
+
}
|
|
1351
|
+
if (!Array.isArray(target)) {
|
|
1352
|
+
classNames = [target];
|
|
1353
|
+
}
|
|
1354
|
+
else {
|
|
1355
|
+
classNames = target;
|
|
1356
|
+
}
|
|
1357
|
+
_loop_1 = function (className) {
|
|
1358
|
+
var children, itemHeights, maxHeight;
|
|
1359
|
+
return __generator(this, function (_c) {
|
|
1360
|
+
switch (_c.label) {
|
|
1361
|
+
case 0:
|
|
1362
|
+
children = parent.getElementsByClassName(className);
|
|
1363
|
+
if (!children || children.length < 2) {
|
|
1364
|
+
return [2 /*return*/, "continue"];
|
|
1365
|
+
}
|
|
1366
|
+
if (!this_1.loadLazyImages) return [3 /*break*/, 2];
|
|
1367
|
+
return [4 /*yield*/, this_1.imageService.preLoadImages({ elements: children })];
|
|
1368
|
+
case 1:
|
|
1369
|
+
_c.sent();
|
|
1370
|
+
_c.label = 2;
|
|
1371
|
+
case 2:
|
|
1372
|
+
// reset all children height
|
|
1373
|
+
Array.from(children).forEach(function (element) {
|
|
1374
|
+
element.style.height = 'initial';
|
|
1375
|
+
});
|
|
1376
|
+
itemHeights = Array.from(children).map(function (element) {
|
|
1377
|
+
if (element.getBoundingClientRect) {
|
|
1378
|
+
return element.getBoundingClientRect().height;
|
|
1379
|
+
}
|
|
1380
|
+
return 0;
|
|
1381
|
+
});
|
|
1382
|
+
maxHeight = itemHeights.reduce(function (prev, curr) { return (curr > prev ? curr : prev); }, 0);
|
|
1383
|
+
// update the child structureElements height to the tallest one
|
|
1384
|
+
Array.from(children).forEach(function (element) { return (element.style.height = maxHeight + "px"); });
|
|
1385
|
+
return [2 /*return*/];
|
|
1386
|
+
}
|
|
1387
|
+
});
|
|
1388
|
+
};
|
|
1389
|
+
this_1 = this;
|
|
1390
|
+
_b.label = 1;
|
|
1391
|
+
case 1:
|
|
1392
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
1393
|
+
classNames_1 = __values(classNames), classNames_1_1 = classNames_1.next();
|
|
1394
|
+
_b.label = 2;
|
|
1395
|
+
case 2:
|
|
1396
|
+
if (!!classNames_1_1.done) return [3 /*break*/, 5];
|
|
1397
|
+
className = classNames_1_1.value;
|
|
1398
|
+
return [5 /*yield**/, _loop_1(className)];
|
|
1399
|
+
case 3:
|
|
1400
|
+
_b.sent();
|
|
1401
|
+
_b.label = 4;
|
|
1402
|
+
case 4:
|
|
1403
|
+
classNames_1_1 = classNames_1.next();
|
|
1404
|
+
return [3 /*break*/, 2];
|
|
1405
|
+
case 5: return [3 /*break*/, 8];
|
|
1406
|
+
case 6:
|
|
1407
|
+
e_1_1 = _b.sent();
|
|
1408
|
+
e_1 = { error: e_1_1 };
|
|
1409
|
+
return [3 /*break*/, 8];
|
|
1410
|
+
case 7:
|
|
1411
|
+
try {
|
|
1412
|
+
if (classNames_1_1 && !classNames_1_1.done && (_a = classNames_1.return)) _a.call(classNames_1);
|
|
1413
|
+
}
|
|
1414
|
+
finally { if (e_1) throw e_1.error; }
|
|
1415
|
+
return [7 /*endfinally*/];
|
|
1416
|
+
case 8: return [2 /*return*/];
|
|
1417
|
+
}
|
|
1418
|
+
});
|
|
1419
|
+
});
|
|
1420
|
+
};
|
|
1421
|
+
return MatchHeightDirective;
|
|
1422
|
+
}());
|
|
1423
|
+
MatchHeightDirective.decorators = [
|
|
1424
|
+
{ type: i0.Directive, args: [{
|
|
1425
|
+
selector: '[ltMatchHeight]',
|
|
1426
|
+
},] }
|
|
1427
|
+
];
|
|
1428
|
+
MatchHeightDirective.ctorParameters = function () { return [
|
|
1429
|
+
{ type: i0.ElementRef },
|
|
1430
|
+
{ type: ImageService },
|
|
1431
|
+
{ type: String, decorators: [{ type: i0.Inject, args: [i0.PLATFORM_ID,] }] }
|
|
1432
|
+
]; };
|
|
1433
|
+
MatchHeightDirective.propDecorators = {
|
|
1434
|
+
ltMatchHeight: [{ type: i0.Input }],
|
|
1435
|
+
loadLazyImages: [{ type: i0.Input }],
|
|
1436
|
+
onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
|
|
1437
|
+
};
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* Reszise detection
|
|
1441
|
+
* (inpsired by: https://stackblitz.com/edit/angular-resizable)
|
|
1442
|
+
*/
|
|
1443
|
+
var ResizableDirective = /** @class */ (function () {
|
|
1444
|
+
function ResizableDirective(el) {
|
|
1445
|
+
this.el = el;
|
|
1446
|
+
this.resizableGrabWidth = 8;
|
|
1447
|
+
this.resizableMinWidth = 10;
|
|
1448
|
+
this.dragging = false;
|
|
1449
|
+
}
|
|
1450
|
+
ResizableDirective.prototype.ngOnInit = function () {
|
|
1451
|
+
this.addListenerToDocument();
|
|
1452
|
+
this.addListenerToElement();
|
|
1453
|
+
};
|
|
1454
|
+
ResizableDirective.prototype.mouseMoveG = function (evt) {
|
|
1455
|
+
if (!this.dragging) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
this.newWidth(evt.clientX - this.el.nativeElement.offsetLeft);
|
|
1459
|
+
evt.stopPropagation();
|
|
1460
|
+
};
|
|
1461
|
+
ResizableDirective.prototype.newWidth = function (wid) {
|
|
1462
|
+
var result = Math.max(this.resizableMinWidth, wid);
|
|
1463
|
+
this.el.nativeElement.style.width = result + 'px';
|
|
1464
|
+
};
|
|
1465
|
+
ResizableDirective.prototype.mouseDown = function (evt) {
|
|
1466
|
+
if (this.inDragRegion(evt)) {
|
|
1467
|
+
this.dragging = true;
|
|
1468
|
+
this.preventGlobalMouseEvents();
|
|
1469
|
+
evt.stopPropagation();
|
|
1470
|
+
}
|
|
1471
|
+
};
|
|
1472
|
+
ResizableDirective.prototype.restoreGlobalMouseEvents = function () {
|
|
1473
|
+
document.body.style['pointer-events'] = 'auto';
|
|
1474
|
+
};
|
|
1475
|
+
ResizableDirective.prototype.mouseUpG = function (evt) {
|
|
1476
|
+
if (!this.dragging) {
|
|
1477
|
+
return;
|
|
1478
|
+
}
|
|
1479
|
+
this.restoreGlobalMouseEvents();
|
|
1480
|
+
this.dragging = false;
|
|
1481
|
+
evt.stopPropagation();
|
|
1482
|
+
};
|
|
1483
|
+
ResizableDirective.prototype.mouseMove = function (evt) {
|
|
1484
|
+
if (this.inDragRegion(evt) || this.dragging) {
|
|
1485
|
+
this.el.nativeElement.style.cursor = 'col-resize';
|
|
1486
|
+
}
|
|
1487
|
+
else {
|
|
1488
|
+
this.el.nativeElement.style.cursor = 'default';
|
|
1489
|
+
}
|
|
1490
|
+
};
|
|
1491
|
+
ResizableDirective.prototype.preventGlobalMouseEvents = function () {
|
|
1492
|
+
document.body.style['pointer-events'] = 'none';
|
|
1493
|
+
};
|
|
1494
|
+
ResizableDirective.prototype.inDragRegion = function (evt) {
|
|
1495
|
+
return this.el.nativeElement.clientWidth - evt.clientX + this.el.nativeElement.offsetLeft < this.resizableGrabWidth;
|
|
1496
|
+
};
|
|
1497
|
+
ResizableDirective.prototype.addListenerToDocument = function () {
|
|
1498
|
+
var _this = this;
|
|
1499
|
+
document.addEventListener('mousemove', function (e) {
|
|
1500
|
+
_this.mouseMoveG(e);
|
|
1501
|
+
}, true);
|
|
1502
|
+
document.addEventListener('mouseup', function (e) {
|
|
1503
|
+
_this.mouseUpG(e);
|
|
1504
|
+
}, true);
|
|
1505
|
+
};
|
|
1506
|
+
ResizableDirective.prototype.addListenerToElement = function () {
|
|
1507
|
+
var _this = this;
|
|
1508
|
+
this.el.nativeElement.addEventListener('mousedown', function (e) {
|
|
1509
|
+
_this.mouseDown(e);
|
|
1510
|
+
}, true);
|
|
1511
|
+
this.el.nativeElement.addEventListener('mousemove', function (e) {
|
|
1512
|
+
_this.mouseMove(e);
|
|
1513
|
+
}, true);
|
|
1514
|
+
};
|
|
1515
|
+
return ResizableDirective;
|
|
1516
|
+
}());
|
|
1517
|
+
ResizableDirective.decorators = [
|
|
1518
|
+
{ type: i0.Directive, args: [{
|
|
1519
|
+
selector: '[ltResizable]',
|
|
1520
|
+
},] }
|
|
1521
|
+
];
|
|
1522
|
+
ResizableDirective.ctorParameters = function () { return [
|
|
1523
|
+
{ type: i0.ElementRef }
|
|
1524
|
+
]; };
|
|
1525
|
+
ResizableDirective.propDecorators = {
|
|
1526
|
+
resizableGrabWidth: [{ type: i0.Input }],
|
|
1527
|
+
resizableMinWidth: [{ type: i0.Input }]
|
|
1528
|
+
};
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* Truncate string with ellipses
|
|
1532
|
+
*/
|
|
1533
|
+
var EllipsesPipe = /** @class */ (function () {
|
|
1534
|
+
function EllipsesPipe() {
|
|
1535
|
+
}
|
|
1536
|
+
EllipsesPipe.prototype.transform = function (value, limit) {
|
|
1537
|
+
if (!value) {
|
|
1538
|
+
return null;
|
|
1539
|
+
}
|
|
1540
|
+
return value.length > limit ? value.substring(0, limit) + '...' : value;
|
|
1344
1541
|
};
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1542
|
+
return EllipsesPipe;
|
|
1543
|
+
}());
|
|
1544
|
+
EllipsesPipe.decorators = [
|
|
1545
|
+
{ type: i0.Pipe, args: [{
|
|
1546
|
+
name: 'ltEllipses',
|
|
1547
|
+
},] }
|
|
1548
|
+
];
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* Declarate html as safe
|
|
1552
|
+
*/
|
|
1553
|
+
var SafeHtmlPipe = /** @class */ (function () {
|
|
1554
|
+
function SafeHtmlPipe(sanitized) {
|
|
1555
|
+
this.sanitized = sanitized;
|
|
1556
|
+
}
|
|
1557
|
+
SafeHtmlPipe.prototype.transform = function (value) {
|
|
1558
|
+
return this.sanitized.bypassSecurityTrustHtml(value);
|
|
1351
1559
|
};
|
|
1560
|
+
return SafeHtmlPipe;
|
|
1561
|
+
}());
|
|
1562
|
+
SafeHtmlPipe.decorators = [
|
|
1563
|
+
{ type: i0.Pipe, args: [{ name: 'ltSafeHtml' },] }
|
|
1564
|
+
];
|
|
1565
|
+
SafeHtmlPipe.ctorParameters = function () { return [
|
|
1566
|
+
{ type: i1.DomSanitizer }
|
|
1567
|
+
]; };
|
|
1568
|
+
|
|
1569
|
+
// Imported and exported elements
|
|
1570
|
+
var elements = [
|
|
1571
|
+
// Directives
|
|
1572
|
+
ContextMenuDirective,
|
|
1573
|
+
LazyLoadDirective,
|
|
1574
|
+
MatchHeightDirective,
|
|
1575
|
+
ResizableDirective,
|
|
1576
|
+
// Pipes
|
|
1577
|
+
EllipsesPipe,
|
|
1578
|
+
SafeHtmlPipe,
|
|
1579
|
+
];
|
|
1580
|
+
/**
|
|
1581
|
+
* Base module
|
|
1582
|
+
*/
|
|
1583
|
+
var BaseModule = /** @class */ (function () {
|
|
1584
|
+
function BaseModule() {
|
|
1585
|
+
}
|
|
1352
1586
|
/**
|
|
1353
|
-
*
|
|
1354
|
-
* Hint: functions will be ignored and when an array or an object is different the hole array or object will used as property value
|
|
1355
|
-
*
|
|
1356
|
-
* @returns Record<string, any> Object with properties from first object
|
|
1587
|
+
* Set configuration of base module in root module of the app
|
|
1357
1588
|
*/
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
var
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1589
|
+
BaseModule.forRoot = function (baseModuleConfig) {
|
|
1590
|
+
if (baseModuleConfig === void 0) { baseModuleConfig = {}; }
|
|
1591
|
+
// Default config
|
|
1592
|
+
var config = Object.assign({ apiUrl: 'localhost:3000', authGuardRedirectUrl: '/auth', logging: false, version: null, prefix: null, scrollDetectionOffset: 200, scrollOffset: 100, storageType: 'local' }, baseModuleConfig);
|
|
1593
|
+
// Prepare providers
|
|
1594
|
+
var providers = [
|
|
1595
|
+
{
|
|
1596
|
+
provide: BASE_MODULE_CONFIG,
|
|
1597
|
+
useValue: baseModuleConfig,
|
|
1598
|
+
},
|
|
1599
|
+
];
|
|
1600
|
+
// Add apollo features if API URL is set
|
|
1601
|
+
if (baseModuleConfig.apiUrl) {
|
|
1602
|
+
providers.push({
|
|
1603
|
+
provide: i1$1.APOLLO_OPTIONS,
|
|
1604
|
+
useFactory: apolloOptionsFactory,
|
|
1605
|
+
deps: [BASE_MODULE_CONFIG, http.HttpLink, AuthService],
|
|
1606
|
+
});
|
|
1373
1607
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
try {
|
|
1377
|
-
if (_f && !_f.done && (_d = _e.return)) _d.call(_e);
|
|
1378
|
-
}
|
|
1379
|
-
finally { if (e_7) throw e_7.error; }
|
|
1608
|
+
else if (config.logging) {
|
|
1609
|
+
console.log('apiUrl is missing, ApolloLink is not initialized');
|
|
1380
1610
|
}
|
|
1381
|
-
|
|
1611
|
+
// Return root module
|
|
1612
|
+
return {
|
|
1613
|
+
ngModule: BaseModule,
|
|
1614
|
+
providers: providers,
|
|
1615
|
+
};
|
|
1382
1616
|
};
|
|
1383
|
-
return
|
|
1617
|
+
return BaseModule;
|
|
1384
1618
|
}());
|
|
1619
|
+
BaseModule.decorators = [
|
|
1620
|
+
{ type: i0.NgModule, args: [{
|
|
1621
|
+
declarations: elements,
|
|
1622
|
+
exports: elements,
|
|
1623
|
+
},] }
|
|
1624
|
+
];
|
|
1385
1625
|
|
|
1386
1626
|
/**
|
|
1387
1627
|
* Standard class
|
|
@@ -2602,9 +2842,10 @@
|
|
|
2602
2842
|
/**
|
|
2603
2843
|
* Initializer
|
|
2604
2844
|
*/
|
|
2605
|
-
function ScrollService(router, moduleConfig) {
|
|
2845
|
+
function ScrollService(router, moduleConfig, imageService) {
|
|
2606
2846
|
this.router = router;
|
|
2607
2847
|
this.moduleConfig = moduleConfig;
|
|
2848
|
+
this.imageService = imageService;
|
|
2608
2849
|
/**
|
|
2609
2850
|
* Is a scroll listener set
|
|
2610
2851
|
*
|
|
@@ -2655,7 +2896,7 @@
|
|
|
2655
2896
|
undoOverflowChanges = true;
|
|
2656
2897
|
}
|
|
2657
2898
|
if (!config.loadImagesBefore) return [3 /*break*/, 4];
|
|
2658
|
-
return [4 /*yield*/, this.preLoadImages()];
|
|
2899
|
+
return [4 /*yield*/, this.imageService.preLoadImages()];
|
|
2659
2900
|
case 3:
|
|
2660
2901
|
_a.sent();
|
|
2661
2902
|
_a.label = 4;
|
|
@@ -2785,122 +3026,9 @@
|
|
|
2785
3026
|
// Return promise
|
|
2786
3027
|
return this.scrollPromise;
|
|
2787
3028
|
};
|
|
2788
|
-
/**
|
|
2789
|
-
* Preaload images (for lazy handling)
|
|
2790
|
-
*
|
|
2791
|
-
* @param options
|
|
2792
|
-
* @protected
|
|
2793
|
-
*/
|
|
2794
|
-
ScrollService.prototype.preLoadImages = function (options) {
|
|
2795
|
-
var _this = this;
|
|
2796
|
-
// Init configuration
|
|
2797
|
-
var config = Object.assign({ doneFunnction: undefined, timeout: undefined }, options);
|
|
2798
|
-
return new Promise(function (resolve) {
|
|
2799
|
-
var e_1, _a;
|
|
2800
|
-
// Init variables
|
|
2801
|
-
var resolved = false;
|
|
2802
|
-
var timeoutId;
|
|
2803
|
-
// Init loading
|
|
2804
|
-
var images = Array.from(document.getElementsByTagName('img'));
|
|
2805
|
-
var promises = [];
|
|
2806
|
-
var _loop_1 = function (image) {
|
|
2807
|
-
var src = image.getAttribute('src');
|
|
2808
|
-
// Check if changes are necessary and possible
|
|
2809
|
-
if ((image.complete && image.naturalHeight !== 0) || image.getAttribute('loading') !== 'lazy' || !src) {
|
|
2810
|
-
return "continue";
|
|
2811
|
-
}
|
|
2812
|
-
var newImage = document.createElement('img');
|
|
2813
|
-
Array.from(image.attributes).forEach(function (attr) {
|
|
2814
|
-
if (attr.name !== 'loading' && attr.name !== 'src') {
|
|
2815
|
-
newImage.setAttribute(attr.name, attr.value);
|
|
2816
|
-
}
|
|
2817
|
-
});
|
|
2818
|
-
image.replaceWith(newImage);
|
|
2819
|
-
promises.push(_this.loadImage(newImage, src));
|
|
2820
|
-
};
|
|
2821
|
-
try {
|
|
2822
|
-
// Prepare images
|
|
2823
|
-
for (var images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
|
|
2824
|
-
var image = images_1_1.value;
|
|
2825
|
-
_loop_1(image);
|
|
2826
|
-
}
|
|
2827
|
-
}
|
|
2828
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
2829
|
-
finally {
|
|
2830
|
-
try {
|
|
2831
|
-
if (images_1_1 && !images_1_1.done && (_a = images_1.return)) _a.call(images_1);
|
|
2832
|
-
}
|
|
2833
|
-
finally { if (e_1) throw e_1.error; }
|
|
2834
|
-
}
|
|
2835
|
-
if (config.timeout) {
|
|
2836
|
-
timeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2837
|
-
return __generator(this, function (_a) {
|
|
2838
|
-
switch (_a.label) {
|
|
2839
|
-
case 0:
|
|
2840
|
-
resolved = true;
|
|
2841
|
-
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
2842
|
-
return [4 /*yield*/, config.doneFunction()];
|
|
2843
|
-
case 1:
|
|
2844
|
-
_a.sent();
|
|
2845
|
-
_a.label = 2;
|
|
2846
|
-
case 2:
|
|
2847
|
-
resolve(undefined);
|
|
2848
|
-
return [2 /*return*/];
|
|
2849
|
-
}
|
|
2850
|
-
});
|
|
2851
|
-
}); });
|
|
2852
|
-
}
|
|
2853
|
-
// Wait until all images loaded
|
|
2854
|
-
Promise.all(promises)
|
|
2855
|
-
.catch(function (e) { return console.error('Error during image loading', e); })
|
|
2856
|
-
.finally(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
2857
|
-
var result;
|
|
2858
|
-
return __generator(this, function (_a) {
|
|
2859
|
-
switch (_a.label) {
|
|
2860
|
-
case 0:
|
|
2861
|
-
// Check if already resolved
|
|
2862
|
-
if (resolved) {
|
|
2863
|
-
return [2 /*return*/];
|
|
2864
|
-
}
|
|
2865
|
-
// Stop timeout
|
|
2866
|
-
if (timeoutId) {
|
|
2867
|
-
clearTimeout(timeoutId);
|
|
2868
|
-
}
|
|
2869
|
-
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
2870
|
-
return [4 /*yield*/, config.doneFunction()];
|
|
2871
|
-
case 1:
|
|
2872
|
-
result = _a.sent();
|
|
2873
|
-
_a.label = 2;
|
|
2874
|
-
case 2:
|
|
2875
|
-
resolve(result);
|
|
2876
|
-
return [2 /*return*/];
|
|
2877
|
-
}
|
|
2878
|
-
});
|
|
2879
|
-
}); });
|
|
2880
|
-
});
|
|
2881
|
-
};
|
|
2882
|
-
/**
|
|
2883
|
-
* Load image for image element
|
|
2884
|
-
*
|
|
2885
|
-
* @param imageElement
|
|
2886
|
-
* @param src
|
|
2887
|
-
* @protected
|
|
2888
|
-
*/
|
|
2889
|
-
ScrollService.prototype.loadImage = function (imageElement, src) {
|
|
2890
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
2891
|
-
return __generator(this, function (_a) {
|
|
2892
|
-
src = src || imageElement.src;
|
|
2893
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
2894
|
-
imageElement.onload = function () { return resolve(imageElement); };
|
|
2895
|
-
imageElement.onerror = reject;
|
|
2896
|
-
imageElement.src = src;
|
|
2897
|
-
})];
|
|
2898
|
-
});
|
|
2899
|
-
});
|
|
2900
|
-
};
|
|
2901
3029
|
return ScrollService;
|
|
2902
3030
|
}());
|
|
2903
|
-
ScrollService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ScrollService_Factory() { return new ScrollService(i0__namespace.ɵɵinject(i1__namespace$1.Router), i0__namespace.ɵɵinject(BASE_MODULE_CONFIG)); }, token: ScrollService, providedIn: "root" });
|
|
3031
|
+
ScrollService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ScrollService_Factory() { return new ScrollService(i0__namespace.ɵɵinject(i1__namespace$1.Router), i0__namespace.ɵɵinject(BASE_MODULE_CONFIG), i0__namespace.ɵɵinject(ImageService)); }, token: ScrollService, providedIn: "root" });
|
|
2904
3032
|
ScrollService.decorators = [
|
|
2905
3033
|
{ type: i0.Injectable, args: [{
|
|
2906
3034
|
providedIn: 'root',
|
|
@@ -2908,7 +3036,8 @@
|
|
|
2908
3036
|
];
|
|
2909
3037
|
ScrollService.ctorParameters = function () { return [
|
|
2910
3038
|
{ type: i1$2.Router },
|
|
2911
|
-
{ type: undefined, decorators: [{ type: i0.Inject, args: [BASE_MODULE_CONFIG,] }] }
|
|
3039
|
+
{ type: undefined, decorators: [{ type: i0.Inject, args: [BASE_MODULE_CONFIG,] }] },
|
|
3040
|
+
{ type: ImageService }
|
|
2912
3041
|
]; };
|
|
2913
3042
|
|
|
2914
3043
|
/**
|
|
@@ -2919,23 +3048,79 @@
|
|
|
2919
3048
|
this.titleService = titleService;
|
|
2920
3049
|
this.metaTagService = metaTagService;
|
|
2921
3050
|
}
|
|
2922
|
-
SEOService.prototype.initPageForSEO = function (
|
|
2923
|
-
this.
|
|
2924
|
-
this.
|
|
2925
|
-
|
|
2926
|
-
|
|
3051
|
+
SEOService.prototype.initPageForSEO = function (input) {
|
|
3052
|
+
this.setGeneralData(input);
|
|
3053
|
+
this.setTwitterData(input);
|
|
3054
|
+
this.setTwitterData(input);
|
|
3055
|
+
this.setFacebookData(input);
|
|
3056
|
+
if (input.keywords) {
|
|
3057
|
+
this.setPageKeywords(input.keywords);
|
|
2927
3058
|
}
|
|
2928
3059
|
};
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
3060
|
+
/**
|
|
3061
|
+
* Set general metadata
|
|
3062
|
+
*
|
|
3063
|
+
* @param data
|
|
3064
|
+
* @private
|
|
3065
|
+
*/
|
|
3066
|
+
SEOService.prototype.setGeneralData = function (data) {
|
|
3067
|
+
this.titleService.setTitle(data.title);
|
|
3068
|
+
this.metaTagService.updateTag({ name: 'description', content: data.description });
|
|
3069
|
+
};
|
|
3070
|
+
/**
|
|
3071
|
+
* Set metadata for twitter
|
|
3072
|
+
*
|
|
3073
|
+
* @param data
|
|
3074
|
+
* @private
|
|
3075
|
+
*/
|
|
3076
|
+
SEOService.prototype.setTwitterData = function (data) {
|
|
3077
|
+
this.metaTagService.updateTag({ name: 'twitter:title', content: data.title });
|
|
3078
|
+
this.metaTagService.updateTag({ name: 'twitter:description', content: data.description });
|
|
3079
|
+
this.metaTagService.updateTag({
|
|
3080
|
+
property: 'twitter:url',
|
|
3081
|
+
content: data.url ? data.url : window.location.href,
|
|
3082
|
+
});
|
|
3083
|
+
if (data.image) {
|
|
3084
|
+
this.metaTagService.updateTag({
|
|
3085
|
+
property: 'twitter:image',
|
|
3086
|
+
content: data.image,
|
|
3087
|
+
});
|
|
3088
|
+
this.metaTagService.updateTag({
|
|
3089
|
+
property: 'twitter:card',
|
|
3090
|
+
content: 'summary_large_image',
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
2933
3093
|
};
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
3094
|
+
/**
|
|
3095
|
+
* Set metadata for facebook
|
|
3096
|
+
*
|
|
3097
|
+
* @param data
|
|
3098
|
+
* @private
|
|
3099
|
+
*/
|
|
3100
|
+
SEOService.prototype.setFacebookData = function (data) {
|
|
3101
|
+
this.metaTagService.updateTag({ property: 'og:title', content: data.title });
|
|
3102
|
+
this.metaTagService.updateTag({ property: 'og:description', content: data.description });
|
|
3103
|
+
this.metaTagService.updateTag({
|
|
3104
|
+
property: 'og:type',
|
|
3105
|
+
content: 'website',
|
|
3106
|
+
});
|
|
3107
|
+
this.metaTagService.updateTag({
|
|
3108
|
+
property: 'og:url',
|
|
3109
|
+
content: data.url ? data.url : window.location.href,
|
|
3110
|
+
});
|
|
3111
|
+
if (data.image) {
|
|
3112
|
+
this.metaTagService.updateTag({
|
|
3113
|
+
property: 'og:image',
|
|
3114
|
+
content: data.image,
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
2938
3117
|
};
|
|
3118
|
+
/**
|
|
3119
|
+
* Set page keywords
|
|
3120
|
+
*
|
|
3121
|
+
* @param keywords
|
|
3122
|
+
* @private
|
|
3123
|
+
*/
|
|
2939
3124
|
SEOService.prototype.setPageKeywords = function (keywords) {
|
|
2940
3125
|
this.metaTagService.updateTag({ name: 'keywords', content: keywords });
|
|
2941
3126
|
};
|
|
@@ -3000,6 +3185,7 @@
|
|
|
3000
3185
|
exports.GraphQLService = GraphQLService;
|
|
3001
3186
|
exports.GraphQLType = GraphQLType;
|
|
3002
3187
|
exports.Helper = Helper;
|
|
3188
|
+
exports.ImageService = ImageService;
|
|
3003
3189
|
exports.LazyLoadDirective = LazyLoadDirective;
|
|
3004
3190
|
exports.LoaderService = LoaderService;
|
|
3005
3191
|
exports.LogoutGuard = LogoutGuard;
|