bootstrap-grid-class-detector
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "bootstrap-grid-class-detector", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Displays the currently active Bootstrap grid class in bottom/right corner of browser", | ||
@@ -21,2 +21,3 @@ "main": "src/index.js", | ||
"width", | ||
"height", | ||
"mobile", | ||
@@ -27,3 +28,6 @@ "desktop", | ||
"md", | ||
"lg" | ||
"lg", | ||
"window", | ||
"size", | ||
"Angular" | ||
], | ||
@@ -30,0 +34,0 @@ "author": "xErik", |
# bootstrap-grid-class-detector | ||
Displays the currently active Bootstrap grid class in bottom/right corner of browser: **xs, sm, md or lg**. | ||
Displays the currently active Bootstrap grid class in bottom/right corner of browser: **xs, sm, md or lg**. Also displays current window size. | ||
@@ -10,3 +10,3 @@ | ||
``` | ||
npm install bootstrap-grid-class-detector | ||
npm install bootstrap-grid-class-detector --save-dev | ||
``` | ||
@@ -16,5 +16,12 @@ | ||
*app.js (or wherever)* | ||
***Node / AngularJS*** | ||
``` | ||
require('bootstrap-grid-class-detector'); | ||
``` | ||
***HTML*** | ||
``` | ||
<script src="<your path>/src/index.js"></script> | ||
``` |
@@ -6,12 +6,16 @@ "use strict"; | ||
var id = 'deviceInfo', | ||
type = "Mobile (xs)", | ||
type = "XS: 0..768", | ||
widthType = 'innerWidth', | ||
heightType = 'innerHeight', | ||
container = document.getElementById(id), | ||
width; | ||
width, | ||
height; | ||
if (!('innerWidth' in window)) { | ||
widthType = 'clientWidth'; | ||
heightType = 'clientHeight'; | ||
window = document.documentElement || document.body; | ||
} | ||
width = window[widthType]; | ||
height = window[heightType]; | ||
@@ -27,27 +31,33 @@ if (!container) { | ||
if (width >= 1200) { | ||
type = "Large Desktop (lg)"; | ||
type = "LG: 1200..∞"; | ||
} else if (width >= 992) { | ||
type = "Medium Desktop (md)"; | ||
type = "MD: 992..1199"; | ||
} else if (width >= 768) { | ||
type = "Tablet (sm)"; | ||
type = "SM: 768..991"; | ||
} | ||
type = '<b>' + type + ' width</b><br/>width: ' + width + ' height: ' + height + ''; | ||
container.innerHTML = type; | ||
} | ||
// refresh on resize | ||
if (window.addEventListener) { | ||
window.addEventListener("resize", refreshDeviceInfo, false); | ||
} else if (window.attachEvent) { | ||
window.attachEvent("onresize", refreshDeviceInfo); | ||
} else { | ||
window.onresize = refreshDeviceInfo; | ||
} | ||
document.addEventListener("DOMContentLoaded", function(event) { | ||
refreshDeviceInfo(); | ||
// refresh on resize | ||
if (window.addEventListener) { | ||
window.addEventListener("resize", refreshDeviceInfo, false); | ||
} else if (window.attachEvent) { | ||
window.attachEvent("onresize", refreshDeviceInfo); | ||
} else { | ||
window.onresize = refreshDeviceInfo; | ||
} | ||
}); | ||
try { | ||
exports = module.exports = function() { | ||
exports = module.exports = function() { | ||
}; | ||
}; | ||
} catch (e) { | ||
// ignore, catches if included by script-tag | ||
} |
Sorry, the diff of this file is not supported yet
13374
50
26