]> git.mxchange.org Git - friendica.git/blob - view/theme/smoothly/jot-header.tpl
Merge pull request #482 from pixelroot/master
[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                 var checkedstr = '';
198
199                 $('.item-select').each( function() {
200                         if($(this).is(':checked')) {
201                                 if(checkedstr.length != 0) {
202                                         checkedstr = checkedstr + ',' + $(this).val();
203                                 }
204                                 else {
205                                         checkedstr = $(this).val();
206                                 }
207                         }       
208                 });
209                 $.post('item', { dropitems: checkedstr }, function(data) {
210                         window.location.reload();
211                 });
212         }
213
214         function jotGetLink() {
215                 reply = prompt("$linkurl");
216                 if(reply && reply.length) {
217                         reply = bin2hex(reply);
218                         $('#profile-rotator').show();
219                         $.get('parse_url?binurl=' + reply, function(data) {
220                                 addeditortext(data);
221                                 $('#profile-rotator').hide();
222                         });
223                 }
224         }
225
226         function jotVideoURL() {
227                 reply = prompt("$vidurl");
228                 if(reply && reply.length) {
229                         addeditortext('[video]' + reply + '[/video]');
230                 }
231         }
232
233         function jotAudioURL() {
234                 reply = prompt("$audurl");
235                 if(reply && reply.length) {
236                         addeditortext('[audio]' + reply + '[/audio]');
237                 }
238         }
239
240
241         function jotGetLocation() {
242                 reply = prompt("$whereareu", $('#jot-location').val());
243                 if(reply && reply.length) {
244                         $('#jot-location').val(reply);
245                 }
246         }
247
248         function jotTitle() {
249                 reply = prompt("$title", $('#jot-title').val());
250                 if(reply && reply.length) {
251                         $('#jot-title').val(reply);
252                 }
253         }
254
255         function jotShare(id) {
256                 $('#like-rotator-' + id).show();
257                 $.get('share/' + id, function(data) {
258                                 if (!editor) $("#profile-jot-text").val("");
259                                 initEditor(function(){
260                                         addeditortext(data);
261                                         $('#like-rotator-' + id).hide();
262                                         $(window).scrollTop(0);
263                                 });
264                 });
265         }
266
267         function linkdropper(event) {
268                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
269                 if(linkFound)
270                         event.preventDefault();
271         }
272
273         function linkdrop(event) {
274                 var reply = event.dataTransfer.getData("text/uri-list");
275                 event.target.textContent = reply;
276                 event.preventDefault();
277                 if(reply && reply.length) {
278                         reply = bin2hex(reply);
279                         $('#profile-rotator').show();
280                         $.get('parse_url?binurl=' + reply, function(data) {
281                                 if (!editor) $("#profile-jot-text").val("");
282                                 initEditor(function(){
283                                         addeditortext(data);
284                                         $('#profile-rotator').hide();
285                                 });
286                         });
287                 }
288         }
289
290         function itemTag(id) {
291                 reply = prompt("$term");
292                 if(reply && reply.length) {
293                         reply = reply.replace('#','');
294                         if(reply.length) {
295
296                                 commentBusy = true;
297                                 $('body').css('cursor', 'wait');
298
299                                 $.get('tagger/' + id + '?term=' + reply);
300                                 if(timer) clearTimeout(timer);
301                                 timer = setTimeout(NavUpdate,3000);
302                                 liking = 1;
303                         }
304                 }
305         }
306         
307         function itemFiler(id) {
308                 
309                 var bordercolor = $("input").css("border-color");
310                 
311                 $.get('filer/', function(data){
312                         $.fancybox(data);
313                         $("#id_term").keypress(function(){
314                                 $(this).css("border-color",bordercolor);
315                         })
316                         $("#select_term").change(function(){
317                                 $("#id_term").css("border-color",bordercolor);
318                         })
319                         
320                         $("#filer_save").click(function(e){
321                                 e.preventDefault();
322                                 reply = $("#id_term").val();
323                                 if(reply && reply.length) {
324                                         commentBusy = true;
325                                         $('body').css('cursor', 'wait');
326                                         $.get('filer/' + id + '?term=' + reply);
327                                         if(timer) clearTimeout(timer);
328                                         timer = setTimeout(NavUpdate,3000);
329                                         liking = 1;
330                                         $.fancybox.close();
331                                 } else {
332                                         $("#id_term").css("border-color","#FF0000");
333                                 }
334                                 return false;
335                         });
336                 });
337                 
338         }
339
340         
341
342         function jotClearLocation() {
343                 $('#jot-coord').val('');
344                 $('#profile-nolocation-wrapper').hide();
345         }
346
347   function addeditortext(data) {
348         if(plaintext == 'none') {
349             var currentText = $("#profile-jot-text").val();
350             $("#profile-jot-text").val(currentText + data);
351         }
352         else
353             tinyMCE.execCommand('mceInsertRawHTML',false,data);
354     }
355
356
357         $geotag
358
359 </script>