diff --git a/README.md b/README.md index 5ae5ebf..18b603d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,12 @@ -chrome-bootstrap +chrome-bootstrap-dynamic ================ A Chrome extension to overlay your Bootstrap grid + +Forked version of https://github.com/chuckhendo/chrome-bootstrap + +Added option for adding an attribute to the body tag for customizing +number of columns that are overlayed. +Attribute is optional, fallback to 12 columns. + + diff --git a/grid.js b/grid.js index 696fe64..afe11b3 100644 --- a/grid.js +++ b/grid.js @@ -1,26 +1,30 @@ if (document.getElementsByClassName('cb-grid-lines').length){ - + document.body.removeChild(document.getElementsByClassName('cb-grid-lines')[0]); } else { - document.body.innerHTML += '
\ + + var html = "", + numCols = 12, + dataNumCols = document.getElementsByTagName("body")[0].getAttribute("data-bootstrap-num-cols"); + + if(typeof dataNumCols === "string" && dataNumCols.length){ + numCols = parseInt(dataNumCols, 10); + } + + html += '
\
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ -
\ +
'; + + for (var i = 0; i < numCols; i += 1) { + html += '
'; + } + + html += '
\
\
'; - + + document.body.innerHTML += html; + } \ No newline at end of file