mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
Merge branch 'MDL-75401-master-integration' of https://github.com/ferranrecio/moodle
This commit is contained in:
commit
80d4981d8d
130
lib/classes/output/sticky_footer.php
Normal file
130
lib/classes/output/sticky_footer.php
Normal file
@ -0,0 +1,130 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
namespace core\output;
|
||||
|
||||
use renderable;
|
||||
|
||||
/**
|
||||
* Class to render a sticky footer element.
|
||||
*
|
||||
* Sticky footer can be rendered at any moment if the page (even inside a form) but
|
||||
* it will be displayed at the bottom of the page.
|
||||
*
|
||||
* Important: note that pages can only display one sticky footer at once.
|
||||
*
|
||||
* Important: not all themes are compatible with sticky footer. If the current theme
|
||||
* is not compatible it will be rendered as a standard div element.
|
||||
*
|
||||
* @package core
|
||||
* @category output
|
||||
* @copyright 2022 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class sticky_footer implements named_templatable, renderable {
|
||||
|
||||
/**
|
||||
* @var string content of the sticky footer.
|
||||
*/
|
||||
protected $stickycontent = '';
|
||||
|
||||
/**
|
||||
* @var string extra CSS classes. By default, elements are justified to the end.
|
||||
*/
|
||||
protected $stickyclasses = 'justify-content-end';
|
||||
|
||||
/**
|
||||
* @var array extra HTML attributes (attribute => value).
|
||||
*/
|
||||
protected $attributes = [];
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param string $stickycontent the footer content
|
||||
* @param string|null $stickyclasses extra CSS classes
|
||||
* @param array $attributes extra html attributes (attribute => value)
|
||||
*/
|
||||
public function __construct(string $stickycontent = '', ?string $stickyclasses = null, array $attributes = []) {
|
||||
$this->stickycontent = $stickycontent;
|
||||
if ($stickyclasses !== null) {
|
||||
$this->stickyclasses = $stickyclasses;
|
||||
}
|
||||
$this->attributes = $attributes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the footer contents.
|
||||
*
|
||||
* @param string $stickycontent the footer content
|
||||
*/
|
||||
public function set_content(string $stickycontent) {
|
||||
$this->stickycontent = $stickycontent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add extra classes to the sticky footer.
|
||||
*
|
||||
* @param string $stickyclasses the extra classes
|
||||
*/
|
||||
public function add_classes(string $stickyclasses) {
|
||||
if (!empty($this->stickyclasses)) {
|
||||
$this->stickyclasses .= ' ';
|
||||
}
|
||||
$this->stickyclasses = $stickyclasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add extra attributes to the sticky footer element.
|
||||
*
|
||||
* @param string $atribute the attribute
|
||||
* @param string $value the value
|
||||
*/
|
||||
public function add_attribute(string $atribute, string $value) {
|
||||
$this->attributes[$atribute] = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template (core/inplace_editable).
|
||||
*
|
||||
* @param renderer_base $output typically, the renderer that's calling this function
|
||||
* @return array data context for a mustache template
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output) {
|
||||
$extras = [];
|
||||
foreach ($this->attributes as $attribute => $value) {
|
||||
$extras[] = [
|
||||
'attribute' => $attribute,
|
||||
'value' => $value,
|
||||
];
|
||||
}
|
||||
return [
|
||||
'stickycontent' => (string)$this->stickycontent,
|
||||
'stickyclasses' => $this->stickyclasses,
|
||||
'extras' => $extras,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the template to use for this templatable.
|
||||
*
|
||||
* @param \renderer_base $renderer The renderer requesting the template name
|
||||
* @return string the template name
|
||||
*/
|
||||
public function get_template_name(\renderer_base $renderer): string {
|
||||
return 'core/sticky_footer';
|
||||
}
|
||||
}
|
47
lib/templates/sticky_footer.mustache
Normal file
47
lib/templates/sticky_footer.mustache
Normal file
@ -0,0 +1,47 @@
|
||||
{{!
|
||||
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/sticky_footer
|
||||
|
||||
Displays a page sticky footer element.
|
||||
|
||||
Sticky footer behaviour depends on the theme. The default template is
|
||||
a regular element.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"stickycontent" : "<a href=\"#\">Moodle</a>",
|
||||
"extras" : [
|
||||
{
|
||||
"attribute" : "data-example",
|
||||
"value" : "stickyfooter"
|
||||
}
|
||||
],
|
||||
"stickyclasses" : "extraclasses"
|
||||
}
|
||||
}}
|
||||
<div
|
||||
id="sticky-footer"
|
||||
class="{{$ stickyclasses }}{{stickyclasses}}{{/ stickyclasses }}"
|
||||
{{#extras}}
|
||||
{{attribute}}="{{value}}"
|
||||
{{/extras}}
|
||||
>
|
||||
{{$ stickycontent }}
|
||||
{{{stickycontent}}}
|
||||
{{/ stickycontent }}
|
||||
</div>
|
@ -58,15 +58,12 @@ class view_action_bar implements templatable, renderable {
|
||||
* @return array
|
||||
*/
|
||||
public function export_for_template(\renderer_base $output): array {
|
||||
global $PAGE, $DB;
|
||||
global $PAGE;
|
||||
|
||||
$data = [
|
||||
'urlselect' => $this->urlselect->export_for_template($output),
|
||||
];
|
||||
|
||||
$addentrybutton = new add_entries_action($this->id);
|
||||
$data['addentrybutton'] = $addentrybutton->export_for_template($output);
|
||||
|
||||
if (has_capability('mod/data:manageentries', $PAGE->context)) {
|
||||
$importentrieslink = new moodle_url('/mod/data/import.php',
|
||||
['d' => $this->id, 'backto' => $PAGE->url->out(false)]);
|
||||
|
156
mod/data/classes/output/view_footer.php
Normal file
156
mod/data/classes/output/view_footer.php
Normal file
@ -0,0 +1,156 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
namespace mod_data\output;
|
||||
|
||||
use action_link;
|
||||
use core\output\sticky_footer;
|
||||
use html_writer;
|
||||
use mod_data\manager;
|
||||
use mod_data\template;
|
||||
use moodle_url;
|
||||
use renderer_base;
|
||||
|
||||
/**
|
||||
* Renderable class for sticky footer in the view pages of the database activity.
|
||||
*
|
||||
* @package mod_data
|
||||
* @copyright 2022 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class view_footer extends sticky_footer {
|
||||
|
||||
/** @var int $totalcount the total records count. */
|
||||
private $totalcount;
|
||||
|
||||
/** @var int $currentpage the current page */
|
||||
private $currentpage;
|
||||
|
||||
/** @var int $nowperpage the number of elements per page */
|
||||
private $nowperpage;
|
||||
|
||||
/** @var moodle_url $baseurl the page base url */
|
||||
private $baseurl;
|
||||
|
||||
/** @var template $parser the template name */
|
||||
private $parser;
|
||||
|
||||
/** @var manager $manager if the user can manage capabilities or not */
|
||||
private $manager;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
*
|
||||
* @param manager $manager the activity manager
|
||||
* @param int $totalcount the total records count
|
||||
* @param int $currentpage the current page
|
||||
* @param int $nowperpage the number of elements per page
|
||||
* @param moodle_url $baseurl the page base url
|
||||
* @param template $parser the current template name
|
||||
*/
|
||||
public function __construct(
|
||||
manager $manager,
|
||||
int $totalcount,
|
||||
int $currentpage,
|
||||
int $nowperpage,
|
||||
moodle_url $baseurl,
|
||||
template $parser
|
||||
) {
|
||||
$this->manager = $manager;
|
||||
$this->totalcount = $totalcount;
|
||||
$this->currentpage = $currentpage;
|
||||
$this->nowperpage = $nowperpage;
|
||||
$this->baseurl = $baseurl;
|
||||
$this->parser = $parser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export this data so it can be used as the context for a mustache template (core/inplace_editable).
|
||||
*
|
||||
* @param renderer_base $output typically, the renderer that's calling this function
|
||||
* @return array data context for a mustache template
|
||||
*/
|
||||
public function export_for_template(renderer_base $output) {
|
||||
$this->set_content(
|
||||
$this->get_footer_output($output)
|
||||
);
|
||||
return parent::export_for_template($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the pre-rendered footer content.
|
||||
*
|
||||
* @param \renderer_base $output The renderer to be used to render the action bar elements.
|
||||
* @return string the rendered content
|
||||
*/
|
||||
public function get_footer_output(renderer_base $output): string {
|
||||
$data = [];
|
||||
|
||||
$cm = $this->manager->get_coursemodule();
|
||||
$instance = $this->manager->get_instance();
|
||||
$currentgroup = groups_get_activity_group($cm);
|
||||
$groupmode = groups_get_activity_groupmode($cm);
|
||||
$context = $this->manager->get_context();
|
||||
$canmanageentries = has_capability('mod/data:manageentries', $context);
|
||||
$parser = $this->parser;
|
||||
|
||||
// Sticky footer content.
|
||||
$data['pagination'] = $output->paging_bar(
|
||||
$this->totalcount,
|
||||
$this->currentpage,
|
||||
$this->nowperpage,
|
||||
$this->baseurl
|
||||
);
|
||||
|
||||
if ($parser->get_template_name() != 'singletemplate' && $canmanageentries) {
|
||||
// Build the select/deselect all control.
|
||||
$selectallid = 'selectall-listview-entries';
|
||||
$togglegroup = 'listview-entries';
|
||||
$mastercheckbox = new \core\output\checkbox_toggleall($togglegroup, true, [
|
||||
'id' => $selectallid,
|
||||
'name' => $selectallid,
|
||||
'value' => 1,
|
||||
'label' => get_string('selectall'),
|
||||
'classes' => 'btn-secondary mr-1',
|
||||
], true);
|
||||
$data['selectall'] = $output->render($mastercheckbox);
|
||||
|
||||
$data['deleteselected'] = html_writer::empty_tag('input', [
|
||||
'class' => 'btn btn-secondary',
|
||||
'type' => 'submit',
|
||||
'value' => get_string('deleteselected'),
|
||||
'disabled' => true,
|
||||
'data-action' => 'toggle',
|
||||
'data-togglegroup' => $togglegroup,
|
||||
'data-toggle' => 'action',
|
||||
]);
|
||||
}
|
||||
if (data_user_can_add_entry($instance, $currentgroup, $groupmode, $context)) {
|
||||
$addentrylink = new moodle_url(
|
||||
'/mod/data/edit.php',
|
||||
['id' => $cm->id, 'backto' => $this->baseurl]
|
||||
);
|
||||
$addentrybutton = new action_link(
|
||||
$addentrylink,
|
||||
get_string('add', 'mod_data'),
|
||||
null,
|
||||
['class' => 'btn btn-primary', 'role' => 'button']
|
||||
);
|
||||
$data['addentrybutton'] = $addentrybutton->export_for_template($output);
|
||||
}
|
||||
return $output->render_from_template('mod_data/view_footer', $data);
|
||||
}
|
||||
}
|
@ -215,6 +215,15 @@ class template {
|
||||
$this->tags = $matches['tags'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current template name.
|
||||
*
|
||||
* @return string the template name
|
||||
*/
|
||||
public function get_template_name(): string {
|
||||
return $this->templatename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the list of action icons.
|
||||
*
|
||||
|
@ -217,7 +217,9 @@ if (!$rid && ((!$data->maxentries) ||
|
||||
]);
|
||||
}
|
||||
|
||||
echo html_writer::div($actionbuttons, 'mdl-align mt-2');
|
||||
$stickyfooter = new core\output\sticky_footer($actionbuttons);
|
||||
echo $OUTPUT->render($stickyfooter);
|
||||
|
||||
echo $OUTPUT->box_end();
|
||||
echo '</div></form>';
|
||||
|
||||
|
@ -70,36 +70,22 @@ if ($action !== '') {
|
||||
}
|
||||
|
||||
if ($id) {
|
||||
$url->param('id', $id);
|
||||
$PAGE->set_url($url);
|
||||
if (! $cm = get_coursemodule_from_id('data', $id)) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
throw new \moodle_exception('coursemisconf');
|
||||
}
|
||||
if (! $data = $DB->get_record('data', array('id'=>$cm->instance))) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
|
||||
} else {
|
||||
list($course, $cm) = get_course_and_cm_from_cmid($id, manager::MODULE);
|
||||
$manager = manager::create_from_coursemodule($cm);
|
||||
$url->param('id', $cm->id);
|
||||
} else { // We must have $d.
|
||||
$instance = $DB->get_record('data', ['id' => $d], '*', MUST_EXIST);
|
||||
$manager = manager::create_from_instance($instance);
|
||||
$cm = $manager->get_coursemodule();
|
||||
$course = get_course($cm->course);
|
||||
$url->param('d', $d);
|
||||
$PAGE->set_url($url);
|
||||
if (! $data = $DB->get_record('data', array('id'=>$d))) {
|
||||
throw new \moodle_exception('invalidid', 'data');
|
||||
}
|
||||
if (! $course = $DB->get_record('course', array('id'=>$data->course))) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
if (! $cm = get_coursemodule_from_instance('data', $data->id, $course->id)) {
|
||||
throw new \moodle_exception('invalidcoursemodule');
|
||||
}
|
||||
}
|
||||
|
||||
require_login($course, true, $cm);
|
||||
|
||||
$manager = manager::create_from_coursemodule($cm);
|
||||
$PAGE->set_url($url);
|
||||
$data = $manager->get_instance();
|
||||
$context = $manager->get_context();
|
||||
|
||||
require_login($course, true, $cm);
|
||||
require_capability('mod/data:managetemplates', $context);
|
||||
|
||||
$formimportzip = new data_import_preset_zip_form();
|
||||
@ -463,8 +449,11 @@ if (($mode == 'new') && (!empty($newtype))) { // Adding a new field.
|
||||
echo '<input type="submit" class="btn btn-secondary ml-1" value="'.get_string('save', 'data').'" />';
|
||||
echo '</div>';
|
||||
echo '</form>';
|
||||
echo '</div>';
|
||||
|
||||
// Add a sticky footer.
|
||||
echo $renderer->render_fields_footer($manager);
|
||||
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
/// Finish the page
|
||||
|
@ -393,7 +393,6 @@ $string['savedataaspreset'] = 'Save all fields and templates as preset';
|
||||
$string['saveaspresetmissingcapability'] = 'The user does not have permission to save the database as a preset.';
|
||||
$string['savesettings'] = 'Save settings';
|
||||
$string['savesuccess'] = 'Preset saved. <a href="{$a->url}">Preview preset</a>';
|
||||
$string['savetemplate'] = 'Save template';
|
||||
$string['search'] = 'Search';
|
||||
$string['search:activity'] = 'Database - activity information';
|
||||
$string['search:entry'] = 'Database - entries';
|
||||
@ -446,6 +445,7 @@ $string['usestandard'] = 'Use a preset';
|
||||
$string['usestandard_help'] = 'To use a preset available to the whole site, select it from the list. (If you have added a preset to the list using the save as preset feature then you have the option of deleting it.)';
|
||||
$string['viewfromdate'] = 'Read only from';
|
||||
$string['viewnavigation'] = 'View mode tertiary navigation';
|
||||
$string['viewtemplates'] = 'View templates';
|
||||
$string['viewtodate'] = 'Read only to';
|
||||
$string['viewtodatevalidation'] = 'The read only to date cannot be before the read only from date.';
|
||||
$string['wrongdataid'] = 'Wrong data id provided';
|
||||
@ -458,3 +458,4 @@ $string['buttons'] = 'Actions';
|
||||
$string['nolisttemplate'] = 'List template is not yet defined';
|
||||
$string['nosingletemplate'] = 'Single template is not yet defined';
|
||||
$string['blank'] = 'Blank';
|
||||
$string['savetemplate'] = 'Save template';
|
||||
|
@ -3,3 +3,4 @@ buttons,mod_data
|
||||
nosingletemplate,mod_data
|
||||
nolisttemplate,mod_data
|
||||
blank,mod_data
|
||||
savetemplate,mod_data
|
||||
|
@ -412,18 +412,15 @@ class data_field_base { // Base class for Database Field Types (see field/*/
|
||||
echo '<input type="hidden" name="d" value="'.$this->data->id.'" />'."\n";
|
||||
if (empty($this->field->id)) {
|
||||
echo '<input type="hidden" name="mode" value="add" />'."\n";
|
||||
$savebutton = get_string('add');
|
||||
} else {
|
||||
echo '<input type="hidden" name="fid" value="'.$this->field->id.'" />'."\n";
|
||||
echo '<input type="hidden" name="mode" value="update" />'."\n";
|
||||
$savebutton = get_string('savechanges');
|
||||
}
|
||||
echo '<input type="hidden" name="type" value="'.$this->type.'" />'."\n";
|
||||
echo '<input name="sesskey" value="'.sesskey().'" type="hidden" />'."\n";
|
||||
|
||||
echo $OUTPUT->heading($this->name(), 3);
|
||||
|
||||
|
||||
$filepath = $CFG->dirroot.'/mod/data/field/'.$this->type.'/mod.html';
|
||||
|
||||
if (!file_exists($filepath)) {
|
||||
@ -432,12 +429,22 @@ class data_field_base { // Base class for Database Field Types (see field/*/
|
||||
require_once($filepath);
|
||||
}
|
||||
|
||||
echo html_writer::start_div('mt-3');
|
||||
echo html_writer::tag('input', null, array('type' => 'submit', 'value' => $savebutton,
|
||||
'class' => 'btn btn-primary'));
|
||||
echo html_writer::tag('input', null, array('type' => 'submit', 'name' => 'cancel',
|
||||
'value' => get_string('cancel'), 'class' => 'btn btn-secondary ml-2'));
|
||||
echo html_writer::end_div();
|
||||
$actionbuttons = html_writer::start_div();
|
||||
$actionbuttons .= html_writer::tag('input', null, [
|
||||
'type' => 'submit',
|
||||
'name' => 'cancel',
|
||||
'value' => get_string('cancel'),
|
||||
'class' => 'btn btn-secondary mr-2'
|
||||
]);
|
||||
$actionbuttons .= html_writer::tag('input', null, [
|
||||
'type' => 'submit',
|
||||
'value' => get_string('save'),
|
||||
'class' => 'btn btn-primary'
|
||||
]);
|
||||
$actionbuttons .= html_writer::end_div();
|
||||
|
||||
$stickyfooter = new core\output\sticky_footer($actionbuttons);
|
||||
echo $OUTPUT->render($stickyfooter);
|
||||
|
||||
echo '</form>';
|
||||
|
||||
|
@ -1,6 +1,29 @@
|
||||
<?php
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Database activity renderer.
|
||||
*
|
||||
* @copyright 2010 Sam Hemelryk
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package mod_data
|
||||
*/
|
||||
|
||||
use mod_data\local\importer\preset_existing_importer;
|
||||
use mod_data\manager;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@ -33,7 +56,6 @@ class mod_data_renderer extends plugin_renderer_base {
|
||||
*/
|
||||
public function importing_preset(stdClass $datamodule, \mod_data\local\importer\preset_importer $importer): string {
|
||||
|
||||
$strcontinue = get_string('continue');
|
||||
$strwarning = get_string('mappingwarning', 'data');
|
||||
$strfieldmappings = get_string('fieldmappings', 'data');
|
||||
|
||||
@ -99,7 +121,23 @@ class mod_data_renderer extends plugin_renderer_base {
|
||||
$attrs = array('type' => 'checkbox', 'name' => 'overwritesettings', 'id' => 'overwritesettings', 'class' => 'ml-1');
|
||||
$html .= html_writer::empty_tag('input', $attrs);
|
||||
$html .= html_writer::end_tag('div');
|
||||
$html .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-primary', 'value' => $strcontinue));
|
||||
|
||||
$actionbuttons = html_writer::start_div();
|
||||
$cancelurl = new moodle_url('/mod/data/preset.php', ['d' => $datamodule->id]);
|
||||
$actionbuttons .= html_writer::tag('a', get_string('cancel') , [
|
||||
'href' => $cancelurl->out(false),
|
||||
'class' => 'btn btn-secondary mr-2',
|
||||
'role' => 'button',
|
||||
]);
|
||||
$actionbuttons .= html_writer::empty_tag('input', [
|
||||
'type' => 'submit',
|
||||
'class' => 'btn btn-primary',
|
||||
'value' => get_string('continue'),
|
||||
]);
|
||||
$actionbuttons .= html_writer::end_div();
|
||||
|
||||
$stickyfooter = new core\output\sticky_footer($actionbuttons);
|
||||
$html .= $this->render($stickyfooter);
|
||||
|
||||
$html .= html_writer::end_tag('div');
|
||||
$html .= html_writer::end_tag('form');
|
||||
@ -119,6 +157,20 @@ class mod_data_renderer extends plugin_renderer_base {
|
||||
return $this->render_from_template('mod_data/fields_action_bar', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the fields page footer.
|
||||
*
|
||||
* @param manager $manager the instance manager
|
||||
* @return string The HTML output
|
||||
*/
|
||||
public function render_fields_footer(manager $manager): string {
|
||||
$cm = $manager->get_coursemodule();
|
||||
$pageurl = new moodle_url('/mod/data/templates.php', ['id' => $cm->id]);
|
||||
return $this->render_from_template('mod_data/fields_footer', [
|
||||
'pageurl' => $pageurl->out(false),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the action bar for the view page.
|
||||
*
|
||||
|
@ -50,9 +50,9 @@
|
||||
"title": null
|
||||
},
|
||||
"extraurlselect": {
|
||||
"id": "url_select_test",
|
||||
"id": "extra_url_select_test",
|
||||
"action": "https://example.com/post",
|
||||
"formid": "url_select_form",
|
||||
"formid": "extra_url_select_form",
|
||||
"sesskey": "sesskey",
|
||||
"classes": "urlselect",
|
||||
"label": "",
|
||||
|
31
mod/data/templates/fields_footer.mustache
Normal file
31
mod/data/templates/fields_footer.mustache
Normal file
@ -0,0 +1,31 @@
|
||||
{{!
|
||||
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 mod_data/fields_footer
|
||||
|
||||
The mod_data fields sticky footer content.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"pageurl": "http://yoursite/mod/data/field.php"
|
||||
}
|
||||
}}
|
||||
{{< core/sticky_footer }}
|
||||
{{$ stickyclasses }} justify-content-start{{/ stickyclasses }}
|
||||
{{$ stickycontent }}
|
||||
<div class="pl-3">
|
||||
<a href="{{pageurl}}">{{#str}} viewtemplates, mod_data {{/str}}</a>
|
||||
</div>
|
||||
{{/ stickycontent }}
|
||||
{{/ core/sticky_footer }}
|
@ -34,10 +34,14 @@
|
||||
{{{preview}}}
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" action="{{formactionurl}}" class="mt-4">
|
||||
<input type="hidden" name="d" value="{{d}}">
|
||||
<input type="hidden" name="mode" value="usepreset">
|
||||
<input type="hidden" name="action" value="select">
|
||||
<input type="hidden" name="fullname" value="{{userid}}/{{shortname}}">
|
||||
<input type="submit" name="selectpreset" value="{{#str}}usepreset, mod_data{{/str}}" class="btn btn-secondary mt-2 float-right">
|
||||
</form>
|
||||
{{< core/sticky_footer }}
|
||||
{{$ stickycontent }}
|
||||
<form method="post" action="{{formactionurl}}">
|
||||
<input type="hidden" name="d" value="{{d}}">
|
||||
<input type="hidden" name="mode" value="usepreset">
|
||||
<input type="hidden" name="action" value="select">
|
||||
<input type="hidden" name="fullname" value="{{userid}}/{{shortname}}">
|
||||
<input type="submit" name="selectpreset" value="{{#str}}usepreset, mod_data{{/str}}" class="btn btn-primary">
|
||||
</form>
|
||||
{{/ stickycontent }}
|
||||
{{/ core/sticky_footer }}
|
||||
|
@ -86,7 +86,17 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<input type="submit" name="selectpreset" value="{{#str}}usepreset, mod_data{{/str}}" class="btn btn-secondary mt-2 float-right" disabled>
|
||||
{{< core/sticky_footer }}
|
||||
{{$ stickycontent }}
|
||||
<input
|
||||
type="submit"
|
||||
name="selectpreset"
|
||||
value="{{#str}}usepreset, mod_data{{/str}}"
|
||||
class="btn btn-secondary"
|
||||
disabled
|
||||
>
|
||||
{{/ stickycontent }}
|
||||
{{/ core/sticky_footer }}
|
||||
</form>
|
||||
|
||||
{{#js}}
|
||||
|
@ -93,22 +93,9 @@
|
||||
{{/editors}}
|
||||
</div>
|
||||
</div>
|
||||
{{#disableeditor}}
|
||||
<div class="container-fluid mt-4">
|
||||
<div class="row">
|
||||
<div>
|
||||
<input
|
||||
class="btn btn-secondary"
|
||||
type="button"
|
||||
name="resetbutton"
|
||||
value="{{#str}} resettemplate, data {{/str}}"
|
||||
/>
|
||||
<input
|
||||
class="btn btn-primary"
|
||||
type="submit"
|
||||
value="{{#str}} savetemplate, data {{/str}}"
|
||||
/>
|
||||
</div>
|
||||
{{#disableeditor}}
|
||||
<div class="ml-auto">
|
||||
<input
|
||||
type="checkbox"
|
||||
@ -119,7 +106,24 @@
|
||||
/>
|
||||
<label for="useeditor">{{#str}} editorenable, data {{/str}}</label>
|
||||
</div>
|
||||
{{/disableeditor}}
|
||||
</div>
|
||||
</div>
|
||||
{{/disableeditor}}
|
||||
{{< core/sticky_footer }}
|
||||
{{$ stickycontent }}
|
||||
<div>
|
||||
<input
|
||||
class="btn btn-secondary"
|
||||
type="button"
|
||||
name="resetbutton"
|
||||
value="{{#str}} reset {{/str}}"
|
||||
/>
|
||||
<input
|
||||
class="btn btn-primary"
|
||||
type="submit"
|
||||
value="{{#str}} save {{/str}}"
|
||||
/>
|
||||
</div>
|
||||
{{/ stickycontent }}
|
||||
{{/ core/sticky_footer }}
|
||||
</form>
|
||||
|
52
mod/data/templates/view_footer.mustache
Normal file
52
mod/data/templates/view_footer.mustache
Normal file
@ -0,0 +1,52 @@
|
||||
{{!
|
||||
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 mod_data/view_footer
|
||||
|
||||
The mod_data sticky footer content.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"selectall": "<button>Select all</button>",
|
||||
"deleteselected": "<button>Cancel selection</button>",
|
||||
"pagination": "1, 2, 3...",
|
||||
"addentrybutton": {
|
||||
"disabled": false,
|
||||
"url": "#",
|
||||
"id": "test-id",
|
||||
"classes": "btn btn-link",
|
||||
"attributes": [
|
||||
{
|
||||
"name": "title",
|
||||
"value": "Add entry"
|
||||
}
|
||||
],
|
||||
"text": "Add"
|
||||
}
|
||||
}
|
||||
}}
|
||||
{{#selectall}}
|
||||
<div class="navitem">
|
||||
{{{selectall}}}
|
||||
{{{deleteselected}}}
|
||||
</div>
|
||||
{{/selectall}}
|
||||
<div class="navitem submit mr-auto ml-auto">
|
||||
{{{pagination}}}
|
||||
</div>
|
||||
{{#addentrybutton}}
|
||||
<div class="navitem">
|
||||
{{> core/action_link}}
|
||||
</div>
|
||||
{{/addentrybutton}}
|
@ -40,11 +40,11 @@ Feature: Users can add the ##actionsmenu## replacement to the database templates
|
||||
| Header | <table> |
|
||||
| Repeated entry | <tr><td>[[field1]]</td><td>##actionsmenu##</td><tr> |
|
||||
| Footer | </table> |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
And I set the field "Templates tertiary navigation" to "Single template"
|
||||
And I set the following fields to these values:
|
||||
| Single template | <table><tr><td>[[field1]]</td><td>[[field2]]</td><td>##actionsmenu##</td><tr></table> |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
|
||||
@javascript
|
||||
Scenario: The ##actionsmenu## replacement displays the expected actions with default settings depending on the user permissions
|
||||
|
@ -62,7 +62,7 @@ class behat_mod_data extends behat_base {
|
||||
}
|
||||
|
||||
$this->execute("behat_forms::i_set_the_following_fields_to_these_values", $fielddata);
|
||||
$this->execute('behat_forms::press_button', get_string('add'));
|
||||
$this->execute('behat_forms::press_button', get_string('save'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,7 +131,7 @@ Feature: Users can use mod_data without editing the templates
|
||||
| Header | New header! |
|
||||
| Repeated entry | This is the template content |
|
||||
| Footer | New footer! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
And I navigate to "Database" in current page administration
|
||||
And I should see "New header!"
|
||||
And I should see "This is the template content"
|
||||
@ -139,7 +139,7 @@ Feature: Users can use mod_data without editing the templates
|
||||
And I should not see "Student entry 1"
|
||||
And I should not see "Some content 1"
|
||||
When I navigate to "Templates" in current page administration
|
||||
And I click on "Reset template" "button"
|
||||
And I click on "Reset" "button" in the "sticky-footer" "region"
|
||||
And I click on "Reset template" "button" in the "Reset template?" "dialogue"
|
||||
And I should see "Template reset"
|
||||
And I navigate to "Database" in current page administration
|
||||
|
@ -33,7 +33,7 @@ Feature: Users can edit the database templates
|
||||
| Header | New header! |
|
||||
| Repeated entry | [[field1]] and [[field2]]! |
|
||||
| Footer | New footer! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
When I navigate to "Database" in current page administration
|
||||
Then I should see "New header!"
|
||||
And I should see "Student entry 1 and Some content 1!"
|
||||
@ -44,7 +44,7 @@ Feature: Users can edit the database templates
|
||||
Given I set the field "Templates tertiary navigation" to "Single template"
|
||||
And I set the following fields to these values:
|
||||
| Single template | [[field1]] and [[field2]] details! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
When I navigate to "Database" in current page administration
|
||||
And I set the field "View mode tertiary navigation" to "Single view"
|
||||
Then I should see "Student entry 1 and Some content 1 details!"
|
||||
@ -54,7 +54,7 @@ Feature: Users can edit the database templates
|
||||
Given I set the field "Templates tertiary navigation" to "Add entry template"
|
||||
And I set the following fields to these values:
|
||||
| Add entry template | [[field1]] [[field2]] Form extra! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
When I navigate to "Database" in current page administration
|
||||
And I click on "Add entry" "button"
|
||||
Then I should see "Form extra!"
|
||||
@ -64,7 +64,7 @@ Feature: Users can edit the database templates
|
||||
Given I set the field "Templates tertiary navigation" to "Advanced search template"
|
||||
And I set the following fields to these values:
|
||||
| Advanced search template | New advanced search template! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
When I navigate to "Database" in current page administration
|
||||
And I click on "Advanced search" "checkbox"
|
||||
Then I should see "New advanced search template!"
|
||||
@ -74,7 +74,7 @@ Feature: Users can edit the database templates
|
||||
Given I click on "Enable editor" "checkbox"
|
||||
And I set the following fields to these values:
|
||||
| Repeated entry | <span class="d-none">Nope</span>Yep! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
When I navigate to "Database" in current page administration
|
||||
Then I should not see "Nope"
|
||||
And I should see "Yep!"
|
||||
@ -84,11 +84,11 @@ Feature: Users can edit the database templates
|
||||
Given I click on "Enable editor" "checkbox"
|
||||
And I set the following fields to these values:
|
||||
| Repeated entry | <span class="hideme">Nope</span>Yep! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
And I set the field "Templates tertiary navigation" to "CSS template"
|
||||
And I set the following fields to these values:
|
||||
| CSS template | .hideme {display: none;} |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
When I navigate to "Database" in current page administration
|
||||
Then I should not see "Nope"
|
||||
And I should see "Yep!"
|
||||
@ -98,11 +98,11 @@ Feature: Users can edit the database templates
|
||||
Given I click on "Enable editor" "checkbox"
|
||||
And I set the following fields to these values:
|
||||
| Repeated entry | <span id="hideme">Nope</span>Yep! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
And I set the field "Templates tertiary navigation" to "Javascript template"
|
||||
And I set the following fields to these values:
|
||||
| Javascript template | window.onload = () => document.querySelector('#hideme').style.display = 'none'; |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
When I navigate to "Database" in current page administration
|
||||
Then I should not see "Nope"
|
||||
And I should see "Yep!"
|
||||
@ -113,7 +113,7 @@ Feature: Users can edit the database templates
|
||||
| Header | New header! |
|
||||
| Repeated entry | This is the template content |
|
||||
| Footer | New footer! |
|
||||
And I click on "Save template" "button"
|
||||
And I click on "Save" "button" in the "sticky-footer" "region"
|
||||
And I navigate to "Database" in current page administration
|
||||
And I should see "New header!"
|
||||
And I should see "This is the template content"
|
||||
@ -121,7 +121,7 @@ Feature: Users can edit the database templates
|
||||
And I should not see "Student entry 1"
|
||||
And I should not see "Some content 1"
|
||||
When I navigate to "Templates" in current page administration
|
||||
And I click on "Reset template" "button"
|
||||
And I click on "Reset" "button" in the "sticky-footer" "region"
|
||||
And I click on "Reset template" "button" in the "Reset template?" "dialogue"
|
||||
Then I should see "Template reset"
|
||||
And I navigate to "Database" in current page administration
|
||||
|
@ -217,8 +217,8 @@ if ($PAGE->user_allowed_editing() && !$PAGE->theme->haseditswitch) {
|
||||
$urlediting = 'on';
|
||||
$strediting = get_string('blocksediton');
|
||||
}
|
||||
$url = new moodle_url($CFG->wwwroot.'/mod/data/view.php', array('id' => $cm->id, 'edit' => $urlediting));
|
||||
$PAGE->set_button($OUTPUT->single_button($url, $strediting));
|
||||
$editurl = new moodle_url($CFG->wwwroot.'/mod/data/view.php', ['id' => $cm->id, 'edit' => $urlediting]);
|
||||
$PAGE->set_button($OUTPUT->single_button($editurl, $strediting));
|
||||
}
|
||||
|
||||
if ($mode == 'asearch') {
|
||||
@ -426,8 +426,8 @@ if ($showactivity) {
|
||||
|
||||
} else {
|
||||
// We have some records to print.
|
||||
$url = new moodle_url('/mod/data/view.php', array('d' => $data->id, 'sesskey' => sesskey()));
|
||||
echo html_writer::start_tag('form', array('action' => $url, 'method' => 'post'));
|
||||
$formurl = new moodle_url('/mod/data/view.php', ['d' => $data->id, 'sesskey' => sesskey()]);
|
||||
echo html_writer::start_tag('form', ['action' => $formurl, 'method' => 'post']);
|
||||
|
||||
if ($maxcount != $totalcount) {
|
||||
$a = new stdClass();
|
||||
@ -447,7 +447,6 @@ if ($showactivity) {
|
||||
$baseurlparams['page'] = $page;
|
||||
}
|
||||
$baseurl = new moodle_url($baseurl, $baseurlparams);
|
||||
echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
|
||||
|
||||
require_once($CFG->dirroot.'/rating/lib.php');
|
||||
if ($data->assessed != RATING_AGGREGATE_NONE) {
|
||||
@ -474,10 +473,8 @@ if ($showactivity) {
|
||||
];
|
||||
$parser = $manager->get_template('singletemplate', $options);
|
||||
echo $parser->parse_entries($records);
|
||||
|
||||
echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
|
||||
|
||||
} else { // List template
|
||||
} else {
|
||||
// List template.
|
||||
$baseurl = '/mod/data/view.php';
|
||||
$baseurlparams = ['d' => $data->id, 'advanced' => $advanced, 'paging' => $paging];
|
||||
if (!empty($search)) {
|
||||
@ -485,8 +482,6 @@ if ($showactivity) {
|
||||
}
|
||||
$baseurl = new moodle_url($baseurl, $baseurlparams);
|
||||
|
||||
echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl);
|
||||
|
||||
echo $data->listtemplateheader;
|
||||
$options = [
|
||||
'search' => $search,
|
||||
@ -497,34 +492,17 @@ if ($showactivity) {
|
||||
echo $parser->parse_entries($records);
|
||||
|
||||
echo $data->listtemplatefooter;
|
||||
|
||||
echo $OUTPUT->paging_bar($totalcount, $page, $nowperpage, $baseurl->out());
|
||||
}
|
||||
|
||||
if ($mode != 'single' && $canmanageentries) {
|
||||
// Build the select/deselect all control.
|
||||
$selectallid = 'selectall-listview-entries';
|
||||
$togglegroup = 'listview-entries';
|
||||
$mastercheckbox = new \core\output\checkbox_toggleall($togglegroup, true, [
|
||||
'id' => $selectallid,
|
||||
'name' => $selectallid,
|
||||
'value' => 1,
|
||||
'label' => get_string('selectall'),
|
||||
'classes' => 'btn-secondary mr-1',
|
||||
], true);
|
||||
echo $OUTPUT->render($mastercheckbox);
|
||||
|
||||
$deleteselected = html_writer::empty_tag('input', array(
|
||||
'class' => 'btn btn-secondary',
|
||||
'type' => 'submit',
|
||||
'value' => get_string('deleteselected'),
|
||||
'disabled' => true,
|
||||
'data-action' => 'toggle',
|
||||
'data-togglegroup' => $togglegroup,
|
||||
'data-toggle' => 'action',
|
||||
));
|
||||
echo $deleteselected;
|
||||
}
|
||||
$stickyfooter = new mod_data\output\view_footer(
|
||||
$manager,
|
||||
$totalcount,
|
||||
$page,
|
||||
$nowperpage,
|
||||
$baseurl,
|
||||
$parser
|
||||
);
|
||||
echo $OUTPUT->render($stickyfooter);
|
||||
|
||||
echo html_writer::end_tag('form');
|
||||
}
|
||||
|
10
theme/boost/amd/build/sticky-footer.min.js
vendored
Normal file
10
theme/boost/amd/build/sticky-footer.min.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
define("theme_boost/sticky-footer",["exports","core/pending"],(function(_exports,_pending){var obj;
|
||||
/**
|
||||
* Sticky footer module.
|
||||
*
|
||||
* @module theme_boost/sticky-footer
|
||||
* @copyright 2022 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=_exports.enableStickyFooter=_exports.disableStickyFooter=void 0,_pending=(obj=_pending)&&obj.__esModule?obj:{default:obj};const SELECTORS_STICKYFOOTER=".stickyfooter",SELECTORS_PAGE="#page",CLASSES_HASSTICKYFOOTER="hasstickyfooter";let initialized=!1,previousScrollPosition=0;const scrollSpy=()=>{if(document.body.clientWidth>=768)return;let scrollPosition=(()=>{const page=document.querySelector(SELECTORS_PAGE);return page?page.scrollTop:window.pageYOffset})();scrollPosition>previousScrollPosition?disableStickyFooter():enableStickyFooter(),previousScrollPosition=scrollPosition},enableStickyFooter=()=>{const pendingPromise=new _pending.default("theme_boost/sticky-footer:enabling"),footer=document.querySelector(SELECTORS_STICKYFOOTER),page=document.querySelector(SELECTORS_PAGE);footer&&page&&(document.body.classList.add(CLASSES_HASSTICKYFOOTER),page.classList.add(CLASSES_HASSTICKYFOOTER)),setTimeout((()=>pendingPromise.resolve()),1e3)};_exports.enableStickyFooter=enableStickyFooter;const disableStickyFooter=()=>{document.body.classList.remove(CLASSES_HASSTICKYFOOTER);const page=document.querySelector(SELECTORS_PAGE);null==page||page.classList.remove(CLASSES_HASSTICKYFOOTER)};_exports.disableStickyFooter=disableStickyFooter;_exports.init=()=>{var _document$querySelect;if(initialized||document.body.classList.contains("behat-site"))return;initialized=!0,enableStickyFooter();(null!==(_document$querySelect=document.querySelector(SELECTORS_PAGE))&&void 0!==_document$querySelect?_document$querySelect:document.body).addEventListener("scroll",scrollSpy)}}));
|
||||
|
||||
//# sourceMappingURL=sticky-footer.min.js.map
|
1
theme/boost/amd/build/sticky-footer.min.js.map
Normal file
1
theme/boost/amd/build/sticky-footer.min.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"sticky-footer.min.js","sources":["../src/sticky-footer.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Sticky footer module.\n *\n * @module theme_boost/sticky-footer\n * @copyright 2022 Ferran Recio <ferran@moodle.com>\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport Pending from 'core/pending';\n\nconst SELECTORS = {\n STICKYFOOTER: '.stickyfooter',\n PAGE: '#page',\n};\n\nconst CLASSES = {\n HASSTICKYFOOTER: 'hasstickyfooter',\n};\n\nlet initialized = false;\n\nlet previousScrollPosition = 0;\n\n/**\n * Return the current page scroll position.\n * @package\n * @returns {number} the current scroll position\n */\nconst getScrollPosition = () => {\n const page = document.querySelector(SELECTORS.PAGE);\n if (page) {\n return page.scrollTop;\n }\n return window.pageYOffset;\n};\n\n/**\n * Scroll handler.\n * @package\n */\nconst scrollSpy = () => {\n // Ignore scroll if page size is not small.\n if (document.body.clientWidth >= 768) {\n return;\n }\n // Detect if scroll is going down.\n let scrollPosition = getScrollPosition();\n if (scrollPosition > previousScrollPosition) {\n disableStickyFooter();\n } else {\n enableStickyFooter();\n }\n previousScrollPosition = scrollPosition;\n};\n\n/**\n * Enable sticky footer in the page.\n */\nexport const enableStickyFooter = () => {\n // We need some seconds to make sure the CSS animation is ready.\n const pendingPromise = new Pending('theme_boost/sticky-footer:enabling');\n const footer = document.querySelector(SELECTORS.STICKYFOOTER);\n const page = document.querySelector(SELECTORS.PAGE);\n if (footer && page) {\n document.body.classList.add(CLASSES.HASSTICKYFOOTER);\n page.classList.add(CLASSES.HASSTICKYFOOTER);\n }\n setTimeout(() => pendingPromise.resolve(), 1000);\n};\n\n/**\n * Disable sticky footer in the page.\n */\nexport const disableStickyFooter = () => {\n document.body.classList.remove(CLASSES.HASSTICKYFOOTER);\n const page = document.querySelector(SELECTORS.PAGE);\n page?.classList.remove(CLASSES.HASSTICKYFOOTER);\n};\n\n/**\n * Initialize the module.\n */\nexport const init = () => {\n // Prevent sticky footer in behat.\n if (initialized || document.body.classList.contains('behat-site')) {\n return;\n }\n initialized = true;\n enableStickyFooter();\n const content = document.querySelector(SELECTORS.PAGE) ?? document.body;\n content.addEventListener(\"scroll\", scrollSpy);\n};\n"],"names":["SELECTORS","CLASSES","initialized","previousScrollPosition","scrollSpy","document","body","clientWidth","scrollPosition","page","querySelector","scrollTop","window","pageYOffset","getScrollPosition","disableStickyFooter","enableStickyFooter","pendingPromise","Pending","footer","classList","add","setTimeout","resolve","remove","contains","addEventListener"],"mappings":";;;;;;;2MAyBMA,uBACY,gBADZA,eAEI,QAGJC,wBACe,sBAGjBC,aAAc,EAEdC,uBAAyB,QAmBvBC,UAAY,QAEVC,SAASC,KAAKC,aAAe,eAI7BC,eAlBkB,YAChBC,KAAOJ,SAASK,cAAcV,uBAChCS,KACOA,KAAKE,UAETC,OAAOC,aAaOC,GACjBN,eAAiBL,uBACjBY,sBAEAC,qBAEJb,uBAAyBK,gBAMhBQ,mBAAqB,WAExBC,eAAiB,IAAIC,iBAAQ,sCAC7BC,OAASd,SAASK,cAAcV,wBAChCS,KAAOJ,SAASK,cAAcV,gBAChCmB,QAAUV,OACVJ,SAASC,KAAKc,UAAUC,IAAIpB,yBAC5BQ,KAAKW,UAAUC,IAAIpB,0BAEvBqB,YAAW,IAAML,eAAeM,WAAW,2DAMlCR,oBAAsB,KAC/BV,SAASC,KAAKc,UAAUI,OAAOvB,+BACzBQ,KAAOJ,SAASK,cAAcV,gBACpCS,MAAAA,MAAAA,KAAMW,UAAUI,OAAOvB,yFAMP,kCAEZC,aAAeG,SAASC,KAAKc,UAAUK,SAAS,qBAGpDvB,aAAc,EACdc,oDACgBX,SAASK,cAAcV,uEAAmBK,SAASC,MAC3DoB,iBAAiB,SAAUtB"}
|
107
theme/boost/amd/src/sticky-footer.js
Normal file
107
theme/boost/amd/src/sticky-footer.js
Normal file
@ -0,0 +1,107 @@
|
||||
// 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/>.
|
||||
|
||||
/**
|
||||
* Sticky footer module.
|
||||
*
|
||||
* @module theme_boost/sticky-footer
|
||||
* @copyright 2022 Ferran Recio <ferran@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
import Pending from 'core/pending';
|
||||
|
||||
const SELECTORS = {
|
||||
STICKYFOOTER: '.stickyfooter',
|
||||
PAGE: '#page',
|
||||
};
|
||||
|
||||
const CLASSES = {
|
||||
HASSTICKYFOOTER: 'hasstickyfooter',
|
||||
};
|
||||
|
||||
let initialized = false;
|
||||
|
||||
let previousScrollPosition = 0;
|
||||
|
||||
/**
|
||||
* Return the current page scroll position.
|
||||
* @package
|
||||
* @returns {number} the current scroll position
|
||||
*/
|
||||
const getScrollPosition = () => {
|
||||
const page = document.querySelector(SELECTORS.PAGE);
|
||||
if (page) {
|
||||
return page.scrollTop;
|
||||
}
|
||||
return window.pageYOffset;
|
||||
};
|
||||
|
||||
/**
|
||||
* Scroll handler.
|
||||
* @package
|
||||
*/
|
||||
const scrollSpy = () => {
|
||||
// Ignore scroll if page size is not small.
|
||||
if (document.body.clientWidth >= 768) {
|
||||
return;
|
||||
}
|
||||
// Detect if scroll is going down.
|
||||
let scrollPosition = getScrollPosition();
|
||||
if (scrollPosition > previousScrollPosition) {
|
||||
disableStickyFooter();
|
||||
} else {
|
||||
enableStickyFooter();
|
||||
}
|
||||
previousScrollPosition = scrollPosition;
|
||||
};
|
||||
|
||||
/**
|
||||
* Enable sticky footer in the page.
|
||||
*/
|
||||
export const enableStickyFooter = () => {
|
||||
// We need some seconds to make sure the CSS animation is ready.
|
||||
const pendingPromise = new Pending('theme_boost/sticky-footer:enabling');
|
||||
const footer = document.querySelector(SELECTORS.STICKYFOOTER);
|
||||
const page = document.querySelector(SELECTORS.PAGE);
|
||||
if (footer && page) {
|
||||
document.body.classList.add(CLASSES.HASSTICKYFOOTER);
|
||||
page.classList.add(CLASSES.HASSTICKYFOOTER);
|
||||
}
|
||||
setTimeout(() => pendingPromise.resolve(), 1000);
|
||||
};
|
||||
|
||||
/**
|
||||
* Disable sticky footer in the page.
|
||||
*/
|
||||
export const disableStickyFooter = () => {
|
||||
document.body.classList.remove(CLASSES.HASSTICKYFOOTER);
|
||||
const page = document.querySelector(SELECTORS.PAGE);
|
||||
page?.classList.remove(CLASSES.HASSTICKYFOOTER);
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the module.
|
||||
*/
|
||||
export const init = () => {
|
||||
// Prevent sticky footer in behat.
|
||||
if (initialized || document.body.classList.contains('behat-site')) {
|
||||
return;
|
||||
}
|
||||
initialized = true;
|
||||
enableStickyFooter();
|
||||
const content = document.querySelector(SELECTORS.PAGE) ?? document.body;
|
||||
content.addEventListener("scroll", scrollSpy);
|
||||
};
|
@ -2320,6 +2320,10 @@ $footer-link-color: $bg-inverse-link-color !default;
|
||||
@include box-shadow($popover-box-shadow);
|
||||
}
|
||||
|
||||
.hasstickyfooter .btn-footer-popover {
|
||||
bottom: calc(2rem + #{$navbar-height});
|
||||
}
|
||||
|
||||
.popover.footer {
|
||||
.popover-body {
|
||||
padding: 0;
|
||||
|
@ -7,6 +7,13 @@ body.behat-site {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
// Sticky footer can overlap with elements so we keep it relative for behat.
|
||||
&.hasstickyfooter .stickyfooter,
|
||||
.stickyfooter {
|
||||
position: inherit;
|
||||
z-index: inherit;
|
||||
}
|
||||
|
||||
// We need more spacing in action menus so behat does not click on the wrong menu item.
|
||||
.dropdown-item {
|
||||
margin-top: 4px !important; /* stylelint-disable declaration-no-important */
|
||||
@ -100,4 +107,3 @@ body > .debuggingmessage {
|
||||
body > .debuggingmessage ~ .debuggingmessage {
|
||||
margin-top: .5rem;
|
||||
}
|
||||
|
||||
|
@ -192,6 +192,13 @@
|
||||
top: $navbar-height;
|
||||
height: calc(100vh - #{$navbar-height});
|
||||
}
|
||||
.hasstickyfooter {
|
||||
.drawer-left,
|
||||
.drawer-right {
|
||||
top: $navbar-height;
|
||||
height: calc(100vh - #{$navbar-height} - #{$navbar-height});
|
||||
}
|
||||
}
|
||||
|
||||
#page.drawers {
|
||||
position: relative;
|
||||
@ -217,6 +224,9 @@
|
||||
margin-left: $drawer-left-width;
|
||||
margin-right: $drawer-right-width;
|
||||
}
|
||||
&.hasstickyfooter {
|
||||
height: calc(100vh - #{$navbar-height} - #{$navbar-height});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,30 @@ body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.stickyfooter {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: $navbar-height + 1px;
|
||||
bottom: -$navbar-height;
|
||||
transition: bottom .5s;
|
||||
z-index: $zindex-dropdown;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.hasstickyfooter .stickyfooter {
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
/* Standard components fixes for sticky footer. */
|
||||
|
||||
.stickyfooter ul.pagination {
|
||||
margin-bottom: map-get($spacers, 1);
|
||||
}
|
||||
|
||||
|
||||
/* Breakpoints fixes. */
|
||||
|
||||
@include media-breakpoint-up(sm) {
|
||||
#page-wrapper {
|
||||
height: 100%;
|
||||
|
@ -11727,6 +11727,9 @@ ul {
|
||||
bottom: 2rem;
|
||||
right: 2rem; }
|
||||
|
||||
.hasstickyfooter .btn-footer-popover {
|
||||
bottom: calc(2rem + 60px); }
|
||||
|
||||
.popover.footer .popover-body {
|
||||
padding: 0; }
|
||||
.popover.footer .popover-body .footer-section a {
|
||||
@ -19923,6 +19926,11 @@ body.reset-style .btn:not(.btn-icon) {
|
||||
body.behat-site .fixed-top {
|
||||
position: absolute; }
|
||||
|
||||
body.behat-site.hasstickyfooter .stickyfooter,
|
||||
body.behat-site .stickyfooter {
|
||||
position: inherit;
|
||||
z-index: inherit; }
|
||||
|
||||
body.behat-site .dropdown-item {
|
||||
margin-top: 4px !important;
|
||||
/* stylelint-disable declaration-no-important */ }
|
||||
@ -20001,6 +20009,24 @@ html,
|
||||
body {
|
||||
height: 100%; }
|
||||
|
||||
.stickyfooter {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 61px;
|
||||
bottom: -60px;
|
||||
transition: bottom .5s;
|
||||
z-index: 1000;
|
||||
overflow: hidden; }
|
||||
|
||||
.hasstickyfooter .stickyfooter {
|
||||
bottom: 0; }
|
||||
|
||||
/* Standard components fixes for sticky footer. */
|
||||
.stickyfooter ul.pagination {
|
||||
margin-bottom: 0.25rem; }
|
||||
|
||||
/* Breakpoints fixes. */
|
||||
@media (min-width: 576px) {
|
||||
#page-wrapper {
|
||||
height: 100%;
|
||||
@ -20624,6 +20650,10 @@ span[data-flexitour="container"][x-placement="right"], span[data-flexitour="cont
|
||||
.drawer-right {
|
||||
top: 60px;
|
||||
height: calc(100vh - 60px); }
|
||||
.hasstickyfooter .drawer-left,
|
||||
.hasstickyfooter .drawer-right {
|
||||
top: 60px;
|
||||
height: calc(100vh - 60px - 60px); }
|
||||
#page.drawers {
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
@ -20648,7 +20678,9 @@ span[data-flexitour="container"][x-placement="right"], span[data-flexitour="cont
|
||||
right: calc(315px + 2rem); }
|
||||
#page.drawers.show-drawer-left.show-drawer-right {
|
||||
margin-left: 285px;
|
||||
margin-right: 315px; } }
|
||||
margin-right: 315px; }
|
||||
#page.drawers.hasstickyfooter {
|
||||
height: calc(100vh - 60px - 60px); } }
|
||||
|
||||
.drawercontrolbuttons {
|
||||
margin-top: 92px; }
|
||||
|
53
theme/boost/templates/core/sticky_footer.mustache
Normal file
53
theme/boost/templates/core/sticky_footer.mustache
Normal file
@ -0,0 +1,53 @@
|
||||
{{!
|
||||
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 theme_boost/core/sticky_footer
|
||||
|
||||
Displays a page sticky footer element.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"stickycontent": "<a href=\"#\">Moodle</a>",
|
||||
"stickyclasses": "justify-content-end",
|
||||
"extras": [
|
||||
{
|
||||
"attribute" : "data-example",
|
||||
"value" : "stickyfooter"
|
||||
}
|
||||
]
|
||||
}
|
||||
}}
|
||||
<div
|
||||
id="sticky-footer"
|
||||
class="d-flex flex-row align-items-center stickyfooter p-2 fixed-bottom bg-white border-top {{!
|
||||
}} {{$ stickyclasses }}{{!
|
||||
}}{{# stickyclasses }}{{ stickyclasses }}{{/ stickyclasses }}{{!
|
||||
}}{{^ stickyclasses }}justify-content-end{{/ stickyclasses }}{{!
|
||||
}}{{/ stickyclasses }}"
|
||||
{{#extras}}
|
||||
{{attribute}}="{{value}}"
|
||||
{{/extras}}
|
||||
>
|
||||
{{$ stickycontent }}
|
||||
{{{stickycontent}}}
|
||||
{{/ stickycontent }}
|
||||
</div>
|
||||
{{#js}}
|
||||
require(['theme_boost/sticky-footer'], function(footer) {
|
||||
footer.init();
|
||||
});
|
||||
{{/js}}
|
@ -263,3 +263,12 @@
|
||||
padding-top: 0 !important; /* stylelint-disable-line declaration-no-important */
|
||||
}
|
||||
}
|
||||
|
||||
#page-footer {
|
||||
padding-top: $spacer * .5;
|
||||
padding-bottom: $spacer * .5;
|
||||
}
|
||||
|
||||
body.hasstickyfooter #page-footer {
|
||||
padding-bottom: calc(#{$spacer} * .5 + #{$navbar-height});
|
||||
}
|
||||
|
@ -11727,6 +11727,9 @@ ul {
|
||||
bottom: 2rem;
|
||||
right: 2rem; }
|
||||
|
||||
.hasstickyfooter .btn-footer-popover {
|
||||
bottom: calc(2rem + 50px); }
|
||||
|
||||
.popover.footer .popover-body {
|
||||
padding: 0; }
|
||||
.popover.footer .popover-body .footer-section a {
|
||||
@ -19869,6 +19872,11 @@ body:not(.jsenabled) .langmenu:hover > .dropdown-menu,
|
||||
body.behat-site .fixed-top {
|
||||
position: absolute; }
|
||||
|
||||
body.behat-site.hasstickyfooter .stickyfooter,
|
||||
body.behat-site .stickyfooter {
|
||||
position: inherit;
|
||||
z-index: inherit; }
|
||||
|
||||
body.behat-site .dropdown-item {
|
||||
margin-top: 4px !important;
|
||||
/* stylelint-disable declaration-no-important */ }
|
||||
@ -19947,6 +19955,24 @@ html,
|
||||
body {
|
||||
height: 100%; }
|
||||
|
||||
.stickyfooter {
|
||||
position: fixed;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 51px;
|
||||
bottom: -50px;
|
||||
transition: bottom .5s;
|
||||
z-index: 1000;
|
||||
overflow: hidden; }
|
||||
|
||||
.hasstickyfooter .stickyfooter {
|
||||
bottom: 0; }
|
||||
|
||||
/* Standard components fixes for sticky footer. */
|
||||
.stickyfooter ul.pagination {
|
||||
margin-bottom: 0.25rem; }
|
||||
|
||||
/* Breakpoints fixes. */
|
||||
@media (min-width: 576px) {
|
||||
#page-wrapper {
|
||||
height: 100%;
|
||||
@ -20570,6 +20596,10 @@ span[data-flexitour="container"][x-placement="right"], span[data-flexitour="cont
|
||||
.drawer-right {
|
||||
top: 50px;
|
||||
height: calc(100vh - 50px); }
|
||||
.hasstickyfooter .drawer-left,
|
||||
.hasstickyfooter .drawer-right {
|
||||
top: 50px;
|
||||
height: calc(100vh - 50px - 50px); }
|
||||
#page.drawers {
|
||||
position: relative;
|
||||
overflow-y: auto;
|
||||
@ -20594,7 +20624,9 @@ span[data-flexitour="container"][x-placement="right"], span[data-flexitour="cont
|
||||
right: calc(315px + 2rem); }
|
||||
#page.drawers.show-drawer-left.show-drawer-right {
|
||||
margin-left: 285px;
|
||||
margin-right: 315px; } }
|
||||
margin-right: 315px; }
|
||||
#page.drawers.hasstickyfooter {
|
||||
height: calc(100vh - 50px - 50px); } }
|
||||
|
||||
.drawercontrolbuttons {
|
||||
margin-top: 92px; }
|
||||
@ -22075,3 +22107,10 @@ body {
|
||||
.block.block_settings #settingsnav {
|
||||
padding-top: 0 !important;
|
||||
/* stylelint-disable-line declaration-no-important */ }
|
||||
|
||||
#page-footer {
|
||||
padding-top: 0.5rem;
|
||||
padding-bottom: 0.5rem; }
|
||||
|
||||
body.hasstickyfooter #page-footer {
|
||||
padding-bottom: calc(1rem * .5 + 50px); }
|
||||
|
@ -30,7 +30,7 @@
|
||||
}
|
||||
}
|
||||
}}
|
||||
<footer id="page-footer" class="py-3 footer-dark bg-dark text-light">
|
||||
<footer id="page-footer" class="footer-dark bg-dark text-light">
|
||||
<div class="container footer-dark-inner">
|
||||
<div id="course-footer">{{{ output.course_footer }}}</div>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user