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