From 6e24853aa1ba2aeae8a9a24ee427ce00d4f560e2 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Mon, 2 Jan 2017 17:05:28 +0000 Subject: [PATCH] MDL-57557 calendar: convert from yui module to bootstrap popovers --- calendar/lib.php | 25 ++++++----- .../templates/minicalendar_day_link.mustache | 38 ++++++++++++++++ .../minicalendar_day_link.mustache | 38 ++++++++++++++++ .../minicalendar_day_link.mustache | 44 +++++++++++++++++++ 4 files changed, 135 insertions(+), 10 deletions(-) create mode 100644 calendar/templates/minicalendar_day_link.mustache create mode 100644 theme/boost/templates/core_calendar/minicalendar_day_link.mustache create mode 100644 theme/bootstrapbase/templates/core_calendar/minicalendar_day_link.mustache diff --git a/calendar/lib.php b/calendar/lib.php index f1e09a05bb6..ddf2a8cfe7f 100644 --- a/calendar/lib.php +++ b/calendar/lib.php @@ -420,7 +420,6 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea } else { $popupdata = calendar_get_popup(false, $daytime, $popupcontent); } - $cellattributes = array_merge($cellattributes, $popupdata); // Class and cell content if(isset($typesbyday[$day]['startglobal'])) { @@ -435,7 +434,14 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea if ($finishclass) { $class .= ' duration_finish'; } - $cell = html_writer::link($dayhref, $day); + + $data = array( + 'url' => $dayhref, + 'day' => $day, + 'content' => $popupdata['data-core_calendar-popupcontent'], + 'title' => $popupdata['data-core_calendar-title'] + ); + $cell = $OUTPUT->render_from_template('core_calendar/minicalendar_day_link', $data); } else { $cell = $day; } @@ -477,8 +483,13 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea if (!isset($eventsbyday[$day]) && !isset($durationbyday[$day])) { $class .= ' eventnone'; $popupdata = calendar_get_popup(true, false); - $cellattributes = array_merge($cellattributes, $popupdata); - $cell = html_writer::link('#', $day); + $data = array( + 'url' => '#', + 'day' => $day, + 'content' => $popupdata['data-core_calendar-popupcontent'], + 'title' => $popupdata['data-core_calendar-title'] + ); + $cell = $OUTPUT->render_from_template('core_calendar/minicalendar_day_link', $data); } $cell = get_accesshide($today . ' ') . $cell; } @@ -495,12 +506,6 @@ function calendar_get_mini($courses, $groups, $users, $calmonth = false, $calyea $content .= ''; // Last row ends $content .= ''; // Tabular display of days ends - - static $jsincluded = false; - if (!$jsincluded) { - $PAGE->requires->yui_module('moodle-calendar-info', 'Y.M.core_calendar.info.init'); - $jsincluded = true; - } return $content; } diff --git a/calendar/templates/minicalendar_day_link.mustache b/calendar/templates/minicalendar_day_link.mustache new file mode 100644 index 00000000000..bdb5e676181 --- /dev/null +++ b/calendar/templates/minicalendar_day_link.mustache @@ -0,0 +1,38 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template core_calendar/minicalendar_day_link + + Displays link to calendar day in mini calendar, with hover tooltip. + + Example context (json): + { + "day": "Today", + "url": "http://example.com/", + "title": "Monday 2nd January", + "content": "iconTest site event" + } +}} +{{< core/hover_tooltip }} + {{$anchor}} + {{day}} + {{/anchor}} + {{$tooltip}} + {{title}} + {{{content}}} + {{/tooltip}} +{{/ core/hover_tooltip }} diff --git a/theme/boost/templates/core_calendar/minicalendar_day_link.mustache b/theme/boost/templates/core_calendar/minicalendar_day_link.mustache new file mode 100644 index 00000000000..d4ce07caca4 --- /dev/null +++ b/theme/boost/templates/core_calendar/minicalendar_day_link.mustache @@ -0,0 +1,38 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template core_calendar/minicalendar_day_link + + Displays link to calendar day in mini calendar, with hover tooltip. + + Example context (json): + { + "day": "Today", + "url": "http://example.com/", + "title": "Monday 2nd January", + "content": "Test site event" + } +}} +{{day}} diff --git a/theme/bootstrapbase/templates/core_calendar/minicalendar_day_link.mustache b/theme/bootstrapbase/templates/core_calendar/minicalendar_day_link.mustache new file mode 100644 index 00000000000..c3a003417c7 --- /dev/null +++ b/theme/bootstrapbase/templates/core_calendar/minicalendar_day_link.mustache @@ -0,0 +1,44 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template core_calendar/minicalendar_day_link + + Displays link to calendar day in mini calendar, with hover tooltip. + + Example context (json): + { + "day": "Today", + "url": "http://example.com/", + "title": "Monday 2nd January", + "content": "Test site event" + } +}} +{{day}} +{{#js}} +require(['jquery'], function($) { + require(['theme_bootstrapbase/bootstrap'], function() { + $('#{{uniqid}}').popover(); + }); +}); +{{/js}}