source: extensions/MenuRandomPhoto/mrp.js

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

Copy/Paste Error

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