@pernod-ricard-global-cms/jsutils 1.5.21 → 1.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jsutils.js +25 -1
- package/package.json +1 -1
package/jsutils.js
CHANGED
|
@@ -52,6 +52,9 @@ export function toggleClassByValidity( input, button ) {
|
|
|
52
52
|
* @returns {boolean}
|
|
53
53
|
*/
|
|
54
54
|
export function inCriticalCssConfig( assetKey ) {
|
|
55
|
+
if(!globalThis.criticalConfig) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
55
58
|
if (
|
|
56
59
|
globalThis.criticalConfig &&
|
|
57
60
|
globalThis.criticalConfig.indexOf( assetKey ) === -1
|
|
@@ -87,6 +90,9 @@ export function checkDevice() {
|
|
|
87
90
|
try {
|
|
88
91
|
const deviceAgent = navigator.userAgent.toLowerCase();
|
|
89
92
|
const htmlElement = document.querySelector( 'html' );
|
|
93
|
+
if ( ( 'ontouchstart' in globalThis )&&( (window.screen.width * window.devicePixelRatio) >= 2048 ) && (window.screen.width<window.screen.height)) {
|
|
94
|
+
htmlElement.classList.add( 'highResTabletPortrait' );
|
|
95
|
+
}
|
|
90
96
|
if ( 'ontouchstart' in globalThis ) {
|
|
91
97
|
htmlElement.classList.add( 'touch' );
|
|
92
98
|
}
|
|
@@ -533,6 +539,23 @@ export function detectSwipe(element, callback, removeHandlers = false) {
|
|
|
533
539
|
}
|
|
534
540
|
}
|
|
535
541
|
|
|
542
|
+
/**
|
|
543
|
+
* Function for getting the ios operating system version
|
|
544
|
+
*
|
|
545
|
+
* @returns {number} the ios version
|
|
546
|
+
*/
|
|
547
|
+
export function checkIosVersion() {
|
|
548
|
+
const agent = window.navigator.userAgent,
|
|
549
|
+
start = agent.indexOf('OS ');
|
|
550
|
+
if (
|
|
551
|
+
(agent.indexOf('iPhone') > -1 || agent.indexOf('iPad') > -1) &&
|
|
552
|
+
start > -1
|
|
553
|
+
) {
|
|
554
|
+
return window.Number(agent.substr(start + 3, 3).replace('_', '.'));
|
|
555
|
+
}
|
|
556
|
+
return 0;
|
|
557
|
+
}
|
|
558
|
+
|
|
536
559
|
const api = {
|
|
537
560
|
copyToClipboard,
|
|
538
561
|
checkDevice,
|
|
@@ -555,6 +578,7 @@ const api = {
|
|
|
555
578
|
toggleClassByValidity,
|
|
556
579
|
waitForLoad,
|
|
557
580
|
getElementStyles,
|
|
558
|
-
getPercent
|
|
581
|
+
getPercent,
|
|
582
|
+
checkIosVersion
|
|
559
583
|
};
|
|
560
584
|
export default api;
|