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