⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imagebox_new.js

📁 ajax源码
💻 JS
📖 第 1 页 / 共 2 页
字号:
		outerContainer = document.createElement('div');		jQuery(outerContainer)			.attr('id', 'ImageBoxOuterContainer')			.css(				{					display		: 'none',					position	: 'absolute',					overflow	: 'hidden',					top			: '0',					left		: '0',					textAlign	: 'center',					backgroundColor : 'transparent',					lineHeigt	: '0'				}			)			.append([container,captionEl]);		jQuery('body')			.append(overlay)			.append(outerContainer);		//minimum width :		prevImageEl = jQuery('#ImageBoxPrevImage');		prevWidth = prevImageEl.css("width");		if (!prevWidth) {			prevWidth='';		}		else{			if(prevWidth!=''){				prevWidth = prevWidth.replace(/px/g,''); //on eleve le texte 'px' pour pouvoir faire des calculs			}		}		nextImageEl = jQuery('#ImageBoxNextImage');		nextWidth = nextImageEl.css("width");		if (!nextWidth) {			nextWidth='';		}		else{			if(nextWidth!=''){				nextWidth = nextWidth.replace(/px/g,''); //on eleve le texte 'px' pour pouvoir faire des calculs			}		}		jQuery.ImageBox.minWidth=-(-(jQuery.ImageBox.options.border * 2)-nextWidth-prevWidth); //2*border+nextWidth+prevWidth	},	start : function(e, elm)	{		el = elm ? jQuery(elm) : jQuery(this);		linkRel =  el.attr('rel');		var totalImages, iteration, prevImage, nextImage;		if (linkRel != 'imagebox') {			jQuery.ImageBox.currentRel = linkRel;			gallery = jQuery('a[@rel=' + linkRel + ']');			totalImages = gallery.size();			iteration = gallery.index(elm ? elm : this);			prevImage = gallery.get(iteration - 1);			nextImage = gallery.get(iteration + 1);		}		imageSrc =  el.attr('href');		captionText = el.attr('title');		caption2 = el.attr('content') || "";		if (caption2!="") {			captionText+="<br>"+caption2;		}		pageSize = jQuery.iUtil.getScroll();		overlay = jQuery('#ImageBoxOverlay');		if (!jQuery.ImageBox.opened) {			jQuery.ImageBox.opened = true;			if (jQuery.browser.msie) {				jQuery('#ImageBoxIframe')					.css ('height', Math.max(pageSize.ih,pageSize.h) + 'px')					.css ('width', Math.max(pageSize.iw,pageSize.w) + 'px')					.show();			}			overlay				.css ('height', Math.max(pageSize.ih,pageSize.h) + 'px')				.css ('width', Math.max(pageSize.iw,pageSize.w) + 'px')				.show()				.fadeTo(					300,					jQuery.ImageBox.options.overlayOpacity,					function()					{						jQuery.ImageBox.loadImage(							imageSrc,							captionText,							pageSize,							totalImages,							iteration,							prevImage,							nextImage						);					}				);			jQuery('#ImageBoxOuterContainer').css ('width', Math.max(pageSize.iw,pageSize.w) + 'px');		} else {			jQuery('#ImageBoxPrevImage').get(0).onclick = null;			jQuery('#ImageBoxNextImage').get(0).onclick = null;			jQuery.ImageBox.loadImage(				imageSrc,				captionText,				pageSize,				totalImages,				iteration,				prevImage,				nextImage			);		}		return false;	},	loadImage : function(imageSrc, captiontext, pageSize, totalImages, iteration, prevImage, nextImage)	{		jQuery('#ImageBoxCurrentImage').remove();		prevImageEl = jQuery('#ImageBoxPrevImage');		prevImageEl.hide();		nextImageEl = jQuery('#ImageBoxNextImage');		nextImageEl.hide();		loader = jQuery('#ImageBoxLoader');		container = jQuery('#ImageBoxContainer');		outerContainer = jQuery('#ImageBoxOuterContainer');		captionEl = jQuery('#ImageBoxCaption').css('visibility', 'hidden');		//Avoid safari Bug :		//jQuery('#ImageBoxCaptionText').html(captionText);		jQuery('#ImageBoxCaptionText').html("<div id='ImageBoxCaptextcontainer' style='padding-right:4px'>"+captionText+"</div>");		jQuery.ImageBox.animationInProgress = true;		if (totalImages && jQuery.ImageBox.options.showTextImage)			jQuery('#ImageBoxCaptionImages').html(				jQuery.ImageBox.options.textImage				+ ' ' + (iteration + 1) + ' '				+ jQuery.ImageBox.options.textImageFrom				+ ' ' + totalImages			);		if (prevImage) {			prevImageEl.get(0).onclick = function()			{				this.blur();				jQuery.ImageBox.start(null, prevImage);				return false;			};		}		if (nextImage) {			nextImageEl.get(0).onclick =function()			{				this.blur();				jQuery.ImageBox.start(null, nextImage);				return false;			};		}		loader.show();		containerSize = jQuery.iUtil.getSize(container.get(0));		containerW = Math.max(containerSize.wb, loader.get(0).width + jQuery.ImageBox.options.border * 2);		containerH = Math.max(containerSize.hb, loader.get(0).height + jQuery.ImageBox.options.border * 2);		loader			.css(				{					left	: (containerW - loader.get(0).width)/2 + 'px',					top		: (containerH - loader.get(0).height)/2 + 'px'				}			);		container			.css(				{					width	: containerW + 'px',					height	: containerH + 'px'				}			)			.show();		clientSize = jQuery.iUtil.getClient();		outerContainer			.css('top', pageSize.t +  (clientSize.h / 15) + 'px');		if (outerContainer.css('display') == 'none') {			outerContainer				.show()				.fadeIn(					jQuery.ImageBox.options.fadeDuration				);		}		imageEl = new Image;		// avoid Safari bug :		imageEl.id='ImageBoxCurrentImage';		imageEl.onload = function(){				if (jQuery.browser.safari) {					containerW = jQImageBox_imageEl.width + jQuery.ImageBox.options.border * 2;					containerH = jQImageBox_imageEl.height + jQuery.ImageBox.options.border * 2;				}				containerW = imageEl.width + jQuery.ImageBox.options.border * 2;				containerH = imageEl.height + jQuery.ImageBox.options.border * 2;				//min width :				if (jQuery.ImageBox.minWidth > containerW ) {					containerW = jQuery.ImageBox.minWidth + jQuery.ImageBox.options.border * 2;				}				loader.hide();				container.animate(					{						height		: containerH					},					containerSize.hb != containerH ? jQuery.ImageBox.options.fadeDuration : 1,					function()					{						container.animate(							{								width		: containerW							},							containerSize.wb != containerW ? jQuery.ImageBox.options.fadeDuration : 1,							function()							{								if (jQuery.browser.safari) {									var imgtoprepend="<img src='"+jQImageBox_imageEl.src+"' id='imgboxtmp' style='display:none' >";									container.prepend(imgtoprepend);									var jqi_width = jQuery('#imgboxtmp').width();									while(jqi_width==0){										jqi_width = jQuery('#imgboxtmp').width();									}									jqi_height = jQuery('#imgboxtmp').height();									jQuery('#imgboxtmp').remove();									jqi_width = jqi_width - 2* jQuery.ImageBox.options.border;									var imgtoprepend="<img src='"+jQImageBox_imageEl.src+"' id='"+jQImageBox_imageEl.id+"' >";									container.prepend(imgtoprepend); //pour safari...								}								else{									container.prepend(imageEl);								}								jQuery('#ImageBoxCurrentImage')									.css(										{											position	: 'absolute',											left		: (containerW-jQuery('#ImageBoxCurrentImage').width())/2+'px', //jQuery.ImageBox.options.border + 'px',											top			: jQuery.ImageBox.options.border + 'px'										}									)									.fadeIn(										jQuery.ImageBox.options.fadeDuration,										function()										{											captionSize = jQuery.iUtil.getSize(captionEl.get(0));											//min width :											if (jQuery.ImageBox.minWidth > containerW ) {												 containerW = jQuery.ImageBox.minWidth;											}											if (prevImage) {												prevImageEl													.css(														{															left	: jQuery.ImageBox.options.border + 'px',															top		: jQuery.ImageBox.options.border + 'px',															width	: containerW/2 ,//- jQuery.ImageBox.options.border * 3 + 'px',															height	: containerH - jQuery.ImageBox.options.border * 2 + 'px'														}													)													.show();											}											if (nextImage) {												nextImageEl													.css(														{															left	: containerW/2 + jQuery.ImageBox.options.border * 2 + 1 + 'px',															top		: jQuery.ImageBox.options.border + 'px',															width	: containerW/2 - jQuery.ImageBox.options.border * 3 + 'px',															height	: containerH - jQuery.ImageBox.options.border * 2 + 'px'														}													)													.show();											}											jQuery("#ImageBoxCaptextcontainer").css('padding-top',jQuery("#ImageBoxClose").height());											captionEl												.css(													{														width		: containerW + 'px',														top			: - captionSize.hb + 'px',														visibility	: 'visible'													}												)												.animate(													{														top		: -1													},													jQuery.ImageBox.options.fadeDuration,													function()													{														jQuery.ImageBox.animationInProgress = false;													}												);										}									);							}						);					}				);			}		imageEl.src = imageSrc;		jQImageBox_imageEl = imageEl;	},	hideImage : function()	{		jQuery('#ImageBoxCurrentImage').remove();		jQuery('#ImageBoxOuterContainer').hide();		jQuery('#ImageBoxCaption').css('visibility', 'hidden');		jQuery('#ImageBoxOverlay').fadeTo(			300,			0,			function(){				jQuery(this).hide();				if (jQuery.browser.msie) {					jQuery('#ImageBoxIframe').hide();				}			}		);		jQuery('#ImageBoxPrevImage').get(0).onclick = null;		jQuery('#ImageBoxNextImage').get(0).onclick = null;		jQuery.ImageBox.currentRel = null;		jQuery.ImageBox.opened = false;		jQuery.ImageBox.animationInProgress = false;		return false;	}};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -