Commit eed38cd88fcf7c8bfb7702f0bb78b9f4f5468b9e

Authored by Braulio Bhavamitra
1 parent 48e8a1da

Move to modal api

Showing 44 changed files with 195 additions and 196 deletions   Show diff stats
app/helpers/application_helper.rb
... ... @@ -8,7 +8,7 @@ module ApplicationHelper
8 8  
9 9 include PermissionNameHelper
10 10  
11   - include ColorboxHelper
  11 + include ModalHelper
12 12  
13 13 include BoxesHelper
14 14  
... ... @@ -648,7 +648,7 @@ module ApplicationHelper
648 648 ' onblur="if(/^\s*$/.test(this.value)){this.value=\''+s+'\'} this.form.className=\'focus-out\'">'+
649 649 '</form>'
650 650 else
651   - colorbox_link_to '<span class="icon-menu-search"></span>'+ _('Search'), {
  651 + modal_link_to '<span class="icon-menu-search"></span>'+ _('Search'), {
652 652 :controller => 'search',
653 653 :action => 'popup',
654 654 :category_path => (@category ? @category.explode_path : nil)},
... ... @@ -1046,7 +1046,7 @@ module ApplicationHelper
1046 1046 {s_('contents|Most commented') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_comments'})}}
1047 1047 ]
1048 1048 if logged_in?
1049   - links.push(_('New content') => colorbox_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})}))
  1049 + links.push(_('New content') => modal_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})}))
1050 1050 end
1051 1051  
1052 1052 link_to(content_tag(:span, _('Contents'), :class => 'icon-menu-articles'), {:controller => "search", :action => 'contents', :category_path => nil}, :id => 'submenu-contents') +
... ...
app/helpers/boxes_helper.rb
... ... @@ -231,7 +231,7 @@ module BoxesHelper
231 231 end
232 232  
233 233 if block.editable?
234   - buttons << colorbox_icon_button(:edit, _('Edit'), { :action => 'edit', :id => block.id })
  234 + buttons << modal_icon_button(:edit, _('Edit'), { :action => 'edit', :id => block.id })
235 235 end
236 236  
237 237 if !block.main?
... ... @@ -241,7 +241,7 @@ module BoxesHelper
241 241 end
242 242  
243 243 if block.respond_to?(:help)
244   - buttons << colorbox_inline_icon(:help, _('Help on this block'), {}, "#help-on-box-#{block.id}") << content_tag('div', content_tag('h2', _('Help')) + content_tag('div', block.help, :style => 'margin-bottom: 1em;') + colorbox_close_button(_('Close')), :style => 'display: none;', :id => "help-on-box-#{block.id}")
  244 + buttons << modal_inline_icon(:help, _('Help on this block'), {}, "#help-on-box-#{block.id}") << content_tag('div', content_tag('h2', _('Help')) + content_tag('div', block.help, :style => 'margin-bottom: 1em;') + modal_close_button(_('Close')), :style => 'display: none;', :id => "help-on-box-#{block.id}")
245 245 end
246 246  
247 247 if block.embedable?
... ...
app/helpers/colorbox_helper.rb
... ... @@ -1,46 +0,0 @@
1   -module ColorboxHelper
2   -
3   - def colorbox_inline_link_to title, url, selector, options = {}
4   - link_to title, url, colorbox_options(options.merge(:inline => selector))
5   - end
6   -
7   - def colorbox_inline_icon type, title, url, selector, options = {}
8   - icon_button type, title, url, colorbox_options(options.merge(:inline => selector))
9   - end
10   -
11   - def colorbox_link_to title, url, options = {}
12   - link_to title, url, colorbox_options(options)
13   - end
14   -
15   - def colorbox_close_link text, options = {}
16   - link_to text, '#', colorbox_options(options, :close)
17   - end
18   -
19   - def colorbox_close_button(text, options = {})
20   - button(:close, text, '#', colorbox_options(options, :close).merge(:rel => 'deactivate'))
21   - end
22   -
23   - def colorbox_button(type, label, url, options = {})
24   - button(type, label, url, colorbox_options(options))
25   - end
26   -
27   - def colorbox_icon_button(type, label, url, options = {})
28   - icon_button(type, label, url, colorbox_options(options))
29   - end
30   -
31   - # options must be an HTML options hash as passed to link_to etc.
32   - #
33   - # returns a new hash with colorbox class added. Keeps existing classes.
34   - def colorbox_options(options, type=nil)
35   - inline_selector = options.delete :inline
36   - options[:onclick] = "return colorbox_helpers.inline('#{inline_selector}')" if inline_selector
37   -
38   - classes = if inline_selector then '' else 'colorbox' end
39   - classes += "-#{type.to_s}" if type.present?
40   - classes << " #{options[:class]}" if options.has_key? :class
41   - options.merge!(:class => classes)
42   -
43   - options
44   - end
45   -
46   -end
app/helpers/comment_helper.rb
... ... @@ -65,7 +65,7 @@ module CommentHelper
65 65  
66 66 def link_for_edit(comment)
67 67 if comment.can_be_updated_by?(user)
68   - {:link => expirable_comment_link(comment, :edit, _('Edit'), url_for(:profile => profile.identifier, :controller => :comment, :action => :edit, :id => comment.id),:class => 'colorbox')}
  68 + {:link => expirable_comment_link(comment, :edit, _('Edit'), url_for(:profile => profile.identifier, :controller => :comment, :action => :edit, :id => comment.id),:class => 'modal')}
69 69 end
70 70 end
71 71  
... ...
app/helpers/modal_helper.rb 0 → 100644
... ... @@ -0,0 +1,46 @@
  1 +module ModalHelper
  2 +
  3 + def modal_inline_link_to title, url, selector, options = {}
  4 + link_to title, url, modal_options(options.merge(:inline => selector))
  5 + end
  6 +
  7 + def modal_inline_icon type, title, url, selector, options = {}
  8 + icon_button type, title, url, modal_options(options.merge(:inline => selector))
  9 + end
  10 +
  11 + def modal_link_to title, url, options = {}
  12 + link_to title, url, modal_options(options)
  13 + end
  14 +
  15 + def modal_close_link text, options = {}
  16 + link_to text, '#', modal_options(options, :close)
  17 + end
  18 +
  19 + def modal_close_button(text, options = {})
  20 + button :close, text, '#', modal_options(options, :close).merge(:rel => 'deactivate')
  21 + end
  22 +
  23 + def modal_button(type, label, url, options = {})
  24 + button type, label, url, modal_options(options)
  25 + end
  26 +
  27 + def modal_icon_button(type, label, url, options = {})
  28 + icon_button type, label, url, modal_options(options)
  29 + end
  30 +
  31 + # options must be an HTML options hash as passed to link_to etc.
  32 + #
  33 + # returns a new hash with modal class added. Keeps existing classes.
  34 + def modal_options(options, type=nil)
  35 + inline_selector = options.delete :inline
  36 + options[:onclick] = "return noosfero.modal.inline('#{inline_selector}')" if inline_selector
  37 +
  38 + classes = if inline_selector then '' else 'modal-toggle' end
  39 + classes += " modal-#{type.to_s}" if type.present?
  40 + classes << " #{options[:class]}" if options.has_key? :class
  41 + options.merge!(:class => classes)
  42 +
  43 + options
  44 + end
  45 +
  46 +end
... ...
app/views/account/_login_form.html.erb
... ... @@ -13,7 +13,7 @@
13 13  
14 14 <% button_bar do %>
15 15 <%= submit_button( 'login', _('Log in') )%>
16   - <%= colorbox_close_button _('Cancel') if request.xhr? %>
  16 + <%= modal_close_button _('Cancel') if request.xhr? %>
17 17 <% end %>
18 18  
19 19 <% end %>
... ...
app/views/account/index_anonymous.html.erb
1 1 <h1><%= _('Identify yourself') %></h1>
2 2  
3 3 <p>
4   -<%= colorbox_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' } %>
  4 +<%= modal_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' } %>
5 5  
6 6 <%= _('You need to login to be able to use all the features in this environment.') %>
7 7 </p>
... ...
app/views/account/login.html.erb
... ... @@ -18,7 +18,7 @@
18 18 <% button_bar do %>
19 19 <%= submit_button( 'login', _('Log in') )%>
20 20 <% if is_popin %>
21   - <%= colorbox_close_button(_('Cancel')) %>
  21 + <%= modal_close_button(_('Cancel')) %>
22 22 <% end %>
23 23 <% end %>
24 24  
... ...
app/views/account/logout_popup.html.erb
... ... @@ -2,6 +2,6 @@
2 2 <p>
3 3 <% button_bar do %>
4 4 <%= button :ok, _('Yes'), { :controller => 'account', :action => 'logout' } %>
5   - <%= colorbox_close_button _('No, I want to stay.') %>
  5 + <%= modal_close_button _('No, I want to stay.') %>
6 6 <% end %>
7 7 </p>
... ...
app/views/box_organizer/add_block.html.erb
... ... @@ -42,7 +42,7 @@
42 42  
43 43 <% button_bar do %>
44 44 <%= submit_button(:add, _("Add")) %>
45   - <%= colorbox_close_button(_('Close')) %>
  45 + <%= modal_close_button(_('Close')) %>
46 46 <% end %>
47 47  
48 48 <% end %>
... ...
app/views/box_organizer/edit.html.erb
... ... @@ -27,7 +27,7 @@
27 27  
28 28 <% button_bar do %>
29 29 <%= submit_button(:save, _('Save')) %>
30   - <%= colorbox_close_button(_('Cancel')) %>
  30 + <%= modal_close_button(_('Cancel')) %>
31 31 <% end %>
32 32  
33 33 <% end %>
... ...
app/views/box_organizer/index.html.erb
1 1 <h1><%= _('Editing sideboxes')%></h1>
2 2  
3 3 <% button_bar :class=>'design-menu' do %>
4   - <%= colorbox_button('add', _('Add a block'), { :action => 'add_block' }) %>
  4 + <%= modal_button('add', _('Add a block'), { :action => 'add_block' }) %>
5 5 <%= button(:back, _('Back to control panel'), :controller => (profile.nil? ? 'admin_panel': 'profile_editor')) %>
6 6 <% end %>
... ...
app/views/cms/edit.html.erb
... ... @@ -28,7 +28,7 @@
28 28 <% end %>
29 29  
30 30 <div style='float: right'>
31   - <%= colorbox_button :help, _('Why categorize?'), :action => 'why_categorize' %>
  31 + <%= modal_button :help, _('Why categorize?'), :action => 'why_categorize' %>
32 32 </div>
33 33  
34 34 <%= select_categories(:article, _('Categorize your article')) %>
... ...
app/views/cms/select_article_type.html.erb
... ... @@ -15,6 +15,6 @@
15 15 </ul>
16 16 <br style="clear:both" />
17 17  
18   -<%= colorbox_close_button(_('Cancel')) %>
  18 +<%= modal_close_button(_('Cancel')) %>
19 19  
20 20 </div>
... ...
app/views/cms/view.html.erb
... ... @@ -17,7 +17,7 @@
17 17 <% button_bar(:style => 'margin-bottom: 1em;') do %>
18 18 <% parent_id = ((@article && @article.allow_children?) ? @article : nil) %>
19 19  
20   - <%= colorbox_button('new', _('New content'), :action => 'new', :parent_id => parent_id, :cms => true) %>
  20 + <%= modal_button('new', _('New content'), :action => 'new', :parent_id => parent_id, :cms => true) %>
21 21 <%= button(:back, _('Back to control panel'), :controller => 'profile_editor', :action => "index") %>
22 22 <% end %>
23 23  
... ...
app/views/cms/why_categorize.html.erb
... ... @@ -5,5 +5,5 @@
5 5 </p>
6 6  
7 7 <% button_bar do %>
8   - <%= colorbox_close_button _('Close') %>
  8 + <%= modal_close_button _('Close') %>
9 9 <% end %>
... ...
app/views/comment/_comment_form.html.erb
... ... @@ -10,7 +10,7 @@
10 10 <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %>
11 11 <% button_bar do %>
12 12 <%= button_to_function :add, _('Confirm'), "return false", :id => "confirm-captcha" %>
13   - <%= button_to_function :cancel, _('Cancel'), "jQuery.colorbox.close()" %>
  13 + <%= button_to_function :cancel, _('Cancel'), "noosfero.modal.close()" %>
14 14 <% end %>
15 15 </div>
16 16  
... ... @@ -31,10 +31,10 @@ function check_captcha(button, confirm_action) {
31 31 return true;
32 32 <% else %>
33 33 jQuery('#recaptcha-container').show();
34   - jQuery.colorbox({ html: jQuery('#recaptcha-container').html(), maxWidth : '600px', maxHeight : '300px' });
  34 + noosfero.modal.inline('#recaptcha-container', {maxWidth :'600px', maxHeight : '300px' });
35 35 jQuery('#confirm-captcha').unbind('click');
36 36 jQuery('#confirm-captcha').bind('click', function() {
37   - jQuery.colorbox.close();
  37 + noosfero.modal.close();
38 38 button.form.recaptcha_response_field.value = jQuery('#recaptcha_response_field').val();
39 39 button.form.recaptcha_challenge_field.value = jQuery('#recaptcha_challenge_field').val();
40 40 button.form.confirm.value = 'true';
... ... @@ -88,7 +88,7 @@ function check_captcha(button, confirm_action) {
88 88 <% if !edition_mode %>
89 89 <%= button :cancel, _('Cancel'), '', :id => 'cancel-comment' %>
90 90 <% else %>
91   - <%= button :cancel, _('Cancel'), '#', :onclick => "jQuery.colorbox.close();" %>
  91 + <%= button :cancel, _('Cancel'), '#', :onclick => "noosfero.modal.close();" %>
92 92 <% end %>
93 93 <% end %>
94 94 <% end %>
... ...
app/views/content_viewer/_article_toolbar.html.erb
... ... @@ -28,7 +28,7 @@
28 28 <%= expirable_button @page, :locale, content, url %>
29 29 <% end %>
30 30  
31   - <%= colorbox_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new, @page) %>
  31 + <%= modal_button(:new, label_for_new_article(@page), profile.admin_url.merge(:controller => 'cms', :action => 'new', :parent_id => (@page.folder? ? @page : (@page.parent.nil? ? nil : @page.parent)))) unless remove_content_button(:new, @page) %>
32 32 <% end %>
33 33  
34 34 <% if @page.accept_uploads? && @page.allow_create?(user) %>
... ...
app/views/content_viewer/_comment_form.html.erb
... ... @@ -7,10 +7,10 @@ function submit_comment_form(button) {
7 7 return true;
8 8 <% else %>
9 9 jQuery('#recaptcha-container').show();
10   - jQuery.colorbox({ inline : true, href : '#recaptcha-container', maxWidth : '600px', maxHeight : '300px' });
  10 + noosfero.modal.inline('#recaptcha-container', {maxWidth :'600px', maxHeight : '300px' });
11 11 jQuery('#confirm-captcha').unbind('click');
12 12 jQuery('#confirm-captcha').bind('click', function() {
13   - jQuery.colorbox.close();
  13 + noosfero.modal.close();
14 14 button.form.recaptcha_response_field.value = jQuery('#recaptcha_response_field').val();
15 15 button.form.recaptcha_challenge_field.value = jQuery('#recaptcha_challenge_field').val();
16 16 button.form.confirm.value = 'true';
... ... @@ -38,7 +38,7 @@ function submit_comment_form(button) {
38 38 <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %>
39 39 <% button_bar do %>
40 40 <%= button_to_function :add, _('Confirm'), "return false", :id => "confirm-captcha" %>
41   - <%= button_to_function :cancel, _('Cancel'), "jQuery.colorbox.close()" %>
  41 + <%= button_to_function :cancel, _('Cancel'), "noosfero.modal.close()" %>
42 42 <% end %>
43 43 </div>
44 44  
... ...
app/views/layouts/_user.html.erb
... ... @@ -7,7 +7,7 @@
7 7 </span>
8 8 <% else %>
9 9 <span class='not-logged-in'>
10   - <%= _("<span class='login'>%s</span>") % colorbox_inline_link_to('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, '#inlineLoginBox', :id => 'link_login') %>
  10 + <%= _("<span class='login'>%s</span>") % modal_inline_link_to('<i class="icon-menu-login"></i><strong>' + _('Login') + '</strong>', login_url, '#inlineLoginBox', :id => 'link_login') %>
11 11 <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_exec(&content) }.join("") %>
12 12  
13 13 <div id='inlineLoginBox' style='display: none;'>
... ...
app/views/layouts/application-ng.html.erb
... ... @@ -18,7 +18,7 @@
18 18 <%= yield :head %>
19 19 <%=
20 20 @plugins.dispatch(:head_ending).map do |content|
21   - if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end
  21 + if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end
22 22 end.join("\n")
23 23 %>
24 24  
... ... @@ -32,7 +32,7 @@
32 32  
33 33 <%=
34 34 @plugins.dispatch(:body_beginning).map do |content|
35   - if content.respond_to?(:call) then instance_exec(&content).html_safe else content.html_safe end
  35 + if content.respond_to?(:call) then instance_exec(&content).to_s.html_safe else content.to_s.html_safe end
36 36 end.join("\n")
37 37 %>
38 38  
... ...
app/views/profile/join.html.erb
... ... @@ -9,7 +9,7 @@
9 9 <%= hidden_field_tag(:confirmation, 1) %>
10 10 <%= submit_button(:ok, _("Yes, I want to join.") % profile.name) %>
11 11 <% if logged_in? && request.xhr? %>
12   - <%= colorbox_close_button _("No, I don't want") %>
  12 + <%= modal_close_button _("No, I don't want") %>
13 13 <% else %>
14 14 <%= button(:cancel, _("No, I don't want."), profile.url) %>
15 15 <% end %>
... ...
app/views/profile/leave.html.erb
... ... @@ -9,7 +9,7 @@
9 9 <%= hidden_field_tag(:back_to, @back_to) %>
10 10 <%= submit_button(:ok, _("Yes, I want to leave.") % profile.name) %>
11 11 <% if logged_in? && request.xhr? %>
12   - <%= colorbox_close_button _("No, I don't want") %>
  12 + <%= modal_close_button _("No, I don't want") %>
13 13 <% else %>
14 14 <%= button(:cancel, _("No, I don't want."), profile.url) %>
15 15 <% end %>
... ...
app/views/profile/report_abuse.html.erb
... ... @@ -9,7 +9,7 @@
9 9 <% end %>
10 10  
11 11 <%= submit_button(:send, _('Report profile'), :style => 'float: left; cursor: pointer;', :id => 'report-abuse-submit-button', :onclick => "jQuery('#form-submit-loading').show()") %>
12   - <%= button(:cancel, _('Cancel'), {}, :style => 'float: left; padding-top: 0px; padding-bottom: 0px;', :onclick => 'jQuery.colorbox.close(); return false;')%>
  12 + <%= button(:cancel, _('Cancel'), {}, :style => 'float: left; padding-top: 0px; padding-bottom: 0px;', :onclick => 'noosfero.modal.close(); return false;')%>
13 13 <div id="form-submit-loading" class="small-loading" style="width: 16px; height: 16px; margin-top: 3px; float: left; display: none;"></div>
14 14 <% end %>
15 15  
... ... @@ -30,7 +30,7 @@
30 30 success: function(data, status, ajax){
31 31 if ( !data.ok ) display_notice(data.error.message);
32 32 else {
33   - $.colorbox.close();
  33 + noosfero.modal.close();
34 34 display_notice(data.message);
35 35 window.location.reload();
36 36 }
... ...
app/views/profile_themes/add_css.html.erb
... ... @@ -5,7 +5,7 @@
5 5  
6 6 <% button_bar do %>
7 7 <%= submit_button(:add, _('Add')) %>
8   - <%= colorbox_close_button _('Cancel') %>
  8 + <%= modal_close_button _('Cancel') %>
9 9 <% end %>
10 10  
11 11 <% end %>
... ...
app/views/profile_themes/edit.html.erb
... ... @@ -16,7 +16,7 @@
16 16 <% end %>
17 17 </ul>
18 18 <% button_bar do %>
19   - <%= colorbox_button :add, _('New CSS'), :action => 'add_css', :id => @theme.id %>
  19 + <%= modal_button :add, _('New CSS'), :action => 'add_css', :id => @theme.id %>
20 20 <% end %>
21 21 </div>
22 22  
... ... @@ -28,7 +28,7 @@
28 28 <% end %>
29 29 </ul>
30 30 <% button_bar do %>
31   - <%= colorbox_button :add, _('Add image'), :action => 'add_image', :id => @theme.id %>
  31 + <%= modal_button :add, _('Add image'), :action => 'add_image', :id => @theme.id %>
32 32 <% end %>
33 33 </div>
34 34  
... ...
app/views/profile_themes/index.html.erb
... ... @@ -42,7 +42,7 @@
42 42  
43 43 <% button_bar do %>
44 44 <% if environment.enabled?('user_themes') %>
45   - <%= colorbox_button :add, _('New theme ...'), :action => 'new' %>
  45 + <%= modal_button :add, _('New theme ...'), :action => 'new' %>
46 46 <% end %>
47 47 <%= button(:back, _('Back'), :controller => 'profile_editor', :action => 'index') %>
48 48 <% end %>
... ...
app/views/shared/user_menu.html.erb
... ... @@ -20,7 +20,7 @@
20 20 </li>
21 21  
22 22 <li>
23   - <%= colorbox_link_to '<span class="icon-new"></span>' + _('New article'), '/myprofile/{login}/cms/new' %>
  23 + <%= modal_link_to '<span class="icon-new"></span>' + _('New article'), '/myprofile/{login}/cms/new' %>
24 24 </li>
25 25  
26 26 <li id='manage-enterprises-link-template' style='display: none'><a href='/myprofile/{identifier}'><span class="icon-menu-enterprise"></span><%= _('Manage %s') % '{name}' %></a></li>
... ... @@ -58,7 +58,7 @@
58 58 <% if theme_option( :menu_login ) == 'full_form' %>
59 59 <%= render :file => 'account/login_block' %>
60 60 <% else %>
61   - <%= colorbox_inline_link_to('<span class="icon-menu-login"></span>'+ _('Login'), login_url, '#inlineLoginBox', :id => 'link_login') %>
  61 + <%= modal_inline_link_to('<span class="icon-menu-login"></span>'+ _('Login'), login_url, '#inlineLoginBox', :id => 'link_login') %>
62 62 <div id='inlineLoginBox' style='display: none;'>
63 63 <%= render :file => 'account/login', :locals => { :is_popin => true } %>
64 64 </div>
... ...
plugins/custom_forms/public/style.css
... ... @@ -25,7 +25,7 @@
25 25 .edit-information {
26 26 display: none;
27 27 }
28   -#colorbox .edit-information {
  28 +.modal .edit-information {
29 29 display: block;
30 30 }
31 31  
... ...
plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_select.html.erb
... ... @@ -26,7 +26,7 @@
26 26 <%= labelled_radio_button 'Multiple Select', "fields[#{counter}][kind]", 'multiple_select', field.multiple && field.list %><br />
27 27  
28 28 <% button_bar do %>
29   - <%= button :ok, c_('Ok'), '#', :class => 'colorbox-ok-button', :div_id => elem_id %>
  29 + <%= button :ok, _('Ok'), '#', :div_id => elem_id %>
30 30 <% end %>
31 31 </div>
32 32  
... ...
plugins/shopping_cart/public/cart.js
... ... @@ -290,14 +290,11 @@ function Cart(config) {
290 290 log.error('Send request - HTTP '+status, errorThrown);
291 291 },
292 292 complete: function() {
293   - $.colorbox.close();
  293 + noosfero.modal.close();
294 294 }
295 295 });
296 296 }
297 297  
298   - Cart.colorbox_close = function() {
299   - $.colorbox.close();
300   - }
301 298  
302 299 $(window).bind('beforeunload', function(){
303 300 log('Page unload.');
... ...
plugins/shopping_cart/views/cart.html.erb
... ... @@ -5,7 +5,7 @@
5 5 <a href="cart:clean" onclick="Cart.clean(this); return false" class="cart-clean"><%=_('Clean basket')%></a>
6 6 <ul class="cart-items"></ul>
7 7 <div class="cart-total"><%=_('Total:')%> <b></b></div>
8   - <a href="/plugin/shopping_cart/buy" class="cart-buy colorbox"><%=_('Shopping checkout')%></a>
  8 + <a href="/plugin/shopping_cart/buy" class="cart-buy modal"><%=_('Shopping checkout')%></a>
9 9 </div>
10 10 <a href="#" onclick="Cart.toggle(this); return false" class="cart-toggle">
11 11 <span class="str-show"><%=_('Show basket')%></span>
... ...
plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb
... ... @@ -24,7 +24,7 @@
24 24 <% end %>
25 25 <% delivery_option = @settings.delivery_options.first && @settings.delivery_options.first.first %>
26 26 <%= items_table(@cart[:items], @profile, delivery_option) %>
27   - <%= link_to '', '#', :onclick => "Cart.colorbox_close(this);", :class => 'cart-box-close icon-cancel' %>
  27 + <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %>
28 28 </div>
29 29  
30 30 <%= javascript_include_tag '../plugins/shopping_cart/buy' %>
... ...
plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb
... ... @@ -17,7 +17,7 @@
17 17 </div>
18 18 <% end %>
19 19 <%= items_table(session[:cart][:items], profile) %>
20   - <%= link_to '', '#', :onclick => "Cart.colorbox_close(this);", :class => 'cart-box-close icon-cancel' %>
  20 + <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %>
21 21 </div>
22 22  
23 23 <script type="text/javascript">
... ...
plugins/stoa/public/javascripts/signup_complement.js
... ... @@ -55,9 +55,10 @@ $(&quot;#usp_id_field&quot;).observe_field(1, function(){
55 55 });
56 56  
57 57 function displayValidationUspIdError(error){
58   - jQuery.colorbox({html: '<h2>'+error.message+'</h2>'+error.backtrace.join("<br />"),
  58 + noosfero.modal.html('<h2>'+error.message+'</h2>'+error.backtrace.join("<br />"), {
59 59 height: "80%",
60   - width: "70%" });
  60 + width: "70%"
  61 + });
61 62 }
62 63  
63 64 jQuery('#usp_id_field').focus(function() { jQuery('#usp-id-balloon').fadeIn('slow'); });
... ...
public/javascripts/article.js
... ... @@ -88,7 +88,7 @@ jQuery(function($) {
88 88 var $item = $(this).closest('.item');
89 89 var html_selector = $item.attr('data-item');
90 90 insert_item_in_text($item.find(html_selector));
91   - $.colorbox.close();
  91 + noosfero.modal.close();
92 92 return false;
93 93 });
94 94 $('a.zoom').live('click', function() {
... ... @@ -96,14 +96,13 @@ jQuery(function($) {
96 96 var html_selector = $item.attr('data-item');
97 97 var name = $item.attr('title');
98 98 var img = $item.find(html_selector).find('img').attr('src');
99   - $.colorbox({
100   - html: zoom_dialog_html(name, img),
101   - scrolling: false
  99 + noosfero.modal.html(zoom_dialog_html(img), {
  100 + scrolling: false,
102 101 });
103 102 return false;
104 103 });
105 104 $('a.close').live('click', function() {
106   - $.colorbox.close();
  105 + noosfero.modal.close();
107 106 return false;
108 107 })
109 108  
... ...
public/javascripts/colorbox-helpers.js
... ... @@ -1,44 +0,0 @@
1   -colorbox_helpers = {
2   -
3   - watchClass: function() {
4   - jQuery(function($) {
5   - $('.colorbox').live('click', function() {
6   - $.colorbox({
7   - href: $(this).attr('href'),
8   - maxWidth: $(window).width()-50,
9   - height: $(window).height()-50,
10   - open: true,
11   - close: 'Cancel',
12   - onComplete: function(bt) {
13   - var opt = {}, maxH = $(window).height()-50;
14   - if ($('#cboxLoadedContent *:first').height() > maxH) opt.height = maxH;
15   - $.colorbox.resize(opt);
16   - }
17   - });
18   - return false;
19   - });
20   -
21   - $('.colorbox-close').live('click', function() {
22   - $.colorbox.close();
23   - return false;
24   - });
25   -
26   - });
27   - },
28   -
29   - inline: function(href) {
30   - var href = jQuery(href);
31   -
32   - jQuery.colorbox({
33   - inline: true, href: href,
34   - onLoad: function(){ href.show(); },
35   - onCleanup: function(){ href.hide(); },
36   - });
37   -
38   - return false;
39   - },
40   -
41   -};
42   -
43   -colorbox_helpers.watchClass();
44   -
public/javascripts/comment_form.js
... ... @@ -53,7 +53,7 @@ function save_comment(button) {
53 53 //Comment of reply
54 54 $('#'+ data.render_target).replaceWith(data.html);
55 55 $('#' + data.render_target).effect("highlight", {}, 3000);
56   - $.colorbox.close();
  56 + noosfero.modal.close();
57 57 increment_comment_count(comment_div);
58 58 } else {
59 59 //New comment of article
... ... @@ -64,7 +64,7 @@ function save_comment(button) {
64 64 });
65 65  
66 66 page_comment_form.find('.errorExplanation').remove();
67   - $.colorbox.close();
  67 + noosfero.modal.close();
68 68 increment_comment_count(comment_div);
69 69 }
70 70  
... ...
public/javascripts/modal.js 0 → 100644
... ... @@ -0,0 +1,58 @@
  1 +noosfero.modal = {
  2 +
  3 + watchClass: function() {
  4 + jQuery(function($) {
  5 + $(document).delegate('.modal-toggle', 'click', function() {
  6 + $.colorbox({
  7 + href: $(this).attr('href'),
  8 + maxWidth: $(window).width()-50,
  9 + height: $(window).height()-50,
  10 + open: true,
  11 + close: 'Cancel',
  12 + class: 'modal',
  13 + onComplete: function(bt) {
  14 + var opt = {}, maxH = $(window).height()-50;
  15 + if ($('#cboxLoadedContent *:first').height() > maxH) opt.height = maxH;
  16 + $.colorbox.resize(opt);
  17 + }
  18 + });
  19 + return false;
  20 + });
  21 +
  22 + $(document).delegate('.modal-close', 'click', function() {
  23 + $.colorbox.close();
  24 + return false;
  25 + });
  26 +
  27 + });
  28 + },
  29 +
  30 + inline: function(href, options) {
  31 + href = jQuery(href);
  32 + options = jQuery.extend({
  33 + inline: true, href: href,
  34 + onLoad: function(){ href.show(); },
  35 + onCleanup: function(){ href.hide(); },
  36 + }, options)
  37 +
  38 + jQuery.colorbox(options);
  39 +
  40 + return false;
  41 + },
  42 +
  43 + html: function(html, options) {
  44 + options = jQuery.extend({
  45 + html: html,
  46 + }, options);
  47 +
  48 + jQuery.colorbox(options);
  49 + },
  50 +
  51 + close: function() {
  52 + jQuery.colorbox.close();
  53 + },
  54 +
  55 +};
  56 +
  57 +noosfero.modal.watchClass();
  58 +
... ...
public/javascripts/report-abuse.js
1 1 jQuery(function($) {
2 2 $('.report-abuse-action').live('click', function() {
3 3 if($(this).attr('href')){
4   - $.fn.colorbox({
5   - href: $(this).attr('href'),
  4 + noosfero.modal.inline($(this).attr('href'), {
6 5 innerHeight: '300px',
7 6 innerWidth: '445px'
8 7 });
... ...
public/stylesheets/application.css
... ... @@ -1901,17 +1901,6 @@ a.button.disabled, input.disabled {
1901 1901 * Block options editor floating window *
1902 1902 ****************************************/
1903 1903  
1904   -/* FIXME This changes broke colorboxes all over the place.
1905   - * Therefore I'm canceling them until they are properly treateda. */
1906   -#cboxLoadedContent {
1907   - background: #FFF;
1908   -/* box-shadow: 0 0 15px #888 inset;
1909   - border-radius: 5px;
1910   - border: 1px solid #777;
1911   - border-left: none;
1912   - border-right: none; */
1913   -}
1914   -
1915 1904 .block-config-options {
1916 1905 padding: 0px 10px 0px 30px;
1917 1906 }
... ...
test/functional/cms_controller_test.rb
... ... @@ -638,7 +638,7 @@ class CmsControllerTest &lt; ActionController::TestCase
638 638  
639 639 should 'display OK button on why_categorize popup' do
640 640 get :why_categorize, :profile => profile.identifier
641   - assert_tag :tag => 'a', :attributes => { :rel => 'deactivate'} # colorbox close button
  641 + assert_tag :tag => 'a', :attributes => { :rel => 'deactivate'} # modal close button
642 642 end
643 643  
644 644 should 'display published option' do
... ...
test/unit/colorbox_helper_test.rb
... ... @@ -1,36 +0,0 @@
1   -require_relative "../test_helper"
2   -
3   -class ColorboxHelperTest < ActiveSupport::TestCase
4   -
5   - include ColorboxHelper
6   -
7   - should 'provide the needed files' do
8   - assert File.exists?(Rails.root.join('public', 'stylesheets', 'colorbox.css')), 'colorbox.css expected to be in public/stylesheets, but not found'
9   - assert File.exists?(Rails.root.join('public', 'javascripts', 'colorbox.js')), 'colorbox.js expected to be in public/javascripts, but not found'
10   - end
11   -
12   - should 'provide link to close colorbox' do
13   - expects(:button).with(:close, 'text', '#', has_entries({ :class => 'colorbox-close', :id => 'my-id' })).returns('[close-colorbox]')
14   -
15   - assert_equal '[close-colorbox]', colorbox_close_button('text', :id => 'my-id')
16   - end
17   -
18   - should 'merge existing :class option in colorbox_close_button' do
19   - expects(:button).with(:close, 'text', '#', has_entries({ :class => 'colorbox-close my-class', :id => 'my-id' })).returns('[close-colorbox]')
20   -
21   - assert_equal '[close-colorbox]', colorbox_close_button('text', :class => 'my-class', :id => 'my-id' )
22   - end
23   -
24   - should 'provide colorbox_button' do
25   - expects(:button).with('type', 'label', { :action => 'popup'}, has_entries({ :class => 'colorbox' })).returns('[button]')
26   -
27   - assert_equal '[button]', colorbox_button('type', 'label', { :action => 'popup'})
28   - end
29   -
30   - should 'provide colorbox_icon_button' do
31   - expects(:icon_button).with('type', 'label', { :action => 'popup'}, has_entries({ :class => 'colorbox' })).returns('[button]')
32   -
33   - assert_equal '[button]', colorbox_icon_button('type', 'label', { :action => 'popup'})
34   - end
35   -
36   -end
test/unit/modal_helper_test.rb 0 → 100644
... ... @@ -0,0 +1,36 @@
  1 +require_relative '../test_helper'
  2 +
  3 +class ModalHelperTest < ActiveSupport::TestCase
  4 +
  5 + include ModalHelper
  6 +
  7 + should 'provide the needed files' do
  8 + assert File.exists?(Rails.root.join('public', 'stylesheets', 'colorbox.css')), 'colorbox.css expected to be in public/stylesheets, but not found'
  9 + assert File.exists?(Rails.root.join('public', 'javascripts', 'jquery.colorbox-min.js')), 'jquery.colorbox-min.js expected to be in public/javascripts, but not found'
  10 + end
  11 +
  12 + should 'provide link to close modal' do
  13 + expects(:button).with(:close, 'text', '#', has_entries({ :class => 'modal-toggle modal-close', :id => 'my-id' })).returns('[close-modal]')
  14 +
  15 + assert_equal '[close-modal]', modal_close_button('text', :id => 'my-id')
  16 + end
  17 +
  18 + should 'merge existing :class option in modal_close_button' do
  19 + expects(:button).with(:close, 'text', '#', has_entries({ :class => 'modal-toggle modal-close my-class', :id => 'my-id' })).returns('[close-modal]')
  20 +
  21 + assert_equal '[close-modal]', modal_close_button('text', :class => 'my-class', :id => 'my-id' )
  22 + end
  23 +
  24 + should 'provide modal_button' do
  25 + expects(:button).with('type', 'label', { :action => 'popup'}, has_entries({ :class => 'modal-toggle' })).returns('[button]')
  26 +
  27 + assert_equal '[button]', modal_button('type', 'label', { :action => 'popup'})
  28 + end
  29 +
  30 + should 'provide modal_icon_button' do
  31 + expects(:icon_button).with('type', 'label', { :action => 'popup'}, has_entries({ :class => 'modal-toggle' })).returns('[button]')
  32 +
  33 + assert_equal '[button]', modal_icon_button('type', 'label', { :action => 'popup'})
  34 + end
  35 +
  36 +end
... ...