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() {
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,
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,
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) {
227 function initEditor(callback){
228 if (editor == false) {
229 $("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
230 $("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
231 $("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
232 var parent = $("#profile-jot-acl-wrapper").parent();
233 if (parent.css('display') == 'none') {
240 $(".jothidden").show();
244 if (typeof callback != "undefined") {
249 function enableOnUser(){
261 function addeditortext(textElem, data) {
262 var currentText = $(textElem).val();
263 $(textElem).val(currentText + data);
266 function jotVideoURL() {
267 reply = prompt(window.vidURL);
268 if (reply && reply.length) {
269 addeditortext("#profile-jot-text", '[video]' + reply + '[/video]');
273 function jotAudioURL() {
274 reply = prompt(window.audURL);
275 if (reply && reply.length) {
276 addeditortext("#profile-jot-text", '[audio]' + reply + '[/audio]');
281 function jotGetLocation() {
282 reply = prompt(window.whereAreU, $('#jot-location').val());
283 if (reply && reply.length) {
284 $('#jot-location').val(reply);
288 function jotShare(id) {
289 if ($('#jot-popup').length != 0) $('#jot-popup').show();
291 $('#like-rotator-' + id).show();
292 $.get('share/' + id, function(data) {
293 if (!editor) $("#profile-jot-text").val("");
294 initEditor(function() {
295 addeditortext("#profile-jot-text", data);
296 $('#like-rotator-' + id).hide();
297 $(window).scrollTop(0);
303 function jotGetLink() {
304 reply = prompt(window.linkURL);
305 if (reply && reply.length) {
306 reply = bin2hex(reply);
307 $('#profile-rotator').show();
308 $.get('parse_url?binurl=' + reply, function(data) {
309 addeditortext(window.jotId, data);
310 $('#profile-rotator').hide();
315 function jotClearLocation() {
316 $('#jot-coord').val('');
317 $('#profile-nolocation-wrapper').hide();
320 if (typeof window.geoTag === 'function') window.geoTag();
328 function confirmDelete() { return confirm(window.delItem); }
330 function itemTag(id) {
331 reply = prompt(window.term);
332 if (reply && reply.length) {
333 reply = reply.replace('#','');
337 $('body').css('cursor', 'wait');
339 $.get('tagger/' + id + '?term=' + reply, NavUpdate);
340 /*if (timer) clearTimeout(timer);
341 timer = setTimeout(NavUpdate,3000);*/
347 function itemFiler(id) {
348 $.get('filer/', function(data) {
350 var promptText = $('#id_term_label', data).text();
352 reply = prompt(promptText);
353 if (reply && reply.length) {
355 $('body').css('cursor', 'wait');
356 $.get('filer/' + id + '?term=' + reply, NavUpdate);
365 function commentOpen(obj,id) {
366 if (obj.value == "") {
367 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
368 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
369 $("#mod-cmnt-wrap-" + id).show();
370 openMenu("comment-edit-submit-wrapper-" + id);
373 function commentClose(obj,id) {
374 if (obj.value == "") {
375 $("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
376 $("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
377 $("#mod-cmnt-wrap-" + id).hide();
378 closeMenu("comment-edit-submit-wrapper-" + id);
383 function commentInsert(obj,id) {
384 var tmpStr = $("#comment-edit-text-" + id).val();
386 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
387 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
388 openMenu("comment-edit-submit-wrapper-" + id);
390 var ins = $(obj).html();
391 ins = ins.replace("<","<");
392 ins = ins.replace(">",">");
393 ins = ins.replace("&","&");
394 ins = ins.replace(""",'"');
395 $("#comment-edit-text-" + id).val(tmpStr + ins);
398 function qCommentInsert(obj,id) {
399 var tmpStr = $("#comment-edit-text-" + id).val();
401 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
402 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
403 openMenu("comment-edit-submit-wrapper-" + id);
405 var ins = $(obj).val();
406 ins = ins.replace("<","<");
407 ins = ins.replace(">",">");
408 ins = ins.replace("&","&");
409 ins = ins.replace(""",'"');
410 $("#comment-edit-text-" + id).val(tmpStr + ins);
414 function insertFormatting(BBcode, id) {
415 var tmpStr = $("#comment-edit-text-" + id).val();
417 $("#comment-edit-text-" + id).addClass("comment-edit-text-full");
418 $("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
419 openMenu("comment-edit-submit-wrapper-" + id);
422 textarea = document.getElementById("comment-edit-text-" +id);
423 if (document.selection) {
425 selected = document.selection.createRange();
426 if (BBcode == "url") {
427 selected.text = "["+BBcode+"=http://]" + selected.text + "[/"+BBcode+"]";
429 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
431 } else if (textarea.selectionStart || textarea.selectionStart == "0") {
432 var start = textarea.selectionStart;
433 var end = textarea.selectionEnd;
434 if (BBcode == "url") {
435 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
437 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
444 function cmtBbOpen(id) {
445 $(".comment-edit-bb-" + id).show();
447 function cmtBbClose(id) {
448 $(".comment-edit-bb-" + id).hide();