1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-26 21:39:08 +02:00

Allow viewport option to be a function

Closes #16151 by merging a rebased version of it that adds docs and 1 more assertion.
This commit is contained in:
Adrien Siami
2015-03-25 14:46:21 +01:00
committed by Chris Rebert
parent 48232aad6c
commit e949505b89
4 changed files with 36 additions and 3 deletions

View File

@@ -50,7 +50,7 @@
this.type = type
this.$element = $(element)
this.options = this.getOptions(options)
this.$viewport = this.options.viewport && $(this.options.viewport.selector || this.options.viewport)
this.$viewport = this.options.viewport && $($.isFunction(this.options.viewport) ? this.options.viewport.call(this, this.$element) : (this.options.viewport.selector || this.options.viewport))
if (this.$element[0] instanceof document.constructor && !this.options.selector) {
throw new Error('`selector` option must be specified when initializing ' + this.type + ' on the window.document object!')