1$(document).ready(function() { 2 sam.headerCompetitions.init(); 3}); 4 5sam.headerCompetitions = new function() { 6 var that = this; 7 8 const LI_HEIGHT = 32; 9 10 const OFFSET = 4; 11 12 const MAX_COMPETITIONS = 5; 13 14 var classes = { 15 'cont' : 'js-header-competitions-cont', 16 'exclude' : 'js-header-competition-other', 17 'blocks' : 'js-header-tournaments-cont', 18 'competition': 'js-header-competition-item', 19 'parent' : 'js-header-parent', 20 'tournament' : 'js-header-tournament', 21 'tournaments': 'js-header-tournaments', 22 'rounds' : 'js-header-rounds' 23 }; 24 var selectors = { 25 'cont' : '.' + classes.cont, 26 'exclude' : '.' + classes.exclude, 27 'blocks' : '.' + classes.blocks, 28 'competition': '.' + classes.competition, 29 'parent' : '.' + classes.parent, 30 'tournament' : '.' + classes.tournament, 31 'tournaments': '.' + classes.tournaments, 32 'rounds' : '.' + classes.rounds 33 }; 34 35 this.init = function() { 36 that.competitionsInit(); 37 }; 38 39 this.competitionsInit = function() { 40 var competitions = $(selectors.competition), diff = competitions.length - MAX_COMPETITIONS, 41 shiftIndex = diff >= 0 ? diff + 1 : 0; 42 43 $(competitions).each(function(index) { 44 var cont = $('#' + $(this).data('contId')), 45 side = index >= shiftIndex ? 'left' : 'right'; 46
47 if (!$(this).hasClass(classes.exclude)) { 48 //that.setContHeight(this, cont); 49 //that.setTournamentsPosition(this, cont, side); 50 if (index > competitions.length - 5) { 51 $(cont).css('right', 0); 52 } 53 that.tournamentsInit(this, side); 54 } 55 56 that.setHover(this, cont); 57 58 $(cont).hide(); 59 }); 60 61 $(selectors.cont).each(function() { 62 $(this).css('top', $(this).hasClass('header__competitions-cont--small') ? 60 : 85); 63 }); 64 }; 65 66 this.tournamentsInit = function(el, side) { 67 $(el).find(selectors.blocks).find('> ' + selectors.parent + ', > ' + selectors.tournament).each(function(index) { 68 var isParent = $(this).hasClass(classes.parent); 69 70 if (isParent) { 71 //ÐоÑеÑние ÑÑÑниÑÑ 72 that.setHover(this, $(this).find(selectors.tournaments)); 73 that.childrenInit(this, side, index); 74 } else { 75 //ÐÑÐ°Ð¿Ñ 76 that.setHover(this, $(this).find(selectors.rounds)); 77 that.roundsInit(this, side, index); 78 } 79 }); 80 }; 81 82 this.childrenInit = function(el, side, index) { 83 $(el).find(selectors.tournaments).each(function() { 84 that.setBlockPosition(this, side, index); 85 86 $(el).find(selectors.tournament).each(function(tournamentIndex) { 87 that.setHover(this, $(this).find(selectors.rounds)); 88 that.roundsInit(this, side, tournamentIndex) 89 }); 90 }); 91 92 $(el).find(selectors.tournaments).hide(); 93 }; 94 95 this.roundsInit = function(el, side, index) { 96 $(el).find(selectors.rounds).each(function() { 97 that.setBlockPosition(this, side, index); 98 }); 99 100 $(el).find(selectors.rounds).hide(); 101 }; 102 103 this.setHover = function(hoverEl, toggleEl) { 104 var hoverTimer; 105 $(hoverEl).hover( 106 function() { 107 hoverTimer = setInterval(function() { 108 $(this).addClass('active'); 109 $(toggleEl).show(); 110 clearInterval(hoverTimer); 111 }, 1000); 112 }, 113 function() { 114 clearInterval(hoverTimer); 115 $(this).removeClass('active'); 116 $(toggleEl).hide(); 117 } 118 ); 119 }; 120 121 this.setContHeight = function(el, cont) { 122 var minPositions = 0; 123 $(el).find('ul').each(function() { 124 if (minPositions < $(this).find('> li').length) { 125 minPositions = $(this).find('> li').length; 126 } 127 }); 128 129 var minHeight = minPositions * LI_HEIGHT, padding = parseInt($(cont).css('paddingTop')) + parseInt($(cont).css('paddingBottom')); 130 $(cont).css('height', minHeight + padding); 131 $(el).find('ul').css('height', minHeight); 132 }; 133 134 this.setTournamentsPosition = function(el, cont, side) { 135 var position = $(el).position(), 136 tournaments = $(el).find(selectors.blocks); 137 $(tournaments).addClass(side + '-side').css({'left' : position.left - parseInt($(cont).css('paddingLeft'))}); 138 }; 139 140 this.setBlockPosition = function(el, side, index) { 141 var top = -LI_HEIGHT * (index + 1) - OFFSET, maxLiWidth; 142 if (side == 'left') { 143 maxLiWidth = that.getMaxLiWidth(el); 144 $(el).css('width', maxLiWidth); 145 $(el).css({'left': -maxLiWidth, 'top': top}); 146 } else { 147 maxLiWidth = that.getMaxLiWidth($(el).parent().parent()); 148 $(el).css({'left': maxLiWidth, 'top': top}); 149 } 150 }; 151 152 this.getMaxLiWidth = function(el) { 153 var maxLiWidth = 0; 154 $(el).find('> li > a').each(function() { 155 if (($(this).outerWidth()) > maxLiWidth) { 156 maxLiWidth = $(this).outerWidth(); 157 } 158 }); 159 160 return ++maxLiWidth; 161 }; 162};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.