]> git.mxchange.org Git - friendica.git/blob - view/theme/dispy-dark/jot-header.tpl
4c8f59d7969bd2348ebbacf1d3daa26da4f6f4e2
[friendica.git] / view / theme / dispy-dark / jot-header.tpl
1 <script type="text/javascript">
2 var editor = false;
3 var textlen = 0;
4 var plaintext = '$editselect';
5
6 function initEditor(cb) {
7         if (editor==false) {
8                 $("#profile-jot-text-loading").show();
9                 if(plaintext == 'none') {
10                         $("#profile-jot-text-loading").hide();
11                         $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
12                         editor = true;
13                         $("a#jot-perms-icon").fancybox({
14                                 'transitionIn' : 'elastic',
15                                 'transitionOut' : 'elastic'
16                         });
17                         $(".jothidden").show();
18                         if (typeof cb!="undefined") cb();
19                         return;
20                 }
21                 tinyMCE.init({
22                         theme : "advanced",
23                         mode : "specific_textareas",
24                         editor_selector: $editselect,
25                         auto_focus: "profile-jot-text",
26                         plugins : "bbcode,paste,fullscreen,autoresize",
27                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code,fullscreen",
28                         theme_advanced_buttons2 : "",
29                         theme_advanced_buttons3 : "",
30                         theme_advanced_toolbar_location : "top",
31                         theme_advanced_toolbar_align : "center",
32                         theme_advanced_blockformats : "blockquote,code",
33                         paste_text_sticky : true,
34                         entity_encoding : "raw",
35                         add_unload_trigger : false,
36                         remove_linebreaks : false,
37                         force_p_newlines : false,
38                         force_br_newlines : true,
39                         forced_root_block : '',
40                         convert_urls: false,
41                         content_css: "$baseurl/view/custom_tinymce.css",
42                         theme_advanced_path : false,
43                         setup : function(ed) {
44                                 cPopup = null;
45                                 ed.onKeyDown.add(function(ed,e) {
46                                         if(cPopup !== null)
47                                                 cPopup.onkey(e);
48                                 });
49
50                                 ed.onKeyUp.add(function(ed, e) {
51                                         var txt = tinyMCE.activeEditor.getContent();
52                                         match = txt.match(/@([^ \n]+)$/);
53                                         if(match!==null) {
54                                                 if(cPopup === null) {
55                                                         cPopup = new ACPopup(this,baseurl+"/acl");
56                                                 }
57                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
58                                                 if(! cPopup.ready) cPopup = null;
59                                         }
60                                         else {
61                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
62                                         }
63
64                                         textlen = txt.length;
65                                         if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
66                                                 $('#profile-jot-desc').html(ispublic);
67                                         }
68                                         else {
69                                                 $('#profile-jot-desc').html('&#160;');
70                                         }        
71
72                                  //Character count
73
74                                         if(textlen <= 140) {
75                                                 $('#character-counter').removeClass('red');
76                                                 $('#character-counter').removeClass('orange');
77                                                 $('#character-counter').addClass('grey');
78                                         }
79                                         if((textlen > 140) && (textlen <= 420)) {
80                                                 $('#character-counter').removeClass('grey');
81                                                 $('#character-counter').removeClass('red');
82                                                 $('#character-counter').addClass('orange');
83                                         }
84                                         if(textlen > 420) {
85                                                 $('#character-counter').removeClass('grey');
86                                                 $('#character-counter').removeClass('orange');
87                                                 $('#character-counter').addClass('red');
88                                         }
89                                         $('#character-counter').text(textlen);
90                                 });
91
92                                 ed.onInit.add(function(ed) {
93                                         ed.pasteAsPlainText = true;
94                                         $("#profile-jot-text-loading").hide();
95                                         $(".jothidden").show();
96                                         if (typeof cb!="undefined") cb();
97                                 });
98
99                         }
100                 });
101                 editor = true;
102                 // setup acl popup
103                 $("a#jot-perms-icon").fancybox({
104                         'transitionIn' : 'elastic',
105                         'transitionOut' : 'elastic'
106                 }); 
107         } else {
108                 if (typeof cb!="undefined") cb();
109         }
110 }
111
112 function enableOnUser(){
113         if (editor) return;
114         $(this).val("");
115         initEditor();
116 }
117
118 </script>
119 <script type="text/javascript" src="$baseurl/js/ajaxupload.js"></script>
120 <script type="text/javascript">
121         var ispublic = '$ispublic';
122         var addtitle = '$addtitle';
123
124         $(document).ready(function() {
125                 
126                 /* enable tinymce on focus and click */
127                 $("#profile-jot-text").focus(enableOnUser);
128                 $("#profile-jot-text").click(enableOnUser);
129                 /* enable character counter */
130                 $("#profile-jot-text").focus(charCounter);
131                 $("#profile-jot-text").click(charCounter);
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                                         addeditortext(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                                         addeditortext(response);
151                                         $('#profile-rotator').hide();
152                                 }                                
153                         }
154                 );
155
156
157         });
158
159         function deleteCheckedItems() {
160                 var checkedstr = '';
161
162                 $('.item-select').each( function() {
163                         if($(this).is(':checked')) {
164                                 if(checkedstr.length != 0) {
165                                         checkedstr = checkedstr + ',' + $(this).val();
166                                 }
167                                 else {
168                                         checkedstr = $(this).val();
169                                 }
170                         }       
171                 });
172                 $.post('item', { dropitems: checkedstr }, function(data) {
173                         window.location.reload();
174                 });
175         }
176
177         function jotGetLink() {
178                 reply = prompt("$linkurl");
179                 if(reply && reply.length) {
180                         reply = bin2hex(reply);
181                         $('#profile-rotator').show();
182                         $.get('parse_url?binurl=' + reply, function(data) {
183                                 addeditortext(data);
184                                 $('#profile-rotator').hide();
185                         });
186                 }
187         }
188
189         function jotVideoURL() {
190                 reply = prompt("$vidurl");
191                 if(reply && reply.length) {
192                         addeditortext('[video]' + reply + '[/video]');
193                 }
194         }
195
196         function jotAudioURL() {
197                 reply = prompt("$audurl");
198                 if(reply && reply.length) {
199                         addeditortext('[audio]' + reply + '[/audio]');
200                 }
201         }
202
203
204         function jotGetLocation() {
205                 reply = prompt("$whereareu", $('#jot-location').val());
206                 if(reply && reply.length) {
207                         $('#jot-location').val(reply);
208                 }
209         }
210
211         function jotShare(id) {
212                 if ($('#jot-popup').length != 0) $('#jot-popup').show();
213
214                 $('#like-rotator-' + id).show();
215                 $.get('share/' + id, function(data) {
216                         if (!editor) $("#profile-jot-text").val("");
217                         initEditor(function(){
218                                 addeditortext(data);
219                                 $('#like-rotator-' + id).hide();
220                                 $(window).scrollTop(0);
221                         });
222
223                 });
224         }
225
226         function linkdropper(event) {
227                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
228                 if(linkFound)
229                         event.preventDefault();
230         }
231
232         function linkdrop(event) {
233                 var reply = event.dataTransfer.getData("text/uri-list");
234                 event.target.textContent = reply;
235                 event.preventDefault();
236                 if(reply && reply.length) {
237                         reply = bin2hex(reply);
238                         $('#profile-rotator').show();
239                         $.get('parse_url?binurl=' + reply, function(data) {
240                                 if (!editor) $("#profile-jot-text").val("");
241                                 initEditor(function(){
242                                         addeditortext(data);
243                                         $('#profile-rotator').hide();
244                                 });
245                         });
246                 }
247         }
248
249         function itemTag(id) {
250                 reply = prompt("$term");
251                 if(reply && reply.length) {
252                         reply = reply.replace('#','');
253                         if(reply.length) {
254
255                                 commentBusy = true;
256                                 $('body').css('cursor', 'wait');
257
258                                 $.get('tagger/' + id + '?term=' + reply);
259                                 if(timer) clearTimeout(timer);
260                                 timer = setTimeout(NavUpdate,3000);
261                                 liking = 1;
262                         }
263                 }
264         }
265
266         function itemFiler(id) {
267                 reply = prompt("$fileas");
268                 if(reply && reply.length) {
269                         commentBusy = true;
270                         $('body').css('cursor', 'wait');
271                         $.get('filer/' + id + '?term=' + reply);
272                         if(timer) clearTimeout(timer);
273                         timer = setTimeout(NavUpdate,3000);
274                         liking = 1;
275                 }
276         }
277
278         function jotClearLocation() {
279                 $('#jot-coord').val('');
280                 $('#profile-nolocation-wrapper').hide();
281         }
282
283         function addeditortext(data) {
284                 if(plaintext == 'none') {
285                         var currentText = $("#profile-jot-text").val();
286                         $("#profile-jot-text").val(currentText + data);
287                 }
288                 else
289                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
290         }       
291
292         $geotag
293
294         function charCounter() {
295                 // character count part deux
296                 //$(this).val().length is not a function Line 282(3)
297                 $('#profile-jot-text').keyup(function() {
298                         var textlen = 0;
299                         var maxLen1 = 140;
300                         var maxLen2 = 420;
301
302                         $('#character-counter').removeClass('jothidden');
303
304                         textLen = $(this).val().length;
305                         if(textLen <= maxLen1) {
306                                 $('#character-counter').removeClass('red');
307                                 $('#character-counter').removeClass('orange');
308                                 $('#character-counter').addClass('grey');
309                         }
310                         if((textLen > maxLen1) && (textlen <= maxLen2)) {
311                                 $('#character-counter').removeClass('grey');
312                                 $('#character-counter').removeClass('red');
313                                 $('#character-counter').addClass('orange');
314                         }
315                         if(textLen > maxLen2) {
316                                 $('#character-counter').removeClass('grey');
317                                 $('#character-counter').removeClass('orange');
318                                 $('#character-counter').addClass('red');
319                         }
320                         $('#character-counter').text( textLen );
321                 });
322                 $('#profile-jot-text').keyup();
323         }
324
325 </script>
326