jQuery(document).ready(function ($) {
var $grid = $('#grid');
var $columns = $grid.children('.column');
var showing = 5;
var $markup = $('#markup code');
var $message = $('#message');
var $add = $('#add');
var $remove = $('#remove');
function showColumns() {
if (showing === 13) {
$message.show();
} else {
$message.hide();
}
showing = Math.min(Math.max(parseInt(showing), 2), 12);
$columns.hide();
$columns.slice(0, showing).show();
$markup.html('<div class="columns">');
$markup.append('\n');
for(i = 0; i < showing; i++) {
$markup.append(' <div class="column">');
$markup.append(i + 1);
$markup.append('</div>');
$markup.append('\n');
}
$markup.append('</div>');
}
$add.click(function() {
showing++;
showColumns();
});
$remove.click(function() {
showing--;
showColumns();
});
});