1 $j(document).ready(function() {
3 /* enable tinymce on focus and click */
4 $j("#profile-jot-text").focus(enableOnUser);
5 $j("#profile-jot-text").click(enableOnUser);
7 if(typeof window.AjaxUpload != "undefined") {
8 switch(window.ajaxType) {
10 var uploader = new window.AjaxUpload(
12 { action: 'wall_upload/'+window.nickname,
14 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
15 onComplete: function(file,response) {
16 addeditortext(response);
17 $j('#profile-rotator').hide();
22 var file_uploader = new window.AjaxUpload(
24 { action: 'wall_attach/'+window.nickname,
26 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
27 onComplete: function(file,response) {
28 addeditortext(response);
29 $j('#profile-rotator').hide();
35 var uploader = new window.AjaxUpload(
37 { action: 'wall_upload/' + window.nickname,
39 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
40 onComplete: function(file,response) {
41 tinyMCE.execCommand('mceInsertRawHTML',false,response);
42 $j('#profile-rotator').hide();
52 if(typeof window.aclInit !="undefined" && typeof acl=="undefined"){
55 [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
59 /*$j('html').click(function() { $j("#nav-notifications-menu" ).hide(); });*/
61 /*$j('.group-edit-icon').hover(
63 $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
65 $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
68 $j('.sidebar-group-element').hover(
70 id = $j(this).attr('id');
71 $j('#edit-' + id).addClass('icon'); $j('#edit-' + id).removeClass('iconspacer');},
74 id = $j(this).attr('id');
75 $j('#edit-' + id).removeClass('icon');$j('#edit-' + id).addClass('iconspacer');}
79 $j('.savedsearchdrop').hover(
81 $j(this).addClass('drop'); $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
83 $j(this).removeClass('drop'); $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
86 $j('.savedsearchterm').hover(
88 id = $j(this).attr('id');
89 $j('#drop-' + id).addClass('icon'); $j('#drop-' + id).addClass('drophide'); $j('#drop-' + id).removeClass('iconspacer');},
92 id = $j(this).attr('id');
93 $j('#drop-' + id).removeClass('icon');$j('#drop-' + id).removeClass('drophide'); $j('#drop-' + id).addClass('iconspacer');}
96 if(window.autoCompleteType == "display-head") {
97 //$j(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
98 // make auto-complete work in more places
99 //$j(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
100 $j(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
103 if(window.aclType == "event_head") {
104 $j('#events-calendar').fullCalendar({
105 events: baseurl + '/events/json/',
107 left: 'prev,next today',
109 right: 'month,agendaWeek,agendaDay'
111 timeFormat: 'H(:mm)',
112 eventClick: function(calEvent, jsEvent, view) {
113 showEvent(calEvent.id);
116 eventRender: function(event, element, view) {
117 //console.log(view.name);
118 if (event.item['author-name']==null) return;
121 element.find(".fc-event-title").html(
122 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
123 event.item['author-avatar'],
124 event.item['author-name'],
129 element.find(".fc-event-title").html(
130 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
131 event.item['author-avatar'],
132 event.item['author-name'],
138 element.find(".fc-event-title").html(
139 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
140 event.item['author-avatar'],
141 event.item['author-name'],
152 var args=location.href.replace(baseurl,"").split("/");
153 if (args.length>=4) {
154 $j("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
158 var hash = location.hash.split("-")
159 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
162 if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
163 $j('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
165 $j('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
166 selstr = $j(this).text();
167 $j('#jot-perms-icon').removeClass('unlock').addClass('lock');
168 $j('#jot-public').hide();
171 $j('#jot-perms-icon').removeClass('lock').addClass('unlock');
172 $j('#jot-public').show();
175 }).trigger('change');
178 switch(window.autocompleteType) {
180 var a = $j("#recip").autocomplete({
181 serviceUrl: baseurl + '/acl',
184 onSelect: function(value,data) {
185 $j("#recip-complete").val(data);
189 case 'contacts-head':
190 var a = $j("#contacts-search").autocomplete({
191 serviceUrl: baseurl + '/acl',
195 a.setOptions({ params: { type: 'a' }});
202 $j('#event-share-checkbox').change(function() {
204 if ($j('#event-share-checkbox').is(':checked')) {
205 $j('#acl-wrapper').show();
208 $j('#acl-wrapper').hide();
210 }).trigger('change');
213 $j(".popupbox").click(function () {
214 var parent = $j( $j(this).attr('href') ).parent();
215 if (parent.css('display') == 'none') {
225 // update pending count //
228 $j("nav").bind('nav-update', function(e,data){
229 var elm = $j('#pending-update');
230 var register = $j(data).find('register').text();
231 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
238 function insertFormatting(comment,BBcode,id) {
240 var tmpStr = $j("#comment-edit-text-" + id).val();
241 if(tmpStr == comment) {
243 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
244 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
245 openMenu("comment-edit-submit-wrapper-" + id);
246 $j("#comment-edit-text-" + id).val(tmpStr);
249 textarea = document.getElementById("comment-edit-text-" +id);
250 if (document.selection) {
252 selected = document.selection.createRange();
253 if (BBcode == "url"){
254 selected.text = "["+BBcode+"]" + "http://" + selected.text + "[/"+BBcode+"]";
256 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
257 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
258 var start = textarea.selectionStart;
259 var end = textarea.selectionEnd;
260 if (BBcode == "url"){
261 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
263 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
268 function cmtBbOpen(id) {
269 $j(".comment-edit-bb-" + id).show();
271 function cmtBbClose(id) {
272 $j(".comment-edit-bb-" + id).hide();
280 var plaintext = 'none';//window.editSelect;
281 var ispublic = window.isPublic;
283 function initEditor(cb){
285 // $j("#profile-jot-text-loading").show();
286 if(plaintext == 'none') {
287 // $j("#profile-jot-text-loading").hide();
288 $j("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
289 $j("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
291 /* $j("a#jot-perms-icon").fancybox({
292 'transitionIn' : 'none',
293 'transitionOut' : 'none'
295 $j("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
296 var parent = $j("#profile-jot-acl-wrapper").parent();
297 if (parent.css('display') == 'none') {
302 // $j("#profile-jot-acl-wrapper").parent().toggle();
305 $j(".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 : '',
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 && $j('#jot-perms-icon').is('.unlock')) {
356 $j('#profile-jot-desc').html(ispublic);
359 $j('#profile-jot-desc').html(' ');
365 $j('#character-counter').removeClass('red');
366 $j('#character-counter').removeClass('orange');
367 $j('#character-counter').addClass('grey');
369 if((textlen > 140) && (textlen <= 420)) {
370 $j('#character-counter').removeClass('grey');
371 $j('#character-counter').removeClass('red');
372 $j('#character-counter').addClass('orange');
375 $j('#character-counter').removeClass('grey');
376 $j('#character-counter').removeClass('orange');
377 $j('#character-counter').addClass('red');
379 $j('#character-counter').text(textlen);
382 ed.onInit.add(function(ed) {
383 ed.pasteAsPlainText = true;
384 $j("#profile-jot-text-loading").hide();
385 $j(".jothidden").show();
386 if (typeof cb!="undefined") cb();
393 $j("a#jot-perms-icon").fancybox({
394 'transitionIn' : 'elastic',
395 'transitionOut' : '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 : '',
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 = $j('#'+editorId);
440 if (typeof(textarea.attr('tabindex')) != "undefined") {
441 $j('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
442 textarea.attr('tabindex', null);
449 $j("#prvmail-text").contact_autocomplete(baseurl+"/acl");
455 function initCrop() {
456 function onEndCrop( coords, dimensions ) {
457 $( 'x1' ).value = coords.x1;
458 $( 'y1' ).value = coords.y1;
459 $( 'x2' ).value = coords.x2;
460 $( 'y2' ).value = coords.y2;
461 $( 'width' ).value = dimensions.width;
462 $( 'height' ).value = dimensions.height;
465 Event.observe( window, 'load', function() {
466 new Cropper.ImgWithPreview(
469 previewWrap: 'previewWrap',
474 ratioDim: { x: 100, y:100 },
482 function confirmDelete() { return confirm(window.delItem); }
483 function commentOpen(obj,id) {
484 if(obj.value == window.commentEmptyText) {
486 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
487 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
488 $j("#mod-cmnt-wrap-" + id).show();
489 openMenu("comment-edit-submit-wrapper-" + id);
492 function commentClose(obj,id) {
493 if(obj.value == "") {
494 obj.value = window.commentEmptyText;
495 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
496 $j("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
497 $j("#mod-cmnt-wrap-" + id).hide();
498 closeMenu("comment-edit-submit-wrapper-" + id);
503 function commentInsert(obj,id) {
504 var tmpStr = $j("#comment-edit-text-" + id).val();
505 if(tmpStr == window.commentEmptyText) {
507 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
508 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
509 openMenu("comment-edit-submit-wrapper-" + id);
511 var ins = $j(obj).html();
512 ins = ins.replace("<","<");
513 ins = ins.replace(">",">");
514 ins = ins.replace("&","&");
515 ins = ins.replace(""",'"');
516 $j("#comment-edit-text-" + id).val(tmpStr + ins);
519 function qCommentInsert(obj,id) {
520 var tmpStr = $j("#comment-edit-text-" + id).val();
521 if(tmpStr == window.commentEmptyText) {
523 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
524 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
525 openMenu("comment-edit-submit-wrapper-" + id);
527 var ins = $j(obj).val();
528 ins = ins.replace("<","<");
529 ins = ins.replace(">",">");
530 ins = ins.replace("&","&");
531 ins = ins.replace(""",'"');
532 $j("#comment-edit-text-" + id).val(tmpStr + ins);
536 function showHideComments(id) {
537 if( $j("#collapsed-comments-" + id).is(":visible")) {
538 $j("#collapsed-comments-" + id).hide();
539 $j("#hide-comments-" + id).html(window.showMore);
542 $j("#collapsed-comments-" + id).show();
543 $j("#hide-comments-" + id).html(window.showFewer);
547 /*function showHideCommentBox(id) {
548 if( $j('#comment-edit-form-' + id).is(':visible')) {
549 $j('#comment-edit-form-' + id).hide();
552 $j('#comment-edit-form-' + id).show();
557 /*function deleteCheckedItems() {
560 $j('.item-select').each( function() {
561 if($j(this).is(':checked')) {
562 if(checkedstr.length != 0) {
563 checkedstr = checkedstr + ',' + $j(this).val();
566 checkedstr = $j(this).val();
570 $j.post('item', { dropitems: checkedstr }, function(data) {
571 window.location.reload();
575 function jotVideoURL() {
576 reply = prompt(window.vidURL);
577 if(reply && reply.length) {
578 addeditortext('[video]' + reply + '[/video]');
582 function jotAudioURL() {
583 reply = prompt(window.audURL);
584 if(reply && reply.length) {
585 addeditortext('[audio]' + reply + '[/audio]');
590 function jotGetLocation() {
591 reply = prompt(window.whereAreU, $j('#jot-location').val());
592 if(reply && reply.length) {
593 $j('#jot-location').val(reply);
597 function jotShare(id) {
598 if ($j('#jot-popup').length != 0) $j('#jot-popup').show();
600 $j('#like-rotator-' + id).show();
601 $j.get('share/' + id, function(data) {
602 if (!editor) $j("#profile-jot-text").val("");
603 initEditor(function(){
605 $j('#like-rotator-' + id).hide();
606 $j(window).scrollTop(0);
612 function linkdropper(event) {
613 var linkFound = event.dataTransfer.types.contains("text/uri-list");
615 event.preventDefault();
618 switch(window.ajaxType) {
620 function jotGetLink() {
621 reply = prompt(window.linkURL);
622 if(reply && reply.length) {
623 reply = bin2hex(reply);
624 $j('#profile-rotator').show();
625 $j.get('parse_url?binurl=' + reply, function(data) {
627 $j('#profile-rotator').hide();
632 function linkdrop(event) {
633 var reply = event.dataTransfer.getData("text/uri-list");
634 event.target.textContent = reply;
635 event.preventDefault();
636 if(reply && reply.length) {
637 reply = bin2hex(reply);
638 $j('#profile-rotator').show();
639 $j.get('parse_url?binurl=' + reply, function(data) {
640 if (!editor) $j("#profile-jot-text").val("");
641 initEditor(function(){
643 $j('#profile-rotator').hide();
650 case 'wallmsg-header':
652 function jotGetLink() {
653 reply = prompt(window.linkURL);
654 if(reply && reply.length) {
655 $j('#profile-rotator').show();
656 $j.get('parse_url?url=' + reply, function(data) {
657 tinyMCE.execCommand('mceInsertRawHTML',false,data);
658 $j('#profile-rotator').hide();
663 function linkdrop(event) {
664 var reply = event.dataTransfer.getData("text/uri-list");
665 event.target.textContent = reply;
666 event.preventDefault();
667 if(reply && reply.length) {
668 $j('#profile-rotator').show();
669 $j.get('parse_url?url=' + reply, function(data) {
670 tinyMCE.execCommand('mceInsertRawHTML',false,data);
671 $j('#profile-rotator').hide();
681 function showEvent(eventid) {
683 baseurl + '/events/?id='+eventid,
691 function itemTag(id) {
692 reply = prompt(window.term);
693 if(reply && reply.length) {
694 reply = reply.replace('#','');
698 $j('body').css('cursor', 'wait');
700 $j.get('tagger/' + id + '?term=' + reply, NavUpdate);
701 /*if(timer) clearTimeout(timer);
702 timer = setTimeout(NavUpdate,3000);*/
708 function itemFiler(id) {
710 $j.get('filer/', function(data){
712 var promptText = $j('#id_term_label', data).text();
714 reply = prompt(promptText);
715 if(reply && reply.length) {
717 $j('body').css('cursor', 'wait');
718 $j.get('filer/' + id + '?term=' + reply, NavUpdate);
719 /* if(timer) clearTimeout(timer);
720 timer = setTimeout(NavUpdate,3000);*/
722 /* $j.fancybox.close();*/
726 /* var bordercolor = $j("input").css("border-color");
728 $j.get('filer/', function(data){
730 $j("#id_term").keypress(function(){
731 $j(this).css("border-color",bordercolor);
733 $j("#select_term").change(function(){
734 $j("#id_term").css("border-color",bordercolor);
737 $j("#filer_save").click(function(e){
739 reply = $j("#id_term").val();
740 if(reply && reply.length) {
742 $j('body').css('cursor', 'wait');
743 $j.get('filer/' + id + '?term=' + reply);
744 if(timer) clearTimeout(timer);
745 timer = setTimeout(NavUpdate,3000);
749 $j("#id_term").css("border-color","#FF0000");
757 function jotClearLocation() {
758 $j('#jot-coord').val('');
759 $j('#profile-nolocation-wrapper').hide();
762 function addeditortext(data) {
763 if(plaintext == 'none') {
764 var currentText = $j("#profile-jot-text").val();
765 $j("#profile-jot-text").val(currentText + data);
768 tinyMCE.execCommand('mceInsertRawHTML',false,data);*/
771 if(typeof window.geoTag === 'function') window.geoTag();