]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/templates/jot-header.tpl
Merge remote-tracking branch 'upstream/develop' into aria
[friendica.git] / view / theme / frio / templates / jot-header.tpl
1
2 <script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js"></script>
3 <script type="text/javascript" src="{{$baseurl}}/view/js/linkPreview.js"></script>
4 <script type="text/javascript" src="{{$baseurl}}/view/theme/frio/js/jot.js"></script>
5
6 <script type="text/javascript">
7         var editor = false;
8         var textlen = 0;
9
10         function initEditor(callback) {
11                 if (editor == false) {
12                         $("#profile-jot-text-loading").show();
13                         $("#profile-jot-text-loading").hide();
14                         //$("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
15                         $("#jot-category").show();
16                         $("#jot-category").addClass("jot-category-ex");
17                         $("#jot-profile-jot-wrapper").show();
18                         $("#profile-jot-text").editor_autocomplete(baseurl + '/search/acl');
19                         $("#profile-jot-text").bbco_autocomplete('bbcode');
20                         $("a#jot-perms-icon").colorbox({
21                                 'inline' : true,
22                                 'transition' : 'elastic'
23                         });
24                         $(".jothidden").show();
25                         $("#profile-jot-text").keyup(function(){
26                                 var textlen = $(this).val().length;
27                                 $('#character-counter').text(textlen);
28                         });
29
30                         editor = true;
31                 }
32                 if (typeof callback != "undefined") {
33                         callback();
34                 }
35         }
36
37         function enableOnUser(){
38                 initEditor();
39         }
40 </script>
41
42 <script type="text/javascript">
43         var ispublic = '{{$ispublic nofilter}}';
44         aStr.linkurl = '{{$linkurl}}';
45
46
47         $(document).ready(function() {
48
49                 /* enable editor on focus and click */
50                 $("#profile-jot-text").focus(enableOnUser);
51                 $("#profile-jot-text").click(enableOnUser);
52
53                 // When clicking on a forum in acl we should remove the profile jot textarea
54                 // default value before inserting the forum mention
55                 $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
56                         jotTextOpenUI(document.getElementById("profile-jot-text"));
57                 });
58
59
60                 /* show images / file browser window
61                  *
62                  **/
63
64                 /* callback */
65                 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
66                         ///@todo this part isn't ideal and need to be done in a better way
67                         jotTextOpenUI(document.getElementById("profile-jot-text"));
68                         jotActive();
69                         addeditortext(embedcode);
70                 });
71                 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
72                         jotTextOpenUI(document.getElementById("profile-jot-text"));
73                         jotActive();
74                         addeditortext(embedcode);
75                 });
76
77                 $('#wall-image-upload').on('click', function(){
78                         Dialog.doImageBrowser("main");
79                         jotActive();
80                 });
81
82                 $('#wall-file-upload').on('click', function(){
83                         Dialog.doFileBrowser("main");
84                         jotActive();
85                 });
86         });
87
88         function deleteCheckedItems() {
89                 if(confirm('{{$delitems}}')) {
90                         var checkedstr = '';
91                         var ItemsToDelete = {};
92
93                         $("#item-delete-selected").hide();
94                         $('#item-delete-selected-rotator').show();
95                         $('body').css('cursor', 'wait');
96
97                         $('.item-select').each( function() {
98                                 if($(this).is(':checked')) {
99                                         if(checkedstr.length != 0) {
100                                                 checkedstr = checkedstr + ',' + $(this).val();
101                                                 var deleteItem = this.closest(".wall-item-container");
102                                                 ItemsToDelete[deleteItem.id] = deleteItem;
103                                         }
104                                         else {
105                                                 checkedstr = $(this).val();
106                                         }
107
108                                         // Get the corresponding item container
109                                         var deleteItem = this.closest(".wall-item-container");
110                                         ItemsToDelete[deleteItem.id] = deleteItem;
111                                 }
112                         });
113
114                         // Fade the the the container from the items we want to delete
115                         for(var key in  ItemsToDelete) {
116                                 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
117                         };
118
119                         $.post('item', { dropitems: checkedstr }, function(data) {
120                         }).done(function() {
121                                 // Loop through the ItemsToDelete Object and remove
122                                 // corresponding item div
123                                 for(var key in  ItemsToDelete) {
124                                         $(ItemsToDelete[key]).remove();
125                                 }
126                                 $('body').css('cursor', 'auto');
127                                 $('#item-delete-selected-rotator').hide();
128                         });
129                 }
130         }
131
132         function jotVideoURL() {
133                 reply = prompt("{{$vidurl}}");
134                 if(reply && reply.length) {
135                         addeditortext('[video]' + reply + '[/video]');
136                 }
137         }
138
139         function jotAudioURL() {
140                 reply = prompt("{{$audurl}}");
141                 if(reply && reply.length) {
142                         addeditortext('[audio]' + reply + '[/audio]');
143                 }
144         }
145
146         function jotGetLocation() {
147                 reply = prompt("{{$whereareu}}", $('#jot-location').val());
148                 if(reply && reply.length) {
149                         $('#jot-location').val(reply);
150                 }
151         }
152
153         function jotShare(id) {
154                 $.get('share/' + id, function(data) {
155                         // remove the former content of the text input
156                         $("#profile-jot-text").val("");
157                         initEditor(function(){
158                                 addeditortext(data);
159                         });
160                 });
161
162                 jotShow();
163
164                 $("#jot-popup").show();
165         }
166
167         function linkDropper(event) {
168                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
169                 if(linkFound)
170                         event.preventDefault();
171         }
172
173         function linkDrop(event) {
174                 var reply = event.dataTransfer.getData("text/uri-list");
175                 var noAttachment = '';
176                 event.target.textContent = reply;
177                 event.preventDefault();
178                 if(reply && reply.length) {
179                         reply = bin2hex(reply);
180                         $('#profile-rotator').show();
181                         if (currentText.includes("[attachment") && currentText.includes("[/attachment]")) {
182                                 noAttachment = '&noAttachment=1';
183                         }
184                         $.get('parse_url?binurl=' + reply + noAttachment, function(data) {
185                                 if (!editor) $("#profile-jot-text").val("");
186                                 initEditor(function(){
187                                         addeditortext(data);
188                                         $('#profile-rotator').hide();
189                                 });
190                         });
191                         autosize.update($("#profile-jot-text"));
192                 }
193         }
194
195         function itemTag(id) {
196                 reply = prompt("{{$term}}");
197                 if(reply && reply.length) {
198                         reply = reply.replace('#','');
199                         if(reply.length) {
200
201                                 commentBusy = true;
202                                 $('body').css('cursor', 'wait');
203
204                                 $.get('tagger/' + id + '?term=' + reply);
205                                 if(timer) clearTimeout(timer);
206                                 timer = setTimeout(NavUpdate,3000);
207                                 liking = 1;
208                         }
209                 }
210         }
211
212         function itemFiler(id) {
213                 var bordercolor = $("input").css("border-color");
214
215                 $.get('filer/', function(data){
216                         $.colorbox({html:data});
217                         $("#id_term").keypress(function(){
218                                 $(this).css("border-color",bordercolor);
219                         })
220                         $("#select_term").change(function(){
221                                 $("#id_term").css("border-color",bordercolor);
222                         })
223
224                         $("#filer_save").click(function(e){
225                                 e.preventDefault();
226                                 reply = $("#id_term").val();
227                                 if(reply && reply.length) {
228                                         commentBusy = true;
229                                         $('body').css('cursor', 'wait');
230                                         $.get('filer/' + id + '?term=' + reply, NavUpdate);
231 //                                      if(timer) clearTimeout(timer);
232 //                                      timer = setTimeout(NavUpdate,3000);
233                                         liking = 1;
234                                         $.colorbox.close();
235                                 } else {
236                                         $("#id_term").css("border-color","#FF0000");
237                                 }
238                                 return false;
239                         });
240                 });
241
242         }
243
244         function jotClearLocation() {
245                 $('#jot-coord').val('');
246                 $('#profile-nolocation-wrapper').hide();
247         }
248
249         function addeditortext(data) {
250                 // get the textfield
251                 var textfield = document.getElementById("profile-jot-text");
252                 // check if the textfield does have the default-value
253                 jotTextOpenUI(textfield);
254                 // save already existent content
255                 var currentText = $("#profile-jot-text").val();
256                 //insert the data as new value
257                 textfield.value = currentText + data;
258                 autosize.update($("#profile-jot-text"));
259         }
260
261         {{$geotag nofilter}}
262
263         function jotShow() {
264                 var modal = $('#jot-modal').modal();
265                 jotcache = $("#jot-sections");
266
267                 // Auto focus on the first enabled field in the modal
268                 modal.on('shown.bs.modal', function (e) {
269                         $('#jot-modal-content').find('select:not([disabled]), input:not([type=hidden]):not([disabled]), textarea:not([disabled])').first().focus();
270                 })
271
272                 modal
273                         .find('#jot-modal-content')
274                         .append(jotcache)
275                         .modal.show;
276
277                 // Jot attachment live preview.
278                 linkPreview = $('#profile-jot-text').linkPreview();
279         }
280
281         // Activate the jot text section in the jot modal
282         function jotActive() {
283                 // Make sure jot text does have really the active class (we do this because there are some
284                 // other events which trigger jot text (we need to do this for the desktop and mobile
285                 // jot nav
286                 var elem = $("#jot-modal .jot-nav #jot-text-lnk");
287                 var elemMobile = $("#jot-modal .jot-nav #jot-text-lnk-mobile")
288                 toggleJotNav(elem[0]);
289                 toggleJotNav(elemMobile[0]);
290         }
291 </script>