From 872d636ad4eda887af59e38cae5ca6825a28c0a2 Mon Sep 17 00:00:00 2001 From: Dan Helfman Date: Tue, 7 Oct 2008 16:39:49 -0700 Subject: [PATCH] Note resizing (growing and shrinking) now works as expected in Safari/Chrome. Shrinking didn't work before this fix. --- NEWS | 1 + static/js/Editor.js | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/NEWS b/NEWS index 324c6ff..422d903 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,7 @@ * You can now create and end links. * Underline and strikethrough now work. * Pulldowns for search suggestions, importing, and exporting show up. + * Note resizing (growing and shrinking) works as expected. * Improved page loading speed and fixed a rare session locking timeout bug by removing all implicit session locking. * Fixed a bug that broke that Luminotes Desktop product download page if diff --git a/static/js/Editor.js b/static/js/Editor.js index cb05a1f..a0768b3 100644 --- a/static/js/Editor.js +++ b/static/js/Editor.js @@ -284,15 +284,21 @@ Editor.prototype.insert_html = function ( html ) { Editor.prototype.resize = function () { if ( !this.document ) return; - var dimensions; - // TODO: find a better way to determine which dimensions to use than just checking for contentDocument - if ( this.iframe.contentDocument ) { // Firefox - dimensions = { "h": elementDimensions( this.document.documentElement ).h }; + var height; + + if ( WEBKIT ) { + var self = this; + withDocument( this.document, function () { + var body = getFirstElementByTagAndClassName( "body" ); + height = elementDimensions( body ).h; + } ); + } else if ( this.iframe.contentDocument ) { // Gecko and other sane browsers + height = elementDimensions( this.document.documentElement ).h; } else { // IE - dimensions = { "h": this.document.body.scrollHeight }; + height = this.document.body.scrollHeight; } - setElementDimensions( this.iframe, dimensions ); + setElementDimensions( this.iframe, { "h": height } ); } Editor.prototype.key_pressed = function ( event ) {