diff --git a/plugins/responsive/lib/ext/application_helper.rb b/plugins/responsive/lib/ext/application_helper.rb index dd89921..ce49ff1 100644 --- a/plugins/responsive/lib/ext/application_helper.rb +++ b/plugins/responsive/lib/ext/application_helper.rb @@ -1,4 +1,5 @@ require_dependency 'application_helper' +require_relative 'input_helper' module ApplicationHelper @@ -406,11 +407,11 @@ module ApplicationHelper end if options[:horizontal] - label_html = content_tag('label', gettext(text), class: 'control-label col-sm-3 col-md-2 col-lg-2', for: field_id) - result = content_tag('div', label_html + content_tag('div',field_html, class: 'col-sm-9 col-md-6 col-lg-6'), class: 'form-group' ) + label_html = content_tag :label, gettext(text), class: 'control-label col-sm-3 col-md-2 col-lg-2', for: field_id + result = content_tag :div, label_html + content_tag('div',field_html, class: 'col-sm-9 col-md-6 col-lg-6'), class: 'form-group' else - label_html = content_tag('label', gettext(text), class: 'control-label', for: field_id) - result = content_tag('div', label_html + field_html, class: 'form-group' ) + label_html = content_tag :label, gettext(text), class: 'control-label', for: field_id + result = content_tag :div, label_html + field_html, class: 'form-group' end result diff --git a/plugins/responsive/lib/ext/form_builder.rb b/plugins/responsive/lib/ext/form_builder.rb new file mode 100644 index 0000000..66e3fd3 --- /dev/null +++ b/plugins/responsive/lib/ext/form_builder.rb @@ -0,0 +1,15 @@ + +class ResponsiveFormBuilder < ActionView::Helpers::FormBuilder + + %w[file_field text_field text_area password_field submit button].each do |method| + define_method method do |*args, &block| + options = args.extract_options! + options[:class] = "#{options[:class]} form-control" + super(*(args << options), &block) + end + end + +end + +ActionView::Base.default_form_builder = ResponsiveFormBuilder + diff --git a/plugins/responsive/lib/ext/forms_helper.rb b/plugins/responsive/lib/ext/forms_helper.rb index a6b8f35..e8dfbac 100644 --- a/plugins/responsive/lib/ext/forms_helper.rb +++ b/plugins/responsive/lib/ext/forms_helper.rb @@ -2,6 +2,7 @@ require_dependency 'forms_helper' require_relative 'application_helper' module FormsHelper + extend ActiveSupport::Concern protected @@ -30,8 +31,8 @@ module FormsHelper bt_cancel = html_options[:cancel] ? button(:cancel, _('Cancel'), html_options[:cancel]) : '' - button_size = html_options[:size] || 'xs' - size_class = button_size == 'default' ? '' : 'btn-'+button_size + button_size = html_options[:size] || 'default' + size_class = if button_size == 'default' then '' else 'btn-'+button_size end html_options.delete :size if html_options[:size] html_options[:class] = [html_options[:class], 'submit'].compact.join(' ') @@ -47,6 +48,22 @@ module FormsHelper bt_submit + bt_cancel end + %w[select select_tag text_field_tag password_field_tag].each do |method| + define_method method do |*args, &block| + #return super(*args, &block) unless theme_responsive? + + options = args.extract_options! + options[:class] = "#{options[:class]} form-control" + super(*(args << options), &block) + end + end + %w[select_month select_year].each do |method| + define_method method do |date, options={}, html_options={}| + html_options[:class] = "#{html_options[:class]} form-control" + super date, options, html_options + end + end + end include ResponsiveChecks @@ -54,7 +71,6 @@ module FormsHelper include ResponsiveMethods end - protected end module ApplicationHelper diff --git a/plugins/responsive/lib/ext/input_helper.rb b/plugins/responsive/lib/ext/input_helper.rb new file mode 100644 index 0000000..f7ef3ee --- /dev/null +++ b/plugins/responsive/lib/ext/input_helper.rb @@ -0,0 +1,19 @@ +module InputHelper + + extend ActiveSupport::Concern + protected + + def input_group_addon addon, options = {}, &block + content_tag :div, + content_tag(:span, addon, class: 'input-group-addon') + yield, + class: 'input-group' + end + +end + +module ApplicationHelper + + include InputHelper + +end + diff --git a/plugins/responsive/public/_bootstrap-sprockets.scss b/plugins/responsive/public/_bootstrap-sprockets.scss new file mode 100644 index 0000000..7d30692 --- /dev/null +++ b/plugins/responsive/public/_bootstrap-sprockets.scss @@ -0,0 +1,7 @@ +@function twbs-font-path($path) { + @return font-path($path); +} + +@function twbs-image-path($path) { + @return image-path($path); +} diff --git a/plugins/responsive/test/unit/foo_plugin_test.rb b/plugins/responsive/test/unit/foo_plugin_test.rb new file mode 100644 index 0000000..71d51e0 --- /dev/null +++ b/plugins/responsive/test/unit/foo_plugin_test.rb @@ -0,0 +1,10 @@ +require File.dirname(__FILE__) + '/../../../../test/test_helper' + +class FooPluginTest < ActiveSupport::TestCase + def test_foo + FooPlugin::Bar.create! + end + def test_monkey_patch + Profile.new.bar + end +end diff --git a/plugins/responsive/views/layouts/_content.html.erb b/plugins/responsive/views/layouts/_content.html.erb new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/plugins/responsive/views/layouts/_content.html.erb diff --git a/plugins/responsive/views/layouts/_menu_responsive.html.erb b/plugins/responsive/views/layouts/_menu_responsive.html.erb index 0935cc7..cc2b8a4 100644 --- a/plugins/responsive/views/layouts/_menu_responsive.html.erb +++ b/plugins/responsive/views/layouts/_menu_responsive.html.erb @@ -48,7 +48,7 @@