--- /dev/null
+/**
+ * Javascript to insert the field tags into the textarea.
+ * Used when editing a data template
+ */
+function insert_field_tags(selectlist) {
+ if (typeof(currEditor) != 'undefined' && currEditor._editMode == 'wysiwyg') {
+ // HTMLArea-specific
+ currEditor.insertHTML(selectlist.options[selectlist.selectedIndex].value);
+ } else {
+ // For inserting when in HTMLArea code view or for normal textareas
+ insertAtCursor(currTextarea, selectlist.options[selectlist.selectedIndex].value);
+ }
+}
+
+/**
+ * javascript for hiding/displaying advanced search form when viewing
+ */
+function showHideAdvSearch(checked) {
+ var divs = document.getElementsByTagName('div');
+ for(i=0;i<divs.length;i++) {
+ if(divs[i].id.match('data_adv_form')) {
+ if(checked) {
+ divs[i].style.display = 'inline';
+ }
+ else {
+ divs[i].style.display = 'none';
+ }
+ }
+ else if (divs[i].id.match('reg_search')) {
+ if (!checked) {
+ divs[i].style.display = 'inline';
+ }
+ else {
+ divs[i].style.display = 'none';
+ }
+ }
+ }
+}
\ No newline at end of file
$meta .= '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/mod/data/css.php?d='.$data->id.'" /> ';
}
if ($data->jstemplate) {
- $meta .= '<script type="text/javascript" src="'.$CFG->wwwroot.'/mod/data/js.php?d='.$data->id.'"></script>';
+ $PAGE->requires->js('mod/data/js.php?d='.$data->id)->in_head();
}
* @return void
*/
function data_print_preference_form($data, $perpage, $search, $sort='', $order='ASC', $search_array = '', $advanced = 0, $mode= ''){
- global $CFG, $DB;
+ global $CFG, $DB, $PAGE;
$cm = get_coursemodule_from_instance('data', $data->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
else {
$checked = '';
}
- print '
-
- <script type="text/javascript">
- //<![CDATA[
- <!-- Start
- // javascript for hiding/displaying advanced search form
-
- function showHideAdvSearch(checked) {
- var divs = document.getElementsByTagName(\'div\');
- for(i=0;i<divs.length;i++) {
- if(divs[i].id.match(\'data_adv_form\')) {
- if(checked) {
- divs[i].style.display = \'inline\';
- }
- else {
- divs[i].style.display = \'none\';
- }
- }
- else if (divs[i].id.match(\'reg_search\')) {
- if (!checked) {
- divs[i].style.display = \'inline\';
- }
- else {
- divs[i].style.display = \'none\';
- }
- }
- }
- }
- // End -->
- //]]>
- </script>';
+ $PAGE->requires->js('mod/data/data.js');
echo ' <input type="hidden" name="advanced" value="0" />';
echo ' <input type="hidden" name="filter" value="1" />';
echo ' <input type="checkbox" id="advancedcheckbox" name="advanced" value="1" '.$checked.' onchange="showHideAdvSearch(this.checked);" /><label for="advancedcheckbox">'.get_string('advancedsearch', 'data').'</label>';
$bodytag .= 'currTextarea = document.getElementById(\'tempform\').template;';
$bodytag .= '" ';
- // Javascript to insert the field tags into the textarea.
- $meta = '<script type="text/javascript">'."\n";
- $meta .= '//<![CDATA['."\n";
- $meta .= 'function insert_field_tags(selectlist) {';
- $meta .= ' if (typeof(currEditor) != \'undefined\' && currEditor._editMode == \'wysiwyg\') {';
- // HTMLArea-specific
- $meta .= ' currEditor.insertHTML(selectlist.options[selectlist.selectedIndex].value); ';
- $meta .= ' } else {';
- // For inserting when in HTMLArea code view or for normal textareas
- $meta .= ' insertAtCursor(currTextarea, selectlist.options[selectlist.selectedIndex].value);';
- $meta .= ' }'."\n";
- $meta .= '}'."\n";
- $meta .= '//]]>'."\n";
- $meta .= '</script>'."\n";
-
+ $PAGE->requires->js('mod/data/data.js');
$navigation = build_navigation('', $cm);
print_header_simple($data->name, '', $navigation,
- '', $meta, true, update_module_button($cm->id, $course->id, get_string('modulename', 'data')),
+ '', '', true, update_module_button($cm->id, $course->id, get_string('modulename', 'data')),
navmenu($course, $cm), '', $bodytag);
print_heading(format_string($data->name));
$meta .= '<link rel="stylesheet" type="text/css" href="'.$CFG->wwwroot.'/mod/data/css.php?d='.$data->id.'" /> ';
}
if ($data->jstemplate) {
- $meta .= '<script type="text/javascript" src="'.$CFG->wwwroot.'/mod/data/js.php?d='.$data->id.'"></script>';
+ $PAGE->requires->js('mod/data/js.php?d='.$data->id)->in_head();
}
/// Print the page header