]> git.mjollnir.org Git - moodle.git/commitdiff
overlib MDL-19735 Overlib is now included only where it is used
authorsamhemelryk <samhemelryk>
Thu, 17 Sep 2009 07:46:20 +0000 (07:46 +0000)
committersamhemelryk <samhemelryk>
Thu, 17 Sep 2009 07:46:20 +0000 (07:46 +0000)
At the same time I have converted the calendar block to use YUI instead of overlib, this introduces one regression in that the panel is shown immediatly but should really have a minimal delay for usability.
This will be fixed once the theme changes for 2.0 have been commited

16 files changed:
blocks/calendar_month/block_calendar_month.php
calendar/calendar.js [new file with mode: 0644]
calendar/event.php
calendar/export.php
calendar/lib.php
calendar/overlib.cfg.php [deleted file]
calendar/view.php
grade/report/grader/index.php
group/overview.php
lib/outputrenderers.php
mod/hotpot/review.php
mod/quiz/attempt.php
mod/quiz/report/grading/report.php
mod/quiz/review.php
mod/quiz/reviewquestion.php
question/type/multianswer/questiontype.php

index a699935f51e661097b695e57e0690e64e43e257c..11ccacf9d67ad92b97e84b533f40bb09c515c9af 100644 (file)
@@ -56,20 +56,19 @@ class block_calendar_month extends block_base {
             $courseset = true;
             $SESSION->cal_courses_shown[$this->page->course->id] = $this->page->course;
         }
-    
+
         // Be VERY careful with the format for default courses arguments!
         // Correct formatting is [courseid] => 1 to be concise with moodlelib.php functions.
         calendar_set_filters($courses, $group, $user, $filtercourse, $groupeventsfrom, false);
+        $this->page->requires->js('calendar/calendar.js');
         if ($courseshown == SITEID) {
             // For the front page
-            $this->content->text .= calendar_overlib_html();
             $this->content->text .= calendar_top_controls('frontpage', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
             $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
             // No filters for now
 
         } else {
             // For any other course
-            $this->content->text .= calendar_overlib_html();
             $this->content->text .= calendar_top_controls('course', array('id' => $courseshown, 'm' => $cal_m, 'y' => $cal_y));
             $this->content->text .= calendar_get_mini($courses, $group, $user, $cal_m, $cal_y);
             $this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
diff --git a/calendar/calendar.js b/calendar/calendar.js
new file mode 100644 (file)
index 0000000..5259e12
--- /dev/null
@@ -0,0 +1,15 @@
+function attach_calendar_panel(properties) {
+    YAHOO.namespace("moodle.container");
+    YAHOO.moodle.container[properties.id] = new YAHOO.widget.Panel(properties.id+'_panel', {
+        width:"320px",
+        visible:false,
+        draggable:false,
+        close:false,
+        constraintoviewport:true
+    } );
+    YAHOO.moodle.container[properties.id].setHeader(properties.title);
+    YAHOO.moodle.container[properties.id].setBody(properties.content);
+    YAHOO.moodle.container[properties.id].render(properties.id);
+    YAHOO.util.Event.addListener(properties.id, 'mouseover', YAHOO.moodle.container[properties.id].show, YAHOO.moodle.container[properties.id], true);
+    YAHOO.util.Event.addListener(properties.id, 'mouseout', YAHOO.moodle.container[properties.id].hide, YAHOO.moodle.container[properties.id], true);
+}
\ No newline at end of file
index ea18110a71ebc3ca7fe92a231d01c50a5096478f..d25491023460b71ce3a285556c952aca51692013 100644 (file)
 
     echo $OUTPUT->header();
 
-    echo calendar_overlib_html();
-
     echo '<table id="calendar">';
     echo '<tr><td class="maincalendar">';
 
index 0ebc55899cbde75ca0d36758f212d30aa03607e1..f759edfc5426814f0563422151c234d7826c6aaf 100644 (file)
@@ -75,8 +75,6 @@ $PAGE->set_focuscontrol('eventform.name');
 
 echo $OUTPUT->header();
 
-echo calendar_overlib_html();
-
 // Layout the whole page as three big columns.
 echo '<table id="calendar">';
 echo '<tr>';
index 0b30f9726069992bddb0aa5d3a125d0bdf304513..dce38bd0d91a1f55cf0d8d82843d78e5c6cfad42 100644 (file)
@@ -347,6 +347,11 @@ function calendar_get_mini($courses, $groups, $users, $cal_month = false, $cal_y
  * @return $popup string, contains onmousover and onmouseout events.
  */
 function calendar_get_popup($is_today, $event_timestart, $popupcontent='') {
+    global $PAGE;
+    static $popupcount;
+    if ($popupcount === null) {
+        $popupcount = 1;
+    }
     $popupcaption = '';
     if($is_today) {
         $popupcaption = get_string('today', 'calendar').' ';
@@ -358,10 +363,11 @@ function calendar_get_popup($is_today, $event_timestart, $popupcontent='') {
     } else {
         $popupcaption .= get_string('eventsfor', 'calendar', userdate($event_timestart, get_string('strftimedayshort')));
     }
-    $popupcontent = addslashes_js(s($popupcontent));
-    $popupcaption = addslashes_js(s($popupcaption));
-    $popup = 'onmouseover="return overlib(\''.$popupcontent.'\', CAPTION, \''.$popupcaption.'\');" onmouseout="return nd();"';
-    return $popup;
+    $id = 'calendar_tooltip_'.$popupcount;
+    $PAGE->requires->yui_lib('container');
+    $PAGE->requires->js_function_call('attach_calendar_panel', Array(Array('id'=>$id,'title'=>$popupcaption, 'content'=>$popupcontent)));
+    $popupcount++;
+    return 'id="'.$id.'"';
 }
 
 function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
@@ -1180,14 +1186,6 @@ function calendar_session_vars($course=null) {
     }
 }
 
-function calendar_overlib_html() {
-    global $PAGE;
-    $output = '';
-    $output .= $PAGE->requires->js('calendar/overlib.cfg.php')->asap();
-    $output .= '<div id="overDiv" style="position: absolute; visibility: hidden; z-index:1000;"></div>';
-    return $output;
-}
-
 function calendar_set_referring_course($courseid) {
     global $SESSION;
     $SESSION->cal_course_referer = intval($courseid);
diff --git a/calendar/overlib.cfg.php b/calendar/overlib.cfg.php
deleted file mode 100644 (file)
index eb2221a..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-ol_delay = 350;
-ol_fgclass = 'cal_popup_fg';
-ol_bgclass = 'cal_popup_bg';
-ol_cgclass = 'cal_popup_cg';
-ol_captionfontclass = 'cal_popup_caption';
-ol_noclose = true;
-ol_sticky = true;
-ol_close = 'X';
-ol_offsety = -1;
-ol_mouseoff = 1;
index 4cb9bc8e8f1c420f0ff57758afd3247ecf3d8c77..8c17594a2f66c0323723349c96c3bccdf536d33c 100644 (file)
     $strcalendar = get_string('calendar', 'calendar');
     $prefsbutton = calendar_preferences_button();
 
+    $PAGE->requires->js('calendar/calendar.js');
+
     // Print title and header
     $PAGE->set_title("$site->shortname: $strcalendar: $pagetitle");
     $PAGE->set_heading($strcalendar);
 
     echo $OUTPUT->header();
 
-    echo calendar_overlib_html();
-
     // Layout the whole page as three big columns.
     echo '<table id="calendar" style="height:100%;">';
     echo '<tr>';
index 2eab35fa45e5bdd36b3ce109472690437439756d..0ba3f079a14971d77789ceb62e72766dd4dcc1c7 100644 (file)
@@ -119,6 +119,8 @@ $PAGE->requires->yui_lib('element');
 $PAGE->requires->yui_lib('container');
 $PAGE->requires->js('grade/report/grader/functions.js');
 $PAGE->requires->js('grade/report/grader/grader.js');
+$PAGE->requires->js('lib/overlib/overlib.js')->in_head();
+$PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
 
 if ($report->get_pref('enableajax')) {
     $report = new grade_report_grader_ajax($courseid, $gpr, $context, $page, $sortitemid);
index c207a3e0b0f40863b6afc4fe7b6da76324e694b8..0b14a741c938e4107304b6820a4a04c83a6b81c7 100644 (file)
@@ -115,6 +115,9 @@ if ($rs = $DB->get_recordset_sql($sql, $params)) {
     $rs->close();
 }
 
+$PAGE->requires->js('lib/overlib/overlib.js')->in_head();
+$PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
+
 $PAGE->navbar->add($strparticipants, new moodle_url($CFG->wwwroot.'/user/index.php', array('id'=>$courseid)));
 $PAGE->navbar->add($strgroups);
 
index 1efb7f6208fb618b5e1a17bb40c1db4e1711d60e..41d021f8fd6e0b9af4d406562b03d966b776208d 100644 (file)
@@ -492,8 +492,6 @@ class moodle_core_renderer extends moodle_renderer_base {
         $this->page->requires->js('lib/javascript-static.js')->in_head();
         $this->page->requires->js('lib/javascript-deprecated.js')->in_head();
         $this->page->requires->js('lib/javascript-mod.php')->in_head();
-        $this->page->requires->js('lib/overlib/overlib.js')->in_head();
-        $this->page->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
         $this->page->requires->js_function_call('setTimeout', array('fix_column_widths()', 20));
 
         $focus = $this->page->focuscontrol;
index 7d82add3902b0ac56550a9e7270c7ea22fb7f0c8..76c4c6725991b15524dacb2606288a12d830122e 100644 (file)
@@ -51,7 +51,9 @@
     $strmodulenameplural = get_string("modulenameplural", "hotpot");
     $strmodulename  = get_string("modulename", "hotpot");
     // print header
-   
+
+    $PAGE->requires->js('lib/overlib/overlib.js')->in_head();
+    $PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
     $PAGE->set_title(format_string($course->shortname) . ": $hotpot->name");
     $PAGE->set_heading($course->fullname);
     $PAGE->set_button(update_module_button($cm->id, $course->id, $strmodulename));
index cb0a786cd748aedb9baa7d466a964a642783a0a5..7d9809ff6e25f769da0af89179bd49da4377e3b6 100644 (file)
@@ -85,6 +85,8 @@
     $attemptobj->load_question_states($questionids);
 
 /// Print the quiz page ////////////////////////////////////////////////////////
+    $PAGE->requires->js('lib/overlib/overlib.js')->in_head();
+    $PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
 
     // Arrange for the navigation to be displayed.
     $navbc = $attemptobj->get_navigation_panel('quiz_attempt_nav_panel', $page);
index 5e2ce45000fe2d99dbf1c17f82dfbf876919ffef..60993cf9b935e6b8d19d1c77ffc8f88f06d9ecfe 100644 (file)
@@ -28,7 +28,7 @@ class quiz_grading_report extends quiz_default_report {
      * Displays the report.
      */
     function display($quiz, $cm, $course) {
-        global $CFG, $QTYPES, $DB, $OUTPUT;
+        global $CFG, $QTYPES, $DB, $OUTPUT, $PAGE;
 
         $viewoptions = array('mode'=>'grading', 'q'=>$quiz->id);
 
@@ -56,6 +56,9 @@ class quiz_grading_report extends quiz_default_report {
 
         $this->cm = $cm;
 
+        echo $PAGE->requires->js('lib/overlib/overlib.js')->asap();
+        echo $PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->asap();
+
         $this->print_header_and_tabs($cm, $course, $quiz, $reportmode="grading");
 
         // Check permissions
index 0a823e162aab31e74cfe563315b2ad082a8b760d..7577725eaa7b0a3ad379aa42abcb8077b7a8a688 100644 (file)
@@ -85,6 +85,9 @@
     $firstregion = reset($PAGE->blocks->get_regions());
     $PAGE->blocks->add_pretend_block($navbc, $firstregion);
 
+    $PAGE->requires->js('lib/overlib/overlib.js')->in_head();
+    $PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
+
 /// Print the page header
     $headtags = $attemptobj->get_html_head_contributions($page);
     if ($accessmanager->securewindow_required($attemptobj->is_preview_user())) {
index f02fb41e08c0e7ff886fa89899130e4983322f91..75f21de62be5b00a0ab1a1c7156b664a223c99a4 100644 (file)
@@ -61,6 +61,9 @@
             ($stateid ? '&state=' . $stateid : ''),
             $attemptobj->get_quizid(), $attemptobj->get_cmid());
 
+    $PAGE->requires->js('lib/overlib/overlib.js')->in_head();
+    $PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->in_head();
+
 /// Print the page header
     $attemptobj->get_question_html_head_contributions($questionid);
 
index 7cd6e655186ef486851c706e0831e06d80d29522..a3672e452e044e09878ccd8c3b8da0c5ca91d525 100644 (file)
@@ -277,7 +277,7 @@ class embedded_cloze_qtype extends default_questiontype {
     }
 
     function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
-        global $QTYPES, $CFG, $USER, $OUTPUT;
+        global $QTYPES, $CFG, $USER, $OUTPUT, $PAGE;
 
         $readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
         $disabled = empty($options->readonly) ? '' : 'disabled="disabled"';
@@ -307,6 +307,9 @@ class embedded_cloze_qtype extends default_questiontype {
         // The regex will recognize text snippets of type {#X}
         // where the X can be any text not containg } or white-space characters.
 
+        echo $PAGE->requires->js('lib/overlib/overlib.js')->asap();
+        echo $PAGE->requires->js('lib/overlib/overlib_cssstyle.js')->asap();
+
         while (preg_match('~\{#([^[:space:]}]*)}~', $qtextremaining, $regs)) {
             $qtextsplits = explode($regs[0], $qtextremaining, 2);
             echo $qtextsplits[0];
@@ -360,6 +363,7 @@ class embedded_cloze_qtype extends default_questiontype {
                         $feedback .= '</div>';
                     }
                 }
+
             if ($options->feedback) {
                 $chosenanswer = null;
                 switch ($wrapped->qtype) {