Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 42 additions & 19 deletions src/jquery.simplemodal.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@
$.modal.impl.update(height, width);
};

/*
* Transition to another modal without closing the overlay
*/
$.modal.switchModals = function ( newModalObj , options ) {
$.modal.impl.switchModals( newModalObj , options );
};

/*
* Chained function to create a modal dialog.
*
Expand Down Expand Up @@ -320,21 +327,25 @@
.appendTo(s.o.appendTo);
}

// create the overlay
s.d.overlay = $('<div></div>')
.attr('id', s.o.overlayId)
.addClass('simplemodal-overlay')
.css($.extend(s.o.overlayCss, {
display: 'none',
opacity: s.o.opacity / 100,
height: s.o.modal ? d[0] : 0,
width: s.o.modal ? d[1] : 0,
position: 'fixed',
left: 0,
top: 0,
zIndex: s.o.zIndex + 1
}))
.appendTo(s.o.appendTo);
s.d.overlay = $('#' + s.o.overlayId);

if(s.d.overlay.length == 0 ) {
// create the overlay
s.d.overlay = $('<div></div>')
.attr('id', s.o.overlayId)
.addClass('simplemodal-overlay')
.css($.extend(s.o.overlayCss, {
display: 'none',
opacity: s.o.opacity / 100,
height: s.o.modal ? d[0] : 0,
width: s.o.modal ? d[1] : 0,
position: 'fixed',
left: 0,
top: 0,
zIndex: s.o.zIndex + 1
}))
.appendTo(s.o.appendTo);
}

// create the container
s.d.container = $('<div></div>')
Expand Down Expand Up @@ -663,7 +674,7 @@
* function was internal or external. If it was external, the
* onClose callback will be ignored
*/
close: function () {
close: function ( keepOverlay ) {
var s = this;

// prevent close when dialog does not exist
Expand Down Expand Up @@ -704,13 +715,25 @@

// remove the remaining elements
s.d.container.hide().remove();
s.d.overlay.hide();
if(!keepOverlay)
s.d.overlay.hide();
s.d.iframe && s.d.iframe.hide().remove();
s.d.overlay.remove();
if(!keepOverlay)
s.d.overlay.remove();

// reset the dialog object
s.d = {};
}
}
},

/*
* Close the currently open modal and open a new one, keeping
* the overlay in place to create a warm and fuzzy transisiton between modals
*/
switchModals: function( newModalObj , options )
{
this.close(true);
newModalObj.modal( options );
}
};
}));