Adds a macro for inserting collapsed text (#12167).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10680 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
0faab70be5
commit
d29fa4735b
|
@ -933,6 +933,7 @@ en:
|
|||
button_quote: Quote
|
||||
button_duplicate: Duplicate
|
||||
button_show: Show
|
||||
button_hide: Hide
|
||||
button_edit_section: Edit this section
|
||||
button_export: Export
|
||||
button_delete_my_account: Delete my account
|
||||
|
|
|
@ -907,6 +907,7 @@ fr:
|
|||
button_quote: Citer
|
||||
button_duplicate: Dupliquer
|
||||
button_show: Afficher
|
||||
button_hide: Cacher
|
||||
button_edit_section: Modifier cette section
|
||||
button_export: Exporter
|
||||
button_delete_my_account: Supprimer mon compte
|
||||
|
|
|
@ -212,6 +212,19 @@ module Redmine
|
|||
out
|
||||
end
|
||||
|
||||
desc "Inserts of collapsed block of text. Example:\n\n {{collapse(View details...)\nThis is a block of text that is collapsed by default.\nIt can be expanded by clicking a link.\n}}"
|
||||
macro :collapse do |obj, args, text|
|
||||
html_id = "collapse-#{Redmine::Utils.random_hex(4)}"
|
||||
show_label = args[0] || l(:button_show)
|
||||
hide_label = args[1] || args[0] || l(:button_hide)
|
||||
js = "$('##{html_id}-show, ##{html_id}-hide').toggle(); $('##{html_id}').fadeToggle(150);"
|
||||
out = ''.html_safe
|
||||
out << link_to_function(show_label, js, :id => "#{html_id}-show", :class => 'collapsible collapsed')
|
||||
out << link_to_function(hide_label, js, :id => "#{html_id}-hide", :class => 'collapsible', :style => 'display:none;')
|
||||
out << content_tag('div', textilizable(text, :object => obj), :id => html_id, :class => 'collapsed-text', :style => 'display:none;')
|
||||
out
|
||||
end
|
||||
|
||||
desc "Displays a clickable thumbnail of an attached image. Examples:\n\n<pre>{{thumbnail(image.png)}}\n{{thumbnail(image.png, size=300, title=Thumbnail)}}</pre>"
|
||||
macro :thumbnail do |obj, args|
|
||||
args, options = extract_macro_options(args, :size, :title)
|
||||
|
|
|
@ -185,6 +185,11 @@ class ActiveSupport::TestCase
|
|||
assert !s.include?(expected), "\"#{expected}\" found in \"#{s}\""
|
||||
end
|
||||
|
||||
def assert_select_in(text, *args, &block)
|
||||
d = HTML::Document.new(CGI::unescapeHTML(String.new(text))).root
|
||||
assert_select(d, *args, &block)
|
||||
end
|
||||
|
||||
def assert_mail_body_match(expected, mail)
|
||||
if expected.is_a?(String)
|
||||
assert_include expected, mail_body(mail)
|
||||
|
|
|
@ -180,6 +180,36 @@ class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase
|
|||
assert_include 'Page not found', textilizable(text)
|
||||
end
|
||||
|
||||
def test_macro_collapse
|
||||
text = "{{collapse\n*Collapsed* block of text\n}}"
|
||||
result = textilizable(text)
|
||||
|
||||
assert_select_in result, 'div.collapsed-text'
|
||||
assert_select_in result, 'strong', :text => 'Collapsed'
|
||||
assert_select_in result, 'a.collapsible.collapsed', :text => 'Show'
|
||||
assert_select_in result, 'a.collapsible', :text => 'Hide'
|
||||
end
|
||||
|
||||
def test_macro_collapse_with_one_arg
|
||||
text = "{{collapse(Example)\n*Collapsed* block of text\n}}"
|
||||
result = textilizable(text)
|
||||
|
||||
assert_select_in result, 'div.collapsed-text'
|
||||
assert_select_in result, 'strong', :text => 'Collapsed'
|
||||
assert_select_in result, 'a.collapsible.collapsed', :text => 'Example'
|
||||
assert_select_in result, 'a.collapsible', :text => 'Example'
|
||||
end
|
||||
|
||||
def test_macro_collapse_with_two_args
|
||||
text = "{{collapse(Show example, Hide example)\n*Collapsed* block of text\n}}"
|
||||
result = textilizable(text)
|
||||
|
||||
assert_select_in result, 'div.collapsed-text'
|
||||
assert_select_in result, 'strong', :text => 'Collapsed'
|
||||
assert_select_in result, 'a.collapsible.collapsed', :text => 'Show example'
|
||||
assert_select_in result, 'a.collapsible', :text => 'Hide example'
|
||||
end
|
||||
|
||||
def test_macro_child_pages
|
||||
expected = "<p><ul class=\"pages-hierarchy\">\n" +
|
||||
"<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a>\n" +
|
||||
|
|
Loading…
Reference in New Issue