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
e_preventDefault(e);
[3500] Fix | Delete
}
[3501] Fix | Delete
finishTouch();
[3502] Fix | Delete
});
[3503] Fix | Delete
on(d.scroller, "touchcancel", finishTouch);
[3504] Fix | Delete
[3505] Fix | Delete
// Sync scrolling between fake scrollbars and real scrollable
[3506] Fix | Delete
// area, ensure viewport is updated when scrolling.
[3507] Fix | Delete
on(d.scroller, "scroll", function() {
[3508] Fix | Delete
if (d.scroller.clientHeight) {
[3509] Fix | Delete
setScrollTop(cm, d.scroller.scrollTop);
[3510] Fix | Delete
setScrollLeft(cm, d.scroller.scrollLeft, true);
[3511] Fix | Delete
signal(cm, "scroll", cm);
[3512] Fix | Delete
}
[3513] Fix | Delete
});
[3514] Fix | Delete
[3515] Fix | Delete
// Listen to wheel events in order to try and update the viewport on time.
[3516] Fix | Delete
on(d.scroller, "mousewheel", function(e){onScrollWheel(cm, e);});
[3517] Fix | Delete
on(d.scroller, "DOMMouseScroll", function(e){onScrollWheel(cm, e);});
[3518] Fix | Delete
[3519] Fix | Delete
// Prevent wrapper from ever scrolling
[3520] Fix | Delete
on(d.wrapper, "scroll", function() { d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
[3521] Fix | Delete
[3522] Fix | Delete
d.dragFunctions = {
[3523] Fix | Delete
enter: function(e) {if (!signalDOMEvent(cm, e)) e_stop(e);},
[3524] Fix | Delete
over: function(e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
[3525] Fix | Delete
start: function(e){onDragStart(cm, e);},
[3526] Fix | Delete
drop: operation(cm, onDrop),
[3527] Fix | Delete
leave: function(e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
[3528] Fix | Delete
};
[3529] Fix | Delete
[3530] Fix | Delete
var inp = d.input.getField();
[3531] Fix | Delete
on(inp, "keyup", function(e) { onKeyUp.call(cm, e); });
[3532] Fix | Delete
on(inp, "keydown", operation(cm, onKeyDown));
[3533] Fix | Delete
on(inp, "keypress", operation(cm, onKeyPress));
[3534] Fix | Delete
on(inp, "focus", bind(onFocus, cm));
[3535] Fix | Delete
on(inp, "blur", bind(onBlur, cm));
[3536] Fix | Delete
}
[3537] Fix | Delete
[3538] Fix | Delete
function dragDropChanged(cm, value, old) {
[3539] Fix | Delete
var wasOn = old && old != CodeMirror.Init;
[3540] Fix | Delete
if (!value != !wasOn) {
[3541] Fix | Delete
var funcs = cm.display.dragFunctions;
[3542] Fix | Delete
var toggle = value ? on : off;
[3543] Fix | Delete
toggle(cm.display.scroller, "dragstart", funcs.start);
[3544] Fix | Delete
toggle(cm.display.scroller, "dragenter", funcs.enter);
[3545] Fix | Delete
toggle(cm.display.scroller, "dragover", funcs.over);
[3546] Fix | Delete
toggle(cm.display.scroller, "dragleave", funcs.leave);
[3547] Fix | Delete
toggle(cm.display.scroller, "drop", funcs.drop);
[3548] Fix | Delete
}
[3549] Fix | Delete
}
[3550] Fix | Delete
[3551] Fix | Delete
// Called when the window resizes
[3552] Fix | Delete
function onResize(cm) {
[3553] Fix | Delete
var d = cm.display;
[3554] Fix | Delete
if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
[3555] Fix | Delete
return;
[3556] Fix | Delete
// Might be a text scaling operation, clear size caches.
[3557] Fix | Delete
d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
[3558] Fix | Delete
d.scrollbarsClipped = false;
[3559] Fix | Delete
cm.setSize();
[3560] Fix | Delete
}
[3561] Fix | Delete
[3562] Fix | Delete
// MOUSE EVENTS
[3563] Fix | Delete
[3564] Fix | Delete
// Return true when the given mouse event happened in a widget
[3565] Fix | Delete
function eventInWidget(display, e) {
[3566] Fix | Delete
for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
[3567] Fix | Delete
if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
[3568] Fix | Delete
(n.parentNode == display.sizer && n != display.mover))
[3569] Fix | Delete
return true;
[3570] Fix | Delete
}
[3571] Fix | Delete
}
[3572] Fix | Delete
[3573] Fix | Delete
// Given a mouse event, find the corresponding position. If liberal
[3574] Fix | Delete
// is false, it checks whether a gutter or scrollbar was clicked,
[3575] Fix | Delete
// and returns null if it was. forRect is used by rectangular
[3576] Fix | Delete
// selections, and tries to estimate a character position even for
[3577] Fix | Delete
// coordinates beyond the right of the text.
[3578] Fix | Delete
function posFromMouse(cm, e, liberal, forRect) {
[3579] Fix | Delete
var display = cm.display;
[3580] Fix | Delete
if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") return null;
[3581] Fix | Delete
[3582] Fix | Delete
var x, y, space = display.lineSpace.getBoundingClientRect();
[3583] Fix | Delete
// Fails unpredictably on IE[67] when mouse is dragged around quickly.
[3584] Fix | Delete
try { x = e.clientX - space.left; y = e.clientY - space.top; }
[3585] Fix | Delete
catch (e) { return null; }
[3586] Fix | Delete
var coords = coordsChar(cm, x, y), line;
[3587] Fix | Delete
if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
[3588] Fix | Delete
var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
[3589] Fix | Delete
coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
[3590] Fix | Delete
}
[3591] Fix | Delete
return coords;
[3592] Fix | Delete
}
[3593] Fix | Delete
[3594] Fix | Delete
// A mouse down can be a single click, double click, triple click,
[3595] Fix | Delete
// start of selection drag, start of text drag, new cursor
[3596] Fix | Delete
// (ctrl-click), rectangle drag (alt-drag), or xwin
[3597] Fix | Delete
// middle-click-paste. Or it might be a click on something we should
[3598] Fix | Delete
// not interfere with, such as a scrollbar or widget.
[3599] Fix | Delete
function onMouseDown(e) {
[3600] Fix | Delete
var cm = this, display = cm.display;
[3601] Fix | Delete
if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) return;
[3602] Fix | Delete
display.shift = e.shiftKey;
[3603] Fix | Delete
[3604] Fix | Delete
if (eventInWidget(display, e)) {
[3605] Fix | Delete
if (!webkit) {
[3606] Fix | Delete
// Briefly turn off draggability, to allow widgets to do
[3607] Fix | Delete
// normal dragging things.
[3608] Fix | Delete
display.scroller.draggable = false;
[3609] Fix | Delete
setTimeout(function(){display.scroller.draggable = true;}, 100);
[3610] Fix | Delete
}
[3611] Fix | Delete
return;
[3612] Fix | Delete
}
[3613] Fix | Delete
if (clickInGutter(cm, e)) return;
[3614] Fix | Delete
var start = posFromMouse(cm, e);
[3615] Fix | Delete
window.focus();
[3616] Fix | Delete
[3617] Fix | Delete
switch (e_button(e)) {
[3618] Fix | Delete
case 1:
[3619] Fix | Delete
// #3261: make sure, that we're not starting a second selection
[3620] Fix | Delete
if (cm.state.selectingText)
[3621] Fix | Delete
cm.state.selectingText(e);
[3622] Fix | Delete
else if (start)
[3623] Fix | Delete
leftButtonDown(cm, e, start);
[3624] Fix | Delete
else if (e_target(e) == display.scroller)
[3625] Fix | Delete
e_preventDefault(e);
[3626] Fix | Delete
break;
[3627] Fix | Delete
case 2:
[3628] Fix | Delete
if (webkit) cm.state.lastMiddleDown = +new Date;
[3629] Fix | Delete
if (start) extendSelection(cm.doc, start);
[3630] Fix | Delete
setTimeout(function() {display.input.focus();}, 20);
[3631] Fix | Delete
e_preventDefault(e);
[3632] Fix | Delete
break;
[3633] Fix | Delete
case 3:
[3634] Fix | Delete
if (captureRightClick) onContextMenu(cm, e);
[3635] Fix | Delete
else delayBlurEvent(cm);
[3636] Fix | Delete
break;
[3637] Fix | Delete
}
[3638] Fix | Delete
}
[3639] Fix | Delete
[3640] Fix | Delete
var lastClick, lastDoubleClick;
[3641] Fix | Delete
function leftButtonDown(cm, e, start) {
[3642] Fix | Delete
if (ie) setTimeout(bind(ensureFocus, cm), 0);
[3643] Fix | Delete
else cm.curOp.focus = activeElt();
[3644] Fix | Delete
[3645] Fix | Delete
var now = +new Date, type;
[3646] Fix | Delete
if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
[3647] Fix | Delete
type = "triple";
[3648] Fix | Delete
} else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
[3649] Fix | Delete
type = "double";
[3650] Fix | Delete
lastDoubleClick = {time: now, pos: start};
[3651] Fix | Delete
} else {
[3652] Fix | Delete
type = "single";
[3653] Fix | Delete
lastClick = {time: now, pos: start};
[3654] Fix | Delete
}
[3655] Fix | Delete
[3656] Fix | Delete
var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained;
[3657] Fix | Delete
if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
[3658] Fix | Delete
type == "single" && (contained = sel.contains(start)) > -1 &&
[3659] Fix | Delete
(cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
[3660] Fix | Delete
(cmp(contained.to(), start) > 0 || start.xRel < 0))
[3661] Fix | Delete
leftButtonStartDrag(cm, e, start, modifier);
[3662] Fix | Delete
else
[3663] Fix | Delete
leftButtonSelect(cm, e, start, type, modifier);
[3664] Fix | Delete
}
[3665] Fix | Delete
[3666] Fix | Delete
// Start a text drag. When it ends, see if any dragging actually
[3667] Fix | Delete
// happen, and treat as a click if it didn't.
[3668] Fix | Delete
function leftButtonStartDrag(cm, e, start, modifier) {
[3669] Fix | Delete
var display = cm.display, startTime = +new Date;
[3670] Fix | Delete
var dragEnd = operation(cm, function(e2) {
[3671] Fix | Delete
if (webkit) display.scroller.draggable = false;
[3672] Fix | Delete
cm.state.draggingText = false;
[3673] Fix | Delete
off(document, "mouseup", dragEnd);
[3674] Fix | Delete
off(display.scroller, "drop", dragEnd);
[3675] Fix | Delete
if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
[3676] Fix | Delete
e_preventDefault(e2);
[3677] Fix | Delete
if (!modifier && +new Date - 200 < startTime)
[3678] Fix | Delete
extendSelection(cm.doc, start);
[3679] Fix | Delete
// Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
[3680] Fix | Delete
if (webkit || ie && ie_version == 9)
[3681] Fix | Delete
setTimeout(function() {document.body.focus(); display.input.focus();}, 20);
[3682] Fix | Delete
else
[3683] Fix | Delete
display.input.focus();
[3684] Fix | Delete
}
[3685] Fix | Delete
});
[3686] Fix | Delete
// Let the drag handler handle this.
[3687] Fix | Delete
if (webkit) display.scroller.draggable = true;
[3688] Fix | Delete
cm.state.draggingText = dragEnd;
[3689] Fix | Delete
dragEnd.copy = mac ? e.altKey : e.ctrlKey
[3690] Fix | Delete
// IE's approach to draggable
[3691] Fix | Delete
if (display.scroller.dragDrop) display.scroller.dragDrop();
[3692] Fix | Delete
on(document, "mouseup", dragEnd);
[3693] Fix | Delete
on(display.scroller, "drop", dragEnd);
[3694] Fix | Delete
}
[3695] Fix | Delete
[3696] Fix | Delete
// Normal selection, as opposed to text dragging.
[3697] Fix | Delete
function leftButtonSelect(cm, e, start, type, addNew) {
[3698] Fix | Delete
var display = cm.display, doc = cm.doc;
[3699] Fix | Delete
e_preventDefault(e);
[3700] Fix | Delete
[3701] Fix | Delete
var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
[3702] Fix | Delete
if (addNew && !e.shiftKey) {
[3703] Fix | Delete
ourIndex = doc.sel.contains(start);
[3704] Fix | Delete
if (ourIndex > -1)
[3705] Fix | Delete
ourRange = ranges[ourIndex];
[3706] Fix | Delete
else
[3707] Fix | Delete
ourRange = new Range(start, start);
[3708] Fix | Delete
} else {
[3709] Fix | Delete
ourRange = doc.sel.primary();
[3710] Fix | Delete
ourIndex = doc.sel.primIndex;
[3711] Fix | Delete
}
[3712] Fix | Delete
[3713] Fix | Delete
if (chromeOS ? e.shiftKey && e.metaKey : e.altKey) {
[3714] Fix | Delete
type = "rect";
[3715] Fix | Delete
if (!addNew) ourRange = new Range(start, start);
[3716] Fix | Delete
start = posFromMouse(cm, e, true, true);
[3717] Fix | Delete
ourIndex = -1;
[3718] Fix | Delete
} else if (type == "double") {
[3719] Fix | Delete
var word = cm.findWordAt(start);
[3720] Fix | Delete
if (cm.display.shift || doc.extend)
[3721] Fix | Delete
ourRange = extendRange(doc, ourRange, word.anchor, word.head);
[3722] Fix | Delete
else
[3723] Fix | Delete
ourRange = word;
[3724] Fix | Delete
} else if (type == "triple") {
[3725] Fix | Delete
var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)));
[3726] Fix | Delete
if (cm.display.shift || doc.extend)
[3727] Fix | Delete
ourRange = extendRange(doc, ourRange, line.anchor, line.head);
[3728] Fix | Delete
else
[3729] Fix | Delete
ourRange = line;
[3730] Fix | Delete
} else {
[3731] Fix | Delete
ourRange = extendRange(doc, ourRange, start);
[3732] Fix | Delete
}
[3733] Fix | Delete
[3734] Fix | Delete
if (!addNew) {
[3735] Fix | Delete
ourIndex = 0;
[3736] Fix | Delete
setSelection(doc, new Selection([ourRange], 0), sel_mouse);
[3737] Fix | Delete
startSel = doc.sel;
[3738] Fix | Delete
} else if (ourIndex == -1) {
[3739] Fix | Delete
ourIndex = ranges.length;
[3740] Fix | Delete
setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
[3741] Fix | Delete
{scroll: false, origin: "*mouse"});
[3742] Fix | Delete
} else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
[3743] Fix | Delete
setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
[3744] Fix | Delete
{scroll: false, origin: "*mouse"});
[3745] Fix | Delete
startSel = doc.sel;
[3746] Fix | Delete
} else {
[3747] Fix | Delete
replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
[3748] Fix | Delete
}
[3749] Fix | Delete
[3750] Fix | Delete
var lastPos = start;
[3751] Fix | Delete
function extendTo(pos) {
[3752] Fix | Delete
if (cmp(lastPos, pos) == 0) return;
[3753] Fix | Delete
lastPos = pos;
[3754] Fix | Delete
[3755] Fix | Delete
if (type == "rect") {
[3756] Fix | Delete
var ranges = [], tabSize = cm.options.tabSize;
[3757] Fix | Delete
var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
[3758] Fix | Delete
var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
[3759] Fix | Delete
var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
[3760] Fix | Delete
for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
[3761] Fix | Delete
line <= end; line++) {
[3762] Fix | Delete
var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
[3763] Fix | Delete
if (left == right)
[3764] Fix | Delete
ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos)));
[3765] Fix | Delete
else if (text.length > leftPos)
[3766] Fix | Delete
ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize))));
[3767] Fix | Delete
}
[3768] Fix | Delete
if (!ranges.length) ranges.push(new Range(start, start));
[3769] Fix | Delete
setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
[3770] Fix | Delete
{origin: "*mouse", scroll: false});
[3771] Fix | Delete
cm.scrollIntoView(pos);
[3772] Fix | Delete
} else {
[3773] Fix | Delete
var oldRange = ourRange;
[3774] Fix | Delete
var anchor = oldRange.anchor, head = pos;
[3775] Fix | Delete
if (type != "single") {
[3776] Fix | Delete
if (type == "double")
[3777] Fix | Delete
var range = cm.findWordAt(pos);
[3778] Fix | Delete
else
[3779] Fix | Delete
var range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0)));
[3780] Fix | Delete
if (cmp(range.anchor, anchor) > 0) {
[3781] Fix | Delete
head = range.head;
[3782] Fix | Delete
anchor = minPos(oldRange.from(), range.anchor);
[3783] Fix | Delete
} else {
[3784] Fix | Delete
head = range.anchor;
[3785] Fix | Delete
anchor = maxPos(oldRange.to(), range.head);
[3786] Fix | Delete
}
[3787] Fix | Delete
}
[3788] Fix | Delete
var ranges = startSel.ranges.slice(0);
[3789] Fix | Delete
ranges[ourIndex] = new Range(clipPos(doc, anchor), head);
[3790] Fix | Delete
setSelection(doc, normalizeSelection(ranges, ourIndex), sel_mouse);
[3791] Fix | Delete
}
[3792] Fix | Delete
}
[3793] Fix | Delete
[3794] Fix | Delete
var editorSize = display.wrapper.getBoundingClientRect();
[3795] Fix | Delete
// Used to ensure timeout re-tries don't fire when another extend
[3796] Fix | Delete
// happened in the meantime (clearTimeout isn't reliable -- at
[3797] Fix | Delete
// least on Chrome, the timeouts still happen even when cleared,
[3798] Fix | Delete
// if the clear happens after their scheduled firing time).
[3799] Fix | Delete
var counter = 0;
[3800] Fix | Delete
[3801] Fix | Delete
function extend(e) {
[3802] Fix | Delete
var curCount = ++counter;
[3803] Fix | Delete
var cur = posFromMouse(cm, e, true, type == "rect");
[3804] Fix | Delete
if (!cur) return;
[3805] Fix | Delete
if (cmp(cur, lastPos) != 0) {
[3806] Fix | Delete
cm.curOp.focus = activeElt();
[3807] Fix | Delete
extendTo(cur);
[3808] Fix | Delete
var visible = visibleLines(display, doc);
[3809] Fix | Delete
if (cur.line >= visible.to || cur.line < visible.from)
[3810] Fix | Delete
setTimeout(operation(cm, function(){if (counter == curCount) extend(e);}), 150);
[3811] Fix | Delete
} else {
[3812] Fix | Delete
var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
[3813] Fix | Delete
if (outside) setTimeout(operation(cm, function() {
[3814] Fix | Delete
if (counter != curCount) return;
[3815] Fix | Delete
display.scroller.scrollTop += outside;
[3816] Fix | Delete
extend(e);
[3817] Fix | Delete
}), 50);
[3818] Fix | Delete
}
[3819] Fix | Delete
}
[3820] Fix | Delete
[3821] Fix | Delete
function done(e) {
[3822] Fix | Delete
cm.state.selectingText = false;
[3823] Fix | Delete
counter = Infinity;
[3824] Fix | Delete
e_preventDefault(e);
[3825] Fix | Delete
display.input.focus();
[3826] Fix | Delete
off(document, "mousemove", move);
[3827] Fix | Delete
off(document, "mouseup", up);
[3828] Fix | Delete
doc.history.lastSelOrigin = null;
[3829] Fix | Delete
}
[3830] Fix | Delete
[3831] Fix | Delete
var move = operation(cm, function(e) {
[3832] Fix | Delete
if (!e_button(e)) done(e);
[3833] Fix | Delete
else extend(e);
[3834] Fix | Delete
});
[3835] Fix | Delete
var up = operation(cm, done);
[3836] Fix | Delete
cm.state.selectingText = up;
[3837] Fix | Delete
on(document, "mousemove", move);
[3838] Fix | Delete
on(document, "mouseup", up);
[3839] Fix | Delete
}
[3840] Fix | Delete
[3841] Fix | Delete
// Determines whether an event happened in the gutter, and fires the
[3842] Fix | Delete
// handlers for the corresponding event.
[3843] Fix | Delete
function gutterEvent(cm, e, type, prevent) {
[3844] Fix | Delete
try { var mX = e.clientX, mY = e.clientY; }
[3845] Fix | Delete
catch(e) { return false; }
[3846] Fix | Delete
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
[3847] Fix | Delete
if (prevent) e_preventDefault(e);
[3848] Fix | Delete
[3849] Fix | Delete
var display = cm.display;
[3850] Fix | Delete
var lineBox = display.lineDiv.getBoundingClientRect();
[3851] Fix | Delete
[3852] Fix | Delete
if (mY > lineBox.bottom || !hasHandler(cm, type)) return e_defaultPrevented(e);
[3853] Fix | Delete
mY -= lineBox.top - display.viewOffset;
[3854] Fix | Delete
[3855] Fix | Delete
for (var i = 0; i < cm.options.gutters.length; ++i) {
[3856] Fix | Delete
var g = display.gutters.childNodes[i];
[3857] Fix | Delete
if (g && g.getBoundingClientRect().right >= mX) {
[3858] Fix | Delete
var line = lineAtHeight(cm.doc, mY);
[3859] Fix | Delete
var gutter = cm.options.gutters[i];
[3860] Fix | Delete
signal(cm, type, cm, line, gutter, e);
[3861] Fix | Delete
return e_defaultPrevented(e);
[3862] Fix | Delete
}
[3863] Fix | Delete
}
[3864] Fix | Delete
}
[3865] Fix | Delete
[3866] Fix | Delete
function clickInGutter(cm, e) {
[3867] Fix | Delete
return gutterEvent(cm, e, "gutterClick", true);
[3868] Fix | Delete
}
[3869] Fix | Delete
[3870] Fix | Delete
// Kludge to work around strange IE behavior where it'll sometimes
[3871] Fix | Delete
// re-fire a series of drag-related events right after the drop (#1551)
[3872] Fix | Delete
var lastDrop = 0;
[3873] Fix | Delete
[3874] Fix | Delete
function onDrop(e) {
[3875] Fix | Delete
var cm = this;
[3876] Fix | Delete
clearDragCursor(cm);
[3877] Fix | Delete
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
[3878] Fix | Delete
return;
[3879] Fix | Delete
e_preventDefault(e);
[3880] Fix | Delete
if (ie) lastDrop = +new Date;
[3881] Fix | Delete
var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
[3882] Fix | Delete
if (!pos || cm.isReadOnly()) return;
[3883] Fix | Delete
// Might be a file drop, in which case we simply extract the text
[3884] Fix | Delete
// and insert it.
[3885] Fix | Delete
if (files && files.length && window.FileReader && window.File) {
[3886] Fix | Delete
var n = files.length, text = Array(n), read = 0;
[3887] Fix | Delete
var loadFile = function(file, i) {
[3888] Fix | Delete
if (cm.options.allowDropFileTypes &&
[3889] Fix | Delete
indexOf(cm.options.allowDropFileTypes, file.type) == -1)
[3890] Fix | Delete
return;
[3891] Fix | Delete
[3892] Fix | Delete
var reader = new FileReader;
[3893] Fix | Delete
reader.onload = operation(cm, function() {
[3894] Fix | Delete
var content = reader.result;
[3895] Fix | Delete
if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) content = "";
[3896] Fix | Delete
text[i] = content;
[3897] Fix | Delete
if (++read == n) {
[3898] Fix | Delete
pos = clipPos(cm.doc, pos);
[3899] Fix | Delete
var change = {from: pos, to: pos,
[3900] Fix | Delete
text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
[3901] Fix | Delete
origin: "paste"};
[3902] Fix | Delete
makeChange(cm.doc, change);
[3903] Fix | Delete
setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
[3904] Fix | Delete
}
[3905] Fix | Delete
});
[3906] Fix | Delete
reader.readAsText(file);
[3907] Fix | Delete
};
[3908] Fix | Delete
for (var i = 0; i < n; ++i) loadFile(files[i], i);
[3909] Fix | Delete
} else { // Normal drop
[3910] Fix | Delete
// Don't do a replace if the drop happened inside of the selected text.
[3911] Fix | Delete
if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
[3912] Fix | Delete
cm.state.draggingText(e);
[3913] Fix | Delete
// Ensure the editor is re-focused
[3914] Fix | Delete
setTimeout(function() {cm.display.input.focus();}, 20);
[3915] Fix | Delete
return;
[3916] Fix | Delete
}
[3917] Fix | Delete
try {
[3918] Fix | Delete
var text = e.dataTransfer.getData("Text");
[3919] Fix | Delete
if (text) {
[3920] Fix | Delete
if (cm.state.draggingText && !cm.state.draggingText.copy)
[3921] Fix | Delete
var selected = cm.listSelections();
[3922] Fix | Delete
setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
[3923] Fix | Delete
if (selected) for (var i = 0; i < selected.length; ++i)
[3924] Fix | Delete
replaceRange(cm.doc, "", selected[i].anchor, selected[i].head, "drag");
[3925] Fix | Delete
cm.replaceSelection(text, "around", "paste");
[3926] Fix | Delete
cm.display.input.focus();
[3927] Fix | Delete
}
[3928] Fix | Delete
}
[3929] Fix | Delete
catch(e){}
[3930] Fix | Delete
}
[3931] Fix | Delete
}
[3932] Fix | Delete
[3933] Fix | Delete
function onDragStart(cm, e) {
[3934] Fix | Delete
if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return; }
[3935] Fix | Delete
if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) return;
[3936] Fix | Delete
[3937] Fix | Delete
e.dataTransfer.setData("Text", cm.getSelection());
[3938] Fix | Delete
e.dataTransfer.effectAllowed = "copyMove"
[3939] Fix | Delete
[3940] Fix | Delete
// Use dummy image instead of default browsers image.
[3941] Fix | Delete
// Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
[3942] Fix | Delete
if (e.dataTransfer.setDragImage && !safari) {
[3943] Fix | Delete
var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
[3944] Fix | Delete
img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
[3945] Fix | Delete
if (presto) {
[3946] Fix | Delete
img.width = img.height = 1;
[3947] Fix | Delete
cm.display.wrapper.appendChild(img);
[3948] Fix | Delete
// Force a relayout, or Opera won't use our image for some obscure reason
[3949] Fix | Delete
img._top = img.offsetTop;
[3950] Fix | Delete
}
[3951] Fix | Delete
e.dataTransfer.setDragImage(img, 0, 0);
[3952] Fix | Delete
if (presto) img.parentNode.removeChild(img);
[3953] Fix | Delete
}
[3954] Fix | Delete
}
[3955] Fix | Delete
[3956] Fix | Delete
function onDragOver(cm, e) {
[3957] Fix | Delete
var pos = posFromMouse(cm, e);
[3958] Fix | Delete
if (!pos) return;
[3959] Fix | Delete
var frag = document.createDocumentFragment();
[3960] Fix | Delete
drawSelectionCursor(cm, pos, frag);
[3961] Fix | Delete
if (!cm.display.dragCursor) {
[3962] Fix | Delete
cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
[3963] Fix | Delete
cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
[3964] Fix | Delete
}
[3965] Fix | Delete
removeChildrenAndAdd(cm.display.dragCursor, frag);
[3966] Fix | Delete
}
[3967] Fix | Delete
[3968] Fix | Delete
function clearDragCursor(cm) {
[3969] Fix | Delete
if (cm.display.dragCursor) {
[3970] Fix | Delete
cm.display.lineSpace.removeChild(cm.display.dragCursor);
[3971] Fix | Delete
cm.display.dragCursor = null;
[3972] Fix | Delete
}
[3973] Fix | Delete
}
[3974] Fix | Delete
[3975] Fix | Delete
// SCROLL EVENTS
[3976] Fix | Delete
[3977] Fix | Delete
// Sync the scrollable area and scrollbars, ensure the viewport
[3978] Fix | Delete
// covers the visible area.
[3979] Fix | Delete
function setScrollTop(cm, val) {
[3980] Fix | Delete
if (Math.abs(cm.doc.scrollTop - val) < 2) return;
[3981] Fix | Delete
cm.doc.scrollTop = val;
[3982] Fix | Delete
if (!gecko) updateDisplaySimple(cm, {top: val});
[3983] Fix | Delete
if (cm.display.scroller.scrollTop != val) cm.display.scroller.scrollTop = val;
[3984] Fix | Delete
cm.display.scrollbars.setScrollTop(val);
[3985] Fix | Delete
if (gecko) updateDisplaySimple(cm);
[3986] Fix | Delete
startWorker(cm, 100);
[3987] Fix | Delete
}
[3988] Fix | Delete
// Sync scroller and scrollbar, ensure the gutter elements are
[3989] Fix | Delete
// aligned.
[3990] Fix | Delete
function setScrollLeft(cm, val, isScroller) {
[3991] Fix | Delete
if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) return;
[3992] Fix | Delete
val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
[3993] Fix | Delete
cm.doc.scrollLeft = val;
[3994] Fix | Delete
alignHorizontally(cm);
[3995] Fix | Delete
if (cm.display.scroller.scrollLeft != val) cm.display.scroller.scrollLeft = val;
[3996] Fix | Delete
cm.display.scrollbars.setScrollLeft(val);
[3997] Fix | Delete
}
[3998] Fix | Delete
[3999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function