AntonLV 5 лет назад
Родитель
Сommit
20d51b45bd

+ 8 - 0
inc/js/functions.js

@@ -1181,6 +1181,14 @@ function bx_prompt(sMessage, sValue, fOnClickOk, fOnClickCancel, oParams)
     });
 }
 
+/**
+ * Check if mobile or desktop device.
+ */
+function bx_check_mq()
+{
+    return window.getComputedStyle(document.querySelector('body'), '::before').getPropertyValue('content').replace(/'/g, "").replace(/"/g, "");
+}
+
 /**
  * This function loads the passed list of js files and executes callback function when the all files are loaded.
  * In case when this function is called for dynamic loading of the same file but many times (like Plyr video init)

+ 5 - 0
template/css/media-desktop.css

@@ -3,6 +3,11 @@ html.bx-media-desktop {
     font-size:100%;
 }
 
+/* never visible - used to check MQ */
+.bx-media-desktop body::before {
+    content: 'desktop';
+}
+
 .bx-media-desktop .bx-def-media-desktop-hide {
     display:none !important;
 }

+ 6 - 0
template/css/media-phone.css

@@ -3,6 +3,12 @@ html.bx-media-phone {
     font-size:85%;
 }
 
+/* never visible - used to check MQ */
+.bx-media-phone body::before {
+  display: none;
+  content: 'mobile';
+}
+
 .bx-media-phone .bx-def-media-phone-hide {
     display:none !important;
 }

+ 5 - 0
template/css/media-tablet.css

@@ -3,6 +3,11 @@ html.bx-media-tablet {
     font-size:100%;
 }
 
+/* never visible - used to check MQ */
+.bx-media-tablet body::before {
+    content: 'tablet';
+}
+
 .bx-media-tablet .bx-def-media-tablet-hide {
     display:none !important;
 }