Sha256: 189c5bf2561426b38dcbf131e91476b0d77e264936e5c27e13c07a9aea47e543

Contents?: true

Size: 1.17 KB

Versions: 48

Compression:

Stored size: 1.17 KB

Contents

/*
  Override the default confirm dialog
  defined by jQuery UJS
*/
$.rails.allowAction = function(link){
  if (link.data('confirm') == undefined){
    return true;
  }
  $.rails.showConfirmationDialog(link);
  return false;
}

/*
  Remove the data-confirm from the link so
  Rails doesn't re-trigger the modal. Then
  trigger a click of the link.
*/
$.rails.confirmed = function(link){
  link.data('confirm', null);
  link.trigger('click.rails');
}

/*
  Toggle the Foundation reveal modal when a data-confirm
  element is clicked.
*/
$.rails.showConfirmationDialog = function(link){
  var el = link.data('confirm');
  $('[data-' + el + ']').foundation('open');
}

/*
  General Usage:
  Link
  <a href="somewhere" data-confirm="my-data-element">Delete</a>

  Modal
  <div class="reveal" data-reveal data-my-data-element>
    ...
    <a href="#" data-reveal-confirm="my-data-element">OK</a>
    ...
  </div>
*/
$(document).on('click', '*[data-reveal-confirm]', function(e){
  e.preventDefault();
  var el = $(e.currentTarget).data('reveal-confirm');
  var link = $('[data-confirm="'+ el + '"]');
  var modal = $('[data-' + el + ']');
  $(modal).foundation('close');
  $.rails.confirmed(link);
});

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
ama_layout-9.4.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-9.3.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-9.2.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-9.1.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-9.0.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-8.0.2 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-8.0.1 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-8.0.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-7.0.2 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-7.0.1 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.12.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-7.0.pre app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.11.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-6.10.0.pre app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.10.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.9.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.8.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.7.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.6.0 app/assets/javascripts/ama_layout/confirm_modal.js
ama_layout-5.5.0 app/assets/javascripts/ama_layout/confirm_modal.js