Opening a modal window can be canceled

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8774 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-08-16 09:08:57 +00:00
parent d8671ed397
commit 7311a6c175

View file

@ -97,7 +97,7 @@ jQuery(function($){
// Modal Window
$('a.modalAnchor')
.click(function(){
var $this = $(this), $modal;
var $this = $(this), $modal, disabled;
// get and initialize modal window
$modal = $( $this.attr('href') );
@ -134,7 +134,14 @@ jQuery(function($){
$this.unbind('init.mw');
})
.bind('open.mw', function(){
var $this = $(this), $modal, duration;
var $this = $(this), before_event, $modal, duration;
// before event trigger
before_event = $.Event('before-open.mw');
$this.trigger(before_event);
// is event canceled?
if(before_event.isDefaultPrevented()) return false;
// get modal window
$modal = $( $this.attr('href') );
@ -148,9 +155,6 @@ jQuery(function($){
// workaroud for IE6
$('html,body').addClass('modalContainer');
// before event trigger
$this.trigger('before-open.mw');
// after event trigger
function after(){ $this.trigger('after-open.mw') };
@ -166,7 +170,14 @@ jQuery(function($){
.find('button.modalClose:first').focus();
})
.bind('close.mw', function(){
var $this = $(this), $modal, duration;
var $this = $(this), before_event, $modal, duration;
// before event trigger
before_event = $.Event('before-close.mw');
$this.trigger(before_event);
// is event canceled?
if(before_event.isDefaultPrevented()) return false;
// get modal window
$modal = $( $this.attr('href') );
@ -180,15 +191,13 @@ jQuery(function($){
// workaroud for IE6
$('html,body').removeClass('modalContainer');
// before event trigger
$this.trigger('before-close.mw');
// after event trigger
function after(){ $this.trigger('after-close.mw') };
$modal.fadeOut(duration, after);
$this.focus();
});
$('div.modal').hide();
// pagination