? .DS_Store ? ctools_resize.patch Index: mc.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/js/mc.js,v retrieving revision 1.3 diff -u -p -r1.3 mc.js --- mc.js 18 Sep 2009 21:00:52 -0000 1.3 +++ mc.js 6 Oct 2009 04:19:03 -0000 @@ -86,10 +86,7 @@ Drupal.CTools.Modal.modalContent = funct // Create our content div, get the dimensions, and hide it var modalContent = $('#modalContent').css('top','-1000px'); - var mdcTop = wt + ( winHeight / 2 ) - ( modalContent.outerHeight() / 2); - var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2); $('#modalBackdrop').css(css).css('top', 0).css('height', docHeight + 'px').css('width', docWidth + 'px').show(); - modalContent.css({top: mdcTop + 'px', left: mdcLeft + 'px'}).hide()[animation](speed); // Bind a click for closing the modalContent modalContentClose = function(){close(); return false;}; @@ -117,22 +114,8 @@ Drupal.CTools.Modal.modalContent = funct }; // Move and resize the modalBackdrop and modalContent on resize of the window - modalContentResize = function(){ - // Get our heights - var docHeight = $(document).outerHeight(); - var docWidth = $(document).innerWidth(); - var winHeight = $(window).height(); - var winWidth = $(window).width(); - if( docHeight < winHeight ) docHeight = winHeight; - - // Get where we should move content to - var modalContent = $('#modalContent'); - var mdcTop = ( winHeight / 2 ) - ( modalContent.outerHeight() / 2); - var mdcLeft = ( winWidth / 2 ) - ( modalContent.outerWidth() / 2); - - // Apply the changes - $('#modalBackdrop').css('height', docHeight + 'px').css('width', docWidth + 'px').show(); - modalContent.css('top', mdcTop + 'px').css('left', mdcLeft + 'px').show(); + modalContentResize = function(){ + Drupal.theme('CToolsModalResize'); }; $(window).bind('resize', modalContentResize); Index: modal.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/ctools/js/modal.js,v retrieving revision 1.17 diff -u -p -r1.17 modal.js --- modal.js 21 Sep 2009 20:53:00 -0000 1.17 +++ modal.js 6 Oct 2009 04:19:03 -0000 @@ -46,6 +46,9 @@ Drupal.CTools.Modal.show = function() { Drupal.CTools.Modal.modalContent(Drupal.CTools.Modal.modal, opts); $('#modalContent .modal-content').html(Drupal.theme('CToolsModalThrobber')); + + // Now that throbber markup is loaded and populated, position modal. + Drupal.theme('CToolsModalResize'); }; /** @@ -232,6 +235,10 @@ Drupal.behaviors.CToolsModal = function( Drupal.CTools.AJAX.commands.modal_display = function(command) { $('#modal-title').html(command.title); $('#modal-content').html(command.output); + + // Now that content markup is loaded and populated, position modal. + Drupal.theme('CToolsModalResize'); + Drupal.attachBehaviors($('#modal-content')); } @@ -241,3 +248,37 @@ Drupal.CTools.AJAX.commands.modal_displa Drupal.CTools.AJAX.commands.modal_dismiss = function(command) { Drupal.CTools.Modal.dismiss(); } + +/** + * Re-size the modal. + */ +Drupal.theme.prototype.CToolsModalResize = function() { + var modalContent = $('#modalContent'); + // Get the document height & width. + var docHeight = $(document).outerHeight() + 50; + var docWidth = $(document).innerWidth(); + // position code lifted from http://www.quirksmode.org/viewport/compatibility.html + if (self.pageYOffset) { // all except Explorer + var wt = self.pageYOffset; + } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict + var wt = document.documentElement.scrollTop; + } else if (document.body) { // all other Explorers + var wt = document.body.scrollTop; + } + // Get the window height & width. + var winHeight = $(window).innerHeight(); + var winWidth = $(window).innerWidth(); + // Before getting modal height & width, we need to move modal to top left so that the values are as accurate as possible. + // This is especially needed when the modal content is very wide and fills up most of the available screen width. + modalContent.css('visibility', 'hidden'); + modalContent.css('top', '15px').css('left', '15px'); + var mdcTop = wt + (winHeight / 2) - (modalContent.height() / 2); + var mdcLeft = (winWidth / 2) - (modalContent.width() / 2); + // If popup is taller or wider than viewable area, snap popup to top or left of viewable area - adding 15px padding. + (mdcTop < (15+wt)) ? mdcTop = wt+15 : null; + (mdcLeft < 15) ? mdcLeft = 15 : null; + // Apply the changes. + $('#modalBackdrop').css('height', docHeight + 'px').css('width', docWidth + 'px').show(); + modalContent.css('top', mdcTop + 'px').css('left', mdcLeft + 'px').show(); + modalContent.css('visibility', 'visible'); +}