-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopy-code-area.js
More file actions
16 lines (16 loc) · 825 Bytes
/
copy-code-area.js
File metadata and controls
16 lines (16 loc) · 825 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(function() {
/* globals require, $ */
'use strict';
require(['clipboard'], clipboard => {
new clipboard('.copy-code', { target: trigger => trigger.previousElementSibling })
.on('success', e => {
e.clearSelection();
$(e.trigger).attr('data-original-title', 'הועתק!').tooltip('fixTitle').tooltip('show');
setTimeout(() => $(e.trigger).attr('data-original-title', 'העתק').tooltip('fixTitle').tooltip('hide'), 1000);
});
});
$(window).on('action:posts.loaded action:topic.loaded action:posts.edited', () => {
$('[component="post/content"]>pre').wrap('<div class="pre-wrapper"><div>').after('<i class="copy-code fa fa-copy"></i>');
$('.copy-code').attr('title', 'העתק').tooltip({ container: 'body' });
});
})();