Make WordPress Core

Ticket #6811: edit-image-popup4.patch

File edit-image-popup4.patch, 9.2 KB (added by azaozz, 15 years ago)
  • wp-admin/gears-manifest.php

     
    6464?>
    6565{
    6666"betaManifestVersion" : 1,
    67 "version" : "<?php echo $man_version; ?>_20080622",
     67"version" : "<?php echo $man_version; ?>_20080625",
    6868"entries" : [
    6969<?php echo $defaults; ?>
    7070
     
    126126{ "url" : "../wp-includes/js/tinymce/themes/advanced/js/link.js?ver=3101" },
    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" },
    132132{ "url" : "../wp-includes/js/tinymce/themes/advanced/anchor.htm?ver=3101" },
  • wp-includes/js/tinymce/plugins/wpeditimage/editimage.html

     
    44<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    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
    1010<link rel="stylesheet" href="css/editimage.css?ver=3101" type="text/css" media="all" />
  • wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js

     
    3838        close : function() {
    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
    4947                if (tinymce.isOpera)
     
    153151                el.style.backgroundColor = '#E5E5E5';
    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];
    158168
     
    175185        },
    176186
    177187        imgEditSize : function(el) {
    178                 var t = this, f = document.forms[0], sz, m = null;
     188                var t = this, f = document.forms[0];
    179189
     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';
    181192
    182                 if ( ! t.preloadImg || W == "" || H == "" )
    183                         return;
    184 
    185193                size = parseInt(id.substring(1)) / 100;
    186194
    187195                w = Math.round(w * size);
     
    197205        demoSetSize : function(img) {
    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
    204212        demoSetStyle : function() {
     
    216224
    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);
    221230        },
     
    242251
    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');
    247257                f.img_alt.value = ed.dom.getAttrib(el, 'alt');
     
    293303                        d.className = "alignnone";
    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/*
    308309                // Test if is attachment
     
    331332        },
    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();
    337338                el = ed.selection.getNode();
    338339
    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');
    348349                        else ed.dom.removeClass(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, {
    359354                        src : f.img_src.value,
     
    362357                        width : f.width.value,
    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();
    374367                                ed.dom.remove(pa, 1);
    375368                                ed.selection.moveToBookmark(b);
    376369                                tinyMCEPopup.execCommand("mceEndUndoLevel");
    377                                 tinyMCEPopup.close();
    378                                 return;
    379370                        }
     371                } else {
     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");
    380406                }
    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                         });
     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');
    401413                } 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                         });
     414                        if ( P && P.style && P.style.textAlign == 'center' )
     415                                ed.dom.setStyle(P, 'textAlign', '');
    410416                }
    411417
    412                 tinyMCEPopup.execCommand("mceEndUndoLevel");
     418                ed.execCommand('mceRepaint');
    413419                tinyMCEPopup.close();
    414420        },
    415421
     
    493499                var f = document.forms[0], t = wpImage;
    494500
    495501                if ( f.width.value == '' || f.height.value == '' ) {
    496                         f.width.value = t.preloadImg.width;
    497                         f.height.value = t.preloadImg.height;
     502                        f.width.value = t.width = t.preloadImg.width;
     503                        f.height.value = t.height = t.preloadImg.height;
    498504                }
     505               
     506                t.showSizeSet();
    499507                t.demoSetSize();
     508                if ( f.img_style.value )
     509                        t.demoSetStyle();
    500510        },
    501511
    502512        getImageData : function() {