]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/templates/jot-header.tpl
Merge remote-tracking branch 'upstream/develop' into 1606-shared-template
[friendica.git] / view / theme / frio / templates / jot-header.tpl
1
2
3 {{*<script language="javascript" type="text/javascript">*}}
4
5
6 <script>
7 var editor=false;
8 var textlen = 0;
9 var plaintext = '{{$editselect}}';
10
11 function initEditor(cb){
12         if (editor==false){
13                 $("#profile-jot-text-loading").show();
14                 if(plaintext == 'none') {
15                         $("#profile-jot-text-loading").hide();
16                         //$("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
17                         $("#jot-category").show();
18                         $("#jot-category").addClass("jot-category-ex");
19                         $("#jot-profile-jot-wrapper").show();
20                         $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
21                         $("#profile-jot-text").bbco_autocomplete('bbcode');
22                         editor = true;
23                         $("a#jot-perms-icon").colorbox({
24                                 'inline' : true,
25                                 'transition' : 'elastic'
26                         });
27                         $(".jothidden").show();
28                         if (typeof cb!="undefined") cb();
29                         return;
30                 }       
31                 tinyMCE.init({
32                         theme : "advanced",
33                         mode : "specific_textareas",
34                         editor_selector: {{$editselect}},
35                         auto_focus: "profile-jot-text",
36                         plugins : "bbcode,paste,autoresize, inlinepopups",
37                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
38                         theme_advanced_buttons2 : "",
39                         theme_advanced_buttons3 : "",
40                         theme_advanced_toolbar_location : "top",
41                         theme_advanced_toolbar_align : "center",
42                         theme_advanced_blockformats : "blockquote,code",
43                         theme_advanced_resizing : true,
44                         gecko_spellcheck : true,
45                         paste_text_sticky : true,
46                         entity_encoding : "raw",
47                         add_unload_trigger : false,
48                         remove_linebreaks : false,
49                         //force_p_newlines : false,
50                         //force_br_newlines : true,
51                         forced_root_block : 'div',
52                         convert_urls: false,
53                         content_css: "{{$baseurl}}/view/custom_tinymce.css",
54                         theme_advanced_path : false,
55                         file_browser_callback : "fcFileBrowser",
56                         setup : function(ed) {
57                                 cPopup = null;
58                                 ed.onKeyDown.add(function(ed,e) {
59                                         if(cPopup !== null)
60                                                 cPopup.onkey(e);
61                                 });
62
63                                 ed.onKeyUp.add(function(ed, e) {
64                                         var txt = tinyMCE.activeEditor.getContent();
65                                         match = txt.match(/@([^ \n]+)$/);
66                                         if(match!==null) {
67                                                 if(cPopup === null) {
68                                                         cPopup = new ACPopup(this,baseurl+"/acl");
69                                                 }
70                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
71                                                 if(! cPopup.ready) cPopup = null;
72                                         }
73                                         else {
74                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
75                                         }
76
77                                         textlen = txt.length;
78                                         if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
79                                                 $('#profile-jot-desc').html(ispublic);
80                                         }
81                                         else {
82                                                 $('#profile-jot-desc').html('&nbsp;');
83                                         }        
84
85                                  //Character count
86
87                                         if(textlen <= 140) {
88                                                 $('#character-counter').removeClass('red');
89                                                 $('#character-counter').removeClass('orange');
90                                                 $('#character-counter').addClass('grey');
91                                         }
92                                         if((textlen > 140) && (textlen <= 420)) {
93                                                 $('#character-counter').removeClass('grey');
94                                                 $('#character-counter').removeClass('red');
95                                                 $('#character-counter').addClass('orange');
96                                         }
97                                         if(textlen > 420) {
98                                                 $('#character-counter').removeClass('grey');
99                                                 $('#character-counter').removeClass('orange');
100                                                 $('#character-counter').addClass('red');
101                                         }
102                                         $('#character-counter').text(textlen);
103                                 });
104
105                                 ed.onInit.add(function(ed) {
106                                         ed.pasteAsPlainText = true;
107                                         $("#profile-jot-text-loading").hide();
108                                         $(".jothidden").show();
109                                         if (typeof cb!="undefined") cb();
110                                 });
111
112                         }
113
114                 });
115                 editor = true;
116
117                 // setup acl popup
118                 $("a#jot-perms-icon").colorbox({
119                         'inline' : true,
120                         'transition' : 'elastic'
121                 }); 
122
123         } else {
124                 if (typeof cb!="undefined") cb();
125         }
126 }
127
128 function enableOnUser(){
129         if (editor) return;
130         $(this).val("");
131         initEditor();
132 }
133
134
135
136
137 </script>
138 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
139 <script>
140         var ispublic = '{{$ispublic}}';
141
142
143         $(document).ready(function() {
144
145                 /* enable tinymce on focus and click */
146                 $("#profile-jot-text").focus(enableOnUser);
147                 $("#profile-jot-text").click(enableOnUser);
148
149
150
151
152                 /* show images / file browser window
153                  *
154                  **/
155
156                 /* callback */
157                 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
158                         ///@todo this part isn't ideal and need to be done in a better way
159                         jotTextOpenUI(document.getElementById("profile-jot-text"));
160                         jotActive();
161                         addeditortext(embedcode);
162                 });
163                 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
164                         jotTextOpenUI(document.getElementById("profile-jot-text"));
165                         jotActive();
166                         addeditortext(embedcode);
167                 });
168
169                 $('#wall-image-upload').on('click', function(){
170                         Dialog.doImageBrowser("main");
171                         jotActive();
172                 });
173
174                 $('#wall-file-upload').on('click', function(){
175                         Dialog.doFileBrowser("main");
176                         jotActive();
177                 });
178
179                 /**
180                         var uploader = new window.AjaxUpload(
181                                 'wall-image-upload',
182                                 { action: 'wall_upload/{{$nickname}}',
183                                         name: 'userfile',
184                                         onSubmit: function(file,ext) { $('#profile-rotator').show(); },
185                                         onComplete: function(file,response) {
186                                                 addeditortext(response);
187                                                 $('#profile-rotator').hide();
188                                         }
189                                 }
190                         );
191                         var file_uploader = new window.AjaxUpload(
192                                 'wall-file-upload',
193                                 { action: 'wall_attach/{{$nickname}}',
194                                         name: 'userfile',
195                                         onSubmit: function(file,ext) { $('#profile-rotator').show(); },
196                                         onComplete: function(file,response) {
197                                                 addeditortext(response);
198                                                 $('#profile-rotator').hide();
199                                         }
200                                 }
201                         );
202
203                 }
204                 **/
205         });
206
207         function deleteCheckedItems() {
208                 if(confirm('{{$delitems}}')) {
209                         var checkedstr = '';
210                         var ItemsToDelete = {};
211
212                         $("#item-delete-selected").hide();
213                         $('#item-delete-selected-rotator').show();
214                         $('body').css('cursor', 'wait');
215
216                         $('.item-select').each( function() {
217                                 if($(this).is(':checked')) {
218                                         if(checkedstr.length != 0) {
219                                                 checkedstr = checkedstr + ',' + $(this).val();
220                                                 var deleteItem = this.closest(".wall-item-container");
221                                                 ItemsToDelete[deleteItem.id] = deleteItem;
222                                         }
223                                         else {
224                                                 checkedstr = $(this).val();
225                                         }
226
227                                         // Get the corresponding item container
228                                         var deleteItem = this.closest(".wall-item-container");
229                                         ItemsToDelete[deleteItem.id] = deleteItem;
230                                 }
231                         });
232
233                         // Fade the the the container from the items we want to delete
234                         for(var key in  ItemsToDelete) {
235                                 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
236                         };
237
238                         $.post('item', { dropitems: checkedstr }, function(data) {
239                         }).done(function() {
240                                 // Loop through the ItemsToDelete Object and remove
241                                 // corresponding item div
242                                 for(var key in  ItemsToDelete) {
243                                         $(ItemsToDelete[key]).remove();
244                                 }
245                                 $('body').css('cursor', 'auto');
246                                 $('#item-delete-selected-rotator').hide();
247                         });
248                 }
249         }
250
251         function jotGetLink() {
252                 reply = prompt("{{$linkurl}}");
253                 if(reply && reply.length) {
254                         reply = bin2hex(reply);
255                         $('#profile-rotator').show();
256                         $.get('parse_url?binurl=' + reply, function(data) {
257                                 addeditortext(data);
258                                 $('#profile-rotator').hide();
259                         });
260                 }
261         }
262
263         function jotVideoURL() {
264                 reply = prompt("{{$vidurl}}");
265                 if(reply && reply.length) {
266                         addeditortext('[video]' + reply + '[/video]');
267                 }
268         }
269
270         function jotAudioURL() {
271                 reply = prompt("{{$audurl}}");
272                 if(reply && reply.length) {
273                         addeditortext('[audio]' + reply + '[/audio]');
274                 }
275         }
276
277
278         function jotGetLocation() {
279                 reply = prompt("{{$whereareu}}", $('#jot-location').val());
280                 if(reply && reply.length) {
281                         $('#jot-location').val(reply);
282                 }
283         }
284
285         function jotShare(id) {
286 //              if ($('#jot-popup').length != 0) $('#jot-popup').show();
287 //
288 //              $('#like-rotator-' + id).show();
289 //              $.get('share/' + id, function(data) {
290 //                      if (!editor) $("#profile-jot-text").val("");
291 //                      initEditor(function(){
292 //                              addeditortext(data);
293 //                              $('#like-rotator-' + id).hide();
294 //                              $(window).scrollTop(0);
295 //                      });
296 //
297 //              });
298
299                 $.get('share/' + id, function(data) {
300                         if (!editor) $("#profile-jot-text").val("");
301                         initEditor(function(){
302                         addeditortext(data);
303                         });
304                 });
305
306                 jotShow();
307
308                 $("#jot-popup").show();
309         }
310
311         function linkdropper(event) {
312                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
313                 if(linkFound)
314                         event.preventDefault();
315         }
316
317         function linkdrop(event) {
318                 var reply = event.dataTransfer.getData("text/uri-list");
319                 event.target.textContent = reply;
320                 event.preventDefault();
321                 if(reply && reply.length) {
322                         reply = bin2hex(reply);
323                         $('#profile-rotator').show();
324                         $.get('parse_url?binurl=' + reply, function(data) {
325                                 if (!editor) $("#profile-jot-text").val("");
326                                 initEditor(function(){
327                                         addeditortext(data);
328                                         $('#profile-rotator').hide();
329                                 });
330                         });
331                 }
332         }
333
334         function itemTag(id) {
335                 reply = prompt("{{$term}}");
336                 if(reply && reply.length) {
337                         reply = reply.replace('#','');
338                         if(reply.length) {
339
340                                 commentBusy = true;
341                                 $('body').css('cursor', 'wait');
342
343                                 $.get('tagger/' + id + '?term=' + reply);
344                                 if(timer) clearTimeout(timer);
345                                 timer = setTimeout(NavUpdate,3000);
346                                 liking = 1;
347                         }
348                 }
349         }
350
351         function itemFiler(id) {
352
353                 var bordercolor = $("input").css("border-color");
354
355                 $.get('filer/', function(data){
356                         $.colorbox({html:data});
357                         $("#id_term").keypress(function(){
358                                 $(this).css("border-color",bordercolor);
359                         })
360                         $("#select_term").change(function(){
361                                 $("#id_term").css("border-color",bordercolor);
362                         })
363
364                         $("#filer_save").click(function(e){
365                                 e.preventDefault();
366                                 reply = $("#id_term").val();
367                                 if(reply && reply.length) {
368                                         commentBusy = true;
369                                         $('body').css('cursor', 'wait');
370                                         $.get('filer/' + id + '?term=' + reply, NavUpdate);
371 //                                      if(timer) clearTimeout(timer);
372 //                                      timer = setTimeout(NavUpdate,3000);
373                                         liking = 1;
374                                         $.colorbox.close();
375                                 } else {
376                                         $("#id_term").css("border-color","#FF0000");
377                                 }
378                                 return false;
379                         });
380                 });
381
382         }
383
384         function jotClearLocation() {
385                 $('#jot-coord').val('');
386                 $('#profile-nolocation-wrapper').hide();
387         }
388
389         function addeditortext(data) {
390                 if(plaintext == 'none') {
391                         var currentText = $("#profile-jot-text").val();
392                         $("#profile-jot-text").val(currentText + data);
393                 }
394                 else
395                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
396         }
397
398         {{$geotag}}
399
400         function jotShow() {
401                 var modal = $('#jot-modal').modal();
402                 var jot = $("#profile-jot-form");
403
404                 // Clear bs modal on close
405                 // We need this to prevent that the modal displays old content
406                 $('body').on('hidden.bs.modal', '#jot-modal', function () {
407                         $(this).removeData('bs.modal');
408                         $("#jot-content").append(jot);
409                 });
410
411                 modal
412                         .find('#jot-modal-body')
413                         .append(jot)
414                         .modal.show
415                         ;
416         }
417
418         // the following functions show/hide the specific jot content 
419         // in dependence of the selected nav
420         function aclActive() {
421                 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
422                 $(".modal-body #profile-jot-acl-wrapper").show();
423         }
424
425
426         function previewActive() {
427                 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").hide();
428                 preview_post();
429         }
430
431         function jotActive() {
432                 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
433                 $(".modal-body #profile-jot-wrapper").show();
434
435                 //make sure jot text does have really the active class (we do this because there are some
436                 // other events which trigger jot text
437                 toggleJotNav($("#jot-modal .jot-nav #jot-text-lnk"));
438         }
439
440         function fbrowserActive() {
441                 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #profile-jot-acl-wrapper").hide();
442
443                 $(".modal-body #jot-fbrowser-wrapper").show();
444
445                 $(function() {Dialog.showJot();});
446         }
447
448 </script>
449