]> git.mxchange.org Git - friendica.git/blob - view/theme/dispy/jot-header.tpl
a3464f3f7a45294133755ce2f554755dcab7411e
[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         tinyMCE.init({
13                 theme : "advanced",
14                 mode : "specific_textareas",
15                 editor_selector: /(profile-jot-text|prvmail-text)/,
16                 plugins : "bbcode,paste,fullscreen,autoresize",
17                 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code,fullscreen",
18                 theme_advanced_buttons2 : "",
19                 theme_advanced_buttons3 : "",
20                 theme_advanced_toolbar_location : "top",
21                 theme_advanced_toolbar_align : "center",
22                 theme_advanced_blockformats : "blockquote,code",
23                 //theme_advanced_resizing : true,
24                 //theme_advanced_statusbar_location : "bottom",
25                 paste_text_sticky : true,
26                 entity_encoding : "raw",
27                 add_unload_trigger : false,
28                 remove_linebreaks : false,
29                 force_p_newlines : false,
30                 force_br_newlines : true,
31                 forced_root_block : '',
32                 convert_urls: false,
33                 content_css: "$baseurl/view/custom_tinymce.css",
34                 theme_advanced_path : false,
35                 setup : function(ed) {
36                      //Character count
37                         ed.onKeyUp.add(function(ed, e) {
38                                 var txt = tinyMCE.activeEditor.getContent();
39                                 textlen = txt.length;
40                                 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
41                                         $('#profile-jot-desc').html(ispublic);
42                                 }
43                                 else {
44                                         $('#profile-jot-desc').html('&nbsp;');
45                                 }
46
47                                 if(textlen <= 140) {
48                                         $('#character-counter').removeClass('red');
49                                         $('#character-counter').removeClass('orange');
50                                         $('#character-counter').addClass('grey');
51                                 }
52                                 if((textlen > 140) && (textlen <= 420)) {
53                                         $('#character-counter').removeClass('grey');
54                                         $('#character-counter').removeClass('red');
55                                         $('#character-counter').addClass('orange');
56                                 }
57                                 if(textlen > 420) {
58                                         $('#character-counter').removeClass('grey');
59                                         $('#character-counter').removeClass('orange');
60                                         $('#character-counter').addClass('red');
61                                 }
62                                 $('#character-counter').text(textlen);
63                         });
64                         ed.onInit.add(function(ed) {
65                                 ed.pasteAsPlainText = true;
66                                 $("#profile-jot-text-loading").hide();
67                                 $("#profile-jot-submit-wrapper").show();
68                                 $("#profile-upload-wrapper").show();
69                                 $("#profile-attach-wrapper").show();
70                                 $("#profile-link-wrapper").show();
71                                 $("#profile-youtube-wrapper").show();
72                                 $("#profile-video-wrapper").show();
73                                 $("#profile-audio-wrapper").show();
74                                 $("#profile-location-wrapper").show();
75                                 $("#profile-nolocation-wrapper").show();
76                                 $("#profile-title-wrapper").show();
77                                 $("#profile-jot-plugin-wrapper").show();
78                                 $("#character-counter").show();
79                                 if (typeof cb!="undefined") cb();
80                         });
81                 }
82         });
83         editor = true;
84         // setup acl popup
85         $("a#jot-perms-icon").fancybox({
86             'transitionIn' : 'none',
87             'transitionOut' : 'none'
88         }); 
89     } else {
90         if (typeof cb!="undefined") cb();
91     }
92 } // initEditor
93 </script>
94 <script type="text/javascript" src="js/ajaxupload.js" ></script>
95 <script>
96     var ispublic = '$ispublic';
97         $(document).ready(function() {
98                 /* enable tinymce on focus */
99                 $("#profile-jot-text").focus(function(){
100                     if (editor) return;
101                     $(this).val("");
102                     initEditor();
103                 }); 
104
105                 $("#jot-title-desc").click(function() {
106                         $("#jot-title-desc").hide();
107                         $("#jot-title").show();
108                 });             
109
110                 var uploader = new window.AjaxUpload(
111                         'wall-image-upload',
112                         { action: 'wall_upload/$nickname',
113                                 name: 'userfile',
114                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
115                                 onComplete: function(file,response) {
116                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
117                                         $('#profile-rotator').hide();
118                                 }                                
119                         }
120                 );
121                 var file_uploader = new window.AjaxUpload(
122                         'wall-file-upload',
123                         { action: 'wall_attach/$nickname',
124                                 name: 'userfile',
125                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
126                                 onComplete: function(file,response) {
127                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
128                                         $('#profile-rotator').hide();
129                                 }                                
130                         }
131                 );              
132                 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
133                         var selstr;
134                         $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
135                                 selstr = $(this).text();
136                                 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
137                                 $('#jot-public').hide();
138                                 $('.profile-jot-net input').attr('disabled', 'disabled');
139                         });
140                         if(selstr == null) { 
141                                 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
142                                 $('#jot-public').show();
143                                 $('.profile-jot-net input').attr('disabled', false);
144                         }
145
146                 }).trigger('change');
147
148         });
149
150         function deleteCheckedItems() {
151                 var checkedstr = '';
152
153                 $('.item-select').each( function() {
154                         if($(this).is(':checked')) {
155                                 if(checkedstr.length != 0) {
156                                         checkedstr = checkedstr + ',' + $(this).val();
157                                 }
158                                 else {
159                                         checkedstr = $(this).val();
160                                 }
161                         }       
162                 });
163                 $.post('item', { dropitems: checkedstr }, function(data) {
164                         window.location.reload();
165                 });
166         }
167
168         function jotGetLink() {
169                 reply = prompt("$linkurl");
170                 if(reply && reply.length) {
171                         reply = bin2hex(reply);
172                         $('#profile-rotator').show();
173                         $.get('parse_url?binurl=' + reply, function(data) {
174                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
175                                 $('#profile-rotator').hide();
176                         });
177                 }
178         }
179
180         function jotGetVideo() {
181                 reply = prompt("$utubeurl");
182                 if(reply && reply.length) {
183                         tinyMCE.execCommand('mceInsertRawHTML',false,'[youtube]' + reply + '[/youtube]');
184                 }
185         }
186
187         function jotVideoURL() {
188                 reply = prompt("$vidurl");
189                 if(reply && reply.length) {
190                         tinyMCE.execCommand('mceInsertRawHTML',false,'[video]' + reply + '[/video]');
191                 }
192         }
193
194         function jotAudioURL() {
195                 reply = prompt("$audurl");
196                 if(reply && reply.length) {
197                         tinyMCE.execCommand('mceInsertRawHTML',false,'[audio]' + reply + '[/audio]');
198                 }
199         }
200
201
202         function jotGetLocation() {
203                 reply = prompt("$whereareu", $('#jot-location').val());
204                 if(reply && reply.length) {
205                         $('#jot-location').val(reply);
206                 }
207         }
208
209         function jotTitle() {
210                 reply = prompt("$title", $('#jot-title').val());
211                 if(reply && reply.length) {
212                         $('#jot-title').val(reply);
213                 }
214         }
215
216         function jotShare(id) {
217                 $('#like-rotator-' + id).show();
218                 $.get('share/' + id, function(data) {
219                                 if (!editor) $("#profile-jot-text").val("");
220                                 initEditor(function(){
221                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
222                                         $('#like-rotator-' + id).hide();
223                                         $(window).scrollTop(0);
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                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
245                                         $('#profile-rotator').hide();
246                                 });
247                         });
248                 }
249         }
250
251         function jotClearLocation() {
252                 $('#jot-coord').val('');
253                 $('#profile-nolocation-wrapper').hide();
254         }
255
256         $geotag
257
258 </script>
259