source: extensions/MenuRandomPhoto/mrp.js @ 31780

Last change on this file since 31780 was 31780, checked in by romanf, 7 years ago

Fixes and UI change to show delay in s instead of ms

  • Property svn:executable set to *
File size: 1.3 KB
Line 
1$(function() {
2  $('#imrp_ill0').width(MRP_blockHeight);
3  $('#imrp_ill0').height(MRP_blockHeight);
4
5  var randomPict = MRP_Opt['pictures'];
6  if (randomPict.length > 1) {
7    $('#imrp_ill0 a').attr("href", randomPict[0]['link']);
8    $('#imrp_ill0 img').attr("src", randomPict[0]['thumb']);
9
10    var nextFaderPos = 1;
11    var duration = 400;
12    var pause = false;
13
14    $('#imrp_ill0 img').after('<img id="irmbRPicImg">');
15    $('#imrp_ill0 img').eq(1).hide();
16    $('#imrp_ill0 img')[1].src = randomPict[1]['thumb'];
17    $('#imrp_ill0 img').css('position', 'absolute');
18
19    $('#imrp_ill0').hover(function() {
20      pause = true;
21    },function() {
22      pause = false;
23    });
24
25    function doRotate() {
26      if ($('#imrp_ill0 img')[1].complete) {
27        if(!pause) {
28          $('#imrp_ill0 img').first().fadeOut(duration, function() {
29            nextFaderPos = (nextFaderPos + 1) % randomPict.length;
30            $('#imrp_ill0 img')[1].src = randomPict[nextFaderPos]['thumb'];
31          });
32          $('#imrp_ill0 img').first().insertAfter($('#imrp_ill0 img').eq(1)); // swap
33          $('#imrp_ill0 img').first().fadeIn(duration);
34          setTimeout(function() {
35            $('#imrp_ill0 a').attr("href", randomPict[nextFaderPos]['link']);
36          }, duration/3);
37        }
38      }
39    }
40
41    var rotate = setInterval(doRotate, MRP_delay);
42  }
43});
Note: See TracBrowser for help on using the repository browser.