Sha256: 8611b38cc5e2db776e09749b4048ff8082fc72234be91b406271f9b63223a487
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
module ApplicationHelpers def bs_box(*opts, &blk) title = opts.shift unless opts.first.is_a?(Hash) width = opts.shift unless opts.first.is_a?(Hash) if opts.length == 1 && opts.first.is_a?(Hash) args = opts.first title = args.fetch(:title) if args.key?(:title) width = args[:width] if args.key?(:width) right = args[:right] if args.key?(:right) else args = {} end BootstrapBuilders::Box.new(args.merge(title: title, width: width, right: right, block: blk, context: self)).html end def bs_edit_button(args) args[:label] = t("edit") unless args.key?(:label) BootstrapBuilders::Button.new(args.merge(icon: "wrench", context: self, can_type: :edit)).html end def bs_destroy_button(args) args[:label] = t("delete") unless args.key?(:label) args[:data] ||= {} args[:data][:confirm] ||= t("are_you_sure") button = BootstrapBuilders::Button.new(args.merge(icon: "remove", context: self, can_type: :destroy, method: :delete)) button.classes << "btn-danger" button.html end def bs_new_button(args) args[:label] = t("add_new") unless args.key?(:label) BootstrapBuilders::Button.new(args.merge(icon: "pencil", context: self, can_type: :new)).html end def bs_show_button(args) args[:label] = t("show") unless args.key?(:label) BootstrapBuilders::Button.new(args.merge(icon: "zoom-in", context: self, can_type: :show)).html end def bs_table(args = {}, &blk) classes = ["table", "table-bordered", "table-striped", "table-hover"] if args[:class].is_a?(String) classes += args.fetch(:class).split(/\s+/) elsif args[:class].is_a?(Array) classes += args.fetch(:class) end content_tag(:table, class: classes, &blk) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_builders-0.0.3 | lib/bootstrap_builders/application_helpers.rb |