Changeset 31892 for extensions


Ignore:
Timestamp:
Oct 1, 2017, 10:24:14 AM (7 years ago)
Author:
romanf
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/MenuRandomPhoto/mrp.js

    r31891 r31892  
    1 $(function() {
    2   $('#imrp_ill0').width(MRP_blockHeight);
    3   $('#imrp_ill0').height(MRP_blockHeight);
     1$(function()
     2{
     3    if (typeof MRP_blockHeight === 'undefined')
     4        return;
    45
     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=======
    515  var randomPict = MRP_Opt['pictures'];
    616  if (randomPict.length > 1 && $("#mbRandomPhoto").length > 0) {
    717    $('#imrp_ill0 a').attr("href", randomPict[0]['link']);
    818    $('#imrp_ill0 img').attr("src", randomPict[0]['thumb']);
     19>>>>>>> .r31891
    920
    10     var nextFaderPos = 1;
    11     var duration = 400;
    12     var pause = false;
     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']);
    1326
    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');
     27        var nextFaderPos = 1;
     28        var duration = 400;
     29        var pause = false;
    1830
    19     $('#imrp_ill0').hover(function() {
    20       pause = true;
    21     },function() {
    22       pause = false;
    23     });
     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');
    2435
    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);
     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            }
    3755        }
    38       }
     56
     57        var rotate = setInterval(doRotate, MRP_delay);
    3958    }
    40 
    41     var rotate = setInterval(doRotate, MRP_delay);
    42   }
    4359});
Note: See TracChangeset for help on using the changeset viewer.