mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
Fix "Link" button on messages
- Add clipboard.js to bower - Add pop-out section that populates with URL - Add copy to clipboard button, hover confirmation
This commit is contained in:
committed by
James Hillyerd
parent
ee5f75631a
commit
fd59aad4f0
@@ -1,17 +1,47 @@
|
||||
var baseURL = window.location.protocol + '//' + window.location.host;
|
||||
var navBarOffset = 75;
|
||||
var mediumDeviceWidth = 980;
|
||||
var messageListMargin = 275;
|
||||
var clipboard = null;
|
||||
|
||||
// onDocChange is called each time we load partials into the DOM
|
||||
function onDocChange() {
|
||||
// Bootstrap tooltips
|
||||
$('[data-toggle="tooltip"]').tooltip()
|
||||
|
||||
// Clipboard functionality
|
||||
if (clipboard != null) {
|
||||
clipboard.destroy();
|
||||
}
|
||||
clipboard = new Clipboard('.btn-clipboard');
|
||||
clipboard.on('success', function(el) {
|
||||
flashTooltip(el.trigger, 'Copied!');
|
||||
el.clearSelection();
|
||||
});
|
||||
clipboard.on('error', function(el) {
|
||||
flashTooltip(el.trigger, 'Copy Failed!');
|
||||
});
|
||||
}
|
||||
|
||||
// flashTooltip temporarily changes the text of a tooltip
|
||||
function flashTooltip(el, text) {
|
||||
var prevText = $(el).attr('data-original-title');
|
||||
$(el).attr('data-original-title', text).tooltip('show');
|
||||
$(el).attr('data-original-title', prevText);
|
||||
}
|
||||
|
||||
function messageLoaded(responseText, textStatus, XMLHttpRequest) {
|
||||
if (textStatus == "error") {
|
||||
alert("Failed to load message, server said:\n" + responseText);
|
||||
} else {
|
||||
var top = $('#message-container').offset().top - navBarOffset;
|
||||
$(window).scrollTop(top);
|
||||
return;
|
||||
}
|
||||
onDocChange();
|
||||
var top = $('#message-container').offset().top - navBarOffset;
|
||||
$(window).scrollTop(top);
|
||||
}
|
||||
|
||||
function listLoaded() {
|
||||
onDocChange();
|
||||
$('.listEntry').click(
|
||||
function() {
|
||||
$('.listEntry').removeClass("disabled");
|
||||
@@ -73,3 +103,9 @@ function messageSource(id) {
|
||||
'menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no');
|
||||
}
|
||||
|
||||
function toggleMessageLink(id) {
|
||||
var url = baseURL + '/link/' + mailbox + '/' + id;
|
||||
$('#link-input-control').val(url);
|
||||
$('#link-row').slideToggle();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user