diff --git a/www/common/common-interface.js b/www/common/common-interface.js index 9f0746a90..ad5b51195 100644 --- a/www/common/common-interface.js +++ b/www/common/common-interface.js @@ -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); diff --git a/www/common/sframe-common-interface.js b/www/common/sframe-common-interface.js index c3a4757b4..73e09c603 100644 --- a/www/common/sframe-common-interface.js +++ b/www/common/sframe-common-interface.js @@ -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;