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

📄 slide.js

📁 tarena电子月刊第一期,包括java开发、面试相关信息
💻 JS
📖 第 1 页 / 共 4 页
字号:
function setShadeOpacity(opacity){this.shadeOpacity=opacity;}function disableFading(){this.fadePhotos=false;}function enableFading(){this.fadePhotos=true;}function disablePanning(){this.panPhotos=false;}function enablePanning(){this.panPhotos=true;}function setFontSize(size){this.fontSize=size;}function setFont(font){this.font=font;}function enableAutoPlay(){this.autoPlay=true;}function disableAutoPlay(){this.autoPlay=false;}function enableEmailLink(){this.enableEmailLink=true;}function disableEmailLink(){this.enableEmailLink=false;}function enablePhotoLink(){this.enablePhotoLink=true;}function disablePhotoLink(){this.enablePhotoLink=false;}function setOnClickEvent(newfunc){this.customOnClickEvent=newfunc;}function setOnRightclickEvent(newfunc){this.customOnRightclickEvent=newfunc;}function enableLoop(){this.loop=true;}function disableLoop(){this.loop=false;}function enableToolbar(){this.showToolbar=true;}function disableToolbar(){this.showToolbar=false;}function enableToolbarAnimator(){this.toolbarAnimator=new ToolbarAnimator(this);}function disableToolbarAnimator(){if(this.toolbarAnimator!=undefined){this.toolbarAnimator.reset();this.toolbarAnimator=undefined;}}function setControlsImageMap(imagemap){this.customImageMap=imagemap;}function setOverrideToolbarStyles(overrideToolbarStyles){this.overrideToolbarStyles=overrideToolbarStyles;}function setNoPadding(nopadding){this.nopadding=nopadding;}function showPhoto(index,cropWidth,opacity){if(this.photos.length===0){return true;}if(getRootWindow().permissionDenied&&this.badgeMode==undefined&&!getRootWindow().livemode){this.setStartFragmentIdentifier(index);return true;}if(index!=undefined)this.index=index;if(this.index<0||this.index>=this.photos.length){log.error("Invalid photo index");return true;}var doc=this.win.document;var firstShow=false;if(!this.shown){firstShow=true;doc.viewer=this;try{this.hideOverlappingElements();}catch(e){}}var zIndex=16384;var winSize=getWindowSize(this.win);var availW=winSize.w-(this.nopadding?this.borderWidth*2:20);var availH=winSize.h-(this.nopadding?this.borderWidth*2:20);var scrollPos=getScrollPos(this.win);var scrollLeft=scrollPos.left;var scrollTop=scrollPos.top;this.addBackShade(zIndex);this.addByLine(zIndex);this.addBylineCaption();if(this.showToolbar){this.addToolbar(availW,zIndex);this.addCaptions();}var photo=this.photos[this.index];if(isNaN(photo.w)||isNaN(photo.h)){if(photo.preloadImage!=undefined){if(isNaN(photo.w)&&photo.preloadImage.width>0)photo.w=photo.preloadImage.width;if(isNaN(photo.h)&&photo.preloadImage.height>0)photo.h=photo.preloadImage.height;}else{this.index--;this.next();return false;}}this.shown=true;var offset=(this.nopadding?0:20);var pw=-1;var ph=-1;if(parseInt(photo.w)>availW||parseInt(photo.h)>availH){if(parseInt(photo.w)/availW>parseInt(photo.h)/availH){pw=availW-offset;ph=parseInt(pw*photo.h/photo.w);}else{ph=availH-offset;pw=parseInt(ph*photo.w/photo.h);}}else{pw=parseInt(photo.w);ph=parseInt(photo.h);}if(pw<=0||ph<=0){if(!this.showToolbar)throw"Missing photo dimension";}if(cropWidth==undefined)cropWidth=0;var photoDiv=doc.createElement("div");photoDiv.id=VIEWER_ID_PHOTO;photoDiv.style.visibility="hidden";photoDiv.style.position="absolute";photoDiv.style.zIndex=zIndex;photoDiv.style.overflow="hidden";photoDiv.style.border=this.borderWidth+"px solid "+this.borderColor;photoDiv.style.textAlign="center";photoDiv.style.backgroundColor=this.backgroundColor;var photoElt=doc.createElement("img");photoElt.style.visibility="hidden";photoElt.style.position="relative";photoElt.style.backgroundColor=this.backgroundColor;photoElt.style.border="none";photoElt.style.cursor="pointer";photoElt.style.zIndex=(parseInt(photoDiv.style.zIndex)+1)+"";photoElt.onclick=onClickEvent;photoElt.oncontextmenu=onContextMenuEvent;if(opacity!=undefined&&this.fadePhotos){var fadeElt=(FADE_BORDER?photoDiv:photoElt);setOpacity(fadeElt,opacity);}var left=parseInt((availW-pw)/2)+(this.nopadding?0:OFFSET_LEFT);photoDiv.style.left=(left+scrollLeft+cropWidth/2)+"px";var top=parseInt((availH-ph)/2)+(this.nopadding?0:OFFSET_TOP);photoDiv.style.top=(top+scrollTop)+"px";photoElt.style.visibility="hidden";photoDiv.style.width=(pw-cropWidth>0?pw-cropWidth:pw)+"px";photoDiv.style.height=ph+"px";photoElt.style.width=pw+"px";photoElt.style.height=ph+"px";photoElt.src=photo.src;photoDiv.style.visibility="visible";photoElt.style.visibility="visible";photoDiv.appendChild(photoElt);doc.body.appendChild(photoDiv);if(this.photoDiv!=undefined){try{doc.body.removeChild(this.photoDiv);}catch(e){}}this.photoDiv=photoDiv;this.photoImg=photoElt;this.setLoading(false);if(this.showCallback!=undefined)this.showCallback(this.index);if(firstShow&&this.autoPlay){this.slideShow(true);}return false;}function isPhotoShown(){return this.shown;}function closeViewer(){getViewer().close();}function onPhotoLoad(event){var viewer=getViewer();if(viewer!=undefined){if(flickrHack(viewer,viewer.index)){viewer.setLoading(false);viewer.index--;viewer.next();return;}viewer.show();}}function closePhoto(){var win=this.win;if(win==undefined)win=window;var doc=win.document;var elt=this.photoDiv;if(elt!=undefined)doc.body.removeChild(elt);elt=doc.getElementById(VIEWER_ID_BACK);if(elt!=undefined)doc.body.removeChild(elt);elt=doc.getElementById(VIEWER_ID_TOOLBAR);if(elt!=undefined)doc.body.removeChild(elt);elt=doc.getElementById(VIEWER_ID_BYLINE);if(elt!=undefined)doc.body.removeChild(elt);this.shown=false;this.slideShowRunning=false;this.slideShowPaused=false;try{this.showOverlappingElements();}catch(e){log.error(e);}if(this.toolbarAnimator!=undefined){this.toolbarAnimator.reset();}if(this.closeCallback!=undefined)this.closeCallback(this.index);if(this.contextMenu!=undefined)this.contextMenu.hide();}function nextPhoto(n){if(this.contextMenu!=undefined&&this.contextMenu.visible)this.contextMenu.hide();if(this.isLoading)return;if(n==undefined)n=1;var oldIndex=this.index;if(this.index+n>=this.photos.length){if(this.loop&&n!=this.photos.length){this.index=0;}else{this.index=this.photos.length-1;}}else if(this.index+n<0){if(n<-1)this.index=0;else if(this.loop)this.index=this.photos.length-1;elsereturn;}else{this.index+=n;}if(this.index==oldIndex)return;this.slideShowStop();var img=new Image();this.photos[this.index].preloadImage=img;this.setLoading(true);img.onload=onPhotoLoad;img.onerror=onPhotoLoad;if(this.photos[this.index].src!=undefined){img.src=this.photos[this.index].src;}else{onPhotoLoad();}}function prevPhoto(n){if(this.contextMenu!=undefined&&this.contextMenu.visible)this.contextMenu.hide();if(n==undefined)n=1;this.next(-n);}function firstPhoto(){if(this.contextMenu!=undefined&&this.contextMenu.visible)this.contextMenu.hide();this.prev(this.photos.length);}function lastPhoto(){if(this.contextMenu!=undefined&&this.contextMenu.visible)this.contextMenu.hide();this.next(this.photos.length);}function startSlideShow(){if(this.contextMenu!=undefined&&this.contextMenu.visible)this.contextMenu.hide();getViewer().slideShow(true);}var slideTimeout;var slidePreloadImageLoaded=false;var slidePreloadTime=undefined;function slideShow(start){if(this.toolbarAnimator!=undefined)this.toolbarAnimator.slideshowAction();var nextIndex=this.index+1;if(nextIndex>=this.photos.length){if(this.loop)nextIndex=0;else if(!this.slideShowPaused&&!this.slideShowRunning){this.setToolbarImage(P_IMG_ROOT+"/"+TOOLBAR_IMG);return;}}var doc=this.win.document;var viewer=this;var photoElt=this.photoImg;if(photoElt==undefined)return;var photoDiv=this.photoDiv;var fadeElt=(FADE_BORDER?photoDiv:photoElt);if(start!=undefined&&start===true){if(this.slideShowPaused){this.slideShowPaused=false;this.setToolbarImage(P_IMG_ROOT+"/"+TOOLBAR_IMG_RUNNING);if(this.contextMenu!=undefined&&this.contextMenu.visible)this.contextMenu.hide();return;}else if(this.slideShowRunning){this.slideShowPaused=true;this.setToolbarImage(P_IMG_ROOT+"/"+TOOLBAR_IMG);return;}else{if(this.contextMenu!=undefined&&this.contextMenu.visible)this.contextMenu.hide();this.slideShowRunning=true;this.slideShowPaused=false;this.slideFirstPhoto=true;this.setToolbarImage(P_IMG_ROOT+"/"+TOOLBAR_IMG_RUNNING);}if(this.isLoading||this.index>this.photos.length-1){return;}}else if(this.slideShowPaused){window.setTimeout(function(){viewer.slideShow(false);},200);return;}else if(!this.slideShowRunning){this.setToolbarImage(P_IMG_ROOT+"/"+TOOLBAR_IMG);return;}var left=0;if(photoElt.leftOffset!=undefined){left=parseFloat(photoElt.leftOffset);}if(left===0){if(nextIndex<this.photos.length){slidePreloadImageLoaded=false;var slidePreloadImage=new Image();this.photos[nextIndex].preloadImage=slidePreloadImage;slidePreloadTime=getTimeMillis();slidePreloadImage.onload=onSlideLoad;slidePreloadImage.onerror=onSlideLoad;slidePreloadImage.src=this.photos[nextIndex].src;}}if(left>-SLIDE_OFFSET){left-=MOVE_STEP;if(-left<=FADE_STEPS){if(fadeElt.style.opacity!=undefined&&parseFloat(fadeElt.style.opacity)<1){if(this.fadePhotos&&this.photos[this.index].src!=undefined)setOpacity(fadeElt,-left/FADE_STEPS);}}else if(left+SLIDE_OFFSET<FADE_STEPS){if(nextIndex<this.photos.length&&!slidePreloadImageLoaded){if(slidePreloadTime!=undefined&&getTimeMillis()-slidePreloadTime>PRELOAD_TIMEOUT)slidePreloadImageLoaded=true;left++;this.setLoading(true);}else{if(nextIndex<this.photos.length&&this.fadePhotos&&this.photos[this.index].src!=undefined)setOpacity(fadeElt,(left+SLIDE_OFFSET)/FADE_STEPS);}}photoElt.leftOffset=left;if(this.panPhotos&&!this.slideFirstPhoto){photoElt.style.left=left+"px";}}else{if(nextIndex>=this.photos.length){this.slideShowRunning=false;this.slideShowPaused=false;this.setToolbarImage(P_IMG_ROOT+"/"+TOOLBAR_IMG);if(this.toolbarAnimator!=undefined)this.toolbarAnimator.reset();if(this.endCallback!=undefined)this.endCallback();return;}this.index=nextIndex;this.slideFirstPhoto=false;this.show(undefined,(this.panPhotos?SLIDE_OFFSET:0),0);fadeElt=(FADE_BORDER?this.photoDiv:this.photoImg);if(this.fadePhotos)setOpacity(fadeElt,0);this.photoImg.leftOffset=0;if(this.panPhotos)this.photoImg.style.left="0px";}var pause=this.slideDuration/SLIDE_OFFSET;if(this.slideFirstPhoto){pause/=2;}slideTimeout=window.setTimeout(function(){viewer.slideShow(false);},pause);}function onSlideLoad(event){var viewer=getViewer();if(viewer!=undefined){if(flickrHack(viewer,viewer.index+1)){var slidePreloadImage=viewer.photos[viewer.index+1].preloadImage;slidePreloadImage.src=viewer.photos[viewer.index+1].src;slidePreloadTime=getTimeMillis();return;}slidePreloadImageLoaded=true;viewer.setLoading(false);}}function slideShowStop(){this.slideShowRunning=false;this.slideShowPaused=false;var doc=this.win.document;var photoElt=this.photoImg;if(photoElt!=undefined){if(this.fadePhotos){var fadeElt=(FADE_BORDER?this.photoDiv:photoElt);setOpacity(fadeElt,1);}photoElt.style.left="0px";}}function addBackShade(zIndex){var doc=this.win.document;if(doc.getElementById(VIEWER_ID_BACK)!=undefined){return;}var photoBack=doc.createElement("div");photoBack.id=VIEWER_ID_BACK;photoBack.style.top="0px";photoBack.style.left="0px";photoBack.style.bottom="0px";photoBack.style.right="0px";photoBack.style.margin="0";photoBack.style.padding="0";photoBack.style.border="none";photoBack.style.cursor="pointer";if(IE&&!(IE7&&STRICT_MODE)){photoBack.style.position="absolute";var docSize=getDocumentSize(this.win);photoBack.style.width=(docSize.w-21)+"px";photoBack.style.height=(docSize.h-4)+"px";}else{photoBack.style.position="fixed";photoBack.style.width="100%";photoBack.style.height="100%";}photoBack.style.zIndex=zIndex-1;photoBack.style.backgroundColor=this.shadeColor;if(this.backgroundShade)setOpacity(photoBack,this.shadeOpacity);elsesetOpacity(photoBack,0.0);photoBack.onclick=onClickEvent;doc.body.appendChild(photoBack);}function addToolbar(availW,zIndex){var doc=this.win.document;var i;if(doc.getElementById(VIEWER_ID_TOOLBAR)!=undefined)return;var photoToolbar=doc.createElement("div");photoToolbar.id=VIEWER_ID_TOOLBAR;setOpacity(photoToolbar,TOOLBAR_OPACITY);photoToolbar.style.zIndex=zIndex+1;var imgBack=TOOLBAR_IMG_BACK;if(!isHosted()){imgBack+="-nologo";}if(IE&&!IE7){imgBack+="-indexed";}imgBack+=".png";if(!this.overrideToolbarStyles){var bottom=10;if(IE&&!(IE7&&STRICT_MODE)){photoToolbar.style.position="absolute";if(IE7){var top=getWindowSize(this.win).h+getScrollPos(this.win).top;photoToolbar.style.top=(top-TOOLBAR_H-10)+"px";}else{photoToolbar.style.bottom=bottom+"px";}}else{photoToolbar.style.position="fixed";photoToolbar.style.bottom=bottom+"px";}photoToolbar.style.left=(availW-TOOLBAR_W+10)/2+"px";photoToolbar.style.width=TOOLBAR_W+"px";photoToolbar.style.height=TOOLBAR_H+"px";photoToolbar.style.textAlign="center";photoToolbar.style.backgroundImage="url('"+P_IMG_ROOT+"/"+imgBack+"')";photoToolbar.style.backgroundPosition="50% 0%";photoToolbar.style.backgroundRepeat="no-repeat";photoToolbar.style.lineHeight=LINE_HEIGHT;}var toolbarMask=undefined;if(!this.enableEmailLink&&TOOLBAR_IMG_MASK!=undefined){toolbarMask=doc.createElement("img");toolbarMask.style.position="absolute";toolbarMask.style.width=44;toolbarMask.style.height=44;toolbarMask.style.left="289px";toolbarMask.style.top="0px";toolbarMask.src=P_IMG_ROOT+"/"+TOOLBAR_IMG_MASK;photoToolbar.appendChild(toolbarMask);}if(!this.enablePhotoLink&&TOOLBAR_IMG_MASK!=undefined){toolbarMask=doc.createElement("img");toolbarMask.style.position="absolute";toolbarMask.style.width=44;toolbarMask.style.height=44;toolbarMask.style.left="339px";toolbarMask.style.top="0px";toolbarMask.src=P_IMG_ROOT+"/"+TOOLBAR_IMG_MASK;photoToolbar.appendChild(toolbarMask);}

⌨️ 快捷键说明

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