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