UNPKG

buefy

Version:

Lightweight UI components for Vue.js based on Bulma

65 lines (58 loc) 1.77 kB
'use strict'; /** * Get value of an object property/path even if it's nested */ function getValueByPath(obj, path) { var value = path.split('.').reduce(function (o, i) { return o[i]; }, obj); return value; } /** * Extension of indexOf method by equality function if specified */ function indexOf(array, obj, fn) { if (!array) return -1; if (!fn || typeof fn !== 'function') return array.indexOf(obj); for (var i = 0; i < array.length; i++) { if (fn(array[i], obj)) { return i; } } return -1; } /** * Mobile detection * https://www.abeautifulsite.net/detecting-mobile-devices-with-javascript */ var isMobile = { Android: function Android() { return typeof window !== 'undefined' && window.navigator.userAgent.match(/Android/i); }, BlackBerry: function BlackBerry() { return typeof window !== 'undefined' && window.navigator.userAgent.match(/BlackBerry/i); }, iOS: function iOS() { return typeof window !== 'undefined' && window.navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function Opera() { return typeof window !== 'undefined' && window.navigator.userAgent.match(/Opera Mini/i); }, Windows: function Windows() { return typeof window !== 'undefined' && window.navigator.userAgent.match(/IEMobile/i); }, any: function any() { return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows(); } }; function removeElement(el) { if (typeof el.remove !== 'undefined') { el.remove(); } else if (typeof el.parentNode !== 'undefined') { el.parentNode.removeChild(el); } } exports.getValueByPath = getValueByPath; exports.indexOf = indexOf; exports.isMobile = isMobile; exports.removeElement = removeElement;