Исправляем косяки со вставкой bbcode из popup-a
Добавил: Amro   Дата: 23.11.2011 00:01

Итак, для многих уже не секрет, что Textboxer в Seditio работает не так как нужно, к примеру не работает нормальная вставка bbcode из popup окна, точнее она работает, но bbcodы не вставляются в позицию курсора текстового контейнера, а вставляются просто в его конец.

Это похабное дело мы и будем исправлять ниже. Править придется всего два файла, а именно pfs.inc.php и конечно же tb2.js

Начнем с последнего tb2.js, приводить его весь здесь смысла не имеет, скажу тока что изменил: 1) перевел функцию wrap (да да ту самую котораю отвечает за вставку в textarea bbcodов) в раздел глобальных и 2) обозвал её wrap_textboxer (это для того чтобы глядишь где-нибуть это название с чем-то не пересеклось). Скачать можно непосредственно с этого сайта tb2.js

Далее правим pfs.inc.php:

заменяем:

Код:
$morejavascript = "
function addthumb(thmb, image, c1,c2)
  { opener.document.".$c1.".".$c2.".value += '[thumb='+thmb+']'+image+'[/thumb]'; }
function addpix(gfile,c1,c2)
  { opener.document.".$c1.".".$c2.".value += '[img]'+gfile+'[/img]'; }
  ";

на:

Код:
$morejavascript = "
function addthumb(thmb, image, c1,c2)
  { window.opener.textboxer_wrap('','[thumb='+thmb+']'+image+'[/thumb]','',2,'".$c2."');   
    /* opener.document.".$c1.".".$c2.".value += '[thumb='+thmb+']'+image+'[/thumb]'; */ } 
function addpix(gfile,c1,c2)
  { window.opener.textboxer_wrap('','[img]'+gfile+'[/img]','',2,'".$c2."');  
    /* opener.document.".$c1.".".$c2.".value += '[img]'+gfile+'[/img]'; */ }
  ";

и

Код:
$pfs_header1 = $cfg['doctype']."<html><head>
<title>".$cfg['maintitle']."</title>".sed_htmlmetas()."
<script type=\"text/javascript\">
<!--
function help(rcode,c1,c2)
  { window.open('plug.php?h='+rcode+'&c1='+c1+'&c2='+c2,'Help','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=512,top=16'); }
function addthumb(thmb, image, c1,c2)
  { opener.document.".$c1.".".$c2.".value += '[thumb='+thmb+']'+image+'[/thumb]'; }
function addpix(gfile,c1,c2)
  { opener.document.".$c1.".".$c2.".value += '[img]'+gfile+'[/img]'; }
function addfile(gfile,c1,c2)
  { opener.document.".$c1.".".$c2.".value += '[pfs]".$cfg['rel_dir_user']."'+gfile+'[/pfs]'; }
function addglink(id,c1,c2)
  { opener.document.".$c1.".".$c2.".value += '[gallery='+id+']".$L["pfs_gallery"]." #'+id+'[/gallery]'; }
function comments(rcode)
  { window.open('comments.php?id='+rcode,'Comments','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=576,top=64'); }
function picture(url,sx,sy)
  { window.open('pfs.php?m=view&id='+url,'Picture','toolbar=0,location=0,directories=0,menuBar=0,resizable=1,scrollbars=yes,width='+sx+',height='+sy+',left=0,top=0'); }
function ratings(rcode)
  { window.open('ratings.php?id='+rcode,'Ratings','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=16,top=16'); }
//-->
</script>
";

на

Код:
$pfs_header1 = $cfg['doctype']."<html><head>
<title>".$cfg['maintitle']."</title>".sed_htmlmetas()."
<script type=\"text/javascript\">
<!--
function help(rcode,c1,c2)
  { window.open('plug.php?h='+rcode+'&c1='+c1+'&c2='+c2,'Help','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=512,top=16'); }
function addthumb(thmb, image, c1,c2)
  { window.opener.textboxer_wrap('','[thumb='+thmb+']'+image+'[/thumb]','',2,'".$c2."');  
    /* opener.document.".$c1.".".$c2.".value += '[thumb='+thmb+']'+image+'[/thumb]'; */ }
function addpix(gfile,c1,c2)
  { window.opener.textboxer_wrap('','[img]'+gfile+'[/img]','',2,'".$c2."');  
    /* opener.document.".$c1.".".$c2.".value += '[img]'+gfile+'[/img]'; */ }
function addfile(gfile,c1,c2)
  { window.opener.textboxer_wrap('','[pfs]".$cfg['rel_dir_user']."'+gfile+'[/pfs]','',2,'".$c2."');
    /* opener.document.".$c1.".".$c2.".value += '[pfs]".$cfg['rel_dir_user']."'+gfile+'[/pfs]'; */ }
function addglink(id,c1,c2)
  { window.opener.textboxer_wrap('','[gallery='+id+']".$L["pfs_gallery"]." #'+id+'[/gallery]','',2,'".$c2."');   
    /* opener.document.".$c1.".".$c2.".value += '[gallery='+id+']".$L["pfs_gallery"]." #'+id+'[/gallery]'; */ }
function comments(rcode)
  { window.open('comments.php?id='+rcode,'Comments','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=576,top=64'); }
function picture(url,sx,sy)
  { window.open('pfs.php?m=view&id='+url,'Picture','toolbar=0,location=0,directories=0,menuBar=0,resizable=1,scrollbars=yes,width='+sx+',height='+sy+',left=0,top=0'); }
function ratings(rcode)
  { window.open('ratings.php?id='+rcode,'Ratings','toolbar=0,location=0,directories=0,menuBar=0,resizable=0,scrollbars=yes,width=480,height=512,left=16,top=16'); }
//-->
</script>
";

старые обращения как видите я просто комментнул, если не нужны можно убрать /* — */
Вот и все! теперь наш textboxer будет вставлят картинки из PFS туда куда нужно, туда где установлен курсор: )

P.S. не забываем обновить кэш браузера, а то мало ли чего!

comments powered by HyperComments