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