]> git.mxchange.org Git - friendica.git/blob - view/jot-header.tpl
New theme "vier" derives from "quattro"
[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                                 cPopup = null;
34                                 ed.onKeyDown.add(function(ed,e) {
35                                         if(cPopup !== null)
36                                                 cPopup.onkey(e);
37                                 });
38
39                                 ed.onKeyUp.add(function(ed, e) {
40                                         var txt = tinyMCE.activeEditor.getContent();
41                                         match = txt.match(/@([^ \n]+)$/);
42                                         if(match!==null) {
43                                                 if(cPopup === null) {
44                                                         cPopup = new ACPopup(this,baseurl+"/acl");
45                                                 }
46                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
47                                                 if(! cPopup.ready) cPopup = null;
48                                         }
49                                         else {
50                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
51                                         }
52
53                                         textlen = txt.length;
54                                         if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
55                                                 $('#profile-jot-desc').html(ispublic);
56                                         }
57                                         else {
58                                                 $('#profile-jot-desc').html('&nbsp;');
59                                         }        
60
61                                  //Character count
62
63                                         if(textlen <= 140) {
64                                                 $('#character-counter').removeClass('red');
65                                                 $('#character-counter').removeClass('orange');
66                                                 $('#character-counter').addClass('grey');
67                                         }
68                                         if((textlen > 140) && (textlen <= 420)) {
69                                                 $('#character-counter').removeClass('grey');
70                                                 $('#character-counter').removeClass('red');
71                                                 $('#character-counter').addClass('orange');
72                                         }
73                                         if(textlen > 420) {
74                                                 $('#character-counter').removeClass('grey');
75                                                 $('#character-counter').removeClass('orange');
76                                                 $('#character-counter').addClass('red');
77                                         }
78                                         $('#character-counter').text(textlen);
79                                 });
80
81                                 ed.onInit.add(function(ed) {
82                                         ed.pasteAsPlainText = true;
83                                         $("#profile-jot-text-loading").hide();
84                                         $(".jothidden").show();
85                                         if (typeof cb!="undefined") cb();
86                                 });
87
88                         }
89                 });
90                 editor = true;
91                 // setup acl popup
92                 $("a#jot-perms-icon").fancybox({
93                         'transitionIn' : 'elastic',
94                         'transitionOut' : 'elastic'
95                 }); 
96         } else {
97                 if (typeof cb!="undefined") cb();
98         }
99 }
100
101 function enableOnUser(){
102         if (editor) return;
103         $(this).val("");
104         initEditor();
105 }
106
107 </script>
108 <script type="text/javascript" src="js/ajaxupload.js" ></script>
109 <script>
110         var ispublic = '$ispublic';
111         var addtitle = '$addtitle';
112
113         $(document).ready(function() {
114                 
115                 /* enable tinymce on focus and click */
116                 $("#profile-jot-text").focus(enableOnUser);
117                 $("#profile-jot-text").click(enableOnUser);
118
119         
120                 var uploader = new window.AjaxUpload(
121                         'wall-image-upload',
122                         { action: 'wall_upload/$nickname',
123                                 name: 'userfile',
124                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
125                                 onComplete: function(file,response) {
126                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
127                                         $('#profile-rotator').hide();
128                                 }                                
129                         }
130                 );
131                 var file_uploader = new window.AjaxUpload(
132                         'wall-file-upload',
133                         { action: 'wall_attach/$nickname',
134                                 name: 'userfile',
135                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
136                                 onComplete: function(file,response) {
137                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
138                                         $('#profile-rotator').hide();
139                                 }                                
140                         }
141                 );
142
143
144         });
145
146         function deleteCheckedItems() {
147                 var checkedstr = '';
148
149                 $('.item-select').each( function() {
150                         if($(this).is(':checked')) {
151                                 if(checkedstr.length != 0) {
152                                         checkedstr = checkedstr + ',' + $(this).val();
153                                 }
154                                 else {
155                                         checkedstr = $(this).val();
156                                 }
157                         }       
158                 });
159                 $.post('item', { dropitems: checkedstr }, function(data) {
160                         window.location.reload();
161                 });
162         }
163
164         function jotGetLink() {
165                 reply = prompt("$linkurl");
166                 if(reply && reply.length) {
167                         reply = bin2hex(reply);
168                         $('#profile-rotator').show();
169                         $.get('parse_url?binurl=' + reply, function(data) {
170                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
171                                 $('#profile-rotator').hide();
172                         });
173                 }
174         }
175
176         function jotVideoURL() {
177                 reply = prompt("$vidurl");
178                 if(reply && reply.length) {
179                         tinyMCE.execCommand('mceInsertRawHTML',false,'[video]' + reply + '[/video]');
180                 }
181         }
182
183         function jotAudioURL() {
184                 reply = prompt("$audurl");
185                 if(reply && reply.length) {
186                         tinyMCE.execCommand('mceInsertRawHTML',false,'[audio]' + reply + '[/audio]');
187                 }
188         }
189
190
191         function jotGetLocation() {
192                 reply = prompt("$whereareu", $('#jot-location').val());
193                 if(reply && reply.length) {
194                         $('#jot-location').val(reply);
195                 }
196         }
197
198         function jotShare(id) {
199                 $('#like-rotator-' + id).show();
200                 $.get('share/' + id, function(data) {
201                         if (!editor) $("#profile-jot-text").val("");
202                         initEditor(function(){
203                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
204                                 $('#like-rotator-' + id).hide();
205                                 $(window).scrollTop(0);
206                         });
207
208                 });
209         }
210
211         function linkdropper(event) {
212                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
213                 if(linkFound)
214                         event.preventDefault();
215         }
216
217         function linkdrop(event) {
218                 var reply = event.dataTransfer.getData("text/uri-list");
219                 event.target.textContent = reply;
220                 event.preventDefault();
221                 if(reply && reply.length) {
222                         reply = bin2hex(reply);
223                         $('#profile-rotator').show();
224                         $.get('parse_url?binurl=' + reply, function(data) {
225                                 if (!editor) $("#profile-jot-text").val("");
226                                 initEditor(function(){
227                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
228                                         $('#profile-rotator').hide();
229                                 });
230                         });
231                 }
232         }
233
234         function itemTag(id) {
235                 reply = prompt("$term");
236                 if(reply && reply.length) {
237                         reply = reply.replace('#','');
238                         if(reply.length) {
239
240                                 commentBusy = true;
241                                 $('body').css('cursor', 'wait');
242
243                                 $.get('tagger/' + id + '?term=' + reply);
244                                 if(timer) clearTimeout(timer);
245                                 timer = setTimeout(NavUpdate,3000);
246                                 liking = 1;
247                         }
248                 }
249         }
250
251         function jotClearLocation() {
252                 $('#jot-coord').val('');
253                 $('#profile-nolocation-wrapper').hide();
254         }
255
256         $geotag
257
258 </script>
259