Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "copy link" option to the conversation list dropdown #1670

Merged
merged 1 commit into from
Apr 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ input[type="password"] {
#app-navigation .app-navigation-entry-menu li span[class*=' icon-'] {
padding: 16px;
box-sizing: border-box;
width: 36px;
}

#app-navigation .app-navigation-entry-utils-menu-button {
Expand Down
54 changes: 54 additions & 0 deletions js/views/roomlistview.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
'</li>'+
'{{/if}}'+
'{{/if}}'+
'<li>'+
'<button class="clipboard-button">'+
'<span class="icon-clippy"></span>'+
'<span>'+t('spreed', 'Copy link')+'</span>'+
'</button>'+
'</li>'+
'<li><div class="separator"></div></li>'+
'<li{{#if notifyAlways}} class="active"{{/if}}>'+
'<button class="notify-always-button">'+
Expand Down Expand Up @@ -196,6 +202,11 @@
}

this.toggleMenuClass();

var completeURL = window.location.protocol + '//' + window.location.host + roomURL;
this.ui.clipboardButton.attr('value', completeURL);
this.ui.clipboardButton.attr('data-clipboard-text', completeURL);
this.initClipboard();
},
events: {
'click .app-navigation-entry-utils-menu-button button': 'toggleMenu',
Expand All @@ -211,6 +222,7 @@
ui: {
'room': '.app-navigation-entry-link',
'menu': '.app-navigation-entry-menu',
'clipboardButton': '.clipboard-button',
'menuList': '.app-navigation-entry-menu-list'
},
template: Handlebars.compile(ITEM_TEMPLATE),
Expand Down Expand Up @@ -323,6 +335,48 @@

this.model.join();
},

/**
* Clipboard
*/
initClipboard: function() {
var clipboard = new Clipboard('.clipboard-button');
clipboard.on('success', function(e) {
var $input = $(e.trigger);
$input.tooltip('hide')
.attr('data-original-title', t('core', 'Link copied!'))
.tooltip('fixTitle')
.tooltip({placement: 'bottom', trigger: 'manual'})
.tooltip('show');
_.delay(function() {
$input.tooltip('hide')
.attr('data-original-title', t('core', 'Copy link'))
.tooltip('fixTitle');
}, 3000);
});
clipboard.on('error', function (e) {
var $input = $(e.trigger);
var actionMsg = '';
if (/iPhone|iPad/i.test(navigator.userAgent)) {
actionMsg = t('core', 'Not supported!');
} else if (/Mac/i.test(navigator.userAgent)) {
actionMsg = t('core', 'Press ⌘-C to copy.');
} else {
actionMsg = t('core', 'Press Ctrl-C to copy.');
}

$input.tooltip('hide')
.attr('data-original-title', actionMsg)
.tooltip('fixTitle')
.tooltip({placement: 'bottom', trigger: 'manual'})
.tooltip('show');
_.delay(function () {
$input.tooltip('hide')
.attr('data-original-title', t('spreed', 'Copy link'))
.tooltip('fixTitle');
}, 3000);
});
}
});

var RoomListView = Marionette.CollectionView.extend({
Expand Down