Changeset 4252 for branches/2.2.0.1


Ignore:
Timestamp:
05/06/11 16:17:48 (13 years ago)
Author:
rafaelraymundo
Message:

Ticket #1726 - Permitindo o envio de mail em texto puro. r4202

Location:
branches/2.2.0.1
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.0.1/expressoMail1_2/inc/class.imap_functions.inc.php

    r4243 r4252  
    21402140                $mail->AddReplyTo($replytoaddress); 
    21412141                $mail->Subject = $subject; 
    2142                 $mail->IsHTML($params['type'] != 'textplain'); 
     2142                $mail->IsHTML( ( array_key_exists( 'type', $params ) && in_array( strtolower( $params[ 'type' ] ), array( 'html', 'plain' ) ) ) ? strtolower( $params[ 'type' ] ) != 'plain' : true ); 
    21432143                $mail->Body = $body; 
    21442144 
  • branches/2.2.0.1/expressoMail1_2/js/abas.js

    r4139 r4252  
    5656                                try 
    5757                                { 
    58                                         if (Element('viewsource_rt_checkbox').checked) 
     58                                        if (Element('viewsource_rt_checkbox_' + ID).checked) 
    5959                                        {   
    6060                                                connector.loadScript("rich_text_editor"); 
  • branches/2.2.0.1/expressoMail1_2/js/color_palette.js

    r320 r4252  
    2424cColorPalette.prototype.repos = function (intElemScrollTop) 
    2525{ 
    26         var new_pos = findPosY(Element("forecolor")) - intElemScrollTop + 20; 
    27         this.div.style.top = new_pos; 
     26    if ( Element("forecolor") ) 
     27    { 
     28        var new_pos = findPosY(Element("forecolor")) - intElemScrollTop + 20; 
     29        this.div.style.top = new_pos; 
     30    } 
    2831} 
    2932 
  • branches/2.2.0.1/expressoMail1_2/js/draw_api.js

    r4197 r4252  
    26192619 
    26202620        tr_menu_new_message.appendChild(td_menu_new_message); 
     2621 
     2622        if ( ! expresso_offline ) 
     2623        { 
     2624                var text_plain = td_menu_new_message.appendChild( 
     2625                        document.createElement( 'span' ) 
     2626                ).appendChild( 
     2627                        document.createTextNode( ' | ' ) 
     2628                ).parentNode.appendChild( 
     2629                        document.createElement( 'input' ) 
     2630                ).parentNode.appendChild( 
     2631                        document.createTextNode( get_lang('Send this mail as text plain') + '.') 
     2632                ).previousSibling; 
     2633                text_plain.setAttribute( 'tabIndex', '-1' ); 
     2634                text_plain.id = 'textplain_rt_checkbox_' + ID ; 
     2635                text_plain.type = "checkbox"; 
     2636                text_plain.onclick = function () 
     2637                { 
     2638                        RichTextEditor.plain( ( ! this.checked ) ? this.checked : mobile_device || ( this.checked = confirm( 'The text format will be lost.' ) ) ); 
     2639                        document.getElementById( 'viewsource_rt_checkbox_' + ID ).parentNode.style.display = ( this.checked ) ? 'none' : ''; 
     2640                }; 
     2641        } 
     2642 
    26212643        tbody_menu_new_message.appendChild(tr_menu_new_message); 
    26222644        table_menu_new_message.appendChild(tbody_menu_new_message); 
     
    32253247                draw_from_field(sel_from,tr1_1); 
    32263248        resizeWindow(); 
     3249 
     3250        if ( ! expresso_offline ) 
     3251        { 
     3252                if ( mobile_device ) 
     3253                { 
     3254                        text_plain.click( ); 
     3255                        text_plain.parentNode.style.display = 'none'; 
     3256                } 
     3257        } 
     3258         
    32273259        return ID; 
    32283260} 
  • branches/2.2.0.1/expressoMail1_2/js/globals.js

    r3384 r4252  
    4545var divStatusBar = document.getElementById("divStatusBar"); 
    4646var denyFileExtensions = new Array('exe','com','reg','chm','cnf','hta','ins','jse','job','lnk','pif','src','scf','sct','shb','vbe','vbs','wsc','wsf','wsh','cer','its','mau','','mda','mar','mdz','prf','pst'); 
     47var mobile_device = false; 
    4748 
  • branches/2.2.0.1/expressoMail1_2/js/main.js

    r4197 r4252  
    7979 
    8080        cExecute ("$this.functions.get_preferences", save_preferences); 
     81        cExecute ("phpgwapi.browser.isMobile", function( data ) 
     82        { 
     83                mobile_device = ( ( data.constructor == Boolean ) ? data : ( data === 'true' ) ); 
     84        } ); 
    8185        setTimeout('auto_refresh()', time_refresh); 
    8286 
     
    886890                } 
    887891        var new_border_ID = draw_new_message(parseInt(border_ID)); 
    888  
    889892        if(typeof(openTab.type[new_border_ID]) != "undefined") { 
    890893                if(tabTypes[type] == openTab.type[new_border_ID]) { 
     
    907910                } 
    908911        } 
    909  
    910912        if (new_border_ID == false) 
    911913        { 
     
    16371639        } 
    16381640 
    1639         if ( document.getElementById('viewsource_rt_checkbox').checked == true ) 
    1640                 document.getElementById('viewsource_rt_checkbox').click(); 
     1641        if ( document.getElementById('viewsource_rt_checkbox_' + ID).checked == true ) 
     1642                document.getElementById('viewsource_rt_checkbox_' + ID).click(); 
    16411643 
    16421644        var save_link = Element("save_message_options_"+ID); 
     
    16491651                send_message_return(data, this.ID_tmp); // this is a hack to escape quotation form connector bug 
    16501652        }; 
     1653 
     1654        var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + ID ); 
     1655        mail_as_plain = ( mail_as_plain ) ? mail_as_plain.checked : false; 
    16511656 
    16521657        var textArea = document.createElement("TEXTAREA"); 
     
    16541659        textArea.name = "body"; 
    16551660        body = document.getElementById("body_"+ID); 
    1656         textArea.value += '<body>\r\n'; 
    1657         textArea.value += body.contentWindow.document.body.innerHTML; 
    1658         textArea.value += '\r\n</body>'; 
     1661        textArea.value += ( ( mail_as_plain ) ? body.previousSibling.value : ( '<body>\r\n' + body.contentWindow.document.body.innerHTML + '\r\n</body>' ) ); 
    16591662        var input_folder = document.createElement("INPUT"); 
    16601663        input_folder.style.display='none'; 
     
    16901693        form.appendChild(input_folder); 
    16911694        form.appendChild(msg_id); 
     1695 
     1696        var mail_type = form.appendChild( document.createElement( 'input' ) ); 
     1697        mail_type.name = 'type'; 
     1698        mail_type.type = 'hidden'; 
     1699        mail_type.value = ( mail_as_plain ) ? 'plain' : 'html'; 
    16921700 
    16931701        var _subject = trim(Element("subject_"+ID).value); 
     
    18951903                withImage = false; 
    18961904 
    1897         var rt_checkbox = Element('viewsource_rt_checkbox'); 
     1905        var rt_checkbox = Element('viewsource_rt_checkbox_' + ID); 
    18981906        if (rt_checkbox == null) 
    18991907                return false; 
     
    22282236        } else{ 
    22292237                show_attachs = ""; 
    2230         } 
    2231          
     2238        }        
    22322239        var current_path = window.location.href.substr(0,window.location.href.lastIndexOf("/")); 
    22332240        var window_print_head  = window_print.document.getElementsByTagName("head")[0]; 
  • branches/2.2.0.1/expressoMail1_2/js/rich_text_editor.js

    r3865 r4252  
    2525                parentDiv.appendChild(this.table); 
    2626 
     27        var mail_as_plain = document.getElementById( 'textplain_rt_checkbox_' + this.id ); 
     28        this.table.style.visibility = ( mail_as_plain && mail_as_plain.checked ) ? 'hidden' : 'visible'; 
     29 
    2730        if(!Element(this.editor)) 
    2831        { 
     
    3134        else 
    3235        { 
    33                 Element("viewsource_rt_checkbox").checked=false; 
     36                Element( 'viewsource_rt_checkbox_' + this.id ).checked=false; 
    3437        } 
    3538 
     
    5053                config_events( iframe, 'onload', function( ) 
    5154                { 
    52                         iframe.contentWindow.document.designMode = "on"; 
     55                        if ( iframe.contentWindow.document.body && iframe.contentWindow.document.body.contentEditable ) 
     56                                iframe.contentWindow.document.body.contentEditable = true; 
     57 
    5358                        if ( iframe.contentWindow.document.documentElement ){ 
    5459                                iframe.contentWindow.document.documentElement.style.background = '#fff'; 
     
    5762                }); 
    5863 
    59                 var checkbox = document.createElement("INPUT"); 
    60                 checkbox.id = 'viewsource_rt_checkbox'; 
    61                 checkbox.type = "checkbox"; 
    62                 checkbox.setAttribute("tabIndex","-1"); 
    63                 checkbox.onclick = function () {RichTextEditor.viewsource(this.checked)}; 
    64                 var text = document.createTextNode(get_lang('View HTML source') + '.'); 
    6564                parentDiv.appendChild(iframe); 
    66                 parentDiv.appendChild(checkbox); 
    67                 parentDiv.appendChild(text); 
     65 
     66                var source = document.createElement( 'input' ); 
     67                source.id = 'viewsource_rt_checkbox_' + this.id; 
     68                source.type = "checkbox"; 
     69                source.setAttribute("tabIndex","-1"); 
     70                source.onclick = function( ) 
     71                { 
     72                        RichTextEditor.viewsource(this.checked); 
     73                }; 
     74                source = parentDiv.appendChild( 
     75                        document.createElement( 'span' ).appendChild( source ).parentNode 
     76                ).appendChild( 
     77                        document.createTextNode( get_lang( 'View HTML source' ) + '.' ) 
     78                ).parentNode; 
    6879} 
    6980 
     
    138149                        document.getElementById(this.editor).contentWindow.document.body.innerHTML = html.toString(); 
    139150                        document.getElementById("table_richtext_toolbar").style.visibility="visible";   
     151                } 
     152        } 
     153} 
     154 
     155cRichTextEditor.prototype.plain = function(source) { 
     156        var html; 
     157        var editor = document.getElementById( this.editor ); 
     158 
     159        if (source) { 
     160                if (is_ie){ 
     161                        connector.loadScript('html2xhtml'); 
     162                        html = frames[this.editor].document.body; 
     163                        var xhtml = get_xhtml(html, 'en', 'iso-8859-1'); 
     164                        frames[this.editor].document.body.innerText = xhtml; 
     165                        document.getElementById("table_richtext_toolbar").style.visibility="hidden"; 
     166                } 
     167                else{ 
     168                        html = document.createTextNode( editor.contentWindow.document.body.innerHTML ); 
     169                        this.table.style.visibility="hidden"; 
     170                        editor.contentWindow.document.body.innerHTML = ''; 
     171 
     172                        var textarea = document.createElement( 'textarea' ); 
     173                        textarea.style.width = '99%'; 
     174                        textarea.style.height = '300px'; 
     175                        textarea.style.fontSize = '12pt'; 
     176                        textarea.innerHTML = html.nodeValue.replace( /<br\s*\/?>/mg, "\n" ).replace( /(<([^>]+)>)/ig, '' ); 
     177 
     178                        editor.style.width = '0px'; 
     179                        editor.style.height = '0px'; 
     180                        editor.style.visibility = 'hidden'; 
     181 
     182                        editor.parentNode.insertBefore( textarea, editor ); 
     183                        textarea.focus( ); 
     184                } 
     185        } else { 
     186                if (is_ie){ 
     187                        var output = escape(frames[this.editor].document.body.innerText); 
     188                        output = output.replace("%3CP%3E%0D%0A%3CHR%3E", "%3CHR%3E"); 
     189                        output = output.replace("%3CHR%3E%0D%0A%3C/P%3E", "%3CHR%3E"); 
     190                        frames[this.editor].document.body.innerHTML = unescape(output); 
     191                        document.getElementById("table_richtext_toolbar").style.visibility="visible"; 
     192                } 
     193                else{ 
     194                        editor.contentWindow.document.body.innerHTML = editor.previousSibling.value.replace( /\n/g, '<br/>' ); 
     195                        editor.parentNode.removeChild( editor.previousSibling ); 
     196 
     197                        editor.style.width = '99%'; 
     198                        editor.style.height = '300px'; 
     199                        editor.style.visibility = 'visible'; 
     200 
     201                        this.loadEditor( this.id ); 
    140202                } 
    141203        } 
  • branches/2.2.0.1/phpgwapi/inc/class.browser.inc.php

    r3621 r4252  
    199199                } 
    200200 
     201                function isMobile( ) 
     202                { 
     203                        return $this -> is_ipad( ) 
     204                                || $this -> is_iphone( ) 
     205                                || $this -> is_nokia( ) 
     206                                || $this -> is_ipod( ) 
     207                                || $this -> is_blackberry( ) 
     208                                || $this -> is_android( ); 
     209                } 
     210 
    201211                function is_beos() 
    202212                { 
Note: See TracChangeset for help on using the changeset viewer.