more conformant tagPrompt behaviour

pull/1/head
ansuz 7 years ago
parent db4c3e7e2c
commit 68f7d4bc0a

@ -135,6 +135,11 @@ define([
});
};
var $root = $t.parent();
$t.on('tokenfield:removetoken', function (e) {
$root.find('.token-input').focus();
});
t.preventDuplicates = function (cb) {
$t.on('tokenfield:createtoken', function (ev) {
var val;
@ -185,22 +190,29 @@ define([
var $t = $(tagger).fadeOut(150, function () { $t.remove(); });
});
var listener = listenForKeys(function () {}, function () {
close();
stopListening(listener);
var listener;
var close = Util.once(function (result, ev) {
var $frame = $(tagger).fadeOut(150, function () {
stopListening(listener);
$frame.remove();
cb(result, ev);
});
});
var CB = Util.once(cb);
findOKButton(tagger).click(function () {
var $ok = findOKButton(tagger).click(function () {
var tokens = field.getTokens();
close();
CB(tokens);
close(tokens);
});
var $cancel = findCancelButton(tagger).click(function () {
close(null);
});
findCancelButton(tagger).click(function () {
close();
CB(null);
listenForKeys(function () {
$ok.click();
}, function () {
$cancel.click();
});
document.body.appendChild(tagger);
// :(
setTimeout(function () {
field.setTokens(tags);

@ -203,12 +203,11 @@ define([
.click(function () {
sframeChan.query('Q_TAGS_GET', null, function (err, res) {
if (err || res.error) { return void console.error(err || res.error); }
var dialog = Cryptpad.dialog.tagPrompt(res.data, function (tags) {
Cryptpad.dialog.tagPrompt(res.data, function (tags) {
if (!Array.isArray(tags)) { return; }
console.error(tags);
sframeChan.event('EV_TAGS_SET', tags);
});
document.body.appendChild(dialog);
});
});
break;

Loading…
Cancel
Save