]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/js/compose.js
Update composer module to use the new ACL selector
[friendica.git] / view / theme / frio / js / compose.js
1 $(function() {
2         // Jot attachment live preview.
3         let $textarea = $('textarea[name=body]');
4         $textarea.linkPreview();
5         $textarea.keyup(function(){
6                 var textlen = $(this).val().length;
7                 $('#character-counter').text(textlen);
8         });
9         $textarea.editor_autocomplete(baseurl + '/search/acl');
10         $textarea.bbco_autocomplete('bbcode');
11
12         let location_button = document.getElementById('profile-location');
13         let location_input = document.getElementById('jot-location');
14
15         if (location_button && location_input) {
16                 updateLocationButtonDisplay(location_button, location_input);
17
18                 location_input.addEventListener('change', function () {
19                         updateLocationButtonDisplay(location_button, location_input);
20                 });
21                 location_input.addEventListener('keyup', function () {
22                         updateLocationButtonDisplay(location_button, location_input);
23                 });
24
25                 location_button.addEventListener('click', function() {
26                         if (location_input.value) {
27                                 location_input.value = '';
28                                 updateLocationButtonDisplay(location_button, location_input);
29                         } else if ("geolocation" in navigator) {
30                                 navigator.geolocation.getCurrentPosition(function(position) {
31                                         location_input.value = position.coords.latitude + ', ' + position.coords.longitude;
32                                         updateLocationButtonDisplay(location_button, location_input);
33                                 }, function (error) {
34                                         location_button.disabled = true;
35                                         updateLocationButtonDisplay(location_button, location_input);
36                                 });
37                         }
38                 });
39         }
40 });
41
42 function updateLocationButtonDisplay(location_button, location_input)
43 {
44         location_button.classList.remove('btn-primary');
45         if (location_input.value) {
46                 location_button.disabled = false;
47                 location_button.classList.add('btn-primary');
48                 location_button.title = location_button.dataset.titleClear;
49         } else if (!"geolocation" in navigator) {
50                 location_button.disabled = true;
51                 location_button.title = location_button.dataset.titleUnavailable;
52         } else if (location_button.disabled) {
53                 location_button.title = location_button.dataset.titleDisabled;
54         } else {
55                 location_button.title = location_button.dataset.titleSet;
56         }
57 }