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