angular-flash icon indicating copy to clipboard operation
angular-flash copied to clipboard

Add a timeout to clear message automatically feature

Open map7 opened this issue 11 years ago • 7 comments

I needed a feature which would clear the messages after so many seconds when creating a new flash message.

map7 avatar Sep 12 '13 03:09 map7

I like this feature UP

regis-leray avatar Oct 17 '13 18:10 regis-leray

Hey, First of all sorry! I totally missed this one... Second thank you for your input.

I've done "auto hide" flash messages before with ngAnimate and CSS. So I quickly put this plnkr together to demonstrate http://embed.plnkr.co/y1INk36bPbW7GaX15QbQ/preview The flash-messages.css stylesheet is where the magic happens, specially line 20 where we set the 3 seconds delay for the hide animation. Does it help you in any way?

Regarding including html messages, that's a nice feature. I'm just going to double check how to make it work with the latest version of angular's SCE. If I'm not mistaken if you don't include ngSanitize in your project and are using ng-html-bind-unsafe, angular renders nothing. Would you mind double checking this as well? And perhaps send another pull request, so we could split this one?

Cheers, -g

gtramontina avatar Oct 18 '13 04:10 gtramontina

By the way, for the sake of knowledge sharing, if you wanted html as flash messages to be able to add something like bootstrap icons: <i class="icon-info-sign">Success - you could use CSS pseudo elements to display such icons, like this:

#loading-messages .error:before,
#loading-messages .warning:before,
#loading-messages .info:before,
#loading-messages .success:before {
  display: inline-block;
  width: 1em;
  font-family: 'FontAwesome';
  margin-right: 4px
}

#loading-messages .error:before { content: '\f057'; }
#loading-messages .warning:before { content: '\f071'; }
#loading-messages .info:before { content: '\f06a'; }
#loading-messages .success:before { content: '\f058'; }

Cheers, -g

gtramontina avatar Oct 18 '13 04:10 gtramontina

@map7 that is exactly what i was looking for.

@gtramontina thanks for sharing those CSS snippets, i want do close my flash message using this.

luisfdeandrade avatar Nov 14 '13 19:11 luisfdeandrade

@luisfdeandrade you're saying you +1 the pull request or using CSS only (http://embed.plnkr.co/y1INk36bPbW7GaX15QbQ/preview) satisfy your needs? Or were you talking about the FontAwesome icons?

EDIT: you're welcome anyway. :-)

gtramontina avatar Nov 14 '13 21:11 gtramontina

+1 for timeout. Otherwise it seems not possible to clear the flash-messages

Traxmaxx avatar Nov 15 '13 16:11 Traxmaxx

i just added to my directive template and worked fine, using same structure like twitter bootstrap.

<button type="button" class="close" data-dismiss="alert" aria-hidden="false">&times;</button>

luisfdeandrade avatar Nov 18 '13 10:11 luisfdeandrade