Commit e34bb2b0 authored by Nikolay Gromov's avatar Nikolay Gromov

library

parent aa4c6db2
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"start": "./node_modules/.bin/gulp", "start": "./node_modules/.bin/gulp",
"less-lint": "lesshint ./src/less/ ./src/blocks/", "less-lint": "lesshint ./src/less/ ./src/blocks/"
"precommit": "npm run less-lint"
}, },
"author": "Nikolay Gromov", "author": "Nikolay Gromov",
"license": "MIT", "license": "MIT",
......
$( document ).ready(function() { ready(function(){
$('.js-library-code-toggler').on('click', function(){ // Открытие/закрытие блока с кодом
$(this).closest('.js-library-code-parent').find('.js-library-code').slideToggle(); var codeShowTriggers = document.querySelectorAll('.blocks-library__code-show-trigger');
for (var i = 0; i < codeShowTriggers.length; i++) {
codeShowTriggers[i].addEventListener('click', function(){
this.closest('.blocks-library__code-wrapper').querySelector('.blocks-library__code').classList.toggle('blocks-library__code--shown');
}); });
}
}); });
...@@ -90,13 +90,20 @@ ...@@ -90,13 +90,20 @@
} }
&__code { &__code {
transition: max-height @transition-time;
overflow: hidden;
.js & { .js & {
display: none; max-height: 0;
}
.js &--shown {
max-height: 410px;
} }
pre { pre {
margin: 0; margin: 0;
max-height: 410px;
} }
} }
} }
......
...@@ -1524,7 +1524,6 @@ ...@@ -1524,7 +1524,6 @@
<section class="blocks-library__item" id="btn" data-name=".btn"> <section class="blocks-library__item" id="btn" data-name=".btn">
<h1 class="blocks-library__item-title">Кнопки</h1> <h1 class="blocks-library__item-title">Кнопки</h1>
<div class="blocks-library__sub-item"> <div class="blocks-library__sub-item">
<div class="js-font-resizer">
<p> <p>
<input type="text" value="Текстовое поле для сравнения высоты" title="Текстовое поле для сравнения высоты" style="width:70px"> <input type="text" value="Текстовое поле для сравнения высоты" title="Текстовое поле для сравнения высоты" style="width:70px">
<a href="" class="btn">Cсылка</a> <a href="" class="btn">Cсылка</a>
...@@ -1543,10 +1542,9 @@ ...@@ -1543,10 +1542,9 @@
<input type="submit" class="btn btn--danger" value="Input"> <input type="submit" class="btn btn--danger" value="Input">
<button class="btn btn--danger">Button</button> <button class="btn btn--danger">Button</button>
</p> </p>
</div> <div class="blocks-library__code-wrapper">
<div class="blocks-library__code-wrapper js-library-code-parent"> <span class="blocks-library__code-show-trigger" title="Показать код"><i class="blocks-library__code-icon"></i></span>
<span class="blocks-library__code-show-trigger js-library-code-toggler" title="Показать код"><i class="blocks-library__code-icon"></i></span> <div class="blocks-library__code">
<div class="blocks-library__code js-library-code">
<pre> <pre>
<code class="html">&lt;input type="text" value="Текстовое поле для сравнения высоты" style="width:70px"&gt;</code> <code class="html">&lt;input type="text" value="Текстовое поле для сравнения высоты" style="width:70px"&gt;</code>
<code class="html"> </code> <code class="html"> </code>
......
...@@ -18,6 +18,24 @@ function closest(el, selector) { ...@@ -18,6 +18,24 @@ function closest(el, selector) {
/*
Запуск по готовности DOM
http://youmightnotneedjquery.com/#ready
Применение: ready(function(){ console.log('ddd'); });
*/
function ready(fn) {
if (document.readyState != 'loading'){
fn();
} else {
document.addEventListener('DOMContentLoaded', fn);
}
}
// Свой код с jQuery // Свой код с jQuery
// $( document ).ready(function() { // $( document ).ready(function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment