]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-content/themes/twentytwelve/js/theme-customizer.js
Wordpress 3.5
[autoinstalls/wordpress.git] / wp-content / themes / twentytwelve / js / theme-customizer.js
diff --git a/wp-content/themes/twentytwelve/js/theme-customizer.js b/wp-content/themes/twentytwelve/js/theme-customizer.js
new file mode 100644 (file)
index 0000000..c1018b0
--- /dev/null
@@ -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