renovations

This commit is contained in:
Ilya Kantor 2015-02-21 00:59:02 +03:00
parent 24171550ae
commit a62682e188
49 changed files with 620 additions and 894 deletions

View file

@ -0,0 +1,50 @@
.customselect {
width: 200px;
font-size: 14px;
display: inline-block;
}
.customselect .title {
height: 20px;
border: 2px groove #ADD8E6;
background: white;
width: 200px;
box-sizing: border-box;
padding: 2px;
line-height: 14px;
cursor: pointer;
text-align: left;
}
.customselect li {
padding: 2px;
cursor: pointer;
}
.customselect li:nth-child(even) {
background-color: #f0f8ff;
}
.customselect li:hover {
background-color: #7fffd4;
}
.customselect ul {
list-style: none;
margin: 0;
padding: 0;
display: none;
position: absolute;
z-index: 1000;
background: white;
width: 200px;
border-bottom: 1px solid #add8e6;
border-left: 1px solid #add8e6;
border-right: 1px solid #add8e6;
box-sizing: border-box;
}
.customselect.open ul {
display: block;
}

View file

@ -0,0 +1 @@
// ваш код CustomSelect

View file

@ -2,54 +2,51 @@
<html>
<head>
<title>Селект</title>
<script src='http://code.jquery.com/jquery.min.js'></script>
<script src="https://cdn.polyfill.io/v1/polyfill.js?features=CustomEvent,Element.prototype.closest"></script>
<link rel="stylesheet" href="customselect.css"/>
<!-- для вашего кода -->
<script src="customselect.js"></script>
</head>
<body>
<div>Последний результат: <span id="result">...</span></div>
<img src="https://js.cx/clipart/select-button.gif">
<div id="animal-select" class="customselect">
<div class="customselect-title">Выберите</div>
<ol class="customselect-options">
<button class="title">Выберите</button>
<ul>
<!-- значение хранится в свойстве data-value -->
<li data-value="bird">Птицы</li>
<li data-value="fish">Рыбы</li>
<li data-value="animal">Звери</li>
<li data-value="dino">Динозавры</li>
<li data-value="simplest">Одноклеточные</li>
</ol>
</ul>
</div>
<div id="food-select" class="customselect">
<div class="customselect-title">Выберите</div>
<ol class="customselect-options">
<button class="title">Выберите</button>
<ul>
<li data-value="carnivore">Плотоядные</li>
<li data-value="herbivore">Травоядные</li>
<li data-value="omnivore">Всеядные</li>
</ol>
</ul>
</div>
<script>
// создаём два селекта
var animalSelect = new CustomSelect({
elem: $('#animal-select')
elem: document.getElementById('animal-select')
});
var foodSelect = new CustomSelect({
elem: $('#food-select')
elem: document.getElementById('food-select')
});
// выводим выбранное значение
$([animalSelect, foodSelect]).on('select', function (event) {
$('#result').html(event.value)
document.addEventListener('select', function (event) {
document.getElementById('result').innerHTML = event.detail.value;
});
</script>
</body>
</html>
</html>