]> git.mxchange.org Git - friendica.git/blob - view/jot-header.tpl
Merge pull request #142 from fabrixxm/newacl
[friendica.git] / view / jot-header.tpl
1
2 <script language="javascript" type="text/javascript">
3
4 var editor=false;
5 var textlen = 0;
6
7 function initEditor(){
8         $("#profile-jot-text-loading").show();
9         tinyMCE.init({
10                 theme : "advanced",
11                 mode : "specific_textareas",
12                 editor_selector: /(profile-jot-text|prvmail-text)/,
13                 plugins : "bbcode,paste,autoresize",
14                 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
15                 theme_advanced_buttons2 : "",
16                 theme_advanced_buttons3 : "",
17                 theme_advanced_toolbar_location : "top",
18                 theme_advanced_toolbar_align : "center",
19                 theme_advanced_blockformats : "blockquote,code",
20                 paste_text_sticky : true,
21                 entity_encoding : "raw",
22                 add_unload_trigger : false,
23                 remove_linebreaks : false,
24                 force_p_newlines : false,
25                 force_br_newlines : true,
26                 forced_root_block : '',
27                 convert_urls: false,
28                 content_css: "$baseurl/view/custom_tinymce.css",
29                 theme_advanced_path : false,
30                 setup : function(ed) {
31                          //Character count
32                         ed.onKeyUp.add(function(ed, e) {
33                                 var txt = tinyMCE.activeEditor.getContent();
34                                 textlen = txt.length;
35                                 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
36                                         $('#profile-jot-desc').html(ispublic);
37                                 }
38                                 else {
39                                         $('#profile-jot-desc').html('&nbsp;');
40                                 }        
41
42                                 if(textlen <= 140) {
43                                         $('#character-counter').removeClass('red');
44                                         $('#character-counter').removeClass('orange');
45                                         $('#character-counter').addClass('grey');
46                                 }
47                                 if((textlen > 140) && (textlen <= 420)) {
48                                         $('#character-counter').removeClass('grey');
49                                         $('#character-counter').removeClass('red');
50                                         $('#character-counter').addClass('orange');
51                                 }
52                                 if(textlen > 420) {
53                                         $('#character-counter').removeClass('grey');
54                                         $('#character-counter').removeClass('orange');
55                                         $('#character-counter').addClass('red');
56                                 }
57                                 $('#character-counter').text(textlen);
58                         });
59
60                         ed.onInit.add(function(ed) {
61                                 ed.pasteAsPlainText = true;
62                                 $("#profile-jot-text-loading").hide();
63                                 $("#profile-jot-submit-wrapper").show();
64                         });
65
66                 }
67         });
68         editor = true;
69         
70         // setup acl popup
71         $("#profile-jot-acl-wrapper").hide();
72         $("a#jot-perms-icon").fancybox({
73                 'transitionIn' : 'none',
74                 'transitionOut' : 'none'
75         }); 
76 }
77
78 </script>
79 <script type="text/javascript" src="include/ajaxupload.js" ></script>
80 <script>
81         var ispublic = '$ispublic';
82         $(document).ready(function() {
83                 
84                 /* enable tinymce on focus */
85                 $("#profile-jot-text").focus(function(){
86                         if (editor) return;
87                         $(this).val("");
88                         initEditor();
89                 });
90                 
91         
92                 var uploader = new window.AjaxUpload(
93                         'wall-image-upload',
94                         { action: 'wall_upload/$nickname',
95                                 name: 'userfile',
96                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
97                                 onComplete: function(file,response) {
98                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
99                                         $('#profile-rotator').hide();
100                                 }                                
101                         }
102                 );
103                 var file_uploader = new window.AjaxUpload(
104                         'wall-file-upload',
105                         { action: 'wall_attach/$nickname',
106                                 name: 'userfile',
107                                 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
108                                 onComplete: function(file,response) {
109                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
110                                         $('#profile-rotator').hide();
111                                 }                                
112                         }
113                 );
114
115
116         });
117
118         function deleteCheckedItems() {
119                 var checkedstr = '';
120
121                 $('.item-select').each( function() {
122                         if($(this).is(':checked')) {
123                                 if(checkedstr.length != 0) {
124                                         checkedstr = checkedstr + ',' + $(this).val();
125                                 }
126                                 else {
127                                         checkedstr = $(this).val();
128                                 }
129                         }       
130                 });
131                 $.post('item', { dropitems: checkedstr }, function(data) {
132                         window.location.reload();
133                 });
134         }
135
136         function jotGetLink() {
137                 reply = prompt("$linkurl");
138                 if(reply && reply.length) {
139                         reply = bin2hex(reply);
140                         $('#profile-rotator').show();
141                         $.get('parse_url?url=' + reply, function(data) {
142                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
143                                 $('#profile-rotator').hide();
144                         });
145                 }
146         }
147
148         function jotGetVideo() {
149                 reply = prompt("$utubeurl");
150                 if(reply && reply.length) {
151                         tinyMCE.execCommand('mceInsertRawHTML',false,'[youtube]' + reply + '[/youtube]');
152                 }
153         }
154
155         function jotVideoURL() {
156                 reply = prompt("$vidurl");
157                 if(reply && reply.length) {
158                         tinyMCE.execCommand('mceInsertRawHTML',false,'[video]' + reply + '[/video]');
159                 }
160         }
161
162         function jotAudioURL() {
163                 reply = prompt("$audurl");
164                 if(reply && reply.length) {
165                         tinyMCE.execCommand('mceInsertRawHTML',false,'[audio]' + reply + '[/audio]');
166                 }
167         }
168
169
170         function jotGetLocation() {
171                 reply = prompt("$whereareu", $('#jot-location').val());
172                 if(reply && reply.length) {
173                         $('#jot-location').val(reply);
174                 }
175         }
176
177         function jotTitle() {
178                 reply = prompt("$title", $('#jot-title').val());
179                 if(reply && reply.length) {
180                         $('#jot-title').val(reply);
181                 }
182         }
183
184         function jotShare(id) {
185                 $('#like-rotator-' + id).show();
186                 $.get('share/' + id, function(data) {
187                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
188                         $('#like-rotator-' + id).hide();
189                         $(window).scrollTop(0);
190                 });
191         }
192
193         function linkdropper(event) {
194                 var linkFound = event.dataTransfer.types.contains("text/uri-list");
195                 if(linkFound)
196                         event.preventDefault();
197         }
198
199         function linkdrop(event) {
200                 var reply = event.dataTransfer.getData("text/uri-list");
201                 event.target.textContent = reply;
202                 event.preventDefault();
203                 if(reply && reply.length) {
204                         $('#profile-rotator').show();
205                         $.get('parse_url?url=' + reply, function(data) {
206                                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
207                                 $('#profile-rotator').hide();
208                         });
209                 }
210         }
211
212         function jotClearLocation() {
213                 $('#jot-coord').val('');
214                 $('#profile-nolocation-wrapper').hide();
215         }
216
217         $geotag
218
219 </script>
220