From 4633a6188e0e7751b11a0bfb238dba45be33837b Mon Sep 17 00:00:00 2001 From: Sergey Boltonosov Date: Fri, 8 Jun 2018 22:45:42 +0400 Subject: [PATCH] Allow options on canvas element --- docs/javascript.html | 3 +++ js/offcanvas.js | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/docs/javascript.html b/docs/javascript.html index 2d99d19b8..f6499f2f7 100644 --- a/docs/javascript.html +++ b/docs/javascript.html @@ -140,6 +140,9 @@

Via JavaScript

{% endhighlight %}

Options

+ +

Options can be placed both on control and on target menu element.

+ diff --git a/js/offcanvas.js b/js/offcanvas.js index 49b9c5854..d85096c80 100644 --- a/js/offcanvas.js +++ b/js/offcanvas.js @@ -37,7 +37,7 @@ if (this.options.autohide && !this.options.modal) { var eventName = (navigator.userAgent.match(/(iPad|iPhone)/i) === null) ? 'click' : 'touchstart' $(document).on('click touchstart', $.proxy(this.autohide, this)) - } + } // Backdrop is added to dropdown on it's open, if device is touchable (or desctop FF, https://github.com/twbs/bootstrap/issues/13748) // and dropdown is not inside .navbar-nav. So we remove it @@ -49,7 +49,7 @@ this.options.disableScrolling = this.options.disablescrolling delete this.options.disablescrolling } - + if (this.options.toggle) this.toggle() } @@ -421,7 +421,7 @@ || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 var $canvas = $(target) var data = $canvas.data('bs.offcanvas') - var option = data ? 'toggle' : $this.data() + var option = data ? 'toggle' : $.extend($this.data(), $canvas.data()) e.preventDefault(); e.stopPropagation()