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