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