Changeset 822285
- Timestamp:
- 12/15/2013 06:11:56 AM (12 years ago)
- Location:
- jellyfish-counter-widget
- Files:
-
- 5 added
- 2 edited
-
tags/0.9 (added)
-
tags/0.9/jellyfish-counter-widget.php (added)
-
tags/0.9/js (added)
-
tags/0.9/js/odometer.js (added)
-
tags/0.9/readme.txt (added)
-
trunk/jellyfish-counter-widget.php (modified) (11 diffs)
-
trunk/readme.txt (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
jellyfish-counter-widget/trunk/jellyfish-counter-widget.php
r747009 r822285 52 52 $digit_height = (!empty($instance['digit_height']) ? esc_attr($instance['digit_height']) : '40' ); 53 53 $digit_width = (!empty($instance['digit_width']) ? esc_attr($instance['digit_width']) : '30' ); 54 $digit_padding = ( !empty($instance['digit_padding']) ? esc_attr($instance['digit_padding']) : '0' );55 $digit_bustedness = ( !empty($instance['digit_bustedness']) ? esc_attr($instance['digit_bustedness']) : '2' );54 $digit_padding = (isset($instance['digit_padding']) ? esc_attr($instance['digit_padding']) : '0' ); 55 $digit_bustedness = (isset($instance['digit_bustedness']) ? esc_attr($instance['digit_bustedness']) : '2' ); 56 56 $digit_style = (!empty($instance['digit_style']) ? esc_attr($instance['digit_style']) : 'font-family: Courier New, Courier, monospace; font-weight: 900;' ); 57 $start_value = (!empty($instance['start_value']) ? esc_attr($instance['start_value']) : ' 0' );58 $end_value = ( !empty($instance['end_value']) ? esc_attr($instance['end_value']) : '100' );57 $start_value = (!empty($instance['start_value']) ? esc_attr($instance['start_value']) : '10' ); 58 $end_value = (isset($instance['end_value']) ? esc_attr($instance['end_value']) : '100' ); 59 59 $animate_speed = (!empty($instance['animate_speed']) ? esc_attr($instance['animate_speed']) : '50' ); 60 60 $persist = (!empty($instance['persist']) ? esc_attr($instance['persist']) : 'false' ); 61 $count_down = (!empty($instance['count_down']) ? esc_attr($instance['count_down']) : 'false' ); 61 62 $persist_interval = (!empty($instance['persist_interval']) ? esc_attr($instance['persist_interval']) : '1' ); 62 63 $init_timestamp = (!empty($instance['init_timestamp']) ? esc_attr($instance['init_timestamp']) : time() ); … … 64 65 <p> 65 66 <label for="<?php echo $this->get_field_id('widget_title'); ?>"> 66 <?php echo 'Title:'; ?> 67 <input type="text" 67 <?php echo 'Title:'; ?> 68 <input type="text" 68 69 id="<?php echo $this->get_field_id('widget_title'); ?>" 69 70 name="<?php echo $this->get_field_name('widget_title'); ?>" 70 value="<?php echo $widget_title; ?>" /> 71 value="<?php echo $widget_title; ?>" /> 71 72 </label> 72 73 </p> 73 74 <p> 74 75 <label for="<?php echo $this->get_field_id('show_title'); ?>"> 75 <?php echo 'Show Title'; ?> 76 <?php echo 'Show Title'; ?> 76 77 <select id="<?php echo $this->get_field_id('show_title'); ?>" 77 78 name="<?php echo $this->get_field_name('show_title'); ?>"> … … 87 88 <p> 88 89 <label for="<?php echo $this->get_field_id('start_value'); ?>"> 89 <?php echo 'Start Value:'; ?> 90 <input type="text" 90 <?php echo 'Start Value:'; ?> 91 <input type="text" 91 92 id="<?php echo $this->get_field_id('start_value'); ?>" 92 93 name="<?php echo $this->get_field_name('start_value'); ?>" 93 value="<?php echo $start_value; ?>" /> 94 value="<?php echo $start_value; ?>" /> 94 95 </label> 95 96 </p> 96 97 <p> 97 98 <label for="<?php echo $this->get_field_id('end_value'); ?>"> 98 <?php echo 'End Value:'; ?> 99 <input type="text" 99 <?php echo 'End Value:'; ?> 100 <input type="text" 100 101 id="<?php echo $this->get_field_id('end_value'); ?>" 101 102 name="<?php echo $this->get_field_name('end_value'); ?>" 102 value="<?php echo $end_value; ?>" /> 103 </label> 104 </p> 103 value="<?php echo $end_value; ?>" /> 104 </label> 105 </p> 106 <p> 107 <label for="<?php echo $this->get_field_id('count_down'); ?>"> 108 <?php echo 'Count Direction'; ?> 109 <select id="<?php echo $this->get_field_id('count_down'); ?>" 110 name="<?php echo $this->get_field_name('count_down'); ?>"> 111 <option value="true" 112 <?php selected($count_down, 'true'); ?>> 113 Down</option> 114 <option value="false" 115 <?php selected($count_down, 'false'); ?>> 116 Up</option> 117 </select> 118 </label> 119 </p> 105 120 <p> 106 121 <label for="<?php echo $this->get_field_id('persist'); ?>"> 107 <?php echo 'Continuous Counter'; ?> 122 <?php echo 'Continuous Counter'; ?> 108 123 <select id="<?php echo $this->get_field_id('persist'); ?>" 109 124 name="<?php echo $this->get_field_name('persist'); ?>"> … … 119 134 <p> 120 135 <label for="<?php echo $this->get_field_id('persist_interval'); ?>"> 121 <?php echo 'Continuous Interval (seconds):'; ?> 122 <input type="text" 136 <?php echo 'Continuous Interval (seconds):'; ?> 137 <input type="text" 123 138 id="<?php echo $this->get_field_id('persist_interval'); ?>" 124 139 name="<?php echo $this->get_field_name('persist_interval'); ?>" 125 value="<?php echo $persist_interval; ?>" /> 126 </label> 127 </p> 140 value="<?php echo $persist_interval; ?>" /> 141 </label> 142 </p> 128 143 <p> 129 144 <label for="<?php echo $this->get_field_id('number_of_digits'); ?>"> 130 <?php echo 'Number of Digits:'; ?> 131 <input type="text" 145 <?php echo 'Number of Digits:'; ?> 146 <input type="text" 132 147 id="<?php echo $this->get_field_id('number_of_digits'); ?>" 133 148 name="<?php echo $this->get_field_name('number_of_digits'); ?>" 134 value="<?php echo $number_of_digits; ?>" /> 135 </label> 136 </p> 149 value="<?php echo $number_of_digits; ?>" /> 150 </label> 151 </p> 137 152 <p> 138 153 <label for="<?php echo $this->get_field_id('display_tenths'); ?>"> 139 <?php echo 'Display Tenths'; ?> 154 <?php echo 'Display Tenths'; ?> 140 155 <select id="<?php echo $this->get_field_id('display_tenths'); ?>" 141 156 name="<?php echo $this->get_field_name('display_tenths'); ?>"> … … 151 166 <p> 152 167 <label for="<?php echo $this->get_field_id('animate_speed'); ?>"> 153 <?php echo 'Animation Speed (1-100):'; ?> 154 <input type="text" 168 <?php echo 'Animation Speed (1-100):'; ?> 169 <input type="text" 155 170 id="<?php echo $this->get_field_id('animate_speed'); ?>" 156 171 name="<?php echo $this->get_field_name('animate_speed'); ?>" 157 value="<?php echo $animate_speed; ?>" /> 158 </label> 159 </p> 172 value="<?php echo $animate_speed; ?>" /> 173 </label> 174 </p> 160 175 <p> 161 176 <label for="<?php echo $this->get_field_id('digit_height'); ?>"> 162 <?php echo 'Digit Height:'; ?> 163 <input type="text" 177 <?php echo 'Digit Height:'; ?> 178 <input type="text" 164 179 id="<?php echo $this->get_field_id('digit_height'); ?>" 165 180 name="<?php echo $this->get_field_name('digit_height'); ?>" 166 value="<?php echo $digit_height; ?>" /> 167 </label> 168 </p> 181 value="<?php echo $digit_height; ?>" /> 182 </label> 183 </p> 169 184 <p> 170 185 <label for="<?php echo $this->get_field_id('digit_width'); ?>"> 171 <?php echo 'Digit Width:'; ?> 172 <input type="text" 186 <?php echo 'Digit Width:'; ?> 187 <input type="text" 173 188 id="<?php echo $this->get_field_id('digit_width'); ?>" 174 189 name="<?php echo $this->get_field_name('digit_width'); ?>" 175 value="<?php echo $digit_width; ?>" /> 176 </label> 177 </p> 190 value="<?php echo $digit_width; ?>" /> 191 </label> 192 </p> 178 193 <p> 179 194 <label for="<?php echo $this->get_field_id('digit_padding'); ?>"> 180 <?php echo 'Padding:'; ?> 181 <input type="text" 195 <?php echo 'Padding:'; ?> 196 <input type="text" 182 197 id="<?php echo $this->get_field_id('digit_padding'); ?>" 183 198 name="<?php echo $this->get_field_name('digit_padding'); ?>" 184 value="<?php echo $digit_padding; ?>" /> 185 </label> 186 </p> 199 value="<?php echo $digit_padding; ?>" /> 200 </label> 201 </p> 187 202 <p> 188 203 <label for="<?php echo $this->get_field_id('digit_bustedness'); ?>"> 189 <?php echo 'Bustedness:'; ?> 190 <input type="text" 204 <?php echo 'Bustedness:'; ?> 205 <input type="text" 191 206 id="<?php echo $this->get_field_id('digit_bustedness'); ?>" 192 207 name="<?php echo $this->get_field_name('digit_bustedness'); ?>" 193 value="<?php echo $digit_bustedness; ?>" /> 194 </label> 195 </p> 208 value="<?php echo $digit_bustedness; ?>" /> 209 </label> 210 </p> 196 211 <p> 197 212 <label for="<?php echo $this->get_field_id('digit_style'); ?>"> 198 <?php echo 'Digit Style:'; ?> 199 <input type="text" 213 <?php echo 'Digit Style:'; ?> 214 <input type="text" 200 215 id="<?php echo $this->get_field_id('digit_style'); ?>" 201 216 name="<?php echo $this->get_field_name('digit_style'); ?>" 202 value="<?php echo $digit_style; ?>" /> 217 value="<?php echo $digit_style; ?>" /> 203 218 </label> 204 219 </p> … … 272 287 $instance['persist'] = 273 288 strip_tags($new_instance['persist']); 289 290 $instance['count_down'] = 291 strip_tags($new_instance['count_down']); 274 292 275 293 $instance['display_tenths'] = … … 314 332 esc_attr($instance['init_timestamp']) : 315 333 time() ); 334 // Added in v0.8 335 $count_down = (!empty($instance['count_down']) ? 336 esc_attr($instance['count_down']) : 337 'false' ); 316 338 317 339 if ($persist == 'true') { 318 $start_value = $start_value + round((time() - $init_timestamp) / $persist_interval); 319 if ($start_value > $end_value) { 320 $start_value = $end_value; 340 if ( $count_down == 'true') { 341 $start_value = $start_value - round((time() - $init_timestamp) / $persist_interval); 342 if ($start_value < $end_value) { 343 $start_value = $end_value; 344 } 345 } else { 346 $start_value = $start_value + round((time() - $init_timestamp) / $persist_interval); 347 if ($start_value > $end_value) { 348 $start_value = $end_value; 349 } 321 350 } 322 351 $animate_speed = 100; … … 344 373 var wholeNumber = 0; 345 374 var persist = $persist; 375 var countDown = $count_down; 346 376 var div = document.getElementById('odometer-" . $args['widget_id'] . "'); 347 377 var myOdometer = new Odometer(div, { 348 digits: $number_of_digits, 378 digits: $number_of_digits, 349 379 tenths: $display_tenths, 350 380 digitHeight: $digit_height, … … 354 384 bustedness: $digit_bustedness 355 385 }); 356 357 386 358 387 function updateOdometer() { 359 if (persist == true) { 360 counterNow=counterNow+0.15; 388 if (persist) { 389 if (countDown) { 390 counterNow=counterNow-0.15; 391 } else { 392 counterNow=counterNow+0.15; 393 } 361 394 wholeNumber=wholeNumber+0.15; 362 395 if (wholeNumber >= 1) { 363 396 wholeNumber = 0; 397 counterNow = Math.round(counterNow); 364 398 waitTime = ($persist_interval * 1000); 365 399 } else { … … 367 401 } 368 402 } else { 369 counterNow=counterNow+0.01; 403 if (countDown) { 404 counterNow=counterNow-0.01; 405 } else { 406 counterNow=counterNow+0.01; 407 } 370 408 waitTime = (100 - $animate_speed); 371 409 } 372 if ( counterNow < counterEndValue) {410 if (( !countDown && (counterNow < counterEndValue)) || (countDown && (counterNow > counterEndValue))) { 373 411 myOdometer.set(counterNow); 374 412 window.setTimeout(function() { … … 377 415 } 378 416 } 379 417 380 418 if ( counterEndValue != counterStartValue) { 381 419 myOdometer.set(counterStartValue); -
jellyfish-counter-widget/trunk/readme.txt
r747009 r822285 6 6 Tags: counter, odometer, milometer, animated, widget, totaliser 7 7 Requires at least: 3.0 8 Tested up to: 3. 59 Stable tag: 0. 88 Tested up to: 3.8 9 Stable tag: 0.9 10 10 License: GPLv2 or later 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 15 15 == Description == 16 16 17 This plugin adds a widget to your WordPress web site that displays a static or 18 animated odometer style counter that can display a set value or can animate 17 This plugin adds a widget to your WordPress web site that displays a static or 18 animated odometer style counter that can display a set value or can animate 19 19 between a starting and ending value. The counter can now have a continuous and 20 20 non resetting operation where it increments over time in the background until 21 21 the goal is reached. 22 22 23 The counter can either count upwards or downwards and is suitable for both incrementing 24 totals or countdown situations. 25 23 26 A great visual effect for travel blogs or any website that wants to display a 24 running total of anything. 27 running total of anything. 25 28 26 29 You can have as many counters as you wish, all can have individual settings for 27 30 totals and appearance. 28 31 29 The counters are created via css and javascript and require no external graphics 32 The counters are created via css and javascript and require no external graphics 30 33 files. 31 34 … … 34 37 35 38 You can see a counter in action at http://sharkaroo.net/map 36 Using an animated counter adds visual and narrative impact to an otherwise 39 Using an animated counter adds visual and narrative impact to an otherwise 37 40 static value. 38 41 … … 40 43 http://strawberryjellyfish.com/wordpress-plugin-jellyfish-counter-widget/ 41 44 42 This plugin uses a modified version of a javascript odometer class written by 45 This plugin uses a modified version of a javascript odometer class written by 43 46 Gavin Brock http://gavcode.wordpress.com/2008/04/07/cssjavascript-animated-odometer/ 44 47 … … 46 49 ==Usage== 47 50 48 Add a counter widget to your sidebar and adjust the settings to suit your 51 Add a counter widget to your sidebar and adjust the settings to suit your 49 52 requirements. 50 53 51 54 There are three basic modes of operation: 52 55 53 * Static - If you only give a Start Value and no End Value the counter will display 54 a static number (useful if you just want to show a total and update it manually 56 * Static - If you only give a Start Value and no End Value the counter will display 57 a static number (useful if you just want to show a total and update it manually 55 58 as necessary) 56 59 57 * Animated – If you supply both start value and end value in the widget, when it 58 is displayed the counter will increment upwards until it reaches the end value. 59 Speed of the count is controlled by the Animation Speed option. Note, this counter 60 has no memory, it will reset when a page is reloaded or changed. Good for visual 60 * Animated – If you supply both start value and end value in the widget, when it 61 is displayed the counter will increment upwards until it reaches the end value. 62 Speed of the count is controlled by the Animation Speed option. Note, this counter 63 has no memory, it will reset when a page is reloaded or changed. Good for visual 61 64 effect where start and end values are very close together. 62 65 63 * Continuous – If you want to count over a long period of time and need your 64 counter to continue to count irrespective of page loads then just select the 65 continuous option in the widget. Then select the interval between the counter 66 increments, in seconds. As soon as you save the widget the counter will “start” 67 and will continue to tick away even if nobody is viewing your blog. You can of 68 course still use the start values and end values in this mode however animation 66 * Continuous – If you want to count over a long period of time and need your 67 counter to continue to count irrespective of page loads then just select the 68 continuous option in the widget. Then select the interval between the counter 69 increments, in seconds. As soon as you save the widget the counter will “start” 70 and will continue to tick away even if nobody is viewing your blog. You can of 71 course still use the start values and end values in this mode however animation 69 72 speed and display tenths have no effect. 70 73 … … 74 77 In the "Digit Style" setting you can specify a font or font style, this must be 75 78 valid css values as it it added to the digits css. Note you cannot adjust the size 76 of the font here, that is automatically set from the height/width and padding settings. 79 of the font here, that is automatically set from the height/width and padding settings. 77 80 78 81 … … 80 83 == Installation == 81 84 82 Extract the zip file and just drop the contents in the wp-content/plugins/ 83 directory of your WordPress installation and then activate the Plugin from 84 Plugins page. Go to the widgets admin page to add a counter widget, each widget 85 Extract the zip file and just drop the contents in the wp-content/plugins/ 86 directory of your WordPress installation and then activate the Plugin from 87 Plugins page. Go to the widgets admin page to add a counter widget, each widget 85 88 has it's own settings. 86 89 87 == Frequently Asked Questions == 90 == Frequently Asked Questions == 88 91 89 92 == Changelog == 90 =0.6=91 * initial release92 93 93 =0.8= 94 * by request, added a non resetting continuous counter feature that can increment 94 * 0.9 Added countdown feature. Fixed bug where end value could not be 0 95 96 * 0.8 by request, added a non resetting continuous counter feature that can increment 95 97 every set number of seconds until it reaches its goal 98 99 * 0.6 initial release 96 100 97 101 == Upgrade Notice == 98 102 99 Existing counter widgets may need the animation speed adjusting as the timing 100 method has changed slightly making the counter animate slightly faster on103 Existing counter widgets may need the animation speed adjusting as the timing 104 method has changed slightly since 0.6 making the counter animate slightly faster on 101 105 some browsers. 102 106
Note: See TracChangeset
for help on using the changeset viewer.