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