Sha256: e94ce8a6ba25c482b4eeaf9a861bbb3c8bae321756b240979aa5c54609ea728f

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module Helpers
  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)).html
  end

  def bs_edit_button(args)
    BootstrapBuilders::Button.new(args.merge(title: t("edit"), icon: "wrench", context: self)).html
  end

  def bs_destroy_button(args)
    args[:class] ||= []
    args[:class] << "btn-danger"

    args[:data] ||= {}
    args[:data][:confirm] ||= t("are_you_sure")

    BootstrapBuilders::Button.new(args.merge(title: t("delete"), icon: "remove", context: self, method: :delete)).html
  end

  def bs_new_button(args)
    BootstrapBuilders::Button.new(args.merge(title: t("add_new"), icon: "pencil", context: self)).html
  end

  def bs_show_button(args)
    BootstrapBuilders::Button.new(args.merge(title: t("show"), icon: "zoom-in", context: self)).html
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bootstrap_builders-0.0.1 lib/bootstrap_helpers/helpers.rb