]> git.mxchange.org Git - friendica.git/blob - view/theme/frost/js/theme.js
Darkzero/NS .contact-photo-menu
[friendica.git] / view / theme / frost / js / theme.js
1 $j(document).ready(function() {
2
3         window.navMenuTimeout = {
4                 '#network-menu-list-timeout': null,
5                 '#contacts-menu-list-timeout': null,
6                 '#system-menu-list-timeout': null,
7                 '#network-menu-list-opening': false,
8                 '#contacts-menu-list-opening': false,
9                 '#system-menu-list-opening': false,
10                 '#network-menu-list-closing': false,
11                 '#contacts-menu-list-closing': false,
12                 '#system-menu-list-closing': false
13         };
14
15 /*    $j.ajaxSetup({ 
16         cache: false 
17     });*/
18
19
20         if(typeof acl=="undefined"){
21                 acl = new ACL(
22                         baseurl+"/acl",
23                         [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
24                 );
25         }
26
27         /* enable tinymce on focus and click */
28         $j("#profile-jot-text").focus(enableOnUser);
29         $j("#profile-jot-text").click(enableOnUser);
30
31
32         $j('.nav-menu-link').hover(function() {
33                 showNavMenu($j(this).attr('rel'));
34         }, function() {
35                 hideNavMenu($j(this).attr('rel'));
36         });
37
38 /*      $j('html').click(function() { $j("#nav-notifications-menu" ).hide(); });*/
39
40         $j('.group-edit-icon').hover(
41                 function() {
42                         $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
43                 function() {
44                         $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
45                 );
46
47         $j('.sidebar-group-element').hover(
48                 function() {
49                         id = $j(this).attr('id');
50                         $j('#edit-' + id).addClass('icon'); $j('#edit-' + id).removeClass('iconspacer');},
51
52                 function() {
53                         id = $j(this).attr('id');
54                         $j('#edit-' + id).removeClass('icon');$j('#edit-' + id).addClass('iconspacer');}
55                 );
56
57
58         $j('.savedsearchdrop').hover(
59                 function() {
60                         $j(this).addClass('drop'); $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
61                 function() {
62                         $j(this).removeClass('drop'); $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
63         );
64
65         $j('.savedsearchterm').hover(
66                 function() {
67                         id = $j(this).attr('id');
68                         $j('#drop-' + id).addClass('icon');     $j('#drop-' + id).addClass('drophide'); $j('#drop-' + id).removeClass('iconspacer');},
69
70                 function() {
71                         id = $j(this).attr('id');
72                         $j('#drop-' + id).removeClass('icon');$j('#drop-' + id).removeClass('drophide'); $j('#drop-' + id).addClass('iconspacer');}
73         );
74
75 /*      $j('.nav-load-page-link').click(function() {
76                 getPageContent( $j(this).attr('href') );
77                 hideNavMenu( '#' + $j(this).closest('ul').attr('id') );
78                 return false;
79         });*/
80
81         if(window.autoCompleteType == "display-head") {
82                 //$j(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
83                 // make auto-complete work in more places
84                 //$j(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
85                 $j(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
86         }
87
88         if(window.aclType == "event_head") {
89                 $j('#events-calendar').fullCalendar({
90                         events: baseurl + '/events/json/',
91                         header: {
92                                 left: 'prev,next today',
93                                 center: 'title',
94                                 right: 'month,agendaWeek,agendaDay'
95                         },                      
96                         timeFormat: 'H(:mm)',
97                         eventClick: function(calEvent, jsEvent, view) {
98                                 showEvent(calEvent.id);
99                         },
100                         
101                         eventRender: function(event, element, view) {
102                                 //console.log(view.name);
103                                 if (event.item['author-name']==null) return;
104                                 switch(view.name){
105                                         case "month":
106                                         element.find(".fc-event-title").html(
107                                                 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
108                                                         event.item['author-avatar'],
109                                                         event.item['author-name'],
110                                                         event.title
111                                         ));
112                                         break;
113                                         case "agendaWeek":
114                                         element.find(".fc-event-title").html(
115                                                 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
116                                                         event.item['author-avatar'],
117                                                         event.item['author-name'],
118                                                         event.item.desc,
119                                                         event.item.location
120                                         ));
121                                         break;
122                                         case "agendaDay":
123                                         element.find(".fc-event-title").html(
124                                                 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
125                                                         event.item['author-avatar'],
126                                                         event.item['author-name'],
127                                                         event.item.desc,
128                                                         event.item.location
129                                         ));
130                                         break;
131                                 }
132                         }
133                         
134                 });
135                 
136                 // center on date
137                 var args=location.href.replace(baseurl,"").split("/");
138                 if (args.length>=4) {
139                         $j("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
140                 } 
141                 
142                 // show event popup
143                 var hash = location.hash.split("-")
144                 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
145         }       
146
147         $j('#event-share-checkbox').change(function() {
148
149                 if ($j('#event-share-checkbox').is(':checked')) { 
150                         $j('#acl-wrapper').show();
151                 }
152                 else {
153                         $j('#acl-wrapper').hide();
154                 }
155         }).trigger('change');
156
157
158         if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
159                 $j('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
160                         var selstr;
161                         $j('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
162                                 selstr = $j(this).text();
163                                 $j('#jot-perms-icon').removeClass('unlock').addClass('lock');
164                                 $j('#jot-public').hide();
165                         });
166                         if(selstr == null) { 
167                                 $j('#jot-perms-icon').removeClass('lock').addClass('unlock');
168                                 $j('#jot-public').show();
169                         }
170
171                 }).trigger('change');
172         }
173 // For event_end.tpl
174 /*              $j('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
175                         var selstr;
176                         $j('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
177                                 selstr = $j(this).text();
178                                 $j('#jot-public').hide();
179                         });
180                         if(selstr == null) {
181                                 $j('#jot-public').show();
182                         }
183
184                 }).trigger('change');*/
185
186
187         switch(window.autocompleteType) {
188                 case 'msg-header':
189                         var a = $j("#recip").autocomplete({ 
190                                 serviceUrl: baseurl + '/acl',
191                                 minChars: 2,
192                                 width: 350,
193                                 onSelect: function(value,data) {
194                                         $j("#recip-complete").val(data);
195                                 }                       
196                         });
197                         break;
198                 case 'contacts-head':
199                         var a = $j("#contacts-search").autocomplete({ 
200                                 serviceUrl: baseurl + '/acl',
201                                 minChars: 2,
202                                 width: 350,
203                         });
204                         a.setOptions({ params: { type: 'a' }});
205                         break;
206                 default:
207                         break;
208         }
209
210
211         if(typeof window.AjaxUpload != "undefined") {
212                 switch(window.ajaxType) {
213                         case 'jot-header':
214                                 var uploader = new window.AjaxUpload(
215                                         'wall-image-upload',
216                                         { action: 'wall_upload/'+window.nickname,
217                                                 name: 'userfile',
218                                                 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
219                                                 onComplete: function(file,response) {
220                                                         addeditortext(response);
221                                                         $j('#profile-rotator').hide();
222                                                 }                                
223                                         }
224                                 );
225
226                                 var file_uploader = new window.AjaxUpload(
227                                         'wall-file-upload',
228                                         { action: 'wall_attach/'+window.nickname,
229                                                 name: 'userfile',
230                                                 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
231                                                 onComplete: function(file,response) {
232                                                         addeditortext(response);
233                                                         $j('#profile-rotator').hide();
234                                                 }                                
235                                         }
236                                 );
237                                 break;
238                         case 'msg-header':
239                                 var uploader = new window.AjaxUpload(
240                                         'prvmail-upload',
241                                         { action: 'wall_upload/' + window.nickname,
242                                                 name: 'userfile',
243                                                 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
244                                                 onComplete: function(file,response) {
245                                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
246                                                         $j('#profile-rotator').hide();
247                                                 }                                
248                                         }
249                                 );
250                                 break;
251                         default:
252                                 break;
253                 }
254         }
255
256 });
257
258
259 // update pending count //
260 $j(function(){
261
262         $j("nav").bind('nav-update',  function(e,data){
263                 var elm = $j('#pending-update');
264                 var register = $j(data).find('register').text();
265                 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
266                 elm.html(register);
267         });
268 });
269
270
271 $j(function(){
272         
273         $j("#cnftheme").fancybox({
274                 width: 800,
275                 autoDimensions: false,
276                 onStart: function(){
277                         var theme = $j("#id_theme :selected").val();
278                         $j("#cnftheme").attr('href', baseurl + "/admin/themes/"+theme);
279                 }, 
280                 onComplete: function(){
281                         $j("div#fancybox-content form").submit(function(e){
282                                 var url = $j(this).attr('action');
283                                 // can't get .serialize() to work...
284                                 var data={};
285                                 $j(this).find("input").each(function(){
286                                         data[$j(this).attr('name')] = $j(this).val();
287                                 });
288                                 $j(this).find("select").each(function(){
289                                         data[$j(this).attr('name')] = $j(this).children(":selected").val();
290                                 });
291                                 console.log(":)", url, data);
292                                 
293                                 $j.post(url, data, function(data) {
294                                         if(timer) clearTimeout(timer);
295                                         NavUpdate();
296                                         $j.fancybox.close();
297                                 })
298                                 
299                                 return false;
300                         });
301                         
302                 }
303         });
304 });
305
306
307 if(typeof window.photoEdit != 'undefined') {
308
309         $j(document).keydown(function(event) {
310
311                         if(window.prevLink != '') { if(event.ctrlKey && event.keyCode == 37) { event.preventDefault(); window.location.href = window.prevLink; }}
312                         if(window.nextLink != '') { if(event.ctrlKey && event.keyCode == 39) { event.preventDefault(); window.location.href = window.nextLink; }}
313
314         });
315 }
316
317 switch(window.ajaxType) {
318         case 'jot-header':
319                 function jotGetLink() {
320                         reply = prompt(window.linkURL);
321                         if(reply && reply.length) {
322                                 reply = bin2hex(reply);
323                                 $j('#profile-rotator').show();
324                                 $j.get('parse_url?binurl=' + reply, function(data) {
325                                         addeditortext(data);
326                                         $j('#profile-rotator').hide();
327                                 });
328                         }
329                 }
330
331                 function linkdrop(event) {
332                         var reply = event.dataTransfer.getData("text/uri-list");
333                         event.target.textContent = reply;
334                         event.preventDefault();
335                         if(reply && reply.length) {
336                                 reply = bin2hex(reply);
337                                 $j('#profile-rotator').show();
338                                 $j.get('parse_url?binurl=' + reply, function(data) {
339                                         if (!editor) $j("#profile-jot-text").val("");
340                                         initEditor(function(){
341                                                 addeditortext(data);
342                                                 $j('#profile-rotator').hide();
343                                         });
344                                 });
345                         }
346                 }
347                 break;
348         case 'msg-header':
349         case 'wallmsg-header':
350                 function jotGetLink() {
351                         reply = prompt(window.linkURL);
352                         if(reply && reply.length) {
353                                 $j('#profile-rotator').show();
354                                 $j.get('parse_url?url=' + reply, function(data) {
355                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
356                                         $j('#profile-rotator').hide();
357                                 });
358                         }
359                 }
360
361                 function linkdrop(event) {
362                         var reply = event.dataTransfer.getData("text/uri-list");
363                         event.target.textContent = reply;
364                         event.preventDefault();
365                         if(reply && reply.length) {
366                                 $j('#profile-rotator').show();
367                                 $j.get('parse_url?url=' + reply, function(data) {
368                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
369                                         $j('#profile-rotator').hide();
370                                 });
371                         }
372                 }
373
374                 break;
375         default:
376                 break;
377 }
378
379
380 function showEvent(eventid) {
381         $j.get(
382                 baseurl + '/events/?id='+eventid,
383                 function(data){
384                         $j.fancybox(data);
385                 }
386         );                      
387 }
388
389 function initCrop() {
390         function onEndCrop( coords, dimensions ) {
391                 $( 'x1' ).value = coords.x1;
392                 $( 'y1' ).value = coords.y1;
393                 $( 'x2' ).value = coords.x2;
394                 $( 'y2' ).value = coords.y2;
395                 $( 'width' ).value = dimensions.width;
396                 $( 'height' ).value = dimensions.height;
397         }
398
399         Event.observe( window, 'load', function() {
400                 new Cropper.ImgWithPreview(
401                 'croppa',
402                 {
403                         previewWrap: 'previewWrap',
404                         minWidth: 175,
405                         minHeight: 175,
406                         maxWidth: 640,
407                         maxHeight: 640,
408                         ratioDim: { x: 100, y:100 },
409                         displayOnInit: true,
410                         onEndCrop: onEndCrop
411                 });
412         });
413 }
414
415
416 /*
417 $j(document).mouseup(function (clickPos) {
418
419         var sysMenu = $j("#system-menu-list");
420         var sysMenuLink = $j(".system-menu-link");
421         var contactsMenu = $j("#contacts-menu-list");
422         var contactsMenuLink = $j(".contacts-menu-link");
423         var networkMenu = $j("#network-menu-list");
424         var networkMenuLink = $j(".network-menu-link");
425
426         if( !sysMenu.is(clickPos.target) && !sysMenuLink.is(clickPos.target) && sysMenu.has(clickPos.target).length === 0) {
427                 hideNavMenu("#system-menu-list");
428         }
429         if( !contactsMenu.is(clickPos.target) && !contactsMenuLink.is(clickPos.target) && contactsMenu.has(clickPos.target).length === 0) {
430                 hideNavMenu("#contacts-menu-list");
431         }
432         if( !networkMenu.is(clickPos.target) && !networkMenuLink.is(clickPos.target) && networkMenu.has(clickPos.target).length === 0) {
433                 hideNavMenu("#network-menu-list");
434         }
435 });
436
437
438 function getPageContent(url) {
439
440         var pos = $j('.main-container').position();
441
442         $j('.main-container').css('margin-left', pos.left);     
443         $j('.main-content-container').hide(0, function () {
444                 $j('.main-content-loading').show(0);
445         });
446
447         $j.get(url, function(html) {
448                 console.log($j('.main-content-container').html());
449                 $j('.main-content-container').html( $j('.main-content-container', html).html() );
450                 console.log($j('.main-content-container').html());
451                 $j('.main-content-loading').hide(function() {
452                         $j('.main-content-container').fadeIn(800,function() {
453                                 $j('.main-container').css('margin-left', 'auto'); // This sucks -- if the CSS specification changes, this will be wrong
454                         });
455                 });
456         });
457 }
458 */
459
460 function showNavMenu(menuID) {
461
462         if(window.navMenuTimeout[menuID + '-closing']) {
463                 window.navMenuTimeout[menuID + '-closing'] = false;
464                 clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
465         }
466         else {
467                 window.navMenuTimeout[menuID + '-opening'] = true;
468                 
469                 window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
470                         $j(menuID).slideDown('fast').show();
471                         window.navMenuTimeout[menuID + '-opening'] = false;
472                 }, 200);
473         }
474 }
475
476 function hideNavMenu(menuID) {
477
478         if(window.navMenuTimeout[menuID + '-opening']) {
479                 window.navMenuTimeout[menuID + '-opening'] = false;
480                 clearTimeout(window.navMenuTimeout[menuID + '-timeout']);
481         }
482         else {
483                 window.navMenuTimeout[menuID + '-closing'] = true;
484                 
485                 window.navMenuTimeout[menuID + '-timeout'] = setTimeout( function () {
486                         $j(menuID).slideUp('fast');
487                         window.navMenuTimeout[menuID + '-closing'] = false;
488                 }, 500);
489         }
490 }
491
492
493
494 function insertFormatting(comment,BBcode,id) {
495         
496                 var tmpStr = $j("#comment-edit-text-" + id).val();
497                 if(tmpStr == comment) {
498                         tmpStr = "";
499                         $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
500                         $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
501                         openMenu("comment-edit-submit-wrapper-" + id);
502                         $j("#comment-edit-text-" + id).val(tmpStr);
503                 }
504
505         textarea = document.getElementById("comment-edit-text-" +id);
506         if (document.selection) {
507                 textarea.focus();
508                 selected = document.selection.createRange();
509                 if (BBcode == "url"){
510                         selected.text = "["+BBcode+"]" + "http://" +  selected.text + "[/"+BBcode+"]";
511                         } else                  
512                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
513         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
514                 var start = textarea.selectionStart;
515                 var end = textarea.selectionEnd;
516                 if (BBcode == "url"){
517                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + "http://" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
518                         } else
519                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
520         }
521         return true;
522 }
523
524 function cmtBbOpen(id) {
525         $j(".comment-edit-bb-" + id).show();
526 }
527 function cmtBbClose(id) {
528         $j(".comment-edit-bb-" + id).hide();
529 }
530
531 function confirmDelete() { return confirm(window.delItem); }
532
533 function commentOpen(obj,id) {
534         if(obj.value == window.commentEmptyText) {
535                 obj.value = "";
536                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
537                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
538                 $j("#mod-cmnt-wrap-" + id).show();
539                 openMenu("comment-edit-submit-wrapper-" + id);
540         }
541 }
542 function commentClose(obj,id) {
543         if(obj.value == "") {
544                 obj.value = window.commentEmptyText;
545                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
546                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
547                 $j("#mod-cmnt-wrap-" + id).hide();
548                 closeMenu("comment-edit-submit-wrapper-" + id);
549         }
550 }
551
552
553 function commentInsert(obj,id) {
554         var tmpStr = $j("#comment-edit-text-" + id).val();
555         if(tmpStr == window.commentEmptyText) {
556                 tmpStr = "";
557                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
558                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
559                 openMenu("comment-edit-submit-wrapper-" + id);
560         }
561         var ins = $j(obj).html();
562         ins = ins.replace("&lt;","<");
563         ins = ins.replace("&gt;",">");
564         ins = ins.replace("&amp;","&");
565         ins = ins.replace("&quot;",'"');
566         $j("#comment-edit-text-" + id).val(tmpStr + ins);
567 }
568
569 function qCommentInsert(obj,id) {
570         var tmpStr = $j("#comment-edit-text-" + id).val();
571         if(tmpStr == window.commentEmptyText) {
572                 tmpStr = "";
573                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
574                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
575                 openMenu("comment-edit-submit-wrapper-" + id);
576         }
577         var ins = $j(obj).val();
578         ins = ins.replace("&lt;","<");
579         ins = ins.replace("&gt;",">");
580         ins = ins.replace("&amp;","&");
581         ins = ins.replace("&quot;",'"');
582         $j("#comment-edit-text-" + id).val(tmpStr + ins);
583         $j(obj).val("");
584 }
585
586 function showHideComments(id) {
587         if( $j("#collapsed-comments-" + id).is(":visible")) {
588                 $j("#collapsed-comments-" + id).hide();
589                 $j("#hide-comments-" + id).html(window.showMore);
590         }
591         else {
592                 $j("#collapsed-comments-" + id).show();
593                 $j("#hide-comments-" + id).html(window.showFewer);
594         }
595 }
596
597
598
599 function enableOnUser(){
600         if (editor) return;
601         $j(this).val("");
602         initEditor();
603 }
604
605
606 var editor=false;
607 var textlen = 0;
608 var plaintext = window.editSelect;
609 var ispublic = window.isPublic;
610
611 function initEditor(cb){
612         if (editor==false){
613                 $j("#profile-jot-text-loading").show();
614                 if(plaintext == 'none') {
615                         $j("#profile-jot-text-loading").hide();
616                         $j("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
617                         $j("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
618                         editor = true;
619                         $j("a#jot-perms-icon").fancybox({
620                                 'transitionIn' : 'elastic',
621                                 'transitionOut' : 'elastic'
622                         });
623                         $j(".jothidden").show();
624                         if (typeof cb!="undefined") cb();
625                         return;
626                 }
627                 tinyMCE.init({
628                         theme : "advanced",
629                         mode : "specific_textareas",
630                         editor_selector: window.editSelect,
631                         auto_focus: "profile-jot-text",
632                         plugins : "bbcode,paste,autoresize, inlinepopups",
633                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
634                         theme_advanced_buttons2 : "",
635                         theme_advanced_buttons3 : "",
636                         theme_advanced_toolbar_location : "top",
637                         theme_advanced_toolbar_align : "center",
638                         theme_advanced_blockformats : "blockquote,code",
639                         gecko_spellcheck : true,
640                         paste_text_sticky : true,
641                         entity_encoding : "raw",
642                         add_unload_trigger : false,
643                         remove_linebreaks : false,
644                         force_p_newlines : false,
645                         force_br_newlines : true,
646                         forced_root_block : '',
647                         convert_urls: false,
648                         content_css: window.baseURL + "/view/custom_tinymce.css",
649                         theme_advanced_path : false,
650                         file_browser_callback : "fcFileBrowser",
651                         setup : function(ed) {
652                                 cPopup = null;
653                                 ed.onKeyDown.add(function(ed,e) {
654                                         if(cPopup !== null)
655                                                 cPopup.onkey(e);
656                                 });
657
658                                 ed.onKeyUp.add(function(ed, e) {
659                                         var txt = tinyMCE.activeEditor.getContent();
660                                         match = txt.match(/@([^ \n]+)$/);
661                                         if(match!==null) {
662                                                 if(cPopup === null) {
663                                                         cPopup = new ACPopup(this,baseurl+"/acl");
664                                                 }
665                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
666                                                 if(! cPopup.ready) cPopup = null;
667                                         }
668                                         else {
669                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
670                                         }
671
672                                         textlen = txt.length;
673                                         if(textlen != 0 && $j('#jot-perms-icon').is('.unlock')) {
674                                                 $j('#profile-jot-desc').html(ispublic);
675                                         }
676                                         else {
677                                                 $j('#profile-jot-desc').html('&nbsp;');
678                                         }        
679
680                                  //Character count
681
682                                         if(textlen <= 140) {
683                                                 $j('#character-counter').removeClass('red');
684                                                 $j('#character-counter').removeClass('orange');
685                                                 $j('#character-counter').addClass('grey');
686                                         }
687                                         if((textlen > 140) && (textlen <= 420)) {
688                                                 $j('#character-counter').removeClass('grey');
689                                                 $j('#character-counter').removeClass('red');
690                                                 $j('#character-counter').addClass('orange');
691                                         }
692                                         if(textlen > 420) {
693                                                 $j('#character-counter').removeClass('grey');
694                                                 $j('#character-counter').removeClass('orange');
695                                                 $j('#character-counter').addClass('red');
696                                         }
697                                         $j('#character-counter').text(textlen);
698                                 });
699
700                                 ed.onInit.add(function(ed) {
701                                         ed.pasteAsPlainText = true;
702                                         $j("#profile-jot-text-loading").hide();
703                                         $j(".jothidden").show();
704                                         if (typeof cb!="undefined") cb();
705                                 });
706
707                         }
708                 });
709                 editor = true;
710                 // setup acl popup
711                 $j("a#jot-perms-icon").fancybox({
712                         'transitionIn' : 'none',
713                         'transitionOut' : 'none'
714                 }); 
715         } else {
716                 if (typeof cb!="undefined") cb();
717         }
718 }
719
720
721 function msgInitEditor() {
722         if(plaintext != 'none') {
723                 tinyMCE.init({
724                         theme : "advanced",
725                         mode : "specific_textareas",
726                         editor_selector: /(profile-jot-text|prvmail-text)/,
727                         plugins : "bbcode,paste",
728                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
729                         theme_advanced_buttons2 : "",
730                         theme_advanced_buttons3 : "",
731                         theme_advanced_toolbar_location : "top",
732                         theme_advanced_toolbar_align : "center",
733                         theme_advanced_blockformats : "blockquote,code",
734                         gecko_spellcheck : true,
735                         paste_text_sticky : true,
736                         entity_encoding : "raw",
737                         add_unload_trigger : false,
738                         remove_linebreaks : false,
739                         force_p_newlines : false,
740                         force_br_newlines : true,
741                         forced_root_block : '',
742                         convert_urls: false,
743                         content_css: baseurl + "/view/custom_tinymce.css",
744                              //Character count
745                         theme_advanced_path : false,
746                         setup : function(ed) {
747                                 ed.onInit.add(function(ed) {
748                                         ed.pasteAsPlainText = true;
749                                         var editorId = ed.editorId;
750                                         var textarea = $j('#'+editorId);
751                                         if (typeof(textarea.attr('tabindex')) != "undefined") {
752                                                 $j('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
753                                                 textarea.attr('tabindex', null);
754                                         }
755                                 });
756                         }
757                 });
758         }
759         else
760                 $j("#prvmail-text").contact_autocomplete(baseurl+"/acl");
761 }
762
763
764 function profInitEditor() {
765         tinyMCE.init({
766                 theme : "advanced",
767                 mode : window.editSelect,
768                 plugins : "bbcode,paste",
769                 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
770                 theme_advanced_buttons2 : "",
771                 theme_advanced_buttons3 : "",
772                 theme_advanced_toolbar_location : "top",
773                 theme_advanced_toolbar_align : "center",
774                 theme_advanced_blockformats : "blockquote,code",
775                 gecko_spellcheck : true,
776                 paste_text_sticky : true,
777                 entity_encoding : "raw",
778                 add_unload_trigger : false,
779                 remove_linebreaks : false,
780                 force_p_newlines : false,
781                 force_br_newlines : true,
782                 forced_root_block : '',
783                 content_css: baseurl + "/view/custom_tinymce.css",
784                 theme_advanced_path : false,
785                 setup : function(ed) {
786                         ed.onInit.add(function(ed) {
787                         ed.pasteAsPlainText = true;
788                     });
789                 }
790
791         });
792 }
793
794 function eventInitEditor() {
795         tinyMCE.init({
796                 theme : "advanced",
797                 mode : "textareas",
798                 plugins : "bbcode,paste",
799                 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
800                 theme_advanced_buttons2 : "",
801                 theme_advanced_buttons3 : "",
802                 theme_advanced_toolbar_location : "top",
803                 theme_advanced_toolbar_align : "center",
804                 theme_advanced_blockformats : "blockquote,code",
805                 gecko_spellcheck : true,
806                 paste_text_sticky : true,
807                 entity_encoding : "raw",
808                 add_unload_trigger : false,
809                 remove_linebreaks : false,
810                 force_p_newlines : false,
811                 force_br_newlines : true,
812                 forced_root_block : '',
813                 content_css: baseurl + "/view/custom_tinymce.css",
814                 theme_advanced_path : false,
815                 setup : function(ed) {
816                         ed.onInit.add(function(ed) {
817                                 ed.pasteAsPlainText = true;
818                         });
819                 }
820
821         });
822 }
823
824 function contactInitEditor () {
825         tinyMCE.init({
826                 theme : "advanced",
827                 mode : window.editSelect,
828                 elements: "contact-edit-info",
829                 plugins : "bbcode",
830                 theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
831                 theme_advanced_buttons2 : "",
832                 theme_advanced_buttons3 : "",
833                 theme_advanced_toolbar_location : "top",
834                 theme_advanced_toolbar_align : "center",
835                 theme_advanced_styles : "blockquote,code",
836                 gecko_spellcheck : true,
837                 entity_encoding : "raw",
838                 add_unload_trigger : false,
839                 remove_linebreaks : false,
840                 force_p_newlines : false,
841                 force_br_newlines : true,
842                 forced_root_block : '',
843                 content_css: baseurl + "/view/custom_tinymce.css"
844
845
846         });
847 }
848
849 function wallInitEditor() {
850         var plaintext = window.editSelect;
851
852         if(plaintext != 'none') {
853                 tinyMCE.init({
854                         theme : "advanced",
855                         mode : "specific_textareas",
856                         editor_selector: /(profile-jot-text|prvmail-text)/,
857                         plugins : "bbcode,paste",
858                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
859                         theme_advanced_buttons2 : "",
860                         theme_advanced_buttons3 : "",
861                         theme_advanced_toolbar_location : "top",
862                         theme_advanced_toolbar_align : "center",
863                         theme_advanced_blockformats : "blockquote,code",
864                         gecko_spellcheck : true,
865                         paste_text_sticky : true,
866                         entity_encoding : "raw",
867                         add_unload_trigger : false,
868                         remove_linebreaks : false,
869                         force_p_newlines : false,
870                         force_br_newlines : true,
871                         forced_root_block : '',
872                         convert_urls: false,
873                         content_css: baseurl + "/view/custom_tinymce.css",
874                                  //Character count
875                         theme_advanced_path : false,
876                         setup : function(ed) {
877                                 ed.onInit.add(function(ed) {
878                                         ed.pasteAsPlainText = true;
879                                         var editorId = ed.editorId;
880                                         var textarea = $j('#'+editorId);
881                                         if (typeof(textarea.attr('tabindex')) != "undefined") {
882                                                 $j('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
883                                                 textarea.attr('tabindex', null);
884                                         }
885                                 });
886                         }
887                 });
888         }
889         else
890                 $j("#prvmail-text").contact_autocomplete(baseurl+"/acl");
891 }
892
893 function deleteCheckedItems() {
894         var checkedstr = '';
895
896         $j('.item-select').each( function() {
897                 if($j(this).is(':checked')) {
898                         if(checkedstr.length != 0) {
899                                 checkedstr = checkedstr + ',' + $j(this).val();
900                         }
901                         else {
902                                 checkedstr = $j(this).val();
903                         }
904                 }       
905         });
906         $j.post('item', { dropitems: checkedstr }, function(data) {
907                 window.location.reload();
908         });
909 }
910
911
912 function jotVideoURL() {
913         reply = prompt(window.vidURL);
914         if(reply && reply.length) {
915                 addeditortext('[video]' + reply + '[/video]');
916         }
917 }
918
919 function jotAudioURL() {
920         reply = prompt(window.audURL);
921         if(reply && reply.length) {
922                 addeditortext('[audio]' + reply + '[/audio]');
923         }
924 }
925
926
927 function jotGetLocation() {
928         reply = prompt(window.whereAreU, $j('#jot-location').val());
929         if(reply && reply.length) {
930                 $j('#jot-location').val(reply);
931         }
932 }
933
934 function jotShare(id) {
935         if ($j('#jot-popup').length != 0) $j('#jot-popup').show();
936
937         $j('#like-rotator-' + id).show();
938         $j.get('share/' + id, function(data) {
939                 if (!editor) $j("#profile-jot-text").val("");
940                 initEditor(function(){
941                         addeditortext(data);
942                         $j('#like-rotator-' + id).hide();
943                         $j(window).scrollTop(0);
944                 });
945
946         });
947 }
948
949 function linkdropper(event) {
950         var linkFound = event.dataTransfer.types.contains("text/uri-list");
951         if(linkFound)
952                 event.preventDefault();
953 }
954
955 function itemTag(id) {
956         reply = prompt(window.term);
957         if(reply && reply.length) {
958                 reply = reply.replace('#','');
959                 if(reply.length) {
960
961                         commentBusy = true;
962                         $j('body').css('cursor', 'wait');
963
964                         $j.get('tagger/' + id + '?term=' + reply, NavUpdate);
965                         /*if(timer) clearTimeout(timer);
966                         timer = setTimeout(NavUpdate,3000);*/
967                         liking = 1;
968                 }
969         }
970 }
971
972 function itemFiler(id) {
973         
974         var bordercolor = $j("input").css("border-color");
975         
976         $j.get('filer/', function(data){
977                 $j.fancybox(data);
978                 $j("#id_term").keypress(function(){
979                         $j(this).css("border-color",bordercolor);
980                 })
981                 $j("#select_term").change(function(){
982                         $j("#id_term").css("border-color",bordercolor);
983                 })
984                 
985                 $j("#filer_save").click(function(e){
986                         e.preventDefault();
987                         reply = $j("#id_term").val();
988                         if(reply && reply.length) {
989                                 commentBusy = true;
990                                 $j('body').css('cursor', 'wait');
991                                 $j.get('filer/' + id + '?term=' + reply, NavUpdate);
992 /*                                      if(timer) clearTimeout(timer);
993                                 timer = setTimeout(NavUpdate,3000);*/
994                                 liking = 1;
995                                 $j.fancybox.close();
996                         } else {
997                                 $j("#id_term").css("border-color","#FF0000");
998                         }
999                         return false;
1000                 });
1001         });
1002         
1003 }
1004
1005 function jotClearLocation() {
1006         $j('#jot-coord').val('');
1007         $j('#profile-nolocation-wrapper').hide();
1008 }
1009
1010 function addeditortext(data) {
1011         if(plaintext == 'none') {
1012                 var currentText = $j("#profile-jot-text").val();
1013                 $j("#profile-jot-text").val(currentText + data);
1014         }
1015         else
1016                 tinyMCE.execCommand('mceInsertRawHTML',false,data);
1017 }
1018
1019 if(typeof window.geoTag === 'function') window.geoTag();
1020
1021