Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
11
dojo.provide("dojo.widget.SlideShow");
12
dojo.require("dojo.event.*");
13
dojo.require("dojo.widget.*");
14
dojo.require("dojo.lfx.*");
15
dojo.require("dojo.html.display");
16
dojo.widget.defineWidget("dojo.widget.SlideShow", dojo.widget.HtmlWidget, {templateString:"<div style=\"position: relative; padding: 3px;\">\n\t\t<div>\n\t\t\t<input type=\"button\" value=\"pause\" \n\t\t\t\tdojoAttachPoint=\"startStopButton\"\n\t\t\t\tdojoAttachEvent=\"onClick: togglePaused;\">\n\t\t</div>\n\t\t<div style=\"position: relative; width: ${this.width}; height: ${this.height};\"\n\t\t\tdojoAttachPoint=\"imagesContainer\"\n\t\t\tdojoAttachEvent=\"onClick: togglePaused;\">\n\t\t\t<img dojoAttachPoint=\"img1\" class=\"slideShowImg\" \n\t\t\t\tstyle=\"z-index: 1; width: ${this.width}; height: ${this.height};\"  />\n\t\t\t<img dojoAttachPoint=\"img2\" class=\"slideShowImg\" \n\t\t\t\tstyle=\"z-index: 0; width: ${this.width}; height: ${this.height};\" />\n\t\t</div>\t\n</div>\n", templateCssString:".slideShowImg {\n\tposition: absolute;\n\tleft: 0px;\n\ttop: 0px; \n\tborder: 2px solid #4d4d4d;\n\tpadding: 0px;\n\tmargin: 0px;\n}\n\n", templateCssPath:dojo.uri.moduleUri("dojo.widget", "templates/SlideShow.css"), imgUrls:[], imgUrlBase:"", delay:4000, transitionInterval:2000, imgWidth:800, imgHeight:600, preventCache:false, stopped:false, _urlsIdx:0, _background:"img2", _foreground:"img1", fadeAnim:null, startStopButton:null, img1:null, img2:null, postMixInProperties:function () {
17
	this.width = this.imgWidth + "px";
18
	this.height = this.imgHeight + "px";
19
}, fillInTemplate:function () {
20
	if (dojo.render.html.safari && this.imgUrls.length == 2) {
21
		this.preventCache = true;
22
	}
23
	dojo.html.setOpacity(this.img1, 0.9999);
24
	dojo.html.setOpacity(this.img2, 0.9999);
25
	if (this.imgUrls.length > 1) {
26
		this.img2.src = this.imgUrlBase + this.imgUrls[this._urlsIdx++] + this._getUrlSuffix();
27
		this._endTransition();
28
	} else {
29
		this.img1.src = this.imgUrlBase + this.imgUrls[this._urlsIdx++] + this._getUrlSuffix();
30
	}
31
}, _getUrlSuffix:function () {
32
	if (this.preventCache) {
33
		return "?ts=" + (new Date()).getTime();
34
	} else {
35
		return "";
36
	}
37
}, togglePaused:function () {
38
	if (this.stopped) {
39
		this.stopped = false;
40
		this._backgroundImageLoaded();
41
		this.startStopButton.value = "pause";
42
	} else {
43
		this.stopped = true;
44
		this.startStopButton.value = "play";
45
	}
46
}, _backgroundImageLoaded:function () {
47
	if (this.stopped) {
48
		return;
49
	}
50
	if (this.fadeAnim) {
51
		this.fadeAnim.stop();
52
	}
53
	this.fadeAnim = dojo.lfx.fadeOut(this[this._foreground], this.transitionInterval, null);
54
	dojo.event.connect(this.fadeAnim, "onEnd", this, "_endTransition");
55
	this.fadeAnim.play();
56
}, _endTransition:function () {
57
	with (this[this._background].style) {
58
		zIndex = parseInt(zIndex) + 1;
59
	}
60
	with (this[this._foreground].style) {
61
		zIndex = parseInt(zIndex) - 1;
62
	}
63
	var tmp = this._foreground;
64
	this._foreground = this._background;
65
	this._background = tmp;
66
	this._loadNextImage();
67
}, _loadNextImage:function () {
68
	dojo.event.kwConnect({srcObj:this[this._background], srcFunc:"onload", adviceObj:this, adviceFunc:"_backgroundImageLoaded", once:true, delay:this.delay});
69
	dojo.html.setOpacity(this[this._background], 1);
70
	this[this._background].src = this.imgUrlBase + this.imgUrls[this._urlsIdx++];
71
	if (this._urlsIdx > (this.imgUrls.length - 1)) {
72
		this._urlsIdx = 0;
73
	}
74
}});
75