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