Commit 54c2e24359b490712e25a4a90aa01e5d38665838
1 parent
61955a0f
Exists in
staging
and in
42 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,6 +251,8 @@ module ApplicationHelper | ||
251 | #control_panel link | 251 | #control_panel link |
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>' | 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 | #manage_enterprises | 256 | #manage_enterprises |
255 | manage_enterprises_str = manage_enterprises | 257 | manage_enterprises_str = manage_enterprises |
256 | output += manage_enterprises_str.present? ? '<li>' + manage_enterprises_str + '</li>' : '' | 258 | output += manage_enterprises_str.present? ? '<li>' + manage_enterprises_str + '</li>' : '' |
@@ -0,0 +1,41 @@ | @@ -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 | class ResponsiveFormBuilder < ActionView::Helpers::FormBuilder | 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 | define_method method do |*args, &block| | 5 | define_method method do |*args, &block| |
6 | options = args.extract_options! | 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 | super(*(args << options), &block) | 12 | super(*(args << options), &block) |
9 | end | 13 | end |
10 | end | 14 | end |
plugins/responsive/lib/ext/forms_helper.rb
@@ -9,7 +9,7 @@ module FormsHelper | @@ -9,7 +9,7 @@ module FormsHelper | ||
9 | module ResponsiveMethods | 9 | module ResponsiveMethods |
10 | 10 | ||
11 | # add -inline class | 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 | return super unless theme_responsive? | 13 | return super unless theme_responsive? |
14 | 14 | ||
15 | options[:id] ||= 'radio-' + FormsHelper.next_id_number | 15 | options[:id] ||= 'radio-' + FormsHelper.next_id_number |
@@ -18,7 +18,7 @@ module FormsHelper | @@ -18,7 +18,7 @@ module FormsHelper | ||
18 | end | 18 | end |
19 | 19 | ||
20 | # add -inline class | 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 | return super unless theme_responsive? | 22 | return super unless theme_responsive? |
23 | 23 | ||
24 | options[:id] ||= 'checkbox-' + FormsHelper.next_id_number | 24 | options[:id] ||= 'checkbox-' + FormsHelper.next_id_number |
@@ -26,7 +26,7 @@ module FormsHelper | @@ -26,7 +26,7 @@ module FormsHelper | ||
26 | content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline') | 26 | content_tag( 'label', check_box_tag( name, value, checked, options ) + ' ' + human_name, for: options[:id], class: 'checkbox-inline') |
27 | end | 27 | end |
28 | 28 | ||
29 | - def submit_button(type, label, html_options = {}) | 29 | + def submit_button type, label, html_options = {} |
30 | return super unless theme_responsive? | 30 | return super unless theme_responsive? |
31 | 31 | ||
32 | bt_cancel = html_options[:cancel] ? button(:cancel, _('Cancel'), html_options[:cancel]) : '' | 32 | bt_cancel = html_options[:cancel] ? button(:cancel, _('Cancel'), html_options[:cancel]) : '' |
@@ -48,18 +48,26 @@ module FormsHelper | @@ -48,18 +48,26 @@ module FormsHelper | ||
48 | bt_submit + bt_cancel | 48 | bt_submit + bt_cancel |
49 | end | 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 | define_method method do |*args, &block| | 52 | define_method method do |*args, &block| |
53 | #return super(*args, &block) unless theme_responsive? | 53 | #return super(*args, &block) unless theme_responsive? |
54 | 54 | ||
55 | options = args.extract_options! | 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 | super(*(args << options), &block) | 61 | super(*(args << options), &block) |
58 | end | 62 | end |
59 | end | 63 | end |
60 | %w[select_month select_year].each do |method| | 64 | %w[select_month select_year].each do |method| |
61 | define_method method do |date, options={}, html_options={}| | 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 | super date, options, html_options | 71 | super date, options, html_options |
64 | end | 72 | end |
65 | end | 73 | end |
plugins/responsive/views/layouts/_profile_title.html.erb
1 | -<div class="row profile-title"> | 1 | +<div class="row"> |
2 | <div class="block-outer"> | 2 | <div class="block-outer"> |
3 | <div id="profile-title" class=" block col-lg-12 col-md-12 col-sm-12"> | 3 | <div id="profile-title" class=" block col-lg-12 col-md-12 col-sm-12"> |
4 | <h1 class="page-title"><%= profile.short_name %> | 4 | <h1 class="page-title"><%= profile.short_name %> |
plugins/responsive/views/templates/_boxes_2leftbars.html.erb
@@ -5,12 +5,12 @@ | @@ -5,12 +5,12 @@ | ||
5 | </div> | 5 | </div> |
6 | <% end %> | 6 | <% end %> |
7 | <% if box = boxes[1] %> | 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 | <%= display_box_content box, main_content %> | 9 | <%= display_box_content box, main_content %> |
10 | </div> | 10 | </div> |
11 | <% end %> | 11 | <% end %> |
12 | <% if box = boxes[2] %> | 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 | <%= display_box_content box, main_content %> | 14 | <%= display_box_content box, main_content %> |
15 | </div> | 15 | </div> |
16 | <% end %> | 16 | <% end %> |