Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some fixes and addons #2

Open
wants to merge 2 commits into
base: 0.0.3-stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions app/views/issues/_history.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

<% reply_links = authorize_for('issues', 'edit') -%>
<% tabs = [
{:label => :label_history_tab_all, :name => 'history_all'},
{:label => :label_history_tab_comments, :name => 'history_comments'},
{:label => :label_history_tab_all, :name => 'history_all'},
] %>
<% selected_tab = params[:tab] ? params[:tab].to_s : 'history_comments' %>

<div class="tabs">
<div class="tabs" id="tabs-scroll">
<ul>
<% tabs.each do |tab| -%>
<li><%= link_to l(tab[:label]), { :tab => tab[:name] },
Expand All @@ -27,16 +27,14 @@
<%= content_tag('a', '', :name => "note-#{journal.indice}")%>
<%= authoring journal.created_on, journal.user, :label => :label_updated_time_by %></h4>

<% if journal.details.any? %>
<ul class="details">
<% details_to_strings(journal.details).each do |string| %>
<li><%= string %></li>
<% end %>
</ul>
<% end %>
<%= render_notes(issue, journal, :reply_links => reply_links) unless journal.notes.blank? %>
</div>
<%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
<%= call_hook(:view_issues_history_journal_bottom, { :journal => journal }) %>
<% end %>

<% heads_for_wiki_formatter if User.current.allowed_to?(:edit_issue_notes, issue.project) || User.current.allowed_to?(:edit_own_issue_notes, issue.project) %>
Expand Down
60 changes: 53 additions & 7 deletions assets/javascripts/issue-history-tabs.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
/*
Author: Daniel Munn <https://github.com/danmunn
Author: Radovan Kepák <https://github.com/bckp
Date: 23/05/2012
*/
function init_tabs() {
tabComment = $('tab-history_comments');
tabAll = $('tab-history_all');
tabComment.observe('click', click_comments);
tabAll.observe('click', click_all);
tabComment.hasClassName('selected') ? show_comments() : show_all();
function init_tabs(){
try{
tabComment = $('tab-history_comments');
tabAll = $('tab-history_all');
tabComment.observe('click', click_comments);
tabAll.observe('click', click_all);
tabComment.hasClassName('selected') ? show_comments() : show_all();
tabScroll = {elm: $('tabs-scroll')};

init_scroll_tabs();

Event.observe(window, 'scroll', function(){
scroll_tabs();
});

Event.observe(window, 'resize', function(){
init_scroll_tabs();
});
}catch(e){};
}

function init_scroll_tabs(){
//Reset position, set width
tabScroll.elm.setStyle({
'position': 'absolute', 'left': '0px',
'width': $('content').getLayout().get('width') + 'px'
});
a = $('tabs-scroll').cumulativeOffset();

//Set new values
tabScroll.top = a.top;
tabScroll.left = a.left;

//Call
scroll_tabs();
}

function show_comments() {
$$('.journal').invoke('hide');
$$('.journal .details').invoke('hide');
$$('.journal.has-notes').invoke('show');
}

function show_all() {
$$('.journal .details').invoke('show');
$$('.journal').invoke('show');
}

Expand All @@ -33,9 +65,23 @@ function click_all(e) {
Event.stop(e);
}

function scroll_tabs(){
if( (document.viewport.getScrollOffsets().top - tabScroll.top) > 0 )
tabScroll.elm.setStyle({
'position': 'fixed',
'left': tabScroll.left + 'px',
});
else
tabScroll.elm.setStyle({
'position': 'absolute',
'left': '0px'
});
}

var tabAll;
var tabComment;
var tabScroll;

document.observe('dom:loaded', function(){
init_tabs();
});
});
13 changes: 12 additions & 1 deletion assets/stylesheets/issue_history_tabs.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#history{
position: relative;
}

#history > h3 {
display: none;
visibility: hidden;
}

#history > #tabs-scroll{
position: absolute;
top: 0px;
left: 0px;
background: white;
}
3 changes: 3 additions & 0 deletions config/locales/cs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cs:
label_history_tab_all: Vše
label_history_tab_comments: Komentáře