hexlet-volunteers/interviews

View on GitHub
public/javascripts/index.js

Summary

Maintainability
A
0 mins
Test Coverage
/*
 *= require tether/dist/js/tether.js
 *= require jquery/dist/jquery.js
 *= require bootstrap/dist/js/bootstrap.js
 */

// SO-driven development https://gist.github.com/claviska/ab56d08bb19d011e3c35
 $(function() {

     function reposition() {

         var modal = $(this),
             dialog = modal.find('.modal-dialog');

         modal.css('display', 'block');

         // Dividing by two centers the modal exactly, but dividing by three
         // or four works better for larger screens.
         dialog.css("margin-top", Math.max(0, ($(window).height() - dialog.height()) / 2));

     }

     // Reposition when a modal is shown
     $('.modal').on('show.bs.modal', reposition);

     // Reposition when the window is resized
     $(window).on('resize', function() {
         $('.modal:visible').each(reposition);
     });

 });