var sangarSizeAndScale; ;(function($) { sangarSizeAndScale = function(base, opt) { /** * Function: setupScaleImage */ base.setupScaleImage = function(imageDom) { // set sangarWrapper height // base.$sangarWrapper.height(base.origHeight + base.$pagination.outerHeight(true)); // scaleImage if(opt.scaleImage) { imageDom.each(function(index){ var width = base.sangarWidth; var height = base.getImgHeight(width,index,imageDom.length); var slideHeight = $(this).parent().height(); if(base.origHeight > height) { var curImgWidth = base.getImgWidth(base.origHeight,index,imageDom.length); var curDiffWidth = (curImgWidth - base.sangarWidth) * -1; $(this).css({ 'height': base.origHeight + 'px', 'width': curImgWidth + 'px', 'margin-left': curDiffWidth / 2 + 'px' }) // neutralize $(this).css({ 'margin-top': '' }) } else { var diff = base.origHeight - height; if(opt.imageVerticalAlign == 'top') { $(this).css('margin-top', '0px'); } else if(opt.imageVerticalAlign == 'bottom') { $(this).css('margin-top', diff + 'px'); } else { $(this).css('margin-top', (diff / 2) + 'px'); } $(this).width(width); // neutralize $(this).css({ 'height': 'auto', 'margin-left': '' }) } // width $(this).parent().width(width); }) } else { var padding = 10; var curImgHeight = base.origHeight - (padding * 2); var curParWidth = imageDom.parent().width(); var curParHeight = imageDom.parent().height(); // image imageDom.css({ 'border-radius': '3px' }); // parent imageDom.parent().css({ 'padding': padding + 'px', 'width': (curParWidth - padding * 2) + 'px', 'height': (curParHeight - padding * 2) + 'px' }); // container var contWidth = base.sangarWidth - (padding * 2); var contHeight = base.origHeight - (padding * 2); // horizontal center align imageDom.each(function(index){ var width = base.getImgWidth(curImgHeight,index,imageDom.length); var diff = contWidth - width; if(diff > 0) { $(this).css({ 'margin-left': (diff / 2) + 'px', 'margin-top': '0px', 'height': curImgHeight + 'px' }); } else { var width = base.sangarWidth; var height = base.getImgHeight(width,index,imageDom.length); var diff = contHeight - height; $(this).css({ 'margin-left': '0px', 'margin-top': (diff / 2) + 'px', 'height': height + 'px' }); } }) } } /** * Function: setupScaleIframe */ base.setupScaleIframe = function(iframeDom) { iframeDom.each(function(index){ $(this).width(base.sangarWidth); $(this).height(base.origHeight); }); } } })(jQuery);