diff --git a/spec/dummy/app/assets/stylesheets/application.css.scss b/spec/dummy/app/assets/stylesheets/application.css.scss index 94a6a23..f1ada13 100644 --- a/spec/dummy/app/assets/stylesheets/application.css.scss +++ b/spec/dummy/app/assets/stylesheets/application.css.scss @@ -17,7 +17,7 @@ @import 'dvl/components/pagination'; @import 'dvl/components/pagination_compact'; @import 'dvl/components/popovers'; -@import 'dvl/components/delete_popover'; +@import 'dvl/components/confirmation_popover'; @import 'dvl/components/progress'; @import 'dvl/components/sidebar_data'; @import 'dvl/components/sidebar_nav'; diff --git a/spec/dummy/app/views/home/components.rb b/spec/dummy/app/views/home/components.rb index f5cb61a..a3c165d 100644 --- a/spec/dummy/app/views/home/components.rb +++ b/spec/dummy/app/views/home/components.rb @@ -546,15 +546,39 @@ def main ul(class: 'delete_list') { li(class: 'js_delete_1') { text 'Project 1' - a(icon('minus-circle', 'aria-label' => 'Delete'), class: 'icon_secondary', 'data-confirm' => true, 'data-confirm-with' => 'popover', href: '/delete', 'data-method' => 'delete', 'data-remote' => true) + a( + icon('minus-circle', 'aria-label' => 'Delete'), + class: 'icon_secondary', + 'data-confirm' => true, + 'data-confirm-with' => 'popover', + href: '/delete', + 'data-method' => 'delete', + 'data-remote' => true + ) } li(class: 'js_delete_2') { text 'Project 2' - a(icon('minus-circle', 'aria-label' => 'Delete'), class: 'icon_secondary', 'data-confirm' => 'This is an important record. It will be destroyed forever.', 'data-confirm-with' => 'popover', href: '/delete', 'data-method' => 'delete', 'data-remote' => true) + a( + icon('minus-circle', 'aria-label' => 'Delete'), + class: 'icon_secondary', + 'data-confirm' => 'This is an important record. It will be destroyed forever.', + 'data-confirm-with' => 'popover', + href: '/delete', + 'data-method' => 'delete', + 'data-remote' => true + ) } li(class: 'js_delete_3') { text 'Project 3' - a(icon('minus-circle', 'aria-label' => 'Delete'), class: 'icon_secondary', 'data-confirm' => true, 'data-confirm-with' => 'popover', 'data-confirmation-options' => { 't_delete' => 'Archive' }.to_json, href: '/delete', 'data-method' => 'delete', 'data-remote' => true) + a( + icon('minus-circle', 'aria-label' => 'Delete'), + class: 'icon_secondary', + 'data-confirm' => true, + 'data-confirm-with' => 'popover', + 'data-confirm-text' => 'Archive', + href: '/delete', + 'data-method' => 'delete', + 'data-remote' => true) } } }, sub: true, hint: 'Popovers can contain headers and alternate button text.' diff --git a/vendor/assets/javascripts/dvl/components/confirmations.coffee b/vendor/assets/javascripts/dvl/components/confirmations.coffee index 9376576..f856373 100644 --- a/vendor/assets/javascripts/dvl/components/confirmations.coffee +++ b/vendor/assets/javascripts/dvl/components/confirmations.coffee @@ -2,9 +2,11 @@ Dvl.Confirmations = {} class Dvl.Confirmations.Popover defaults: - t_cancel: 'Cancel' - t_delete: 'Delete' - popoverOpts: {} + 'cancel-text': 'Cancel' + 'cancel-class': '' + 'confirm-class': 'error' + 'confirm-text': 'Delete' + 'popover-opts': {} # cancelCb: constructor: ($el, message, cb, opts = {}) -> @@ -15,11 +17,14 @@ class Dvl.Confirmations.Popover @$el.data('popover-confirmation', @) - @options = $.extend {}, @defaults, @$el.data('confirmation-options'), opts + @options = $.extend {}, @defaults, opts + + for i of @defaults + @options[i] = @$el.data(i) if @$el.data(i)? if message wrappedMessage = """ -