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