source: extensions/MenuRandomPhoto/mrp.js @ 31892

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

Make sure, MRP only runs if the template was included.

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