123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- /**
- * Copyright © 2016-2019 Threema GmbH (https://threema.ch/).
- *
- * This file is part of Threema Web.
- *
- * Threema Web is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or (at
- * your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
- * General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with Threema Web. If not, see <http://www.gnu.org/licenses/>.
- */
- import {AsyncEvent} from 'ts-events';
- import './components';
- import config from './config';
- import './controllers';
- import './directives';
- import './filters';
- import './partials/messenger';
- import './partials/welcome';
- import './services';
- import './threema/container';
- // Configure asynchronous events
- AsyncEvent.setScheduler(function(callback) {
- // Replace the default setImmediate() call by a setTimeout(, 0) call
- setTimeout(callback, 0);
- });
- // Create app module and set dependencies
- angular.module('3ema', [
- // Angular
- 'ngAnimate',
- 'ngSanitize',
- 'ngAria',
- // 3rd party
- 'ui.router',
- 'angular-inview',
- 'monospaced.qrcode',
- 'luegg.directives',
- 'pascalprecht.translate',
- 'ngMaterial',
- // Own
- '3ema.filters',
- '3ema.components',
- '3ema.directives',
- '3ema.container',
- '3ema.services',
- '3ema.controllers',
- '3ema.welcome',
- '3ema.messenger',
- ])
- // Set versions
- .value('VERSION', config.VERSION)
- .value('PROTOCOL_VERSION', 2)
- // Configuration object
- .constant('CONFIG', config)
- // Set cache bust parameter
- .constant('CACHE_BUST', `v=${config.VERSION}`)
- // Constants to be used by controllers
- .constant('BROWSER_MIN_VERSIONS', {
- FF: 60,
- CHROME: 65,
- OPERA: 52,
- SAFARI: 11,
- })
- // Set default route
- .config(['$urlRouterProvider', ($urlRouterProvider) => {
- $urlRouterProvider.otherwise('/welcome');
- }])
- // Configure i18n / l10n
- .config(['$translateProvider', ($translateProvider: ng.translate.ITranslateProvider) => {
- $translateProvider.useSanitizeValueStrategy('sanitizeParameters');
- $translateProvider.useMessageFormatInterpolation();
- $translateProvider
- .useStaticFilesLoader({
- prefix: 'i18n/',
- suffix: '.json',
- })
- .uniformLanguageTag('java')
- .registerAvailableLanguageKeys(['cs', 'de', 'en', 'es', 'fr', 'nl', 'sk', 'uk', 'zh'], {
- 'cs_*': 'cs',
- 'de_*': 'de',
- 'en_*': 'en',
- 'es_*': 'es',
- 'fr_*': 'fr',
- 'nl_*': 'nl',
- 'sk_*': 'sk',
- 'uk_*': 'uk',
- 'zh_*': 'zh',
- })
- .determinePreferredLanguage()
- .fallbackLanguage('en');
- }])
- // Configure theme
- .config(['$mdThemingProvider', ($mdThemingProvider) => {
- $mdThemingProvider.definePalette('threema', {
- 50: 'f2faf5',
- 100: 'e6f6eb',
- 200: 'cdedd9',
- 300: 'b4e4c5',
- 400: '9bdbb2',
- 500: '82d29f',
- 600: '69ca8c',
- 700: '50c078',
- 800: '37b865',
- 900: '1eae52',
- A100: '05a63f',
- A200: '048432',
- A400: '03732b',
- A700: '036325',
- contrastDefaultColor: 'light',
- contrastDarkColors: ['50', '100', '200', '300', '400', '500', '600'],
- });
- $mdThemingProvider.theme('default')
- .primaryPalette('grey', {
- default: '800',
- })
- .accentPalette('threema', {
- default: 'A100',
- });
- }])
- // Optimizations: https://docs.angularjs.org/guide/production
- .config(['$compileProvider', ($compileProvider) => {
- // Disable debug info for improved performance
- // TODO: Somehow breaks overflow: scroll on chat window.
- // Comment for now.
- // $compileProvider.debugInfoEnabled(false);
- }])
- // Add cache busting parameter to some HTTP requests
- .config(['$httpProvider', ($httpProvider: ng.IHttpProvider) => {
- $httpProvider.interceptors.push(['CACHE_BUST', (CACHE_BUST: string) => {
- return {
- request: (conf) => {
- if (conf.url.indexOf('partials/') !== -1 ||
- conf.url.indexOf('directives/') !== -1 ||
- conf.url.indexOf('components/') !== -1 ||
- conf.url.indexOf('i18n/') !== -1) {
- const separator = conf.url.indexOf('?') === -1 ? '?' : '&';
- conf.url = conf.url + separator + CACHE_BUST;
- }
- return conf;
- },
- };
- }]);
- }])
- ;
|