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