You are not connected. Please login or register

[Code] Nút Like & Dislike

Go down  Thông điệp [Trang 1 trong tổng số 1 trang]

SuperMan

SuperMan
»Admin
»Admin

Demo :
 [Code] Nút Like & Dislike  Captur14

B1 và B2 ở dưới để ở chỗ thích hợp nhé
B1:Chèn Nút Like và Dislike

Code:
<div style="float: left;margin-top: 1px;">
                      <!-- BEGIN switch_vote_active -->
          <div class="vote vote-button" title="Thích bài viết này">
              <!-- BEGIN switch_vote -->
          <a target="v{postrow.displayed.U_POST_ID}" href="{postrow.displayed.switch_vote_active.switch_vote.U_VOTE_PLUS}" alt="c3zplus" class="c3zplus lvote"><span style="font: normal 11px Tahoma, Arial, Helvetica, sans-serif;margin-left: -2px; color: #3B5998;">Thích</span></a>
              <!-- END switch_vote -->
          </div>
          <div class="vote vote-button" title="Không thích bài viết này">
              <!-- BEGIN switch_vote -->
            <a target="v{postrow.displayed.U_POST_ID}" href="{postrow.displayed.switch_vote_active.switch_vote.U_VOTE_MINUS}" alt="c3zminus" class="c3zminus lvote"><span style="font: normal 11px Tahoma, Arial, Helvetica, sans-serif;margin-left: -2px; color: #3B5998;">Không thích</span></a>
            <!-- END switch_vote --></div><div id="v{postrow.displayed.U_POST_ID}" class="loadding" style="display: none"><img src="http://i43.servimg.com/u/f43/16/03/04/56/icon_l12.gif"/> Đang Vote chờ xíu ^_^! </div>
                                                      <!-- END switch_vote_active --></div>

B2:Chèn Phần đếm số vote

Code:
<div style="float:left; margin-top:5px;background-color:#FFF;">
                  <!-- BEGIN switch_vote_active -->     
      <iframe name="v{postrow.displayed.U_POST_ID}" class="ajaxvote" style="display:none"></iframe>
    <!-- BEGIN switch_no_bar -->
      <span class="c3zvau v{postrow.displayed.U_POST_ID}" title="{postrow.displayed.switch_vote_active.L_VOTE_TITLE}">{postrow.displayed.switch_vote_active.L_VOTE_TITLE}</span>
    <!-- END switch_no_bar -->
    <!-- BEGIN switch_bar -->
      <span class="c3zvau v{postrow.displayed.U_POST_ID}" title="{postrow.displayed.switch_vote_active.L_VOTE_TITLE}">{postrow.displayed.switch_vote_active.L_VOTE_TITLE}</span>
    <!-- END switch_bar -->
                      <!-- END switch_vote_active --></div>

B3: Cho nốt code này vào cuối viewtopic_body là xong

Code:
<style>
    /*vote*/
    .ost,.share,.c3zvau .qua,.no{background-position:5px 50%;background-repeat:no-repeat;border:1px solid #C2D5E3;margin:6px 2px 0;padding:5px 8px 5px 25px}.share{background-image:url(http://i43.servimg.com/u/f43/16/03/04/56/fav10.png)}.qua{background-image:url(http://i43.servimg.com/u/f43/16/03/04/56/no10.gif);padding-left:29px!important}.no{padding:5px 8px}.no .vop{background:url(http://i43.servimg.com/u/f43/16/03/04/56/like-f10.png) no-repeat left center;padding:0 0 0 18px}.no .vom{background:url(http://i43.servimg.com/u/f43/16/03/04/56/dislik10.png) no-repeat left center;padding:0 0 0 18px}
    .vote-button{float:left;width:60px}
    .c3zplus:hover{background-color:#ebedf4;border-color:#9dacce}
    .c3zminus:hover{background-color:#ebedf4;border-color:#9dacce}
    .c3zplus {
    background: url(http://i43.servimg.com/u/f43/16/03/04/56/like-f10.png) no-repeat scroll 0 0 #ECEEF5;
    background-position: 6px 36%;
    background-repeat: no-repeat;
    border: 1px solid #CAD4E7;
    border-radius: 3px 3px 3px 3px;
    color: white!important;
    display: block;
    float: left;
    height: 13px;
    margin: -4px 2px 0;
    padding: 4px 4px 5px 24px;
    position: relative;
    text-align: left;
    width: 25px;
    }
    .c3zminus {
    background: url(http://i43.servimg.com/u/f43/16/03/04/56/dislik10.png) no-repeat scroll #ECEEF5;
    background-position: 6px 36%;
    background-repeat: no-repeat;
    border: 1px solid #CAD4E7;
    border-radius: 3px 3px 3px 3px;
    color: white!important;
    display: block;
    float: left;
    height: 13px;
    margin: -4px 0px 0;
    padding: 4px 4px 5px 24px;
    position: relative;
    text-align: left;
    width: 55px;
    }
    </style>
    <script type="text/javascript">
    function chvote(a, b) {
      "Message not voted" == b && (b = "c3zone z vietk 0% (0 vote)");
      var d = parseInt(b.split(" ")[3], 10) / 100,
          c = parseInt(b.split(" ")[4].substr(1), 10),
          b = "Message reputation : " + Math.round(100 * ("c3zplus" == a ? (d * c + 1) / (c + 1) : d * c / (c + 1))) + "% (" + (c + 1) + " vote)";
      return votetrans(b)
    }
    $(".c3zvau").each(function () {
      var a = $(this).text();
      $(this).html(votetrans(a))
    });

    function votetrans(a) {
      if ("Message not voted" == a) return "<span class='qua'>Hãy là người đầu tiên thích điều này</span>";
      var b = parseInt(a.split(" ")[3], 10) / 100,
          a = parseInt(a.split(" ")[4].substr(1), 10),
          d = 0 != b ? "<span class=vop>" + Math.round(b * a) + "+</span>" : "",
          c = 0 != b && 1 != b ? ' <span style="color:#C2D5E3">|</span> ' : "",
          a = 1 != b ? "<span class=vom>" + Math.round(a - b * a) + "-</span>" : "",
          b = Math.round(100 * b);
      return "<span class=no>" + d + c + a + "</span> <span class=qua>Đánh giá: " + b + "%</span>"
    }
    $(".lvote").click(function () {
      "c3zplus" == $(this).attr("alt") ? $(this).parent().html("").next().html("") : $(this).parent().html("").prev().html("");
      var a = $(this).attr("target"),
          b = $(this).attr("alt"),
          d = $("." + a).attr("title");
      $("#" + a).show();
      $("." + a).html(chvote(b, d));
      $("#" + a).fadeIn("slow").animate({
          opacity: 1
      }, 1500).fadeOut("slow", function () {
          $("." + a).fadeOut("slow").animate({
            opacity: 1
          }, 1E3).fadeIn()
      });
      $("." + $(this).attr("target")).removeAttr("title")
    });
    </script>

Nguồn : CNTT-K3.ORG

Về Đầu Trang  Thông điệp [Trang 1 trong tổng số 1 trang]

Permissions in this forum:
Bạn không có quyền trả lời bài viết