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