Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bootstrap error #77

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,34 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }

var $;
if (typeof window !== 'undefined' && window && window.jQuery) {
$ = window.jQuery;
if (typeof window !== 'undefined' && window) {
if (window.jQuery) {
$ = window.jQuery;
} else {
$ = require('jquery');
window.jQuery = $;
}
} else {
$ = require('jquery');
window.jQuery = $;
}

var BS = require('bootstrap');
var React = require('react');
var objectAssign = require('object-assign');
var getOptions = require('./get-options.js');
var bsMultiselect = require('./bootstrap-multiselect.js');
var bsDropdown;

var BS;
// make it play nice when we already have bootstrap dropdown loaded.
if (typeof BS === 'undefined' || typeof BS.dropdown === 'undefined') {
try {
BS = require('bootstrap');
if (typeof BS.dropdown !== 'undefined') {
bsDropdown = BS.dropdown;
}
} catch (e) {
console.log('No bootstap');
}
if (!bsDropdown) {
bsDropdown = require('./bootstrap-dropdown.js');
} else {
bsDropdown = BS.dropdown;
}

$ = bsDropdown.init($);
Expand Down
18 changes: 11 additions & 7 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@ if (typeof window !== 'undefined' && window) {
if (window.jQuery) {
$ = window.jQuery;
} else {
$ = require('jquery')
$ = require('jquery');
window.jQuery = $;
}
} else {
$ = require('jquery');
}

var BS = require('bootstrap');
var React = require('react');
var objectAssign = require('object-assign');
var getOptions = require('./get-options.js');
var bsMultiselect = require('./bootstrap-multiselect.js');
var bsDropdown;

var BS;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like BS is only used within try - it would help readability for the variable declaration to go there.

// make it play nice when we already have bootstrap dropdown loaded.
if (typeof BS === 'undefined' || typeof BS.dropdown === 'undefined') {
bsDropdown = require('./bootstrap-dropdown.js');
try {
BS = require('bootstrap');
if (typeof BS.dropdown !== 'undefined') {
bsDropdown = BS.dropdown;
}
} catch (e) {
console.log('No bootstap');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The console.log shouldn't be necessary- not having bootstrap is supported & handled below

}
else {
bsDropdown = BS.dropdown;
if (!bsDropdown) {
bsDropdown = require('./bootstrap-dropdown.js');
}

$ = bsDropdown.init($);
Expand Down