]> git.mxchange.org Git - friendica.git/blob - view/jot-header.tpl
extending notifications to other types
[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                                         $("#profile-jot-submit-wrapper").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 </script>
102 <script type="text/javascript" src="js/ajaxupload.js" ></script>
103 <script>
104         var ispublic = '$ispublic';
105         $(document).ready(function() {
106                 
107                 /* enable tinymce on focus */
108                 $("#profile-jot-text").focus(function(){
109                         if (editor) return;
110                         $(this).val("");
111                         initEditor();
112                 });
113                 
114         
115                 var uploader = new window.AjaxUpload(
116                         'wall-image-upload',
117                         { action: 'wall_upload/$nickname',
118                                 name: 'userfile',
119                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
120                                 onComplete: function(file,response) {
121                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
122                                         $('#profile-rotator').hide();
123                                 }                                
124                         }
125                 );
126                 var file_uploader = new window.AjaxUpload(
127                         'wall-file-upload',
128                         { action: 'wall_attach/$nickname',
129                                 name: 'userfile',
130                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
131                                 onComplete: function(file,response) {
132                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
133                                         $('#profile-rotator').hide();
134                                 }                                
135                         }
136                 );
137
138
139         });
140
141         function deleteCheckedItems() {
142                 var checkedstr = '';
143
144                 $('.item-select').each( function() {
145                         if($(this).is(':checked')) {
146                                 if(checkedstr.length != 0) {
147                                         checkedstr = checkedstr + ',' + $(this).val();
148                                 }
149                                 else {
150                                         checkedstr = $(this).val();
151                                 }
152                         }       
153                 });
154                 $.post('item', { dropitems: checkedstr }, function(data) {
155                         window.location.reload();
156                 });
157         }
158
159         function jotGetLink() {
160                 reply = prompt("$linkurl");
161                 if(reply && reply.length) {
162                         reply = bin2hex(reply);
163                         $('#profile-rotator').show();
164                         $.get('parse_url?binurl=' + reply, function(data) {
165                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
166                                 $('#profile-rotator').hide();
167                         });
168                 }
169         }
170
171         function jotVideoURL() {
172                 reply = prompt("$vidurl");
173                 if(reply && reply.length) {
174                         tinyMCE.execCommand('mceInsertRawHTML',false,'[video]' + reply + '[/video]');
175                 }
176         }
177
178         function jotAudioURL() {
179                 reply = prompt("$audurl");
180                 if(reply && reply.length) {
181                         tinyMCE.execCommand('mceInsertRawHTML',false,'[audio]' + reply + '[/audio]');
182                 }
183         }
184
185
186         function jotGetLocation() {
187                 reply = prompt("$whereareu", $('#jot-location').val());
188                 if(reply && reply.length) {
189                         $('#jot-location').val(reply);
190                 }
191         }
192
193         function jotTitle() {
194                 reply = prompt("$title", $('#jot-title').val());
195                 if(reply && reply.length) {
196                         $('#jot-title').val(reply);
197                 }
198         }
199
200
201         function jotShare(id) {
202                 $('#like-rotator-' + id).show();
203                 $.get('share/' + id, function(data) {
204                         if (!editor) $("#profile-jot-text").val("");
205                         initEditor(function(){
206                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
207                                 $('#like-rotator-' + id).hide();
208                                 $(window).scrollTop(0);
209                         });
210
211                 });
212         }
213
214         function linkdropper(event) {
215                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
216                 if(linkFound)
217                         event.preventDefault();
218         }
219
220         function linkdrop(event) {
221                 var reply = event.dataTransfer.getData("text/uri-list");
222                 event.target.textContent = reply;
223                 event.preventDefault();
224                 if(reply && reply.length) {
225                         reply = bin2hex(reply);
226                         $('#profile-rotator').show();
227                         $.get('parse_url?binurl=' + reply, function(data) {
228                                 if (!editor) $("#profile-jot-text").val("");
229                                 initEditor(function(){
230                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
231                                         $('#profile-rotator').hide();
232                                 });
233                         });
234                 }
235         }
236
237         function itemTag(id) {
238                 reply = prompt("$term");
239                 if(reply && reply.length) {
240                         reply = reply.replace('#','');
241                         if(reply.length) {
242
243                                 commentBusy = true;
244                                 $('body').css('cursor', 'wait');
245
246                                 $.get('tagger/' + id + '?term=' + reply);
247                                 if(timer) clearTimeout(timer);
248                                 timer = setTimeout(NavUpdate,3000);
249                                 liking = 1;
250                         }
251                 }
252         }
253
254         function jotClearLocation() {
255                 $('#jot-coord').val('');
256                 $('#profile-nolocation-wrapper').hide();
257         }
258
259         $geotag
260
261 </script>
262