diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..89bdc0a8e1081fa153983bd42f9f4ce90f3aa50e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +# 19/02/19 + +## Vitesse de chargement + +La source de la fenêtre modale n'est plus définie en PHP, mais en Javascript à son ouverture. En conséquence, la page se charge plus rapidement lorsqu'il y a de nombreux éléments, et la ressource se charge dans la fenêtre modale lors de son ouverture. + +## Affichage + +L'affichage du contenu de l'iframe sans les menus de nativation et le footer est réactivé. + +L'affichage du contenu de l'iframe sans les menus de nativation et le footer est optimisé pour MOODLE 3.5.4+. + +L'affichage du contenu de l'iframe sans les menus de nativation et le footer fait l'objet d'un paramètre du plugin (case à cochée). Il est activé par défaut. + +# 21/02/19 + +Lors de la fermeture de la fenêtre modale, le contenu de l'iframe est déchargé afin d'éviter qu'un média affiché à l'intérieur (vidéo) continue de fonctionner et en plus consomme de la ressource. L'ergonomie et la performance sont améliorées. + +# 15/05/19 + +Les menu de MOODLE ne s'affichent plus sur certaines ressources où ils persistaient malgré le réglage. + + diff --git a/README.md b/README.md index 5c674eea7eded94d7526da566814479f38e361ff..8756160a1a258820db126a0a9fb970e619fc7704 100644 --- a/README.md +++ b/README.md @@ -43,5 +43,4 @@ L'administrateur peut configurer la couleur du bloc et du texte. Il doit par ail ## Problèmes connus - Il semble qu'il faille positionner le filtre de lien automatique des activité sur "Activé" et non pas "Activé (défaut)" sur certaines installations. Il doit être activé quoi qu'il en soit et placé avant ce filtre Activité modale dans l'ordre d'application des filtres (administration). -- Les menus de Moodle s'affichent également dans l'iFrame de la fenêtre modale et pourraient être supprimés pour un meilleur affichage, bien que ceci soit par nature instable et dépendant du thème utilisé. diff --git a/filter.php b/filter.php index 88bb4d3b12aafb2373c7ec281b9c7f0679caf070..9618a16ac7f06ae46c98bb68b204d5a2d190ad7d 100644 --- a/filter.php +++ b/filter.php @@ -31,21 +31,22 @@ class filter_iena extends moodle_text_filter { - /** @var string This variable is used for delemiter */ + /* @var string This variable is used for delemiter */ public $start = "[IENA]"; - /** @var string This variable is used for delemiter */ + /* @var string This variable is used for delemiter */ public $end = "[/IENA]"; -/** @var string Contain button name, the button name is - * automatically the name of resource */ -public $btn_name; -/** @var string Contain the type of button */ -public $btn_type; -/** @var string Hex color of button is defined in settings ($CFG->color_btn) */ -public $color_btn = "#009085"; -/** @var string Hex color of button text is defined in settings ($CFG->color_btn_txt) */ -public $color_btn_txt = "#ffffff"; -/** @var string set empty, if the id does not exist then turn to "disabled" */ -public $disabled = ""; + /* @var string Contain button name, the button name is automatically the name of resource */ + public $btn_name; + /** @var string Contain the type of button */ + public $btn_type; + /** @var string Hex color of button is defined in settings ($CFG->color_btn) */ + public $color_btn = "#009085"; + /** @var string Hex color of button text is defined in settings ($CFG->color_btn_txt) */ + public $color_btn_txt = "#ffffff"; + /** @var string set empty, if the id does not exist then turn to "disabled" */ + public $disabled = ""; + /** @var string hide iframe nav and footer, admin setting */ + public $iena_filter_iframe = true; /** * Get name and type of resource with the id @@ -137,14 +138,17 @@ function filter($text, array $options = array()) $this->color_btn_txt = $CFG->color_btn_txt; } - //$PAGE->requires->js('/filter/iena/js/jquery-3.3.1.min.js'); - //$PAGE->requires->js('/filter/iena/js/iena.js'); + $PAGE->requires->js('/filter/iena/js/jquery-3.3.1.min.js'); + $PAGE->requires->js('/filter/iena/js/iena.js'); //We hide the menus and block if the iframe parameter is a true - // if (isset($_GET['iframe'])) { - // if ($_GET['iframe'] == 'true') { - // $PAGE->requires->js('/filter/iena/js/iframe_true.js'); - // } - // } + if (isset($CFG->iena_filter_iframe)) { + $this->iena_filter_iframe = $CFG->iena_filter_iframe; + } + if (isset($_GET['iframe']) && $this->iena_filter_iframe == true) { + if ($_GET['iframe'] == 'true') { + $PAGE->requires->js('/filter/iena/js/iframe_true.js'); + } + } preg_match_all('/<a href="(.*?)">(.*?)<\/a>/s', $text, $matches); @@ -193,26 +197,27 @@ function filter($text, array $options = array()) $pieces[$i] = preg_replace("/(\\S+)\\[\/IENA\\]/", "<div>" - . "<a class=\"sr-only\" target=\"_blank\" href=\"$parsed\">Ouvrir dans un nouvel onglet au lieu d'utiliser la modale : $this->btn_name.</a><button type=\"button\" " . $this->disabled . " " + . "<a class=\"sr-only\" target=\"_blank\" href=\"$parsed\">Ouvrir dans un nouvel onglet au lieu d'utiliser la modale : $this->btn_name.</a><button data-iframe=\"" .$parsed. "&iframe=true\" type=\"button\" " . $this->disabled . " " . "class=\"btn iena-filter-modal-btn \" data-toggle=\"modal\" data-target=\"#iena-modal-" . $i . "\" style=\"background-color : " . $this->color_btn . "; " . "color : $this->color_btn_txt;border-radius:0.15rem;\">" . "<img class=\"icon icon\" alt=\"\" src=\"" . $CFG->wwwroot . "/theme/image.php/boost/" . $this->btn_type . "/1/icon\">" . "" . $this->btn_name . " </button>" . "<div class=\"modal fade iena-filter-modal\" id=\"iena-modal-" . $i . "\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"#iena-modal-btn-" . $i . "\" aria-hidden=\"true\">" - . "<div class=\"modal-dialog\" role=\"document\">" - . '<div class="modal-content">' - . '<div class="modal-header">' - . '<h5 class="modal-title" id="iena-modal-btn-'.$i.'">'.$this->btn_name.'</h5>' - . '<button type="button" class="close" data-dismiss="modal" aria-label="Close"> - <span aria-hidden="true">×</span> - </button>' - . "</div>" - . '<div class="modal-body">' - . "<iframe src=\"" . $parsed . "&iframe=true\" frameborder=\"0\" allowfullscreen></iframe>" - . "</div>" - . "</div>" - . "</div>" + . "<div class=\"modal-dialog\" role=\"document\">" + . '<div class="modal-content">' + . '<div class="modal-header">' + . '<h5 class="modal-title" id="iena-modal-btn-'.$i.'">'.$this->btn_name.'</h5>' + . '<button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button>' + . "</div>" + . '<div class="modal-body">' + // . "<iframe src=\"" . $parsed . "&iframe=true\" frameborder=\"0\" allowfullscreen></iframe>" + . "<iframe src=\"\" frameborder=\"0\" allowfullscreen></iframe>" + . "</div>" + . "</div>" + . "</div>" . "</div>" . "</div>" diff --git a/filtersettings.php b/filtersettings.php index 18e0d00d5dc6b0301c8d41d5ac933c2371316ffb..f66e0f0e45c7233abe0c6c455e2216fd5b1709d0 100644 --- a/filtersettings.php +++ b/filtersettings.php @@ -2,4 +2,5 @@ $settings->add(new admin_setting_configtext('color_btn', get_string('btn_settings', 'filter_iena'), get_string('setting_btn_settings', 'filter_iena'), "#009085")); $settings->add(new admin_setting_configtext('color_btn_txt', get_string('btn_txt_settings', 'filter_iena'), get_string('setting_btn_txt_settings', 'filter_iena'), "#ffffff")); + $settings->add(new admin_setting_configcheckbox('iena_filter_iframe', get_string('btn_iframe_setting', 'filter_iena'), get_string('setting_btn_iframe_setting', 'filter_iena'), "1")); ?> diff --git a/js/iena-filter-accessibility.js b/js/iena-filter-accessibility.js deleted file mode 100644 index d3261c2e9285793aaacc25da2e9b0f55d7be83e2..0000000000000000000000000000000000000000 --- a/js/iena-filter-accessibility.js +++ /dev/null @@ -1,9 +0,0 @@ -// (function() { -// window.onload = function () { -// $(".iena-filter-modal-btn").each(function(i, el){ -// el.click = function (e) { -// console.log(e); -// } -// }); -// } -// })() \ No newline at end of file diff --git a/js/iena.js b/js/iena.js index b9b6f5e4ed3a5888cf7e401f235cf1cc2b0c3bab..226c572da278580e581f56f19aaf80608c7d5fea 100644 --- a/js/iena.js +++ b/js/iena.js @@ -1,22 +1,33 @@ ;(function ($) { - $('iframe').load(function () { - $('iframe').contents().find("body") - .append($("<style type='text/css'> \n\ - #page-header{display:none;}\n\ - #page-footer{display:none;} \n\ - .hidden-print{display:none;}\n\ - #page{margin-top: 15px;padding-left: 10px;padding-right: 15px;} \n\ - #card-block{height: 837px;width: 990px;} \n\ - </style>")); - $('iframe').contents().find("header") - .append($("<style type='text/css'> \n\ - .pos-f-t{display:none;} \n\ - .navbar{display:none;} \n\ - .navbar-full{display:none;} \n\ - .navbar-light{display:none;} \n\ - .bg-faded{display:none;} \n\ - .navbar-static-top{display:none;} \n\ - .moodle-has-zindex{display:none;}\n\ - </style>")); + var btns = document.querySelectorAll('.iena-filter-modal-btn'); + for (var i = 0; i < btns.length; i++) { + btns[i].onclick = function (e) { + document.querySelector(e.target.dataset.target + " iframe").setAttribute('src', e.target.dataset.iframe); + } + } + $('.iena-filter-modal').on('hide.bs.modal', function (e) { + e.target.querySelector('iframe').src = ""; }); -})(jQuery); \ No newline at end of file +})(jQuery); +// ;(function ($) { +// $('iframe').load(function () { +// $('iframe').contents().find("body") +// .append($("<style type='text/css'> \n\ +// #page-header{display:none;}\n\ +// #page-footer{display:none;} \n\ +// .hidden-print{display:none;}\n\ +// #page{margin-top: 15px;padding-left: 10px;padding-right: 15px;} \n\ +// #card-block{height: 837px;width: 990px;} \n\ +// </style>")); +// $('iframe').contents().find("header") +// .append($("<style type='text/css'> \n\ +// .pos-f-t{display:none;} \n\ +// .navbar{display:none;} \n\ +// .navbar-full{display:none;} \n\ +// .navbar-light{display:none;} \n\ +// .bg-faded{display:none;} \n\ +// .navbar-static-top{display:none;} \n\ +// .moodle-has-zindex{display:none;}\n\ +// </style>")); +// }); +// })(jQuery); \ No newline at end of file diff --git a/js/iframe_true.js b/js/iframe_true.js index 96ff001ef63e04c7ad885839f00ba007bfbeb06f..97860954a68198a0564c1bfddc190d354a7dade5 100644 --- a/js/iframe_true.js +++ b/js/iframe_true.js @@ -4,28 +4,55 @@ * and open the template in the editor. */ -var elmt = document.getElementById("page-header"); -elmt.className = "none_hidden"; - -var elmt1 = document.getElementById("page-footer"); -elmt1.className = "none_hidden"; - -var elmt2 = document.getElementsByClassName("hidden-print"); -elmt2.className = "none_hidden"; - -var elmt2 = document.getElementsByClassName("hidden-print"); -elmt2.className = "none_hidden"; - -var elmt3 = document.getElementsByClassName("pos-f-t"); -elmt3.className = "none_hidden"; - -var elmt4 = document.getElementsByClassName("navbar"); -elmt3.className = "none_hidden"; -var elmt5 = document.getElementsByClassName("navbar-full"); -elmt3.className = "none_hidden"; -var elmt6 = document.getElementsByClassName("navbar-light"); -elmt3.className = "none_hidden"; -var elmt7 = document.getElementsByClassName("navbar-static-top"); -elmt3.className = "none_hidden"; -var elmt8 = document.getElementsByClassName("moodle-has-zindex"); -elmt3.className = "none_hidden"; +/* http://localhost:8888/moodle35/mod/assign/view.php?id=18&iframe=true + +&iframe=true + +*/ + +;(function () { + window.onload = function () { + var to_hide = [ + "#page-header", + "#page-wrapper > nav", + "#page-footer", + "#nav-drawer" + ]; + for (var i = 0; i < to_hide.length; i++) { + document.querySelector(to_hide[i]).setAttribute('class', 'none-hidden'); + } + document.querySelector('#page').setAttribute('class', ''); + document.querySelector('#page').style.margin = 0; + document.querySelector('#page-wrapper').setAttribute('class', 'no-after'); + document.querySelector('#page-content').setAttribute('class', 'no-margin-l-r'); + document.querySelector('#region-main-box').style.padding = 0; + document.querySelector('#region-main>.card').style.minHeight = 0; + document.body.style.marginLeft = 0; + } +})() + +// var elmt = document.getElementById("page-header"); +// elmt.className = "none_hidden"; + +// var elmt1 = document.getElementById("page-footer"); +// elmt1.className = "none_hidden"; + +// var elmt2 = document.getElementsByClassName("hidden-print"); +// elmt2.className = "none_hidden"; + +// var elmt2 = document.getElementsByClassName("hidden-print"); +// elmt2.className = "none_hidden"; + +// var elmt3 = document.getElementsByClassName("pos-f-t"); +// elmt3.className = "none_hidden"; + +// var elmt4 = document.getElementsByClassName("navbar"); +// elmt3.className = "none_hidden"; +// var elmt5 = document.getElementsByClassName("navbar-full"); +// elmt3.className = "none_hidden"; +// var elmt6 = document.getElementsByClassName("navbar-light"); +// elmt3.className = "none_hidden"; +// var elmt7 = document.getElementsByClassName("navbar-static-top"); +// elmt3.className = "none_hidden"; +// var elmt8 = document.getElementsByClassName("moodle-has-zindex"); +// elmt3.className = "none_hidden"; diff --git a/lang/en/filter_iena.php b/lang/en/filter_iena.php index 6a2a3059e61c4d5d23ac1669061150ad0000161e..ba9eb1a0c577090b19f75fafe380f44dc7fbce19 100644 --- a/lang/en/filter_iena.php +++ b/lang/en/filter_iena.php @@ -5,8 +5,10 @@ $string['pluginname'] = "filter_iena"; $string['filter_iena'] = "filter_iena"; $string['btn_settings'] = "Button background color"; $string['btn_txt_settings'] = "Button text color"; +$string['btn_iframe_setting'] = "Diplay content only"; $string['setting_btn_settings'] = "The value must be in hexa and start with a #"; $string['setting_btn_txt_settings'] = "The value must be in hexa and start with a #"; +$string['setting_btn_iframe_setting'] = "Display only iframe content, without navigation controls and footer."; $string['erreur_ressource'] = "Ressource not found"; ?> \ No newline at end of file diff --git a/lang/fr/filter_iena.php b/lang/fr/filter_iena.php index 17b483dc89818802334fdd6fdd5ffb1db68ed18d..57534ec5298d63879fba087f4bdd1d35875068aa 100644 --- a/lang/fr/filter_iena.php +++ b/lang/fr/filter_iena.php @@ -5,8 +5,10 @@ $string['pluginname'] = "filter_iena"; $string['filter_iena'] = "filter_iena"; $string['btn_settings'] = "Couleur du bouton"; $string['btn_txt_settings'] = "Couleur du texte du bouton"; +$string['btn_iframe_setting'] = "N'afficher que le contenu"; $string['setting_btn_settings'] = "La valeur doit être en hexadécimal et débuter avec un #"; $string['setting_btn_txt_settings'] = "La valeur doit être en hexadécimal et débuter avec un #"; +$string['setting_btn_iframe_setting'] = "N'afficher que le contenu de la page ciblée, sans les menus ou le pied de page."; $string['erreur_ressource'] = "Ressource non trouvée"; ?> \ No newline at end of file diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties deleted file mode 100644 index 6d2691b283e6b22b528dfe6bf012e6a86e9badff..0000000000000000000000000000000000000000 --- a/nbproject/private/private.properties +++ /dev/null @@ -1,2 +0,0 @@ -index.file=index.php -url=http://localhost/wikipediacalls/ diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml deleted file mode 100644 index 8c2649004afc05cb8c5c7c2f47dabb302736d6ca..0000000000000000000000000000000000000000 --- a/nbproject/private/private.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project-private xmlns="http://www.netbeans.org/ns/project-private/1"> - <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/2" lastBookmarkId="0"/> - <open-files xmlns="http://www.netbeans.org/ns/projectui-open-files/2"> - <group> - <file>file:/home/softia/Bureau/wikipediacalls/filtersettings.php</file> - <file>file:/home/softia/Bureau/wikipediacalls/version.php</file> - <file>file:/home/softia/Bureau/wikipediacalls/filter.php</file> - </group> - </open-files> -</project-private> diff --git a/nbproject/project.properties b/nbproject/project.properties deleted file mode 100644 index 9e7cd7bed98ac8006d09b86c08a30fe51184083a..0000000000000000000000000000000000000000 --- a/nbproject/project.properties +++ /dev/null @@ -1,7 +0,0 @@ -include.path=${php.global.include.path} -php.version=PHP_56 -source.encoding=UTF-8 -src.dir=. -tags.asp=false -tags.short=false -web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml deleted file mode 100644 index 72848eccdd48c2734aeb62363521bfd01e966562..0000000000000000000000000000000000000000 --- a/nbproject/project.xml +++ /dev/null @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.php.project</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/php-project/1"> - <name>wikipediacalls</name> - </data> - </configuration> -</project> diff --git a/styles.css b/styles.css index 823d490a04bd9d3e76bd4e1fef25ce960e8c8b77..69f00a5dd10ddea30123a222a614e364113f846b 100644 --- a/styles.css +++ b/styles.css @@ -24,7 +24,15 @@ font-size: 3rem;*/ } -.none_hidden { - /*display: none;*/ +.none-hidden { + display: none; } +.no-after:after { + min-height: 0 !important; +} + +.no-margin-l-r { + margin-left: 0; + margin-right: 0; +} diff --git a/version.php b/version.php index 251da63c1e99ed023e2a18fa454c30a6a6869933..9aaf2ec51fa92e98ce2ec514c81321d002025b4d 100644 --- a/version.php +++ b/version.php @@ -1,36 +1,36 @@ -<?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/>. - - /** - * Version details - * - * The iena filter plugin transforms the moodle resource links - * into a button that opens the resource in a modal - * - * @package filter_iena - * @category filter - * @copyright 2018 Softia/Université lorraine - * @author vrignaud camille - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - - defined('MOODLE_INTERNAL') || die(); - - $plugin->version = 2018071201; // The current plugin version (Date: YYYYMMDDXX) - $plugin->requires = 2011120500; // Requires this Moodle version - $plugin->component = 'filter_iena'; // Full name of the plugin (used for diagnostics) - $plugin->release = "1.0"; +<?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/>. + + /** + * Version details + * + * The iena filter plugin transforms the moodle resource links + * into a button that opens the resource in a modal + * + * @package filter_iena + * @category filter + * @copyright 2018 Softia/Université lorraine + * @author vrignaud camille + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + + defined('MOODLE_INTERNAL') || die(); + + $plugin->version = 2019051501; // The current plugin version (Date: YYYYMMDDXX) + $plugin->requires = 2011120500; // Requires this Moodle version + $plugin->component = 'filter_iena'; // Full name of the plugin (used for diagnostics) + $plugin->release = "1.0"; $plugin->maturity = MATURITY_STABLE; \ No newline at end of file