0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Uses bootstrap popover to show confirmation buttons for links with data-confirm.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 4.2
 Project Readme

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.