52 lines
1.5 KiB
JavaScript
52 lines
1.5 KiB
JavaScript
var cssPropertySupported = (function () {
|
|
var mem = {}; // save test results for efficient future calls with same parameters
|
|
|
|
return function cssPropertySupported(prop, values) {
|
|
if (mem[prop + values]) return mem[prop + values];
|
|
|
|
var element = document.createElement('p'),
|
|
index = values.length,
|
|
value,
|
|
result = false;
|
|
|
|
try {
|
|
while (index--) {
|
|
value = values[index];
|
|
element.style.setProperty(prop, value);
|
|
|
|
if (element.style.getPropertyValue(prop) === value) {
|
|
result = true;
|
|
break;
|
|
}
|
|
}
|
|
} catch (pError) {}
|
|
|
|
mem[prop + values] = result;
|
|
return result;
|
|
};
|
|
})();
|
|
|
|
if (!cssPropertySupported('display', ['flex'])) {
|
|
fillViewport();
|
|
}
|
|
|
|
function fillViewport() {
|
|
var vh = window.innerHeight * 0.01;
|
|
|
|
var main = document.querySelector('main');
|
|
var footer = document.querySelector('footer');
|
|
main.style.minHeight = window.innerHeight - footer.offsetHeight * 2 + 'px';
|
|
|
|
window.addEventListener('resize', function () {
|
|
main.style.minHeight =
|
|
window.innerHeight - footer.offsetHeight * 2 + 'px';
|
|
});
|
|
|
|
// also hide early android browser's zoom controls
|
|
var meta = document.createElement('meta');
|
|
meta.name = 'viewport';
|
|
meta.content =
|
|
'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no';
|
|
document.getElementsByTagName('head')[0].appendChild(meta);
|
|
}
|