Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

fnix/rails_bs_popcon

Repository files navigation

RailsBsPopcon

Code Climate

Use a bootstrap popover for your links with data-confirm:

You must include the following JavaScript file:

#= require rails_bs_popcon

The default options are:

RailsBsPopcon.DEFAULTS = $.extend {}, $.fn.popover.Constructor.DEFAULTS,
  placement: 'top'
  title: 'Are you sure?'
  html: true
  btnOkClass: 'btn btn-danger'
  btnOkIcon: 'glyphicon glyphicon-ok'
  btnOkLabel: 'Yes'
  btnCancelClass: 'btn btn-default'
  btnCancelIcon: 'glyphicon glyphicon-remove'
  btnCancelLabel: 'No'
  template:
      '<div class="popover">
        <div class="arrow"></div>
        <h3 class="popover-title"></h3>
        <div class="popover-content text-center">
        </div>
      </div>'
  content: '
    <div class="btn-group">
      <a class="btn" data-apply="confirmation"></a>
      <a class="btn" data-dismiss="confirmation"></a>
    </div>'

After requiring the popcon file you can change the default options like this:

$.extend RailsBsPopcon.DEFAULTS,
  title: 'Tem certeza?'
  btnOkClass: 'btn btn-danger'
  btnOkLabel: 'Sim'
  btnCancelClass: 'btn btn-default'
  btnCancelLabel: 'Não'

The example below was generated with these modifications:

popcon example

You can also replace these options, or the popover ones, through data attributes, like data-title: 'What?', data-btn-ok-class: 'btn btn-primary btn-sm' and so on.

If you don't want any message inside the popover content just set data-confirm to true.

MIT-LICENSE © Kadu Diógenes.

About

Bootstrap popover for confirmation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published