friendica_2021.01_tupambae_.../view/theme/frio/js/compose.js
Hypolite Petovan 8f4f6899dd Update composer module to use the new ACL selector
- Remove ACL-specific code from compose-footer
- Move compose-footer template remaining content to compose.js
2019-11-28 12:54:56 -05:00

58 lines
2 KiB
JavaScript

$(function() {
// Jot attachment live preview.
let $textarea = $('textarea[name=body]');
$textarea.linkPreview();
$textarea.keyup(function(){
var textlen = $(this).val().length;
$('#character-counter').text(textlen);
});
$textarea.editor_autocomplete(baseurl + '/search/acl');
$textarea.bbco_autocomplete('bbcode');
let location_button = document.getElementById('profile-location');
let location_input = document.getElementById('jot-location');
if (location_button && location_input) {
updateLocationButtonDisplay(location_button, location_input);
location_input.addEventListener('change', function () {
updateLocationButtonDisplay(location_button, location_input);
});
location_input.addEventListener('keyup', function () {
updateLocationButtonDisplay(location_button, location_input);
});
location_button.addEventListener('click', function() {
if (location_input.value) {
location_input.value = '';
updateLocationButtonDisplay(location_button, location_input);
} else if ("geolocation" in navigator) {
navigator.geolocation.getCurrentPosition(function(position) {
location_input.value = position.coords.latitude + ', ' + position.coords.longitude;
updateLocationButtonDisplay(location_button, location_input);
}, function (error) {
location_button.disabled = true;
updateLocationButtonDisplay(location_button, location_input);
});
}
});
}
});
function updateLocationButtonDisplay(location_button, location_input)
{
location_button.classList.remove('btn-primary');
if (location_input.value) {
location_button.disabled = false;
location_button.classList.add('btn-primary');
location_button.title = location_button.dataset.titleClear;
} else if (!"geolocation" in navigator) {
location_button.disabled = true;
location_button.title = location_button.dataset.titleUnavailable;
} else if (location_button.disabled) {
location_button.title = location_button.dataset.titleDisabled;
} else {
location_button.title = location_button.dataset.titleSet;
}
}