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