]> git.mxchange.org Git - friendica.git/blob - view/templates/jot-header.tpl
Merge pull request #2444 from annando/1604-twidere-html
[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 var plaintext = '{{$editselect}}';
8
9 function initEditor(cb){
10         if (editor==false){
11                 var  colorbox_options = {
12                         {{if $APP->is_mobile}}
13                         'width' : '100%',
14                         'height' : '100%',
15                         {{/if}}
16                         'inline' : true,
17                         'transition' : 'elastic'
18                 }
19                 
20                 
21                 
22                 $("#profile-jot-text-loading").show();
23                 if(plaintext == 'none') {
24                         $("#profile-jot-text-loading").hide();
25                         $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
26                         $("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
27                         editor = true;
28                         $("a#jot-perms-icon").colorbox(colorbox_options);
29                         $(".jothidden").show();
30                         if (typeof cb!="undefined") cb();
31                         return;
32                 }
33                 tinyMCE.init({
34                         theme : "advanced",
35                         mode : "specific_textareas",
36                         editor_selector: {{$editselect}},
37                         auto_focus: "profile-jot-text",
38                         plugins : "bbcode,paste,autoresize, inlinepopups",
39                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
40                         theme_advanced_buttons2 : "",
41                         theme_advanced_buttons3 : "",
42                         theme_advanced_toolbar_location : "top",
43                         theme_advanced_toolbar_align : "center",
44                         theme_advanced_blockformats : "blockquote,code",
45                         theme_advanced_resizing : true,
46                         gecko_spellcheck : true,
47                         paste_text_sticky : true,
48                         entity_encoding : "raw",
49                         add_unload_trigger : false,
50                         remove_linebreaks : false,
51                         //force_p_newlines : false,
52                         //force_br_newlines : true,
53                         forced_root_block : 'div',
54                         convert_urls: false,
55                         content_css: "{{$baseurl}}/view/custom_tinymce.css",
56                         theme_advanced_path : false,
57                         file_browser_callback : "fcFileBrowser",
58                         setup : function(ed) {
59                                 cPopup = null;
60                                 ed.onKeyDown.add(function(ed,e) {
61                                         if(cPopup !== null)
62                                                 cPopup.onkey(e);
63                                 });
64
65                                 ed.onKeyUp.add(function(ed, e) {
66                                         var txt = tinyMCE.activeEditor.getContent();
67                                         match = txt.match(/@([^ \n]+)$/);
68                                         if(match!==null) {
69                                                 if(cPopup === null) {
70                                                         cPopup = new ACPopup(this,baseurl+"/acl");
71                                                 }
72                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
73                                                 if(! cPopup.ready) cPopup = null;
74                                         }
75                                         else {
76                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
77                                         }
78
79                                         textlen = txt.length;
80                                         if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
81                                                 $('#profile-jot-desc').html(ispublic);
82                                         }
83                                         else {
84                                                 $('#profile-jot-desc').html('&nbsp;');
85                                         }
86
87                                  //Character count
88
89                                         if(textlen <= 140) {
90                                                 $('#character-counter').removeClass('red');
91                                                 $('#character-counter').removeClass('orange');
92                                                 $('#character-counter').addClass('grey');
93                                         }
94                                         if((textlen > 140) && (textlen <= 420)) {
95                                                 $('#character-counter').removeClass('grey');
96                                                 $('#character-counter').removeClass('red');
97                                                 $('#character-counter').addClass('orange');
98                                         }
99                                         if(textlen > 420) {
100                                                 $('#character-counter').removeClass('grey');
101                                                 $('#character-counter').removeClass('orange');
102                                                 $('#character-counter').addClass('red');
103                                         }
104                                         $('#character-counter').text(textlen);
105                                 });
106
107                                 ed.onInit.add(function(ed) {
108                                         ed.pasteAsPlainText = true;
109                                         $("#profile-jot-text-loading").hide();
110                                         $(".jothidden").show();
111                                         if (typeof cb!="undefined") cb();
112                                 });
113
114                         }
115                 });
116                 editor = true;
117                 // setup acl popup
118                 $("a#jot-perms-icon").colorbox(colorbox_options);
119         } else {
120                 if (typeof cb!="undefined") cb();
121         }
122 }
123
124 function enableOnUser(){
125         if (editor) return;
126         $(this).val("");
127         initEditor();
128 }
129
130 </script>
131 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
132 <script>
133         var ispublic = '{{$ispublic}}';
134
135
136         $(document).ready(function() {
137
138                 /* enable tinymce on focus and click */
139                 $("#profile-jot-text").focus(enableOnUser);
140                 $("#profile-jot-text").click(enableOnUser);
141
142
143
144
145                 /* show images / file browser window
146                  *
147                  **/
148
149                 /* callback */
150                 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
151                         $.colorbox.close();
152                         addeditortext(embedcode);
153                 });
154                 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
155                         $.colorbox.close();
156                         addeditortext(embedcode);
157                 });
158
159                 $('#wall-image-upload').on('click', function(){
160                         Dialog.doImageBrowser("main");
161                 });
162
163                 $('#wall-file-upload').on('click', function(){
164                         Dialog.doFileBrowser("main");
165                 });
166
167                 /**
168                         var uploader = new window.AjaxUpload(
169                                 'wall-image-upload',
170                                 { action: 'wall_upload/{{$nickname}}',
171                                         name: 'userfile',
172                                         onSubmit: function(file,ext) { $('#profile-rotator').show(); },
173                                         onComplete: function(file,response) {
174                                                 addeditortext(response);
175                                                 $('#profile-rotator').hide();
176                                         }
177                                 }
178                         );
179                         var file_uploader = new window.AjaxUpload(
180                                 'wall-file-upload',
181                                 { action: 'wall_attach/{{$nickname}}',
182                                         name: 'userfile',
183                                         onSubmit: function(file,ext) { $('#profile-rotator').show(); },
184                                         onComplete: function(file,response) {
185                                                 addeditortext(response);
186                                                 $('#profile-rotator').hide();
187                                         }
188                                 }
189                         );
190
191                 }
192                 **/
193         });
194
195
196         function deleteCheckedItems() {
197                 if(confirm('{{$delitems}}')) {
198                         var checkedstr = '';
199
200                         $("#item-delete-selected").hide();
201                         $('#item-delete-selected-rotator').show();
202
203                         $('.item-select').each( function() {
204                                 if($(this).is(':checked')) {
205                                         if(checkedstr.length != 0) {
206                                                 checkedstr = checkedstr + ',' + $(this).val();
207                                         }
208                                         else {
209                                                 checkedstr = $(this).val();
210                                         }
211                                 }
212                         });
213                         $.post('item', { dropitems: checkedstr }, function(data) {
214                                 window.location.reload();
215                         });
216                 }
217         }
218
219         function jotGetLink() {
220                 reply = prompt("{{$linkurl}}");
221                 if(reply && reply.length) {
222                         reply = bin2hex(reply);
223                         $('#profile-rotator').show();
224                         $.get('parse_url?binurl=' + reply, function(data) {
225                                 addeditortext(data);
226                                 $('#profile-rotator').hide();
227                         });
228                 }
229         }
230
231         function jotVideoURL() {
232                 reply = prompt("{{$vidurl}}");
233                 if(reply && reply.length) {
234                         addeditortext('[video]' + reply + '[/video]');
235                 }
236         }
237
238         function jotAudioURL() {
239                 reply = prompt("{{$audurl}}");
240                 if(reply && reply.length) {
241                         addeditortext('[audio]' + reply + '[/audio]');
242                 }
243         }
244
245
246         function jotGetLocation() {
247                 reply = prompt("{{$whereareu}}", $('#jot-location').val());
248                 if(reply && reply.length) {
249                         $('#jot-location').val(reply);
250                 }
251         }
252
253         function jotShare(id) {
254                 if ($('#jot-popup').length != 0) $('#jot-popup').show();
255
256                 $('#like-rotator-' + id).show();
257                 $.get('share/' + id, function(data) {
258                         if (!editor) $("#profile-jot-text").val("");
259                         initEditor(function(){
260                                 addeditortext(data);
261                                 $('#like-rotator-' + id).hide();
262                                 $(window).scrollTop(0);
263                         });
264
265                 });
266         }
267
268         function linkdropper(event) {
269                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
270                 if(linkFound)
271                         event.preventDefault();
272         }
273
274         function linkdrop(event) {
275                 var reply = event.dataTransfer.getData("text/uri-list");
276                 event.target.textContent = reply;
277                 event.preventDefault();
278                 if(reply && reply.length) {
279                         reply = bin2hex(reply);
280                         $('#profile-rotator').show();
281                         $.get('parse_url?binurl=' + reply, function(data) {
282                                 if (!editor) $("#profile-jot-text").val("");
283                                 initEditor(function(){
284                                         addeditortext(data);
285                                         $('#profile-rotator').hide();
286                                 });
287                         });
288                 }
289         }
290
291         function itemTag(id) {
292                 reply = prompt("{{$term}}");
293                 if(reply && reply.length) {
294                         reply = reply.replace('#','');
295                         if(reply.length) {
296
297                                 commentBusy = true;
298                                 $('body').css('cursor', 'wait');
299
300                                 $.get('tagger/' + id + '?term=' + reply);
301                                 if(timer) clearTimeout(timer);
302                                 timer = setTimeout(NavUpdate,3000);
303                                 liking = 1;
304                         }
305                 }
306         }
307
308         function itemFiler(id) {
309
310                 var bordercolor = $("input").css("border-color");
311
312                 $.get('filer/', function(data){
313                         $.colorbox({html:data});
314                         $("#id_term").keypress(function(){
315                                 $(this).css("border-color",bordercolor);
316                         })
317                         $("#select_term").change(function(){
318                                 $("#id_term").css("border-color",bordercolor);
319                         })
320
321                         $("#filer_save").click(function(e){
322                                 e.preventDefault();
323                                 reply = $("#id_term").val();
324                                 if(reply && reply.length) {
325                                         commentBusy = true;
326                                         $('body').css('cursor', 'wait');
327                                         $.get('filer/' + id + '?term=' + reply, NavUpdate);
328 //                                      if(timer) clearTimeout(timer);
329 //                                      timer = setTimeout(NavUpdate,3000);
330                                         liking = 1;
331                                         $.colorbox.close();
332                                 } else {
333                                         $("#id_term").css("border-color","#FF0000");
334                                 }
335                                 return false;
336                         });
337                 });
338
339         }
340
341         function jotClearLocation() {
342                 $('#jot-coord').val('');
343                 $('#profile-nolocation-wrapper').hide();
344         }
345
346         function addeditortext(data) {
347                 if(plaintext == 'none') {
348                         var currentText = $("#profile-jot-text").val();
349                         $("#profile-jot-text").val(currentText + data);
350                 }
351                 else
352                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
353         }
354
355         {{$geotag}}
356
357 </script>
358