PageSourceSearch

https://charlestonfreight.co.ke/Spry-UI-1.7/includes/SpryPanelSet.js

js charlestonfreight.co.ke collected 2026-10-06 13:16:57 UTC 8,675 bytes, 318 lines download raw bytes

1// SpryPanelSet.js - version 0.4 - Spry Pre-Release 1.7
2//
3// Copyright (c) 2010. Adobe Systems Incorporated.
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are met:
8//
9//   * Redistributions of source code must retain the above copyright notice,
10//     this list of conditions and the following disclaimer.
11//   * Redistributions in binary form must reproduce the above copyright notice,
12//     this list of conditions and the following disclaimer in the documentation
13//     and/or other materials provided with the distribution.
14//   * Neither the name of Adobe Systems Incorporated nor the names of its
15//     contributors may be used to endorse or promote products derived from this
16//     software without specific prior written permission.
17//
18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28// POSSIBILITY OF SUCH DAMAGE.
29
30(function() { // BeginSpryComponent
31
32if (typeof Spry == "undefined" || !Spry.Widget || !Spry.Widget.Base)
33{
34	alert("SpryPanelSet.js requires SpryWidget.js!");
35	return;
36}
37
38Spry.Widget.PanelSet = function(elements, opts)
39{
40	Spry.Widget.Base.call(this);
41
42	this.elements = elements ? Spry.$$(elements) : [];
43	this.currentPanel = null;
44
45	// Slide Show Mode properties.
46
47	this.displayTimerID = 0;
48
49	// Initialize the panel set object with the global defaults.
50
51	this.setOptions(this, Spry.Widget.PanelSet.config);
52	
53	// Override the defaults with any options passed into the constructor.
54
55	this.setOptions(this, opts);
56
57	if (typeof (this.defaultPanel) == "number")
58	{
59		if (this.defaultPanel < 0)
60			this.defaultPanel = 0;
61		else
62		{
63			var count = this.getPanelCount();
64			if (this.defaultPanel >= count)
65				this.defaultPanel = (count > 1) ? (count - 1) : 0;
66		}
67
68	}
69
70	this.initialize();
71};
72
73Spry.Widget.PanelSet.prototype = new Spry.Widget.Base();
74Spry.Widget.PanelSet.prototype.constructor = Spry.Widget.PanelSet;
75
76Spry.Widget.PanelSet.config = {
77	defaultPanel:    0,
78	autoPlay:       false,
79	displayInterval: 4000, // msecs
80
81	visibleClass:    "PanelVisible",
82	hiddenClass:     "PanelHidden"
83}
84
85Spry.Widget.PanelSet.prototype.initialize = function()
86{
87	var evt = new Spry.Widget.Event(this);
88	this.notifyObservers("onPreInitialize", evt);
89	if (!evt.performDefaultAction)
90		return;
91
92	this.defaultPanel = this.indexToElement(this.defaultPanel);
93	var panels = this.getPanels();
94
95	for (var i = 0; i < panels.length; i++)
96	{
97		var ele = panels[i];
98		var addClass = this.hiddenClass;
99		var removeClass = this.visibleClass;
100
101		if (ele == this.defaultPanel)
102		{
103			addClass = this.visibleClass;
104			removeClass = this.hiddenClass;
105			this.currentPanel = this.defaultPanel;
106		}
107
108		Spry.Utils.addClassName(ele, addClass);
109		Spry.Utils.removeClassName(ele, removeClass);
110	}
111
112	if (this.autoPlay)
113		this.play();
114
115	this.notifyObservers("onPostInitialize", evt);
116};
117
118Spry.Widget.PanelSet.prototype.getPanels = function()
119{
120	return this.elements.slice(0);
121};
122
123Spry.Widget.PanelSet.prototype.getPanelCount = function()
124{
125	return this.getPanels().length;
126};
127
128Spry.Widget.PanelSet.prototype.getCurrentPanel = function()
129{
130	return this.currentPanel;
131};
132
133Spry.Widget.PanelSet.prototype.getCurrentPanelIndex = function()
134{
135	return this.getPanelIndex(this.getCurrentPanel());
136};
137
138Spry.Widget.PanelSet.prototype.getPanelIndex = function(panel)
139{
140	var panels = this.getPanels();
141	for (var i = 0; i < panels.length; i++)
142	{
143		if (panel == panels[i])
144			return i;
145	}
146	return -1;
147};
148
149Spry.Widget.PanelSet.prototype.getPanel = function(panelIndex)
150{
151	return this.getPanels()[panelIndex];
152};
153
154Spry.Widget.PanelSet.prototype.indexToElement = function(eleOrIndex)
155{
156	if (typeof eleOrIndex == "number")
157		return this.getPanels()[eleOrIndex];
158	return eleOrIndex ? Spry.$$(eleOrIndex)[0] : eleOrIndex;
159};
160
161Spry.Widget.PanelSet.prototype.elementToIndex = function(eleOrIndex)
162{
163	var panels = this.getPanels();
164
165	if (typeof eleOrIndex == "number")
166		return panels[eleOrIndex];
167
168	if (typeof eleOrIndex == "string")
169		eleOrIndex = Spry.$$(eleOrIndex)[0];
170
171	return !eleOrIndex ? -1 : panels.indexOf(eleOrIndex);
172};
173
174Spry.Widget.PanelSet.prototype.createEvent = function(target, opts)
175{
176	var eopts = {
177		target: target,
178		targetIndex: this.getPanelIndex(target)
179	};
180	return new Spry.Widget.Event(this, this.setOptions(eopts, opts));
181};
182
183Spry.Widget.PanelSet.prototype.showPanel = function(eleOrIndex)
184{
185	var ele = this.indexToElement(eleOrIndex);
186	if (ele && ele != this.currentPanel)
187	{
188		var evt = this.createEvent(ele, { currentPanel: this.currentPanel });
189		this.notifyObservers("onPreShowPanel", evt);
190
191		if (evt.performDefaultAction)
192		{
193			if (this.currentPanel)
194				this.hidePanel(this.currentPanel);
195	
196			this.currentPanel = ele;
197	
198			Spry.Utils.addClassName(ele, this.visibleClass);
199			Spry.Utils.removeClassName(ele, this.hiddenClass);
200
201			this.notifyObservers("onPostShowPanel", evt);
202		}
203	}
204};
205
206Spry.Widget.PanelSet.prototype.hidePanel = function(eleOrIndex)
207{
208	var evt = this.createEvent(this.currentPanel);
209	this.notifyObservers("onPreHidePanel", evt);
210
211	if (evt.performDefaultAction)
212	{
213		var ele = this.currentPanel;
214
215		Spry.Utils.addClassName(ele, this.hiddenClass);
216		Spry.Utils.removeClassName(ele, this.visibleClass);
217
218		this.currentPanel = null;
219
220		this.notifyObservers("onPostHidePanel", evt);
221	}
222};
223
224Spry.Widget.PanelSet.prototype.showPreviousPanel = function()
225{
226	var evt = new Spry.Widget.Event(this);
227	this.notifyObservers("onPreShowPreviousPanel", evt);
228	if (!evt.performDefaultAction)
229		return;
230
231	var curIndex = this.getCurrentPanelIndex();
232	this.showPanel(((curIndex < 1) ? this.getPanelCount() : curIndex) - 1);
233
234	this.notifyObservers("onPostShowPreviousPanel", evt);
235};
236
237Spry.Widget.PanelSet.prototype.showNextPanel = function()
238{
239	var evt = new Spry.Widget.Event(this);
240	this.notifyObservers("onPreShowNextPanel", evt);
241	if (!evt.performDefaultAction)
242		return;
243
244	this.showPanel((this.getCurrentPanelIndex()+1) % this.getPanelCount());
245
246	this.notifyObservers("onPostShowNextPanel", evt);
247};
248
249Spry.Widget.PanelSet.prototype.showFirstPanel = function()
250{
251	var evt = new Spry.Widget.Event(this);
252	this.notifyObservers("onPreShowFirstPanel", evt);
253	if (!evt.performDefaultAction)
254		return;
255
256	this.showPanel(0);
257
258	this.notifyObservers("onPostShowFirstPanel", evt);
259};
260
261Spry.Widget.PanelSet.prototype.showLastPanel = function()
262{
263	var evt = new Spry.Widget.Event(this);
264	this.notifyObservers("onPreShowLastPanel", evt);
265	if (!evt.performDefaultAction)
266		return;
267
268	var count = this.getPanelCount();
269	this.showPanel(count > 0 ? count - 1 : 0);
270
271	this.notifyObservers("onPostShowLastPanel", evt);
272};
273
274
275Spry.Widget.PanelSet.prototype.startTimer = function()
276{
277	this.stopTimer();
278	var self = this;
279	this.displayTimerID = setTimeout(function() { self.showNextPanel(); self.startTimer(); }, this.displayInterval);
280};
281
282Spry.Widget.PanelSet.prototype.stopTimer = function()
283{
284	if (this.displayTimerID)
285		clearTimeout(this.displayTimerID);
286	this.displayTimerID = 0;
287};
288
289Spry.Widget.PanelSet.prototype.isPlaying = function()
290{
291	return this.displayTimerID != 0;
292};
293
294Spry.Widget.PanelSet.prototype.play = function()
295{
296	var evt = new Spry.Widget.Event(this);
297	this.notifyObservers("onPreStartSlideShowMode", evt);
298	if (!evt.performDefaultAction)
299		return;
300
301	this.startTimer();
302
303	this.notifyObservers("onPostStartSlideShowMode", evt);
304};
305
306Spry.Widget.PanelSet.prototype.stop = function()
307{
308	var evt = new Spry.Widget.Event(this);
309	this.notifyObservers("onPreStopSlideShowMode", evt);
310	if (!evt.performDefaultAction)
311		return;
312
313	this.stopTimer();
314
315	this.notifyObservers("onPostStopSlideShowMode", evt);
316};
317
318})(); // EndSpryComponent

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.