Skip to content
This repository was archived by the owner on Apr 7, 2020. It is now read-only.

Commit 1300c8b

Browse files
author
Dean Sofer
committed
Simplified implementation
1 parent fa904a4 commit 1300c8b

File tree

3 files changed

+18
-60
lines changed

3 files changed

+18
-60
lines changed

dist/mention.js

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -308,45 +308,24 @@ angular.module('ui.mention', []).directive('uiMention', function ($q, $timeout,
308308
$scope.$apply();
309309
});
310310

311-
// Fires before blur
312-
var clicking = false;
313-
this.onMousedown = function (event) {
314-
if (event.target !== $element[0]) {
315-
clicking = true;
316-
$document.off('mousedown', this.onMousedown);
317-
}
318-
};
319-
320-
this.onMouseup = function (event) {
311+
this.onMouseup = (function (event) {
321312
var _this4 = this;
322313

323-
if (event.target !== $element[0]) $document.off('mouseup', this.onMouseup);
314+
if (event.target == $element[0]) return;
315+
console.log('blur');
316+
$document.off('mouseup', this.onMouseup);
324317

325-
if (!clicking) return;
318+
if (!this.searching) return;
326319

327320
// Let ngClick fire first
328321
$scope.$evalAsync(function () {
329322
_this4.cancel();
330323
});
331-
};
324+
}).bind(this);
332325

333326
$element.on('focus', function (event) {
334-
$document.on('mousedown', _this2.onMousedown.bind(_this2));
335-
$document.on('mouseup', _this2.onMouseup.bind(_this2));
336-
});
337-
338-
$element.on('blur', function (event) {
339-
if (clicking) {
340-
return;
341-
} else {
342-
$document.off('mouseup', _this2.onMouseup);
343-
$document.off('mousedown', _this2.onMousedown);
344-
}
345-
346-
if (!_this2.searching) return;
347-
348-
_this2.cancel();
349-
$scope.$apply();
327+
console.log('focus');
328+
$document.on('mouseup', _this2.onMouseup);
350329
});
351330

352331
// Autogrow is mandatory beacuse the textarea scrolls away from highlights

dist/mention.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mention.es6.js

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -289,46 +289,25 @@ angular.module('ui.mention', [])
289289
});
290290

291291

292-
// Fires before blur
293-
var clicking = false;
294-
this.onMousedown = function(event) {
295-
if (event.target !== $element[0]) {
296-
clicking = true;
297-
$document.off('mousedown', this.onMousedown);
298-
}
299-
}
300292

301-
this.onMouseup = function(event) {
302-
if (event.target !== $element[0])
303-
$document.off('mouseup', this.onMouseup);
293+
this.onMouseup = (function(event) {
294+
if (event.target == $element[0])
295+
return
296+
console.log('blur')
297+
$document.off('mouseup', this.onMouseup);
304298

305-
if (!clicking)
299+
if (!this.searching)
306300
return;
307301

308302
// Let ngClick fire first
309303
$scope.$evalAsync( () => {
310304
this.cancel();
311305
});
312-
}
306+
}).bind(this);
313307

314308
$element.on('focus', event => {
315-
$document.on('mousedown', this.onMousedown.bind(this));
316-
$document.on('mouseup', this.onMouseup.bind(this));
317-
});
318-
319-
$element.on('blur', event => {
320-
if (clicking) {
321-
return;
322-
} else {
323-
$document.off('mouseup', this.onMouseup);
324-
$document.off('mousedown', this.onMousedown);
325-
}
326-
327-
if (!this.searching)
328-
return;
329-
330-
this.cancel();
331-
$scope.$apply();
309+
console.log('focus')
310+
$document.on('mouseup', this.onMouseup);
332311
});
333312

334313
// Autogrow is mandatory beacuse the textarea scrolls away from highlights

0 commit comments

Comments
 (0)