Révision c2ac6d1d
Ajouté par Assos Assos il y a environ 5 ans
drupal7/sites/all/modules/ctools/js/modal.js | ||
---|---|---|
378 | 378 |
} |
379 | 379 |
} |
380 | 380 |
|
381 |
if (!speed) { |
|
381 |
if (!speed && 0 !== speed) {
|
|
382 | 382 |
speed = 'fast'; |
383 | 383 |
} |
384 | 384 |
|
... | ... | |
555 | 555 |
// Create our content div, get the dimensions, and hide it |
556 | 556 |
var modalContent = $('#modalContent').css('top','-1000px'); |
557 | 557 |
var $modalHeader = modalContent.find('.modal-header'); |
558 |
var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
|
|
558 |
var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
|
|
559 | 559 |
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2); |
560 | 560 |
$('#modalBackdrop').css(css).css('top', 0).css('height', docHeight + 'px').css('width', docWidth + 'px').show(); |
561 | 561 |
modalContent.css({top: mdcTop + 'px', left: mdcLeft + 'px'}).hide()[animation](speed); |
... | ... | |
588 | 588 |
$('body').unbind( 'keypress', modalEventHandler ); |
589 | 589 |
$('body').unbind( 'keydown', modalTabTrapHandler ); |
590 | 590 |
$('.close', $modalHeader).unbind('click', modalContentClose); |
591 |
$('body').unbind('keypress', modalEventEscapeCloseHandler);
|
|
591 |
$(document).unbind('keydown', modalEventEscapeCloseHandler);
|
|
592 | 592 |
$(document).trigger('CToolsDetachBehaviors', $('#modalContent')); |
593 | 593 |
|
594 |
// Set our animation parameters and use them |
|
595 |
if ( animation == 'fadeIn' ) animation = 'fadeOut'; |
|
596 |
if ( animation == 'slideDown' ) animation = 'slideUp'; |
|
597 |
if ( animation == 'show' ) animation = 'hide'; |
|
594 |
// Closing animation. |
|
595 |
switch (animation) { |
|
596 |
case 'fadeIn': |
|
597 |
modalContent.fadeOut(speed, modalContentRemove); |
|
598 |
break; |
|
598 | 599 |
|
599 |
// Close the content |
|
600 |
modalContent.hide()[animation](speed); |
|
600 |
case 'slideDown': |
|
601 |
modalContent.slideUp(speed, modalContentRemove); |
|
602 |
break; |
|
601 | 603 |
|
602 |
// Remove the content |
|
604 |
case 'show': |
|
605 |
modalContent.hide(speed, modalContentRemove); |
|
606 |
break; |
|
607 |
} |
|
608 |
} |
|
609 |
|
|
610 |
// Remove the content. |
|
611 |
modalContentRemove = function () { |
|
603 | 612 |
$('#modalContent').remove(); |
604 | 613 |
$('#modalBackdrop').remove(); |
605 | 614 |
|
606 |
// Restore focus to where it was before opening the dialog |
|
615 |
// Restore focus to where it was before opening the dialog.
|
|
607 | 616 |
$(oldFocus).focus(); |
608 | 617 |
}; |
609 | 618 |
|
610 | 619 |
// Move and resize the modalBackdrop and modalContent on window resize. |
611 |
modalContentResize = function(){ |
|
612 |
|
|
620 |
modalContentResize = function () { |
|
613 | 621 |
// Reset the backdrop height/width to get accurate document size. |
614 | 622 |
$('#modalBackdrop').css('height', '').css('width', ''); |
615 | 623 |
|
616 | 624 |
// Position code lifted from: |
617 | 625 |
// http://www.quirksmode.org/viewport/compatibility.html |
618 | 626 |
if (self.pageYOffset) { // all except Explorer |
619 |
var wt = self.pageYOffset; |
|
627 |
var wt = self.pageYOffset;
|
|
620 | 628 |
} else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict |
621 | 629 |
var wt = document.documentElement.scrollTop; |
622 | 630 |
} else if (document.body) { // all other Explorers |
... | ... | |
632 | 640 |
|
633 | 641 |
// Get where we should move content to |
634 | 642 |
var modalContent = $('#modalContent'); |
635 |
var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2);
|
|
643 |
var mdcTop = wt + Math.max((winHeight / 2) - (modalContent.outerHeight() / 2), 0);
|
|
636 | 644 |
var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2); |
637 | 645 |
|
638 | 646 |
// Apply the changes |
Formats disponibles : Unified diff
Weekly update of contrib modules