]> git.mjollnir.org Git - moodle.git/commitdiff
mod-scorm MDL-16706 Replaced inline JS with new PAGE methods and created player.js
authorsamhemelryk <samhemelryk>
Mon, 29 Jun 2009 02:38:22 +0000 (02:38 +0000)
committersamhemelryk <samhemelryk>
Mon, 29 Jun 2009 02:38:22 +0000 (02:38 +0000)
mod/scorm/player.js [new file with mode: 0644]
mod/scorm/player.php
mod/scorm/rd.js

diff --git a/mod/scorm/player.js b/mod/scorm/player.js
new file mode 100644 (file)
index 0000000..7efb130
--- /dev/null
@@ -0,0 +1,17 @@
+function scorm_openpopup(url,name,options,width,height) {
+    fullurl = moodle_cfg.wwwroot + '/mod/scorm/' + url;
+    windowobj = window.open(fullurl,name,options);
+    if ((width==100) && (height==100)) {
+        // Fullscreen
+        windowobj.moveTo(0,0);
+    }
+    if (width<=100) {
+        width = Math.round(screen.availWidth * width / 100);
+    }
+    if (height<=100) {
+        height = Math.round(screen.availHeight * height / 100);
+    }
+    windowobj.resizeTo(width,height);
+    windowobj.focus();
+    return windowobj;
+}
\ No newline at end of file
index dd5a48dbb2adbed8a79109e5762c2e701f49f4bc..e51788a3bab3b757cef30c87b82e8d9c9b4d7367 100755 (executable)
                  $navigation,
                  '', '', true, $exitlink.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript);
 
-    echo $PAGE->requires->data_for_js('scormdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height))->asap();
+    echo $PAGE->requires->data_for_js('scormplayerdata', Array('cwidth'=>$scorm->width,'cheight'=>$scorm->height))->asap();
     echo $PAGE->requires->js('mod/scorm/request.js')->asap();
     echo $PAGE->requires->js('mod/scorm/loaddatamodel.php?id='.$cm->id.$scoidstr.$modestr.$attemptstr)->asap();
     echo $PAGE->requires->js('mod/scorm/rd.js')->asap();
         if ($scorm->popup == 0) {
             $fullurl="loadSCO.php?id=".$cm->id.$scoidstr.$modestr;
             echo "                <iframe id=\"scoframe1\" class=\"scoframe\" name=\"scoframe1\" src=\"{$fullurl}\"></iframe>\n";
-            $PAGE->requires->js_function_call('scorm_resize', Array($scorm->width, $scorm->height));
+            $PAGE->requires->js_function_call('scorm_resize');
         } else {
             // Clean the name for the window as IE is fussy
             $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name);
                 $name = 'DefaultPlayerWindow';
             }
             $name = 'scorm_'.$name;
-            ?>
-                    <script type="text/javascript">
-                    //<![CDATA[
-                   scorm_resize(<?php echo $scorm->width.", ". $scorm->height; ?>);
-                        function openpopup(url,name,options,width,height) {
-                            fullurl = "<?php echo $CFG->wwwroot.'/mod/scorm/' ?>" + url;
-                            windowobj = window.open(fullurl,name,options);
-                            if ((width==100) && (height==100)) {
-                                // Fullscreen
-                                windowobj.moveTo(0,0);
-                            }
-                            if (width<=100) {
-                                width = Math.round(screen.availWidth * width / 100);
-                            }
-                            if (height<=100) {
-                                height = Math.round(screen.availHeight * height / 100);
-                            }
-                            windowobj.resizeTo(width,height);
-                            windowobj.focus();
-                            return windowobj;
-                        }
 
-                        url = "loadSCO.php?id=<?php echo $cm->id.$scoidpop ?>";
-                        width = <?php p($scorm->width) ?>;
-                        height = <?php p($scorm->height) ?>;
-                        var main = openpopup(url, "<?php p($name) ?>", "<?php p($scorm->options) ?>", width, height);
-                   //]]>
-                    </script>
+            echo $PAGE->requires->js_function_call('scorm_resize')->asap();
+            echo $PAGE->requires->js('mod/scorm/player.js')->asap();
+            echo $PAGE->requires->js_function_call('scorm_openpopup', Array("loadSCO.php?id=".$cm->id.$scoidpop, p($name), p($scorm->options), p($scorm->width), p($scorm->height)))->asap();
+            ?>
                     <noscript>
                     <iframe id="main" class="scoframe" src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr ?>">
                     </iframe>
index 872abd25336e0b84031839544ca9aa622cd4513b..e4eebcf62d3ffbe8930aa59a263e53fbc33a7ed8 100644 (file)
@@ -1,5 +1,5 @@
 <!--
-function attach_resize_event(scormwidth, scormheight) {
+function attach_resize_event() {
     YAHOO.util.Event.addListener(window, 'resize', scorm_resize);
 }
 
@@ -26,9 +26,9 @@ function scorm_get_element_style(obj, prop, cssProp) {
     return ret;
 }
 
-function scorm_resize (cwidth, cheight) {
-    var cwidth = scormdata.cwidth;
-    var cheight = scormdata.cheight;
+function scorm_resize () {
+    var cwidth = scormplayerdata.cwidth;
+    var cheight = scormplayerdata.cheight;
     var winwidth = 0, winheight = 0;
     if( typeof( window.innerWidth ) == 'number' ) {
         //Non-IE