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