summaryrefslogtreecommitdiffstats
path: root/lib/redmine/wiki_formatting
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-20 14:49:32 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-10-20 14:49:32 +0000
commitd29fa4735b5744f3288e9c33a9e81a5f36abcca1 (patch)
treea94c328505f4c4a8cba94bc16bf0f70b6a790f78 /lib/redmine/wiki_formatting
parent0faab70be58c2b52963b9eb02cc941e32b3c44c7 (diff)
downloadredmine-d29fa4735b5744f3288e9c33a9e81a5f36abcca1.tar.gz
redmine-d29fa4735b5744f3288e9c33a9e81a5f36abcca1.zip
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
Diffstat (limited to 'lib/redmine/wiki_formatting')
-rw-r--r--lib/redmine/wiki_formatting/macros.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb
index 50dbb853d..a50f2d289 100644
--- a/lib/redmine/wiki_formatting/macros.rb
+++ b/lib/redmine/wiki_formatting/macros.rb
@@ -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)