File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 4
4
5
5
jQuery ( document ) . ready ( function ( ) {
6
6
7
+
8
+ //todo find a better way to determine width
7
9
jQuery ( 'img.image_autorefresh' ) . width ( jQuery ( '#content' ) . width ( ) ) ;
8
10
11
+ jQuery ( document ) . focus ( function ( ) {
12
+ jQuery ( 'img.image_autorefresh' ) . each ( function ( ) {
13
+ d = new Date ( ) ;
14
+ this . attr ( "src" , this . data ( "src" ) + "?" + d . getTime ( ) ) ;
15
+ } ) ;
16
+
17
+ } ) ;
9
18
10
19
} ) ;
Original file line number Diff line number Diff line change @@ -30,10 +30,13 @@ function image_autorefresh_shortcode($atts){
30
30
<script>
31
31
setInterval(function()
32
32
{
33
- d = new Date();
34
- image = jQuery('img#image_autorefresh_<?php echo $ randomString ?> ');
35
- image.attr("src", image.data("src") + "?" + d.getTime());
33
+ if(document.hasFocus()){
34
+ d = new Date();
35
+ image = jQuery('img#image_autorefresh_<?php echo $ randomString ?> ');
36
+ image.attr("src", image.data("src") + "?" + d.getTime());
37
+ }
36
38
}, <?php echo $ a ['refresh_time ' ]; ?> 000);
39
+
37
40
</script>
38
41
39
42
<div class="<?php echo '' != $ a ['caption ' ] ? 'wp-caption ' : '' ; ?> align<?php echo $ a ['align ' ]; ?> ">
You can’t perform that action at this time.
0 commit comments