(function($) { $.fn.hoverscroll = function(params) { if (!params) { params = {}; } params = $.extend({}, $.fn.hoverscroll.params, params); this.each(function() { var $this = $(this); if (params.debug) { $.log('[HoverScroll] Trying to create hoverscroll on element ' + this.tagName + '#' + this.id); } $this.addClass('list'); var listctnr = $this.parent(); var ctnr = listctnr.parent(); if (params.arrows) { if (!params.vertical) { } else { listctnr.append('
').append('
') } } ctnr.width(params.width).height(params.height); listctnr.width(params.width).height(params.height); var size = 0; if (!params.vertical) { $this.children().each(function() { if ($(this).outerWidth) { size += $(this).outerWidth(true); } else { size += $(this).width() + parseInt($(this).css('padding-left')) + parseInt($(this).css('padding-right')) + parseInt($(this).css('margin-left')) + parseInt($(this).css('margin-right')); } }); $this.width(size); if (params.debug) { $.log('[HoverScroll] Computed content width : ' + size + 'px'); } if (ctnr.outerWidth) { size = ctnr.outerWidth(); } else { size = ctnr.width() + parseInt(ctnr.css('padding-left')) + parseInt(ctnr.css('padding-right')) + parseInt(ctnr.css('margin-left')) + parseInt(ctnr.css('margin-right')); } if (params.debug) { $.log('[HoverScroll] Computed container width : ' + size + 'px'); } } else { ctnr.addClass('vertical'); $this.children().each(function() { $(this).addClass('thumbItem') if ($(this).outerHeight) { size += $(this).outerHeight(true); } else { size += $(this).height() + parseInt($(this).css('padding-top')) + parseInt($(this).css('padding-bottom')) + parseInt($(this).css('margin-bottom')) + parseInt($(this).css('margin-bottom')); } }); // Apply computed height to listcontainer $this.height(size); if (params.debug) { $.log('[HoverScroll] Computed content height : ' + size + 'px'); } if (ctnr.outerHeight) { size = ctnr.outerHeight(); } else { size = ctnr.height() + parseInt(ctnr.css('padding-top')) + parseInt(ctnr.css('padding-bottom')) + parseInt(ctnr.css('margin-top')) + parseInt(ctnr.css('margin-bottom')); } if (params.debug) { $.log('[HoverScroll] Computed container height : ' + size + 'px'); } } var zone = { 1: { action: 'move', from: 0, to: 0.06 * size, direction: -1 , speed: 8 }, 2: { action: 'move', from: 0.06 * size, to: 0.15 * size, direction: -1 , speed: 4 }, 3: { action: 'move', from: 0.15 * size, to: 0.25 * size, direction: -1 , speed: 2 }, 4: { action: 'move', from: 0.25 * size, to: 0.4 * size, direction: -1 , speed: 1 }, 5: { action: 'stop', from: 0.4 * size, to: 0.6 * size }, 6: { action: 'move', from: 0.6 * size, to: 0.75 * size, direction: 1 , speed: 1 }, 7: { action: 'move', from: 0.75 * size, to: 0.85 * size, direction: 1 , speed: 2 }, 8: { action: 'move', from: 0.85 * size, to: 0.94 * size, direction: 1 , speed: 4 }, 9: { action: 'move', from: 0.94 * size, to: size, direction: 1 , speed: 8 } } ctnr[0].isChanging = false; ctnr[0].direction = 0; ctnr[0].speed = 1; function checkMouse(x, y) { x = x - ctnr.offset().left; y = y - ctnr.offset().top; var pos; if (!params.vertical) { pos = x; } else { pos = y; } for (i in zone) { if (pos >= zone[i].from && pos < zone[i].to) { if (zone[i].action == 'move') { startMoving(zone[i].direction, zone[i].speed); } else { stopMoving(); } } } } function setArrowOpacity() { if (!params.arrows) { return; } var maxScroll; var scroll; if (!params.vertical) { maxScroll = listctnr[0].scrollWidth - listctnr.width(); scroll = listctnr[0].scrollLeft; } else { maxScroll = listctnr[0].scrollHeight - listctnr.height(); scroll = listctnr[0].scrollTop; } var opacity = (scroll / maxScroll)+0.5; var limit = params.arrowsOpacity; var done = false; if (opacity <= 0) { $('div.arrow.left, div.arrow.top', ctnr).hide(); done = true; } if (maxScroll <= 0) { done = true; } $('div.arrow.left, div.arrow.top', ctnr).show().css('opacity', (opacity > limit ? limit : opacity)); $('div.arrow.right, div.arrow.bottom', ctnr).show().css('opacity', (1.95 - opacity > limit ? limit : 1.95 - opacity)); } function startMoving(direction, speed) { if (ctnr[0].direction != direction) { if (params.debug) { $.log('[HoverScroll] Starting to move. direction: ' + direction + ', speed: ' + speed); } stopMoving(); ctnr[0].direction = direction; ctnr[0].isChanging = true; move(); } if (ctnr[0].speed != speed) { if (params.debug) { $.log('[HoverScroll] Changed speed: ' + speed); } ctnr[0].speed = speed; } } function stopMoving() { if (ctnr[0].isChanging) { if (params.debug) { $.log('[HoverScroll] Stoped moving'); } ctnr[0].isChanging = false; ctnr[0].direction = 0; ctnr[0].speed = 1; clearTimeout(ctnr[0].timer); } } function move() { if (ctnr[0].isChanging == false) { return; } setArrowOpacity(); var scrollSide; if (!params.vertical) { scrollSide = 'scrollLeft'; } else { scrollSide = 'scrollTop'; } listctnr[0][scrollSide] += ctnr[0].direction * ctnr[0].speed; ctnr[0].timer = setTimeout(function() { move(); }, 50); } ctnr .mousemove(function(e) { checkMouse(e.pageX, e.pageY); }) .bind('mouseleave', function() { stopMoving(); }); if (params.arrows) { setArrowOpacity(); } else { $('.arrowleft, .arrowright, .arrowtop, .arrowbottom', ctnr).hide(); } }); return this; }; if (!$.fn.offset) { $.fn.offset = function() { this.left = this.top = 0; if (this[0] && this[0].offsetParent) { var obj = this[0]; do { this.left += obj.offsetLeft; this.top += obj.offsetTop; } while (obj = obj.offsetParent); } return this; } } $.fn.hoverscroll.params = { vertical: false, width: 300, height: 50, arrows: true, arrowsOpacity: 0.95, debug: false }; $.log = function(msg) { if (console && console.log) { console.log(msg); } }; })(jQuery); //end hoverscroll.js $(function() { var parLink; if($(".thumb-gallery").length > 0) { $(".thumb-gallery a").fancybox(); $(".thumb-gallery img").mouseover(function(e){ parLink = $(this).parent(); var offset = $(this).offset(); var newSrc = $(this).attr('src'); var newAlt = $(this).attr('title'); $(this).clone().appendTo('#thumb-preview'); $('#thumb-preview') .css("top", (offset.top-14) + "px") .css("left", (offset.left-15) + "px") .show(); //.fadeIn("fast"); $('#thumb-preview').click(function(e){ parLink.trigger('click'); }); $('#thumb-preview').mouseout(function(e){ $(this).empty(); $(this).hide(); }); }); } if($(".thumb-gallery2").length > 0) { $('
').appendTo('body'); $(".thumb-gallery2 a").fancybox(); $(".thumb-gallery2 img").mouseover(function(e){ parLink = $(this).parent(); var offset = $(this).offset(); var newSrc = $(this).attr('src'); var newAlt = $(this).attr('title'); $(this).clone().appendTo('#thumb-preview'); $('#thumb-preview') .css("top", (offset.top-14) + "px") .css("left", (offset.left-15) + "px") .show(); $('#thumb-preview').click(function(e){ parLink.trigger('click'); }); $('#thumb-preview').mouseout(function(e){ $(this).empty(); $(this).hide(); }); }); } /* if($("ul.my-list-2").length > 0) { $('ul.my-list-2').each(function() { var thisName = this.id.substring('list-'.length); //$(this).hoverscroll({width:300}); $(this).hoverscroll(); $(this).children('li').click(function() { var photoNumber = this.id.substring('thumb-'.length); $('a[rel=fancy-'+thisName+']').each(function() { //remove child image if has if ( $(this).children().size() > 0 ) { //$(this).empty(); var oldImage = $(this).children(":first"); var newImgSrc = $('#link-'+photoNumber).attr('href'); var newImgAlt = $('#thumb-'+photoNumber).children('img:first-child').attr('title'); //Classes for vertical or horizontal dimensions var newImgClass = $('#thumb-'+photoNumber).attr('class'); var newImage = $('').attr({'src': newImgSrc, 'class':newImgClass, 'alt':newImgAlt, 'style':'display:none;'}); $(oldImage).fadeOut('fast', function() { if($(oldImage).remove()){ $('#link-'+photoNumber).append(newImage); $('#link-'+photoNumber+" img:first").fadeIn('fast'); } }) } }); }); }); }*/ /* if($("ul.my-list").length > 0) { $('ul.my-list').each(function() { var thisName = this.id.substring('list-'.length); $(this).hoverscroll({width:200}); $(this).children('li').click(function() { var photoNumber = this.id.substring('thumb-'.length); var newImgSrc = '/userfiles/files/o-kompanii/images/avia/'+photoNumber+'.jpg'; var newImgTitle = $('#thumb-'+photoNumber).children(":first").attr('title'); var newImage2 = $('').attr({'src': newImgSrc, 'width': 240, 'height':180, 'alt':newImgTitle, 'title':newImgTitle, 'style':'display:none;'}); $('#'+thisName+'-div').children(":first").fadeOut('fast', function() { if($('#'+thisName+'-div').empty()){//delete image from previous link $('#'+thisName+'-div').append(newImage2); $('#'+thisName+'-div').children(":first").fadeIn('fast'); } }) }); }); }*/ //$("div.item a").fancybox(); //$('h1:first').remove(); if($('#office-links-div')) { $('#office-links-div').replaceWith('' ); } if($('#staff-links-div')) { $('#staff-links-div').replaceWith(''); } if($("a.anchor-arrow, a.anchor").length > 0) { $('a.anchor-arrow, a.anchor').bind("click", jump); } });