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