]> git.mxchange.org Git - friendica.git/blob - view/templates/jot-header.tpl
9b47ed56a71c39d048b9700c2a4c9ba040f30db1
[friendica.git] / view / templates / jot-header.tpl
1
2
3 <script language="javascript" type="text/javascript">
4
5 var editor = false;
6 var textlen = 0;
7
8 function initEditor(callback) {
9         if (editor == false) {
10                 var  colorbox_options = {
11                         {{if $is_mobile}}
12                         'width' : '100%',
13                         'height' : '100%',
14                         {{/if}}
15                         'inline' : true,
16                         'transition' : 'elastic'
17                 }
18
19                 $("#profile-jot-text-loading").show();
20                 $("#profile-jot-text-loading").hide();
21                 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
22                 $("#profile-jot-text").editor_autocomplete(baseurl + '/search/acl');
23                 $("#profile-jot-text").bbco_autocomplete('bbcode');
24                 $("a#jot-perms-icon").colorbox(colorbox_options);
25                 $(".jothidden").show();
26
27                 $("#profile-jot-text").keyup(function(){
28                         var textlen = $(this).val().length;
29                         $('#character-counter').text(textlen);
30                 });
31
32                 editor = true;
33         }
34         if (typeof callback != "undefined") {
35                 callback();
36         }
37 }
38
39 function enableOnUser(){
40         if (editor) {
41                 return;
42         }
43         $(this).val('');
44         initEditor();
45 }
46
47 </script>
48 <script type="text/javascript" src="{{$baseurl}}/view/js/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
49 <script>
50         var ispublic = '{{$ispublic nofilter}}';
51
52
53         $(document).ready(function() {
54
55                 /* enable editor on focus and click */
56                 $("#profile-jot-text").focus(enableOnUser);
57                 $("#profile-jot-text").click(enableOnUser);
58
59                 /* show images / file browser window
60                  *
61                  **/
62
63                 /* callback */
64                 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
65                         $.colorbox.close();
66                         addeditortext(embedcode);
67                 });
68                 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
69                         $.colorbox.close();
70                         addeditortext(embedcode);
71                 });
72
73                 $('#wall-image-upload').on('click', function(){
74                         Dialog.doImageBrowser("main");
75                 });
76
77                 $('#wall-file-upload').on('click', function(){
78                         Dialog.doFileBrowser("main");
79                 });
80         });
81
82
83         function deleteCheckedItems() {
84                 if(confirm('{{$delitems}}')) {
85                         var checkedstr = '';
86
87                         $("#item-delete-selected").hide();
88                         $('#item-delete-selected-rotator').show();
89
90                         $('.item-select').each( function() {
91                                 if($(this).is(':checked')) {
92                                         if(checkedstr.length != 0) {
93                                                 checkedstr = checkedstr + ',' + $(this).val();
94                                         }
95                                         else {
96                                                 checkedstr = $(this).val();
97                                         }
98                                 }
99                         });
100                         $.post('item', { dropitems: checkedstr }, function(data) {
101                                 window.location.reload();
102                         });
103                 }
104         }
105
106         function jotGetLink() {
107                 reply = prompt("{{$linkurl}}");
108                 if(reply && reply.length) {
109                         reply = bin2hex(reply);
110                         $('#profile-rotator').show();
111                         $.get('parseurl?binurl=' + reply, function(data) {
112                                 addeditortext(data);
113                                 $('#profile-rotator').hide();
114                         });
115                 }
116         }
117
118         function jotVideoURL() {
119                 reply = prompt("{{$vidurl}}");
120                 if(reply && reply.length) {
121                         addeditortext('[video]' + reply + '[/video]');
122                 }
123         }
124
125         function jotAudioURL() {
126                 reply = prompt("{{$audurl}}");
127                 if(reply && reply.length) {
128                         addeditortext('[audio]' + reply + '[/audio]');
129                 }
130         }
131
132
133         function jotGetLocation() {
134                 reply = prompt("{{$whereareu}}", $('#jot-location').val());
135                 if(reply && reply.length) {
136                         $('#jot-location').val(reply);
137                 }
138         }
139
140         function jotShare(id) {
141                 if ($('#jot-popup').length != 0) $('#jot-popup').show();
142
143                 $('#like-rotator-' + id).show();
144                 $.get('share/' + id, function(data) {
145                         if (!editor) $("#profile-jot-text").val("");
146                         initEditor(function(){
147                                 addeditortext(data);
148                                 $('#like-rotator-' + id).hide();
149                                 $(window).scrollTop(0);
150                         });
151
152                 });
153         }
154
155         function linkdropper(event) {
156                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
157                 if(linkFound)
158                         event.preventDefault();
159         }
160
161         function linkdrop(event) {
162                 var reply = event.dataTransfer.getData("text/uri-list");
163                 event.target.textContent = reply;
164                 event.preventDefault();
165                 if(reply && reply.length) {
166                         reply = bin2hex(reply);
167                         $('#profile-rotator').show();
168                         $.get('parseurl?binurl=' + reply, function(data) {
169                                 if (!editor) $("#profile-jot-text").val("");
170                                 initEditor(function(){
171                                         addeditortext(data);
172                                         $('#profile-rotator').hide();
173                                 });
174                         });
175                 }
176         }
177
178         function itemTag(id) {
179                 reply = prompt("{{$term}}");
180                 if(reply && reply.length) {
181                         reply = reply.replace('#','');
182                         if(reply.length) {
183
184                                 commentBusy = true;
185                                 $('body').css('cursor', 'wait');
186
187                                 $.post('post/' + id + '/tag/add', {term: reply});
188                                 if(timer) clearTimeout(timer);
189                                 timer = setTimeout(NavUpdate,3000);
190                                 liking = 1;
191                         }
192                 }
193         }
194
195         function itemFiler(id) {
196
197                 var bordercolor = $("input").css("border-color");
198
199                 $.get('filer/', function(data){
200                         $.colorbox({html:data});
201                         $("#id_term").keypress(function(){
202                                 $(this).css("border-color",bordercolor);
203                         })
204                         $("#select_term").change(function(){
205                                 $("#id_term").css("border-color",bordercolor);
206                         })
207
208                         $("#filer_save").click(function(e){
209                                 e.preventDefault();
210                                 reply = $("#id_term").val();
211                                 if(reply && reply.length) {
212                                         commentBusy = true;
213                                         $('body').css('cursor', 'wait');
214                                         $.get('filer/' + id + '?term=' + reply, NavUpdate);
215 //                                      if(timer) clearTimeout(timer);
216 //                                      timer = setTimeout(NavUpdate,3000);
217                                         liking = 1;
218                                         force_update = true;
219                                         $.colorbox.close();
220                                 } else {
221                                         $("#id_term").css("border-color","#FF0000");
222                                 }
223                                 return false;
224                         });
225                 });
226
227         }
228
229         function jotClearLocation() {
230                 $('#jot-coord').val('');
231                 $('#profile-nolocation-wrapper').hide();
232         }
233
234         function addeditortext(data) {
235                 var currentText = $("#profile-jot-text").val();
236                 $("#profile-jot-text").val(currentText + data);
237         }
238
239         {{$geotag nofilter}}
240
241 </script>
242