Commit 54c2e24359b490712e25a4a90aa01e5d38665838
1 parent
61955a0f
Exists in
master
and in
9 other branches
responsive: add some helpers and improve form helpers
Showing
7 changed files
with
69 additions
and
11 deletions
Show diff stats
plugins/responsive/lib/ext/application_helper.rb
| ... | ... | @@ -251,6 +251,8 @@ module ApplicationHelper |
| 251 | 251 | #control_panel link |
| 252 | 252 | output += '<li>' + link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', user.admin_url, class: 'ctrl-panel', title: _("Configure your personal account and content")) + '</li>' |
| 253 | 253 | |
| 254 | + output += chat_user_status_menu('icon-menu-offline', _('Offline')) | |
| 255 | + | |
| 254 | 256 | #manage_enterprises |
| 255 | 257 | manage_enterprises_str = manage_enterprises |
| 256 | 258 | output += manage_enterprises_str.present? ? '<li>' + manage_enterprises_str + '</li>' : '' | ... | ... |
| ... | ... | @@ -0,0 +1,41 @@ |
| 1 | +require_dependency 'chat_helper' | |
| 2 | +require_relative 'application_helper' | |
| 3 | + | |
| 4 | +module ChatHelper | |
| 5 | + | |
| 6 | + extend ActiveSupport::Concern | |
| 7 | + protected | |
| 8 | + | |
| 9 | + module ResponsiveMethods | |
| 10 | + | |
| 11 | + def chat_user_status_menu icon_class, status | |
| 12 | + return super unless theme_responsive? | |
| 13 | + | |
| 14 | + links = [ | |
| 15 | + ['icon-menu-online', _('Online'), 'chat-connect'], | |
| 16 | + ['icon-menu-busy', _('Busy'), 'chat-busy'], | |
| 17 | + ['icon-menu-offline', _('Sign out of chat'), 'chat-disconnect'], | |
| 18 | + ] | |
| 19 | + tag(:li, class: 'divider') + content_tag(:li, _('Chat'), class: 'dropdown-header') + | |
| 20 | + links.map do |link| | |
| 21 | + content_tag :li, | |
| 22 | + link_to(content_tag(:i, nil, class: link[0]) + content_tag(:strong, link[1]), '#', id: link[2], 'data-jid' => user.jid) | |
| 23 | + end.join | |
| 24 | + end | |
| 25 | + end | |
| 26 | + | |
| 27 | + include ResponsiveChecks | |
| 28 | + included do | |
| 29 | + include ResponsiveMethods | |
| 30 | + end | |
| 31 | + | |
| 32 | + protected | |
| 33 | + | |
| 34 | +end | |
| 35 | + | |
| 36 | +module ApplicationHelper | |
| 37 | + | |
| 38 | + include ChatHelper::ResponsiveMethods | |
| 39 | + | |
| 40 | +end | |
| 41 | + | ... | ... |
plugins/responsive/lib/ext/form_builder.rb
| 1 | 1 | |
| 2 | 2 | class ResponsiveFormBuilder < ActionView::Helpers::FormBuilder |
| 3 | 3 | |
| 4 | - %w[file_field text_field text_area password_field submit button].each do |method| | |
| 4 | + %w[file_field text_field text_area number_field password_field].each do |method| | |
| 5 | 5 | define_method method do |*args, &block| |
| 6 | 6 | options = args.extract_options! |
| 7 | - options[:class] = "#{options[:class]} form-control" | |
| 7 | + if options['class'] | |
| 8 | + options['class'] = "#{options['class']} form-control" | |
| 9 | + else | |
| 10 | + options[:class] = "#{options[:class]} form-control" | |
| 11 | + end | |
| 8 | 12 | super(*(args << options), &block) |
| 9 | 13 | end |
| 10 | 14 | end | ... | ... |
plugins/responsive/lib/ext/forms_helper.rb
| ... | ... | @@ -9,7 +9,7 @@ module FormsHelper |
| 9 | 9 | module ResponsiveMethods |
| 10 | 10 | |
| 11 | 11 | # add -inline class |
| 12 | - def labelled_radio_button( human_name, name, value, checked = false, options = {} ) | |
| 12 | + def labelled_radio_button human_name, name, value, checked = false, options = {} | |
| 13 | 13 | return super unless theme_responsive? |
| 14 | 14 | |
| 15 | 15 | options[:id] ||= 'radio-' + FormsHelper.next_id_number |
| ... | ... | @@ -18,7 +18,7 @@ module FormsHelper |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | 20 | # add -inline class |
| 21 | - def labelled_check_box( human_name, name, value = "1", checked = false, options = {} ) | |
| 21 | + def labelled_check_box human_name, name, value = "1", checked = false, options = {} | |
| 22 | 22 | return super unless theme_responsive? |
| 23 | 23 | |
| 24 | 24 | options[:id] ||= 'checkbox-' + FormsHelper.next_id_number |
| ... | ... | @@ -26,7 +26,7 @@ module FormsHelper |
| 26 | 26 | content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline') |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | - def submit_button(type, label, html_options = {}) | |
| 29 | + def submit_button type, label, html_options = {} | |
| 30 | 30 | return super unless theme_responsive? |
| 31 | 31 | |
| 32 | 32 | bt_cancel = html_options[:cancel] ? button(:cancel, _('Cancel'), html_options[:cancel]) : '' |
| ... | ... | @@ -48,18 +48,26 @@ module FormsHelper |
| 48 | 48 | bt_submit + bt_cancel |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | - %w[select select_tag text_field_tag password_field_tag].each do |method| | |
| 51 | + %w[select select_tag text_field_tag number_field_tag password_field_tag].each do |method| | |
| 52 | 52 | define_method method do |*args, &block| |
| 53 | 53 | #return super(*args, &block) unless theme_responsive? |
| 54 | 54 | |
| 55 | 55 | options = args.extract_options! |
| 56 | - options[:class] = "#{options[:class]} form-control" | |
| 56 | + if options['class'] | |
| 57 | + options['class'] = "#{options['class']} form-control" | |
| 58 | + else | |
| 59 | + options[:class] = "#{options[:class]} form-control" | |
| 60 | + end | |
| 57 | 61 | super(*(args << options), &block) |
| 58 | 62 | end |
| 59 | 63 | end |
| 60 | 64 | %w[select_month select_year].each do |method| |
| 61 | 65 | define_method method do |date, options={}, html_options={}| |
| 62 | - html_options[:class] = "#{html_options[:class]} form-control" | |
| 66 | + if html_options['class'] | |
| 67 | + html_options['class'] = "#{html_options['class']} form-control" | |
| 68 | + else | |
| 69 | + html_options[:class] = "#{html_options[:class]} form-control" | |
| 70 | + end | |
| 63 | 71 | super date, options, html_options |
| 64 | 72 | end |
| 65 | 73 | end | ... | ... |
plugins/responsive/views/layouts/_profile_title.html.erb
plugins/responsive/views/templates/_boxes_2leftbars.html.erb
| ... | ... | @@ -5,12 +5,12 @@ |
| 5 | 5 | </div> |
| 6 | 6 | <% end %> |
| 7 | 7 | <% if box = boxes[1] %> |
| 8 | - <div id="box-<%=box.id%>" class="col-lg-3 col-md-3 col-sm-3 col-lg-pull-3 col-md-pull-3 col-sm-pull-4 box-container-2"> | |
| 8 | + <div id="box-<%=box.id%>" class="col-lg-3 col-md-3 col-sm-3 col-lg-pull-3 col-md-pull-3 col-sm-pull-3 box-container-2"> | |
| 9 | 9 | <%= display_box_content box, main_content %> |
| 10 | 10 | </div> |
| 11 | 11 | <% end %> |
| 12 | 12 | <% if box = boxes[2] %> |
| 13 | - <div id="box-<%=box.id%>" class="col-lg-3 col-md-3 col-sm-3 col-lg-pull-8 col-md-pull-8 col-sm-pull-8 box-container-3"> | |
| 13 | + <div id="box-<%=box.id%>" class="col-lg-3 col-md-3 col-sm-3 col-lg-pull-9 col-md-pull-9 col-sm-pull-9 box-container-3"> | |
| 14 | 14 | <%= display_box_content box, main_content %> |
| 15 | 15 | </div> |
| 16 | 16 | <% end %> | ... | ... |