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+'?nomce=1',
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+'?nomce=1',
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+'?nomce=1',
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 homeRedirect() {
239 $j('html').fadeOut('slow', function(){
240 window.location = baseurl + "/login";
245 function insertFormatting(comment,BBcode,id) {
247 var tmpStr = $j("#comment-edit-text-" + id).val();
248 if(tmpStr == comment) {
250 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
251 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
252 openMenu("comment-edit-submit-wrapper-" + id);
253 $j("#comment-edit-text-" + id).val(tmpStr);
256 textarea = document.getElementById("comment-edit-text-" +id);
257 if (document.selection) {
259 selected = document.selection.createRange();
260 if (BBcode == "url"){
261 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
263 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
264 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
265 var start = textarea.selectionStart;
266 var end = textarea.selectionEnd;
267 if (BBcode == "url"){
268 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
270 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
275 function cmtBbOpen(id) {
276 $j(".comment-edit-bb-" + id).show();
278 function cmtBbClose(id) {
279 $j(".comment-edit-bb-" + id).hide();
287 var plaintext = 'none';//window.editSelect;
288 var ispublic = window.isPublic;
290 function initEditor(cb){
292 // $j("#profile-jot-text-loading").show();
293 if(plaintext == 'none') {
294 // $j("#profile-jot-text-loading").hide();
295 $j("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
296 $j("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
298 /* $j("a#jot-perms-icon").fancybox({
299 'transitionIn' : 'none',
300 'transitionOut' : 'none'
302 $j("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
303 var parent = $j("#profile-jot-acl-wrapper").parent();
304 if (parent.css('display') == 'none') {
309 // $j("#profile-jot-acl-wrapper").parent().toggle();
312 $j(".jothidden").show();
313 if (typeof cb!="undefined") cb();
318 mode : "specific_textareas",
319 editor_selector: window.editSelect,
320 auto_focus: "profile-jot-text",
321 plugins : "bbcode,paste,autoresize, inlinepopups",
322 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
323 theme_advanced_buttons2 : "",
324 theme_advanced_buttons3 : "",
325 theme_advanced_toolbar_location : "top",
326 theme_advanced_toolbar_align : "center",
327 theme_advanced_blockformats : "blockquote,code",
328 gecko_spellcheck : true,
329 paste_text_sticky : true,
330 entity_encoding : "raw",
331 add_unload_trigger : false,
332 remove_linebreaks : false,
333 //force_p_newlines : false,
334 //force_br_newlines : true,
335 forced_root_block : 'div',
337 content_css: "$baseurl/view/custom_tinymce.css",
338 theme_advanced_path : false,
339 file_browser_callback : "fcFileBrowser",
340 setup : function(ed) {
342 ed.onKeyDown.add(function(ed,e) {
347 ed.onKeyUp.add(function(ed, e) {
348 var txt = tinyMCE.activeEditor.getContent();
349 match = txt.match(/@([^ \n]+)$/);
351 if(cPopup === null) {
352 cPopup = new ACPopup(this,baseurl+"/acl");
354 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
355 if(! cPopup.ready) cPopup = null;
358 if(cPopup !== null) { cPopup.close(); cPopup = null; }
361 textlen = txt.length;
362 if(textlen != 0 && $j('#jot-perms-icon').is('.unlock')) {
363 $j('#profile-jot-desc').html(ispublic);
366 $j('#profile-jot-desc').html(' ');
372 $j('#character-counter').removeClass('red');
373 $j('#character-counter').removeClass('orange');
374 $j('#character-counter').addClass('grey');
376 if((textlen > 140) && (textlen <= 420)) {
377 $j('#character-counter').removeClass('grey');
378 $j('#character-counter').removeClass('red');
379 $j('#character-counter').addClass('orange');
382 $j('#character-counter').removeClass('grey');
383 $j('#character-counter').removeClass('orange');
384 $j('#character-counter').addClass('red');
386 $j('#character-counter').text(textlen);
389 ed.onInit.add(function(ed) {
390 ed.pasteAsPlainText = true;
391 $j("#profile-jot-text-loading").hide();
392 $j(".jothidden").show();
393 if (typeof cb!="undefined") cb();
400 $j("a#jot-perms-icon").fancybox({
401 'transitionIn' : 'elastic',
402 'transitionOut' : 'elastic'
405 if (typeof cb!="undefined") cb();
409 function enableOnUser(){
415 function wallInitEditor() {
416 var plaintext = window.editSelect;
418 if(plaintext != 'none') {
421 mode : "specific_textareas",
422 editor_selector: /(profile-jot-text|prvmail-text)/,
423 plugins : "bbcode,paste",
424 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
425 theme_advanced_buttons2 : "",
426 theme_advanced_buttons3 : "",
427 theme_advanced_toolbar_location : "top",
428 theme_advanced_toolbar_align : "center",
429 theme_advanced_blockformats : "blockquote,code",
430 gecko_spellcheck : true,
431 paste_text_sticky : true,
432 entity_encoding : "raw",
433 add_unload_trigger : false,
434 remove_linebreaks : false,
435 //force_p_newlines : false,
436 //force_br_newlines : true,
437 forced_root_block : 'div',
439 content_css: baseurl + "/view/custom_tinymce.css",
441 theme_advanced_path : false,
442 setup : function(ed) {
443 ed.onInit.add(function(ed) {
444 ed.pasteAsPlainText = true;
445 var editorId = ed.editorId;
446 var textarea = $j('#'+editorId);
447 if (typeof(textarea.attr('tabindex')) != "undefined") {
448 $j('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
449 textarea.attr('tabindex', null);
456 $j("#prvmail-text").contact_autocomplete(baseurl+"/acl");
462 function initCrop() {
463 function onEndCrop( coords, dimensions ) {
464 $( 'x1' ).value = coords.x1;
465 $( 'y1' ).value = coords.y1;
466 $( 'x2' ).value = coords.x2;
467 $( 'y2' ).value = coords.y2;
468 $( 'width' ).value = dimensions.width;
469 $( 'height' ).value = dimensions.height;
472 Event.observe( window, 'load', function() {
473 new Cropper.ImgWithPreview(
476 previewWrap: 'previewWrap',
481 ratioDim: { x: 100, y:100 },
489 function confirmDelete() { return confirm(window.delItem); }
490 function commentOpen(obj,id) {
491 if(obj.value == window.commentEmptyText) {
493 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
494 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
495 $j("#mod-cmnt-wrap-" + id).show();
496 openMenu("comment-edit-submit-wrapper-" + id);
499 function commentClose(obj,id) {
500 if(obj.value == "") {
501 obj.value = window.commentEmptyText;
502 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
503 $j("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
504 $j("#mod-cmnt-wrap-" + id).hide();
505 closeMenu("comment-edit-submit-wrapper-" + id);
510 function commentInsert(obj,id) {
511 var tmpStr = $j("#comment-edit-text-" + id).val();
512 if(tmpStr == window.commentEmptyText) {
514 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
515 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
516 openMenu("comment-edit-submit-wrapper-" + id);
518 var ins = $j(obj).html();
519 ins = ins.replace("<","<");
520 ins = ins.replace(">",">");
521 ins = ins.replace("&","&");
522 ins = ins.replace(""",'"');
523 $j("#comment-edit-text-" + id).val(tmpStr + ins);
526 function qCommentInsert(obj,id) {
527 var tmpStr = $j("#comment-edit-text-" + id).val();
528 if(tmpStr == window.commentEmptyText) {
530 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
531 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
532 openMenu("comment-edit-submit-wrapper-" + id);
534 var ins = $j(obj).val();
535 ins = ins.replace("<","<");
536 ins = ins.replace(">",">");
537 ins = ins.replace("&","&");
538 ins = ins.replace(""",'"');
539 $j("#comment-edit-text-" + id).val(tmpStr + ins);
543 /*function showHideCommentBox(id) {
544 if( $j('#comment-edit-form-' + id).is(':visible')) {
545 $j('#comment-edit-form-' + id).hide();
548 $j('#comment-edit-form-' + id).show();
553 /*function deleteCheckedItems() {
556 $j('.item-select').each( function() {
557 if($j(this).is(':checked')) {
558 if(checkedstr.length != 0) {
559 checkedstr = checkedstr + ',' + $j(this).val();
562 checkedstr = $j(this).val();
566 $j.post('item', { dropitems: checkedstr }, function(data) {
567 window.location.reload();
571 function jotVideoURL() {
572 reply = prompt(window.vidURL);
573 if(reply && reply.length) {
574 addeditortext('[video]' + reply + '[/video]');
578 function jotAudioURL() {
579 reply = prompt(window.audURL);
580 if(reply && reply.length) {
581 addeditortext('[audio]' + reply + '[/audio]');
586 function jotGetLocation() {
587 reply = prompt(window.whereAreU, $j('#jot-location').val());
588 if(reply && reply.length) {
589 $j('#jot-location').val(reply);
593 function jotShare(id) {
594 if ($j('#jot-popup').length != 0) $j('#jot-popup').show();
596 $j('#like-rotator-' + id).show();
597 $j.get('share/' + id, function(data) {
598 if (!editor) $j("#profile-jot-text").val("");
599 initEditor(function(){
601 $j('#like-rotator-' + id).hide();
602 $j(window).scrollTop(0);
608 function linkdropper(event) {
609 var linkFound = event.dataTransfer.types.contains("text/uri-list");
611 event.preventDefault();
614 switch(window.ajaxType) {
616 function jotGetLink() {
617 reply = prompt(window.linkURL);
618 if(reply && reply.length) {
619 reply = bin2hex(reply);
620 $j('#profile-rotator').show();
621 $j.get('parse_url?binurl=' + reply, function(data) {
623 $j('#profile-rotator').hide();
628 function linkdrop(event) {
629 var reply = event.dataTransfer.getData("text/uri-list");
630 event.target.textContent = reply;
631 event.preventDefault();
632 if(reply && reply.length) {
633 reply = bin2hex(reply);
634 $j('#profile-rotator').show();
635 $j.get('parse_url?binurl=' + reply, function(data) {
636 if (!editor) $j("#profile-jot-text").val("");
637 initEditor(function(){
639 $j('#profile-rotator').hide();
646 case 'wallmsg-header':
648 function jotGetLink() {
649 reply = prompt(window.linkURL);
650 if(reply && reply.length) {
651 $j('#profile-rotator').show();
652 $j.get('parse_url?url=' + reply, function(data) {
653 tinyMCE.execCommand('mceInsertRawHTML',false,data);
654 $j('#profile-rotator').hide();
659 function linkdrop(event) {
660 var reply = event.dataTransfer.getData("text/uri-list");
661 event.target.textContent = reply;
662 event.preventDefault();
663 if(reply && reply.length) {
664 $j('#profile-rotator').show();
665 $j.get('parse_url?url=' + reply, function(data) {
666 tinyMCE.execCommand('mceInsertRawHTML',false,data);
667 $j('#profile-rotator').hide();
677 function showEvent(eventid) {
679 baseurl + '/events/?id='+eventid,
687 function itemTag(id) {
688 reply = prompt(window.term);
689 if(reply && reply.length) {
690 reply = reply.replace('#','');
694 $j('body').css('cursor', 'wait');
696 $j.get('tagger/' + id + '?term=' + reply, NavUpdate);
697 /*if(timer) clearTimeout(timer);
698 timer = setTimeout(NavUpdate,3000);*/
704 function itemFiler(id) {
706 $j.get('filer/', function(data){
708 var promptText = $j('#id_term_label', data).text();
710 reply = prompt(promptText);
711 if(reply && reply.length) {
713 $j('body').css('cursor', 'wait');
714 $j.get('filer/' + id + '?term=' + reply, NavUpdate);
715 /* if(timer) clearTimeout(timer);
716 timer = setTimeout(NavUpdate,3000);*/
718 /* $j.fancybox.close();*/
722 /* var bordercolor = $j("input").css("border-color");
724 $j.get('filer/', function(data){
726 $j("#id_term").keypress(function(){
727 $j(this).css("border-color",bordercolor);
729 $j("#select_term").change(function(){
730 $j("#id_term").css("border-color",bordercolor);
733 $j("#filer_save").click(function(e){
735 reply = $j("#id_term").val();
736 if(reply && reply.length) {
738 $j('body').css('cursor', 'wait');
739 $j.get('filer/' + id + '?term=' + reply);
740 if(timer) clearTimeout(timer);
741 timer = setTimeout(NavUpdate,3000);
745 $j("#id_term").css("border-color","#FF0000");
753 function jotClearLocation() {
754 $j('#jot-coord').val('');
755 $j('#profile-nolocation-wrapper').hide();
758 function addeditortext(data) {
759 if(plaintext == 'none') {
760 var currentText = $j("#profile-jot-text").val();
761 $j("#profile-jot-text").val(currentText + data);
764 tinyMCE.execCommand('mceInsertRawHTML',false,data);*/
767 if(typeof window.geoTag === 'function') window.geoTag();