Commit 76258ab653995bca7ef12d7975015f6352c9c3df
1 parent
3e495905
Exists in
master
and in
28 other branches
ActionItem519: modularizing thickbox stuff
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2326 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
33 additions
and
2 deletions
Show diff stats
app/helpers/application_helper.rb
| ... | ... | @@ -0,0 +1,8 @@ |
| 1 | +module ThickboxHelper | |
| 2 | + def thickbox_inline_popup_link(title, id, options = {}) | |
| 3 | + link_to(title, "#TB_inline?height=300&width=500&inlineId=#{id}&modal=true", {:class => 'thickbox'}.merge(options)) | |
| 4 | + end | |
| 5 | + def thickbox_close_button(title) | |
| 6 | + button_to_function(:close, title, 'tb_remove();') | |
| 7 | + end | |
| 8 | +end | ... | ... |
app/views/shared/user_menu.rhtml
| ... | ... | @@ -58,9 +58,9 @@ |
| 58 | 58 | |
| 59 | 59 | <div id='inlineLoginBox' style='display: none;'> |
| 60 | 60 | <%= render :file => 'account/login' %> |
| 61 | - <center><%= button_to_function(:close, _('Close'), 'tb_remove();') %></center> | |
| 61 | + <center><%= thickbox_close_button _('Close') %></center> | |
| 62 | 62 | </div> |
| 63 | -<a href="#TB_inline?height=300&width=500&inlineId=inlineLoginBox&modal=true" class="thickbox"><span class='icon-menu-login'></span><%= _('Login') %></a> | |
| 63 | +<%= thickbox_inline_popup_link '<span class="icon-menu-login"></span>'+ _('Login'), 'inlineLoginBox' %> | |
| 64 | 64 | |
| 65 | 65 | <% end %> |
| 66 | 66 | ... | ... |
| ... | ... | @@ -0,0 +1,21 @@ |
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | |
| 2 | + | |
| 3 | +class ThickboxHelperTest < Test::Unit::TestCase | |
| 4 | + include ThickboxHelper | |
| 5 | + | |
| 6 | + should 'create thickbox links correcly' do | |
| 7 | + expects(:link_to).with('Title', '#TB_inline?height=300&width=500&inlineId=inlineLoginBox&modal=true', :class => 'thickbox') | |
| 8 | + thickbox_inline_popup_link('Title', 'inlineLoginBox') | |
| 9 | + end | |
| 10 | + | |
| 11 | + should 'pass along extra options' do | |
| 12 | + expects(:link_to).with('Title', anything, :class => 'thickbox', :id => 'lalala', :title => 'lelele') | |
| 13 | + thickbox_inline_popup_link('Title', 'inlineLoginBox', :id => 'lalala', :title => 'lelele') | |
| 14 | + end | |
| 15 | + | |
| 16 | + should 'generate close button' do | |
| 17 | + expects(:button_to_function).with(:close, 'Title', 'tb_remove();').returns('[close-button]') | |
| 18 | + assert_equal '[close-button]', thickbox_close_button('Title') | |
| 19 | + end | |
| 20 | + | |
| 21 | +end | ... | ... |