Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #11 from benbro/blur

Trigger the blur event only if there is no selection
  • Loading branch information...
commit 85e0d20c5fa851c691b7b2995488821ecd52106d 2 parents 2b327bf + 74d8cc8
@timjb timjb authored
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/codemirror-adapter.js
View
10 lib/codemirror-adapter.js
@@ -12,7 +12,7 @@ ot.CodeMirrorAdapter = (function () {
var self = this;
cm.on('change', function (_, change) { self.onChange(change); });
cm.on('cursorActivity', function () { self.trigger('cursorActivity'); });
- cm.on('blur', function () { self.trigger('blur'); });
+ cm.on('blur', function () { self.onBlur(); });
}
// The oldValue is needed to find
@@ -143,6 +143,12 @@ ot.CodeMirrorAdapter = (function () {
this.oldValue = this.cm.getValue();
};
+ CodeMirrorAdapter.prototype.onBlur = function () {
+ if(!cm.getSelection()) {
+ this.trigger('blur');
+ }
+ }
+
CodeMirrorAdapter.prototype.getValue = function () {
return this.oldValue;
};
@@ -255,4 +261,4 @@ ot.CodeMirrorAdapter = (function () {
return CodeMirrorAdapter;
-}());
+}());
Please sign in to comment.
Something went wrong with that request. Please try again.