From 9d0cffa554fac1c958528939533ba0577dd7e311 Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Mon, 22 Jun 2009 03:16:25 +0000 Subject: [PATCH] moddata MDL-16706 Removed inline scripts in mod data and added data.js --- mod/data/data.js | 38 ++++++++++++++++++++++++++++++++++++++ mod/data/edit.php | 2 +- mod/data/lib.php | 34 ++-------------------------------- mod/data/templates.php | 18 ++---------------- mod/data/view.php | 2 +- 5 files changed, 44 insertions(+), 50 deletions(-) create mode 100644 mod/data/data.js diff --git a/mod/data/data.js b/mod/data/data.js new file mode 100644 index 0000000000..f66c8a8bde --- /dev/null +++ b/mod/data/data.js @@ -0,0 +1,38 @@ +/** + * 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;iwwwroot.'/mod/data/css.php?d='.$data->id.'" /> '; } if ($data->jstemplate) { - $meta .= ''; + $PAGE->requires->js('mod/data/js.php?d='.$data->id)->in_head(); } diff --git a/mod/data/lib.php b/mod/data/lib.php index 89eb2a3198..9a9328beb4 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -1305,7 +1305,7 @@ function data_print_template($template, $records, $data, $search='', $page=0, $r * @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); @@ -1381,37 +1381,7 @@ function data_print_preference_form($data, $perpage, $search, $sort='', $order=' else { $checked = ''; } - print ' - - '; + $PAGE->requires->js('mod/data/data.js'); echo ' '; echo ' '; echo ' '; diff --git a/mod/data/templates.php b/mod/data/templates.php index afe0945d2c..a859180831 100755 --- a/mod/data/templates.php +++ b/mod/data/templates.php @@ -78,24 +78,10 @@ $bodytag .= 'currTextarea = document.getElementById(\'tempform\').template;'; $bodytag .= '" '; - // Javascript to insert the field tags into the textarea. - $meta = ''."\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)); diff --git a/mod/data/view.php b/mod/data/view.php index 347f2c0e43..181e7ac98d 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -273,7 +273,7 @@ $meta .= ' '; } if ($data->jstemplate) { - $meta .= ''; + $PAGE->requires->js('mod/data/js.php?d='.$data->id)->in_head(); } /// Print the page header -- 2.39.5