Skip to content

Commit

Permalink
I included spaces from previous commits joaopereirawd#63
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Gonzalez Robles committed Sep 12, 2018
1 parent 3033eb5 commit 695fada
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 57 deletions.
127 changes: 74 additions & 53 deletions animatedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,62 @@
=========================================*/

(function ($) {

$.fn.animatedModal = function(options) {
var modal = $(this);

//Defaults
var settings = $.extend({
modalTarget:'animatedModal',
position:'fixed',
width:'100%',
height:'100%',
top:'0px',
left:'0px',
zIndexIn: '9999',
zIndexOut: '-9999',
color: '#39BEB9',
opacityIn:'1',
opacityOut:'0',
modalTarget:'animatedModal',
position:'fixed',
width:'100%',
height:'100%',
top:'0px',
left:'0px',
zIndexIn: '9999',
zIndexOut: '-9999',
color: '#39BEB9',
opacityIn:'1',
opacityOut:'0',
animatedIn:'zoomIn',
animatedOut:'zoomOut',
animationDuration:'.6s',
overflow:'auto',
animationDuration:'.6s',
overflow:'auto',
// Callbacks
beforeOpen: function() {},
afterOpen: function() {},
beforeClose: function() {},
afterClose: function() {}


beforeOpen: function() {},
afterOpen: function() {},
beforeClose: function() {},
afterClose: function() {},
close: function(event) {
event.preventDefault();
$('body, html').css({'overflow':'auto'});

settings.beforeClose(); //beforeClose
if (id.hasClass(settings.modalTarget+'-on')) {
id.removeClass(settings.modalTarget+'-on');
id.addClass(settings.modalTarget+'-off');
}

if (id.hasClass(settings.modalTarget+'-off')) {
id.removeClass(settings.animatedIn);
id.addClass(settings.animatedOut);
id.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterClose);
};
}

}, options);

var closeBt = $('.close-'+settings.modalTarget);

//console.log(closeBt)
var closeBt = $('.close-'+settings.modalTarget);
var nextBt = $('.next-'+settings.modalTarget);
var previousBt = $('.previous-'+settings.modalTarget);

var href = $(modal).attr('href'),
id = $('body').find('#'+settings.modalTarget),
idConc = '#'+id.attr('id');
//console.log(idConc);
// Default Classes
id.addClass('animated');
id.addClass(settings.modalTarget+'-off');
//console.log(idConc);
// Default Classes
id.addClass('animated');
id.addClass(settings.modalTarget+'-off');

//Init styles
var initStyles = {
Expand All @@ -61,66 +75,73 @@
'overflow-y':settings.overflow,
'z-index':settings.zIndexOut,
'opacity':settings.opacityOut,
'-webkit-animation-duration':settings.animationDuration,
'-moz-animation-duration':settings.animationDuration,
'-ms-animation-duration':settings.animationDuration,
'animation-duration':settings.animationDuration
'-webkit-animation-duration':settings.animationDuration
};
//Apply stles
id.css(initStyles);

modal.click(function(event) {
modal.click(function(event) {
event.preventDefault();
$('body, html').css({'overflow':'hidden'});
if (href == idConc) {
if (id.hasClass(settings.modalTarget+'-off')) {
id.removeClass(settings.animatedOut);
id.removeClass(settings.modalTarget+'-off');
id.addClass(settings.modalTarget+'-on');
}
}

if (id.hasClass(settings.modalTarget+'-on')) {
settings.beforeOpen();
id.css({'opacity':settings.opacityIn,'z-index':settings.zIndexIn});
id.addClass(settings.animatedIn);
id.addClass(settings.animatedIn);
id.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterOpen);
};
}
};
}
});



closeBt.click(function(event) {
event.preventDefault();
$('body, html').css({'overflow':'auto'});

settings.beforeClose(); //beforeClose
if (id.hasClass(settings.modalTarget+'-on')) {
id.removeClass(settings.modalTarget+'-on');
id.addClass(settings.modalTarget+'-off');
}
settings.close(event);
});

if (id.hasClass(settings.modalTarget+'-off')) {
id.removeClass(settings.animatedIn);
id.addClass(settings.animatedOut);
id.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', afterClose);
};
nextBt.click(function(event) {
settings.close(event);
$(settings.next).click();
});

previousBt.click(function(event) {
settings.close(event);
$(settings.previous).click();
});

function afterClose () {
function afterClose () {
id.css({'z-index':settings.zIndexOut});
settings.afterClose(); //afterClose
}

function afterOpen () {
function afterOpen () {
settings.afterOpen(); //afterOpen
}

function afterNext () {
settings.afterNext(); //afterOpen
}

function afterPrevious () {
settings.afterPrevious(); //afterOpen
}

// close modal menu if esc key is used
$(document).keyup(function(event){
if(event.keyCode == 27) {
settings.close(event);
}
});

}; // End animatedModal.js

}(jQuery));




8 changes: 4 additions & 4 deletions demo/js/animatedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@
var href = $(modal).attr('href'),
id = $('body').find('#'+settings.modalTarget),
idConc = '#'+id.attr('id');
//console.log(idConc);
// Default Classes
id.addClass('animated');
id.addClass(settings.modalTarget+'-off');
//console.log(idConc);
// Default Classes
id.addClass('animated');
id.addClass(settings.modalTarget+'-off');

//Init styles
var initStyles = {
Expand Down

0 comments on commit 695fada

Please sign in to comment.