@lenne.tech/ng-base 0.3.1 → 0.3.5
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 +568 -444
- package/bundles/lenne.tech-ng-base-src-lib-base.umd.js.map +1 -1
- package/bundles/lenne.tech-ng-base.umd.js +568 -444
- 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 +50 -29
- 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 +99 -0
- package/esm2015/lib/base/services/scroll.service.js +16 -112
- 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 +50 -29
- 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 +99 -0
- package/esm2015/src/lib/base/services/scroll.service.js +16 -112
- package/esm2015/src/lib/base/services/seo.service.js +70 -14
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js +493 -402
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js.map +1 -1
- package/fesm2015/lenne.tech-ng-base.js +493 -402
- 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 +10 -6
- package/lib/base/public-api.d.ts +1 -0
- package/lib/base/services/image.service.d.ts +24 -0
- package/lib/base/services/scroll.service.d.ts +6 -23
- package/lib/base/services/seo.service.d.ts +36 -3
- package/package.json +1 -1
- package/src/lib/base/classes/helper.class.d.ts +7 -0
- package/src/lib/base/directives/match-height.directive.d.ts +10 -6
- 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 +24 -0
- package/src/lib/base/services/scroll.service.d.ts +6 -23
- 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/src/lib/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.lenne.tech["ng-base"] || {}, global.lenne.tech["ng-base"].src = global.lenne.tech["ng-base"].src || {}, global.lenne.tech["ng-base"].src.lib = global.lenne.tech["ng-base"].src.lib || {}, global.lenne.tech["ng-base"].src.lib.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/src/lib/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.lenne.tech["ng-base"] || {}, global.lenne.tech["ng-base"].src = global.lenne.tech["ng-base"].src || {}, global.lenne.tech["ng-base"].src.lib = global.lenne.tech["ng-base"].src.lib || {}, global.lenne.tech["ng-base"].src.lib.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,492 @@
|
|
|
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 }, 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];
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
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
|
+
};
|
|
1221
|
+
try {
|
|
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
|
+
}
|
|
1227
|
+
}
|
|
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
|
+
});
|
|
1255
|
+
};
|
|
1256
|
+
/**
|
|
1257
|
+
* Load image for image element
|
|
1258
|
+
*
|
|
1259
|
+
* @param imageElement
|
|
1260
|
+
* @param src
|
|
1261
|
+
* @protected
|
|
1262
|
+
*/
|
|
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
|
+
});
|
|
1273
|
+
});
|
|
1274
|
+
};
|
|
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);
|
|
1297
|
+
};
|
|
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();
|
|
1430
|
+
}
|
|
1431
|
+
};
|
|
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;
|
|
1438
|
+
}
|
|
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';
|
|
1446
|
+
}
|
|
1447
|
+
else {
|
|
1448
|
+
this.el.nativeElement.style.cursor = 'default';
|
|
1449
|
+
}
|
|
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;
|
|
1499
|
+
}
|
|
1500
|
+
return value.length > limit ? value.substring(0, limit) + '...' : value;
|
|
1344
1501
|
};
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
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);
|
|
1351
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
|
+
}
|
|
1352
1546
|
/**
|
|
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
|
|
1547
|
+
* Set configuration of base module in root module of the app
|
|
1357
1548
|
*/
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
var
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
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
|
+
});
|
|
1373
1567
|
}
|
|
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; }
|
|
1568
|
+
else if (config.logging) {
|
|
1569
|
+
console.log('apiUrl is missing, ApolloLink is not initialized');
|
|
1380
1570
|
}
|
|
1381
|
-
|
|
1571
|
+
// Return root module
|
|
1572
|
+
return {
|
|
1573
|
+
ngModule: BaseModule,
|
|
1574
|
+
providers: providers,
|
|
1575
|
+
};
|
|
1382
1576
|
};
|
|
1383
|
-
return
|
|
1577
|
+
return BaseModule;
|
|
1384
1578
|
}());
|
|
1579
|
+
BaseModule.decorators = [
|
|
1580
|
+
{ type: i0.NgModule, args: [{
|
|
1581
|
+
declarations: elements,
|
|
1582
|
+
exports: elements,
|
|
1583
|
+
},] }
|
|
1584
|
+
];
|
|
1385
1585
|
|
|
1386
1586
|
/**
|
|
1387
1587
|
* Standard class
|
|
@@ -2602,9 +2802,10 @@
|
|
|
2602
2802
|
/**
|
|
2603
2803
|
* Initializer
|
|
2604
2804
|
*/
|
|
2605
|
-
function ScrollService(router, moduleConfig) {
|
|
2805
|
+
function ScrollService(router, moduleConfig, imageService) {
|
|
2606
2806
|
this.router = router;
|
|
2607
2807
|
this.moduleConfig = moduleConfig;
|
|
2808
|
+
this.imageService = imageService;
|
|
2608
2809
|
/**
|
|
2609
2810
|
* Is a scroll listener set
|
|
2610
2811
|
*
|
|
@@ -2655,7 +2856,7 @@
|
|
|
2655
2856
|
undoOverflowChanges = true;
|
|
2656
2857
|
}
|
|
2657
2858
|
if (!config.loadImagesBefore) return [3 /*break*/, 4];
|
|
2658
|
-
return [4 /*yield*/, this.preLoadImages()];
|
|
2859
|
+
return [4 /*yield*/, this.imageService.preLoadImages()];
|
|
2659
2860
|
case 3:
|
|
2660
2861
|
_a.sent();
|
|
2661
2862
|
_a.label = 4;
|
|
@@ -2714,48 +2915,26 @@
|
|
|
2714
2915
|
* Scroll done promise
|
|
2715
2916
|
*/
|
|
2716
2917
|
ScrollService.prototype.scrollDone = function (options) {
|
|
2717
|
-
var _this = this;
|
|
2718
2918
|
if (options === void 0) { options = {}; }
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
// Return promise for scroll done
|
|
2722
|
-
return new Promise(function (resolve, reject) { return __awaiter(_this, void 0, void 0, function () {
|
|
2723
|
-
var rejected, timeoutId, result;
|
|
2919
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2920
|
+
var config;
|
|
2724
2921
|
return __generator(this, function (_a) {
|
|
2725
2922
|
switch (_a.label) {
|
|
2726
2923
|
case 0:
|
|
2727
|
-
|
|
2728
|
-
// Set timeout handling if necessary
|
|
2729
|
-
if (config.timeout) {
|
|
2730
|
-
timeoutId = window.setTimeout(function () {
|
|
2731
|
-
rejected = true;
|
|
2732
|
-
reject(new Error('Timeout for scrollDone after:' + config.timeout));
|
|
2733
|
-
}, config.timeout);
|
|
2734
|
-
}
|
|
2924
|
+
config = Object.assign({ doneFunction: undefined }, options);
|
|
2735
2925
|
// Wait for scroll done
|
|
2736
2926
|
return [4 /*yield*/, this.scrollDoneDetection()];
|
|
2737
2927
|
case 1:
|
|
2738
2928
|
// Wait for scroll done
|
|
2739
2929
|
_a.sent();
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
window.clearTimeout(timeoutId);
|
|
2930
|
+
// Get result
|
|
2931
|
+
if (config.doneFunction) {
|
|
2932
|
+
return [2 /*return*/, config.doneFunction()];
|
|
2744
2933
|
}
|
|
2745
|
-
|
|
2746
|
-
if (!config.doneFunction) return [3 /*break*/, 3];
|
|
2747
|
-
return [4 /*yield*/, config.doneFunction()];
|
|
2748
|
-
case 2:
|
|
2749
|
-
result = _a.sent();
|
|
2750
|
-
_a.label = 3;
|
|
2751
|
-
case 3:
|
|
2752
|
-
// Scroll done
|
|
2753
|
-
resolve(result);
|
|
2754
|
-
_a.label = 4;
|
|
2755
|
-
case 4: return [2 /*return*/];
|
|
2934
|
+
return [2 /*return*/];
|
|
2756
2935
|
}
|
|
2757
2936
|
});
|
|
2758
|
-
});
|
|
2937
|
+
});
|
|
2759
2938
|
};
|
|
2760
2939
|
/**
|
|
2761
2940
|
* Scroll done detecton
|
|
@@ -2785,122 +2964,9 @@
|
|
|
2785
2964
|
// Return promise
|
|
2786
2965
|
return this.scrollPromise;
|
|
2787
2966
|
};
|
|
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
2967
|
return ScrollService;
|
|
2902
2968
|
}());
|
|
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" });
|
|
2969
|
+
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
2970
|
ScrollService.decorators = [
|
|
2905
2971
|
{ type: i0.Injectable, args: [{
|
|
2906
2972
|
providedIn: 'root',
|
|
@@ -2908,7 +2974,8 @@
|
|
|
2908
2974
|
];
|
|
2909
2975
|
ScrollService.ctorParameters = function () { return [
|
|
2910
2976
|
{ type: i1$2.Router },
|
|
2911
|
-
{ type: undefined, decorators: [{ type: i0.Inject, args: [BASE_MODULE_CONFIG,] }] }
|
|
2977
|
+
{ type: undefined, decorators: [{ type: i0.Inject, args: [BASE_MODULE_CONFIG,] }] },
|
|
2978
|
+
{ type: ImageService }
|
|
2912
2979
|
]; };
|
|
2913
2980
|
|
|
2914
2981
|
/**
|
|
@@ -2919,23 +2986,79 @@
|
|
|
2919
2986
|
this.titleService = titleService;
|
|
2920
2987
|
this.metaTagService = metaTagService;
|
|
2921
2988
|
}
|
|
2922
|
-
SEOService.prototype.initPageForSEO = function (
|
|
2923
|
-
this.
|
|
2924
|
-
this.
|
|
2925
|
-
|
|
2926
|
-
|
|
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);
|
|
2927
2996
|
}
|
|
2928
2997
|
};
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
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
|
+
}
|
|
2933
3031
|
};
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
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
|
+
}
|
|
2938
3055
|
};
|
|
3056
|
+
/**
|
|
3057
|
+
* Set page keywords
|
|
3058
|
+
*
|
|
3059
|
+
* @param keywords
|
|
3060
|
+
* @private
|
|
3061
|
+
*/
|
|
2939
3062
|
SEOService.prototype.setPageKeywords = function (keywords) {
|
|
2940
3063
|
this.metaTagService.updateTag({ name: 'keywords', content: keywords });
|
|
2941
3064
|
};
|
|
@@ -2998,6 +3121,7 @@
|
|
|
2998
3121
|
exports.GraphQLService = GraphQLService;
|
|
2999
3122
|
exports.GraphQLType = GraphQLType;
|
|
3000
3123
|
exports.Helper = Helper;
|
|
3124
|
+
exports.ImageService = ImageService;
|
|
3001
3125
|
exports.LazyLoadDirective = LazyLoadDirective;
|
|
3002
3126
|
exports.LoaderService = LoaderService;
|
|
3003
3127
|
exports.LogoutGuard = LogoutGuard;
|