X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tpl%2Fdefault%2Fjs%2Fshaarli.js;h=cf628e87fc4f15e0b9d1c71a42b5e14994e613f1;hb=286757ab29660916f6b66d1fc0ad3b53aef337c8;hp=4ebb7815a1d4c4860224228e65f4f9f5f68af00f;hpb=82e3bb5f06dc531ee1080a0313833791a1c1f3c7;p=github%2Fshaarli%2FShaarli.git diff --git a/tpl/default/js/shaarli.js b/tpl/default/js/shaarli.js index 4ebb7815..cf628e87 100644 --- a/tpl/default/js/shaarli.js +++ b/tpl/default/js/shaarli.js @@ -138,6 +138,9 @@ window.onload = function () { }); foldAllButton.firstElementChild.classList.toggle('fa-chevron-down'); foldAllButton.firstElementChild.classList.toggle('fa-chevron-up'); + foldAllButton.title = state === 'down' + ? document.getElementById('translation-fold-all').innerHTML + : document.getElementById('translation-expand-all').innerHTML }); }); } @@ -146,7 +149,7 @@ window.onload = function () { { // Switch fold/expand - up = fold if (button.classList.contains('fa-chevron-up')) { - button.title = 'Expand'; + button.title = document.getElementById('translation-expand').innerHTML; if (description != null) { description.style.display = 'none'; } @@ -155,7 +158,7 @@ window.onload = function () { } } else { - button.title = 'Fold'; + button.title = document.getElementById('translation-fold').innerHTML; if (description != null) { description.style.display = 'block'; } @@ -173,7 +176,7 @@ window.onload = function () { var deleteLinks = document.querySelectorAll('.confirm-delete'); [].forEach.call(deleteLinks, function(deleteLink) { deleteLink.addEventListener('click', function(event) { - if(! confirm('Are you sure you want to delete this link ?')) { + if(! confirm(document.getElementById('translation-delete-link').innerHTML)) { event.preventDefault(); } }); @@ -275,8 +278,14 @@ window.onload = function () { }; function init () { function resize () { + /* Fix jumpy resizing: https://stackoverflow.com/a/18262927/1484919 */ + var scrollTop = window.pageYOffset || + (document.documentElement || document.body.parentNode || document.body).scrollTop; + description.style.height = 'auto'; description.style.height = description.scrollHeight+10+'px'; + + window.scrollTo(0, scrollTop); } /* 0-timeout to get the already changed text */ function delayedResize () { @@ -369,7 +378,7 @@ window.onload = function () { var linkCheckboxes = document.querySelectorAll('.delete-checkbox'); var bar = document.getElementById('actions'); [].forEach.call(linkCheckboxes, function(checkbox) { - checkbox.style.display = 'block'; + checkbox.style.display = 'inline-block'; checkbox.addEventListener('click', function(event) { var count = 0; var linkCheckedCheckboxes = document.querySelectorAll('.delete-checkbox:checked'); @@ -401,14 +410,14 @@ window.onload = function () { var message = 'Are you sure you want to delete '+ links.length +' links?\n'; message += 'This action is IRREVERSIBLE!\n\nTitles:\n'; - var ids = ''; + var ids = []; links.forEach(function(item) { message += ' - '+ item['title'] +'\n'; - ids += item['id'] +'+'; + ids.push(item['id']); }); if (window.confirm(message)) { - window.location = '?delete_link&lf_linkdate='+ ids +'&token='+ token.value; + window.location = '?delete_link&lf_linkdate='+ ids.join('+') +'&token='+ token.value; } }); } @@ -418,7 +427,8 @@ window.onload = function () { * * TODO: support error code in the backend for AJAX requests */ - var existingTags = document.querySelector('input[name="taglist"]').value.split(' '); + var tagList = document.querySelector('input[name="taglist"]'); + var existingTags = tagList ? tagList.value.split(' ') : []; var awesomepletes = []; // Display/Hide rename form @@ -515,7 +525,7 @@ window.onload = function () { }); }); - updateAwesompleteList('.rename-tag-input', document.querySelector('input[name="taglist"]').value.split(' '), awesomepletes); + updateAwesompleteList('.rename-tag-input', existingTags, awesomepletes); }; /** @@ -605,12 +615,13 @@ function htmlEntities(str) function activateFirefoxSocial(node) { var loc = location.href; - var baseURL = loc.substring(0, loc.lastIndexOf("/")); + var baseURL = loc.substring(0, loc.lastIndexOf("/") + 1); + var title = document.title; // Keeping the data separated (ie. not in the DOM) so that it's maintainable and diffable. var data = { - name: "{$shaarlititle}", - description: "The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community.", + name: title, + description: document.getElementById('translation-delete-link').innerHTML, author: "Shaarli", version: "1.0.0", @@ -618,7 +629,7 @@ function activateFirefoxSocial(node) { icon32URL: baseURL + "/images/favicon.ico", icon64URL: baseURL + "/images/favicon.ico", - shareURL: baseURL + "{noparse}?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi{/noparse}", + shareURL: baseURL + "?post=%{url}&title=%{title}&description=%{text}&source=firefoxsocialapi", homepageURL: baseURL }; node.setAttribute("data-service", JSON.stringify(data));