1 $(document).ready(function() {
3 /* enable editor on focus and click */
4 $("#profile-jot-text").focus(enableOnUser);
5 $("#profile-jot-text").click(enableOnUser);
7 $('#event-share-checkbox').change(function() {
9 if ($('#event-share-checkbox').is(':checked')) {
10 $('#acl-wrapper').show();
13 $('#acl-wrapper').hide();
18 $(".popupbox").click(function () {
19 var parent = $( $(this).attr('href') ).parent();
20 if (parent.css('display') == 'none') {
30 if(typeof window.AjaxUpload != "undefined") {
31 var uploader = new window.AjaxUpload(
32 window.imageUploadButton,
33 { action: 'wall_upload/' + window.nickname,
35 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
36 onComplete: function(file,response) {
37 addeditortext(window.jotId, response);
38 $('#profile-rotator').hide();
43 if($('#wall-file-upload').length) {
44 var file_uploader = new window.AjaxUpload(
46 { action: 'wall_attach/' + window.nickname,
48 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
49 onComplete: function(file,response) {
50 addeditortext(window.jotId, response);
51 $('#profile-rotator').hide();
59 if(typeof window.aclInit !="undefined" && typeof acl=="undefined"){
62 [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
66 switch(window.autocompleteType) {
68 $("#recip").name_autocomplete(baseurl + '/acl', '', false, function(data) {
69 $("#recip-complete").val(data.id);
73 $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true);
76 $("#contacts-search").keyup(function(event){
77 if(event.keyCode == 13){
78 $("#contacts-search").click();
81 $(".autocomplete-w1 .selected").keyup(function(event){
82 if(event.keyCode == 13){
83 $("#contacts-search").click();
88 $(".comment-wwedit-wrapper textarea").editor_autocomplete(baseurl+"/acl");
95 /* if(window.autoCompleteType == "display-head") {
96 //$(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
97 // make auto-complete work in more places
98 //$(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
99 $(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
103 if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
104 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
106 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
107 selstr = $(this).text();
108 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
109 $('#jot-public').hide();
112 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
113 $('#jot-public').show();
116 }).trigger('change');
119 if(window.aclType == "event_head") {
120 $('#events-calendar').fullCalendar({
121 events: baseurl + window.eventModuleUrl +'/json/',
123 left: 'prev,next today',
125 right: 'month,agendaWeek,agendaDay'
127 timeFormat: 'H(:mm)',
128 eventClick: function(calEvent, jsEvent, view) {
129 showEvent(calEvent.id);
132 eventRender: function(event, element, view) {
133 //console.log(view.name);
134 if (event.item['author-name']==null) return;
137 element.find(".fc-title").html(
138 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
139 event.item['author-avatar'],
140 event.item['author-name'],
145 element.find(".fc-title").html(
146 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
147 event.item['author-avatar'],
148 event.item['author-name'],
154 element.find(".fc-title").html(
155 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
156 event.item['author-avatar'],
157 event.item['author-name'],
168 var args=location.href.replace(baseurl,"").split("/");
169 if (args.length>=5 && window.eventModeParams == 2) {
170 $("#events-calendar").fullCalendar('gotoDate',args[3] , args[4]-1);
171 } else if (args.length>=4 && window.eventModeParams == 1) {
172 $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
176 var hash = location.hash.split("-")
177 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
182 // update pending count //
185 $("nav").bind('nav-update', function(e,data){
186 var elm = $('#pending-update');
187 var register = $(data).find('register').text();
188 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
195 function homeRedirect() {
196 $('html').fadeOut('slow', function(){
197 window.location = baseurl + "/login";
202 function initCrop() {
203 function onEndCrop( coords, dimensions ) {
204 $PR( 'x1' ).value = coords.x1;
205 $PR( 'y1' ).value = coords.y1;
206 $PR( 'x2' ).value = coords.x2;
207 $PR( 'y2' ).value = coords.y2;
208 $PR( 'width' ).value = dimensions.width;
209 $PR( 'height' ).value = dimensions.height;
212 Event.observe( window, 'load', function() {
213 new Cropper.ImgWithPreview(
216 previewWrap: 'previewWrap',
221 ratioDim: { x: 100, y:100 },
229 function showEvent(eventid) {
231 baseurl + window.eventModuleUrl + '/?id=' + eventid,
233 $.colorbox({html:data});
244 function initEditor(callback){
245 if (editor == false) {
246 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
247 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
248 $("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
249 var parent = $("#profile-jot-acl-wrapper").parent();
250 if (parent.css('display') == 'none') {
257 $(".jothidden").show();
261 if (typeof callback != "undefined") {
266 function enableOnUser(){
278 function addeditortext(textElem, data) {
279 var currentText = $(textElem).val();
280 $(textElem).val(currentText + data);
283 function jotVideoURL() {
284 reply = prompt(window.vidURL);
285 if(reply && reply.length) {
286 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
290 function jotAudioURL() {
291 reply = prompt(window.audURL);
292 if(reply && reply.length) {
293 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
298 function jotGetLocation() {
299 reply = prompt(window.whereAreU, $('#jot-location').val());
300 if(reply && reply.length) {
301 $('#jot-location').val(reply);
305 function jotShare(id) {
306 if ($('#jot-popup').length != 0) $('#jot-popup').show();
308 $('#like-rotator-' + id).show();
309 $.get('share/' + id, function(data) {
310 if (!editor) $("#profile-jot-text").val("");
311 initEditor(function(){
312 addeditortext("#profile-jot-text", data);
313 $('#like-rotator-' + id).hide();
314 $(window).scrollTop(0);
320 function jotGetLink() {
321 reply = prompt(window.linkURL);
322 if(reply && reply.length) {
323 reply = bin2hex(reply);
324 $('#profile-rotator').show();
325 $.get('parse_url?binurl=' + reply, function(data) {
326 addeditortext(window.jotId, data);
327 $('#profile-rotator').hide();
332 /*function linkdropper(event) {
333 var linkFound = event.dataTransfer.types.contains("text/uri-list");
335 event.preventDefault();
338 function linkdrop(event) {
339 var reply = event.dataTransfer.getData("text/uri-list");
340 event.target.textContent = reply;
341 event.preventDefault();
342 if(reply && reply.length) {
343 reply = bin2hex(reply);
344 $('#profile-rotator').show();
345 $.get('parse_url?binurl=' + reply, function(data) {
346 //if (!editor) $("#profile-jot-text").val("");
347 //initEditor(function(){
348 addeditortext(window.jotId, data);
349 $('#profile-rotator').hide();
355 function jotClearLocation() {
356 $('#jot-coord').val('');
357 $('#profile-nolocation-wrapper').hide();
360 if(typeof window.geoTag === 'function') window.geoTag();
368 function confirmDelete() { return confirm(window.delItem); }
370 /*function deleteCheckedItems() {
373 $('.item-select').each( function() {
374 if($(this).is(':checked')) {
375 if(checkedstr.length != 0) {
376 checkedstr = checkedstr + ',' + $(this).val();
379 checkedstr = $(this).val();
383 $.post('item', { dropitems: checkedstr }, function(data) {
384 window.location.reload();
388 function itemTag(id) {
389 reply = prompt(window.term);
390 if(reply && reply.length) {
391 reply = reply.replace('#','');
395 $('body').css('cursor', 'wait');
397 $.get('tagger/' + id + '?term=' + reply, NavUpdate);
398 /*if(timer) clearTimeout(timer);
399 timer = setTimeout(NavUpdate,3000);*/
405 function itemFiler(id) {
407 $.get('filer/', function(data){
409 var promptText = $('#id_term_label', data).text();
411 reply = prompt(promptText);
412 if(reply && reply.length) {
414 $('body').css('cursor', 'wait');
415 $.get('filer/' + id + '?term=' + reply, NavUpdate);
416 /* if(timer) clearTimeout(timer);
417 timer = setTimeout(NavUpdate,3000);*/
419 /* $.colorbox.close();*/
423 /* var bordercolor = $("input").css("border-color");
425 $.get('filer/', function(data){
426 $.colorbox({html:data});
427 $("#id_term").keypress(function(){
428 $(this).css("border-color",bordercolor);
430 $("#select_term").change(function(){
431 $("#id_term").css("border-color",bordercolor);
434 $("#filer_save").click(function(e){
436 reply = $("#id_term").val();
437 if(reply && reply.length) {
439 $('body').css('cursor', 'wait');
440 $.get('filer/' + id + '?term=' + reply);
441 if(timer) clearTimeout(timer);
442 timer = setTimeout(NavUpdate,3000);
446 $("#id_term").css("border-color","#FF0000");
461 function commentOpen(obj,id) {
462 if(obj.value == window.commentEmptyText) {
464 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
465 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
466 $("#mod-cmnt-wrap-" + id).show();
467 openMenu("comment-edit-submit-wrapper-" + id);
470 function commentClose(obj,id) {
471 if(obj.value == "") {
472 obj.value = window.commentEmptyText;
473 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
474 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
475 $("#mod-cmnt-wrap-" + id).hide();
476 closeMenu("comment-edit-submit-wrapper-" + id);
481 function commentInsert(obj,id) {
482 var tmpStr = $("#comment-edit-text-" + id).val();
483 if(tmpStr == window.commentEmptyText) {
485 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
486 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
487 openMenu("comment-edit-submit-wrapper-" + id);
489 var ins = $(obj).html();
490 ins = ins.replace("<","<");
491 ins = ins.replace(">",">");
492 ins = ins.replace("&","&");
493 ins = ins.replace(""",'"');
494 $("#comment-edit-text-" + id).val(tmpStr + ins);
497 function qCommentInsert(obj,id) {
498 var tmpStr = $("#comment-edit-text-" + id).val();
499 if(tmpStr == window.commentEmptyText) {
501 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
502 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
503 openMenu("comment-edit-submit-wrapper-" + id);
505 var ins = $(obj).val();
506 ins = ins.replace("<","<");
507 ins = ins.replace(">",">");
508 ins = ins.replace("&","&");
509 ins = ins.replace(""",'"');
510 $("#comment-edit-text-" + id).val(tmpStr + ins);
514 /*function showHideCommentBox(id) {
515 if( $('#comment-edit-form-' + id).is(':visible')) {
516 $('#comment-edit-form-' + id).hide();
519 $('#comment-edit-form-' + id).show();
524 function insertFormatting(comment,BBcode,id) {
526 var tmpStr = $("#comment-edit-text-" + id).val();
527 if(tmpStr == comment) {
529 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
530 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
531 openMenu("comment-edit-submit-wrapper-" + id);
532 $("#comment-edit-text-" + id).val(tmpStr);
535 textarea = document.getElementById("comment-edit-text-" +id);
536 if (document.selection) {
538 selected = document.selection.createRange();
539 if (BBcode == "url"){
540 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
542 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
543 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
544 var start = textarea.selectionStart;
545 var end = textarea.selectionEnd;
546 if (BBcode == "url"){
547 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
549 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
554 function cmtBbOpen(id) {
555 $(".comment-edit-bb-" + id).show();
557 function cmtBbClose(id) {
558 $(".comment-edit-bb-" + id).hide();