@pepperi-addons/ngx-lib 0.2.54 → 0.2.55
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/pepperi-addons-ngx-lib.umd.js +300 -253
- package/bundles/pepperi-addons-ngx-lib.umd.js.map +1 -1
- package/core/common/services/addon.service.d.ts +8 -3
- package/core/common/services/public-api.d.ts +1 -0
- package/core/common/services/translate.service.d.ts +9 -0
- package/esm2015/core/common/services/addon.service.js +36 -34
- package/esm2015/core/common/services/public-api.js +2 -1
- package/esm2015/core/common/services/translate.service.js +48 -0
- package/fesm2015/pepperi-addons-ngx-lib.js +285 -243
- package/fesm2015/pepperi-addons-ngx-lib.js.map +1 -1
- package/package.json +1 -1
- package/pepperi-addons-ngx-lib.metadata.json +1 -1
|
@@ -2040,6 +2040,227 @@
|
|
|
2040
2040
|
{ type: PepJwtHelperService }
|
|
2041
2041
|
]; };
|
|
2042
2042
|
|
|
2043
|
+
var PepFileService = /** @class */ (function () {
|
|
2044
|
+
function PepFileService() {
|
|
2045
|
+
this.scripts = new Map();
|
|
2046
|
+
this.styles = new Map();
|
|
2047
|
+
}
|
|
2048
|
+
PepFileService.prototype.loadFiles = function (files) {
|
|
2049
|
+
var _this = this;
|
|
2050
|
+
var promises = [];
|
|
2051
|
+
files.forEach(function (file) {
|
|
2052
|
+
if (file.type === 'style') {
|
|
2053
|
+
promises.push(_this.loadStyle(file.path));
|
|
2054
|
+
}
|
|
2055
|
+
else if (file.type === 'script') {
|
|
2056
|
+
promises.push(_this.loadScript(file.path));
|
|
2057
|
+
}
|
|
2058
|
+
});
|
|
2059
|
+
return Promise.all(promises);
|
|
2060
|
+
};
|
|
2061
|
+
PepFileService.prototype.removeFiles = function (files) {
|
|
2062
|
+
for (var index = 0; index < files.length &&
|
|
2063
|
+
files[index].path &&
|
|
2064
|
+
files[index].path.trim() !== ''; index++) {
|
|
2065
|
+
var name = this.getFileName(files[index].path, true);
|
|
2066
|
+
var element = document.getElementById(name);
|
|
2067
|
+
element.parentNode.removeChild(element);
|
|
2068
|
+
if (files[index].type === 'script' && this.scripts.has(name)) {
|
|
2069
|
+
this.scripts.delete(name);
|
|
2070
|
+
}
|
|
2071
|
+
else if (files[index].type === 'style' && this.styles.has(name)) {
|
|
2072
|
+
this.styles.delete(name);
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
2075
|
+
};
|
|
2076
|
+
PepFileService.prototype.loadScript = function (path) {
|
|
2077
|
+
var _this = this;
|
|
2078
|
+
return new Promise(function (resolve, reject) {
|
|
2079
|
+
var name = _this.getFileName(path, true);
|
|
2080
|
+
// If the script isn't exist add it.
|
|
2081
|
+
if (!_this.scripts.has(name)) {
|
|
2082
|
+
_this.scripts.set(name, { loaded: false, src: path });
|
|
2083
|
+
}
|
|
2084
|
+
var scriptItem = _this.scripts.get(name);
|
|
2085
|
+
// Resolve if already loaded
|
|
2086
|
+
if (scriptItem.loaded) {
|
|
2087
|
+
resolve({
|
|
2088
|
+
script: name,
|
|
2089
|
+
loaded: true,
|
|
2090
|
+
status: 'Already Loaded',
|
|
2091
|
+
});
|
|
2092
|
+
}
|
|
2093
|
+
else {
|
|
2094
|
+
// Load script
|
|
2095
|
+
var script_1 = document.createElement('script');
|
|
2096
|
+
script_1.type = 'text/javascript';
|
|
2097
|
+
script_1.src = scriptItem.src;
|
|
2098
|
+
script_1.setAttribute('id', name);
|
|
2099
|
+
script_1.async = false;
|
|
2100
|
+
if (script_1.readyState) {
|
|
2101
|
+
// IE
|
|
2102
|
+
script_1.onreadystatechange = function () {
|
|
2103
|
+
if (script_1.readyState === 'loaded' ||
|
|
2104
|
+
script_1.readyState === 'complete') {
|
|
2105
|
+
script_1.onreadystatechange = null;
|
|
2106
|
+
scriptItem.loaded = true;
|
|
2107
|
+
resolve({
|
|
2108
|
+
path: path,
|
|
2109
|
+
type: 'script',
|
|
2110
|
+
loaded: true,
|
|
2111
|
+
status: 'Loaded',
|
|
2112
|
+
});
|
|
2113
|
+
}
|
|
2114
|
+
};
|
|
2115
|
+
}
|
|
2116
|
+
else {
|
|
2117
|
+
// Others
|
|
2118
|
+
script_1.onload = function () {
|
|
2119
|
+
scriptItem.loaded = true;
|
|
2120
|
+
resolve({
|
|
2121
|
+
path: path,
|
|
2122
|
+
type: 'script',
|
|
2123
|
+
loaded: true,
|
|
2124
|
+
status: 'Loaded',
|
|
2125
|
+
});
|
|
2126
|
+
};
|
|
2127
|
+
}
|
|
2128
|
+
script_1.onerror = function (error) { return resolve({
|
|
2129
|
+
path: path,
|
|
2130
|
+
type: 'script',
|
|
2131
|
+
loaded: false,
|
|
2132
|
+
status: 'Loaded',
|
|
2133
|
+
}); };
|
|
2134
|
+
document.getElementsByTagName('head')[0].appendChild(script_1);
|
|
2135
|
+
}
|
|
2136
|
+
});
|
|
2137
|
+
};
|
|
2138
|
+
PepFileService.prototype.loadStyle = function (path) {
|
|
2139
|
+
var _this = this;
|
|
2140
|
+
return new Promise(function (resolve, reject) {
|
|
2141
|
+
var name = _this.getFileName(path, true);
|
|
2142
|
+
// If the style isn't exist add it.
|
|
2143
|
+
if (!_this.styles.has(name)) {
|
|
2144
|
+
_this.styles.set(name, { loaded: false, src: path });
|
|
2145
|
+
}
|
|
2146
|
+
var styleItem = _this.styles.get(name);
|
|
2147
|
+
// Resolve if already loaded
|
|
2148
|
+
if (styleItem.loaded) {
|
|
2149
|
+
resolve({
|
|
2150
|
+
path: path,
|
|
2151
|
+
type: 'style',
|
|
2152
|
+
loaded: true,
|
|
2153
|
+
status: 'Already Loaded',
|
|
2154
|
+
});
|
|
2155
|
+
}
|
|
2156
|
+
else {
|
|
2157
|
+
// Load style
|
|
2158
|
+
var style = document.createElement('link');
|
|
2159
|
+
style.type = 'text/css';
|
|
2160
|
+
style.rel = 'stylesheet';
|
|
2161
|
+
style.href = styleItem.src;
|
|
2162
|
+
style.media = 'all';
|
|
2163
|
+
style.setAttribute('id', name);
|
|
2164
|
+
styleItem.loaded = true;
|
|
2165
|
+
resolve({
|
|
2166
|
+
path: path,
|
|
2167
|
+
type: 'style',
|
|
2168
|
+
loaded: true,
|
|
2169
|
+
status: 'Loaded',
|
|
2170
|
+
});
|
|
2171
|
+
document.getElementsByTagName('head')[0].appendChild(style);
|
|
2172
|
+
}
|
|
2173
|
+
});
|
|
2174
|
+
};
|
|
2175
|
+
PepFileService.prototype.loadFontStyle = function (styleId, href) {
|
|
2176
|
+
var head = document.getElementsByTagName('head')[0];
|
|
2177
|
+
var styleElement = document.getElementById(styleId);
|
|
2178
|
+
if (styleElement) {
|
|
2179
|
+
styleElement.href = href;
|
|
2180
|
+
}
|
|
2181
|
+
else {
|
|
2182
|
+
var style = document.createElement('link');
|
|
2183
|
+
style.id = styleId;
|
|
2184
|
+
style.rel = 'stylesheet';
|
|
2185
|
+
style.href = "" + href;
|
|
2186
|
+
head.appendChild(style);
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
PepFileService.prototype.getFileName = function (filePath, withExtenstion) {
|
|
2190
|
+
if (withExtenstion === void 0) { withExtenstion = false; }
|
|
2191
|
+
var lastIndex = withExtenstion
|
|
2192
|
+
? filePath.length - 1
|
|
2193
|
+
: filePath.lastIndexOf('.');
|
|
2194
|
+
return filePath.substr(filePath.lastIndexOf('/') + 1, lastIndex);
|
|
2195
|
+
};
|
|
2196
|
+
PepFileService.prototype.getFileExtension = function (filePath) {
|
|
2197
|
+
var fileSplit = filePath.split('.');
|
|
2198
|
+
var fileExt = '';
|
|
2199
|
+
if (fileSplit.length > 1) {
|
|
2200
|
+
fileExt = fileSplit[fileSplit.length - 2];
|
|
2201
|
+
}
|
|
2202
|
+
return fileExt;
|
|
2203
|
+
};
|
|
2204
|
+
/* Returns true if url is valid */
|
|
2205
|
+
PepFileService.prototype.isValidUrl = function (url) {
|
|
2206
|
+
/* Try creating a valid URL */
|
|
2207
|
+
try {
|
|
2208
|
+
var tmp = new URL(url);
|
|
2209
|
+
return true;
|
|
2210
|
+
}
|
|
2211
|
+
catch (e) {
|
|
2212
|
+
return false;
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
PepFileService.prototype.convertFromb64toBlob = function (b64Data, contentType, sliceSize) {
|
|
2216
|
+
if (contentType === void 0) { contentType = ''; }
|
|
2217
|
+
if (sliceSize === void 0) { sliceSize = 512; }
|
|
2218
|
+
var byteCharacters = atob(b64Data);
|
|
2219
|
+
var byteArrays = [];
|
|
2220
|
+
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
2221
|
+
var slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
2222
|
+
var byteNumbers = new Array(slice.length);
|
|
2223
|
+
for (var i = 0; i < slice.length; i++) {
|
|
2224
|
+
byteNumbers[i] = slice.charCodeAt(i);
|
|
2225
|
+
}
|
|
2226
|
+
var byteArray = new Uint8Array(byteNumbers);
|
|
2227
|
+
byteArrays.push(byteArray);
|
|
2228
|
+
}
|
|
2229
|
+
var blob = new Blob(byteArrays, { type: contentType });
|
|
2230
|
+
return blob;
|
|
2231
|
+
};
|
|
2232
|
+
PepFileService.prototype.getAssetsPath = function (assetsDomain) {
|
|
2233
|
+
if (assetsDomain === void 0) { assetsDomain = ''; }
|
|
2234
|
+
var concatChar = assetsDomain === '' || assetsDomain.endsWith('/') ? '' : '/';
|
|
2235
|
+
return "" + assetsDomain + concatChar + "assets/ngx-lib/";
|
|
2236
|
+
};
|
|
2237
|
+
PepFileService.prototype.getAssetsTranslationsSuffix = function () {
|
|
2238
|
+
return '.ngx-lib.json';
|
|
2239
|
+
};
|
|
2240
|
+
PepFileService.prototype.getAssetsTranslationsPath = function (assetsDomain) {
|
|
2241
|
+
if (assetsDomain === void 0) { assetsDomain = ''; }
|
|
2242
|
+
return this.getAssetsPath(assetsDomain) + "i18n/";
|
|
2243
|
+
};
|
|
2244
|
+
PepFileService.prototype.getAssetsImagesPath = function (assetsDomain, image) {
|
|
2245
|
+
if (assetsDomain === void 0) { assetsDomain = ''; }
|
|
2246
|
+
if (image === void 0) { image = ''; }
|
|
2247
|
+
return this.getAssetsPath(assetsDomain) + "images/" + image;
|
|
2248
|
+
};
|
|
2249
|
+
PepFileService.prototype.getSvgAsImageSrc = function (svg) {
|
|
2250
|
+
var blob = new Blob([svg], { type: 'image/svg+xml' });
|
|
2251
|
+
var url = URL.createObjectURL(blob);
|
|
2252
|
+
return url;
|
|
2253
|
+
};
|
|
2254
|
+
return PepFileService;
|
|
2255
|
+
}());
|
|
2256
|
+
PepFileService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PepFileService_Factory() { return new PepFileService(); }, token: PepFileService, providedIn: "root" });
|
|
2257
|
+
PepFileService.decorators = [
|
|
2258
|
+
{ type: i0.Injectable, args: [{
|
|
2259
|
+
providedIn: 'root',
|
|
2260
|
+
},] }
|
|
2261
|
+
];
|
|
2262
|
+
PepFileService.ctorParameters = function () { return []; };
|
|
2263
|
+
|
|
2043
2264
|
var PepCookieService = /** @class */ (function () {
|
|
2044
2265
|
function PepCookieService(document, platformId) {
|
|
2045
2266
|
this.document = document;
|
|
@@ -2350,14 +2571,61 @@
|
|
|
2350
2571
|
{ type: i3.HttpClient }
|
|
2351
2572
|
]; };
|
|
2352
2573
|
|
|
2574
|
+
/*
|
|
2575
|
+
This service is the webapp api for addon usege.
|
|
2576
|
+
*/
|
|
2577
|
+
var PepTranslateService = /** @class */ (function () {
|
|
2578
|
+
function PepTranslateService(http
|
|
2579
|
+
// private sessionService: PepSessionService,
|
|
2580
|
+
// private httpService: PepHttpService,
|
|
2581
|
+
// private loaderService: PepLoaderService
|
|
2582
|
+
) {
|
|
2583
|
+
this.http = http;
|
|
2584
|
+
//
|
|
2585
|
+
}
|
|
2586
|
+
PepTranslateService.prototype.createMultiTranslateLoader = function (resources) {
|
|
2587
|
+
return new ngxTranslateMultiHttpLoader.MultiTranslateHttpLoader(this.http, resources);
|
|
2588
|
+
};
|
|
2589
|
+
PepTranslateService.prototype.setDefaultTranslateLang = function (translate, urlLangParam) {
|
|
2590
|
+
if (urlLangParam === void 0) { urlLangParam = 'userLang'; }
|
|
2591
|
+
var userLang = 'en';
|
|
2592
|
+
translate.setDefaultLang(userLang);
|
|
2593
|
+
userLang = translate.getBrowserLang().split('-')[0]; // use navigator lang if available
|
|
2594
|
+
if (urlLangParam.length > 0) {
|
|
2595
|
+
var index = location.href.indexOf(urlLangParam);
|
|
2596
|
+
if (index > -1) {
|
|
2597
|
+
// urlLangParam=XX
|
|
2598
|
+
var startIndex = index + urlLangParam.length + '='.length;
|
|
2599
|
+
userLang = location.href.substring(startIndex, startIndex + 2);
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
// the lang to use, if the lang isn't available, it will use the current loader to get them
|
|
2603
|
+
translate.use(userLang).subscribe(function (res) {
|
|
2604
|
+
// In here you can put the code you want. At this point the lang will be loaded
|
|
2605
|
+
});
|
|
2606
|
+
};
|
|
2607
|
+
return PepTranslateService;
|
|
2608
|
+
}());
|
|
2609
|
+
PepTranslateService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PepTranslateService_Factory() { return new PepTranslateService(i0__namespace.ɵɵinject(i3__namespace.HttpClient)); }, token: PepTranslateService, providedIn: "root" });
|
|
2610
|
+
PepTranslateService.decorators = [
|
|
2611
|
+
{ type: i0.Injectable, args: [{
|
|
2612
|
+
providedIn: 'root',
|
|
2613
|
+
},] }
|
|
2614
|
+
];
|
|
2615
|
+
PepTranslateService.ctorParameters = function () { return [
|
|
2616
|
+
{ type: i3.HttpClient }
|
|
2617
|
+
]; };
|
|
2618
|
+
|
|
2353
2619
|
/*
|
|
2354
2620
|
This service is the webapp api for addon usege.
|
|
2355
2621
|
*/
|
|
2356
2622
|
var PepAddonService = /** @class */ (function () {
|
|
2357
|
-
function PepAddonService(sessionService, httpService, loaderService) {
|
|
2623
|
+
function PepAddonService(sessionService, httpService, loaderService, translateService, fileService) {
|
|
2358
2624
|
this.sessionService = sessionService;
|
|
2359
2625
|
this.httpService = httpService;
|
|
2360
2626
|
this.loaderService = loaderService;
|
|
2627
|
+
this.translateService = translateService;
|
|
2628
|
+
this.fileService = fileService;
|
|
2361
2629
|
this.ADDON_ASSETS_PATH_KEY = 'AddonAssetsPath';
|
|
2362
2630
|
this.ADDONS_DICTIONARY_ASSETS_PATH_KEY = 'AddonsDictionaryAssetsPath';
|
|
2363
2631
|
this.ADDON_API_RELATIVE_PATH = '/addons/api';
|
|
@@ -2410,44 +2678,41 @@
|
|
|
2410
2678
|
_this.loaderService.hide();
|
|
2411
2679
|
});
|
|
2412
2680
|
};
|
|
2413
|
-
PepAddonService.
|
|
2681
|
+
PepAddonService.prototype.getNgxLibTranslationResource = function (subAddonUUID) {
|
|
2682
|
+
if (subAddonUUID === void 0) { subAddonUUID = ''; }
|
|
2683
|
+
var addonStaticFolder = this.getAddonStaticFolder(subAddonUUID);
|
|
2684
|
+
var translationsPath = this.fileService.getAssetsTranslationsPath(addonStaticFolder);
|
|
2685
|
+
var translationsSuffix = this.fileService.getAssetsTranslationsSuffix();
|
|
2686
|
+
return {
|
|
2687
|
+
prefix: translationsPath,
|
|
2688
|
+
suffix: translationsSuffix,
|
|
2689
|
+
};
|
|
2690
|
+
};
|
|
2691
|
+
PepAddonService.prototype.getAddonTranslationResource = function (subAddonUUID) {
|
|
2414
2692
|
if (subAddonUUID === void 0) { subAddonUUID = ''; }
|
|
2415
|
-
var addonStaticFolder =
|
|
2416
|
-
var translationsPath = fileService.getAssetsTranslationsPath(addonStaticFolder);
|
|
2417
|
-
var translationsSuffix = fileService.getAssetsTranslationsSuffix();
|
|
2693
|
+
var addonStaticFolder = this.getAddonStaticFolder(subAddonUUID);
|
|
2418
2694
|
var defaultSubFolder = 'assets/i18n/';
|
|
2419
|
-
return
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
},
|
|
2424
|
-
{
|
|
2425
|
-
prefix: addonStaticFolder.length > 0 ? "" + addonStaticFolder + defaultSubFolder : "/" + defaultSubFolder,
|
|
2426
|
-
suffix: '.json',
|
|
2427
|
-
},
|
|
2428
|
-
]);
|
|
2695
|
+
return {
|
|
2696
|
+
prefix: addonStaticFolder.length > 0 ? "" + addonStaticFolder + defaultSubFolder : "/" + defaultSubFolder,
|
|
2697
|
+
suffix: '.json',
|
|
2698
|
+
};
|
|
2429
2699
|
};
|
|
2430
2700
|
PepAddonService.prototype.setDefaultTranslateLang = function (translate, urlLangParam) {
|
|
2431
2701
|
if (urlLangParam === void 0) { urlLangParam = 'userLang'; }
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
if (
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
}
|
|
2443
|
-
// the lang to use, if the lang isn't available, it will use the current loader to get them
|
|
2444
|
-
translate.use(userLang).subscribe(function (res) {
|
|
2445
|
-
// In here you can put the code you want. At this point the lang will be loaded
|
|
2446
|
-
});
|
|
2702
|
+
this.translateService.setDefaultTranslateLang(translate, urlLangParam);
|
|
2703
|
+
};
|
|
2704
|
+
PepAddonService.createDefaultMultiTranslateLoader = function (http, fileService, addonService, subAddonUUID) {
|
|
2705
|
+
if (subAddonUUID === void 0) { subAddonUUID = ''; }
|
|
2706
|
+
var ngxLibTranslationResource = addonService.getNgxLibTranslationResource(subAddonUUID);
|
|
2707
|
+
var addonTranslationResource = addonService.getAddonTranslationResource(subAddonUUID);
|
|
2708
|
+
return addonService.translateService.createMultiTranslateLoader([
|
|
2709
|
+
ngxLibTranslationResource,
|
|
2710
|
+
addonTranslationResource
|
|
2711
|
+
]);
|
|
2447
2712
|
};
|
|
2448
2713
|
return PepAddonService;
|
|
2449
2714
|
}());
|
|
2450
|
-
PepAddonService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PepAddonService_Factory() { return new PepAddonService(i0__namespace.ɵɵinject(PepSessionService), i0__namespace.ɵɵinject(PepHttpService), i0__namespace.ɵɵinject(PepLoaderService)); }, token: PepAddonService, providedIn: "root" });
|
|
2715
|
+
PepAddonService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PepAddonService_Factory() { return new PepAddonService(i0__namespace.ɵɵinject(PepSessionService), i0__namespace.ɵɵinject(PepHttpService), i0__namespace.ɵɵinject(PepLoaderService), i0__namespace.ɵɵinject(PepTranslateService), i0__namespace.ɵɵinject(PepFileService)); }, token: PepAddonService, providedIn: "root" });
|
|
2451
2716
|
PepAddonService.decorators = [
|
|
2452
2717
|
{ type: i0.Injectable, args: [{
|
|
2453
2718
|
providedIn: 'root',
|
|
@@ -2456,7 +2721,9 @@
|
|
|
2456
2721
|
PepAddonService.ctorParameters = function () { return [
|
|
2457
2722
|
{ type: PepSessionService },
|
|
2458
2723
|
{ type: PepHttpService },
|
|
2459
|
-
{ type: PepLoaderService }
|
|
2724
|
+
{ type: PepLoaderService },
|
|
2725
|
+
{ type: PepTranslateService },
|
|
2726
|
+
{ type: PepFileService }
|
|
2460
2727
|
]; };
|
|
2461
2728
|
|
|
2462
2729
|
var PepColorService = /** @class */ (function () {
|
|
@@ -2921,227 +3188,6 @@
|
|
|
2921
3188
|
},] }
|
|
2922
3189
|
];
|
|
2923
3190
|
|
|
2924
|
-
var PepFileService = /** @class */ (function () {
|
|
2925
|
-
function PepFileService() {
|
|
2926
|
-
this.scripts = new Map();
|
|
2927
|
-
this.styles = new Map();
|
|
2928
|
-
}
|
|
2929
|
-
PepFileService.prototype.loadFiles = function (files) {
|
|
2930
|
-
var _this = this;
|
|
2931
|
-
var promises = [];
|
|
2932
|
-
files.forEach(function (file) {
|
|
2933
|
-
if (file.type === 'style') {
|
|
2934
|
-
promises.push(_this.loadStyle(file.path));
|
|
2935
|
-
}
|
|
2936
|
-
else if (file.type === 'script') {
|
|
2937
|
-
promises.push(_this.loadScript(file.path));
|
|
2938
|
-
}
|
|
2939
|
-
});
|
|
2940
|
-
return Promise.all(promises);
|
|
2941
|
-
};
|
|
2942
|
-
PepFileService.prototype.removeFiles = function (files) {
|
|
2943
|
-
for (var index = 0; index < files.length &&
|
|
2944
|
-
files[index].path &&
|
|
2945
|
-
files[index].path.trim() !== ''; index++) {
|
|
2946
|
-
var name = this.getFileName(files[index].path, true);
|
|
2947
|
-
var element = document.getElementById(name);
|
|
2948
|
-
element.parentNode.removeChild(element);
|
|
2949
|
-
if (files[index].type === 'script' && this.scripts.has(name)) {
|
|
2950
|
-
this.scripts.delete(name);
|
|
2951
|
-
}
|
|
2952
|
-
else if (files[index].type === 'style' && this.styles.has(name)) {
|
|
2953
|
-
this.styles.delete(name);
|
|
2954
|
-
}
|
|
2955
|
-
}
|
|
2956
|
-
};
|
|
2957
|
-
PepFileService.prototype.loadScript = function (path) {
|
|
2958
|
-
var _this = this;
|
|
2959
|
-
return new Promise(function (resolve, reject) {
|
|
2960
|
-
var name = _this.getFileName(path, true);
|
|
2961
|
-
// If the script isn't exist add it.
|
|
2962
|
-
if (!_this.scripts.has(name)) {
|
|
2963
|
-
_this.scripts.set(name, { loaded: false, src: path });
|
|
2964
|
-
}
|
|
2965
|
-
var scriptItem = _this.scripts.get(name);
|
|
2966
|
-
// Resolve if already loaded
|
|
2967
|
-
if (scriptItem.loaded) {
|
|
2968
|
-
resolve({
|
|
2969
|
-
script: name,
|
|
2970
|
-
loaded: true,
|
|
2971
|
-
status: 'Already Loaded',
|
|
2972
|
-
});
|
|
2973
|
-
}
|
|
2974
|
-
else {
|
|
2975
|
-
// Load script
|
|
2976
|
-
var script_1 = document.createElement('script');
|
|
2977
|
-
script_1.type = 'text/javascript';
|
|
2978
|
-
script_1.src = scriptItem.src;
|
|
2979
|
-
script_1.setAttribute('id', name);
|
|
2980
|
-
script_1.async = false;
|
|
2981
|
-
if (script_1.readyState) {
|
|
2982
|
-
// IE
|
|
2983
|
-
script_1.onreadystatechange = function () {
|
|
2984
|
-
if (script_1.readyState === 'loaded' ||
|
|
2985
|
-
script_1.readyState === 'complete') {
|
|
2986
|
-
script_1.onreadystatechange = null;
|
|
2987
|
-
scriptItem.loaded = true;
|
|
2988
|
-
resolve({
|
|
2989
|
-
path: path,
|
|
2990
|
-
type: 'script',
|
|
2991
|
-
loaded: true,
|
|
2992
|
-
status: 'Loaded',
|
|
2993
|
-
});
|
|
2994
|
-
}
|
|
2995
|
-
};
|
|
2996
|
-
}
|
|
2997
|
-
else {
|
|
2998
|
-
// Others
|
|
2999
|
-
script_1.onload = function () {
|
|
3000
|
-
scriptItem.loaded = true;
|
|
3001
|
-
resolve({
|
|
3002
|
-
path: path,
|
|
3003
|
-
type: 'script',
|
|
3004
|
-
loaded: true,
|
|
3005
|
-
status: 'Loaded',
|
|
3006
|
-
});
|
|
3007
|
-
};
|
|
3008
|
-
}
|
|
3009
|
-
script_1.onerror = function (error) { return resolve({
|
|
3010
|
-
path: path,
|
|
3011
|
-
type: 'script',
|
|
3012
|
-
loaded: false,
|
|
3013
|
-
status: 'Loaded',
|
|
3014
|
-
}); };
|
|
3015
|
-
document.getElementsByTagName('head')[0].appendChild(script_1);
|
|
3016
|
-
}
|
|
3017
|
-
});
|
|
3018
|
-
};
|
|
3019
|
-
PepFileService.prototype.loadStyle = function (path) {
|
|
3020
|
-
var _this = this;
|
|
3021
|
-
return new Promise(function (resolve, reject) {
|
|
3022
|
-
var name = _this.getFileName(path, true);
|
|
3023
|
-
// If the style isn't exist add it.
|
|
3024
|
-
if (!_this.styles.has(name)) {
|
|
3025
|
-
_this.styles.set(name, { loaded: false, src: path });
|
|
3026
|
-
}
|
|
3027
|
-
var styleItem = _this.styles.get(name);
|
|
3028
|
-
// Resolve if already loaded
|
|
3029
|
-
if (styleItem.loaded) {
|
|
3030
|
-
resolve({
|
|
3031
|
-
path: path,
|
|
3032
|
-
type: 'style',
|
|
3033
|
-
loaded: true,
|
|
3034
|
-
status: 'Already Loaded',
|
|
3035
|
-
});
|
|
3036
|
-
}
|
|
3037
|
-
else {
|
|
3038
|
-
// Load style
|
|
3039
|
-
var style = document.createElement('link');
|
|
3040
|
-
style.type = 'text/css';
|
|
3041
|
-
style.rel = 'stylesheet';
|
|
3042
|
-
style.href = styleItem.src;
|
|
3043
|
-
style.media = 'all';
|
|
3044
|
-
style.setAttribute('id', name);
|
|
3045
|
-
styleItem.loaded = true;
|
|
3046
|
-
resolve({
|
|
3047
|
-
path: path,
|
|
3048
|
-
type: 'style',
|
|
3049
|
-
loaded: true,
|
|
3050
|
-
status: 'Loaded',
|
|
3051
|
-
});
|
|
3052
|
-
document.getElementsByTagName('head')[0].appendChild(style);
|
|
3053
|
-
}
|
|
3054
|
-
});
|
|
3055
|
-
};
|
|
3056
|
-
PepFileService.prototype.loadFontStyle = function (styleId, href) {
|
|
3057
|
-
var head = document.getElementsByTagName('head')[0];
|
|
3058
|
-
var styleElement = document.getElementById(styleId);
|
|
3059
|
-
if (styleElement) {
|
|
3060
|
-
styleElement.href = href;
|
|
3061
|
-
}
|
|
3062
|
-
else {
|
|
3063
|
-
var style = document.createElement('link');
|
|
3064
|
-
style.id = styleId;
|
|
3065
|
-
style.rel = 'stylesheet';
|
|
3066
|
-
style.href = "" + href;
|
|
3067
|
-
head.appendChild(style);
|
|
3068
|
-
}
|
|
3069
|
-
};
|
|
3070
|
-
PepFileService.prototype.getFileName = function (filePath, withExtenstion) {
|
|
3071
|
-
if (withExtenstion === void 0) { withExtenstion = false; }
|
|
3072
|
-
var lastIndex = withExtenstion
|
|
3073
|
-
? filePath.length - 1
|
|
3074
|
-
: filePath.lastIndexOf('.');
|
|
3075
|
-
return filePath.substr(filePath.lastIndexOf('/') + 1, lastIndex);
|
|
3076
|
-
};
|
|
3077
|
-
PepFileService.prototype.getFileExtension = function (filePath) {
|
|
3078
|
-
var fileSplit = filePath.split('.');
|
|
3079
|
-
var fileExt = '';
|
|
3080
|
-
if (fileSplit.length > 1) {
|
|
3081
|
-
fileExt = fileSplit[fileSplit.length - 2];
|
|
3082
|
-
}
|
|
3083
|
-
return fileExt;
|
|
3084
|
-
};
|
|
3085
|
-
/* Returns true if url is valid */
|
|
3086
|
-
PepFileService.prototype.isValidUrl = function (url) {
|
|
3087
|
-
/* Try creating a valid URL */
|
|
3088
|
-
try {
|
|
3089
|
-
var tmp = new URL(url);
|
|
3090
|
-
return true;
|
|
3091
|
-
}
|
|
3092
|
-
catch (e) {
|
|
3093
|
-
return false;
|
|
3094
|
-
}
|
|
3095
|
-
};
|
|
3096
|
-
PepFileService.prototype.convertFromb64toBlob = function (b64Data, contentType, sliceSize) {
|
|
3097
|
-
if (contentType === void 0) { contentType = ''; }
|
|
3098
|
-
if (sliceSize === void 0) { sliceSize = 512; }
|
|
3099
|
-
var byteCharacters = atob(b64Data);
|
|
3100
|
-
var byteArrays = [];
|
|
3101
|
-
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
|
3102
|
-
var slice = byteCharacters.slice(offset, offset + sliceSize);
|
|
3103
|
-
var byteNumbers = new Array(slice.length);
|
|
3104
|
-
for (var i = 0; i < slice.length; i++) {
|
|
3105
|
-
byteNumbers[i] = slice.charCodeAt(i);
|
|
3106
|
-
}
|
|
3107
|
-
var byteArray = new Uint8Array(byteNumbers);
|
|
3108
|
-
byteArrays.push(byteArray);
|
|
3109
|
-
}
|
|
3110
|
-
var blob = new Blob(byteArrays, { type: contentType });
|
|
3111
|
-
return blob;
|
|
3112
|
-
};
|
|
3113
|
-
PepFileService.prototype.getAssetsPath = function (assetsDomain) {
|
|
3114
|
-
if (assetsDomain === void 0) { assetsDomain = ''; }
|
|
3115
|
-
var concatChar = assetsDomain === '' || assetsDomain.endsWith('/') ? '' : '/';
|
|
3116
|
-
return "" + assetsDomain + concatChar + "assets/ngx-lib/";
|
|
3117
|
-
};
|
|
3118
|
-
PepFileService.prototype.getAssetsTranslationsSuffix = function () {
|
|
3119
|
-
return '.ngx-lib.json';
|
|
3120
|
-
};
|
|
3121
|
-
PepFileService.prototype.getAssetsTranslationsPath = function (assetsDomain) {
|
|
3122
|
-
if (assetsDomain === void 0) { assetsDomain = ''; }
|
|
3123
|
-
return this.getAssetsPath(assetsDomain) + "i18n/";
|
|
3124
|
-
};
|
|
3125
|
-
PepFileService.prototype.getAssetsImagesPath = function (assetsDomain, image) {
|
|
3126
|
-
if (assetsDomain === void 0) { assetsDomain = ''; }
|
|
3127
|
-
if (image === void 0) { image = ''; }
|
|
3128
|
-
return this.getAssetsPath(assetsDomain) + "images/" + image;
|
|
3129
|
-
};
|
|
3130
|
-
PepFileService.prototype.getSvgAsImageSrc = function (svg) {
|
|
3131
|
-
var blob = new Blob([svg], { type: 'image/svg+xml' });
|
|
3132
|
-
var url = URL.createObjectURL(blob);
|
|
3133
|
-
return url;
|
|
3134
|
-
};
|
|
3135
|
-
return PepFileService;
|
|
3136
|
-
}());
|
|
3137
|
-
PepFileService.ɵprov = i0__namespace.ɵɵdefineInjectable({ factory: function PepFileService_Factory() { return new PepFileService(); }, token: PepFileService, providedIn: "root" });
|
|
3138
|
-
PepFileService.decorators = [
|
|
3139
|
-
{ type: i0.Injectable, args: [{
|
|
3140
|
-
providedIn: 'root',
|
|
3141
|
-
},] }
|
|
3142
|
-
];
|
|
3143
|
-
PepFileService.ctorParameters = function () { return []; };
|
|
3144
|
-
|
|
3145
3191
|
var PepValidatorService = /** @class */ (function () {
|
|
3146
3192
|
function PepValidatorService(translate) {
|
|
3147
3193
|
if (translate === void 0) { translate = null; }
|
|
@@ -4860,6 +4906,7 @@
|
|
|
4860
4906
|
exports.PepTextareaField = PepTextareaField;
|
|
4861
4907
|
exports.PepTextboxField = PepTextboxField;
|
|
4862
4908
|
exports.PepToNumberPipe = PepToNumberPipe;
|
|
4909
|
+
exports.PepTranslateService = PepTranslateService;
|
|
4863
4910
|
exports.PepUtilitiesService = PepUtilitiesService;
|
|
4864
4911
|
exports.PepValidatorService = PepValidatorService;
|
|
4865
4912
|
exports.PepWindowScrollingService = PepWindowScrollingService;
|