]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/templates/jot-header.tpl
Merge pull request #2935 from silke/deprecated-themes
[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                 // When clicking on a forum in acl we should remove the profile jot textarea
150                 // default value before inserting the forum mention
151                 $("body").on('click', '#jot-modal .acl-list-item.forum', function(){
152                         jotTextOpenUI(document.getElementById("profile-jot-text"));
153                 });
154
155
156                 /* show images / file browser window
157                  *
158                  **/
159
160                 /* callback */
161                 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
162                         ///@todo this part isn't ideal and need to be done in a better way
163                         jotTextOpenUI(document.getElementById("profile-jot-text"));
164                         jotActive();
165                         addeditortext(embedcode);
166                 });
167                 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
168                         jotTextOpenUI(document.getElementById("profile-jot-text"));
169                         jotActive();
170                         addeditortext(embedcode);
171                 });
172
173                 $('#wall-image-upload').on('click', function(){
174                         Dialog.doImageBrowser("main");
175                         jotActive();
176                 });
177
178                 $('#wall-file-upload').on('click', function(){
179                         Dialog.doFileBrowser("main");
180                         jotActive();
181                 });
182
183                 /**
184                         var uploader = new window.AjaxUpload(
185                                 'wall-image-upload',
186                                 { action: 'wall_upload/{{$nickname}}',
187                                         name: 'userfile',
188                                         onSubmit: function(file,ext) { $('#profile-rotator').show(); },
189                                         onComplete: function(file,response) {
190                                                 addeditortext(response);
191                                                 $('#profile-rotator').hide();
192                                         }
193                                 }
194                         );
195                         var file_uploader = new window.AjaxUpload(
196                                 'wall-file-upload',
197                                 { action: 'wall_attach/{{$nickname}}',
198                                         name: 'userfile',
199                                         onSubmit: function(file,ext) { $('#profile-rotator').show(); },
200                                         onComplete: function(file,response) {
201                                                 addeditortext(response);
202                                                 $('#profile-rotator').hide();
203                                         }
204                                 }
205                         );
206
207                 }
208                 **/
209         });
210
211         function deleteCheckedItems() {
212                 if(confirm('{{$delitems}}')) {
213                         var checkedstr = '';
214                         var ItemsToDelete = {};
215
216                         $("#item-delete-selected").hide();
217                         $('#item-delete-selected-rotator').show();
218                         $('body').css('cursor', 'wait');
219
220                         $('.item-select').each( function() {
221                                 if($(this).is(':checked')) {
222                                         if(checkedstr.length != 0) {
223                                                 checkedstr = checkedstr + ',' + $(this).val();
224                                                 var deleteItem = this.closest(".wall-item-container");
225                                                 ItemsToDelete[deleteItem.id] = deleteItem;
226                                         }
227                                         else {
228                                                 checkedstr = $(this).val();
229                                         }
230
231                                         // Get the corresponding item container
232                                         var deleteItem = this.closest(".wall-item-container");
233                                         ItemsToDelete[deleteItem.id] = deleteItem;
234                                 }
235                         });
236
237                         // Fade the the the container from the items we want to delete
238                         for(var key in  ItemsToDelete) {
239                                 $(ItemsToDelete[key]).fadeTo('fast', 0.33);
240                         };
241
242                         $.post('item', { dropitems: checkedstr }, function(data) {
243                         }).done(function() {
244                                 // Loop through the ItemsToDelete Object and remove
245                                 // corresponding item div
246                                 for(var key in  ItemsToDelete) {
247                                         $(ItemsToDelete[key]).remove();
248                                 }
249                                 $('body').css('cursor', 'auto');
250                                 $('#item-delete-selected-rotator').hide();
251                         });
252                 }
253         }
254
255         function jotGetLink() {
256                 reply = prompt("{{$linkurl}}");
257                 if(reply && reply.length) {
258                         reply = bin2hex(reply);
259                         $('#profile-rotator').show();
260                         $.get('parse_url?binurl=' + reply, function(data) {
261                                 addeditortext(data);
262                                 $('#profile-rotator').hide();
263                         });
264                 }
265         }
266
267         function jotVideoURL() {
268                 reply = prompt("{{$vidurl}}");
269                 if(reply && reply.length) {
270                         addeditortext('[video]' + reply + '[/video]');
271                 }
272         }
273
274         function jotAudioURL() {
275                 reply = prompt("{{$audurl}}");
276                 if(reply && reply.length) {
277                         addeditortext('[audio]' + reply + '[/audio]');
278                 }
279         }
280
281
282         function jotGetLocation() {
283                 reply = prompt("{{$whereareu}}", $('#jot-location').val());
284                 if(reply && reply.length) {
285                         $('#jot-location').val(reply);
286                 }
287         }
288
289         function jotShare(id) {
290                 $.get('share/' + id, function(data) {
291                         // remove the former content of the text input
292                         $("#profile-jot-text").val("");
293                         initEditor(function(){
294                                 addeditortext(data);
295                         });
296                 });
297
298                 jotShow();
299
300                 $("#jot-popup").show();
301         }
302
303         function linkdropper(event) {
304                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
305                 if(linkFound)
306                         event.preventDefault();
307         }
308
309         function linkdrop(event) {
310                 var reply = event.dataTransfer.getData("text/uri-list");
311                 event.target.textContent = reply;
312                 event.preventDefault();
313                 if(reply && reply.length) {
314                         reply = bin2hex(reply);
315                         $('#profile-rotator').show();
316                         $.get('parse_url?binurl=' + reply, function(data) {
317                                 if (!editor) $("#profile-jot-text").val("");
318                                 initEditor(function(){
319                                         addeditortext(data);
320                                         $('#profile-rotator').hide();
321                                 });
322                         });
323                 }
324         }
325
326         function itemTag(id) {
327                 reply = prompt("{{$term}}");
328                 if(reply && reply.length) {
329                         reply = reply.replace('#','');
330                         if(reply.length) {
331
332                                 commentBusy = true;
333                                 $('body').css('cursor', 'wait');
334
335                                 $.get('tagger/' + id + '?term=' + reply);
336                                 if(timer) clearTimeout(timer);
337                                 timer = setTimeout(NavUpdate,3000);
338                                 liking = 1;
339                         }
340                 }
341         }
342
343         function itemFiler(id) {
344
345                 var bordercolor = $("input").css("border-color");
346
347                 $.get('filer/', function(data){
348                         $.colorbox({html:data});
349                         $("#id_term").keypress(function(){
350                                 $(this).css("border-color",bordercolor);
351                         })
352                         $("#select_term").change(function(){
353                                 $("#id_term").css("border-color",bordercolor);
354                         })
355
356                         $("#filer_save").click(function(e){
357                                 e.preventDefault();
358                                 reply = $("#id_term").val();
359                                 if(reply && reply.length) {
360                                         commentBusy = true;
361                                         $('body').css('cursor', 'wait');
362                                         $.get('filer/' + id + '?term=' + reply, NavUpdate);
363 //                                      if(timer) clearTimeout(timer);
364 //                                      timer = setTimeout(NavUpdate,3000);
365                                         liking = 1;
366                                         $.colorbox.close();
367                                 } else {
368                                         $("#id_term").css("border-color","#FF0000");
369                                 }
370                                 return false;
371                         });
372                 });
373
374         }
375
376         function jotClearLocation() {
377                 $('#jot-coord').val('');
378                 $('#profile-nolocation-wrapper').hide();
379         }
380
381         function addeditortext(data) {
382                 if(plaintext == 'none') {
383                         // get the textfield
384                         var textfield = document.getElementById("profile-jot-text");
385                         // check if the textfield does have the default-value
386                         jotTextOpenUI(textfield);
387                         // save already existent content
388                         var currentText = $("#profile-jot-text").val();
389                         //insert the data as new value
390                         textfield.value = currentText + data;
391                 }
392                 else
393                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
394         }
395
396         {{$geotag}}
397
398         function jotShow() {
399                 var modal = $('#jot-modal').modal();
400                 jotcache = $("#jot-sections");
401
402                 modal
403                         .find('#jot-modal-content')
404                         .append(jotcache)
405                         .modal.show;
406         }
407
408         // the following functions show/hide the specific jot content 
409         // in dependence of the selected nav
410         function aclActive() {
411                 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
412                 $(".modal-body #profile-jot-acl-wrapper").show();
413         }
414
415
416         function previewActive() {
417                 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper,.modal-body #jot-fbrowser-wrapper").hide();
418                 preview_post();
419         }
420
421         function jotActive() {
422                 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content, .modal-body #jot-fbrowser-wrapper").hide();
423                 $(".modal-body #profile-jot-wrapper").show();
424
425                 //make sure jot text does have really the active class (we do this because there are some
426                 // other events which trigger jot text
427                 toggleJotNav($("#jot-modal .jot-nav #jot-text-lnk"));
428         }
429
430         function fbrowserActive() {
431                 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content, .modal-body #profile-jot-acl-wrapper").hide();
432
433                 $(".modal-body #jot-fbrowser-wrapper").show();
434
435                 $(function() {Dialog.showJot();});
436         }
437
438
439 </script>
440