diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2672ef1..7eb9808 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,7 @@ module ApplicationHelper include PermissionNameHelper - include ColorboxHelper + include ModalHelper include BoxesHelper @@ -648,7 +648,7 @@ module ApplicationHelper ' onblur="if(/^\s*$/.test(this.value)){this.value=\''+s+'\'} this.form.className=\'focus-out\'">'+ '' else - colorbox_link_to ''+ _('Search'), { + modal_link_to ''+ _('Search'), { :controller => 'search', :action => 'popup', :category_path => (@category ? @category.explode_path : nil)}, @@ -1046,7 +1046,7 @@ module ApplicationHelper {s_('contents|Most commented') => {:href => url_for({:controller => 'search', :action => 'contents', :filter => 'more_comments'})}} ] if logged_in? - links.push(_('New content') => colorbox_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})})) + links.push(_('New content') => modal_options({:href => url_for({:controller => 'cms', :action => 'new', :profile => current_user.login, :cms => true})})) end link_to(content_tag(:span, _('Contents'), :class => 'icon-menu-articles'), {:controller => "search", :action => 'contents', :category_path => nil}, :id => 'submenu-contents') + diff --git a/app/helpers/boxes_helper.rb b/app/helpers/boxes_helper.rb index e45f0e3..e1fd4a1 100644 --- a/app/helpers/boxes_helper.rb +++ b/app/helpers/boxes_helper.rb @@ -231,7 +231,7 @@ module BoxesHelper end if block.editable? - buttons << colorbox_icon_button(:edit, _('Edit'), { :action => 'edit', :id => block.id }) + buttons << modal_icon_button(:edit, _('Edit'), { :action => 'edit', :id => block.id }) end if !block.main? @@ -241,7 +241,7 @@ module BoxesHelper end if block.respond_to?(:help) - 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}") + 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}") end if block.embedable? diff --git a/app/helpers/colorbox_helper.rb b/app/helpers/colorbox_helper.rb deleted file mode 100644 index a18daf4..0000000 --- a/app/helpers/colorbox_helper.rb +++ /dev/null @@ -1,46 +0,0 @@ -module ColorboxHelper - - def colorbox_inline_link_to title, url, selector, options = {} - link_to title, url, colorbox_options(options.merge(:inline => selector)) - end - - def colorbox_inline_icon type, title, url, selector, options = {} - icon_button type, title, url, colorbox_options(options.merge(:inline => selector)) - end - - def colorbox_link_to title, url, options = {} - link_to title, url, colorbox_options(options) - end - - def colorbox_close_link text, options = {} - link_to text, '#', colorbox_options(options, :close) - end - - def colorbox_close_button(text, options = {}) - button(:close, text, '#', colorbox_options(options, :close).merge(:rel => 'deactivate')) - end - - def colorbox_button(type, label, url, options = {}) - button(type, label, url, colorbox_options(options)) - end - - def colorbox_icon_button(type, label, url, options = {}) - icon_button(type, label, url, colorbox_options(options)) - end - - # options must be an HTML options hash as passed to link_to etc. - # - # returns a new hash with colorbox class added. Keeps existing classes. - def colorbox_options(options, type=nil) - inline_selector = options.delete :inline - options[:onclick] = "return colorbox_helpers.inline('#{inline_selector}')" if inline_selector - - classes = if inline_selector then '' else 'colorbox' end - classes += "-#{type.to_s}" if type.present? - classes << " #{options[:class]}" if options.has_key? :class - options.merge!(:class => classes) - - options - end - -end diff --git a/app/helpers/comment_helper.rb b/app/helpers/comment_helper.rb index ba19262..9b93e8c 100644 --- a/app/helpers/comment_helper.rb +++ b/app/helpers/comment_helper.rb @@ -65,7 +65,7 @@ module CommentHelper def link_for_edit(comment) if comment.can_be_updated_by?(user) - {:link => expirable_comment_link(comment, :edit, _('Edit'), url_for(:profile => profile.identifier, :controller => :comment, :action => :edit, :id => comment.id),:class => 'colorbox')} + {:link => expirable_comment_link(comment, :edit, _('Edit'), url_for(:profile => profile.identifier, :controller => :comment, :action => :edit, :id => comment.id),:class => 'modal')} end end diff --git a/app/helpers/modal_helper.rb b/app/helpers/modal_helper.rb new file mode 100644 index 0000000..3c602e5 --- /dev/null +++ b/app/helpers/modal_helper.rb @@ -0,0 +1,46 @@ +module ModalHelper + + def modal_inline_link_to title, url, selector, options = {} + link_to title, url, modal_options(options.merge(:inline => selector)) + end + + def modal_inline_icon type, title, url, selector, options = {} + icon_button type, title, url, modal_options(options.merge(:inline => selector)) + end + + def modal_link_to title, url, options = {} + link_to title, url, modal_options(options) + end + + def modal_close_link text, options = {} + link_to text, '#', modal_options(options, :close) + end + + def modal_close_button(text, options = {}) + button :close, text, '#', modal_options(options, :close).merge(:rel => 'deactivate') + end + + def modal_button(type, label, url, options = {}) + button type, label, url, modal_options(options) + end + + def modal_icon_button(type, label, url, options = {}) + icon_button type, label, url, modal_options(options) + end + + # options must be an HTML options hash as passed to link_to etc. + # + # returns a new hash with modal class added. Keeps existing classes. + def modal_options(options, type=nil) + inline_selector = options.delete :inline + options[:onclick] = "return noosfero.modal.inline('#{inline_selector}')" if inline_selector + + classes = if inline_selector then '' else 'modal-toggle' end + classes += " modal-#{type.to_s}" if type.present? + classes << " #{options[:class]}" if options.has_key? :class + options.merge!(:class => classes) + + options + end + +end diff --git a/app/views/account/_login_form.html.erb b/app/views/account/_login_form.html.erb index 1e6354a..56660c0 100644 --- a/app/views/account/_login_form.html.erb +++ b/app/views/account/_login_form.html.erb @@ -13,7 +13,7 @@ <% button_bar do %> <%= submit_button( 'login', _('Log in') )%> - <%= colorbox_close_button _('Cancel') if request.xhr? %> + <%= modal_close_button _('Cancel') if request.xhr? %> <% end %> <% end %> diff --git a/app/views/account/index_anonymous.html.erb b/app/views/account/index_anonymous.html.erb index b4e1ae1..239f9c2 100644 --- a/app/views/account/index_anonymous.html.erb +++ b/app/views/account/index_anonymous.html.erb @@ -1,7 +1,7 @@

<%= _('Identify yourself') %>

-<%= colorbox_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' } %> +<%= modal_link_to _('Login.'), { :controller => 'account', :action => 'login_popup' } %> <%= _('You need to login to be able to use all the features in this environment.') %>

diff --git a/app/views/account/login.html.erb b/app/views/account/login.html.erb index 2726220..9fd0cc0 100644 --- a/app/views/account/login.html.erb +++ b/app/views/account/login.html.erb @@ -18,7 +18,7 @@ <% button_bar do %> <%= submit_button( 'login', _('Log in') )%> <% if is_popin %> - <%= colorbox_close_button(_('Cancel')) %> + <%= modal_close_button(_('Cancel')) %> <% end %> <% end %> diff --git a/app/views/account/logout_popup.html.erb b/app/views/account/logout_popup.html.erb index bcbb3e8..a16bbfa 100644 --- a/app/views/account/logout_popup.html.erb +++ b/app/views/account/logout_popup.html.erb @@ -2,6 +2,6 @@

<% button_bar do %> <%= button :ok, _('Yes'), { :controller => 'account', :action => 'logout' } %> - <%= colorbox_close_button _('No, I want to stay.') %> + <%= modal_close_button _('No, I want to stay.') %> <% end %>

diff --git a/app/views/box_organizer/add_block.html.erb b/app/views/box_organizer/add_block.html.erb index f086512..ed647ea 100644 --- a/app/views/box_organizer/add_block.html.erb +++ b/app/views/box_organizer/add_block.html.erb @@ -42,7 +42,7 @@ <% button_bar do %> <%= submit_button(:add, _("Add")) %> - <%= colorbox_close_button(_('Close')) %> + <%= modal_close_button(_('Close')) %> <% end %> <% end %> diff --git a/app/views/box_organizer/edit.html.erb b/app/views/box_organizer/edit.html.erb index 0f545f4..03f6687 100644 --- a/app/views/box_organizer/edit.html.erb +++ b/app/views/box_organizer/edit.html.erb @@ -27,7 +27,7 @@ <% button_bar do %> <%= submit_button(:save, _('Save')) %> - <%= colorbox_close_button(_('Cancel')) %> + <%= modal_close_button(_('Cancel')) %> <% end %> <% end %> diff --git a/app/views/box_organizer/index.html.erb b/app/views/box_organizer/index.html.erb index d66e1e1..fa0e337 100644 --- a/app/views/box_organizer/index.html.erb +++ b/app/views/box_organizer/index.html.erb @@ -1,6 +1,6 @@

<%= _('Editing sideboxes')%>

<% button_bar :class=>'design-menu' do %> - <%= colorbox_button('add', _('Add a block'), { :action => 'add_block' }) %> + <%= modal_button('add', _('Add a block'), { :action => 'add_block' }) %> <%= button(:back, _('Back to control panel'), :controller => (profile.nil? ? 'admin_panel': 'profile_editor')) %> <% end %> diff --git a/app/views/cms/edit.html.erb b/app/views/cms/edit.html.erb index 3140fe3..7c41265 100644 --- a/app/views/cms/edit.html.erb +++ b/app/views/cms/edit.html.erb @@ -28,7 +28,7 @@ <% end %>
- <%= colorbox_button :help, _('Why categorize?'), :action => 'why_categorize' %> + <%= modal_button :help, _('Why categorize?'), :action => 'why_categorize' %>
<%= select_categories(:article, _('Categorize your article')) %> diff --git a/app/views/cms/select_article_type.html.erb b/app/views/cms/select_article_type.html.erb index ed84cdf..23a78c4 100644 --- a/app/views/cms/select_article_type.html.erb +++ b/app/views/cms/select_article_type.html.erb @@ -15,6 +15,6 @@
-<%= colorbox_close_button(_('Cancel')) %> +<%= modal_close_button(_('Cancel')) %> diff --git a/app/views/cms/view.html.erb b/app/views/cms/view.html.erb index 36827cc..b9a2b0c 100644 --- a/app/views/cms/view.html.erb +++ b/app/views/cms/view.html.erb @@ -17,7 +17,7 @@ <% button_bar(:style => 'margin-bottom: 1em;') do %> <% parent_id = ((@article && @article.allow_children?) ? @article : nil) %> - <%= colorbox_button('new', _('New content'), :action => 'new', :parent_id => parent_id, :cms => true) %> + <%= modal_button('new', _('New content'), :action => 'new', :parent_id => parent_id, :cms => true) %> <%= button(:back, _('Back to control panel'), :controller => 'profile_editor', :action => "index") %> <% end %> diff --git a/app/views/cms/why_categorize.html.erb b/app/views/cms/why_categorize.html.erb index 3c9f2dd..e15432f 100644 --- a/app/views/cms/why_categorize.html.erb +++ b/app/views/cms/why_categorize.html.erb @@ -5,5 +5,5 @@

<% button_bar do %> - <%= colorbox_close_button _('Close') %> + <%= modal_close_button _('Close') %> <% end %> diff --git a/app/views/comment/_comment_form.html.erb b/app/views/comment/_comment_form.html.erb index af7d312..ecbc9cd 100644 --- a/app/views/comment/_comment_form.html.erb +++ b/app/views/comment/_comment_form.html.erb @@ -10,7 +10,7 @@ <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %> <% button_bar do %> <%= button_to_function :add, _('Confirm'), "return false", :id => "confirm-captcha" %> - <%= button_to_function :cancel, _('Cancel'), "jQuery.colorbox.close()" %> + <%= button_to_function :cancel, _('Cancel'), "noosfero.modal.close()" %> <% end %> @@ -31,10 +31,10 @@ function check_captcha(button, confirm_action) { return true; <% else %> jQuery('#recaptcha-container').show(); - jQuery.colorbox({ html: jQuery('#recaptcha-container').html(), maxWidth : '600px', maxHeight : '300px' }); + noosfero.modal.inline('#recaptcha-container', {maxWidth :'600px', maxHeight : '300px' }); jQuery('#confirm-captcha').unbind('click'); jQuery('#confirm-captcha').bind('click', function() { - jQuery.colorbox.close(); + noosfero.modal.close(); button.form.recaptcha_response_field.value = jQuery('#recaptcha_response_field').val(); button.form.recaptcha_challenge_field.value = jQuery('#recaptcha_challenge_field').val(); button.form.confirm.value = 'true'; @@ -88,7 +88,7 @@ function check_captcha(button, confirm_action) { <% if !edition_mode %> <%= button :cancel, _('Cancel'), '', :id => 'cancel-comment' %> <% else %> - <%= button :cancel, _('Cancel'), '#', :onclick => "jQuery.colorbox.close();" %> + <%= button :cancel, _('Cancel'), '#', :onclick => "noosfero.modal.close();" %> <% end %> <% end %> <% end %> diff --git a/app/views/content_viewer/_article_toolbar.html.erb b/app/views/content_viewer/_article_toolbar.html.erb index 09dfc75..ffa7597 100644 --- a/app/views/content_viewer/_article_toolbar.html.erb +++ b/app/views/content_viewer/_article_toolbar.html.erb @@ -28,7 +28,7 @@ <%= expirable_button @page, :locale, content, url %> <% end %> - <%= 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) %> + <%= 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) %> <% end %> <% if @page.accept_uploads? && @page.allow_create?(user) %> diff --git a/app/views/content_viewer/_comment_form.html.erb b/app/views/content_viewer/_comment_form.html.erb index 91f8ad9..4954f00 100644 --- a/app/views/content_viewer/_comment_form.html.erb +++ b/app/views/content_viewer/_comment_form.html.erb @@ -7,10 +7,10 @@ function submit_comment_form(button) { return true; <% else %> jQuery('#recaptcha-container').show(); - jQuery.colorbox({ inline : true, href : '#recaptcha-container', maxWidth : '600px', maxHeight : '300px' }); + noosfero.modal.inline('#recaptcha-container', {maxWidth :'600px', maxHeight : '300px' }); jQuery('#confirm-captcha').unbind('click'); jQuery('#confirm-captcha').bind('click', function() { - jQuery.colorbox.close(); + noosfero.modal.close(); button.form.recaptcha_response_field.value = jQuery('#recaptcha_response_field').val(); button.form.recaptcha_challenge_field.value = jQuery('#recaptcha_challenge_field').val(); button.form.confirm.value = 'true'; @@ -38,7 +38,7 @@ function submit_comment_form(button) { <%= recaptcha_tags(:display => { :theme => 'clean' }, :ajax => true) %> <% button_bar do %> <%= button_to_function :add, _('Confirm'), "return false", :id => "confirm-captcha" %> - <%= button_to_function :cancel, _('Cancel'), "jQuery.colorbox.close()" %> + <%= button_to_function :cancel, _('Cancel'), "noosfero.modal.close()" %> <% end %> diff --git a/app/views/layouts/_user.html.erb b/app/views/layouts/_user.html.erb index dda041c..cec9a5d 100644 --- a/app/views/layouts/_user.html.erb +++ b/app/views/layouts/_user.html.erb @@ -7,7 +7,7 @@ <% else %> - <%= _("%s") % colorbox_inline_link_to('' + _('Login') + '', login_url, '#inlineLoginBox', :id => 'link_login') %> + <%= _("%s") % modal_inline_link_to('' + _('Login') + '', login_url, '#inlineLoginBox', :id => 'link_login') %> <%= @plugins.dispatch(:alternative_authentication_link).collect { |content| instance_exec(&content) }.join("") %> @@ -28,7 +28,7 @@ <% end %> <% button_bar do %> - <%= colorbox_button :add, _('Add image'), :action => 'add_image', :id => @theme.id %> + <%= modal_button :add, _('Add image'), :action => 'add_image', :id => @theme.id %> <% end %> diff --git a/app/views/profile_themes/index.html.erb b/app/views/profile_themes/index.html.erb index 39a7b1e..71ec863 100644 --- a/app/views/profile_themes/index.html.erb +++ b/app/views/profile_themes/index.html.erb @@ -42,7 +42,7 @@ <% button_bar do %> <% if environment.enabled?('user_themes') %> - <%= colorbox_button :add, _('New theme ...'), :action => 'new' %> + <%= modal_button :add, _('New theme ...'), :action => 'new' %> <% end %> <%= button(:back, _('Back'), :controller => 'profile_editor', :action => 'index') %> <% end %> diff --git a/app/views/shared/user_menu.html.erb b/app/views/shared/user_menu.html.erb index 4a7031e..b3874ce 100644 --- a/app/views/shared/user_menu.html.erb +++ b/app/views/shared/user_menu.html.erb @@ -20,7 +20,7 @@
  • - <%= colorbox_link_to '' + _('New article'), '/myprofile/{login}/cms/new' %> + <%= modal_link_to '' + _('New article'), '/myprofile/{login}/cms/new' %>
  • @@ -58,7 +58,7 @@ <% if theme_option( :menu_login ) == 'full_form' %> <%= render :file => 'account/login_block' %> <% else %> - <%= colorbox_inline_link_to(''+ _('Login'), login_url, '#inlineLoginBox', :id => 'link_login') %> + <%= modal_inline_link_to(''+ _('Login'), login_url, '#inlineLoginBox', :id => 'link_login') %> diff --git a/plugins/custom_forms/public/style.css b/plugins/custom_forms/public/style.css index bcfba5b..7bb01f5 100644 --- a/plugins/custom_forms/public/style.css +++ b/plugins/custom_forms/public/style.css @@ -25,7 +25,7 @@ .edit-information { display: none; } -#colorbox .edit-information { +.modal .edit-information { display: block; } diff --git a/plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_select.html.erb b/plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_select.html.erb index 9a89db4..17317e9 100644 --- a/plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_select.html.erb +++ b/plugins/custom_forms/views/custom_forms_plugin_myprofile/_edit_select.html.erb @@ -26,7 +26,7 @@ <%= labelled_radio_button 'Multiple Select', "fields[#{counter}][kind]", 'multiple_select', field.multiple && field.list %>
    <% button_bar do %> - <%= button :ok, c_('Ok'), '#', :class => 'colorbox-ok-button', :div_id => elem_id %> + <%= button :ok, _('Ok'), '#', :div_id => elem_id %> <% end %> diff --git a/plugins/shopping_cart/public/cart.js b/plugins/shopping_cart/public/cart.js index ed13327..6043975 100644 --- a/plugins/shopping_cart/public/cart.js +++ b/plugins/shopping_cart/public/cart.js @@ -290,14 +290,11 @@ function Cart(config) { log.error('Send request - HTTP '+status, errorThrown); }, complete: function() { - $.colorbox.close(); + noosfero.modal.close(); } }); } - Cart.colorbox_close = function() { - $.colorbox.close(); - } $(window).bind('beforeunload', function(){ log('Page unload.'); diff --git a/plugins/shopping_cart/views/cart.html.erb b/plugins/shopping_cart/views/cart.html.erb index a5e70c0..dac4baf 100644 --- a/plugins/shopping_cart/views/cart.html.erb +++ b/plugins/shopping_cart/views/cart.html.erb @@ -5,7 +5,7 @@ <%=_('Clean basket')%>
    <%=_('Total:')%>
    - <%=_('Shopping checkout')%> + <%=_('Shopping checkout')%> <%=_('Show basket')%> diff --git a/plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb b/plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb index 5eefaff..25ff05c 100644 --- a/plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb +++ b/plugins/shopping_cart/views/shopping_cart_plugin/buy.html.erb @@ -24,7 +24,7 @@ <% end %> <% delivery_option = @settings.delivery_options.first && @settings.delivery_options.first.first %> <%= items_table(@cart[:items], @profile, delivery_option) %> - <%= link_to '', '#', :onclick => "Cart.colorbox_close(this);", :class => 'cart-box-close icon-cancel' %> + <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %> <%= javascript_include_tag '../plugins/shopping_cart/buy' %> diff --git a/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb b/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb index ebfd7aa..5e44cd9 100644 --- a/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb +++ b/plugins/shopping_cart/views/shopping_cart_plugin_profile/buy.html.erb @@ -17,7 +17,7 @@ <% end %> <%= items_table(session[:cart][:items], profile) %> - <%= link_to '', '#', :onclick => "Cart.colorbox_close(this);", :class => 'cart-box-close icon-cancel' %> + <%= link_to_function '', "noosfero.modal.close();", :class => 'cart-box-close icon-cancel' %>