mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fewer js-functions
This commit is contained in:
parent
8a8f61c568
commit
5077419b68
@ -1,40 +1,31 @@
|
|||||||
function attachClipboard(selector) {
|
function attachClipboard(selector, containerselector, textElement) {
|
||||||
|
// set container
|
||||||
var cis = new ClipboardJS(selector, {
|
if (containerselector){
|
||||||
text: function(trigger) {
|
containerselector = document.getElementById(containerselector);
|
||||||
var content = trigger.parentElement.parentElement.textContent;
|
} else {
|
||||||
|
containerselector = document.body;
|
||||||
return content.trim();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set text-function
|
||||||
|
if (textElement){
|
||||||
|
text = function() {
|
||||||
|
return document.getElementById(textElement).textContent;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
text = function() {
|
||||||
|
var content = trigger.parentElement.parentElement.textContent;return content.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// create Clipboard
|
||||||
|
var cis = new ClipboardJS(selector, {
|
||||||
|
text: text,
|
||||||
|
container: containerselector
|
||||||
});
|
});
|
||||||
console.log(cis);
|
console.log(cis);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function attachmodalClipboard(selector) {
|
|
||||||
|
|
||||||
new ClipboardJS(selector, {
|
|
||||||
text: function(trigger) {
|
|
||||||
var content = trigger.parentElement.parentElement.textContent;
|
|
||||||
return content.trim();
|
|
||||||
},
|
|
||||||
container: document.getElementById('modal-about')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function AboutClipboard(selector) {
|
|
||||||
|
|
||||||
new ClipboardJS(selector, {
|
|
||||||
text: function() {
|
|
||||||
console.log('about');
|
|
||||||
return document.getElementById('about-copy-text').textContent;
|
|
||||||
},
|
|
||||||
container: document.getElementById('modal-about')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function inventreeDocReady() {
|
function inventreeDocReady() {
|
||||||
/* Run this function when the HTML document is loaded.
|
/* Run this function when the HTML document is loaded.
|
||||||
* This will be called for every page that extends "base.html"
|
* This will be called for every page that extends "base.html"
|
||||||
@ -88,8 +79,8 @@ function inventreeDocReady() {
|
|||||||
|
|
||||||
// Initialize clipboard-buttons
|
// Initialize clipboard-buttons
|
||||||
attachClipboard('.clip-btn');
|
attachClipboard('.clip-btn');
|
||||||
attachmodalClipboard('.clip-btn');
|
attachClipboard('.clip-btn', 'modal-about'); // modals
|
||||||
AboutClipboard('.clip-btn-version');
|
attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text'); // version-text
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user