Back to PhocacartRenderJs class

Method renderAjaxAskAQuestion

public static
renderAjaxAskAQuestion
(mixed $options = array())

Method renderAjaxAskAQuestion - Source code

/*
public static function renderDetectVirtualKeyboard() {
    $s 	= array();
    $s[] = 'jQuery(document).ready(function(){';
    $s[] = '  var phDefaultSize = jQuery(window).width() + jQuery(window).height()';
    $s[] = '  jQuery(window).resize(function(){';
    $s[] = '    if(jQuery(window).width() + jQuery(window).height() != phDefaultSize){';
    $s[] = '       ';
    $s[] = '      jQuery(".ph-pos-wrap-main").css("position","fixed");';
    $s[] = '    } else {';
    $s[] = '       ';
    $s[] = '      jQuery(".ph-pos-wrap-main").css("position","relative");';
    $s[] = '    }';
    $s[] = '  });';
    $s[] = '});';
    Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
}
*/
public static function renderAjaxAskAQuestion($options = array())
{
    $paramsC = PhocacartUtils::getComponentParameters();
    $item_askquestion = $paramsC->get('item_askquestion', 0);
    $popup_askquestion = $paramsC->get('popup_askquestion', 0);
    if ($item_askquestion > 0 && $popup_askquestion == 2) {
        $s[] = ' jQuery(document).ready(function(){';
        $s[] = '	jQuery(document).on("click", "a.phModalContainerButton", function (e) {';
        $s[] = '      var src = jQuery(this).attr("data-src");';
        $s[] = '      var height = "100%";';
        //jQuery(this).attr("data-height") || 300;// Does not work and it is solved by CSS
        $s[] = '      var width = "100%";';
        //jQuery(this).attr("data-width") || 400;
        $s[] = '      var id = jQuery(this).attr("data-id");';
        $s[] = '      var idIframe = "#" + id + " iframe";';
        // Loaded dynamically to not have previous src in iframe, see: components/com_phocacart/layouts/popup_container_iframe.php
        $s[] = '      var idBody = "#" + id + " .modal-body";';
        $s[] = '      jQuery(idBody).html(\'<iframe frameborder="0"></iframe>\');';
        // end iframe could be a past of layout file
        $s[] = '      jQuery(idIframe).attr({"src":src, "height": height, "width": width});';
        //$s[] = '      jQuery(id).modal();';
        // Is loaded by HTML
        //    $s[] = '      var modal = new bootstrap.Modal(document.getElementById(id), {});';
        //    $s[] = '      modal.show();';
        $s[] = '   });';
        $s[] = ' });';
        Factory::getDocument()->addScriptDeclaration(implode("\n", $s));
    }
}