roman.lesnikov@gmail.com 3 лет назад
Родитель
Сommit
b5a520f595
1 измененных файлов с 30 добавлено и 1 удалено
  1. 30 1
      oembed.php

+ 30 - 1
oembed.php

@@ -16,7 +16,36 @@ bx_import('BxDolEmbed');
 $oEmbed = BxDolEmbed::getObjectInstance('sys_iframely');
 
 if (bx_get('html')){
-    echo '<div style="max-width:900; margin:0px auto; justify-content: center; ">' . $oEmbed->getDataHtml($aLinks, bx_get('theme')) . '</div>';
+    echo '<style>body, html {margin:0px}</style><div style="max-width:900; margin:0px auto; justify-content: center;" id="ifr">' . $oEmbed->getDataHtml($aLinks, bx_get('theme')) . '<script language="javascript" src="'.BX_DOL_URL_ROOT.'/plugins_public/jquery/jquery.min.js"></script><script>
+    $(document).ready(function () {
+        a = ["' . bx_get('hash') . '",  $("#ifr").height(),$("#ifr").width()];
+        try{
+            window.parent.postMessage(JSON.stringify(a), "*");
+            window.ReactNativeWebView.postMessage(JSON.stringify(a));
+         }
+         catch(){}
+    })
+    window.addEventListener("message", function(event) {
+        if (event.data && event.data!=""){
+            try {
+            a = JSON.parse(event.data);
+                    } catch (e) {
+            console.error("Failed to parse JSON:", event.data);
+            throw e;
+        }
+            if (a && a.method=="resize"){
+                a = ["' . bx_get('hash') . '",  a.height,$(".iframely-embed").width()];
+                try{
+                window.parent.postMessage(JSON.stringify(a), "*");
+                window.ReactNativeWebView.postMessage(JSON.stringify(a));
+                }
+                catch(){}  
+            }
+        }
+       
+    }, false);
+    
+  </script></div>';
     exit();
 }
 echoJson($oEmbed->parseLinks($aLinks));