mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-16 10:22:55 -05:00
init crater
This commit is contained in:
30
resources/assets/js/helpers/directives.js
Normal file
30
resources/assets/js/helpers/directives.js
Normal file
@@ -0,0 +1,30 @@
|
||||
Vue.directive('click-outside', {
|
||||
bind: function (el, binding, vnode) {
|
||||
el.event = function (event) {
|
||||
// here I check that click was outside the el and his childrens
|
||||
if (!(el === event.target || el.contains(event.target))) {
|
||||
// and if it did, call method provided in attribute value
|
||||
vnode.context[binding.expression](event)
|
||||
}
|
||||
}
|
||||
document.body.addEventListener('click', el.event)
|
||||
},
|
||||
unbind: function (el) {
|
||||
document.body.removeEventListener('click', el.event)
|
||||
}
|
||||
})
|
||||
|
||||
Vue.directive('autoresize', {
|
||||
inserted: function (el) {
|
||||
el.style.height = el.scrollHeight + 'px'
|
||||
el.style.overflow.y = 'hidden'
|
||||
el.style.resize = 'none'
|
||||
function OnInput () {
|
||||
this.style.height = 'auto'
|
||||
this.style.height = (this.scrollHeight) + 'px'
|
||||
this.scrollTop = this.scrollHeight
|
||||
window.scrollTo(window.scrollLeft, (this.scrollTop + this.scrollHeight))
|
||||
}
|
||||
el.addEventListener('input', OnInput, false)
|
||||
}
|
||||
})
|
||||
16
resources/assets/js/helpers/layout.js
Normal file
16
resources/assets/js/helpers/layout.js
Normal file
@@ -0,0 +1,16 @@
|
||||
export default {
|
||||
toggleSidebar () {
|
||||
var icon = $('.hamburger').first()
|
||||
$('body').toggleClass('sidebar-open')
|
||||
icon.toggleClass('is-active')
|
||||
},
|
||||
reset () {
|
||||
$('body').removeClass(function (index, css) {
|
||||
return (css.match(/(^|\s)layout-\S+/g) || []).join(' ')
|
||||
})
|
||||
},
|
||||
set (layoutName) {
|
||||
this.reset()
|
||||
$('body').addClass(layoutName)
|
||||
}
|
||||
}
|
||||
40
resources/assets/js/helpers/plugin.js
Normal file
40
resources/assets/js/helpers/plugin.js
Normal file
@@ -0,0 +1,40 @@
|
||||
export default {
|
||||
// EasyPieChart () {
|
||||
// var elems = $('.easy-pie-chart')
|
||||
// elems.each(function (index, element) {
|
||||
// var color = $(this).data('color') ? $(this).data('color') : '#ffde00'
|
||||
|
||||
// let myBarChart = new EasyPieChart(element, {
|
||||
// scaleColor: false,
|
||||
// barColor: color,
|
||||
// trackColor: '#f8f8f8',
|
||||
// size: 80,
|
||||
// onStep: function (from, to, percent) {
|
||||
// $(this.el).find('.percent').text(Math.round(percent))
|
||||
// }
|
||||
// })
|
||||
// })
|
||||
// },
|
||||
|
||||
Editors () {
|
||||
$('.ls-summernote').summernote()
|
||||
|
||||
var editor = $('.ls-simplemde')[0]
|
||||
|
||||
if (editor) {
|
||||
var simplemde = new SimpleMDE({ element: editor })
|
||||
}
|
||||
},
|
||||
initPlugins (plugins) {
|
||||
plugins.forEach((plugin) => {
|
||||
if (this.isFunction(this[plugin])) {
|
||||
this[plugin]()
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
isFunction (functionToCheck) {
|
||||
var getType = {}
|
||||
return functionToCheck && getType.toString.call(functionToCheck) === '[object Function]'
|
||||
}
|
||||
}
|
||||
91
resources/assets/js/helpers/utilities.js
Normal file
91
resources/assets/js/helpers/utilities.js
Normal file
@@ -0,0 +1,91 @@
|
||||
export default {
|
||||
toggleSidebar () {
|
||||
let icon = document.getElementsByClassName('hamburger')[0]
|
||||
document.body.classList.toggle('sidebar-open')
|
||||
icon.classList.toggle('is-active')
|
||||
},
|
||||
|
||||
addClass (el, className) {
|
||||
if (el.classList) el.classList.add(className)
|
||||
else el.className += ' ' + className
|
||||
},
|
||||
|
||||
hasClass (el, className) {
|
||||
const hasClass = el.classList
|
||||
? el.classList.contains(className)
|
||||
: new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className)
|
||||
|
||||
return hasClass
|
||||
},
|
||||
|
||||
reset (prefix) {
|
||||
let regx = new RegExp('\\b' + prefix + '(.*)?\\b', 'g')
|
||||
document.body.className = document.body.className.replace(regx, '')
|
||||
},
|
||||
|
||||
setLayout (layoutName) {
|
||||
this.reset('layout-')
|
||||
document.body.classList.add('layout-' + layoutName)
|
||||
},
|
||||
|
||||
setSkin (skinName) {
|
||||
this.reset('skin-')
|
||||
document.body.classList.add('skin-' + skinName)
|
||||
},
|
||||
|
||||
setLogo (logoSrc) {
|
||||
document.getElementById('logo-desk').src = logoSrc
|
||||
},
|
||||
|
||||
formatMoney (amount, currency = 0) {
|
||||
if (!currency) {
|
||||
currency = {precision: 2, thousand_separator: ',', decimal_separator: '.', symbol: '$'}
|
||||
}
|
||||
|
||||
amount = amount / 100
|
||||
|
||||
let {precision, decimal_separator, thousand_separator, symbol} = currency
|
||||
|
||||
try {
|
||||
precision = Math.abs(precision)
|
||||
precision = isNaN(precision) ? 2 : precision
|
||||
|
||||
const negativeSign = amount < 0 ? '-' : ''
|
||||
|
||||
let i = parseInt(amount = Math.abs(Number(amount) || 0).toFixed(precision)).toString()
|
||||
let j = (i.length > 3) ? i.length % 3 : 0
|
||||
|
||||
let moneySymbol = `<span style="font-family: sans-serif">${symbol}</span>`
|
||||
|
||||
return moneySymbol + ' ' + negativeSign + (j ? i.substr(0, j) + thousand_separator : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand_separator) + (precision ? decimal_separator + Math.abs(amount - i).toFixed(precision).slice(2) : '')
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
formatGraphMoney (amount, currency = 0) {
|
||||
if (!currency) {
|
||||
currency = {precision: 2, thousand_separator: ',', decimal_separator: '.', symbol: '$'}
|
||||
}
|
||||
|
||||
amount = amount / 100
|
||||
|
||||
let {precision, decimal_separator, thousand_separator, symbol} = currency
|
||||
|
||||
try {
|
||||
precision = Math.abs(precision)
|
||||
precision = isNaN(precision) ? 2 : precision
|
||||
|
||||
const negativeSign = amount < 0 ? '-' : ''
|
||||
|
||||
let i = parseInt(amount = Math.abs(Number(amount) || 0).toFixed(precision)).toString()
|
||||
let j = (i.length > 3) ? i.length % 3 : 0
|
||||
|
||||
let moneySymbol = `${symbol}`
|
||||
|
||||
return moneySymbol + ' ' + negativeSign + (j ? i.substr(0, j) + thousand_separator : '') + i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousand_separator) + (precision ? decimal_separator + Math.abs(amount - i).toFixed(precision).slice(2) : '')
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user