]> git.mxchange.org Git - friendica.git/blob - view/jot-header.tpl
never enough comments
[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="js/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 jotVideoURL() {
153                 reply = prompt("$vidurl");
154                 if(reply && reply.length) {
155                         tinyMCE.execCommand('mceInsertRawHTML',false,'[video]' + reply + '[/video]');
156                 }
157         }
158
159         function jotAudioURL() {
160                 reply = prompt("$audurl");
161                 if(reply && reply.length) {
162                         tinyMCE.execCommand('mceInsertRawHTML',false,'[audio]' + reply + '[/audio]');
163                 }
164         }
165
166
167         function jotGetLocation() {
168                 reply = prompt("$whereareu", $('#jot-location').val());
169                 if(reply && reply.length) {
170                         $('#jot-location').val(reply);
171                 }
172         }
173
174         function jotTitle() {
175                 reply = prompt("$title", $('#jot-title').val());
176                 if(reply && reply.length) {
177                         $('#jot-title').val(reply);
178                 }
179         }
180
181
182         function jotShare(id) {
183                 $('#like-rotator-' + id).show();
184                 $.get('share/' + id, function(data) {
185                         if (!editor) $("#profile-jot-text").val("");
186                         initEditor(function(){
187                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
188                                 $('#like-rotator-' + id).hide();
189                                 $(window).scrollTop(0);
190                         });
191
192                 });
193         }
194
195         function linkdropper(event) {
196                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
197                 if(linkFound)
198                         event.preventDefault();
199         }
200
201         function linkdrop(event) {
202                 var reply = event.dataTransfer.getData("text/uri-list");
203                 event.target.textContent = reply;
204                 event.preventDefault();
205                 if(reply && reply.length) {
206                         $('#profile-rotator').show();
207                         $.get('parse_url?url=' + reply, function(data) {
208                                 if (!editor) $("#profile-jot-text").val("");
209                                 initEditor(function(){
210                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
211                                         $('#profile-rotator').hide();
212                                 });
213                         });
214                 }
215         }
216
217         function jotClearLocation() {
218                 $('#jot-coord').val('');
219                 $('#profile-nolocation-wrapper').hide();
220         }
221
222         $geotag
223
224 </script>
225