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