1 $(document).ready(function() {
3 /* enable tinymce on focus and click */
4 $("#profile-jot-text").focus(enableOnUser);
5 $("#profile-jot-text").click(enableOnUser);
7 $('#event-share-checkbox').change(function() {
8 if ($('#event-share-checkbox').is(':checked')) {
9 $('#acl-wrapper').show();
12 $('#acl-wrapper').hide();
16 $(".popupbox").click(function () {
17 var parent = $( $(this).attr('href') ).parent();
18 if (parent.css('display') == 'none') {
28 if (typeof window.AjaxUpload != "undefined") {
29 var uploader = new window.AjaxUpload(
30 window.imageUploadButton,
31 { action: 'wall_upload/'+window.nickname+'?nomce=1',
33 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
34 onComplete: function(file,response) {
35 addeditortext(window.jotId, response);
36 $('#profile-rotator').hide();
41 if ($('#wall-file-upload').length) {
42 var file_uploader = new window.AjaxUpload(
44 { action: 'wall_attach/'+window.nickname+'?nomce=1',
46 onSubmit: function(file,ext) { $('#profile-rotator').show(); },
47 onComplete: function(file,response) {
48 addeditortext(window.jotId, response);
49 $('#profile-rotator').hide();
57 if (typeof window.aclInit !="undefined" && typeof acl=="undefined") {
60 [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
64 switch(window.autocompleteType) {
66 $("#recip").name_autocomplete(baseurl + '/acl', '', false, function(data) {
67 $("#recip-complete").val(data.id);
71 $("#contacts-search").contact_autocomplete(baseurl + '/acl', 'a', true);
74 $("#contacts-search").keyup(function(event) {
75 if (event.keyCode == 13) {
76 $("#contacts-search").click();
79 $(".autocomplete-w1 .selected").keyup(function(event) {
80 if (event.keyCode == 13) {
81 $("#contacts-search").click();
86 $(".comment-wwedit-wrapper textarea").editor_autocomplete(baseurl+"/acl");
92 if (window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
93 $('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
95 $('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
96 selstr = $(this).text();
97 $('#jot-perms-icon').removeClass('unlock').addClass('lock');
98 $('#jot-public').hide();
100 if (selstr == null) {
101 $('#jot-perms-icon').removeClass('lock').addClass('unlock');
102 $('#jot-public').show();
105 }).trigger('change');
108 if (window.aclType == "event_head") {
109 $('#events-calendar').fullCalendar({
110 events: baseurl + window.eventModuleUrl +'/json/',
112 left: 'prev,next today',
114 right: 'month,agendaWeek,agendaDay'
116 timeFormat: 'H(:mm)',
117 eventClick: function(calEvent, jsEvent, view) {
118 showEvent(calEvent.id);
121 eventRender: function(event, element, view) {
122 //console.log(view.name);
123 if (event.item['author-name']==null) return;
126 element.find(".fc-title").html(
127 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
128 event.item['author-avatar'],
129 event.item['author-name'],
134 element.find(".fc-title").html(
135 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
136 event.item['author-avatar'],
137 event.item['author-name'],
143 element.find(".fc-title").html(
144 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
145 event.item['author-avatar'],
146 event.item['author-name'],
157 var args=location.href.replace(baseurl,"").split("/");
158 if (args.length>=5 && window.eventModeParams == 2) {
159 $("#events-calendar").fullCalendar('gotoDate',args[3] , args[4]-1);
160 } else if (args.length>=4 && window.eventModeParams == 1) {
161 $("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
165 var hash = location.hash.split("-")
166 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
171 // update pending count //
174 $("nav").bind('nav-update', function(e,data) {
175 var elm = $('#pending-update');
176 var register = $(data).find('register').text();
177 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
184 function homeRedirect() {
185 $('html').fadeOut('slow', function() {
186 window.location = baseurl + "/login";
191 function initCrop() {
192 function onEndCrop( coords, dimensions ) {
193 $PR( 'x1' ).value = coords.x1;
194 $PR( 'y1' ).value = coords.y1;
195 $PR( 'x2' ).value = coords.x2;
196 $PR( 'y2' ).value = coords.y2;
197 $PR( 'width' ).value = dimensions.width;
198 $PR( 'height' ).value = dimensions.height;
201 Event.observe( window, 'load', function() {
202 new Cropper.ImgWithPreview(
205 previewWrap: 'previewWrap',
210 ratioDim: { x: 100, y:100 },
218 function showEvent(eventid) {
229 var plaintext = 'none';//window.editSelect;
230 //var ispublic = window.isPublic;
232 function initEditor(cb) {
234 if (plaintext == 'none') {
235 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
236 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
239 $("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
240 var parent = $("#profile-jot-acl-wrapper").parent();
241 if (parent.css('display') == 'none') {
249 $(".jothidden").show();
250 if (typeof cb!="undefined") {
256 if (typeof cb!="undefined") cb();
260 function enableOnUser() {
272 function addeditortext(textElem, data) {
273 if (window.editSelect == 'none') {
274 var currentText = $(textElem).val();
275 $(textElem).val(currentText + data);
279 function jotVideoURL() {
280 reply = prompt(window.vidURL);
281 if (reply && reply.length) {
282 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
286 function jotAudioURL() {
287 reply = prompt(window.audURL);
288 if (reply && reply.length) {
289 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
294 function jotGetLocation() {
295 reply = prompt(window.whereAreU, $('#jot-location').val());
296 if (reply && reply.length) {
297 $('#jot-location').val(reply);
301 function jotShare(id) {
302 if ($('#jot-popup').length != 0) $('#jot-popup').show();
304 $('#like-rotator-' + id).show();
305 $.get('share/' + id, function(data) {
306 if (!editor) $("#profile-jot-text").val("");
307 initEditor(function() {
308 addeditortext("#profile-jot-text", data);
309 $('#like-rotator-' + id).hide();
310 $(window).scrollTop(0);
316 function jotGetLink() {
317 reply = prompt(window.linkURL);
318 if (reply && reply.length) {
319 reply = bin2hex(reply);
320 $('#profile-rotator').show();
321 $.get('parse_url?binurl=' + reply, function(data) {
322 addeditortext(window.jotId, data);
323 $('#profile-rotator').hide();
328 function jotClearLocation() {
329 $('#jot-coord').val('');
330 $('#profile-nolocation-wrapper').hide();
333 if (typeof window.geoTag === 'function') window.geoTag();
341 function confirmDelete() { return confirm(window.delItem); }
343 function itemTag(id) {
344 reply = prompt(window.term);
345 if (reply && reply.length) {
346 reply = reply.replace('#','');
350 $('body').css('cursor', 'wait');
352 $.get('tagger/' + id + '?term=' + reply, NavUpdate);
353 /*if (timer) clearTimeout(timer);
354 timer = setTimeout(NavUpdate,3000);*/
360 function itemFiler(id) {
361 $.get('filer/', function(data) {
363 var promptText = $('#id_term_label', data).text();
365 reply = prompt(promptText);
366 if (reply && reply.length) {
368 $('body').css('cursor', 'wait');
369 $.get('filer/' + id + '?term=' + reply, NavUpdate);
378 function commentOpen(obj,id) {
379 if (obj.value == "") {
380 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
381 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
382 $("#mod-cmnt-wrap-" + id).show();
383 openMenu("comment-edit-submit-wrapper-" + id);
386 function commentClose(obj,id) {
387 if (obj.value == "") {
388 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
389 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
390 $("#mod-cmnt-wrap-" + id).hide();
391 closeMenu("comment-edit-submit-wrapper-" + id);
396 function commentInsert(obj,id) {
397 var tmpStr = $("#comment-edit-text-" + id).val();
399 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
400 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
401 openMenu("comment-edit-submit-wrapper-" + id);
403 var ins = $(obj).html();
404 ins = ins.replace("<","<");
405 ins = ins.replace(">",">");
406 ins = ins.replace("&","&");
407 ins = ins.replace(""",'"');
408 $("#comment-edit-text-" + id).val(tmpStr + ins);
411 function qCommentInsert(obj,id) {
412 var tmpStr = $("#comment-edit-text-" + id).val();
414 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
415 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
416 openMenu("comment-edit-submit-wrapper-" + id);
418 var ins = $(obj).val();
419 ins = ins.replace("<","<");
420 ins = ins.replace(">",">");
421 ins = ins.replace("&","&");
422 ins = ins.replace(""",'"');
423 $("#comment-edit-text-" + id).val(tmpStr + ins);
427 function insertFormatting(comment,BBcode,id) {
429 var tmpStr = $("#comment-edit-text-" + id).val();
430 if(tmpStr == comment) {
432 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
433 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
434 openMenu("comment-edit-submit-wrapper-" + id);
435 $("#comment-edit-text-" + id).val(tmpStr);
438 textarea = document.getElementById("comment-edit-text-" +id);
439 if (document.selection) {
441 selected = document.selection.createRange();
442 if (BBcode == "url"){
443 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
445 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
446 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
447 var start = textarea.selectionStart;
448 var end = textarea.selectionEnd;
449 if (BBcode == "url"){
450 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
452 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
457 function cmtBbOpen(id) {
458 $(".comment-edit-bb-" + id).show();
460 function cmtBbClose(id) {
461 $(".comment-edit-bb-" + id).hide();