Index: moodle/mod/lamslesson/mod_form.php =================================================================== diff -u -r606bc0215a34c4af3f93611e71553d8020d47036 -ra6150c3e710746604a092a68783fb66dea52134a --- moodle/mod/lamslesson/mod_form.php (.../mod_form.php) (revision 606bc0215a34c4af3f93611e71553d8020d47036) +++ moodle/mod/lamslesson/mod_form.php (.../mod_form.php) (revision a6150c3e710746604a092a68783fb66dea52134a) @@ -92,57 +92,33 @@ $openpreviewlabel = get_string('previewthislesson', 'lamslesson'); // html "chunk" for open Author button - $authorpreviewbutton = << - - -
- - - $openauthorlabel - -
+ $authorpreviewbutton .= html_writer::script('', $CFG->wwwroot.'/mod/lamslesson/preview.js'); -XXX; + + $authorpreviewbutton .= html_writer::start_tag('div', array('id' => 'buttons', 'style' => 'float:right;')); + // Preview button + $authorpreviewbutton .= html_writer::start_tag('span', array('id' => 'previewbutton', 'style' => 'visibility:hidden;', 'class' => 'yui-button yui-link-button')); + $authorpreviewbutton .= html_writer::start_tag('span', array('class' => 'first-child')); + $authorpreviewbutton .= html_writer::link('#nogo', $openpreviewlabel, array('onclick' => js_writer::function_call('openPreview', array('1' => $previewurl, '2' => preview, '3' => 0)))); + $authorpreviewbutton .= html_writer::end_tag('span'); + $authorpreviewbutton .= html_writer::end_tag('span'); + //Authoring button + $authorpreviewbutton .= html_writer::start_tag('span', array('id' => 'authorbutton', 'class' => 'yui-button yui-link-button')); + $authorpreviewbutton .= html_writer::start_tag('span', array('class' => 'first-child')); + $authorpreviewbutton .= html_writer::link('#nogo', $openauthorlabel, array('onclick' => js_writer::function_call('openAuthor', array('1' => $authorurl, '2' => author, '3' => 0)))); + $authorpreviewbutton .= html_writer::end_tag('span'); + $authorpreviewbutton .= html_writer::end_tag('span'); + $authorpreviewbutton .= html_writer::end_tag('div'); } -// $mform->addElement('',''); $mform->addElement('hidden', 'sequence_id'); $mform->setType('sequence_id', PARAM_INT); Index: moodle/mod/lamslesson/preview.js =================================================================== diff -u --- moodle/mod/lamslesson/preview.js (revision 0) +++ moodle/mod/lamslesson/preview.js (revision a6150c3e710746604a092a68783fb66dea52134a) @@ -0,0 +1,46 @@ + /* + * LAMSLesson validation + * + * Date: 2012-01-07 + * LAMS Foundation (http://lamsfoundation.org) + */ + +function openAuthor(url,name,fullscreen) { + url = url + "&requestSrc=" + escape(requestsrc); + url = url + "¬ifyCloseURL=" + escape(window.location.href); + authorWin = window.open(url,name,options); + if (fullscreen) { + authorWin.moveTo(0,0); + authorWin.resizeTo(screen.availWidth,screen.availHeight); + } + authorWin.focus(); + return false; +} + +function openPreview(url,name,fullscreen) { + url = url + "&ldId=" + document.getElementsByName("sequence_id")[0].value; + url = url + "&course=" + course; + previewWin = window.open(url,name,options); + if (fullscreen) { + previewWin.moveTo(0,0); + previewWin.resizeTo(screen.availWidth,screen.availHeight); + } + previewWin.focus(); + return false; +} + +function selectSequence(obj, name){ + // if the selected object is a sequence (id!=0) then we assign the id to the hidden sequence_id + // also if the name is blank we just add the name of the sequence to the name too. + + document.getElementsByName("sequence_id")[0].value = obj; + + if (obj!=0) { + if (document.getElementsByName("name")[0].value == '') { + document.getElementsByName("name")[0].value = name; + } + document.getElementById('previewbutton').style.visibility='visible'; + } else { + document.getElementById('previewbutton').style.visibility='hidden'; + } +}