awesomplete
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -58,3 +58,3 @@ /** | ||
"input": this.evaluate.bind(this), | ||
"blur": this.close.bind(this), | ||
"blur": this.close.bind(this, { reason: "blur" }), | ||
"keydown": function(evt) { | ||
@@ -71,3 +71,3 @@ var c = evt.keyCode; | ||
else if (c === 27) { // Esc | ||
me.close(); | ||
me.close({ reason: "esc" }); | ||
} | ||
@@ -82,3 +82,3 @@ else if (c === 38 || c === 40) { // Down/Up arrow | ||
$.bind(this.input.form, {"submit": this.close.bind(this)}); | ||
$.bind(this.input.form, {"submit": this.close.bind(this, { reason: "submit" })}); | ||
@@ -152,7 +152,11 @@ $.bind(this.ul, {"mousedown": function(evt) { | ||
close: function () { | ||
close: function (o) { | ||
if (!this.opened) { | ||
return; | ||
} | ||
this.ul.setAttribute("hidden", ""); | ||
this.index = -1; | ||
$.fire(this.input, "awesomplete-close"); | ||
$.fire(this.input, "awesomplete-close", o || {}); | ||
}, | ||
@@ -219,3 +223,3 @@ | ||
this.replace(suggestion); | ||
this.close(); | ||
this.close({ reason: "select" }); | ||
$.fire(this.input, "awesomplete-selectcomplete", { | ||
@@ -252,3 +256,3 @@ text: suggestion | ||
if (this.ul.children.length === 0) { | ||
this.close(); | ||
this.close({ reason: "nomatches" }); | ||
} else { | ||
@@ -259,3 +263,3 @@ this.open(); | ||
else { | ||
this.close(); | ||
this.close({ reason: "nomatches" }); | ||
} | ||
@@ -262,0 +266,0 @@ } |
@@ -0,1 +1,9 @@ | ||
# 1.1.1 (2016-06-25) | ||
## Fixes | ||
* Improved docs | ||
* Emit close reason with `awesomplete-close` events ([8c0ff62](https://github.com/LeaVerou/awesomplete/commit/8c0ff6225c96af2f5f3b7312d7ba7b69f71be575)). See [Events](http://leaverou.github.io/awesomplete/#events). | ||
* Fire `awesomplete-close` event only if open ([2cef2c2](https://github.com/LeaVerou/awesomplete/commit/2cef2c28a6f74ee5c0b294d2c3c7d2bad72bd466)) | ||
# 1.1.0 (2016-03-16) | ||
@@ -2,0 +10,0 @@ |
{ | ||
"name": "awesomplete", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "http://leaverou.github.io/awesomplete/", | ||
@@ -5,0 +5,0 @@ "main": "awesomplete.js", |
# Awesomplete | ||
[![npm version](https://img.shields.io/npm/v/awesomplete.svg)](https://www.npmjs.com/package/awesomplete) | ||
[![Build Status](https://img.shields.io/travis/LeaVerou/awesomplete/gh-pages.svg)](https://travis-ci.org/LeaVerou/awesomplete) | ||
@@ -3,0 +4,0 @@ [![Code Climate](https://img.shields.io/codeclimate/github/LeaVerou/awesomplete.svg)](https://codeclimate.com/github/LeaVerou/awesomplete) |
@@ -27,4 +27,14 @@ describe("awesomplete.close", function () { | ||
expect(handler).toHaveBeenCalled(); | ||
expect(handler).toHaveBeenCalledWith( | ||
jasmine.any(document.createEvent("HTMLEvents").constructor) | ||
); | ||
}); | ||
it("returns early if already closed", function () { | ||
var handler = $.spyOnEvent(this.subject.input, "awesomplete-close"); | ||
this.subject.close(); | ||
this.subject.close(); | ||
expect(handler.calls.count()).toBe(1); | ||
}); | ||
}); |
@@ -18,3 +18,5 @@ describe("awesomplete.evaluate", function () { | ||
expect(this.subject.close).toHaveBeenCalled(); | ||
expect(this.subject.close).toHaveBeenCalledWith({ | ||
reason: "nomatches" | ||
}); | ||
}); | ||
@@ -32,3 +34,5 @@ }); | ||
expect(this.subject.close).toHaveBeenCalled(); | ||
expect(this.subject.close).toHaveBeenCalledWith({ | ||
reason: "nomatches" | ||
}); | ||
}); | ||
@@ -35,0 +39,0 @@ }); |
@@ -69,3 +69,5 @@ describe("awesomplete.select", function () { | ||
expect(this.subject.close).toHaveBeenCalled(); | ||
expect(this.subject.close).toHaveBeenCalledWith({ | ||
reason: "select" | ||
}); | ||
}); | ||
@@ -72,0 +74,0 @@ |
@@ -10,4 +10,7 @@ describe("blur event", function () { | ||
$.fire(this.subject.input, "blur"); | ||
expect(Awesomplete.prototype.close).toHaveBeenCalled(); | ||
expect(Awesomplete.prototype.close).toHaveBeenCalledWith( | ||
{ reason: "blur" }, | ||
jasmine.any(document.createEvent("HTMLEvents").constructor) | ||
); | ||
}); | ||
}); |
@@ -26,3 +26,5 @@ describe("keydown event", function () { | ||
expect(this.subject.close).toHaveBeenCalled(); | ||
expect(this.subject.close).toHaveBeenCalledWith({ | ||
reason: "esc" | ||
}); | ||
}); | ||
@@ -29,0 +31,0 @@ |
@@ -12,4 +12,7 @@ describe("form submit event", function () { | ||
$.fire(this.subject.input.form, "submit"); | ||
expect(Awesomplete.prototype.close).toHaveBeenCalled(); | ||
expect(Awesomplete.prototype.close).toHaveBeenCalledWith( | ||
{ reason: "submit" }, | ||
jasmine.any(document.createEvent("HTMLEvents").constructor) | ||
); | ||
}); | ||
}); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
116274
2309
79