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