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