Hide the trash icon for read-only pads if we have the edit link in drive

pull/1/head
yflory 8 years ago
parent 02cc9c8344
commit 3fd5669647

@ -56,6 +56,9 @@
margin-left: 5px;
}
}
&.hidden {
display: none;
}
}
.cryptpad-lag {

@ -128,6 +128,9 @@
.cryptpad-toolbar button#shareButton .large {
margin-left: 5px;
}
.cryptpad-toolbar button.hidden {
display: none;
}
.cryptpad-toolbar .cryptpad-lag {
box-sizing: content-box;
height: 16px;

@ -581,6 +581,21 @@ define([
};
// STORAGE
var isNotStrongestStored = common.isNotStrongestStored = function (href, recents) {
var parsed = parsePadUrl(href);
return recents.some(function (pad) {
var p = parsePadUrl(pad.href);
if (p.type !== parsed.type) { return false; } // Not the same type
if (p.hash === parsed.hash) { return false; } // Same hash, not stronger
var pHash = parseHash(p.hash);
var parsedHash = parseHash(parsed.hash);
if (pHash.version !== parsedHash.version) { return false; }
if (pHash.channel !== parsedHash.channel) { return false; }
if (pHash.mode === 'edit' && parsedHash.mode === 'view') { return true; }
if (pHash.mode === parsedHash.mode && parsedHash.present) { return true; }
return false;
});
};
var setPadTitle = common.setPadTitle = function (name, cb) {
var href = window.location.href;
var parsed = parsePadUrl(href);
@ -893,6 +908,11 @@ define([
'class': "fa fa-trash cryptpad-forget",
style: 'font:'+size+' FontAwesome'
});
getRecentPads(function (err, recent) {
if (isNotStrongestStored(window.location.href, recent)) {
button.addClass('hidden');
}
});
if (callback) {
button.click(function() {
var href = window.location.href;
@ -1067,7 +1087,8 @@ define([
var createLanguageSelector = common.createLanguageSelector = function ($container, $initBlock) {
var options = [];
var languages = Messages._languages;
for (var l in languages) {
var keys = Object.keys(languages).sort();
keys.forEach(function (l) {
options.push({
tag: 'a',
attributes: {
@ -1077,7 +1098,7 @@ define([
},
content: languages[l] // Pretty name of the language value
});
}
});
var dropdownConfig = {
text: Messages.language, // Button initial text
options: options, // Entries displayed in the menu

Loading…
Cancel
Save