1/* 2 * infobar - a vertical scrollbar jQuery plugin 3 * 4 * http://sam3.pl 5 * 6 * Copyright (c) CONCEPT Intermedia 2013 7 * Napisane przez 8 * Maciej Dejewski 9 * 10 * 11 * Version: 2.0.0 Last revised: 09/05/2017 12 * 13 */ 14 15if (typeof globalpause == 'undefined') { 16 globalPause=false; 17} 18 19( function( $ ) { 20 var defaults = { 21 customClass: 'hyper-scroll-1', 22 frameRate: 24, //No of movements per second 23 //speed: 1, //No of pixels per frame 24 speedMultiplier: 20, //used to speed up movement 25 direction: 'left', //'left' or 'right'. 26 directionButtons: true, //display left right / up down direction buttons 27 28 orientation: 'horizontal', //'horizontal or 'vertical' - not to be confused with device orientation 29 auto: true, 30 autoMode: 'loop', //auto = true, 'loop' or 'bounce', 31 manualMode: 'loop', //auto = false, 'loop' or 'end' 32 //direction: 'forwards', //'forwards' or 'backwards'. 33 pauseOnHover: true, //autoMode = loop|bounce only 34 pauseOnTouch: true, //" touch device only 35 pauseButton: false, //" generates an extra element to allow manual pausing 36 startOnLoad: false, //use this to delay starting of plugin until all page assets have loaded 37 // tryb 'fade' 38 //displayMode: 'scroll', // 'scroll' - przesuwania 'fade' - pokazywanie jednego newsa po drugim 39 //fadeTimer: 4000, // czas zmiany newsów w trybie fade 40 fadeSpeed: 300, // czas samego efektu fade 41 fadeScrollBeforeTime: 2000, // czas zanim zbyt dÅugi news zacznie siÄ scrollowac 42 fadeScrollAfterTime: 2000 // czas zanim zbyt dÅugi news zmieni siÄ po zakoÅczeniu scrollu 43 }; 44 45 infobar = function( el, titlesString, linksString, options ) { 46 var focusPause=false; 47 var fadeScrollPause = false; 48 49 var docMouseDown = false; 50 51 var clipWidth = 0; 52 53 // prepare titles 54 var titles = titlesString.split(';'); 55 var links = linksString.split(';'); 56 57 var bar = el; 58 var containerClass = jQuery( el ).attr( 'id' ); 59 60 // create titles containers 61 var clip = null; 62 var $items = null; 63 64 var currentDirection = null; 65 66 //console.info(el);; 67 elId = jQuery(el).attr("id"); 68 elParentId = jQuery(el).parent().attr("id"); 69 70 71 // !!!!!!!!!!!!!!!!!!!!!!! 72 // TODO: nadpisujÄ tu niektóre z opcji . . na etapie przerabiania na js byÅo to konieczne .. można by to poprawiÄ . pewnie potrzebne bÄdzie ujednolicenie wartoÅci z adminem 73 for(var key in defaults) { 74 options[key] = defaults[key]; 75 //console.log(key + ' ' + options[key]); 76 } 77 78 currentDirection = options.direction; 79 currentSpeedMultiplier = options.speedMultiplier; 80 81 82 // create titles containers 83 el.append('<div class="infobar-clip"></div>'); 84 clip = jQuery('.infobar-clip'); 85 86 for (var i=0; i < titles.length; i++) { 87 clip.append('<span class="infobar-news news-'+i+'"><span class="infobar-news-bgd"></span><span class="infobar-title">'+titles[i]+'</span></span>'); 88 // wrap in links if required 89 if ((links[i] !='') && (i<links.length)){ 90 jQuery('.news-'+i).wrap('<a href="'+links[i]+'" title="'+titles[i]+'" class="infobar-news linked">'); 91 } 92 } 93 this.list = clip; //called on ul/ol/div etc 94 $items = this.list.children(); 95 96 jQuery('.infobar-title').css({ 97 background: 'url("'+options.newsPictureURL+'") no-repeat 0 2px' 98 }); 99 100 switch (options.displayMode){ 101 102 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 103 // wersja SCROLL 104 case 'scroll': 105 setWidth = function(){ 106 clipWidth = 0; 107 for (var i=0; i < $items.length; i++) { 108 var thisTitW = jQuery('.infobar-title',$items[i]).innerWidth()+parseInt(jQuery($items[i]).css('margin-right'))+parseInt(jQuery($items[i]).css('margin-left'))+parseInt(jQuery($items[i]).css('padding-right'))+parseInt(jQuery($items[i]).css('padding-left')); 109 var thisAW = jQuery('.infobar-title',$items[i]).parent().innerWidth() + parseInt(jQuery($items[i]).css('margin-right')) + parseInt(jQuery($items[i]).css('margin-left')) + parseInt(jQuery($items[i]).css('padding-right'))+parseInt(j
109Query($items[i]).css('padding-left')); 110 var myW = thisAW; 111 if (thisTitW>myW) myW = thisTitW; 112 clipWidth += myW; 113 thisClipWidth = myW; 114 } 115 clipWidth +=2; 116 clip.css({ 117 width: clipWidth 118 }); 119 listWidth = clipWidth; 120 } 121 setWidth(); 122 123 //generate extra markup 124 this.list.wrap( '<div class="infobar-container">' ); 125 jQuery('.infobar-container').css({ 126 width: 2*clipWidth, 127 //height: el.outerHeight(), 128 position: 'relative' 129 }); 130 131 // sum width of all elements 132 var total = 0; 133 134 $items.each(function() { 135 total += jQuery( this ).outerWidth( true )+1; 136 }); 137 138 this.list.css( { 139 "float": 'left', 140 width: total +50+ 'px' 141 }); 142 143 var isPaused = false; 144 var currentSpeedMultiplier = 0; 145 146 var listWidth = clipWidth; 147 setWidth(); 148 //var containerWidth = this.list.parent().innerWidth(); 149 var containerWidth = el.innerWidth(); 150 151 152 var animationOn = false; 153 154 if ( listWidth > containerWidth ) { 155 animationOn = true; 156 } 157 158 // if animation should be on (list longer then container) 159 if ( animationOn ) { 160 //duplicate list clip 161 this.list.clone( true ).appendTo( this.list.parent() ); 162 163 var listItems = this.list.parent().children(); 164 165 jQuery( listItems[ 0 ] ).addClass( 'element-1' ); 166 jQuery( listItems[ 1 ] ).addClass( 'element-2' ); 167 168 var list2Links = jQuery('a',listItems[1]); 169 for (var i=0;i<list2Links.length;i++){ 170 jQuery(list2Links[i]).attr('tabindex','-1'); 171 } 172 173 // place the second list container 174 if (options.direction == 'left') { 175 jQuery( listItems[ 1 ] ).css({ 176 left: listWidth 177 }); 178 } 179 else if ( options.direction == 'right' ) { 180 jQuery( listItems[ 1 ] ).css( { 181 left: -listWidth 182 } ); 183 } 184 var currentStep = options.speed; 185 //alert( isPaused ); 186 187 setWidth(); 188 189 // start the animation 190 self.interval = setInterval( function() { 191 if ( !isPaused && !focusPause && !globalPause) { 192 currentStep = options.speed + currentSpeedMultiplier; 193 194 // left direction 195 if ( currentDirection == 'left' ) { 196 // move items 197 jQuery( listItems[ 0 ] ).animate( { 198 left: "-=" + currentStep + "px" 199 }, 0 ); 200 jQuery( listItems[ 1 ] ).animate( { 201 left: "-=" + currentStep + "px" 202 }, 0 ); 203 204 205 // reset position 206 if ( parseInt( jQuery( listItems[ 0 ] ).css( 'left' ) ) <= -listWidth ) { 207 jQuery( listItems[ 0 ] ).css( { 208 left: listWidth 209 } ); 210 } 211 if ( parseInt( jQuery( listItems[ 1 ] ).css( 'left' ) ) <= -listWidth ) { 212 jQuery( listItems[ 1 ] ).css( { 213 left: listWidth 214 } ); 215 } 216 } 217 218 // right direction 219 if ( currentDirection == 'right' ) { 220 // move items 221 jQuery( listItems[ 0 ] ).animate( { 222 left: "+=" + currentStep + "px" 223 }, 0 ); 224 jQuery( listItems[ 1 ] ).animate( { 225 left: "+=" + currentStep + "px" 226 }, 0 ); 227 228 // reset position 229 if ( parseInt( jQuery( listItems[ 0 ] ).css( 'left' ) ) >= listWidth ) { 230 jQuery( listItems[ 0 ] ).css( { 231 left: -listWidth 232 } ); 233 } 234 if ( parseInt( jQuery( listItems[ 1 ] ).css( 'left' ) ) >= listWidth ) { 235 jQuery( listItems[ 1 ] ).css( { 236 left: -listWidth 237 } ); 238 } 239 } 240 241 } 242 }, 30 ); 243 } 244 else { 245 jQuery(".banners-container-over", this.list.parent().parent().parent()).css({ 246 'display': 'none' 247 }) 248 249 } 250 // news hover 251 jQuery('.infobar-news.linked').mouseenter(function(){ 252 jQuery('.infobar-news-bgd', this).stop().animate({opacity: 1}, options.hoverSpeed); 253 }); 254 jQuery('.infobar-news.linked').mouseleave(function(){ 255 jQuery('.infobar-news-bgd', this).stop().animate({opacity: 0}, options.hoverSpeed); 256 }); 257 258 // infobar hover 259 jQuery(el).mouseenter( function() { 260 isPaused = true; 261 //jQuery( listItems[ 0 ] ).css( 'left' ); 262 } ); 263 jQuery(el).mouseleave( function() { 264 isPaused = false;
265 } ); 266 267 // navigation arrows 268 jQuery( ".banners-arrow-left", this.list.parent().parent() ).mouseenter( function() { 269 currentSpeedMultiplier = options.speedMultiplier; 270 if ( self.o.direction == 'right' ) { 271 currentDirection = 'left'; 272 } 273 jQuery( this ).stop().animate( { 274 backgroundPosition: "-20px 0px" 275 }, buttonHoverDuration ); 276 } ); 277 jQuery( ".banners-arrow-left", this.list.parent().parent() ).mouseleave( function() { 278 currentSpeedMultiplier = 0; 279 if ( self.o.direction == 'right' ) { 280 currentDirection = 'left'; 281 } 282 jQuery( this ).stop().animate( { 283 backgroundPosition: "0px 0px" 284 }, buttonHoverDuration ); 285 } ); 286 jQuery( ".banners-arrow-right", this.list.parent().parent() ).mouseenter( function() { 287 currentSpeedMultiplier = options.speedMultiplier; 288 if ( self.o.direction == 'left' ) { 289 currentDirection = 'right'; 290 } 291 jQuery( this ).stop().animate( { 292 backgroundPosition: "0px 0px" 293 }, buttonHoverDuration ); 294 } ); 295 jQuery( ".banners-arrow-right", this.list.parent().parent() ).mouseleave( function() { 296 currentSpeedMultiplier = 0; 297 if ( self.o.direction == 'left' ) { 298 currentDirection = 'left'; 299 } 300 jQuery( this ).stop().animate( { 301 backgroundPosition: "-20px 0px" 302 }, buttonHoverDuration ); 303 } ); 304 305 306 jQuery(document).mousedown(function(){docMouseDown = true;}); 307 jQuery(document).mouseup(function(){docMouseDown = false;}); 308 309 310 // focus in 311 jQuery('a',el).focusin(function(){ 312 if (!docMouseDown){ 313 focusPause=true; 314 var mya=jQuery(this); 315 var apleft = jQuery(mya).position().left; 316 var apw = jQuery(mya).outerWidth(true); 317 var conWidth = jQuery(bar).outerWidth(true); 318 var listItem0Left = 0; 319 320 if ((apleft+apw)>conWidth) listItem0Left=conWidth-apleft-apw; 321 322 jQuery( listItems[ 0 ] ).css( { 323 left: listItem0Left 324 }); 325 jQuery( listItems[ 1 ] ).css( { 326 left: listItem0Left+listWidth 327 }); 328 } 329 }); 330 jQuery(el).focusout(function(){ 331 focusPause=false; 332 }); 333 break; 334 335 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 336 // FADE 337 case 'fade': 338 //generate extra markup 339 340 this.list.wrap( '<div class="infobar-container">' ); 341 jQuery('.infobar-container').css({ 342 //height: el.outerHeight(), 343 position: 'relative' 344 }); 345 var ibHeight = jQuery('.infobar-container').height(); 346 jQuery('.infobar-news:not(a>span.infobar-news)').css({ 347 top:ibHeight, 348 position:'absolute' 349 }); 350 351 var news = jQuery('.infobar-news:not(a>span.infobar-news)'); 352 for (var i=0;i<news.length;i++){ 353 jQuery(news[i]).attr('data-id',i); 354 } 355 var totalNews = news.length; 356 var currentNews = 0; 357 var previousNews = 0; 358 359 var fadeInTimeout = null; 360 var fadeScrollBeforeTimeout = null; 361 var fadeScrollAfterTimeout = null; 362 var fsdeScrollInterval = null; 363 var fadeTimerInterval = null; 364 365 // timer 366 function restartFadeTimer(){ 367 clearInterval(fadeTimerInterval); 368 fadeTimerInterval = setInterval( function() { 369 if ( !isPaused && !focusPause && !globalPause && !fadeScrollPause && (totalNews>0)) { 370 previousNews = currentNews; 371 currentNews ++; 372 if (currentNews >= totalNews) currentNews = 0; 373 hideNews(previousNews,options.fadeSpeed); 374 showNews(currentNews,options.fadeSpeed,400); 375 } 376 }, options.fadeTimer ); 377 } 378 restartFadeTimer(); 379 380 function hideNews(i,speed,delay){ 381 //cc('hide'); 382 fadeScrollpause = false; 383 clearTimeout(fadeScrollBeforeTimeout); 384 clearTimeout(fadeScrollAfterTimeout); 385 386 setTimeout (function(){ 387 jQuery('.infobar-news:not(a>span.infobar-news)').stop().animate({top:ibHeight},speed); 388 },delay); 389 } 390 function showNews(i,speed,delay){ 391 //cc('show',i); 392 fadeInTimeout = setTimeout (function(){ 393 jQuery(news[i]).css({left:0}); 394 jQuery(news[i]).delay(delay).stop().animate({top:0},speed); 395 },delay); 396 397 // scroll for this news 398 var $con = jQuery('.infobar-container'); 399 var conW = $con.width(); 400 var nW = jQuery(news[i]).width(); 401 402 if (nW>conW) { 403 fadeScrollPause = true; 404 fadeScrollBeforeTimeout = setTimeout(function(){ 405 currentSpeedMultiplier = 0; 406 currentStep = parseInt(options.speed) + parseInt(currentSpeedMultiplier); 407 408 // move items 409 fadeScrollInterval = setInterval(function(){ 410 411 conW = $con.width(); 412 nW = jQuery(news[i]).width(); 413 414 jQuery( news[ i ] ).animate( { 415 left: "-=" + currentStep + "px" 416 }, 0 ); 417 418 // reset position 419 var right = parseInt( jQuery( news[i] ).css( 'left' ) ) + nW; 420 421 if ( right <= (conW - 50) ) { 422 clearInterval(fadeScrollInterval); 423 fadeScrollAfterTimeout = setTimeout(function(){ 424 previousNews = currentNews; 425 currentNews ++; 426 if (currentNews >= totalNews) currentNews = 0; 427 fadeScrollPause = false;
428 hideNews(previousNews,options.fadeSpeed); 429 showNews(currentNews,options.fadeSpeed,400); 430 },options.fadeScrollAfterTime); 431 432 } 433 },30); 434 435 },options.fadeScrollBeforeTime); 436 } 437 restartFadeTimer(); 438 } 439 440 showNews(currentNews,0); 441 442 // news hover 443 jQuery('.infobar-news.linked').mouseenter(function(){ 444 jQuery('.infobar-news-bgd', this).stop().animate({opacity: 1}, options.hoverSpeed); 445 }); 446 jQuery('.infobar-news.linked').mouseleave(function(){ 447 jQuery('.infobar-news-bgd', this).stop().animate({opacity: 0}, options.hoverSpeed); 448 }); 449 450 // infobar hover 451 jQuery(el).mouseenter( function() { 452 isPaused = true; 453 //jQuery( listItems[ 0 ] ).css( 'left' ); 454 } ); 455 jQuery(el).mouseleave( function() { 456 isPaused = false; 457 restartFadeTimer(); 458 } ); 459 460 jQuery(document).mousedown(function(){docMouseDown = true;}); 461 jQuery(document).mouseup(function(){docMouseDown = false;}); 462 463 // focus in 464 jQuery('a',el).focusin(function(){ 465 jQuery('#infobar_div').scrollTop(0); 466 if (!docMouseDown){ 467 focusPause=true; 468 469 var n=jQuery(this); 470 var id = jQuery(n).attr('data-id'); 471 472 previousNews = currentNews; 473 currentNews = id; 474 clearTimeout(fadeInTimeout); 475 hideNews(previousNews,0); 476 showNews(currentNews,0,0); 477 } 478 }); 479 jQuery(el).focusout(function(){ 480 focusPause=false; 481 }); 482 483 break; 484 } 485 486 // append styles to head 487 function addStyles(){ 488// var css = '#'+elParentId + ' {background: '+ options.backgroundTopColor +'!important;}'; 489 var css = ''; 490// if (options.borderColor != 'null' ) 491// css += '#'+elParentId + ' {border-color: '+options.backgroundTopColor+'!important; }'; 492 if (options.fontHoverBackgroundTopColor != 'null' ) 493 css += '.infobar-container a:hover {background-color: '+options.fontHoverBackgroundTopColor+';}'; 494 if (options.fontColor != 'null' ) 495 css += '.infobar-container .infobar-title {color: '+options.fontColor+';}'; 496 if (options.fontHoverColor != 'null' ) 497 css += '.infobar-container a:hover .infobar-title {color: '+options.fontHoverColor+';}'; 498 499 var head = document.head || document.getElementsByTagName('head')[0], 500 style = document.createElement('style'); 501 502 style.type = 'text/css'; 503 if (style.styleSheet){ 504 style.styleSheet.cssText = css; 505 } else { 506 style.appendChild(document.createTextNode(css)); 507 } 508 509 head.appendChild(style); 510 } //addStyles() 511 512 addStyles(); 513 514 } // infobar() 515})(jQuery,window);
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.