Merge branch 'staging' of github.com:xwiki-labs/cryptpad into staging
This commit is contained in:
@@ -131,13 +131,14 @@ define([
|
||||
var $t = t.tokenfield = $(t.element).tokenfield();
|
||||
t.getTokens = function () {
|
||||
return $t.tokenfield('getTokens').map(function (token) {
|
||||
return token.value;
|
||||
return token.value.toLowerCase();
|
||||
});
|
||||
};
|
||||
|
||||
t.preventDuplicates = function (cb) {
|
||||
$t.on('tokenfield:createtoken', function (ev) {
|
||||
var val;
|
||||
ev.attrs.value = ev.attrs.value.toLowerCase();
|
||||
if (t.getTokens().some(function (t) {
|
||||
if (t === ev.attrs.value) { return ((val = t)); }
|
||||
})) {
|
||||
@@ -152,8 +153,8 @@ define([
|
||||
$t.tokenfield('setTokens',
|
||||
tokens.map(function (token) {
|
||||
return {
|
||||
value: token,
|
||||
label: token,
|
||||
value: token.toLowerCase(),
|
||||
label: token.toLowerCase(),
|
||||
};
|
||||
}));
|
||||
};
|
||||
@@ -171,13 +172,13 @@ define([
|
||||
var input = dialog.textInput();
|
||||
|
||||
var tagger = dialog.frame([
|
||||
dialog.message('make some tags'), // TODO translate
|
||||
dialog.message(Messages.tags_add),
|
||||
input,
|
||||
dialog.nav(),
|
||||
]);
|
||||
|
||||
var field = UI.tokenField(input).preventDuplicates(function (val) {
|
||||
UI.warn('Duplicate tag: ' + val); // TODO translate
|
||||
UI.warn(Messages._getKey('tags_duplicate', [val]));
|
||||
});
|
||||
|
||||
var close = Util.once(function () {
|
||||
|
||||
@@ -536,6 +536,17 @@ define([
|
||||
cb(void 0, entry);
|
||||
};
|
||||
|
||||
common.resetTags = function (href, tags, cb) {
|
||||
cb = cb || $.noop;
|
||||
if (!Array.isArray(tags)) { return void cb('INVALID_TAGS'); }
|
||||
getFileEntry(href, function (e, entry) {
|
||||
if (e) { return void cb(e); }
|
||||
if (!entry) { cb('NO_ENTRY'); }
|
||||
entry.tags = tags.slice();
|
||||
cb();
|
||||
});
|
||||
};
|
||||
|
||||
common.tagPad = function (href, tag, cb) {
|
||||
if (typeof(cb) !== 'function') {
|
||||
return void console.error('EXPECTED_CALLBACK');
|
||||
|
||||
@@ -194,6 +194,24 @@ define([
|
||||
})
|
||||
.click(common.prepareFeedback(type));
|
||||
break;
|
||||
case 'hashtag':
|
||||
button = $('<button>', {
|
||||
'class': 'fa fa-hashtag',
|
||||
title: Messages.tags_title,
|
||||
})
|
||||
.click(common.prepareFeedback(type))
|
||||
.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) {
|
||||
if (!Array.isArray(tags)) { return; }
|
||||
console.error(tags);
|
||||
sframeChan.event('EV_TAGS_SET', tags);
|
||||
});
|
||||
document.body.appendChild(dialog);
|
||||
});
|
||||
});
|
||||
break;
|
||||
default:
|
||||
button = $('<button>', {
|
||||
'class': "fa fa-question",
|
||||
|
||||
@@ -370,6 +370,20 @@ define([
|
||||
}
|
||||
});
|
||||
|
||||
sframeChan.on('Q_TAGS_GET', function (data, cb) {
|
||||
Cryptpad.getPadTags(null, function (err, data) {
|
||||
cb({
|
||||
error: err,
|
||||
data: data
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
sframeChan.on('EV_TAGS_SET', function (data) {
|
||||
console.log(data);
|
||||
Cryptpad.resetTags(null, data);
|
||||
});
|
||||
|
||||
if (cfg.addRpc) {
|
||||
cfg.addRpc(sframeChan, Cryptpad);
|
||||
}
|
||||
|
||||
@@ -130,4 +130,9 @@ define({
|
||||
|
||||
// Put one or more entries to the cache which will go in localStorage.
|
||||
'EV_CACHE_PUT': true,
|
||||
|
||||
// Set and get the tags using the tag prompt button
|
||||
'Q_TAGS_GET': true,
|
||||
'EV_TAGS_SET': true,
|
||||
|
||||
});
|
||||
|
||||
@@ -415,6 +415,7 @@ define([
|
||||
var containsSearchedTag = function (T) {
|
||||
if (!tags) { return false; }
|
||||
if (!T.length) { return false; }
|
||||
T = T.map(function (t) { return t.toLowerCase(); });
|
||||
return tags.some(function (tag) {
|
||||
return T.some(function (t) {
|
||||
return t.indexOf(tag) !== -1;
|
||||
|
||||
@@ -2408,6 +2408,13 @@ define([
|
||||
}
|
||||
}
|
||||
|
||||
if (data.tags && Array.isArray(data.tags)) {
|
||||
$('<label>', {'for': 'cp-drive-tags'}).text(Messages.fm_prop_tagsList).appendTo($d);
|
||||
$d.append(Cryptpad.dialog.selectable(data.tags.join(', '), {
|
||||
id: 'cp-drive-tags',
|
||||
}));
|
||||
}
|
||||
|
||||
if (APP.loggedIn && AppConfig.enablePinning) {
|
||||
// check the size of this file...
|
||||
console.log(data.href);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
@import (once) "../../customize/src/less2/include/toolbar.less";
|
||||
@import (once) '../../customize/src/less2/include/alertify.less';
|
||||
@import (once) '../../customize/src/less2/include/tokenfield.less';
|
||||
|
||||
.toolbar_main();
|
||||
.alertify_main();
|
||||
|
||||
// body
|
||||
&.cp-app-pad {
|
||||
.tokenfield_main();
|
||||
#cke_1_top {
|
||||
overflow: visible;
|
||||
padding: 0px;
|
||||
@@ -38,6 +40,6 @@
|
||||
display:none !important;
|
||||
}
|
||||
&.cp-app-pad .cp-toolbar-userlist-drawer {
|
||||
display:none;
|
||||
display:none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -694,6 +694,10 @@ define([
|
||||
};
|
||||
common.openFilePicker(pickerCfg);
|
||||
}).appendTo($rightside);
|
||||
|
||||
|
||||
var $tags = common.createButton('hashtag', true);
|
||||
$rightside.append($tags);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user