I\'ve been looking at the CSS & JavaScript from Bootstrap 3. Nothing is modularized under a common alias. For the JavaScript, it is injected into jQuery\'s prototype...<
In my scenario, I have an API that has bootstrap render mode and needs to determine the major bootstrap version. I'm facing many occurences of implementators using only the Bootstrap CSS and not the javascript. I therefore hacked together following function which, altough not perfect and clean at all, helps me detect what version of bootstrap CSS is referenced (if any)
function getBoostrapMajorVersion() {
try {
return Number(window['jQuery'].fn.tooltip.Constructor.VERSION.substring(0, 1));
} catch (e) { }
var testElement = document.createElement('div');
testElement.setAttribute('style', 'display:block;width:100px;height:100px;position:absolute;opacity:0.001;');
testElement.innerHTML = '';
document.body.appendChild(testElement);
if (testElement.childNodes[0].clientHeight == 25 && testElement.childNodes[0].clientWidth == 50) {
document.body.removeChild(testElement);
return 4;
}
testElement.innerHTML = ''
testElement.setAttribute('class', 'hidden-xs hidden-sm hidden-md hidden-lg');
if (testElement.clientHeight == 0) {
document.body.removeChild(testElement);
return 3;
}
}