comparison client/src/main.js @ 2385:279334be495c

client: cleaned up main.js
author Markus Kottlaender <markus@intevation.de>
date Mon, 25 Feb 2019 14:20:50 +0100
parents 5176ea7fbc53
children f185503ef35a
comparison
equal deleted inserted replaced
2384:c06b001dc26b 2385:279334be495c
11 * Author(s): 11 * Author(s):
12 * Thomas Junk <thomas.junk@intevation.de> 12 * Thomas Junk <thomas.junk@intevation.de>
13 * Markus Kottländer <markus@intevation.de> 13 * Markus Kottländer <markus@intevation.de>
14 */ 14 */
15 15
16 // 3rd-party
16 import Vue from "vue"; 17 import Vue from "vue";
17 import App from "./components/App.vue"; 18 import App from "./components/App.vue";
19 import VTooltip from "v-tooltip";
20 import GetTextPlugin from "vue-gettext";
21 import Snotify, { SnotifyPosition } from "vue-snotify";
22 import VueClipboard from "vue-clipboard2";
23 import ToggleButton from "vue-js-toggle-button";
24 import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
25 import { library } from "@fortawesome/fontawesome-svg-core";
26
27 // local
18 import router from "./router"; 28 import router from "./router";
19 import store from "./store"; 29 import store from "./store";
20 import GetTextPlugin from "vue-gettext";
21 import translations from "./locale/translations.json"; 30 import translations from "./locale/translations.json";
22 import locale2 from "locale2"; 31 import { supportedLanguages, defaultLanguage } from "./locale/languages.js";
23 import Snotify, { SnotifyPosition } from "vue-snotify"; 32
33 // styles
24 import "../node_modules/bootstrap/dist/css/bootstrap.min.css"; 34 import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
25 import "../node_modules/animate.css/animate.min.css"; 35 import "../node_modules/animate.css/animate.min.css";
26 import "../node_modules/ol/ol.css"; 36 import "../node_modules/ol/ol.css";
27 import "../node_modules/highlight.js/styles/paraiso-dark.css"; 37 import "../node_modules/highlight.js/styles/paraiso-dark.css";
28 import "../node_modules/vue-snotify/styles/material.css"; 38 import "../node_modules/vue-snotify/styles/material.css";
29 import VTooltip from "v-tooltip"; 39
30 import { library } from "@fortawesome/fontawesome-svg-core"; 40 // fontawesome5 icons
31 import { 41 import {
32 faAngleDown, 42 faAngleDown,
33 faAngleLeft, 43 faAngleLeft,
34 faAngleRight, 44 faAngleRight,
35 faAngleUp, 45 faAngleUp,
76 faWater, 86 faWater,
77 faWrench, 87 faWrench,
78 faRedo 88 faRedo
79 } from "@fortawesome/free-solid-svg-icons"; 89 } from "@fortawesome/free-solid-svg-icons";
80 import { faAdn } from "@fortawesome/free-brands-svg-icons"; 90 import { faAdn } from "@fortawesome/free-brands-svg-icons";
81 import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
82 import VueClipboard from "vue-clipboard2";
83 91
84 library.add( 92 library.add(
85 faAdn, 93 faAdn,
86 faAngleDown, 94 faAngleDown,
87 faAngleLeft, 95 faAngleLeft,
129 faUsersCog, 137 faUsersCog,
130 faWater, 138 faWater,
131 faWrench, 139 faWrench,
132 faRedo 140 faRedo
133 ); 141 );
134 import ToggleButton from "vue-js-toggle-button";
135 142
136 Vue.use(ToggleButton); 143 // register plugins
137
138 Vue.component("font-awesome-icon", FontAwesomeIcon);
139
140 Vue.use(VTooltip);
141
142 const options = {
143 toast: {
144 position: SnotifyPosition.centerBottom
145 }
146 };
147
148 Vue.use(Snotify, options);
149
150 Vue.use(VueClipboard);
151
152 let browserLanguage = locale2;
153
154 // planned also RS, BiH, UA
155 const supportedLanguages = {
156 en_GB: "British English",
157 de_AT: "Deutsch",
158 sk_SK: "slovenčina",
159 hu_HU: "Magyar",
160 hr_HR: "Hrvatska",
161 bg_BG: "български",
162 ro_RO: "Română"
163 };
164
165 let isAvailableLanguage = Object.keys(supportedLanguages).filter(language => {
166 return browserLanguage.replace("-", "_") === language;
167 });
168
169 if (isAvailableLanguage.length === 0) {
170 isAvailableLanguage = Object.keys(supportedLanguages).filter(language => {
171 return language.substr(0, 2) === browserLanguage.substr(0, 2);
172 });
173 }
174
175 let defaultLanguage =
176 isAvailableLanguage.length > 0 ? isAvailableLanguage[0] : "en_GB";
177
178 Vue.use(GetTextPlugin, { 144 Vue.use(GetTextPlugin, {
179 translations: translations, 145 translations: translations,
180 availableLanguages: supportedLanguages, 146 availableLanguages: supportedLanguages,
181 defaultLanguage: defaultLanguage 147 defaultLanguage: defaultLanguage
182 }); 148 });
149 Vue.use(Snotify, { toast: { position: SnotifyPosition.centerBottom } });
150 Vue.use(ToggleButton);
151 Vue.use(VTooltip);
152 Vue.use(VueClipboard);
183 153
154 // register global components
155 Vue.component("font-awesome-icon", FontAwesomeIcon);
156
157 // global vue config
184 Vue.config.productionTip = false; 158 Vue.config.productionTip = false;
185 159
186 const app = new Vue({ 160 const app = new Vue({
187 router, 161 router,
188 store, 162 store,