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