Skip to content

Instantly share code, notes, and snippets.

View adi518's full-sized avatar
🌴
On vacation

Adi adi518

🌴
On vacation
View GitHub Profile
<template>
<div :class="[namespace]">
</div>
</template>
<script>
// Abstract
import Component from '@/components/component'
// Components
export default {
install(Vue, options) {
Vue.prototype.$state = options.store.state
Vue.prototype.$getters = options.store.getters
Vue.prototype.$commit = options.store.commit
Vue.prototype.$dispatch = options.store.dispatch
}
}
export default {
install(Vue, options) {
Vue.prototype.$bus = options.EventBus
}
}
// http://wicky.nillia.ms/enquire.js/
// https://www.sitepoint.com/javascript-media-queries/
// https://modernweb.com/using-media-queries-in-javascript/
// https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia
// https://coderwall.com/p/i817wa/one-line-function-to-detect-mobile-devices-with-javascript
const generateDebounce = require('lodash.debounce')
export default {
install(Vue, options = {}) {
// Resources
import VeeValidate from 'vee-validate'
// Implementation
export default {
directives: {
validate: {
...VeeValidate.directive
}
},
@adi518
adi518 / Uppercase.vue
Last active January 20, 2018 17:50 — forked from bengry/Uppercase.vue
// Uppercase.vue
<template>
<div>
<slot v-bind="{style: style}" />
</div>
</template>
<script>
export default {
data() {
@adi518
adi518 / detectIe.js
Last active February 16, 2018 00:10
/* eslint-disable space-before-function-paren */
// As always with these things, YMMV. ;)
// https://github.com/stowball/Layout-Engine
// https://stackoverflow.com/a/14658198/4106263
// https://en.wikipedia.org/wiki/Internet_Explorer_version_history
// https://stackoverflow.com/questions/9900311/how-do-i-target-only-internet-explorer-10-for-certain-situations-like-internet-e/14916454#14916454
// Constants
const IE7_OR_LOWER = '<= 7'
// https://j11y.io/jquery/#v=git&fn=jQuery.fn.outerHeight
// https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop
// https://github.com/ramitos/dimensions/blob/master/src/dimensions.js
// https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
// https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect
export function isScrolled(el) {
return el.scrollTop + el.clientHeight === el.scrollHeight
// https://github.com/joyqi/mobile-device-js
// TODO: Add Android
// Constants
const DEVICES = {
'Apple A7 GPU': {
1136: ['iPhone 5', 'iPhone 5s'],
2048: ['iPad Air', 'iPad Mini 2', 'iPad Mini 3']
},
'Apple A8 GPU': {
// https://stackoverflow.com/questions/23757345/android-does-not-correctly-scroll-on-input-focus-if-not-body-element
export const androidScrollOnInputFocusPolyfill = () => {
if (document.activeElement.tagName === 'INPUT') {
window.setTimeout(function () {
document.activeElement.scrollIntoViewIfNeeded()
}, 0)
}
}