]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/templates/jot-header.tpl
Merge pull request #2353 from shtrom/issue757-https-reverse-proxy-headers-on-develop
[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                 $.get('share/' + id, function(data) {
287                         // remove the former content of the text input
288                         $("#profile-jot-text").val("");
289                         initEditor(function(){
290                                 addeditortext(data);
291                         });
292                 });
293
294                 jotShow();
295
296                 $("#jot-popup").show();
297         }
298
299         function linkdropper(event) {
300                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
301                 if(linkFound)
302                         event.preventDefault();
303         }
304
305         function linkdrop(event) {
306                 var reply = event.dataTransfer.getData("text/uri-list");
307                 event.target.textContent = reply;
308                 event.preventDefault();
309                 if(reply && reply.length) {
310                         reply = bin2hex(reply);
311                         $('#profile-rotator').show();
312                         $.get('parse_url?binurl=' + reply, function(data) {
313                                 if (!editor) $("#profile-jot-text").val("");
314                                 initEditor(function(){
315                                         addeditortext(data);
316                                         $('#profile-rotator').hide();
317                                 });
318                         });
319                 }
320         }
321
322         function itemTag(id) {
323                 reply = prompt("{{$term}}");
324                 if(reply && reply.length) {
325                         reply = reply.replace('#','');
326                         if(reply.length) {
327
328                                 commentBusy = true;
329                                 $('body').css('cursor', 'wait');
330
331                                 $.get('tagger/' + id + '?term=' + reply);
332                                 if(timer) clearTimeout(timer);
333                                 timer = setTimeout(NavUpdate,3000);
334                                 liking = 1;
335                         }
336                 }
337         }
338
339         function itemFiler(id) {
340
341                 var bordercolor = $("input").css("border-color");
342
343                 $.get('filer/', function(data){
344                         $.colorbox({html:data});
345                         $("#id_term").keypress(function(){
346                                 $(this).css("border-color",bordercolor);
347                         })
348                         $("#select_term").change(function(){
349                                 $("#id_term").css("border-color",bordercolor);
350                         })
351
352                         $("#filer_save").click(function(e){
353                                 e.preventDefault();
354                                 reply = $("#id_term").val();
355                                 if(reply && reply.length) {
356                                         commentBusy = true;
357                                         $('body').css('cursor', 'wait');
358                                         $.get('filer/' + id + '?term=' + reply, NavUpdate);
359 //                                      if(timer) clearTimeout(timer);
360 //                                      timer = setTimeout(NavUpdate,3000);
361                                         liking = 1;
362                                         $.colorbox.close();
363                                 } else {
364                                         $("#id_term").css("border-color","#FF0000");
365                                 }
366                                 return false;
367                         });
368                 });
369
370         }
371
372         function jotClearLocation() {
373                 $('#jot-coord').val('');
374                 $('#profile-nolocation-wrapper').hide();
375         }
376
377         function addeditortext(data) {
378                 if(plaintext == 'none') {
379                         var currentText = $("#profile-jot-text").val();
380                         $("#profile-jot-text").val(currentText + data);
381                 }
382                 else
383                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
384         }
385
386         {{$geotag}}
387
388         function jotShow() {
389                 var modal = $('#jot-modal').modal();
390                 jotcache = $("#profile-jot-form");
391
392                 modal
393                         .find('#jot-modal-body')
394                         .append(jotcache)
395                         .modal.show
396                         ;
397         }
398
399         // the following functions show/hide the specific jot content 
400         // in dependence of the selected nav
401         function aclActive() {
402                 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
403                 $(".modal-body #profile-jot-acl-wrapper").show();
404         }
405
406
407         function previewActive() {
408                 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").hide();
409                 preview_post();
410         }
411
412         function jotActive() {
413                 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
414                 $(".modal-body #profile-jot-wrapper").show();
415
416                 //make sure jot text does have really the active class (we do this because there are some
417                 // other events which trigger jot text
418                 toggleJotNav($("#jot-modal .jot-nav #jot-text-lnk"));
419         }
420
421         function fbrowserActive() {
422                 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #profile-jot-acl-wrapper").hide();
423
424                 $(".modal-body #jot-fbrowser-wrapper").show();
425
426                 $(function() {Dialog.showJot();});
427         }
428
429 </script>
430