Hi guys,
this is the page im working on:
www.pupr.edu/department/industrial/students.asp
I need to Create a Sliding Panels Widget INSIDE a panel of the Main Sliding Panels Pidget
Example
-Sliding Panel Widget 1 Menu-
[ Sliding Panel Widget 1 : Students ]
>panel 1: Titled Prospective
=panel content:
*Inside Sliding Panels Menu
*Inside Sliding Panels Widget 2( with 4 panels )
=/ends content panel 1:Prospective.
>panel 2: Titled Current
=panel content:
*Inside Sliding Panels Menu
*Inside Sliding Panels Widget 3( with 3 panels )
=/ends content panel 2: Current
[/Ends Sliding Panels Widget 1: Students]
I cant figure out why its nor working,
with what i have right now its as if its not recognizing it as a sliding panel.
I gave the "MiniSlidingPanel" ( Inside one ) its own css file, it uses the same js file as the main slide panels
i named it different than the main slidepanel in the same <script> on the bottom of the page
i really dont know what im doing wrong
HELP
forum, please give me something
this is the widgets code part in the page:
<div id="centerC">
<div id="panelwidget" class="SlidingPanels">
<div class="SlidingPanelsContentGroup">
<div class="SlidingPanelsContent" id="p1">
<div class="panelcontent">
<h1>Prospective Students</h1>
<!-- insert mini slidepanels menu -->
<div class="MSP_submenudiv">
<p align="center">
<a href="javascript:;" onclick="MSP.showPanel(0);" id="msp1" class="MSP_submenuli" >Career Description</a>
<a href="javascript:;" onclick="MSP.showPanel(1);" id="msp2" class="MSP_submenuli" >Opportunities</a>
<a href="http://www.pupr.edu/admissions-home.asp" target="_blank" id="p3" class="MSP_submenuli">Admissions</a>
<a href="http://www.pupr.edu/financialaid" target="_blank" id="p4" class="MSP_submenuli" >Financial Aid</a>
</p>
</div>
<!-- insert mini slidepanels include -->
<div id="minipanelwidget" class=".MSP_SlidingPanels">
<div class=".MSP_SlidingPanelsContentGroup">
<div class=".MSP_SlidingPanelsContent" id="msp1">
<div class=".MSP_panelcontent">
<h1>Career Description</h1>
<P>
testing
<br />
TESTING
<br />
TESTING
</P>
</div></div>
<div class=".MSP_SlidingPanelsContent" id="msp2">
<div>
<h1>Opportunities</h1>
<P>
testing
<br />
TESTING
<br />
TESTING
</P>
</div></div>
</div><!-- ContentGroup-->
</div><!-- ends panelwidget-->
</div></div>
<div class="SlidingPanelsContent" id="p2">
<div>
<h1>Current Students</h1>
<!-- insert mini slidepanels menu -->
<!-- empty for now -->
<!-- insert mini slidepanels include -->
<!-- empty for now -->
</div></div>
</div><!-- ContentGroup-->
</div><!-- ends panelwidget-->
</div><!-- CENTER -->
I'm not even sure Spry allows nested panels - you may want to ask your question in the Spry forum here: http://forums.adobe.com/community/labs/spry
Yes, I think it would get confused as they both would use the same div id's. You may have to create a second CSS and JS file renaming elements so they are unique. I was able to insert a Vertical CSS menu into an Accorion content area and it worked fine, but there were no similar elements or divs.
Also, try a search for accordion panel, maybe with jQuery. I did see a script out there for this and it had several variations, including nesting and vertical options - an accordion with only one tab is basically the same as a sliding panel.
i did create a different css for it and i changed the div classes to addning "MSP_" before the original name\still didnt work.
i also changed the widgets name from sp1 ( the main widget ) to MSP and 'panelwidget" to "minipanelwidget"
+ my last thought was that maybe the panels couldnt float because they were all inside a fixed size area?
but then again, if it floats that shouldnt be a problem :/ right?
+ I think the problem is its not recognizing it as a sliding panels widget,
do you know of i have to change the name in the js file ?
Try this test code and adapt it to your needs:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script src="SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
<link href="SpryAssets/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="CollapsiblePanelRoot" class="CollapsiblePanelRoot">
<div class="CollapsiblePanelTab" tabindex="0">Tab Root</div>
<div class="CollapsiblePanelContent">
<div id="CollapsiblePanel1" class="CollapsiblePanel">
<div class="CollapsiblePanelTab" tabindex="0">Tab1</div>
<div class="CollapsiblePanelContent">Content1</div>
</div>
<div id="CollapsiblePanel2" class="CollapsiblePanel">
<div class="CollapsiblePanelTab" tabindex="0">Tab2</div>
<div class="CollapsiblePanelContent">Content2</div>
</div>
<div id="CollapsiblePanel3" class="CollapsiblePanel">
<div class="CollapsiblePanelTab" tabindex="0">Tab3</div>
<div class="CollapsiblePanelContent">Content3</div>
</div>
</div>
</div>
<script type="text/javascript">
var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});
var CollapsiblePanel2 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel2", {contentIsOpen:false});
var CollapsiblePanel3 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel3", {contentIsOpen:false});
var CollapsiblePanelRoot = new Spry.Widget.CollapsiblePanel("CollapsiblePanelRoot");
</script>
</body>
</html>
I was thinking it was written in a way that the names it used in the programming use the css names or something like that.
Here's the JS:
// SprySlidingPanels.js - version 0.5 - Spry Pre-Release 1.6
//
// Copyright (c) 2006. Adobe Systems Incorporated.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// * Neither the name of Adobe Systems Incorporated nor the names of its
// contributors may be used to endorse or promote products derived from this
// software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
var Spry;
if (!Spry) Spry = {};
if (!Spry.Widget) Spry.Widget = {};
Spry.Widget.SlidingPanels = function(element, opts)
{
this.element = this.getElement(element);
this.enableAnimation = true;
this.currentPanel = null;
this.enableKeyboardNavigation = true;
this.hasFocus = false;
this.previousPanelKeyCode = Spry.Widget.SlidingPanels.KEY_LEFT;
this.nextPanelKeyCode = Spry.Widget.SlidingPanels.KEY_RIGHT;
this.currentPanelClass = "SlidingPanelsCurrentPanel";
this.focusedClass = "SlidingPanelsFocused";
this.animatingClass = "SlidingPanelsAnimating";
Spry.Widget.SlidingPanels.setOptions(this, opts);
if (this.element)
this.element.style.overflow = "hidden";
// Developers can specify the default panel as an index,
// id or an actual element node. Make sure to normalize
// it into an element node because that is what we expect
// internally.
if (this.defaultPanel)
{
if (typeof this.defaultPanel == "number")
this.currentPanel = this.getContentPanels()[this.defaultPanel];
else
this.currentPanel = this.getElement(this.defaultPanel);
}
// If we still don't have a current panel, use the first one!
if (!this.currentPanel)
this.currentPanel = this.getContentPanels()[0];
// Since we rely on the positioning information of the
// panels, we need to wait for the onload event to fire before
// we can attempt to show the initial panel. Once the onload
// fires, we know that all CSS files have loaded. This is
// especially important for Safari.
if (Spry.Widget.SlidingPanels.onloadDidFire)
this.attachBehaviors();
else
Spry.Widget.SlidingPanels.loadQueue.push(this);
};
Spry.Widget.SlidingPanels.prototype.onFocus = function(e)
{
this.hasFocus = true;
this.addClassName(this.element, this.focusedClass);
return false;
};
Spry.Widget.SlidingPanels.prototype.onBlur = function(e)
{
this.hasFocus = false;
this.removeClassName(this.element, this.focusedClass);
return false;
};
Spry.Widget.SlidingPanels.KEY_LEFT = 37;
Spry.Widget.SlidingPanels.KEY_UP = 38;
Spry.Widget.SlidingPanels.KEY_RIGHT = 39;
Spry.Widget.SlidingPanels.KEY_DOWN = 40;
Spry.Widget.SlidingPanels.prototype.onKeyDown = function(e)
{
var key = e.keyCode;
if (!this.hasFocus || (key != this.previousPanelKeyCode && key != this.nextPanelKeyCode))
return true;
if (key == this.nextPanelKeyCode)
this.showNextPanel();
else /* if (key == this.previousPanelKeyCode) */
this.showPreviousPanel();
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
if (e.stopPropagation) e.stopPropagation();
else e.cancelBubble = true;
return false;
};
Spry.Widget.SlidingPanels.prototype.attachBehaviors = function()
{
var ele = this.element;
if (!ele)
return;
if (this.enableKeyboardNavigation)
{
var focusEle = null;
var tabIndexAttr = ele.attributes.getNamedItem("tabindex");
if (tabIndexAttr || ele.nodeName.toLowerCase() == "a")
focusEle = ele;
if (focusEle)
{
var self = this;
Spry.Widget.SlidingPanels.addEventListener(focusEle, "focus", function(e) { return self.onFocus(e || window.event); }, false);
Spry.Widget.SlidingPanels.addEventListener(focusEle, "blur", function(e) { return self.onBlur(e || window.event); }, false);
Spry.Widget.SlidingPanels.addEventListener(focusEle, "keydown", function(e) { return self.onKeyDown(e || window.event); }, false);
}
}
if (this.currentPanel)
{
// Temporarily turn off animation when showing the
// initial panel.
var ea = this.enableAnimation;
this.enableAnimation = false;
this.showPanel(this.currentPanel);
this.enableAnimation = ea;
}
};
Spry.Widget.SlidingPanels.prototype.getElement = function(ele)
{
if (ele && typeof ele == "string")
return document.getElementById(ele);
return ele;
};
Spry.Widget.SlidingPanels.prototype.addClassName = function(ele, className)
{
if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) != -1))
return;
ele.className += (ele.className ? " " : "") + className;
};
Spry.Widget.SlidingPanels.prototype.removeClassName = function(ele, className)
{
if (!ele || !className || (ele.className && ele.className.search(new RegExp("\\b" + className + "\\b")) == -1))
return;
ele.className = ele.className.replace(new RegExp("\\s*\\b" + className + "\\b", "g"), "");
};
Spry.Widget.SlidingPanels.setOptions = function(obj, optionsObj, ignoreUndefinedProps)
{
if (!optionsObj)
return;
for (var optionName in optionsObj)
{
if (ignoreUndefinedProps && optionsObj[optionName] == undefined)
continue;
obj[optionName] = optionsObj[optionName];
}
};
Spry.Widget.SlidingPanels.prototype.getElementChildren = function(element)
{
var children = [];
var child = element.firstChild;
while (child)
{
if (child.nodeType == 1 /* Node.ELEMENT_NODE */)
children.push(child);
child = child.nextSibling;
}
return children;
};
Spry.Widget.SlidingPanels.prototype.getCurrentPanel = function()
{
return this.currentPanel;
};
Spry.Widget.SlidingPanels.prototype.getContentGroup = function()
{
return this.getElementChildren(this.element)[0];
};
Spry.Widget.SlidingPanels.prototype.getContentPanels = function()
{
return this.getElementChildren(this.getContentGroup());
};
Spry.Widget.SlidingPanels.prototype.getContentPanelsCount = function()
{
return this.getContentPanels().length;
};
Spry.Widget.SlidingPanels.onloadDidFire = false;
Spry.Widget.SlidingPanels.loadQueue = [];
Spry.Widget.SlidingPanels.addLoadListener = function(handler)
{
if (typeof window.addEventListener != 'undefined')
window.addEventListener('load', handler, false);
else if (typeof document.addEventListener != 'undefined')
document.addEventListener('load', handler, false);
else if (typeof window.attachEvent != 'undefined')
window.attachEvent('onload', handler);
};
Spry.Widget.SlidingPanels.processLoadQueue = function(handler)
{
Spry.Widget.SlidingPanels.onloadDidFire = true;
var q = Spry.Widget.SlidingPanels.loadQueue;
var qlen = q.length;
for (var i = 0; i < qlen; i++)
q[i].attachBehaviors();
};
Spry.Widget.SlidingPanels.addLoadListener(Spry.Widget.SlidingPanels.pr ocessLoadQueue);
Spry.Widget.SlidingPanels.addEventListener = function(element, eventType, handler, capture)
{
try
{
if (element.addEventListener)
element.addEventListener(eventType, handler, capture);
else if (element.attachEvent)
element.attachEvent("on" + eventType, handler);
}
catch (e) {}
};
Spry.Widget.SlidingPanels.prototype.getContentPanelIndex = function(ele)
{
if (ele)
{
ele = this.getElement(ele);
var panels = this.getContentPanels();
var numPanels = panels.length;
for (var i = 0; i < numPanels; i++)
{
if (panels[i] == ele)
return i;
}
}
return -1;
};
Spry.Widget.SlidingPanels.prototype.showPanel = function(elementOrIndex)
{
var pIndex = -1;
if (typeof elementOrIndex == "number")
pIndex = elementOrIndex;
else // Must be the element for the content panel.
pIndex = this.getContentPanelIndex(elementOrIndex);
var numPanels = this.getContentPanelsCount();
if (numPanels > 0)
pIndex = (pIndex >= numPanels) ? numPanels - 1 : pIndex;
else
pIndex = 0;
var panel = this.getContentPanels()[pIndex];
var contentGroup = this.getContentGroup();
if (panel && contentGroup)
{
if (this.currentPanel)
this.removeClassName(this.currentPanel, this.currentPanelClass);
this.currentPanel = panel;
var nx = -panel.offsetLeft;
var ny = -panel.offsetTop;
if (this.enableAnimation)
{
if (this.animator)
this.animator.stop();
var cx = contentGroup.offsetLeft;
var cy = contentGroup.offsetTop;
if (cx != nx || cy != ny)
{
var self = this;
this.addClassName(this.element, this.animatingClass);
this.animator = new Spry.Widget.SlidingPanels.PanelAnimator(contentGroup, cx, cy, nx, ny, { duration: this.duration, fps: this.fps, transition: this.transition, finish: function()
{
self.removeClassName(self.element, self.animatingClass);
self.addClassName(panel, self.currentPanelClass);
} });
this.animator.start();
}
}
else
{
contentGroup.style.left = nx + "px";
contentGroup.style.top = ny + "px";
this.addClassName(panel, this.currentPanelClass);
}
}
return panel;
};
Spry.Widget.SlidingPanels.prototype.showFirstPanel = function()
{
return this.showPanel(0);
};
Spry.Widget.SlidingPanels.prototype.showLastPanel = function()
{
return this.showPanel(this.getContentPanels().length - 1);
};
Spry.Widget.SlidingPanels.prototype.showPreviousPanel = function()
{
return this.showPanel(this.getContentPanelIndex(this.currentPanel) - 1);
};
Spry.Widget.SlidingPanels.prototype.showNextPanel = function()
{
return this.showPanel(this.getContentPanelIndex(this.currentPanel) + 1);
};
Spry.Widget.SlidingPanels.PanelAnimator = function(ele, curX, curY, dstX, dstY, opts)
{
this.element = ele;
this.curX = curX;
this.curY = curY;
this.dstX = dstX;
this.dstY = dstY;
this.fps = 60;
this.duration = 500;
this.transition = Spry.Widget.SlidingPanels.PanelAnimator.defaultTransition;
this.startTime = 0;
this.timerID = 0;
this.finish = null;
var self = this;
this.intervalFunc = function() { self.step(); };
Spry.Widget.SlidingPanels.setOptions(this, opts, true);
this.interval = 1000/this.fps;
};
Spry.Widget.SlidingPanels.PanelAnimator.defaultTransition = function(time, begin, finish, duration) { time /= duration; return begin + ((2 - time) * time * finish); };
Spry.Widget.SlidingPanels.PanelAnimator.prototype.start = function()
{
this.stop();
this.startTime = (new Date()).getTime();
this.timerID = setTimeout(this.intervalFunc, this.interval);
};
Spry.Widget.SlidingPanels.PanelAnimator.prototype.stop = function()
{
if (this.timerID)
clearTimeout(this.timerID);
this.timerID = 0;
};
Spry.Widget.SlidingPanels.PanelAnimator.prototype.step = function()
{
var elapsedTime = (new Date()).getTime() - this.startTime;
var done = elapsedTime >= this.duration;
var x, y;
if (done)
{
x = this.curX = this.dstX;
y = this.curY = this.dstY;
}
else
{
x = this.transition(elapsedTime, this.curX, this.dstX - this.curX, this.duration);
y = this.transition(elapsedTime, this.curY, this.dstY - this.curY, this.duration);
}
this.element.style.left = x + "px";
this.element.style.top = y + "px";
if (!done)
this.timerID = setTimeout(this.intervalFunc, this.interval);
else if (this.finish)
this.finish();
};
Ill try adding MSP_ to all the Spry.Widget.SlidingPanels
and ill come back to post the results
Thanks Bemdesign!
Altho, im really looking to use sliding panels
because the widget allows me to have the menu wherever i want,
instead of on top of the panel, it would occupy valuable space in the content area aswell i think
Is there a way to remove the panel tab from the collapsible panels and call them to open from a menu ?
so Id have the "naked" panels to open/close sideways with the click of their "separated tabs" in a menu located above them all ?
* menu dosnt move when clicked + panels open/close
The way it's configured you must have the panel tab (it's an essential element of the Spry Panel widget) - but yes, you could configure things so that the panels open via a menu system or have it so the main panel tab doesn't change height, but rather the content inside becomes visible (I think that's what you're asking for?).
You may find it useful to review the Spry documentation found here: http://labs.adobe.com/technologies/spry/docs.html
im asking for whatever widget it is to look like:
menu1 | menu2 | menu3 <----- fixed there, no matter what panel is clicked, menu stays there
---------------------------
| |
| | <--- Only one panel visible at a time( without tab = i guess i could put it to height 0? )
| panel | no title of the other panels visible anytime
| |
---------------------------
ill try this with an accordion, thanks for your suggestion BEM!
( if you see a mess of lines the little drawing i did got distorted )
Oh! In that case use the Spry Tabbed Panel widget and customize that. The apperance can be changed by editing the SpryTabbedPanels.css stylesheet, the functionality (i.e. which tab is open by default, etc.) can be done by reviewing the Spry documentation and adding in the allowable options in the JavaScript code on your page where you instantiate the widget (i.e. where the "var CollapsiblePanel1 = new Spry.Widget.CollapsiblePanel("CollapsiblePanel1", {contentIsOpen:false});" show up in your code on the page).
Hope this helps. For further questions regarding Spry you probably should check in at the Spry forums: http://forums.adobe.com/community/labs/spry
EVERYONE - THE ANSWER TO THIS IS ON POST: http://forums.adobe.com/message/4072199#4072199
BEM, Thanks for all your help,
I did not have to use the collapsible panels tho,
on the linked forum gramps fixed the code errors
and made the sliding panels work inside the sliding panels.
North America
Europe, Middle East and Africa
Asia Pacific