Plugin Directory

Changeset 466654

Timestamp:
11/23/2011 06:06:12 PM (13 years ago)
Author:
taylorde
Message:

actually uploading 0.1.3's trunk

Location:
tdd-progress-bar/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • tdd-progress-bar/trunk/css/default.css

    r464667 r466654  
    1818
    1919.red {
    20     background-position-y:0;
     20    background-position0;
    2121    }
    2222
    2323.race .red {
    24     background-position-y:-12px;
     24    background-position-12px;
    2525    }
    2626
    2727.orange {
    28     background-position-y:-50px;
     28    background-position-50px;
    2929    }
    3030
    3131.race .orange {
    32     background-position-y:-62px;
     32    background-position-62px;
    3333    }
    3434
    3535.yellow {
    36     background-position-y:-100px;
     36    background-position-100px;
    3737    }
    3838
    3939.race .yellow {
    40     background-position-y:-112px;
     40    background-position-112px;
    4141    }
    4242
    4343.green {
    44     background-position-y:-150px;
     44    background-position-150px;
    4545    }
    4646
    4747.race .green {
    48     background-position-y:-162px;
     48    background-position-162px;
    4949    }
    5050
    5151.teal {
    52     background-position-y:-200px;
     52    background-position-200px;
    5353    }
    5454
    5555.race .teal {
    56     background-position-y:-212px;
     56    background-position-212px;
    5757    }
    5858
    5959.lightblue {
    60     background-position-y:-250px;
     60    background-position-250px;
    6161    }
    6262
    6363.race .lightblue {
    64     background-position-y:-262px;
     64    background-position-262px;
    6565    }
    6666
    6767.blue {
    68     background-position-y:-300px;
     68    background-position-300px;
    6969    }
    7070
    7171.race .blue {
    72     background-position-y:-312px;
     72    background-position-312px;
    7373    }
    7474
    7575.purple {
    76     background-position-y:-350px;
     76    background-position-350px;
    7777    }
    7878
    7979.race .purple {
    80     background-position-y:-362px;
     80    background-position-362px;
    8181    }
    8282
    8383.fuchsia {
    84     background-position-y:-400px;
     84    background-position-400px;
    8585    }
    8686   
    8787.race .fuchsia {
    88     background-position-y:-415px;
     88    background-position-415px;
    8989    }
    9090
    9191.strawberry {
    92     background-position-y:-450px;
     92    background-position-450px;
    9393    }
    9494   
    9595.race .strawberry {
    96     background-position-y:-415px;
     96    background-position5px;
    9797    }
    9898
  • tdd-progress-bar/trunk/inc/admin.php

    r464689 r466654  
    11<?php
     2
     3
     4
     5
     6
     7
     8
     9
     10
     11
     12
     13
     14
     15
     16
     17
     18
    219/*
    320* Setup custom meta boxes for the tdd_bp custom post type page
    421*/
    522function tdd_pb_metabox_create() {
    6     add_meta_box( 'tdd_pb_meta', 'Progress Bar Options', 'tdd_pb_metabox_display', 'tdd_pb' );
     23    add_meta_box( 'tdd_pb_meta', , 'tdd_pb_metabox_display', 'tdd_pb' );
    724}
    825add_action( 'add_meta_boxes', 'tdd_pb_metabox_create' );
    926
     27
     28
     29
    1030function tdd_pb_metabox_display($post) {
    11 /*
    12         bar specific options:
    13             - color/graphic
    14             - percentage (or API call)
    15 */
    1631    $tdd_pb_color = get_post_meta( $post->ID, '_tdd_pb_color', true );
    1732    $tdd_pb_percentage = get_post_meta( $post->ID, '_tdd_pb_percentage', true );
    18 
    1933?>
    2034
     
    2337            <th scope="row"><label for="td_pb_color">Bar Color</label></th>
    2438            <td><select name="tdd_pb_color">
    25                 <option value="strawberry" <?php selected( $tdd_pb_color, 'strawberry' ); ?>>Strawberry</option>
    26                 <option value="fuchsia" <?php selected( $tdd_pb_color, 'fuchsia' ); ?>>Fuchsia</option>
    27                 <option value="purple" <?php selected( $tdd_pb_color, 'purple' ); ?>>Purple</option>
    28                 <option value="blue" <?php selected( $tdd_pb_color, 'blue' ); ?>>Blue</option>
    29                 <option value="lightblue" <?php selected( $tdd_pb_color, 'lightblue' ); ?>>Light Blue</option>
    30                 <option value="teal" <?php selected( $tdd_pb_color, 'teal' ); ?>>Teal</option>
    31                 <option value="green" <?php selected( $tdd_pb_color, 'green' ); ?>>Green</option>
    32                 <option value="yellow" <?php selected( $tdd_pb_color, 'yellow' ); ?>>Yellow</option>
    33                 <option value="orange" <?php selected( $tdd_pb_color, 'orange' ); ?>>Orange</option>
    34                 <option value="red" <?php selected( $tdd_pb_color, 'red' ); ?>>Red</option>
     39                <?php global $colors; ?>
     40                <?php foreach ($colors as $color=>$label ): ?>
     41                    <option value="<?php echo $color; ?>" <?php selected( $tdd_pb_color, $color ); ?>"><?php echo $label; ?></option>
     42                <?php endforeach; ?>
    3543                </select></td>
    3644        </tr>
     
    4048        </tr>
    4149    </table>
    42 
    43     <p>Example shortcode: <code>[progress id=<?php the_ID(); ?>]</code> </p>
     50    <?php $id = get_the_ID(); ?>
     51    <p><?php _e( "Example shortcode: <code>[progress id={$id}]</code>", 'tdd_pb'); ?> </p>
     52   
     53    <?php echo tdd_pb_get_bars( array(
     54        'ids' => array( get_the_ID() ),
     55        'class' => 'race',
     56    ) );
     57    ?>
     58   
    4459<?php
    4560}
     
    6883    unset($columns['date']);
    6984    return array_merge($columns,
    70               array('percentage' => 'Percentage',
    71                     'color' => 'Color' ,
     85              array('progress_bar' => 'Progress Bar',
    7286                    'shortcode' => 'Shortcode',
    7387                    'date' => __('Date'),
     
    8498   
    8599    switch ( $column ){
    86         case 'color':
    87             echo get_post_meta( $post->ID, '_tdd_pb_color', true );
    88             break;
    89         case 'percentage':
    90             echo get_post_meta( $post->ID, '_tdd_pb_percentage', true ) . '% complete';
     100        case 'progress_bar':
     101            echo tdd_pb_get_bars( array(
     102                'ids' => array( $post->ID ),
     103                'class' => 'race',
     104            ) );
     105
    91106            break;
    92107        case 'shortcode':
    93             echo '<code>[progress id='. $post->ID .']';
     108            echo '<code>[progress id='. $post->ID .']';
    94109            break;
    95110    }
    96111}
    97112add_action( 'manage_posts_custom_column' , 'tdd_pb_custom_columns' );
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
    98225
    99226
     
    107234<div class="wrap">
    108235    <?php screen_icon( 'plugins' ); ?>
    109     <h2>TDD Progress Bars</h2>
     236    <h2></h2>
    110237   
    111238    <form action="options.php" method="post">
    112239    <?php settings_fields( 'tdd_pb_options' ); ?>
    113240    <?php do_settings_sections(  __FILE__ ); ?>
    114     <input name="Submit" type="submit" value="Save Changes" class="button-primary" />
     241    <input name="Submit" type="submit" value="" class="button-primary" />
    115242    </form>
    116243</div>
     
    123250   
    124251    //register Scripts and Styles section & controls
    125     add_settings_section( 'tdd_pb_sas', 'Scripts and Styles', 'tdd_pb_admin_sasheader', __FILE__ );
    126     add_settings_field( 'animate', 'Animate Bars', 'tdd_pb_admin_form_animate', __FILE__ , 'tdd_pb_sas' );
    127     add_settings_field( 'default_css', 'Use Default CSS', 'tdd_pb_admin_form_default_css', __FILE__, 'tdd_pb_sas');
     252    add_settings_section( 'tdd_pb_sas', , 'tdd_pb_admin_sasheader', __FILE__ );
     253    add_settings_field( 'animate', , 'tdd_pb_admin_form_animate', __FILE__ , 'tdd_pb_sas' );
     254    add_settings_field( 'default_css', , 'tdd_pb_admin_form_default_css', __FILE__, 'tdd_pb_sas');
    128255
    129256    //register Percent section & controls
    130     add_settings_section( 'tdd_pb_percent', 'Percentage Displays', 'tdd_pb_admin_percentheader', __FILE__ );
    131     add_settings_field( 'display_percentage', 'Display Percent Complete', 'tdd_pb_admin_form_perecent_display', __FILE__, 'tdd_pb_percent' );
    132     add_settings_field( 'percentage_color', 'Color of Percentage Text', 'tdd_pb_admin_form_percentage_color', __FILE__, 'tdd_pb_percent' );
    133     add_settings_field( 'bar_background_color', 'Color of Bar Background', 'tdd_pb_admin_form_bar_background_color', __FILE__, 'tdd_pb_percent' );
     257    add_settings_section( 'tdd_pb_percent', , 'tdd_pb_admin_percentheader', __FILE__ );
     258    add_settings_field( 'display_percentage', , 'tdd_pb_admin_form_perecent_display', __FILE__, 'tdd_pb_percent' );
     259    add_settings_field( 'percentage_color', , 'tdd_pb_admin_form_percentage_color', __FILE__, 'tdd_pb_percent' );
     260    add_settings_field( 'bar_background_color', , 'tdd_pb_admin_form_bar_background_color', __FILE__, 'tdd_pb_percent' );
    134261
    135262}
     
    138265//Scripts & Styles section header
    139266function tdd_pb_admin_sasheader(){
    140     echo "<p>The following two boxes allow you to stop including the animation javascript and the default CSS on each page load. It's highly suggested that you don't turn off the Default CSS option unless you have a replacement in mind. The Animate Bars option can be turned off freely if you'd prefer the bars didn't have that cool animation (or you want to save HTTP requests).</p>";
     267    ;
    141268}
    142269
     
    145272    $options = get_option('tdd_pb_options');
    146273    $checked = ($options['animate']) ? ' checked="checked" ' : '';
    147     echo "<input name='tdd_pb_options[animate]' id='animate' type='checkbox' ". $checked ."> <br />
    148             <small>This script depends on jQuery, so it will ensure that is loaded as well</small>";
     274    echo "<input name='tdd_pb_options[animate]' id='animate' type='checkbox' ". $checked ."> <br />
     275    ;
    149276}
    150277
     
    159286//Percentage displays section header
    160287function tdd_pb_admin_percentheader(){
    161 echo "<p>By default, the percentage progress is displayed in the bar. This allows you to optionally turn that off and/or set the color of the text</p>";
     288;
    162289}
    163290
     
    173300function tdd_pb_admin_form_percentage_color(){
    174301    $options = get_option('tdd_pb_options');
    175     echo "#<input name='tdd_pb_options[percentage_color]' id='percentage_color' type='text' value='{$options['percentage_color']}' maxlength='6' size='6' />";
     302    ;
    176303}
    177304
  • tdd-progress-bar/trunk/js/animate.js

    r464667 r466654  
    11jQuery(document).ready(function($){
    22
    3     var i = -700;
     3    /* http://keith-wood.name/backgroundPos.html
     4       Background position animation for jQuery v1.0.1.
     5       Written by Keith Wood (kbwood{at}iinet.com.au) November 2010.
     6       Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
     7       MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
     8       Please attribute the author if you use it. */
     9    (function($){var g='bgPos';$.fx.step['backgroundPosition']=$.fx.step['background-position']=function(a){if(!a.set){var b=$(a.elem);var c=b.data(g);b.css('backgroundPosition',c);a.start=parseBackgroundPosition(c);a.end=parseBackgroundPosition($.fn.jquery>='1.6'?a.end:a.options.curAnim['backgroundPosition']||a.options.curAnim['background-position']);for(var i=0;i<a.end.length;i++){if(a.end[i][0]){a.end[i][1]=a.start[i][1]+(a.end[i][0]=='-='?-1:+1)*a.end[i][1]}}a.set=true}$(a.elem).css('background-position',((a.pos*(a.end[0][1]-a.start[0][1])+a.start[0][1])+a.end[0][2])+' '+((a.pos*(a.end[1][1]-a.start[1][1])+a.start[1][1])+a.end[1][2]))};function parseBackgroundPosition(c){var d={center:'50%',left:'0%',right:'100%',top:'0%',bottom:'100%'};var e=c.split(/ /);var f=function(a){var b=(d[e[a]]||e[a]||'50%').match(/^([+-]=)?([+-]?\d+(\.\d*)?)(.*)$/);e[a]=[b[1],parseFloat(b[2]),b[4]||'px']};if(e.length==1&&$.inArray(e[0],['top','bottom'])>-1){e[1]=e[0];e[0]='50%'}f(0);f(1);return e}$.fn.animate=function(e){return function(a,b,c,d){if(a['backgroundPosition']||a['background-position']){this.data(g,this.css('backgroundPosition')||'center')}return e.apply(this,[a,b,c,d])}}($.fn.animate)})(jQuery);
    410
    5     setInterval(function() {
    6    
    7             $('.tdd_pb_bar').animate( {'background-position-x': i}, 18000, 'linear' );
    8             i = i - 700;
    911
    10     } , 1000);
     12    //Width of graphic in pixels. Just to keep things logical.
     13    //Also the amount that it will move every x seconds...
     14    var i = -400;
    1115
    12 });
     16    //for each .tdd_pb_bar, set a function that does this thing...
     17    $('.tdd_pb_bar').each(function(index,value){
     18
     19        //Get the background position (x and y), split into an array
     20        var currbackgroundposn = $(value).css('background-position').split(' ', 2 );
     21        var x = Number(currbackgroundposn[0].split('px',1));
     22        var y = currbackgroundposn[1];
     23
     24        //Run it once to start us off.     
     25        $(value).animate( {'background-position': i + 'px ' + y }, 15000, 'linear' );
     26
     27       
     28        setInterval( function(){
     29
     30            var currbackgroundposn = $(value).css('background-position').split(' ', 2 );
     31            var x = Number(currbackgroundposn[0].split('px',1));
     32
     33            var posn = x+i + 'px ' + y;
     34           
     35            $(value).animate( {'background-position': posn }, 15000, 'linear' );
     36               
     37        }, 15000 );
     38       
     39    }); // .each
     40       
     41
     42}); //doc.ready
  • tdd-progress-bar/trunk/readme.txt

    r464689 r466654  
    55Requires at least: 3.2.1
    66Tested up to: 3.2.1
    7 Stable tag: 0.1.2
     7Stable tag: 0.1.
    88
    99A progress bar plugin solution.
     
    4242== Changelog ==
    4343
    44 = 1.2 =
     44= 0.1.3=
     45* Given the major change to the CSS, the javascript to make things animate also had to change pretty extensively. One side effect is that the animations on a page will eventually slow to a standstill at the rate of about 1-2 pixels every 15 seconds or so. The animation is still a work in progress...
     46* Major bug fixes for the CSS to show up in, well, pretty much everything but Chrome. Didn't realize I was using an unsupported style.
     47* Small CSS fix for the "Strawberry" color - now shows up correctly
     48* Quick Edit mode on the "Manage Progress Bars" page now has the ability to change percentage and bar color. No need to specifically edit the progress bar now.
     49* Added the function tdd_pb_get_bars() function, which could be used in templates, but I'm going to leave undocumented for the moment so If it needs to change, it can. It's mostly designed for internal use.
     50* Added [tdd_pb] as a shortcode alias for [progress]. I think most people will use [progress], but I wanted to use [tdd_pb] since it's all over the code
     51* The Default CSS and Javascript are now added to the progress bar pages in wp-admin.
     52* Progress bars are now displayed in wp-admin on the "Manage Progress Bars" and the "Edit Progress Bar" screens
     53
     54= 0.1.2 =
    4555* Settings page actually works now
    4656* Settings page now references __FILE__ instead of some arbitrary tag.
    4757
    48 = 1.1 =
     58= 1.1 =
    4959* Left some debugging code for the advanced debug bar in the script. Have to remove it to make this thing work.
    5060
     
    5464== Upgrade Notice ==
    5565
    56 = 1.2 =
     66= 0.1.3 =
     67* Major fix for CSS and Javascript. Now works in Firefox (and likely other browsers, but still testing).
     68* Added some features to the "Manage Progress Bars" page
     69* If you use custom CSS (or javascript for that matter), you will need to also include it for use in wp-admin. See admin_enqueue_scripts for examples of how to do this. This is to enable the proper display of progress bars in wp-admin. Alternatively, you could leave the default styles checkbox on (which will enable them for the admin side as well), and remove the action that adds the styles to the public side.
     70
     71= 0.1.2 =
    5772* If you'd like the settings page to work, upgrade.
    5873
    59 = 1.1 =
     74= 1.1 =
    6075* Blocking bugfix. Plugin won't work unless you upgrade
    6176
  • tdd-progress-bar/trunk/tdd-progress-bar.php

    r464751 r466654  
    44Plugin URI: http://github.com/tddewey/tdd-progress
    55Description: Manage and display progress bars
    6 Version: 0.1.2
     6Version: 0.1.
    77Author: Taylor D. Dewey
    88Author URI: http://websitesthatdontsuck.com
     
    3838               
    3939*/
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
    4051$tdd_pb_options = get_option( 'tdd_pb_options');
     52
    4153
    4254/* load some default settings during plugin activation */
     
    6173function tdd_pb_load_styles() {
    6274    wp_enqueue_style( 'tdd_pb_style', plugins_url( 'css/default.css', __FILE__ ), '', '.1' );
     75
    6376}
    6477
    6578if ( $tdd_pb_options['default_css'] ){
    6679    add_action( 'init', 'tdd_pb_load_styles', 99 );
     80
    6781}
    6882
     
    8397if ( $tdd_pb_options['animate'] ){
    8498    add_action( 'init', 'tdd_pb_load_js', 99 );
     99
    85100}
    86101
     
    93108function tdd_pb_register_post_type(){
    94109    $labels = array(
    95         'name' => 'Progress Bars',
    96         'singular_name' => 'Progress Bar',
    97         'add_new' => 'Add New Progress Bar',
    98         'add_new_item' => 'Add New Progress Bar',
    99         'edit_item' => 'Edit Progress Bar',
    100         'new_item' => 'New Progress Bar',
    101         'view_item' => 'View Progress Bar',
    102         'search_items' => 'Search Progress Bars',
    103         'not_found' => 'No Progress Bars Found',
    104         'not_found_in_trash' => 'No Progress Bars Found in the Trash',
     110        'name' => ,
     111        'singular_name' => ,
     112        'add_new' => ,
     113        'add_new_item' => ,
     114        'edit_item' => ,
     115        'new_item' => ,
     116        'view_item' => ,
     117        'search_items' => ,
     118        'not_found' => ,
     119        'not_found_in_trash' => ,
    105120    );
    106121   
     
    140155* [progress ids=1]
    141156* [progress ids=3,4 width='50px']
    142 */
    143 
    144 function tdd_pb_shortcode($args){
    145     $tdd_pb_options = get_option( 'tdd_pb_options');
     157
     158* Also any of the above formats using shortcode [tdd_pb]
     159*/
     160
     161
     162function tdd_pb_shortcode( $args ){
    146163
    147164    $args = shortcode_atts( array(
     
    158175    $idsarr = array_merge($idarr, $idsarr);
    159176   
    160     //Filter the array to ensure we're getting things that look like integers.
    161     $idsarr = array_filter( $idsarr, 'is_numeric' );
    162    
    163     //count if this is a race (more than one progress bar being displayed)
     177    //Request some bars
     178    $return = tdd_pb_get_bars(array(
     179        'ids' => $idsarr,
     180        'width' => $args['width'],
     181        'class' => $args['class'],
     182    ));
     183   
     184    //Return them bars
     185    return $return;
     186}
     187
     188add_shortcode('progress', 'tdd_pb_shortcode' );
     189add_shortcode('tdd_pb', 'tdd_pb_shortcode' );
     190
     191
     192/*
     193* Returns a progress bar container with 1 or more progress bars
     194*
     195* @param    array   $ids            An array of the ids of progress bars to fetch.
     196* @param    str     $width          Width, specified in pixels, percents, em, whatever of the container
     197* @param    str     $class          Any additional CSS classes to add to the global container (can force a race this way)
     198* @param    str     $default_color  If the color of a bar isn't specified, this is the fallback.
     199*/
     200function tdd_pb_get_bars( $args ){
     201    $defaults = array(
     202        'ids' => array(),
     203        'width' => 'auto',
     204        'class' => '',
     205        'default_color' => 'red',
     206        );
     207
     208    $tdd_pb_options = get_option( 'tdd_pb_options');
     209
     210   
     211    //parse incoming arguments against default.
     212    $args = wp_parse_args( $args, $defaults );
     213
     214
     215    //Filter the array to ensure we're getting things that look like integers. Will also filter out blank array items (i.e. '' )
     216    $idsarr = array_filter( $args['ids'], 'is_numeric' );
     217
     218    //count if this is a race (more than one progress bar being displayed. The race format can also be forced by passing "race" in the $class argument)
    164219    $race = ( count( $idsarr ) > 1 ) ? 'race' : '';
    165     //Load up the $return var with our progress bar container
    166     $return = '<div class="tdd_pb_global_container '. $race .' '.$args["class"].'" style="width:'.strip_tags($args["width"]).'">';
     220
     221    //Set up our global container
     222    $return = '<div class="tdd_pb_global_container '.$race.' '.$args['class'].'" style="width:'.strip_tags( $args['width'] ).'">';
     223   
     224    //If there are no ids to display, this is kind of a moot proccess - so let's say so:
     225    if ( count( $idsarr ) <= 0 ){
     226        $return .= '<p>' . __( 'No progress bars were set, so there is nothing to display', 'tdd_pb' ). '</p></div>';
     227        return $return;
     228    }
    167229   
    168230    //Setup a new WP_Query for our progress bars.
     
    174236        'meta_key' => '_tdd_pb_percentage'
    175237    ));
     238
     239
     240
     241
     242
     243
    176244   
    177245    while ( $tdd_pb_query->have_posts() ): $tdd_pb_query->the_post();
     
    179247        $color = strip_tags( get_post_meta( get_the_ID(), '_tdd_pb_color', true ) );
    180248        //if no color, define a default
    181         $color = (!$color) ? 'red' : $color;
     249        $color = (!$color) ? : $color;
    182250        $return .= '<div title="'.get_the_title() .'" class="tdd_pb_bar_container" style="background-color: #'. $tdd_pb_options["bar_background_color"] .'">';
    183251        if ($tdd_pb_options['display_percentage']){
     
    187255   
    188256    endwhile;
    189    
     257
    190258    //Close the progress bar container, and return everything to screen.
    191259    $return .= '</div>';
    192260    return $return;
    193261}
    194 add_shortcode('progress', 'tdd_pb_shortcode' );
Note: See TracChangeset for help on using the changeset viewer.