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