(function($){ $.skebggallery = function(selector, settings){ //-- default settings -------------------------------------- var config = { 'delay' : 2000, // Length between transitions 'fadeSpeed' : 500, // Speed of transition 'autoplay' : 1, // Slideshow starts playing automatically on/off(1/0) 'navigation' : 1, // Gallery navigation on/off(1/0) 'playPause' : 1, // Gallery playPause on/off(1/0) 'thumbnails' : 1, // Gallery thumbnails on/off(1/0) 'fit_always' : 0, // Image will never exceed browser width or height (Ignores min. dimensions) 'fit_landscape' : 0, // Landscape images will not exceed browser width 'fit_portrait' : 0, // Portrait images will not exceed browser height 'min_width' : 0, // Min width allowed (in pixels) 'min_height' : 0, // Min height allowed (in pixels) 'horizontal_center': 1, // Horizontally center background 'vertical_center' : 1, // Vertically center background (in this case must 'bottom_crop'=0) 'bottom_crop' : 0, // Start image cropping from bottom (in this case must 'vertical_center'=0) 'thumb_style' : 'square', // Thumbnails style circle/square (circle/square) 'nav_position' : 'right' // Navigation Position left/right (left/right) }; if ( settings ){$.extend(config, settings);} //-- variables ---------------------------------- var obj = jQuery(selector); var slide = obj.find('.skebg_bg'); var count = slide.length; var controlloop = true; var i = 0; var j; var cycleTimer; var base = this; var subfn = this; var slides = false; var domobj,domobjscroll,dom_thumb,bullet,navObj; var thumb_style,nav_pos; //-- Resize slides ----------------------------- //---------------------------------------------- base.resizeSlideNow = function() { return obj.each(function() { // Resize each image seperately jQuery('img',obj).each(function(){ thisSlide = jQuery(this); var ratio = (thisSlide.height()/thisSlide.width()).toFixed(2); // Define image ratio // Gather browser size var browserwidth = obj.width(), browserheight = obj.height(), offset; /*-----Resize Image-----*/ if (config.fit_always) // Fit always is enabled { thisSlide.addClass('fit_always'); } else { // Normal Resize if ((browserheight <= config.min_height) && (browserwidth <= config.min_width)){ // If window smaller than minimum width and height if ((browserheight/browserwidth) > ratio){ config.fit_landscape && ratio < 1 ? resizeWidth(true) : resizeHeight(true); // If landscapes are set to fit } else { config.fit_portrait && ratio >= 1 ? resizeHeight(true) : resizeWidth(true); // If portraits are set to fit } } else if (browserwidth <= config.min_width){ // If window only smaller than minimum width if ((browserheight/browserwidth) > ratio){ config.fit_landscape && ratio < 1 ? resizeWidth(true) : resizeHeight(); // If landscapes are set to fit } else { config.fit_portrait && ratio >= 1 ? resizeHeight() : resizeWidth(true); // If portraits are set to fit } } else if (browserheight <= config.min_height){ // If window only smaller than minimum height if ((browserheight/browserwidth) > ratio){ config.fit_landscape && ratio < 1 ? resizeWidth() : resizeHeight(true); // If landscapes are set to fit } else { config.fit_portrait && ratio >= 1 ? resizeHeight(true) : resizeWidth(); // If portraits are set to fit } } else {// If larger than minimums if ((browserheight/browserwidth) > ratio){ config.fit_landscape && ratio < 1 ? resizeWidth() : resizeHeight(); // If landscapes are set to fit } else { config.fit_portrait && ratio >= 1 ? resizeHeight() : resizeWidth(); // If portraits are set to fit } } } /*-----End Image Resize-----*/ /*-----Resize Functions-----*/ function resizeWidth(minimum){ if (minimum){ // If minimum height needs to be considered if(thisSlide.width() < browserwidth || thisSlide.width() < config.min_width ){ if (thisSlide.width() * ratio >= config.min_height){ thisSlide.width(config.min_width); thisSlide.height(thisSlide.width() * ratio); }else{ resizeHeight(); } } }else{ if (config.min_height >= browserheight && !config.fit_landscape){ // If minimum height needs to be considered if (browserwidth * ratio >= config.min_height || (browserwidth * ratio >= config.min_height && ratio <= 1)){ // If resizing would push below minimum height or image is a landscape thisSlide.width(browserwidth); thisSlide.height(browserwidth * ratio); } else if (ratio > 1){ // Else the image is portrait thisSlide.height(config.min_height); thisSlide.width(thisSlide.height() / ratio); } else if (thisSlide.width() < browserwidth) { thisSlide.width(browserwidth); thisSlide.height(thisSlide.width() * ratio); } }else{ // Otherwise, resize as normal thisSlide.width(browserwidth); thisSlide.height(browserwidth * ratio); } } }; function resizeHeight(minimum){ if (minimum){ // If minimum height needs to be considered if(thisSlide.height() < browserheight){ if (thisSlide.height() / ratio >= config.min_width){ thisSlide.height(config.min_height); thisSlide.width(thisSlide.height() / ratio); }else{ resizeWidth(true); } } }else{ // Otherwise, resized as normal if (config.min_width >= browserwidth){ // If minimum width needs to be considered if (browserheight / ratio >= config.min_width || ratio > 1){ // If resizing would push below minimum width or image is a portrait thisSlide.height(browserheight); thisSlide.width(browserheight / ratio); } else if (ratio <= 1){ // Else the image is landscape thisSlide.width(config.min_width); thisSlide.height(thisSlide.width() * ratio); } }else{ // Otherwise, resize as normal thisSlide.height(browserheight); thisSlide.width(browserheight / ratio); } } }; /*-----End Resize Functions-----*/ // Horizontally Center if (config.horizontal_center && !config.fit_always){ jQuery(this).css('left', (browserwidth - jQuery(this).width())/2); } // Vertically Center if (config.vertical_center && !config.fit_always){ jQuery(this).css('top', (browserheight - jQuery(this).height())/2); } // Crop start from bottom if (config.bottom_crop && !config.fit_always){ jQuery(this).css('bottom','0'); jQuery(this).css('top','auto'); } }); return false; }); }; //-------- end resizing slide functions ------- //-- call window resizing function ------------ //--------------------------------------------- if (!config.fit_always){ jQuery(window).resize(function(){ base.resizeSlideNow(); }); } jQuery('html').resize(function(eventObj) { //alert('xcvzxc'); base.resizeSlideNow(); }); //-- check and build the gallery elements ----- //--------------------------------------------- base.buildgallery = function() { jQuery('body').append('