[Tutorial] Citar texto selecionado

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Admin
Admin
Administrador
Tempo Online : 250d 6h 21m 59s
Mensagens : 693
Reputação : 4
https://bestweb.forumeiro.com

MensagemAdmin Qui Set 29, 2016 11:36 pm

Informações:

Autor: Daemon
Versões: Todas as versões
Introdução: Citar texto selecionado

Instalação:

Acesse:
Painel de controle ->> Modulos ->> HTML & Javascripts ->> Gestão dos códigos Javascripts
Então crie um novo javascript com investimento nos topicos com esse código:

PunBB e Invision:
Código:
/* Quote selected text
Created on 14/01/2015
Made by - Daemon */
function getSelectionText() {
    var text;
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != 'Control') {
        text = document.selection.createRange().text;
    }
    return text;
}
function fadeIn(newEl, display) {
  newEl.style.opacity = 0;
  newEl.style.display = display || 'inline';
  (function fade() {
    var val = parseFloat(newEl.style.opacity);
    if (!((val += .1) > 1)) {
      newEl.style.opacity = val;
      requestAnimationFrame(fade);
    }
  })();
}
$(function() {
if(_userdata["session_logged_in"] === 1) {
   var newEl = document.createElement('span');
   newEl.className = 'quote_selection';
   newEl.innerHTML = 'Quote';
   style = document.createElement('style');
   style.type = 'text/css';
   style.innerHTML = '.quote_selection {' +
                     '  background: #f0f0f0;' +
                     '  color: #333;' +
                     '  cursor: pointer;' +
                     '  border-radius: 3px;' +
                     '  -webkit-border-radius: 3px;' +
                     '  -moz-border-radius: 3px;' +
                     '  display: none;' +
                     '  -webkit-touch-callout: none;' +
                     '  -webkit-user-select: none;' +
                     '  -khtml-user-select: none;' +
                     '  -moz-user-select: none;' +
                     '  -ms-user-select: none;' +
                     '  user-select: none;' +
                     '  padding: 2px 8px;' +
                     '  position: absolute;' +
                     '  border: 1px solid #ddd;' +
                     '  text-shadow: rgba(255,255,255,0.55) 0px 1px 0px;' +
                     '  font-size: 11px;' +
                     '  -webkit-box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '  -moz-box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '  box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '}';
   document.body.appendChild(style);
   document.body.appendChild(newEl);
   var x = document.querySelectorAll('.post-entry');
   for (var i = 0; i < x.length; i++) {
        x[i].addEventListener('mouseup', function(e) {
             var selectedTxt = getSelectionText();
             if (selectedTxt) {
             fadeIn(newEl);
             newEl.style.top = e.pageY + 'px';
             newEl.style.left = e.pageX + 'px';
             var author = this.parentNode.firstChild.firstChild.firstChild.textContent;
             newEl.onclick = function() {
               $('#text_editor_textarea').sceditor('instance').insertText('[quote="' + author + '"]' + getSelectionText() + '[/quote]');
               newEl.style.display = 'none';
             };
             } else {newEl.style.display = 'none';}
        });
   }
}
});

PhpBB3:
Código:
/* Quote selected text
Created on 14/01/2015
Made by - Daemon */
function getSelectionText() {
    var text;
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != 'Control') {
        text = document.selection.createRange().text;
    }
    return text;
}
function fadeIn(newEl, display) {
  newEl.style.opacity = 0;
  newEl.style.display = display || 'inline';
  (function fade() {
    var val = parseFloat(newEl.style.opacity);
    if (!((val += .1) > 1)) {
      newEl.style.opacity = val;
      requestAnimationFrame(fade);
    }
  })();
}
$(function() {
if(_userdata.session_logged_in > 0) {
   var newEl = document.createElement('span');
   newEl.className = 'quote_selection';
   newEl.innerHTML = 'Quote';
   style = document.createElement('style');
   style.type = 'text/css';
   style.innerHTML = '.quote_selection {' +
                     '  background: #f0f0f0;' +
                     '  color: #333;' +
                     '  cursor: pointer;' +
                     '  border-radius: 3px;' +
                     '  -webkit-border-radius: 3px;' +
                     '  -moz-border-radius: 3px;' +
                     '  display: none;' +
                     '  -webkit-touch-callout: none;' +
                     '  -webkit-user-select: none;' +
                     '  -khtml-user-select: none;' +
                     '  -moz-user-select: none;' +
                     '  -ms-user-select: none;' +
                     '  user-select: none;' +
                     '  padding: 2px 8px;' +
                     '  position: absolute;' +
                     '  border: 1px solid #ddd;' +
                     '  text-shadow: rgba(255,255,255,0.55) 0px 1px 0px;' +
                     '  font-size: 11px;' +
                     '  -webkit-box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '  -moz-box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '  box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '}';
   document.body.appendChild(style);
   document.body.appendChild(newEl);
   var x = document.querySelectorAll('.content');
   for (var i = 0; i < x.length; i++) {
        x[i].addEventListener('mouseup', function(e) {
             var selectedTxt = getSelectionText();
             if (selectedTxt) {
             fadeIn(newEl);
             newEl.style.top = e.pageY + 'px';
             newEl.style.left = e.pageX + 'px';
             var author = this.parentNode.parentNode.querySelector('.postprofile').querySelector('strong[style]').textContent;
             newEl.onclick = function() {
               $('#text_editor_textarea').sceditor('instance').insertText('[quote="' + author + '"]' + getSelectionText() + '[/quote]');
               newEl.style.display = 'none';
             };
             } else {newEl.style.display = 'none';}
        });
   }
}
});

Phpbb2:
Código:
/* Quote selected text
Created on 14/01/2015
Made by - Daemon */
function getSelectionText() {
    var text;
    if (window.getSelection) {
        text = window.getSelection().toString();
    } else if (document.selection && document.selection.type != 'Control') {
        text = document.selection.createRange().text;
    }
    return text;
}
function fadeIn(newEl, display) {
  newEl.style.opacity = 0;
  newEl.style.display = display || 'inline';
  (function fade() {
    var val = parseFloat(newEl.style.opacity);
    if (!((val += .1) > 1)) {
      newEl.style.opacity = val;
      requestAnimationFrame(fade);
    }
  })();
}
$(function() {
if(_userdata.session_logged_in > 0) {
   var newEl = document.createElement('span');
   newEl.className = 'quote_selection';
   newEl.innerHTML = 'Quote';
   style = document.createElement('style');
   style.type = 'text/css';
   style.innerHTML = '.quote_selection {' +
                     '  background: #f0f0f0;' +
                     '  color: #333;' +
                     '  cursor: pointer;' +
                     '  border-radius: 3px;' +
                     '  -webkit-border-radius: 3px;' +
                     '  -moz-border-radius: 3px;' +
                     '  display: none;' +
                     '  -webkit-touch-callout: none;' +
                     '  -webkit-user-select: none;' +
                     '  -khtml-user-select: none;' +
                     '  -moz-user-select: none;' +
                     '  -ms-user-select: none;' +
                     '  user-select: none;' +
                     '  padding: 2px 8px;' +
                     '  position: absolute;' +
                     '  border: 1px solid #ddd;' +
                     '  text-shadow: rgba(255,255,255,0.55) 0px 1px 0px;' +
                     '  font-size: 11px;' +
                     '  -webkit-box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '  -moz-box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '  box-shadow: rgba(0,0,0,0.1) 0px 1px 3px;' +
                     '}';
   document.body.appendChild(style);
   document.body.appendChild(newEl);
   var x = document.querySelectorAll('td[class*="row"] table');
   for (var i = 0; i < x.length; i++) {
        x[i].addEventListener('mouseup', function(e) {
             var selectedTxt = getSelectionText();
             if (selectedTxt) {
             fadeIn(newEl);
             newEl.style.top = e.pageY + 'px';
             newEl.style.left = e.pageX + 'px';
             var author = this.parentNode.parentNode.querySelector('.name').textContent;
             newEl.onclick = function() {
               $('#text_editor_textarea').sceditor('instance').insertText('[quote="' + author + '"]' + getSelectionText() + '[/quote]');
               newEl.style.display = 'none';
             };
             } else {newEl.style.display = 'none';}
        });
   }
}
});

Resultados:
[Tutorial] Citar texto selecionado 7kmkAu0

Ver o tópico anterior Ver o tópico seguinte Ir para o topo

Cria uma conta ou logue para postar uma mensagem.

Você precisa ser um membro, para poder postar uma resposta.

Criar conta

Participe de nossa comunidade, basta se registrar. É Fácil!


Criar uma conta

Logar

Já tem uma conta? Sem problemas, Logue agora.


Logar-se

 
Permissões neste sub-fórum
Não podes responder a tópicos