mirror of
https://github.com/friendica/friendica
synced 2024-11-14 18:22:55 +00:00
8f4f6899dd
- Remove ACL-specific code from compose-footer - Move compose-footer template remaining content to compose.js
57 lines
2 KiB
JavaScript
57 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;
|
|
}
|
|
}
|