Buton BB code in editor
Pagina 1 din 1 • Distribuiţi
Buton BB code in editor
Buna ziua ,ma poate ajuta cineva sa creez un buton in editor ,,download,, [download]link de download[/download].Acest buton este pentru a limita posibilitatea de download softuri tv a membrilor noi.
Am incercat eu sa creez butonul urmarind tuturiale existente pe [Trebuie sa fiti inscris si conectat pentru a vedea acest link] dar nu imi apare in editor.
Aici este codul js pentru limitare download
iar aici CSS
Am incercat eu sa creez butonul urmarind tuturiale existente pe [Trebuie sa fiti inscris si conectat pentru a vedea acest link] dar nu imi apare in editor.
Aici este codul js pentru limitare download
- Cod:
$(function() {
var
mesajeNecesare = 4,
mesajText = "<span class="link">PENTRU A DESCARCA ACEST LINK TREBUIE SA DESCHIDETI TOPIC DE CERERE. VA MULTUMIM!</span>";
$('.post .postbody .content').each(function() {
console.log('- tpost');
if(_userdata.user_posts < mesajeNecesare) {
this.innerHTML = this.innerHTML.replace(/\[download\]<a href="(.*)">(.*?)\[\/download\]<\/a>/g, mesajText);
} else {
this.innerHTML = this.innerHTML.replace(/\[download\]<a href="(.*)">(.*?)\[\/download\]<\/a>/g, "<div id="download-link"><a href="$2" target="_blank">Download</a></div>");
}
});
var config = {
position_left : true,
negative_vote : true,
vote_bar : true,
icon_plus : '<img src="https://i.servimg.com/u/f18/18/21/41/30/plus10.png" alt="+"/>',
icon_minus : '<img src="https://i.servimg.com/u/f18/18/21/41/30/minus10.png" alt="-"/>',
title_plus : 'Apreciaza-l pe %{USERNAME}\ pentru acest mesaj',
title_minus : 'Dezapreciaza-l pe %{USERNAME}\ pentru acest mesaj',
title_like_singular : '%{VOTES} persoana apreciaza postarea lui %{USERNAME}',
title_like_plural : '%{VOTES} persoane apreciaza postarea lui %{USERNAME}',
title_dislike_singular : '%{VOTES} persoana nu ii place postarea lui %{USERNAME}',
title_dislike_plural : '%{VOTES} persoane nu apreciaza postarea lui %{USERNAME}',
title_vote_bar : '%{VOTES} persoane apreciaza postarea lui %{USERNAME} %{PERCENT}'
},
submit_vote = function() {
var next = this.nextSibling,
box = this.parentNode,
bar = box.getElementsByTagName('DIV'),
vote = box.getElementsByTagName('A'),
mode = /eval=plus/.test(this.href) ? 1 : 0,
i = 0, j = vote.length, pos, neg, percent;
$.get(this.href, function() {
next.innerHTML = +next.innerHTML + 1;
next.title = next.title.replace(/(\d+)/, function(M, $1) { return +$1 + 1 });
pos = +vote[0].nextSibling.innerHTML;
neg = vote[1] ? +vote[1].nextSibling.innerHTML : 0;
percent = pos == 0 ? '0%' : pos == neg ? '50%' : Math.round(pos / (pos + neg) * 100) + '%';
if (bar[0]) {
bar[0].style.display = '';
bar[0].firstChild.style.width = percent;
box.title = box.title.replace(/\d+\/\d+/, pos + '/' + ( pos + neg )).replace(/\(\d+%\)/, '(' + percent + ')');
}
});
for (; i < j; i++) {
vote[i].href = '#';
vote[i].className = vote[i].className.replace(/fa_vote/, 'fa_voted');
vote[i].onclick = function() { return false };
}
return false;
},
vote = $('.vote'), i = 0, j = vote.length,
version = $('.bodylinewidth')[0] ? 0 :
document.getElementById('phpbb') ? 1 :
$('.pun')[0] ? 2 :
document.getElementById('ipbwrapper') ? 3 :
document.getElementById('modernbb') ? 4 :
'badapple', // version check
vdata = {
tag : ['SPAN', 'LI', 'SPAN', 'LI', 'LI'][version],
name : ['.name', '.postprofile dt > strong', '.username', '.popmenubutton', '.postprofile-name'][version],
actions : ['.post-options', '.profile-icons', '.post-options', '.posting-icons', '.profile-icons'][version]
},
post, plus, minus, n_pos, n_neg, title_pos, title_neg, li, ul, bar, button, total, percent, span, pseudo, vote_bar;
if (version == 'badapple') {
if (window.console) console.warn('This plugin is not optimized for your forum version. Please contact the support for further assistance.');
return;
}
for (; i < j; i++) {
post = $(vote[i]).closest('.post')[0];
bar = $('.vote-bar', vote[i])[0];
button = $('a[href*="p_vote"]', vote[i]);
pseudo = $(vdata.name, post).text() || 'MISSING_STRING';
ul = $(vdata.actions, post)[0];
li = document.createElement(vdata.tag);
li.className = 'fa_reputation';
if (li.tagName == 'SPAN') li.style.display = 'inline-block';
if (bar) {
total = +bar.title.replace(/.*?\((\d+).*/, '$1');
percent = +bar.title.replace(/.*?(\d+)%.*/, '$1');
n_pos = Math.round(total * (percent / 100));
n_neg = total - n_pos;
} else {
n_pos = 0;
n_neg = 0;
}
title_pos = (n_pos == 1 ? config.title_like_singular : config.title_like_plural).replace(/%\{USERNAME\}/g, pseudo).replace(/%\{VOTES\}/g, n_pos);
title_neg = (n_neg == 1 ? config.title_dislike_singular : config.title_dislike_plural).replace(/%\{USERNAME\}/g, pseudo).replace(/%\{VOTES\}/g, n_neg);
li.innerHTML = '<span class="fa_count fa_positive" title="' + title_pos + '">' + n_pos + '</span>' + (config.negative_vote ? ' <span class="fa_count fa_negative" title="' + title_neg + '">' + n_neg + '</span>' : '');
span = li.getElementsByTagName('SPAN');
plus = document.createElement('A');
plus.href = button[0] ? button[0].href : '#';
plus.onclick = button[0] ? submit_vote : function() { return false };
plus.className = 'fa_vote' + (button[0] ? '' : 'd') + ' fa_plus';
plus.innerHTML = config.icon_plus;
plus.title = (button[0] ? config.title_plus : title_pos).replace(/%\{USERNAME\}/g, pseudo);
span[0] && li.insertBefore(plus, span[0]);
if (config.negative_vote) {
minus = document.createElement('A');
minus.href = button[1] ? button[1].href : '#';
minus.onclick = button[1] ? submit_vote : function() { return false };
minus.className = 'fa_vote' + (button[1] ? '' : 'd') + ' fa_minus';
minus.innerHTML = config.icon_minus;
minus.title = (button[1] ? config.title_minus : title_neg).replace(/%\{USERNAME\}/g, pseudo);
span[1] && li.insertBefore(minus, span[1]);
}
if (config.vote_bar) {
vote_bar = document.createElement('DIV');
vote_bar.className = 'fa_votebar';
vote_bar.innerHTML = '<div class="fa_votebar_inner" style="width:' + percent + '%;"></div>';
vote_bar.style.display = bar ? '' : 'none';
li.title = config.title_vote_bar.replace(/%\{USERNAME\}/, pseudo).replace(/%\{VOTES\}/, n_pos + '/' + (n_pos + n_neg)).replace(/%\{PERCENT\}/, '(' + percent + '%)');
li.appendChild(vote_bar);
}
config.position_left? ul.insertBefore(li, ul.firstChild) : ul.appendChild(li);
vote[i].parentNode.removeChild(vote[i]);
}
});
iar aici CSS
- Cod:
div#download-link {
background: #368ad2;
width: 10%;
text-align: center;
padding: 5px;
color: white;
font-size: 14px;
}
div#download-link > a {
color: whitesmoke;
}
Ultima editare efectuata de catre Dani David in Mier Oct 25, 2017 3:36 pm, editata de 2 ori
Dani David- Membru activ
- Mesaje : 551
Varsta : 57
Localizare : Bucuresti
Data înscrierii : 04/06/2017
Mulțumiri : 9
Re: Buton BB code in editor
Va salut,ma puteti ajuta ?va rog.
Multumesc
Multumesc
Dani David- Membru activ
- Mesaje : 551
Varsta : 57
Localizare : Bucuresti
Data înscrierii : 04/06/2017
Mulțumiri : 9
Re: Buton BB code in editor
Buna seara,
Inlocuiti codul javascript oferit mai sus cu acesta:
Inlocuiti codul javascript oferit mai sus cu acesta:
- Cod:
$(function() {
$(function() {
jQuery('body').append('<div id="downloadlink" class="sceditor-dropdown sceditor-downloadlink" style="visibility:hidden;width:auto;text-align:left;"><div><label for="linkdownload" unselectable="on">URL</label> <input type="text" id="linksrc" class="url" placeholder="http://" value=""></div><div><input type="button" class="button" value="inserare"></div></div>');
jQuery('.sceditor-group:last-child').after('<div class="sceditor-group" id="download_link"><a class="sceditor-button" title="Download BBCode" onclick="selectWysiwyg(this, \'downloadlink\');"><div style="background:url(http://icons.iconarchive.com/icons/icons8/windows-8/16/Users-Moderator-icon.png) no-repeat center;"></div></a></div>');
$('div input[value="inserare"]', $('#downloadlink')).live("click", function(e) {
$('textarea#text_editor_textarea').sceditor('instance').insert('[download]'+ $('#linksrc', $('#downloadlink')).val() +'[/download]');
$('#linksrc', $('#downloadlink')).val('');
$('#downloadlink').css({'visibility':'hidden'});
});
$.sceditor.plugins.bbcode.bbcode.set('download', {
tags: {
'div': {
'class': ['download-link']
}
},
format: '[download]{0}[/download]',
html: '<div class="download-link"><a href="{0}" target="_blank">Download File</a></div>'
});
});
});
$(function() {
var
mesajeNecesare = 4,
mesajText = "<span class="link">PENTRU A DESCARCA ACEST LINK TREBUIE SA DESCHIDETI TOPIC DE CERERE. VA MULTUMIM!</span>";
$('.post .postbody .content').each(function() {
console.log('- tpost');
if(_userdata.user_posts < mesajeNecesare) {
this.innerHTML = this.innerHTML.replace(/\[download\]<a href="(.*)">(.*?)\[\/download\]<\/a>/g, mesajText);
} else {
this.innerHTML = this.innerHTML.replace(/\[download\]<a href="(.*)">(.*?)\[\/download\]<\/a>/g, "<div id="download-link"><a href="$2" target="_blank">Download</a></div>");
}
});
var config = {
position_left : true,
negative_vote : true,
vote_bar : true,
icon_plus : '<img src="https://i.servimg.com/u/f18/18/21/41/30/plus10.png" alt="+"/>',
icon_minus : '<img src="https://i.servimg.com/u/f18/18/21/41/30/minus10.png" alt="-"/>',
title_plus : 'Apreciaza-l pe %{USERNAME}\ pentru acest mesaj',
title_minus : 'Dezapreciaza-l pe %{USERNAME}\ pentru acest mesaj',
title_like_singular : '%{VOTES} persoana apreciaza postarea lui %{USERNAME}',
title_like_plural : '%{VOTES} persoane apreciaza postarea lui %{USERNAME}',
title_dislike_singular : '%{VOTES} persoana nu ii place postarea lui %{USERNAME}',
title_dislike_plural : '%{VOTES} persoane nu apreciaza postarea lui %{USERNAME}',
title_vote_bar : '%{VOTES} persoane apreciaza postarea lui %{USERNAME} %{PERCENT}'
},
submit_vote = function() {
var next = this.nextSibling,
box = this.parentNode,
bar = box.getElementsByTagName('DIV'),
vote = box.getElementsByTagName('A'),
mode = /eval=plus/.test(this.href) ? 1 : 0,
i = 0, j = vote.length, pos, neg, percent;
$.get(this.href, function() {
next.innerHTML = +next.innerHTML + 1;
next.title = next.title.replace(/(\d+)/, function(M, $1) { return +$1 + 1 });
pos = +vote[0].nextSibling.innerHTML;
neg = vote[1] ? +vote[1].nextSibling.innerHTML : 0;
percent = pos == 0 ? '0%' : pos == neg ? '50%' : Math.round(pos / (pos + neg) * 100) + '%';
if (bar[0]) {
bar[0].style.display = '';
bar[0].firstChild.style.width = percent;
box.title = box.title.replace(/\d+\/\d+/, pos + '/' + ( pos + neg )).replace(/\(\d+%\)/, '(' + percent + ')');
}
});
for (; i < j; i++) {
vote[i].href = '#';
vote[i].className = vote[i].className.replace(/fa_vote/, 'fa_voted');
vote[i].onclick = function() { return false };
}
return false;
},
vote = $('.vote'), i = 0, j = vote.length,
version = $('.bodylinewidth')[0] ? 0 :
document.getElementById('phpbb') ? 1 :
$('.pun')[0] ? 2 :
document.getElementById('ipbwrapper') ? 3 :
document.getElementById('modernbb') ? 4 :
'badapple', // version check
vdata = {
tag : ['SPAN', 'LI', 'SPAN', 'LI', 'LI'][version],
name : ['.name', '.postprofile dt > strong', '.username', '.popmenubutton', '.postprofile-name'][version],
actions : ['.post-options', '.profile-icons', '.post-options', '.posting-icons', '.profile-icons'][version]
},
post, plus, minus, n_pos, n_neg, title_pos, title_neg, li, ul, bar, button, total, percent, span, pseudo, vote_bar;
if (version == 'badapple') {
if (window.console) console.warn('This plugin is not optimized for your forum version. Please contact the support for further assistance.');
return;
}
for (; i < j; i++) {
post = $(vote[i]).closest('.post')[0];
bar = $('.vote-bar', vote[i])[0];
button = $('a[href*="p_vote"]', vote[i]);
pseudo = $(vdata.name, post).text() || 'MISSING_STRING';
ul = $(vdata.actions, post)[0];
li = document.createElement(vdata.tag);
li.className = 'fa_reputation';
if (li.tagName == 'SPAN') li.style.display = 'inline-block';
if (bar) {
total = +bar.title.replace(/.*?\((\d+).*/, '$1');
percent = +bar.title.replace(/.*?(\d+)%.*/, '$1');
n_pos = Math.round(total * (percent / 100));
n_neg = total - n_pos;
} else {
n_pos = 0;
n_neg = 0;
}
title_pos = (n_pos == 1 ? config.title_like_singular : config.title_like_plural).replace(/%\{USERNAME\}/g, pseudo).replace(/%\{VOTES\}/g, n_pos);
title_neg = (n_neg == 1 ? config.title_dislike_singular : config.title_dislike_plural).replace(/%\{USERNAME\}/g, pseudo).replace(/%\{VOTES\}/g, n_neg);
li.innerHTML = '<span class="fa_count fa_positive" title="' + title_pos + '">' + n_pos + '</span>' + (config.negative_vote ? ' <span class="fa_count fa_negative" title="' + title_neg + '">' + n_neg + '</span>' : '');
span = li.getElementsByTagName('SPAN');
plus = document.createElement('A');
plus.href = button[0] ? button[0].href : '#';
plus.onclick = button[0] ? submit_vote : function() { return false };
plus.className = 'fa_vote' + (button[0] ? '' : 'd') + ' fa_plus';
plus.innerHTML = config.icon_plus;
plus.title = (button[0] ? config.title_plus : title_pos).replace(/%\{USERNAME\}/g, pseudo);
span[0] && li.insertBefore(plus, span[0]);
if (config.negative_vote) {
minus = document.createElement('A');
minus.href = button[1] ? button[1].href : '#';
minus.onclick = button[1] ? submit_vote : function() { return false };
minus.className = 'fa_vote' + (button[1] ? '' : 'd') + ' fa_minus';
minus.innerHTML = config.icon_minus;
minus.title = (button[1] ? config.title_minus : title_neg).replace(/%\{USERNAME\}/g, pseudo);
span[1] && li.insertBefore(minus, span[1]);
}
if (config.vote_bar) {
vote_bar = document.createElement('DIV');
vote_bar.className = 'fa_votebar';
vote_bar.innerHTML = '<div class="fa_votebar_inner" style="width:' + percent + '%;"></div>';
vote_bar.style.display = bar ? '' : 'none';
li.title = config.title_vote_bar.replace(/%\{USERNAME\}/, pseudo).replace(/%\{VOTES\}/, n_pos + '/' + (n_pos + n_neg)).replace(/%\{PERCENT\}/, '(' + percent + '%)');
li.appendChild(vote_bar);
}
config.position_left? ul.insertBefore(li, ul.firstChild) : ul.appendChild(li);
vote[i].parentNode.removeChild(vote[i]);
}
});
Dani David- Membru activ
- Mesaje : 551
Varsta : 57
Localizare : Bucuresti
Data înscrierii : 04/06/2017
Mulțumiri : 9
Re: Buton BB code in editor
Multumesc [Trebuie sa fiti inscris si conectat pentru a vedea acest link] am rezolvat am copiat doar codul js pentru buton si l-am implementat separat si este ok doar daca il activez pe topicuri ,nu merge si amplasat pe toate paginile avand nevoie la deschidere topic cel mai mult sau editare daca se poate modifica ar fi super si codul de criptare link functioneaza doar amplasat pe topicuri .Daca e necesar iti dau acces la PA sa vezi despre ce este vorba.
Asta e codul facut de tine
Asta e codul facut de tine
- Cod:
$(function() {
$(function() {
jQuery('body').append('<div id="downloadlink" class="sceditor-dropdown sceditor-downloadlink" style="visibility:hidden;width:auto;text-align:left;"><div><label for="linkdownload" unselectable="on">URL</label> <input type="text" id="linksrc" class="url" placeholder="http://" value=""></div><div><input type="button" class="button" value="inserare"></div></div>');
jQuery('.sceditor-group:last-child').after('<div class="sceditor-group" id="download_link"><a class="sceditor-button" title="Download BBCode" onclick="selectWysiwyg(this, \'downloadlink\');"><div style="background:url(http://icons.iconarchive.com/icons/icons8/windows-8/16/Users-Moderator-icon.png) no-repeat center;"></div></a></div>');
$('div input[value="inserare"]', $('#downloadlink')).live("click", function(e) {
$('textarea#text_editor_textarea').sceditor('instance').insert('[download]'+ $('#linksrc', $('#downloadlink')).val() +'[/download]');
$('#linksrc', $('#downloadlink')).val('');
$('#downloadlink').css({'visibility':'hidden'});
});
$.sceditor.plugins.bbcode.bbcode.set('download', {
tags: {
'div': {
'class': ['download-link']
}
},
format: '[download]{0}[/download]',
html: '<div class="download-link"><a href="{0}" target="_blank">Download File</a></div>'
});
});
});
Dani David- Membru activ
- Mesaje : 551
Varsta : 57
Localizare : Bucuresti
Data înscrierii : 04/06/2017
Mulțumiri : 9
Re: Buton BB code in editor
Buna seara,
Inainte eliminati acest cod:
Apoi incercati acest cod:
Inainte eliminati acest cod:
- Cod:
var
mesajeNecesare = 4,
mesajText = "<span class="link">PENTRU A DESCARCA ACEST LINK TREBUIE SA DESCHIDETI TOPIC DE CERERE. VA MULTUMIM!</span>";
$('.post .postbody .content').each(function() {
console.log('- tpost');
if(_userdata.user_posts < mesajeNecesare) {
this.innerHTML = this.innerHTML.replace(/\[download\]<a href="(.*)">(.*?)\[\/download\]<\/a>/g, mesajText);
} else {
this.innerHTML = this.innerHTML.replace(/\[download\]<a href="(.*)">(.*?)\[\/download\]<\/a>/g, "<div id="download-link"><a href="$2" target="_blank">Download</a></div>");
}
});
Apoi incercati acest cod:
- Cod:
$(function() {
$(function() {
jQuery('body').append('<div id="downloadlink" class="sceditor-dropdown sceditor-downloadlink" style="visibility:hidden;width:auto;text-align:left;"><div><label for="linkdownload" unselectable="on">URL</label> <input type="text" id="linksrc" class="url" placeholder="http://" value=""></div><div><input type="button" class="button" value="inserare"></div></div>');
jQuery('.sceditor-group:last-child').after('<div class="sceditor-group" id="download_link"><a class="sceditor-button" title="Download BBCode" onclick="selectWysiwyg(this, \'downloadlink\');"><div style="background:url(http://icons.iconarchive.com/icons/dakirby309/windows-8-metro/16/Folders-OS-Downloads-Folder-Metro-icon.png) no-repeat center;"></div></a></div>');
$('div input[value="inserare"]', $('#downloadlink')).live("click", function(e) {
var link, linkHTTPS, linkHTTP, a = $('#linksrc', $('#downloadlink')).val();
if(/https:\/\//g.test(a)) {
linkHTTPS = a.split('https://')[1];
link = linkHTTPS;
} else {
linkHTTP = a.split('http://')[1];
link = linkHTTP;
}
$('textarea#text_editor_textarea').sceditor('instance').insert('[download='+ link +'][/download]');
$('#linksrc', $('#downloadlink')).val('');
$('#downloadlink').css({'visibility':'hidden'});
});
var
mesajeNecesare = 4,
mesajText = "<span class=\"link\">PENTRU A DESCARCA ACEST LINK TREBUIE SA DESCHIDETI TOPIC DE CERERE. VA MULTUMIM!</span>";
var dw = $('.post .postbody .content');
for(var i = 0; i < dw.length; i++) {
if(_userdata.user_posts < mesajeNecesare) {
dw[i].innerHTML = dw[i].innerHTML.replace(/\[download=(.*?)\]\[\/download\]/g, mesajText);
} else {
dw[i].innerHTML = dw[i].innerHTML.replace(/\[download=(.*?)\]\[\/download\]/g, '<div id="download-link"><a href="http://$1" target="_blank">Download</a></div>');
}
}
});
});
Re: Buton BB code in editor
Nu vrea.a disparut si butonul de moderare sa ingustat si subforumul
Dani David- Membru activ
- Mesaje : 551
Varsta : 57
Localizare : Bucuresti
Data înscrierii : 04/06/2017
Mulțumiri : 9
Re: Buton BB code in editor
Problema rezolvata prin oferirea detelor administrative prin PM.
=> Topic trimis in cos.
=> Topic trimis in cos.
Subiecte similare
» Buton editor
» Din: Buton editor
» Adăugați GIF-uri în mesajele dvs. printr-un nou buton din editor
» Cum setez la tag-urile [code] si [/code] contur, inaltime, latime, imagine de fundal si culori
» Cum pun scrisul de la tagul [code][/code] sa fie intr-un chenar?
» Din: Buton editor
» Adăugați GIF-uri în mesajele dvs. printr-un nou buton din editor
» Cum setez la tag-urile [code] si [/code] contur, inaltime, latime, imagine de fundal si culori
» Cum pun scrisul de la tagul [code][/code] sa fie intr-un chenar?
Pagina 1 din 1
Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum