2012-10-29 13:43:52 +00:00
{% load i18n %}
2012-09-03 12:54:07 +00:00
{% load url from future %}
2013-03-15 06:41:20 +00:00
var Bottom_bar = '< div id = "bottom-bar" > {% if groups %}< button id = "discuss" > {% trans "Discuss" %}< / button > < button id = "click-into-group" > {% trans "To group" %}< / button > {% endif %}< / div > ';
2012-08-08 09:14:04 +00:00
$('#wrapper').append(Bottom_bar);
2013-03-15 06:41:20 +00:00
$('#main-panel').css('margin-bottom', $('#bottom-bar').outerHeight() + 2);
2012-08-15 06:16:15 +00:00
$('#footer').addClass('hide');
2012-10-20 12:18:08 +00:00
{% if groups %}
2013-03-15 06:41:20 +00:00
$('#discuss').click(function() {
var form = $('#discuss-to-group-form');
var caret = $('#discuss-to-group-caret');
if (form.hasClass('hide')) {
form.removeClass('hide');
caret.removeClass('hide');
caret.css({'left': $(this).offset().left});
2012-10-22 09:15:35 +00:00
} else {
2013-03-15 06:41:20 +00:00
form.addClass('hide');
caret.addClass('hide');
2012-10-22 09:15:35 +00:00
}
});
$(document).click(function(e) {
var target = e.target || event.srcElement;
2013-03-15 06:41:20 +00:00
if (!$('#discuss, #discuss-to-group-form, #discuss-to-group-caret').is(target) & & !($('#discuss-to-group-form, #discuss-to-group-caret').find('*').is(target))) {
$('#discuss-to-group-form, #discuss-to-group-caret').addClass('hide');
2012-10-22 09:15:35 +00:00
}
2012-08-08 09:14:04 +00:00
});
2012-09-03 12:54:07 +00:00
2013-03-15 06:41:20 +00:00
$('#discuss-submit').click(function() {
if (!$.trim($('#discuss-to-group-form .input').val())) {
apply_form_error('discuss-to-group-form', '{% trans "Please input a discussion." %}');
2012-10-22 09:15:35 +00:00
return false;
}
});
$('#main').append('< div id = "to-group" class = "hide" > {{ repo_group_str|escapejs }}< / div > < div id = "to-group-caret" class = "hide" > < div class = "outer-caret" > < div class = "inner-caret" > < / div > < / div > < / div > ');
2012-09-03 12:54:07 +00:00
$('#click-into-group').click(function() {
2012-10-19 06:25:23 +00:00
{% if groups|length == 1 %}
// only one group, just turn to group page
2012-09-03 12:54:07 +00:00
{% for group in groups %}
location.href= "{% url 'group_info' group.id %}";
{% endfor %}
2012-11-13 08:22:35 +00:00
2012-10-19 06:25:23 +00:00
{% else %}
// more than one group, then let user choose
2012-10-20 13:37:02 +00:00
if ($('#to-group').hasClass('hide')) {
$('#to-group, #to-group-caret').removeClass('hide');
2012-11-13 08:22:35 +00:00
$('#to-group-caret').css('left', $('#click-into-group').offset().left + $('#click-into-group').width()/3);
if ($('#to-group').offset().left > $('#click-into-group').offset().left) {
$('#to-group').css('left', $('#click-into-group').offset().left);
}
2012-10-20 13:37:02 +00:00
} else {
$('#to-group, #to-group-caret').addClass('hide');
}
2012-10-19 06:25:23 +00:00
{% endif %}
2012-09-03 12:54:07 +00:00
});
2012-10-20 13:37:02 +00:00
$(document).click(function(e) {
var target = e.target || event.srcElement;
if (!$('#click-into-group, #to-group, #to-group-caret').is(target) & & !($('#to-group, #to-group-caret').find('*').is(target))) {
$('#to-group, #to-group-caret').addClass('hide');
}
});
2012-11-28 11:39:22 +00:00
{% endif %}
2012-11-13 08:22:35 +00:00
$(function() {
var btn_height = $('#bottom-bar button').outerHeight();
2013-03-15 06:41:20 +00:00
$('#discuss-to-group-caret, #to-group-caret, #comment-caret').css({'bottom': btn_height + 1});
$('#file-comment, #to-group, #discuss-to-group-form').css({'bottom': btn_height + 1 + $('.outer-caret').outerHeight()});
2012-11-13 08:22:35 +00:00
});