Plugin Directory

Changeset 1009887


Ignore:
Timestamp:
10/19/2014 08:10:31 AM (11 years ago)
Author:
toxicToad
Message:

Major rewrite

  • Additional style and Format options
  • Shortcode support, create counters within post content!
  • Abstracted CSS and JavaScript for cleaner markup and easier customisation
  • Access and control counters via JavaScript
Location:
jellyfish-counter-widget/trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • jellyfish-counter-widget/trunk/jellyfish-counter-widget.php

    r829329 r1009887  
    22/*
    33    Plugin Name: Jellyfish Counter Widget
    4     Plugin URI: http://strawberryjellyfish.com/wordpress-plugin-jellyfish-counter-widget/
    5     Description: Creates a widget with an odometer style counter that displays either a static number or animates up to a predefined value.
     4    Plugin URI: http://strawberryjellyfish.com/wordpress-plugins/jellyfish-counter/
     5    Description: Fully configurable static or animated odometer style rotating counters.
    66    Author: Rob Miller
    7     Version: 1.0
     7    Version: 1.3
    88    Author URI: http://strawberryjellyfish.com/
    99*/
     
    2828<?php
    2929
    30 add_action('init', 'jellyfish_cw_action_init');
    31 add_action('widgets_init', 'jellyfish_cw_create_widgets');
     30add_action( 'init', 'jellyfish_cw_action_init' );
     31add_action( 'widgets_init', 'jellyfish_cw_create_widgets' );
    3232
    3333function jellyfish_cw_create_widgets() {
    34     register_widget('Jellyfish_Counter_Widget');
     34    register_widget( 'Jellyfish_Counter_Widget' );
    3535}
    3636
    3737function jellyfish_cw_action_init() {
    38     load_plugin_textdomain('jellyfish_cw', false, dirname(plugin_basename(__FILE__)));
     38    load_plugin_textdomain( 'jellyfish_cw', false, dirname( plugin_basename( __FILE__ ) ) );
     39    wp_register_style( 'jellyfish_cw_css', plugins_url( 'css/jellyfish-counter.css', __FILE__ ) );
     40    wp_register_script( 'jellyfish_cw_odometer', plugins_url( 'js/jellyfish-odometer.js', __FILE__ ), array( 'jquery' ), '', true );
     41    wp_register_script( 'jellyfish_cw_loader', plugins_url( 'js/jellyfish-counter-loader.js', __FILE__ ), array( 'jquery' ), '', true );
     42    // there is no way of knowing if we use a shortcode or not until well after
     43    // the head has rendered which is too late to add css on demand...
     44    // so just have to always enqueue css by default - not ideal 8|
     45    wp_enqueue_style( 'jellyfish_cw_css' );
     46    add_shortcode( 'jellyfish_counter', 'jellyfish_cw_shortcode_handler' );
    3947}
     48
     49function jellyfish_cw_shortcode_handler( $atts, $content = null ) {
     50    global $post;
     51    // merge shortcode args with default values
     52    $a = shortcode_atts(
     53        array(
     54            'id' => time(),
     55            'digits' => 6,
     56            'format' => '',
     57            'tenths' => true,
     58            'digit_height' => 40,
     59            'digit_width' => 30,
     60            'digit_padding' => 0,
     61            'digit_style' => '',
     62            'bustedness' => 2,
     63            'flat' => false,
     64            'speed' => 80,
     65            'start' => 0,
     66            'end' => 0,
     67            'direction' => 'up',
     68            'timestamp' => false,
     69            'interval' => 1
     70        ), $atts );
     71
     72    $element_id = 'jellyfish-counter-shortcode-' . esc_attr( $a['id'] );
     73
     74    if ($a['timestamp']) {
     75        $init_timestamp = strtotime($a['timestamp'], current_time( 'timestamp' ));
     76        if ($init_timestamp) {
     77            if ( $a['direction'] == 'down' ) {
     78                $a['start'] -= round( ( current_time( 'timestamp' ) - $init_timestamp ) / $a['interval'] );
     79                if ( $a['start'] <= $a['end'] ) {
     80                    $a['start'] = $a['end'];
     81                }
     82            } else {
     83                $a['start'] += round( ( current_time( 'timestamp' ) - $init_timestamp ) / $a['interval'] );
     84                if ( $a['start'] >= $a['end'] ) {
     85                    $a['start'] = $a['end'];
     86                }
     87            }
     88        }
     89    } else {
     90        $current_value = $a['start'];
     91    }
     92    wp_enqueue_script( 'jellyfish_cw_odometer' );
     93    wp_enqueue_script( 'jellyfish_cw_loader' );
     94
     95    $counter_html = '
     96        <div id="' . $element_id . '"
     97            class="jellyfish-counter"
     98            data-digits="' . esc_attr( $a['digits'] ) .'"
     99            data-format="' . esc_attr( $a['format'] ) .'"
     100            data-tenths="' . esc_attr( $a['tenths'] ) .'"
     101            data-digit-height="' . esc_attr( $a['digit_height'] ) .'"
     102            data-digit-width="' . esc_attr( $a['digit_width'] ) .'"
     103            data-digit-padding="' . esc_attr( $a['digit_padding'] ) .'"
     104            data-digit-style="' . esc_attr( $a['digit_style'] ) .'"
     105            data-bustedness="' . esc_attr( $a['bustedness'] ) .'"
     106            data-flat="' . esc_attr( $a['flat'] ) .'"
     107            data-wait-time="' .  max( 0, ( 100 - esc_attr( $a['speed'] ) ) ) .'"
     108            data-start-value="' . esc_attr( $a['start'] ) .'"
     109            data-end-value="' . esc_attr( $a['end'] ) .'"
     110            data-direction="' . esc_attr( $a['direction'] ) .'"
     111            data-timestamp="' . esc_attr( $a['timestamp'] ) .'"
     112            data-interval="' . esc_attr( $a['interval'] ) .'">
     113        </div>';
     114    $jellyfish_cw_shortcode_id++;
     115    return $counter_html;
     116}
     117
     118
    40119
    41120// Counter Widget class
     
    44123    function __construct() {
    45124        parent::__construct(
    46                 'counter_widget', 'Counter Widget', array('description' => 'Show an odometer style counter')
     125            'counter_widget', 'Counter Widget', array( 'description' => 'Show an odometer style counter' )
    47126        );
    48127    }
    49128
    50129    // options form
    51     function form($instance) {
     130    function form( $instance ) {
    52131        // Retrieve previous values from instance or set default values if new
    53132        $disable_title = $instance['disable_title'];
    54133        $disable_depth = $instance['disable_depth'];
    55134        $disable_tenths = $instance['disable_tenths'];
    56         $persist = ($instance['persist'] == 'true' || $instance['persist'] == 'on') ? 'on' : null;
     135        $persist = ( $instance['persist'] == 'true' || $instance['persist'] == 'on' ) ? 'on' : null;
    57136        $init_timestamp = $instance['init_timestamp'];
    58137
    59         $start_value = (is_numeric($instance['start_value']) ? $instance['start_value'] : 0 );
    60         $end_value = (is_numeric($instance['end_value']) ? $instance['end_value'] : 100 );
    61         $animate_speed = (is_numeric($instance['animate_speed']) ? $instance['animate_speed'] : 50 );
    62         $direction = (!empty($instance['direction']) ? $instance['direction'] : 'up' );
    63         $persist_interval = (is_numeric($instance['persist_interval']) ? $instance['persist_interval'] : 1 );
    64         $number_of_digits = (is_numeric($instance['number_of_digits']) ? $instance['number_of_digits'] : 5 );
    65         $digit_height = (is_numeric($instance['digit_height']) ? $instance['digit_height'] : 40 );
    66         $digit_width = (is_numeric($instance['digit_width']) ? $instance['digit_width'] : 30 );
    67         $digit_padding = (is_numeric($instance['digit_padding']) ? $instance['digit_padding'] : 0 );
    68         $digit_bustedness = (is_numeric($instance['digit_bustedness']) ? $instance['digit_bustedness'] : 2 );
    69 
    70         $digit_style = (!empty($instance['digit_style']) ? $instance['digit_style'] : 'font-family: Courier New, Courier, monospace; font-weight: 900;' );
    71         $widget_title = (!empty($instance['widget_title']) ? $instance['widget_title'] : 'Counter' );
     138        $start_value = ( is_numeric( $instance['start_value'] ) ? $instance['start_value'] : 0 );
     139        $end_value = ( is_numeric( $instance['end_value'] ) ? $instance['end_value'] : 100 );
     140        $animate_speed = ( is_numeric( $instance['animate_speed'] ) ? $instance['animate_speed'] : 50 );
     141        $direction = ( !empty( $instance['direction'] ) ? $instance['direction'] : 'up' );
     142        $interval = ( is_numeric( $instance['persist_interval'] ) ? $instance['persist_interval'] : 1 );
     143        $number_of_digits = ( is_numeric( $instance['number_of_digits'] ) ? $instance['number_of_digits'] : 5 );
     144        $digit_height = ( is_numeric( $instance['digit_height'] ) ? $instance['digit_height'] : 40 );
     145        $digit_width = ( is_numeric( $instance['digit_width'] ) ? $instance['digit_width'] : 30 );
     146        $digit_padding = ( is_numeric( $instance['digit_padding'] ) ? $instance['digit_padding'] : 0 );
     147        $digit_bustedness = ( is_numeric( $instance['digit_bustedness'] ) ? $instance['digit_bustedness'] : 2 );
     148
     149        $digit_style = ( !empty( $instance['digit_style'] ) ? $instance['digit_style'] : 'font-family: Courier New, Courier, monospace; font-weight: 900;' );
     150        $widget_title = ( !empty( $instance['widget_title'] ) ? $instance['widget_title'] : 'Counter' );
    72151        $before_text = $instance['before_text'];
    73152        $after_text = $instance['after_text'];
     153        $format = $instance['format'];
    74154
    75155        // get the current count of an active continuous counter
    76         if (($persist == 'on') && !empty($init_timestamp)) {
    77             if ( $direction == 'down') {
    78                 $current_value = $start_value - round((time() - $init_timestamp) / $persist_interval);
    79                 if ($current_value < $end_value) {
    80                     $current_value = $end_value;
     156        // set to end value if it's already finished
     157        if ( ( $persist == 'on' ) && !empty( $init_timestamp ) ) {
     158            if ( $direction == 'down' ) {
     159                 $start_value -= round( ( current_time( 'timestamp' ) - $init_timestamp ) / $interval );
     160                if ( $start_value < $end_value ) {
     161                    $start_value = $end_value;
    81162                }
    82             } elseif ( $direction == 'up') {
    83                 $current_value = $start_value + round((time() - $init_timestamp) / $persist_interval);
    84                 if ($current_value > $end_value) {
    85                     $current_value = $end_value;
     163            } elseif ( $direction == 'up' ) {
     164                $start_value += round( ( current_time( 'timestamp' ) - $init_timestamp ) / $interval );
     165                if ( $start_value > $end_value ) {
     166                    $start_value = $end_value;
    86167                }
    87168            }
    88169        }
    89170
    90         ?>
    91         <p>
    92             <label for="<?php echo $this->get_field_id('start_value'); ?>">
    93                 <?php echo _e('Start Value:', 'jellyfish_cw'); ?>
    94                 <input type="text"
    95                        id="<?php echo $this->get_field_id('start_value'); ?>"
    96                        name="<?php echo $this->get_field_name('start_value'); ?>"
    97                        value="<?php echo $start_value; ?>"
    98                        class="widefat"
    99                        />
    100             </label>
    101         <?php if (($persist == 'on') && (isset($current_value))) { ?>
     171?>
     172        <p>
     173            <label for="<?php echo $this->get_field_id( 'start_value' ); ?>">
     174                <?php echo _e( 'Start Value:', 'jellyfish_cw' ); ?>
     175                <input type="text"
     176                    id="<?php echo $this->get_field_id( 'start_value' ); ?>"
     177                    name="<?php echo $this->get_field_name( 'start_value' ); ?>"
     178                    value="<?php echo $start_value; ?>"
     179                    class="widefat"
     180                />
     181            </label>
     182        <?php if ( ( $persist == 'on' ) && ( isset( $current_value ) ) ) { ?>
    102183            <span class="description">
    103                 <?php _e('This counter is active, the current count is', 'jellyfish_cw'); ?> <?php echo $current_value; ?>.
    104                 <?php _e('Changing the start value will restart the counter.', 'jellyfish_cw'); ?>
     184                <?php _e( 'This counter is active, the current count is', 'jellyfish_cw' ); ?> <?php echo $current_value; ?>.
     185                <?php _e( 'Changing the start value will restart the counter.', 'jellyfish_cw' ); ?>
    105186            </span>
    106187        <?php } ?>
    107188        </p>
    108         <p>
    109             <label for="<?php echo $this->get_field_id('end_value'); ?>">
    110                 <?php _e('End Value:', 'jellyfish_cw'); ?>
    111                 <input type="text"
    112                        id="<?php echo $this->get_field_id('end_value'); ?>"
    113                        name="<?php echo $this->get_field_name('end_value'); ?>"
    114                        value="<?php echo $end_value; ?>"
    115                        class="widefat"
    116                        />
    117             </label>
    118         </p>
    119         <p>
    120             <label for="<?php echo $this->get_field_id('direction'); ?>">
    121                 <?php _e('Counter Type:', 'jellyfish_cw'); ?>
    122                 <select id="<?php echo $this->get_field_id('direction'); ?>"
    123                         name="<?php echo $this->get_field_name('direction'); ?>">
     189
     190        <p>
     191            <label for="<?php echo $this->get_field_id( 'end_value' ); ?>">
     192                <?php _e( 'End Value:', 'jellyfish_cw' ); ?>
     193                <input type="text"
     194                    id="<?php echo $this->get_field_id( 'end_value' ); ?>"
     195                    name="<?php echo $this->get_field_name( 'end_value' ); ?>"
     196                    value="<?php echo $end_value; ?>"
     197                    class="widefat"
     198                />
     199            </label>
     200        </p>
     201        <p>
     202            <label for="<?php echo $this->get_field_id( 'direction' ); ?>">
     203                <?php _e( 'Counter Type:', 'jellyfish_cw' ); ?>
     204                <select id="<?php echo $this->get_field_id( 'direction' ); ?>"
     205                    name="<?php echo $this->get_field_name( 'direction' ); ?>">
    124206                    <option value="up"
    125                             <?php selected($direction, 'up'); ?>>
    126                         <?php _e('Count Up', 'jellyfish_cw'); ?></option>
     207                        <?php selected( $direction, 'up' ); ?>>
     208                        <?php _e( 'Count Up', 'jellyfish_cw' ); ?></option>
    127209                    <option value="static"
    128                             <?php selected($direction, 'static'); ?>>
    129                         <?php _e('Static', 'jellyfish_cw'); ?></option>
     210                        <?php selected( $direction, 'static' ); ?>>
     211                        <?php _e( 'Static', 'jellyfish_cw' ); ?></option>
    130212                    <option value="down"
    131                             <?php selected($direction, 'down'); ?>>
    132                         <?php _e('Count Down', 'jellyfish_cw'); ?></option>
     213                        <?php selected( $direction, 'down' ); ?>>
     214                        <?php _e( 'Count Down', 'jellyfish_cw' ); ?></option>
    133215                </select>
    134216            </label>
    135217        </p>
    136218        <p>
    137             <input class="checkbox" type="checkbox" <?php checked( $persist, 'on'); ?>
     219            <input class="checkbox" type="checkbox" <?php checked( $persist, 'on' ); ?>
    138220                id="<?php echo $this->get_field_id( 'persist' ); ?>"
    139                 name="<?php echo $this->get_field_name( 'persist' ); ?>" />
    140 
    141             <label for="<?php echo $this->get_field_id('persist'); ?>">
    142                 <?php _e('Continuous Counter', 'jellyfish_cw'); ?>
     221                name="<?php echo $this->get_field_name( 'persist' ); ?>"
     222            />
     223            <label for="<?php echo $this->get_field_id( 'persist' ); ?>">
     224                <?php _e( 'Continuous Counter', 'jellyfish_cw' ); ?>
    143225            </label>
    144226            <br/>
    145227            <span class="description">
    146                 <?php _e('Counts continuously in the background, starts as soon as this widget is saved.', 'jellyfish_cw'); ?>
     228                <?php _e( 'Counts continuously in the background, starts as soon as this widget is saved.', 'jellyfish_cw' ); ?>
    147229            </span>
    148230        </p>
    149231        <p>
    150             <label for="<?php echo $this->get_field_id('persist_interval'); ?>">
    151                 <?php _e('Continuous Interval:', 'jellyfish_cw'); ?>
    152                 <input type="text"
    153                        id="<?php echo $this->get_field_id('persist_interval'); ?>"
    154                        name="<?php echo $this->get_field_name('persist_interval'); ?>"
    155                        value="<?php echo $persist_interval; ?>"
    156                        size=6
    157                        />
    158                  <?php _e('seconds', 'jellyfish_cw'); ?>
     232            <label for="<?php echo $this->get_field_id( 'persist_interval' ); ?>">
     233                <?php _e( 'Continuous Interval:', 'jellyfish_cw' ); ?>
     234                <input type="text"
     235                    id="<?php echo $this->get_field_id( 'persist_interval' ); ?>"
     236                    name="<?php echo $this->get_field_name( 'persist_interval' ); ?>"
     237                    value="<?php echo $interval; ?>"
     238                    size=6
     239                />
     240                <?php _e( 'seconds', 'jellyfish_cw' ); ?>
    159241            </label>
    160242            <br/>
    161243            <span class="description">
    162                 <?php _e('How often a continuous style counter updates', 'jellyfish_cw'); ?>
     244                <?php _e( 'How often a continuous style counter updates', 'jellyfish_cw' ); ?>
    163245            </span>
    164246        </p>
    165247        <hr>
    166         <h3 class="title"><?php _e('Appearance', 'jellyfish_cw'); ?></h3>
    167         <p>
    168             <label for="<?php echo $this->get_field_id('widget_title'); ?>">
    169                 <?php _e('Widget Title:', 'jellyfish_cw'); ?>
    170                 <input type="text"
    171                        id="<?php echo $this->get_field_id('widget_title'); ?>"
    172                        name="<?php echo $this->get_field_name('widget_title'); ?>"
    173                        value="<?php echo $widget_title; ?>"
    174                        class="widefat"
    175                 />
    176             </label>
    177         </p>
    178         <p>
    179             <input class="checkbox" type="checkbox" <?php checked( $disable_title, 'on'); ?>
     248        <h3 class="title"><?php _e( 'Appearance', 'jellyfish_cw' ); ?></h3>
     249        <p>
     250            <label for="<?php echo $this->get_field_id( 'widget_title' ); ?>">
     251                <?php _e( 'Widget Title:', 'jellyfish_cw' ); ?>
     252                <input type="text"
     253                    id="<?php echo $this->get_field_id( 'widget_title' ); ?>"
     254                    name="<?php echo $this->get_field_name( 'widget_title' ); ?>"
     255                    value="<?php echo $widget_title; ?>"
     256                    class="widefat"
     257                />
     258            </label>
     259        </p>
     260        <p>
     261            <input class="checkbox" type="checkbox" <?php checked( $disable_title, 'on' ); ?>
    180262                id="<?php echo $this->get_field_id( 'disable_title' ); ?>"
    181                 name="<?php echo $this->get_field_name( 'disable_title' ); ?>" />
    182             <label for="<?php echo $this->get_field_id('disable_title'); ?>">
    183                 <?php _e('Hide Title', 'jellyfish_cw'); ?>
    184             </label>
    185         </p>
    186         <p>
    187             <label for="<?php echo $this->get_field_id('before_text'); ?>">
    188                 <?php _e('Text to display before counter:', 'jellyfish_cw'); ?></label>
    189             <textarea id="<?php echo $this->get_field_id('before_text'); ?>" class="widefat" name="<?php echo $this->get_field_name('before_text'); ?>"><?php echo $before_text; ?></textarea>
    190         </p>
    191         <p>
    192             <label for="<?php echo $this->get_field_id('after_text'); ?>">
    193                 <?php _e('Text to display after counter:', 'jellyfish_cw'); ?></label>
    194             <textarea id="<?php echo $this->get_field_id('after_text'); ?>" class="widefat" name="<?php echo $this->get_field_name('after_text'); ?>"><?php echo $after_text; ?></textarea>
    195         </p>
    196         <p>
    197             <label for="<?php echo $this->get_field_id('number_of_digits'); ?>">
    198                 <?php _e('Number of Digits:', 'jellyfish_cw'); ?>
    199                 <input type="text"
    200                        id="<?php echo $this->get_field_id('number_of_digits'); ?>"
    201                        name="<?php echo $this->get_field_name('number_of_digits'); ?>"
    202                        value="<?php echo $number_of_digits; ?>"
    203                        size=3
    204                        />
    205             </label>
    206         </p>
    207         <p>
    208             <input class="checkbox" type="checkbox" <?php checked( $disable_tenths, 'on'); ?>
     263                name="<?php echo $this->get_field_name( 'disable_title' ); ?>"
     264            />
     265            <label for="<?php echo $this->get_field_id( 'disable_title' ); ?>">
     266                <?php _e( 'Hide Title', 'jellyfish_cw' ); ?>
     267            </label>
     268        </p>
     269        <p>
     270            <label for="<?php echo $this->get_field_id( 'before_text' ); ?>">
     271                <?php _e( 'Text to display before counter:', 'jellyfish_cw' ); ?>
     272            </label>
     273            <textarea id="<?php echo $this->get_field_id( 'before_text' ); ?>" class="widefat" name="<?php echo $this->get_field_name( 'before_text' ); ?>"><?php echo $before_text; ?></textarea>
     274        </p>
     275        <p>
     276            <label for="<?php echo $this->get_field_id( 'after_text' ); ?>">
     277                <?php _e( 'Text to display after counter:', 'jellyfish_cw' ); ?>
     278            </label>
     279            <textarea id="<?php echo $this->get_field_id( 'after_text' ); ?>" class="widefat" name="<?php echo $this->get_field_name( 'after_text' ); ?>"><?php echo $after_text; ?></textarea>
     280        </p>
     281        <p>
     282            <label for="<?php echo $this->get_field_id( 'number_of_digits' ); ?>">
     283                <?php _e( 'Number of Digits:', 'jellyfish_cw' ); ?>
     284                <input type="text"
     285                    id="<?php echo $this->get_field_id( 'number_of_digits' ); ?>"
     286                    name="<?php echo $this->get_field_name( 'number_of_digits' ); ?>"
     287                    value="<?php echo $number_of_digits; ?>"
     288                    size=3
     289                />
     290            </label>
     291        </p>
     292        <p>
     293            <label for="<?php echo $this->get_field_id( 'format' ); ?>">
     294                <?php _e( 'Format:', 'jellyfish_cw' ); ?>
     295                <input type="text"
     296                    id="<?php echo $this->get_field_id( 'format' ); ?>"
     297                    name="<?php echo $this->get_field_name( 'format' ); ?>"
     298                    value="<?php echo $format; ?>"
     299                />
     300            </label>
     301            <br/>
     302            <span class="description">
     303                <?php _e( 'Allows a custom format for the counter e.g $00.00. This option with override the Number of Digits option. Any 0 will be replaced with a counter digit, any other characters will be displayed as it is.', 'jellyfish_cw' ); ?>
     304            </span>
     305        </p>
     306        <p>
     307            <input class="checkbox" type="checkbox" <?php checked( $disable_tenths, 'on' ); ?>
    209308                id="<?php echo $this->get_field_id( 'disable_tenths' ); ?>"
    210309                name="<?php echo $this->get_field_name( 'disable_tenths' ); ?>" />
    211             <label for="<?php echo $this->get_field_id('disable_tenths'); ?>">
    212                 <?php _e('Disable Tenths', 'jellyfish_cw'); ?>
    213             </label>
    214         </p>
    215         <p>
    216             <label for="<?php echo $this->get_field_id('animate_speed'); ?>">
    217                 <?php _e('Animation Speed:', 'jellyfish_cw'); ?>
    218                 <input type="text"
    219                        id="<?php echo $this->get_field_id('animate_speed'); ?>"
    220                        name="<?php echo $this->get_field_name('animate_speed'); ?>"
    221                        value="<?php echo $animate_speed; ?>"
    222                        size=3
     310            <label for="<?php echo $this->get_field_id( 'disable_tenths' ); ?>">
     311                <?php _e( 'Disable Tenths', 'jellyfish_cw' ); ?>
     312            </label>
     313        </p>
     314        <p>
     315            <label for="<?php echo $this->get_field_id( 'animate_speed' ); ?>">
     316                <?php _e( 'Animation Speed:', 'jellyfish_cw' ); ?>
     317                <input type="text"
     318                    id="<?php echo $this->get_field_id( 'animate_speed' ); ?>"
     319                    name="<?php echo $this->get_field_name( 'animate_speed' ); ?>"
     320                    value="<?php echo $animate_speed; ?>"
     321                    size=3
    223322                />
    224323            </label>
    225324            <br/>
    226325            <span class="description">
    227                 <?php _e('A value (1-100). Not used for continuous style counters', 'jellyfish_cw'); ?>
     326                <?php _e( 'A value (1-100). Not used for continuous style counters', 'jellyfish_cw' ); ?>
    228327            </span>
    229328        </p>
    230329        <p>
    231             <label for="<?php echo $this->get_field_id('digit_height'); ?>">
    232                 <?php _e('Digit Height:', 'jellyfish_cw'); ?>
    233                 <input type="text"
    234                        id="<?php echo $this->get_field_id('digit_height'); ?>"
    235                        name="<?php echo $this->get_field_name('digit_height'); ?>"
    236                        value="<?php echo $digit_height; ?>"
    237                        size=3
     330            <label for="<?php echo $this->get_field_id( 'digit_height' ); ?>">
     331                <?php _e( 'Digit Height:', 'jellyfish_cw' ); ?>
     332                <input type="text"
     333                    id="<?php echo $this->get_field_id( 'digit_height' ); ?>"
     334                    name="<?php echo $this->get_field_name( 'digit_height' ); ?>"
     335                    value="<?php echo $digit_height; ?>"
     336                    size=3
    238337                />
    239338                <?php echo ' px'; ?>
     
    241340        </p>
    242341        <p>
    243             <label for="<?php echo $this->get_field_id('digit_width'); ?>">
    244                 <?php _e('Digit Width:', 'jellyfish_cw'); ?>
    245                 <input type="text"
    246                        id="<?php echo $this->get_field_id('digit_width'); ?>"
    247                        name="<?php echo $this->get_field_name('digit_width'); ?>"
    248                        value="<?php echo $digit_width; ?>"
    249                        size=3
     342            <label for="<?php echo $this->get_field_id( 'digit_width' ); ?>">
     343                <?php _e( 'Digit Width:', 'jellyfish_cw' ); ?>
     344                <input type="text"
     345                    id="<?php echo $this->get_field_id( 'digit_width' ); ?>"
     346                    name="<?php echo $this->get_field_name( 'digit_width' ); ?>"
     347                    value="<?php echo $digit_width; ?>"
     348                    size=3
    250349                />
    251350                <?php echo ' px'; ?>
     
    253352        </p>
    254353        <p>
    255             <label for="<?php echo $this->get_field_id('digit_padding'); ?>">
    256                 <?php _e('Digit Padding:', 'jellyfish_cw'); ?>
    257                 <input type="text"
    258                        id="<?php echo $this->get_field_id('digit_padding'); ?>"
    259                        name="<?php echo $this->get_field_name('digit_padding'); ?>"
    260                        value="<?php echo $digit_padding; ?>"
    261                        size=3
     354            <label for="<?php echo $this->get_field_id( 'digit_padding' ); ?>">
     355                <?php _e( 'Digit Padding:', 'jellyfish_cw' ); ?>
     356                <input type="text"
     357                    id="<?php echo $this->get_field_id( 'digit_padding' ); ?>"
     358                    name="<?php echo $this->get_field_name( 'digit_padding' ); ?>"
     359                    value="<?php echo $digit_padding; ?>"
     360                    size=3
    262361                />
    263362                <?php echo ' px'; ?>
     
    265364        </p>
    266365        <p>
    267             <input class="checkbox" type="checkbox" <?php checked( $disable_depth, 'on'); ?>
     366            <input class="checkbox" type="checkbox" <?php checked( $disable_depth, 'on' ); ?>
    268367                id="<?php echo $this->get_field_id( 'disable_depth' ); ?>"
    269368                name="<?php echo $this->get_field_name( 'disable_depth' ); ?>" />
    270             <label for="<?php echo $this->get_field_id('disable_depth'); ?>">
    271                 <?php _e('Disable 3D effect', 'jellyfish_cw'); ?>
    272             </label>
    273         </p>
    274         <p>
    275             <label for="<?php echo $this->get_field_id('digit_bustedness'); ?>">
    276                 <?php _e('Bustedness:', 'jellyfish_cw'); ?>
    277                 <input type="text"
    278                        id="<?php echo $this->get_field_id('digit_bustedness'); ?>"
    279                        name="<?php echo $this->get_field_name('digit_bustedness'); ?>"
    280                        value="<?php echo $digit_bustedness; ?>"
    281                        size=3
     369            <label for="<?php echo $this->get_field_id( 'disable_depth' ); ?>">
     370                <?php _e( 'Disable 3D effect', 'jellyfish_cw' ); ?>
     371            </label>
     372        </p>
     373        <p>
     374            <label for="<?php echo $this->get_field_id( 'digit_bustedness' ); ?>">
     375                <?php _e( 'Bustedness:', 'jellyfish_cw' ); ?>
     376                <input type="text"
     377                    id="<?php echo $this->get_field_id( 'digit_bustedness' ); ?>"
     378                    name="<?php echo $this->get_field_name( 'digit_bustedness' ); ?>"
     379                    value="<?php echo $digit_bustedness; ?>"
     380                    size=3
    282381                />
    283382            </label>
     
    286385        </p>
    287386        <p>
    288             <label for="<?php echo $this->get_field_id('digit_style'); ?>">
    289                 <?php _e('Digit Style:', 'jellyfish_cw'); ?>
    290                 <input type="text"
    291                        id="<?php echo $this->get_field_id('digit_style'); ?>"
    292                        name="<?php echo $this->get_field_name('digit_style'); ?>"
    293                        value="<?php echo $digit_style; ?>"
    294                        class="widefat"
     387            <label for="<?php echo $this->get_field_id( 'digit_style' ); ?>">
     388                <?php _e( 'Digit Style:', 'jellyfish_cw' ); ?>
     389                <input type="text"
     390                    id="<?php echo $this->get_field_id( 'digit_style' ); ?>"
     391                    name="<?php echo $this->get_field_name( 'digit_style' ); ?>"
     392                    value="<?php echo $digit_style; ?>"
     393                    class="widefat"
    295394                />
    296395            </label>
    297396            <br/>
    298397            <span class="description">
    299                 <?php _e('CSS entered here will alter the appearance of the digits', 'jellyfish_cw'); ?>
     398                <?php _e( 'CSS entered here will alter the appearance of the digits', 'jellyfish_cw' ); ?>
    300399            </span>
    301400        </p>
     
    303402    }
    304403
    305     function update($new_instance, $old_instance) {
     404    function update( $new_instance, $old_instance ) {
    306405        $instance = $old_instance;
    307406
    308407        // string values
    309         $instance['digit_style'] = sanitize_text_field($new_instance['digit_style']);
    310         $instance['widget_title'] = sanitize_text_field($new_instance['widget_title']);
    311         $instance['before_text'] = sanitize_text_field($new_instance['before_text']);
    312         $instance['after_text'] = sanitize_text_field($new_instance['after_text']);
    313         $instance['direction'] = sanitize_text_field($new_instance['direction']);
     408        $instance['digit_style'] = sanitize_text_field( $new_instance['digit_style'] );
     409        $instance['widget_title'] = sanitize_text_field( $new_instance['widget_title'] );
     410        $instance['before_text'] = sanitize_text_field( $new_instance['before_text'] );
     411        $instance['after_text'] = sanitize_text_field( $new_instance['after_text'] );
     412        $instance['direction'] = sanitize_text_field( $new_instance['direction'] );
     413        $instance['format'] = sanitize_text_field( $new_instance['format'] );
    314414
    315415        // boolean values
     
    320420
    321421        // numeric values
    322         if (is_numeric($new_instance['number_of_digits'])) {
    323             $instance['number_of_digits'] = intval($new_instance['number_of_digits']);
    324         }
    325 
    326         if (is_numeric($new_instance['digit_height'])) {
    327             $instance['digit_height'] = intval($new_instance['digit_height']);
    328         }
    329 
    330         if (is_numeric($new_instance['digit_width'])) {
    331             $instance['digit_width'] = intval($new_instance['digit_width']);
    332         }
    333 
    334         if (is_numeric($new_instance['digit_padding'])) {
    335             $instance['digit_padding'] = intval($new_instance['digit_padding']);
    336         }
    337 
    338         if (is_numeric($new_instance['digit_bustedness'])) {
    339             $instance['digit_bustedness'] = intval($new_instance['digit_bustedness']);
    340         }
    341 
    342         if (is_numeric($new_instance['end_value'])) {
    343             $instance['end_value'] = intval($new_instance['end_value']);
    344         }
    345 
    346         if (is_numeric($new_instance['animate_speed'])) {
    347             $instance['animate_speed'] = min(intval($new_instance['animate_speed']), 100);
    348         }
    349 
    350         if (is_numeric($new_instance['persist_interval'])) {
    351             $instance['persist_interval'] = intval($new_instance['persist_interval']);
    352         }
    353 
    354         if (is_numeric($new_instance['start_value']) && ($new_instance['start_value'] != $instance['start_value'])) {
     422        if ( is_numeric( $new_instance['number_of_digits'] ) ) {
     423            $instance['number_of_digits'] = intval( $new_instance['number_of_digits'] );
     424        }
     425
     426        if ( is_numeric( $new_instance['digit_height'] ) ) {
     427            $instance['digit_height'] = intval( $new_instance['digit_height'] );
     428        }
     429
     430        if ( is_numeric( $new_instance['digit_width'] ) ) {
     431            $instance['digit_width'] = intval( $new_instance['digit_width'] );
     432        }
     433
     434        if ( is_numeric( $new_instance['digit_padding'] ) ) {
     435            $instance['digit_padding'] = intval( $new_instance['digit_padding'] );
     436        }
     437
     438        if ( is_numeric( $new_instance['digit_bustedness'] ) ) {
     439            $instance['digit_bustedness'] = intval( $new_instance['digit_bustedness'] );
     440        }
     441
     442        if ( is_numeric( $new_instance['end_value'] ) ) {
     443            $instance['end_value'] = intval( $new_instance['end_value'] );
     444        }
     445
     446        if ( is_numeric( $new_instance['animate_speed'] ) ) {
     447            $instance['animate_speed'] = min( intval( $new_instance['animate_speed'] ), 100 );
     448        }
     449
     450        if ( is_numeric( $new_instance['persist_interval'] ) ) {
     451            $instance['persist_interval'] = intval( $new_instance['persist_interval'] );
     452        }
     453
     454        if ( is_numeric( $new_instance['start_value'] ) && ( $new_instance['start_value'] != $instance['start_value'] ) ) {
    355455            // start value has changed, time to restart the counter
    356             $instance['init_timestamp'] = time();
     456            $instance['init_timestamp'] = current_time( 'timestamp' );
    357457            $instance['start_value'] = $new_instance['start_value'];
    358458        }
    359459
    360         if (empty($instance['init_timestamp'])) {
    361             $instance['init_timestamp'] = time();
     460        if ( empty( $instance['init_timestamp'] ) ) {
     461            $instance['init_timestamp'] = current_time( 'timestamp' );
    362462        }
    363463        return $instance;
    364464    }
    365465
    366     function widget($args, $instance) {
     466    function widget( $args, $instance ) {
    367467        // queue javascript if widget is used
    368         if (is_active_widget(false, false, $this->id_base))
    369             wp_enqueue_script('odometer', plugins_url('js/odometer.js', __FILE__), array('jquery'), '', true);
    370 
     468        if ( is_active_widget( false, false, $this->id_base ) ) {
     469            wp_enqueue_script( 'jellyfish_cw_odometer' );
     470            wp_enqueue_script( 'jellyfish_cw_loader' );
     471        }
    371472        // Extract members of args array as individual variables
    372         extract($args);
     473        extract( $args );
    373474
    374475        // these options were not in the first release so to play nice
    375476        // we'll add some defaults here to avoid any undefined indexes
    376477
    377         $persist_interval = (isset($instance['persist_interval']) ?
    378                         $instance['persist_interval'] : 1 );
    379 
    380         $init_timestamp = (isset($instance['init_timestamp']) ?
    381                         $instance['init_timestamp'] : time() );
    382         //
    383 
    384         $disable_title = isset($instance['disable_title']) ? 'true' : 'false';
    385         $disable_tenths = isset($instance['disable_tenths']) ? 'true' : 'false';
     478        $interval = ( isset( $instance['persist_interval'] ) ?
     479            $instance['persist_interval'] : 1 );
     480
     481        $init_timestamp = ( isset( $instance['init_timestamp'] ) ?
     482            $instance['init_timestamp'] : current_time( 'timestamp' ) );
     483
     484        $disable_title = isset( $instance['disable_title'] ) ? 'true' : 'false';
     485        $disable_tenths = isset( $instance['disable_tenths'] ) ? 'true' : 'false';
    386486        $tenths = $disable_tenths == 'true' ? 'false' : 'true' ;
    387         $disable_depth = isset($instance['disable_depth']) ? 'true' : 'false';
    388         $persist = isset($instance['persist']) ? 'true' : 'false';
     487        $disable_depth = isset( $instance['disable_depth'] ) ? 'true' : 'false';
     488        $persist = isset( $instance['persist'] ) ? 'true' : 'false';
    389489
    390490        $number_of_digits = $instance['number_of_digits'];
     491        $format = $instance['format'];
    391492        $start_value = $instance['start_value'];
    392493        $end_value = $instance['end_value'];
    393494
    394495        $animate_speed = $instance['animate_speed'];
    395         $wait_time = max(0, (100 - $animate_speed));
     496        $wait_time = max( 0, ( 100 - $animate_speed ) );
    396497
    397498        $digit_height = $instance['digit_height'];
     
    401502        $digit_style = $instance['digit_style'];
    402503        $widget_title = $instance['widget_title'];
    403         $before_text = esc_attr($instance['before_text']);
    404         $after_text = esc_attr($instance['after_text']);
     504        $before_text = esc_attr( $instance['before_text'] );
     505        $after_text = esc_attr( $instance['after_text'] );
    405506        $direction = $instance['direction'];
    406507
    407         if ($persist == 'true') {
    408             // calculate how may 'counts' have passed since initializing the counter widget
    409             // and update the start_value appropriately. If we have already passed the end_value
    410             // then we don't want to continue counting.
    411             if ( $direction == 'down') {
    412                 $start_value = $start_value - round((time() - $init_timestamp) / $persist_interval);
    413                 if ($start_value < $end_value) {
     508        if ( $persist == 'true' ) {
     509            // calculate how may 'counts' have passed since initializing the counter
     510            // widget and update the start_value appropriately. If we have already
     511            // passed the end_value then we don't want to continue counting.
     512            if ( $direction == 'down' ) {
     513                $start_value -= round( ( current_time( 'timestamp' ) - $init_timestamp ) / $interval );
     514                if ( $start_value < $end_value ) {
    414515                    $start_value = $end_value;
    415516                }
    416             } elseif ( $direction == 'up') {
    417                 $start_value = $start_value + round((time() - $init_timestamp) / $persist_interval);
    418                 if ($start_value > $end_value) {
     517            } elseif ( $direction == 'up' ) {
     518                $start_value += round( ( current_time( 'timestamp' ) - $init_timestamp ) / $interval );
     519                if ( $start_value > $end_value ) {
    419520                    $start_value = $end_value;
    420521                }
     
    423524            $tenths = 'false';
    424525        } else {
    425             $persist_interval = 1;
    426         }
    427 
    428         $persist_interval_ms = $persist_interval * 1000;
    429 
    430         if ($direction == 'static') {
     526            $interval = 1;
     527        }
     528
     529        if ( $direction == 'static' ) {
    431530            $end_value = $start_value;
    432531        }
     
    434533        // Begin widget output
    435534        echo $before_widget;
    436         if ($disable_title == 'false') {
     535        if ( $disable_title == 'false' ) {
    437536            echo $before_title;
    438             echo apply_filters('widget_title', $widget_title);
     537            echo apply_filters( 'widget_title', $widget_title );
    439538            echo $after_title;
    440539        }
    441         if ($before_text) {
     540        if ( $before_text ) {
    442541            echo '<div class="odometer-description">';
    443             echo apply_filters('the_content', $before_text);
     542            echo apply_filters( 'widget_content', $before_text );
    444543            echo '</div>';
    445544        }
    446         echo '<div id="odometer-' . $args['widget_id'] . '" class="odometer-widget"></div>';
    447         if ($after_text) {
     545        echo '<div id="odometer-' . $args['widget_id'] . '"
     546                        class="odometer-widget jellyfish-counter"
     547                        data-digits="' . $number_of_digits .'"
     548                        data-format="' . $format .'"
     549                        data-tenths="' . $tenths .'"
     550                        data-digit-height="' . $digit_height .'"
     551                        data-digit-width="' . $digit_width .'"
     552                        data-digit-padding="' . $digit_padding .'"
     553                        data-digit-style="' . $digit_style .'"
     554                        data-bustedness="' . $digit_bustedness .'"
     555                        data-flat="' . $disable_depth .'"
     556                        data-wait-time="' . $wait_time .'"
     557                        data-start-value="' . $start_value .'"
     558                        data-end-value="' . $end_value .'"
     559                        data-direction="' . $direction .'"
     560                        data-timestamp="' . $persist .'"
     561                        data-interval="' . $interval .'">
     562                    </div>';
     563        if ( $after_text ) {
    448564            echo '<div class="odometer-description">';
    449             echo apply_filters('the_content', $after_text);
     565            echo apply_filters( 'widget_content', $after_text );
    450566            echo '</div>';
    451567        }
    452         // output javascript
    453         echo "<script type='text/javascript'>
    454                 jQuery(document).ready(function() {
    455                     var waitTime = $wait_time;
    456                     var counterStartValue = $start_value;
    457                     var counterEndValue = $end_value;
    458                     var counterNow = $start_value;
    459                     var direction = '$direction';
    460                     var wholeNumber = 0;
    461                     var persist = $persist;
    462                     var div = document.getElementById('odometer-" . $args['widget_id'] . "');
    463                     var myOdometer = new Odometer(div, {
    464                         digits: $number_of_digits,
    465                         tenths: $tenths,
    466                         digitHeight: $digit_height,
    467                         digitWidth: $digit_width,
    468                         digitPadding: $digit_padding,
    469                         fontStyle: '$digit_style',
    470                         bustedness: $digit_bustedness,
    471                         disableHighlights: $disable_depth
    472                     });
    473 
    474                     function updateOdometer() {
    475                         if (persist) {
    476                             if (direction =='down') {
    477                                 counterNow=counterNow-0.15;
    478                             } else {
    479                                 counterNow=counterNow+0.15;
    480                             }
    481                             wholeNumber=wholeNumber+0.15;
    482                             if (wholeNumber >= 1) {
    483                                 wholeNumber = 0;
    484                                 counterNow = Math.round(counterNow);
    485                                 waitTime = $persist_interval_ms;
    486                             } else {
    487                                 waitTime = 1;
    488                             }
    489                         } else {
    490                             if (direction =='down') {
    491                                 counterNow=counterNow-0.01;
    492                             } else {
    493                                 counterNow=counterNow+0.01;
    494                             }
    495                         }
    496                         if (( direction !='down' && (counterNow < counterEndValue)) || (direction =='down' && (counterNow > counterEndValue))) {
    497                             myOdometer.set(counterNow);
    498                             window.setTimeout(function() {
    499                                 updateOdometer();
    500                             }, waitTime);
    501                         }
    502                     }
    503 
    504                     if ( counterEndValue != counterStartValue) {
    505                         myOdometer.set(counterStartValue);
    506                         updateOdometer();
    507                     } else {
    508                         myOdometer.set(counterStartValue);
    509                     }
    510                 });
    511             </script>";
    512568        // finish off widget
    513569        echo $after_widget;
    514570    }
    515571}
     572
    516573?>
  • jellyfish-counter-widget/trunk/languages/jellyfish_cw-en_GB.po

    r829329 r1009887  
    33"Project-Id-Version: Jellyfish Counter Widget v1.0\n"
    44"Report-Msgid-Bugs-To: \n"
    5 "POT-Creation-Date: \n"
    6 "PO-Revision-Date: 2013-12-27 03:00:14+0000\n"
     5"POT-Creation-Date: 2014-09-19 19:14+0930\n"
     6"PO-Revision-Date: 2014-09-19 19:15+0930\n"
    77"Last-Translator: Rob Miller <[email protected]>\n"
    88"Language-Team: \n"
     9"Language: en_GB\n"
    910"MIME-Version: 1.0\n"
    1011"Content-Type: text/plain; charset=UTF-8\n"
    1112"Content-Transfer-Encoding: 8bit\n"
    1213"Plural-Forms: nplurals=2; plural=n != 1;\n"
    13 "X-Generator: CSL v1.x\n"
    14 "X-Poedit-Language: English\n"
    15 "X-Poedit-Country: UNITED KINGDOM\n"
     14"X-Generator: Poedit 1.6.3\n"
    1615"X-Poedit-SourceCharset: utf-8\n"
    17 "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
     16"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
     17"_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
    1818"X-Poedit-Basepath: ../\n"
    19 "X-Poedit-Bookmarks: \n"
     19"X-Textdomain-Support: yes\n"
    2020"X-Poedit-SearchPath-0: .\n"
    21 "X-Textdomain-Support: yes"
    2221
    23 #: jellyfish-counter-widget.php:97
    24 #@ jellyfish_cw
     22# @ jellyfish_cw
     23#: jellyfish-counter-widget.php:94
    2524msgid "Start Value:"
    2625msgstr "Start Value:"
    2726
    28 #: jellyfish-counter-widget.php:114
    29 #@ jellyfish_cw
     27# @ jellyfish_cw
     28#: jellyfish-counter-widget.php:104
     29msgid "This counter is active, the current count is"
     30msgstr "This counter is active, the current count is"
     31
     32# @ jellyfish_cw
     33#: jellyfish-counter-widget.php:105
     34msgid "Changing the start value will restart the counter."
     35msgstr "Changing the start value will restart the counter."
     36
     37# @ jellyfish_cw
     38#: jellyfish-counter-widget.php:111
    3039msgid "End Value:"
    3140msgstr "End Value:"
    3241
    33 #: jellyfish-counter-widget.php:125
    34 #@ jellyfish_cw
     42# @ jellyfish_cw
     43#: jellyfish-counter-widget.php:122
    3544msgid "Counter Type:"
    3645msgstr "Counter Type:"
    3746
    38 #: jellyfish-counter-widget.php:130
    39 #@ jellyfish_cw
     47# @ jellyfish_cw
     48#: jellyfish-counter-widget.php:127
    4049msgid "Count Up"
    4150msgstr "Count Up"
    4251
    43 #: jellyfish-counter-widget.php:133
    44 #@ jellyfish_cw
     52# @ jellyfish_cw
     53#: jellyfish-counter-widget.php:130
    4554msgid "Static"
    4655msgstr "Static"
    4756
    48 #: jellyfish-counter-widget.php:136
    49 #@ jellyfish_cw
     57# @ jellyfish_cw
     58#: jellyfish-counter-widget.php:133
    5059msgid "Count Down"
    5160msgstr "Count Down"
    5261
    53 #: jellyfish-counter-widget.php:146
    54 #@ jellyfish_cw
     62# @ jellyfish_cw
     63#: jellyfish-counter-widget.php:143
    5564msgid "Continuous Counter"
    5665msgstr "Continuous Counter"
    5766
    58 #: jellyfish-counter-widget.php:150
    59 #@ jellyfish_cw
    60 msgid "Counts continuously in the background, starts as soon as this widget is saved."
    61 msgstr "Counts continuously in the background, starts as soon as this widget is saved."
     67# @ jellyfish_cw
     68#: jellyfish-counter-widget.php:147
     69msgid ""
     70"Counts continuously in the background, starts as soon as this widget is "
     71"saved."
     72msgstr ""
     73"Counts continuously in the background, starts as soon as this widget is "
     74"saved."
    6275
    63 #: jellyfish-counter-widget.php:155
    64 #@ jellyfish_cw
     76# @ jellyfish_cw
     77#: jellyfish-counter-widget.php:152
    6578msgid "Continuous Interval:"
    6679msgstr "Continuous Interval:"
    6780
    68 #: jellyfish-counter-widget.php:162
    69 #@ jellyfish_cw
     81# @ jellyfish_cw
     82#: jellyfish-counter-widget.php:159
    7083msgid "seconds"
    7184msgstr "seconds"
    7285
    73 #: jellyfish-counter-widget.php:166
    74 #@ jellyfish_cw
     86# @ jellyfish_cw
     87#: jellyfish-counter-widget.php:163
    7588msgid "How often a continuous style counter updates"
    7689msgstr "How often a continuous style counter updates"
    7790
    78 #: jellyfish-counter-widget.php:170
    79 #@ jellyfish_cw
     91# @ jellyfish_cw
     92#: jellyfish-counter-widget.php:167
    8093msgid "Appearance"
    8194msgstr "Appearance"
    8295
    83 #: jellyfish-counter-widget.php:173
    84 #@ jellyfish_cw
     96# @ jellyfish_cw
     97#: jellyfish-counter-widget.php:170
    8598msgid "Widget Title:"
    8699msgstr "Widget Title:"
    87100
    88 #: jellyfish-counter-widget.php:187
    89 #@ jellyfish_cw
     101# @ jellyfish_cw
     102#: jellyfish-counter-widget.php:184
    90103msgid "Hide Title"
    91104msgstr "Hide Title"
    92105
    93 #: jellyfish-counter-widget.php:192
    94 #@ jellyfish_cw
     106# @ jellyfish_cw
     107#: jellyfish-counter-widget.php:189
    95108msgid "Text to display before counter:"
    96109msgstr "Text to display before counter:"
    97110
    98 #: jellyfish-counter-widget.php:200
    99 #@ jellyfish_cw
     111# @ jellyfish_cw
     112#: jellyfish-counter-widget.php:194
    100113msgid "Text to display after counter:"
    101114msgstr "Text to display after counter:"
    102115
    103 #: jellyfish-counter-widget.php:208
    104 #@ jellyfish_cw
     116# @ jellyfish_cw
     117#: jellyfish-counter-widget.php:199
    105118msgid "Number of Digits:"
    106119msgstr "Number of Digits:"
    107120
    108 #: jellyfish-counter-widget.php:222
    109 #@ jellyfish_cw
     121#: jellyfish-counter-widget.php:210
     122msgid "Format:"
     123msgstr "Format:"
     124
     125#: jellyfish-counter-widget.php:219
     126msgid ""
     127"Allows a custom format for the counter e.g $00.00. This option with override "
     128"the Number of Digits option. Any 0 will be replaced with a counter digit, "
     129"any other characters will be displayed as it is."
     130msgstr ""
     131"Allows a custom format for the counter e.g $00.00. This option with override "
     132"the Number of Digits option. Any 0 will be replaced with a counter digit, "
     133"any other characters will be displayed as it is."
     134
     135# @ jellyfish_cw
     136#: jellyfish-counter-widget.php:228
    110137msgid "Disable Tenths"
    111138msgstr "Disable Tenths"
    112139
    113 #: jellyfish-counter-widget.php:227
    114 #@ jellyfish_cw
     140# @ jellyfish_cw
     141#: jellyfish-counter-widget.php:233
    115142msgid "Animation Speed:"
    116143msgstr "Animation Speed:"
    117144
    118 #: jellyfish-counter-widget.php:237
    119 #@ jellyfish_cw
     145# @ jellyfish_cw
     146#: jellyfish-counter-widget.php:243
    120147msgid "A value (1-100). Not used for continuous style counters"
    121148msgstr "A value (1-100). Not used for continuous style counters"
    122149
    123 #: jellyfish-counter-widget.php:242
    124 #@ jellyfish_cw
     150# @ jellyfish_cw
     151#: jellyfish-counter-widget.php:248
    125152msgid "Digit Height:"
    126153msgstr "Digit Height:"
    127154
    128 #: jellyfish-counter-widget.php:254
    129 #@ jellyfish_cw
     155# @ jellyfish_cw
     156#: jellyfish-counter-widget.php:260
    130157msgid "Digit Width:"
    131158msgstr "Digit Width:"
    132159
    133 #: jellyfish-counter-widget.php:266
    134 #@ jellyfish_cw
     160# @ jellyfish_cw
     161#: jellyfish-counter-widget.php:272
    135162msgid "Digit Padding:"
    136163msgstr "Digit Padding:"
    137164
    138 #: jellyfish-counter-widget.php:281
    139 #@ jellyfish_cw
     165# @ jellyfish_cw
     166#: jellyfish-counter-widget.php:287
    140167msgid "Disable 3D effect"
    141168msgstr "Disable 3D effect"
    142169
    143 #: jellyfish-counter-widget.php:286
    144 #@ jellyfish_cw
     170# @ jellyfish_cw
     171#: jellyfish-counter-widget.php:292
    145172msgid "Bustedness:"
    146173msgstr "Bustedness:"
    147174
    148 #: jellyfish-counter-widget.php:299
    149 #@ jellyfish_cw
     175# @ jellyfish_cw
     176#: jellyfish-counter-widget.php:305
    150177msgid "Digit Style:"
    151178msgstr "Digit Style:"
    152179
    153 #: jellyfish-counter-widget.php:309
    154 #@ jellyfish_cw
     180# @ jellyfish_cw
     181#: jellyfish-counter-widget.php:315
    155182msgid "CSS entered here will alter the appearance of the digits"
    156183msgstr "CSS entered here will alter the appearance of the digits"
    157 
    158 #: jellyfish-counter-widget.php:107
    159 #@ jellyfish_cw
    160 msgid "This counter is active, the current count is"
    161 msgstr "This counter is active, the current count is"
    162 
    163 #: jellyfish-counter-widget.php:108
    164 #@ jellyfish_cw
    165 msgid "Changing the start value will restart the counter."
    166 msgstr "Changing the start value will restart the counter."
    167 
  • jellyfish-counter-widget/trunk/readme.txt

    r829329 r1009887  
    33Author URI: http://strawberryjellyfish.com/
    44Donate link: http://strawberryjellyfish.com/donate/
    5 Plugin URI: http://strawberryjellyfish.com/wordpress-plugin-jellyfish-counter-widget/
     5Plugin URI: http://strawberryjellyfish.com/wordpress-plugins/jellyfish-counter/
    66Tags: counter, odometer, milometer, animated, widget, totaliser
    77Requires at least: 3.0
    8 Tested up to: 3.8
    9 Stable tag: 1.0
     8Tested up to: 4.0
     9Stable tag: 1.3
    1010License: GPLv2 or later
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html
    1212
    13 A rotating odometer style counter widget that can display either a static value
    14 or animate to a predefined total. Great for tracking any totals,
    15 not just for counting jellyfish.
     13Show eye catching totals with static or animated counter widgets and shortcodes.
     14Classic retro odometer style or easy customise your own custom look.
    1615
    1716== Description ==
    1817
    19 This plugin allows you to add a widgets to your WordPress web site that can display
    20 a static or animated odometer style counter. The counter can be used as a manually
    21 updated total, an automatic counter updating over time or just as an animated
    22 visual effect.
    23 
    24 The counter can either count upwards or downwards and is suitable for both incrementing
    25 totals or countdown situations.
    26 
    27 A great visual effect for travel blogs or any website that wants to display a
    28 running total of anything.
    29 
    30 You can have as many counters as you wish, all can have individual settings for
    31 totals and appearance.
    32 
    33 The counters are highly configurable through the widget interface and are generated
    34 using CSS and Javascript, requiring no external graphics files.
    35 
    36 
    37 Demo
    38 
    39 You can see a counter in action at http://sharkaroo.net/map
     18The Jellyfish Counter plugin provides a widget and shortcode enabling you to
     19easily add animated counters to your WordPress site.
     20
     21Counters can be used as a manually updated total, an automatic counter that
     22updates over time or just as an animated visual effect. Each counter can count upwards or downwards making them suitable for both incrementing totals or countdown situations. A great visual effect for travel blogs or any website
     23that wants to display a running total or countdown of anything.
     24
     25Jellyfish Counters are highly configurable through the widget interface, and
     26being generated using CSS and JavaScript, they require no external graphics
     27files. You may have as many counters as you wish on a page, all can have
     28individual settings for totals and appearance.
     29
     30New Shortcode support allows you to generate a counter directly within any
     31post or page content making counters no longer limited to your sidebar or
     32other widgetable area.
     33
     34Advanced users will find that Jellyfish Counter objects are fully accessible
     35via JavaScript and may be controlled and reconfigured as desired though your
     36own custom scripting.
     37
     38
     39=Demo=
     40
     41Here's a typical counter in action at http://sharkaroo.net/map
    4042Using an animated counter adds visual and narrative impact to an otherwise
    4143static value.
    4244
    43 Another demo and further information can be found at the plugin website
    44 http://strawberryjellyfish.com/wordpress-plugin-jellyfish-counter-widget/
    45 
    46 This plugin uses a modified version of a javascript odometer class written by
    47 Gavin Brock http://gavcode.wordpress.com/2008/04/07/cssjavascript-animated-odometer/
    48 
    49 
    50 ==Usage==
    51 
    52 Add a counter widget to your sidebar and adjust the settings to suit your
    53 requirements.
    54 
    55 There are three basic modes of operation:
    56 
    57 * Static - If you want the counter to simply display a non animate number just
    58 set a Start Value to the desired number for the counter and set the
    59 Counter Type to 'static'
    60 
    61 * Animated – If you supply both start value and end value in the widget, the counter
    62 will increment upwards or downwards depending on the chosen Counter Type until it
    63 reaches the end value. Speed of the count is controlled by the Animation Speed option.
    64 Note, this counter has no memory, it will reset when a page is reloaded or changed
    65 but it is great for a visual effect where start and end values are very close together.
    66 
    67 * Continuous – If you want to count over a long period of time and need your
    68 counter to continue to count irrespective of page loads then just select the
    69 continuous option in the widget. Then choose the interval between the counter
    70 increments, in seconds. As soon as you save the widget the counter will "start"
    71 and will continue to tick away even if nobody is viewing your blog. Changing the
    72 setting on an active continuous counter will not effect the count value and it will
    73 keep count, if you wish to reset an active continuous counter just change the start value
    74 and save the widget and the counter will restart from the new starting value.
    75 Note: In continuous mode, animation speed and display tenths have no effect.
    76 
    77 The counter is very configurable through the widget panel. You can define the digit
    78 height, width and font as well as animation speed (animated mode only) and "bustedness"
    79 (misalignment of the digits). Additionally, through "Digit Style" setting you can
    80 specify a font, font style, colour, background or any other CSS display properties for
    81 the digits.
    82 Note: you cannot adjust the size of the font here as is automatically calculated from
    83 the height / width and padding settings.
    84 
    85 Need a flat looking counter? "Disable 3D effect" removes the CSS shading effect.
     45Check out the plugin homepage for more demos and further information:
     46http://strawberryjellyfish.com/wordpress-plugins/jellyfish-counter/
    8647
    8748
    8849== Installation ==
    8950
    90 Extract the zip file and just drop the contents in the wp-content/plugins/
    91 directory of your WordPress installation and then activate the Plugin from
    92 Plugins page. Go to the widgets admin page to add a counter widget, each widget
    93 has its own settings.
     51Either install and activate the plugin via your WordPress Admin
     52
     53Or
     54
     55Extract the zip file and just drop the contents in the wp-content/plugins/ directory of your WordPress installation and then activate the Plugin from
     56Plugins page.
     57
     58After activation you'll find a new Counter widget in the widgets panel of
     59your WordPress admin, drag as many counter widgets as you need to your sidebar
     60and other widgetable areas. Each counter widget has it's own settings.
     61
     62You can also use the [jellyfish_counter] shortcode with page or post content
     63to display a counter within your page or post. Shortcode counters can be
     64configured just as much as their widget counterparts. See Usage for details.
     65
     66
     67== Frequently Asked Questions ==
     68
     69
     70== Screenshots ==
    9471
    9572
    9673== Changelog ==
     74
     75= 1.3 =
     76* Shortcodes! You can now show counters directly in the post or page content
     77using the [jellyfish_counter] shortcode.
     78* The Odometer class has been extended further and renamed JellyfishOdometer.
     79* General code cleanups and function / variable renaming
     80* Added completedFunction attribute to jellyfish-odometer.js to allow defining
     81a callback function that will be triggered when the counter completes
     82* Continuous counter timestamps use your blogs local time instead of UTC
     83* Updated Readme
     84
     85= 1.2 =
     86* Another major re-factoring of JavaScript. All counter functions are now part
     87of the odometer class which now takes it's configuration from data attributes
     88on the counter container element. No more inline JavaScript!
     89* Much of the inline CSS has now been abstracted to a base stylesheet making
     90it easier to restyle counters. Individual counter can still be styled through
     91their widgets.
     92
     93= 1.1 =
     94* No longer use widget_content filter instead of the_content filter on widget
     95before/after text
     96* Major reworking of odometer class to incorporate new features
     97* Added format option to allow formatting the counter display to include non
     98counting characters such as prefixes or separators
    9799
    98100= 1.0 =
     
    120122== Upgrade Notice ==
    121123
    122 Existing counters should not be effected by an upgrade but it is always good practice
    123 to backup your database and installation before performing an upgrade.
    124 
    125 After an upgrade visit the widget admin page to check the new options available to your
    126 counters.
     124Existing counters should not be effected by an upgrade but it is always good
     125practice to backup your database and installation before performing an upgrade.
     126
     127After an upgrade visit the widget admin page to check the new options available
     128to your counters.
     129
     130Note:
     131
     132There have been changes in class names after vesrion 1.0, if you have added
     133custom counter styles to your WordPress theme you may need to make minor
     134changes to reflect the new CSS classes applied to counter elements.
     135
     136If you have made any changes to the plugin files they will be lost if you
     137upgrade.
     138
     139
     140
     141==Usage==
     142
     143=Widget=
     144
     145Simply drag a counter widget to your sidebar and adjust the settings to suit
     146your needs.
     147
     148There are three basic modes of operation:
     149
     150* Static - If you want the counter to simply display a non animated number
     151just set a Start Value to the desired number for the counter and set the
     152Counter Type to 'static'
     153
     154* Animated – If you supply both start value and end value in the widget, the
     155counter will increment upwards or downwards depending on the chosen Counter
     156Type until it reaches the end value. Speed of the count is controlled by the
     157Animation Speed option. Note, this counter has no memory, it will reset when a
     158page is reloaded or changed but it is great for a visual effect where start and
     159end values are relatively close together.
     160
     161* Continuous – If you want to count over a long period of time and need your
     162counter to continue to count irrespective of page loads then just select the
     163continuous option in the widget. Then choose the interval between the counter
     164increments, in seconds. As soon as you save the widget the counter will "start"
     165and will continue to tick away even if nobody is viewing your blog. Changing the
     166setting on an active continuous counter will not effect the count value and it
     167will keep count, if you wish to reset an active continuous counter just change
     168the start value and save the widget and the counter will restart from the new
     169starting value.
     170Note: In continuous mode, animation speed and display tenths have no effect.
     171
     172The counters are very configurable through the widget panel. You can define
     173the digit height, width and font as well as animation speed (animated mode only)
     174and "bustedness" (odometer style misalignment of the digits).
     175
     176You can further customise the appearance of an individual counter via the
     177"Digit Style" input that will accept a valid CSS style attributes such as
     178font-family, colour, background etc.
     179
     180Note: the size of the font here as is automatically calculated
     181from the height, width and padding settings.
     182
     183Need a flat looking counter?
     184"Disable 3D effect" removes the CSS shading effect.
     185
     186If you want to display a prefix on the counter or include separating
     187characters, use the Format input. Just enter a string here representing your
     188desired counter appearance, a 0 represents a counter digit, any other
     189character will be displayed as it is. The Format option overrides the number
     190of digits option, if a format string exists then the counter will use the
     191total number of 0 characters as the number of digits.
     192
     193Example Formats:
     194
     195$0.00
     1961,000,000
     1970000 km
     198
     199=Shortcode=
     200
     201You can generate a counter directly within page or post content using the
     202[jellyfish_counter] shortcode. The shortcode accepts a full range of
     203parameters to provide identical functionality to the widget version.
     204
     205The following parameters may be used within a shortcode:
     206
     207* digits : a number, Number of digits in the counter
     208* format : a string,  representing any fancy display format
     209* tenths : true/false, display tenths digit or not
     210* digit_height : number, pixel height of digits
     211* digit_width : number, pixel width of digits
     212* digit_padding : number, pixel padding for digits
     213* digit_style : a string, custom css styles for the digits
     214* bustedness : a number, misalignment of digits
     215* flat : true/false, don't show 3d effect, show 3d effect
     216* speed : a number, 0 - 100, animation speed
     217* start : a number, starting value for the counter
     218* end : a number, ending value for the counter
     219* direction : a, string 'up' or 'down'
     220* interval : The number of seconds between updates of a continuous counter
     221* timestamp : false or a string representing the starting time for the counter
     222
     223If you don't specify a parameter it's default value will be used.
     224
     225Examples:
     226
     227[jellyfish_counter end=100]
     228The above shortcode translates as:
     229Display a counter that animates upwards from 0 to 100
     230
     231[jellyfish_counter start=999 end=0 direction="down"
     232digit_style="background: transparent; color: red;" flat=true;
     233timestamp="2014-09-28 9:20:21" interval=300 ]
     234
     235The above shortcode translates as:
     236Display a counter that starts at 999 and ends at 0, counting downwards.
     237It has red digits on a transparent background with no 3D shading effect.
     238It is a persistent counter that started counting at 9:20:21 on 2014-09-28 and
     239has been decrementing by one every 300 seconds (5 minutes) since then.
     240
     241
     242= Styling =
     243
     244You can modify the appearance of an individual counters text through the
     245widget control panel or through shortcode parameters. This should be
     246sufficient for most uses.
     247
     248However, if you need to globally override the default counter style or make
     249other CSS changes to the counter digits or container, take a look at
     250jellyfish-counter.css for the appropriate class names. You should override
     251this in you theme rather than modifying this css file as any changes made
     252would be lost when the plugin upgrades..
Note: See TracChangeset for help on using the changeset viewer.