Merge remote branch 'friendica/master'
[friendica.git/.git] / view / theme / frost-mobile / js / theme.js
1 $j(document).ready(function() {
2
3         /* enable tinymce on focus and click */
4         $j("#profile-jot-text").focus(enableOnUser);
5         $j("#profile-jot-text").click(enableOnUser);
6
7         if(typeof window.AjaxUpload != "undefined") {
8                 switch(window.ajaxType) {
9                         case 'jot-header':
10                                 var uploader = new window.AjaxUpload(
11                                         'wall-image-upload',
12                                         { action: 'wall_upload/'+window.nickname+'?nomce=1',
13                                                 name: 'userfile',
14                                                 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
15                                                 onComplete: function(file,response) {
16                                                         addeditortext(response);
17                                                         $j('#profile-rotator').hide();
18                                                 }                                
19                                         }
20                                 );
21
22                                 var file_uploader = new window.AjaxUpload(
23                                         'wall-file-upload',
24                                         { action: 'wall_attach/'+window.nickname+'?nomce=1',
25                                                 name: 'userfile',
26                                                 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
27                                                 onComplete: function(file,response) {
28                                                         addeditortext(response);
29                                                         $j('#profile-rotator').hide();
30                                                 }                                
31                                         }
32                                 );
33                                 break;
34                         case 'msg-header':
35                                 var uploader = new window.AjaxUpload(
36                                         'prvmail-upload',
37                                         { action: 'wall_upload/'+window.nickname+'?nomce=1',
38                                                 name: 'userfile',
39                                                 onSubmit: function(file,ext) { $j('#profile-rotator').show(); },
40                                                 onComplete: function(file,response) {
41                                                         tinyMCE.execCommand('mceInsertRawHTML',false,response);
42                                                         $j('#profile-rotator').hide();
43                                                 }                                
44                                         }
45                                 );
46                                 break;
47                         default:
48                                 break;
49                 }
50         }
51
52         if(typeof window.aclInit !="undefined" && typeof acl=="undefined"){
53                 acl = new ACL(
54                         baseurl+"/acl",
55                         [ window.allowCID,window.allowGID,window.denyCID,window.denyGID ]
56                 );
57         }
58
59 /*$j('html').click(function() { $j("#nav-notifications-menu" ).hide(); });*/
60
61         /*$j('.group-edit-icon').hover(
62                 function() {
63                         $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
64                 function() {
65                         $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
66         );
67
68         $j('.sidebar-group-element').hover(
69                 function() {
70                         id = $j(this).attr('id');
71                         $j('#edit-' + id).addClass('icon'); $j('#edit-' + id).removeClass('iconspacer');},
72
73                 function() {
74                         id = $j(this).attr('id');
75                         $j('#edit-' + id).removeClass('icon');$j('#edit-' + id).addClass('iconspacer');}
76         );
77
78
79         $j('.savedsearchdrop').hover(
80                 function() {
81                         $j(this).addClass('drop'); $j(this).addClass('icon'); $j(this).removeClass('iconspacer');},
82                 function() {
83                         $j(this).removeClass('drop'); $j(this).removeClass('icon'); $j(this).addClass('iconspacer');}
84         );
85
86         $j('.savedsearchterm').hover(
87                 function() {
88                         id = $j(this).attr('id');
89                         $j('#drop-' + id).addClass('icon');     $j('#drop-' + id).addClass('drophide'); $j('#drop-' + id).removeClass('iconspacer');},
90
91                 function() {
92                         id = $j(this).attr('id');
93                         $j('#drop-' + id).removeClass('icon');$j('#drop-' + id).removeClass('drophide'); $j('#drop-' + id).addClass('iconspacer');}
94         );*/
95
96         if(window.autoCompleteType == "display-head") {
97                 //$j(".comment-edit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
98                 // make auto-complete work in more places
99                 //$j(".wall-item-comment-wrapper textarea").contact_autocomplete(baseurl+"/acl");
100                 $j(".comment-wwedit-wrapper textarea").contact_autocomplete(baseurl+"/acl");
101         }
102
103         if(window.aclType == "event_head") {
104                 $j('#events-calendar').fullCalendar({
105                         events: baseurl + '/events/json/',
106                         header: {
107                                 left: 'prev,next today',
108                                 center: 'title',
109                                 right: 'month,agendaWeek,agendaDay'
110                         },                      
111                         timeFormat: 'H(:mm)',
112                         eventClick: function(calEvent, jsEvent, view) {
113                                 showEvent(calEvent.id);
114                         },
115                         
116                         eventRender: function(event, element, view) {
117                                 //console.log(view.name);
118                                 if (event.item['author-name']==null) return;
119                                 switch(view.name){
120                                         case "month":
121                                         element.find(".fc-event-title").html(
122                                                 "<img src='{0}' style='height:10px;width:10px'>{1} : {2}".format(
123                                                         event.item['author-avatar'],
124                                                         event.item['author-name'],
125                                                         event.title
126                                         ));
127                                         break;
128                                         case "agendaWeek":
129                                         element.find(".fc-event-title").html(
130                                                 "<img src='{0}' style='height:12px; width:12px'>{1}<p>{2}</p><p>{3}</p>".format(
131                                                         event.item['author-avatar'],
132                                                         event.item['author-name'],
133                                                         event.item.desc,
134                                                         event.item.location
135                                         ));
136                                         break;
137                                         case "agendaDay":
138                                         element.find(".fc-event-title").html(
139                                                 "<img src='{0}' style='height:24px;width:24px'>{1}<p>{2}</p><p>{3}</p>".format(
140                                                         event.item['author-avatar'],
141                                                         event.item['author-name'],
142                                                         event.item.desc,
143                                                         event.item.location
144                                         ));
145                                         break;
146                                 }
147                         }
148                         
149                 });
150                 
151                 // center on date
152                 var args=location.href.replace(baseurl,"").split("/");
153                 if (args.length>=4) {
154                         $j("#events-calendar").fullCalendar('gotoDate',args[2] , args[3]-1);
155                 } 
156                 
157                 // show event popup
158                 var hash = location.hash.split("-")
159                 if (hash.length==2 && hash[0]=="#link") showEvent(hash[1]);
160         }       
161
162         if(window.aclType == "settings-head" || window.aclType == "photos_head" || window.aclType == "event_head") {
163                 $j('#contact_allow, #contact_deny, #group_allow, #group_deny').change(function() {
164                         var selstr;
165                         $j('#contact_allow option:selected, #contact_deny option:selected, #group_allow option:selected, #group_deny option:selected').each( function() {
166                                 selstr = $j(this).text();
167                                 $j('#jot-perms-icon').removeClass('unlock').addClass('lock');
168                                 $j('#jot-public').hide();
169                         });
170                         if(selstr == null) { 
171                                 $j('#jot-perms-icon').removeClass('lock').addClass('unlock');
172                                 $j('#jot-public').show();
173                         }
174
175                 }).trigger('change');
176         }
177
178         switch(window.autocompleteType) {
179                 case 'msg-header':
180                         var a = $j("#recip").autocomplete({ 
181                                 serviceUrl: baseurl + '/acl',
182                                 minChars: 2,
183                                 width: 350,
184                                 onSelect: function(value,data) {
185                                         $j("#recip-complete").val(data);
186                                 }                       
187                         });
188                         break;
189                 case 'contacts-head':
190                         var a = $j("#contacts-search").autocomplete({ 
191                                 serviceUrl: baseurl + '/acl',
192                                 minChars: 2,
193                                 width: 350,
194                         });
195                         a.setOptions({ params: { type: 'a' }});
196                         break;
197                 default:
198                         break;
199         }
200
201
202         $j('#event-share-checkbox').change(function() {
203
204                 if ($j('#event-share-checkbox').is(':checked')) { 
205                         $j('#acl-wrapper').show();
206                 }
207                 else {
208                         $j('#acl-wrapper').hide();
209                 }
210         }).trigger('change');
211
212
213         $j(".popupbox").click(function () {
214                 var parent = $j( $j(this).attr('href') ).parent();
215                 if (parent.css('display') == 'none') {
216                         parent.show();
217                 } else {
218                         parent.hide();
219                 }
220                 return false;
221         });
222
223 });
224
225 // update pending count //
226 $j(function(){
227
228         $j("nav").bind('nav-update',  function(e,data){
229                 var elm = $j('#pending-update');
230                 var register = $j(data).find('register').text();
231                 if (register=="0") { register=""; elm.hide();} else { elm.show(); }
232                 elm.html(register);
233         });
234 });
235
236
237
238 function homeRedirect() {
239         $j('html').fadeOut('slow', function(){
240                 window.location = baseurl + "/login";
241         });
242 }
243
244
245 function insertFormatting(comment,BBcode,id) {
246         
247         var tmpStr = $j("#comment-edit-text-" + id).val();
248         if(tmpStr == comment) {
249                 tmpStr = "";
250                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
251                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
252                 openMenu("comment-edit-submit-wrapper-" + id);
253                 $j("#comment-edit-text-" + id).val(tmpStr);
254         }
255
256         textarea = document.getElementById("comment-edit-text-" +id);
257         if (document.selection) {
258                 textarea.focus();
259                 selected = document.selection.createRange();
260                 if (BBcode == "url"){
261                         selected.text = "["+BBcode+"=http://]" +  selected.text + "[/"+BBcode+"]";
262                         } else                  
263                 selected.text = "["+BBcode+"]" + selected.text + "[/"+BBcode+"]";
264         } else if (textarea.selectionStart || textarea.selectionStart == "0") {
265                 var start = textarea.selectionStart;
266                 var end = textarea.selectionEnd;
267                 if (BBcode == "url"){
268                         textarea.value = textarea.value.substring(0, start) + "["+BBcode+"=http://]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
269                         } else
270                 textarea.value = textarea.value.substring(0, start) + "["+BBcode+"]" + textarea.value.substring(start, end) + "[/"+BBcode+"]" + textarea.value.substring(end, textarea.value.length);
271         }
272         return true;
273 }
274
275 function cmtBbOpen(id) {
276         $j(".comment-edit-bb-" + id).show();
277 }
278 function cmtBbClose(id) {
279         $j(".comment-edit-bb-" + id).hide();
280 }
281
282
283
284
285 var editor=false;
286 var textlen = 0;
287 var plaintext = 'none';//window.editSelect;
288         var ispublic = window.isPublic;
289
290 function initEditor(cb){
291         if (editor==false){
292 //              $j("#profile-jot-text-loading").show();
293                 if(plaintext == 'none') {
294 //                      $j("#profile-jot-text-loading").hide();
295                         $j("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
296                         $j("#profile-jot-text").contact_autocomplete(baseurl+"/acl");
297                         editor = true;
298 /*                      $j("a#jot-perms-icon").fancybox({
299                                 'transitionIn' : 'none',
300                                 'transitionOut' : 'none'
301                         });*/
302                         $j("a#jot-perms-icon, a#settings-default-perms-menu").click(function () {
303                                 var parent = $j("#profile-jot-acl-wrapper").parent();
304                                 if (parent.css('display') == 'none') {
305                                         parent.show();
306                                 } else {
307                                         parent.hide();
308                                 }
309 //                              $j("#profile-jot-acl-wrapper").parent().toggle();
310                                 return false;
311                         });
312                         $j(".jothidden").show();
313                         if (typeof cb!="undefined") cb();
314                         return;
315                 }       
316 /*              tinyMCE.init({
317                         theme : "advanced",
318                         mode : "specific_textareas",
319                         editor_selector: window.editSelect,
320                         auto_focus: "profile-jot-text",
321                         plugins : "bbcode,paste,autoresize, inlinepopups",
322                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor,formatselect,code",
323                         theme_advanced_buttons2 : "",
324                         theme_advanced_buttons3 : "",
325                         theme_advanced_toolbar_location : "top",
326                         theme_advanced_toolbar_align : "center",
327                         theme_advanced_blockformats : "blockquote,code",
328                         gecko_spellcheck : true,
329                         paste_text_sticky : true,
330                         entity_encoding : "raw",
331                         add_unload_trigger : false,
332                         remove_linebreaks : false,
333                         //force_p_newlines : false,
334                         //force_br_newlines : true,
335                         forced_root_block : 'div',
336                         convert_urls: false,
337                         content_css: "$baseurl/view/custom_tinymce.css",
338                         theme_advanced_path : false,
339                         file_browser_callback : "fcFileBrowser",
340                         setup : function(ed) {
341                                 cPopup = null;
342                                 ed.onKeyDown.add(function(ed,e) {
343                                         if(cPopup !== null)
344                                                 cPopup.onkey(e);
345                                 });
346
347                                 ed.onKeyUp.add(function(ed, e) {
348                                         var txt = tinyMCE.activeEditor.getContent();
349                                         match = txt.match(/@([^ \n]+)$/);
350                                         if(match!==null) {
351                                                 if(cPopup === null) {
352                                                         cPopup = new ACPopup(this,baseurl+"/acl");
353                                                 }
354                                                 if(cPopup.ready && match[1]!==cPopup.searchText) cPopup.search(match[1]);
355                                                 if(! cPopup.ready) cPopup = null;
356                                         }
357                                         else {
358                                                 if(cPopup !== null) { cPopup.close(); cPopup = null; }
359                                         }
360
361                                         textlen = txt.length;
362                                         if(textlen != 0 && $j('#jot-perms-icon').is('.unlock')) {
363                                                 $j('#profile-jot-desc').html(ispublic);
364                                         }
365                                         else {
366                                                 $j('#profile-jot-desc').html('&nbsp;');
367                                         }        
368
369                                  //Character count
370
371                                         if(textlen <= 140) {
372                                                 $j('#character-counter').removeClass('red');
373                                                 $j('#character-counter').removeClass('orange');
374                                                 $j('#character-counter').addClass('grey');
375                                         }
376                                         if((textlen > 140) && (textlen <= 420)) {
377                                                 $j('#character-counter').removeClass('grey');
378                                                 $j('#character-counter').removeClass('red');
379                                                 $j('#character-counter').addClass('orange');
380                                         }
381                                         if(textlen > 420) {
382                                                 $j('#character-counter').removeClass('grey');
383                                                 $j('#character-counter').removeClass('orange');
384                                                 $j('#character-counter').addClass('red');
385                                         }
386                                         $j('#character-counter').text(textlen);
387                                 });
388
389                                 ed.onInit.add(function(ed) {
390                                         ed.pasteAsPlainText = true;
391                                         $j("#profile-jot-text-loading").hide();
392                                         $j(".jothidden").show();
393                                         if (typeof cb!="undefined") cb();
394                                 });
395
396                         }
397                 });
398                 editor = true;
399                 // setup acl popup
400                 $j("a#jot-perms-icon").fancybox({
401                         'transitionIn' : 'elastic',
402                         'transitionOut' : 'elastic'
403                 }); */
404         } else {
405                 if (typeof cb!="undefined") cb();
406         }
407 }
408
409 function enableOnUser(){
410         if (editor) return;
411         $j(this).val("");
412         initEditor();
413 }
414
415 function wallInitEditor() {
416         var plaintext = window.editSelect;
417
418         if(plaintext != 'none') {
419                 tinyMCE.init({
420                         theme : "advanced",
421                         mode : "specific_textareas",
422                         editor_selector: /(profile-jot-text|prvmail-text)/,
423                         plugins : "bbcode,paste",
424                         theme_advanced_buttons1 : "bold,italic,underline,undo,redo,link,unlink,image,forecolor",
425                         theme_advanced_buttons2 : "",
426                         theme_advanced_buttons3 : "",
427                         theme_advanced_toolbar_location : "top",
428                         theme_advanced_toolbar_align : "center",
429                         theme_advanced_blockformats : "blockquote,code",
430                         gecko_spellcheck : true,
431                         paste_text_sticky : true,
432                         entity_encoding : "raw",
433                         add_unload_trigger : false,
434                         remove_linebreaks : false,
435                         //force_p_newlines : false,
436                         //force_br_newlines : true,
437                         forced_root_block : 'div',
438                         convert_urls: false,
439                         content_css: baseurl + "/view/custom_tinymce.css",
440                                  //Character count
441                         theme_advanced_path : false,
442                         setup : function(ed) {
443                                 ed.onInit.add(function(ed) {
444                                         ed.pasteAsPlainText = true;
445                                         var editorId = ed.editorId;
446                                         var textarea = $j('#'+editorId);
447                                         if (typeof(textarea.attr('tabindex')) != "undefined") {
448                                                 $j('#'+editorId+'_ifr').attr('tabindex', textarea.attr('tabindex'));
449                                                 textarea.attr('tabindex', null);
450                                         }
451                                 });
452                         }
453                 });
454         }
455         else
456                 $j("#prvmail-text").contact_autocomplete(baseurl+"/acl");
457 }
458
459
460
461
462 function initCrop() {
463         function onEndCrop( coords, dimensions ) {
464                 $( 'x1' ).value = coords.x1;
465                 $( 'y1' ).value = coords.y1;
466                 $( 'x2' ).value = coords.x2;
467                 $( 'y2' ).value = coords.y2;
468                 $( 'width' ).value = dimensions.width;
469                 $( 'height' ).value = dimensions.height;
470         }
471
472         Event.observe( window, 'load', function() {
473                 new Cropper.ImgWithPreview(
474                 'croppa',
475                 {
476                         previewWrap: 'previewWrap',
477                         minWidth: 175,
478                         minHeight: 175,
479                         maxWidth: 640,
480                         maxHeight: 640,
481                         ratioDim: { x: 100, y:100 },
482                         displayOnInit: true,
483                         onEndCrop: onEndCrop
484                 });
485         });
486 }
487
488
489 function confirmDelete() { return confirm(window.delItem); }
490 function commentOpen(obj,id) {
491         if(obj.value == window.commentEmptyText) {
492                 obj.value = "";
493                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
494                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
495                 $j("#mod-cmnt-wrap-" + id).show();
496                 openMenu("comment-edit-submit-wrapper-" + id);
497         }
498 }
499 function commentClose(obj,id) {
500         if(obj.value == "") {
501                 obj.value = window.commentEmptyText;
502                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-full");
503                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-empty");
504                 $j("#mod-cmnt-wrap-" + id).hide();
505                 closeMenu("comment-edit-submit-wrapper-" + id);
506         }
507 }
508
509
510 function commentInsert(obj,id) {
511         var tmpStr = $j("#comment-edit-text-" + id).val();
512         if(tmpStr == window.commentEmptyText) {
513                 tmpStr = "";
514                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
515                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
516                 openMenu("comment-edit-submit-wrapper-" + id);
517         }
518         var ins = $j(obj).html();
519         ins = ins.replace("&lt;","<");
520         ins = ins.replace("&gt;",">");
521         ins = ins.replace("&amp;","&");
522         ins = ins.replace("&quot;",'"');
523         $j("#comment-edit-text-" + id).val(tmpStr + ins);
524 }
525
526 function qCommentInsert(obj,id) {
527         var tmpStr = $j("#comment-edit-text-" + id).val();
528         if(tmpStr == window.commentEmptyText) {
529                 tmpStr = "";
530                 $j("#comment-edit-text-" + id).addClass("comment-edit-text-full");
531                 $j("#comment-edit-text-" + id).removeClass("comment-edit-text-empty");
532                 openMenu("comment-edit-submit-wrapper-" + id);
533         }
534         var ins = $j(obj).val();
535         ins = ins.replace("&lt;","<");
536         ins = ins.replace("&gt;",">");
537         ins = ins.replace("&amp;","&");
538         ins = ins.replace("&quot;",'"');
539         $j("#comment-edit-text-" + id).val(tmpStr + ins);
540         $j(obj).val("");
541 }
542
543 /*function showHideCommentBox(id) {
544         if( $j('#comment-edit-form-' + id).is(':visible')) {
545                 $j('#comment-edit-form-' + id).hide();
546         }
547         else {
548                 $j('#comment-edit-form-' + id).show();
549         }
550 }*/
551
552
553 /*function deleteCheckedItems() {
554         var checkedstr = '';
555
556         $j('.item-select').each( function() {
557                 if($j(this).is(':checked')) {
558                         if(checkedstr.length != 0) {
559                                 checkedstr = checkedstr + ',' + $j(this).val();
560                         }
561                         else {
562                                 checkedstr = $j(this).val();
563                         }
564                 }       
565         });
566         $j.post('item', { dropitems: checkedstr }, function(data) {
567                 window.location.reload();
568         });
569 }*/
570
571 function jotVideoURL() {
572         reply = prompt(window.vidURL);
573         if(reply && reply.length) {
574                 addeditortext('[video]' + reply + '[/video]');
575         }
576 }
577
578 function jotAudioURL() {
579         reply = prompt(window.audURL);
580         if(reply && reply.length) {
581                 addeditortext('[audio]' + reply + '[/audio]');
582         }
583 }
584
585
586 function jotGetLocation() {
587         reply = prompt(window.whereAreU, $j('#jot-location').val());
588         if(reply && reply.length) {
589                 $j('#jot-location').val(reply);
590         }
591 }
592
593 function jotShare(id) {
594         if ($j('#jot-popup').length != 0) $j('#jot-popup').show();
595
596         $j('#like-rotator-' + id).show();
597         $j.get('share/' + id, function(data) {
598                 if (!editor) $j("#profile-jot-text").val("");
599                 initEditor(function(){
600                         addeditortext(data);
601                         $j('#like-rotator-' + id).hide();
602                         $j(window).scrollTop(0);
603                 });
604
605         });
606 }
607
608 function linkdropper(event) {
609         var linkFound = event.dataTransfer.types.contains("text/uri-list");
610         if(linkFound)
611                 event.preventDefault();
612 }
613
614 switch(window.ajaxType) {
615         case 'jot-header':
616                 function jotGetLink() {
617                         reply = prompt(window.linkURL);
618                         if(reply && reply.length) {
619                                 reply = bin2hex(reply);
620                                 $j('#profile-rotator').show();
621                                 $j.get('parse_url?binurl=' + reply, function(data) {
622                                         addeditortext(data);
623                                         $j('#profile-rotator').hide();
624                                 });
625                         }
626                 }
627
628                 function linkdrop(event) {
629                         var reply = event.dataTransfer.getData("text/uri-list");
630                         event.target.textContent = reply;
631                         event.preventDefault();
632                         if(reply && reply.length) {
633                                 reply = bin2hex(reply);
634                                 $j('#profile-rotator').show();
635                                 $j.get('parse_url?binurl=' + reply, function(data) {
636                                         if (!editor) $j("#profile-jot-text").val("");
637                                         initEditor(function(){
638                                                 addeditortext(data);
639                                                 $j('#profile-rotator').hide();
640                                         });
641                                 });
642                         }
643                 }
644                 break;
645         case 'msg-header':
646         case 'wallmsg-header':
647 // TINYMCE -- BAD
648                 function jotGetLink() {
649                         reply = prompt(window.linkURL);
650                         if(reply && reply.length) {
651                                 $j('#profile-rotator').show();
652                                 $j.get('parse_url?url=' + reply, function(data) {
653                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
654                                         $j('#profile-rotator').hide();
655                                 });
656                         }
657                 }
658
659                 function linkdrop(event) {
660                         var reply = event.dataTransfer.getData("text/uri-list");
661                         event.target.textContent = reply;
662                         event.preventDefault();
663                         if(reply && reply.length) {
664                                 $j('#profile-rotator').show();
665                                 $j.get('parse_url?url=' + reply, function(data) {
666                                         tinyMCE.execCommand('mceInsertRawHTML',false,data);
667                                         $j('#profile-rotator').hide();
668                                 });
669                         }
670                 }
671
672                 break;
673         default:
674                 break;
675 }
676
677 function showEvent(eventid) {
678 /*      $j.get(
679                 baseurl + '/events/?id='+eventid,
680                 function(data){
681                         $j.fancybox(data);
682                 }
683         );*/                    
684 }
685
686
687 function itemTag(id) {
688         reply = prompt(window.term);
689         if(reply && reply.length) {
690                 reply = reply.replace('#','');
691                 if(reply.length) {
692
693                         commentBusy = true;
694                         $j('body').css('cursor', 'wait');
695
696                         $j.get('tagger/' + id + '?term=' + reply, NavUpdate);
697                         /*if(timer) clearTimeout(timer);
698                         timer = setTimeout(NavUpdate,3000);*/
699                         liking = 1;
700                 }
701         }
702 }
703
704 function itemFiler(id) {
705         
706         $j.get('filer/', function(data){
707
708                 var promptText = $j('#id_term_label', data).text();
709
710                 reply = prompt(promptText);
711                 if(reply && reply.length) {
712                         commentBusy = true;
713                         $j('body').css('cursor', 'wait');
714                         $j.get('filer/' + id + '?term=' + reply, NavUpdate);
715 /*                              if(timer) clearTimeout(timer);
716                         timer = setTimeout(NavUpdate,3000);*/
717                         liking = 1;
718 /*                              $j.fancybox.close();*/
719                 }
720         });
721
722 /*              var bordercolor = $j("input").css("border-color");
723         
724         $j.get('filer/', function(data){
725                 $j.fancybox(data);
726                 $j("#id_term").keypress(function(){
727                         $j(this).css("border-color",bordercolor);
728                 })
729                 $j("#select_term").change(function(){
730                         $j("#id_term").css("border-color",bordercolor);
731                 })
732                 
733                 $j("#filer_save").click(function(e){
734                         e.preventDefault();
735                         reply = $j("#id_term").val();
736                         if(reply && reply.length) {
737                                 commentBusy = true;
738                                 $j('body').css('cursor', 'wait');
739                                 $j.get('filer/' + id + '?term=' + reply);
740                                 if(timer) clearTimeout(timer);
741                                 timer = setTimeout(NavUpdate,3000);
742                                 liking = 1;
743                                 $j.fancybox.close();
744                         } else {
745                                 $j("#id_term").css("border-color","#FF0000");
746                         }
747                         return false;
748                 });
749         });
750 */              
751 }
752
753 function jotClearLocation() {
754         $j('#jot-coord').val('');
755         $j('#profile-nolocation-wrapper').hide();
756 }
757
758 function addeditortext(data) {
759         if(plaintext == 'none') {
760                 var currentText = $j("#profile-jot-text").val();
761                 $j("#profile-jot-text").val(currentText + data);
762         }
763         /*else
764                 tinyMCE.execCommand('mceInsertRawHTML',false,data);*/
765 }
766
767 if(typeof window.geoTag === 'function') window.geoTag();
768
769