Академический Документы
Профессиональный Документы
Культура Документы
c
R
Dreamweaver CS3 viene equipado con funciones de etiqueta de Spry, que son una forma
WYSIWYG para añadir AJAX a una página web. Automáticamente le proporcionará con
HTML, CSS y JavaScript para realizar ciertas funciones interactivas. En este artículo
usted aprenderá cómo utilizar el widgetSpryAccordion paneles.
Dificultad: Fácil Moderadamente
c
@ Dreamweaver CS3
@ Una web completa en parte, la página o el sitio
1. 1
La apariencia predeterminada
2. 2
4. 4
5. 5
6. 6
7. 7
8. 8
9. 9
c
â
%
&
#'
(
)
!
*
+,,-& +,,.
'
!
!
*
)
$
!
!0
!$
% $0
!
%
0
2
!
%
3"4* 0 !
5
c
6
.AccordionPanelTab {
background -color: #333;
border-top: solid 1px black;
border-bottom: solid 1px gray;
margin: 0px;
padding: 2px;
cursor: pointer;
-moz-user-select: none;
-khtml-user-select: none;
font-size: 14px;
}
[list]
.Accordion
.AccordionPanel
.AccordionPanelTab
.AccordionPanelContent
9
!
$
!
%
ë à 6:::
66:($
:
:
6
;
+ );
!
50
?
&!
'
$
2
&2'
$
#
#
#
!!!
!
)
)!
c
2
!!!
2
8$)
)
)) 0&
$
'!
c
2
a Spry;
(!Spry) Spry = ;
(!Spry.Widget) Spry.Widget = ;
Spry.Widget.Accordion =
(element, opts)
.element = .getElement(element);
.defaultPanel = 0;
.hoverClass = "AccordionPanelTabHover" ;
.openClass = "AccordionPanelOpen" ;
.closedClass = "AccordionPanelClosed" ;
.focusedClass = "AccordionFocused" ;
.enableAnimation = true;
.enableKeyboardNavigation = true;
.currentPanel = null;
.animator = null;
.hasFocus = null;
.previousPanelKeyCode = Spry.Widget.Accordion.KEY_UP;
.nextPanelKeyCode = Spry.Widget.Accordion.KEY_DOWN;
.useFixedPanelHeights = true;
.fixedPanelHeight = 0;
.attachBehaviors();
;
Spry.Widget.Accordion.prototype.getElement =
(ele)
(ele &&
ele == "string")
document.getElementById(ele);
ele;
;
Spry.Widget.Accordion.prototype.removeClassName =
(ele, clas
sName)
(!ele || !className || (ele.className && ele.className.search(
RegExp("\\b" + className + "\\b")) == -1))
;
ele.className = ele.className.replace( RegExp("\\s*\\b" + clas
sName + "\\b", "g"), "");
;
Spry.Widget.Accordion.setOptions =
(obj, optionsObj, ignoreU
ndefinedProps)
(!optionsObj)
;
(a optionName optionsObj)
(ignoreUndefinedProps && optionsObj[optionName] ==
)
;
obj[optionName] = optionsObj[optionName];
;
Spry.Widget.Accordion.prototype.onPanelTabMouseOver =
(e, pa
nel)
(panel)
.addClassName( .getPanelTab(pan el), .hoverClass);
false;
;
Spry.Widget.Accordion.prototype.onPanelTabMouseOut =
(e, pan
el)
(panel)
.removeClassName( .getPanelTab(panel), .hoverClass)
;
false;
;
a panelA = .currentPanel;
a panelB;
(
elementOrIndex == "number")
panelB = .getPanels()[elementOrIndex];
panelB = .getElement(elementOrIndex);
(!contentB)
null;
( .enableAnimation)
( .animator)
.animator.stop();
.animator = Spry.Widget.Accordion.PanelAnimator( ,
panelB, duration: .duration, fps: .fps, transition: .t
ransition );
.animator.start();
(contentA)
contentA.style.display = "none";
contentA.style.height = "0px";
contentB.style.display = "block";
contentB.style.height = .useFixedPanelHeights ? .fixed
PanelHeight + "px" : "auto";
(panelA)
.removeClassName(panelA, .openClass);
.addClassName(panelA, .closedClass);
.removeClassName(panelB, .closedClass);
.addClassName(panelB, .openClass);
.currentPanel = panelB;
panelB;
;
Spry.Widget.Accordion.prototype.openNextPanel =
()
.openPanel( .getCurrentPanelIndex() + 1);
;
Spry.Widget.Accordion.prototype.openPreviousPanel =
()
.openPanel( .getCurrentPanelIndex() - 1);
;
Spry.Widget.Accordion.prototype.openFirstPanel =
()
.openPanel( 0);
;
Spry.Widget.Accordion.prototype.openLastPanel =
()
a panels = .getPanels();
.openPanel(panel s[panels.length - 1]);
;
Spry.Widget.Accordion.prototype.onPanelTabClick =
(e, panel)
(panel != .currentPanel)
.openPanel(panel);
.closePanel();
( .enableKeyboardNavigation)
.focus();
(e.preventDefault) e.preventDefault();
e.returnValue = false;
(e.stopPropagation) e.stopPropagation();
e.cancelBubble = true;
false;
;
Spry.Widget.Accordion.prototype.onFocus =
(e)
.hasFocus = true;
.addClassName( .element, .focusedClass);
false;
;
Spry.Widget.Accordion.prototype.onBlur =
(e)
.hasFocus = false;
.removeClassName( .element, .focusedClass);
false;
;
Spry.Widget.Accordion.KEY_UP = 38;
Spry.Widget.Accordion.KEY_DOWN = 40;
Spry.Widget.Accordion.prototype.onKeyDown =
(e)
a key = e.keyCode;
(! .hasFocus || (key != .previousPanelKeyCode && key !=
.nextPanelKeyCode))
true;
a panels = .getPanels();
(!panels || panels.length < 1)
false;
a currentPanel = .currentPanel ? .currentPanel : panels
[0];
a nextPanel = (key == .nextPanelK eyCode) ? currentPanel.nex
tSibling : currentPanel.previousSibling;
(nextPanel)
(nextPanel.nodeType == 1 /* Node.ELEMENT_NODE */)
;
nextPanel = (key == .nextPanelKeyCode) ? nextPanel.nextSib
ling : nextPanel.previousSibling;
(e.preventDefault) e.preventDefault();
e.returnValue = false;
(e.stopPropagation) e.stopPropagation();
e.cancelBubble = true;
false;
;
Spry.Widget.Accordion.prototype.attachPanelHandlers =
(panel
)
(!panel)
;
a tab = .getPanelTab(panel);
(tab)
a self = ;
Spry.Widget.Accordion.addEventListener(tab, "click",
(
e) self.onPanelTabClick(e, panel); , false);
Spry.Widget.Accordion.addEventListener(tab, "mouseover" ,
(e) self.onPanelTabMouseOver(e, panel); , false);
Spry.Widget.Accordion.addEventListener(tab, "mouseout" ,
Spry.Widget.Accordion.addEventListener =
(element, eventType
, handler, capture)
(element.addEventListener)
element.addEventListener(eventType, handler, capture);
(element.attachEvent)
element.attachEvent( "on" + eventType, handler);
(e)
;
Spry.Widget.Accordion.prototype.initPanel =
(panel, isDefaul
t)
a content = .getPanelContent(panel);
(isDefault)
.currentPanel = panel;
.removeClassName(panel, .closedClass);
.addClassNa me(panel, .openClass);
(content)
( .useFixedPanelHeights)
// We are in fixed panel height mode and the user passed
in
// a panel height for us to use.
( .fixedPanelHeight)
content.style.height = .fixedPanelHeight + "px";
// We are in variable panel height mode, but since we ca
n't
// calculate the panel height here, we just set the heig
ht to
// auto so that it expands to show all of its content.
content.style.height = "auto";
.removeClassName(panel, .openClass);
.addClassName(panel, .closedClass);
(content)
content.style.height = "0px";
content.style.display = "none";
.attachPanelHandlers(panel);
;
Spry.Widget.Accordion.prototype.attachBehaviors =
()
a panels = .getPanels();
(a i = 0; i < panels.length; i++)
.initPanel(panels[i], i == .defaultPanel);
Spry.Widget.Accordion.prototype.getPanels =
()
.getElementChildren( .element);
;
Spry.Widget.Accordion.prototype.getCurrentPanel =
()
.currentPanel;
;
Spry.Widget.Accordion.prototype.getPanelIndex =
(panel)
a panels = .getPanels();
( a i = 0 ; i < panels.length; i++ )
( panel == panels[i] )
i;
-1;
;
Spry.Widget.Accordion.prototype.getCurrentPanelIndex =
()
.getPanelIndex( .currentPanel);
;
Spry.Widget.Accordion.prototype.getPanelTab =
(panel)
(!panel)
null;
.getElementChi ldren(panel)[ 0];
;
Spry.Widget.Accordion.prototype.getPanelContent =
(panel)
(!panel)
null;
.getElementChildren(panel)[ 1];
;
Spry.Widget.Accordion.prototype.getElementChildren =
(elemen
t)
a children = [];
a child = element.firstChild;
(child)
(child.nodeType == 1 /* Node.ELEMENT_NODE */)
children.push(child);
child = child.nextSibling;
children;
;
Spry.Widget.Accordion.prototype.focus =
()
( .element && .element.focus)
.element.focus();
;
Spry.Widget.Accordion.prototype.blur =
()
( .element && .element.blur)
.element.blur() ;
;
/////////////////////////////////////////////////////
Spry.Widget.Accordion.PanelAnimator =
(accordion, panel, opt
s)
.timer = null;
.interval = 0;
.fps = 60;
.duration = 500;
.startTime = 0;
.transition = Spry.Widget.Accordion.PanelAnimator.defaultTran
sition;
.onComplete = null;
.panel = panel;
.panelToOpen = accordion.getElement(panel);
.panelData = [];
.useFixedPanelHeights = accordion.us eFixedPanelHeights;
a panels = accordion.getPanels();
(a i = 0; i < panels.length; i++)
a p = panels[i];
a c = accordion.getPanelContent(p);
(c)
a h = c.offsetHeight;
(h == )
h = 0;
(p == panel && h == 0)
c.style.display = "block";
(p == panel || h > 0)
a obj = Object;
obj.panel = p;
obj.content = c;
obj.fromHeight = h;
obj.toHeight = (p == panel) ? (accordion. useFixedPanelHe
ights ? accordion.fixedPanelHeight : c.scrollHeight) : 0;
obj.distance = obj.toHeight - obj.fromHeight;
obj.overflow = c.style.overflow;
.panelData.push(obj);
c.style.overflow = "hidden";
c.style.height = h + "px";
;
Spry.Widget.Accordion.PanelAnimator.defaultTransition =
(tim
e, begin, finish, duration) time /= duration; begin + ((2 -
time) * time * finish); ;
Spry.Widget.Accordion.PanelAnimator.prototype.stop =
()
( .timer)
clearTimeout( .timer);
.timer = null;
;
Spry.Widget.Accordion.PanelAnimator.prototype.stepAnimation =
()
a curTime = ( Date).getTime();
a elapsedTime = curTime - .startTime;
a i, obj;
(i = 0; i < .panelData.length; i++)
obj = .panelData[i];
a ht = .transition(elapsedTime, obj.fromHeight, obj.dist
ance, .duration);
obj.content.style.height = ((ht < 0) ? 0 : ht) + "px";
a self = ;
.timer = setTimeout(
() self.stepAnimation(); ,
.interval);
;
)2
*
2
&!0'
$
3"4*!
c
3"4*