@lenne.tech/ng-base 0.2.2 → 0.3.3
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 +308 -159
- package/bundles/lenne.tech-ng-base-src-lib-base.umd.js.map +1 -1
- package/bundles/lenne.tech-ng-base.umd.js +308 -159
- package/bundles/lenne.tech-ng-base.umd.js.map +1 -1
- package/esm2015/lib/base/directives/match-height.directive.js +45 -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 +113 -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/directives/match-height.directive.js +45 -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 +113 -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 +231 -127
- package/fesm2015/lenne.tech-ng-base-src-lib-base.js.map +1 -1
- package/fesm2015/lenne.tech-ng-base.js +231 -127
- package/fesm2015/lenne.tech-ng-base.js.map +1 -1
- package/lib/base/directives/match-height.directive.d.ts +7 -3
- 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 +12 -11
- package/src/lib/base/directives/match-height.directive.d.ts +7 -3
- 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
|
@@ -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,12 +786,162 @@
|
|
|
785
786
|
src: [{ type: i0.Input }]
|
|
786
787
|
};
|
|
787
788
|
|
|
789
|
+
/**
|
|
790
|
+
* Image service
|
|
791
|
+
*/
|
|
792
|
+
var ImageService = /** @class */ (function () {
|
|
793
|
+
function ImageService() {
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Preaload images (for lazy handling)
|
|
797
|
+
*
|
|
798
|
+
* @param options
|
|
799
|
+
* @protected
|
|
800
|
+
*/
|
|
801
|
+
ImageService.prototype.preLoadImages = function (options) {
|
|
802
|
+
var _this = this;
|
|
803
|
+
// Init configuration
|
|
804
|
+
var config = Object.assign({ doneFunnction: undefined, elements: document, regExp: undefined, timeout: undefined }, options);
|
|
805
|
+
return new Promise(function (resolve) {
|
|
806
|
+
var e_1, _b;
|
|
807
|
+
var _a;
|
|
808
|
+
// Init variables
|
|
809
|
+
var resolved = false;
|
|
810
|
+
var timeoutId;
|
|
811
|
+
// HTMLCollection to array
|
|
812
|
+
if (config.elements instanceof HTMLCollection) {
|
|
813
|
+
config.elements = Array.from(config.elements);
|
|
814
|
+
}
|
|
815
|
+
// Single element to array
|
|
816
|
+
if (!Array.isArray(config.elements)) {
|
|
817
|
+
config.elements = [config.elements];
|
|
818
|
+
}
|
|
819
|
+
// Init loading
|
|
820
|
+
var promises = [];
|
|
821
|
+
// Get all images
|
|
822
|
+
var images = [];
|
|
823
|
+
config.elements.forEach(function (element) {
|
|
824
|
+
images = images.concat(Array.from(element.getElementsByTagName('img')));
|
|
825
|
+
});
|
|
826
|
+
var _loop_1 = function (image) {
|
|
827
|
+
var src = image.getAttribute('src');
|
|
828
|
+
// Check if changes are necessary and possible
|
|
829
|
+
if ((image.complete && image.naturalHeight !== 0) || // already laoded
|
|
830
|
+
image.getAttribute('loading') !== 'lazy' || // loading attribute !== lazy
|
|
831
|
+
!src || // Image has no src
|
|
832
|
+
((_a = config.regExp) === null || _a === void 0 ? void 0 : _a.test(src)) // Test if src matches regular expression
|
|
833
|
+
) {
|
|
834
|
+
return "continue";
|
|
835
|
+
}
|
|
836
|
+
// Replace lazy loading image with immediately loading image
|
|
837
|
+
var newImage = document.createElement('img');
|
|
838
|
+
Array.from(image.attributes).forEach(function (attr) {
|
|
839
|
+
if (attr.name !== 'loading' && attr.name !== 'src') {
|
|
840
|
+
newImage.setAttribute(attr.name, attr.value);
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
image.replaceWith(newImage);
|
|
844
|
+
// Wait for laoding
|
|
845
|
+
promises.push(_this.loadImage(newImage, src));
|
|
846
|
+
};
|
|
847
|
+
try {
|
|
848
|
+
// Prepare images
|
|
849
|
+
for (var images_1 = __values(images), images_1_1 = images_1.next(); !images_1_1.done; images_1_1 = images_1.next()) {
|
|
850
|
+
var image = images_1_1.value;
|
|
851
|
+
_loop_1(image);
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
855
|
+
finally {
|
|
856
|
+
try {
|
|
857
|
+
if (images_1_1 && !images_1_1.done && (_b = images_1.return)) _b.call(images_1);
|
|
858
|
+
}
|
|
859
|
+
finally { if (e_1) throw e_1.error; }
|
|
860
|
+
}
|
|
861
|
+
if (config.timeout) {
|
|
862
|
+
timeoutId = setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
863
|
+
return __generator(this, function (_b) {
|
|
864
|
+
switch (_b.label) {
|
|
865
|
+
case 0:
|
|
866
|
+
resolved = true;
|
|
867
|
+
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
868
|
+
return [4 /*yield*/, config.doneFunction()];
|
|
869
|
+
case 1:
|
|
870
|
+
_b.sent();
|
|
871
|
+
_b.label = 2;
|
|
872
|
+
case 2:
|
|
873
|
+
resolve(undefined);
|
|
874
|
+
return [2 /*return*/];
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
}); });
|
|
878
|
+
}
|
|
879
|
+
// Wait until all images loaded
|
|
880
|
+
Promise.all(promises)
|
|
881
|
+
.catch(function (e) { return console.error('Error during image loading', e); })
|
|
882
|
+
.finally(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
883
|
+
var result;
|
|
884
|
+
return __generator(this, function (_b) {
|
|
885
|
+
switch (_b.label) {
|
|
886
|
+
case 0:
|
|
887
|
+
// Check if already resolved
|
|
888
|
+
if (resolved) {
|
|
889
|
+
return [2 /*return*/];
|
|
890
|
+
}
|
|
891
|
+
// Stop timeout
|
|
892
|
+
if (timeoutId) {
|
|
893
|
+
clearTimeout(timeoutId);
|
|
894
|
+
}
|
|
895
|
+
if (!config.doneFunnction) return [3 /*break*/, 2];
|
|
896
|
+
return [4 /*yield*/, config.doneFunction()];
|
|
897
|
+
case 1:
|
|
898
|
+
result = _b.sent();
|
|
899
|
+
_b.label = 2;
|
|
900
|
+
case 2:
|
|
901
|
+
resolve(result);
|
|
902
|
+
return [2 /*return*/];
|
|
903
|
+
}
|
|
904
|
+
});
|
|
905
|
+
}); });
|
|
906
|
+
});
|
|
907
|
+
};
|
|
908
|
+
/**
|
|
909
|
+
* Load image for image element
|
|
910
|
+
*
|
|
911
|
+
* @param imageElement
|
|
912
|
+
* @param src
|
|
913
|
+
* @protected
|
|
914
|
+
*/
|
|
915
|
+
ImageService.prototype.loadImage = function (imageElement, src) {
|
|
916
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
917
|
+
return __generator(this, function (_b) {
|
|
918
|
+
src = src || imageElement.src;
|
|
919
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
920
|
+
imageElement.onload = function () { return resolve(imageElement); };
|
|
921
|
+
imageElement.onerror = reject;
|
|
922
|
+
imageElement.src = src;
|
|
923
|
+
})];
|
|
924
|
+
});
|
|
925
|
+
});
|
|
926
|
+
};
|
|
927
|
+
return ImageService;
|
|
928
|
+
}());
|
|
929
|
+
ImageService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function ImageService_Factory() { return new ImageService(); }, token: ImageService, providedIn: "root" });
|
|
930
|
+
ImageService.decorators = [
|
|
931
|
+
{ type: i0.Injectable, args: [{
|
|
932
|
+
providedIn: 'root',
|
|
933
|
+
},] }
|
|
934
|
+
];
|
|
935
|
+
|
|
788
936
|
/**
|
|
789
937
|
* Set same height (maximum) to different elements
|
|
790
938
|
*/
|
|
791
939
|
var MatchHeightDirective = /** @class */ (function () {
|
|
792
|
-
function MatchHeightDirective(el) {
|
|
940
|
+
function MatchHeightDirective(el, imageService, zone) {
|
|
793
941
|
this.el = el;
|
|
942
|
+
this.imageService = imageService;
|
|
943
|
+
this.zone = zone;
|
|
944
|
+
this.loadLazyImages = true;
|
|
794
945
|
}
|
|
795
946
|
MatchHeightDirective.prototype.onResize = function () {
|
|
796
947
|
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
@@ -799,33 +950,82 @@
|
|
|
799
950
|
this.matchHeight(this.el.nativeElement, this.ltMatchHeight);
|
|
800
951
|
};
|
|
801
952
|
MatchHeightDirective.prototype.matchHeight = function (parent, target) {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
953
|
+
var _this = this;
|
|
954
|
+
// Timeout is set to force Angular to wait for all actions and only continue once the process has run through.
|
|
955
|
+
// Otherwise, an infinite loop will occur.
|
|
956
|
+
setTimeout(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
957
|
+
var classNames, _loop_1, this_1, classNames_1, classNames_1_1, className, e_1_1;
|
|
958
|
+
var e_1, _a;
|
|
959
|
+
return __generator(this, function (_b) {
|
|
960
|
+
switch (_b.label) {
|
|
961
|
+
case 0:
|
|
962
|
+
if (!parent) {
|
|
963
|
+
return [2 /*return*/];
|
|
964
|
+
}
|
|
965
|
+
if (!Array.isArray(target)) {
|
|
966
|
+
classNames = [target];
|
|
967
|
+
}
|
|
968
|
+
else {
|
|
969
|
+
classNames = target;
|
|
970
|
+
}
|
|
971
|
+
_loop_1 = function (className) {
|
|
972
|
+
var children, itemHeights, maxHeight;
|
|
973
|
+
return __generator(this, function (_c) {
|
|
974
|
+
switch (_c.label) {
|
|
975
|
+
case 0:
|
|
976
|
+
children = parent.getElementsByClassName(className);
|
|
977
|
+
if (!children || children.length < 2) {
|
|
978
|
+
return [2 /*return*/, "continue"];
|
|
979
|
+
}
|
|
980
|
+
if (!this_1.loadLazyImages) return [3 /*break*/, 2];
|
|
981
|
+
return [4 /*yield*/, this_1.imageService.preLoadImages({ elements: children })];
|
|
982
|
+
case 1:
|
|
983
|
+
_c.sent();
|
|
984
|
+
_c.label = 2;
|
|
985
|
+
case 2:
|
|
986
|
+
// reset all children height
|
|
987
|
+
Array.from(children).forEach(function (element) {
|
|
988
|
+
element.style.height = 'initial';
|
|
989
|
+
});
|
|
990
|
+
itemHeights = Array.from(children).map(function (x) { return x.getBoundingClientRect().height; });
|
|
991
|
+
maxHeight = itemHeights.reduce(function (prev, curr) { return (curr > prev ? curr : prev); }, 0);
|
|
992
|
+
// update the child structureElements height to the tallest one
|
|
993
|
+
Array.from(children).forEach(function (element) { return (element.style.height = maxHeight + "px"); });
|
|
994
|
+
return [2 /*return*/];
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
};
|
|
998
|
+
this_1 = this;
|
|
999
|
+
_b.label = 1;
|
|
1000
|
+
case 1:
|
|
1001
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
1002
|
+
classNames_1 = __values(classNames), classNames_1_1 = classNames_1.next();
|
|
1003
|
+
_b.label = 2;
|
|
1004
|
+
case 2:
|
|
1005
|
+
if (!!classNames_1_1.done) return [3 /*break*/, 5];
|
|
1006
|
+
className = classNames_1_1.value;
|
|
1007
|
+
return [5 /*yield**/, _loop_1(className)];
|
|
1008
|
+
case 3:
|
|
1009
|
+
_b.sent();
|
|
1010
|
+
_b.label = 4;
|
|
1011
|
+
case 4:
|
|
1012
|
+
classNames_1_1 = classNames_1.next();
|
|
1013
|
+
return [3 /*break*/, 2];
|
|
1014
|
+
case 5: return [3 /*break*/, 8];
|
|
1015
|
+
case 6:
|
|
1016
|
+
e_1_1 = _b.sent();
|
|
1017
|
+
e_1 = { error: e_1_1 };
|
|
1018
|
+
return [3 /*break*/, 8];
|
|
1019
|
+
case 7:
|
|
1020
|
+
try {
|
|
1021
|
+
if (classNames_1_1 && !classNames_1_1.done && (_a = classNames_1.return)) _a.call(classNames_1);
|
|
1022
|
+
}
|
|
1023
|
+
finally { if (e_1) throw e_1.error; }
|
|
1024
|
+
return [7 /*endfinally*/];
|
|
1025
|
+
case 8: return [2 /*return*/];
|
|
1026
|
+
}
|
|
821
1027
|
});
|
|
822
|
-
|
|
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
|
-
});
|
|
1028
|
+
}); }, 1);
|
|
829
1029
|
};
|
|
830
1030
|
return MatchHeightDirective;
|
|
831
1031
|
}());
|
|
@@ -835,10 +1035,13 @@
|
|
|
835
1035
|
},] }
|
|
836
1036
|
];
|
|
837
1037
|
MatchHeightDirective.ctorParameters = function () { return [
|
|
838
|
-
{ type: i0.ElementRef }
|
|
1038
|
+
{ type: i0.ElementRef },
|
|
1039
|
+
{ type: ImageService },
|
|
1040
|
+
{ type: i0.NgZone }
|
|
839
1041
|
]; };
|
|
840
1042
|
MatchHeightDirective.propDecorators = {
|
|
841
1043
|
ltMatchHeight: [{ type: i0.Input }],
|
|
1044
|
+
loadLazyImages: [{ type: i0.Input }],
|
|
842
1045
|
onResize: [{ type: i0.HostListener, args: ['window:resize',] }]
|
|
843
1046
|
};
|
|
844
1047
|
|
|
@@ -2602,9 +2805,10 @@
|
|
|
2602
2805
|
/**
|
|
2603
2806
|
* Initializer
|
|
2604
2807
|
*/
|
|
2605
|
-
function ScrollService(router, moduleConfig) {
|
|
2808
|
+
function ScrollService(router, moduleConfig, imageService) {
|
|
2606
2809
|
this.router = router;
|
|
2607
2810
|
this.moduleConfig = moduleConfig;
|
|
2811
|
+
this.imageService = imageService;
|
|
2608
2812
|
/**
|
|
2609
2813
|
* Is a scroll listener set
|
|
2610
2814
|
*
|
|
@@ -2655,7 +2859,7 @@
|
|
|
2655
2859
|
undoOverflowChanges = true;
|
|
2656
2860
|
}
|
|
2657
2861
|
if (!config.loadImagesBefore) return [3 /*break*/, 4];
|
|
2658
|
-
return [4 /*yield*/, this.preLoadImages()];
|
|
2862
|
+
return [4 /*yield*/, this.imageService.preLoadImages()];
|
|
2659
2863
|
case 3:
|
|
2660
2864
|
_a.sent();
|
|
2661
2865
|
_a.label = 4;
|
|
@@ -2785,122 +2989,9 @@
|
|
|
2785
2989
|
// Return promise
|
|
2786
2990
|
return this.scrollPromise;
|
|
2787
2991
|
};
|
|
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
2992
|
return ScrollService;
|
|
2902
2993
|
}());
|
|
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" });
|
|
2994
|
+
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
2995
|
ScrollService.decorators = [
|
|
2905
2996
|
{ type: i0.Injectable, args: [{
|
|
2906
2997
|
providedIn: 'root',
|
|
@@ -2908,7 +2999,8 @@
|
|
|
2908
2999
|
];
|
|
2909
3000
|
ScrollService.ctorParameters = function () { return [
|
|
2910
3001
|
{ type: i1$2.Router },
|
|
2911
|
-
{ type: undefined, decorators: [{ type: i0.Inject, args: [BASE_MODULE_CONFIG,] }] }
|
|
3002
|
+
{ type: undefined, decorators: [{ type: i0.Inject, args: [BASE_MODULE_CONFIG,] }] },
|
|
3003
|
+
{ type: ImageService }
|
|
2912
3004
|
]; };
|
|
2913
3005
|
|
|
2914
3006
|
/**
|
|
@@ -2919,23 +3011,79 @@
|
|
|
2919
3011
|
this.titleService = titleService;
|
|
2920
3012
|
this.metaTagService = metaTagService;
|
|
2921
3013
|
}
|
|
2922
|
-
SEOService.prototype.initPageForSEO = function (
|
|
2923
|
-
this.
|
|
2924
|
-
this.
|
|
2925
|
-
|
|
2926
|
-
|
|
3014
|
+
SEOService.prototype.initPageForSEO = function (input) {
|
|
3015
|
+
this.setGeneralData(input);
|
|
3016
|
+
this.setTwitterData(input);
|
|
3017
|
+
this.setTwitterData(input);
|
|
3018
|
+
this.setFacebookData(input);
|
|
3019
|
+
if (input.keywords) {
|
|
3020
|
+
this.setPageKeywords(input.keywords);
|
|
2927
3021
|
}
|
|
2928
3022
|
};
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
3023
|
+
/**
|
|
3024
|
+
* Set general metadata
|
|
3025
|
+
*
|
|
3026
|
+
* @param data
|
|
3027
|
+
* @private
|
|
3028
|
+
*/
|
|
3029
|
+
SEOService.prototype.setGeneralData = function (data) {
|
|
3030
|
+
this.titleService.setTitle(data.title);
|
|
3031
|
+
this.metaTagService.updateTag({ name: 'description', content: data.description });
|
|
3032
|
+
};
|
|
3033
|
+
/**
|
|
3034
|
+
* Set metadata for twitter
|
|
3035
|
+
*
|
|
3036
|
+
* @param data
|
|
3037
|
+
* @private
|
|
3038
|
+
*/
|
|
3039
|
+
SEOService.prototype.setTwitterData = function (data) {
|
|
3040
|
+
this.metaTagService.updateTag({ name: 'twitter:title', content: data.title });
|
|
3041
|
+
this.metaTagService.updateTag({ name: 'twitter:description', content: data.description });
|
|
3042
|
+
this.metaTagService.updateTag({
|
|
3043
|
+
property: 'twitter:url',
|
|
3044
|
+
content: data.url ? data.url : window.location.href,
|
|
3045
|
+
});
|
|
3046
|
+
if (data.image) {
|
|
3047
|
+
this.metaTagService.updateTag({
|
|
3048
|
+
property: 'twitter:image',
|
|
3049
|
+
content: data.image,
|
|
3050
|
+
});
|
|
3051
|
+
this.metaTagService.updateTag({
|
|
3052
|
+
property: 'twitter:card',
|
|
3053
|
+
content: 'summary_large_image',
|
|
3054
|
+
});
|
|
3055
|
+
}
|
|
2933
3056
|
};
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
3057
|
+
/**
|
|
3058
|
+
* Set metadata for facebook
|
|
3059
|
+
*
|
|
3060
|
+
* @param data
|
|
3061
|
+
* @private
|
|
3062
|
+
*/
|
|
3063
|
+
SEOService.prototype.setFacebookData = function (data) {
|
|
3064
|
+
this.metaTagService.updateTag({ property: 'og:title', content: data.title });
|
|
3065
|
+
this.metaTagService.updateTag({ property: 'og:description', content: data.description });
|
|
3066
|
+
this.metaTagService.updateTag({
|
|
3067
|
+
property: 'og:type',
|
|
3068
|
+
content: 'website',
|
|
3069
|
+
});
|
|
3070
|
+
this.metaTagService.updateTag({
|
|
3071
|
+
property: 'og:url',
|
|
3072
|
+
content: data.url ? data.url : window.location.href,
|
|
3073
|
+
});
|
|
3074
|
+
if (data.image) {
|
|
3075
|
+
this.metaTagService.updateTag({
|
|
3076
|
+
property: 'og:image',
|
|
3077
|
+
content: data.image,
|
|
3078
|
+
});
|
|
3079
|
+
}
|
|
2938
3080
|
};
|
|
3081
|
+
/**
|
|
3082
|
+
* Set page keywords
|
|
3083
|
+
*
|
|
3084
|
+
* @param keywords
|
|
3085
|
+
* @private
|
|
3086
|
+
*/
|
|
2939
3087
|
SEOService.prototype.setPageKeywords = function (keywords) {
|
|
2940
3088
|
this.metaTagService.updateTag({ name: 'keywords', content: keywords });
|
|
2941
3089
|
};
|
|
@@ -2998,6 +3146,7 @@
|
|
|
2998
3146
|
exports.GraphQLService = GraphQLService;
|
|
2999
3147
|
exports.GraphQLType = GraphQLType;
|
|
3000
3148
|
exports.Helper = Helper;
|
|
3149
|
+
exports.ImageService = ImageService;
|
|
3001
3150
|
exports.LazyLoadDirective = LazyLoadDirective;
|
|
3002
3151
|
exports.LoaderService = LoaderService;
|
|
3003
3152
|
exports.LogoutGuard = LogoutGuard;
|