I recently created a plugin for Joomla which uses the nice SweetAlert2 popup script and it generally works fine. However, surprisingly, when the size of the html message I use is too long, the box does not popup and the content gets instead written to the document body itself. Is there a size limit for the html parameter or could this somehow be caused by Joomla?
No, I did not yet isolate how many characters it fails but I will.
No, I did not dig into SweetAlert2's code as it goes way beyond what I can do with javascript.
Yes, I checked the miniorange plugin but it was not really what I needed.
Here's the code for the part where I check the html parameter (note that I had to try to deal with accented characters too).
/** * * Create content * * Parameters-values separators is := */ function generateText($array) { $res =explode(",",$array); // For each parameter // we extract value foreach ($res as $str) { $s = explode(":=", $str); // Test apostrophe if ($s[0] == 'html' || $s[0] == 'text') { //$s[1] = trim($s[1],"'"); if (strpos($s[1],"l'") !== false) { $accents = str_replace("l'","l\'",$s[1]); $string = "'" . $accents . "'"; } else $string = $s[1]; } else $string = $s[1]; // In case there's html, decode to keep tags $corr = html_entity_decode($string); // Add to final text $texte .= $s[0] . ": " . $corr .","; } // Remove last two chars $new = substr($texte, 0, -1); return $new; }
:=
is the separator and the plugin syntax is like:
{swal title:='<span style="font-size: 16px;">INFORMATION</span>',html:='<span style="font-size: 14px;">Mask and sanitary pass are</span><b><span style="font-size: 14px; color: #FF0000;"> mandatory for all adults and kids from 12 to 17 to....</span></b><br /><br /><b>Thanks!</b>',icon:='info',confirmButtonText:='OK',iconColor:='#FF0000'}{/swal}
$array
should never contain string-type data.$string = "'" . $accents . "'";
will be breaking the SweetAlert's parsing code. I assume that it is looking for single-quote wrapped substrings, but you are mangling the substrings wheneverl'
is found. Is this the goal: 3v4l.org/QiGci ?