]> git.mxchange.org Git - friendica.git/blob - view/theme/dispy/jot-header.tpl
still working on jot-header. amending <aside> and other elements
[friendica.git] / view / theme / dispy / 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 // this is here because of the silly tinymce error. didn't help.
8 var skin = 'default';
9
10 function initEditor(cb) {
11         if (editor==false) {
12                 $("#profile-jot-text-loading").show();
13                 if(plaintext == 'none') {
14                         $("#profile-jot-text-loading").hide();
15                         $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
16                         editor = true;
17                         $("a#jot-perms-icon").fancybox({
18                                 'transitionIn' : 'elastic',
19                                 'transitionOut' : 'elastic'
20                         });
21                         $(".jothidden").show();
22                         if (typeof cb!="undefined") cb();
23                         return;
24                 }
25                 tinyMCE.init({
26                         theme : "advanced",
27                         mode : "specific_textareas",
28                         editor_selector: $editselect,
29                         auto_focus: "profile-jot-text",
30                         plugins : "bbcode,paste,fullscreen,autoresize",
31                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code,fullscreen",
32                         theme_advanced_buttons2 : "",
33                         theme_advanced_buttons3 : "",
34                         theme_advanced_toolbar_location : "top",
35                         theme_advanced_toolbar_align : "center",
36                         theme_advanced_blockformats : "blockquote,code",
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('&#160;');
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 charCounter() {
117         // character count part deux
118         $('#profile-jot-text').keyup(function(event) {
119                 var textlen = $('#profile-jot-text').val().length();
120                 var maxLen1 = 140;
121                 var maxLen2 = 420;
122
123                 $('#character-counter').removeClass('jothidden');
124                 if(textlen <= maxLen1) {
125                         $('#character-counter').removeClass('red');
126                         $('#character-counter').removeClass('orange');
127                         $('#character-counter').addClass('grey');
128                 }
129                 if((textlen > maxLen1) && (textlen <= maxLen2)) {
130                         $('#character-counter').removeClass('grey');
131                         $('#character-counter').removeClass('red');
132                         $('#character-counter').addClass('orange');
133                 }
134                 if(textlen > maxLen2) {
135                         $('#character-counter').removeClass('grey');
136                         $('#character-counter').removeClass('orange');
137                         $('#character-counter').addClass('red');
138                 }
139                 $('#character-counter').html($('#profile-jot-text').val().length);
140         });
141 }
142
143 function enableOnUser(){
144         if (editor) return;
145         $(this).val("");
146         initEditor();
147 }
148
149 </script>
150 <script type="text/javascript" src="$baseurl/js/ajaxupload.js" ></script>
151 <script>
152         var ispublic = '$ispublic';
153         var addtitle = '$addtitle';
154
155         $(document).ready(function() {
156                 
157                 /* enable tinymce on focus and click */
158                 $("#profile-jot-text").focus(enableOnUser);
159                 $("#profile-jot-text").click(enableOnUser);
160                 $("#profile-jot-text").focus(charCounter);
161                 $("#profile-jot-text").click(charCounter);
162
163                 var uploader = new window.AjaxUpload(
164                         'wall-image-upload',
165                         { action: 'wall_upload/$nickname',
166                                 name: 'userfile',
167                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
168                                 onComplete: function(file,response) {
169                                         addeditortext(response);
170                                         $('#profile-rotator').hide();
171                                 }                                
172                         }
173                 );
174                 var file_uploader = new window.AjaxUpload(
175                         'wall-file-upload',
176                         { action: 'wall_attach/$nickname',
177                                 name: 'userfile',
178                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
179                                 onComplete: function(file,response) {
180                                         addeditortext(response);
181                                         $('#profile-rotator').hide();
182                                 }                                
183                         }
184                 );
185
186
187         });
188
189         function deleteCheckedItems() {
190                 var checkedstr = '';
191
192                 $('.item-select').each( function() {
193                         if($(this).is(':checked')) {
194                                 if(checkedstr.length != 0) {
195                                         checkedstr = checkedstr + ',' + $(this).val();
196                                 }
197                                 else {
198                                         checkedstr = $(this).val();
199                                 }
200                         }       
201                 });
202                 $.post('item', { dropitems: checkedstr }, function(data) {
203                         window.location.reload();
204                 });
205         }
206
207         function jotGetLink() {
208                 reply = prompt("$linkurl");
209                 if(reply && reply.length) {
210                         reply = bin2hex(reply);
211                         $('#profile-rotator').show();
212                         $.get('parse_url?binurl=' + reply, function(data) {
213                                 addeditortext(data);
214                                 $('#profile-rotator').hide();
215                         });
216                 }
217         }
218
219         function jotVideoURL() {
220                 reply = prompt("$vidurl");
221                 if(reply && reply.length) {
222                         addeditortext('[video]' + reply + '[/video]');
223                 }
224         }
225
226         function jotAudioURL() {
227                 reply = prompt("$audurl");
228                 if(reply && reply.length) {
229                         addeditortext('[audio]' + reply + '[/audio]');
230                 }
231         }
232
233
234         function jotGetLocation() {
235                 reply = prompt("$whereareu", $('#jot-location').val());
236                 if(reply && reply.length) {
237                         $('#jot-location').val(reply);
238                 }
239         }
240
241         function jotShare(id) {
242                 if ($('#jot-popup').length != 0) $('#jot-popup').show();
243
244                 $('#like-rotator-' + id).show();
245                 $.get('share/' + id, function(data) {
246                         if (!editor) $("#profile-jot-text").val("");
247                         initEditor(function(){
248                                 addeditortext(data);
249                                 $('#like-rotator-' + id).hide();
250                                 $(window).scrollTop(0);
251                         });
252
253                 });
254         }
255
256         function linkdropper(event) {
257                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
258                 if(linkFound)
259                         event.preventDefault();
260         }
261
262         function linkdrop(event) {
263                 var reply = event.dataTransfer.getData("text/uri-list");
264                 event.target.textContent = reply;
265                 event.preventDefault();
266                 if(reply && reply.length) {
267                         reply = bin2hex(reply);
268                         $('#profile-rotator').show();
269                         $.get('parse_url?binurl=' + reply, function(data) {
270                                 if (!editor) $("#profile-jot-text").val("");
271                                 initEditor(function(){
272                                         addeditortext(data);
273                                         $('#profile-rotator').hide();
274                                 });
275                         });
276                 }
277         }
278
279         function itemTag(id) {
280                 reply = prompt("$term");
281                 if(reply && reply.length) {
282                         reply = reply.replace('#','');
283                         if(reply.length) {
284
285                                 commentBusy = true;
286                                 $('body').css('cursor', 'wait');
287
288                                 $.get('tagger/' + id + '?term=' + reply);
289                                 if(timer) clearTimeout(timer);
290                                 timer = setTimeout(NavUpdate,3000);
291                                 liking = 1;
292                         }
293                 }
294         }
295
296         function jotClearLocation() {
297                 $('#jot-coord').val('');
298                 $('#profile-nolocation-wrapper').hide();
299         }
300
301         function addeditortext(data) {
302                 if(plaintext == 'none') {
303                         var currentText = $("#profile-jot-text").val();
304                         $("#profile-jot-text").val(currentText + data);
305                 }
306                 else
307                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
308         }       
309
310         $geotag
311
312 </script>
313