UNPKG

quasar-framework

Version:

Simultaneously build desktop/mobile SPA websites & phone/tablet apps with VueJS

1,751 lines (1,533 loc) 212 kB
/*! * Quasar Framework v0.8.3 * (c) 2016 Razvan Stoenescu * Released under the MIT License. */ import Velocity$1 from 'velocity-animate'; import moment from 'moment'; import FastClick from 'fastclick'; /* istanbul ignore next */ function getUserAgent () { return (navigator.userAgent || navigator.vendor || window.opera).toLowerCase() } /* istanbul ignore next */ function getMatch (userAgent, platformMatch) { var match = /(edge)\/([\w.]+)/.exec(userAgent) || /(opr)[\/]([\w.]+)/.exec(userAgent) || /(vivaldi)[\/]([\w.]+)/.exec(userAgent) || /(chrome)[\/]([\w.]+)/.exec(userAgent) || /(iemobile)[\/]([\w.]+)/.exec(userAgent) || /(version)(applewebkit)[\/]([\w.]+).*(safari)[\/]([\w.]+)/.exec(userAgent) || /(webkit)[\/]([\w.]+).*(version)[\/]([\w.]+).*(safari)[\/]([\w.]+)/.exec(userAgent) || /(webkit)[\/]([\w.]+)/.exec(userAgent) || /(opera)(?:.*version|)[\/]([\w.]+)/.exec(userAgent) || /(msie) ([\w.]+)/.exec(userAgent) || userAgent.indexOf('trident') >= 0 && /(rv)(?::| )([\w.]+)/.exec(userAgent) || userAgent.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(userAgent) || []; return { browser: match[5] || match[3] || match[1] || '', version: match[2] || match[4] || '0', versionNumber: match[4] || match[2] || '0', platform: platformMatch[0] || '' } } /* istanbul ignore next */ function getPlatformMatch (userAgent) { return /(ipad)/.exec(userAgent) || /(ipod)/.exec(userAgent) || /(windows phone)/.exec(userAgent) || /(iphone)/.exec(userAgent) || /(kindle)/.exec(userAgent) || /(silk)/.exec(userAgent) || /(android)/.exec(userAgent) || /(win)/.exec(userAgent) || /(mac)/.exec(userAgent) || /(linux)/.exec(userAgent) || /(cros)/.exec(userAgent) || /(playbook)/.exec(userAgent) || /(bb)/.exec(userAgent) || /(blackberry)/.exec(userAgent) || [] } /* istanbul ignore next */ function getPlatform () { let userAgent = getUserAgent(), platformMatch = getPlatformMatch(userAgent), matched = getMatch(userAgent, platformMatch), browser = {}; if (matched.browser) { browser[matched.browser] = true; browser.version = matched.version; browser.versionNumber = parseInt(matched.versionNumber, 10); } if (matched.platform) { browser[matched.platform] = true; } // These are all considered mobile platforms, meaning they run a mobile browser if (browser.android || browser.bb || browser.blackberry || browser.ipad || browser.iphone || browser.ipod || browser.kindle || browser.playbook || browser.silk || browser['windows phone']) { browser.mobile = true; } // Set iOS if on iPod, iPad or iPhone if (browser.ipod || browser.ipad || browser.iphone) { browser.ios = true; } if (browser['windows phone']) { browser.winphone = true; delete browser['windows phone']; } // These are all considered desktop platforms, meaning they run a desktop browser if (browser.cros || browser.mac || browser.linux || browser.win) { browser.desktop = true; } // Chrome, Opera 15+, Vivaldi and Safari are webkit based browsers if (browser.chrome || browser.opr || browser.safari || browser.vivaldi) { browser.webkit = true; } // IE11 has a new token so we will assign it msie to avoid breaking changes if (browser.rv || browser.iemobile) { matched.browser = 'ie'; browser.ie = true; } // Edge is officially known as Microsoft Edge, so rewrite the key to match if (browser.edge) { matched.browser = 'edge'; browser.edge = true; } // Blackberry browsers are marked as Safari on BlackBerry if (browser.safari && browser.blackberry || browser.bb) { matched.browser = 'blackberry'; browser.blackberry = true; } // Playbook browsers are marked as Safari on Playbook if (browser.safari && browser.playbook) { matched.browser = 'playbook'; browser.playbook = true; } // Opera 15+ are identified as opr if (browser.opr) { matched.browser = 'opera'; browser.opera = true; } // Stock Android browsers are marked as Safari on Android. if (browser.safari && browser.android) { matched.browser = 'android'; browser.android = true; } // Kindle browsers are marked as Safari on Kindle if (browser.safari && browser.kindle) { matched.browser = 'kindle'; browser.kindle = true; } // Kindle Silk browsers are marked as Safari on Kindle if (browser.safari && browser.silk) { matched.browser = 'silk'; browser.silk = true; } if (browser.vivaldi) { matched.browser = 'vivaldi'; browser.vivaldi = true; } // Assign the name and platform variable browser.name = matched.browser; browser.platform = matched.platform; if (window._cordovaNative) { browser.cordova = true; } return browser } var Platform = { is: getPlatform(), has: { touch: (() => !!('ontouchstart' in document.documentElement) || /* istanbul ignore next */ window.navigator.msMaxTouchPoints > 0)() }, within: { iframe: window.self !== window.top } }; let bus; function install$1 (_Vue) { bus = new _Vue(); } var Events = { $on (...args) { bus && bus.$on(...args); }, $once (...args) { bus && bus.$once(...args); }, $emit (...args) { bus && bus.$emit(...args); }, $off (...args) { bus && bus.$off(...args); } }; /* * Credits go to sindresorhus */ function rgbToHex (red, green, blue) { if (typeof red === 'string') { const res = red.match(/\b\d{1,3}\b/g).map(Number); red = res[0]; green = res[1]; blue = res[2]; } if ( typeof red !== 'number' || typeof green !== 'number' || typeof blue !== 'number' || red > 255 || green > 255 || blue > 255 ) { throw new TypeError('Expected three numbers below 256') } return ((blue | green << 8 | red << 16) | 1 << 24).toString(16).slice(1) } function hexToRgb (hex) { if (typeof hex !== 'string') { throw new TypeError('Expected a string') } hex = hex.replace(/^#/, ''); if (hex.length === 3) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; } let num = parseInt(hex, 16); return [num >> 16, num >> 8 & 255, num & 255] } var colors = Object.freeze({ rgbToHex: rgbToHex, hexToRgb: hexToRgb }); let now = Date.now; var debounce = function (fn, wait = 250, immediate) { let timeout, params, context, timestamp, result, later = () => { let last = now() - timestamp; if (last < wait && last >= 0) { timeout = setTimeout(later, wait - last); } else { timeout = null; if (!immediate) { result = fn.apply(context, params); if (!timeout) { context = params = null; } } } }; return function (...args) { var callNow = immediate && !timeout; context = this; timestamp = now(); params = args; if (!timeout) { timeout = setTimeout(later, wait); } if (callNow) { result = fn.apply(context, args); context = params = null; } return result } }; function offset (el) { if (el === window) { return {top: 0, left: 0} } let {top, left} = el.getBoundingClientRect(); return {top, left} } function style (el, property) { return window.getComputedStyle(el).getPropertyValue(property) } function height$1 (el) { if (el === window) { return viewport().height } return parseFloat(window.getComputedStyle(el).getPropertyValue('height'), 10) } function width$1 (el) { if (el === window) { return viewport().width } return parseFloat(window.getComputedStyle(el).getPropertyValue('width'), 10) } function css$1 (element, css) { let style = element.style; Object.keys(css).forEach(prop => { style[prop] = css[prop]; }); } function viewport () { let e = window, a = 'inner'; if (!('innerWidth' in window)) { a = 'client'; e = document.documentElement || document.body; } return { width: e[a + 'Width'], height: e[a + 'Height'] } } function ready$1 (fn) { if (typeof fn !== 'function') { return } if (document.readyState === 'complete') { return fn() } document.addEventListener('DOMContentLoaded', fn, false); } function getScrollTarget (el) { return el.closest('.layout-view') || window } function getScrollPosition (scrollTarget) { if (scrollTarget === window) { return window.pageYOffset || window.scrollY || document.body.scrollTop || 0 } return scrollTarget.scrollTop } var dom = Object.freeze({ offset: offset, style: style, height: height$1, width: width$1, css: css$1, viewport: viewport, ready: ready$1, getScrollTarget: getScrollTarget, getScrollPosition: getScrollPosition }); function rightClick (e) { if (!e) { e = window.event; } if (e.which) { return e.which == 3 // eslint-disable-line } if (e.button) { return e.button == 2 // eslint-disable-line } return false } function position$1 (e) { let posx, posy; if (!e) { e = window.event; } if (e.touches && e.touches[0]) { e = e.touches[0]; } else if (e.changedTouches && e.changedTouches[0]) { e = e.changedTouches[0]; } if (e.clientX || e.clientY) { posx = e.clientX; posy = e.clientY; } else if (e.pageX || e.pageY) { posx = e.pageX - document.body.scrollLeft - document.documentElement.scrollLeft; posy = e.pageY - document.body.scrollTop - document.documentElement.scrollTop; } return { top: posy, left: posx } } function targetElement (e) { let target; if (!e) { e = window.event; } if (e.target) { target = e.target; } else if (e.srcElement) { target = e.srcElement; } // defeat Safari bug if (target.nodeType === 3) { target = target.parentNode; } return target } var event = Object.freeze({ rightClick: rightClick, position: position$1, targetElement: targetElement }); let toString = Object.prototype.toString; let hasOwn = Object.prototype.hasOwnProperty; let class2type = {}; 'Boolean Number String Function Array Date RegExp Object'.split(' ').forEach(name => { class2type['[object ' + name + ']'] = name.toLowerCase(); }); function type$1 (obj) { return obj == null ? String(obj) : class2type[toString.call(obj)] || 'object' } function isPlainObject (obj) { if (!obj || type$1(obj) !== 'object') { return false } if (obj.constructor && !hasOwn.call(obj, 'constructor') && !hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { return false } let key; for (key in obj) {} return key === undefined || hasOwn.call(obj, key) } function extend () { let options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; if (typeof target === 'boolean') { deep = target; target = arguments[1] || {}; i = 2; } if (typeof target !== 'object' && type$1(target) !== 'function') { target = {}; } if (length === i) { target = this; i--; } for (; i < length; i++) { if ((options = arguments[i]) != null) { for (name in options) { src = target[name]; copy = options[name]; if (target === copy) { continue } if (deep && copy && (isPlainObject(copy) || (copyIsArray = type$1(copy) === 'array'))) { if (copyIsArray) { copyIsArray = false; clone = src && type$1(src) === 'array' ? src : []; } else { clone = src && isPlainObject(src) ? src : {}; } target[name] = extend(deep, clone, copy); } else if (copy !== undefined) { target[name] = copy; } } } } return target } var getVueRef = function (vm, refName) { let parent = vm.$parent; while (parent && (!parent.$refs || !parent.$refs[refName])) { parent = parent.$parent; } if (parent) { return parent.$refs[refName] } }; var ModalGenerator = function (VueComponent) { return { create (props) { const node = document.createElement('div'); document.body.appendChild(node); let vm = new Vue({ el: node, data () { return {props} }, render: h => h(VueComponent, {props}) }); return { close (fn) { vm.quasarClose(fn); } } } } }; var Dialog$1 = {render: function(){with(this){return _h('quasar-modal',{ref:"dialog",staticClass:"minimized"},[_h('div',{staticClass:"modal-header",domProps:{"innerHTML":_s(title || '')}}),(message)?_h('div',{staticClass:"modal-body modal-scroll",domProps:{"innerHTML":_s(message)}}):_e(),(form)?_h('div',{staticClass:"modal-body modal-scroll"},[_l((form),function(el){return [(el.type === 'heading')?_h('h6',{domProps:{"innerHTML":_s(el.label)}}):_e(),(el.type === 'textbox')?_h('div',{staticClass:"floating-label",attrs:{"style":"margin-bottom: 10px"}},[_h('input',{directives:[{name:"model",rawName:"v-model",value:(el.model),expression:"el.model"}],staticClass:"full-width",attrs:{"type":"text","placeholder":el.placeholder,"required":""},domProps:{"value":_s(el.model)},on:{"input":function($event){if($event.target.composing)return;el.model=$event.target.value;}}}),_h('label',{domProps:{"innerHTML":_s(el.label)}})]):_e(),(el.type === 'textarea')?_h('div',{staticClass:"floating-label",attrs:{"style":"margin-bottom: 10px"}},[_h('textarea',{directives:[{name:"model",rawName:"v-model",value:(el.model),expression:"el.model"}],staticClass:"full-width",attrs:{"type":"text","placeholder":el.placeholder,"required":""},domProps:{"value":_s(el.model)},on:{"input":function($event){if($event.target.composing)return;el.model=$event.target.value;}}}),_h('label',{domProps:{"innerHTML":_s(el.label)}})]):_e(),(el.type === 'numeric')?_h('div',{attrs:{"style":"margin-bottom: 10px"}},[_h('label',{domProps:{"innerHTML":_s(el.label)}}),_h('quasar-numeric',{directives:[{name:"model",rawName:"v-model",value:(el.model),expression:"el.model"}],attrs:{"min":el.min,"max":el.max,"step":el.step},domProps:{"value":(el.model)},on:{"input":function($event){el.model=$event;}}})]):_e(),(el.type === 'chips')?_h('div',{attrs:{"style":"margin-bottom: 10px"}},[_h('label',{domProps:{"innerHTML":_s(el.label)}}),_h('quasar-chips',{directives:[{name:"model",rawName:"v-model",value:(el.model),expression:"el.model"}],domProps:{"value":(el.model)},on:{"input":function($event){el.model=$event;}}})]):_e(),_l((el.items),function(radio){return (el.type === 'radio')?_h('label',{staticClass:"item"},[_h('div',{staticClass:"item-primary"},[_h('quasar-radio',{directives:[{name:"model",rawName:"v-model",value:(el.model),expression:"el.model"}],attrs:{"val":radio.value},domProps:{"value":(el.model)},on:{"input":function($event){el.model=$event;}}})]),_h('div',{staticClass:"item-content",domProps:{"innerHTML":_s(radio.label)}})]):_e()}),_l((el.items),function(checkbox){return (el.type === 'checkbox')?_h('label',{staticClass:"item"},[_h('div',{staticClass:"item-primary"},[_h('quasar-checkbox',{directives:[{name:"model",rawName:"v-model",value:(checkbox.model),expression:"checkbox.model"}],domProps:{"value":(checkbox.model)},on:{"input":function($event){checkbox.model=$event;}}})]),_h('div',{staticClass:"item-content",domProps:{"innerHTML":_s(checkbox.label)}})]):_e()}),_l((el.items),function(toggle){return (el.type === 'toggle')?_h('label',{staticClass:"item"},[_h('div',{staticClass:"item-content has-secondary",domProps:{"innerHTML":_s(toggle.label)}}),_h('div',{staticClass:"item-secondary"},[_h('quasar-toggle',{directives:[{name:"model",rawName:"v-model",value:(toggle.model),expression:"toggle.model"}],domProps:{"value":(toggle.model)},on:{"input":function($event){toggle.model=$event;}}})])]):_e()}),(el.type === 'rating')?_h('div',{attrs:{"style":"margin-bottom: 10px"}},[_h('label',{domProps:{"innerHTML":_s(el.label)}}),_h('quasar-rating',{directives:[{name:"model",rawName:"v-model",value:(el.model),expression:"el.model"}],style:({fontSize: el.size || '2rem'}),attrs:{"max":el.max,"icon":el.icon},domProps:{"value":(el.model)},on:{"input":function($event){el.model=$event;}}})]):_e()]})]):_e(),(progress)?_h('div',{staticClass:"modal-body"},[_h('quasar-progress',{staticClass:"primary stripe animate",class:{indeterminate: progress.indeterminate},attrs:{"percentage":progress.model}}),(!progress.indeterminate)?_h('span',[_s(progress.model)+" %"]):_e()]):_e(),(buttons)?_h('div',{staticClass:"modal-buttons",class:{row: !stackButtons, column: stackButtons}},[_l((buttons),function(button){return _h('button',{staticClass:"primary clear",domProps:{"innerHTML":_s(typeof button === 'string' ? button : button.label)},on:{"click":function($event){trigger(button.handler);}}})})]):_e(),(!buttons && !nobuttons)?_h('div',{staticClass:"modal-buttons row"},[_h('button',{staticClass:"primary clear",on:{"click":function($event){close();}}},["OK"])]):_e()])}},staticRenderFns: [], props: { title: String, message: String, form: Object, stackButtons: Boolean, buttons: Array, nobuttons: Boolean, progress: Object }, computed: { opened () { return this.$refs.dialog.active } }, methods: { trigger (handler) { this.close(() => { if (typeof handler === 'function') { handler(this.getFormData()); } }); }, getFormData () { if (!this.form) { return } let data = {}; Object.keys(this.form).forEach(name => { let el = this.form[name]; if (['checkbox', 'toggle'].includes(el.type)) { data[name] = el.items.filter(item => item.model).map(item => item.value); } else if (el.type !== 'heading') { data[name] = el.model; } }); return data }, close (fn) { if (!this.opened) { return } this.$refs.dialog.close(() => { if (typeof fn === 'function') { fn(); } this.$root.$destroy(); }); } }, mounted () { this.$refs.dialog.open(); this.$root.quasarClose = this.close; }, destroyed () { if (document.body.contains(this.$el)) { document.body.removeChild(this.$el); } } }; var Dialog = ModalGenerator(Dialog$1); /* istanbul ignore next */ var openURL = (url) => { if (Platform.is.cordova) { navigator.app.loadUrl(url, { openExternal: true }); return } let win = window.open(url, '_blank'); if (win) { win.focus(); } else { Dialog.create({ title: 'Cannot Open Window', message: 'Please allow popups first, then please try again.' }).show(); } }; function s4 () { return Math.floor((1 + Math.random()) * 0x10000) .toString(16) .substring(1) } var uid = function () { return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4() }; let data = {}; function add$1 (name, el, ctx) { let id = uid(); el.dataset['__' + name] = id; if (!data[name]) { data[name] = {}; } else if (data[name][id]) { console.warn('Element store [add]: overwriting data'); } data[name][id] = ctx; } function get (name, el) { let id = el.dataset['__' + name]; if (!id) { console.warn('Element store [get]: id not registered', name, el); return } if (!data[name]) { console.warn('Element store [get]: name not registered', name, el); return } let ctx = data[name][id]; if (!ctx) { console.warn('Element store [get]: data not found for', name, ':', id, '->', el); return } return ctx } function remove$1 (name, el) { let id = el.dataset['__' + name]; if (!id) { console.warn('Element store [remove]: id not registered', name, el); return } if (data[name] && data[name][id]) { delete data[name][id]; } } var store = Object.freeze({ add: add$1, get: get, remove: remove$1 }); var throttle = function (fn, limit = 250) { let wait = false; return function (...args) { if (wait) { return } wait = true; fn.apply(this, args); setTimeout(() => { wait = false; }, limit); } }; var Utils = { colors, debounce, dom, event, extend, getVueRef, openURL, store, throttle, uid }; let transitionDuration = 300; let displayDuration = 2500; // in ms function parseOptions (opts, defaults) { if (!opts) { throw new Error('Missing toast options.') } let options = Utils.extend( true, {}, defaults, typeof opts === 'string' ? {html: opts} : opts ); if (!options.html) { throw new Error('Missing toast content/HTML.') } return options } var Toast = {render: function(){with(this){return _h('div',{staticClass:"quasar-toast-container",class:{active: active}},[(stack[0])?_h('div',{staticClass:"quasar-toast row no-wrap items-center non-selectable",class:classes,style:({color: stack[0].color, background: stack[0].bgColor})},[(stack[0].icon)?_h('i',[_s(stack[0].icon)]):_e()," ",(stack[0].image)?_h('img',{attrs:{"src":stack[0].image}}):_e(),_h('div',{staticClass:"quasar-toast-message auto",domProps:{"innerHTML":_s(stack[0].html)}}),(stack[0].button && stack[0].button.label)?_h('a',{style:({color: stack[0].button.color}),on:{"click":function($event){dismiss(stack[0].button.handler);}}},[_s(stack[0].button.label)+" "]):_e(),_h('a',{style:({color: stack[0].button.color}),on:{"click":function($event){dismiss();}}},[_m(0)])]):_e()])}},staticRenderFns: [function(){with(this){return _h('i',["close"])}}], data () { return { active: false, inTransition: false, stack: [], timer: null, defaults: { color: 'white', bgColor: '#323232', button: { color: 'yellow' } } } }, computed: { classes () { if (!this.stack.length || !this.stack[0].classes) { return {} } return this.stack[0].classes.split(' ') } }, methods: { create (options) { this.stack.push(parseOptions(options, this.defaults)); if (this.active || this.inTransition) { return } this.active = true; this.inTransition = true; this.__show(); }, __show () { Events.$emit('app:toast', this.stack[0].html); this.timer = setTimeout(() => { if (this.stack.length > 0) { this.dismiss(); } else { this.inTransition = false; } }, transitionDuration + (this.stack[0].timeout || displayDuration)); }, dismiss (done) { this.active = false; if (this.timer) { clearTimeout(this.timer); this.timer = null; } setTimeout(() => { if (typeof this.stack[0].onDismiss === 'function') { this.stack[0].onDismiss(); } this.stack.shift(); done && done(); if (this.stack.length > 0) { this.active = true; this.__show(); return } this.inTransition = false; }, transitionDuration + 50); }, setDefaults (opts) { Utils.extend(true, this.defaults, opts); } } }; let toast; let types = [ { name: 'positive', defaults: {icon: 'check', classes: 'bg-positive'} }, { name: 'negative', defaults: {icon: 'whatshot', classes: 'bg-negative'} }, { name: 'info', defaults: {icon: 'info', classes: 'bg-info'} }, { name: 'warning', defaults: {icon: 'warning', classes: 'bg-warning'} } ]; function create (opts, defaults) { if (!opts) { throw new Error('Missing toast options.') } if (defaults) { opts = Utils.extend( true, typeof opts === 'string' ? {html: opts} : opts, defaults ); } toast.create(opts); } types.forEach(type => { create[type.name] = opts => create(opts, type.defaults); }); function install$2 (_Vue) { let node = document.createElement('div'); document.body.appendChild(node); toast = new _Vue(Toast).$mount(node); } var toast$1 = { create, setDefaults (opts) { toast.setDefaults(opts); }, install: install$2 }; function set$1 (theme) { if (current) { document.body.classList.remove(current); } current = theme; document.body.classList.add(theme); // add meta tag for mobile address bar coloring if (Platform.is.mobile && !Platform.is.cordova) { let tempDiv = document.createElement('div'); tempDiv.style.height = '10px'; tempDiv.style.position = 'absolute'; tempDiv.style.top = '-100000px'; tempDiv.className = 'bg-primary'; document.body.appendChild(tempDiv); let primaryColor = window.getComputedStyle(tempDiv).getPropertyValue('background-color'); document.body.removeChild(tempDiv); let rgb = primaryColor.match(/\d+/g); let hex = '#' + Utils.colors.rgbToHex(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2])); // http://stackoverflow.com/a/33193739 let metaTag = document.createElement('meta'); if (Platform.is.winphone) { // <meta name="msapplication-navbutton-color" content="#4285f4"> metaTag.setAttribute('name', 'msapplication-navbutton-color'); } // Chrome, Firefox OS, Opera, Vivaldi if (Platform.is.webkit || Platform.is.vivaldi) { // <meta name="theme-color" content="#4285f4"> metaTag.setAttribute('name', 'theme-color'); } if (Platform.is.safari) { // <meta name="apple-mobile-web-app-status-bar-style" content="#4285f4"> metaTag.setAttribute('name', 'apple-mobile-web-app-status-bar-style'); } metaTag.setAttribute('content', hex); document.getElementsByTagName('head')[0].appendChild(metaTag); } } var current; var theme$1 = Object.freeze({ set: set$1, get current () { return current; } }); var slide$1 = { enter (el, done) { Velocity(el, 'stop'); Velocity(el, 'slideDown', done); }, enterCancelled (el) { Velocity(el, 'stop'); el.removeAttribute('style'); }, leave (el, done) { Velocity(el, 'stop'); Velocity(el, 'slideUp', done); }, leaveCancelled (el) { Velocity(el, 'stop'); el.removeAttribute('style'); } }; let transitions = {slide: slide$1}; var Transition = { functional: true, props: { name: { type: String, default: 'slide', validator (value) { if (!transitions[value]) { console.error('Quasar Transition unknown: ' + value); return false } return true } } }, render (h, context) { if (!transitions[context.props.name]) { throw new Error(`Quasar Transition ${context.props.name} is unnowkn.`) } var data = { props: { name: 'quasar-transition', mode: 'out-in' }, on: transitions[context.props.name] }; return h('transition', data, context.children) } }; var dGoBack = { bind (el, { value, modifiers }, vnode) { let ctx = { value, position: window.history.length - 1, single: modifiers.single }; if (Platform.is.cordova) { ctx.goBack = () => { vnode.context.$router.go(ctx.single ? -1 : ctx.position - window.history.length); }; } else { ctx.goBack = () => { vnode.context.$router.replace(ctx.value); }; } Utils.store.add('goback', el, ctx); el.addEventListener('click', ctx.goBack); }, update (el, binding) { if (binding.oldValue !== binding.value) { let ctx = Utils.store.get('goback', el); ctx.value = binding.value; } }, unbind (el) { el.removeEventListener('click', Utils.store.get('goback', el).goBack); Utils.store.remove('goback', el); } }; var dLink = { bind (el, binding, vnode) { let ctx = { replace: binding.replace, route: binding.value, go () { vnode.context.$router[ctx.replace ? 'replace' : 'push'](ctx.route); } }; Utils.store.add('link', el, ctx); el.addEventListener('click', ctx.go); }, update (el, binding) { let ctx = Utils.store.get('link', el); if (binding.oldValue !== binding.value) { ctx.route = binding.value; } if (binding.replace !== ctx.replace) { ctx.replace = binding.replace; } }, unbind (el) { el.removeEventListener('click', Utils.store.get('link', el).go); Utils.store.remove('link', el); } }; function updateBinding (el, binding, ctx) { if (typeof binding.value !== 'function') { ctx.scrollTarget.removeEventListener('scroll', ctx.scroll); console.error('v-scroll-fire requires a function as parameter', el); return } ctx.handler = binding.value; if (typeof binding.oldValue !== 'function') { ctx.scrollTarget.addEventListener('scroll', ctx.scroll); ctx.scroll(); } } var dScrollFire = { bind (el, binding) { let ctx = { scroll: Utils.debounce(() => { let containerBottom, elementBottom, fire; if (ctx.scrollTarget === window) { elementBottom = el.getBoundingClientRect().bottom; fire = elementBottom < Utils.dom.viewport().height; } else { containerBottom = Utils.dom.offset(ctx.scrollTarget).top + Utils.dom.height(ctx.scrollTarget); elementBottom = Utils.dom.offset(el).top + Utils.dom.height(el); fire = elementBottom < containerBottom; } if (fire) { ctx.scrollTarget.removeEventListener('scroll', ctx.scroll); ctx.handler(el); } }, 25) }; Utils.store.add('scrollfire', el, ctx); }, inserted (el, binding) { let ctx = Utils.store.get('scrollfire', el); ctx.scrollTarget = Utils.dom.getScrollTarget(el); updateBinding(el, binding, ctx); }, update (el, binding) { if (binding.value !== binding.oldValue) { updateBinding(el, binding, Utils.store.get('scrollfire', el)); } }, unbind (el) { let ctx = Utils.store.get('scrollfire', el); ctx.scrollTarget.removeEventListener('scroll', ctx.scroll); Utils.store.remove('scrollfire', el); } }; function updateBinding$1 (el, binding, ctx) { if (typeof binding.value !== 'function') { ctx.scrollTarget.removeEventListener('scroll', ctx.scroll); console.error('v-scroll requires a function as parameter', el); return } ctx.handler = binding.value; if (typeof binding.oldValue !== 'function') { ctx.scrollTarget.addEventListener('scroll', ctx.scroll); } } var dScroll = { bind (el, binding) { let ctx = { scroll () { ctx.handler(Utils.dom.getScrollPosition(ctx.scrollTarget)); } }; Utils.store.add('scroll', el, ctx); }, inserted (el, binding) { let ctx = Utils.store.get('scroll', el); ctx.scrollTarget = Utils.dom.getScrollTarget(el); updateBinding$1(el, binding, ctx); }, update (el, binding) { if (binding.oldValue !== binding.value) { updateBinding$1(el, binding, Utils.store.get('scrollfire', el)); } }, unbind (el) { let ctx = Utils.store.get('scroll', el); ctx.scrollTarget.removeEventListener('scroll', ctx.scroll); Utils.store.remove('scroll', el); } }; var dTooltip = { bind (el, binding) { el.setAttribute('quasar-tooltip', binding.value); el.classList.add('quasar-tooltip'); if (binding.modifiers.inline) { el.classList.add('flex', 'inline'); } }, update (el, binding) { if (binding.value !== binding.oldValue) { el.setAttribute('quasar-tooltip', binding.value); } }, unbind (el) { el.removeAttribute('quasar-tooltip'); } }; let defaultDuration = 800; function updateBinding$2 (el, binding, ctx) { ctx.duration = parseInt(binding.arg, 10) || defaultDuration; if (binding.oldValue !== binding.value) { ctx.handler = binding.value; } } var dTouchHold = { bind (el, binding) { let ctx = { start (evt) { ctx.timer = setTimeout(() => { document.removeEventListener('mousemove', ctx.mouseAbort); document.removeEventListener('mouseup', ctx.mouseAbort); ctx.handler(); }, ctx.duration); }, mouseStart (evt) { document.addEventListener('mousemove', ctx.mouseAbort); document.addEventListener('mouseup', ctx.mouseAbort); ctx.start(evt); }, abort (evt) { if (ctx.timer) { clearTimeout(ctx.timer); ctx.timer = null; } }, mouseAbort (evt) { document.removeEventListener('mousemove', ctx.mouseAbort); document.removeEventListener('mouseup', ctx.mouseAbort); ctx.abort(evt); } }; Utils.store.add('touchhold', el, ctx); updateBinding$2(el, binding, ctx); el.addEventListener('touchstart', ctx.start); el.addEventListener('touchmove', ctx.abort); el.addEventListener('touchend', ctx.abort); el.addEventListener('mousedown', ctx.mouseStart); }, update (el, binding) { updateBinding$2(el, binding, Utils.store.get('touchhold', el)); }, unbind (el, binding) { let ctx = Utils.store.get('touchhold', el); el.removeEventListener('touchstart', ctx.start); el.removeEventListener('touchmove', ctx.abort); el.removeEventListener('touchend', ctx.abort); el.removeEventListener('mousedown', ctx.mouseStart); document.removeEventListener('mousemove', ctx.mouseAbort); document.removeEventListener('mouseup', ctx.mouseAbort); Utils.store.remove('touchhold'); } }; function getDirection (mod) { if (Object.keys(mod).length === 0) { return { horizontal: true, vertical: true } } let dir = {};['horizontal', 'vertical'].forEach(direction => { if (mod[direction]) { dir[direction] = true; } }); return dir } function updateClasses (el, dir) { el.classList.add('quasar-touch'); if (dir.horizontal && !dir.vertical) { el.classList.add('quasar-touch-y'); el.classList.remove('quasar-touch-x'); } else if (!dir.horizontal && dir.vertical) { el.classList.add('quasar-touch-x'); el.classList.remove('quasar-touch-y'); } } function processChanges (evt, ctx, isFinal) { let direction, position = Utils.event.position(evt), distX = position.left - ctx.event.x, distY = position.top - ctx.event.y, absDistX = Math.abs(distX), absDistY = Math.abs(distY); if (ctx.direction.horizontal && !ctx.direction.vertical) { direction = distX < 0 ? 'left' : 'right'; } else if (!ctx.direction.horizontal && ctx.direction.vertical) { direction = distY < 0 ? 'up' : 'down'; } else if (absDistX >= absDistY) { direction = distX < 0 ? 'left' : 'right'; } else { direction = distY < 0 ? 'up' : 'down'; } return { evt, position, direction, isFirst: ctx.event.isFirst, isFinal: Boolean(isFinal), duration: new Date().getTime() - ctx.event.time, distance: { x: absDistX, y: absDistY }, delta: { x: position.left - ctx.event.lastX, y: position.top - ctx.event.lastY } } } function shouldTrigger (ctx, changes) { if (ctx.direction.horizontal && ctx.direction.vertical) { return true } if (ctx.direction.horizontal && !ctx.direction.vertical) { return Math.abs(changes.delta.x) > 0 } if (!ctx.direction.horizontal && ctx.direction.vertical) { return Math.abs(changes.delta.y) > 0 } } var dTouchPan = { bind (el, binding) { let ctx = { handler: binding.value, direction: getDirection(binding.modifiers), mouseStart (evt) { document.addEventListener('mousemove', ctx.mouseMove); document.addEventListener('mouseup', ctx.mouseEnd); ctx.start(evt); }, start (evt) { let position = Utils.event.position(evt); ctx.event = { x: position.left, y: position.top, time: new Date().getTime(), detected: false, prevent: ctx.direction.horizontal && ctx.direction.vertical, isFirst: true, lastX: position.left, lastY: position.top }; }, mouseMove (evt) { ctx.event.prevent = true; ctx.move(evt); }, move (evt) { if (ctx.event.prevent) { evt.preventDefault(); let changes = processChanges(evt, ctx, false); if (shouldTrigger(ctx, changes)) { ctx.handler(changes); ctx.event.lastX = changes.position.left; ctx.event.lastY = changes.position.top; ctx.event.isFirst = false; } return } if (ctx.event.detected) { return } ctx.event.detected = true; let position = Utils.event.position(evt), distX = position.left - ctx.event.x, distY = position.top - ctx.event.y; if (ctx.direction.horizontal && !ctx.direction.vertical) { if (Math.abs(distX) > Math.abs(distY)) { evt.preventDefault(); ctx.event.prevent = true; } } else { if (Math.abs(distX) < Math.abs(distY)) { evt.preventDefault(); ctx.event.prevent = true; } } }, mouseEnd (evt) { document.removeEventListener('mousemove', ctx.mouseMove); document.removeEventListener('mouseup', ctx.mouseEnd); ctx.end(evt); }, end (evt) { if (!ctx.event.prevent || ctx.event.isFirst) { return } ctx.handler(processChanges(evt, ctx, true)); } }; Utils.store.add('touchpan', el, ctx); updateClasses(el, ctx.direction); el.addEventListener('touchstart', ctx.start); el.addEventListener('mousedown', ctx.mouseStart); el.addEventListener('touchmove', ctx.move); el.addEventListener('touchend', ctx.end); }, update (el, binding) { if (binding.oldValue !== binding.value) { let ctx = Utils.store.get('touchpan', el); ctx.handler = binding.value; } }, unbind (el, binding) { let ctx = Utils.store.get('touchpan', el); el.removeEventListener('touchstart', ctx.start); el.removeEventListener('mousedown', ctx.mouseStart); el.removeEventListener('touchmove', ctx.move); el.removeEventListener('touchend', ctx.end); Utils.store.remove('touchpan', el); } }; function getDirection$1 (mod) { if (Object.keys(mod).length === 0) { return { left: true, right: true, up: true, down: true, horizontal: true, vertical: true } } let dir = {};['left', 'right', 'up', 'down', 'horizontal', 'vertical'].forEach(direction => { if (mod[direction]) { dir[direction] = true; } }); if (dir.horizontal) { dir.left = dir.right = true; } if (dir.vertical) { dir.up = dir.down = true; } if (dir.left || dir.right) { dir.horizontal = true; } if (dir.up || dir.down) { dir.vertical = true; } return dir } function updateClasses$1 (el, dir) { el.classList.add('quasar-touch'); if (dir.horizontal && !dir.vertical) { el.classList.add('quasar-touch-y'); el.classList.remove('quasar-touch-x'); } else if (!dir.horizontal && dir.vertical) { el.classList.add('quasar-touch-x'); el.classList.remove('quasar-touch-y'); } } var dTouchSwipe = { bind (el, binding) { let ctx = { handler: binding.value, direction: getDirection$1(binding.modifiers), start (evt) { let position = Utils.event.position(evt); ctx.event = { x: position.left, y: position.top, time: new Date().getTime(), detected: false, prevent: ctx.direction.horizontal && ctx.direction.vertical }; document.addEventListener('mousemove', ctx.move); document.addEventListener('mouseup', ctx.end); }, move (evt) { let position = Utils.event.position(evt), distX = position.left - ctx.event.x, distY = position.top - ctx.event.y; if (ctx.event.prevent) { evt.preventDefault(); return } if (ctx.event.detected) { return } ctx.event.detected = true; if (ctx.direction.horizontal && !ctx.direction.vertical) { if (Math.abs(distX) > Math.abs(distY)) { evt.preventDefault(); ctx.event.prevent = true; } } else { if (Math.abs(distX) < Math.abs(distY)) { evt.preventDefault(); ctx.event.prevent = true; } } }, end (evt) { document.removeEventListener('mousemove', ctx.move); document.removeEventListener('mouseup', ctx.end); let direction, position = Utils.event.position(evt), distX = position.left - ctx.event.x, distY = position.top - ctx.event.y; if (distX !== 0 || distY !== 0) { if (Math.abs(distX) >= Math.abs(distY)) { direction = distX < 0 ? 'left' : 'right'; } else { direction = distY < 0 ? 'up' : 'down'; } if (ctx.direction[direction]) { ctx.handler({ evt, direction, duration: new Date().getTime() - ctx.event.time, distance: { x: Math.abs(distX), y: Math.abs(distY) } }); } } } }; Utils.store.add('touchswipe', el, ctx); updateClasses$1(el, ctx.direction); el.addEventListener('touchstart', ctx.start); el.addEventListener('mousedown', ctx.start); el.addEventListener('touchmove', ctx.move); el.addEventListener('touchend', ctx.end); }, update (el, binding) { if (binding.oldValue !== binding.value) { let ctx = Utils.store.get('touchswipe', el); ctx.handler = binding.value; } }, unbind (el, binding) { let ctx = Utils.store.get('touchswipe', el); el.removeEventListener('touchstart', ctx.start); el.removeEventListener('mousedown', ctx.start); el.removeEventListener('touchmove', ctx.move); el.removeEventListener('touchend', ctx.end); Utils.store.remove('touchswipe', el); } }; var Checkbox = {render: function(){with(this){return _h('label',{staticClass:"quasar-checkbox",class:{disabled: disable}},[_h('input',{directives:[{name:"model",rawName:"v-model",value:(model),expression:"model"}],attrs:{"type":"checkbox","disabled":disable},domProps:{"checked":Array.isArray(model)?_i(model,null)>-1:_q(model,true)},on:{"change":function($event){var $$a=model,$$el=$event.target,$$c=$$el.checked?(true):(false);if(Array.isArray($$a)){var $$v=null,$$i=_i($$a,$$v);if($$c){$$i<0&&(model=$$a.concat($$v));}else{$$i>-1&&(model=$$a.slice(0,$$i).concat($$a.slice($$i+1)));}}else{model=$$c;}}}}),_m(0)])}},staticRenderFns: [function(){with(this){return _h('div')}}], props: { value: { type: Boolean, required: true }, disable: Boolean }, computed: { model: { get () { return this.value }, set (value) { this.$emit('input', value); } } } }; var Chips = {render: function(){with(this){return _h('div',{staticClass:"quasar-chips group",class:{active: active, disabled: disable},on:{"click":focus}},[_l((value),function(label,index){return _h('span',{key:index,staticClass:"chip label bg-light text-grey-9"},[_s(label)+" ",_h('i',{staticClass:"on-right",on:{"click":function($event){remove(index);}}},["close"])])}),_h('div',{staticClass:"quasar-chips-input chip label text-grey-9"},[_h('input',{directives:[{name:"model",rawName:"v-model",value:(input),expression:"input"}],ref:"input",staticClass:"no-style",attrs:{"type":"text","disabled":disable,"placeholder":placeholder},domProps:{"value":_s(input)},on:{"keyup":function($event){if($event.keyCode!==13)return;add();},"focus":function($event){active = true;},"blur":function($event){active = false;},"input":function($event){if($event.target.composing)return;input=$event.target.value;}}})," ",_h('button',{staticClass:"small",class:{invisible: !input.length},on:{"click":function($event){add();}}},[_m(0)])])])}},staticRenderFns: [function(){with(this){return _h('i',["send"])}}], props: { value: { type: Array, required: true }, disable: Boolean, placeholder: String }, data () { return { active: false, input: '' } }, methods: { add (value = this.input) { if (!this.disable && value) { this.$emit('input', this.value.concat([value])); this.input = ''; } }, remove (index) { if (!this.disable && index >= 0 && index < this.value.length) { let value = this.value.slice(0); value.splice(index, 1); this.$emit('input', value); } }, focus () { this.$refs.input.focus(); } } }; var Collapsible = {render: function(){with(this){return _h('div',{staticClass:"quasar-collapsible"},[_h('div',{staticClass:"item item-link non-selectable item-collapsible",on:{"click":function($event){toggle();}}},[(icon)?_h('i',{staticClass:"item-primary",domProps:{"textContent":_s(icon)}}):_e()," ",(img)?_h('img',{staticClass:"item-primary thumbnail",attrs:{"src":img}}):_e(),(avatar)?_h('img',{staticClass:"item-primary",attrs:{"src":avatar}}):_e(),_h('div',{staticClass:"item-content has-secondary"},[_h('div',[_s(label)])]),_h('i',{staticClass:"item-secondary",class:{'rotate-180': active}},["keyboard_arrow_down"])]),_h('quasar-transition',{attrs:{"name":"slide"}},[_h('div',{directives:[{name:"show",rawName:"v-show",value:(active),expression:"active"}],staticClass:"quasar-collapsible-sub-item"},[_t("default")])])])}},staticRenderFns: [], props: { opened: Boolean, icon: String, img: String, avatar: String, label: String }, data () { return { active: this.opened } }, watch: { opened (value) { this.active = value; } }, methods: { toggle () { this.active = !this.active; }, open () { this.active = true; }, close () { this.active = false; } } }; var ContextMenuDesktop = {render: function(){with(this){return _h('quasar-popover',{ref:"popover",on:{"close":function($event){__cleanup();}}},[_t("default")])}},staticRenderFns: [], props: { disable: Boolean }, methods: { close () { this.$refs.popover.close(); }, __open (event) { if (this.disable) { return } this.$refs.popover.open(event); this.$nextTick(() => { this.scrollTarget = Utils.dom.getScrollTarget(this.target); this.scrollTarget.addEventListener('scroll', this.close); }); }, __cleanup () { this.scrollTarget.removeEventListener('scroll', this.close); } }, mounted () { this.$nextTick(() => { this.target = this.$el.parentNode; this.target.addEventListener('contextmenu', this.__open); }); }, beforeDestroy () { this.target.removeEventListener('contexmenu', this.handler); } }; var ContextMenuMobile = {render: function(){with(this){return _h('quasar-modal',{ref:"dialog",staticClass:"minimized"},[_t("default")])}},staticRenderFns: [], props: { disable: Boolean }, methods: { open () { this.handler(); }, close () { this.target.classList.remove('non-selectable'); this.$refs.dialog.close(); }, toggle () { if (this.$refs.dialog.active) { this.close(); } else { this.open(); } } }, mounted () { this.$nextTick(() => { this.target = this.$el.parentNode; this.handler = () => { if (!this.disable) { this.$refs.dialog.open(); } }; this.touchStartHandler = (event) => { this.target.classList.add('non-selectable'); this.touchTimer = setTimeout(() => { event.preventDefault(); event.stopPropagation(); this.cleanup(); setTimeout(() => { this.handler(); }, 10); }, 600); }; this.cleanup = () => { this.target.classList.remove('non-selectable'); if (this.touchTimer) { clearTimeout(this.touchTimer); this.touchTimer = null; } }; this.target.addEventListener('touchstart', this.touchStartHandler); this.target.addEventListener('touchcancel', this.cleanup); this.target.addEventListener('touchmove', this.cleanup); this.target.addEventListener('touchend', this.cleanup); }); }, beforeDestroy () { this.target.removeEventListener('touchstart', this.touchStartHandler); this.target.removeEventListener('touchcancel', this.cleanup); this.target.removeEventListener('touchmove', this.cleanup); this.target.removeEventListener('touchend', this.cleanup); } }; let contentCSS = { ios: { maxHeight: '80vh', height: 'auto', boxShadow: 'none', backgroundColor: '#e4e4e4' }, mat: { maxWidth: '95vw', maxHeight: '98vh' } }; var DatetimeMobile = {render: function(){with(this){return _h('div',{staticClass:"cursor-pointer textfield caret",class:{disabled: disable},on:{"click":open}},[_h('div',{domProps:{"innerHTML":_s(label)}}),_h('quasar-modal',{ref:"dialog",staticClass:"with-backdrop",class:classNames,attrs:{"transition":transition,"position-classes":position,"content-css":css}},[_h('quasar-inline-datetime',{directives:[{name:"model",rawName:"v-model",value:(model),expression:"model"}],staticClass:"no-border",attrs:{"type":type,"style":"width: 100%"},domProps:{"value":(model)},on:{"input":function($event){model=$event;}}},[_h('div',{staticClass:"modal-buttons row full-width"},[_h('button',{staticClass:"primary clear",domProps:{"innerHTML":_s(cancelLabel)},on:{"click":function($event){close();}}})," ",_h('button