瀏覽代碼

Remove setFrameReady() function that hardcoded portal URL in the main.js file

See:

https://github.com/chamilo/chamilo-lms/commit/c7b881eecc33fc75b4091cc670c72a7f770b9ab5?diff=unified
Julio Montoya 6 年之前
父節點
當前提交
0928cb0bc2

+ 2 - 5
main/document/showinframes.php

@@ -174,9 +174,7 @@ if (api_is_course_admin()) {
     $frameheight = 165;
 }
 
-$js_glossary_in_documents = '
-    setFrameReady("mainFrame", _p);
-';
+$frameReady = Display::getFrameReadyBlock('top.mainFrame');
 
 $web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
 // PDF should be displayed with viewerJS
@@ -252,8 +250,7 @@ if (!$playerSupported && $execute_iframe) {
         // Fixes the content height of the frame
         window.onload = function() {
             updateContentHeight();
-            '.$js_glossary_in_documents.'
-
+            '.$frameReady.'
         }
     </script>';
 }

+ 52 - 0
main/inc/lib/display.lib.php

@@ -2745,4 +2745,56 @@ HTML;
                     <hr />
               </div>';
     }
+
+    /**
+     * @param string $frameName
+     *
+     * @return string
+     */
+    public static function getFrameReadyBlock($frameName)
+    {
+        $defaultFeatures = ['playpause', 'current', 'progress', 'duration', 'tracks', 'volume', 'fullscreen', 'vrview'];
+        $features = api_get_configuration_value('video_features');
+        if (!empty($features) && isset($features['features'])) {
+            foreach ($features['features'] as $feature) {
+                if ($feature === 'vrview') {
+                    continue;
+                }
+                $defaultFeatures[] = $feature;
+            }
+        }
+
+        $defaultFeatures = implode("','", $defaultFeatures);
+        $frameReady = '
+          $.frameReady(function() {
+            $(document).ready(function () {
+                $("video:not(.skip), audio:not(.skip)").mediaelementplayer({
+                    pluginPath: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/",            
+                    features: ["'.$defaultFeatures.'"],
+                    success: function(mediaElement, originalNode, instance) {
+                    },
+                    vrPath: "'.api_get_path(WEB_PUBLIC_PATH).'assets/vrview/build/vrview.js"
+                });
+            });
+          }, "'.$frameName.'",
+          {
+            load: [
+                { type:"script", id:"_fr1", src:"'.api_get_jquery_web_path().'"},
+                { type:"script", id:"_fr7", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/MathJax/MathJax.js?config=AM_HTMLorMML"},
+                { type:"script", id:"_fr4", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/jquery-ui.min.js"},
+                { type:"stylesheet", id:"_fr5", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/jquery-ui.min.css"},
+                { type:"stylesheet", id:"_fr6", src:"'.api_get_path(WEB_PUBLIC_PATH).'assets/jquery-ui/themes/smoothness/theme.css"},
+                { type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
+                { type:"script", id:"_fr3", src:"'.api_get_path(WEB_CODE_PATH).'glossary/glossary.js.php?'.api_get_cidreq().'"},
+                {type: "script", id: "_media1", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/mediaelement-and-player.min.js"},
+                {type: "stylesheet", id: "_media2", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/build/mediaelementplayer.min.css"},                
+                {type: "stylesheet", id: "_media4", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/plugins/vrview/vrview.css"},
+                {type: "script", id: "_media4", src: "'.api_get_path(WEB_PUBLIC_PATH).'assets/mediaelement/plugins/vrview/vrview.js"},
+            ]
+          });';
+
+        return $frameReady;
+
+
+    }
 }

+ 2 - 0
main/lp/lp_view.php

@@ -623,6 +623,8 @@ $template->assign(
     )
 );
 
+$frameReady = Display::getFrameReadyBlock('top.content_name');
+$template->assign('frame_ready', $frameReady);
 $view = $template->get_template('learnpath/view.tpl');
 $content = $template->fetch($view);
 

+ 0 - 34
main/template/default/layout/main.js.tpl

@@ -598,38 +598,4 @@ function copyTextToClipBoard(elementId)
 
     /* Copy the text inside the text field */
     document.execCommand("copy");
-
-    /* Alert the copied text */
-    //alert('Copied');
 }
-
-function setFrameReady(iframeName, _p)
-{
-    $(document).ready(function () {
-        $('video:not(.skip), audio:not(.skip)').mediaelementplayer({
-            pluginPath: _p.web + 'web/assets/mediaelement/build/',
-            //renderers: ['html5', 'flash_video', 'native_flv'],
-            features: ['{{ video_features }}'],
-            success: function(mediaElement, originalNode, instance) {
-            },
-            vrPath: _p.web + 'web/assets/vrview/build/vrview.js'
-        });
-    });
-
-    $.frameReady(function () {
-    }, 'top.' + iframeName, {
-        load: [
-            {type: 'script', id: '_fr1', src: _p.web + 'web/assets/jquery/dist/jquery.min.js'},
-            {type: 'script', id: '_fr7', src: _p.web + 'web/assets/MathJax/MathJax.js?config=AM_HTMLorMML'},
-            {type: 'script', id: '_fr4', src: _p.web + 'web/assets/jquery-ui/jquery-ui.min.js'},
-            {type: 'stylesheet', id: '_fr5', src: _p.web + 'web/assets/jquery-ui/themes/smoothness/jquery-ui.min.css'},
-            {type: 'stylesheet', id: '_fr6', src: _p.web + 'web/assets/jquery-ui/themes/smoothness/theme.css'},
-            {type: 'script', id: '_fr2', src: _p.web + 'main/inc/lib/javascript/jquery.highlight.js'},
-            {type: 'script', id: '_fr3', src: _p.web + 'main/glossary/glossary.js.php?' + _p.web_cid_query },
-            {type: 'script', id: '_media1', src: _p.web + 'web/assets/mediaelement/build/mediaelement-and-player.min.js'},
-            {type: 'stylesheet', id: '_media2', src: _p.web + 'web/assets/mediaelement/build/mediaelementplayer.min.css'},
-            {type: 'stylesheet', id: '_media4', src: _p.web + 'web/assets/mediaelement/plugins/vrview/vrview.css'},
-            {type: 'script', id: '_media4', src: _p.web + 'web/assets/mediaelement/plugins/vrview/vrview.js'},
-        ]
-    });
-}

+ 7 - 5
main/template/default/learnpath/view.tpl

@@ -384,11 +384,13 @@
             })();
         {% endif %}
         {% if disable_js_in_lp_view == 0 %}
-            $('iframe#content_id').on('load', function () {
-                var arr = ['link', 'sco'];
-                if (!$.inArray(olms.lms_item_type, arr)) {
-                    setFrameReady('content_name', _p);
-                }
+            $(document).ready(function () {
+                $('iframe#content_id').on('load', function () {
+                    var arr = ['link', 'sco'];
+                    if (!$.inArray(olms.lms_item_type, arr)) {
+                        {{ frame_ready }}
+                    }
+                });
             });
         {% endif %}