Changeset 5911 for trunk/expressoMail1_2/js/main.js
- Timestamp:
- 04/11/12 11:35:15 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/js/main.js
r5891 r5911 283 283 { 284 284 away=false; 285 var save_link = Element("save_message_options_"+border_id);285 var save_link = content.find(".save"); 286 286 save_link.onclick = function onclick(event) {openTab.toPreserve[border_id] = true;save_msg(border_id);} ; 287 $("#save_message_options_"+border_id).button({disabled: false});287 save_link.button({disabled: false}); 288 288 $(".header-button").button(); 289 289 }; 290 291 var subject_obj = document.getElementById('subject_'+border_id); 290 var content = $("#content_id_"+border_id); 291 292 var subject_obj = content.find(".subject"); 292 293 if ( subject_obj.addEventListener ) 293 294 subject_obj.addEventListener('keypress', keypress_handler, false); … … 295 296 subject_obj.attachEvent('onkeypress', keypress_handler); 296 297 297 var to_obj = document.getElementById('to_'+border_id);298 var to_obj = content.find('[name="input_to"]'); 298 299 if ( to_obj.addEventListener ) 299 300 to_obj.addEventListener('keypress', keypress_handler, false); … … 301 302 to_obj.attachEvent('onkeypress', keypress_handler); 302 303 303 var cc_obj = document.getElementById('cc_'+border_id);304 var cc_obj = content.find('[name="input_cc"]'); 304 305 if ( cc_obj.addEventListener ) 305 306 cc_obj.addEventListener('keypress', keypress_handler, false); … … 307 308 cc_obj.attachEvent('onkeypress', keypress_handler); 308 309 309 if( document.getElementById('cco_'+border_id)){310 var cco_obj = document.getElementById('cco_'+border_id);310 if(content.find('[name="input_cco"]').length){ 311 var cco_obj = content.find('[name="input_cco"]'); 311 312 if ( cco_obj.addEventListener ) 312 313 cco_obj.addEventListener('keypress', keypress_handler, false); … … 1455 1456 if (type != 'edit') 1456 1457 { 1457 return new_border_ID; 1458 delete_border(currentTab); 1459 new_border_ID = draw_new_message(parseInt(border_ID)); 1458 1460 } 1459 1461 } else { … … 1560 1562 if(type!="new" && type!="edit" && document.getElementById("is_local_"+border_ID) != null) 1561 1563 data.is_local_message = (document.getElementById("is_local_"+border_ID).value=="1")?true:false; 1562 switch(type){ 1564 1565 if(typeof($.fn.elastic) == "undefined"){ 1566 $.lazy({ 1567 src: '../prototype/plugins/jquery-elastic/jquery.elastic.source.js', 1568 name: 'elastic' 1569 }); 1570 } 1571 var content = $("#content_id_"+new_border_ID); 1572 content.find('[name="msg_reply_from"]').val($("#msg_number_" + border_ID).val()); 1573 1574 switch(type){ 1563 1575 case "reply_without_history": 1564 1576 RichTextEditor.replyController = true; //Seta o editor como modo reply 1565 Element("to_" + new_border_ID).value = data.to;1577 content.find('[name="input_to"]').val(data.to); 1566 1578 title = "Re: " + data.subject; 1567 Element("subject_" + new_border_ID).value = "Re: " + data.subject; 1568 useOriginalAttachments(new_border_ID,border_ID); 1569 1579 content.find(".subject").val("Re: " + data.subject); 1580 useOriginalAttachments(new_border_ID,border_ID); 1570 1581 1571 1582 // Insert the signature automaticaly at message body if use_signature preference is set 1572 1583 if (preferences.use_signature == "1"){ 1573 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature ,true) ; 1574 } 1575 msg_reply_from = document.createElement('input'); 1576 msg_reply_from.id = "msg_reply_from_" + new_border_ID; 1577 msg_reply_from.type = "hidden"; 1578 msg_reply_from.value = Element("msg_number_" + border_ID).value; 1579 Element("content_id_" + new_border_ID).appendChild(msg_reply_from); 1584 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature ,true) ; 1585 } 1580 1586 break; 1581 1587 case "reply_with_history": … … 1583 1589 RichTextEditor.replyController = true; //Seta o editor como modo reply 1584 1590 title = "Re: " + data.subject; 1585 Element("subject_" + new_border_ID).value = "Re: " + data.subject;1586 Element("to_" + new_border_ID).value = data.to;1591 content.find(".subject").val("Re: " + data.subject); 1592 content.find('[name="input_to"]').val(data.to); 1587 1593 1588 1594 useOriginalAttachments(new_border_ID,border_ID); … … 1594 1600 else 1595 1601 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>'+ block_quoted_body,true); 1596 msg_reply_from = document.createElement('input');1597 msg_reply_from.id = "msg_reply_from_" + new_border_ID;1598 msg_reply_from.type = "hidden";1599 msg_reply_from.value = Element("msg_number_" + border_ID).value;1600 Element("content_id_" + new_border_ID).appendChild(msg_reply_from);1601 1602 break; 1602 1603 case "reply_to_all_without_history": … … 1610 1611 1611 1612 title = "Re: " + data.subject; 1612 Element("subject_" + new_border_ID).value = "Re: " + data.subject;1613 content.find(".subject").val("Re: " + data.subject); 1613 1614 1614 1615 if (data.to.indexOf(Element("user_email").value) > 0 ) 1615 Element("to_" + new_border_ID).value = data.to_all;1616 content.find('[name="input_to"]').val(data.to_all); 1616 1617 else 1617 Element("to_" + new_border_ID).value = data.to + ',' + data.to_all; 1618 //Element("to_" + new_border_ID).value = data.to; 1619 //Element("to_" + new_border_ID).value += ', ' + data.to_all; 1618 content.find('[name="input_to"]').val(data.to + ',' + data.to_all); 1619 1620 if (data.cc){ 1621 data.cc = new Array(); 1622 data.cc = removeUserEmail(_array_cc); 1623 data.cc = removeAlternative(data.cc,_array_to_alternative); 1624 if (data.cc != get_lang("undisclosed-recipient")) 1625 data.cc = data.cc.join(","); 1626 else 1627 data.cc = ""; 1628 if(data.cc != ""){ 1629 content.find('[name="input_cc"]').val(data.cc); 1630 content.find(".cc-tr").css("display"," ");//cc-button 1631 //document.getElementById("a_cc_link" + new_border_ID).value = data.cc; 1632 content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); 1633 content.find(".cc-button").find("span").html("Remover CC"); 1634 content.find('[name="input_cc"]').elastic().unbind('blur'); 1635 content.find('[name="input_cc"]').trigger("update"); 1636 } 1637 } 1638 1639 useOriginalAttachments(new_border_ID,border_ID); 1640 if (preferences.use_signature == "1") 1641 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature,true); 1642 1643 break; 1644 case "reply_to_all_with_history": 1645 RichTextEditor.replyController = true; //Seta o editor como modo reply 1646 //delete user email from to_all array. 1647 data.to_all = new Array(); 1648 data.to_all = removeUserEmail(_array_to_all); 1649 data.to_all = removeAlternative(data.to_all,_array_to_alternative); 1650 1651 if (data.to_all != get_lang("undisclosed-recipient")) 1652 data.to_all = data.to_all.join(","); 1653 else 1654 data.to_all = ""; 1655 title = "Re: " + data.subject; 1620 1656 1657 if (data.to.indexOf(Element("user_email").value) > 0 ) 1658 content.find('[name="input_to"]').val(data.to_all); 1659 else 1660 content.find('[name="input_to"]').val(data.to + ',' + data.to_all); 1621 1661 if (data.cc){ 1622 1662 data.cc = new Array(); … … 1627 1667 else 1628 1668 data.cc = ""; 1629 if(data.cc == ""){ 1630 //document.getElementById("cc_" + new_border_ID).value = data.cc; 1631 document.getElementById("tr_cc_" + new_border_ID).style.display='none'; 1632 }else{ 1633 document.getElementById("cc_" + new_border_ID).value = data.cc; 1634 document.getElementById("tr_cc_" + new_border_ID).style.display=''; 1635 //document.getElementById("a_cc_link" + new_border_ID).value = data.cc; 1636 $("#a_cc_link_"+new_border_ID).toggleClass("expressomail-button-icon-ative"); 1637 $("#a_cc_link_"+new_border_ID).find("span").html("Remover CC"); 1638 $("#cc_"+new_border_ID).elastic().unbind('blur'); 1639 $("#cc_"+new_border_ID).trigger("update"); 1669 if(data.cc != ""){ 1670 content.find('[name="input_cc"]').val(data.cc); 1671 content.find(".cc-tr").show(); 1672 content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); 1673 content.find(".cc-button").find("span").html("Remover CC"); 1674 content.find('[name="input_cc"]').elastic().unbind('blur'); 1675 content.find('[name="input_cc"]').trigger("update"); 1640 1676 } 1641 1677 } 1642 1643 useOriginalAttachments(new_border_ID,border_ID); 1644 1645 // Insert the signature automaticaly at message body if use_signature preference is set 1646 if (preferences.use_signature == "1") 1647 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature,true); 1648 msg_reply_from = document.createElement('input'); 1649 msg_reply_from.id = "msg_reply_from_" + new_border_ID; 1650 msg_reply_from.type = "hidden"; 1651 msg_reply_from.value = Element("msg_number_" + border_ID).value; 1652 Element("content_id_" + new_border_ID).appendChild(msg_reply_from); 1653 break; 1654 case "reply_to_all_with_history": 1655 RichTextEditor.replyController = true; //Seta o editor como modo reply 1656 //delete user email from to_all array. 1657 data.to_all = new Array(); 1658 data.to_all = removeUserEmail(_array_to_all); 1659 data.to_all = removeAlternative(data.to_all,_array_to_alternative); 1660 1661 if (data.to_all != get_lang("undisclosed-recipient")) 1662 data.to_all = data.to_all.join(","); 1663 else 1664 data.to_all = ""; 1665 title = "Re: " + data.subject; 1666 1667 if (data.to.indexOf(Element("user_email").value) > 0 ) 1668 Element("to_" + new_border_ID).value = data.to_all; 1669 else 1670 Element("to_" + new_border_ID).value = data.to + ',' + data.to_all; 1671 if (data.cc){ 1672 data.cc = new Array(); 1673 data.cc = removeUserEmail(_array_cc); 1674 data.cc = removeAlternative(data.cc,_array_to_alternative); 1675 if (data.cc != get_lang("undisclosed-recipient")) 1676 data.cc = data.cc.join(","); 1677 else 1678 data.cc = ""; 1679 if(data.cc == ""){ 1680 //document.getElementById("cc_" + new_border_ID).value = data.cc; 1681 document.getElementById("tr_cc_" + new_border_ID).style.display='none'; 1682 }else{ 1683 document.getElementById("cc_" + new_border_ID).value = data.cc; 1684 document.getElementById("tr_cc_" + new_border_ID).style.display=''; 1685 //document.getElementById("a_cc_link" + new_border_ID).value = data.cc; 1686 $("#a_cc_link_"+new_border_ID).toggleClass("expressomail-button-icon-ative"); 1687 $("#a_cc_link_"+new_border_ID).find("span").html("Remover CC"); 1688 $("#cc_"+new_border_ID).elastic().unbind('blur'); 1689 $("#cc_"+new_border_ID).trigger("update"); 1690 } 1691 } 1692 document.getElementById("subject_" + new_border_ID).value = "Re: " + data.subject; 1678 content.find(".subject").val("Re: " + data.subject); 1693 1679 useOriginalAttachments(new_border_ID,border_ID); 1694 1680 block_quoted_body = make_body_reply(data.body, data.to, data.date_day, data.date_hour); 1695 // Insert the signature automaticaly at message body if use_signature preference is set1681 1696 1682 if (preferences.use_signature == "1") 1697 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ block_quoted_body,true); 1698 else 1699 RichTextEditor.setInitData(new_border_ID,block_quoted_body,true); 1700 msg_reply_from = document.createElement('input'); 1701 msg_reply_from.id = "msg_reply_from_" + new_border_ID; 1702 msg_reply_from.type = "hidden"; 1703 msg_reply_from.value = Element("msg_number_" + border_ID).value; 1704 Element("content_id_" + new_border_ID).appendChild(msg_reply_from); 1683 RichTextEditor.setInitData(new_border_ID,'<div><br type="_moz"></div>' + signature + '<div><br type="_moz"></div>'+ block_quoted_body,true); 1684 else 1685 RichTextEditor.setInitData(new_border_ID,block_quoted_body,true); 1686 1705 1687 break; 1706 1688 case "forward": 1707 1708 msg_forward_from = document.createElement('input');1709 msg_forward_from.id = "msg_forward_from_" + new_border_ID;1710 msg_forward_from.type = "hidden";1711 msg_forward_from.value = Element("msg_number_" + border_ID).value;1712 Element("content_id_" + new_border_ID).appendChild(msg_forward_from);1713 1689 title = "Fw: " + data.subject; 1714 document.getElementById("subject_" + new_border_ID).value = "Fw: " + data.subject;1690 content.find(".subject").val("Fw: " + data.subject); 1715 1691 var divFiles = Element("divFiles_"+new_border_ID); 1716 1692 var campo_arquivo; … … 1741 1717 } 1742 1718 } 1743 Element("to_" + new_border_ID).value = _to +',';1719 content.find('[name="input_to"]').val(_to +','); 1744 1720 Element('msg_number').value = ''; 1745 1721 } … … 1749 1725 RichTextEditor.setInitData(new_border_ID, '<div><br type="_moz"></div>' + signature); 1750 1726 else 1751 $('#to_'+new_border_ID).focus();1727 content.find('[name="input_to"]').focus(); 1752 1728 break; 1753 1729 case "edit": … … 1764 1740 } 1765 1741 1766 Element("to_" + new_border_ID).value = data.to;1742 content.find('[name="input_to"]').val(data.to); 1767 1743 if (data.cc){ 1768 1744 data.cc = data.cc.replace(/</gi,"<"); 1769 1745 data.cc = data.cc.replace(/>/gi,">"); 1770 Element("cc_" + new_border_ID).value = data.cc; 1771 Element("cc_" + new_border_ID).style.display = ""; 1772 Element("tr_cc_"+ new_border_ID).style.display = ''; 1773 Element("cc_" + new_border_ID).style.width = "100%"; 1774 $("#a_cc_link_"+new_border_ID).toggleClass("expressomail-button-icon-ative"); 1775 $("#a_cc_link_"+new_border_ID).find("span").html("Remover CC"); 1776 $("#cc_"+new_border_ID).elastic().unbind('blur'); 1777 $("#cc_"+new_border_ID).trigger("update"); 1778 //Element("a_cc_link_" + new_border_ID).style.display = 'none'; 1779 //if(Element("cco_" + new_border_ID) != null) 1780 // Element("space_link_" + new_border_ID).style.display = 'none'; 1746 content.find('[name="input_cc"]').val(data.cc); 1747 content.find(".cc-tr").show(); 1748 content.find(".cc-button").toggleClass("expressomail-button-icon-ative"); 1749 content.find(".cc-button").find("span").html(get_lang('Remove CC')); 1750 content.find('[name="input_cc"]').elastic().unbind('blur'); 1751 content.find('[name="input_cc"]').trigger("update"); 1781 1752 } 1782 1753 if (data.cco){ 1783 if(Element("cco_" + new_border_ID) != null){ 1784 Element("cco_" + new_border_ID).value = data.cco; 1785 Element("cco_" + new_border_ID).style.display = ''; 1786 Element("cco_" + new_border_ID).style.width = "100%"; 1787 Element("tr_cco_"+ new_border_ID).style.display = ''; 1788 $("#a_cco_link_"+new_border_ID).toggleClass("expressomail-button-icon-ative"); 1789 $("#a_cco_link_"+new_border_ID).find("span").html("Remover CC"); 1790 $("#cco_"+new_border_ID).elastic().unbind('blur'); 1791 $("#cco_"+new_border_ID).trigger("update"); 1792 //Element("space_link_" + new_border_ID).style.display = 'none'; 1793 //Element("a_cco_link_" + new_border_ID).style.display = 'none'; 1794 Element("tr_cco_"+ new_border_ID).style.display = ''; 1795 } 1796 } 1797 Element("subject_" + new_border_ID).value = data.subject; 1754 if(content.find('[name="input_cco"]').length){ 1755 content.find('[name="input_cco"]').val(data.cco); 1756 content.find(".cco-tr").show(); 1757 content.find(".cco-button").toggleClass("expressomail-button-icon-ative"); 1758 content.find(".cco-button").find("span").html(get_lang('Remove CCo')); 1759 content.find('[name="input_cco"]').elastic().unbind('blur'); 1760 content.find('[name="input_cco"]').trigger("update"); 1761 } 1762 } 1763 content.find(".subject").val(data.subject); 1798 1764 1799 if( Element("disposition_notification_" + border_ID)){1800 $("#return_receipt_"+new_border_ID).attr("checked", true);1801 $("[name=return_receipt_"+new_border_ID+"]").toggleClass("expressomail-button-icon-ative");1765 if( $("#disposition_notification_" + border_ID).length ){ 1766 content.find('[name="input_return_receipt"]').attr("checked", true); 1767 content.find(".return-recept").toggleClass("expressomail-button-icon-ative"); 1802 1768 //Element("return_receipt_" + new_border_ID).checked = true; 1803 1769 } … … 1806 1772 if(element_important_message) { 1807 1773 1808 if(Element("disposition_important_" + border_ID)){ 1809 $("#important_message_"+new_border_ID).attr("checked", true); 1810 $("[name=important_message_"+new_border_ID+"]").toggleClass("expressomail-button-icon-ative"); 1811 //element_important_message.checked = true; 1774 if($("#disposition_important_" + border_ID).length){ 1775 content.find('[name="input_important_message"]').attr("checked", true); 1776 content.find(".important").toggleClass("expressomail-button-icon-ative"); 1812 1777 } 1813 1778 } 1814 1779 1815 1780 if (Element("attachments_" + border_ID)) 1816 1781 addOriginalAttachments(new_border_ID,border_ID); 1817 1782 1818 1783 RichTextEditor.setInitData(new_border_ID, data.body, 'edit'); … … 1822 1787 } 1823 1788 1824 $("#to_"+new_border_ID).trigger("update");1825 var txtarea = Element('body_'+new_border_ID);1789 content.find('[name="input_to"]').trigger("update"); 1790 var txtarea = $('#body_'+new_border_ID); 1826 1791 var height = document.body.scrollHeight - 330; 1827 txtarea. style.overflowY = "auto";1828 txtarea. style.height = height;1792 txtarea.css("overflowY","auto"); 1793 txtarea.css("height",height); 1829 1794 //Insere o conteúdo da mensagem e a assinatura no editor de texto simples 1830 1831 1832 1833 1834 txtarea.value = data.body.replace( new RegExp('<pre>((.\n*)*)</pre>'),'$1');1835 1836 txtarea.value += '\n' + signature;1837 1838 1795 if (preferences.plain_text_editor == 1){ 1796 Element('textplain_rt_checkbox_'+new_border_ID).checked = true; 1797 if (txtarea != null){ 1798 if (data.body != undefined) 1799 txtarea.val(data.body.replace( new RegExp('<pre>((.\n*)*)</pre>'),'$1')); 1800 if (preferences.use_signature == "1") 1801 txtarea.val(txtarea.val + '\n' + signature); 1802 } 1803 } 1839 1804 Element("border_id_" + new_border_ID).title = title; 1840 1805 set_border_caption("border_id_" + new_border_ID, title); … … 1843 1808 return new_border_ID; //Preciso retornar o ID da nova mensagem. 1844 1809 } 1845 1846 1810 1847 1811 //Remove o email do usuario ao responder a todos … … 2204 2168 function send_valided_message(ID, folder, folder_name) 2205 2169 { 2206 2207 if (preferences.auto_save_draft == 1) 2208 autoSaveControl.status[ID] = true; 2209 2210 var save_link = Element("save_message_options_"+ID); 2211 var onClick = save_link.onclick; 2170 if (preferences.auto_save_draft == 1) 2171 autoSaveControl.status[ID] = true; 2172 var content = $("#content_id_"+ID); 2173 var save_link = $("#content_id_"+ID).find(".save"); 2174 var onClick = save_link.onclick; 2212 2175 save_link.onclick = ''; 2213 $("#save_message_options_"+ID).button({disabled: true});2176 save_link.button({disabled: true}); 2214 2177 2215 2178 ID_tmp = ID; … … 2294 2257 form.parentNode.appendChild(mail_type); 2295 2258 2296 var _subject = trim( Element("subject_"+ID).value);2259 var _subject = trim(content.find(".subject").val()); 2297 2260 if((_subject.length == 0) && !confirm(get_lang("Send this message without a subject?"))) { 2298 save_link.onclick = onClick;2299 Element("subject_"+ID).focus();2261 save_link.click(onClick); 2262 content.find(".subject").focus(); 2300 2263 return; 2301 2264 } 2302 stringEmail = Element("to_"+ID).value;2265 stringEmail = content.find('[name="input_to"]').val(); 2303 2266 2304 if ( Element("cco_"+ID) != null)2305 if( Element("tr_cco_"+ID).style.display!= "none")2306 stringEmail += Element("cco_"+ID).value =='' ? "":", "+Element("cco_"+ID).value;2267 if ( content.find('[name="input_cco"]').length) 2268 if(content.find(".cco-tr").css("display") != "none") 2269 stringEmail += content.find('[name="input_cco"]').val() =='' ? "":", "+content.find('[name="input_cco"]').val(); 2307 2270 2308 if( Element("tr_cc_"+ID).style.display!= "none")2309 stringEmail += Element("cc_"+ID).value =='' ? "":", "+Element("cc_"+ID).value;2271 if(content.find(".cc-tr").css("display") != "none") 2272 stringEmail += content.find('[name="input_cc"]').val() =='' ? "":", "+content.find('[name="input_cc"]').val(); 2310 2273 2311 2274 if (expresso_offline) { 2312 2275 2313 2276 var invalidEmail = searchEmail(stringEmail); 2314 if( Element("to_"+ID).value=="" && Element("cco_"+ID).value=="" && Element("cc_"+ID).value=="") {2277 if(content.find('[name="input_to"]').val()=="" && content.find('[name="input_cco"]').val()=="" && content.find('[name="input_cc"]').val()=="") { 2315 2278 write_msg(get_lang("message without receiver")); 2316 2279 return;
Note: See TracChangeset
for help on using the changeset viewer.