1 $(document).ready(function() {
3 /* enable tinymce on focus and click */
4 $("#profile-jot-text").focus(enableOnUser);
5 $("#profile-jot-text").click(enableOnUser);
7 /*$('html').click(function() { $("#nav-notifications-menu" ).hide(); });*/
9 /*$('.group-edit-icon').hover(
11 $(this).addClass('icon'); $(this).removeClass('iconspacer');},
13 $(this).removeClass('icon'); $(this).addClass('iconspacer');}
16 $('.sidebar-group-element').hover(
18 id = $(this).attr('id');
19 $('#edit-' + id).addClass('icon'); $('#edit-' + id).removeClass('iconspacer');},
22 id = $(this).attr('id');
23 $('#edit-' + id).removeClass('icon');$('#edit-' + id).addClass('iconspacer');}
27 $('.savedsearchdrop').hover(
29 $(this).addClass('drop'); $(this).addClass('icon'); $(this).removeClass('iconspacer');},
31 $(this).removeClass('drop'); $(this).removeClass('icon'); $(this).addClass('iconspacer');}
34 $('.savedsearchterm').hover(
36 id = $(this).attr('id');
37 $('#drop-' + id).addClass('icon'); $('#drop-' + id).addClass('drophide'); $('#drop-' + id).removeClass('iconspacer');},
40 id = $(this).attr('id');
41 $('#drop-' + id).removeClass('icon');$('#drop-' + id).removeClass('drophide'); $('#drop-' + id).addClass('iconspacer');}
45 $('#event-share-checkbox').change(function() {
47 if ($('#event-share-checkbox').is(':checked')) {
48 $('#acl-wrapper').show();
51 $('#acl-wrapper').hide();
56 $(".popupbox").click(function () {
57 var parent = $( $(this).attr('href') ).parent();
58 if (parent.css('display') == 'none') {
68 if(typeof window.AjaxUpload != "undefined") {
69 var uploader = new window.AjaxUpload(
70 window.imageUploadButton,
71 { action: 'wall_upload/'+window.nickname+'?nomce=1',
73 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
74 onComplete: function(file,response) {
75 addeditortext(window.jotId, response);
76 $('#profile-rotator').hide();
81 if($('#wall-file-upload').length) {
82 var file_uploader = new window.AjaxUpload(
84 { action: 'wall_attach/'+window.nickname+'?nomce=1',
86 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
87 onComplete: function(file,response) {
88 addeditortext(window.jotId, response);
89 $('#profile-rotator').hide();
97 if(typeof window.aclInit !="undefined" && typeof acl=="undefined"){
100 [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
104 switch(window.autocompleteType) {
106 var a = $("#recip").autocomplete({
107 serviceUrl: baseurl + '/acl',
110 onSelect: function(value,data) {
111 $("#recip-complete").val(data);
115 case 'contacts-head':
116 var a = $("#contacts-search").autocomplete({
117 serviceUrl: baseurl + '/acl',
121 a.setOptions({ params: { type: 'a' }});
124 $(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
131 /* if(window.autoCompleteType == "display-head") {
132 //$(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
133 // make auto-complete work in more places
134 //$(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
135 $(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
139 if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
140 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
142 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
143 selstr = $(this).text();
144 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
145 $('#jot-public').hide();
148 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
149 $('#jot-public').show();
152 }).trigger('change');
155 if(window.aclType == "event_head") {
156 $('#events-calendar').fullCalendar({
157 events: baseurl + '/events/json/',
159 left: 'prev,next today',
161 right: 'month,agendaWeek,agendaDay'
163 timeFormat: 'H(:mm)',
164 eventClick: function(calEvent, jsEvent, view) {
165 showEvent(calEvent.id);
168 eventRender: function(event, element, view) {
169 //console.log(view.name);
170 if (event.item['author-name']==null) return;
173 element.find(".fc-event-title").html(
174 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
175 event.item['author-avatar'],
176 event.item['author-name'],
181 element.find(".fc-event-title").html(
182 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
183 event.item['author-avatar'],
184 event.item['author-name'],
190 element.find(".fc-event-title").html(
191 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
192 event.item['author-avatar'],
193 event.item['author-name'],
204 var args=location.href.replace(baseurl,"").split("/");
205 if (args.length>=4) {
206 $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
210 var hash = location.hash.split("-")
211 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
216 // update pending count //
219 $("nav").bind('nav-update', function(e,data){
220 var elm = $('#pending-update');
221 var register = $(data).find('register').text();
222 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
229 function homeRedirect() {
230 $('html').fadeOut('slow', function(){
231 window.location = baseurl + "/login";
236 function initCrop() {
237 function onEndCrop( coords, dimensions ) {
238 $PR( 'x1' ).value = coords.x1;
239 $PR( 'y1' ).value = coords.y1;
240 $PR( 'x2' ).value = coords.x2;
241 $PR( 'y2' ).value = coords.y2;
242 $PR( 'width' ).value = dimensions.width;
243 $PR( 'height' ).value = dimensions.height;
246 Event.observe( window, 'load', function() {
247 new Cropper.ImgWithPreview(
250 previewWrap: 'previewWrap',
255 ratioDim: { x: 100, y:100 },
263 function showEvent(eventid) {
265 baseurl + '/events/?id='+eventid,
267 $.colorbox({html:data});
280 var plaintext = 'none';//window.editSelect;
281 //var ispublic = window.isPublic;
283 function initEditor(cb){
285 // $("#profile-jot-text-loading").show();
286 if(plaintext == 'none') {
287 // $("#profile-jot-text-loading").hide();
288 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
289 $("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
291 /* $("a#jot-perms-icon").colorbox({
293 'transition' : 'elastic'
295 $("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
296 var parent = $("#profile-jot-acl-wrapper").parent();
297 if (parent.css('display') == 'none') {
302 // $("#profile-jot-acl-wrapper").parent().toggle();
305 $(".jothidden").show();
306 if (typeof cb!="undefined") cb();
311 mode : "specific_textareas",
312 editor_selector: window.editSelect,
313 auto_focus: "profile-jot-text",
314 plugins : "bbcode,paste,autoresize, inlinepopups",
315 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
316 theme_advanced_buttons2 : "",
317 theme_advanced_buttons3 : "",
318 theme_advanced_toolbar_location : "top",
319 theme_advanced_toolbar_align : "center",
320 theme_advanced_blockformats : "blockquote,code",
321 gecko_spellcheck : true,
322 paste_text_sticky : true,
323 entity_encoding : "raw",
324 add_unload_trigger : false,
325 remove_linebreaks : false,
326 //force_p_newlines : false,
327 //force_br_newlines : true,
328 forced_root_block : 'div',
330 content_css: "$baseurl/view/custom_tinymce.css",
331 theme_advanced_path : false,
332 file_browser_callback : "fcFileBrowser",
333 setup : function(ed) {
335 ed.onKeyDown.add(function(ed,e) {
340 ed.onKeyUp.add(function(ed, e) {
341 var txt = tinyMCE.activeEditor.getContent();
342 match = txt.match(/@([^ \n]+)$/);
344 if(cPopup === null) {
345 cPopup = new ACPopup(this,baseurl+"/acl");
347 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
348 if(! cPopup.ready) cPopup = null;
351 if(cPopup !== null) { cPopup.close(); cPopup = null; }
354 textlen = txt.length;
355 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
356 $('#profile-jot-desc').html(ispublic);
359 $('#profile-jot-desc').html(' ');
365 $('#character-counter').removeClass('red');
366 $('#character-counter').removeClass('orange');
367 $('#character-counter').addClass('grey');
369 if((textlen > 140) && (textlen <= 420)) {
370 $('#character-counter').removeClass('grey');
371 $('#character-counter').removeClass('red');
372 $('#character-counter').addClass('orange');
375 $('#character-counter').removeClass('grey');
376 $('#character-counter').removeClass('orange');
377 $('#character-counter').addClass('red');
379 $('#character-counter').text(textlen);
382 ed.onInit.add(function(ed) {
383 ed.pasteAsPlainText = true;
384 $("#profile-jot-text-loading").hide();
385 $(".jothidden").show();
386 if (typeof cb!="undefined") cb();
393 $("a#jot-perms-icon").colorbox({
395 'transition' : 'elastic'
398 if (typeof cb!="undefined") cb();
402 function enableOnUser(){
408 /*function wallInitEditor() {
409 var plaintext = window.editSelect;
411 if(plaintext != 'none') {
414 mode : "specific_textareas",
415 editor_selector: /(profile-jot-text|prvmail-text)/,
416 plugins : "bbcode,paste",
417 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
418 theme_advanced_buttons2 : "",
419 theme_advanced_buttons3 : "",
420 theme_advanced_toolbar_location : "top",
421 theme_advanced_toolbar_align : "center",
422 theme_advanced_blockformats : "blockquote,code",
423 gecko_spellcheck : true,
424 paste_text_sticky : true,
425 entity_encoding : "raw",
426 add_unload_trigger : false,
427 remove_linebreaks : false,
428 //force_p_newlines : false,
429 //force_br_newlines : true,
430 forced_root_block : 'div',
432 content_css: baseurl + "/view/custom_tinymce.css",
434 theme_advanced_path : false,
435 setup : function(ed) {
436 ed.onInit.add(function(ed) {
437 ed.pasteAsPlainText = true;
438 var editorId = ed.editorId;
439 var textarea = $('#'+editorId);
440 if (typeof(textarea.attr('tabindex')) != "undefined") {
441 $('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
442 textarea.attr('tabindex', null);
449 $("#prvmail-text").contact_autocomplete(baseurl+"/acl");
458 function addeditortext(textElem, data) {
459 if(window.editSelect == 'none') {
460 var currentText = $(textElem).val();
461 $(textElem).val(currentText + data);
464 tinyMCE.execCommand('mceInsertRawHTML',false,data);*/
467 function jotVideoURL() {
468 reply = prompt(window.vidURL);
469 if(reply && reply.length) {
470 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
474 function jotAudioURL() {
475 reply = prompt(window.audURL);
476 if(reply && reply.length) {
477 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
482 function jotGetLocation() {
483 reply = prompt(window.whereAreU, $('#jot-location').val());
484 if(reply && reply.length) {
485 $('#jot-location').val(reply);
489 function jotShare(id) {
490 if ($('#jot-popup').length != 0) $('#jot-popup').show();
492 $('#like-rotator-' + id).show();
493 $.get('share/' + id, function(data) {
494 if (!editor) $("#profile-jot-text").val("");
495 initEditor(function(){
496 addeditortext("#profile-jot-text", data);
497 $('#like-rotator-' + id).hide();
498 $(window).scrollTop(0);
504 function jotGetLink() {
505 reply = prompt(window.linkURL);
506 if(reply && reply.length) {
507 reply = bin2hex(reply);
508 $('#profile-rotator').show();
509 $.get('parse_url?binurl=' + reply, function(data) {
510 addeditortext(window.jotId, data);
511 $('#profile-rotator').hide();
516 /*function linkdropper(event) {
517 var linkFound = event.dataTransfer.types.contains("text/uri-list");
519 event.preventDefault();
522 function linkdrop(event) {
523 var reply = event.dataTransfer.getData("text/uri-list");
524 event.target.textContent = reply;
525 event.preventDefault();
526 if(reply && reply.length) {
527 reply = bin2hex(reply);
528 $('#profile-rotator').show();
529 $.get('parse_url?binurl=' + reply, function(data) {
530 //if (!editor) $("#profile-jot-text").val("");
531 //initEditor(function(){
532 addeditortext(window.jotId, data);
533 $('#profile-rotator').hide();
539 function jotClearLocation() {
540 $('#jot-coord').val('');
541 $('#profile-nolocation-wrapper').hide();
544 if(typeof window.geoTag === 'function') window.geoTag();
552 function confirmDelete() { return confirm(window.delItem); }
554 /*function deleteCheckedItems() {
557 $('.item-select').each( function() {
558 if($(this).is(':checked')) {
559 if(checkedstr.length != 0) {
560 checkedstr = checkedstr + ',' + $(this).val();
563 checkedstr = $(this).val();
567 $.post('item', { dropitems: checkedstr }, function(data) {
568 window.location.reload();
572 function itemTag(id) {
573 reply = prompt(window.term);
574 if(reply && reply.length) {
575 reply = reply.replace('#','');
579 $('body').css('cursor', 'wait');
581 $.get('tagger/' + id + '?term=' + reply, NavUpdate);
582 /*if(timer) clearTimeout(timer);
583 timer = setTimeout(NavUpdate,3000);*/
589 function itemFiler(id) {
591 $.get('filer/', function(data){
593 var promptText = $('#id_term_label', data).text();
595 reply = prompt(promptText);
596 if(reply && reply.length) {
598 $('body').css('cursor', 'wait');
599 $.get('filer/' + id + '?term=' + reply, NavUpdate);
600 /* if(timer) clearTimeout(timer);
601 timer = setTimeout(NavUpdate,3000);*/
603 /* $.colorbox.close();*/
607 /* var bordercolor = $("input").css("border-color");
609 $.get('filer/', function(data){
610 $.colorbox({html:data});
611 $("#id_term").keypress(function(){
612 $(this).css("border-color",bordercolor);
614 $("#select_term").change(function(){
615 $("#id_term").css("border-color",bordercolor);
618 $("#filer_save").click(function(e){
620 reply = $("#id_term").val();
621 if(reply && reply.length) {
623 $('body').css('cursor', 'wait');
624 $.get('filer/' + id + '?term=' + reply);
625 if(timer) clearTimeout(timer);
626 timer = setTimeout(NavUpdate,3000);
630 $("#id_term").css("border-color","#FF0000");
645 function commentOpen(obj,id) {
646 if(obj.value == window.commentEmptyText) {
648 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
649 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
650 $("#mod-cmnt-wrap-" + id).show();
651 openMenu("comment-edit-submit-wrapper-" + id);
654 function commentClose(obj,id) {
655 if(obj.value == "") {
656 obj.value = window.commentEmptyText;
657 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
658 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
659 $("#mod-cmnt-wrap-" + id).hide();
660 closeMenu("comment-edit-submit-wrapper-" + id);
665 function commentInsert(obj,id) {
666 var tmpStr = $("#comment-edit-text-" + id).val();
667 if(tmpStr == window.commentEmptyText) {
669 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
670 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
671 openMenu("comment-edit-submit-wrapper-" + id);
673 var ins = $(obj).html();
674 ins = ins.replace("<","<");
675 ins = ins.replace(">",">");
676 ins = ins.replace("&","&");
677 ins = ins.replace(""",'"');
678 $("#comment-edit-text-" + id).val(tmpStr + ins);
681 function qCommentInsert(obj,id) {
682 var tmpStr = $("#comment-edit-text-" + id).val();
683 if(tmpStr == window.commentEmptyText) {
685 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
686 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
687 openMenu("comment-edit-submit-wrapper-" + id);
689 var ins = $(obj).val();
690 ins = ins.replace("<","<");
691 ins = ins.replace(">",">");
692 ins = ins.replace("&","&");
693 ins = ins.replace(""",'"');
694 $("#comment-edit-text-" + id).val(tmpStr + ins);
698 /*function showHideCommentBox(id) {
699 if( $('#comment-edit-form-' + id).is(':visible')) {
700 $('#comment-edit-form-' + id).hide();
703 $('#comment-edit-form-' + id).show();
708 function insertFormatting(comment,BBcode,id) {
710 var tmpStr = $("#comment-edit-text-" + id).val();
711 if(tmpStr == comment) {
713 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
714 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
715 openMenu("comment-edit-submit-wrapper-" + id);
716 $("#comment-edit-text-" + id).val(tmpStr);
719 textarea = document.getElementById("comment-edit-text-" +id);
720 if (document.selection) {
722 selected = document.selection.createRange();
723 if (BBcode == "url"){
724 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
726 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
727 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
728 var start = textarea.selectionStart;
729 var end = textarea.selectionEnd;
730 if (BBcode == "url"){
731 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
733 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
738 function cmtBbOpen(id) {
739 $(".comment-edit-bb-" + id).show();
741 function cmtBbClose(id) {
742 $(".comment-edit-bb-" + id).hide();