Skip to content
Snippets Groups Projects
Commit cbf44f55 authored by Thomas Fradet's avatar Thomas Fradet
Browse files

Merge branch 'dev'

parents 0c6c0f3d c5a63729
No related branches found
No related tags found
No related merge requests found
......@@ -170,6 +170,17 @@ function filter($text, array $options = array())
}
$len = strpos($pieces[$i], $this->end, $ini) - $ini;
$parsed = substr($pieces[$i], $ini, $len);
/* calcul unique modale id for showing modale, based on module type (page, test, etc.) and module id */
$modal_id = $i; /* default */
$module_id = null;
preg_match('/id=([\d]+)*/', $pieces[$i], $module_id);
$module_type = "";
preg_match('/\/mod\/([^\/]+)\//', $pieces[$i], $module_type);
if (isset($module_id[1]) && isset($module_id[1])) {
$modal_id = $module_type[1] . $module_id[1];
}
preg_match_all('/id=[\d]*/', $parsed, $matches);
if ($matches[0]) {
preg_match_all('/[\d]+/', $matches[0][0], $id_btn);
......@@ -198,16 +209,16 @@ 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 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 . "; "
. "class=\"btn iena-filter-modal-btn \" data-toggle=\"modal\" data-target=\"#iena-modal-" . $modal_id . "\" 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 fade iena-filter-modal\" id=\"iena-modal-" . $modal_id . "\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"#iena-modal-btn-" . $modal_id . "\" 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>'
. '<h5 class="modal-title" id="iena-modal-btn-'.$modal_id.'">'.$this->btn_name.'</h5>'
. '<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>'
......
......@@ -9,29 +9,11 @@
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 = "";
});
/* iframe kill after modale closing doesn't work... */
// console.log($('.iena-filter-modal'));
// $('.iena-filter-modal').on('hidden.bs.modal', function (e) {
// console.log(e);
// console.log(this);
// this.querySelector('iframe').src = "";
// });
})(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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment