Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../lib
File: codemirror.js
}, NullScrollbars.prototype);
[500] Fix | Delete
[501] Fix | Delete
CodeMirror.scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
[502] Fix | Delete
[503] Fix | Delete
function initScrollbars(cm) {
[504] Fix | Delete
if (cm.display.scrollbars) {
[505] Fix | Delete
cm.display.scrollbars.clear();
[506] Fix | Delete
if (cm.display.scrollbars.addClass)
[507] Fix | Delete
rmClass(cm.display.wrapper, cm.display.scrollbars.addClass);
[508] Fix | Delete
}
[509] Fix | Delete
[510] Fix | Delete
cm.display.scrollbars = new CodeMirror.scrollbarModel[cm.options.scrollbarStyle](function(node) {
[511] Fix | Delete
cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
[512] Fix | Delete
// Prevent clicks in the scrollbars from killing focus
[513] Fix | Delete
on(node, "mousedown", function() {
[514] Fix | Delete
if (cm.state.focused) setTimeout(function() { cm.display.input.focus(); }, 0);
[515] Fix | Delete
});
[516] Fix | Delete
node.setAttribute("cm-not-content", "true");
[517] Fix | Delete
}, function(pos, axis) {
[518] Fix | Delete
if (axis == "horizontal") setScrollLeft(cm, pos);
[519] Fix | Delete
else setScrollTop(cm, pos);
[520] Fix | Delete
}, cm);
[521] Fix | Delete
if (cm.display.scrollbars.addClass)
[522] Fix | Delete
addClass(cm.display.wrapper, cm.display.scrollbars.addClass);
[523] Fix | Delete
}
[524] Fix | Delete
[525] Fix | Delete
function updateScrollbars(cm, measure) {
[526] Fix | Delete
if (!measure) measure = measureForScrollbars(cm);
[527] Fix | Delete
var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
[528] Fix | Delete
updateScrollbarsInner(cm, measure);
[529] Fix | Delete
for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
[530] Fix | Delete
if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
[531] Fix | Delete
updateHeightsInViewport(cm);
[532] Fix | Delete
updateScrollbarsInner(cm, measureForScrollbars(cm));
[533] Fix | Delete
startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
[534] Fix | Delete
}
[535] Fix | Delete
}
[536] Fix | Delete
[537] Fix | Delete
// Re-synchronize the fake scrollbars with the actual size of the
[538] Fix | Delete
// content.
[539] Fix | Delete
function updateScrollbarsInner(cm, measure) {
[540] Fix | Delete
var d = cm.display;
[541] Fix | Delete
var sizes = d.scrollbars.update(measure);
[542] Fix | Delete
[543] Fix | Delete
d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
[544] Fix | Delete
d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
[545] Fix | Delete
d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
[546] Fix | Delete
[547] Fix | Delete
if (sizes.right && sizes.bottom) {
[548] Fix | Delete
d.scrollbarFiller.style.display = "block";
[549] Fix | Delete
d.scrollbarFiller.style.height = sizes.bottom + "px";
[550] Fix | Delete
d.scrollbarFiller.style.width = sizes.right + "px";
[551] Fix | Delete
} else d.scrollbarFiller.style.display = "";
[552] Fix | Delete
if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
[553] Fix | Delete
d.gutterFiller.style.display = "block";
[554] Fix | Delete
d.gutterFiller.style.height = sizes.bottom + "px";
[555] Fix | Delete
d.gutterFiller.style.width = measure.gutterWidth + "px";
[556] Fix | Delete
} else d.gutterFiller.style.display = "";
[557] Fix | Delete
}
[558] Fix | Delete
[559] Fix | Delete
// Compute the lines that are visible in a given viewport (defaults
[560] Fix | Delete
// the the current scroll position). viewport may contain top,
[561] Fix | Delete
// height, and ensure (see op.scrollToPos) properties.
[562] Fix | Delete
function visibleLines(display, doc, viewport) {
[563] Fix | Delete
var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
[564] Fix | Delete
top = Math.floor(top - paddingTop(display));
[565] Fix | Delete
var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
[566] Fix | Delete
[567] Fix | Delete
var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
[568] Fix | Delete
// Ensure is a {from: {line, ch}, to: {line, ch}} object, and
[569] Fix | Delete
// forces those lines into the viewport (if possible).
[570] Fix | Delete
if (viewport && viewport.ensure) {
[571] Fix | Delete
var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
[572] Fix | Delete
if (ensureFrom < from) {
[573] Fix | Delete
from = ensureFrom;
[574] Fix | Delete
to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
[575] Fix | Delete
} else if (Math.min(ensureTo, doc.lastLine()) >= to) {
[576] Fix | Delete
from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
[577] Fix | Delete
to = ensureTo;
[578] Fix | Delete
}
[579] Fix | Delete
}
[580] Fix | Delete
return {from: from, to: Math.max(to, from + 1)};
[581] Fix | Delete
}
[582] Fix | Delete
[583] Fix | Delete
// LINE NUMBERS
[584] Fix | Delete
[585] Fix | Delete
// Re-align line numbers and gutter marks to compensate for
[586] Fix | Delete
// horizontal scrolling.
[587] Fix | Delete
function alignHorizontally(cm) {
[588] Fix | Delete
var display = cm.display, view = display.view;
[589] Fix | Delete
if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) return;
[590] Fix | Delete
var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
[591] Fix | Delete
var gutterW = display.gutters.offsetWidth, left = comp + "px";
[592] Fix | Delete
for (var i = 0; i < view.length; i++) if (!view[i].hidden) {
[593] Fix | Delete
if (cm.options.fixedGutter) {
[594] Fix | Delete
if (view[i].gutter)
[595] Fix | Delete
view[i].gutter.style.left = left;
[596] Fix | Delete
if (view[i].gutterBackground)
[597] Fix | Delete
view[i].gutterBackground.style.left = left;
[598] Fix | Delete
}
[599] Fix | Delete
var align = view[i].alignable;
[600] Fix | Delete
if (align) for (var j = 0; j < align.length; j++)
[601] Fix | Delete
align[j].style.left = left;
[602] Fix | Delete
}
[603] Fix | Delete
if (cm.options.fixedGutter)
[604] Fix | Delete
display.gutters.style.left = (comp + gutterW) + "px";
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
// Used to ensure that the line number gutter is still the right
[608] Fix | Delete
// size for the current document size. Returns true when an update
[609] Fix | Delete
// is needed.
[610] Fix | Delete
function maybeUpdateLineNumberWidth(cm) {
[611] Fix | Delete
if (!cm.options.lineNumbers) return false;
[612] Fix | Delete
var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
[613] Fix | Delete
if (last.length != display.lineNumChars) {
[614] Fix | Delete
var test = display.measure.appendChild(elt("div", [elt("div", last)],
[615] Fix | Delete
"CodeMirror-linenumber CodeMirror-gutter-elt"));
[616] Fix | Delete
var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
[617] Fix | Delete
display.lineGutter.style.width = "";
[618] Fix | Delete
display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
[619] Fix | Delete
display.lineNumWidth = display.lineNumInnerWidth + padding;
[620] Fix | Delete
display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
[621] Fix | Delete
display.lineGutter.style.width = display.lineNumWidth + "px";
[622] Fix | Delete
updateGutterSpace(cm);
[623] Fix | Delete
return true;
[624] Fix | Delete
}
[625] Fix | Delete
return false;
[626] Fix | Delete
}
[627] Fix | Delete
[628] Fix | Delete
function lineNumberFor(options, i) {
[629] Fix | Delete
return String(options.lineNumberFormatter(i + options.firstLineNumber));
[630] Fix | Delete
}
[631] Fix | Delete
[632] Fix | Delete
// Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
[633] Fix | Delete
// but using getBoundingClientRect to get a sub-pixel-accurate
[634] Fix | Delete
// result.
[635] Fix | Delete
function compensateForHScroll(display) {
[636] Fix | Delete
return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left;
[637] Fix | Delete
}
[638] Fix | Delete
[639] Fix | Delete
// DISPLAY DRAWING
[640] Fix | Delete
[641] Fix | Delete
function DisplayUpdate(cm, viewport, force) {
[642] Fix | Delete
var display = cm.display;
[643] Fix | Delete
[644] Fix | Delete
this.viewport = viewport;
[645] Fix | Delete
// Store some values that we'll need later (but don't want to force a relayout for)
[646] Fix | Delete
this.visible = visibleLines(display, cm.doc, viewport);
[647] Fix | Delete
this.editorIsHidden = !display.wrapper.offsetWidth;
[648] Fix | Delete
this.wrapperHeight = display.wrapper.clientHeight;
[649] Fix | Delete
this.wrapperWidth = display.wrapper.clientWidth;
[650] Fix | Delete
this.oldDisplayWidth = displayWidth(cm);
[651] Fix | Delete
this.force = force;
[652] Fix | Delete
this.dims = getDimensions(cm);
[653] Fix | Delete
this.events = [];
[654] Fix | Delete
}
[655] Fix | Delete
[656] Fix | Delete
DisplayUpdate.prototype.signal = function(emitter, type) {
[657] Fix | Delete
if (hasHandler(emitter, type))
[658] Fix | Delete
this.events.push(arguments);
[659] Fix | Delete
};
[660] Fix | Delete
DisplayUpdate.prototype.finish = function() {
[661] Fix | Delete
for (var i = 0; i < this.events.length; i++)
[662] Fix | Delete
signal.apply(null, this.events[i]);
[663] Fix | Delete
};
[664] Fix | Delete
[665] Fix | Delete
function maybeClipScrollbars(cm) {
[666] Fix | Delete
var display = cm.display;
[667] Fix | Delete
if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
[668] Fix | Delete
display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
[669] Fix | Delete
display.heightForcer.style.height = scrollGap(cm) + "px";
[670] Fix | Delete
display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
[671] Fix | Delete
display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
[672] Fix | Delete
display.scrollbarsClipped = true;
[673] Fix | Delete
}
[674] Fix | Delete
}
[675] Fix | Delete
[676] Fix | Delete
// Does the actual updating of the line display. Bails out
[677] Fix | Delete
// (returning false) when there is nothing to be done and forced is
[678] Fix | Delete
// false.
[679] Fix | Delete
function updateDisplayIfNeeded(cm, update) {
[680] Fix | Delete
var display = cm.display, doc = cm.doc;
[681] Fix | Delete
[682] Fix | Delete
if (update.editorIsHidden) {
[683] Fix | Delete
resetView(cm);
[684] Fix | Delete
return false;
[685] Fix | Delete
}
[686] Fix | Delete
[687] Fix | Delete
// Bail out if the visible area is already rendered and nothing changed.
[688] Fix | Delete
if (!update.force &&
[689] Fix | Delete
update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
[690] Fix | Delete
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
[691] Fix | Delete
display.renderedView == display.view && countDirtyView(cm) == 0)
[692] Fix | Delete
return false;
[693] Fix | Delete
[694] Fix | Delete
if (maybeUpdateLineNumberWidth(cm)) {
[695] Fix | Delete
resetView(cm);
[696] Fix | Delete
update.dims = getDimensions(cm);
[697] Fix | Delete
}
[698] Fix | Delete
[699] Fix | Delete
// Compute a suitable new viewport (from & to)
[700] Fix | Delete
var end = doc.first + doc.size;
[701] Fix | Delete
var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
[702] Fix | Delete
var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
[703] Fix | Delete
if (display.viewFrom < from && from - display.viewFrom < 20) from = Math.max(doc.first, display.viewFrom);
[704] Fix | Delete
if (display.viewTo > to && display.viewTo - to < 20) to = Math.min(end, display.viewTo);
[705] Fix | Delete
if (sawCollapsedSpans) {
[706] Fix | Delete
from = visualLineNo(cm.doc, from);
[707] Fix | Delete
to = visualLineEndNo(cm.doc, to);
[708] Fix | Delete
}
[709] Fix | Delete
[710] Fix | Delete
var different = from != display.viewFrom || to != display.viewTo ||
[711] Fix | Delete
display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
[712] Fix | Delete
adjustView(cm, from, to);
[713] Fix | Delete
[714] Fix | Delete
display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
[715] Fix | Delete
// Position the mover div to align with the current scroll position
[716] Fix | Delete
cm.display.mover.style.top = display.viewOffset + "px";
[717] Fix | Delete
[718] Fix | Delete
var toUpdate = countDirtyView(cm);
[719] Fix | Delete
if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
[720] Fix | Delete
(display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
[721] Fix | Delete
return false;
[722] Fix | Delete
[723] Fix | Delete
// For big changes, we hide the enclosing element during the
[724] Fix | Delete
// update, since that speeds up the operations on most browsers.
[725] Fix | Delete
var focused = activeElt();
[726] Fix | Delete
if (toUpdate > 4) display.lineDiv.style.display = "none";
[727] Fix | Delete
patchDisplay(cm, display.updateLineNumbers, update.dims);
[728] Fix | Delete
if (toUpdate > 4) display.lineDiv.style.display = "";
[729] Fix | Delete
display.renderedView = display.view;
[730] Fix | Delete
// There might have been a widget with a focused element that got
[731] Fix | Delete
// hidden or updated, if so re-focus it.
[732] Fix | Delete
if (focused && activeElt() != focused && focused.offsetHeight) focused.focus();
[733] Fix | Delete
[734] Fix | Delete
// Prevent selection and cursors from interfering with the scroll
[735] Fix | Delete
// width and height.
[736] Fix | Delete
removeChildren(display.cursorDiv);
[737] Fix | Delete
removeChildren(display.selectionDiv);
[738] Fix | Delete
display.gutters.style.height = display.sizer.style.minHeight = 0;
[739] Fix | Delete
[740] Fix | Delete
if (different) {
[741] Fix | Delete
display.lastWrapHeight = update.wrapperHeight;
[742] Fix | Delete
display.lastWrapWidth = update.wrapperWidth;
[743] Fix | Delete
startWorker(cm, 400);
[744] Fix | Delete
}
[745] Fix | Delete
[746] Fix | Delete
display.updateLineNumbers = null;
[747] Fix | Delete
[748] Fix | Delete
return true;
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
function postUpdateDisplay(cm, update) {
[752] Fix | Delete
var viewport = update.viewport;
[753] Fix | Delete
[754] Fix | Delete
for (var first = true;; first = false) {
[755] Fix | Delete
if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
[756] Fix | Delete
// Clip forced viewport to actual scrollable area.
[757] Fix | Delete
if (viewport && viewport.top != null)
[758] Fix | Delete
viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
[759] Fix | Delete
// Updated line heights might result in the drawn area not
[760] Fix | Delete
// actually covering the viewport. Keep looping until it does.
[761] Fix | Delete
update.visible = visibleLines(cm.display, cm.doc, viewport);
[762] Fix | Delete
if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
[763] Fix | Delete
break;
[764] Fix | Delete
}
[765] Fix | Delete
if (!updateDisplayIfNeeded(cm, update)) break;
[766] Fix | Delete
updateHeightsInViewport(cm);
[767] Fix | Delete
var barMeasure = measureForScrollbars(cm);
[768] Fix | Delete
updateSelection(cm);
[769] Fix | Delete
updateScrollbars(cm, barMeasure);
[770] Fix | Delete
setDocumentHeight(cm, barMeasure);
[771] Fix | Delete
}
[772] Fix | Delete
[773] Fix | Delete
update.signal(cm, "update", cm);
[774] Fix | Delete
if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
[775] Fix | Delete
update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
[776] Fix | Delete
cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
[777] Fix | Delete
}
[778] Fix | Delete
}
[779] Fix | Delete
[780] Fix | Delete
function updateDisplaySimple(cm, viewport) {
[781] Fix | Delete
var update = new DisplayUpdate(cm, viewport);
[782] Fix | Delete
if (updateDisplayIfNeeded(cm, update)) {
[783] Fix | Delete
updateHeightsInViewport(cm);
[784] Fix | Delete
postUpdateDisplay(cm, update);
[785] Fix | Delete
var barMeasure = measureForScrollbars(cm);
[786] Fix | Delete
updateSelection(cm);
[787] Fix | Delete
updateScrollbars(cm, barMeasure);
[788] Fix | Delete
setDocumentHeight(cm, barMeasure);
[789] Fix | Delete
update.finish();
[790] Fix | Delete
}
[791] Fix | Delete
}
[792] Fix | Delete
[793] Fix | Delete
function setDocumentHeight(cm, measure) {
[794] Fix | Delete
cm.display.sizer.style.minHeight = measure.docHeight + "px";
[795] Fix | Delete
cm.display.heightForcer.style.top = measure.docHeight + "px";
[796] Fix | Delete
cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
[797] Fix | Delete
}
[798] Fix | Delete
[799] Fix | Delete
// Read the actual heights of the rendered lines, and update their
[800] Fix | Delete
// stored heights to match.
[801] Fix | Delete
function updateHeightsInViewport(cm) {
[802] Fix | Delete
var display = cm.display;
[803] Fix | Delete
var prevBottom = display.lineDiv.offsetTop;
[804] Fix | Delete
for (var i = 0; i < display.view.length; i++) {
[805] Fix | Delete
var cur = display.view[i], height;
[806] Fix | Delete
if (cur.hidden) continue;
[807] Fix | Delete
if (ie && ie_version < 8) {
[808] Fix | Delete
var bot = cur.node.offsetTop + cur.node.offsetHeight;
[809] Fix | Delete
height = bot - prevBottom;
[810] Fix | Delete
prevBottom = bot;
[811] Fix | Delete
} else {
[812] Fix | Delete
var box = cur.node.getBoundingClientRect();
[813] Fix | Delete
height = box.bottom - box.top;
[814] Fix | Delete
}
[815] Fix | Delete
var diff = cur.line.height - height;
[816] Fix | Delete
if (height < 2) height = textHeight(display);
[817] Fix | Delete
if (diff > .001 || diff < -.001) {
[818] Fix | Delete
updateLineHeight(cur.line, height);
[819] Fix | Delete
updateWidgetHeight(cur.line);
[820] Fix | Delete
if (cur.rest) for (var j = 0; j < cur.rest.length; j++)
[821] Fix | Delete
updateWidgetHeight(cur.rest[j]);
[822] Fix | Delete
}
[823] Fix | Delete
}
[824] Fix | Delete
}
[825] Fix | Delete
[826] Fix | Delete
// Read and store the height of line widgets associated with the
[827] Fix | Delete
// given line.
[828] Fix | Delete
function updateWidgetHeight(line) {
[829] Fix | Delete
if (line.widgets) for (var i = 0; i < line.widgets.length; ++i)
[830] Fix | Delete
line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight;
[831] Fix | Delete
}
[832] Fix | Delete
[833] Fix | Delete
// Do a bulk-read of the DOM positions and sizes needed to draw the
[834] Fix | Delete
// view, so that we don't interleave reading and writing to the DOM.
[835] Fix | Delete
function getDimensions(cm) {
[836] Fix | Delete
var d = cm.display, left = {}, width = {};
[837] Fix | Delete
var gutterLeft = d.gutters.clientLeft;
[838] Fix | Delete
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
[839] Fix | Delete
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
[840] Fix | Delete
width[cm.options.gutters[i]] = n.clientWidth;
[841] Fix | Delete
}
[842] Fix | Delete
return {fixedPos: compensateForHScroll(d),
[843] Fix | Delete
gutterTotalWidth: d.gutters.offsetWidth,
[844] Fix | Delete
gutterLeft: left,
[845] Fix | Delete
gutterWidth: width,
[846] Fix | Delete
wrapperWidth: d.wrapper.clientWidth};
[847] Fix | Delete
}
[848] Fix | Delete
[849] Fix | Delete
// Sync the actual display DOM structure with display.view, removing
[850] Fix | Delete
// nodes for lines that are no longer in view, and creating the ones
[851] Fix | Delete
// that are not there yet, and updating the ones that are out of
[852] Fix | Delete
// date.
[853] Fix | Delete
function patchDisplay(cm, updateNumbersFrom, dims) {
[854] Fix | Delete
var display = cm.display, lineNumbers = cm.options.lineNumbers;
[855] Fix | Delete
var container = display.lineDiv, cur = container.firstChild;
[856] Fix | Delete
[857] Fix | Delete
function rm(node) {
[858] Fix | Delete
var next = node.nextSibling;
[859] Fix | Delete
// Works around a throw-scroll bug in OS X Webkit
[860] Fix | Delete
if (webkit && mac && cm.display.currentWheelTarget == node)
[861] Fix | Delete
node.style.display = "none";
[862] Fix | Delete
else
[863] Fix | Delete
node.parentNode.removeChild(node);
[864] Fix | Delete
return next;
[865] Fix | Delete
}
[866] Fix | Delete
[867] Fix | Delete
var view = display.view, lineN = display.viewFrom;
[868] Fix | Delete
// Loop over the elements in the view, syncing cur (the DOM nodes
[869] Fix | Delete
// in display.lineDiv) with the view as we go.
[870] Fix | Delete
for (var i = 0; i < view.length; i++) {
[871] Fix | Delete
var lineView = view[i];
[872] Fix | Delete
if (lineView.hidden) {
[873] Fix | Delete
} else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
[874] Fix | Delete
var node = buildLineElement(cm, lineView, lineN, dims);
[875] Fix | Delete
container.insertBefore(node, cur);
[876] Fix | Delete
} else { // Already drawn
[877] Fix | Delete
while (cur != lineView.node) cur = rm(cur);
[878] Fix | Delete
var updateNumber = lineNumbers && updateNumbersFrom != null &&
[879] Fix | Delete
updateNumbersFrom <= lineN && lineView.lineNumber;
[880] Fix | Delete
if (lineView.changes) {
[881] Fix | Delete
if (indexOf(lineView.changes, "gutter") > -1) updateNumber = false;
[882] Fix | Delete
updateLineForChanges(cm, lineView, lineN, dims);
[883] Fix | Delete
}
[884] Fix | Delete
if (updateNumber) {
[885] Fix | Delete
removeChildren(lineView.lineNumber);
[886] Fix | Delete
lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
[887] Fix | Delete
}
[888] Fix | Delete
cur = lineView.node.nextSibling;
[889] Fix | Delete
}
[890] Fix | Delete
lineN += lineView.size;
[891] Fix | Delete
}
[892] Fix | Delete
while (cur) cur = rm(cur);
[893] Fix | Delete
}
[894] Fix | Delete
[895] Fix | Delete
// When an aspect of a line changes, a string is added to
[896] Fix | Delete
// lineView.changes. This updates the relevant part of the line's
[897] Fix | Delete
// DOM structure.
[898] Fix | Delete
function updateLineForChanges(cm, lineView, lineN, dims) {
[899] Fix | Delete
for (var j = 0; j < lineView.changes.length; j++) {
[900] Fix | Delete
var type = lineView.changes[j];
[901] Fix | Delete
if (type == "text") updateLineText(cm, lineView);
[902] Fix | Delete
else if (type == "gutter") updateLineGutter(cm, lineView, lineN, dims);
[903] Fix | Delete
else if (type == "class") updateLineClasses(lineView);
[904] Fix | Delete
else if (type == "widget") updateLineWidgets(cm, lineView, dims);
[905] Fix | Delete
}
[906] Fix | Delete
lineView.changes = null;
[907] Fix | Delete
}
[908] Fix | Delete
[909] Fix | Delete
// Lines with gutter elements, widgets or a background class need to
[910] Fix | Delete
// be wrapped, and have the extra elements added to the wrapper div
[911] Fix | Delete
function ensureLineWrapped(lineView) {
[912] Fix | Delete
if (lineView.node == lineView.text) {
[913] Fix | Delete
lineView.node = elt("div", null, null, "position: relative");
[914] Fix | Delete
if (lineView.text.parentNode)
[915] Fix | Delete
lineView.text.parentNode.replaceChild(lineView.node, lineView.text);
[916] Fix | Delete
lineView.node.appendChild(lineView.text);
[917] Fix | Delete
if (ie && ie_version < 8) lineView.node.style.zIndex = 2;
[918] Fix | Delete
}
[919] Fix | Delete
return lineView.node;
[920] Fix | Delete
}
[921] Fix | Delete
[922] Fix | Delete
function updateLineBackground(lineView) {
[923] Fix | Delete
var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
[924] Fix | Delete
if (cls) cls += " CodeMirror-linebackground";
[925] Fix | Delete
if (lineView.background) {
[926] Fix | Delete
if (cls) lineView.background.className = cls;
[927] Fix | Delete
else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
[928] Fix | Delete
} else if (cls) {
[929] Fix | Delete
var wrap = ensureLineWrapped(lineView);
[930] Fix | Delete
lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
[931] Fix | Delete
}
[932] Fix | Delete
}
[933] Fix | Delete
[934] Fix | Delete
// Wrapper around buildLineContent which will reuse the structure
[935] Fix | Delete
// in display.externalMeasured when possible.
[936] Fix | Delete
function getLineContent(cm, lineView) {
[937] Fix | Delete
var ext = cm.display.externalMeasured;
[938] Fix | Delete
if (ext && ext.line == lineView.line) {
[939] Fix | Delete
cm.display.externalMeasured = null;
[940] Fix | Delete
lineView.measure = ext.measure;
[941] Fix | Delete
return ext.built;
[942] Fix | Delete
}
[943] Fix | Delete
return buildLineContent(cm, lineView);
[944] Fix | Delete
}
[945] Fix | Delete
[946] Fix | Delete
// Redraw the line's text. Interacts with the background and text
[947] Fix | Delete
// classes because the mode may output tokens that influence these
[948] Fix | Delete
// classes.
[949] Fix | Delete
function updateLineText(cm, lineView) {
[950] Fix | Delete
var cls = lineView.text.className;
[951] Fix | Delete
var built = getLineContent(cm, lineView);
[952] Fix | Delete
if (lineView.text == lineView.node) lineView.node = built.pre;
[953] Fix | Delete
lineView.text.parentNode.replaceChild(built.pre, lineView.text);
[954] Fix | Delete
lineView.text = built.pre;
[955] Fix | Delete
if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
[956] Fix | Delete
lineView.bgClass = built.bgClass;
[957] Fix | Delete
lineView.textClass = built.textClass;
[958] Fix | Delete
updateLineClasses(lineView);
[959] Fix | Delete
} else if (cls) {
[960] Fix | Delete
lineView.text.className = cls;
[961] Fix | Delete
}
[962] Fix | Delete
}
[963] Fix | Delete
[964] Fix | Delete
function updateLineClasses(lineView) {
[965] Fix | Delete
updateLineBackground(lineView);
[966] Fix | Delete
if (lineView.line.wrapClass)
[967] Fix | Delete
ensureLineWrapped(lineView).className = lineView.line.wrapClass;
[968] Fix | Delete
else if (lineView.node != lineView.text)
[969] Fix | Delete
lineView.node.className = "";
[970] Fix | Delete
var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
[971] Fix | Delete
lineView.text.className = textClass || "";
[972] Fix | Delete
}
[973] Fix | Delete
[974] Fix | Delete
function updateLineGutter(cm, lineView, lineN, dims) {
[975] Fix | Delete
if (lineView.gutter) {
[976] Fix | Delete
lineView.node.removeChild(lineView.gutter);
[977] Fix | Delete
lineView.gutter = null;
[978] Fix | Delete
}
[979] Fix | Delete
if (lineView.gutterBackground) {
[980] Fix | Delete
lineView.node.removeChild(lineView.gutterBackground);
[981] Fix | Delete
lineView.gutterBackground = null;
[982] Fix | Delete
}
[983] Fix | Delete
if (lineView.line.gutterClass) {
[984] Fix | Delete
var wrap = ensureLineWrapped(lineView);
[985] Fix | Delete
lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
[986] Fix | Delete
"left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) +
[987] Fix | Delete
"px; width: " + dims.gutterTotalWidth + "px");
[988] Fix | Delete
wrap.insertBefore(lineView.gutterBackground, lineView.text);
[989] Fix | Delete
}
[990] Fix | Delete
var markers = lineView.line.gutterMarkers;
[991] Fix | Delete
if (cm.options.lineNumbers || markers) {
[992] Fix | Delete
var wrap = ensureLineWrapped(lineView);
[993] Fix | Delete
var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", "left: " +
[994] Fix | Delete
(cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px");
[995] Fix | Delete
cm.display.input.setUneditable(gutterWrap);
[996] Fix | Delete
wrap.insertBefore(gutterWrap, lineView.text);
[997] Fix | Delete
if (lineView.line.gutterClass)
[998] Fix | Delete
gutterWrap.className += " " + lineView.line.gutterClass;
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function