Commit 54e4917a authored by Nikolay Gromov's avatar Nikolay Gromov

Добавил модальные окна

parent 8e86fca4
...@@ -1795,7 +1795,7 @@ ...@@ -1795,7 +1795,7 @@
<h2 class="blocks-library__item-title">Модальные окна</h2> <h2 class="blocks-library__item-title">Модальные окна</h2>
<p>Основан на modal.js из Bootstrap. Изменения минимальны (имена классов, пространство имен событий).</p> <p>Основан на modal.js из Bootstrap. Изменения минимальны (имена классов, пространство имен событий, некоторые упрощения).</p>
<p class="alert alert--warning">Зависит от <a href="https://jquery.com/">jQuery</a> (включен в сборку по умолчанию).</p> <p class="alert alert--warning">Зависит от <a href="https://jquery.com/">jQuery</a> (включен в сборку по умолчанию).</p>
...@@ -1803,10 +1803,59 @@ ...@@ -1803,10 +1803,59 @@
<a href="#modal-demo-02" data-toggle="modal">Показать модальное окно 2</a> <a href="#modal-demo-02" data-toggle="modal">Показать модальное окно 2</a>
<span data-toggle="modal" data-target="#modal-demo-03">Показать модальное окно 3</span> <span data-toggle="modal" data-target="#modal-demo-03">Показать модальное окно 3</span>
<p>
Методы:
</p>
<pre class="code">
<code>$('#modal-demo-01').modal(options)</code>
<code onclick="$('#modal-demo-01').modal('show');">$('#modal-demo-01').modal('show')</code>
<code onclick="$('#modal-demo-01').modal('hide');">$('#modal-demo-01').modal('hide')</code>
<code onclick="$('#modal-demo-01').modal('toggle');">$('#modal-demo-01').modal('toggle')</code>
</pre>
<p>
События:
</p>
<pre class="code">
<code>$('#modal-demo-01').on('show.nth.modal', function(){</code>
<code> console.log('show.nth.modal');</code>
<code>});</code>
<code>$('#modal-demo-01').on('shown.nth.modal', function(){</code>
<code> console.log('shown.nth.modal');</code>
<code>});</code>
<code>$('#modal-demo-01').on('hide.nth.modal', function(){</code>
<code> console.log('hide.nth.modal');</code>
<code>});</code>
<code>$('#modal-demo-01').on('hidden.nth.modal', function(){</code>
<code> console.log('hidden.nth.modal');</code>
<code>});</code>
</pre>
<div class="blocks-library__code-wrapper"> <div class="blocks-library__code-wrapper">
<span class="blocks-library__code-show-trigger" title="Показать код"><i class="blocks-library__code-icon"></i></span> <span class="blocks-library__code-show-trigger" title="Показать код"><i class="blocks-library__code-icon"></i></span>
<div class="blocks-library__code"> <div class="blocks-library__code">
<pre class="code">111</pre> <pre class="code">
<code>&lt;button class="btn" type="button" data-toggle="modal" data-target="#modal-demo-01">Показать модальное окно 1&lt;/button></code>
<code>&lt;a href="#modal-demo-01" data-toggle="modal">Показать модальное окно 2&lt;/a></code>
<code>&lt;span data-toggle="modal" data-target="#modal-demo-01">Показать модальное окно 3&lt;/span></code>
<code> </code>
<code>&lt;div id="modal-demo-01" class="modal" tabindex="-1" role="dialog"></code>
<code> &lt;div class="modal__dialog" role="document"></code>
<code> &lt;div class="modal__content"></code>
<code> &lt;div class="modal__header"></code>
<code> &lt;span class="close modal__close" data-dismiss="modal" aria-label="Закрыть">&lt;span>&lt;/span>&lt;/span></code>
<code> &lt;h4 class="modal__title">Modal 01 title&lt;/h4></code>
<code> &lt;/div></code>
<code> &lt;div class="modal__body">...&lt;/div></code>
<code> &lt;div class="modal__footer"></code>
<code> &lt;button type="button" class="btn" data-dismiss="modal">Закрыть&lt;/button></code>
<code> &lt;/div></code>
<code> &lt;/div></code>
<code> &lt;/div></code>
<code>&lt;/div></code>
</pre>
</div> </div>
</div> </div>
...@@ -1882,6 +1931,19 @@ ...@@ -1882,6 +1931,19 @@
var offCanvasMenuContent = document.getElementById('off-canvas-menu'); var offCanvasMenuContent = document.getElementById('off-canvas-menu');
offCanvasMenuContent.innerHTML = offCanvasMenu; offCanvasMenuContent.innerHTML = offCanvasMenu;
$('#modal-demo-01').on('show.nth.modal', function(){
console.log('show.nth.modal');
});
$('#modal-demo-01').on('shown.nth.modal', function(){
console.log('shown.nth.modal');
});
$('#modal-demo-01').on('hide.nth.modal', function(){
console.log('hide.nth.modal');
});
$('#modal-demo-01').on('hidden.nth.modal', function(){
console.log('hidden.nth.modal');
});
}); });
</script> </script>
......
...@@ -25,21 +25,21 @@ ...@@ -25,21 +25,21 @@
this.scrollbarWidth = 0 this.scrollbarWidth = 0
this.ignoreBackdropClick = false this.ignoreBackdropClick = false
if (this.options.remote) { // if (this.options.remote) {
this.$element // this.$element
// .find('.modal-content') // // .find('.modal-content')
.find('.modal__content') // .find('.modal__content')
.load(this.options.remote, $.proxy(function () { // .load(this.options.remote, $.proxy(function () {
// this.$element.trigger('loaded.bs.modal') // // this.$element.trigger('loaded.bs.modal')
this.$element.trigger('loaded.nth.modal') // this.$element.trigger('loaded.nth.modal')
}, this)) // }, this))
} // }
} }
Modal.VERSION = '3.3.7' Modal.VERSION = '3.3.7'
Modal.TRANSITION_DURATION = 300 // Modal.TRANSITION_DURATION = 300
Modal.BACKDROP_TRANSITION_DURATION = 150 // Modal.BACKDROP_TRANSITION_DURATION = 150
Modal.DEFAULTS = { Modal.DEFAULTS = {
backdrop: true, backdrop: true,
...@@ -89,7 +89,8 @@ ...@@ -89,7 +89,8 @@
} }
that.$element that.$element
.show() // .show()
.css('display', 'flex')
.scrollTop(0) .scrollTop(0)
that.adjustDialog() that.adjustDialog()
......
...@@ -9,6 +9,8 @@ $font-size--h4: 1.25em !default; ...@@ -9,6 +9,8 @@ $font-size--h4: 1.25em !default;
$line-height: 1.375em !default; $line-height: 1.375em !default;
$screen-lg: 992px !default;
$opacity: 0.7 !default; $opacity: 0.7 !default;
$transition-time: 0.3s !default; $transition-time: 0.3s !default;
...@@ -42,6 +44,15 @@ $z-index-modal: 100 !default; ...@@ -42,6 +44,15 @@ $z-index-modal: 100 !default;
margin: 0; margin: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
@media (min-width: $screen-lg) {
width: 600px;
height: auto;
#{$block-name}--open & {
animation: modal-content-show $transition-time 1 both;
}
}
} }
&__content { &__content {
...@@ -92,12 +103,19 @@ $z-index-modal: 100 !default; ...@@ -92,12 +103,19 @@ $z-index-modal: 100 !default;
left: 0; left: 0;
z-index: ($z-index-modal - 1); z-index: ($z-index-modal - 1);
background-color: rgba(0, 0, 0, $opacity); background-color: rgba(0, 0, 0, $opacity);
animation: modal-backdrop-show $transition-time 1;
@media (min-width: $screen-lg) {
animation: modal-backdrop-show $transition-time 1;
}
} }
&--open { &--open {
#{$block-name}__dialog {} @media (min-width: $screen-lg) {
display: flex;
justify-content: center;
align-items: center;
}
} }
} }
...@@ -113,3 +131,16 @@ $z-index-modal: 100 !default; ...@@ -113,3 +131,16 @@ $z-index-modal: 100 !default;
opacity: 1; opacity: 1;
} }
} }
@keyframes modal-content-show {
0% {
opacity: 0;
transform: translateY(-2em);
}
100% {
opacity: 1;
transform: translateY(0);
}
}
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