from gitlab
This commit is contained in:
585
common/resources/node_modules/angular-translate/dist/angular-translate-loader-partial/angular-translate-loader-partial.js
generated
vendored
Normal file
585
common/resources/node_modules/angular-translate/dist/angular-translate-loader-partial/angular-translate-loader-partial.js
generated
vendored
Normal file
@ -0,0 +1,585 @@
|
||||
/*!
|
||||
* angular-translate - v2.18.2 - 2020-01-04
|
||||
*
|
||||
* Copyright (c) 2020 The angular-translate team, Pascal Precht; Licensed MIT
|
||||
*/
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module unless amdModuleId is set
|
||||
define([], function () {
|
||||
return (factory());
|
||||
});
|
||||
} else if (typeof module === 'object' && module.exports) {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory();
|
||||
} else {
|
||||
factory();
|
||||
}
|
||||
}(this, function () {
|
||||
|
||||
angular.module('pascalprecht.translate')
|
||||
/**
|
||||
* @ngdoc object
|
||||
* @name pascalprecht.translate.$translatePartialLoaderProvider
|
||||
*
|
||||
* @description
|
||||
* By using a $translatePartialLoaderProvider you can configure a list of a needed
|
||||
* translation parts directly during the configuration phase of your application's
|
||||
* lifetime. All parts you add by using this provider would be loaded by
|
||||
* angular-translate at the startup as soon as possible.
|
||||
*/
|
||||
.provider('$translatePartialLoader', $translatePartialLoader);
|
||||
|
||||
function $translatePartialLoader() {
|
||||
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @name Part
|
||||
*
|
||||
* @description
|
||||
* Represents Part object to add and set parts at runtime.
|
||||
*/
|
||||
function Part(name, priority, urlTemplate) {
|
||||
this.name = name;
|
||||
this.isActive = true;
|
||||
this.tables = {};
|
||||
this.priority = priority || 0;
|
||||
this.langPromises = {};
|
||||
this.urlTemplate = urlTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name parseUrl
|
||||
* @method
|
||||
*
|
||||
* @description
|
||||
* Returns a parsed url template string and replaces given target lang
|
||||
* and part name it.
|
||||
*
|
||||
* @param {string|function} urlTemplate - Either a string containing an url pattern (with
|
||||
* '{part}' and '{lang}') or a function(part, lang)
|
||||
* returning a string.
|
||||
* @param {string} targetLang - Language key for language to be used.
|
||||
* @return {string} Parsed url template string
|
||||
*/
|
||||
Part.prototype.parseUrl = function (urlTemplate, targetLang) {
|
||||
if (angular.isFunction(urlTemplate)) {
|
||||
return urlTemplate(this.name, targetLang);
|
||||
}
|
||||
return urlTemplate.replace(/\{part\}/g, this.name).replace(/\{lang\}/g, targetLang);
|
||||
};
|
||||
|
||||
Part.prototype.getTable = function (lang, $q, $http, $httpOptions, urlTemplate, errorHandler) {
|
||||
|
||||
//locals
|
||||
var self = this;
|
||||
var lastLangPromise = this.langPromises[lang];
|
||||
var deferred = $q.defer();
|
||||
|
||||
//private helper helpers
|
||||
var fetchData = function () {
|
||||
return $http(
|
||||
angular.extend({
|
||||
method : 'GET',
|
||||
url : self.parseUrl(self.urlTemplate || urlTemplate, lang)
|
||||
},
|
||||
$httpOptions)
|
||||
);
|
||||
};
|
||||
|
||||
//private helper
|
||||
var handleNewData = function (data) {
|
||||
self.tables[lang] = data;
|
||||
deferred.resolve(data);
|
||||
};
|
||||
|
||||
//private helper
|
||||
var rejectDeferredWithPartName = function () {
|
||||
deferred.reject(self.name);
|
||||
};
|
||||
|
||||
//private helper
|
||||
var tryGettingThisTable = function () {
|
||||
//data fetching logic
|
||||
fetchData().then(
|
||||
function (result) {
|
||||
handleNewData(result.data);
|
||||
},
|
||||
function (errorResponse) {
|
||||
if (errorHandler) {
|
||||
errorHandler(self.name, lang, errorResponse).then(handleNewData, rejectDeferredWithPartName);
|
||||
} else {
|
||||
rejectDeferredWithPartName();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//loading logic
|
||||
if (!this.tables[lang]) {
|
||||
//let's try loading the data
|
||||
if (!lastLangPromise) {
|
||||
//this is the first request - just go ahead and hit the server
|
||||
tryGettingThisTable();
|
||||
} else {
|
||||
//this is an additional request after one or more unfinished or failed requests
|
||||
//chain the deferred off the previous request's promise so that this request conditionally executes
|
||||
//if the previous request succeeds then the result will be passed through, but if it fails then this request will try again and hit the server
|
||||
lastLangPromise.then(deferred.resolve, tryGettingThisTable);
|
||||
}
|
||||
//retain a reference to the last promise so we can continue the chain if another request is made before any succeed
|
||||
//you can picture the promise chain as a singly-linked list (formed by the .then handler queues) that's traversed by the execution context
|
||||
this.langPromises[lang] = deferred.promise;
|
||||
}
|
||||
else {
|
||||
//the part has already been loaded - if lastLangPromise is also undefined then the table has been populated using setPart
|
||||
//this breaks the promise chain because we're not tying langDeferred's outcome to a previous call's promise handler queues, but we don't care because there's no asynchronous execution context to keep track of anymore
|
||||
deferred.resolve(this.tables[lang]);
|
||||
}
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
var parts = {};
|
||||
|
||||
function hasPart(name) {
|
||||
return Object.prototype.hasOwnProperty.call(parts, name);
|
||||
}
|
||||
|
||||
function isStringValid(str) {
|
||||
return angular.isString(str) && str !== '';
|
||||
}
|
||||
|
||||
function isPartAvailable(name) {
|
||||
if (!isStringValid(name)) {
|
||||
throw new TypeError('Invalid type of a first argument, a non-empty string expected.');
|
||||
}
|
||||
|
||||
return (hasPart(name) && parts[name].isActive);
|
||||
}
|
||||
|
||||
function deepExtend(dst, src) {
|
||||
for (var property in src) {
|
||||
if (src[property] && src[property].constructor &&
|
||||
src[property].constructor === Object) {
|
||||
dst[property] = dst[property] || {};
|
||||
deepExtend(dst[property], src[property]);
|
||||
} else {
|
||||
dst[property] = src[property];
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
function getPrioritizedParts() {
|
||||
var prioritizedParts = [];
|
||||
for (var part in parts) {
|
||||
if (parts[part].isActive) {
|
||||
prioritizedParts.push(parts[part]);
|
||||
}
|
||||
}
|
||||
prioritizedParts.sort(function (a, b) {
|
||||
return a.priority - b.priority;
|
||||
});
|
||||
return prioritizedParts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoaderProvider#addPart
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider
|
||||
*
|
||||
* @description
|
||||
* Registers a new part of the translation table to be loaded once the
|
||||
* `angular-translate` gets into runtime phase. It does not actually load any
|
||||
* translation data, but only registers a part to be loaded in the future.
|
||||
*
|
||||
* @param {string} name A name of the part to add
|
||||
* @param {int} [priority=0] Sets the load priority of this part.
|
||||
* @param {string|function} urlTemplate Either a string containing an url pattern (with
|
||||
* '{part}' and '{lang}') or a function(part, lang)
|
||||
* returning a string.
|
||||
*
|
||||
* @returns {object} $translatePartialLoaderProvider, so this method is chainable
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param
|
||||
* of the wrong type. Please, note that the `name` param has to be a
|
||||
* non-empty **string**.
|
||||
*/
|
||||
this.addPart = function (name, priority, urlTemplate) {
|
||||
if (!isStringValid(name)) {
|
||||
throw new TypeError('Couldn\'t add part, part name has to be a string!');
|
||||
}
|
||||
|
||||
if (!hasPart(name)) {
|
||||
parts[name] = new Part(name, priority, urlTemplate);
|
||||
}
|
||||
parts[name].isActive = true;
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdocs function
|
||||
* @name pascalprecht.translate.$translatePartialLoaderProvider#setPart
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider
|
||||
*
|
||||
* @description
|
||||
* Sets a translation table to the specified part. This method does not make the
|
||||
* specified part available, but only avoids loading this part from the server.
|
||||
*
|
||||
* @param {string} lang A language of the given translation table
|
||||
* @param {string} part A name of the target part
|
||||
* @param {object} table A translation table to set to the specified part
|
||||
*
|
||||
* @return {object} $translatePartialLoaderProvider, so this method is chainable
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass params
|
||||
* of the wrong type. Please, note that the `lang` and `part` params have to be a
|
||||
* non-empty **string**s and the `table` param has to be an object.
|
||||
*/
|
||||
this.setPart = function (lang, part, table) {
|
||||
if (!isStringValid(lang)) {
|
||||
throw new TypeError('Couldn\'t set part.`lang` parameter has to be a string!');
|
||||
}
|
||||
if (!isStringValid(part)) {
|
||||
throw new TypeError('Couldn\'t set part.`part` parameter has to be a string!');
|
||||
}
|
||||
if (typeof table !== 'object' || table === null) {
|
||||
throw new TypeError('Couldn\'t set part. `table` parameter has to be an object!');
|
||||
}
|
||||
|
||||
if (!hasPart(part)) {
|
||||
parts[part] = new Part(part);
|
||||
parts[part].isActive = false;
|
||||
}
|
||||
|
||||
parts[part].tables[lang] = table;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoaderProvider#deletePart
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider
|
||||
*
|
||||
* @description
|
||||
* Removes the previously added part of the translation data. So, `angular-translate` will not
|
||||
* load it at the startup.
|
||||
*
|
||||
* @param {string} name A name of the part to delete
|
||||
*
|
||||
* @returns {object} $translatePartialLoaderProvider, so this method is chainable
|
||||
*
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong
|
||||
* type. Please, note that the `name` param has to be a non-empty **string**.
|
||||
*/
|
||||
this.deletePart = function (name) {
|
||||
if (!isStringValid(name)) {
|
||||
throw new TypeError('Couldn\'t delete part, first arg has to be string.');
|
||||
}
|
||||
|
||||
if (hasPart(name)) {
|
||||
parts[name].isActive = false;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoaderProvider#isPartAvailable
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoaderProvider
|
||||
*
|
||||
* @description
|
||||
* Checks if the specific part is available. A part becomes available after it was added by the
|
||||
* `addPart` method. Available parts would be loaded from the server once the `angular-translate`
|
||||
* asks the loader to that.
|
||||
*
|
||||
* @param {string} name A name of the part to check
|
||||
*
|
||||
* @returns {boolean} Returns **true** if the part is available now and **false** if not.
|
||||
*
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong
|
||||
* type. Please, note that the `name` param has to be a non-empty **string**.
|
||||
*/
|
||||
this.isPartAvailable = isPartAvailable;
|
||||
|
||||
/**
|
||||
* @ngdoc object
|
||||
* @name pascalprecht.translate.$translatePartialLoader
|
||||
*
|
||||
* @requires $q
|
||||
* @requires $http
|
||||
* @requires $injector
|
||||
* @requires $rootScope
|
||||
* @requires $translate
|
||||
*
|
||||
* @description
|
||||
*
|
||||
* @param {object} options Options object
|
||||
*
|
||||
* @throws {TypeError}
|
||||
*/
|
||||
this.$get = ['$rootScope', '$injector', '$q', '$http', '$log',
|
||||
function ($rootScope, $injector, $q, $http, $log) {
|
||||
|
||||
/**
|
||||
* @ngdoc event
|
||||
* @name pascalprecht.translate.$translatePartialLoader#$translatePartialLoaderStructureChanged
|
||||
* @eventOf pascalprecht.translate.$translatePartialLoader
|
||||
* @eventType broadcast on root scope
|
||||
*
|
||||
* @description
|
||||
* A $translatePartialLoaderStructureChanged event is called when a state of the loader was
|
||||
* changed somehow. It could mean either some part is added or some part is deleted. Anyway when
|
||||
* you get this event the translation table is not longer current and has to be updated.
|
||||
*
|
||||
* @param {string} name A name of the part which is a reason why the event was fired
|
||||
*/
|
||||
|
||||
var service = function (options) {
|
||||
if (!isStringValid(options.key)) {
|
||||
throw new TypeError('Unable to load data, a key is not a non-empty string.');
|
||||
}
|
||||
|
||||
if (!isStringValid(options.urlTemplate) && !angular.isFunction(options.urlTemplate)) {
|
||||
throw new TypeError('Unable to load data, a urlTemplate is not a non-empty string or not a function.');
|
||||
}
|
||||
|
||||
var errorHandler = options.loadFailureHandler;
|
||||
if (errorHandler !== undefined) {
|
||||
if (!angular.isString(errorHandler)) {
|
||||
throw new Error('Unable to load data, a loadFailureHandler is not a string.');
|
||||
} else {
|
||||
errorHandler = $injector.get(errorHandler);
|
||||
}
|
||||
}
|
||||
|
||||
var loaders = [],
|
||||
prioritizedParts = getPrioritizedParts();
|
||||
|
||||
angular.forEach(prioritizedParts, function (part) {
|
||||
loaders.push(
|
||||
part.getTable(options.key, $q, $http, options.$http, options.urlTemplate, errorHandler)
|
||||
);
|
||||
part.urlTemplate = part.urlTemplate || options.urlTemplate;
|
||||
});
|
||||
|
||||
// workaround for #1781
|
||||
var structureHasBeenChangedWhileLoading = false;
|
||||
var dirtyCheckEventCloser = $rootScope.$on('$translatePartialLoaderStructureChanged', function () {
|
||||
structureHasBeenChangedWhileLoading = true;
|
||||
});
|
||||
|
||||
return $q.all(loaders)
|
||||
.then(function () {
|
||||
dirtyCheckEventCloser();
|
||||
if (structureHasBeenChangedWhileLoading) {
|
||||
if (!options.__retries) {
|
||||
// the part structure has been changed while loading (the origin ones)
|
||||
// this can happen if an addPart/removePart has been invoked right after a $translate.use(lang)
|
||||
// TODO maybe we can optimize this with the actual list of missing parts
|
||||
options.__retries = (options.__retries || 0) + 1;
|
||||
return service(options);
|
||||
} else {
|
||||
// the part structure has been changed again while loading (retried one)
|
||||
// because this could an infinite loop, this will not load another one again
|
||||
$log.warn('The partial loader has detected a multiple structure change (with addPort/removePart) ' +
|
||||
'while loading translations. You should consider using promises of $translate.use(lang) and ' +
|
||||
'$translate.refresh(). Also parts should be added/removed right before an explicit refresh ' +
|
||||
'if possible.');
|
||||
}
|
||||
}
|
||||
var table = {};
|
||||
prioritizedParts = getPrioritizedParts();
|
||||
angular.forEach(prioritizedParts, function (part) {
|
||||
deepExtend(table, part.tables[options.key]);
|
||||
});
|
||||
return table;
|
||||
}, function () {
|
||||
dirtyCheckEventCloser();
|
||||
return $q.reject(options.key);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoader#addPart
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoader
|
||||
*
|
||||
* @description
|
||||
* Registers a new part of the translation table. This method does not actually perform any xhr
|
||||
* requests to get translation data. The new parts will be loaded in order of priority from the server next time
|
||||
* `angular-translate` asks the loader to load translations.
|
||||
*
|
||||
* @param {string} name A name of the part to add
|
||||
* @param {int} [priority=0] Sets the load priority of this part.
|
||||
*
|
||||
* @returns {object} $translatePartialLoader, so this method is chainable
|
||||
*
|
||||
* @fires {$translatePartialLoaderStructureChanged} The $translatePartialLoaderStructureChanged
|
||||
* event would be fired by this method in case the new part affected somehow on the loaders
|
||||
* state. This way it means that there are a new translation data available to be loaded from
|
||||
* the server.
|
||||
*
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong
|
||||
* type. Please, note that the `name` param has to be a non-empty **string**.
|
||||
*/
|
||||
service.addPart = function (name, priority, urlTemplate) {
|
||||
if (!isStringValid(name)) {
|
||||
throw new TypeError('Couldn\'t add part, first arg has to be a string');
|
||||
}
|
||||
|
||||
if (!hasPart(name)) {
|
||||
parts[name] = new Part(name, priority, urlTemplate);
|
||||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name);
|
||||
} else if (!parts[name].isActive) {
|
||||
parts[name].isActive = true;
|
||||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name);
|
||||
}
|
||||
|
||||
return service;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoader#deletePart
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoader
|
||||
*
|
||||
* @description
|
||||
* Deletes the previously added part of the translation data. The target part could be deleted
|
||||
* either logically or physically. When the data is deleted logically it is not actually deleted
|
||||
* from the browser, but the loader marks it as not active and prevents it from affecting on the
|
||||
* translations. If the deleted in such way part is added again, the loader will use the
|
||||
* previously loaded data rather than loading it from the server once more time. But if the data
|
||||
* is deleted physically, the loader will completely remove all information about it. So in case
|
||||
* of recycling this part will be loaded from the server again.
|
||||
*
|
||||
* @param {string} name A name of the part to delete
|
||||
* @param {boolean=} [removeData=false] An indicator if the loader has to remove a loaded
|
||||
* translation data physically. If the `removeData` if set to **false** the loaded data will not be
|
||||
* deleted physically and might be reused in the future to prevent an additional xhr requests.
|
||||
*
|
||||
* @returns {object} $translatePartialLoader, so this method is chainable
|
||||
*
|
||||
* @fires {$translatePartialLoaderStructureChanged} The $translatePartialLoaderStructureChanged
|
||||
* event would be fired by this method in case a part deletion process affects somehow on the
|
||||
* loaders state. This way it means that some part of the translation data is now deprecated and
|
||||
* the translation table has to be recompiled with the remaining translation parts.
|
||||
*
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass some param of the
|
||||
* wrong type. Please, note that the `name` param has to be a non-empty **string** and
|
||||
* the `removeData` param has to be either **undefined** or **boolean**.
|
||||
*/
|
||||
service.deletePart = function (name, removeData) {
|
||||
if (!isStringValid(name)) {
|
||||
throw new TypeError('Couldn\'t delete part, first arg has to be string');
|
||||
}
|
||||
|
||||
if (removeData === undefined) {
|
||||
removeData = false;
|
||||
} else if (typeof removeData !== 'boolean') {
|
||||
throw new TypeError('Invalid type of a second argument, a boolean expected.');
|
||||
}
|
||||
|
||||
if (hasPart(name)) {
|
||||
var wasActive = parts[name].isActive;
|
||||
if (removeData) {
|
||||
var $translate = $injector.get('$translate');
|
||||
var cache = $translate.loaderCache();
|
||||
if (typeof(cache) === 'string') {
|
||||
// getting on-demand instance of loader
|
||||
cache = $injector.get(cache);
|
||||
}
|
||||
// Purging items from cache...
|
||||
if (typeof(cache) === 'object') {
|
||||
angular.forEach(parts[name].tables, function (value, key) {
|
||||
cache.remove(parts[name].parseUrl(parts[name].urlTemplate, key));
|
||||
});
|
||||
}
|
||||
delete parts[name];
|
||||
} else {
|
||||
parts[name].isActive = false;
|
||||
}
|
||||
if (wasActive) {
|
||||
$rootScope.$emit('$translatePartialLoaderStructureChanged', name);
|
||||
}
|
||||
}
|
||||
|
||||
return service;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoader#isPartLoaded
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoader
|
||||
*
|
||||
* @description
|
||||
* Checks if the registered translation part is loaded into the translation table.
|
||||
*
|
||||
* @param {string} name A name of the part
|
||||
* @param {string} lang A key of the language
|
||||
*
|
||||
* @returns {boolean} Returns **true** if the translation of the part is loaded to the translation table and **false** if not.
|
||||
*
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong
|
||||
* type. Please, note that the `name` and `lang` params have to be non-empty **string**.
|
||||
*/
|
||||
service.isPartLoaded = function (name, lang) {
|
||||
return angular.isDefined(parts[name]) && angular.isDefined(parts[name].tables[lang]);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoader#getRegisteredParts
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoader
|
||||
*
|
||||
* @description
|
||||
* Gets names of the parts that were added with the `addPart`.
|
||||
*
|
||||
* @returns {array} Returns array of registered parts, if none were registered then an empty array is returned.
|
||||
*/
|
||||
service.getRegisteredParts = function () {
|
||||
var registeredParts = [];
|
||||
angular.forEach(parts, function (p) {
|
||||
if (p.isActive) {
|
||||
registeredParts.push(p.name);
|
||||
}
|
||||
});
|
||||
return registeredParts;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @ngdoc function
|
||||
* @name pascalprecht.translate.$translatePartialLoader#isPartAvailable
|
||||
* @methodOf pascalprecht.translate.$translatePartialLoader
|
||||
*
|
||||
* @description
|
||||
* Checks if a target translation part is available. The part becomes available just after it was
|
||||
* added by the `addPart` method. Part's availability does not mean that it was loaded from the
|
||||
* server, but only that it was added to the loader. The available part might be loaded next
|
||||
* time the loader is called.
|
||||
*
|
||||
* @param {string} name A name of the part to delete
|
||||
*
|
||||
* @returns {boolean} Returns **true** if the part is available now and **false** if not.
|
||||
*
|
||||
* @throws {TypeError} The method could throw a **TypeError** if you pass the param of the wrong
|
||||
* type. Please, note that the `name` param has to be a non-empty **string**.
|
||||
*/
|
||||
service.isPartAvailable = isPartAvailable;
|
||||
|
||||
return service;
|
||||
|
||||
}];
|
||||
|
||||
}
|
||||
|
||||
$translatePartialLoader.displayName = '$translatePartialLoader';
|
||||
return 'pascalprecht.translate';
|
||||
|
||||
}));
|
6
common/resources/node_modules/angular-translate/dist/angular-translate-loader-partial/angular-translate-loader-partial.min.js
generated
vendored
Normal file
6
common/resources/node_modules/angular-translate/dist/angular-translate-loader-partial/angular-translate-loader-partial.min.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* angular-translate - v2.18.2 - 2020-01-04
|
||||
*
|
||||
* Copyright (c) 2020 The angular-translate team, Pascal Precht; Licensed MIT
|
||||
*/
|
||||
!function(t,e){"function"==typeof define&&define.amd?define([],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():e()}(0,function(){function t(){"use strict";function a(t,e,r){this.name=t,this.isActive=!0,this.tables={},this.priority=e||0,this.langPromises={},this.urlTemplate=r}a.prototype.parseUrl=function(t,e){return angular.isFunction(t)?t(this.name,e):t.replace(/\{part\}/g,this.name).replace(/\{lang\}/g,e)},a.prototype.getTable=function(e,t,r,a,n,i){var o=this,s=this.langPromises[e],l=t.defer(),u=function(t){o.tables[e]=t,l.resolve(t)},c=function(){l.reject(o.name)},p=function(){r(angular.extend({method:"GET",url:o.parseUrl(o.urlTemplate||n,e)},a)).then(function(t){u(t.data)},function(t){i?i(o.name,e,t).then(u,c):c()})};return this.tables[e]?l.resolve(this.tables[e]):(s?s.then(l.resolve,p):p(),this.langPromises[e]=l.promise),l.promise};var n={};function i(t){return Object.prototype.hasOwnProperty.call(n,t)}function f(t){return angular.isString(t)&&""!==t}function t(t){if(!f(t))throw new TypeError("Invalid type of a first argument, a non-empty string expected.");return i(t)&&n[t].isActive}function d(){var t=[];for(var e in n)n[e].isActive&&t.push(n[e]);return t.sort(function(t,e){return t.priority-e.priority}),t}this.addPart=function(t,e,r){if(!f(t))throw new TypeError("Couldn't add part, part name has to be a string!");return i(t)||(n[t]=new a(t,e,r)),n[t].isActive=!0,this},this.setPart=function(t,e,r){if(!f(t))throw new TypeError("Couldn't set part.`lang` parameter has to be a string!");if(!f(e))throw new TypeError("Couldn't set part.`part` parameter has to be a string!");if("object"!=typeof r||null===r)throw new TypeError("Couldn't set part. `table` parameter has to be an object!");return i(e)||(n[e]=new a(e),n[e].isActive=!1),n[e].tables[t]=r,this},this.deletePart=function(t){if(!f(t))throw new TypeError("Couldn't delete part, first arg has to be string.");return i(t)&&(n[t].isActive=!1),this},this.isPartAvailable=t,this.$get=["$rootScope","$injector","$q","$http","$log",function(o,s,l,u,c){var p=function(r){if(!f(r.key))throw new TypeError("Unable to load data, a key is not a non-empty string.");if(!f(r.urlTemplate)&&!angular.isFunction(r.urlTemplate))throw new TypeError("Unable to load data, a urlTemplate is not a non-empty string or not a function.");var e=r.loadFailureHandler;if(void 0!==e){if(!angular.isString(e))throw new Error("Unable to load data, a loadFailureHandler is not a string.");e=s.get(e)}var a=[],t=d();angular.forEach(t,function(t){a.push(t.getTable(r.key,l,u,r.$http,r.urlTemplate,e)),t.urlTemplate=t.urlTemplate||r.urlTemplate});var n=!1,i=o.$on("$translatePartialLoaderStructureChanged",function(){n=!0});return l.all(a).then(function(){if(i(),n){if(!r.__retries)return r.__retries=(r.__retries||0)+1,p(r);c.warn("The partial loader has detected a multiple structure change (with addPort/removePart) while loading translations. You should consider using promises of $translate.use(lang) and $translate.refresh(). Also parts should be added/removed right before an explicit refresh if possible.")}var e={};return t=d(),angular.forEach(t,function(t){!function t(e,r){for(var a in r)r[a]&&r[a].constructor&&r[a].constructor===Object?(e[a]=e[a]||{},t(e[a],r[a])):e[a]=r[a];return e}(e,t.tables[r.key])}),e},function(){return i(),l.reject(r.key)})};return p.addPart=function(t,e,r){if(!f(t))throw new TypeError("Couldn't add part, first arg has to be a string");return i(t)?n[t].isActive||(n[t].isActive=!0,o.$emit("$translatePartialLoaderStructureChanged",t)):(n[t]=new a(t,e,r),o.$emit("$translatePartialLoaderStructureChanged",t)),p},p.deletePart=function(r,t){if(!f(r))throw new TypeError("Couldn't delete part, first arg has to be string");if(void 0===t)t=!1;else if("boolean"!=typeof t)throw new TypeError("Invalid type of a second argument, a boolean expected.");if(i(r)){var e=n[r].isActive;if(t){var a=s.get("$translate").loaderCache();"string"==typeof a&&(a=s.get(a)),"object"==typeof a&&angular.forEach(n[r].tables,function(t,e){a.remove(n[r].parseUrl(n[r].urlTemplate,e))}),delete n[r]}else n[r].isActive=!1;e&&o.$emit("$translatePartialLoaderStructureChanged",r)}return p},p.isPartLoaded=function(t,e){return angular.isDefined(n[t])&&angular.isDefined(n[t].tables[e])},p.getRegisteredParts=function(){var e=[];return angular.forEach(n,function(t){t.isActive&&e.push(t.name)}),e},p.isPartAvailable=t,p}]}return angular.module("pascalprecht.translate").provider("$translatePartialLoader",t),t.displayName="$translatePartialLoader","pascalprecht.translate"});
|
Reference in New Issue
Block a user