Pracuje nad zrobienie mailboxa i nie jestem pewien czy zrobilem to we wlasciwy sposob... tzn chyba nie do konca, bo mam minimum 2 problemy
Maile otwieram w modalu, a tresc laduje do summernote w iframe
<script type="text/javascript">
$.ajax({
url: 'json/load-email',
dataType: 'json',
data: datac,
type: 'POST',
success: function(msg)
{
[...]
$('#showmsg').find('.inbox-view').html('<iframe id="showmsgiframe" style="width: 100%;height: 300px;border: 0px;" frameborder="0" marginheight="0" marginwidth="0" width="100%"></iframe>');
$(function() {
var $frame = $('#showmsgiframe');
setTimeout( function() {
var doc = $frame[0].contentWindow.document;
var $body = $('body',doc);
if (msg['mail']['body']['html'] != '')
{
$body.html(msg['mail']['body']['html']);
}
else if (msg['mail']['body']['plain'] != '')
$body.html(msg['mail']['body']['plain']);
}, 1 );
});
[...]
}[...]
</script>
Kolejny kod dotyczy opcji "Reply" gdzie otwiera sie nowe okno z mozliwoscia edytowania wew iframe
<script type="text/javascript">
[...]
$('#sendmsg').find('#message').summernote('code','<script type="text/template" id="iframeContent"><!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Inner</title></head><body contenteditable="true" style="margin: 0px; padding: 0px;"><blockquote style="width: 100%;height: 100%; padding: 0px;margin: 0px;"><br><br><small>----- Original Message -----<br><strong>From:</strong> '+mailfrom+'<br><strong>Sent:</strong> '+emaildate+'<br><strong>To:</strong> '+emailset+'<br><strong>Subject:</strong> '+mailsubject+'<br><br><br>'+cont+'</small></blockquote></body></html></script><iframe id="ifrm" style="width: 100%;height: 100%;border: 0px;" frameborder="0" scrolling="yes"></iframe>');
[...]
var iframe = document.getElementById( 'ifrm' );
var content = document.getElementById("iframeContent").innerHTML;
var frameDoc = iframe.document;
if (iframe.contentWindow)
{
frameDoc = iframe.contentWindow.document;
}
frameDoc.open();
frameDoc.writeln(content);
frameDoc.close();
</script>
Nastepnie wysylka formularza.
Problem jest taki, ze mail ktory przychodzi nie zawiera nowej wiadomosci, a tresc ktora byla w iframe dochodzi jako ucieta... zakladam, ze powinienem przed wysylka wyciagnac wszystko z iframe i tylko to wyslac, ale czy to jest wlasnie sposob w jaki prawidlowo powinno to byc zrobione?
Drugi problem jest taki, ze summernote (toolbar) nie dziala dla tekstu wpisywanego w iframe... dziala tylko dla tekstu pisanego poza iframe, ale jesli daje taka mozliwosc to po wpisaniu czegokolwiek do summernote znika iframe.
Jakies wskazowki/pomysly?
Wprowadzilem pewne zmiany i maile dochodza
<script type="text/javascript">
[...]
$('#sendmsg').find('#script').html('<script type="text/template" id="iframeContent"><!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Inner</title></head><body contenteditable="true" style="margin: 0px; padding: 0px;"><br><br><small>----- Original Message -----<br><strong>From:</strong> '+mailfrom+'<br><strong>Sent:</strong> '+emaildate+'<br><strong>To:</strong> '+emailset+'<br><strong>Subject:</strong> '+mailsubject+'<br><br><br>'+cont+'</small></body></html></script>');
$('#sendmsg').find('#message').summernote('code','<iframe id="ifrm" style="width: 100%;height: 100%;border: 0px;" frameborder="0" scrolling="yes"></iframe>');
[...]
</script>
Nadal jest problem z toolbarem, ktory nie dziala dla iframe :/