mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-09 16:35:01 -04:00
Move IE-style domline creation into the domline file.
This commit is contained in:
parent
b1063556a0
commit
b023eb1fe5
2 changed files with 65 additions and 65 deletions
|
@ -2800,69 +2800,7 @@ function Ace2Inner(){
|
|||
|
||||
function doCreateDomLine(nonEmpty)
|
||||
{
|
||||
if (browser.msie && (!nonEmpty))
|
||||
{
|
||||
var result = {
|
||||
node: null,
|
||||
appendSpan: noop,
|
||||
prepareForAdd: noop,
|
||||
notifyAdded: noop,
|
||||
clearSpans: noop,
|
||||
finishUpdate: noop,
|
||||
lineMarker: 0
|
||||
};
|
||||
|
||||
var lineElem = doc.createElement("div");
|
||||
result.node = lineElem;
|
||||
|
||||
result.notifyAdded = function()
|
||||
{
|
||||
// magic -- settng an empty div's innerHTML to the empty string
|
||||
// keeps it from collapsing. Apparently innerHTML must be set *after*
|
||||
// adding the node to the DOM.
|
||||
// Such a div is what IE 6 creates naturally when you make a blank line
|
||||
// in a document of divs. However, when copy-and-pasted the div will
|
||||
// contain a space, so we note its emptiness with a property.
|
||||
lineElem.innerHTML = " "; // Frist we set a value that isnt blank
|
||||
// a primitive-valued property survives copy-and-paste
|
||||
setAssoc(lineElem, "shouldBeEmpty", true);
|
||||
// an object property doesn't
|
||||
setAssoc(lineElem, "unpasted", {});
|
||||
lineElem.innerHTML = ""; // Then we make it blank.. New line and no space = Awesome :)
|
||||
};
|
||||
var lineClass = 'ace-line';
|
||||
result.appendSpan = function(txt, cls)
|
||||
{
|
||||
if ((!txt) && cls)
|
||||
{
|
||||
// gain a whole-line style (currently to show insertion point in CSS)
|
||||
lineClass = domline.addToLineClass(lineClass, cls);
|
||||
}
|
||||
// otherwise, ignore appendSpan, this is an empty line
|
||||
};
|
||||
result.clearSpans = function()
|
||||
{
|
||||
lineClass = ''; // non-null to cause update
|
||||
};
|
||||
|
||||
var writeClass = function()
|
||||
{
|
||||
if (lineClass !== null) lineElem.className = lineClass;
|
||||
};
|
||||
|
||||
result.prepareForAdd = writeClass;
|
||||
result.finishUpdate = writeClass;
|
||||
result.getInnerHTML = function()
|
||||
{
|
||||
return "";
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return domline.createDomLine(nonEmpty, doesWrap, browser, doc);
|
||||
}
|
||||
return domline.createDomLine(nonEmpty, doesWrap, browser, doc);
|
||||
}
|
||||
|
||||
function textify(str)
|
||||
|
|
|
@ -249,9 +249,71 @@ DOMLine.prototype = {};
|
|||
|
||||
}).call(DOMLine.prototype);
|
||||
|
||||
domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||
function SpecialIEDOMLine(nonEmpty, doesWrap, browser, document) {
|
||||
this.node = null;
|
||||
this.lineMarker = 0;
|
||||
this.node = document.createElement("div")
|
||||
|
||||
this.lineClass = 'ace-line';
|
||||
|
||||
// Apparently overridden at the instance level sometimes...
|
||||
this.notifyAdded = function () {this._notifyAdded()};
|
||||
this.finishUpdate = function () {this._finishUpdate()};;
|
||||
}
|
||||
SpecialIEDOMLine.prototype = {};
|
||||
(function () {
|
||||
this._notifyAdded = function () {
|
||||
// magic -- settng an empty div's innerHTML to the empty string
|
||||
// keeps it from collapsing. Apparently innerHTML must be set *after*
|
||||
// adding the node to the DOM.
|
||||
// Such a div is what IE 6 creates naturally when you make a blank line
|
||||
// in a document of divs. However, when copy-and-pasted the div will
|
||||
// contain a space, so we note its emptiness with a property.
|
||||
this.node.innerHTML = " "; // Frist we set a value that isnt blank
|
||||
// a primitive-valued property survives copy-and-paste
|
||||
Ace2Common.setAssoc(lineElem, "shouldBeEmpty", true);
|
||||
// an object property doesn't
|
||||
Ace2Common.setAssoc(lineElem, "unpasted", {});
|
||||
this.node.innerHTML = ""; // Then we make it blank.. New line and no space = Awesome :)
|
||||
}
|
||||
|
||||
this.appendSpan = function (txt, cls) {
|
||||
if ((!txt) && cls) {
|
||||
// gain a whole-line style (currently to show insertion point in CSS)
|
||||
this.lineClass = domline.addToLineClass(lineClass, cls);
|
||||
}
|
||||
// otherwise, ignore appendSpan, this is an empty line
|
||||
}
|
||||
|
||||
this.clearSpans = function () {
|
||||
this.lineClass = ''; // non-null to cause update
|
||||
}
|
||||
|
||||
this._writeClass = function () {
|
||||
if (this.lineClass !== null) {
|
||||
this.node.className = this.lineClass;
|
||||
}
|
||||
}
|
||||
|
||||
this.prepareForAdd = function () {
|
||||
return this._writeClass;
|
||||
}
|
||||
this._finishUpdate = function () {
|
||||
return this._writeClass;
|
||||
}
|
||||
this.getInnerHTML = function () {
|
||||
return "";
|
||||
}
|
||||
}).call(SpecialIEDOMLine.prototype);
|
||||
|
||||
function createDomLine(nonEmpty, doesWrap, browser, document)
|
||||
{
|
||||
return new DOMLine(nonEmpty, doesWrap, optBrowser, optDocument);
|
||||
if (browser.msie && (!nonEmpty)) {
|
||||
// TODO: Why is this necessary?
|
||||
return new SpecialIEDOMLine(nonEmpty, doesWrap, browser, document);
|
||||
} else {
|
||||
return new DOMLine(nonEmpty, doesWrap, browser, document);
|
||||
}
|
||||
};
|
||||
|
||||
domline.processSpaces = function(s, doesWrap)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue