Change Bespin to Ace and reformat some comments.

This commit is contained in:
Gastón Kleiman 2011-02-19 05:53:25 +08:00 • committed by Fabian Jakobs
commit eb35995ea4

View file

@ -130,19 +130,18 @@ function setupContainer(element, getValue) {
var parentNode = element.parentNode; var parentNode = element.parentNode;
// This will hold the Bespin editor. // This will hold the editor.
var container = document.createElement('div'); var container = document.createElement('div');
// To put Bespin in the place of the textarea, we have to copy a // To put Ace in the place of the textarea, we have to copy a few of the
// few of the textarea's style attributes to the div container. // textarea's style attributes to the div container.
// //
// The problem is, that the properties have to get computed (they // The problem is that the properties have to get computed (they might be
// might be defined by a CSS file on the page - you can't access // defined by a CSS file on the page - you can't access such rules that
// such rules that apply to an element via elm.style). Computed // apply to an element via elm.style). Computed properties are converted to
// properties are converted to pixels although the dimension might // pixels although the dimension might be given as percentage. When the
// be given as percentage. When the window resizes, the dimensions // window resizes, the dimensions defined by percentages changes, so the
// defined by percentages changes, so the properties have to get // properties have to get recomputed to get the new/true pixels.
// recomputed to get the new/true pixels.
var resizeEvent = function() { var resizeEvent = function() {
var style = 'position:relative;'; var style = 'position:relative;';
[ [
@ -152,20 +151,20 @@ function setupContainer(element, getValue) {
getCSSProperty(element, container, item) + ';'; getCSSProperty(element, container, item) + ';';
}); });
// Calculating the width/height of the textarea is somewhat // Calculating the width/height of the textarea is somewhat tricky. To
// tricky. To do it right, you have to include the paddings // do it right, you have to include the paddings to the sides as well
// to the sides as well (eg. width = width + padding-left, -right). // (eg. width = width + padding-left, -right). This works well, as
// This works well, as long as the width of the element is not // long as the width of the element is not set or given in pixels. In
// set or given in pixels. In this case and after the textarea // this case and after the textarea is hidden, getCSSProperty(element,
// is hidden, getCSSProperty(element, container, 'width') will // container, 'width') will still return pixel value. If the element
// still return pixel value. If the element has realtiv dimensions // has realtiv dimensions (e.g. width='95<percent>')
// (e.g. width='95<percent>') getCSSProperty(...) will return pixel values // getCSSProperty(...) will return pixel values only as long as the
// only as long as the textarea is visible. After it is hidden // textarea is visible. After it is hidden getCSSProperty will return
// getCSSProperty will return the relativ dimensions as they // the relative dimensions as they are set on the element (in the case
// are set on the element (in the case of width, 95<percent>). // of width, 95<percent>).
// Making the sum of pixel vaules (e.g. padding) and realtive // Making the sum of pixel vaules (e.g. padding) and realtive values
// values (e.g. <percent>) is not possible. As such the padding styles // (e.g. <percent>) is not possible. As such the padding styles are
// are ignored. // ignored.
// The complete width is the width of the textarea + the padding // The complete width is the width of the textarea + the padding
// to the left and right. // to the left and right.