use _emit iso _dispatchEvent
This commit is contained in:
parent
02f1447e2c
commit
d2a783f824
13 changed files with 52 additions and 52 deletions
|
|
@ -155,7 +155,7 @@ var Anchor = exports.Anchor = function(doc, row, column) {
|
|||
|
||||
this.row = pos.row;
|
||||
this.column = pos.column;
|
||||
this._dispatchEvent("change", {
|
||||
this._emit("change", {
|
||||
old: old,
|
||||
value: pos
|
||||
});
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
|||
first: firstRow,
|
||||
last: lastRow
|
||||
};
|
||||
this._dispatchEvent("update", {data: data});
|
||||
this._emit("update", {data: data});
|
||||
};
|
||||
|
||||
this.start = function(startRow) {
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ var Document = function(text) {
|
|||
range: range,
|
||||
lines: lines
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
this._emit("change", { data: delta });
|
||||
return range.end;
|
||||
};
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ var Document = function(text) {
|
|||
range: Range.fromPoints(position, end),
|
||||
text: this.getNewLineCharacter()
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
this._emit("change", { data: delta });
|
||||
|
||||
return end;
|
||||
};
|
||||
|
|
@ -252,7 +252,7 @@ var Document = function(text) {
|
|||
range: Range.fromPoints(position, end),
|
||||
text: text
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
this._emit("change", { data: delta });
|
||||
|
||||
return end;
|
||||
};
|
||||
|
|
@ -304,7 +304,7 @@ var Document = function(text) {
|
|||
range: range,
|
||||
text: removed
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
this._emit("change", { data: delta });
|
||||
return range.start;
|
||||
};
|
||||
|
||||
|
|
@ -325,7 +325,7 @@ var Document = function(text) {
|
|||
nl: this.getNewLineCharacter(),
|
||||
lines: removed
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
this._emit("change", { data: delta });
|
||||
return removed;
|
||||
};
|
||||
|
||||
|
|
@ -343,7 +343,7 @@ var Document = function(text) {
|
|||
range: range,
|
||||
text: this.getNewLineCharacter()
|
||||
};
|
||||
this._dispatchEvent("change", { data: delta });
|
||||
this._emit("change", { data: delta });
|
||||
};
|
||||
|
||||
this.replace = function(range, text) {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ var EditSession = function(text, mode) {
|
|||
}
|
||||
|
||||
this.bgTokenizer.start(delta.range.start.row);
|
||||
this._dispatchEvent("change", e);
|
||||
this._emit("change", e);
|
||||
};
|
||||
|
||||
this.setValue = function(text) {
|
||||
|
|
@ -275,7 +275,7 @@ var EditSession = function(text, mode) {
|
|||
|
||||
this.$modified = true;
|
||||
this.$tabSize = tabSize;
|
||||
this._dispatchEvent("changeTabSize");
|
||||
this._emit("changeTabSize");
|
||||
};
|
||||
|
||||
this.getTabSize = function() {
|
||||
|
|
@ -291,7 +291,7 @@ var EditSession = function(text, mode) {
|
|||
if (this.$overwrite == overwrite) return;
|
||||
|
||||
this.$overwrite = overwrite;
|
||||
this._dispatchEvent("changeOverwrite");
|
||||
this._emit("changeOverwrite");
|
||||
};
|
||||
|
||||
this.getOverwrite = function() {
|
||||
|
|
@ -311,22 +311,22 @@ var EditSession = function(text, mode) {
|
|||
for (var i=0; i<rows.length; i++) {
|
||||
this.$breakpoints[rows[i]] = true;
|
||||
}
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
this._emit("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoints = function() {
|
||||
this.$breakpoints = [];
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
this._emit("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.setBreakpoint = function(row) {
|
||||
this.$breakpoints[row] = true;
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
this._emit("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.clearBreakpoint = function(row) {
|
||||
delete this.$breakpoints[row];
|
||||
this._dispatchEvent("changeBreakpoint", {});
|
||||
this._emit("changeBreakpoint", {});
|
||||
};
|
||||
|
||||
this.getBreakpoints = function() {
|
||||
|
|
@ -346,10 +346,10 @@ var EditSession = function(text, mode) {
|
|||
|
||||
if (inFront) {
|
||||
this.$frontMarkers[id] = marker;
|
||||
this._dispatchEvent("changeFrontMarker")
|
||||
this._emit("changeFrontMarker")
|
||||
} else {
|
||||
this.$backMarkers[id] = marker;
|
||||
this._dispatchEvent("changeBackMarker")
|
||||
this._emit("changeBackMarker")
|
||||
}
|
||||
|
||||
return id;
|
||||
|
|
@ -363,7 +363,7 @@ var EditSession = function(text, mode) {
|
|||
var markers = marker.inFront ? this.$frontMarkers : this.$backMarkers;
|
||||
if (marker) {
|
||||
delete (markers[markerId]);
|
||||
this._dispatchEvent(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
|
||||
this._emit(marker.inFront ? "changeFrontMarker" : "changeBackMarker");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ var EditSession = function(text, mode) {
|
|||
else
|
||||
this.$annotations[row] = [annotation];
|
||||
}
|
||||
this._dispatchEvent("changeAnnotation", {});
|
||||
this._emit("changeAnnotation", {});
|
||||
};
|
||||
|
||||
this.getAnnotations = function() {
|
||||
|
|
@ -399,7 +399,7 @@ var EditSession = function(text, mode) {
|
|||
|
||||
this.clearAnnotations = function() {
|
||||
this.$annotations = {};
|
||||
this._dispatchEvent("changeAnnotation", {});
|
||||
this._emit("changeAnnotation", {});
|
||||
};
|
||||
|
||||
this.$detectNewLine = function(text) {
|
||||
|
|
@ -480,7 +480,7 @@ var EditSession = function(text, mode) {
|
|||
this.onReloadTokenizer = function(e) {
|
||||
var rows = e.data;
|
||||
this.bgTokenizer.start(rows.first);
|
||||
this._dispatchEvent("tokenizerUpdate", e);
|
||||
this._emit("tokenizerUpdate", e);
|
||||
};
|
||||
|
||||
this.$mode = null;
|
||||
|
|
@ -504,7 +504,7 @@ var EditSession = function(text, mode) {
|
|||
this.bgTokenizer = new BackgroundTokenizer(tokenizer);
|
||||
var _self = this;
|
||||
this.bgTokenizer.addEventListener("update", function(e) {
|
||||
_self._dispatchEvent("tokenizerUpdate", e);
|
||||
_self._emit("tokenizerUpdate", e);
|
||||
});
|
||||
} else {
|
||||
this.bgTokenizer.setTokenizer(tokenizer);
|
||||
|
|
@ -518,7 +518,7 @@ var EditSession = function(text, mode) {
|
|||
|
||||
this.$setFolding(mode.foldingRules);
|
||||
|
||||
this._dispatchEvent("changeMode");
|
||||
this._emit("changeMode");
|
||||
};
|
||||
|
||||
this.$stopWorker = function() {
|
||||
|
|
@ -551,7 +551,7 @@ var EditSession = function(text, mode) {
|
|||
if (this.$scrollTop === scrollTopRow) return;
|
||||
|
||||
this.$scrollTop = scrollTopRow;
|
||||
this._dispatchEvent("changeScrollTop");
|
||||
this._emit("changeScrollTop");
|
||||
};
|
||||
|
||||
this.getScrollTopRow = function() {
|
||||
|
|
@ -920,7 +920,7 @@ var EditSession = function(text, mode) {
|
|||
this.$updateWrapData(0, len - 1);
|
||||
}
|
||||
|
||||
this._dispatchEvent("changeWrapMode");
|
||||
this._emit("changeWrapMode");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -938,7 +938,7 @@ var EditSession = function(text, mode) {
|
|||
this.$wrapLimitRange.max = max;
|
||||
this.$modified = true;
|
||||
// This will force a recalculation of the wrap limit
|
||||
this._dispatchEvent("changeWrapMode");
|
||||
this._emit("changeWrapMode");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -952,7 +952,7 @@ var EditSession = function(text, mode) {
|
|||
if (this.$useWrapMode) {
|
||||
this.$updateWrapData(0, this.getLength() - 1);
|
||||
this.$resetRowCache(0)
|
||||
this._dispatchEvent("changeWrapLimit");
|
||||
this._emit("changeWrapLimit");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ function Folding() {
|
|||
|
||||
// Notify that fold data has changed.
|
||||
this.$modified = true;
|
||||
this._dispatchEvent("changeFold", { data: fold });
|
||||
this._emit("changeFold", { data: fold });
|
||||
|
||||
return fold;
|
||||
};
|
||||
|
|
@ -400,7 +400,7 @@ function Folding() {
|
|||
|
||||
// Notify that fold data has changed.
|
||||
this.$modified = true;
|
||||
this._dispatchEvent("changeFold", { data: fold });
|
||||
this._emit("changeFold", { data: fold });
|
||||
};
|
||||
|
||||
this.removeFolds = function(folds) {
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ var Text = function(parentEl) {
|
|||
var size = this.$measureSizes();
|
||||
if (size && (this.$characterSize.width !== size.width || this.$characterSize.height !== size.height)) {
|
||||
this.$characterSize = size;
|
||||
this._dispatchEvent("changeCharaterSize", {data: size});
|
||||
this._emit("changeCharaterSize", {data: size});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ module.exports = {
|
|||
assert.equal(e.type, "juhu");
|
||||
});
|
||||
|
||||
emitter._dispatchEvent("juhu");
|
||||
emitter._emit("juhu");
|
||||
assert.ok(called);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ var MouseHandler = function(editor) {
|
|||
};
|
||||
|
||||
this.onMouseEvent = function(name, e) {
|
||||
this.editor._dispatchEvent(name, new MouseEvent(e, this.editor));
|
||||
this.editor._emit(name, new MouseEvent(e, this.editor));
|
||||
};
|
||||
|
||||
this.$dragDelay = 250;
|
||||
|
|
@ -104,7 +104,7 @@ var MouseHandler = function(editor) {
|
|||
if (!listeners || !listeners.length)
|
||||
return;
|
||||
|
||||
this.editor._dispatchEvent(name, new MouseEvent(e, this.editor));
|
||||
this.editor._emit(name, new MouseEvent(e, this.editor));
|
||||
};
|
||||
|
||||
this.onMouseWheel = function(name, e) {
|
||||
|
|
@ -113,7 +113,7 @@ var MouseHandler = function(editor) {
|
|||
mouseEvent.wheelX = e.wheelX;
|
||||
mouseEvent.wheelY = e.wheelY;
|
||||
|
||||
this.editor._dispatchEvent(name, mouseEvent);
|
||||
this.editor._emit(name, mouseEvent);
|
||||
};
|
||||
|
||||
}).call(MouseHandler.prototype);
|
||||
|
|
|
|||
|
|
@ -163,9 +163,9 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
}.bind(this), 0);
|
||||
}
|
||||
}
|
||||
this.pos._dispatchEvent("change", {value: this.pos});
|
||||
this.pos._emit("change", {value: this.pos});
|
||||
for (var i = 0; i < this.others.length; i++) {
|
||||
this.others[i]._dispatchEvent("change", {value: this.others[i]});
|
||||
this.others[i]._emit("change", {value: this.others[i]});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -174,10 +174,10 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass)
|
|||
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._dispatchEvent("cursorEnter", event);
|
||||
this._emit("cursorEnter", event);
|
||||
} else {
|
||||
this.hideOtherMarkers();
|
||||
this._dispatchEvent("cursorLeave", event);
|
||||
this._emit("cursorLeave", event);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ var ScrollBar = function(parent) {
|
|||
oop.implement(this, EventEmitter);
|
||||
|
||||
this.onScroll = function() {
|
||||
this._dispatchEvent("scroll", {data: this.element.scrollTop});
|
||||
this._emit("scroll", {data: this.element.scrollTop});
|
||||
};
|
||||
|
||||
this.getWidth = function() {
|
||||
|
|
|
|||
|
|
@ -60,16 +60,16 @@ var Selection = function(session) {
|
|||
|
||||
var _self = this;
|
||||
this.selectionLead.on("change", function(e) {
|
||||
_self._dispatchEvent("changeCursor");
|
||||
_self._emit("changeCursor");
|
||||
if (!_self.$isEmpty)
|
||||
_self._dispatchEvent("changeSelection");
|
||||
_self._emit("changeSelection");
|
||||
if (!_self.$preventUpdateDesiredColumnOnChange && e.old.column != e.value.column)
|
||||
_self.$updateDesiredColumn();
|
||||
});
|
||||
|
||||
this.selectionAnchor.on("change", function() {
|
||||
if (!_self.$isEmpty)
|
||||
_self._dispatchEvent("changeSelection");
|
||||
_self._emit("changeSelection");
|
||||
});
|
||||
};
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ var Selection = function(session) {
|
|||
|
||||
if (this.$isEmpty) {
|
||||
this.$isEmpty = false;
|
||||
this._dispatchEvent("changeSelection");
|
||||
this._emit("changeSelection");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -161,7 +161,7 @@ var Selection = function(session) {
|
|||
this.clearSelection = function() {
|
||||
if (!this.$isEmpty) {
|
||||
this.$isEmpty = true;
|
||||
this._dispatchEvent("changeSelection");
|
||||
this._emit("changeSelection");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ var require = function(parentId, id) {
|
|||
|
||||
var chunks = id.split("/");
|
||||
chunks[0] = require.tlns[chunks[0]] || chunks[0];
|
||||
path = chunks.join("/") + ".js";
|
||||
var path = chunks.join("/") + ".js";
|
||||
|
||||
require.id = id;
|
||||
importScripts(path);
|
||||
|
|
@ -64,7 +64,7 @@ var define = function(id, deps, factory) {
|
|||
|
||||
var req = function(deps, factory) {
|
||||
return require(id, deps, factory);
|
||||
}
|
||||
};
|
||||
|
||||
require.modules[id] = {
|
||||
factory: function() {
|
||||
|
|
@ -118,7 +118,7 @@ function initSender() {
|
|||
var main;
|
||||
var sender;
|
||||
|
||||
onmessage = function(e) {
|
||||
var onmessage = function(e) {
|
||||
var msg = e.data;
|
||||
if (msg.command) {
|
||||
main[msg.command].apply(main, msg.args);
|
||||
|
|
@ -131,6 +131,6 @@ onmessage = function(e) {
|
|||
main = new clazz(sender);
|
||||
}
|
||||
else if (msg.event && sender) {
|
||||
sender._dispatchEvent(msg.event, msg.data);
|
||||
sender._emit(msg.event, msg.data);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,11 +46,11 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
|
|||
|
||||
if (window.require.packaged) {
|
||||
var base = this.$guessBasePath();
|
||||
var worker = this.$worker = new Worker(base + packagedJs);
|
||||
this.$worker = new Worker(base + packagedJs);
|
||||
}
|
||||
else {
|
||||
var workerUrl = this.$normalizePath(require.nameToUrl("ace/worker/worker", null, "_"));
|
||||
var worker = this.$worker = new Worker(workerUrl);
|
||||
this.$worker = new Worker(workerUrl);
|
||||
|
||||
var tlns = {};
|
||||
for (var i=0; i<topLevelNamespaces.length; i++) {
|
||||
|
|
@ -84,7 +84,7 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
|
|||
break;
|
||||
|
||||
case "event":
|
||||
_self._dispatchEvent(msg.name, {data: msg.data});
|
||||
_self._emit(msg.name, {data: msg.data});
|
||||
break;
|
||||
|
||||
case "call":
|
||||
|
|
@ -136,7 +136,7 @@ var WorkerClient = function(topLevelNamespaces, packagedJs, module, classname) {
|
|||
};
|
||||
|
||||
this.terminate = function() {
|
||||
this._dispatchEvent("terminate", {});
|
||||
this._emit("terminate", {});
|
||||
this.$worker.terminate();
|
||||
this.$worker = null;
|
||||
this.$doc.removeEventListener("change", this.changeListener);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue