remove $ function and property from EventEmitter
This commit is contained in:
parent
7974ef5a71
commit
10843ba7e6
11 changed files with 60 additions and 59 deletions
|
|
@ -103,7 +103,7 @@ var BackgroundTokenizer = function(tokenizer, editor) {
|
||||||
first: firstRow,
|
first: firstRow,
|
||||||
last: lastRow
|
last: lastRow
|
||||||
};
|
};
|
||||||
this.$dispatchEvent("update", {data: data});
|
this._dispatchEvent("update", {data: data});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.start = function(startRow) {
|
this.start = function(startRow) {
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ var Document = function(text, mode) {
|
||||||
firstRow: firstRow,
|
firstRow: firstRow,
|
||||||
lastRow: lastRow
|
lastRow: lastRow
|
||||||
};
|
};
|
||||||
this.$dispatchEvent("change", { data: data});
|
this._dispatchEvent("change", { data: data});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setUndoManager = function(undoManager) {
|
this.setUndoManager = function(undoManager) {
|
||||||
|
|
@ -153,7 +153,7 @@ var Document = function(text, mode) {
|
||||||
|
|
||||||
this.modified = true;
|
this.modified = true;
|
||||||
this.$tabSize = tabSize;
|
this.$tabSize = tabSize;
|
||||||
this.$dispatchEvent("changeTabSize");
|
this._dispatchEvent("changeTabSize");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getTabSize = function() {
|
this.getTabSize = function() {
|
||||||
|
|
@ -169,22 +169,22 @@ var Document = function(text, mode) {
|
||||||
for (var i=0; i<rows.length; i++) {
|
for (var i=0; i<rows.length; i++) {
|
||||||
this.$breakpoints[rows[i]] = true;
|
this.$breakpoints[rows[i]] = true;
|
||||||
}
|
}
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.clearBreakpoints = function() {
|
this.clearBreakpoints = function() {
|
||||||
this.$breakpoints = [];
|
this.$breakpoints = [];
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setBreakpoint = function(row) {
|
this.setBreakpoint = function(row) {
|
||||||
this.$breakpoints[row] = true;
|
this.$breakpoints[row] = true;
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.clearBreakpoint = function(row) {
|
this.clearBreakpoint = function(row) {
|
||||||
delete this.$breakpoints[row];
|
delete this.$breakpoints[row];
|
||||||
this.$dispatchEvent("changeBreakpoint", {});
|
this._dispatchEvent("changeBreakpoint", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.$detectNewLine = function(text) {
|
this.$detectNewLine = function(text) {
|
||||||
|
|
@ -260,7 +260,7 @@ var Document = function(text, mode) {
|
||||||
if (this.$mode === mode) return;
|
if (this.$mode === mode) return;
|
||||||
|
|
||||||
this.$mode = mode;
|
this.$mode = mode;
|
||||||
this.$dispatchEvent("changeMode");
|
this._dispatchEvent("changeMode");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getMode = function() {
|
this.getMode = function() {
|
||||||
|
|
@ -275,7 +275,7 @@ var Document = function(text, mode) {
|
||||||
if (this.$scrollTop === scrollTopRow) return;
|
if (this.$scrollTop === scrollTopRow) return;
|
||||||
|
|
||||||
this.$scrollTop = scrollTopRow;
|
this.$scrollTop = scrollTopRow;
|
||||||
this.$dispatchEvent("changeScrollTop");
|
this._dispatchEvent("changeScrollTop");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getScrollTopRow = function() {
|
this.getScrollTopRow = function() {
|
||||||
|
|
|
||||||
|
|
@ -493,7 +493,7 @@ var Editor =function(renderer, doc) {
|
||||||
this.onCursorChange();
|
this.onCursorChange();
|
||||||
this.$blockScrolling = false;
|
this.$blockScrolling = false;
|
||||||
|
|
||||||
this.$dispatchEvent("changeOverwrite", {data: overwrite});
|
this._dispatchEvent("changeOverwrite", {data: overwrite});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getOverwrite = function() {
|
this.getOverwrite = function() {
|
||||||
|
|
@ -520,7 +520,7 @@ var Editor =function(renderer, doc) {
|
||||||
|
|
||||||
this.$selectionStyle = style;
|
this.$selectionStyle = style;
|
||||||
this.onSelectionChange();
|
this.onSelectionChange();
|
||||||
this.$dispatchEvent("changeSelectionStyle", {data: style});
|
this._dispatchEvent("changeSelectionStyle", {data: style});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ var Text = function(parentEl) {
|
||||||
var size = self.$measureSizes();
|
var size = self.$measureSizes();
|
||||||
if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) {
|
if (self.$characterSize.width !== size.width || self.$characterSize.height !== size.height) {
|
||||||
self.$characterSize = size;
|
self.$characterSize = size;
|
||||||
self.$dispatchEvent("changeCharaterSize", {data: size});
|
self._dispatchEvent("changeCharaterSize", {data: size});
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ var ScrollBar = function(parent) {
|
||||||
oop.implement(this, EventEmitter);
|
oop.implement(this, EventEmitter);
|
||||||
|
|
||||||
this.onScroll = function() {
|
this.onScroll = function() {
|
||||||
this.$dispatchEvent("scroll", {data: this.element.scrollTop});
|
this._dispatchEvent("scroll", {data: this.element.scrollTop});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getWidth = function() {
|
this.getWidth = function() {
|
||||||
|
|
|
||||||
|
|
@ -79,11 +79,11 @@ var Selection = function(doc) {
|
||||||
|
|
||||||
if (!this.selectionAnchor) {
|
if (!this.selectionAnchor) {
|
||||||
this.selectionAnchor = anchor;
|
this.selectionAnchor = anchor;
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
}
|
}
|
||||||
else if (this.selectionAnchor.row !== anchor.row || this.selectionAnchor.column !== anchor.column) {
|
else if (this.selectionAnchor.row !== anchor.row || this.selectionAnchor.column !== anchor.column) {
|
||||||
this.selectionAnchor = anchor;
|
this.selectionAnchor = anchor;
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
@ -142,7 +142,7 @@ var Selection = function(doc) {
|
||||||
this.clearSelection = function() {
|
this.clearSelection = function() {
|
||||||
if (this.selectionAnchor) {
|
if (this.selectionAnchor) {
|
||||||
this.selectionAnchor = null;
|
this.selectionAnchor = null;
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -181,7 +181,7 @@ var Selection = function(doc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
this.$dispatchEvent("changeSelection", {});
|
this._dispatchEvent("changeSelection", {});
|
||||||
};
|
};
|
||||||
|
|
||||||
this.selectTo = function(row, column) {
|
this.selectTo = function(row, column) {
|
||||||
|
|
@ -381,7 +381,7 @@ var Selection = function(doc) {
|
||||||
// only dispatch change if the cursor actually changed
|
// only dispatch change if the cursor actually changed
|
||||||
if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) {
|
if (cursor.row !== this.selectionLead.row || cursor.column !== this.selectionLead.column) {
|
||||||
this.selectionLead = cursor;
|
this.selectionLead = cursor;
|
||||||
this.$dispatchEvent("changeCursor", { data: this.getCursor() });
|
this._dispatchEvent("changeCursor", { data: this.getCursor() });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ var EventEmitterTest = new TestCase("EventEmitterTest", {
|
||||||
assertEquals("juhu", e.type);
|
assertEquals("juhu", e.type);
|
||||||
});
|
});
|
||||||
|
|
||||||
emitter.$dispatchEvent("juhu");
|
emitter._dispatchEvent("juhu");
|
||||||
assertTrue(called);
|
assertTrue(called);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ var VirtualRenderer = function(container, theme) {
|
||||||
var pageX = event.getDocumentX(e);
|
var pageX = event.getDocumentX(e);
|
||||||
var pageY = event.getDocumentY(e);
|
var pageY = event.getDocumentY(e);
|
||||||
|
|
||||||
this.$dispatchEvent("gutter" + e.type, {
|
this._dispatchEvent("gutter" + e.type, {
|
||||||
row: this.screenToTextCoordinates(pageX, pageY).row,
|
row: this.screenToTextCoordinates(pageX, pageY).row,
|
||||||
htmlEvent: e
|
htmlEvent: e
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ exports.addRequestOutput = function(request) {
|
||||||
exports.requests.shiftObject();
|
exports.requests.shiftObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.$dispatchEvent('addedRequestOutput', { request: request });
|
exports._dispatchEvent('addedRequestOutput', { request: request });
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -238,7 +238,7 @@ exports.Request.prototype.output = function(content) {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.outputs.push(content);
|
this.outputs.push(content);
|
||||||
this.$dispatchEvent('changed', {});
|
this._dispatchEvent('changed', {});
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
@ -256,7 +256,7 @@ exports.Request.prototype.done = function(content) {
|
||||||
this.output(content);
|
this.output(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$dispatchEvent('changed', {});
|
this._dispatchEvent('changed', {});
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -37,49 +37,50 @@
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var lang = require("pilot/lang").lang;
|
var lang = require("pilot/lang").lang;
|
||||||
|
|
||||||
var EventEmitter = {};
|
var EventEmitter = {};
|
||||||
|
|
||||||
EventEmitter.$dispatchEvent = function(eventName, e) {
|
EventEmitter._dispatchEvent = function(eventName, e) {
|
||||||
this.$eventRegistry = this.$eventRegistry || {};
|
this._eventRegistry = this._eventRegistry || {};
|
||||||
|
|
||||||
var listeners = this.$eventRegistry[eventName];
|
var listeners = this._eventRegistry[eventName];
|
||||||
if (!listeners || !listeners.length) return;
|
if (!listeners || !listeners.length) return;
|
||||||
|
|
||||||
var e = e || {};
|
var e = e || {};
|
||||||
e.type = eventName;
|
e.type = eventName;
|
||||||
|
|
||||||
for (var i=0; i<listeners.length; i++) {
|
for (var i=0; i<listeners.length; i++) {
|
||||||
listeners[i](e);
|
listeners[i](e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EventEmitter.on =
|
EventEmitter.on =
|
||||||
EventEmitter.addEventListener = function(eventName, callback) {
|
EventEmitter.addEventListener = function(eventName, callback) {
|
||||||
this.$eventRegistry = this.$eventRegistry || {};
|
this._eventRegistry = this._eventRegistry || {};
|
||||||
|
|
||||||
var listeners = this.$eventRegistry[eventName];
|
var listeners = this._eventRegistry[eventName];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
var listeners = this.$eventRegistry[eventName] = [];
|
var listeners = this._eventRegistry[eventName] = [];
|
||||||
}
|
}
|
||||||
if (lang.arrayIndexOf(listeners, callback) == -1) {
|
if (lang.arrayIndexOf(listeners, callback) == -1) {
|
||||||
listeners.push(callback);
|
listeners.push(callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EventEmitter.removeEventListener = function(eventName, callback) {
|
EventEmitter.removeEventListener = function(eventName, callback) {
|
||||||
this.$eventRegistry = this.$eventRegistry || {};
|
this._eventRegistry = this._eventRegistry || {};
|
||||||
|
|
||||||
var listeners = this.$eventRegistry[eventName];
|
var listeners = this._eventRegistry[eventName];
|
||||||
if (!listeners) {
|
if (!listeners) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var index = lang.arrayIndexOf(listeners, callback);
|
var index = lang.arrayIndexOf(listeners, callback);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
listeners.splice(index, 1);
|
listeners.splice(index, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.EventEmitter = EventEmitter;
|
||||||
|
|
||||||
exports.EventEmitter = EventEmitter;
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ Settings.prototype = {
|
||||||
persister.persistValue(this, key, value);
|
persister.persistValue(this, key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$dispatchEvent('settingChange', { key: key, value: value });
|
this._dispatchEvent('settingChange', { key: key, value: value });
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue