Skip to content

Commit

Permalink
Fix incorrect initial size, for #507
Browse files Browse the repository at this point in the history
  • Loading branch information
avernet committed Mar 25, 2015
1 parent d92b679 commit a5f4e5f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
var deltaSize, d = ed.getDoc(), body = d.body, de = d.documentElement, DOM = tinymce.DOM, resizeHeight = t.autoresize_min_height, myHeight;

// Get height differently depending on the browser used
myHeight = tinymce.isIE ? body.scrollHeight : (tinymce.isWebKit && body.clientHeight == 0 ? 0 : body.offsetHeight);
// 2015-03-25 avernet Original code doesn't take the margins around the body into account
//myHeight = tinymce.isIE ? body.scrollHeight : (tinymce.isWebKit && body.clientHeight == 0 ? 0 : body.offsetHeight);
myHeight = ORBEON.jQuery(body).outerHeight(true);

// Don't make it smaller than the minimum height
if (myHeight > t.autoresize_min_height)
Expand Down Expand Up @@ -77,9 +79,10 @@
t.autoresize_max_height = parseInt(ed.getParam('autoresize_max_height', 0));

// Add padding at the bottom for better UX
ed.onInit.add(function(ed){
ed.dom.setStyle(ed.getBody(), 'paddingBottom', ed.getParam('autoresize_bottom_margin', 50) + 'px');
});
// 2015-03-25 avernet Don't add padding, which looked like a hack for incorrect code to compute height
//ed.onInit.add(function(ed){
// ed.dom.setStyle(ed.getBody(), 'paddingBottom', ed.getParam('autoresize_bottom_margin', 50) + 'px');
//});

// Add appropriate listeners for resizing content area
ed.onChange.add(resize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ resourceEditor = _.memoize ->

afterTinyMCEInitialized = (f) ->
if tinymceObject.initialized then f()
else tinymceObject.onPostRender.add(f)
else tinymceObject.onInit.add(f)

makeSpaceForMCE = ->
mceHeight = $(tinymceObject.container).height()
Expand All @@ -79,7 +79,6 @@ resourceEditor = _.memoize ->
mceConfig = _.clone(YAHOO.xbl.fr.Tinymce.DefaultConfig)
mceConfig.plugins += ',autoresize'
mceConfig.autoresize_min_height = 100
mceConfig.autoresize_bottom_margin = 16 # Default padding for autoresize adds too much empty space at the bottom

tinymceObject = new window.tinymce.Editor(tinymceAnchor.attr('id'), mceConfig)
tinymceObject.render()
Expand All @@ -105,14 +104,19 @@ resourceEditor = _.memoize ->
getValue : ->
if lhha() == 'text'
content = tinymceObject.getContent()
# Workaround to TinyMCE issue, see https://twitter.com/avernet/status/579031182605750272
# Workaround to TinyMCE issue, see
# https://twitter.com/avernet/status/579031182605750272
if content == '<div>\xa0</div>' then '' else content
else
textfield.val()
setValue : (newValue) ->
if lhha() == 'text'
afterTinyMCEInitialized ->
tinymceObject.setContent(newValue)
# Workaround for resize not happening with empty values, see
# https://twitter.com/avernet/status/580798585291177984
tinymceObject.execCommand('mceAutoResize')

else
textfield.val(newValue)
textfield.focus()
Expand Down

0 comments on commit a5f4e5f

Please sign in to comment.