Make WordPress Core

Changeset 8191


Ignore:
Timestamp:
06/25/2008 04:30:28 PM (17 years ago)
Author:
ryan
Message:

Edit image fixes from azaozz: : new link not created if the image has class "aligncenter" in Safari; recalculates the demo image size properly and applies any inline styles to it; if relative link is added, it's converted to absolute; "Unknown error" in IE6. see #6811

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/gears-manifest.php

    r8186 r8191  
    6565{
    6666"betaManifestVersion" : 1,
    67 "version" : "<?php echo $man_version; ?>_20080622",
     67"version" : "<?php echo $man_version; ?>_20080625",
    6868"entries" : [
    6969<?php echo $defaults; ?>
     
    127127{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/source_editor.js?ver=3101" },
    128128{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/anchor.js?ver=3101" },
    129 { "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=3101" },
     129{ "url" : "../wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js?ver=3102" },
    130130
    131131{ "url" : "../wp-includes/js/tinymce/themes/advanced/source_editor.htm?ver=3101" },
  • trunk/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html

    r8167 r8191  
    55<title></title>
    66
    7 <script type="text/javascript" src="js/editimage.js?ver=3101"></script>
     7<script type="text/javascript" src="js/editimage.js?ver=3102"></script>
    88<script type="text/javascript" src="../../utils/form_utils.js?ver=3101"></script>
    99
  • trunk/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js

    r8167 r8191  
    3939        var t = this, win = t.getWin();
    4040
    41        
    4241        // To avoid domain relaxing issue in Opera
    4342        function close() {
    4443            win.tb_remove();
    45             t.editor.execCommand('mceRepaint');
    46             tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup
     44            tinymce = tinyMCE = t.editor = t.dom = t.dom.doc = null; // Cleanup
    4745        };
    4846
     
    154152    },
    155153
     154    showSizeSet : function() {
     155        var t = this;
     156       
     157        if ( (t.width * 1.3) > parseInt(t.preloadImg.width) ) {
     158            var s130 = t.I('s130'), s120 = t.I('s120'), s110 = t.I('s110');
     159
     160            s130.onclick = s120.onclick = s110.onclick = null;
     161            s130.onmouseover = s120.onmouseover = s110.onmouseover = null;
     162            s130.style.color = s120.style.color = s110.style.color = '#aaa';
     163        }
     164    },
     165
    156166    showSizeRem : function() {
    157167        var t = this, demo = t.I('img_demo'), f = document.forms[0];
     
    176186
    177187    imgEditSize : function(el) {
    178         var t = this, f = document.forms[0], sz, m = null;
    179 
     188        var t = this, f = document.forms[0];
     189
     190        if ( ! t.preloadImg || ! t.preloadImg.width || ! t.preloadImg.height )  return;
    180191        var W = parseInt(t.preloadImg.width), H = parseInt(t.preloadImg.height), w = t.width || W, h = t.height || H, id = el.id || 's100';
    181 
    182         if ( ! t.preloadImg || W == "" || H == "" )
    183             return;
    184192
    185193        size = parseInt(id.substring(1)) / 100;
     
    198206        var demo = this.I('img_demo'), f = document.forms[0];
    199207
    200         demo.width = f.width.value ? Math.floor(f.width.value * 0.5) : '';
    201         demo.height = f.height.value ? Math.floor(f.height.value * 0.5) : '';
     208        demo.width = f.width.value ? Math.round(f.width.value * 0.5) : '';
     209        demo.height = f.height.value ? Math.round(f.height.value * 0.5) : '';
    202210    },
    203211
     
    217225        f.width.value = t.width = t.preloadImg.width;
    218226        f.height.value = t.height = t.preloadImg.height;
     227        t.showSizeSet();
    219228        t.demoSetSize();
    220229        t.showSize(el);
     
    243252        f.img_src.value = d.src = link = ed.dom.getAttrib(el, 'src');
    244253        ed.dom.setStyle(el, 'float', '');
     254        t.getImageData();
    245255
    246256        f.img_title.value = ed.dom.getAttrib(el, 'title');
     
    294304        }
    295305
    296         t.getImageData();
    297 
    298         if ( (t.width * 1.3) > parseInt(t.preloadImg.width) ) {
    299             var s130 = t.I('s130'), s120 = t.I('s120'), s110 = t.I('s110');
    300 
    301             s130.onclick = s120.onclick = s110.onclick = null;
    302             s130.onmouseover = s120.onmouseover = s110.onmouseover = null;
    303             s130.style.color = s120.style.color = s110.style.color = '#aaa';
    304         }
    305 
     306        if ( t.width && t.preloadImg.width ) t.showSizeSet();
    306307        document.body.style.display = '';
    307308/*
     
    332333
    333334    update : function() {
    334         var t = this, f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, el, P, v = f.img_classes.value;
     335        var t = this, f = document.forms[0], nl = f.elements, ed = tinyMCEPopup.editor, el, P, A, v = f.img_classes.value;
    335336
    336337        tinyMCEPopup.restoreSelection();
     
    339340        if (el.nodeName != 'IMG') return;
    340341        if (f.img_src.value === '') t.remove();
     342
     343        A = ed.dom.getParent(el, 'A');
    341344        P = ed.dom.getParent(el, 'p');
    342         if ( P && P.style && P.style.textAlign == 'center' )
    343             ed.dom.setStyle(P, 'textAlign', '');
    344 /*
    345         if ( tinymce.isIE ) {
     345
     346/*      if ( tinymce.isIE ) {
    346347            if ( f.img_classes.value.indexOf('aligncenter') != -1 )
    347348                ed.dom.addClass(P, 'mce_iecenter');
     
    349350        }
    350351*/
    351         if ( v.indexOf('alignleft') != -1 )
    352             tinyMCEPopup.execCommand('JustifyLeft');
    353         else if ( v.indexOf('alignright') != -1 )
    354             tinyMCEPopup.execCommand('JustifyRight');
    355         else if ( v.indexOf('aligncenter') != -1 )
    356             tinyMCEPopup.execCommand('JustifyCenter');
    357352
    358353        ed.dom.setAttribs(el, {
     
    363358            height : f.height.value,
    364359            style : f.img_style.value,
    365             'class' : f.img_classes.value
     360            'class' : '' //f.img_classes.value
    366361        });
    367362
    368         pa = ed.dom.getParent(el, 'A');
    369 
    370363        if ( ! f.link_href.value ) {
    371             if ( pa ) {
     364            if ( A ) {
    372365                tinyMCEPopup.execCommand("mceBeginUndoLevel");
    373366                b = ed.selection.getBookmark();
     
    375368                ed.selection.moveToBookmark(b);
    376369                tinyMCEPopup.execCommand("mceEndUndoLevel");
    377                 tinyMCEPopup.close();
    378                 return;
    379             }
    380         }
    381 
    382         tinyMCEPopup.execCommand("mceBeginUndoLevel");
    383 
    384         // Create new anchor elements
    385         if (pa == null) {
    386             tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
    387 
    388             tinymce.each(ed.dom.select("a"), function(n) {
    389                 if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
    390 
    391                     ed.dom.setAttribs(n, {
    392                         href : f.link_href.value,
    393                         title : f.link_title.value,
    394                         rel : f.link_rel.value,
    395                         target : (f.link_target.checked == true) ? '_blank' : '',
    396                         'class' : f.link_classes.value,
    397                         style : f.link_style.value
    398                     });
    399                 }
    400             });
     370            }
    401371        } else {
    402             ed.dom.setAttribs(pa, {
    403                 href : f.link_href.value,
    404                 title : f.link_title.value,
    405                 rel : f.link_rel.value,
    406                 target : (f.link_target.checked == true) ? '_blank' : '',
    407                 'class' : f.link_classes.value,
    408                 style : f.link_style.value
    409             });
    410         }
    411 
    412         tinyMCEPopup.execCommand("mceEndUndoLevel");
     372            tinyMCEPopup.execCommand("mceBeginUndoLevel");
     373   
     374            // Create new anchor elements
     375            if ( A == null ) {
     376               
     377                if ( ! f.link_href.value.match(/https?:\/\//) )
     378                    f.link_href.value = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.link_href.value);
     379               
     380                tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
     381   
     382                tinymce.each(ed.dom.select("a"), function(n) {
     383                    if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
     384   
     385                        ed.dom.setAttribs(n, {
     386                            href : f.link_href.value,
     387                            title : f.link_title.value,
     388                            rel : f.link_rel.value,
     389                            target : (f.link_target.checked == true) ? '_blank' : '',
     390                            'class' : f.link_classes.value,
     391                            style : f.link_style.value
     392                        });
     393                    }
     394                });
     395            } else {
     396                ed.dom.setAttribs(A, {
     397                    href : f.link_href.value,
     398                    title : f.link_title.value,
     399                    rel : f.link_rel.value,
     400                    target : (f.link_target.checked == true) ? '_blank' : '',
     401                    'class' : f.link_classes.value,
     402                    style : f.link_style.value
     403                });
     404            }
     405            tinyMCEPopup.execCommand("mceEndUndoLevel");
     406        }
     407       
     408        ed.dom.setAttrib(el, 'class', f.img_classes.value);
     409       
     410        if ( v.indexOf('aligncenter') != -1 ) {
     411            if ( P && ( ! P.style || P.style.textAlign != 'center' ) )
     412                ed.dom.setStyle(P, 'textAlign', 'center');
     413        } else {
     414            if ( P && P.style && P.style.textAlign == 'center' )
     415                ed.dom.setStyle(P, 'textAlign', '');
     416        }
     417
     418        ed.execCommand('mceRepaint');
    413419        tinyMCEPopup.close();
    414420    },
     
    494500
    495501        if ( f.width.value == '' || f.height.value == '' ) {
    496             f.width.value = t.preloadImg.width;
    497             f.height.value = t.preloadImg.height;
    498         }
     502            f.width.value = t.width = t.preloadImg.width;
     503            f.height.value = t.height = t.preloadImg.height;
     504        }
     505       
     506        t.showSizeSet();
    499507        t.demoSetSize();
     508        if ( f.img_style.value )
     509            t.demoSetStyle();
    500510    },
    501511
Note: See TracChangeset for help on using the changeset viewer.