public
modalWindowDynamic
(mixed $id, mixed $textButton, mixed $w = 700, mixed $h = 400, mixed $reload = false, mixed $autoOpen = 0, mixed $iframeLink = '', mixed $iframeClass = '', mixed $customFooter = '', mixed $pageClass = '')
public function modalWindowDynamic($id, $textButton, $w = 700, $h = 400, $reload = false, $autoOpen = 0, $iframeLink = '', $iframeClass = '', $customFooter = '', $pageClass = '')
{
$s = array();
if ($customFooter != '') {
$footer = $customFooter;
} else {
$footer = '<button type="button" class="btn btn-primary" data-bs-dismiss="modal" aria-hidden="true">' . Text::_('COM_PHOCACART_CLOSE') . '</button>';
}
// Global Close
//if ($autoOpen == 1) {
$s[] = 'window.phCloseModal = function(){';
//$s[] = ' jQuery("#'.$id.'").modal(\'hide\');';
//$s[] = ' var modal = new bootstrap.Modal(document.getElementById("'.$id.'"), {});';
//$s[] = ' modal.dispose();';
$s[] = ' var modalEl = document.getElementById("' . $id . '");';
$s[] = ' var modal = bootstrap.Modal.getInstance(modalEl);';
$s[] = ' modal.hide();';
$s[] = ' jQuery("#' . $id . ' .modal-body").css("background", "");';
// set back the backround, previously set to white for not first page of wizard
$s[] = '}';
$s[] = ' ';
//}
$s[] = 'jQuery(document).ready(function() {';
if ($autoOpen == 1) {
//$s[] = ' jQuery("#'.$id.'").modal("show");';
$s[] = ' var modal = new bootstrap.Modal(document.getElementById("' . $id . '"), {});';
$s[] = ' modal.show();';
//$s[] = ' jQuery("#'.$id.'").on("shown", function() {';
$s[] = ' var bsModal = document.getElementById("' . $id . '");';
$s[] = ' bsModal.addEventListener("shown.bs.modal", function () {';
} else {
$s[] = ' jQuery(document.body).on(\'click\', \'.' . $id . 'ModalButton\' ,function(e) {';
$s[] = ' var src = jQuery(this).attr(\'data-src\');';
// Specific case for downloadable files - they need to include token folder like product has (product and attribute download files are stored in one folder)
if ($id == 'phFileDownloadNameModalO') {
// Get value from each row not from main
$s[] = ' var idFolder = \'#\' + jQuery(this).attr(\'data-id-folder\');';
$s[] = ' var phDownloadFolder = jQuery(idFolder).val();';
$s[] = ' src = src + "&folder=" + phDownloadFolder + "&downloadfolder=" + phDownloadFolder;';
}
}
if ($iframeLink != '') {
$modalBody = '';
$s[] = ' var src = "' . $iframeLink . '";';
$s[] = ' jQuery("iframe").on("load", function(){';
// Add specific class to body because of making the background transparent (body in iframe)
$s[] = ' jQuery(this).contents().find("body").addClass("ph-body-iframe");';
// Get information about current page in start wizard and set white background to all pages larger than 1
// Only first page (page = 0) is different, it has background set in phocacart.css
if ($pageClass != '') {
$s[] = ' var phPage =jQuery(this).contents().find(".' . $pageClass . '").data("page");';
$s[] = ' if (phPage > 0) {';
$s[] = ' jQuery("#' . $id . ' .modal-body").css("background", "#ffffff");';
$s[] = ' }';
}
if ($iframeClass != '') {
// Add specific class to body in iframe - to stylize it easily
$s[] = ' jQuery(this).contents().find("body").addClass("' . strip_tags(htmlspecialchars($iframeClass, ENT_QUOTES, 'UTF-8')) . '");';
}
$s[] = ' });';
} else {
// NO IFRAME LINK We have no iframe link, we will build it dynamically
$modalBody = '<iframe frameborder="0"></iframe>';
$s[] = ' jQuery("#' . $id . ' iframe").attr({\'src\':src});';
}
//$s[] = ' var height = jQuery(this).attr(\'data-height\') || '.$w.';';
//$s[] = ' var height = jQuery(window).height() - 200;';
//$s[] = ' var width = jQuery(this).attr(\'data-width\') || '.$h.';';
//$s[] = ' height = height + \'px\';';
//$s[] = ' width = width + \'px\';';
//$s[] = ' jQuery("#'.$id.' iframe").attr({\'src\':src, \'height\': height, \'width\': width});';
/// $s[] = ' jQuery("#'.$id.' iframe").attr({\'src\':src});';
//$s[] = ' var maxHeight = jQuery(this).height();';
//$s[] = ' var maxHeightString = \'max-height:\' + maxHeight + \'px\';';
//$s[] = ' jQuery("#'.$id.' iframe").attr({\'src\':src, \'height\': \''.$h.'px\', \'width\': \'auto\', \'style\' : maxHeightString});';
$s[] = ' });';
if ($reload) {
//$s[] = ' jQuery("#'.$id.'").on("hidden", function () {';
$s[] = ' var bsModal = document.getElementById("' . $id . '");';
$s[] = ' bsModal.addEventListener("hidden.bs.modal", function () {';
$s[] = ' var phOverlay = jQuery(\'<div id="phOverlay"><div id="phLoaderFull"> </div></div>\');';
$s[] = ' phOverlay.appendTo(document.body);';
$s[] = ' jQuery("#phOverlay").fadeIn().css("display","block");';
$s[] = ' setTimeout(function(){';
$s[] = ' window.parent.location.reload();';
$s[] = ' },10);';
$s[] = ' });';
}
$s[] = '})';
Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
$html = array();
//libraries/src/HTML/Helpers/Bootstrap.php
$html[] = HTMLHelper::_('bootstrap.renderModal', $id, array('url' => $iframeLink, 'title' => Text::_($textButton), 'width' => '', 'height' => '', 'modalWidth' => '80', 'bodyHeight' => '80', 'footer' => $footer), $modalBody);
return implode("\n", $html);
/* Row
$o .= ' <a href="#'.$idA.'" role="button" class="btn btn-primary '.$idA.'ModalButton" data-toggle="modal" title="' . Text::_($textButton) . '" data-src="'.$url.$id.'" data-height="'.$h.'" data-width="'.$w.'">'
. '<span class="icon-list icon-white"></span> '
. Text::_($textButton) . '</a></span>';
*/
}