From 76258ab653995bca7ef12d7975015f6352c9c3df Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Fri, 25 Jul 2008 21:48:52 +0000 Subject: [PATCH] ActionItem519: modularizing thickbox stuff --- app/helpers/application_helper.rb | 2 ++ app/helpers/thickbox_helper.rb | 8 ++++++++ app/views/shared/user_menu.rhtml | 4 ++-- test/unit/thickbox_helper_test.rb | 21 +++++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 app/helpers/thickbox_helper.rb create mode 100644 test/unit/thickbox_helper_test.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 24b2248..53cfd64 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -6,6 +6,8 @@ module ApplicationHelper include LightboxHelper + include ThickboxHelper + include BoxesHelper include FormsHelper diff --git a/app/helpers/thickbox_helper.rb b/app/helpers/thickbox_helper.rb new file mode 100644 index 0000000..1916c52 --- /dev/null +++ b/app/helpers/thickbox_helper.rb @@ -0,0 +1,8 @@ +module ThickboxHelper + def thickbox_inline_popup_link(title, id, options = {}) + link_to(title, "#TB_inline?height=300&width=500&inlineId=#{id}&modal=true", {:class => 'thickbox'}.merge(options)) + end + def thickbox_close_button(title) + button_to_function(:close, title, 'tb_remove();') + end +end diff --git a/app/views/shared/user_menu.rhtml b/app/views/shared/user_menu.rhtml index 6a3272f..235e2c2 100644 --- a/app/views/shared/user_menu.rhtml +++ b/app/views/shared/user_menu.rhtml @@ -58,9 +58,9 @@ -<%= _('Login') %> +<%= thickbox_inline_popup_link ''+ _('Login'), 'inlineLoginBox' %> <% end %> diff --git a/test/unit/thickbox_helper_test.rb b/test/unit/thickbox_helper_test.rb new file mode 100644 index 0000000..70776cd --- /dev/null +++ b/test/unit/thickbox_helper_test.rb @@ -0,0 +1,21 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class ThickboxHelperTest < Test::Unit::TestCase + include ThickboxHelper + + should 'create thickbox links correcly' do + expects(:link_to).with('Title', '#TB_inline?height=300&width=500&inlineId=inlineLoginBox&modal=true', :class => 'thickbox') + thickbox_inline_popup_link('Title', 'inlineLoginBox') + end + + should 'pass along extra options' do + expects(:link_to).with('Title', anything, :class => 'thickbox', :id => 'lalala', :title => 'lelele') + thickbox_inline_popup_link('Title', 'inlineLoginBox', :id => 'lalala', :title => 'lelele') + end + + should 'generate close button' do + expects(:button_to_function).with(:close, 'Title', 'tb_remove();').returns('[close-button]') + assert_equal '[close-button]', thickbox_close_button('Title') + end + +end -- libgit2 0.21.2