diff --git a/Editor.js b/Editor.js index 9de1afa5..3ffa7444 100644 --- a/Editor.js +++ b/Editor.js @@ -13,7 +13,7 @@ var keys = { function KeyBinding(element, host) { - addListener(element, "keydown", function(e) + lib.addListener(element, "keydown", function(e) { var key = e.keyCode; @@ -23,7 +23,7 @@ function KeyBinding(element, host) if (e.metaKey) { host.selectAll(); - return stopEvent(e); + return lib.stopEvent(e); } break; @@ -33,7 +33,7 @@ function KeyBinding(element, host) } else { host.navigateUp(); } - return stopEvent(e); + return lib.stopEvent(e); case keys.DOWN: if (e.shiftKey) { @@ -41,7 +41,7 @@ function KeyBinding(element, host) } else { host.navigateDown(); } - return stopEvent(e); + return lib.stopEvent(e); case keys.LEFT: if (e.metaKey && e.shiftKey) { @@ -53,7 +53,7 @@ function KeyBinding(element, host) } else { host.navigateLeft(); } - return stopEvent(e); + return lib.stopEvent(e); case keys.RIGHT: if (e.metaKey && e.shiftKey) { @@ -65,7 +65,7 @@ function KeyBinding(element, host) } else { host.navigateRight(); } - return stopEvent(e); + return lib.stopEvent(e); case keys.POS1: if (e.shiftKey) { @@ -73,7 +73,7 @@ function KeyBinding(element, host) } else { host.navigateLineStart(); } - return stopEvent(e); + return lib.stopEvent(e); case keys.END: if (e.shiftKey) { @@ -81,19 +81,19 @@ function KeyBinding(element, host) } else { host.navigateLineEnd(); } - return stopEvent(e); + return lib.stopEvent(e); case keys.DELETE: host.removeRight(); - return stopEvent(e); + return lib.stopEvent(e); case keys.BACKSPACE: host.removeLeft(); - return stopEvent(e); + return lib.stopEvent(e); case keys.TAB: host.onTextInput(" "); - return stopEvent(e); + return lib.stopEvent(e); } }); }; @@ -106,13 +106,13 @@ function Editor(doc, renderer) this.textInput = new TextInput(container, this); new KeyBinding(container, this); - addListener(container, "mousedown", bind(this.onMouseDown, this)); - addListener(container, "dblclick", bind(this.onMouseDoubleClick, this)); - addMouseWheelListener(container, bind(this.onMouseWheel, this)); - addTripleClickListener(container, bind(this.selectCurrentLine, this)); + lib.addListener(container, "mousedown", lib.bind(this.onMouseDown, this)); + lib.addListener(container, "dblclick", lib.bind(this.onMouseDoubleClick, this)); + lib.addMouseWheelListener(container, lib.bind(this.onMouseWheel, this)); + lib.addTripleClickListener(container, lib.bind(this.selectCurrentLine, this)); this.doc = doc; - doc.addChangeListener(bind(this.onDocumentChange, this)); + doc.addChangeListener(lib.bind(this.onDocumentChange, this)); renderer.setDocument(doc); this.cursor = { @@ -184,10 +184,10 @@ function Editor(doc, renderer) _self.renderer.scrollCursorIntoView(); }; - capture(this.container, onMouseSelection, onMouseSelectionEnd); + lib.capture(this.container, onMouseSelection, onMouseSelectionEnd); var timerId = setInterval(onSelectionInterval, 20 ); - return preventDefault(e); + return lib.preventDefault(e); }, onMouseDoubleClick : function(e) @@ -233,7 +233,7 @@ function Editor(doc, renderer) { var delta = e.wheel; this.renderer.scrollToY(this.renderer.getScrollTop() - (delta * 15)); - return preventDefault(e); + return lib.preventDefault(e); }, getCopyText : function() diff --git a/TextInput.js b/TextInput.js index c4ffb03b..73893536 100644 --- a/TextInput.js +++ b/TextInput.js @@ -51,23 +51,23 @@ function TextInput(parentNode, host) { text.select(); } - addListener(text, "keypress", onTextInput, false); - addListener(text, "textInput", onTextInput, false); - addListener(text, "paste", onTextInput, false); - addListener(text, "propertychange", onTextInput, false); + lib.addListener(text, "keypress", onTextInput, false); + lib.addListener(text, "textInput", onTextInput, false); + lib.addListener(text, "paste", onTextInput, false); + lib.addListener(text, "propertychange", onTextInput, false); - addListener(text, "copy", onCopy, false); - addListener(text, "cut", onCut, false); + lib.addListener(text, "copy", onCopy, false); + lib.addListener(text, "cut", onCut, false); - addListener(text, "compositionstart", onCompositionStart, false); - addListener(text, "compositionupdate", onCompositionUpdate, false); - addListener(text, "compositionend", onCompositionEnd, false); + lib.addListener(text, "compositionstart", onCompositionStart, false); + lib.addListener(text, "compositionupdate", onCompositionUpdate, false); + lib.addListener(text, "compositionend", onCompositionEnd, false); - addListener(text, "blur", function() { + lib.addListener(text, "blur", function() { host.onBlur(); }, false); - addListener(text, "focus", function() { + lib.addListener(text, "focus", function() { host.onFocus(); }, false); diff --git a/experiments/triple_click.html b/experiments/triple_click.html index bdc3caa7..3fa905b9 100644 --- a/experiments/triple_click.html +++ b/experiments/triple_click.html @@ -18,7 +18,7 @@