]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/templates/jot-header.tpl
Merge pull request #4593 from annando/fix-ostatus
[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                 reply = prompt("{{$linkurl}}");
131                 if(reply && reply.length) {
132                         reply = bin2hex(reply);
133                         $('#profile-rotator').show();
134                         $.get('parse_url?binurl=' + reply, function(data) {
135                                 addeditortext(data);
136                                 $('#profile-rotator').hide();
137                         });
138                 }
139         }
140
141         function jotVideoURL() {
142                 reply = prompt("{{$vidurl}}");
143                 if(reply && reply.length) {
144                         addeditortext('[video]' + reply + '[/video]');
145                 }
146         }
147
148         function jotAudioURL() {
149                 reply = prompt("{{$audurl}}");
150                 if(reply && reply.length) {
151                         addeditortext('[audio]' + reply + '[/audio]');
152                 }
153         }
154
155
156         function jotGetLocation() {
157                 reply = prompt("{{$whereareu}}", $('#jot-location').val());
158                 if(reply && reply.length) {
159                         $('#jot-location').val(reply);
160                 }
161         }
162
163         function jotShare(id) {
164                 $.get('share/' + id, function(data) {
165                         // remove the former content of the text input
166                         $("#profile-jot-text").val("");
167                         initEditor(function(){
168                                 addeditortext(data);
169                         });
170                 });
171
172                 jotShow();
173
174                 $("#jot-popup").show();
175         }
176
177         function linkdropper(event) {
178                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
179                 if(linkFound)
180                         event.preventDefault();
181         }
182
183         function linkdrop(event) {
184                 var reply = event.dataTransfer.getData("text/uri-list");
185                 event.target.textContent = reply;
186                 event.preventDefault();
187                 if(reply && reply.length) {
188                         reply = bin2hex(reply);
189                         $('#profile-rotator').show();
190                         $.get('parse_url?binurl=' + reply, function(data) {
191                                 if (!editor) $("#profile-jot-text").val("");
192                                 initEditor(function(){
193                                         addeditortext(data);
194                                         $('#profile-rotator').hide();
195                                 });
196                         });
197                 }
198         }
199
200         function itemTag(id) {
201                 reply = prompt("{{$term}}");
202                 if(reply && reply.length) {
203                         reply = reply.replace('#','');
204                         if(reply.length) {
205
206                                 commentBusy = true;
207                                 $('body').css('cursor', 'wait');
208
209                                 $.get('tagger/' + id + '?term=' + reply);
210                                 if(timer) clearTimeout(timer);
211                                 timer = setTimeout(NavUpdate,3000);
212                                 liking = 1;
213                         }
214                 }
215         }
216
217         function itemFiler(id) {
218
219                 var bordercolor = $("input").css("border-color");
220
221                 $.get('filer/', function(data){
222                         $.colorbox({html:data});
223                         $("#id_term").keypress(function(){
224                                 $(this).css("border-color",bordercolor);
225                         })
226                         $("#select_term").change(function(){
227                                 $("#id_term").css("border-color",bordercolor);
228                         })
229
230                         $("#filer_save").click(function(e){
231                                 e.preventDefault();
232                                 reply = $("#id_term").val();
233                                 if(reply && reply.length) {
234                                         commentBusy = true;
235                                         $('body').css('cursor', 'wait');
236                                         $.get('filer/' + id + '?term=' + reply, NavUpdate);
237 //                                      if(timer) clearTimeout(timer);
238 //                                      timer = setTimeout(NavUpdate,3000);
239                                         liking = 1;
240                                         $.colorbox.close();
241                                 } else {
242                                         $("#id_term").css("border-color","#FF0000");
243                                 }
244                                 return false;
245                         });
246                 });
247
248         }
249
250         function jotClearLocation() {
251                 $('#jot-coord').val('');
252                 $('#profile-nolocation-wrapper').hide();
253         }
254
255         function addeditortext(data) {
256                 // get the textfield
257                 var textfield = document.getElementById("profile-jot-text");
258                 // check if the textfield does have the default-value
259                 jotTextOpenUI(textfield);
260                 // save already existent content
261                 var currentText = $("#profile-jot-text").val();
262                 //insert the data as new value
263                 textfield.value = currentText + data;
264         }
265
266         {{$geotag}}
267
268         function jotShow() {
269                 var modal = $('#jot-modal').modal();
270                 jotcache = $("#jot-sections");
271
272                 // Auto focus on the first enabled field in the modal
273                 modal.on('shown.bs.modal', function (e) {
274                         $('#jot-modal-content').find('select:not([disabled]), input:not([type=hidden]):not([disabled]), textarea:not([disabled])').first().focus();
275                 })
276
277                 modal
278                         .find('#jot-modal-content')
279                         .append(jotcache)
280                         .modal.show;
281         }
282
283         // Activate the jot text section in the jot modal
284         function jotActive() {
285                 // Make sure jot text does have really the active class (we do this because there are some
286                 // other events which trigger jot text (we need to do this for the desktop and mobile
287                 // jot nav
288                 var elem = $("#jot-modal .jot-nav #jot-text-lnk");
289                 var elemMobile = $("#jot-modal .jot-nav #jot-text-lnk-mobile")
290                 toggleJotNav(elem[0]);
291                 toggleJotNav(elemMobile[0]);
292         }
293 </script>