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

📄 thumbnailpicker.js

📁 这是一个ajax的例子大家好好的看看就是一个鱼眼的效果
💻 JS
📖 第 1 页 / 共 2 页
字号:
if(!dojo._hasResource["dojox.image.ThumbnailPicker"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.dojo._hasResource["dojox.image.ThumbnailPicker"] = true;dojo.provide("dojox.image.ThumbnailPicker");dojo.experimental("dojox.image.ThumbnailPicker");//// dojox.image.ThumbnailPicker courtesy Shane O Sullivan, licensed under a Dojo CLA // @author  Copyright 2007 Shane O Sullivan (shaneosullivan1@gmail.com)//// For a sample usage, see http://www.skynet.ie/~sos/photos.php////	document topics.dojo.require("dojo.fx");dojo.require("dijit._Widget");dojo.require("dijit._Templated");dojo.declare("dojox.image.ThumbnailPicker",	[dijit._Widget, dijit._Templated],	{	// summary: A scrolling Thumbnail Picker widget 	//	// imageStore: Object	// A data store that implements the dojo.data Read API.	imageStore: null,	// request: Object	// A dojo.data Read API Request object.	request: null,	// size: Number	// Width or height in pixels, depending if horizontal or vertical.	size: 500, //FIXME: use CSS?	// thumbHeight: Number	// Default height of a thumbnail image	thumbHeight: 75, // FIXME: use CSS?	// thumbWidth: Number	// Default width of an image	thumbWidth: 100, // FIXME: use CSS?	// useLoadNotifier: Boolean	// Setting useLoadNotifier to true makes a colored DIV appear under each	// thumbnail image, which is used to display the loading status of each	// image in the data store.	useLoadNotifier: false,	// useHyperlink: boolean	// Setting useHyperlink to true causes a click on a thumbnail to open a link.	useHyperlink: false,	// hyperlinkTarget: String	// If hyperlinkTarget is set to "new", clicking on a thumb will open a new window	// If it is set to anything else, clicking a thumbnail will open the url in the	// current window.	hyperlinkTarget: "new",	// isClickable: Boolean	// When set to true, the cursor over a thumbnail changes.	isClickable: true,	// isScrollable: Boolean	// When true, uses smoothScroll to move between pages	isScrollable: true,	// isHorizontal: Boolean	// If true, the thumbnails are displayed horizontally. Otherwise they are displayed	// vertically	isHorizontal: true,	//autoLoad: Boolean	autoLoad: true,	// linkAttr: String	// The attribute name for accessing the url from the data store	linkAttr: "link",		// imageThumbAttr: String	// The attribute name for accessing the thumbnail image url from the data store	imageThumbAttr: "imageUrlThumb",			// imageLargeAttr: String	// The attribute name for accessing the large image url from the data store	imageLargeAttr: "imageUrl",		// pageSize: Number	//	The number of images to request each time.	pageSize: 20,		// titleAttr: String	// The attribute name for accessing the title from the data store	titleAttr: "title",		templateString:"<div dojoAttachPoint=\"outerNode\" class=\"thumbOuter\">\n\t<div dojoAttachPoint=\"navPrev\" class=\"thumbNav thumbClickable\">\n\t  <img src=\"\" dojoAttachPoint=\"navPrevImg\"/>    \n\t</div>\n\t<div dojoAttachPoint=\"thumbScroller\" class=\"thumbScroller\">\n\t  <div dojoAttachPoint=\"thumbsNode\" class=\"thumbWrapper\"></div>\n\t</div>\n\t<div dojoAttachPoint=\"navNext\" class=\"thumbNav thumbClickable\">\n\t  <img src=\"\" dojoAttachPoint=\"navNextImg\"/>  \n\t</div>\n</div>\n", 	tempImgPath: dojo.moduleUrl("dojo", "resources/blank.gif"),		// thumbs: Array	// Stores the image nodes for the thumbnails.	_thumbs: [],		// _thumbIndex: Number	// The index of the first thumbnail shown	_thumbIndex: 0,		// _maxPhotos: Number	// The total number of photos in the image store	_maxPhotos: 0,		// _loadedImages: Object	// Stores the indices of images that have been marked as loaded using the	// markImageLoaded function.	_loadedImages: {},	postCreate: function(){		// summary: Initializes styles and listeners				this.widgetid = this.id;		this.inherited(arguments);		this.pageSize = Number(this.pageSize);		this._scrollerSize = this.size - (51 * 2);				var sizeProp = this._sizeProperty = this.isHorizontal ? "width" : "height";			// FIXME: do this via css? calculate the correct width for the widget		dojo.style(this.outerNode, "textAlign","center");		dojo.style(this.outerNode, sizeProp, this.size+"px");			dojo.style(this.thumbScroller, sizeProp, this._scrollerSize + "px");			//If useHyperlink is true, then listen for a click on a thumbnail, and		//open the link		if(this.useHyperlink){			dojo.subscribe(this.getClickTopicName(), this, function(packet){				var index = packet.index;				var url = this.imageStore.getValue(packet.data,this.linkAttr);								//If the data item doesn't contain a URL, do nothing				if(!url){return;}								if(this.hyperlinkTarget == "new"){					window.open(url);				}else{					window.location = url;				}			});		}			if(this.isScrollable) {			// FIXME: does this break builds or anything? 			dojo.require("dojox.fx.scroll");			dojo.require("dojox.fx.easing"); 		}		if(this.isClickable){			dojo.addClass(this.thumbsNode, "thumbClickable");		}		this._totalSize = 0;		this.init();	},		init: function(){		// summary: Creates DOM nodes for thumbnail images and initializes their listeners 		if(this.isInitialized) {return false;}			var classExt = this.isHorizontal ? "Horiz" : "Vert";			// FIXME: can we setup a listener around the whole element and determine based on e.target?	  		dojo.addClass(this.navPrev, "prev" + classExt);		dojo.addClass(this.navNext, "next" + classExt);		dojo.addClass(this.thumbsNode, "thumb"+classExt);		dojo.addClass(this.outerNode, "thumb"+classExt);			this.navNextImg.setAttribute("src", this.tempImgPath);		this.navPrevImg.setAttribute("src", this.tempImgPath);				this.connect(this.navPrev, "onclick", "_prev");		this.connect(this.navNext, "onclick", "_next");		this.isInitialized = true;				if(this.isHorizontal){			this._offsetAttr = "offsetLeft";			this._sizeAttr = "offsetWidth";			this._scrollAttr = "scrollLeft";		}else{			this._offsetAttr = "offsetTop";			this._sizeAttr = "offsetHeight";			this._scrollAttr = "scrollTop";		}			this._updateNavControls();		if(this.imageStore && this.request){this._loadNextPage();}		return true;	},	getClickTopicName: function(){		// summary: Returns the name of the dojo topic that can be		//   subscribed to in order to receive notifications on		//   which thumbnail was selected.		return (this.widgetId || this.id) + "/select"; // String	},	getShowTopicName: function(){		// summary: Returns the name of the dojo topic that can be		//   subscribed to in order to receive notifications on		//   which thumbnail is now visible		return (this.widgetId || this.id) + "/show"; // String	},	setDataStore: function(dataStore, request, /*optional*/paramNames){		// summary: Sets the data store and request objects to read data from.		// dataStore:		//	An implementation of the dojo.data.api.Read API. This accesses the image		//	data.		// request:		//	An implementation of the dojo.data.api.Request API. This specifies the		//	query and paging information to be used by the data store		// paramNames:		//	An object defining the names of the item attributes to fetch from the		//	data store.  The four attributes allowed are 'linkAttr', 'imageLargeAttr',		//	'imageThumbAttr' and 'titleAttr'		this.reset();			this.request = {			query: {},			start: request.start || 0,			count: request.count || 10,			onBegin: dojo.hitch(this, function(total){				this._maxPhotos = total;			})		};			if(request.query){ dojo.mixin(this.request.query, request.query);}			if(paramNames){			dojo.forEach(["imageThumbAttr", "imageLargeAttr", "linkAttr", "titleAttr"], function(attrName){				if(paramNames[attrName]){ this[attrName] = paramNames[attrName]; }				}, this);		}				this.request.start = 0;		this.request.count = this.pageSize;		this.imageStore = dataStore;			if(!this.init()){this._loadNextPage();}	},	reset: function(){		// summary: Resets the widget back to its original state.		this._loadedImages = {};		dojo.forEach(this._thumbs, function(img){			if(img){				//	dojo.event.browser.clean(img);				if(img.parentNode){					img.parentNode.removeChild(img);					}			}		});			this._thumbs = [];		this.isInitialized = false;		this._noImages = true;	},		isVisible: function(index) {		// summary: Returns true if the image at the specified index is currently visible. False otherwise.		var img = this._thumbs[index];		if(!img){return false;}		var pos = this.isHorizontal ? "offsetLeft" : "offsetTop";		var size = this.isHorizontal ? "offsetWidth" : "offsetHeight";

⌨️ 快捷键说明

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