Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added fittext script for the hero region title.

  • Loading branch information...
commit b0c9a7619adff5a2748e075d2025e6641734415a 1 parent 8980418
@aristath aristath authored
View
43 assets/js/vendor/jquery.fittext.js
@@ -0,0 +1,43 @@
+/*global jQuery */
+/*!
+* FitText.js 1.1
+*
+* Copyright 2011, Dave Rupert http://daverupert.com
+* Released under the WTFPL license
+* http://sam.zoy.org/wtfpl/
+*
+* Date: Thu May 05 14:23:00 2011 -0600
+*/
+
+(function( $ ){
+
+ $.fn.fitText = function( kompressor, options ) {
+
+ // Setup options
+ var compressor = kompressor || 1,
+ settings = $.extend({
+ 'minFontSize' : Number.NEGATIVE_INFINITY,
+ 'maxFontSize' : Number.POSITIVE_INFINITY
+ }, options);
+
+ return this.each(function(){
+
+ // Store the object
+ var $this = $(this);
+
+ // Resizer() resizes items based on the object width divided by the compressor * 10
+ var resizer = function () {
+ $this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
+ };
+
+ // Call once to set.
+ resizer();
+
+ // Call on resize. Opera debounces their resize by default.
+ $(window).on('resize', resizer);
+
+ });
+
+ };
+
+})( jQuery );
View
25 lib/customizer/hero/functions.php
@@ -22,6 +22,7 @@ function shoestrap_hero_customizer( $wp_customize ){
$settings[] = array( 'slug' => 'shoestrap_hero_background_color', 'default' => '#333333' );
$settings[] = array( 'slug' => 'shoestrap_hero_textcolor', 'default' => '#ffffff' );
$settings[] = array( 'slug' => 'shoestrap_hero_visibility', 'default' => 'front' );
+ $settings[] = array( 'slug' => 'shoestrap_hero_title_fittext', 'default' => '' );
foreach( $settings as $setting ){
$wp_customize->add_setting( $setting['slug'], array( 'default' => $setting['default'], 'type' => 'theme_mod', 'capability' => 'edit_theme_options' ) );
@@ -47,6 +48,10 @@ function shoestrap_hero_customizer( $wp_customize ){
$text_controls[] = array( 'setting' => 'shoestrap_hero_cta_text', 'label' => 'Call To Action Button Text', 'section' => 'shoestrap_hero', 'priority' => 3 );
$text_controls[] = array( 'setting' => 'shoestrap_hero_cta_link', 'label' => 'Call To Action Button Link', 'section' => 'shoestrap_hero', 'priority' => 4 );
+ //Checkbox Controls
+ $checkbox_controls = array();
+ $checkbox_controls[] = array( 'setting' => 'shoestrap_hero_title_fittext', 'label' => 'Use FitText for the Title', 'section' => 'shoestrap_hero', 'priority' => 2 );
+
foreach( $color_controls as $control ){
$wp_customize->add_control( new WP_Customize_Color_Control(
$wp_customize,
@@ -94,6 +99,16 @@ function shoestrap_hero_customizer( $wp_customize ){
));
}
+ foreach ( $checkbox_controls as $control ) {
+ $wp_customize->add_control( $control['setting'], array(
+ 'label' => __( $control['label'], 'shoestrap' ),
+ 'section' => $control['section'],
+ 'settings' => $control['setting'],
+ 'type' => 'checkbox',
+ 'priority' => $control['priority'],
+ ));
+ }
+
// Content of the Hero Region
$wp_customize->add_control( new Shoestrap_Customize_Textarea_Control( $wp_customize, 'shoestrap_hero_content', array(
'label' => 'Content',
@@ -149,4 +164,12 @@ function shoestrap_hero_content() {
</div>
<?php }
}
-add_action( 'shoestrap_hero', 'shoestrap_hero_content' );
+add_action( 'shoestrap_hero', 'shoestrap_hero_content' );
+
+function shoestrap_hero_title_fittext_script() {
+ if ( get_theme_mod( 'shoestrap_hero_title_fittext' ) == 1 ) {
+ echo '<style>.hero-title { width: 100%; } </style>';
+ echo '<script>$(".hero-title").fitText();</script>';
+ }
+}
+add_action('wp_footer', 'shoestrap_hero_title_fittext_script', 100);
View
9 lib/scripts.php
@@ -21,6 +21,7 @@ function shoestrap_scripts() {
$no_radius = get_theme_mod( 'shoestrap_general_no_radius' );
$no_gradients = get_theme_mod( 'shoestrap_general_no_gradients' );
$override_js_version = get_option( 'shoestrap_override_js_version' );
+ $hero_title_fittext = get_theme_mod( 'shoestrap_hero_title_fittext' );
if ( $header_scripts == 1 )
$h_f = false;
@@ -64,12 +65,20 @@ function shoestrap_scripts() {
wp_enqueue_script('comment-reply');
}
}
+
+ if ( $hero_title_fittext == 1 ) {
+ wp_register_script('shoestrap_fittext', get_template_directory_uri() . '/assets/js/vendor/jquery.fittext.js', false, null, $h_f);
+ }
wp_register_script('modernizr', get_template_directory_uri() . '/assets/js/vendor/modernizr-2.6.2.min.js', false, null, $h_f);
wp_register_script('shoestrap_main', get_template_directory_uri() . '/assets/js/main.js', false, null, $h_f);
wp_enqueue_script('jquery');
wp_enqueue_script('modernizr');
wp_enqueue_script('shoestrap_main');
+
+ if ( $hero_title_fittext == 1 ) {
+ wp_enqueue_script('shoestrap_fittext');
+ }
}
add_action('wp_enqueue_scripts', 'shoestrap_scripts', 100);
Please sign in to comment.
Something went wrong with that request. Please try again.