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