Remove static from Utils
parent
fe9413c7b7
commit
1e305ba7ff
|
@ -1,32 +1,32 @@
|
||||||
export default class DomHandler {
|
export default {
|
||||||
|
|
||||||
static innerWidth(el) {
|
innerWidth(el) {
|
||||||
let width = el.offsetWidth;
|
let width = el.offsetWidth;
|
||||||
let style = getComputedStyle(el);
|
let style = getComputedStyle(el);
|
||||||
|
|
||||||
width += parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
width += parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
||||||
return width;
|
return width;
|
||||||
}
|
},
|
||||||
|
|
||||||
static width(el) {
|
width(el) {
|
||||||
let width = el.offsetWidth;
|
let width = el.offsetWidth;
|
||||||
let style = getComputedStyle(el);
|
let style = getComputedStyle(el);
|
||||||
|
|
||||||
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
|
||||||
return width;
|
return width;
|
||||||
}
|
},
|
||||||
|
|
||||||
static getWindowScrollTop() {
|
getWindowScrollTop() {
|
||||||
let doc = document.documentElement;
|
let doc = document.documentElement;
|
||||||
return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
|
||||||
}
|
},
|
||||||
|
|
||||||
static getWindowScrollLeft() {
|
getWindowScrollLeft() {
|
||||||
let doc = document.documentElement;
|
let doc = document.documentElement;
|
||||||
return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
|
return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
|
||||||
}
|
},
|
||||||
|
|
||||||
static getOuterWidth(el, margin) {
|
getOuterWidth(el, margin) {
|
||||||
if (el) {
|
if (el) {
|
||||||
let width = el.offsetWidth;
|
let width = el.offsetWidth;
|
||||||
|
|
||||||
|
@ -40,9 +40,9 @@ export default class DomHandler {
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static getOuterHeight(el, margin) {
|
getOuterHeight(el, margin) {
|
||||||
if (el) {
|
if (el) {
|
||||||
let height = el.offsetHeight;
|
let height = el.offsetHeight;
|
||||||
|
|
||||||
|
@ -56,9 +56,9 @@ export default class DomHandler {
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static getClientHeight(el, margin) {
|
getClientHeight(el, margin) {
|
||||||
if (el) {
|
if (el) {
|
||||||
let height = el.clientHeight;
|
let height = el.clientHeight;
|
||||||
|
|
||||||
|
@ -71,9 +71,9 @@ export default class DomHandler {
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static getViewport() {
|
getViewport() {
|
||||||
let win = window,
|
let win = window,
|
||||||
d = document,
|
d = document,
|
||||||
e = d.documentElement,
|
e = d.documentElement,
|
||||||
|
@ -82,18 +82,18 @@ export default class DomHandler {
|
||||||
h = win.innerHeight || e.clientHeight || g.clientHeight;
|
h = win.innerHeight || e.clientHeight || g.clientHeight;
|
||||||
|
|
||||||
return {width: w, height: h};
|
return {width: w, height: h};
|
||||||
}
|
},
|
||||||
|
|
||||||
static getOffset(el) {
|
getOffset(el) {
|
||||||
var rect = el.getBoundingClientRect();
|
var rect = el.getBoundingClientRect();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
top: rect.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0),
|
top: rect.top + (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0),
|
||||||
left: rect.left + (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0),
|
left: rect.left + (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0),
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
|
|
||||||
static index(element) {
|
index(element) {
|
||||||
let children = element.parentNode.childNodes;
|
let children = element.parentNode.childNodes;
|
||||||
let num = 0;
|
let num = 0;
|
||||||
for (var i = 0; i < children.length; i++) {
|
for (var i = 0; i < children.length; i++) {
|
||||||
|
@ -101,9 +101,9 @@ export default class DomHandler {
|
||||||
if (children[i].nodeType === 1) num++;
|
if (children[i].nodeType === 1) num++;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
},
|
||||||
|
|
||||||
static addMultipleClasses(element, className) {
|
addMultipleClasses(element, className) {
|
||||||
if (element.classList) {
|
if (element.classList) {
|
||||||
let styles = className.split(' ');
|
let styles = className.split(' ');
|
||||||
for (let i = 0; i < styles.length; i++) {
|
for (let i = 0; i < styles.length; i++) {
|
||||||
|
@ -117,23 +117,23 @@ export default class DomHandler {
|
||||||
element.className += ' ' + styles[i];
|
element.className += ' ' + styles[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static addClass(element, className) {
|
addClass(element, className) {
|
||||||
if (element.classList)
|
if (element.classList)
|
||||||
element.classList.add(className);
|
element.classList.add(className);
|
||||||
else
|
else
|
||||||
element.className += ' ' + className;
|
element.className += ' ' + className;
|
||||||
}
|
},
|
||||||
|
|
||||||
static removeClass(element, className) {
|
removeClass(element, className) {
|
||||||
if (element.classList)
|
if (element.classList)
|
||||||
element.classList.remove(className);
|
element.classList.remove(className);
|
||||||
else
|
else
|
||||||
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
|
||||||
}
|
},
|
||||||
|
|
||||||
static hasClass(element, className) {
|
hasClass(element, className) {
|
||||||
if (element) {
|
if (element) {
|
||||||
if (element.classList)
|
if (element.classList)
|
||||||
return element.classList.contains(className);
|
return element.classList.contains(className);
|
||||||
|
@ -142,35 +142,35 @@ export default class DomHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
},
|
||||||
|
|
||||||
static find(element, selector) {
|
find(element, selector) {
|
||||||
return element.querySelectorAll(selector);
|
return element.querySelectorAll(selector);
|
||||||
}
|
},
|
||||||
|
|
||||||
static findSingle(element, selector) {
|
findSingle(element, selector) {
|
||||||
return element.querySelector(selector);
|
return element.querySelector(selector);
|
||||||
}
|
},
|
||||||
|
|
||||||
static getHeight(el) {
|
getHeight(el) {
|
||||||
let height = el.offsetHeight;
|
let height = el.offsetHeight;
|
||||||
let style = getComputedStyle(el);
|
let style = getComputedStyle(el);
|
||||||
|
|
||||||
height -= parseFloat(style.paddingTop) + parseFloat(style.paddingBottom) + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
height -= parseFloat(style.paddingTop) + parseFloat(style.paddingBottom) + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
||||||
|
|
||||||
return height;
|
return height;
|
||||||
}
|
},
|
||||||
|
|
||||||
static getWidth(el) {
|
getWidth(el) {
|
||||||
let width = el.offsetWidth;
|
let width = el.offsetWidth;
|
||||||
let style = getComputedStyle(el);
|
let style = getComputedStyle(el);
|
||||||
|
|
||||||
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
|
width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
|
||||||
|
|
||||||
return width;
|
return width;
|
||||||
}
|
},
|
||||||
|
|
||||||
static absolutePosition(element, target) {
|
absolutePosition(element, target) {
|
||||||
let elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element)
|
let elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element)
|
||||||
let elementOuterHeight = elementDimensions.height;
|
let elementOuterHeight = elementDimensions.height;
|
||||||
let elementOuterWidth = elementDimensions.width;
|
let elementOuterWidth = elementDimensions.width;
|
||||||
|
@ -202,9 +202,9 @@ export default class DomHandler {
|
||||||
|
|
||||||
element.style.top = top + 'px';
|
element.style.top = top + 'px';
|
||||||
element.style.left = left + 'px';
|
element.style.left = left + 'px';
|
||||||
}
|
},
|
||||||
|
|
||||||
static relativePosition(element, target) {
|
relativePosition(element, target) {
|
||||||
let elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
|
let elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
|
||||||
const targetHeight = target.offsetHeight;
|
const targetHeight = target.offsetHeight;
|
||||||
const targetOffset = target.getBoundingClientRect();
|
const targetOffset = target.getBoundingClientRect();
|
||||||
|
@ -238,13 +238,13 @@ export default class DomHandler {
|
||||||
|
|
||||||
element.style.top = top + 'px';
|
element.style.top = top + 'px';
|
||||||
element.style.left = left + 'px';
|
element.style.left = left + 'px';
|
||||||
}
|
},
|
||||||
|
|
||||||
static getParents(element, parents = []) {
|
getParents(element, parents = []) {
|
||||||
return element['parentNode'] === null ? parents : this.getParents(element.parentNode, parents.concat([element.parentNode]));
|
return element['parentNode'] === null ? parents : this.getParents(element.parentNode, parents.concat([element.parentNode]));
|
||||||
}
|
},
|
||||||
|
|
||||||
static getScrollableParents(element) {
|
getScrollableParents(element) {
|
||||||
let scrollableParents = [];
|
let scrollableParents = [];
|
||||||
|
|
||||||
if (element) {
|
if (element) {
|
||||||
|
@ -274,9 +274,9 @@ export default class DomHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
return scrollableParents;
|
return scrollableParents;
|
||||||
}
|
},
|
||||||
|
|
||||||
static getHiddenElementOuterHeight(element) {
|
getHiddenElementOuterHeight(element) {
|
||||||
element.style.visibility = 'hidden';
|
element.style.visibility = 'hidden';
|
||||||
element.style.display = 'block';
|
element.style.display = 'block';
|
||||||
let elementHeight = element.offsetHeight;
|
let elementHeight = element.offsetHeight;
|
||||||
|
@ -284,9 +284,9 @@ export default class DomHandler {
|
||||||
element.style.visibility = 'visible';
|
element.style.visibility = 'visible';
|
||||||
|
|
||||||
return elementHeight;
|
return elementHeight;
|
||||||
}
|
},
|
||||||
|
|
||||||
static getHiddenElementOuterWidth(element) {
|
getHiddenElementOuterWidth(element) {
|
||||||
element.style.visibility = 'hidden';
|
element.style.visibility = 'hidden';
|
||||||
element.style.display = 'block';
|
element.style.display = 'block';
|
||||||
let elementWidth = element.offsetWidth;
|
let elementWidth = element.offsetWidth;
|
||||||
|
@ -294,9 +294,9 @@ export default class DomHandler {
|
||||||
element.style.visibility = 'visible';
|
element.style.visibility = 'visible';
|
||||||
|
|
||||||
return elementWidth;
|
return elementWidth;
|
||||||
}
|
},
|
||||||
|
|
||||||
static getHiddenElementDimensions(element) {
|
getHiddenElementDimensions(element) {
|
||||||
var dimensions = {};
|
var dimensions = {};
|
||||||
element.style.visibility = 'hidden';
|
element.style.visibility = 'hidden';
|
||||||
element.style.display = 'block';
|
element.style.display = 'block';
|
||||||
|
@ -306,9 +306,9 @@ export default class DomHandler {
|
||||||
element.style.visibility = 'visible';
|
element.style.visibility = 'visible';
|
||||||
|
|
||||||
return dimensions;
|
return dimensions;
|
||||||
}
|
},
|
||||||
|
|
||||||
static fadeIn(element, duration) {
|
fadeIn(element, duration) {
|
||||||
element.style.opacity = 0;
|
element.style.opacity = 0;
|
||||||
|
|
||||||
var last = +new Date();
|
var last = +new Date();
|
||||||
|
@ -324,9 +324,9 @@ export default class DomHandler {
|
||||||
};
|
};
|
||||||
|
|
||||||
tick();
|
tick();
|
||||||
}
|
},
|
||||||
|
|
||||||
static fadeOut(element, ms) {
|
fadeOut(element, ms) {
|
||||||
var opacity = 1,
|
var opacity = 1,
|
||||||
interval = 50,
|
interval = 50,
|
||||||
duration = ms,
|
duration = ms,
|
||||||
|
@ -342,22 +342,22 @@ export default class DomHandler {
|
||||||
|
|
||||||
element.style.opacity = opacity;
|
element.style.opacity = opacity;
|
||||||
}, interval);
|
}, interval);
|
||||||
}
|
},
|
||||||
|
|
||||||
static getUserAgent() {
|
getUserAgent() {
|
||||||
return navigator.userAgent;
|
return navigator.userAgent;
|
||||||
}
|
},
|
||||||
|
|
||||||
static appendChild(element, target) {
|
appendChild(element, target) {
|
||||||
if(this.isElement(target))
|
if(this.isElement(target))
|
||||||
target.appendChild(element);
|
target.appendChild(element);
|
||||||
else if(target.el && target.elElement)
|
else if(target.el && target.elElement)
|
||||||
target.elElement.appendChild(element);
|
target.elElement.appendChild(element);
|
||||||
else
|
else
|
||||||
throw new Error('Cannot append ' + target + ' to ' + element);
|
throw new Error('Cannot append ' + target + ' to ' + element);
|
||||||
}
|
},
|
||||||
|
|
||||||
static scrollInView(container, item) {
|
scrollInView(container, item) {
|
||||||
let borderTopValue = getComputedStyle(container).getPropertyValue('borderTopWidth');
|
let borderTopValue = getComputedStyle(container).getPropertyValue('borderTopWidth');
|
||||||
let borderTop = borderTopValue ? parseFloat(borderTopValue) : 0;
|
let borderTop = borderTopValue ? parseFloat(borderTopValue) : 0;
|
||||||
let paddingTopValue = getComputedStyle(container).getPropertyValue('paddingTop');
|
let paddingTopValue = getComputedStyle(container).getPropertyValue('paddingTop');
|
||||||
|
@ -375,9 +375,9 @@ export default class DomHandler {
|
||||||
else if ((offset + itemHeight) > elementHeight) {
|
else if ((offset + itemHeight) > elementHeight) {
|
||||||
container.scrollTop = scroll + offset - elementHeight + itemHeight;
|
container.scrollTop = scroll + offset - elementHeight + itemHeight;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static clearSelection() {
|
clearSelection() {
|
||||||
if(window.getSelection) {
|
if(window.getSelection) {
|
||||||
if(window.getSelection().empty) {
|
if(window.getSelection().empty) {
|
||||||
window.getSelection().empty();
|
window.getSelection().empty();
|
||||||
|
@ -392,9 +392,9 @@ export default class DomHandler {
|
||||||
//ignore IE bug
|
//ignore IE bug
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static calculateScrollbarWidth() {
|
calculateScrollbarWidth() {
|
||||||
if(this.calculatedScrollbarWidth != null)
|
if(this.calculatedScrollbarWidth != null)
|
||||||
return this.calculatedScrollbarWidth;
|
return this.calculatedScrollbarWidth;
|
||||||
|
|
||||||
|
@ -408,9 +408,9 @@ export default class DomHandler {
|
||||||
this.calculatedScrollbarWidth = scrollbarWidth;
|
this.calculatedScrollbarWidth = scrollbarWidth;
|
||||||
|
|
||||||
return scrollbarWidth;
|
return scrollbarWidth;
|
||||||
}
|
},
|
||||||
|
|
||||||
static getBrowser() {
|
getBrowser() {
|
||||||
if(!this.browser) {
|
if(!this.browser) {
|
||||||
let matched = this.resolveUserAgent();
|
let matched = this.resolveUserAgent();
|
||||||
this.browser = {};
|
this.browser = {};
|
||||||
|
@ -428,9 +428,9 @@ export default class DomHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.browser;
|
return this.browser;
|
||||||
}
|
},
|
||||||
|
|
||||||
static resolveUserAgent() {
|
resolveUserAgent() {
|
||||||
let ua = navigator.userAgent.toLowerCase();
|
let ua = navigator.userAgent.toLowerCase();
|
||||||
let match = /(chrome)[ ]([\w.]+)/.exec(ua) ||
|
let match = /(chrome)[ ]([\w.]+)/.exec(ua) ||
|
||||||
/(webkit)[ ]([\w.]+)/.exec(ua) ||
|
/(webkit)[ ]([\w.]+)/.exec(ua) ||
|
||||||
|
@ -443,17 +443,17 @@ export default class DomHandler {
|
||||||
browser: match[1] || "",
|
browser: match[1] || "",
|
||||||
version: match[2] || "0"
|
version: match[2] || "0"
|
||||||
};
|
};
|
||||||
}
|
},
|
||||||
|
|
||||||
static isVisible(element) {
|
isVisible(element) {
|
||||||
return element.offsetParent != null;
|
return element.offsetParent != null;
|
||||||
}
|
},
|
||||||
|
|
||||||
static invokeElementMethod(element, methodName, args) {
|
invokeElementMethod(element, methodName, args) {
|
||||||
(element)[methodName].apply(element, args);
|
(element)[methodName].apply(element, args);
|
||||||
}
|
},
|
||||||
|
|
||||||
static getFocusableElements(element) {
|
getFocusableElements(element) {
|
||||||
let focusableElements = DomHandler.find(element, `button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
|
let focusableElements = DomHandler.find(element, `button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
|
||||||
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
|
[href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
|
||||||
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
|
input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]), select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden]),
|
||||||
|
@ -468,9 +468,9 @@ export default class DomHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
return visibleFocusableElements;
|
return visibleFocusableElements;
|
||||||
}
|
},
|
||||||
|
|
||||||
static isClickable(element) {
|
isClickable(element) {
|
||||||
const targetNode = element.nodeName;
|
const targetNode = element.nodeName;
|
||||||
const parentNode = element.parentElement && element.parentElement.nodeName;
|
const parentNode = element.parentElement && element.parentElement.nodeName;
|
||||||
|
|
||||||
|
@ -479,9 +479,9 @@ export default class DomHandler {
|
||||||
this.hasClass(element, 'p-button') || this.hasClass(element.parentElement, 'p-button') ||
|
this.hasClass(element, 'p-button') || this.hasClass(element.parentElement, 'p-button') ||
|
||||||
this.hasClass(element.parentElement, 'p-checkbox') || this.hasClass(element.parentElement, 'p-radiobutton')
|
this.hasClass(element.parentElement, 'p-checkbox') || this.hasClass(element.parentElement, 'p-radiobutton')
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
|
|
||||||
static applyStyle(element, style) {
|
applyStyle(element, style) {
|
||||||
if (typeof style === 'string') {
|
if (typeof style === 'string') {
|
||||||
element.style.cssText = this.style;
|
element.style.cssText = this.style;
|
||||||
}
|
}
|
||||||
|
@ -490,17 +490,17 @@ export default class DomHandler {
|
||||||
element.style[prop] = style[prop];
|
element.style[prop] = style[prop];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static isIOS() {
|
isIOS() {
|
||||||
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window['MSStream'];
|
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window['MSStream'];
|
||||||
}
|
},
|
||||||
|
|
||||||
static isAndroid() {
|
isAndroid() {
|
||||||
return /(android)/i.test(navigator.userAgent);
|
return /(android)/i.test(navigator.userAgent);
|
||||||
}
|
},
|
||||||
|
|
||||||
static isTouchDevice() {
|
isTouchDevice() {
|
||||||
return (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0));
|
return (('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
export default class ObjectUtils {
|
export default {
|
||||||
|
|
||||||
static equals(obj1, obj2, field) {
|
equals(obj1, obj2, field) {
|
||||||
if (field)
|
if (field)
|
||||||
return (this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field));
|
return (this.resolveFieldData(obj1, field) === this.resolveFieldData(obj2, field));
|
||||||
else
|
else
|
||||||
return this.deepEquals(obj1, obj2);
|
return this.deepEquals(obj1, obj2);
|
||||||
}
|
},
|
||||||
|
|
||||||
static deepEquals(a, b) {
|
deepEquals(a, b) {
|
||||||
if (a === b) return true;
|
if (a === b) return true;
|
||||||
|
|
||||||
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
if (a && b && typeof a == 'object' && typeof b == 'object') {
|
||||||
|
@ -55,9 +55,9 @@ export default class ObjectUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
return a !== a && b !== b;
|
return a !== a && b !== b;
|
||||||
}
|
},
|
||||||
|
|
||||||
static resolveFieldData(data, field) {
|
resolveFieldData(data, field) {
|
||||||
if (data && Object.keys(data).length && field) {
|
if (data && Object.keys(data).length && field) {
|
||||||
if (this.isFunction(field)) {
|
if (this.isFunction(field)) {
|
||||||
return field(data);
|
return field(data);
|
||||||
|
@ -80,13 +80,13 @@ export default class ObjectUtils {
|
||||||
else {
|
else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static isFunction(obj) {
|
isFunction(obj) {
|
||||||
return !!(obj && obj.constructor && obj.call && obj.apply);
|
return !!(obj && obj.constructor && obj.call && obj.apply);
|
||||||
}
|
},
|
||||||
|
|
||||||
static filter(value, fields, filterValue) {
|
filter(value, fields, filterValue) {
|
||||||
var filteredItems = [];
|
var filteredItems = [];
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
|
@ -101,9 +101,9 @@ export default class ObjectUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
return filteredItems;
|
return filteredItems;
|
||||||
}
|
},
|
||||||
|
|
||||||
static reorderArray(value, from, to) {
|
reorderArray(value, from, to) {
|
||||||
let target;
|
let target;
|
||||||
if (value && (from !== to)) {
|
if (value && (from !== to)) {
|
||||||
if (to >= value.length) {
|
if (to >= value.length) {
|
||||||
|
@ -114,9 +114,9 @@ export default class ObjectUtils {
|
||||||
}
|
}
|
||||||
value.splice(to, 0, value.splice(from, 1)[0]);
|
value.splice(to, 0, value.splice(from, 1)[0]);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static findIndexInList(value, list) {
|
findIndexInList(value, list) {
|
||||||
let index = -1;
|
let index = -1;
|
||||||
|
|
||||||
if (list) {
|
if (list) {
|
||||||
|
@ -129,9 +129,9 @@ export default class ObjectUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
return index;
|
return index;
|
||||||
}
|
},
|
||||||
|
|
||||||
static contains(value, list) {
|
contains(value, list) {
|
||||||
if (value != null && list && list.length) {
|
if (value != null && list && list.length) {
|
||||||
for (let val of list) {
|
for (let val of list) {
|
||||||
if (this.equals(value, val))
|
if (this.equals(value, val))
|
||||||
|
@ -140,9 +140,9 @@ export default class ObjectUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
},
|
||||||
|
|
||||||
static insertIntoOrderedArray(item, index, arr, sourceArr) {
|
insertIntoOrderedArray(item, index, arr, sourceArr) {
|
||||||
if (arr.length > 0) {
|
if (arr.length > 0) {
|
||||||
let injected = false;
|
let injected = false;
|
||||||
for (let i = 0; i < arr.length; i++) {
|
for (let i = 0; i < arr.length; i++) {
|
||||||
|
@ -161,9 +161,9 @@ export default class ObjectUtils {
|
||||||
else {
|
else {
|
||||||
arr.push(item);
|
arr.push(item);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
|
||||||
static removeAccents(str) {
|
removeAccents(str) {
|
||||||
if (str && str.search(/[\xC0-\xFF]/g) > -1) {
|
if (str && str.search(/[\xC0-\xFF]/g) > -1) {
|
||||||
str = str
|
str = str
|
||||||
.replace(/[\xC0-\xC5]/g, "A")
|
.replace(/[\xC0-\xC5]/g, "A")
|
||||||
|
@ -190,9 +190,9 @@ export default class ObjectUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
},
|
||||||
|
|
||||||
static getVNodeProp(vnode, prop) {
|
getVNodeProp(vnode, prop) {
|
||||||
let props = vnode.props;
|
let props = vnode.props;
|
||||||
if (props) {
|
if (props) {
|
||||||
let kebapProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
let kebapProp = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||||
|
|
Loading…
Reference in New Issue