[Hastymail-cvs] SF.net SVN: hastymail:[1083] trunk/hastymail2/plugins
Brought to you by:
sailfrog,
slushpupie
From: <sai...@us...> - 2009-10-19 02:57:13
|
Revision: 1083 http://hastymail.svn.sourceforge.net/hastymail/?rev=1083&view=rev Author: sailfrog Date: 2009-10-19 02:57:05 +0000 (Mon, 19 Oct 2009) Log Message: ----------- make the js_sign plugin work with the html_mail plugin (preliminary) Modified Paths: -------------- trunk/hastymail2/plugins/html_mail/work.php trunk/hastymail2/plugins/js_sign/work.php Modified: trunk/hastymail2/plugins/html_mail/work.php =================================================================== --- trunk/hastymail2/plugins/html_mail/work.php 2009-10-19 01:22:59 UTC (rev 1082) +++ trunk/hastymail2/plugins/html_mail/work.php 2009-10-19 02:57:05 UTC (rev 1083) @@ -74,6 +74,7 @@ content_css : "?page=html_mail", force_br_newlines : true, forced_root_block : \'\' , + body_id: "compose_message", relative_urls : false, width: "635", mode: "textareas", Modified: trunk/hastymail2/plugins/js_sign/work.php =================================================================== --- trunk/hastymail2/plugins/js_sign/work.php 2009-10-19 01:22:59 UTC (rev 1082) +++ trunk/hastymail2/plugins/js_sign/work.php 2009-10-19 02:57:05 UTC (rev 1083) @@ -26,6 +26,18 @@ if ($tools->get_page() != 'compose') { return; } + $html_format_mail = false; + $txt_area = 'txtArea = document.getElementById("compose_message");'; + $txt_value = 'txtArea.value'; + $txt_pre = ''; + if (isset($_SESSION['plugins']['work_hooks']['html_mail'])) { + $html_format_mail = $tools->get_setting('html_format_mail'); + if ($html_format_mail) { + $txt_area = 'txtArea = compose_message_ifr.document.body;'; + $txt_value = 'txtArea.innerHTML'; + $txt_pre = 'compose_message_ifr.'; + } + } $tools->add_js_event_handler('compose_sign', 'onclick', 'js_sign_handler'); $tools->register_ajax_callback('get_sig', 2, false); $js = '<script type="text/javascript">'.$tools->start_cdata().' @@ -49,29 +61,39 @@ } function callback_js_sign_get_sig(output) { if (output != "") { - txtArea = document.getElementById("compose_message"); + '.$txt_area.' var pos = get_cursor_pos(txtArea); if (!pos) { - pos = 0; + pos = '.$txt_value.'.length; } - var preText = txtArea.value.substr(0, pos); - var postText = txtArea.value.substr(pos); + var preText = '.$txt_value.'.substr(0, pos); + var postText = '.$txt_value.'.substr(pos); var pre = "\n\n"; - var post = "\n"; + var post = "\n";'; + if ($html_format_mail) { + $js .= ' + pre = "<br />"; + post = "<br />"; + output = output.replace(/\n/mg, "<br />"); + '; + } + else { + $js .= ' if (pos == 0 || preText.match(/\n\s*$/)) { pre = "\n"; } if (!postText.match(/^\s*\n/)) { post = "\n\n"; - } - txtArea.value = preText + pre + output + post + postText; + }'; + } + $js .= $txt_value.' = preText + pre + output + post + postText; } } function get_cursor_pos(ctrl) { var CaretPos = 0; - if (document.selection) { + if ('.$txt_pre.'document.selection) { ctrl.focus (); - var Sel = document.selection.createRange (); + var Sel = '.$txt_pre.'document.selection.createRange (); Sel.moveEnd ("character", -ctrl.value.length); CaretPos = Sel.text.length; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |