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