From: samhemelryk Date: Fri, 26 Jun 2009 06:31:26 +0000 (+0000) Subject: mod-scorm MDL-16706 Removed inline JS and replaced with new PAGE methods X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=bd257031a90778413df390003134f4eba6595acb;p=moodle.git mod-scorm MDL-16706 Removed inline JS and replaced with new PAGE methods --- diff --git a/mod/scorm/datamodels/scorm_12lib.php b/mod/scorm/datamodels/scorm_12lib.php index be20df944e..076e399c02 100644 --- a/mod/scorm/datamodels/scorm_12lib.php +++ b/mod/scorm/datamodels/scorm_12lib.php @@ -107,7 +107,7 @@ function scorm_eval_prerequisites($prerequisites, $usertracks) { } function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='normal',$attempt='',$play=false) { - global $CFG, $DB; + global $CFG, $DB, $PAGE; $strexpand = get_string('expcoll','scorm'); $modestr = ''; @@ -318,25 +318,8 @@ function scorm_get_toc($user,$scorm,$liststyle,$currentorg='',$scoid='',$mode='n } $result->toc .= "\t\n"; if ($scorm->hidetoc == 0) { - $result->toc .= ' - '."\n"; + $PAGE->requires->data_for_js('scormdata', Array('scormpixdir'=>$scormpixdir)); + $PAGE->requires->js('mod/scorm/datamodels/scorm_datamodels.js'); } $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='; diff --git a/mod/scorm/datamodels/scorm_13lib.php b/mod/scorm/datamodels/scorm_13lib.php index 626358bfd3..14dddb0390 100644 --- a/mod/scorm/datamodels/scorm_13lib.php +++ b/mod/scorm/datamodels/scorm_13lib.php @@ -1,7 +1,7 @@ toc .= "\t\n"; if ($scorm->hidetoc == 0) { - $result->toc .= ' - '."\n"; + $PAGE->requires->data_for_js('scormdata', Array('scormpixdir'=>$scormpixdir)); + $PAGE->requires->js('mod/scorm/datamodels/scorm_datamodels.js'); } $url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='; diff --git a/mod/scorm/datamodels/scorm_datamodels.js b/mod/scorm/datamodels/scorm_datamodels.js new file mode 100644 index 0000000000..071c4c5e78 --- /dev/null +++ b/mod/scorm/datamodels/scorm_datamodels.js @@ -0,0 +1,14 @@ +function expandCollide(which,list,item) { + var el = document.ids ? document.ids[list] : document.getElementById ? document.getElementById(list) : document.all[list]; + which = which.substring(0,(which.length)); + var el2 = document.ids ? document.ids[which] : document.getElementById ? document.getElementById(which) : document.all[which]; + if (el.style.display != "none") { + el2.src = scormdata.scormpixdir+"/plus.gif"; + el.style.display='none'; + new cookie("hide:SCORMitem" + item, 1, 356, "/").set(); + } else { + el2.src = scormdata.scormpixdir+"/minus.gif"; + el.style.display='block'; + new cookie("hide:SCORMitem" + item, 1, -1, "/").set(); + } +} \ No newline at end of file diff --git a/mod/scorm/player.php b/mod/scorm/player.php index b0a6091dbc..dd5a48dbb2 100755 --- a/mod/scorm/player.php +++ b/mod/scorm/player.php @@ -157,31 +157,24 @@ print_header($pagetitle, $course->fullname, $navigation, '', '', true, $exitlink.update_module_button($cm->id, $course->id, $strscorm), '', false, $bodyscript); - //if ($sco->scormtype == 'sco') { -?> - - - - -requires->data_for_js('scormdata', 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(); + $PAGE->requires->js_function_call('attach_resize_event'); + if (($sco->previd != 0) && ((!isset($sco->previous)) || ($sco->previous == 0))) { $scostr = '&scoid='.$sco->previd; - echo ' \n"; + $PAGE->requires->js_function_call('scorm_set_prev', Array($CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr)); } else { - echo ' \n"; + $PAGE->requires->js_function_call('scorm_set_prev', Array($CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id)); } if (($sco->nextid != 0) && ((!isset($sco->next)) || ($sco->next == 0))) { $scostr = '&scoid='.$sco->nextid; - echo ' \n"; + $PAGE->requires->js_function_call('scorm_set_next', Array($CFG->wwwroot.'/mod/scorm/player.php?id='.$cm->id.$orgstr.$modepop.$scostr)); } else { - echo ' \n"; + $PAGE->requires->js_function_call('scorm_set_next', Array($CFG->wwwroot.'/mod/scorm/view.php?id='.$cm->id)); } ?>
@@ -301,9 +294,9 @@ prerequisites) { if ($scorm->popup == 0) { - echo " \n"; $fullurl="loadSCO.php?id=".$cm->id.$scoidstr.$modestr; echo " \n"; + $PAGE->requires->js_function_call('scorm_resize', Array($scorm->width, $scorm->height)); } else { // Clean the name for the window as IE is fussy $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name); diff --git a/mod/scorm/rd.js b/mod/scorm/rd.js index c8c3038e01..872abd2533 100644 --- a/mod/scorm/rd.js +++ b/mod/scorm/rd.js @@ -1,4 +1,17 @@