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