use ES5 bind() instead of lang.bind()
This commit is contained in:
parent
a0d4f85b9e
commit
69095379c3
5 changed files with 43 additions and 35 deletions
|
|
@ -65,10 +65,10 @@ var Editor =function(renderer, doc) {
|
|||
});
|
||||
|
||||
var mouseTarget = renderer.getMouseEventTarget();
|
||||
event.addListener(mouseTarget, "mousedown", lang.bind(this.onMouseDown, this));
|
||||
event.addMultiMouseDownListener(mouseTarget, 0, 2, 500, lang.bind(this.onMouseDoubleClick, this));
|
||||
event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, lang.bind(this.onMouseTripleClick, this));
|
||||
event.addMouseWheelListener(mouseTarget, lang.bind(this.onMouseWheel, this));
|
||||
event.addListener(mouseTarget, "mousedown", this.onMouseDown.bind(this));
|
||||
event.addMultiMouseDownListener(mouseTarget, 0, 2, 500, this.onMouseDoubleClick.bind(this));
|
||||
event.addMultiMouseDownListener(mouseTarget, 0, 3, 600, this.onMouseTripleClick.bind(this));
|
||||
event.addMouseWheelListener(mouseTarget, this.onMouseWheel.bind(this));
|
||||
|
||||
this.$selectionMarker = null;
|
||||
this.$highlightLineMarker = null;
|
||||
|
|
@ -128,26 +128,26 @@ var Editor =function(renderer, doc) {
|
|||
|
||||
this.doc = doc;
|
||||
|
||||
this.$onDocumentChange = lang.bind(this.onDocumentChange, this);
|
||||
this.$onDocumentChange = this.onDocumentChange.bind(this);
|
||||
doc.addEventListener("change", this.$onDocumentChange);
|
||||
this.renderer.setDocument(doc);
|
||||
|
||||
this.$onDocumentModeChange = lang.bind(this.onDocumentModeChange, this);
|
||||
this.$onDocumentModeChange = this.onDocumentModeChange.bind(this);
|
||||
doc.addEventListener("changeMode", this.$onDocumentModeChange);
|
||||
|
||||
this.$onDocumentChangeTabSize = lang.bind(this.renderer.updateText, this.renderer);
|
||||
this.$onDocumentChangeTabSize = this.renderer.updateText.bind(this.renderer);
|
||||
doc.addEventListener("changeTabSize", this.$onDocumentChangeTabSize);
|
||||
|
||||
this.$onDocumentChangeBreakpoint = lang.bind(this.onDocumentChangeBreakpoint, this);
|
||||
this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this);
|
||||
this.doc.addEventListener("changeBreakpoint", this.$onDocumentChangeBreakpoint);
|
||||
|
||||
this.selection = doc.getSelection();
|
||||
this.$desiredColumn = 0;
|
||||
|
||||
this.$onCursorChange = lang.bind(this.onCursorChange, this);
|
||||
this.$onCursorChange = this.onCursorChange.bind(this);
|
||||
this.selection.addEventListener("changeCursor", this.$onCursorChange);
|
||||
|
||||
this.$onSelectionChange = lang.bind(this.onSelectionChange, this);
|
||||
this.$onSelectionChange = this.onSelectionChange.bind(this);
|
||||
this.selection.addEventListener("changeSelection", this.$onSelectionChange);
|
||||
|
||||
this.onDocumentModeChange();
|
||||
|
|
@ -284,7 +284,7 @@ var Editor =function(renderer, doc) {
|
|||
var tokenizer = mode.getTokenizer();
|
||||
|
||||
if (!this.bgTokenizer) {
|
||||
var onUpdate = lang.bind(this.onTokenizerUpdate, this);
|
||||
var onUpdate = this.onTokenizerUpdate.bind(this);
|
||||
this.bgTokenizer = new BackgroundTokenizer(tokenizer, this);
|
||||
this.bgTokenizer.addEventListener("update", onUpdate);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("pilot/oop");
|
||||
var lang = require("pilot/lang");
|
||||
var dom = require("pilot/dom");
|
||||
var event = require("pilot/event");
|
||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||
|
|
@ -55,7 +54,7 @@ var ScrollBar = function(parent) {
|
|||
this.width = dom.scrollbarWidth();
|
||||
this.element.style.width = this.width;
|
||||
|
||||
event.addListener(this.element, "scroll", lang.bind(this.onScroll, this));
|
||||
event.addListener(this.element, "scroll", this.onScroll.bind(this));
|
||||
};
|
||||
|
||||
(function() {
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
define(function(require, exports, module) {
|
||||
|
||||
var oop = require("pilot/oop");
|
||||
var lang = require("pilot/lang");
|
||||
var dom = require("pilot/dom");
|
||||
var event = require("pilot/event");
|
||||
var GutterLayer = require("ace/layer/gutter").Gutter;
|
||||
|
|
@ -85,7 +84,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
this.layers = [ this.$markerLayer, textLayer, this.$cursorLayer ];
|
||||
|
||||
this.scrollBar = new ScrollBar(container);
|
||||
this.scrollBar.addEventListener("scroll", lang.bind(this.onScroll, this));
|
||||
this.scrollBar.addEventListener("scroll", this.onScroll.bind(this));
|
||||
|
||||
this.scrollTop = 0;
|
||||
|
||||
|
|
@ -101,8 +100,8 @@ var VirtualRenderer = function(container, theme) {
|
|||
|
||||
self.$loop.schedule(self.CHANGE_FULL);
|
||||
});
|
||||
event.addListener(this.$gutter, "click", lang.bind(this.$onGutterClick, this));
|
||||
event.addListener(this.$gutter, "dblclick", lang.bind(this.$onGutterClick, this));
|
||||
event.addListener(this.$gutter, "click", this.$onGutterClick.bind(this));
|
||||
event.addListener(this.$gutter, "dblclick", this.$onGutterClick.bind(this));
|
||||
|
||||
this.$size = {
|
||||
width: 0,
|
||||
|
|
@ -111,7 +110,7 @@ var VirtualRenderer = function(container, theme) {
|
|||
scrollerWidth: 0
|
||||
};
|
||||
|
||||
this.$loop = new RenderLoop(lang.bind(this.$renderChanges, this));
|
||||
this.$loop = new RenderLoop(this.$renderChanges.bind(this));
|
||||
this.$loop.schedule(this.CHANGE_FULL);
|
||||
|
||||
this.$updatePrintMargin();
|
||||
|
|
|
|||
|
|
@ -65,22 +65,38 @@ if (!Object.keys) {
|
|||
}
|
||||
|
||||
if (!Function.prototype.bind) {
|
||||
// From Narwhal
|
||||
Function.prototype.bind = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
// from MDC
|
||||
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
|
||||
Function.prototype.bind = function () {
|
||||
var slice = [].slice;
|
||||
var args = slice.call(arguments, 1);
|
||||
var self = this;
|
||||
var bound = function () {
|
||||
return self.call.apply(
|
||||
self,
|
||||
args.concat(
|
||||
Array.prototype.slice.call(arguments)
|
||||
)
|
||||
);
|
||||
};
|
||||
var nop = function () {};
|
||||
|
||||
// optimize common case
|
||||
if (arguments.length == 1) {
|
||||
var bound = return function() {
|
||||
return fcn.apply(this instanceof nop ? this : obj, arguments);
|
||||
};
|
||||
}
|
||||
else {
|
||||
var bound = function () {
|
||||
return self.apply(
|
||||
this instanceof nop ? this : ( obj || {} ),
|
||||
args.concat( slice.call(arguments) )
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
nop.prototype = self.prototype;
|
||||
bound.prototype = new nop();
|
||||
|
||||
// From Narwhal
|
||||
bound.name = this.name;
|
||||
bound.displayName = this.displayName;
|
||||
bound.length = this.length;
|
||||
bound.unbound = self;
|
||||
|
||||
return bound;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,12 +82,6 @@ exports.escapeRegExp = function(str) {
|
|||
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
|
||||
};
|
||||
|
||||
exports.bind = function(fcn, context) {
|
||||
return function() {
|
||||
return fcn.apply(context, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
exports.deferredCall = function(fcn) {
|
||||
|
||||
var timer = null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue