|
@@ -216,14 +216,14 @@ window.onload = function () {
|
|
|
/**
|
|
|
* Autofocus text fields
|
|
|
*/
|
|
|
- // ES6 syntax
|
|
|
- let autofocusElements = document.querySelectorAll('.autofocus');
|
|
|
- for (let autofocusElement of autofocusElements) {
|
|
|
- if (autofocusElement.value == '') {
|
|
|
+ var autofocusElements = document.querySelectorAll('.autofocus');
|
|
|
+ var breakLoop = false;
|
|
|
+ [].forEach.call(autofocusElements, function(autofocusElement) {
|
|
|
+ if (autofocusElement.value == '' && ! breakLoop) {
|
|
|
autofocusElement.focus();
|
|
|
- break;
|
|
|
+ breakLoop = true;
|
|
|
}
|
|
|
- }
|
|
|
+ });
|
|
|
|
|
|
/**
|
|
|
* Handle sub menus/forms
|
|
@@ -357,11 +357,61 @@ window.onload = function () {
|
|
|
var continent = document.getElementById('continent');
|
|
|
var city = document.getElementById('city');
|
|
|
if (continent != null && city != null) {
|
|
|
- continent.addEventListener('change', function(event) {
|
|
|
+ continent.addEventListener('change', function (event) {
|
|
|
hideTimezoneCities(city, continent.options[continent.selectedIndex].value, true);
|
|
|
});
|
|
|
hideTimezoneCities(city, continent.options[continent.selectedIndex].value, false);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Bulk actions
|
|
|
+ */
|
|
|
+ var linkCheckboxes = document.querySelectorAll('.delete-checkbox');
|
|
|
+ var bar = document.getElementById('actions');
|
|
|
+ [].forEach.call(linkCheckboxes, function(checkbox) {
|
|
|
+ checkbox.style.display = 'block';
|
|
|
+ checkbox.addEventListener('click', function(event) {
|
|
|
+ var count = 0;
|
|
|
+ var linkCheckedCheckboxes = document.querySelectorAll('.delete-checkbox:checked');
|
|
|
+ [].forEach.call(linkCheckedCheckboxes, function(checkbox) {
|
|
|
+ count++;
|
|
|
+ });
|
|
|
+ if (count == 0 && bar.classList.contains('open')) {
|
|
|
+ bar.classList.toggle('open');
|
|
|
+ } else if (count > 0 && ! bar.classList.contains('open')) {
|
|
|
+ bar.classList.toggle('open');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ var deleteButton = document.getElementById('actions-delete');
|
|
|
+ var token = document.querySelector('input[type="hidden"][name="token"]');
|
|
|
+ if (deleteButton != null && token != null) {
|
|
|
+ deleteButton.addEventListener('click', function(event) {
|
|
|
+ event.preventDefault();
|
|
|
+
|
|
|
+ var links = [];
|
|
|
+ var linkCheckedCheckboxes = document.querySelectorAll('.delete-checkbox:checked');
|
|
|
+ [].forEach.call(linkCheckedCheckboxes, function(checkbox) {
|
|
|
+ links.push({
|
|
|
+ 'id': checkbox.value,
|
|
|
+ 'title': document.querySelector('.linklist-item[data-id="'+ checkbox.value +'"] .linklist-link').innerHTML
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ var message = 'Are you sure you want to delete '+ links.length +' links?\n';
|
|
|
+ message += 'This action is IRREVERSIBLE!\n\nTitles:\n';
|
|
|
+ var ids = '';
|
|
|
+ links.forEach(function(item) {
|
|
|
+ message += ' - '+ item['title'] +'\n';
|
|
|
+ ids += item['id'] +'+';
|
|
|
+ });
|
|
|
+
|
|
|
+ if (window.confirm(message)) {
|
|
|
+ window.location = '?delete_link&lf_linkdate='+ ids +'&token='+ token.value;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
function activateFirefoxSocial(node) {
|
|
@@ -397,7 +447,7 @@ function activateFirefoxSocial(node) {
|
|
|
*/
|
|
|
function hideTimezoneCities(cities, currentContinent, reset = false) {
|
|
|
var first = true;
|
|
|
- [].forEach.call(cities, function(option) {
|
|
|
+ [].forEach.call(cities, function (option) {
|
|
|
if (option.getAttribute('data-continent') != currentContinent) {
|
|
|
option.className = 'hidden';
|
|
|
} else {
|