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