2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-10-23 18:33:24 +01:00
|
|
|
import Vue, { VNode } from 'vue';
|
|
|
|
import { DirectiveBinding } from 'vue/types/options';
|
2019-09-09 11:33:39 +01:00
|
|
|
|
2019-10-28 17:33:06 +00:00
|
|
|
import { NotificatorPlugin } from '@/utils/plugins/notificator';
|
|
|
|
|
2018-11-05 15:26:18 +00:00
|
|
|
import App from './App.vue';
|
2019-10-28 13:27:12 +00:00
|
|
|
import { router } from './router';
|
|
|
|
import { store } from './store';
|
2018-11-05 15:26:18 +00:00
|
|
|
|
2019-07-30 11:13:24 +01:00
|
|
|
Vue.config.devtools = true;
|
|
|
|
Vue.config.performance = true;
|
2018-11-05 15:26:18 +00:00
|
|
|
Vue.config.productionTip = false;
|
|
|
|
|
2019-10-28 17:33:06 +00:00
|
|
|
const notificator = new NotificatorPlugin();
|
|
|
|
|
|
|
|
Vue.use(notificator);
|
|
|
|
|
2019-10-23 18:33:24 +01:00
|
|
|
let clickOutsideEvent: EventListener;
|
|
|
|
|
|
|
|
Vue.directive('click-outside', {
|
|
|
|
bind: function (el: HTMLElement, binding: DirectiveBinding, vnode: VNode) {
|
|
|
|
clickOutsideEvent = function(event: Event): void {
|
|
|
|
if (el === event.target) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vnode.context) {
|
|
|
|
vnode.context[binding.expression](event);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
document.body.addEventListener('click', clickOutsideEvent);
|
|
|
|
},
|
|
|
|
unbind: function(): void {
|
|
|
|
document.body.removeEventListener('click', clickOutsideEvent);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-11-25 12:59:41 +00:00
|
|
|
/**
|
|
|
|
* number directive allow user to type only numbers in input
|
|
|
|
*/
|
|
|
|
Vue.directive('number', {
|
|
|
|
bind (el: HTMLElement) {
|
|
|
|
el.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
|
|
const keyCode = parseInt(e.key);
|
|
|
|
|
|
|
|
if (!isNaN(keyCode) || e.key === 'Delete' || e.key === 'Backspace') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* leadingZero adds zero to the start of single digit number
|
|
|
|
*/
|
|
|
|
Vue.filter('leadingZero', function (value: number): string {
|
|
|
|
if (value <= 9) {
|
|
|
|
return `0${value}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
return `${value}`;
|
|
|
|
});
|
|
|
|
|
2019-11-20 13:46:22 +00:00
|
|
|
/**
|
|
|
|
* centsToDollars is a Vue filter that converts amount of cents in dollars string.
|
|
|
|
*/
|
|
|
|
Vue.filter('centsToDollars', (cents: number): string => {
|
|
|
|
return `$${(cents / 100).toFixed(2)}`;
|
|
|
|
});
|
|
|
|
|
2018-11-05 15:26:18 +00:00
|
|
|
new Vue({
|
2019-02-20 13:33:56 +00:00
|
|
|
router,
|
|
|
|
store,
|
|
|
|
render: (h) => h(App),
|
2018-11-05 15:26:18 +00:00
|
|
|
}).$mount('#app');
|