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

Added action on PRE elements + French translations #1

Open
wants to merge 8 commits into
base: master
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
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
Redmine plugin to collapse quotes in issue history.
History
* v 0.0.2:
** Made image links be relative so that it both works with redmine installed at the root or in a subfolder (such as /redmine)
4 changes: 2 additions & 2 deletions app/views/hooks/_view_issues_show_description_bottom.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ a.toggle-quoted-text {
}

a.quoted-text-collapsed {
background-image: url(/images/arrow_collapsed.png);
background-image: url(../images/arrow_collapsed.png);
}

a.quoted-text-expanded {
background-image: url(/images/arrow_expanded.png);
background-image: url(../images/arrow_expanded.png);
}
</style>

Expand Down
38 changes: 20 additions & 18 deletions assets/javascripts/collapse_quotes.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
Event.observe(window, 'load', function() {
$$('#history > div.has-notes').each(function(div) {
div.select('blockquote').each(function(blockquote) {
if (blockquote.getHeight() < 100)
$(function() {
$('#history div.has-notes').each(function(i) {
$(this).find("blockquote,pre").each(function(i) {
q = $(this);
if (q.height() < 100)
return;

anchor = '<a class="toggle-quoted-text quoted-text-collapsed" href="#" onclick="return toggleQuotedTextVisibility(this);">' + getShowQuotedTextString() + '</a>';
blockquote.insert({ before: anchor });
blockquote.hide();
a = '<a class="toggle-quoted-text quoted-text-collapsed" href="#" onclick="return toggleQuotedTextVisibility(this);">' + getShowQuotedTextString() + '</a>';
q.before(a);
q.hide();
});
});
});

function toggleQuotedTextVisibility(anchor) {
anchor = $(anchor);
blockquote = anchor.next("blockquote");
blockquote.toggle();
if (blockquote.visible()) {
anchor.innerText = getShowQuotedTextString();
anchor.removeClassName("quoted-text-collapsed");
anchor.addClassName("quoted-text-expanded");
function toggleQuotedTextVisibility(a) {
a = $(a);
q = a.next("blockquote,pre");
q.toggle();
// reflect current visibility state
if (q.is(':visible')) {
a.text(getHideQuotedTextString());
a.removeClass("quoted-text-collapsed");
a.addClass("quoted-text-expanded");
} else {
anchor.innerText = getHideQuotedTextString();
anchor.addClassName("quoted-text-collapsed");
anchor.removeClassName("quoted-text-expanded");
a.text(getShowQuotedTextString());
a.addClass("quoted-text-collapsed");
a.removeClass("quoted-text-expanded");
}
return false;
}
4 changes: 4 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# English strings go here for Rails i18n
fr:
label_show_quoted_text: "- Afficher la citation -"
label_hide_quoted_text: "- Masquer la citation -"
3 changes: 3 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
it:
label_show_quoted_text: "- Mostra testo citato -"
label_hide_quoted_text: "- Nascondi testo citato -"
3 changes: 1 addition & 2 deletions init.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

require 'redmine'
require 'dispatcher'

require_dependency 'redmine_collapse_quotes/view_hooks'

Redmine::Plugin.register :redmine_collapse_quotes do
name 'Redmine Collapse Quotes plugin'
author 'Alex Shulgin <[email protected]>'
description 'Redmine plugin to collapse quotes in issue history'
version '0.0.1'
version '0.0.2'
# url 'https://github.com/commandprompt/redmine_collapse_quotes/'
# author_url 'http://example.com/about'

Expand Down