jQuery UI dialog has a property 'dialogClass' that applies a class to the modal popup that is triggered.

Does automodal support anything like that? Or could it be added to the window config along with width, etc?

Thx

Comments

ha5bro’s picture

I've added a class (that simply uses automodal + the specified width) to automodal.js,

          if(settings['width']){
            $('.modalframe').addClass('modalframe' + settings['width']);
          }

Into Drupal.behaviors.automodal like so...

  Drupal.behaviors.automodal = function (context) {
    $.each(Drupal.settings.automodal, function(selector, settings) {
      $(selector +':not(.automodal-processed)', context)
        .addClass('automodal-processed')
        .bind('click', function() {
          settings.url = $(this).attr('href') || '#';
          if (settings.url.indexOf('?') >= 0) {
            settings.url += '&'
          }
          else {
            settings.url += '?'
          }
          settings.url += 'automodal=true';

          // Allow others to alter the settings as needed.
          settings = Drupal.automodal.settingsAlterCall(settings);

          settings.onSubmit = Drupal.automodal.onSubmitCall;
          Drupal.modalFrame.open(settings);
          
          if(settings['width']){
            $('.modalframe').addClass('modalframe' + settings['width']);
          }
          
          return false;
        });
    });
  }

Is there another way to accomplish this? A friendly way that lets me update automodal easily would be preferred. I see that settingsAlterCall(settings) allows me to easily change defined settings, but not create a new class. I might be out to lunch though, any guidance/help is appreciated.

imclean’s picture

You should be able to use something like this in a custom module:

automodal_add('.automodal', array(
    'width'   => 231,
    'height'  => 210,    
    'customDialogOptions' => array('dialogClass' => 'modalframe231')
  )
);

This adds the class just fine for me, but then the node being opened never displays, it just gets stuck on "Loading...".

imclean’s picture

Ok, the custom dialogClass was overriding the existing dialogClass "modalframe". To work around it, just add it back in.

automodal_add('.automodal', array(
    'width'   => 231,
    'height'  => 210,    
    'customDialogOptions' => array('dialogClass' => 'modalframe modalframe231')
  )
);

This is a modalframe API issue, but it could be by design.

See: #1300914: Using customDialogOptions dialogClass overrides modalframe class

ha5bro’s picture

Status: Active » Closed (works as designed)

'customDialogOptions' => array('dialogClass' => 'modalframe modalframe231')

Genius! Thanks imclean.