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 $("#recip").name_autocomplete(baseurl + '/acl', '', false, function(data) {
107 $("#recip-complete").val(data.id);
110 case 'contacts-head':
111 $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true);
114 $("#contacts-search").keyup(function(event){
115 if(event.keyCode == 13){
116 $("#contacts-search").click();
119 $(".autocomplete-w1 .selected").keyup(function(event){
120 if(event.keyCode == 13){
121 $("#contacts-search").click();
126 $(".comment-wwedit-wrapper textarea").editor_autocomplete(baseurl+"/acl");
133 /* if(window.autoCompleteType == "display-head") {
134 //$(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
135 // make auto-complete work in more places
136 //$(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
137 $(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
141 if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
142 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
144 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
145 selstr = $(this).text();
146 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
147 $('#jot-public').hide();
150 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
151 $('#jot-public').show();
154 }).trigger('change');
157 if(window.aclType == "event_head") {
158 $('#events-calendar').fullCalendar({
159 events: baseurl + '/events/json/',
161 left: 'prev,next today',
163 right: 'month,agendaWeek,agendaDay'
165 timeFormat: 'H(:mm)',
166 eventClick: function(calEvent, jsEvent, view) {
167 showEvent(calEvent.id);
170 eventRender: function(event, element, view) {
171 //console.log(view.name);
172 if (event.item['author-name']==null) return;
175 element.find(".fc-event-title").html(
176 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
177 event.item['author-avatar'],
178 event.item['author-name'],
183 element.find(".fc-event-title").html(
184 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
185 event.item['author-avatar'],
186 event.item['author-name'],
192 element.find(".fc-event-title").html(
193 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
194 event.item['author-avatar'],
195 event.item['author-name'],
206 var args=location.href.replace(baseurl,"").split("/");
207 if (args.length>=4) {
208 $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
212 var hash = location.hash.split("-")
213 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
218 // update pending count //
221 $("nav").bind('nav-update', function(e,data){
222 var elm = $('#pending-update');
223 var register = $(data).find('register').text();
224 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
231 function homeRedirect() {
232 $('html').fadeOut('slow', function(){
233 window.location = baseurl + "/login";
238 function initCrop() {
239 function onEndCrop( coords, dimensions ) {
240 $PR( 'x1' ).value = coords.x1;
241 $PR( 'y1' ).value = coords.y1;
242 $PR( 'x2' ).value = coords.x2;
243 $PR( 'y2' ).value = coords.y2;
244 $PR( 'width' ).value = dimensions.width;
245 $PR( 'height' ).value = dimensions.height;
248 Event.observe( window, 'load', function() {
249 new Cropper.ImgWithPreview(
252 previewWrap: 'previewWrap',
257 ratioDim: { x: 100, y:100 },
265 function showEvent(eventid) {
267 baseurl + '/events/?id='+eventid,
269 $.colorbox({html:data});
282 var plaintext = 'none';//window.editSelect;
283 //var ispublic = window.isPublic;
285 function initEditor(cb){
287 // $("#profile-jot-text-loading").show();
288 if(plaintext == 'none') {
289 // $("#profile-jot-text-loading").hide();
290 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
291 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
293 /* $("a#jot-perms-icon").colorbox({
295 'transition' : 'elastic'
297 $("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
298 var parent = $("#profile-jot-acl-wrapper").parent();
299 if (parent.css('display') == 'none') {
304 // $("#profile-jot-acl-wrapper").parent().toggle();
307 $(".jothidden").show();
308 if (typeof cb!="undefined") cb();
313 mode : "specific_textareas",
314 editor_selector: window.editSelect,
315 auto_focus: "profile-jot-text",
316 plugins : "bbcode,paste,autoresize, inlinepopups",
317 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
318 theme_advanced_buttons2 : "",
319 theme_advanced_buttons3 : "",
320 theme_advanced_toolbar_location : "top",
321 theme_advanced_toolbar_align : "center",
322 theme_advanced_blockformats : "blockquote,code",
323 gecko_spellcheck : true,
324 paste_text_sticky : true,
325 entity_encoding : "raw",
326 add_unload_trigger : false,
327 remove_linebreaks : false,
328 //force_p_newlines : false,
329 //force_br_newlines : true,
330 forced_root_block : 'div',
332 content_css: "$baseurl/view/custom_tinymce.css",
333 theme_advanced_path : false,
334 file_browser_callback : "fcFileBrowser",
335 setup : function(ed) {
337 ed.onKeyDown.add(function(ed,e) {
342 ed.onKeyUp.add(function(ed, e) {
343 var txt = tinyMCE.activeEditor.getContent();
344 match = txt.match(/@([^ \n]+)$/);
346 if(cPopup === null) {
347 cPopup = new ACPopup(this,baseurl+"/acl");
349 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
350 if(! cPopup.ready) cPopup = null;
353 if(cPopup !== null) { cPopup.close(); cPopup = null; }
356 textlen = txt.length;
357 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
358 $('#profile-jot-desc').html(ispublic);
361 $('#profile-jot-desc').html(' ');
367 $('#character-counter').removeClass('red');
368 $('#character-counter').removeClass('orange');
369 $('#character-counter').addClass('grey');
371 if((textlen > 140) && (textlen <= 420)) {
372 $('#character-counter').removeClass('grey');
373 $('#character-counter').removeClass('red');
374 $('#character-counter').addClass('orange');
377 $('#character-counter').removeClass('grey');
378 $('#character-counter').removeClass('orange');
379 $('#character-counter').addClass('red');
381 $('#character-counter').text(textlen);
384 ed.onInit.add(function(ed) {
385 ed.pasteAsPlainText = true;
386 $("#profile-jot-text-loading").hide();
387 $(".jothidden").show();
388 if (typeof cb!="undefined") cb();
395 $("a#jot-perms-icon").colorbox({
397 'transition' : 'elastic'
400 if (typeof cb!="undefined") cb();
404 function enableOnUser(){
410 /*function wallInitEditor() {
411 var plaintext = window.editSelect;
413 if(plaintext != 'none') {
416 mode : "specific_textareas",
417 editor_selector: /(profile-jot-text|prvmail-text)/,
418 plugins : "bbcode,paste",
419 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
420 theme_advanced_buttons2 : "",
421 theme_advanced_buttons3 : "",
422 theme_advanced_toolbar_location : "top",
423 theme_advanced_toolbar_align : "center",
424 theme_advanced_blockformats : "blockquote,code",
425 gecko_spellcheck : true,
426 paste_text_sticky : true,
427 entity_encoding : "raw",
428 add_unload_trigger : false,
429 remove_linebreaks : false,
430 //force_p_newlines : false,
431 //force_br_newlines : true,
432 forced_root_block : 'div',
434 content_css: baseurl + "/view/custom_tinymce.css",
436 theme_advanced_path : false,
437 setup : function(ed) {
438 ed.onInit.add(function(ed) {
439 ed.pasteAsPlainText = true;
440 var editorId = ed.editorId;
441 var textarea = $('#'+editorId);
442 if (typeof(textarea.attr('tabindex')) != "undefined") {
443 $('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
444 textarea.attr('tabindex', null);
451 $("#prvmail-text").contact_autocomplete(baseurl+"/acl");
460 function addeditortext(textElem, data) {
461 if(window.editSelect == 'none') {
462 var currentText = $(textElem).val();
463 $(textElem).val(currentText + data);
466 tinyMCE.execCommand('mceInsertRawHTML',false,data);*/
469 function jotVideoURL() {
470 reply = prompt(window.vidURL);
471 if(reply && reply.length) {
472 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
476 function jotAudioURL() {
477 reply = prompt(window.audURL);
478 if(reply && reply.length) {
479 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
484 function jotGetLocation() {
485 reply = prompt(window.whereAreU, $('#jot-location').val());
486 if(reply && reply.length) {
487 $('#jot-location').val(reply);
491 function jotShare(id) {
492 if ($('#jot-popup').length != 0) $('#jot-popup').show();
494 $('#like-rotator-' + id).show();
495 $.get('share/' + id, function(data) {
496 if (!editor) $("#profile-jot-text").val("");
497 initEditor(function(){
498 addeditortext("#profile-jot-text", data);
499 $('#like-rotator-' + id).hide();
500 $(window).scrollTop(0);
506 function jotGetLink() {
507 reply = prompt(window.linkURL);
508 if(reply && reply.length) {
509 reply = bin2hex(reply);
510 $('#profile-rotator').show();
511 $.get('parse_url?binurl=' + reply, function(data) {
512 addeditortext(window.jotId, data);
513 $('#profile-rotator').hide();
518 /*function linkdropper(event) {
519 var linkFound = event.dataTransfer.types.contains("text/uri-list");
521 event.preventDefault();
524 function linkdrop(event) {
525 var reply = event.dataTransfer.getData("text/uri-list");
526 event.target.textContent = reply;
527 event.preventDefault();
528 if(reply && reply.length) {
529 reply = bin2hex(reply);
530 $('#profile-rotator').show();
531 $.get('parse_url?binurl=' + reply, function(data) {
532 //if (!editor) $("#profile-jot-text").val("");
533 //initEditor(function(){
534 addeditortext(window.jotId, data);
535 $('#profile-rotator').hide();
541 function jotClearLocation() {
542 $('#jot-coord').val('');
543 $('#profile-nolocation-wrapper').hide();
546 if(typeof window.geoTag === 'function') window.geoTag();
554 function confirmDelete() { return confirm(window.delItem); }
556 /*function deleteCheckedItems() {
559 $('.item-select').each( function() {
560 if($(this).is(':checked')) {
561 if(checkedstr.length != 0) {
562 checkedstr = checkedstr + ',' + $(this).val();
565 checkedstr = $(this).val();
569 $.post('item', { dropitems: checkedstr }, function(data) {
570 window.location.reload();
574 function itemTag(id) {
575 reply = prompt(window.term);
576 if(reply && reply.length) {
577 reply = reply.replace('#','');
581 $('body').css('cursor', 'wait');
583 $.get('tagger/' + id + '?term=' + reply, NavUpdate);
584 /*if(timer) clearTimeout(timer);
585 timer = setTimeout(NavUpdate,3000);*/
591 function itemFiler(id) {
593 $.get('filer/', function(data){
595 var promptText = $('#id_term_label', data).text();
597 reply = prompt(promptText);
598 if(reply && reply.length) {
600 $('body').css('cursor', 'wait');
601 $.get('filer/' + id + '?term=' + reply, NavUpdate);
602 /* if(timer) clearTimeout(timer);
603 timer = setTimeout(NavUpdate,3000);*/
605 /* $.colorbox.close();*/
609 /* var bordercolor = $("input").css("border-color");
611 $.get('filer/', function(data){
612 $.colorbox({html:data});
613 $("#id_term").keypress(function(){
614 $(this).css("border-color",bordercolor);
616 $("#select_term").change(function(){
617 $("#id_term").css("border-color",bordercolor);
620 $("#filer_save").click(function(e){
622 reply = $("#id_term").val();
623 if(reply && reply.length) {
625 $('body').css('cursor', 'wait');
626 $.get('filer/' + id + '?term=' + reply);
627 if(timer) clearTimeout(timer);
628 timer = setTimeout(NavUpdate,3000);
632 $("#id_term").css("border-color","#FF0000");
647 function commentOpen(obj,id) {
648 if(obj.value == window.commentEmptyText) {
650 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
651 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
652 $("#mod-cmnt-wrap-" + id).show();
653 openMenu("comment-edit-submit-wrapper-" + id);
656 function commentClose(obj,id) {
657 if(obj.value == "") {
658 obj.value = window.commentEmptyText;
659 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
660 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
661 $("#mod-cmnt-wrap-" + id).hide();
662 closeMenu("comment-edit-submit-wrapper-" + id);
667 function commentInsert(obj,id) {
668 var tmpStr = $("#comment-edit-text-" + id).val();
669 if(tmpStr == window.commentEmptyText) {
671 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
672 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
673 openMenu("comment-edit-submit-wrapper-" + id);
675 var ins = $(obj).html();
676 ins = ins.replace("<","<");
677 ins = ins.replace(">",">");
678 ins = ins.replace("&","&");
679 ins = ins.replace(""",'"');
680 $("#comment-edit-text-" + id).val(tmpStr + ins);
683 function qCommentInsert(obj,id) {
684 var tmpStr = $("#comment-edit-text-" + id).val();
685 if(tmpStr == window.commentEmptyText) {
687 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
688 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
689 openMenu("comment-edit-submit-wrapper-" + id);
691 var ins = $(obj).val();
692 ins = ins.replace("<","<");
693 ins = ins.replace(">",">");
694 ins = ins.replace("&","&");
695 ins = ins.replace(""",'"');
696 $("#comment-edit-text-" + id).val(tmpStr + ins);
700 /*function showHideCommentBox(id) {
701 if( $('#comment-edit-form-' + id).is(':visible')) {
702 $('#comment-edit-form-' + id).hide();
705 $('#comment-edit-form-' + id).show();
710 function insertFormatting(comment,BBcode,id) {
712 var tmpStr = $("#comment-edit-text-" + id).val();
713 if(tmpStr == comment) {
715 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
716 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
717 openMenu("comment-edit-submit-wrapper-" + id);
718 $("#comment-edit-text-" + id).val(tmpStr);
721 textarea = document.getElementById("comment-edit-text-" +id);
722 if (document.selection) {
724 selected = document.selection.createRange();
725 if (BBcode == "url"){
726 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
728 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
729 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
730 var start = textarea.selectionStart;
731 var end = textarea.selectionEnd;
732 if (BBcode == "url"){
733 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
735 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
740 function cmtBbOpen(id) {
741 $(".comment-edit-bb-" + id).show();
743 function cmtBbClose(id) {
744 $(".comment-edit-bb-" + id).hide();