Resolved. Solution to involve my (yet to be incorporated) patch to Chaos tools dialog

See: http://drupal.org/node/1294478


(function($) {

      Drupal.behaviors.fubar = {
	    attach: function (context) {
	
	  $('.horizontal-tabs-panes').once(function(){
		  Drupal.horizontalTab.prototype.focus = function() {
		    /**
		     * Displays the tab's content pane.
		     */
		       if ($(this.fieldset).parents().find('div.ctools-modal-content').length >0){
				if ($.isFunction(Drupal.CTools.Modal.resize))
				      Drupal.CTools.Modal.resize($(this.fieldset).width(),$(this.fieldset).height());
		      }
		  
		      this.fieldset
			.siblings('fieldset.horizontal-tabs-pane')
			  .each(function () {
			    var tab = $(this).data('horizontalTab');
			    tab.fieldset.hide();
			    tab.item.removeClass('selected');
			  })
			.end()
			.show()
			.siblings(':hidden.horizontal-tabs-active-tab')
			  .val(this.fieldset.attr('id'));
		  
		      this.item.addClass('selected');
		      // Mark the active tab for screen readers.
		      $('#active-horizontal-tab').remove();
		      this.link.append('<span id="active-horizontal-tab" class="element-invisible">' + Drupal.t('(active tab)') + '</span>');
	     };

        });
	   
    }
  }
})(jQuery);

Naturally we will be changing the name from fubar

Comments

southweb’s picture

Issue summary: View changes

Improve language

southweb’s picture

Issue summary: View changes

Update

southweb’s picture

Title: Focus/Load event » Modal dialog dynamic resizing for Horizontal Tabs

Updated to reflect the fact we need to calculate all the widths and heights for each fieldgroup before the first dialog is displayed.

Note, rename from fubar, and place anywhere as long as you are using the Field Groups module and have field groups with Horizontal Tabs specified.

(function($) {
      Drupal.behaviors.fubar = {
	  attach: function (context) {
	  $('.horizontal-tabs-panes').once(function(){
		  Drupal.horizontalTab.prototype.focus = function() {
		    /**
		     * Displays the tab's content pane.
		     */
		
                      var ratio  = 0.85;        // Hack for now. For some reason the initial dialog is draw too high.
		       if ($(this.fieldset).parents().find('div.ctools-modal-content').length >0){
	    		          $('fieldset.horizontal-tabs-pane').each(function(){
					  $this = $(this);
					  console.log($this.height());
					  if (!$this.attr("initwidth")){
						$this.attr("initwidth", $this.width());
						$this.attr("initheight", $this.height()*ratio); 
					  }
				});
			      if ($.isFunction(Drupal.CTools.Modal.resize))
				    Drupal.CTools.Modal.resize(this.fieldset.initwidth,this.fieldset.initheight);
			      else { // Cater for current version of ctools - sans the .resize method
				  $('div.ctools-modal-content .modal-content', document).css({
				      'width': (this.fieldset.attr("initwidth") *1  + Drupal.CTools.Modal.currentSettings.modalSize.addWidth) + 'px',
				     'height': (this.fieldset.attr("initheight") *1 + Drupal.CTools.Modal.currentSettings.modalSize.addHeight) + 'px'
				   });
			      }
		      }
		  
		      this.fieldset
			.siblings('fieldset.horizontal-tabs-pane')
			  .each(function () {
			    var tab = $(this).data('horizontalTab');
			    tab.fieldset.hide();
			    tab.item.removeClass('selected');
			  })
			.end()
			.show()
			.siblings(':hidden.horizontal-tabs-active-tab')
			  .val(this.fieldset.attr('id'));
		  
		      this.item.addClass('selected');
		      // Mark the active tab for screen readers.
		      $('#active-horizontal-tab').remove();
		      this.link.append('<span id="active-horizontal-tab" class="element-invisible">' + Drupal.t('(active tab)') + '</span>');
	     };
        });
    }
  }
})(jQuery);

Stalski’s picture

Great, I guess we will push this as soon as the patch is activated in the CTools project. #1294478: Modal dialog dynamic resizing

Stalski’s picture

Status: Active » Postponed
Stalski’s picture

Issue summary: View changes

resolved

nils.destoop’s picture

Issue summary: View changes
Status: Postponed » Closed (won't fix)