more conformant tagPrompt behaviour
This commit is contained in:
@@ -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.preventDuplicates = function (cb) {
|
||||||
$t.on('tokenfield:createtoken', function (ev) {
|
$t.on('tokenfield:createtoken', function (ev) {
|
||||||
var val;
|
var val;
|
||||||
@@ -185,22 +190,29 @@ define([
|
|||||||
var $t = $(tagger).fadeOut(150, function () { $t.remove(); });
|
var $t = $(tagger).fadeOut(150, function () { $t.remove(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
var listener = listenForKeys(function () {}, function () {
|
var listener;
|
||||||
close();
|
var close = Util.once(function (result, ev) {
|
||||||
|
var $frame = $(tagger).fadeOut(150, function () {
|
||||||
stopListening(listener);
|
stopListening(listener);
|
||||||
|
$frame.remove();
|
||||||
|
cb(result, ev);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
var CB = Util.once(cb);
|
var $ok = findOKButton(tagger).click(function () {
|
||||||
findOKButton(tagger).click(function () {
|
|
||||||
var tokens = field.getTokens();
|
var tokens = field.getTokens();
|
||||||
close();
|
close(tokens);
|
||||||
CB(tokens);
|
|
||||||
});
|
});
|
||||||
findCancelButton(tagger).click(function () {
|
var $cancel = findCancelButton(tagger).click(function () {
|
||||||
close();
|
close(null);
|
||||||
CB(null);
|
});
|
||||||
|
listenForKeys(function () {
|
||||||
|
$ok.click();
|
||||||
|
}, function () {
|
||||||
|
$cancel.click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.body.appendChild(tagger);
|
||||||
// :(
|
// :(
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
field.setTokens(tags);
|
field.setTokens(tags);
|
||||||
|
|||||||
@@ -203,12 +203,11 @@ define([
|
|||||||
.click(function () {
|
.click(function () {
|
||||||
sframeChan.query('Q_TAGS_GET', null, function (err, res) {
|
sframeChan.query('Q_TAGS_GET', null, function (err, res) {
|
||||||
if (err || res.error) { return void console.error(err || res.error); }
|
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; }
|
if (!Array.isArray(tags)) { return; }
|
||||||
console.error(tags);
|
console.error(tags);
|
||||||
sframeChan.event('EV_TAGS_SET', tags);
|
sframeChan.event('EV_TAGS_SET', tags);
|
||||||
});
|
});
|
||||||
document.body.appendChild(dialog);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user