from gitlab
This commit is contained in:
112
common/resources/node_modules/angular-translate/dist/angular-translate-loader-static-files/angular-translate-loader-static-files.js
generated
vendored
Normal file
112
common/resources/node_modules/angular-translate/dist/angular-translate-loader-static-files/angular-translate-loader-static-files.js
generated
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
/*!
|
||||
* 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 () {
|
||||
|
||||
$translateStaticFilesLoader.$inject = ['$q', '$http'];
|
||||
angular.module('pascalprecht.translate')
|
||||
/**
|
||||
* @ngdoc object
|
||||
* @name pascalprecht.translate.$translateStaticFilesLoader
|
||||
* @requires $q
|
||||
* @requires $http
|
||||
*
|
||||
* @description
|
||||
* Creates a loading function for a typical static file url pattern:
|
||||
* "lang-en_US.json", "lang-de_DE.json", etc. Using this builder,
|
||||
* the response of these urls must be an object of key-value pairs.
|
||||
*
|
||||
* @param {object} options Options object, which gets prefix, suffix, key, and fileMap
|
||||
*/
|
||||
.factory('$translateStaticFilesLoader', $translateStaticFilesLoader);
|
||||
|
||||
function $translateStaticFilesLoader($q, $http) {
|
||||
|
||||
'use strict';
|
||||
|
||||
return function (options) {
|
||||
|
||||
if (!options || (!angular.isArray(options.files) && (!angular.isString(options.prefix) || !angular.isString(options.suffix)))) {
|
||||
throw new Error('Couldn\'t load static files, no files and prefix or suffix specified!');
|
||||
}
|
||||
|
||||
if (!options.files) {
|
||||
options.files = [{
|
||||
prefix: options.prefix,
|
||||
suffix: options.suffix
|
||||
}];
|
||||
}
|
||||
|
||||
var load = function (file) {
|
||||
if (!file || (!angular.isString(file.prefix) || !angular.isString(file.suffix))) {
|
||||
throw new Error('Couldn\'t load static file, no prefix or suffix specified!');
|
||||
}
|
||||
|
||||
var fileUrl = [
|
||||
file.prefix,
|
||||
options.key,
|
||||
file.suffix
|
||||
].join('');
|
||||
|
||||
if (angular.isObject(options.fileMap) && options.fileMap[fileUrl]) {
|
||||
fileUrl = options.fileMap[fileUrl];
|
||||
}
|
||||
|
||||
return $http(angular.extend({
|
||||
url: fileUrl,
|
||||
method: 'GET'
|
||||
}, options.$http))
|
||||
.then(function(result) {
|
||||
return result.data;
|
||||
}, function () {
|
||||
return $q.reject(options.key);
|
||||
});
|
||||
};
|
||||
|
||||
var promises = [],
|
||||
length = options.files.length;
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
promises.push(load({
|
||||
prefix: options.files[i].prefix,
|
||||
key: options.key,
|
||||
suffix: options.files[i].suffix
|
||||
}));
|
||||
}
|
||||
|
||||
return $q.all(promises)
|
||||
.then(function (data) {
|
||||
var length = data.length,
|
||||
mergedData = {};
|
||||
|
||||
for (var i = 0; i < length; i++) {
|
||||
for (var key in data[i]) {
|
||||
mergedData[key] = data[i][key];
|
||||
}
|
||||
}
|
||||
|
||||
return mergedData;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
$translateStaticFilesLoader.displayName = '$translateStaticFilesLoader';
|
||||
return 'pascalprecht.translate';
|
||||
|
||||
}));
|
@ -0,0 +1,6 @@
|
||||
/*!
|
||||
* angular-translate - v2.18.2 - 2020-01-04
|
||||
*
|
||||
* Copyright (c) 2020 The angular-translate team, Pascal Precht; Licensed MIT
|
||||
*/
|
||||
!function(e,i){"function"==typeof define&&define.amd?define([],function(){return i()}):"object"==typeof module&&module.exports?module.exports=i():i()}(0,function(){function e(n,a){"use strict";return function(r){if(!(r&&(angular.isArray(r.files)||angular.isString(r.prefix)&&angular.isString(r.suffix))))throw new Error("Couldn't load static files, no files and prefix or suffix specified!");r.files||(r.files=[{prefix:r.prefix,suffix:r.suffix}]);for(var e=function(e){if(!e||!angular.isString(e.prefix)||!angular.isString(e.suffix))throw new Error("Couldn't load static file, no prefix or suffix specified!");var i=[e.prefix,r.key,e.suffix].join("");return angular.isObject(r.fileMap)&&r.fileMap[i]&&(i=r.fileMap[i]),a(angular.extend({url:i,method:"GET"},r.$http)).then(function(e){return e.data},function(){return n.reject(r.key)})},i=[],t=r.files.length,f=0;f<t;f++)i.push(e({prefix:r.files[f].prefix,key:r.key,suffix:r.files[f].suffix}));return n.all(i).then(function(e){for(var i=e.length,r={},t=0;t<i;t++)for(var f in e[t])r[f]=e[t][f];return r})}}return e.$inject=["$q","$http"],angular.module("pascalprecht.translate").factory("$translateStaticFilesLoader",e),e.displayName="$translateStaticFilesLoader","pascalprecht.translate"});
|
Reference in New Issue
Block a user