зеркало из https://github.com/nextcloud/spreed.git
Fix attaching event listeners to all the clipboard buttons in the page
When the Clipboard object is created it attaches event listeners to the given element or to all the elements that match the given DOM selector. As all the clipboard buttons in the Talk UI (except the one in the empty content view) have the "clipboard-button" CSS class all the Clipboard objects listened to clicks on all the buttons, so clicking on a single button triggered as many copies as buttons and thus Clipboard objects were in the page. Now the Clipboard objects attach listeners only to their corresponding clipboard button. Note that it is not possible to use just one Clipboard object attached to all the clipboard buttons, though, as the attached elements are fixed when the Clipboard object is created and thus clipboard buttons added after that are not taken into account. Therefore it is much easier to keep track of a single button and create again its Clipboard object when it is rerendered. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Родитель
dd2920c9e6
Коммит
b21fb210b7
|
@ -298,7 +298,11 @@
|
|||
* Clipboard
|
||||
*/
|
||||
initClipboard: function() {
|
||||
var clipboard = new Clipboard('.clipboard-button');
|
||||
if (this.ui.clipboardButton.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var clipboard = new Clipboard(this.ui.clipboardButton[0]);
|
||||
clipboard.on('success', function(e) {
|
||||
var $input = $(e.trigger);
|
||||
$input.tooltip('hide')
|
||||
|
|
|
@ -271,7 +271,11 @@
|
|||
* Clipboard
|
||||
*/
|
||||
initClipboard: function() {
|
||||
var clipboard = new Clipboard('.clipboard-button');
|
||||
if (this.ui.clipboardButton.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var clipboard = new Clipboard(this.ui.clipboardButton[0]);
|
||||
clipboard.on('success', function(e) {
|
||||
var $input = $(e.trigger);
|
||||
$input.tooltip('hide')
|
||||
|
|
Загрузка…
Ссылка в новой задаче