Informações:
Autor: Daemon e Slik
Funcionalidade: Todas as versões
Neste tutorial, mostraremos um método de citar apenas o texto selecionado no post.
Acesse:
e Crie um novo Javascript com investimento nos topicos com esse codigo:Painel de Controle ☛ Modulos ☛ Html e Javascript ☛ Gestão dos Códigos Javascript
PunBB e Invision:
- Código:
/* Quote selected text
Created on 14/01/2015
Made by - Daemon and Slik*/
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 and Slik */
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 And Slik*/
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';}
});
}
}
});