Cody
Rank: Fondator Mesaje : 473 Reputatie : 12 Data de inscriere : 14/03/2013 Varsta : 35 Localizare : Mizil
| Subiect: Butonul Selectati Continutul Vin Apr 12, 2013 12:07 pm | |
| Buna ziua, In acest tutorial va voi arata cum sa puneti butonul "Selectati Continutul" pentru casetele de cod. Acest tutorial este compatibil pentru toate versiunileUn exemplu de "Selectati Continutul" puteti vedea in imaginea de mai jos Daca apasati pe el se va selecta automat tot continutul casetei Pasul 1: PA=>Module=>HTML & JAVASCRIPT=>Javascript codes management=>Create a new javascript Pasul 2: Alegeti ce titlu doriti si setati-i plasamentul pe toate paginilePasul 3: O data ce ati facut asta adaugati urmatorul cod in campul 'Javascript Code' ( doar codul pentru versiunea pe care o aveti) Pentru phpbb2
- Cod:
-
function selectCode(a) { // Get ID of code block var e = jQuery(a).closest('tr').next().find('.cont_code')[0];
// Not IE if (window.getSelection) { var s = window.getSelection(); // Safari if (s.setBaseAndExtent) { s.setBaseAndExtent(e, 0, e, e.innerText.length - 1); } // Firefox and Opera else { // workaround for bug # 42885 if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>') { e.innerHTML = e.innerHTML + ' '; }
var r = document.createRange(); r.selectNodeContents(e); s.removeAllRanges(); s.addRange(r); } } // Some older browsers else if (document.getSelection) { var s = document.getSelection(); var r = document.createRange(); r.selectNodeContents(e); s.removeAllRanges(); s.addRange(r); } // IE else if (document.selection) { var r = document.body.createTextRange(); r.moveToElementText(e); r.select(); } } jQuery(function(){
jQuery('div.postbody td.code').parent().prev().find('b').html('Code: <a href="javascript:void()" onClick="selectCode(this)"><font face="verdana" color="red"></font> Selectati Continutul </a>'); }); Pentru phpBB 3, punBB si invision
- Cod:
-
function selectCode(a) { // Get ID of code block var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0]; // Not IE if (window.getSelection) { var s = window.getSelection(); // Safari if (s.setBaseAndExtent) { s.setBaseAndExtent(e, 0, e, e.innerText.length - 1); } // Firefox and Opera else { // workaround for bug # 42885 if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>') { e.innerHTML = e.innerHTML + ' '; } var r = document.createRange(); r.selectNodeContents(e); s.removeAllRanges(); s.addRange(r); } } // Some older browsers else if (document.getSelection) { var s = document.getSelection(); var r = document.createRange(); r.selectNodeContents(e); s.removeAllRanges(); s.addRange(r); } // IE else if (document.selection) { var r = document.body.createTextRange(); r.moveToElementText(e); r.select(); } } if(text){}else{ var text = 'Selecionar todos';} jQuery(document).ready(function(){ jQuery("dl.codebox dt").not("dl.spoiler > dt").html('Code: <a href="#" onclick="selectCode(this); return false;" title="Select all the content" class="code-a"> Selectati Continutul </a>'); }); |
|