]> git.mxchange.org Git - friendica.git/blob - view/theme/dispy/jot-header.tpl
Merge remote branch 'upstream/master'
[friendica.git] / view / theme / dispy / jot-header.tpl
1
2 <script language="javascript" type="text/javascript" src="$baseurl/library/tinymce/jscripts/tiny_mce/tiny_mce_src.js"></script>
3 <script language="javascript" type="text/javascript">
4
5 var editor=false;
6 var textlen = 0;
7
8 function initEditor(cb) {
9     if (editor==false) {
10         $("#profile-jot-text-loading").show();
11                 $("#jot-title-desc").show();
12  if(plaintext == 'none') {
13             $("#profile-jot-text-loading").hide();
14             $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
15             $(".jothidden").show();
16             editor = true;
17             $("a#jot-perms-icon").fancybox({
18                 'transitionIn' : 'elastic',
19                 'transitionOut' : '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 : '',
59                 convert_urls: false,
60                 content_css: "$baseurl/view/custom_tinymce.css",
61                 theme_advanced_path : false,
62                 setup : function(ed) {
63                      //Character count
64                         ed.onKeyUp.add(function(ed, e) {
65                                 var txt = tinyMCE.activeEditor.getContent();
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('&nbsp;');
72                                 }
73
74                                 if(textlen <= 140) {
75                                         $('#character-counter').removeClass('red');
76                                         $('#character-counter').removeClass('orange');
77                                         $('#character-counter').addClass('grey');
78                                 }
79                                 if((textlen > 140) && (textlen <= 420)) {
80                                         $('#character-counter').removeClass('grey');
81                                         $('#character-counter').removeClass('red');
82                                         $('#character-counter').addClass('orange');
83                                 }
84                                 if(textlen > 420) {
85                                         $('#character-counter').removeClass('grey');
86                                         $('#character-counter').removeClass('orange');
87                                         $('#character-counter').addClass('red');
88                                 }
89                                 $('#character-counter').text(textlen);
90                         });
91                         ed.onInit.add(function(ed) {
92                                 ed.pasteAsPlainText = true;
93                                 $("#profile-jot-text-loading").hide();
94                                 $("#profile-jot-submit-wrapper").show();
95                                 $("#profile-upload-wrapper").show();
96                                 $("#profile-attach-wrapper").show();
97                                 $("#profile-link-wrapper").show();
98                                 $("#profile-youtube-wrapper").show();
99                                 $("#profile-video-wrapper").show();
100                                 $("#profile-audio-wrapper").show();
101                                 $("#profile-location-wrapper").show();
102                                 $("#profile-nolocation-wrapper").show();
103                                 $("#profile-title-wrapper").show();
104                                 $("#profile-jot-plugin-wrapper").show();
105                                 $("#character-counter").show();
106                                 if (typeof cb!="undefined") cb();
107                         });
108                 }
109         });
110         editor = true;
111         // setup acl popup
112         $("a#jot-perms-icon").fancybox({
113             'transitionIn' : 'none',
114             'transitionOut' : 'none'
115         }); 
116     } else {
117         if (typeof cb!="undefined") cb();
118     }
119 } // initEditor
120 </script>
121 <script type="text/javascript" src="js/ajaxupload.js" ></script>
122 <script>
123     var ispublic = '$ispublic';
124         $(document).ready(function() {
125                 /* enable tinymce on focus */
126                 $("#profile-jot-text").focus(function(){
127                     if (editor) return;
128                     $(this).val("");
129                     initEditor();
130                 }); 
131
132                 $("#jot-title").mouseout(function() {
133                         $("#jot-title").hide();
134                         var ttl = $("#jot-title").val();
135                         $('#jot-title-display').html(ttl);
136                         if(ttl.length) {
137                                 $("#jot-title-display").show();
138                         }
139                         else {
140                                 $("#jot-title-desc").show();
141                         }
142                 });
143
144                 $("#jot-title-display").hover(function() {
145                         $("#jot-title-display").hide();
146                         $("#jot-title").show();
147                         $("#jot-title").focus();
148                 });             
149
150                 $("#jot-title-desc").click(function() {
151                         $("#jot-title-desc").hide();
152                         $("#jot-title").show();
153                         $("#jot-title").focus();
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 jotGetVideo() {
227                 reply = prompt("$utubeurl");
228                 if(reply && reply.length) {
229                         addeditortext('[youtube]' + reply + '[/youtube]');
230                 }
231         }
232
233         function jotVideoURL() {
234                 reply = prompt("$vidurl");
235                 if(reply && reply.length) {
236                         addeditortext('[video]' + reply + '[/video]');
237                 }
238         }
239
240         function jotAudioURL() {
241                 reply = prompt("$audurl");
242                 if(reply && reply.length) {
243                         addeditortext('[audio]' + reply + '[/audio]');
244                 }
245         }
246
247
248         function jotGetLocation() {
249                 reply = prompt("$whereareu", $('#jot-location').val());
250                 if(reply && reply.length) {
251                         $('#jot-location').val(reply);
252                 }
253         }
254
255         function jotTitle() {
256                 reply = prompt("$title", $('#jot-title').val());
257                 if(reply && reply.length) {
258                         $('#jot-title').val(reply);
259                 }
260         }
261
262         function jotShare(id) {
263                 $('#like-rotator-' + id).show();
264                 $.get('share/' + id, function(data) {
265                                 if (!editor) $("#profile-jot-text").val("");
266                                 initEditor(function(){
267                                         addeditortext(data);
268                                         $('#like-rotator-' + id).hide();
269                                         $(window).scrollTop(0);
270                                 });
271                 });
272         }
273
274         function linkdropper(event) {
275                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
276                 if(linkFound)
277                         event.preventDefault();
278         }
279
280         function linkdrop(event) {
281                 var reply = event.dataTransfer.getData("text/uri-list");
282                 event.target.textContent = reply;
283                 event.preventDefault();
284                 if(reply && reply.length) {
285                         reply = bin2hex(reply);
286                         $('#profile-rotator').show();
287                         $.get('parse_url?binurl=' + reply, function(data) {
288                                 if (!editor) $("#profile-jot-text").val("");
289                                 initEditor(function(){
290                                         addeditortext(data);
291                                         $('#profile-rotator').hide();
292                                 });
293                         });
294                 }
295         }
296
297         function jotClearLocation() {
298                 $('#jot-coord').val('');
299                 $('#profile-nolocation-wrapper').hide();
300         }
301
302   function addeditortext(data) {
303         if(plaintext == 'none') {
304             var currentText = $("#profile-jot-text").val();
305             $("#profile-jot-text").val(currentText + data);
306         }
307         else
308             tinyMCE.execCommand('mceInsertRawHTML',false,data);
309     }
310
311         $geotag
312
313 </script>
314