App-Mxpress-PDF
view release on metacpan or search on metacpan
public/javascripts/ace/ace.js view on Meta::CPAN
: true;
if (typeof document !== "undefined") {
var div = document.createElement("div");
if (exports.HI_DPI && div.style.transform !== undefined)
exports.HAS_CSS_TRANSFORMS = true;
if (!useragent.isEdge && typeof div.style.animationName !== "undefined")
exports.HAS_CSS_ANIMATION = true;
div = null;
}
if (exports.HAS_CSS_TRANSFORMS) {
exports.translate = function(element, tx, ty) {
element.style.transform = "translate(" + Math.round(tx) + "px, " + Math.round(ty) +"px)";
};
} else {
exports.translate = function(element, tx, ty) {
element.style.top = Math.round(ty) + "px";
element.style.left = Math.round(tx) + "px";
};
}
});
define("ace/lib/oop",["require","exports","module"], function(require, exports, module) {
"use strict";
exports.inherits = function(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
});
};
exports.mixin = function(obj, mixin) {
for (var key in mixin) {
obj[key] = mixin[key];
}
return obj;
};
exports.implement = function(proto, mixin) {
exports.mixin(proto, mixin);
};
});
define("ace/lib/keys",["require","exports","module","ace/lib/oop"], function(require, exports, module) {
"use strict";
var oop = require("./oop");
var Keys = (function() {
var ret = {
MODIFIER_KEYS: {
16: 'Shift', 17: 'Ctrl', 18: 'Alt', 224: 'Meta',
91: 'MetaLeft', 92: 'MetaRight', 93: 'ContextMenu'
},
KEY_MODS: {
"ctrl": 1, "alt": 2, "option" : 2, "shift": 4,
"super": 8, "meta": 8, "command": 8, "cmd": 8,
"control": 1
},
FUNCTION_KEYS : {
8 : "Backspace",
9 : "Tab",
13 : "Return",
19 : "Pause",
27 : "Esc",
32 : "Space",
33 : "PageUp",
34 : "PageDown",
35 : "End",
36 : "Home",
37 : "Left",
38 : "Up",
39 : "Right",
40 : "Down",
44 : "Print",
45 : "Insert",
46 : "Delete",
96 : "Numpad0",
97 : "Numpad1",
98 : "Numpad2",
99 : "Numpad3",
100: "Numpad4",
101: "Numpad5",
102: "Numpad6",
103: "Numpad7",
104: "Numpad8",
105: "Numpad9",
'-13': "NumpadEnter",
112: "F1",
113: "F2",
114: "F3",
115: "F4",
116: "F5",
117: "F6",
118: "F7",
119: "F8",
120: "F9",
121: "F10",
122: "F11",
123: "F12",
144: "Numlock",
145: "Scrolllock"
},
PRINTABLE_KEYS: {
32: ' ', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5',
54: '6', 55: '7', 56: '8', 57: '9', 59: ';', 61: '=', 65: 'a',
66: 'b', 67: 'c', 68: 'd', 69: 'e', 70: 'f', 71: 'g', 72: 'h',
73: 'i', 74: 'j', 75: 'k', 76: 'l', 77: 'm', 78: 'n', 79: 'o',
80: 'p', 81: 'q', 82: 'r', 83: 's', 84: 't', 85: 'u', 86: 'v',
87: 'w', 88: 'x', 89: 'y', 90: 'z', 107: '+', 109: '-', 110: '.',
public/javascripts/ace/ace.js view on Meta::CPAN
var t = text.parentElement;
while (t && t.nodeType == 1) {
ancestors.push(t);
t.setAttribute("ace_nocontext", true);
if (!t.parentElement && t.getRootNode)
t = t.getRootNode().host;
else
t = t.parentElement;
}
}
text.focus({ preventScroll: true });
if (isTransformed) {
ancestors.forEach(function(p) {
p.removeAttribute("ace_nocontext");
});
}
setTimeout(function() {
text.style.position = "";
if (text.style.top == "0px")
text.style.top = top;
}, 0);
};
this.blur = function() {
text.blur();
};
this.isFocused = function() {
return isFocused;
};
host.on("beforeEndOperation", function() {
if (host.curOp && host.curOp.command.name == "insertstring")
return;
if (inComposition) {
lastValue = text.value = "";
onCompositionEnd();
}
resetSelection();
});
var resetSelection = isIOS
? function(value) {
if (!isFocused || (copied && !value) || sendingText) return;
if (!value)
value = "";
var newValue = "\n ab" + value + "cde fg\n";
if (newValue != text.value)
text.value = lastValue = newValue;
var selectionStart = 4;
var selectionEnd = 4 + (value.length || (host.selection.isEmpty() ? 0 : 1));
if (lastSelectionStart != selectionStart || lastSelectionEnd != selectionEnd) {
text.setSelectionRange(selectionStart, selectionEnd);
}
lastSelectionStart = selectionStart;
lastSelectionEnd = selectionEnd;
}
: function() {
if (inComposition || sendingText)
return;
if (!isFocused && !afterContextMenu)
return;
inComposition = true;
var selection = host.selection;
var range = selection.getRange();
var row = selection.cursor.row;
var selectionStart = range.start.column;
var selectionEnd = range.end.column;
var line = host.session.getLine(row);
if (range.start.row != row) {
var prevLine = host.session.getLine(row - 1);
selectionStart = range.start.row < row - 1 ? 0 : selectionStart;
selectionEnd += prevLine.length + 1;
line = prevLine + "\n" + line;
}
else if (range.end.row != row) {
var nextLine = host.session.getLine(row + 1);
selectionEnd = range.end.row > row + 1 ? nextLine.length : selectionEnd;
selectionEnd += line.length + 1;
line = line + "\n" + nextLine;
}
else if (isMobile) {
line = "\n" + line;
selectionEnd += 1;
selectionStart += 1;
}
if (line.length > MAX_LINE_LENGTH) {
if (selectionStart < MAX_LINE_LENGTH && selectionEnd < MAX_LINE_LENGTH) {
line = line.slice(0, MAX_LINE_LENGTH);
} else {
line = "\n";
selectionStart = 0;
selectionEnd = 1;
}
}
var newValue = line + "\n\n";
if (newValue != lastValue) {
text.value = lastValue = newValue;
lastSelectionStart = lastSelectionEnd = newValue.length;
}
if (afterContextMenu) {
lastSelectionStart = text.selectionStart;
lastSelectionEnd = text.selectionEnd;
}
if (
lastSelectionEnd != selectionEnd
|| lastSelectionStart != selectionStart
|| text.selectionEnd != lastSelectionEnd // on ie edge selectionEnd changes silently after the initialization
) {
try {
text.setSelectionRange(selectionStart, selectionEnd);
lastSelectionStart = selectionStart;
lastSelectionEnd = selectionEnd;
} catch(e){}
}
inComposition = false;
};
if (isFocused)
host.onFocus();
var isAllSelected = function(text) {
return text.selectionStart === 0 && text.selectionEnd >= lastValue.length
&& text.value === lastValue && lastValue
&& text.selectionEnd !== lastSelectionEnd;
};
var onSelect = function(e) {
if (inComposition)
return;
if (copied) {
copied = false;
} else if (isAllSelected(text)) {
host.selectAll();
resetSelection();
} else if (isMobile && text.selectionStart != lastSelectionStart) {
resetSelection();
}
};
var inputHandler = null;
this.setInputHandler = function(cb) {inputHandler = cb;};
this.getInputHandler = function() {return inputHandler;};
var afterContextMenu = false;
var sendText = function(value, fromInput) {
if (afterContextMenu)
afterContextMenu = false;
if (pasted) {
resetSelection();
if (value)
host.onPaste(value);
pasted = false;
return "";
} else {
var selectionStart = text.selectionStart;
var selectionEnd = text.selectionEnd;
var extendLeft = lastSelectionStart;
var extendRight = lastValue.length - lastSelectionEnd;
var inserted = value;
var restoreStart = value.length - selectionStart;
var restoreEnd = value.length - selectionEnd;
var i = 0;
while (extendLeft > 0 && lastValue[i] == value[i]) {
i++;
extendLeft--;
}
inserted = inserted.slice(i);
i = 1;
while (extendRight > 0 && lastValue.length - i > lastSelectionStart - 1 && lastValue[lastValue.length - i] == value[value.length - i]) {
i++;
extendRight--;
}
restoreStart -= i-1;
restoreEnd -= i-1;
var endIndex = inserted.length - i + 1;
if (endIndex < 0) {
extendLeft = -endIndex;
endIndex = 0;
}
inserted = inserted.slice(0, endIndex);
if (!fromInput && !inserted && !restoreStart && !extendLeft && !extendRight && !restoreEnd)
return "";
sendingText = true;
if (inserted && !extendLeft && !extendRight && !restoreStart && !restoreEnd || commandMode) {
host.onTextInput(inserted);
} else {
host.onTextInput(inserted, {
extendLeft: extendLeft,
extendRight: extendRight,
restoreStart: restoreStart,
restoreEnd: restoreEnd
});
}
sendingText = false;
lastValue = value;
lastSelectionStart = selectionStart;
lastSelectionEnd = selectionEnd;
lastRestoreEnd = restoreEnd;
return inserted;
}
};
var onInput = function(e) {
if (inComposition)
public/javascripts/ace/ace.js view on Meta::CPAN
if (inComposition.context) {
inComposition.markerRange.start.column = inComposition.selectionStart
= inComposition.context.compositionStartOffset;
}
inComposition.markerRange.end.column = inComposition.markerRange.start.column
+ lastSelectionEnd - inComposition.selectionStart + lastRestoreEnd;
}
}
};
var onCompositionEnd = function(e) {
if (!host.onCompositionEnd || host.$readOnly) return;
inComposition = false;
host.onCompositionEnd();
host.off("mousedown", cancelComposition);
if (e) onInput();
};
function cancelComposition() {
ignoreFocusEvents = true;
text.blur();
text.focus();
ignoreFocusEvents = false;
}
var syncComposition = lang.delayedCall(onCompositionUpdate, 50).schedule.bind(null, null);
function onKeyup(e) {
if (e.keyCode == 27 && text.value.length < text.selectionStart) {
if (!inComposition)
lastValue = text.value;
lastSelectionStart = lastSelectionEnd = -1;
resetSelection();
}
syncComposition();
}
event.addListener(text, "compositionstart", onCompositionStart);
event.addListener(text, "compositionupdate", onCompositionUpdate);
event.addListener(text, "keyup", onKeyup);
event.addListener(text, "keydown", syncComposition);
event.addListener(text, "compositionend", onCompositionEnd);
this.getElement = function() {
return text;
};
this.setCommandMode = function(value) {
commandMode = value;
text.readOnly = false;
};
this.setReadOnly = function(readOnly) {
if (!commandMode)
text.readOnly = readOnly;
};
this.setCopyWithEmptySelection = function(value) {
};
this.onContextMenu = function(e) {
afterContextMenu = true;
resetSelection();
host._emit("nativecontextmenu", {target: host, domEvent: e});
this.moveToMouse(e, true);
};
this.moveToMouse = function(e, bringToFront) {
if (!tempStyle)
tempStyle = text.style.cssText;
text.style.cssText = (bringToFront ? "z-index:100000;" : "")
+ (useragent.isIE ? "opacity:0.1;" : "")
+ "text-indent: -" + (lastSelectionStart + lastSelectionEnd) * host.renderer.characterWidth * 0.5 + "px;";
var rect = host.container.getBoundingClientRect();
var style = dom.computedStyle(host.container);
var top = rect.top + (parseInt(style.borderTopWidth) || 0);
var left = rect.left + (parseInt(rect.borderLeftWidth) || 0);
var maxTop = rect.bottom - top - text.clientHeight -2;
var move = function(e) {
dom.translate(text, e.clientX - left - 2, Math.min(e.clientY - top - 2, maxTop));
};
move(e);
if (e.type != "mousedown")
return;
host.renderer.$isMousePressed = true;
clearTimeout(closeTimeout);
if (useragent.isWin)
event.capture(host.container, move, onContextMenuClose);
};
this.onContextMenuClose = onContextMenuClose;
var closeTimeout;
function onContextMenuClose() {
clearTimeout(closeTimeout);
closeTimeout = setTimeout(function () {
if (tempStyle) {
text.style.cssText = tempStyle;
tempStyle = '';
}
host.renderer.$isMousePressed = false;
if (host.renderer.$keepTextAreaAtCursor)
host.renderer.$moveTextAreaToCursor();
}, 0);
}
var onContextMenu = function(e) {
host.textInput.onContextMenu(e);
onContextMenuClose();
};
event.addListener(text, "mouseup", onContextMenu);
event.addListener(text, "mousedown", function(e) {
e.preventDefault();
onContextMenuClose();
});
event.addListener(host.renderer.scroller, "contextmenu", onContextMenu);
event.addListener(text, "contextmenu", onContextMenu);
if (isIOS)
addIosSelectionHandler(parentNode, host, text);
function addIosSelectionHandler(parentNode, host, text) {
var typingResetTimeout = null;
var typing = false;
text.addEventListener("keydown", function (e) {
if (typingResetTimeout) clearTimeout(typingResetTimeout);
typing = true;
}, true);
text.addEventListener("keyup", function (e) {
typingResetTimeout = setTimeout(function () {
typing = false;
}, 100);
}, true);
var detectArrowKeys = function(e) {
if (document.activeElement !== text) return;
if (typing || inComposition || host.$mouseHandler.isMousePressed) return;
if (copied) {
return;
}
var selectionStart = text.selectionStart;
var selectionEnd = text.selectionEnd;
var key = null;
var modifier = 0;
if (selectionStart == 0) {
key = KEYS.up;
} else if (selectionStart == 1) {
key = KEYS.home;
} else if (selectionEnd > lastSelectionEnd && lastValue[selectionEnd] == "\n") {
key = KEYS.end;
} else if (selectionStart < lastSelectionStart && lastValue[selectionStart - 1] == " ") {
key = KEYS.left;
modifier = MODS.option;
} else if (
selectionStart < lastSelectionStart
|| (
selectionStart == lastSelectionStart
&& lastSelectionEnd != lastSelectionStart
&& selectionStart == selectionEnd
)
) {
key = KEYS.left;
} else if (selectionEnd > lastSelectionEnd && lastValue.slice(0, selectionEnd).split("\n").length > 2) {
key = KEYS.down;
} else if (selectionEnd > lastSelectionEnd && lastValue[selectionEnd - 1] == " ") {
key = KEYS.right;
modifier = MODS.option;
} else if (
selectionEnd > lastSelectionEnd
|| (
selectionEnd == lastSelectionEnd
&& lastSelectionEnd != lastSelectionStart
&& selectionStart == selectionEnd
)
public/javascripts/ace/ace.js view on Meta::CPAN
lastSelectionStart = selectionStart;
lastSelectionEnd = selectionEnd;
resetSelection("");
}
};
document.addEventListener("selectionchange", detectArrowKeys);
host.on("destroy", function() {
document.removeEventListener("selectionchange", detectArrowKeys);
});
}
};
exports.TextInput = TextInput;
});
define("ace/mouse/default_handlers",["require","exports","module","ace/lib/useragent"], function(require, exports, module) {
"use strict";
var useragent = require("../lib/useragent");
var DRAG_OFFSET = 0; // pixels
var SCROLL_COOLDOWN_T = 550; // milliseconds
function DefaultHandlers(mouseHandler) {
mouseHandler.$clickSelection = null;
var editor = mouseHandler.editor;
editor.setDefaultHandler("mousedown", this.onMouseDown.bind(mouseHandler));
editor.setDefaultHandler("dblclick", this.onDoubleClick.bind(mouseHandler));
editor.setDefaultHandler("tripleclick", this.onTripleClick.bind(mouseHandler));
editor.setDefaultHandler("quadclick", this.onQuadClick.bind(mouseHandler));
editor.setDefaultHandler("mousewheel", this.onMouseWheel.bind(mouseHandler));
var exports = ["select", "startSelect", "selectEnd", "selectAllEnd", "selectByWordsEnd",
"selectByLinesEnd", "dragWait", "dragWaitEnd", "focusWait"];
exports.forEach(function(x) {
mouseHandler[x] = this[x];
}, this);
mouseHandler.selectByLines = this.extendSelectionBy.bind(mouseHandler, "getLineRange");
mouseHandler.selectByWords = this.extendSelectionBy.bind(mouseHandler, "getWordRange");
}
(function() {
this.onMouseDown = function(ev) {
var inSelection = ev.inSelection();
var pos = ev.getDocumentPosition();
this.mousedownEvent = ev;
var editor = this.editor;
var button = ev.getButton();
if (button !== 0) {
var selectionRange = editor.getSelectionRange();
var selectionEmpty = selectionRange.isEmpty();
if (selectionEmpty || button == 1)
editor.selection.moveToPosition(pos);
if (button == 2) {
editor.textInput.onContextMenu(ev.domEvent);
if (!useragent.isMozilla)
ev.preventDefault();
}
return;
}
this.mousedownEvent.time = Date.now();
if (inSelection && !editor.isFocused()) {
editor.focus();
if (this.$focusTimeout && !this.$clickSelection && !editor.inMultiSelectMode) {
this.setState("focusWait");
this.captureMouse(ev);
return;
}
}
this.captureMouse(ev);
this.startSelect(pos, ev.domEvent._clicks > 1);
return ev.preventDefault();
};
this.startSelect = function(pos, waitForClickSelection) {
pos = pos || this.editor.renderer.screenToTextCoordinates(this.x, this.y);
var editor = this.editor;
if (!this.mousedownEvent) return;
if (this.mousedownEvent.getShiftKey())
editor.selection.selectToPosition(pos);
else if (!waitForClickSelection)
editor.selection.moveToPosition(pos);
if (!waitForClickSelection)
this.select();
if (editor.renderer.scroller.setCapture) {
editor.renderer.scroller.setCapture();
}
editor.setStyle("ace_selecting");
this.setState("select");
};
this.select = function() {
var anchor, editor = this.editor;
var cursor = editor.renderer.screenToTextCoordinates(this.x, this.y);
if (this.$clickSelection) {
var cmp = this.$clickSelection.comparePoint(cursor);
if (cmp == -1) {
anchor = this.$clickSelection.end;
} else if (cmp == 1) {
anchor = this.$clickSelection.start;
} else {
var orientedRange = calcRangeOrientation(this.$clickSelection, cursor);
cursor = orientedRange.cursor;
anchor = orientedRange.anchor;
}
editor.selection.setSelectionAnchor(anchor.row, anchor.column);
}
editor.selection.selectToPosition(cursor);
editor.renderer.scrollCursorIntoView();
};
this.extendSelectionBy = function(unitName) {
public/javascripts/ace/ace.js view on Meta::CPAN
this.mousedownEvent = e;
var editor = this.editor;
var inSelection = e.inSelection();
var button = e.getButton();
var clickCount = e.domEvent.detail || 1;
if (clickCount === 1 && button === 0 && inSelection) {
if (e.editor.inMultiSelectMode && (e.getAccelKey() || e.getShiftKey()))
return;
this.mousedownEvent.time = Date.now();
var eventTarget = e.domEvent.target || e.domEvent.srcElement;
if ("unselectable" in eventTarget)
eventTarget.unselectable = "on";
if (editor.getDragDelay()) {
if (useragent.isWebKit) {
this.cancelDrag = true;
var mouseTarget = editor.container;
mouseTarget.draggable = true;
}
this.setState("dragWait");
} else {
this.startDrag();
}
this.captureMouse(e, this.onMouseDrag.bind(this));
e.defaultPrevented = true;
}
};
}).call(DragdropHandler.prototype);
function calcDistance(ax, ay, bx, by) {
return Math.sqrt(Math.pow(bx - ax, 2) + Math.pow(by - ay, 2));
}
exports.DragdropHandler = DragdropHandler;
});
define("ace/mouse/touch_handler",["require","exports","module","ace/mouse/mouse_event","ace/lib/event","ace/lib/dom"], function(require, exports, module) {
"use strict";
var MouseEvent = require("./mouse_event").MouseEvent;
var event = require("../lib/event");
var dom = require("../lib/dom");
exports.addTouchListeners = function(el, editor) {
var mode = "scroll";
var startX;
var startY;
var touchStartT;
var lastT;
var longTouchTimer;
var animationTimer;
var animationSteps = 0;
var pos;
var clickCount = 0;
var vX = 0;
var vY = 0;
var pressed;
var contextMenu;
function createContextMenu() {
var clipboard = window.navigator && window.navigator.clipboard;
var isOpen = false;
var updateMenu = function() {
var selected = editor.getCopyText();
var hasUndo = editor.session.getUndoManager().hasUndo();
contextMenu.replaceChild(
dom.buildDom(isOpen ? ["span",
!selected && ["span", { class: "ace_mobile-button", action: "selectall" }, "Select All"],
selected && ["span", { class: "ace_mobile-button", action: "copy" }, "Copy"],
selected && ["span", { class: "ace_mobile-button", action: "cut" }, "Cut"],
clipboard && ["span", { class: "ace_mobile-button", action: "paste" }, "Paste"],
hasUndo && ["span", { class: "ace_mobile-button", action: "undo" }, "Undo"],
["span", { class: "ace_mobile-button", action: "find" }, "Find"],
["span", { class: "ace_mobile-button", action: "openCommandPallete" }, "Pallete"]
] : ["span"]),
contextMenu.firstChild
);
};
var handleClick = function(e) {
var action = e.target.getAttribute("action");
if (action == "more" || !isOpen) {
isOpen = !isOpen;
return updateMenu();
}
if (action == "paste") {
clipboard.readText().then(function (text) {
editor.execCommand(action, text);
});
}
else if (action) {
if (action == "cut" || action == "copy") {
if (clipboard)
clipboard.writeText(editor.getCopyText());
else
document.execCommand("copy");
}
editor.execCommand(action);
}
contextMenu.firstChild.style.display = "none";
isOpen = false;
if (action != "openCommandPallete")
editor.focus();
};
contextMenu = dom.buildDom(["div",
{
class: "ace_mobile-menu",
ontouchstart: function(e) {
mode = "menu";
e.stopPropagation();
e.preventDefault();
editor.textInput.focus();
},
ontouchend: function(e) {
e.stopPropagation();
e.preventDefault();
handleClick(e);
},
onclick: handleClick
},
["span"],
["span", { class: "ace_mobile-button", action: "more" }, "..."]
], editor.container);
}
function showContextMenu() {
if (!contextMenu) createContextMenu();
var cursor = editor.selection.cursor;
var pagePos = editor.renderer.textToScreenCoordinates(cursor.row, cursor.column);
var rect = editor.container.getBoundingClientRect();
contextMenu.style.top = pagePos.pageY - rect.top - 3 + "px";
contextMenu.style.right = "10px";
contextMenu.style.display = "";
contextMenu.firstChild.style.display = "none";
editor.on("input", hideContextMenu);
}
function hideContextMenu(e) {
if (contextMenu)
contextMenu.style.display = "none";
editor.off("input", hideContextMenu);
}
function handleLongTap() {
longTouchTimer = null;
clearTimeout(longTouchTimer);
var range = editor.selection.getRange();
var inSelection = range.contains(pos.row, pos.column);
if (range.isEmpty() || !inSelection) {
editor.selection.moveToPosition(pos);
editor.selection.selectWord();
}
mode = "wait";
showContextMenu();
}
function switchToSelectionMode() {
longTouchTimer = null;
clearTimeout(longTouchTimer);
editor.selection.moveToPosition(pos);
var range = clickCount >= 2
? editor.selection.getLineRange(pos.row)
: editor.session.getBracketRange(pos);
if (range && !range.isEmpty()) {
editor.selection.setRange(range);
} else {
editor.selection.selectWord();
}
mode = "wait";
}
event.addListener(el, "contextmenu", function(e) {
if (!pressed) return;
var textarea = editor.textInput.getElement();
textarea.focus();
});
event.addListener(el, "touchstart", function (e) {
var touches = e.touches;
if (longTouchTimer || touches.length > 1) {
clearTimeout(longTouchTimer);
longTouchTimer = null;
touchStartT = -1;
mode = "zoom";
return;
}
pressed = editor.$mouseHandler.isMousePressed = true;
var h = editor.renderer.layerConfig.lineHeight;
var w = editor.renderer.layerConfig.lineHeight;
var t = e.timeStamp;
lastT = t;
var touchObj = touches[0];
var x = touchObj.clientX;
var y = touchObj.clientY;
if (Math.abs(startX - x) + Math.abs(startY - y) > h)
touchStartT = -1;
startX = e.clientX = x;
startY = e.clientY = y;
vX = vY = 0;
var ev = new MouseEvent(e, editor);
pos = ev.getDocumentPosition();
if (t - touchStartT < 500 && touches.length == 1 && !animationSteps) {
clickCount++;
e.preventDefault();
e.button = 0;
switchToSelectionMode();
} else {
clickCount = 0;
var cursor = editor.selection.cursor;
var anchor = editor.selection.isEmpty() ? cursor : editor.selection.anchor;
var cursorPos = editor.renderer.$cursorLayer.getPixelPosition(cursor, true);
var anchorPos = editor.renderer.$cursorLayer.getPixelPosition(anchor, true);
var rect = editor.renderer.scroller.getBoundingClientRect();
var weightedDistance = function(x, y) {
x = x / w;
y = y / h - 0.75;
return x * x + y * y;
};
if (e.clientX < rect.left) {
mode = "zoom";
return;
}
var diff1 = weightedDistance(
e.clientX - rect.left - cursorPos.left,
e.clientY - rect.top - cursorPos.top
);
var diff2 = weightedDistance(
e.clientX - rect.left - anchorPos.left,
e.clientY - rect.top - anchorPos.top
);
if (diff1 < 3.5 && diff2 < 3.5)
mode = diff1 > diff2 ? "cursor" : "anchor";
if (diff2 < 3.5)
mode = "anchor";
else if (diff1 < 3.5)
mode = "cursor";
else
mode = "scroll";
longTouchTimer = setTimeout(handleLongTap, 450);
}
touchStartT = t;
});
event.addListener(el, "touchend", function (e) {
pressed = editor.$mouseHandler.isMousePressed = false;
if (animationTimer) clearInterval(animationTimer);
if (mode == "zoom") {
mode = "";
animationSteps = 0;
} else if (longTouchTimer) {
editor.selection.moveToPosition(pos);
animationSteps = 0;
showContextMenu();
} else if (mode == "scroll") {
animate();
hideContextMenu();
} else {
showContextMenu();
}
clearTimeout(longTouchTimer);
longTouchTimer = null;
});
event.addListener(el, "touchmove", function (e) {
if (longTouchTimer) {
clearTimeout(longTouchTimer);
longTouchTimer = null;
}
var touches = e.touches;
if (touches.length > 1 || mode == "zoom") return;
var touchObj = touches[0];
var wheelX = startX - touchObj.clientX;
var wheelY = startY - touchObj.clientY;
if (mode == "wait") {
if (wheelX * wheelX + wheelY * wheelY > 4)
mode = "cursor";
else
return e.preventDefault();
}
startX = touchObj.clientX;
startY = touchObj.clientY;
e.clientX = touchObj.clientX;
e.clientY = touchObj.clientY;
var t = e.timeStamp;
var dt = t - lastT;
lastT = t;
if (mode == "scroll") {
var mouseEvent = new MouseEvent(e, editor);
mouseEvent.speed = 1;
mouseEvent.wheelX = wheelX;
mouseEvent.wheelY = wheelY;
if (10 * Math.abs(wheelX) < Math.abs(wheelY)) wheelX = 0;
if (10 * Math.abs(wheelY) < Math.abs(wheelX)) wheelY = 0;
if (dt != 0) {
vX = wheelX / dt;
vY = wheelY / dt;
}
editor._emit("mousewheel", mouseEvent);
if (!mouseEvent.propagationStopped) {
vX = vY = 0;
}
}
else {
var ev = new MouseEvent(e, editor);
var pos = ev.getDocumentPosition();
if (mode == "cursor")
editor.selection.moveCursorToPosition(pos);
else if (mode == "anchor")
editor.selection.setSelectionAnchor(pos.row, pos.column);
editor.renderer.scrollCursorIntoView(pos);
e.preventDefault();
}
});
public/javascripts/ace/ace.js view on Meta::CPAN
this.y = ev.y;
this.isMousePressed = true;
var editor = this.editor;
var renderer = this.editor.renderer;
renderer.$isMousePressed = true;
var self = this;
var onMouseMove = function(e) {
if (!e) return;
if (useragent.isWebKit && !e.which && self.releaseMouse)
return self.releaseMouse();
self.x = e.clientX;
self.y = e.clientY;
mouseMoveHandler && mouseMoveHandler(e);
self.mouseEvent = new MouseEvent(e, self.editor);
self.$mouseMoved = true;
};
var onCaptureEnd = function(e) {
editor.off("beforeEndOperation", onOperationEnd);
clearInterval(timerId);
onCaptureInterval();
self[self.state + "End"] && self[self.state + "End"](e);
self.state = "";
self.isMousePressed = renderer.$isMousePressed = false;
if (renderer.$keepTextAreaAtCursor)
renderer.$moveTextAreaToCursor();
self.$onCaptureMouseMove = self.releaseMouse = null;
e && self.onMouseEvent("mouseup", e);
editor.endOperation();
};
var onCaptureInterval = function() {
self[self.state] && self[self.state]();
self.$mouseMoved = false;
};
if (useragent.isOldIE && ev.domEvent.type == "dblclick") {
return setTimeout(function() {onCaptureEnd(ev);});
}
var onOperationEnd = function(e) {
if (!self.releaseMouse) return;
if (editor.curOp.command.name && editor.curOp.selectionChanged) {
self[self.state + "End"] && self[self.state + "End"]();
self.state = "";
self.releaseMouse();
}
};
editor.on("beforeEndOperation", onOperationEnd);
editor.startOperation({command: {name: "mouse"}});
self.$onCaptureMouseMove = onMouseMove;
self.releaseMouse = event.capture(this.editor.container, onMouseMove, onCaptureEnd);
var timerId = setInterval(onCaptureInterval, 20);
};
this.releaseMouse = null;
this.cancelContextMenu = function() {
var stop = function(e) {
if (e && e.domEvent && e.domEvent.type != "contextmenu")
return;
this.editor.off("nativecontextmenu", stop);
if (e && e.domEvent)
event.stopEvent(e.domEvent);
}.bind(this);
setTimeout(stop, 10);
this.editor.on("nativecontextmenu", stop);
};
}).call(MouseHandler.prototype);
config.defineOptions(MouseHandler.prototype, "mouseHandler", {
scrollSpeed: {initialValue: 2},
dragDelay: {initialValue: (useragent.isMac ? 150 : 0)},
dragEnabled: {initialValue: true},
focusTimeout: {initialValue: 0},
tooltipFollowsMouse: {initialValue: true}
});
exports.MouseHandler = MouseHandler;
});
define("ace/mouse/fold_handler",["require","exports","module","ace/lib/dom"], function(require, exports, module) {
"use strict";
var dom = require("../lib/dom");
function FoldHandler(editor) {
editor.on("click", function(e) {
var position = e.getDocumentPosition();
var session = editor.session;
var fold = session.getFoldAt(position.row, position.column, 1);
if (fold) {
if (e.getAccelKey())
session.removeFold(fold);
else
session.expandFold(fold);
e.stop();
}
var target = e.domEvent && e.domEvent.target;
if (target && dom.hasCssClass(target, "ace_inline_button")) {
if (dom.hasCssClass(target, "ace_toggle_wrap")) {
session.setOption("wrap", !session.getUseWrapMode());
editor.renderer.scrollCursorIntoView();
}
}
});
editor.on("gutterclick", function(e) {
var gutterRegion = editor.renderer.$gutterLayer.getRegion(e);
if (gutterRegion == "foldWidgets") {
var row = e.getDocumentPosition().row;
var session = editor.session;
if (session.foldWidgets && session.foldWidgets[row])
editor.session.onFoldWidgetClick(row, e);
public/javascripts/ace/ace.js view on Meta::CPAN
}
if (!this.$addCommandToMacro) {
this.$addCommandToMacro = function(e) {
this.macro.push([e.command, e.args]);
}.bind(this);
}
this.oldMacro = this.macro;
this.macro = [];
this.on("exec", this.$addCommandToMacro);
return this.recording = true;
};
this.replay = function(editor) {
if (this.$inReplay || !this.macro)
return;
if (this.recording)
return this.toggleRecording(editor);
try {
this.$inReplay = true;
this.macro.forEach(function(x) {
if (typeof x == "string")
this.exec(x, editor);
else
this.exec(x[0], editor, x[1]);
}, this);
} finally {
this.$inReplay = false;
}
};
this.trimMacro = function(m) {
return m.map(function(x){
if (typeof x[0] != "string")
x[0] = x[0].name;
if (!x[1])
x = x[0];
return x;
});
};
}).call(CommandManager.prototype);
exports.CommandManager = CommandManager;
});
define("ace/commands/default_commands",["require","exports","module","ace/lib/lang","ace/config","ace/range"], function(require, exports, module) {
"use strict";
var lang = require("../lib/lang");
var config = require("../config");
var Range = require("../range").Range;
function bindKey(win, mac) {
return {win: win, mac: mac};
}
exports.commands = [{
name: "showSettingsMenu",
bindKey: bindKey("Ctrl-,", "Command-,"),
exec: function(editor) {
config.loadModule("ace/ext/settings_menu", function(module) {
module.init(editor);
editor.showSettingsMenu();
});
},
readOnly: true
}, {
name: "goToNextError",
bindKey: bindKey("Alt-E", "F4"),
exec: function(editor) {
config.loadModule("./ext/error_marker", function(module) {
module.showErrorMarker(editor, 1);
});
},
scrollIntoView: "animate",
readOnly: true
}, {
name: "goToPreviousError",
bindKey: bindKey("Alt-Shift-E", "Shift-F4"),
exec: function(editor) {
config.loadModule("./ext/error_marker", function(module) {
module.showErrorMarker(editor, -1);
});
},
scrollIntoView: "animate",
readOnly: true
}, {
name: "selectall",
description: "Select all",
bindKey: bindKey("Ctrl-A", "Command-A"),
exec: function(editor) { editor.selectAll(); },
readOnly: true
}, {
name: "centerselection",
description: "Center selection",
bindKey: bindKey(null, "Ctrl-L"),
exec: function(editor) { editor.centerSelection(); },
readOnly: true
}, {
name: "gotoline",
description: "Go to line...",
bindKey: bindKey("Ctrl-L", "Command-L"),
exec: function(editor, line) {
if (typeof line === "number" && !isNaN(line))
editor.gotoLine(line);
editor.prompt({ $type: "gotoLine" });
},
readOnly: true
}, {
name: "fold",
bindKey: bindKey("Alt-L|Ctrl-F1", "Command-Alt-L|Command-F1"),
exec: function(editor) { editor.session.toggleFold(false); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
name: "unfold",
bindKey: bindKey("Alt-Shift-L|Ctrl-Shift-F1", "Command-Alt-Shift-L|Command-Shift-F1"),
exec: function(editor) { editor.session.toggleFold(true); },
multiSelectAction: "forEach",
scrollIntoView: "center",
readOnly: true
}, {
public/javascripts/ace/ace.js view on Meta::CPAN
for (var i = this.others.length; i--;)
updateMarker(this.others[i], this.othersClass);
};
this.onCursorChange = function(event) {
if (this.$updating || !this.session) return;
var pos = this.session.selection.getCursor();
if (pos.row === this.pos.row && pos.column >= this.pos.column && pos.column <= this.pos.column + this.length) {
this.showOtherMarkers();
this._emit("cursorEnter", event);
} else {
this.hideOtherMarkers();
this._emit("cursorLeave", event);
}
};
this.detach = function() {
this.session.removeMarker(this.pos && this.pos.markerId);
this.hideOtherMarkers();
this.doc.removeEventListener("change", this.$onUpdate);
this.session.selection.removeEventListener("changeCursor", this.$onCursorChange);
this.session.setUndoSelect(true);
this.session = null;
};
this.cancel = function() {
if (this.$undoStackDepth === -1)
return;
var undoManager = this.session.getUndoManager();
var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth;
for (var i = 0; i < undosRequired; i++) {
undoManager.undo(this.session, true);
}
if (this.selectionBefore)
this.session.selection.fromJSON(this.selectionBefore);
};
}).call(PlaceHolder.prototype);
exports.PlaceHolder = PlaceHolder;
});
define("ace/mouse/multi_select_handler",["require","exports","module","ace/lib/event","ace/lib/useragent"], function(require, exports, module) {
var event = require("../lib/event");
var useragent = require("../lib/useragent");
function isSamePoint(p1, p2) {
return p1.row == p2.row && p1.column == p2.column;
}
function onMouseDown(e) {
var ev = e.domEvent;
var alt = ev.altKey;
var shift = ev.shiftKey;
var ctrl = ev.ctrlKey;
var accel = e.getAccelKey();
var button = e.getButton();
if (ctrl && useragent.isMac)
button = ev.button;
if (e.editor.inMultiSelectMode && button == 2) {
e.editor.textInput.onContextMenu(e.domEvent);
return;
}
if (!ctrl && !alt && !accel) {
if (button === 0 && e.editor.inMultiSelectMode)
e.editor.exitMultiSelectMode();
return;
}
if (button !== 0)
return;
var editor = e.editor;
var selection = editor.selection;
var isMultiSelect = editor.inMultiSelectMode;
var pos = e.getDocumentPosition();
var cursor = selection.getCursor();
var inSelection = e.inSelection() || (selection.isEmpty() && isSamePoint(pos, cursor));
var mouseX = e.x, mouseY = e.y;
var onMouseSelection = function(e) {
mouseX = e.clientX;
mouseY = e.clientY;
};
var session = editor.session;
var screenAnchor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
var screenCursor = screenAnchor;
var selectionMode;
if (editor.$mouseHandler.$enableJumpToDef) {
if (ctrl && alt || accel && alt)
selectionMode = shift ? "block" : "add";
else if (alt && editor.$blockSelectEnabled)
selectionMode = "block";
} else {
if (accel && !alt) {
selectionMode = "add";
if (!isMultiSelect && shift)
return;
} else if (alt && editor.$blockSelectEnabled) {
selectionMode = "block";
}
}
if (selectionMode && useragent.isMac && ev.ctrlKey) {
editor.$mouseHandler.cancelContextMenu();
}
if (selectionMode == "add") {
if (!isMultiSelect && inSelection)
return; // dragging
if (!isMultiSelect) {
var range = selection.toOrientedRange();
editor.addSelectionMarker(range);
}
var oldRange = selection.rangeList.rangeAtPoint(pos);
editor.inVirtualSelectionMode = true;
if (shift) {
oldRange = null;
range = selection.ranges[0] || range;
editor.removeSelectionMarker(range);
}
editor.once("mouseup", function() {
var tmpSel = selection.toOrientedRange();
if (oldRange && tmpSel.isEmpty() && isSamePoint(oldRange.cursor, tmpSel.cursor))
selection.substractPoint(tmpSel.cursor);
else {
if (shift) {
selection.substractPoint(range.cursor);
} else if (range) {
editor.removeSelectionMarker(range);
selection.addRange(range);
}
selection.addRange(tmpSel);
}
editor.inVirtualSelectionMode = false;
});
} else if (selectionMode == "block") {
e.stop();
editor.inVirtualSelectionMode = true;
var initialRange;
var rectSel = [];
var blockSelect = function() {
var newCursor = editor.renderer.pixelToScreenCoordinates(mouseX, mouseY);
var cursor = session.screenToDocumentPosition(newCursor.row, newCursor.column, newCursor.offsetX);
if (isSamePoint(screenCursor, newCursor) && isSamePoint(cursor, selection.lead))
return;
screenCursor = newCursor;
editor.selection.moveToPosition(cursor);
editor.renderer.scrollCursorIntoView();
editor.removeSelectionMarkers(rectSel);
rectSel = selection.rectangularRangeBlock(screenCursor, screenAnchor);
if (editor.$mouseHandler.$clickSelection && rectSel.length == 1 && rectSel[0].isEmpty())
rectSel[0] = editor.$mouseHandler.$clickSelection.clone();
rectSel.forEach(editor.addSelectionMarker, editor);
editor.updateSelectionMarkers();
};
( run in 0.729 second using v1.01-cache-2.11-cpan-39bf76dae61 )