|
|
Модератор форума: Yuri_G |
Сообщество uCoz » Вебмастеру » Общие вопросы от вебмастеров » Всплывающая кнопка Цитировать на форуме (Как это сделать и отладить?) |
Всплывающая кнопка Цитировать на форуме |
У нас на форуме ( http://elitegamersteam.my1.ru/forum/ ) есть специфика объёмных текстов, и очень непрактично мотать мышкой или слайдером туда-сюда, когда собираешь цитаты.
Как-то мне попалось на форумах других систем вот такое решение: ![]() ![]() ![]() Я пыталась просить помощи в теме на сервисе Вопросах по Ukoz . Предложили вот такой код в "Форум" -> "Вид материалов" в самый низ страницы кодов: Код <a href="javascript:Insert('$ID$','$USERNAME$',selection);" onmouseover="get_selection()" class="postQuote$ID$"> <img alt="" style="margin:0;padding:0;border:0;" src="/.s/img/fr/bt/2/p_quote.gif" title="Цитировать"> </a> <script> var getSelectedText = function() { var text = ''; if (window.getSelection) { text = window.getSelection().toString(); } else if (document.selection) { text = document.selection.createRange().text; } return text; } $('#ucoz-forum-post-$ID$').on('mouseup', function(e){ var text = getSelectedText(); if (text != '') {$('.postQuote$ID$').css({'display':'block', 'left':e.pageX-120+'px', 'top':e.pageY-220+'px'});} }); $('.posttdMessage').on('click', function(){$('.postQuote$ID$').hide();}); </script> <style> .postQuote$ID$ { position:absolute; display:none; cursor: pointer; } </style> Но у меня на ресурсе кнопка не отображается, ни у меня, ни у пользователей. Вот сама кнопка: Код <a href="javascript:Insert('$ID$','$USERNAME$',selection);" onmouseover="get_selection()" class="postQuote$ID$"> <img alt="" style="margin:0;padding:0;border:0;" src="http://elitegamersteam.my1.ru/b_Red_Glass/p_quote.gif" title="Цитировать"> </a> Помогите настроить код для корректного отображения. Где что ни так? |
KS_Brook, есть такой вариант: http://vacionlib.ucoz.ru/forum/18-162-1
http://vacionlib.ucoz.ru/support/aquotator.js |
KS_Brook, есть такой вариант: http://vacionlib.ucoz.ru/forum/18-162-1 http://vacionlib.ucoz.ru/support/aquotator.js Код /* AutoQuotator - скрипт на языке JavaScript для форумов системы uCoz Copyright © VACion, 2009 Автор скрипта - VACion, ICQ#: 6-343-207, e-mail: vacion(at)li.ru. Подробная информация: http://vacionlib.org.ru/forum/18-162-1 */ var autoQuotator=function() { this.aQMC="";this.aQI="";this.aQT=0;this.aQST=0; var aQMC,aQI,aQT,aQST,n=[],aQTimeout=false,aQShowTmt=false,aQElement=document.createElement("div"),gEBC=function(n){ for(var e=document.getElementsByTagName("*"),c,a=[],i=0;i<e.length;i++){ c=e[i];if(!c.className) continue; for(var b=0,t,p=c.className.split(' ');b<=p.length;b++){ t=p[b];if(t==n){a[a.length]=c;break;}}} return a; },iCh=function(n,p){ var a=p.getElementsByTagName('*'),i;if(p==n){return true;} for(i=0;i<a.length;i++){if(a[i]==n){return true;}} return false; },aQHide=function(){ aQElement.style.display="none"; aQTimeout=false; },aQShow=function(i){return(function(){ get_selection();if(!selection){return;} aQElement.innerHTML=rep2D(aQI,n[i]); aQElement.style.display=""; aQTimeout=setTimeout(aQHide,aQT);};); },fE=function(e){ e=e||event; if(e.pageX==null&&e.clientX!=null){ html=document.documentElement,body=document.body;e.pageX=e.clientX+(html&&html.scrollLeft||body&&body.scrollLeft||0)-(html.clientLeft||0); e.pageY=e.clientY+(html&&html.scrollTop||body&&body.scrollTop||0)-(html.clientTop||0);} return(e); },rep2D=function(s,y){ y=y.toString().replace("javascript:","").replace("selection","window.selection").replace(";",""); y=decodeURIComponent(y); return(s=s.replace(/\$N\$/g,y)); },ocCheck=function(e){ e=e||event; t=e.target||e.srcElement; if(!iCh(aQElement,t)){aQHide();} },agent=navigator.userAgent.toLowerCase(),isie=((agent.indexOf("msie")!=-1)&&(agent.indexOf("opera")==-1)),oldselection=""; this.Hide=aQHide; this.startAQ=function(){ if(!(this.aQMC&&this.aQI&&this.aQT&&this.aQST)){throw("Ошибка: скрипт должен быть настроен перед запуском");} aQMC=this.aQMC; aQI=this.aQI; aQT=this.aQT; aQST=this.aQST; n=gEBC("postQuote"); if(!n) return; a=gEBC(this.aQMC); c=aQElement; c.style.backgroundColor="#ffffff"; c.style.border="0px"; c.style.padding="0px"; c.style.display="none"; c.style.position="absolute"; c.style.zindex="100"; if(isie){document.body.onload=function(o){o=o?o:function(){};return(function(e){o(e);document.body.appendChild(aQElement);};);}(document.body.onload);}else{document.body.appendChild(aQElement);} for(i=0;i<a.length;i++){ cai=a[i]; cai.selection=""; cai.quotIndex=i; cai.onmousemove=function(om){ om=om?om:function(){}; return(function(e){ om(e);e=fE(e); get_selection(); if(oldselection!=selection){ if(!selection){aQHide();}else{ if(aQTimeout){ clearTimeout(aQTimeout); aQElement.style.left=e.pageX+"px"; aQElement.style.top=(e.pageY+8)+"px"; aQTimeout=setTimeout(aQHide,aQT); }else{ if(aQShowTmt){clearTimeout(aQShowTmt);} aQElement.style.left=e.pageX+"px"; aQElement.style.top=(e.pageY+8)+"px"; aQShowTmt=setTimeout(aQShow(this.quotIndex),aQST);}}} oldselection=selection;};);}(cai.onmousemove);} document.onclick=function(o){o=o?o:function(){};return(function(e){o(e);ocCheck(e);};);}(document.onclick); }; } //Инициализация var AQ=new autoQuotator; //Настройки //Класс объекта, при выделении текста в котором должен появляться AutoQuotator AQ.aQMC="posttdMessage"; //HTML-код всплывающей кнопки ($N$ - вызов цитирования, используется в служебных целях) AQ.aQI='<div class="autoQuotator"><table cellpadding="0" cellspacing="0" border="0"><tr><td valign="middle" align="left"><img src="http://vacionlib.org.ru/bbicons/misc/smquoter.gif" border="0" align="middle"/></td><td valign="middle" align="left"><a href="javascript://" class="noun" onclick="get_selection();$N$;AQ.Hide();">Цитировать</a></td></tr></table></div>'; //Время задержки в миллисекундах(1/1000 секунды) перед показом кнопки AQ.aQST=400; //Время задержки в миллисекундах(1/1000 секунды) после показа кнопки перед её исчезновением AQ.aQT=4000; //Запуск скрипта AQ.startAQ(); Возникла проблема. Браузер показывает, что кнопка ссылается на javascript://. Ставлю href="javascript:Insert('$ID$','$USERNAME$',selection);" Не срабатывает, кнопка просто не отображается... Куда и в каком виде нужно вставить ссылку на цитирование?? (Ребят, выручайте, метод тыка результата не дал, кнопка просто не всплывает) Сообщение отредактировал KS_Brook - Среда, 28 Фев 2018, 18:48:20
|
| |||
| |||