diff --git a/.babelrc.js b/.babelrc.js new file mode 100644 index 0000000..cb09b45 --- /dev/null +++ b/.babelrc.js @@ -0,0 +1,15 @@ +module.exports = { + presets: [ + [ + '@babel/env', + { + loose : true, + modules: false, + exclude: ['transform-typeof-symbol'] + } + ] + ], + plugins: [ + '@babel/proposal-object-rest-spread' + ] +}; diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..7dd9563 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,38 @@ +{ + "extends": "airbnb-base", + "env": { + "browser": true, + "es6": true + }, + "rules": { + "no-underscore-dangle": [ + "off" + ], + "func-names": [ + "off" + ], + "class-methods-use-this": [ + "off" + ], + "max-len": [ + "error", + 120 + ], + "brace-style": [ + "error", + "stroustrup" + ], + "no-param-reassign": [ + "error", + { + "props": false + } + ], + "key-spacing": [ + "error", + { + "align": "colon" + } + ] + } +} diff --git a/Gruntfile.js b/Gruntfile.js deleted file mode 100644 index a45322f..0000000 --- a/Gruntfile.js +++ /dev/null @@ -1,106 +0,0 @@ -module.exports = function(grunt) { - require('jit-grunt')(grunt); - - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - - banner: '/*!\n' + - ' * Bootstrap Confirmation <%= pkg.version %>\n' + - ' * Copyright 2013 Nimit Suwannagate \n' + - ' * Copyright 2014-<%= grunt.template.today("yyyy") %> Damien "Mistic" Sorel \n' + - ' * Licensed under the Apache License, Version 2.0\n' + - ' */', - - // serve folder content - connect: { - dev: { - options: { - port: 9000, - livereload: true - } - } - }, - - // watchers - watch: { - options: { - livereload: true - }, - dev: { - files: ['bootstrap-confirmation.js', 'example/**'], - tasks: [] - } - }, - - // open example - open: { - dev: { - path: 'http://localhost:<%= connect.dev.options.port%>/example/index.html' - } - }, - - // replace version number - replace: { - dist: { - options: { - patterns: [ - { - match: /(Confirmation\.VERSION = ').*(';)/, - replacement: '$1<%= pkg.version %>$2' - } - ] - }, - files: { - 'bootstrap-confirmation.js': [ - 'bootstrap-confirmation.js' - ] - } - } - }, - - // compress js - uglify: { - options: { - banner: '<%= banner %>\n', - mangle: { - except: ['$'] - } - }, - dist: { - files: { - 'bootstrap-confirmation.min.js': [ - 'bootstrap-confirmation.js' - ] - } - } - }, - - // jshint tests - jshint: { - lib: { - files: { - src: [ - 'bootstrap-confirmation.js' - ] - } - } - } - } - ); - - grunt.registerTask('default', [ - 'replace', - 'uglify' - ]); - - grunt.registerTask('test', [ - 'jshint' - ]); - - grunt.registerTask('serve', [ - 'connect', - 'open', - 'watch' - ]); - -}; diff --git a/bootstrap-confirmation.js b/bootstrap-confirmation.js deleted file mode 100644 index 511a0fd..0000000 --- a/bootstrap-confirmation.js +++ /dev/null @@ -1,457 +0,0 @@ -/*! - * Bootstrap Confirmation - * Copyright 2013 Nimit Suwannagate - * Copyright 2014-2017 Damien "Mistic" Sorel - * Licensed under the Apache License, Version 2.0 - */ - -(function($) { - 'use strict'; - - var activeConfirmation; - - // Confirmation extends popover.js - if (!$.fn.popover) { - throw new Error('Confirmation requires popover.js'); - } - - // CONFIRMATION PUBLIC CLASS DEFINITION - // =============================== - var Confirmation = function(element, options) { - options.trigger = 'click'; - - this.init(element, options); - }; - - Confirmation.VERSION = '2.4.1'; - - /** - * Map between keyboard events "keyCode|which" and "key" - */ - Confirmation.KEYMAP = { - 13: 'Enter', - 27: 'Escape', - 39: 'ArrowRight', - 40: 'ArrowDown' - }; - - Confirmation.DEFAULTS = $.extend({}, $.fn.popover.Constructor.DEFAULTS, { - placement: 'top', - title: 'Are you sure?', - popout: false, - singleton: false, - copyAttributes: 'href target', - buttons: null, - onConfirm: $.noop, - onCancel: $.noop, - btnOkClass: 'btn-xs btn-primary', - btnOkIcon: 'glyphicon glyphicon-ok', - btnOkLabel: 'Yes', - btnCancelClass: 'btn-xs btn-default', - btnCancelIcon: 'glyphicon glyphicon-remove', - btnCancelLabel: 'No', - // @formatter:off - // href="#" allows the buttons to be focused - template: '
' + - '
' + - '

' + - '
' + - '

' + - '
' + - '
' + - '' + - '' + - '
' + - '
' + - '
' + - '
' - // @formatter:on - }); - - Confirmation.prototype = $.extend({}, $.fn.popover.Constructor.prototype); - Confirmation.prototype.constructor = Confirmation; - - /** - * Expose defaults - * @returns {object} - */ - Confirmation.prototype.getDefaults = function() { - return Confirmation.DEFAULTS; - }; - - /** - * Init the component - * @param element {jQuery} - * @param options {object} - */ - Confirmation.prototype.init = function(element, options) { - $.fn.popover.Constructor.prototype.init.call(this, 'confirmation', element, options); - - if ((this.options.popout || this.options.singleton) && !options.rootSelector) { - throw new Error('The rootSelector option is required to use popout and singleton features since jQuery 3.'); - } - - // keep trace of selectors - this.options._isDelegate = false; - if (options.selector) { // container of buttons - this.options._selector = this._options._selector = options.rootSelector + ' ' + options.selector; - } - else if (options._selector) { // children of container - this.options._selector = options._selector; - this.options._isDelegate = true; - } - else { // standalone - this.options._selector = options.rootSelector; - } - - var self = this; - - if (!this.options.selector) { - // store copied attributes - this.options._attributes = {}; - if (this.options.copyAttributes) { - if (typeof this.options.copyAttributes === 'string') { - this.options.copyAttributes = this.options.copyAttributes.split(' '); - } - } - else { - this.options.copyAttributes = []; - } - - this.options.copyAttributes.forEach(function(attr) { - this.options._attributes[attr] = this.$element.attr(attr); - }, this); - - // cancel original event - this.$element.on(this.options.trigger, function(e, ack) { - if (!ack) { - e.preventDefault(); - e.stopPropagation(); - e.stopImmediatePropagation(); - } - }); - - // manage singleton - this.$element.on('show.bs.confirmation', function(e) { - if (self.options.singleton) { - // close all other popover already initialized - $(self.options._selector).not($(this)).filter(function() { - return $(this).data('bs.confirmation') !== undefined; - }).confirmation('hide'); - } - }); - } - else { - // cancel original event - this.$element.on(this.options.trigger, this.options.selector, function(e, ack) { - if (!ack) { - e.preventDefault(); - e.stopPropagation(); - e.stopImmediatePropagation(); - } - }); - } - - if (!this.options._isDelegate) { - // manage popout - this.eventBody = false; - this.uid = this.$element[0].id || this.getUID('group_'); - - this.$element.on('shown.bs.confirmation', function(e) { - if (self.options.popout && !self.eventBody) { - self.eventBody = $('body').on('click.bs.confirmation.' + self.uid, function(e) { - if ($(self.options._selector).is(e.target)) { - return; - } - - // close all popover already initialized - $(self.options._selector).filter(function() { - return $(this).data('bs.confirmation') !== undefined; - }).confirmation('hide'); - - $('body').off('click.bs.' + self.uid); - self.eventBody = false; - }); - } - }); - } - }; - - /** - * Overrides, always show - * @returns {boolean} - */ - Confirmation.prototype.hasContent = function() { - return true; - }; - - /** - * Sets the popover content - */ - Confirmation.prototype.setContent = function() { - var self = this; - var $tip = this.tip(); - var title = this.getTitle(); - var content = this.getContent(); - - $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title); - - $tip.find('.confirmation-content').toggle(!!content).children().detach().end()[ - // we use append for html objects to maintain js events - this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text' - ](content); - - $tip.on('click', function(e) { - e.stopPropagation(); - }); - - if (this.options.buttons) { - // configure custom buttons - var $group = $tip.find('.confirmation-buttons .btn-group').empty(); - - this.options.buttons.forEach(function(button) { - $group.append( - $('') - .addClass(button.class || 'btn btn-xs btn-default') - .html(button.label || '') - .attr(button.attr || {}) - .prepend($('').addClass(button.icon), ' ') - .one('click', function(e) { - if ($(this).attr('href') === '#') { - e.preventDefault(); - } - - if (button.onClick) { - button.onClick.call(self.$element); - } - - if (button.cancel) { - self.getOnCancel().call(self.$element, button.value); - self.$element.trigger('canceled.bs.confirmation', [button.value]); - } - else { - self.getOnConfirm().call(self.$element, button.value); - self.$element.trigger('confirmed.bs.confirmation', [button.value]); - } - - if (self.inState) { // Bootstrap 3.3.5 - self.inState.click = false; - } - - self.hide(); - }) - ); - }, this); - } - else { - // configure 'ok' button - $tip.find('[data-apply="confirmation"]') - .addClass(this.options.btnOkClass) - .html(this.options.btnOkLabel) - .attr(this.options._attributes) - .prepend($('').addClass(this.options.btnOkIcon), ' ') - .off('click') - .one('click', function(e) { - if ($(this).attr('href') === '#') { - e.preventDefault(); - } - - self.getOnConfirm().call(self.$element); - self.$element.trigger('confirmed.bs.confirmation'); - - self.$element.trigger(self.options.trigger, [true]); - - self.hide(); - }); - - // configure 'cancel' button - $tip.find('[data-dismiss="confirmation"]') - .addClass(this.options.btnCancelClass) - .html(this.options.btnCancelLabel) - .prepend($('').addClass(this.options.btnCancelIcon), ' ') - .off('click') - .one('click', function(e) { - e.preventDefault(); - - self.getOnCancel().call(self.$element); - self.$element.trigger('canceled.bs.confirmation'); - - if (self.inState) { // Bootstrap 3.3.5 - self.inState.click = false; - } - - self.hide(); - }); - } - - $tip.removeClass('fade top bottom left right in'); - - // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do - // this manually by checking the contents. - if (!$tip.find('.popover-title').html()) { - $tip.find('.popover-title').hide(); - } - - // bind key navigation - activeConfirmation = this; - $(window) - .off('keyup.bs.confirmation') - .on('keyup.bs.confirmation', this._onKeyup.bind(this)); - }; - - /** - * Remove key binding on destroy - */ - Confirmation.prototype.destroy = function() { - if (activeConfirmation === this) { - activeConfirmation = undefined; - $(window).off('keyup.bs.confirmation'); - } - $.fn.popover.Constructor.prototype.destroy.call(this); - }; - - /** - * Remove key binding on hide - */ - Confirmation.prototype.hide = function() { - if (activeConfirmation === this) { - activeConfirmation = undefined; - $(window).off('keyup.bs.confirmation'); - } - $.fn.popover.Constructor.prototype.hide.call(this); - }; - - /** - * Navigate through buttons with keyboard - * @param event - * @private - */ - Confirmation.prototype._onKeyup = function(event) { - if (!this.$tip) { - activeConfirmation = undefined; - $(window).off('keyup.bs.confirmation'); - return; - } - - var key = event.key || Confirmation.KEYMAP[event.keyCode || event.which]; - - var $group = this.$tip.find('.confirmation-buttons .btn-group'); - var $active = $group.find('.active'); - var $next; - - switch (key) { - case 'Escape': - this.hide(); - break; - - case 'ArrowRight': - if ($active.length && $active.next().length) { - $next = $active.next(); - } - else { - $next = $group.children().first(); - } - $active.removeClass('active'); - $next.addClass('active').focus(); - break; - - case 'ArrowLeft': - if ($active.length && $active.prev().length) { - $next = $active.prev(); - } - else { - $next = $group.children().last(); - } - $active.removeClass('active'); - $next.addClass('active').focus(); - break; - } - }; - - /** - * Gets the on-confirm callback - * @returns {function} - */ - Confirmation.prototype.getOnConfirm = function() { - if (this.$element.attr('data-on-confirm')) { - return getFunctionFromString(this.$element.attr('data-on-confirm')); - } - else { - return this.options.onConfirm; - } - }; - - /** - * Gets the on-cancel callback - * @returns {function} - */ - Confirmation.prototype.getOnCancel = function() { - if (this.$element.attr('data-on-cancel')) { - return getFunctionFromString(this.$element.attr('data-on-cancel')); - } - else { - return this.options.onCancel; - } - }; - - /** - * Generates an anonymous function from a function name - * function name may contain dots (.) to navigate through objects - * root context is window - */ - function getFunctionFromString(functionName) { - var context = window; - var namespaces = functionName.split('.'); - var func = namespaces.pop(); - - for (var i = 0, l = namespaces.length; i < l; i++) { - context = context[namespaces[i]]; - } - - return function() { - context[func].call(this); - }; - } - - - // CONFIRMATION PLUGIN DEFINITION - // ========================= - - var old = $.fn.confirmation; - - $.fn.confirmation = function(option) { - var options = (typeof option == 'object' && option) || {}; - options.rootSelector = this.selector || options.rootSelector; // this.selector removed in jQuery > 3 - - return this.each(function() { - var $this = $(this); - var data = $this.data('bs.confirmation'); - - if (!data && option == 'destroy') { - return; - } - if (!data) { - $this.data('bs.confirmation', (data = new Confirmation(this, options))); - } - if (typeof option == 'string') { - data[option](); - - if (option == 'hide' && data.inState) { //data.inState doesn't exist in Bootstrap < 3.3.5 - data.inState.click = false; - } - } - }); - }; - - $.fn.confirmation.Constructor = Confirmation; - - - // CONFIRMATION NO CONFLICT - // =================== - - $.fn.confirmation.noConflict = function() { - $.fn.confirmation = old; - return this; - }; - -}(jQuery)); diff --git a/bootstrap-confirmation.min.js b/bootstrap-confirmation.min.js deleted file mode 100644 index 9446bf7..0000000 --- a/bootstrap-confirmation.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * Bootstrap Confirmation 2.4.1 - * Copyright 2013 Nimit Suwannagate - * Copyright 2014-2018 Damien "Mistic" Sorel - * Licensed under the Apache License, Version 2.0 - */ -!function($){"use strict";function a(a){for(var b=window,c=a.split("."),d=c.pop(),e=0,f=c.length;e

'}),c.prototype=$.extend({},$.fn.popover.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.init=function(a,b){if($.fn.popover.Constructor.prototype.init.call(this,"confirmation",a,b),(this.options.popout||this.options.singleton)&&!b.rootSelector)throw new Error("The rootSelector option is required to use popout and singleton features since jQuery 3.");this.options._isDelegate=!1,b.selector?this.options._selector=this._options._selector=b.rootSelector+" "+b.selector:b._selector?(this.options._selector=b._selector,this.options._isDelegate=!0):this.options._selector=b.rootSelector;var c=this;this.options.selector?this.$element.on(this.options.trigger,this.options.selector,function(a,b){b||(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation())}):(this.options._attributes={},this.options.copyAttributes?"string"==typeof this.options.copyAttributes&&(this.options.copyAttributes=this.options.copyAttributes.split(" ")):this.options.copyAttributes=[],this.options.copyAttributes.forEach(function(a){this.options._attributes[a]=this.$element.attr(a)},this),this.$element.on(this.options.trigger,function(a,b){b||(a.preventDefault(),a.stopPropagation(),a.stopImmediatePropagation())}),this.$element.on("show.bs.confirmation",function(a){c.options.singleton&&$(c.options._selector).not($(this)).filter(function(){return void 0!==$(this).data("bs.confirmation")}).confirmation("hide")})),this.options._isDelegate||(this.eventBody=!1,this.uid=this.$element[0].id||this.getUID("group_"),this.$element.on("shown.bs.confirmation",function(a){c.options.popout&&!c.eventBody&&(c.eventBody=$("body").on("click.bs.confirmation."+c.uid,function(a){$(c.options._selector).is(a.target)||($(c.options._selector).filter(function(){return void 0!==$(this).data("bs.confirmation")}).confirmation("hide"),$("body").off("click.bs."+c.uid),c.eventBody=!1)}))}))},c.prototype.hasContent=function(){return!0},c.prototype.setContent=function(){var a=this,c=this.tip(),d=this.getTitle(),e=this.getContent();if(c.find(".popover-title")[this.options.html?"html":"text"](d),c.find(".confirmation-content").toggle(!!e).children().detach().end()[this.options.html?"string"==typeof e?"html":"append":"text"](e),c.on("click",function(a){a.stopPropagation()}),this.options.buttons){var f=c.find(".confirmation-buttons .btn-group").empty();this.options.buttons.forEach(function(b){f.append($('').addClass(b["class"]||"btn btn-xs btn-default").html(b.label||"").attr(b.attr||{}).prepend($("").addClass(b.icon)," ").one("click",function(c){"#"===$(this).attr("href")&&c.preventDefault(),b.onClick&&b.onClick.call(a.$element),b.cancel?(a.getOnCancel().call(a.$element,b.value),a.$element.trigger("canceled.bs.confirmation",[b.value])):(a.getOnConfirm().call(a.$element,b.value),a.$element.trigger("confirmed.bs.confirmation",[b.value])),a.inState&&(a.inState.click=!1),a.hide()}))},this)}else c.find('[data-apply="confirmation"]').addClass(this.options.btnOkClass).html(this.options.btnOkLabel).attr(this.options._attributes).prepend($("").addClass(this.options.btnOkIcon)," ").off("click").one("click",function(b){"#"===$(this).attr("href")&&b.preventDefault(),a.getOnConfirm().call(a.$element),a.$element.trigger("confirmed.bs.confirmation"),a.$element.trigger(a.options.trigger,[!0]),a.hide()}),c.find('[data-dismiss="confirmation"]').addClass(this.options.btnCancelClass).html(this.options.btnCancelLabel).prepend($("").addClass(this.options.btnCancelIcon)," ").off("click").one("click",function(b){b.preventDefault(),a.getOnCancel().call(a.$element),a.$element.trigger("canceled.bs.confirmation"),a.inState&&(a.inState.click=!1),a.hide()});c.removeClass("fade top bottom left right in"),c.find(".popover-title").html()||c.find(".popover-title").hide(),b=this,$(window).off("keyup.bs.confirmation").on("keyup.bs.confirmation",this._onKeyup.bind(this))},c.prototype.destroy=function(){b===this&&(b=void 0,$(window).off("keyup.bs.confirmation")),$.fn.popover.Constructor.prototype.destroy.call(this)},c.prototype.hide=function(){b===this&&(b=void 0,$(window).off("keyup.bs.confirmation")),$.fn.popover.Constructor.prototype.hide.call(this)},c.prototype._onKeyup=function(a){if(!this.$tip)return b=void 0,void $(window).off("keyup.bs.confirmation");var d,e=a.key||c.KEYMAP[a.keyCode||a.which],f=this.$tip.find(".confirmation-buttons .btn-group"),g=f.find(".active");switch(e){case"Escape":this.hide();break;case"ArrowRight":d=g.length&&g.next().length?g.next():f.children().first(),g.removeClass("active"),d.addClass("active").focus();break;case"ArrowLeft":d=g.length&&g.prev().length?g.prev():f.children().last(),g.removeClass("active"),d.addClass("active").focus()}},c.prototype.getOnConfirm=function(){return this.$element.attr("data-on-confirm")?a(this.$element.attr("data-on-confirm")):this.options.onConfirm},c.prototype.getOnCancel=function(){return this.$element.attr("data-on-cancel")?a(this.$element.attr("data-on-cancel")):this.options.onCancel};var d=$.fn.confirmation;$.fn.confirmation=function(a){var b="object"==typeof a&&a||{};return b.rootSelector=this.selector||b.rootSelector,this.each(function(){var d=$(this),e=d.data("bs.confirmation");(e||"destroy"!=a)&&(e||d.data("bs.confirmation",e=new c(this,b)),"string"==typeof a&&(e[a](),"hide"==a&&e.inState&&(e.inState.click=!1)))})},$.fn.confirmation.Constructor=c,$.fn.confirmation.noConflict=function(){return $.fn.confirmation=d,this}}(jQuery); \ No newline at end of file diff --git a/bower.json b/bower.json index 718da59..77d7306 100644 --- a/bower.json +++ b/bower.json @@ -14,14 +14,14 @@ "homepage": "http://www.strangeplanet.fr" } ], - "main": "bootstrap-confirmation.js", + "main": "dist/bootstrap-confirmation.js", "keywords": [ "bootstrap", "confirmation", "popup" ], "dependencies" : { - "bootstrap": ">=3.2.0 <4" + "bootstrap": ">=4.0.0" }, "repository": { "type": "git", diff --git a/dist/bootstrap-confirmation.js b/dist/bootstrap-confirmation.js new file mode 100644 index 0000000..c133ef3 --- /dev/null +++ b/dist/bootstrap-confirmation.js @@ -0,0 +1,596 @@ +/*! + * Bootstrap Confirmation (v4.0.0) + * @copyright 2013 Nimit Suwannagate + * @copyright 2014-2018 Damien "Mistic" Sorel + * @licence Apache License, Version 2.0 + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('jquery'), require('bootstrap')) : + typeof define === 'function' && define.amd ? define(['jquery', 'bootstrap'], factory) : + (factory(global.jQuery)); +}(this, (function ($) { 'use strict'; + + $ = $ && $.hasOwnProperty('default') ? $['default'] : $; + + function _defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + function _createClass(Constructor, protoProps, staticProps) { + if (protoProps) _defineProperties(Constructor.prototype, protoProps); + if (staticProps) _defineProperties(Constructor, staticProps); + return Constructor; + } + + function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; + } + + function _objectSpread(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + var ownKeys = Object.keys(source); + + if (typeof Object.getOwnPropertySymbols === 'function') { + ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { + return Object.getOwnPropertyDescriptor(source, sym).enumerable; + })); + } + + ownKeys.forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } + + return target; + } + + function _inheritsLoose(subClass, superClass) { + subClass.prototype = Object.create(superClass.prototype); + subClass.prototype.constructor = subClass; + subClass.__proto__ = superClass; + } + + if (typeof $.fn.popover === 'undefined' || $.fn.popover.Constructor.VERSION.split('.').shift() !== '4') { + throw new Error('Bootstrap Confirmation 4 requires Bootstrap Popover 4'); + } + + var Popover = $.fn.popover.Constructor; + + /** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + + var NAME = 'confirmation'; + var VERSION = '4.0.0'; + var DATA_KEY = "bs." + NAME; + var EVENT_KEY = "." + DATA_KEY; + var JQUERY_NO_CONFLICT = $.fn[NAME]; + var BTN_CLASS_DEFAULT = 'btn btn-sm h-100 d-flex align-items-center'; + + var DefaultType = _objectSpread({}, Popover.DefaultType, { + singleton: 'boolean', + popout: 'boolean', + copyAttributes: '(string|array)', + onConfirm: 'function', + onCancel: 'function', + btnOkClass: 'string', + btnOkLabel: 'string', + btnOkIconClass: 'string', + btnOkIconContent: 'string', + btnCancelClass: 'string', + btnCancelLabel: 'string', + btnCancelIconClass: 'string', + btnCancelIconContent: 'string', + buttons: 'array' + }); + + var Default = _objectSpread({}, Popover.Default, { + _attributes: {}, + _selector: null, + placement: 'top', + title: 'Are you sure?', + trigger: 'click', + content: '', + singleton: false, + popout: false, + copyAttributes: 'href target', + onConfirm: $.noop, + onCancel: $.noop, + btnOkClass: 'btn-primary', + btnOkLabel: 'Yes', + btnOkIconClass: '', + btnOkIconContent: '', + btnCancelClass: 'btn-secondary', + btnCancelLabel: 'No', + btnCancelIconClass: '', + btnCancelIconContent: '', + buttons: [], + // @formatter:off + // href="#" allows the buttons to be focused + template: "\n
\n
\n

\n
\n

\n
\n
\n \n \n
\n
\n
\n
" // @formatter:on + + }); + + var ClassName = { + FADE: 'fade', + SHOW: 'show' + }; + var Selector = { + TITLE: '.popover-header', + CONTENT: '.confirmation-content', + BUTTONS: '.confirmation-buttons .btn-group', + BTN_APPLY: '[data-apply=confirmation]', + BTN_DISMISS: '[data-dismiss=confirmation]' + }; + var Keymap = { + 13: 'Enter', + 27: 'Escape', + 39: 'ArrowRight', + 40: 'ArrowDown' + }; + var Event = { + HIDE: "hide" + EVENT_KEY, + HIDDEN: "hidden" + EVENT_KEY, + SHOW: "show" + EVENT_KEY, + SHOWN: "shown" + EVENT_KEY, + INSERTED: "inserted" + EVENT_KEY, + CLICK: "click" + EVENT_KEY, + FOCUSIN: "focusin" + EVENT_KEY, + FOCUSOUT: "focusout" + EVENT_KEY, + MOUSEENTER: "mouseenter" + EVENT_KEY, + MOUSELEAVE: "mouseleave" + EVENT_KEY, + CONFIRMED: "confirmed" + EVENT_KEY, + CANCELED: "canceled" + EVENT_KEY, + KEYUP: "keyup" + EVENT_KEY + }; + /** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + // keep track of the last openned confirmation for keyboard navigation + + var activeConfirmation; + + var Confirmation = + /*#__PURE__*/ + function (_Popover) { + _inheritsLoose(Confirmation, _Popover); + + _createClass(Confirmation, null, [{ + key: "VERSION", + // Getters + get: function get() { + return VERSION; + } + }, { + key: "Default", + get: function get() { + return Default; + } + }, { + key: "NAME", + get: function get() { + return NAME; + } + }, { + key: "DATA_KEY", + get: function get() { + return DATA_KEY; + } + }, { + key: "Event", + get: function get() { + return Event; + } + }, { + key: "EVENT_KEY", + get: function get() { + return EVENT_KEY; + } + }, { + key: "DefaultType", + get: function get() { + return DefaultType; + } // Constructor + + }]); + + function Confirmation(element, config) { + var _this; + + _this = _Popover.call(this, element, config) || this; + + if ((_this.config.popout || _this.config.singleton) && !_this.config.rootSelector) { + throw new Error('The rootSelector option is required to use popout and singleton features since jQuery 3.'); + } // keep trace of selectors + + + _this._isDelegate = false; + + if (config.selector) { + // container of buttons + config._selector = config.rootSelector + " " + config.selector; + _this.config._selector = config._selector; + } else if (config._selector) { + // children of container + _this.config._selector = config._selector; + _this._isDelegate = true; + } else { + // standalone + _this.config._selector = config.rootSelector; + } + + if (!_this.config.selector) { + _this._copyAttributes(); + } + + _this._setConfirmationListeners(); + + return _this; + } // Overrides + + + var _proto = Confirmation.prototype; + + _proto.isWithContent = function isWithContent() { + return true; + }; + + _proto.setContent = function setContent() { + var $tip = $(this.getTipElement()); + + var content = this._getContent(); + + if (typeof content === 'function') { + content = content.call(this.element); + } + + this.setElementContent($tip.find(Selector.TITLE), this.getTitle()); + $tip.find(Selector.CONTENT).toggle(!!content); + + if (content) { + this.setElementContent($tip.find(Selector.CONTENT), content); + } + + if (this.config.buttons.length > 0) { + this._setCustomButtons($tip); + } else { + this._setStandardButtons($tip); + } + + $tip.removeClass(ClassName.FADE + " " + ClassName.SHOW); + + this._setupKeyupEvent(); + }; + + _proto.dispose = function dispose() { + this._cleanKeyupEvent(); + + _Popover.prototype.dispose.call(this); + }; + + _proto.hide = function hide(callback) { + this._cleanKeyupEvent(); + + _Popover.prototype.hide.call(this, callback); + }; // Private + + /** + * Copy the value of `copyAttributes` on the config object + * @private + */ + + + _proto._copyAttributes = function _copyAttributes() { + var _this2 = this; + + this.config._attributes = {}; + + if (this.config.copyAttributes) { + if (typeof this.config.copyAttributes === 'string') { + this.config.copyAttributes = this.config.copyAttributes.split(' '); + } + } else { + this.config.copyAttributes = []; + } + + this.config.copyAttributes.forEach(function (attr) { + _this2.config._attributes[attr] = $(_this2.element).attr(attr); + }); + }; + /** + * Custom event listeners for popouts and singletons + * @private + */ + + + _proto._setConfirmationListeners = function _setConfirmationListeners() { + var self = this; + + if (!this.config.selector) { + // cancel original event + $(this.element).on(this.config.trigger, function (e, ack) { + if (!ack) { + e.preventDefault(); + e.stopPropagation(); + e.stopImmediatePropagation(); + } + }); // manage singleton + + $(this.element).on(Event.SHOWN, function () { + if (self.config.singleton) { + // close all other popover already initialized + $(self.config._selector).not($(this)).filter(function () { + return $(this).data(DATA_KEY) !== undefined; + }).confirmation('hide'); + } + }); + } else { + // cancel original event + $(this.element).on(this.config.trigger, this.config.selector, function (e, ack) { + if (!ack) { + e.preventDefault(); + e.stopPropagation(); + e.stopImmediatePropagation(); + } + }); + } + + if (!this._isDelegate) { + // manage popout + this.eventBody = false; + this.uid = this.element.id || Confirmation.getUID(NAME + "_group"); + $(this.element).on(Event.SHOWN, function () { + if (self.config.popout && !self.eventBody) { + self.eventBody = $('body').on(Event.CLICK + "." + self.uid, function (e) { + if ($(self.config._selector).is(e.target)) { + return; + } // close all popover already initialized + + + $(self.config._selector).filter(function () { + return $(this).data(DATA_KEY) !== undefined; + }).confirmation('hide'); + $('body').off(Event.SHOWN + "." + self.uid); + self.eventBody = false; + }); + } + }); + } + }; + /** + * Init the standard ok/cancel buttons + * @param $tip + * @private + */ + + + _proto._setStandardButtons = function _setStandardButtons($tip) { + var self = this; + var btnApply = $tip.find(Selector.BTN_APPLY).addClass(this.config.btnOkClass).html(this.config.btnOkLabel).attr(this.config._attributes); + + if (this.config.btnOkIconClass || this.config.btnOkIconContent) { + btnApply.prepend($('').addClass(this.config.btnOkIconClass || '').text(this.config.btnOkIconContent || '')); + } + + btnApply.off('click').one('click', function (e) { + if ($(this).attr('href') === '#') { + e.preventDefault(); + } + + self.config.onConfirm.call(self.element); + $(self.element).trigger(Event.CONFIRMED); + $(self.element).trigger(self.config.trigger, [true]); + self.hide(); + }); + var btnDismiss = $tip.find(Selector.BTN_DISMISS).addClass(this.config.btnCancelClass).html(this.config.btnCancelLabel); + + if (this.config.btnCancelIconClass || this.config.btnCancelIconContent) { + btnDismiss.prepend($('').addClass(this.config.btnCancelIconClass || '').text(this.config.btnCancelIconContent || '')); + } + + btnDismiss.off('click').one('click', function (e) { + e.preventDefault(); + self.config.onCancel.call(self.element); + $(self.element).trigger(Event.CANCELED); + self.hide(); + }); + }; + /** + * Init the custom buttons + * @param $tip + * @private + */ + + + _proto._setCustomButtons = function _setCustomButtons($tip) { + var self = this; + var $group = $tip.find(Selector.BUTTONS).empty(); + this.config.buttons.forEach(function (button) { + var btn = $('').addClass(BTN_CLASS_DEFAULT).addClass(button.class || 'btn btn-secondary').html(button.label || '').attr(button.attr || {}); + + if (button.iconClass || button.iconContent) { + btn.prepend($('').addClass(button.iconClass || '').text(button.iconContent || '')); + } + + btn.one('click', function (e) { + if ($(this).attr('href') === '#') { + e.preventDefault(); + } + + if (button.onClick) { + button.onClick.call($(self.element)); + } + + if (button.cancel) { + self.config.onCancel.call(self.element, button.value); + $(self.element).trigger(Event.CANCELED, [button.value]); + } else { + self.config.onConfirm.call(self.element, button.value); + $(self.element).trigger(Event.CONFIRMED, [button.value]); + } + + self.hide(); + }); + $group.append(btn); + }); + }; + /** + * Install the keyboatd event handler + * @private + */ + + + _proto._setupKeyupEvent = function _setupKeyupEvent() { + activeConfirmation = this; + $(window).off(Event.KEYUP).on(Event.KEYUP, this._onKeyup.bind(this)); + }; + /** + * Remove the keyboard event handler + * @private + */ + + + _proto._cleanKeyupEvent = function _cleanKeyupEvent() { + if (activeConfirmation === this) { + activeConfirmation = undefined; + $(window).off(Event.KEYUP); + } + }; + /** + * Event handler for keyboard navigation + * @param event + * @private + */ + + + _proto._onKeyup = function _onKeyup(event) { + if (!this.tip) { + this._cleanKeyupEvent(); + + return; + } + + var $tip = $(this.getTipElement()); + var key = event.key || Keymap[event.keyCode || event.which]; + var $group = $tip.find(Selector.BUTTONS); + var $active = $group.find('.active'); + var $next; + + switch (key) { + case 'Escape': + this.hide(); + break; + + case 'ArrowRight': + if ($active.length && $active.next().length) { + $next = $active.next(); + } else { + $next = $group.children().first(); + } + + $active.removeClass('active'); + $next.addClass('active').focus(); + break; + + case 'ArrowLeft': + if ($active.length && $active.prev().length) { + $next = $active.prev(); + } else { + $next = $group.children().last(); + } + + $active.removeClass('active'); + $next.addClass('active').focus(); + break; + + default: + break; + } + }; // Static + + /** + * Generates an uui, copied from Bootrap's utils + * @param {string} prefix + * @returns {string} + */ + + + Confirmation.getUID = function getUID(prefix) { + var uid = prefix; + + do { + // eslint-disable-next-line no-bitwise + uid += ~~(Math.random() * 1000000); // "~~" acts like a faster Math.floor() here + } while (document.getElementById(uid)); + + return uid; + }; + + Confirmation._jQueryInterface = function _jQueryInterface(config) { + return this.each(function () { + var data = $(this).data(DATA_KEY); + + var _config = typeof config === 'object' ? config : {}; + + _config.rootSelector = $(this).selector || _config.rootSelector; // this.selector removed in jQuery > 3 + + if (!data && /destroy|hide/.test(config)) { + return; + } + + if (!data) { + data = new Confirmation(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError("No method named \"" + config + "\""); + } + + data[config](); + } + }); + }; + + return Confirmation; + }(Popover); + /** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + + + $.fn[NAME] = Confirmation._jQueryInterface; + $.fn[NAME].Constructor = Confirmation; + + $.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Confirmation._jQueryInterface; + }; + +}))); +//# sourceMappingURL=bootstrap-confirmation.js.map diff --git a/dist/bootstrap-confirmation.js.map b/dist/bootstrap-confirmation.js.map new file mode 100644 index 0000000..7c9aeba --- /dev/null +++ b/dist/bootstrap-confirmation.js.map @@ -0,0 +1 @@ +{"version":3,"file":"bootstrap-confirmation.js","sources":["../rollupPluginBabelHelpers","../src/popover.js","../src/confirmation.js"],"sourcesContent":["export { _createClass as createClass, _defineProperty as defineProperty, _objectSpread as objectSpread, _inheritsLoose as inheritsLoose, _assertThisInitialized as assertThisInitialized };\n\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nfunction _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n var ownKeys = Object.keys(source);\n\n if (typeof Object.getOwnPropertySymbols === 'function') {\n ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {\n return Object.getOwnPropertyDescriptor(source, sym).enumerable;\n }));\n }\n\n ownKeys.forEach(function (key) {\n _defineProperty(target, key, source[key]);\n });\n }\n\n return target;\n}\n\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}\n\nfunction _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}","import $ from 'jquery';\nimport 'bootstrap';\n\nif (typeof $.fn.popover === 'undefined' || $.fn.popover.Constructor.VERSION.split('.').shift() !== '4') {\n throw new Error('Bootstrap Confirmation 4 requires Bootstrap Popover 4');\n}\n\nconst Popover = $.fn.popover.Constructor;\n\nexport default Popover;\n","import $ from 'jquery';\nimport Popover from 'bootstrap/js/src/popover';\n\n/**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\nconst NAME = 'confirmation';\nconst VERSION = '4.0.0';\nconst DATA_KEY = `bs.${NAME}`;\nconst EVENT_KEY = `.${DATA_KEY}`;\nconst JQUERY_NO_CONFLICT = $.fn[NAME];\nconst BTN_CLASS_DEFAULT = 'btn btn-sm h-100 d-flex align-items-center';\n\nconst DefaultType = {\n ...Popover.DefaultType,\n singleton : 'boolean',\n popout : 'boolean',\n copyAttributes : '(string|array)',\n onConfirm : 'function',\n onCancel : 'function',\n btnOkClass : 'string',\n btnOkLabel : 'string',\n btnOkIconClass : 'string',\n btnOkIconContent : 'string',\n btnCancelClass : 'string',\n btnCancelLabel : 'string',\n btnCancelIconClass : 'string',\n btnCancelIconContent: 'string',\n buttons : 'array',\n};\n\nconst Default = {\n ...Popover.Default,\n _attributes : {},\n _selector : null,\n placement : 'top',\n title : 'Are you sure?',\n trigger : 'click',\n content : '',\n singleton : false,\n popout : false,\n copyAttributes : 'href target',\n onConfirm : $.noop,\n onCancel : $.noop,\n btnOkClass : 'btn-primary',\n btnOkLabel : 'Yes',\n btnOkIconClass : '',\n btnOkIconContent : '',\n btnCancelClass : 'btn-secondary',\n btnCancelLabel : 'No',\n btnCancelIconClass : '',\n btnCancelIconContent: '',\n buttons : [],\n // @formatter:off\n // href=\"#\" allows the buttons to be focused\n template : `\n
\n
\n

\n
\n

\n
\n
\n \n \n
\n
\n
\n
`,\n // @formatter:on\n};\n\nconst ClassName = {\n FADE: 'fade',\n SHOW: 'show',\n};\n\nconst Selector = {\n TITLE : '.popover-header',\n CONTENT : '.confirmation-content',\n BUTTONS : '.confirmation-buttons .btn-group',\n BTN_APPLY : '[data-apply=confirmation]',\n BTN_DISMISS: '[data-dismiss=confirmation]',\n};\n\nconst Keymap = {\n 13: 'Enter',\n 27: 'Escape',\n 39: 'ArrowRight',\n 40: 'ArrowDown',\n};\n\nconst Event = {\n HIDE : `hide${EVENT_KEY}`,\n HIDDEN : `hidden${EVENT_KEY}`,\n SHOW : `show${EVENT_KEY}`,\n SHOWN : `shown${EVENT_KEY}`,\n INSERTED : `inserted${EVENT_KEY}`,\n CLICK : `click${EVENT_KEY}`,\n FOCUSIN : `focusin${EVENT_KEY}`,\n FOCUSOUT : `focusout${EVENT_KEY}`,\n MOUSEENTER: `mouseenter${EVENT_KEY}`,\n MOUSELEAVE: `mouseleave${EVENT_KEY}`,\n CONFIRMED : `confirmed${EVENT_KEY}`,\n CANCELED : `canceled${EVENT_KEY}`,\n KEYUP : `keyup${EVENT_KEY}`,\n};\n\n/**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n// keep track of the last openned confirmation for keyboard navigation\nlet activeConfirmation;\n\nclass Confirmation extends Popover {\n // Getters\n\n static get VERSION() {\n return VERSION;\n }\n\n static get Default() {\n return Default;\n }\n\n static get NAME() {\n return NAME;\n }\n\n static get DATA_KEY() {\n return DATA_KEY;\n }\n\n static get Event() {\n return Event;\n }\n\n static get EVENT_KEY() {\n return EVENT_KEY;\n }\n\n static get DefaultType() {\n return DefaultType;\n }\n\n // Constructor\n\n constructor(element, config) {\n super(element, config);\n\n if ((this.config.popout || this.config.singleton) && !this.config.rootSelector) {\n throw new Error('The rootSelector option is required to use popout and singleton features since jQuery 3.');\n }\n\n // keep trace of selectors\n this._isDelegate = false;\n\n if (config.selector) { // container of buttons\n config._selector = `${config.rootSelector} ${config.selector}`;\n this.config._selector = config._selector;\n }\n else if (config._selector) { // children of container\n this.config._selector = config._selector;\n this._isDelegate = true;\n }\n else { // standalone\n this.config._selector = config.rootSelector;\n }\n\n if (!this.config.selector) {\n this._copyAttributes();\n }\n\n this._setConfirmationListeners();\n }\n\n // Overrides\n\n isWithContent() {\n return true;\n }\n\n setContent() {\n const $tip = $(this.getTipElement());\n let content = this._getContent();\n\n if (typeof content === 'function') {\n content = content.call(this.element);\n }\n\n this.setElementContent($tip.find(Selector.TITLE), this.getTitle());\n\n $tip.find(Selector.CONTENT).toggle(!!content);\n if (content) {\n this.setElementContent($tip.find(Selector.CONTENT), content);\n }\n\n if (this.config.buttons.length > 0) {\n this._setCustomButtons($tip);\n }\n else {\n this._setStandardButtons($tip);\n }\n\n $tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`);\n\n this._setupKeyupEvent();\n }\n\n dispose() {\n this._cleanKeyupEvent();\n super.dispose();\n }\n\n hide(callback) {\n this._cleanKeyupEvent();\n super.hide(callback);\n }\n\n // Private\n\n /**\n * Copy the value of `copyAttributes` on the config object\n * @private\n */\n _copyAttributes() {\n this.config._attributes = {};\n if (this.config.copyAttributes) {\n if (typeof this.config.copyAttributes === 'string') {\n this.config.copyAttributes = this.config.copyAttributes.split(' ');\n }\n }\n else {\n this.config.copyAttributes = [];\n }\n\n this.config.copyAttributes.forEach((attr) => {\n this.config._attributes[attr] = $(this.element).attr(attr);\n });\n }\n\n /**\n * Custom event listeners for popouts and singletons\n * @private\n */\n _setConfirmationListeners() {\n const self = this;\n\n if (!this.config.selector) {\n // cancel original event\n $(this.element).on(this.config.trigger, (e, ack) => {\n if (!ack) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n }\n });\n\n // manage singleton\n $(this.element).on(Event.SHOWN, function () {\n if (self.config.singleton) {\n // close all other popover already initialized\n $(self.config._selector).not($(this)).filter(function () {\n return $(this).data(DATA_KEY) !== undefined;\n }).confirmation('hide');\n }\n });\n }\n else {\n // cancel original event\n $(this.element).on(this.config.trigger, this.config.selector, (e, ack) => {\n if (!ack) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n }\n });\n }\n\n if (!this._isDelegate) {\n // manage popout\n this.eventBody = false;\n this.uid = this.element.id || Confirmation.getUID(`${NAME}_group`);\n\n $(this.element).on(Event.SHOWN, () => {\n if (self.config.popout && !self.eventBody) {\n self.eventBody = $('body').on(`${Event.CLICK}.${self.uid}`, (e) => {\n if ($(self.config._selector).is(e.target)) {\n return;\n }\n // close all popover already initialized\n $(self.config._selector).filter(function () {\n return $(this).data(DATA_KEY) !== undefined;\n }).confirmation('hide');\n\n $('body').off(`${Event.SHOWN}.${self.uid}`);\n self.eventBody = false;\n });\n }\n });\n }\n }\n\n /**\n * Init the standard ok/cancel buttons\n * @param $tip\n * @private\n */\n _setStandardButtons($tip) {\n const self = this;\n\n const btnApply = $tip.find(Selector.BTN_APPLY)\n .addClass(this.config.btnOkClass)\n .html(this.config.btnOkLabel)\n .attr(this.config._attributes);\n\n if (this.config.btnOkIconClass || this.config.btnOkIconContent) {\n btnApply.prepend($('')\n .addClass(this.config.btnOkIconClass || '')\n .text(this.config.btnOkIconContent || ''));\n }\n\n btnApply.off('click')\n .one('click', function (e) {\n if ($(this).attr('href') === '#') {\n e.preventDefault();\n }\n\n self.config.onConfirm.call(self.element);\n $(self.element).trigger(Event.CONFIRMED);\n $(self.element).trigger(self.config.trigger, [true]);\n\n self.hide();\n });\n\n const btnDismiss = $tip.find(Selector.BTN_DISMISS)\n .addClass(this.config.btnCancelClass)\n .html(this.config.btnCancelLabel);\n\n if (this.config.btnCancelIconClass || this.config.btnCancelIconContent) {\n btnDismiss.prepend($('')\n .addClass(this.config.btnCancelIconClass || '')\n .text(this.config.btnCancelIconContent || ''));\n }\n\n btnDismiss.off('click')\n .one('click', (e) => {\n e.preventDefault();\n\n self.config.onCancel.call(self.element);\n $(self.element).trigger(Event.CANCELED);\n\n self.hide();\n });\n }\n\n /**\n * Init the custom buttons\n * @param $tip\n * @private\n */\n _setCustomButtons($tip) {\n const self = this;\n const $group = $tip.find(Selector.BUTTONS).empty();\n\n this.config.buttons.forEach((button) => {\n const btn = $('')\n .addClass(BTN_CLASS_DEFAULT)\n .addClass(button.class || 'btn btn-secondary')\n .html(button.label || '')\n .attr(button.attr || {});\n\n if (button.iconClass || button.iconContent) {\n btn.prepend($('')\n .addClass(button.iconClass || '')\n .text(button.iconContent || ''));\n }\n\n btn.one('click', function (e) {\n if ($(this).attr('href') === '#') {\n e.preventDefault();\n }\n\n if (button.onClick) {\n button.onClick.call($(self.element));\n }\n\n if (button.cancel) {\n self.config.onCancel.call(self.element, button.value);\n $(self.element).trigger(Event.CANCELED, [button.value]);\n }\n else {\n self.config.onConfirm.call(self.element, button.value);\n $(self.element).trigger(Event.CONFIRMED, [button.value]);\n }\n\n self.hide();\n });\n\n $group.append(btn);\n });\n }\n\n /**\n * Install the keyboatd event handler\n * @private\n */\n _setupKeyupEvent() {\n activeConfirmation = this;\n $(window)\n .off(Event.KEYUP)\n .on(Event.KEYUP, this._onKeyup.bind(this));\n }\n\n /**\n * Remove the keyboard event handler\n * @private\n */\n _cleanKeyupEvent() {\n if (activeConfirmation === this) {\n activeConfirmation = undefined;\n $(window).off(Event.KEYUP);\n }\n }\n\n /**\n * Event handler for keyboard navigation\n * @param event\n * @private\n */\n _onKeyup(event) {\n if (!this.tip) {\n this._cleanKeyupEvent();\n return;\n }\n\n const $tip = $(this.getTipElement());\n const key = event.key || Keymap[event.keyCode || event.which];\n\n const $group = $tip.find(Selector.BUTTONS);\n const $active = $group.find('.active');\n let $next;\n\n switch (key) {\n case 'Escape':\n this.hide();\n break;\n\n case 'ArrowRight':\n if ($active.length && $active.next().length) {\n $next = $active.next();\n }\n else {\n $next = $group.children().first();\n }\n $active.removeClass('active');\n $next.addClass('active').focus();\n break;\n\n case 'ArrowLeft':\n if ($active.length && $active.prev().length) {\n $next = $active.prev();\n }\n else {\n $next = $group.children().last();\n }\n $active.removeClass('active');\n $next.addClass('active').focus();\n break;\n\n default:\n break;\n }\n }\n\n // Static\n\n /**\n * Generates an uui, copied from Bootrap's utils\n * @param {string} prefix\n * @returns {string}\n */\n static getUID(prefix) {\n let uid = prefix;\n do {\n // eslint-disable-next-line no-bitwise\n uid += ~~(Math.random() * 1000000); // \"~~\" acts like a faster Math.floor() here\n } while (document.getElementById(uid));\n return uid;\n }\n\n static _jQueryInterface(config) {\n return this.each(function () {\n let data = $(this).data(DATA_KEY);\n\n const _config = typeof config === 'object' ? config : {};\n _config.rootSelector = $(this).selector || _config.rootSelector; // this.selector removed in jQuery > 3\n\n if (!data && /destroy|hide/.test(config)) {\n return;\n }\n\n if (!data) {\n data = new Confirmation(this, _config);\n $(this).data(DATA_KEY, data);\n }\n\n if (typeof config === 'string') {\n if (typeof data[config] === 'undefined') {\n throw new TypeError(`No method named \"${config}\"`);\n }\n data[config]();\n }\n });\n }\n}\n\n/**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n$.fn[NAME] = Confirmation._jQueryInterface;\n$.fn[NAME].Constructor = Confirmation;\n$.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT;\n return Confirmation._jQueryInterface;\n};\n\nexport default Confirmation;\n"],"names":["$","fn","popover","Constructor","VERSION","split","shift","Error","Popover","NAME","DATA_KEY","EVENT_KEY","JQUERY_NO_CONFLICT","BTN_CLASS_DEFAULT","DefaultType","singleton","popout","copyAttributes","onConfirm","onCancel","btnOkClass","btnOkLabel","btnOkIconClass","btnOkIconContent","btnCancelClass","btnCancelLabel","btnCancelIconClass","btnCancelIconContent","buttons","Default","_attributes","_selector","placement","title","trigger","content","noop","template","ClassName","FADE","SHOW","Selector","TITLE","CONTENT","BUTTONS","BTN_APPLY","BTN_DISMISS","Keymap","Event","HIDE","HIDDEN","SHOWN","INSERTED","CLICK","FOCUSIN","FOCUSOUT","MOUSEENTER","MOUSELEAVE","CONFIRMED","CANCELED","KEYUP","activeConfirmation","Confirmation","element","config","rootSelector","_isDelegate","selector","_copyAttributes","_setConfirmationListeners","isWithContent","setContent","$tip","getTipElement","_getContent","call","setElementContent","find","getTitle","toggle","length","_setCustomButtons","_setStandardButtons","removeClass","_setupKeyupEvent","dispose","_cleanKeyupEvent","hide","callback","forEach","attr","self","on","e","ack","preventDefault","stopPropagation","stopImmediatePropagation","not","filter","data","undefined","confirmation","eventBody","uid","id","getUID","is","target","off","btnApply","addClass","html","prepend","text","one","btnDismiss","$group","empty","button","btn","class","label","iconClass","iconContent","onClick","cancel","value","append","window","_onKeyup","bind","event","tip","key","keyCode","which","$active","$next","next","children","first","focus","prev","last","prefix","Math","random","document","getElementById","_jQueryInterface","each","_config","test","TypeError","noConflict"],"mappings":";;;;;;;;;;;;;;EAEA,SAAS,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE;EAC1C,EAAE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;EACzC,IAAI,IAAI,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;EAC9B,IAAI,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,KAAK,CAAC;EAC3D,IAAI,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC;EACnC,IAAI,IAAI,OAAO,IAAI,UAAU,EAAE,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC;EAC1D,IAAI,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;EAC9D,GAAG;EACH,CAAC;;EAED,SAAS,YAAY,CAAC,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE;EAC5D,EAAE,IAAI,UAAU,EAAE,iBAAiB,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;EACvE,EAAE,IAAI,WAAW,EAAE,iBAAiB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;EAC/D,EAAE,OAAO,WAAW,CAAC;EACrB,CAAC;;EAED,SAAS,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE;EAC1C,EAAE,IAAI,GAAG,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AAf,CAAoBzF,MAApB,CAAb,EAA0C;EACxC;EACD;;EAED,UAAI,CAACoC,IAAL,EAAW;EACTA,eAAO,IAAItC,YAAJ,CAAiB,IAAjB,EAAuB0F,OAAvB,CAAP;EACAxJ,UAAE,IAAF,EAAQoG,IAAR,CAAa1F,QAAb,EAAuB0F,IAAvB;EACD;;EAED,UAAI,OAAOpC,MAAP,KAAkB,QAAtB,EAAgC;EAC9B,YAAI,OAAOoC,KAAKpC,MAAL,CAAP,KAAwB,WAA5B,EAAyC;EACvC,gBAAM,IAAI0F,SAAJ,wBAAkC1F,MAAlC,QAAN;EACD;;EACDoC,aAAKpC,MAAL;EACD;EACF,KArBM,CAAP;EAsBD;;;IAhZwBxD;EAmZ3B;;;;;;;EAMAR,EAAEC,EAAF,CAAKQ,IAAL,IAAaqD,aAAawF,gBAA1B;EACAtJ,EAAEC,EAAF,CAAKQ,IAAL,EAAWN,WAAX,GAAyB2D,YAAzB;;EACA9D,EAAEC,EAAF,CAAKQ,IAAL,EAAWkJ,UAAX,GAAwB,YAAY;EAClC3J,IAAEC,EAAF,CAAKQ,IAAL,IAAaG,kBAAb;EACA,SAAOkD,aAAawF,gBAApB;EACD,CAHD;;;;"} \ No newline at end of file diff --git a/dist/bootstrap-confirmation.min.js b/dist/bootstrap-confirmation.min.js new file mode 100644 index 0000000..3138ea9 --- /dev/null +++ b/dist/bootstrap-confirmation.min.js @@ -0,0 +1,8 @@ +/*! + * Bootstrap Confirmation (v4.0.0) + * @copyright 2013 Nimit Suwannagate + * @copyright 2014-2018 Damien "Mistic" Sorel + * @licence Apache License, Version 2.0 + */ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("jquery"),require("bootstrap")):"function"==typeof define&&define.amd?define(["jquery","bootstrap"],e):e(t.jQuery)}(this,function(a){"use strict";function l(t,e){for(var n=0;n\n
\n

\n
\n

\n
\n
\n \n \n
\n
\n
\n'}),C="fade",y="show",m=".popover-header",v=".confirmation-content",E=".confirmation-buttons .btn-group",_="[data-apply=confirmation]",O="[data-dismiss=confirmation]",k={13:"Enter",27:"Escape",39:"ArrowRight",40:"ArrowDown"},I={HIDE:"hide"+h,HIDDEN:"hidden"+h,SHOW:"show"+h,SHOWN:"shown"+h,INSERTED:"inserted"+h,CLICK:"click"+h,FOCUSIN:"focusin"+h,FOCUSOUT:"focusout"+h,MOUSEENTER:"mouseenter"+h,MOUSELEAVE:"mouseleave"+h,CONFIRMED:"confirmed"+h,CANCELED:"canceled"+h,KEYUP:"keyup"+h},o=function(o){var t,e,n,i,r;function s(t,e){var n;if(((n=o.call(this,t,e)||this).config.popout||n.config.singleton)&&!n.config.rootSelector)throw new Error("The rootSelector option is required to use popout and singleton features since jQuery 3.");return n._isDelegate=!1,e.selector?(e._selector=e.rootSelector+" "+e.selector,n.config._selector=e._selector):e._selector?(n.config._selector=e._selector,n._isDelegate=!0):n.config._selector=e.rootSelector,n.config.selector||n._copyAttributes(),n._setConfirmationListeners(),n}e=o,(t=s).prototype=Object.create(e.prototype),(t.prototype.constructor=t).__proto__=e,n=s,r=[{key:"VERSION",get:function(){return"4.0.0"}},{key:"Default",get:function(){return b}},{key:"NAME",get:function(){return u}},{key:"DATA_KEY",get:function(){return p}},{key:"Event",get:function(){return I}},{key:"EVENT_KEY",get:function(){return h}},{key:"DefaultType",get:function(){return g}}],(i=null)&&l(n.prototype,i),r&&l(n,r);var c=s.prototype;return c.isWithContent=function(){return!0},c.setContent=function(){var t=a(this.getTipElement()),e=this._getContent();"function"==typeof e&&(e=e.call(this.element)),this.setElementContent(t.find(m),this.getTitle()),t.find(v).toggle(!!e),e&&this.setElementContent(t.find(v),e),0").addClass(this.config.btnOkIconClass||"").text(this.config.btnOkIconContent||"")),n.off("click").one("click",function(t){"#"===a(this).attr("href")&&t.preventDefault(),e.config.onConfirm.call(e.element),a(e.element).trigger(I.CONFIRMED),a(e.element).trigger(e.config.trigger,[!0]),e.hide()});var o=t.find(O).addClass(this.config.btnCancelClass).html(this.config.btnCancelLabel);(this.config.btnCancelIconClass||this.config.btnCancelIconContent)&&o.prepend(a("").addClass(this.config.btnCancelIconClass||"").text(this.config.btnCancelIconContent||"")),o.off("click").one("click",function(t){t.preventDefault(),e.config.onCancel.call(e.element),a(e.element).trigger(I.CANCELED),e.hide()})},c._setCustomButtons=function(t){var n=this,o=t.find(E).empty();this.config.buttons.forEach(function(e){var t=a('').addClass(d).addClass(e.class||"btn btn-secondary").html(e.label||"").attr(e.attr||{});(e.iconClass||e.iconContent)&&t.prepend(a("").addClass(e.iconClass||"").text(e.iconContent||"")),t.one("click",function(t){"#"===a(this).attr("href")&&t.preventDefault(),e.onClick&&e.onClick.call(a(n.element)),e.cancel?(n.config.onCancel.call(n.element,e.value),a(n.element).trigger(I.CANCELED,[e.value])):(n.config.onConfirm.call(n.element,e.value),a(n.element).trigger(I.CONFIRMED,[e.value])),n.hide()}),o.append(t)})},c._setupKeyupEvent=function(){f=this,a(window).off(I.KEYUP).on(I.KEYUP,this._onKeyup.bind(this))},c._cleanKeyupEvent=function(){f===this&&(f=void 0,a(window).off(I.KEYUP))},c._onKeyup=function(t){if(this.tip){var e,n=a(this.getTipElement()),o=t.key||k[t.keyCode||t.which],i=n.find(E),r=i.find(".active");switch(o){case"Escape":this.hide();break;case"ArrowRight":e=r.length&&r.next().length?r.next():i.children().first(),r.removeClass("active"),e.addClass("active").focus();break;case"ArrowLeft":e=r.length&&r.prev().length?r.prev():i.children().last(),r.removeClass("active"),e.addClass("active").focus()}}else this._cleanKeyupEvent()},s.getUID=function(t){for(var e=t;e+=~~(1e6*Math.random()),document.getElementById(e););return e},s._jQueryInterface=function(n){return this.each(function(){var t=a(this).data(p),e="object"==typeof n?n:{};if(e.rootSelector=a(this).selector||e.rootSelector,(t||!/destroy|hide/.test(n))&&(t||(t=new s(this,e),a(this).data(p,t)),"string"==typeof n)){if("undefined"==typeof t[n])throw new TypeError('No method named "'+n+'"');t[n]()}})},s}(e);a.fn[u]=o._jQueryInterface,a.fn[u].Constructor=o,a.fn[u].noConflict=function(){return a.fn[u]=n,o._jQueryInterface}}); +//# sourceMappingURL=bootstrap-confirmation.min.js.map \ No newline at end of file diff --git a/dist/bootstrap-confirmation.min.js.map b/dist/bootstrap-confirmation.min.js.map new file mode 100644 index 0000000..44945e6 --- /dev/null +++ b/dist/bootstrap-confirmation.min.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../rollupPluginBabelHelpers","../src/popover.js","../src/confirmation.js"],"names":["_defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","_objectSpread","arguments","source","ownKeys","keys","getOwnPropertySymbols","concat","filter","sym","getOwnPropertyDescriptor","forEach","obj","value","fn","popover","$","Constructor","VERSION","split","shift","Error","activeConfirmation","Popover","NAME","DATA_KEY","EVENT_KEY","JQUERY_NO_CONFLICT","BTN_CLASS_DEFAULT","DefaultType","singleton","popout","copyAttributes","onConfirm","onCancel","btnOkClass","btnOkLabel","btnOkIconClass","btnOkIconContent","btnCancelClass","btnCancelLabel","btnCancelIconClass","btnCancelIconContent","buttons","Default","_attributes","_selector","placement","title","trigger","content","noop","template","ClassName","Selector","Keymap","13","27","39","40","Event","HIDE","HIDDEN","SHOW","SHOWN","INSERTED","CLICK","FOCUSIN","FOCUSOUT","MOUSEENTER","MOUSELEAVE","CONFIRMED","CANCELED","KEYUP","Confirmation","subClass","superClass","protoProps","staticProps","element","config","_this","_Popover","call","this","rootSelector","_isDelegate","selector","_copyAttributes","_setConfirmationListeners","prototype","create","constructor","__proto__","isWithContent","setContent","$tip","getTipElement","_getContent","setElementContent","find","getTitle","toggle","_setCustomButtons","_setStandardButtons","removeClass","_setupKeyupEvent","dispose","_cleanKeyupEvent","hide","callback","_this2","attr","self","on","e","ack","preventDefault","stopPropagation","stopImmediatePropagation","not","undefined","data","confirmation","eventBody","uid","id","getUID","is","off","btnApply","addClass","html","prepend","text","one","btnDismiss","$group","empty","button","btn","class","label","iconClass","iconContent","onClick","cancel","append","window","_onKeyup","bind","event","tip","$next","keyCode","which","$active","next","children","first","focus","prev","last","prefix","Math","random","document","getElementById","_jQueryInterface","each","_config","test","TypeError","noConflict"],"mappings":";;;;;;gOAEA,SAASA,EAAkBC,EAAQC,GACjC,IAAK,IAAIC,EAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CACrC,IAAIE,EAAaH,EAAMC,GACvBE,EAAWC,WAAaD,EAAWC,aAAc,EACjDD,EAAWE,cAAe,EACtB,UAAWF,IAAYA,EAAWG,UAAW,GACjDC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAyBlD,SAASO,EAAcX,GACrB,IAAK,IAAIE,EAAI,EAAGA,EAAIU,UAAUT,OAAQD,IAAK,CACzC,IAAIW,EAAyB,MAAhBD,UAAUV,GAAaU,UAAUV,GAAK,GAC/CY,EAAUN,OAAOO,KAAKF,GAEkB,mBAAjCL,OAAOQ,wBAChBF,EAAUA,EAAQG,OAAOT,OAAOQ,sBAAsBH,GAAQK,OAAO,SAAUC,GAC7E,OAAOX,OAAOY,yBAAyBP,EAAQM,GAAKd,eAIxDS,EAAQO,QAAQ,SAAUX,GA1B9B,IAAyBY,EAAKZ,EAAKa,EAAVD,EA2BHtB,EA3BauB,EA2BAV,EA3BLH,EA2BAA,GA1BxBA,KAAOY,EACTd,OAAOC,eAAea,EAAKZ,EAAK,CAC9Ba,MAAOA,EACPlB,YAAY,EACZC,cAAc,EACdC,UAAU,IAGZe,EAAIZ,GAAOa,IAsBb,OAAOvB,EC9CT,GAA4B,kEAAfwB,GAAGC,SAAmF,MAAxDC,EAAEF,GAAGC,QAAQE,YAAYC,QAAQC,MAAM,KAAKC,QACrF,MAAM,IAAIC,MAAM,yDAGlB,IC+GIC,ED/GEC,EAAUP,EAAEF,GAAGC,QAAQE,YCEvBO,EAAO,eAEPC,EAAAA,MAAiBD,EACjBE,EAAAA,IAAgBD,EAChBE,EAAqBX,EAAEF,GAAGU,GAC1BI,EAAoB,6CAEpBC,EAAAA,EAAAA,GACDN,EAAQM,YADP,CAEJC,UA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I4F,UAAJ,oBAAkC5F,EAAlC,KAER0C,EAAK1C,YA7YczD,GAyZ3BP,EAAEF,GAAGU,GAAQkD,EAAa8F,iBAC1BxJ,EAAEF,GAAGU,GAAMP,YAAcyD,EACzB1D,EAAEF,GAAGU,GAAMqJ,WAAa,WAEtB,OADA7J,EAAEF,GAAGU,GAAQG,EACN+C,EAAa8F","sourcesContent":["export { _createClass as createClass, _defineProperty as defineProperty, _objectSpread as objectSpread, _inheritsLoose as inheritsLoose, _assertThisInitialized as assertThisInitialized };\n\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\n\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\n\nfunction _defineProperty(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n}\n\nfunction _objectSpread(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i] != null ? arguments[i] : {};\n var ownKeys = Object.keys(source);\n\n if (typeof Object.getOwnPropertySymbols === 'function') {\n ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {\n return Object.getOwnPropertyDescriptor(source, sym).enumerable;\n }));\n }\n\n ownKeys.forEach(function (key) {\n _defineProperty(target, key, source[key]);\n });\n }\n\n return target;\n}\n\nfunction _inheritsLoose(subClass, superClass) {\n subClass.prototype = Object.create(superClass.prototype);\n subClass.prototype.constructor = subClass;\n subClass.__proto__ = superClass;\n}\n\nfunction _assertThisInitialized(self) {\n if (self === void 0) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return self;\n}","import $ from 'jquery';\nimport 'bootstrap';\n\nif (typeof $.fn.popover === 'undefined' || $.fn.popover.Constructor.VERSION.split('.').shift() !== '4') {\n throw new Error('Bootstrap Confirmation 4 requires Bootstrap Popover 4');\n}\n\nconst Popover = $.fn.popover.Constructor;\n\nexport default Popover;\n","import $ from 'jquery';\nimport Popover from 'bootstrap/js/src/popover';\n\n/**\n * ------------------------------------------------------------------------\n * Constants\n * ------------------------------------------------------------------------\n */\n\nconst NAME = 'confirmation';\nconst VERSION = '4.0.0';\nconst DATA_KEY = `bs.${NAME}`;\nconst EVENT_KEY = `.${DATA_KEY}`;\nconst JQUERY_NO_CONFLICT = $.fn[NAME];\nconst BTN_CLASS_DEFAULT = 'btn btn-sm h-100 d-flex align-items-center';\n\nconst DefaultType = {\n ...Popover.DefaultType,\n singleton : 'boolean',\n popout : 'boolean',\n copyAttributes : '(string|array)',\n onConfirm : 'function',\n onCancel : 'function',\n btnOkClass : 'string',\n btnOkLabel : 'string',\n btnOkIconClass : 'string',\n btnOkIconContent : 'string',\n btnCancelClass : 'string',\n btnCancelLabel : 'string',\n btnCancelIconClass : 'string',\n btnCancelIconContent: 'string',\n buttons : 'array',\n};\n\nconst Default = {\n ...Popover.Default,\n _attributes : {},\n _selector : null,\n placement : 'top',\n title : 'Are you sure?',\n trigger : 'click',\n content : '',\n singleton : false,\n popout : false,\n copyAttributes : 'href target',\n onConfirm : $.noop,\n onCancel : $.noop,\n btnOkClass : 'btn-primary',\n btnOkLabel : 'Yes',\n btnOkIconClass : '',\n btnOkIconContent : '',\n btnCancelClass : 'btn-secondary',\n btnCancelLabel : 'No',\n btnCancelIconClass : '',\n btnCancelIconContent: '',\n buttons : [],\n // @formatter:off\n // href=\"#\" allows the buttons to be focused\n template : `\n
\n
\n

\n
\n

\n
\n
\n \n \n
\n
\n
\n
`,\n // @formatter:on\n};\n\nconst ClassName = {\n FADE: 'fade',\n SHOW: 'show',\n};\n\nconst Selector = {\n TITLE : '.popover-header',\n CONTENT : '.confirmation-content',\n BUTTONS : '.confirmation-buttons .btn-group',\n BTN_APPLY : '[data-apply=confirmation]',\n BTN_DISMISS: '[data-dismiss=confirmation]',\n};\n\nconst Keymap = {\n 13: 'Enter',\n 27: 'Escape',\n 39: 'ArrowRight',\n 40: 'ArrowDown',\n};\n\nconst Event = {\n HIDE : `hide${EVENT_KEY}`,\n HIDDEN : `hidden${EVENT_KEY}`,\n SHOW : `show${EVENT_KEY}`,\n SHOWN : `shown${EVENT_KEY}`,\n INSERTED : `inserted${EVENT_KEY}`,\n CLICK : `click${EVENT_KEY}`,\n FOCUSIN : `focusin${EVENT_KEY}`,\n FOCUSOUT : `focusout${EVENT_KEY}`,\n MOUSEENTER: `mouseenter${EVENT_KEY}`,\n MOUSELEAVE: `mouseleave${EVENT_KEY}`,\n CONFIRMED : `confirmed${EVENT_KEY}`,\n CANCELED : `canceled${EVENT_KEY}`,\n KEYUP : `keyup${EVENT_KEY}`,\n};\n\n/**\n * ------------------------------------------------------------------------\n * Class Definition\n * ------------------------------------------------------------------------\n */\n\n// keep track of the last openned confirmation for keyboard navigation\nlet activeConfirmation;\n\nclass Confirmation extends Popover {\n // Getters\n\n static get VERSION() {\n return VERSION;\n }\n\n static get Default() {\n return Default;\n }\n\n static get NAME() {\n return NAME;\n }\n\n static get DATA_KEY() {\n return DATA_KEY;\n }\n\n static get Event() {\n return Event;\n }\n\n static get EVENT_KEY() {\n return EVENT_KEY;\n }\n\n static get DefaultType() {\n return DefaultType;\n }\n\n // Constructor\n\n constructor(element, config) {\n super(element, config);\n\n if ((this.config.popout || this.config.singleton) && !this.config.rootSelector) {\n throw new Error('The rootSelector option is required to use popout and singleton features since jQuery 3.');\n }\n\n // keep trace of selectors\n this._isDelegate = false;\n\n if (config.selector) { // container of buttons\n config._selector = `${config.rootSelector} ${config.selector}`;\n this.config._selector = config._selector;\n }\n else if (config._selector) { // children of container\n this.config._selector = config._selector;\n this._isDelegate = true;\n }\n else { // standalone\n this.config._selector = config.rootSelector;\n }\n\n if (!this.config.selector) {\n this._copyAttributes();\n }\n\n this._setConfirmationListeners();\n }\n\n // Overrides\n\n isWithContent() {\n return true;\n }\n\n setContent() {\n const $tip = $(this.getTipElement());\n let content = this._getContent();\n\n if (typeof content === 'function') {\n content = content.call(this.element);\n }\n\n this.setElementContent($tip.find(Selector.TITLE), this.getTitle());\n\n $tip.find(Selector.CONTENT).toggle(!!content);\n if (content) {\n this.setElementContent($tip.find(Selector.CONTENT), content);\n }\n\n if (this.config.buttons.length > 0) {\n this._setCustomButtons($tip);\n }\n else {\n this._setStandardButtons($tip);\n }\n\n $tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`);\n\n this._setupKeyupEvent();\n }\n\n dispose() {\n this._cleanKeyupEvent();\n super.dispose();\n }\n\n hide(callback) {\n this._cleanKeyupEvent();\n super.hide(callback);\n }\n\n // Private\n\n /**\n * Copy the value of `copyAttributes` on the config object\n * @private\n */\n _copyAttributes() {\n this.config._attributes = {};\n if (this.config.copyAttributes) {\n if (typeof this.config.copyAttributes === 'string') {\n this.config.copyAttributes = this.config.copyAttributes.split(' ');\n }\n }\n else {\n this.config.copyAttributes = [];\n }\n\n this.config.copyAttributes.forEach((attr) => {\n this.config._attributes[attr] = $(this.element).attr(attr);\n });\n }\n\n /**\n * Custom event listeners for popouts and singletons\n * @private\n */\n _setConfirmationListeners() {\n const self = this;\n\n if (!this.config.selector) {\n // cancel original event\n $(this.element).on(this.config.trigger, (e, ack) => {\n if (!ack) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n }\n });\n\n // manage singleton\n $(this.element).on(Event.SHOWN, function () {\n if (self.config.singleton) {\n // close all other popover already initialized\n $(self.config._selector).not($(this)).filter(function () {\n return $(this).data(DATA_KEY) !== undefined;\n }).confirmation('hide');\n }\n });\n }\n else {\n // cancel original event\n $(this.element).on(this.config.trigger, this.config.selector, (e, ack) => {\n if (!ack) {\n e.preventDefault();\n e.stopPropagation();\n e.stopImmediatePropagation();\n }\n });\n }\n\n if (!this._isDelegate) {\n // manage popout\n this.eventBody = false;\n this.uid = this.element.id || Confirmation.getUID(`${NAME}_group`);\n\n $(this.element).on(Event.SHOWN, () => {\n if (self.config.popout && !self.eventBody) {\n self.eventBody = $('body').on(`${Event.CLICK}.${self.uid}`, (e) => {\n if ($(self.config._selector).is(e.target)) {\n return;\n }\n // close all popover already initialized\n $(self.config._selector).filter(function () {\n return $(this).data(DATA_KEY) !== undefined;\n }).confirmation('hide');\n\n $('body').off(`${Event.SHOWN}.${self.uid}`);\n self.eventBody = false;\n });\n }\n });\n }\n }\n\n /**\n * Init the standard ok/cancel buttons\n * @param $tip\n * @private\n */\n _setStandardButtons($tip) {\n const self = this;\n\n const btnApply = $tip.find(Selector.BTN_APPLY)\n .addClass(this.config.btnOkClass)\n .html(this.config.btnOkLabel)\n .attr(this.config._attributes);\n\n if (this.config.btnOkIconClass || this.config.btnOkIconContent) {\n btnApply.prepend($('')\n .addClass(this.config.btnOkIconClass || '')\n .text(this.config.btnOkIconContent || ''));\n }\n\n btnApply.off('click')\n .one('click', function (e) {\n if ($(this).attr('href') === '#') {\n e.preventDefault();\n }\n\n self.config.onConfirm.call(self.element);\n $(self.element).trigger(Event.CONFIRMED);\n $(self.element).trigger(self.config.trigger, [true]);\n\n self.hide();\n });\n\n const btnDismiss = $tip.find(Selector.BTN_DISMISS)\n .addClass(this.config.btnCancelClass)\n .html(this.config.btnCancelLabel);\n\n if (this.config.btnCancelIconClass || this.config.btnCancelIconContent) {\n btnDismiss.prepend($('')\n .addClass(this.config.btnCancelIconClass || '')\n .text(this.config.btnCancelIconContent || ''));\n }\n\n btnDismiss.off('click')\n .one('click', (e) => {\n e.preventDefault();\n\n self.config.onCancel.call(self.element);\n $(self.element).trigger(Event.CANCELED);\n\n self.hide();\n });\n }\n\n /**\n * Init the custom buttons\n * @param $tip\n * @private\n */\n _setCustomButtons($tip) {\n const self = this;\n const $group = $tip.find(Selector.BUTTONS).empty();\n\n this.config.buttons.forEach((button) => {\n const btn = $('')\n .addClass(BTN_CLASS_DEFAULT)\n .addClass(button.class || 'btn btn-secondary')\n .html(button.label || '')\n .attr(button.attr || {});\n\n if (button.iconClass || button.iconContent) {\n btn.prepend($('')\n .addClass(button.iconClass || '')\n .text(button.iconContent || ''));\n }\n\n btn.one('click', function (e) {\n if ($(this).attr('href') === '#') {\n e.preventDefault();\n }\n\n if (button.onClick) {\n button.onClick.call($(self.element));\n }\n\n if (button.cancel) {\n self.config.onCancel.call(self.element, button.value);\n $(self.element).trigger(Event.CANCELED, [button.value]);\n }\n else {\n self.config.onConfirm.call(self.element, button.value);\n $(self.element).trigger(Event.CONFIRMED, [button.value]);\n }\n\n self.hide();\n });\n\n $group.append(btn);\n });\n }\n\n /**\n * Install the keyboatd event handler\n * @private\n */\n _setupKeyupEvent() {\n activeConfirmation = this;\n $(window)\n .off(Event.KEYUP)\n .on(Event.KEYUP, this._onKeyup.bind(this));\n }\n\n /**\n * Remove the keyboard event handler\n * @private\n */\n _cleanKeyupEvent() {\n if (activeConfirmation === this) {\n activeConfirmation = undefined;\n $(window).off(Event.KEYUP);\n }\n }\n\n /**\n * Event handler for keyboard navigation\n * @param event\n * @private\n */\n _onKeyup(event) {\n if (!this.tip) {\n this._cleanKeyupEvent();\n return;\n }\n\n const $tip = $(this.getTipElement());\n const key = event.key || Keymap[event.keyCode || event.which];\n\n const $group = $tip.find(Selector.BUTTONS);\n const $active = $group.find('.active');\n let $next;\n\n switch (key) {\n case 'Escape':\n this.hide();\n break;\n\n case 'ArrowRight':\n if ($active.length && $active.next().length) {\n $next = $active.next();\n }\n else {\n $next = $group.children().first();\n }\n $active.removeClass('active');\n $next.addClass('active').focus();\n break;\n\n case 'ArrowLeft':\n if ($active.length && $active.prev().length) {\n $next = $active.prev();\n }\n else {\n $next = $group.children().last();\n }\n $active.removeClass('active');\n $next.addClass('active').focus();\n break;\n\n default:\n break;\n }\n }\n\n // Static\n\n /**\n * Generates an uui, copied from Bootrap's utils\n * @param {string} prefix\n * @returns {string}\n */\n static getUID(prefix) {\n let uid = prefix;\n do {\n // eslint-disable-next-line no-bitwise\n uid += ~~(Math.random() * 1000000); // \"~~\" acts like a faster Math.floor() here\n } while (document.getElementById(uid));\n return uid;\n }\n\n static _jQueryInterface(config) {\n return this.each(function () {\n let data = $(this).data(DATA_KEY);\n\n const _config = typeof config === 'object' ? config : {};\n _config.rootSelector = $(this).selector || _config.rootSelector; // this.selector removed in jQuery > 3\n\n if (!data && /destroy|hide/.test(config)) {\n return;\n }\n\n if (!data) {\n data = new Confirmation(this, _config);\n $(this).data(DATA_KEY, data);\n }\n\n if (typeof config === 'string') {\n if (typeof data[config] === 'undefined') {\n throw new TypeError(`No method named \"${config}\"`);\n }\n data[config]();\n }\n });\n }\n}\n\n/**\n * ------------------------------------------------------------------------\n * jQuery\n * ------------------------------------------------------------------------\n */\n\n$.fn[NAME] = Confirmation._jQueryInterface;\n$.fn[NAME].Constructor = Confirmation;\n$.fn[NAME].noConflict = function () {\n $.fn[NAME] = JQUERY_NO_CONFLICT;\n return Confirmation._jQueryInterface;\n};\n\nexport default Confirmation;\n"]} \ No newline at end of file diff --git a/example/index.html b/example/index.html index dd9dcd9..ba1f7fb 100644 --- a/example/index.html +++ b/example/index.html @@ -6,101 +6,111 @@ Bootstrap Confirmation - + + + +
-
+
-
-
Basic
-
- +
+
Basic
+
+
-
-
Link
-
- Go to Google +
+
Link
+
-
-
Customize
-
-
-
-
Directions
-
- - - + + - +
-
-
Singleton
-
- -
-
-
Popout
-
- - +
+
Popout
+
+ +
-
-
Delegation
-
- - +
+
Delegation
+
+ +
-
-
Custom buttons
-
- - +
+
Custom buttons
+
+ +
- - - + + + + + - - diff --git a/package.json b/package.json index 8503de4..2b70310 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-confirmation2", - "version": "2.4.1", + "version": "4.0.0", "homepage": "http://bootstrap-confirmation.js.org", "description": "Bootstrap plugin for on-place confirm boxes using Popover", "license": "Apache-2.0", @@ -15,24 +15,39 @@ "homepage": "http://www.strangeplanet.fr" } ], - "main": "bootstrap-confirmation.js", + "main": "dist/bootstrap-confirmation.js", + "files": [ + "dist/", + "src/confirmation.js" + ], "keywords": [ "bootstrap", "confirmation", "popup" ], "peerDependencies": { - "bootstrap": ">=3.2.0 <4" + "bootstrap": ">=4.0.0", + "jquery": "1.9.1 - 3", + "popper.js": "^1.12.9" }, "devDependencies": { - "grunt": "^1.0.0", - "grunt-contrib-connect": "^1.0.0", - "grunt-contrib-jshint": "^1.0.0", - "grunt-contrib-uglify": "^1.0.0", - "grunt-contrib-watch": "^1.0.0", - "grunt-open": "^0.2.3", - "grunt-replace": "^1.0.1", - "jit-grunt": "^0.10.0" + "@babel/core": "7.0.0-beta.42", + "@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.42", + "@babel/preset-env": "7.0.0-beta.42", + "babel-eslint": "^8.2.2", + "bootstrap": ">=4.0.0", + "eslint": "^4.19.1", + "eslint-config-airbnb-base": "^12.1.0", + "eslint-plugin-import": "^2.10.0", + "jquery": "1.9.1 - 3", + "live-server": "^1.2.0", + "nodemon": "^1.17.3", + "npm-run-all": "^4.1.2", + "popper.js": "^1.12.9", + "rollup": "^0.57.1", + "rollup-plugin-babel": "4.0.0-beta.2", + "rollup-plugin-replace": "^2.0.0", + "uglify-js": "^3.3.17" }, "repository": { "type": "git", @@ -42,6 +57,13 @@ "url": "https://github.com/mistic100/Bootstrap-Confirmation/issues" }, "scripts": { - "test": "grunt test" + "compile": "rollup --config rollup.config.js --file dist/bootstrap-confirmation.js src/confirmation.js", + "dist": "npm run compile && npm run minify", + "lint": "eslint src", + "minify": "uglifyjs --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/bootstrap-confirmation.js.map,includeSources,url=bootstrap-confirmation.min.js.map\" --output dist/bootstrap-confirmation.min.js dist/bootstrap-confirmation.js", + "server": "live-server --watch=dist,example --open=example", + "start": "npm run compile && npm-run-all --parallel watch server", + "test": "npm run lint", + "watch": "nodemon --watch src --ext js --exec \"npm run compile\"" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..8f7e12c --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,45 @@ +import babel from 'rollup-plugin-babel'; +import replace from 'rollup-plugin-replace'; + +const pkg = require('./package.json'); + +export default { + output : { + format : 'umd', + name : 'bootstrap-confirmation', + sourcemap: true, + exports : 'none', + globals : { + 'jquery': 'jQuery' + }, + banner: `/*! + * Bootstrap Confirmation (v${pkg.version}) + * @copyright 2013 Nimit Suwannagate + * @copyright 2014-2018 Damien "Mistic" Sorel + * @licence Apache License, Version 2.0 + */` + }, + external: [ + 'jquery', + 'bootstrap' + ], + plugins : [ + replace({ + delimiters: ['', ''], + + 'import Popover from \'bootstrap/js/src/popover\';': 'import Popover from \'./popover\';', + 'export default Confirmation;' : '' + }), + babel({ + exclude : 'node_modules/**', // Only transpile our source code + externalHelpersWhitelist: [ // Include only required helpers + 'assertThisInitialized', + 'defineProperties', + 'createClass', + 'inheritsLoose', + 'defineProperty', + 'objectSpread' + ] + }) + ] +}; diff --git a/src/confirmation.js b/src/confirmation.js new file mode 100644 index 0000000..bc698f9 --- /dev/null +++ b/src/confirmation.js @@ -0,0 +1,537 @@ +import $ from 'jquery'; +import Popover from 'bootstrap/js/src/popover'; + +/** + * ------------------------------------------------------------------------ + * Constants + * ------------------------------------------------------------------------ + */ + +const NAME = 'confirmation'; +const VERSION = '4.0.0'; +const DATA_KEY = `bs.${NAME}`; +const EVENT_KEY = `.${DATA_KEY}`; +const JQUERY_NO_CONFLICT = $.fn[NAME]; +const BTN_CLASS_DEFAULT = 'btn btn-sm h-100 d-flex align-items-center'; + +const DefaultType = { + ...Popover.DefaultType, + singleton : 'boolean', + popout : 'boolean', + copyAttributes : '(string|array)', + onConfirm : 'function', + onCancel : 'function', + btnOkClass : 'string', + btnOkLabel : 'string', + btnOkIconClass : 'string', + btnOkIconContent : 'string', + btnCancelClass : 'string', + btnCancelLabel : 'string', + btnCancelIconClass : 'string', + btnCancelIconContent: 'string', + buttons : 'array', +}; + +const Default = { + ...Popover.Default, + _attributes : {}, + _selector : null, + placement : 'top', + title : 'Are you sure?', + trigger : 'click', + content : '', + singleton : false, + popout : false, + copyAttributes : 'href target', + onConfirm : $.noop, + onCancel : $.noop, + btnOkClass : 'btn-primary', + btnOkLabel : 'Yes', + btnOkIconClass : '', + btnOkIconContent : '', + btnCancelClass : 'btn-secondary', + btnCancelLabel : 'No', + btnCancelIconClass : '', + btnCancelIconContent: '', + buttons : [], + // @formatter:off + // href="#" allows the buttons to be focused + template : ` +
+
+

+
+

+
+
+ + +
+
+
+
`, + // @formatter:on +}; + +const ClassName = { + FADE: 'fade', + SHOW: 'show', +}; + +const Selector = { + TITLE : '.popover-header', + CONTENT : '.confirmation-content', + BUTTONS : '.confirmation-buttons .btn-group', + BTN_APPLY : '[data-apply=confirmation]', + BTN_DISMISS: '[data-dismiss=confirmation]', +}; + +const Keymap = { + 13: 'Enter', + 27: 'Escape', + 39: 'ArrowRight', + 40: 'ArrowDown', +}; + +const Event = { + HIDE : `hide${EVENT_KEY}`, + HIDDEN : `hidden${EVENT_KEY}`, + SHOW : `show${EVENT_KEY}`, + SHOWN : `shown${EVENT_KEY}`, + INSERTED : `inserted${EVENT_KEY}`, + CLICK : `click${EVENT_KEY}`, + FOCUSIN : `focusin${EVENT_KEY}`, + FOCUSOUT : `focusout${EVENT_KEY}`, + MOUSEENTER: `mouseenter${EVENT_KEY}`, + MOUSELEAVE: `mouseleave${EVENT_KEY}`, + CONFIRMED : `confirmed${EVENT_KEY}`, + CANCELED : `canceled${EVENT_KEY}`, + KEYUP : `keyup${EVENT_KEY}`, +}; + +/** + * ------------------------------------------------------------------------ + * Class Definition + * ------------------------------------------------------------------------ + */ + +// keep track of the last openned confirmation for keyboard navigation +let activeConfirmation; + +class Confirmation extends Popover { + // Getters + + static get VERSION() { + return VERSION; + } + + static get Default() { + return Default; + } + + static get NAME() { + return NAME; + } + + static get DATA_KEY() { + return DATA_KEY; + } + + static get Event() { + return Event; + } + + static get EVENT_KEY() { + return EVENT_KEY; + } + + static get DefaultType() { + return DefaultType; + } + + // Constructor + + constructor(element, config) { + super(element, config); + + if ((this.config.popout || this.config.singleton) && !this.config.rootSelector) { + throw new Error('The rootSelector option is required to use popout and singleton features since jQuery 3.'); + } + + // keep trace of selectors + this._isDelegate = false; + + if (config.selector) { // container of buttons + config._selector = `${config.rootSelector} ${config.selector}`; + this.config._selector = config._selector; + } + else if (config._selector) { // children of container + this.config._selector = config._selector; + this._isDelegate = true; + } + else { // standalone + this.config._selector = config.rootSelector; + } + + if (!this.config.selector) { + this._copyAttributes(); + } + + this._setConfirmationListeners(); + } + + // Overrides + + isWithContent() { + return true; + } + + setContent() { + const $tip = $(this.getTipElement()); + let content = this._getContent(); + + if (typeof content === 'function') { + content = content.call(this.element); + } + + this.setElementContent($tip.find(Selector.TITLE), this.getTitle()); + + $tip.find(Selector.CONTENT).toggle(!!content); + if (content) { + this.setElementContent($tip.find(Selector.CONTENT), content); + } + + if (this.config.buttons.length > 0) { + this._setCustomButtons($tip); + } + else { + this._setStandardButtons($tip); + } + + $tip.removeClass(`${ClassName.FADE} ${ClassName.SHOW}`); + + this._setupKeyupEvent(); + } + + dispose() { + this._cleanKeyupEvent(); + super.dispose(); + } + + hide(callback) { + this._cleanKeyupEvent(); + super.hide(callback); + } + + // Private + + /** + * Copy the value of `copyAttributes` on the config object + * @private + */ + _copyAttributes() { + this.config._attributes = {}; + if (this.config.copyAttributes) { + if (typeof this.config.copyAttributes === 'string') { + this.config.copyAttributes = this.config.copyAttributes.split(' '); + } + } + else { + this.config.copyAttributes = []; + } + + this.config.copyAttributes.forEach((attr) => { + this.config._attributes[attr] = $(this.element).attr(attr); + }); + } + + /** + * Custom event listeners for popouts and singletons + * @private + */ + _setConfirmationListeners() { + const self = this; + + if (!this.config.selector) { + // cancel original event + $(this.element).on(this.config.trigger, (e, ack) => { + if (!ack) { + e.preventDefault(); + e.stopPropagation(); + e.stopImmediatePropagation(); + } + }); + + // manage singleton + $(this.element).on(Event.SHOWN, function () { + if (self.config.singleton) { + // close all other popover already initialized + $(self.config._selector).not($(this)).filter(function () { + return $(this).data(DATA_KEY) !== undefined; + }).confirmation('hide'); + } + }); + } + else { + // cancel original event + $(this.element).on(this.config.trigger, this.config.selector, (e, ack) => { + if (!ack) { + e.preventDefault(); + e.stopPropagation(); + e.stopImmediatePropagation(); + } + }); + } + + if (!this._isDelegate) { + // manage popout + this.eventBody = false; + this.uid = this.element.id || Confirmation.getUID(`${NAME}_group`); + + $(this.element).on(Event.SHOWN, () => { + if (self.config.popout && !self.eventBody) { + self.eventBody = $('body').on(`${Event.CLICK}.${self.uid}`, (e) => { + if ($(self.config._selector).is(e.target)) { + return; + } + // close all popover already initialized + $(self.config._selector).filter(function () { + return $(this).data(DATA_KEY) !== undefined; + }).confirmation('hide'); + + $('body').off(`${Event.SHOWN}.${self.uid}`); + self.eventBody = false; + }); + } + }); + } + } + + /** + * Init the standard ok/cancel buttons + * @param $tip + * @private + */ + _setStandardButtons($tip) { + const self = this; + + const btnApply = $tip.find(Selector.BTN_APPLY) + .addClass(this.config.btnOkClass) + .html(this.config.btnOkLabel) + .attr(this.config._attributes); + + if (this.config.btnOkIconClass || this.config.btnOkIconContent) { + btnApply.prepend($('') + .addClass(this.config.btnOkIconClass || '') + .text(this.config.btnOkIconContent || '')); + } + + btnApply.off('click') + .one('click', function (e) { + if ($(this).attr('href') === '#') { + e.preventDefault(); + } + + self.config.onConfirm.call(self.element); + $(self.element).trigger(Event.CONFIRMED); + $(self.element).trigger(self.config.trigger, [true]); + + self.hide(); + }); + + const btnDismiss = $tip.find(Selector.BTN_DISMISS) + .addClass(this.config.btnCancelClass) + .html(this.config.btnCancelLabel); + + if (this.config.btnCancelIconClass || this.config.btnCancelIconContent) { + btnDismiss.prepend($('') + .addClass(this.config.btnCancelIconClass || '') + .text(this.config.btnCancelIconContent || '')); + } + + btnDismiss.off('click') + .one('click', (e) => { + e.preventDefault(); + + self.config.onCancel.call(self.element); + $(self.element).trigger(Event.CANCELED); + + self.hide(); + }); + } + + /** + * Init the custom buttons + * @param $tip + * @private + */ + _setCustomButtons($tip) { + const self = this; + const $group = $tip.find(Selector.BUTTONS).empty(); + + this.config.buttons.forEach((button) => { + const btn = $('') + .addClass(BTN_CLASS_DEFAULT) + .addClass(button.class || 'btn btn-secondary') + .html(button.label || '') + .attr(button.attr || {}); + + if (button.iconClass || button.iconContent) { + btn.prepend($('') + .addClass(button.iconClass || '') + .text(button.iconContent || '')); + } + + btn.one('click', function (e) { + if ($(this).attr('href') === '#') { + e.preventDefault(); + } + + if (button.onClick) { + button.onClick.call($(self.element)); + } + + if (button.cancel) { + self.config.onCancel.call(self.element, button.value); + $(self.element).trigger(Event.CANCELED, [button.value]); + } + else { + self.config.onConfirm.call(self.element, button.value); + $(self.element).trigger(Event.CONFIRMED, [button.value]); + } + + self.hide(); + }); + + $group.append(btn); + }); + } + + /** + * Install the keyboatd event handler + * @private + */ + _setupKeyupEvent() { + activeConfirmation = this; + $(window) + .off(Event.KEYUP) + .on(Event.KEYUP, this._onKeyup.bind(this)); + } + + /** + * Remove the keyboard event handler + * @private + */ + _cleanKeyupEvent() { + if (activeConfirmation === this) { + activeConfirmation = undefined; + $(window).off(Event.KEYUP); + } + } + + /** + * Event handler for keyboard navigation + * @param event + * @private + */ + _onKeyup(event) { + if (!this.tip) { + this._cleanKeyupEvent(); + return; + } + + const $tip = $(this.getTipElement()); + const key = event.key || Keymap[event.keyCode || event.which]; + + const $group = $tip.find(Selector.BUTTONS); + const $active = $group.find('.active'); + let $next; + + switch (key) { + case 'Escape': + this.hide(); + break; + + case 'ArrowRight': + if ($active.length && $active.next().length) { + $next = $active.next(); + } + else { + $next = $group.children().first(); + } + $active.removeClass('active'); + $next.addClass('active').focus(); + break; + + case 'ArrowLeft': + if ($active.length && $active.prev().length) { + $next = $active.prev(); + } + else { + $next = $group.children().last(); + } + $active.removeClass('active'); + $next.addClass('active').focus(); + break; + + default: + break; + } + } + + // Static + + /** + * Generates an uui, copied from Bootrap's utils + * @param {string} prefix + * @returns {string} + */ + static getUID(prefix) { + let uid = prefix; + do { + // eslint-disable-next-line no-bitwise + uid += ~~(Math.random() * 1000000); // "~~" acts like a faster Math.floor() here + } while (document.getElementById(uid)); + return uid; + } + + static _jQueryInterface(config) { + return this.each(function () { + let data = $(this).data(DATA_KEY); + + const _config = typeof config === 'object' ? config : {}; + _config.rootSelector = $(this).selector || _config.rootSelector; // this.selector removed in jQuery > 3 + + if (!data && /destroy|hide/.test(config)) { + return; + } + + if (!data) { + data = new Confirmation(this, _config); + $(this).data(DATA_KEY, data); + } + + if (typeof config === 'string') { + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`); + } + data[config](); + } + }); + } +} + +/** + * ------------------------------------------------------------------------ + * jQuery + * ------------------------------------------------------------------------ + */ + +$.fn[NAME] = Confirmation._jQueryInterface; +$.fn[NAME].Constructor = Confirmation; +$.fn[NAME].noConflict = function () { + $.fn[NAME] = JQUERY_NO_CONFLICT; + return Confirmation._jQueryInterface; +}; + +export default Confirmation; diff --git a/src/popover.js b/src/popover.js new file mode 100644 index 0000000..b78eefb --- /dev/null +++ b/src/popover.js @@ -0,0 +1,10 @@ +import $ from 'jquery'; +import 'bootstrap'; + +if (typeof $.fn.popover === 'undefined' || $.fn.popover.Constructor.VERSION.split('.').shift() !== '4') { + throw new Error('Bootstrap Confirmation 4 requires Bootstrap Popover 4'); +} + +const Popover = $.fn.popover.Constructor; + +export default Popover;