Skip to content

Commit

Permalink
New option on close_window_button to reload the page that opened this…
Browse files Browse the repository at this point in the history
… pop-up, as the pop-up is closed. Needed in preparation for MDL-16334.
  • Loading branch information
tjhunt committed Sep 18, 2008
1 parent a5905c9 commit 829eabf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -719,17 +719,24 @@ function button_to_popup_window ($url, $name=null, $linkname=null,
/**
* Prints a simple button to close a window
* @param string $name name of the window to close
* @param boolean $return whether this function should return a string or output it
* @param boolean $return whether this function should return a string or output it.
* @param boolean $reloadopener if true, clicking the button will also reload
* the page that opend this popup window.
* @return string if $return is true, nothing otherwise
*/
function close_window_button($name='closewindow', $return=false) {
function close_window_button($name='closewindow', $return=false, $reloadopener = false) {
global $CFG;

$js = 'self.close();';
if ($reloadopener) {
$js = 'window.opener.location.reload(1);' . $js;
}

$output = '';

$output .= '<div class="closewindow">' . "\n";
$output .= '<form action="#"><div>';
$output .= '<input type="button" onclick="self.close();" value="'.get_string($name).'" />';
$output .= '<input type="button" onclick="' . $js . '" value="'.get_string($name).'" />';
$output .= '</div></form>';
$output .= '</div>' . "\n";

Expand Down

0 comments on commit 829eabf

Please sign in to comment.