X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=assets%2Fdefault%2Fjs%2Fbase.js;h=99e03370a763c0bdd8214ce43a18a6eccaab394c;hb=a062416918c964e7551137c08b5b5671e6e2bb7e;hp=5cf037c2c99a6ad620a86bee4a88447d1c0a6b12;hpb=d42da5435024b4270d5abac11e6fcfa38354f3e9;p=github%2Fshaarli%2FShaarli.git diff --git a/assets/default/js/base.js b/assets/default/js/base.js index 5cf037c2..99e03370 100644 --- a/assets/default/js/base.js +++ b/assets/default/js/base.js @@ -98,29 +98,6 @@ function htmlEntities(str) { return str.replace(/[\u00A0-\u9999<>&]/gim, i => `&#${i.charCodeAt(0)};`); } -function activateFirefoxSocial(node) { - const loc = location.href; - const baseURL = loc.substring(0, loc.lastIndexOf('/') + 1); - - const data = { - name: document.title, - description: document.getElementById('translation-delete-link').innerHTML, - author: 'Shaarli', - version: '1.0.0', - - iconURL: `${baseURL}/images/favicon.ico`, - icon32URL: `${baseURL}/images/favicon.ico`, - icon64URL: `${baseURL}/images/favicon.ico`, - - shareURL: `${baseURL}?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi`, - homepageURL: baseURL, - }; - node.setAttribute('data-service', JSON.stringify(data)); - - const activate = new CustomEvent('ActivateSocialFeature'); - node.dispatchEvent(activate); -} - /** * Add the class 'hidden' to city options not attached to the current selected continent. * @@ -433,16 +410,6 @@ function init(description) { }); }); - /** - * Firefox Social - */ - const ffButton = document.getElementById('ff-social-button'); - if (ffButton != null) { - ffButton.addEventListener('click', (event) => { - activateFirefoxSocial(event.target); - }); - } - const continent = document.getElementById('continent'); const city = document.getElementById('city'); if (continent != null && city != null) { @@ -455,12 +422,12 @@ function init(description) { /** * Bulk actions */ - const linkCheckboxes = document.querySelectorAll('.delete-checkbox'); + const linkCheckboxes = document.querySelectorAll('.link-checkbox'); const bar = document.getElementById('actions'); [...linkCheckboxes].forEach((checkbox) => { checkbox.style.display = 'inline-block'; - checkbox.addEventListener('click', () => { - const linkCheckedCheckboxes = document.querySelectorAll('.delete-checkbox:checked'); + checkbox.addEventListener('change', () => { + const linkCheckedCheckboxes = document.querySelectorAll('.link-checkbox:checked'); const count = [...linkCheckedCheckboxes].length; if (count === 0 && bar.classList.contains('open')) { bar.classList.toggle('open'); @@ -477,7 +444,7 @@ function init(description) { event.preventDefault(); const links = []; - const linkCheckedCheckboxes = document.querySelectorAll('.delete-checkbox:checked'); + const linkCheckedCheckboxes = document.querySelectorAll('.link-checkbox:checked'); [...linkCheckedCheckboxes].forEach((checkbox) => { links.push({ id: checkbox.value, @@ -499,6 +466,25 @@ function init(description) { }); } + /** + * Select all button + */ + const selectAllButtons = document.querySelectorAll('.select-all-button'); + [...selectAllButtons].forEach((selectAllButton) => { + selectAllButton.addEventListener('click', (e) => { + e.preventDefault(); + const checked = selectAllButton.classList.contains('filter-off'); + [...selectAllButtons].forEach((selectAllButton2) => { + selectAllButton2.classList.toggle('filter-off'); + selectAllButton2.classList.toggle('filter-on'); + }); + [...linkCheckboxes].forEach((linkCheckbox) => { + linkCheckbox.checked = checked; + linkCheckbox.dispatchEvent(new Event('change')); + }); + }); + }); + /** * Tag list operations * @@ -581,7 +567,7 @@ function init(description) { event.preventDefault(); const block = findParent(event.target, 'div', { class: 'tag-list-item' }); const tag = block.getAttribute('data-tag'); - const refreshedToken = document.getElementById('token'); + const refreshedToken = document.getElementById('token').value; if (confirm(`Are you sure you want to delete the tag "${tag}"?`)) { const xhr = new XMLHttpRequest();