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

Allow for dynamic number of columns #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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.

<body data-bootstrap-num-cols="15">
38 changes: 21 additions & 17 deletions grid.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
if (document.getElementsByClassName('cb-grid-lines').length){

document.body.removeChild(document.getElementsByClassName('cb-grid-lines')[0]);
}

else {
document.body.innerHTML += '<div class="cb-grid-lines"> \

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 += '<div class="cb-grid-lines"> \
<div class="container"> \
<div class="row"> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
<div class="span1 col-xs-1"></div> \
</div> \
<div class="row">';

for (var i = 0; i < numCols; i += 1) {
html += '<div class="span1 col-xs-1"></div>';
}

html += '</div> \
</div> \
</div>';


document.body.innerHTML += html;

}