mirror of https://github.com/nocodb/nocodb
134 lines
4.6 KiB
134 lines
4.6 KiB
3 years ago
|
/* eslint-disable no-undef */
|
||
4 years ago
|
import Vue from 'vue'
|
||
3 years ago
|
import device from '../mixins/device'
|
||
4 years ago
|
|
||
3 years ago
|
Vue.mixin(device)
|
||
4 years ago
|
|
||
3 years ago
|
export default async({ store }) => {
|
||
|
function getListener(binding) {
|
||
|
return function(e) {
|
||
3 years ago
|
if (store.state.settings.isGaEnabled || store.state.settings.isComp) {
|
||
3 years ago
|
const cat = window.location.hash.replace(/\d+\/(?=dashboard)/, '')
|
||
|
const action = binding.value && binding.value[0]
|
||
|
const label = binding.value && binding.value[1]
|
||
4 years ago
|
try {
|
||
3 years ago
|
if (store.state.settings.isComp) {
|
||
|
ga('send', 'event', `${store.state.settings.isComp}\\${cat}`, action, label)
|
||
4 years ago
|
}
|
||
3 years ago
|
ga('send', 'event', cat, action, label)
|
||
3 years ago
|
} catch {}
|
||
4 years ago
|
}
|
||
3 years ago
|
}
|
||
4 years ago
|
}
|
||
|
|
||
|
Vue.directive('ge', {
|
||
3 years ago
|
bind(el, binding, vnode) {
|
||
4 years ago
|
if (vnode.componentInstance) {
|
||
3 years ago
|
vnode.componentInstance.$on('click', getListener(binding))
|
||
4 years ago
|
} else {
|
||
3 years ago
|
el.addEventListener('click', getListener(binding))
|
||
4 years ago
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
Vue.directive('xc-ver-resize', {
|
||
|
bind: (el, bindings, vnode) => {
|
||
|
// el.style.position = !el.style.position || el.style.position === 'static' ? 'relative' : el.style.position;
|
||
3 years ago
|
const resizer = document.createElement('div')
|
||
|
resizer.className = 'resizer'
|
||
|
resizer.style.position = 'absolute'
|
||
|
resizer.style.height = '100%'
|
||
|
resizer.style.width = '3px'
|
||
|
resizer.style.top = '0'
|
||
|
resizer.style.right = '-1px'
|
||
|
resizer.style.zIndex = '999'
|
||
4 years ago
|
|
||
3 years ago
|
el.appendChild(resizer)
|
||
|
resizer.addEventListener('mousedown', initDrag, false)
|
||
4 years ago
|
|
||
3 years ago
|
// eslint-disable-next-line no-unused-vars
|
||
|
let startX, startY, startWidth
|
||
4 years ago
|
|
||
3 years ago
|
function initDrag(e) {
|
||
3 years ago
|
document.body.style.cursor = 'col-resize'
|
||
|
resizer.classList.add('primary')
|
||
|
startX = e.clientX
|
||
|
startY = e.clientY
|
||
|
startWidth = parseInt(document.defaultView.getComputedStyle(el).width, 10)
|
||
4 years ago
|
// startHeight = parseInt(document.defaultView.getComputedStyle(p).height, 10);
|
||
3 years ago
|
document.documentElement.addEventListener('mousemove', doDrag, false)
|
||
|
document.documentElement.addEventListener('mouseup', stopDrag, false)
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
let width
|
||
4 years ago
|
const emit = (vnode, name, data) => {
|
||
|
const handlers = (vnode.data && vnode.data.on) ||
|
||
3 years ago
|
(vnode.componentOptions && vnode.componentOptions.listeners)
|
||
4 years ago
|
|
||
|
if (handlers && handlers[name]) {
|
||
3 years ago
|
handlers[name].fns(data)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
function doDrag(e) {
|
||
3 years ago
|
width = (startWidth + e.clientX - startX) + 'px'
|
||
3 years ago
|
el.style.width = width
|
||
3 years ago
|
emit(vnode, 'xcresizing', width)
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
function stopDrag(e) {
|
||
3 years ago
|
resizer.classList.remove('primary')
|
||
|
document.body.style.cursor = ''
|
||
|
document.documentElement.removeEventListener('mousemove', doDrag, false)
|
||
|
document.documentElement.removeEventListener('mouseup', stopDrag, false)
|
||
|
emit(vnode, 'xcresize', width)
|
||
|
emit(vnode, 'xcresized')
|
||
4 years ago
|
}
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|
||
|
/**
|
||
|
* @copyright Copyright (c) 2021, Xgene Cloud Ltd
|
||
|
*
|
||
|
* @author Naveen MR <oof1lab@gmail.com>
|
||
|
* @author Pranav C Balan <pranavxc@gmail.com>
|
||
|
*
|
||
|
* @license GNU AGPL version 3 or any later version
|
||
|
*
|
||
|
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*
|
||
|
*/
|