3 <script language="javascript" type="text/javascript">
7 var plaintext = '{{$editselect}}';
9 function initEditor(cb){
11 $("#profile-jot-text-loading").show();
12 if(plaintext == 'none') {
13 $("#profile-jot-text-loading").hide();
14 $("#profile-jot-text").addClass("profile-jot-text-full").removeClass("profile-jot-text-empty");
15 $("#jot-category").show();
16 $("#jot-category").addClass("jot-category-ex");
17 $("#jot-profile-jot-wrapper").show();
18 $("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
20 $("a#jot-perms-icon").colorbox({
22 'transition' : 'elastic'
24 $(".jothidden").show();
25 if (typeof cb!="undefined") cb();
30 mode : "specific_textareas",
31 editor_selector: {{$editselect}},
32 auto_focus: "profile-jot-text",
33 plugins : "bbcode,paste,autoresize, inlinepopups",
34 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
35 theme_advanced_buttons2 : "",
36 theme_advanced_buttons3 : "",
37 theme_advanced_toolbar_location : "top",
38 theme_advanced_toolbar_align : "center",
39 theme_advanced_blockformats : "blockquote,code",
40 theme_advanced_resizing : true,
41 gecko_spellcheck : true,
42 paste_text_sticky : true,
43 entity_encoding : "raw",
44 add_unload_trigger : false,
45 remove_linebreaks : false,
46 //force_p_newlines : false,
47 //force_br_newlines : true,
48 forced_root_block : 'div',
50 content_css: "{{$baseurl}}/view/custom_tinymce.css",
51 theme_advanced_path : false,
52 file_browser_callback : "fcFileBrowser",
53 setup : function(ed) {
55 ed.onKeyDown.add(function(ed,e) {
60 ed.onKeyUp.add(function(ed, e) {
61 var txt = tinyMCE.activeEditor.getContent();
62 match = txt.match(/@([^ \n]+)$/);
65 cPopup = new ACPopup(this,baseurl+"/acl");
67 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
68 if(! cPopup.ready) cPopup = null;
71 if(cPopup !== null) { cPopup.close(); cPopup = null; }
75 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
76 $('#profile-jot-desc').html(ispublic);
79 $('#profile-jot-desc').html(' ');
85 $('#character-counter').removeClass('red');
86 $('#character-counter').removeClass('orange');
87 $('#character-counter').addClass('grey');
89 if((textlen > 140) && (textlen <= 420)) {
90 $('#character-counter').removeClass('grey');
91 $('#character-counter').removeClass('red');
92 $('#character-counter').addClass('orange');
95 $('#character-counter').removeClass('grey');
96 $('#character-counter').removeClass('orange');
97 $('#character-counter').addClass('red');
99 $('#character-counter').text(textlen);
102 ed.onInit.add(function(ed) {
103 ed.pasteAsPlainText = true;
104 $("#profile-jot-text-loading").hide();
105 $(".jothidden").show();
106 if (typeof cb!="undefined") cb();
113 $("a#jot-perms-icon").colorbox({
115 'transition' : 'elastic'
118 if (typeof cb!="undefined") cb();
122 function enableOnUser(){
132 <script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
134 var ispublic = '{{$ispublic}}';
137 $(document).ready(function() {
139 /* enable tinymce on focus and click */
140 $("#profile-jot-text").focus(enableOnUser);
141 $("#profile-jot-text").click(enableOnUser);
146 /* show images / file browser window
151 $('body').on('fbrowser.image.main', function(e, filename, embedcode, id) {
153 addeditortext(embedcode);
155 $('body').on('fbrowser.file.main', function(e, filename, embedcode, id) {
157 addeditortext(embedcode);
160 $('#wall-image-upload').on('click', function(){
161 Dialog.doImageBrowser("main");
164 $('#wall-file-upload').on('click', function(){
165 Dialog.doFileBrowser("main");
169 var uploader = new window.AjaxUpload(
171 { action: 'wall_upload/{{$nickname}}',
173 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
174 onComplete: function(file,response) {
175 addeditortext(response);
176 $('#profile-rotator').hide();
180 var file_uploader = new window.AjaxUpload(
182 { action: 'wall_attach/{{$nickname}}',
184 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
185 onComplete: function(file,response) {
186 addeditortext(response);
187 $('#profile-rotator').hide();
197 function deleteCheckedItems() {
198 if(confirm('{{$delitems}}')) {
201 $("#item-delete-selected").hide();
202 $('#item-delete-selected-rotator').show();
204 $('.item-select').each( function() {
205 if($(this).is(':checked')) {
206 if(checkedstr.length != 0) {
207 checkedstr = checkedstr + ',' + $(this).val();
210 checkedstr = $(this).val();
214 $.post('item', { dropitems: checkedstr }, function(data) {
215 window.location.reload();
220 function jotGetLink() {
221 reply = prompt("{{$linkurl}}");
222 if(reply && reply.length) {
223 reply = bin2hex(reply);
224 $('#profile-rotator').show();
225 $.get('parse_url?binurl=' + reply, function(data) {
227 $('#profile-rotator').hide();
232 function jotVideoURL() {
233 reply = prompt("{{$vidurl}}");
234 if(reply && reply.length) {
235 addeditortext('[video]' + reply + '[/video]');
239 function jotAudioURL() {
240 reply = prompt("{{$audurl}}");
241 if(reply && reply.length) {
242 addeditortext('[audio]' + reply + '[/audio]');
247 function jotGetLocation() {
248 reply = prompt("{{$whereareu}}", $('#jot-location').val());
249 if(reply && reply.length) {
250 $('#jot-location').val(reply);
254 function jotShare(id) {
255 // if ($('#jot-popup').length != 0) $('#jot-popup').show();
257 // $('#like-rotator-' + id).show();
258 // $.get('share/' + id, function(data) {
259 // if (!editor) $("#profile-jot-text").val("");
260 // initEditor(function(){
261 // addeditortext(data);
262 // $('#like-rotator-' + id).hide();
263 // $(window).scrollTop(0);
268 $.get('share/' + id, function(data) {
269 if (!editor) $("#profile-jot-text").val("");
270 initEditor(function(){
277 $("#jot-popup").show();
280 function linkdropper(event) {
281 var linkFound = event.dataTransfer.types.contains("text/uri-list");
283 event.preventDefault();
286 function linkdrop(event) {
287 var reply = event.dataTransfer.getData("text/uri-list");
288 event.target.textContent = reply;
289 event.preventDefault();
290 if(reply && reply.length) {
291 reply = bin2hex(reply);
292 $('#profile-rotator').show();
293 $.get('parse_url?binurl=' + reply, function(data) {
294 if (!editor) $("#profile-jot-text").val("");
295 initEditor(function(){
297 $('#profile-rotator').hide();
303 function itemTag(id) {
304 reply = prompt("{{$term}}");
305 if(reply && reply.length) {
306 reply = reply.replace('#','');
310 $('body').css('cursor', 'wait');
312 $.get('tagger/' + id + '?term=' + reply);
313 if(timer) clearTimeout(timer);
314 timer = setTimeout(NavUpdate,3000);
320 function itemFiler(id) {
322 var bordercolor = $("input").css("border-color");
324 $.get('filer/', function(data){
325 $.colorbox({html:data});
326 $("#id_term").keypress(function(){
327 $(this).css("border-color",bordercolor);
329 $("#select_term").change(function(){
330 $("#id_term").css("border-color",bordercolor);
333 $("#filer_save").click(function(e){
335 reply = $("#id_term").val();
336 if(reply && reply.length) {
338 $('body').css('cursor', 'wait');
339 $.get('filer/' + id + '?term=' + reply, NavUpdate);
340 // if(timer) clearTimeout(timer);
341 // timer = setTimeout(NavUpdate,3000);
345 $("#id_term").css("border-color","#FF0000");
353 function jotClearLocation() {
354 $('#jot-coord').val('');
355 $('#profile-nolocation-wrapper').hide();
358 function addeditortext(data) {
359 if(plaintext == 'none') {
360 var currentText = $("#profile-jot-text").val();
361 $("#profile-jot-text").val(currentText + data);
364 tinyMCE.execCommand('mceInsertRawHTML',false,data);
370 var modal = $('#jot-modal').modal();
371 var jot = $("#profile-jot-form");
373 // Clear bs modal on close
374 // We need this to prevent that the modal displays old content
375 $('body').on('hidden.bs.modal', '#jot-modal', function () {
376 $(this).removeData('bs.modal');
377 $("#jot-content").append(jot);
381 .find('#jot-modal-body')
387 // the following functions show/hide the specific jot content
388 // in dependence of the selected nav
389 function aclActive() {
390 $(".modal-body #profile-jot-wrapper, .modal-body #jot-preview-content").hide();
391 $(".modal-body #profile-jot-acl-wrapper").show();
392 $("#jot-text-lnk, #jot-preview-lnk").parent("li").removeClass("active");
393 $("#jot-perms-lnk").parent("li").addClass("active");
396 function jotActive() {
397 $(".modal-body #profile-jot-acl-wrapper, .modal-body #jot-preview-content").hide();
398 $(".modal-body #profile-jot-wrapper").show();
399 $("#jot-perms-lnk, #jot-preview-lnk").parent("li").removeClass("active");
400 $("#jot-text-lnk").parent("li").addClass("active");
403 function previewActive() {
404 $(".modal-body #profile-jot-wrapper, .modal-body #profile-jot-acl-wrapper").hide();
405 $("#jot-text-lnk, #jot-perms-lnk").parent("li").removeClass("active");
406 $("#jot-preview-lnk").parent("li").addClass("active");