To implement this I added the following code to into cool_message.js:

setTimeout(function() {
      $('.messages', context).fadeOut('slow');
    }, 10000);

We could also add an option to set different timeouts to each message type, for example "0" for system errors.

CommentFileSizeAuthor
#7 1334446-7.patch2.94 KBrahulrasgon

Comments

Vc Developer’s picture

Thanks for the code and its an good idea! Where is the maintainer? There should be a configuration menu for this.

krolpl’s picture

I agree ability to set a timeouts would make this a perfect messages module ;) Great work.

krolpl’s picture

Issue summary: View changes

"cood" instead of "could" ?? WTF?? I need some sleep...

cbe243’s picture

Issue summary: View changes

And for D8?

azovsky’s picture

Of course!

cbe243’s picture

Which cool_message.js ? Because there is 2.
cool_message.js and js/cool_message.js

And exactly where? Because I tried to put it as such:

(function ($) {

Drupal.behaviors.coolMessage = {
  attach: function (context, settings) {
    
    $('.messages', context).hide();
    $('.messages', context).fadeIn('slow');

    // Hide a message when clicked on it.
    $('.messages').click(function() {
      $(this).fadeOut('slow');
    });

  }

};


})(jQuery);
setTimeout(function() {
      $('.messages', context).fadeOut('slow');
    }, 100);

and that doesn't work.

rahulrasgon’s picture

Version: 7.x-1.0-beta1 » 8.x-2.0
rahulrasgon’s picture

Status: Active » Needs review
StatusFileSize
new2.94 KB

Please review the patch.

  • e608ed7 committed on 3.0.x
    Issue #1334446 by rahulrasgon: ADD Auto-remove messages on timeout
    
azovsky’s picture

Status: Needs review » Fixed
azovsky’s picture

Thank you, @rahulrasgon!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.