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