diff --git a/javascript/tiny_mce_improvements.js b/javascript/tiny_mce_improvements.js index 6111cbcc8..ef419c1ef 100644 --- a/javascript/tiny_mce_improvements.js +++ b/javascript/tiny_mce_improvements.js @@ -336,99 +336,6 @@ FlashForm.applyTo('#Form_EditorToolbarFlashForm'); FlashThumbnail.applyTo('#Form_EditorToolbarFlashForm div.thumbnailstrip a'); SideFormAction.applyTo('#Form_EditorToolbarFlashForm .Actions input'); -/** - * Image resizing - */ -MCEImageResizer = Class.create(); -MCEImageResizer.prototype = { - initialize: function() { - //TinyMCE.prototype.addEvent(this, 'click', this._onclick); - }, - _onclick: function() { - var form = $('Form_EditorToolbarMediaForm'); - if(form) { - form.elements.AltText.value = this.alt; - form.elements.ImageTitle.value = this.title; - form.elements.CSSClass.value = this.className; - } - }, - onresizestart: function() { - this.prepareForResize(); - this.heightDiff = 0; - }, - onresizeend: function() { - this.resizeTo(this.style.width, this.style.height); - }, - onmouseup: function() { - if(this.parentNode.parentNode.className.match(/(^|\b)specialImage($|\b)/)) { - this.ownerDoc().setActive(); - this.parentNode.parentNode.setActive(); - } - }, - prepareForResize: function() { - if(this.aspectRatio == null) { - this.aspectRatio = this.height / this.width; - } - - this.originalWidth = this.width; - this.originalHeight = this.height; - }, - - ownerDoc: function() { - var f =this.parentNode; - while(f && f.tagName.toLowerCase() != 'body') f = f.parentNode; - return f; - }, - - resizeTo: function(width, height) { - var newWidth = parseInt(height); - var newHeight = parseInt(height) - this.heightDiff; - if(isNaN(newWidth)) newWidth = this.width; - if(isNaN(newHeight)) newHeight = this.height; - - // Constrain to width of the window - if((this.offsetLeft + this.offsetWidth + 20) > this.ownerDoc().offsetWidth) - newWidth += (this.ownerDoc().offsetWidth - this.offsetLeft - this.offsetWidth - 20); - - if(this.aspectRatio) { - // Figure out which dimension we have altered more - var heightChange = this.originalHeight / this.height; - if(heightChange < 1) heightChange = 1/heightChange; - - var widthChange = this.originalWidth / this.width; - if(widthChange < 1) widthChange = 1/widthChange; - - // Scale by the more constant dimension (so if you edit the height, change width to suit) - if(widthChange > heightChange) - newHeight = newWidth * this.aspectRatio; - else - newWidth = newHeight / this.aspectRatio; - } - - this.style.width = newWidth + 'px'; - this.style.height = newHeight + 'px'; - this.width = newWidth; - this.height = newHeight; - - // Auto-size special image holders - if(this.parentNode.parentNode.className.match(/(^|\b)specialImage($|\b)/)) { - this.parentNode.parentNode.style.width = newWidth + 'px'; - } - } -} - -MCEDLResizer = Class.extend('MCEImageResize'); -MCEDLResizer.prototype = { - onresizestart: function() { - var img = this.getElementsByTagName('img')[0]; - img.prepareForResize(); - img.heightDiff = this.offsetHeight - img.height; - }, - onresizeend: function() { - this.getElementsByTagName('img')[0].resizeTo(this.style.width, this.style.height); - } -} - /** * These callback hook it into tinymce. They need to be referenced in the TinyMCE config. */