WordPress.org

Make WordPress Core

Ticket #18254: 18254.diff

File 18254.diff, 5.1 KB (added by asdasDan, 21 months ago)
  • wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css

     
    344344        font-weight: bold; 
    345345} 
    346346 
     347img.link-align { 
     348        height:22px; 
     349        vertical-align:middle; 
     350        margin-bottom:2px; 
     351        margin-left:-5px; 
     352        cursor:pointer; 
     353} 
     354 
    347355* html #sidemenu li { 
    348356        zoom: 100%; 
    349357} 
  • 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=327"></script> 
     7<script type="text/javascript" src="js/editimage.dev.js"></script> 
    88<script type="text/javascript" src="../../utils/form_utils.js?ver=3223"></script> 
    99 
    1010<link rel="stylesheet" href="css/editimage.css?ver=327" type="text/css" media="all" /> 
     
    148148                        </th> 
    149149                        <td class="field"> 
    150150                                <label for="width">{#wpeditimage.width}</label> 
    151                                 <input type="text" maxlength="5" id="width" name="width"  value="" /> 
     151                                <input type="text" maxlength="5" onkeyup="wpImage.possiblyConstrain(this);" id="width" name="width"  value="" /> 
    152152 
    153153                                <label for="height">{#wpeditimage.height}</label> 
    154                                 <input type="text" maxlength="5" id="height" name="height" value="" /> 
     154                                <input type="text" maxlength="5" onkeyup="wpImage.possiblyConstrain(this);" id="height" name="height" value="" /> 
     155                                <img id="constrain_proportions" class="link-align" title="Constraining Proportions" src="img/link.png" name="constrain_proportions" onclick="wpImage.toggleConstrain();" /> 
     156                                <input type="button" class="button" id="orig_size" name="orig_size" value="{#wpeditimage.orig_size}" onclick="wpImage.origSize();" /> 
    155157 
    156                                 <input type="button" class="button" id="orig_size" name="orig_size" value="{#wpeditimage.orig_size}" onclick="wpImage.origSize();" /> 
    157158                        </td> 
    158159                </tr> 
    159160 
  • wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js

     
    222222                } 
    223223        }, 
    224224 
     225    setConstrainedProportions: function() { 
     226        var f = document.forms[0], t = this; 
     227 
     228        if (t.I('img_classes').value.indexOf('constrained ') != -1 || t.I('img_classes').value.indexOf(' constrained') != -1) { 
     229            f.constrain_proportions.className += (f.constrain_proportions.className == '') ? 'constrained' : ' constrained'; 
     230            f.constrain_proportions.title = 'Constraining Proportions'; 
     231            f.constrain_proportions.src = 'img/link.png'; 
     232        } else { 
     233            f.constrain_proportions.className = f.constrain_proportions.className.replace(/(\sconstrained|constrained\s|constrained)/, ''); 
     234            f.constrain_proportions.src = 'img/broken_link.png'; 
     235            f.constrain_proportions.title = 'Not Constraining'; 
     236        } 
     237    }, 
     238 
     239    toggleConstrain: function() { 
     240        var f = document.forms[0], t = this; 
     241         
     242        if (f.constrain_proportions.className.indexOf('constrained') != -1) { 
     243            f.constrain_proportions.className = f.constrain_proportions.className.replace(/(\sconstrained|constrained\s|constrained)/, ''); 
     244            f.constrain_proportions.src = 'img/broken_link.png'; 
     245            f.constrain_proportions.title = 'Not Constraining'; 
     246            t.I('img_classes').value = t.I('img_classes').value.replace(/(\sconstrained|constrained\s)/, ''); 
     247        } else { 
     248            f.constrain_proportions.title = 'Constraining Proportions'; 
     249            f.constrain_proportions.src = 'img/link.png'; 
     250            f.constrain_proportions.className += (f.constrain_proportions.className == '') ? 'constrained' : ' constrained'; 
     251            t.I('img_classes').value += ' constrained'; 
     252        } 
     253    }, 
     254 
     255    possiblyConstrain : function(el) { 
     256        var f = document.forms[0], t = this; 
     257 
     258        if (f.constrain_proportions.className.indexOf('constrained') == -1) { 
     259            return; 
     260        } 
     261 
     262        var newOriginalImage = new Image(); 
     263        newOriginalImage.src = t.I('img_demo').src; 
     264 
     265        var widthToHeightRatio = (newOriginalImage.width  / newOriginalImage.height); 
     266        var heightToWidthRatio = (newOriginalImage.height / newOriginalImage.width); 
     267 
     268        if (el.id == 'width') { 
     269            f.height.value = (isNaN(el.value * heightToWidthRatio)) ? '' : Math.round(el.value * heightToWidthRatio); 
     270        } else if (el.id == 'height') { 
     271            f.width.value  = (isNaN(el.value * widthToHeightRatio)) ? '' : Math.round(el.value * widthToHeightRatio); 
     272        } 
     273    }, 
    225274        origSize : function() { 
    226275                var t = this, f = document.forms[0], el = t.I('s100'); 
    227276 
     
    287336                f.img_classes.value = c; 
    288337                f.img_style.value = ed.dom.getAttrib(el, 'style'); 
    289338 
     339                t.setConstrainedProportions(); 
     340 
    290341                // Move attribs to styles 
    291342                if ( dom.getAttrib(el, 'hspace') ) 
    292343                        t.updateStyle('hspace');