Skip to content

Commit

Permalink
Merge pull request #211 from TeaWithStrangers/no-mobile-modals
Browse files Browse the repository at this point in the history
No Mobile Modals
  • Loading branch information
Nick Barnwell committed Sep 22, 2014
2 parents 1146203 + ce06b27 commit e7ead09
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/application.js
Expand Up @@ -13,7 +13,7 @@
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require jquery-ui
//= require jquery-ui/dialog
//= require_tree .


function viewportWidth() { return (window.innerWidth > 0) ? window.innerWidth : screen.width; }
14 changes: 13 additions & 1 deletion app/assets/javascripts/modals.js
@@ -1,5 +1,12 @@
var minimumWidthToDisplayModal = 768;
var modal;

function loadModal(modalTarget) {
console.log(viewportWidth());
if(viewportWidth() < minimumWidthToDisplayModal) {
return function(evt) { console.debug("Modal not displayed because minimum width not met") }
}

return function(evt) {
evt.preventDefault();
return $("#modal").load(modalTarget).dialog({
Expand All @@ -12,11 +19,16 @@ function loadModal(modalTarget) {
}
}
function closeModal() { modal.dialog('close') }

function ready() {
$('#login').click(loadModal('/signin'));
$('#login').on('click', function(evt) {
loadModal('/signin')(evt)
});

$('.tea-time-scheduling').on('click', function(evt) {
modal = loadModal(evt.currentTarget.href)(evt)
});

$('a.cancel').on('click', function(evt) {
console.log(evt)
evt.preventDefault();
Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.css.less
Expand Up @@ -12,6 +12,6 @@
*
*= require_self
*= require_tree ./
*= require jquery-ui
*= require jquery-ui/dialog
*/

0 comments on commit e7ead09

Please sign in to comment.