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