-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
147 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
<% unless User.current.login == '' %> | ||
<% unless @board.nil? || @board[:id].nil? || @topic.nil? || @topic.id.nil? %> | ||
<div id="vote" class="vote-area" data-board="<%=@board[:id] %>" data-topic="<%=@topic.id %>"> | ||
<div><a class="vote-button" href="#" data-point="1">▲</a></div> | ||
<div class="vote-point">-</div> | ||
<div><a class="vote-button" href="#" data-point="-1">▼</a></div> | ||
</div> | ||
<label id="label_vote_count" style="display:none"><%=l(:label_vote_count)%></label> | ||
<% end %> | ||
<div id="vote" class="vote-area" data-board="<%=@board.id%>" data-topic="<%=@topic.id%>"> | ||
<div><a class="vote-button" href="#" data-point="1">▲</a></div> | ||
<div class="vote-point">-</div> | ||
<div><a class="vote-button" href="#" data-point="-1">▼</a></div> | ||
</div> | ||
<label id="label_vote_count" style="display:none"><%=l(:label_vote_count)%></label> | ||
<% end %> | ||
<input type="hidden" id="vote-base-url" value="<%=url_for :controller => 'welcome' %>" /> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,123 @@ | ||
/* vote.uncompressed.js Compressed file. using UglifyJS. */ | ||
$(document).ready(function(){var e=$("#vote-base-url");var t="";if(e.length>0){t=e.val()}if($(".controller-messages").length&&$("#vote").length){var n=$("<div></div>").css({clear:"right"});var r=[];$(".message").each(function(){r.push($(this))});var i=function(){if(r.length){s(r.shift())}};var s=function(e){var n=$.Deferred();var r=e.attr("id");var s=$("#vote").clone().show().attr({id:null});if(r){s.data({topic:parseInt(String(r).replace(/message-/gi,""))})}e.css({clear:"both"}).prepend(s);var o=s.data("board");var u=s.data("topic");var a=s.find(".vote-point:first");$.ajax({type:"GET",url:t+"boards/"+o+"/topics/"+u+"/vote",cache:false,error:function(e,t,n){a.html("-")},success:function(e,t,n){a.html($(e).find("#vote-point").html())}}).always(function(){n.always();s.find(".vote-button").bind("click",function(e){e.preventDefault();var n=$(this).data("point");$.ajax({type:"POST",url:t+"boards/"+o+"/topics/"+u+"/vote",data:{point:n},cache:false,success:function(e,t,n){a.html($(e).find("#vote-point").html())}})});i()});return n.promise()};i()}var o=/https?:\/\/.*\/projects\/.*\/boards\/([0-9]*)/;var u=document.URL;var a=u.match(o);var f="#vote-result";if(a){$("<div></div>").attr("id","vote-result-box").insertAfter($("#content").find("p.breadcrumb"));$.ajax({type:"GET",url:t+"boards/"+a[1]+"/vote/result",cache:false,success:function(e,t,n){if($(f).length===0){var r=$(e).find(f).html();if(r){$("#vote-result-box").addClass("vote-result").html(r)}else{$("#vote-result-box").remove()}}}});var l=$("table.list.messages");$("<th></th>").html($("#label_vote_count").text()).insertAfter(l.find("thead > tr > th:nth-child(3)"));$("<td></td>").addClass("vote-td-trigger").insertAfter(l.find("tbody > tr > td:nth-child(3)"));$("td.vote-td-trigger").each(function(){var e=/\/boards\/([0-9]*)\/topics\/([0-9]*)/;var n=$(this).parent().find("td.subject > a").attr("href");var r=n.match(e);if(r){var i=r[1];var s=r[2];var o=$(this);$.ajax({type:"GET",url:t+"boards/"+i+"/topics/"+s+"/vote",cache:false,success:function(e,t,n){o.html($(e).find("#vote-point").html())}})}})}}) | ||
$(document).ready(function() { | ||
if($(".controller-messages").length && $("#vote").length) { | ||
var clr = $("<div></div>").css({ clear: "right" }); | ||
var queue = []; | ||
$(".message").each( | ||
function() { | ||
queue.push($(this)); | ||
} | ||
); | ||
|
||
var execQueue = function() { | ||
if(queue.length) { | ||
queueStep(queue.shift()); | ||
} | ||
}; | ||
|
||
var queueStep = function(that) { | ||
var deferred = $.Deferred(); | ||
var messageId = that.attr("id"); | ||
var vote = $("#vote").clone().show().attr({ id: null }); | ||
if(messageId) { | ||
vote.data({ topic: parseInt(String(messageId).replace(/message-/gi, "")) }); | ||
} | ||
that.css({ "clear": "both" }).prepend(vote); | ||
|
||
var board = vote.data("board"); | ||
var topic = vote.data("topic"); | ||
var votePoint = vote.find(".vote-point:first"); | ||
var voteCheck = vote.find(".vote-check:first"); | ||
|
||
$.ajax({ | ||
type: "GET", | ||
url: "/boards/" + board + "/topics/" + topic + "/vote", | ||
cache: false, | ||
error: function(jqXHR, textStatus, errorThrown) { | ||
votePoint.html("-"); | ||
}, | ||
success: function(data, textStatus, jqXHR) { | ||
votePoint.html(data.point); | ||
voteCheck.html(data.vote ? "☑" : "✅"); | ||
} | ||
|
||
}).always(function() { | ||
deferred.always(); | ||
|
||
vote.find(".vote-button").bind("click", function(event) { | ||
event.preventDefault(); | ||
var point = $(this).data("point"); | ||
$.ajax({ | ||
type: "POST", | ||
url: "/boards/" + board + "/topics/" + topic + "/vote", | ||
data: { point: point }, | ||
cache: false, | ||
success: function(data, textStatus, jqXHR) { | ||
votePoint.html(data.point); | ||
voteCheck.html(data.vote ? "☑" : "✅"); | ||
} | ||
}); | ||
}); | ||
|
||
execQueue(); | ||
}); | ||
return deferred.promise(); | ||
}; | ||
execQueue(); | ||
}; | ||
|
||
var re = /https?:\/\/.*\/projects\/.*\/boards\/([0-9]*)/; | ||
var url = document.URL; | ||
var match = url.match(re); | ||
var result = "#vote-result"; | ||
|
||
if(match) { | ||
$("<div></div>") | ||
.attr("id", "vote-result-box") | ||
.insertAfter($("#content").find("p.breadcrumb")); | ||
|
||
$.ajax({ | ||
type: "GET", | ||
url: "/boards/" + match[1] + "/vote/result", | ||
cache: false, | ||
success: function(data, textStatus, jqXHR) { | ||
if($(result).length === 0) { | ||
var html = $(data).find(result).html(); | ||
if(html) { | ||
$("#vote-result-box").addClass("vote-result").html(html); | ||
}else { | ||
$("#vote-result-box").remove(); | ||
} | ||
} | ||
} | ||
}); | ||
|
||
var table = $("table.list.messages"); | ||
|
||
$("<th></th>") | ||
.html($("#label_vote_count").text()) | ||
.insertAfter(table.find("thead > tr > th:nth-child(3)")); | ||
|
||
$("<td></td>") | ||
.addClass("vote-td-trigger") | ||
.insertAfter(table.find("tbody > tr > td:nth-child(3)")); | ||
|
||
$("td.vote-td-trigger").each(function() { | ||
var _re = /\/boards\/([0-9]*)\/topics\/([0-9]*)/; | ||
var _href = $(this).parent().find("td.subject > a").attr("href"); | ||
var _match = _href.match(_re); | ||
if(_match) { | ||
var _board = _match[1]; | ||
var _topic = _match[2]; | ||
var _this = $(this); | ||
$.ajax({ | ||
type: "GET", | ||
url: "/boards/" + _board + "/topics/" + _topic + "/vote", | ||
cache: false, | ||
success: function(data, textStatus, jqXHR) { | ||
_this.html(data.point); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
en: | ||
label_vote_result: "Vote Result" | ||
label_vote_count: "Votes" | ||
label_vote_count: "Votes" |