Permalink
Browse files

Merge pull request #11 from benbro/blur

Trigger the blur event only if there is no selection
  • Loading branch information...
2 parents 2b327bf + 74d8cc8 commit 85e0d20c5fa851c691b7b2995488821ecd52106d @timjb timjb committed Jan 10, 2013
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/codemirror-adapter.js
View
@@ -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;
-}());
+}());

0 comments on commit 85e0d20

Please sign in to comment.