Skip to content

Instantly share code, notes, and snippets.

@hostilefork
Created August 24, 2013 00:08
Show Gist options
  • Save hostilefork/6325151 to your computer and use it in GitHub Desktop.
Save hostilefork/6325151 to your computer and use it in GitHub Desktop.
Explicit license of a StackOverflow answer to make FontBakery happy. :-)
/*
Copyright 2012 Brian Dickens <hostilefork@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
$(document).ready(function(){
var heightUpdateFunction = function() {
// http://stackoverflow.com/questions/11584061/
var newHeight =
editor.getSession().
getScreenLength()
* editor.renderer.lineHeight
+ editor.renderer.scrollBar.getWidth();
$('#editor').height(newHeight.toString() + "px");
$('#editor-section').height(newHeight.toString() + "px");
// This call is required for the editor to fix all of
// its inner structure for adapting to a change in size
editor.resize();
};
// Set initial size to match initial content
heightUpdateFunction();
// Whenever a change happens inside the ACE editor, update
// the size again
editor.getSession().on('change', heightUpdateFunction);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment