]> git.mxchange.org Git - friendica.git/blob - view/theme/testbubble/templates/jot-header.tpl
removed old comment that is no longer true
[friendica.git] / view / theme / testbubble / templates / jot-header.tpl
1
2
3 <script language="javascript" type="text/javascript" src="{{$baseurl}}/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
4 <script language="javascript" type="text/javascript">
5
6 var editor=false;
7 var textlen = 0;
8 var plaintext = '{{$editselect}}';
9
10 function initEditor(cb) {
11     if (editor==false) {
12         $("#profile-jot-text-loading").show();
13  if(plaintext == 'none') {
14             $("#profile-jot-text-loading").hide();
15             $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
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 </script>
146 <script type="text/javascript" src="js/ajaxupload.js" ></script>
147 <script>
148     var ispublic = '{{$ispublic}}';
149         $(document).ready(function() {
150                 /* enable tinymce on focus */
151                 $("#profile-jot-text").focus(function(){
152                     if (editor) return;
153                     $(this).val("");
154                     initEditor();
155                 }); 
156
157
158                 var uploader = new window.AjaxUpload(
159                         'wall-image-upload',
160                         { action: 'wall_upload/{{$nickname}}',
161                                 name: 'userfile',
162                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
163                                 onComplete: function(file,response) {
164                                         addeditortext(response);
165                                         $('#profile-rotator').hide();
166                                 }                                
167                         }
168                 );
169                 var file_uploader = new window.AjaxUpload(
170                         'wall-file-upload',
171                         { action: 'wall_attach/{{$nickname}}',
172                                 name: 'userfile',
173                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
174                                 onComplete: function(file,response) {
175                                         addeditortext(response);
176                                         $('#profile-rotator').hide();
177                                 }                                
178                         }
179                 );              
180                 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
181                         var selstr;
182                         $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
183                                 selstr = $(this).text();
184                                 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
185                                 $('#jot-public').hide();
186                                 $('.profile-jot-net input').attr('disabled', 'disabled');
187                         });
188                         if(selstr == null) { 
189                                 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
190                                 $('#jot-public').show();
191                                 $('.profile-jot-net input').attr('disabled', false);
192                         }
193
194                 }).trigger('change');
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 jotTitle() {
256                 reply = prompt("{{$title}}", $('#jot-title').val());
257                 if(reply && reply.length) {
258                         $('#jot-title').val(reply);
259                 }
260         }
261
262         function jotShare(id) {
263                 $('#like-rotator-' + id).show();
264                 $.get('share/' + id, function(data) {
265                                 if (!editor) $("#profile-jot-text").val("");
266                                 initEditor(function(){
267                                         addeditortext(data);
268                                         $('#like-rotator-' + id).hide();
269                                         $(window).scrollTop(0);
270                                 });
271                 });
272         }
273
274         function linkdropper(event) {
275                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
276                 if(linkFound)
277                         event.preventDefault();
278         }
279
280         function linkdrop(event) {
281                 var reply = event.dataTransfer.getData("text/uri-list");
282                 event.target.textContent = reply;
283                 event.preventDefault();
284                 if(reply && reply.length) {
285                         reply = bin2hex(reply);
286                         $('#profile-rotator').show();
287                         $.get('parse_url?binurl=' + reply, function(data) {
288                                 if (!editor) $("#profile-jot-text").val("");
289                                 initEditor(function(){
290                                         addeditortext(data);
291                                         $('#profile-rotator').hide();
292                                 });
293                         });
294                 }
295         }
296
297         function itemTag(id) {
298                 reply = prompt("{{$term}}");
299                 if(reply && reply.length) {
300                         reply = reply.replace('#','');
301                         if(reply.length) {
302
303                                 commentBusy = true;
304                                 $('body').css('cursor', 'wait');
305
306                                 $.get('tagger/' + id + '?term=' + reply);
307                                 if(timer) clearTimeout(timer);
308                                 timer = setTimeout(NavUpdate,3000);
309                                 liking = 1;
310                         }
311                 }
312         }
313         
314         function itemFiler(id) {
315                 
316                 var bordercolor = $("input").css("border-color");
317                 
318                 $.get('filer/', function(data){
319                         $.colorbox({html:data});
320                         $("#id_term").keypress(function(){
321                                 $(this).css("border-color",bordercolor);
322                         })
323                         $("#select_term").change(function(){
324                                 $("#id_term").css("border-color",bordercolor);
325                         })
326                         
327                         $("#filer_save").click(function(e){
328                                 e.preventDefault();
329                                 reply = $("#id_term").val();
330                                 if(reply && reply.length) {
331                                         commentBusy = true;
332                                         $('body').css('cursor', 'wait');
333                                         $.get('filer/' + id + '?term=' + reply);
334                                         if(timer) clearTimeout(timer);
335                                         timer = setTimeout(NavUpdate,3000);
336                                         liking = 1;
337                                         $.colorbox.close();
338                                 } else {
339                                         $("#id_term").css("border-color","#FF0000");
340                                 }
341                                 return false;
342                         });
343                 });
344                 
345         }
346
347         
348
349         function jotClearLocation() {
350                 $('#jot-coord').val('');
351                 $('#profile-nolocation-wrapper').hide();
352         }
353
354   function addeditortext(data) {
355         if(plaintext == 'none') {
356             var currentText = $("#profile-jot-text").val();
357             $("#profile-jot-text").val(currentText + data);
358         }
359         else
360             tinyMCE.execCommand('mceInsertRawHTML',false,data);
361     }
362
363
364         {{$geotag}}
365
366 </script>
367