<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script src="//code.jquery.com/jquery-1.11.1.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<h3>Recipients Selector w/ jQuery Checkbox Buttons<br />
<small>Choose your recipients, and display the results below!</small>
</h3>
<p><code>NOTE: These elements are not hooked together - like many other samples on bootsnipp.com, this is a framework sample.</code></p>
<br />
<div class="panel panel-default" >
<!-- PARAM_LOCATION -->
<div class="panel-heading" id="param_location">
<p>Расположение</p>
<select class="form-control input-sm">
<option>Тула</option>
<option>Тульская область</option>
<option>Москва</option>
<option>Московская область</option>
</select>
</div>
<!-- PARAM_ROOMS -->
<div class="panel-heading" id="param_rooms">
<span class="button-checkbox">
<p>Количество комнат</p>
<button type="button" class="btn btn-sm" data-color="default">1</button>
<input type="checkbox" id="showall" class="hidden" checked />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">2</button>
<input type="checkbox" id="showall" class="hidden" />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">3</button>
<input type="checkbox" id="showall" class="hidden" />
</span>
<span class="button-checkbox">
<button type="button" class="btn btn-sm" data-color="default">4+</button>
<input type="checkbox" id="showall" class="hidden" />
</span>
</div>
<!-- PARAM_PRICE -->
<div class="panel-heading" id="param_price">
<p>Цена, руб.</p>
<div class="row">
<div class="col-xs-6">
<select class="form-control input-sm">
<option>От</option>
<option>1 млн.</option>
<option>2 млн.</option>
<option>3 млн.</option>
</select>
</div>
<div class="col-xs-6">
<select class="form-control input-sm">
<option>До</option>
<option>1 млн.</option>
<option>2 млн.</option>
<option>3 млн.</option>
</select>
</div>
</div>
</div>
<!-- PARAM_SQUARE -->
<div class="panel-heading" id="param_square">
<p>Площадь, м2</p>
<div class="row">
<div class="col-xs-6" >
<select class="form-control input-sm">
<option>От</option>
<option>1 млн.</option>
<option>2 млн.</option>
<option>3 млн.</option>
</select>
</div>
<div class="col-xs-6">
<select class="form-control input-sm">
<option>До</option>
<option>1 млн.</option>
<option>2 млн.</option>
<option>3 млн.</option>
</select>
</div>
</div>
</div>
<br />
<!-- INCLUDE BUILDING HOUSES -->
<div class="panel-heading" id="param_square">
<div class="checkbox">
<label>
<input type="checkbox" value="">
Включить строящиеся объекты
</label>
</div>
<!-- Indicates a dangerous or potentially negative action -->
<button type="button" class="btn btn-danger">Danger</button>
</div>
</div>
</div>
/* shirokov additions */
* {
-webkit-border-radius: 3 !important;
-moz-border-radius: 3 !important;
border-radius: 3 !important;
}
#param_location, #param_rooms, #param_price, #param_square {
float:left;
}
#param_rooms select , #param_price select , #param_square select {
width:75px;
}
#param_price .col-xs-6 , #param_square .col-xs-6 {
padding-right:0px;
}
.panel-heading {
/* height:100px; */
}
/* end of shirokov additions */
$(function () {
$('.button-checkbox').each(function () {
// Settings
var $widget = $(this),
$button = $widget.find('button'),
$checkbox = $widget.find('input:checkbox'),
color = $button.data('color'),
settings = {
on: {
icon: 'glyphicon glyphicon-check'
},
off: {
icon: 'glyphicon glyphicon-unchecked'
}
};
// Event Handlers
$button.on('click', function () {
$checkbox.prop('checked', !$checkbox.is(':checked'));
$checkbox.triggerHandler('change');
updateDisplay();
});
$checkbox.on('change', function () {
updateDisplay();
});
// Actions
function updateDisplay() {
var isChecked = $checkbox.is(':checked');
// Set the button's state
$button.data('state', (isChecked) ? "on" : "off");
// Set the button's icon
$button.find('.state-icon')
.removeClass()
//.addClass('state-icon ' + settings[$button.data('state')].icon); //shir: turned off icons
// Update the button's color
if (isChecked) {
$button
.removeClass('btn-default')
.addClass('btn-' + color + ' active');
}
else {
$button
.removeClass('btn-' + color + ' active')
.addClass('btn-default');
}
}
// Initialization
function init() {
updateDisplay();
/* Inject the icon if applicable shir: turned off icons
if ($button.find('.state-icon').length == 0) {
$button.prepend('<i class="state-icon ' + settings[$button.data('state')].icon + '"></i> ');
} */
}
init();
});
});