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