mirror of
https://github.com/wallabag/wallabag.git
synced 2025-06-27 16:36:00 +00:00
Extract Clipboard controller
This commit is contained in:
parent
ffeca7f94d
commit
9da9e6b004
4 changed files with 20 additions and 11 deletions
16
assets/controllers/clipboard_controller.js
Normal file
16
assets/controllers/clipboard_controller.js
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
import ClipboardJS from 'clipboard';
|
||||||
|
|
||||||
|
export default class extends Controller {
|
||||||
|
connect() {
|
||||||
|
this.clipboard = new ClipboardJS(this.element);
|
||||||
|
|
||||||
|
this.clipboard.on('success', (e) => {
|
||||||
|
e.clearSelection();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect() {
|
||||||
|
this.clipboard.destroy();
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,7 +6,6 @@ import $ from 'jquery';
|
||||||
import '@materializecss/materialize/dist/css/materialize.css';
|
import '@materializecss/materialize/dist/css/materialize.css';
|
||||||
import '@materializecss/materialize/dist/js/materialize';
|
import '@materializecss/materialize/dist/js/materialize';
|
||||||
|
|
||||||
import ClipboardJS from 'clipboard';
|
|
||||||
import 'mathjax/es5/tex-svg';
|
import 'mathjax/es5/tex-svg';
|
||||||
|
|
||||||
/* Fonts */
|
/* Fonts */
|
||||||
|
@ -67,12 +66,6 @@ $(document).ready(() => {
|
||||||
$('#user_emailTwoFactor').on('change', () => {
|
$('#user_emailTwoFactor').on('change', () => {
|
||||||
$('#user_googleTwoFactor').prop('checked', false);
|
$('#user_googleTwoFactor').prop('checked', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// handle copy to clipboard for developer stuff
|
|
||||||
const clipboard = new ClipboardJS('.btn');
|
|
||||||
clipboard.on('success', (e) => {
|
|
||||||
e.clearSelection();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
(function darkTheme() {
|
(function darkTheme() {
|
||||||
|
|
|
@ -18,14 +18,14 @@
|
||||||
<td>{{ 'developer.client_parameter.field_id'|trans }}</td>
|
<td>{{ 'developer.client_parameter.field_id'|trans }}</td>
|
||||||
<td>
|
<td>
|
||||||
<strong><code>{{ client_id }}</code></strong>
|
<strong><code>{{ client_id }}</code></strong>
|
||||||
<button class="btn" data-clipboard-text="{{ client_id }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
<button class="btn" data-controller="clipboard" data-clipboard-text="{{ client_id }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ 'developer.client_parameter.field_secret'|trans }}</td>
|
<td>{{ 'developer.client_parameter.field_secret'|trans }}</td>
|
||||||
<td>
|
<td>
|
||||||
<strong><code>{{ client_secret }}</code></strong>
|
<strong><code>{{ client_secret }}</code></strong>
|
||||||
<button class="btn" data-clipboard-text="{{ client_secret }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
<button class="btn" data-controller="clipboard" data-clipboard-text="{{ client_secret }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -35,14 +35,14 @@
|
||||||
<td>{{ 'developer.existing_clients.field_id'|trans }}</td>
|
<td>{{ 'developer.existing_clients.field_id'|trans }}</td>
|
||||||
<td>
|
<td>
|
||||||
<strong><code>{{ client.clientId }}</code></strong>
|
<strong><code>{{ client.clientId }}</code></strong>
|
||||||
<button class="btn" data-clipboard-text="{{ client.clientId }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
<button class="btn" data-controller="clipboard" data-clipboard-text="{{ client.clientId }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ 'developer.existing_clients.field_secret'|trans }}</td>
|
<td>{{ 'developer.existing_clients.field_secret'|trans }}</td>
|
||||||
<td>
|
<td>
|
||||||
<strong><code>{{ client.secret }}</code></strong>
|
<strong><code>{{ client.secret }}</code></strong>
|
||||||
<button class="btn" data-clipboard-text="{{ client.secret }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
<button class="btn" data-controller="clipboard" data-clipboard-text="{{ client.secret }}">{{ 'developer.client.copy_to_clipboard'|trans }}</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue