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 + window.eventModuleUrl +'/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-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-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-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>=5 && window.eventModeParams == 2) {
208 $("#events-calendar").fullCalendar('gotoDate',args[3] , args[4]-1);
209 } else if (args.length>=4 && window.eventModeParams == 1) {
210 $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
214 var hash = location.hash.split("-")
215 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
220 // update pending count //
223 $("nav").bind('nav-update', function(e,data){
224 var elm = $('#pending-update');
225 var register = $(data).find('register').text();
226 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
233 function homeRedirect() {
234 $('html').fadeOut('slow', function(){
235 window.location = baseurl + "/login";
240 function initCrop() {
241 function onEndCrop( coords, dimensions ) {
242 $PR( 'x1' ).value = coords.x1;
243 $PR( 'y1' ).value = coords.y1;
244 $PR( 'x2' ).value = coords.x2;
245 $PR( 'y2' ).value = coords.y2;
246 $PR( 'width' ).value = dimensions.width;
247 $PR( 'height' ).value = dimensions.height;
250 Event.observe( window, 'load', function() {
251 new Cropper.ImgWithPreview(
254 previewWrap: 'previewWrap',
259 ratioDim: { x: 100, y:100 },
267 function showEvent(eventid) {
269 baseurl + window.eventModuleUrl + '/?id=' + eventid,
271 $.colorbox({html:data});
284 var plaintext = 'none';//window.editSelect;
285 //var ispublic = window.isPublic;
287 function initEditor(cb){
289 // $("#profile-jot-text-loading").show();
290 if(plaintext == 'none') {
291 // $("#profile-jot-text-loading").hide();
292 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
293 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
295 /* $("a#jot-perms-icon").colorbox({
297 'transition' : 'elastic'
299 $("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
300 var parent = $("#profile-jot-acl-wrapper").parent();
301 if (parent.css('display') == 'none') {
306 // $("#profile-jot-acl-wrapper").parent().toggle();
309 $(".jothidden").show();
310 if (typeof cb!="undefined") cb();
315 mode : "specific_textareas",
316 editor_selector: window.editSelect,
317 auto_focus: "profile-jot-text",
318 plugins : "bbcode,paste,autoresize, inlinepopups",
319 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
320 theme_advanced_buttons2 : "",
321 theme_advanced_buttons3 : "",
322 theme_advanced_toolbar_location : "top",
323 theme_advanced_toolbar_align : "center",
324 theme_advanced_blockformats : "blockquote,code",
325 gecko_spellcheck : true,
326 paste_text_sticky : true,
327 entity_encoding : "raw",
328 add_unload_trigger : false,
329 remove_linebreaks : false,
330 //force_p_newlines : false,
331 //force_br_newlines : true,
332 forced_root_block : 'div',
334 content_css: "$baseurl/view/custom_tinymce.css",
335 theme_advanced_path : false,
336 file_browser_callback : "fcFileBrowser",
337 setup : function(ed) {
339 ed.onKeyDown.add(function(ed,e) {
344 ed.onKeyUp.add(function(ed, e) {
345 var txt = tinyMCE.activeEditor.getContent();
346 match = txt.match(/@([^ \n]+)$/);
348 if(cPopup === null) {
349 cPopup = new ACPopup(this,baseurl+"/acl");
351 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
352 if(! cPopup.ready) cPopup = null;
355 if(cPopup !== null) { cPopup.close(); cPopup = null; }
358 textlen = txt.length;
359 if(textlen != 0 && $('#jot-perms-icon').is('.unlock')) {
360 $('#profile-jot-desc').html(ispublic);
363 $('#profile-jot-desc').html(' ');
369 $('#character-counter').removeClass('red');
370 $('#character-counter').removeClass('orange');
371 $('#character-counter').addClass('grey');
373 if((textlen > 140) && (textlen <= 420)) {
374 $('#character-counter').removeClass('grey');
375 $('#character-counter').removeClass('red');
376 $('#character-counter').addClass('orange');
379 $('#character-counter').removeClass('grey');
380 $('#character-counter').removeClass('orange');
381 $('#character-counter').addClass('red');
383 $('#character-counter').text(textlen);
386 ed.onInit.add(function(ed) {
387 ed.pasteAsPlainText = true;
388 $("#profile-jot-text-loading").hide();
389 $(".jothidden").show();
390 if (typeof cb!="undefined") cb();
397 $("a#jot-perms-icon").colorbox({
399 'transition' : 'elastic'
402 if (typeof cb!="undefined") cb();
406 function enableOnUser(){
412 /*function wallInitEditor() {
413 var plaintext = window.editSelect;
415 if(plaintext != 'none') {
418 mode : "specific_textareas",
419 editor_selector: /(profile-jot-text|prvmail-text)/,
420 plugins : "bbcode,paste",
421 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
422 theme_advanced_buttons2 : "",
423 theme_advanced_buttons3 : "",
424 theme_advanced_toolbar_location : "top",
425 theme_advanced_toolbar_align : "center",
426 theme_advanced_blockformats : "blockquote,code",
427 gecko_spellcheck : true,
428 paste_text_sticky : true,
429 entity_encoding : "raw",
430 add_unload_trigger : false,
431 remove_linebreaks : false,
432 //force_p_newlines : false,
433 //force_br_newlines : true,
434 forced_root_block : 'div',
436 content_css: baseurl + "/view/custom_tinymce.css",
438 theme_advanced_path : false,
439 setup : function(ed) {
440 ed.onInit.add(function(ed) {
441 ed.pasteAsPlainText = true;
442 var editorId = ed.editorId;
443 var textarea = $('#'+editorId);
444 if (typeof(textarea.attr('tabindex')) != "undefined") {
445 $('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
446 textarea.attr('tabindex', null);
453 $("#prvmail-text").contact_autocomplete(baseurl+"/acl");
462 function addeditortext(textElem, data) {
463 if(window.editSelect == 'none') {
464 var currentText = $(textElem).val();
465 $(textElem).val(currentText + data);
468 tinyMCE.execCommand('mceInsertRawHTML',false,data);*/
471 function jotVideoURL() {
472 reply = prompt(window.vidURL);
473 if(reply && reply.length) {
474 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
478 function jotAudioURL() {
479 reply = prompt(window.audURL);
480 if(reply && reply.length) {
481 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
486 function jotGetLocation() {
487 reply = prompt(window.whereAreU, $('#jot-location').val());
488 if(reply && reply.length) {
489 $('#jot-location').val(reply);
493 function jotShare(id) {
494 if ($('#jot-popup').length != 0) $('#jot-popup').show();
496 $('#like-rotator-' + id).show();
497 $.get('share/' + id, function(data) {
498 if (!editor) $("#profile-jot-text").val("");
499 initEditor(function(){
500 addeditortext("#profile-jot-text", data);
501 $('#like-rotator-' + id).hide();
502 $(window).scrollTop(0);
508 function jotGetLink() {
509 reply = prompt(window.linkURL);
510 if(reply && reply.length) {
511 reply = bin2hex(reply);
512 $('#profile-rotator').show();
513 $.get('parse_url?binurl=' + reply, function(data) {
514 addeditortext(window.jotId, data);
515 $('#profile-rotator').hide();
520 /*function linkdropper(event) {
521 var linkFound = event.dataTransfer.types.contains("text/uri-list");
523 event.preventDefault();
526 function linkdrop(event) {
527 var reply = event.dataTransfer.getData("text/uri-list");
528 event.target.textContent = reply;
529 event.preventDefault();
530 if(reply && reply.length) {
531 reply = bin2hex(reply);
532 $('#profile-rotator').show();
533 $.get('parse_url?binurl=' + reply, function(data) {
534 //if (!editor) $("#profile-jot-text").val("");
535 //initEditor(function(){
536 addeditortext(window.jotId, data);
537 $('#profile-rotator').hide();
543 function jotClearLocation() {
544 $('#jot-coord').val('');
545 $('#profile-nolocation-wrapper').hide();
548 if(typeof window.geoTag === 'function') window.geoTag();
556 function confirmDelete() { return confirm(window.delItem); }
558 /*function deleteCheckedItems() {
561 $('.item-select').each( function() {
562 if($(this).is(':checked')) {
563 if(checkedstr.length != 0) {
564 checkedstr = checkedstr + ',' + $(this).val();
567 checkedstr = $(this).val();
571 $.post('item', { dropitems: checkedstr }, function(data) {
572 window.location.reload();
576 function itemTag(id) {
577 reply = prompt(window.term);
578 if(reply && reply.length) {
579 reply = reply.replace('#','');
583 $('body').css('cursor', 'wait');
585 $.get('tagger/' + id + '?term=' + reply, NavUpdate);
586 /*if(timer) clearTimeout(timer);
587 timer = setTimeout(NavUpdate,3000);*/
593 function itemFiler(id) {
595 $.get('filer/', function(data){
597 var promptText = $('#id_term_label', data).text();
599 reply = prompt(promptText);
600 if(reply && reply.length) {
602 $('body').css('cursor', 'wait');
603 $.get('filer/' + id + '?term=' + reply, NavUpdate);
604 /* if(timer) clearTimeout(timer);
605 timer = setTimeout(NavUpdate,3000);*/
607 /* $.colorbox.close();*/
611 /* var bordercolor = $("input").css("border-color");
613 $.get('filer/', function(data){
614 $.colorbox({html:data});
615 $("#id_term").keypress(function(){
616 $(this).css("border-color",bordercolor);
618 $("#select_term").change(function(){
619 $("#id_term").css("border-color",bordercolor);
622 $("#filer_save").click(function(e){
624 reply = $("#id_term").val();
625 if(reply && reply.length) {
627 $('body').css('cursor', 'wait');
628 $.get('filer/' + id + '?term=' + reply);
629 if(timer) clearTimeout(timer);
630 timer = setTimeout(NavUpdate,3000);
634 $("#id_term").css("border-color","#FF0000");
649 function commentOpen(obj,id) {
650 if(obj.value == window.commentEmptyText) {
652 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
653 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
654 $("#mod-cmnt-wrap-" + id).show();
655 openMenu("comment-edit-submit-wrapper-" + id);
658 function commentClose(obj,id) {
659 if(obj.value == "") {
660 obj.value = window.commentEmptyText;
661 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
662 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
663 $("#mod-cmnt-wrap-" + id).hide();
664 closeMenu("comment-edit-submit-wrapper-" + id);
669 function commentInsert(obj,id) {
670 var tmpStr = $("#comment-edit-text-" + id).val();
671 if(tmpStr == window.commentEmptyText) {
673 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
674 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
675 openMenu("comment-edit-submit-wrapper-" + id);
677 var ins = $(obj).html();
678 ins = ins.replace("<","<");
679 ins = ins.replace(">",">");
680 ins = ins.replace("&","&");
681 ins = ins.replace(""",'"');
682 $("#comment-edit-text-" + id).val(tmpStr + ins);
685 function qCommentInsert(obj,id) {
686 var tmpStr = $("#comment-edit-text-" + id).val();
687 if(tmpStr == window.commentEmptyText) {
689 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
690 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
691 openMenu("comment-edit-submit-wrapper-" + id);
693 var ins = $(obj).val();
694 ins = ins.replace("<","<");
695 ins = ins.replace(">",">");
696 ins = ins.replace("&","&");
697 ins = ins.replace(""",'"');
698 $("#comment-edit-text-" + id).val(tmpStr + ins);
702 /*function showHideCommentBox(id) {
703 if( $('#comment-edit-form-' + id).is(':visible')) {
704 $('#comment-edit-form-' + id).hide();
707 $('#comment-edit-form-' + id).show();
712 function insertFormatting(comment,BBcode,id) {
714 var tmpStr = $("#comment-edit-text-" + id).val();
715 if(tmpStr == comment) {
717 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
718 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
719 openMenu("comment-edit-submit-wrapper-" + id);
720 $("#comment-edit-text-" + id).val(tmpStr);
723 textarea = document.getElementById("comment-edit-text-" +id);
724 if (document.selection) {
726 selected = document.selection.createRange();
727 if (BBcode == "url"){
728 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
730 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
731 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
732 var start = textarea.selectionStart;
733 var end = textarea.selectionEnd;
734 if (BBcode == "url"){
735 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
737 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
742 function cmtBbOpen(id) {
743 $(".comment-edit-bb-" + id).show();
745 function cmtBbClose(id) {
746 $(".comment-edit-bb-" + id).hide();