Skip to content

Commit

Permalink
Merge pull request ajaxorg#2915 from ajaxorg/fix-ie
Browse files Browse the repository at this point in the history
Fix IE issues
  • Loading branch information
nightwing committed Mar 31, 2016
2 parents edd04b3 + d7d3d79 commit e7f5a52
Showing 2 changed files with 24 additions and 14 deletions.
20 changes: 12 additions & 8 deletions lib/ace/keyboard/textinput.js
Original file line number Diff line number Diff line change
@@ -263,18 +263,22 @@ var TextInput = function(parentNode, host) {
resetValue();
};

var handleClipboardData = function(e, data) {
var handleClipboardData = function(e, data, forceIEMime) {
var clipboardData = e.clipboardData || window.clipboardData;
if (!clipboardData || BROKEN_SETDATA)
return;
// using "Text" doesn't work on old webkit but ie needs it
// TODO are there other browsers that require "Text"?
var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
if (data) {
// Safari 5 has clipboardData object, but does not handle setData()
return clipboardData.setData(mime, data) !== false;
} else {
return clipboardData.getData(mime);
var mime = USE_IE_MIME_TYPE || forceIEMime ? "Text" : "text/plain";
try {
if (data) {
// Safari 5 has clipboardData object, but does not handle setData()
return clipboardData.setData(mime, data) !== false;
} else {
return clipboardData.getData(mime);
}
} catch(e) {
if (!forceIEMime)
return handleClipboardData(e, data, true);
}
};

18 changes: 12 additions & 6 deletions lib/ace/scrollbar.js
Original file line number Diff line number Diff line change
@@ -35,6 +35,7 @@ var oop = require("./lib/oop");
var dom = require("./lib/dom");
var event = require("./lib/event");
var EventEmitter = require("./lib/event_emitter").EventEmitter;
var MAX_SCROLL_H = 0x8000;

/**
* An abstract class representing a native scrollbar control.
@@ -70,6 +71,7 @@ var ScrollBar = function(parent) {
this.setVisible = function(isVisible) {
this.element.style.display = isVisible ? "" : "none";
this.isVisible = isVisible;
this.coeff = 1;
};
}).call(ScrollBar.prototype);

@@ -113,7 +115,7 @@ oop.inherits(VScrollBar, ScrollBar);
**/
this.onScroll = function() {
if (!this.skipEvent) {
this.scrollTop = this.element.scrollTop;
this.scrollTop = this.element.scrollTop / this.coeff;
this._emit("scroll", {data: this.scrollTop});
}
this.skipEvent = false;
@@ -140,15 +142,18 @@ oop.inherits(VScrollBar, ScrollBar);
* @param {Number} height The new inner height
* @deprecated Use setScrollHeight instead
**/
this.setInnerHeight = function(height) {
this.inner.style.height = height + "px";
};

this.setInnerHeight =
/**
* Sets the scroll height of the scroll bar, in pixels.
* @param {Number} height The new scroll height
**/
this.setScrollHeight = function(height) {
if (height > MAX_SCROLL_H) {
this.coeff = MAX_SCROLL_H / height;
height = MAX_SCROLL_H;
} else if (this.coeff != 1) {
this.coeff = 1
}
this.inner.style.height = height + "px";
};

@@ -161,7 +166,8 @@ oop.inherits(VScrollBar, ScrollBar);
// this.element.scrollTop != scrollTop which makes page to scroll up.
if (this.scrollTop != scrollTop) {
this.skipEvent = true;
this.scrollTop = this.element.scrollTop = scrollTop;
this.scrollTop = scrollTop;
this.element.scrollTop = scrollTop * this.coeff;
}
};

0 comments on commit e7f5a52

Please sign in to comment.