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