Skip to content

Commit

Permalink
Merge pull request #579 from jasny/Offcanvas_data_attributes_on_canva…
Browse files Browse the repository at this point in the history
…s_element

Allow options on canvas element
  • Loading branch information
jasny committed Jun 12, 2018
2 parents 38ac65d + 4633a61 commit 0bf8df4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions docs/javascript.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ <h3>Via JavaScript</h3>
{% endhighlight %}

<h3>Options</h3>

<p>Options can be placed both on control and on target menu element.</p>

<table class="table table-bordered table-striped">
<thead>
<tr>
Expand Down
6 changes: 3 additions & 3 deletions js/offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,7 +49,7 @@
this.options.disableScrolling = this.options.disablescrolling
delete this.options.disablescrolling
}

if (this.options.toggle) this.toggle()
}

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0bf8df4

Please sign in to comment.