MDL-57557 calendar: convert from yui module to bootstrap popovers

This commit is contained in:
Dan Poltawski 2017-01-02 17:05:28 +00:00
parent facf039a00
commit 6e24853aa1
4 changed files with 135 additions and 10 deletions

View File

@ -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 .= '</tr>'; // Last row ends
$content .= '</table>'; // 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;
}

View File

@ -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 <http://www.gnu.org/licenses/>.
}}
{{!
@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": "<img class='icon smallicon' alt='icon' src='../../../pix/i/siteevent.svg'>Test site event"
}
}}
{{< core/hover_tooltip }}
{{$anchor}}
<a href="{{url}}">{{day}}</a>
{{/anchor}}
{{$tooltip}}
<b>{{title}}</b>
{{{content}}}
{{/tooltip}}
{{/ core/hover_tooltip }}

View File

@ -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 <http://www.gnu.org/licenses/>.
}}
{{!
@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": "<img class='icon smallicon' src='../../../pix/i/siteevent.svg'>Test site event"
}
}}
<a href="{{url}}"
data-container="body"
data-toggle="popover"
data-html="true"
data-trigger="hover"
data-placement="top"
data-title="{{title}}"
data-content="{{content}}"
>{{day}}</a>

View File

@ -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 <http://www.gnu.org/licenses/>.
}}
{{!
@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": "<img class='icon smallicon' src='../../../pix/i/siteevent.svg'>Test site event"
}
}}
<a id="{{uniqid}}" href="{{url}}"
data-container="body"
data-toggle="popover"
data-html="true"
data-trigger="hover"
data-placement="top"
data-title="{{title}}"
data-content="{{content}}">{{day}}</a>
{{#js}}
require(['jquery'], function($) {
require(['theme_bootstrapbase/bootstrap'], function() {
$('#{{uniqid}}').popover();
});
});
{{/js}}