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