web/wp-content/themes/twentytwelve/js/theme-customizer.js
changeset 204 09a1c134465b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/wp-content/themes/twentytwelve/js/theme-customizer.js	Wed Dec 19 17:46:52 2012 -0800
@@ -0,0 +1,32 @@
+/**
+ * Theme Customizer enhancements for a better user experience.
+ *
+ * Contains handlers to make Theme Customizer preview reload changes asynchronously.
+ * Things like site title, description, and background color changes.
+ */
+
+( function( $ ) {
+	// Site title and description.
+	wp.customize( 'blogname', function( value ) {
+		value.bind( function( to ) {
+			$( '.site-title a' ).html( to );
+		} );
+	} );
+	wp.customize( 'blogdescription', function( value ) {
+		value.bind( function( to ) {
+			$( '.site-description' ).html( to );
+		} );
+	} );
+
+	// Hook into background color change and adjust body class value as needed.
+	wp.customize( 'background_color', function( value ) {
+		value.bind( function( to ) {
+			if ( '#ffffff' == to || '#fff' == to )
+				$( 'body' ).addClass( 'custom-background-white' );
+			else if ( '' == to )
+				$( 'body' ).addClass( 'custom-background-empty' );
+			else
+				$( 'body' ).removeClass( 'custom-background-empty custom-background-white' );
+		} );
+	} );
+} )( jQuery );
\ No newline at end of file