Alterar o botão "Curtir mensagem"

3 participantes

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

Tópico resolvido Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 15:17

Detalhes da questão


Endereço do fórum: http://anigames-pt.portugueseforum.net/
Versão do fórum: PhpBB3

Descrição


Gostaria de alterar porque não gosto nada deste botão de curtir, gostaria de altera-lo:

Alterar o botão "Curtir mensagem" Im309d
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Ajudeiro

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Fraise 15.11.15 15:19

Olá @King'!

Está a utilizar algum código para esse sistema de curtir?
Caso sim, poderia fornece-lo?

Até mais.
Fraise
Fraise

Fraise
Ajudeiro
Ajudeiro

Membro desde : 26/06/2015
Mensagens : 6558
Pontos : 8045

https://ajuda.forumeiros.com/ https://twitter.com/@FraiseFdF

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 15:28

Como eu sei se estou ou não a usar um código @Fraise ?
Penso que não... Eu apenas ativei o sistema de reputação.
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Ajudeiro
  • 0

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Fraise 15.11.15 15:32

Eu creio que o senhor esteja a utilizar algo para o sistema de reputação.. poderia verificar em Painel de Controle >> Módulos >> HTML & JavaScript >> Gestão dos códigos JavaScript?

Até mais.
Fraise
Fraise

Fraise
Ajudeiro
Ajudeiro

Membro desde : 26/06/2015
Mensagens : 6558
Pontos : 8045

https://ajuda.forumeiros.com/ https://twitter.com/@FraiseFdF

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 15:42

Tenho um Codigo JS que tem o titulo de: Botão obrigado com função em todos os tópicos não sei se é isto o codigo do sistema de curtir:

Código:
jQuery(document).ready(function() {
    for (var a = $('.post', document.getElementById('main-content')), i = 0, p, rep, votes, plus, item, button, pseudo, opts; p = a[i]; i++) {
        item = document.createElement('LI');
        button = document.createElement('A');
        button.innerHTML = '<i class="fa"></i>';
        button.className = 'fa_vote';
        rep = $('.vote', p)[0];
        opts = p.getElementsByTagName('UL')[0];
        pseudo = $('.postprofile dt', p).text();
        if (rep) {
            votes = $('.vote-bar', rep)[0];
            plus = rep.getElementsByTagName('A')[0];
            if (votes) {
                votes = votes.title.replace(/.*\((\d+).*/, '$1');
                item.innerHTML = '<span class="fa_votes">' + votes + '</span>';
                item.title = votes + (votes == 1 ? ' pessoa gostou do tópico ' : ' pessoas gostaram do tópico ') + pseudo + ''
            } else {
                item.innerHTML = '<span class="fa_votes">0</span>';
                item.title = 'Nenhum voto foi computado para ' + pseudo + ''
            }
            if (plus && /plus/i.test(plus.href)) {
                button.className += ' fa_like';
                button.href = plus.href;
                button.title = 'Curtir a mensagem de ' + pseudo + '';
                button.onclick = function() {
                    var t = this;
                    t.onclick = function() {
                        return false
                    };
                    $.get(t.href, function() {
                        var v = t.nextSibling;
                        v.innerHTML = Number(v.innerHTML) + 1;
                        t.className += 'd';
                        t.parentNode.title = v.innerHTML + (v.innerHTML == 1 ? ' pessoa gostou do tópico ' : ' pessoas gostaram do tópico ') + t.title.replace(/.*?\s(.*?)'.*/, '$1') + '';
                        t.removeAttribute('title');
                        t.href = '#'
                    });
                    return false
                }
            } else {
                button.href = '#';
                button.className += ' fa_liked';
                button.onclick = function() {
                    return false
                }
            }
            item.insertBefore(button, item.firstChild);
            opts.insertBefore(item, opts.firstChild);
            rep.parentNode.removeChild(rep)
        }
    }
});
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Ajudeiro

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Fraise 15.11.15 15:46

É exatamente esse! Qual seria o endereço da imagem do novo botão?

Até mais.
Fraise

Tópico movido de 'Questões sobre a aparência do fórum' para 'Questões sobre códigos'
Fraise

Fraise
Ajudeiro
Ajudeiro

Membro desde : 26/06/2015
Mensagens : 6558
Pontos : 8045

https://ajuda.forumeiros.com/ https://twitter.com/@FraiseFdF

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 15:56

Se possivel o mesmo do FdF ou então este: http://4.bp.blogspot.com/-35oHu0z-Fdg/TwM7Jmu0PoI/AAAAAAAACXs/4YlbAdm4m30/s1600/curtir1.png

Poderia me dar o codigo com ambos os botoes de curtir para eu ver qual fica melhor?

Até mais,
King'
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Chagas 15.11.15 16:03

O razão de ficar [] é que não foi instalado a sistema de ícones Font Awesone, vamos lá no seu templante overall_header
Painel de Controle Flecha ajudeiros Visualização Flecha ajudeiros Templantes Flecha ajudeiros Geral Flecha ajudeiros overall_header Flecha ajudeiros Editar

Agora no inicio de templante tem este código:
Código:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Em cima coloque este código
Código:
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
E aperte SALVAR e depois publique o fórum, aparecerá como aqui.

Até mais,
CT
Chagas

Chagas
Membro

Membro desde : 22/10/2015
Mensagens : 893
Pontos : 1098

https://pelotao.forumeiros.com

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 16:08

Não mudou nada Cutie '-'
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Chagas 15.11.15 16:10

Fez que eu pedi exatamente?
Publicou o templante? clicando Adicionar ?

Até mais,
Chagas

Chagas
Membro

Membro desde : 22/10/2015
Mensagens : 893
Pontos : 1098

https://pelotao.forumeiros.com

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 16:11

Não, eu previsualizei e não verifiquei nenhuma mudança pois não é preciso aplicar o botão "+", pois você pode visualizar o fórum e ver se quer mesmo aplicar o codigo ou não e eu recusei por não alterou nada.
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Chagas 15.11.15 16:29

Deixe o código, altere pra este o JS
Código:
$(function() {
  // General Configuration of the plugin
  var config = {
    position_left : true, // true for left || false for right
    negative_vote : true, // true for negative votes || false for positive only
    vote_bar : true, // display a small bar under the vote buttons
  
    // button config
    icon_plus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/plus10.png" alt="+"/>',
    icon_minus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/minus10.png" alt="-"/>',
  
    // language config
    title_plus : 'Like %{USERNAME}\'s post',
    title_minus : 'Dislike %{USERNAME}\'s post',
  
    title_like_singular : '%{VOTES} person likes %{USERNAME}\'s post',
    title_like_plural : '%{VOTES} people like %{USERNAME}\'s post',
  
    title_dislike_singular : '%{VOTES} person dislikes %{USERNAME}\'s post',
    title_dislike_plural : '%{VOTES} people dislike %{USERNAME}\'s post',
  
    title_vote_bar : '%{VOTES} people liked %{USERNAME}\'s post %{PERCENT}'
  },
    
    
  // function bound to the onclick handler of the vote buttons
  submit_vote = function() {
    var next = this.nextSibling, // the counter next to the vote button that was clicked
        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;
  
    // submit the vote asynchronously
    $.get(this.href, function() {
      next.innerHTML = +next.innerHTML + 1; // add to the vote count
      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 + ')');
      }
    });
  
    // revoke voting capabilities on the post once the vote is cast
    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('wrap') ? 1 : $('.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : 'badapple', // version check
 
  // version data so we don't have to redefine these arrays during the loop
  vdata = {
    tag : ['SPAN', 'LI', 'SPAN', 'LI'][version],
    name : ['.name', '.postprofile dt > strong', '.username', '.popmenubutton'][version],
    actions : ['.post-options', '.profile-icons', '.post-options', '.posting-icons'][version],
  },
 
  post, plus, minus, n_pos, n_neg, title_pos, title_neg, li, ul, bar, button, total, percent, span, pseudo, vote_bar; // startup variables for later use in the loop
 
  // prevent execution if the version cannot be determined
  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]).parentsUntil('.post').parent()[0];
    bar = $('.vote-bar', vote[i])[0]; // vote bar
    button = $('.vote-button', vote[i]); // plus and minus buttons
    pseudo = $(vdata.name, post).text() || 'MISSING_STRING'; // username of the poster
    ul = $(vdata.actions, post)[0]; // post actions
    li = document.createElement(vdata.tag); // vote system container
    li.className = 'fa_reputation';
  
    if (li.tagName == 'SPAN') li.style.display = 'inline-block';
  
    // calculate votes
    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;
    }
  
    // set up negative and positive titles with the correct grammar, votes, and usernames
    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);
  
    // define the vote counts
    li.innerHTML = '<span class="fa_count fa_positive" title="' + title_pos + '">' + n_pos + '</span>' + (config.negative_vote ? '&nbsp;<span class="fa_count fa_negative" title="' + title_neg + '">' + n_neg + '</span>' : '');
    span = li.getElementsByTagName('SPAN'); // get the vote count containers for use as insertion points
  
    // create positive vote button
    plus = document.createElement('A');
    plus.href = button[0] ? button[0].firstChild.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]);
  
    // create negative vote button
    if (config.negative_vote) {
      minus = document.createElement('A');
      minus.href = button[1] ? button[1].firstChild.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]);
    }
  
    // create vote bar
    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);
    }
  
    // finally insert the vote system and remove the default one
    config.position_left ? ul.insertBefore(li, ul.firstChild) : ul.appendChild(li);
    vote[i].parentNode.removeChild(vote[i]);
  }
});

Agora adicione este CSS:
Código:
.fa_vote, .fa_voted, .fa_count {
  font-size:12px;
  font-family:Verdana, Arial, Helvetica, Sans-serif;
  display:inline-block !important;
  width:auto !important;
  transition:300ms;
}
 
.fa_voted, .fa_vote:hover { opacity:0.4 }
.fa_voted { cursor:default }
 
.fa_count {
  font-weight:bold;
  margin:0 3px;
  cursor:default;
}
 
.fa_positive { color:#4A0 }
.fa_negative { color:#A44 }
 
.fa_votebar, .fa_votebar_inner {
  background:#C44;
  height:3px;
}
 
.fa_votebar_inner {
  background:#4A0;
  transition:300ms;
}
O resultado será isto:
http://prntscr.com/931xae

Até mais,
CT
Chagas

Chagas
Membro

Membro desde : 22/10/2015
Mensagens : 893
Pontos : 1098

https://pelotao.forumeiros.com

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 16:31

O codigo que você forneceu funciona porém eu não quero o botao de dislike teria como tira-lo? e tente com que o titulo do topico nao desça para baixo dos botoes de editar, citar etc:

Alterar o botão "Curtir mensagem" 2lm9sp3
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Ajudeiro

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Fraise 15.11.15 16:33

Troque o código por este:
Código:
jQuery(document).ready(function() {
    for (var a = $('.post', document.getElementById('main-content')), i = 0, p, rep, votes, plus, item, button, pseudo, opts; p = a[i]; i++) {
        item = document.createElement('LI');
        button = document.createElement('A');
        button.innerHTML = '<img src="http://i.imgur.com/UdfqUxM.png" width="40px" height="40px">';
        button.className = 'fa_vote';
        rep = $('.vote', p)[0];
        opts = p.getElementsByTagName('UL')[0];
        pseudo = $('.postprofile dt', p).text();
        if (rep) {
            votes = $('.vote-bar', rep)[0];
            plus = rep.getElementsByTagName('A')[0];
            if (votes) {
                votes = votes.title.replace(/.*\((\d+).*/, '$1');
                item.innerHTML = '<span class="fa_votes">' + votes + '</span>';
                item.title = votes + (votes == 1 ? ' pessoa gostou do tópico ' : ' pessoas gostaram do tópico ') + pseudo + ''
            } else {
                item.innerHTML = '<span class="fa_votes">0</span>';
                item.title = 'Nenhum voto foi computado para ' + pseudo + ''
            }
            if (plus && /plus/i.test(plus.href)) {
                button.className += ' fa_like';
                button.href = plus.href;
                button.title = 'Curtir a mensagem de ' + pseudo + '';
                button.onclick = function() {
                    var t = this;
                    t.onclick = function() {
                        return false
                    };
                    $.get(t.href, function() {
                        var v = t.nextSibling;
                        v.innerHTML = Number(v.innerHTML) + 1;
                        t.className += 'd';
                        t.parentNode.title = v.innerHTML + (v.innerHTML == 1 ? ' pessoa gostou do tópico ' : ' pessoas gostaram do tópico ') + t.title.replace(/.*?\s(.*?)'.*/, '$1') + '';
                        t.removeAttribute('title');
                        t.href = '#'
                    });
                    return false
                }
            } else {
                button.href = '#';
                button.className += ' fa_liked';
                button.onclick = function() {
                    return false
                }
            }
            item.insertBefore(button, item.firstChild);
            opts.insertBefore(item, opts.firstChild);
            rep.parentNode.removeChild(rep)
        }
    }
});

Até mais.
Fraise
Fraise

Fraise
Ajudeiro
Ajudeiro

Membro desde : 26/06/2015
Mensagens : 6558
Pontos : 8045

https://ajuda.forumeiros.com/ https://twitter.com/@FraiseFdF

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Chagas 15.11.15 16:34

Altere o JS pra este:
Código:
$(function() {
  // General Configuration of the plugin
  var config = {
    position_left : true, // true for left || false for right
    negative_vote : true, // true for negative votes || false for positive only
    vote_bar : true, // display a small bar under the vote buttons
 
    // button config
    icon_plus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/plus10.png" alt="+"/>',
    icon_minus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/minus10.png" alt="-"/>',
 
    // language config
    title_plus : 'Like %{USERNAME}\'s post',
    title_minus : 'Dislike %{USERNAME}\'s post',
 
    title_like_singular : '%{VOTES} person likes %{USERNAME}\'s post',
    title_like_plural : '%{VOTES} people like %{USERNAME}\'s post',
 
    title_dislike_singular : '%{VOTES} person dislikes %{USERNAME}\'s post',
    title_dislike_plural : '%{VOTES} people dislike %{USERNAME}\'s post',
 
    title_vote_bar : '%{VOTES} people liked %{USERNAME}\'s post %{PERCENT}'
  },
   
   
  // function bound to the onclick handler of the vote buttons
  submit_vote = function() {
    var next = this.nextSibling, // the counter next to the vote button that was clicked
        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;
 
    // submit the vote asynchronously
    $.get(this.href, function() {
      next.innerHTML = +next.innerHTML + 1; // add to the vote count
      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 + ')');
      }
    });
 
    // revoke voting capabilities on the post once the vote is cast
    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('wrap') ? 1 : $('.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : 'badapple', // version check
 
  // version data so we don't have to redefine these arrays during the loop
  vdata = {
    tag : ['SPAN', 'LI', 'SPAN', 'LI'][version],
    name : ['.name', '.postprofile dt > strong', '.username', '.popmenubutton'][version],
    actions : ['.post-options', '.profile-icons', '.post-options', '.posting-icons'][version],
  },
 
  post, plus, minus, n_pos, n_neg, title_pos, title_neg, li, ul, bar, button, total, percent, span, pseudo, vote_bar; // startup variables for later use in the loop
 
  // prevent execution if the version cannot be determined
  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]).parentsUntil('.post').parent()[0];
    bar = $('.vote-bar', vote[i])[0]; // vote bar
    button = $('.vote-button', vote[i]); // plus and minus buttons
    pseudo = $(vdata.name, post).text() || 'MISSING_STRING'; // username of the poster
    ul = $(vdata.actions, post)[0]; // post actions
    li = document.createElement(vdata.tag); // vote system container
    li.className = 'fa_reputation';
 
    if (li.tagName == 'SPAN') li.style.display = 'inline-block';
 
    // calculate votes
    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;
    }
 
    // set up negative and positive titles with the correct grammar, votes, and usernames
    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);
 
    // define the vote counts
    li.innerHTML = '<span class="fa_count fa_positive" title="' + title_pos + '">' + n_pos + '</span>' + (config.negative_vote ? '&nbsp;<span class="fa_count fa_negative" title="' + title_neg + '">' + n_neg + '</span>' : '');
    span = li.getElementsByTagName('SPAN'); // get the vote count containers for use as insertion points
 
    // create positive vote button
    plus = document.createElement('A');
    plus.href = button[0] ? button[0].firstChild.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]);

    // create vote bar
    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);
    }
 
    // finally insert the vote system and remove the default one
    config.position_left ? ul.insertBefore(li, ul.firstChild) : ul.appendChild(li);
    vote[i].parentNode.removeChild(vote[i]);
  }
});

Até mais,
Chagas

Chagas
Membro

Membro desde : 22/10/2015
Mensagens : 893
Pontos : 1098

https://pelotao.forumeiros.com

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 16:36

Poderia colocar igual ao do FdF porém em vez de ser o like verde colocar azul @Fraise ?
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 16:38

Cutie falta isto o "0" a vermelho mantem se

Alterar o botão "Curtir mensagem" 256cp4p
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Chagas 15.11.15 16:39

Altere pra este
Código:
$(function() {
  // General Configuration of the plugin
  var config = {
    position_left : true, // true for left || false for right
    negative_vote : true, // true for negative votes || false for positive only
    vote_bar : true, // display a small bar under the vote buttons
 
    // button config
    icon_plus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/plus10.png" alt="+"/>',
    icon_minus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/minus10.png" alt="-"/>',
 
    // language config
    title_plus : 'Like %{USERNAME}\'s post',
    title_minus : 'Dislike %{USERNAME}\'s post',
 
    title_like_singular : '%{VOTES} person likes %{USERNAME}\'s post',
    title_like_plural : '%{VOTES} people like %{USERNAME}\'s post',
 
    title_dislike_singular : '%{VOTES} person dislikes %{USERNAME}\'s post',
    title_dislike_plural : '%{VOTES} people dislike %{USERNAME}\'s post',
 
    title_vote_bar : '%{VOTES} people liked %{USERNAME}\'s post %{PERCENT}'
  },
   
   
  // function bound to the onclick handler of the vote buttons
  submit_vote = function() {
    var next = this.nextSibling, // the counter next to the vote button that was clicked
        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;
 
    // submit the vote asynchronously
    $.get(this.href, function() {
      next.innerHTML = +next.innerHTML + 1; // add to the vote count
      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 + ')');
      }
    });
 
    // revoke voting capabilities on the post once the vote is cast
    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('wrap') ? 1 : $('.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : 'badapple', // version check
 
  // version data so we don't have to redefine these arrays during the loop
  vdata = {
    tag : ['SPAN', 'LI', 'SPAN', 'LI'][version],
    name : ['.name', '.postprofile dt > strong', '.username', '.popmenubutton'][version],
    actions : ['.post-options', '.profile-icons', '.post-options', '.posting-icons'][version],
  },
 
  post, plus, minus, n_pos, n_neg, title_pos, title_neg, li, ul, bar, button, total, percent, span, pseudo, vote_bar; // startup variables for later use in the loop
 
  // prevent execution if the version cannot be determined
  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]).parentsUntil('.post').parent()[0];
    bar = $('.vote-bar', vote[i])[0]; // vote bar
    button = $('.vote-button', vote[i]); // plus and minus buttons
    pseudo = $(vdata.name, post).text() || 'MISSING_STRING'; // username of the poster
    ul = $(vdata.actions, post)[0]; // post actions
    li = document.createElement(vdata.tag); // vote system container
    li.className = 'fa_reputation';
 
    if (li.tagName == 'SPAN') li.style.display = 'inline-block';
 
    // calculate votes
    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;
    }

    // define the vote counts
    li.innerHTML = '<span class="fa_count fa_positive" title="' + title_pos + '">' + n_pos + '</span>' + (config.negative_vote ? '&nbsp;<span class="fa_count fa_negative" title="' + title_neg + '">' + n_neg + '</span>' : '');
    span = li.getElementsByTagName('SPAN'); // get the vote count containers for use as insertion points
 
    // create positive vote button
    plus = document.createElement('A');
    plus.href = button[0] ? button[0].firstChild.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]);

    // create vote bar
    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);
    }
 
    // finally insert the vote system and remove the default one
    config.position_left ? ul.insertBefore(li, ul.firstChild) : ul.appendChild(li);
    vote[i].parentNode.removeChild(vote[i]);
  }
});

Até mais
CT
Chagas

Chagas
Membro

Membro desde : 22/10/2015
Mensagens : 893
Pontos : 1098

https://pelotao.forumeiros.com

Ir para o topo Ir para baixo

Ajudeiro
  • 0

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Fraise 15.11.15 16:41

O Cutie está apagando partes do código desnecessariamente, quando por opção, podemos colocar false no "negative vote":
Código:
negative_vote : false, // true for negative votes || false for positive only

Ou seja, ficaria assim:
Código:
$(function() {
  // General Configuration of the plugin
  var config = {
    position_left : true, // true for left || false for right
    negative_vote : false, // true for negative votes || false for positive only
    vote_bar : true, // display a small bar under the vote buttons
 
    // button config
    icon_plus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/plus10.png" alt="+"/>',
    icon_minus : '<img src="http://i18.servimg.com/u/f18/18/21/41/30/minus10.png" alt="-"/>',
 
    // language config
    title_plus : 'Like %{USERNAME}\'s post',
    title_minus : 'Dislike %{USERNAME}\'s post',
 
    title_like_singular : '%{VOTES} person likes %{USERNAME}\'s post',
    title_like_plural : '%{VOTES} people like %{USERNAME}\'s post',
 
    title_dislike_singular : '%{VOTES} person dislikes %{USERNAME}\'s post',
    title_dislike_plural : '%{VOTES} people dislike %{USERNAME}\'s post',
 
    title_vote_bar : '%{VOTES} people liked %{USERNAME}\'s post %{PERCENT}'
  },
   
   
  // function bound to the onclick handler of the vote buttons
  submit_vote = function() {
    var next = this.nextSibling, // the counter next to the vote button that was clicked
        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;
 
    // submit the vote asynchronously
    $.get(this.href, function() {
      next.innerHTML = +next.innerHTML + 1; // add to the vote count
      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 + ')');
      }
    });
 
    // revoke voting capabilities on the post once the vote is cast
    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('wrap') ? 1 : $('.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : 'badapple', // version check
 
  // version data so we don't have to redefine these arrays during the loop
  vdata = {
    tag : ['SPAN', 'LI', 'SPAN', 'LI'][version],
    name : ['.name', '.postprofile dt > strong', '.username', '.popmenubutton'][version],
    actions : ['.post-options', '.profile-icons', '.post-options', '.posting-icons'][version],
  },
 
  post, plus, minus, n_pos, n_neg, title_pos, title_neg, li, ul, bar, button, total, percent, span, pseudo, vote_bar; // startup variables for later use in the loop
 
  // prevent execution if the version cannot be determined
  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]).parentsUntil('.post').parent()[0];
    bar = $('.vote-bar', vote[i])[0]; // vote bar
    button = $('.vote-button', vote[i]); // plus and minus buttons
    pseudo = $(vdata.name, post).text() || 'MISSING_STRING'; // username of the poster
    ul = $(vdata.actions, post)[0]; // post actions
    li = document.createElement(vdata.tag); // vote system container
    li.className = 'fa_reputation';
 
    if (li.tagName == 'SPAN') li.style.display = 'inline-block';
 
    // calculate votes
    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;
    }
 
    // set up negative and positive titles with the correct grammar, votes, and usernames
    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);
 
    // define the vote counts
    li.innerHTML = '<span class="fa_count fa_positive" title="' + title_pos + '">' + n_pos + '</span>' + (config.negative_vote ? '&nbsp;<span class="fa_count fa_negative" title="' + title_neg + '">' + n_neg + '</span>' : '');
    span = li.getElementsByTagName('SPAN'); // get the vote count containers for use as insertion points
 
    // create positive vote button
    plus = document.createElement('A');
    plus.href = button[0] ? button[0].firstChild.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]);
 
    // create negative vote button
    if (config.negative_vote) {
      minus = document.createElement('A');
      minus.href = button[1] ? button[1].firstChild.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]);
    }
 
    // create vote bar
    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);
    }
 
    // finally insert the vote system and remove the default one
    config.position_left ? ul.insertBefore(li, ul.firstChild) : ul.appendChild(li);
    vote[i].parentNode.removeChild(vote[i]);
  }
});

Até mais.
Fraise
Fraise

Fraise
Ajudeiro
Ajudeiro

Membro desde : 26/06/2015
Mensagens : 6558
Pontos : 8045

https://ajuda.forumeiros.com/ https://twitter.com/@FraiseFdF

Ir para o topo Ir para baixo

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por King' 15.11.15 17:05

funcionou obrigada aos dois
King'

King'
Membro

Membro desde : 15/02/2014
Mensagens : 583
Pontos : 925

http://pokemonrealforcerpg.portugueseforum.net/

Ir para o topo Ir para baixo

Ajudeiro

Tópico resolvido Re: Alterar o botão "Curtir mensagem"

Mensagem por Fraise 15.11.15 17:08

Alterar o botão "Curtir mensagem" Symbol10 Questão marcada como Resolvida ou o Autor solicitou que ela fosse arquivada.

Tópico marcado como Resolvido e movido para "Questões resolvidas".
Fraise

Fraise
Ajudeiro
Ajudeiro

Membro desde : 26/06/2015
Mensagens : 6558
Pontos : 8045

https://ajuda.forumeiros.com/ https://twitter.com/@FraiseFdF

Ir para o topo Ir para baixo

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

- Tópicos semelhantes

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