]> git.mxchange.org Git - friendica.git/blob - view/theme/testbubble/jot-header.tpl
more title stuff
[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
128                 $("#jot-title").mouseout(function() {
129                         $("#jot-title").hide();
130                         var ttl = $("#jot-title").val();
131                         $('#jot-title-display').html(ttl);
132                         if(ttl.length) {
133                                 $("#jot-title-display").show();
134                         }
135                         else {
136                                 $("#jot-title-desc").show();
137                         }
138                 });
139
140                 $("#jot-title-display").click(function() {
141                         $("#jot-title-display").hide();
142                         $("#jot-title").show();
143                         $("#jot-title").focus();
144                 });             
145
146                 $("#jot-title-desc").click(function() {
147                         $("#jot-title-desc").hide();
148                         $("#jot-title").show();
149                         $("#jot-title").focus();
150                 });             
151
152                 var uploader = new window.AjaxUpload(
153                         'wall-image-upload',
154                         { action: 'wall_upload/$nickname',
155                                 name: 'userfile',
156                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
157                                 onComplete: function(file,response) {
158                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
159                                         $('#profile-rotator').hide();
160                                 }                                
161                         }
162                 );
163                 var file_uploader = new window.AjaxUpload(
164                         'wall-file-upload',
165                         { action: 'wall_attach/$nickname',
166                                 name: 'userfile',
167                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
168                                 onComplete: function(file,response) {
169                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
170                                         $('#profile-rotator').hide();
171                                 }                                
172                         }
173                 );              
174                 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
175                         var selstr;
176                         $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
177                                 selstr = $(this).text();
178                                 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
179                                 $('#jot-public').hide();
180                                 $('.profile-jot-net input').attr('disabled', 'disabled');
181                         });
182                         if(selstr == null) { 
183                                 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
184                                 $('#jot-public').show();
185                                 $('.profile-jot-net input').attr('disabled', false);
186                         }
187
188                 }).trigger('change');
189
190         });
191
192         function deleteCheckedItems() {
193                 var checkedstr = '';
194
195                 $('.item-select').each( function() {
196                         if($(this).is(':checked')) {
197                                 if(checkedstr.length != 0) {
198                                         checkedstr = checkedstr + ',' + $(this).val();
199                                 }
200                                 else {
201                                         checkedstr = $(this).val();
202                                 }
203                         }       
204                 });
205                 $.post('item', { dropitems: checkedstr }, function(data) {
206                         window.location.reload();
207                 });
208         }
209
210         function jotGetLink() {
211                 reply = prompt("$linkurl");
212                 if(reply && reply.length) {
213                         reply = bin2hex(reply);
214                         $('#profile-rotator').show();
215                         $.get('parse_url?binurl=' + reply, function(data) {
216                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
217                                 $('#profile-rotator').hide();
218                         });
219                 }
220         }
221
222         function jotVideoURL() {
223                 reply = prompt("$vidurl");
224                 if(reply && reply.length) {
225                         tinyMCE.execCommand('mceInsertRawHTML',false,'[video]' + reply + '[/video]');
226                 }
227         }
228
229         function jotAudioURL() {
230                 reply = prompt("$audurl");
231                 if(reply && reply.length) {
232                         tinyMCE.execCommand('mceInsertRawHTML',false,'[audio]' + reply + '[/audio]');
233                 }
234         }
235
236
237         function jotGetLocation() {
238                 reply = prompt("$whereareu", $('#jot-location').val());
239                 if(reply && reply.length) {
240                         $('#jot-location').val(reply);
241                 }
242         }
243
244         function jotTitle() {
245                 reply = prompt("$title", $('#jot-title').val());
246                 if(reply && reply.length) {
247                         $('#jot-title').val(reply);
248                 }
249         }
250
251         function jotShare(id) {
252                 $('#like-rotator-' + id).show();
253                 $.get('share/' + id, function(data) {
254                                 if (!editor) $("#profile-jot-text").val("");
255                                 initEditor(function(){
256                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
257                                         $('#like-rotator-' + id).hide();
258                                         $(window).scrollTop(0);
259                                 });
260                 });
261         }
262
263         function linkdropper(event) {
264                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
265                 if(linkFound)
266                         event.preventDefault();
267         }
268
269         function linkdrop(event) {
270                 var reply = event.dataTransfer.getData("text/uri-list");
271                 event.target.textContent = reply;
272                 event.preventDefault();
273                 if(reply && reply.length) {
274                         reply = bin2hex(reply);
275                         $('#profile-rotator').show();
276                         $.get('parse_url?binurl=' + reply, function(data) {
277                                 if (!editor) $("#profile-jot-text").val("");
278                                 initEditor(function(){
279                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
280                                         $('#profile-rotator').hide();
281                                 });
282                         });
283                 }
284         }
285
286         function itemTag(id) {
287                 reply = prompt("$term");
288                 if(reply && reply.length) {
289                         reply = reply.replace('#','');
290                         if(reply.length) {
291
292                                 commentBusy = true;
293                                 $('body').css('cursor', 'wait');
294
295                                 $.get('tagger/' + id + '?term=' + reply);
296                                 if(timer) clearTimeout(timer);
297                                 timer = setTimeout(NavUpdate,3000);
298                                 liking = 1;
299                         }
300                 }
301         }
302
303         function jotClearLocation() {
304                 $('#jot-coord').val('');
305                 $('#profile-nolocation-wrapper').hide();
306         }
307
308         $geotag
309
310 </script>
311