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 == window.commentEmptyText) {
381 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
382 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
383 $("#mod-cmnt-wrap-" + id).show();
384 openMenu("comment-edit-submit-wrapper-" + id);
387 function commentClose(obj,id) {
388 if(obj.value == "") {
389 obj.value = window.commentEmptyText;
390 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
391 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
392 $("#mod-cmnt-wrap-" + id).hide();
393 closeMenu("comment-edit-submit-wrapper-" + id);
398 function commentInsert(obj,id) {
399 var tmpStr = $("#comment-edit-text-" + id).val();
400 if(tmpStr == window.commentEmptyText) {
402 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
403 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
404 openMenu("comment-edit-submit-wrapper-" + id);
406 var ins = $(obj).html();
407 ins = ins.replace("<","<");
408 ins = ins.replace(">",">");
409 ins = ins.replace("&","&");
410 ins = ins.replace(""",'"');
411 $("#comment-edit-text-" + id).val(tmpStr + ins);
414 function qCommentInsert(obj,id) {
415 var tmpStr = $("#comment-edit-text-" + id).val();
416 if(tmpStr == window.commentEmptyText) {
418 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
419 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
420 openMenu("comment-edit-submit-wrapper-" + id);
422 var ins = $(obj).val();
423 ins = ins.replace("<","<");
424 ins = ins.replace(">",">");
425 ins = ins.replace("&","&");
426 ins = ins.replace(""",'"');
427 $("#comment-edit-text-" + id).val(tmpStr + ins);
431 function insertFormatting(comment,BBcode,id) {
433 var tmpStr = $("#comment-edit-text-" + id).val();
434 if(tmpStr == comment) {
436 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
437 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
438 openMenu("comment-edit-submit-wrapper-" + id);
439 $("#comment-edit-text-" + id).val(tmpStr);
442 textarea = document.getElementById("comment-edit-text-" +id);
443 if (document.selection) {
445 selected = document.selection.createRange();
446 if (BBcode == "url"){
447 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
449 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
450 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
451 var start = textarea.selectionStart;
452 var end = textarea.selectionEnd;
453 if (BBcode == "url"){
454 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
456 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
461 function cmtBbOpen(id) {
462 $(".comment-edit-bb-" + id).show();
464 function cmtBbClose(id) {
465 $(".comment-edit-bb-" + id).hide();