mirror of
https://github.com/zulip/zulip.git
synced 2025-10-25 09:03:57 +00:00
pills: Allow removing pill without calling the remove event handler.
Adds an optional parameter `quiet` to removeLastPill and removeAllPills. If `quiet` is a truthy value, the event handler associated with the pill will not be evaluated. This is useful when using clear to reset the pills.
This commit is contained in:
committed by
Tim Abbott
parent
5c01ae87a0
commit
6ff13d0d01
@@ -154,22 +154,25 @@ exports.create = function (opts) {
|
||||
}
|
||||
},
|
||||
|
||||
// this will remove the last pill in the container -- by defaulat tied
|
||||
// this will remove the last pill in the container -- by default tied
|
||||
// to the "backspace" key when the value of the input is empty.
|
||||
removeLastPill: function () {
|
||||
// If quiet is a truthy value, the event handler associated with the
|
||||
// pill will not be evaluated. This is useful when using clear to reset
|
||||
// the pills.
|
||||
removeLastPill: function (quiet) {
|
||||
var pill = store.pills.pop();
|
||||
|
||||
if (pill) {
|
||||
pill.$element.remove();
|
||||
if (typeof store.removePillFunction === "function") {
|
||||
if (!quiet && typeof store.removePillFunction === "function") {
|
||||
store.removePillFunction(pill);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
removeAllPills: function () {
|
||||
removeAllPills: function (quiet) {
|
||||
while (store.pills.length > 0) {
|
||||
this.removeLastPill();
|
||||
this.removeLastPill(quiet);
|
||||
}
|
||||
|
||||
this.clear(store.$input[0]);
|
||||
|
||||
Reference in New Issue
Block a user