/* global dobbySettings, jQuery */
(function( $ ) {
	'use strict';

	const closet = $( '.dobby-closet' );
	const dobby = $( '#dobby' );
	const notices = closet.find( 'div.error,div.notice,div.updated' );

	function reveal() {
		closet.replaceWith( closet.html() );
		dobby.remove();
	}

	function getClass() {
		if ( closet.find( 'div.error,div.notice-error' ).length ) {
			return 'notice-error';
		}

		if ( closet.find( 'div.notice-warning' ).length ) {
			return 'notice-warning';
		}

		return 'notice-info';
	}

	if ( notices.length < dobbySettings.threshold ) {
		reveal();

		return;
	}

	notices.addClass( 'inline' );

	dobby.addClass( getClass() ).removeClass( 'hide-if-js' );

	$( '.dobby-button' ).click( function() {
		closet.insertAfter( dobby );
		reveal();
	} );
})( jQuery );

@@ -125,24 +125,61 @@
 '#dobby' );%0A
+%09const inlineClass = 'dobby-inline';%0A
 %09const notic
@@ -262,42 +262,119 @@
 %7B%0A%09%09
-closet.replaceWith( closet.html() 
+notices.filter( %60.$%7BinlineClass%7D%60 ).removeClass( %60inline $%7BinlineClass%7D%60 );%0A%09%09closet.insertAfter( dobby ).show(
 );%0A%09
@@ -712,16 +712,33 @@
 notices.
+not( '.inline' ).
 addClass
@@ -743,16 +743,31 @@
 ss( 
-'
+%60
 inline
-'
+ $%7BinlineClass%7D%60
  );%0A
@@ -860,66 +860,14 @@
 ck( 
-function() %7B%0A%09%09closet.insertAfter( dobby );%0A%09%09reveal();%0A%09%7D
+reveal
  );%0A

Improve revealing captured admin notices. #9