Permalink
Browse files

improved the display of "Give Up" button and <IFRAME> navigation butt…

…ons (however <IFRAME> still does not resize on FireFox)
  • Loading branch information...
1 parent 3bb2ac0 commit b045850b401fda5b98c40cfb60a09ac014ab829a gbateson committed Sep 28, 2005
Showing with 51 additions and 45 deletions.
  1. +18 −16 mod/hotpot/iframe.js
  2. +5 −6 mod/hotpot/lib.php
  3. +28 −23 mod/hotpot/view.php
View
@@ -16,16 +16,16 @@ function px(i) {
return i + "px";
}
function setSize(obj, w, h) {
- if (is.n4) with (obj) {
- if (w) width = w;
- if (h) height = h;
- } else if (is.opera) with (obj.style) {
+ if (is.n4) {
+ if (w) obj.width = w;
+ if (h) obj.height = h;
+ } else if (is.opera) {
// opera 5 needs pixelWidth/Height
- if (w) pixelWidth = w;
- if (h) pixelHeight = h;
- } else with (obj.style) {
- if (w) width = px(w);
- if (h) height = px(h);
+ if (w) obj.style.pixelWidth = w;
+ if (h) obj.style.pixelHeight = h;
+ } else {
+ if (w) obj.style.width = px(w);
+ if (h) obj.style.height = px(h);
}
}
function getElement(id, lyr) {
@@ -37,13 +37,15 @@ is = new domSniffer();
function set_iframe_height(id) {
var iframe = getElement(id);
if (iframe) {
- obj = iframe.document;
- if (obj.body) {
- obj = obj.body;
- }
- var h = getContentH(obj);
- if (h) {
- setSize(iframe, 0, h);
+ var obj = iframe.document || iframe.contentDocument || null; // IE || FireFox
+ if (obj) {
+ if (obj.body) {
+ obj = obj.body;
+ }
+ var h = getContentH(obj);
+ if (h) {
+ setSize(iframe, 0, h);
+ }
}
}
}
View
@@ -49,10 +49,10 @@
HOTPOT_OUTPUTFORMAT_BEST => get_string("outputformat_best", "hotpot"),
HOTPOT_OUTPUTFORMAT_V6_PLUS => get_string("outputformat_v6_plus", "hotpot"),
HOTPOT_OUTPUTFORMAT_V6 => get_string("outputformat_v6", "hotpot"),
- // HOTPOT_OUTPUTFORMAT_V5_PLUS => get_string("outputformat_v5_plus", "hotpot"),
- // HOTPOT_OUTPUTFORMAT_V5 => get_string("outputformat_v5", "hotpot"),
- // HOTPOT_OUTPUTFORMAT_V4 => get_string("outputformat_v4", "hotpot"),
- // HOTPOT_OUTPUTFORMAT_V3 => get_string("outputformat_v3", "hotpot"),
+ HOTPOT_OUTPUTFORMAT_V5_PLUS => get_string("outputformat_v5_plus", "hotpot"),
+ HOTPOT_OUTPUTFORMAT_V5 => get_string("outputformat_v5", "hotpot"),
+ HOTPOT_OUTPUTFORMAT_V4 => get_string("outputformat_v4", "hotpot"),
+ HOTPOT_OUTPUTFORMAT_V3 => get_string("outputformat_v3", "hotpot"),
// HOTPOT_OUTPUTFORMAT_FLASH => get_string("outputformat_flash", "hotpot"),
// HOTPOT_OUTPUTFORMAT_MOBILE => get_string("outputformat_mobile", "hotpot"),
);
@@ -1627,8 +1627,7 @@ function insert_giveup_form($attemptid, $startblock, $endblock) {
}
function insert_form($startblock, $endblock, $form_name, $form_fields, $center=false) {
global $CFG;
- $char = substr($endblock, 0, 1);
- $search = '#(?<='.preg_quote($startblock).')'."[^$char]*".'(?='.preg_quote($endblock).')#';
+ $search = '#(?<='.preg_quote($startblock).')(.+?)(?='.preg_quote($endblock).')#s';
$replace = '<form action="'.$CFG->wwwroot.'/mod/hotpot/attempt.php" method="POST" name="'.$form_name.'" target="'.$CFG->framename.'">'.$form_fields.'</form>';
if ($center) {
$replace = '<div style="margin-left:auto; margin-right:auto; text-align: center;">'.$replace.'</div>';
View
@@ -140,7 +140,7 @@
$get_css = optional_param('css');
$framename = optional_param('framename');
- // look for <FRAMESET> (v5)
+ // look for <FRAMESET> (HP5 v5)
$frameset = '';
$frameset_tags = '';
if (preg_match_all('|<frameset([^>]*)>(.*?)</frameset>|is', $hp->html, $matches)) {
@@ -176,26 +176,30 @@
if (empty($frameset)) {
// HP6 v6
- if ($hotpot->navigation==HOTPOT_NAVIGATION_BUTTONS) {
- // convert URLs in nav buttons
- } else {
- $hp->remove_nav_buttons();
- }
- if ($hotpot->navigation==HOTPOT_NAVIGATION_GIVEUP) {
- $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
+ switch ($hotpot->navigation) {
+ case HOTPOT_NAVIGATION_BUTTONS:
+ // do nothing (i.e. leave buttons as they are)
+ break;
+ case HOTPOT_NAVIGATION_GIVEUP:
+ $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
+ break;
+ default:
+ $hp->remove_nav_buttons();
}
$hp->insert_submission_form($attemptid, '<!-- BeginSubmissionForm -->', '<!-- EndSubmissionForm -->');
} else {
// HP5 v5
- if ($hotpot->navigation==HOTPOT_NAVIGATION_BUTTONS) {
- // convert URLs in nav buttons
- } else {
- // remove navigation buttons
- $hp->html = preg_replace('#NavBar\+=(.*);#', '', $hp->html);
- }
- if ($hotpot->navigation==HOTPOT_NAVIGATION_GIVEUP) {
- // $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
+ switch ($hotpot->navigation) {
+ case HOTPOT_NAVIGATION_BUTTONS:
+ // convert URLs in nav buttons
+ break;
+ case HOTPOT_NAVIGATION_GIVEUP:
+ // $hp->insert_giveup_form($attemptid, '<!-- BeginTopNavButtons -->', '<!-- EndTopNavButtons -->');
+ break;
+ default:
+ // remove navigation buttons
+ $hp->html = preg_replace('#NavBar\+=(.*);#', '', $hp->html);
}
$hp->insert_submission_form($attemptid, "var NavBar='", "';");
}
@@ -325,6 +329,7 @@
$footer = '</html>';
if ($frameset) {
+ // HP5 v5
switch ($framename) {
case 'top':
print_header($title, $heading, $navigation, "", "", true, $button, $loggedinas);
@@ -348,7 +353,7 @@
print "<FRAMESET$frameset_tags>$frameset</FRAMESET>\n";
print "</HTML>\n";
break;
- } // end switch $frameset
+ } // end switch $framename
exit;
// is there a <body> (HP6 and HP5: v6 and v4)
@@ -431,12 +436,12 @@
print "</FRAMESET>\n";
print "</HTML>\n";
break;
- } // end switch $frameset
+ } // end switch $framename
break;
case HOTPOT_NAVIGATION_IFRAME:
- switch ($frameset) {
+ switch ($framename) {
case 'main';
print $hp->html;
break;
@@ -445,7 +450,7 @@
$iframe_id = 'hotpot_iframe';
$body_tags = " onload=\"set_iframe_height('$iframe_id')\"";
- $iframe_js = '<SCRIPT src="iframe.js" type="text/javascript" language="javascript">'."\n";
+ $iframe_js = '<SCRIPT src="iframe.js" type="text/javascript" language="javascript"></SCRIPT>'."\n";
print_header(
$title, $heading, $navigation,
@@ -455,13 +460,13 @@
if (!empty($available_msg)) {
notify($available_msg);
}
- print "<IFRAME id=\"$iframe_id\" src=\"view.php?id=$cm->id&frameset=main\" height=\"100%\" width=\"100%\">";
- print "<ILAYER name=\"$iframe_id\" src=\"view.php?id=$cm->id&frameset=main\" height=\"100%\" width=\"100%\">";
+ print "<IFRAME id=\"$iframe_id\" src=\"view.php?id=$cm->id&framename=main\" height=\"100%\" width=\"100%\">";
+ print "<ILAYER name=\"$iframe_id\" src=\"view.php?id=$cm->id&framename=main\" height=\"100%\" width=\"100%\">";
print "</ILAYER>\n";
print "</IFRAME>\n";
print $footer;
break;
- } // end switch $frameset
+ } // end switch $framename
break;
default:

0 comments on commit b045850

Please sign in to comment.