Replace Zepto with ki.js, rewrite all JS
[plack-app-gruntmaster.git] / js / 10-modal.js
index 30da26750d149e2fcb210fcab835605cb53c4861..980bab79a987ae6001413765e665d6fb7390d69c 100644 (file)
@@ -1,30 +1,32 @@
-;(function(){
-       'use strict';
+var modal, hiding;
 
-       function show_modal () {
-               $('.modal').removeClass('hidden');
-               setTimeout(function (){
-                       $('body').addClass('modal-open');
-               }, 20);
-       }
+function show_modal () {
+       modal.classList.remove('hidden');
+       setTimeout(function (){
+               document.body.classList.add('modal-open');
+       }, 20);
+}
 
-       function hide_modal () {
-               $('body').removeClass('modal-open');
-               $('.modal').one('transitionend', function (){
-                       $('.modal').addClass('hidden');
-               });
-       }
+function hide_modal () {
+       document.body.classList.remove('modal-open');
+}
 
-       $( document ).ready(function() {
-               $('.backdrop,.modal').detach().appendTo('body');
-               $('#solution').on('click', function (e){
-                       show_modal();
-                       e.preventDefault();
-               });
-               $('.backdrop').on('click', hide_modal);
-               window.onkeyup = function (event) {
-                       if (event.keyCode === 27)
-                               hide_modal();
-               }
+$(function() {
+       modal = $('.modal')[0];
+       $(modal).on('transitionend', function (){
+               if(!document.body.classList.contains('modal-open'))
+                       modal.classList.add('hidden');
+       });
+       $('.backdrop,.modal').each(function(el){
+               document.body.appendChild(el);
        });
-})();
+       $('#solution').on('click', function (e){
+               show_modal();
+               e.preventDefault();
+       });
+       $('.backdrop').on('click', hide_modal);
+       window.onkeyup = function (event) {
+               if (event.keyCode === 27)
+                       hide_modal();
+       }
+});
This page took 0.010884 seconds and 4 git commands to generate.