📄 accordionbehavior.js
字号:
// unifying them into a single animation would be a lot messier than the current
// implementation since they won't both play when we're closing the currently open pane).
if (close) {
close.play();
}
if (open) {
open.play();
}
// TODO: Someday get both animations to run on the same timer because it makes an obvious
// difference in IE6 and Safari
},
_startPaneChange : function(pane, opening) {
/// <summary>
/// Setup the pane before it is animated.
/// </summary>
/// <param name="pane" type="Object" mayBeNull="false">
/// Pane that is being animated
/// </param>
/// <param name="opening" type="Boolean" mayBeNull="false">
/// Whether or not the pane is being opened or closed
/// </param>
/// <returns />
var wrapper = pane.content;
var original = wrapper._original;
if (opening) {
// Make the hidden panes visible so we can see them animate
wrapper.style.display = 'block';
} else {
// Hide any overflow because we'll be shrinking the wrapper div down to 0px and
// we don't want content leaking out the bottom
wrapper.style.overflow = 'hidden';
// Turn off overflow on the original div because it's content doesn't grow during
// the animation and leaving it on slows the animation down
original.style.overflow = 'hidden';
// Remove any explicit height off the original content section but manually set
// the wrapper to the initial height (since it will be shrunk from this height
// to zero)
if (this._autoSize === AjaxControlToolkit.AutoSize.Limit) {
wrapper.style.height = this._getTotalSize(original).height + 'px';
original.style.maxHeight = '';
}
}
},
_endPaneChange : function(pane, opening) {
/// <summary>
/// Clean the pane up after it's been animated.
/// </summary>
/// <param name="pane" type="Object" mayBeNull="false">
/// Pane that is being animated
/// </param>
/// <param name="opening" type="Boolean" mayBeNull="false">
/// Whether or not the pane is being opened or closed
/// </param>
/// <returns />
var wrapper = pane.content;
var original = wrapper._original;
if (opening) {
// Depending on the mode, move the explicit height value from the original
// content div to the wrapper div. This is necessary because we moved the
// explicit height value to the wrapper before the animation started since
// it was the target.
if (this._autoSize === AjaxControlToolkit.AutoSize.Limit) {
var remaining = this._getRemainingHeight(true);
original.style.maxHeight = remaining + 'px';
}
// Turn overflow back on so the original div's content can grow accordingly
original.style.overflow = 'auto';
// Remove an explicit height from the wrapper div so that it will
// automatically grow and shrink with the original content div
wrapper.style.height = 'auto';
wrapper.style.overflow = 'auto';
} else {
// If we finished a close animation, completely hide the pane so that
// it's content cannot be tabbed into
wrapper.style.display = 'none';
}
},
_getHeadersSize : function() {
/// <summary>
/// Compute the size of all the header sections
/// </summary>
/// <returns type="Object" mayBeNull="false">
/// Size of all header sections (of the form {width, height}).
/// </returns>
// Compute the amount of space used by all the headers
var total = { width: 0, height: 0 };
for (var i = 0; i < this._panes.length; i++) {
var size = this._getTotalSize(this._panes[i].header);
total.width = Math.max(total.width, size.width);
total.height += size.height;
}
return total;
},
_getRemainingHeight : function(includeGutter) {
/// <summary>
/// Determine how much remaining height we have to fill with the currently selected
/// pane's content section after taking into account all the headers. This is primarily
/// used for the Limit and Fill AutoSize modes.
/// </summary>
/// <param name="includeGutter" type="Boolean" mayBeNull="false">
/// Whether or not we should include the gutter (padding, borders, margins) of the
/// selected pane's original content section. This should be true whenever we're
/// getting the remaining height for the original content section and false whenever
/// we're getting the remaining height for its wrapper.
/// </param>
/// <returns type="Number" integer="true">
/// Remaining height after all the headers have been accounted for
/// </returns>
var height = 0;
var pane = this.get_Pane();
if (this._autoSize === AjaxControlToolkit.AutoSize.None) {
// If the AutoSize mode is "None", then we use the size of the pane
if (pane) {
height = this._getTotalSize(pane.content._original).height;
}
} else {
// Compute the amount of space used
height = this._headersSize;
if (includeGutter && pane) {
height += this._getGutterSize(pane.content._original).height;
}
// Determine how much of the remaining space to use
// (if AutoSize is "Fill", use the rest of the available space)
var accordion = this.get_element();
height = Math.max(accordion.offsetHeight - height, 0);
// If AutoSize is "Limit", then the size of the pane should be either its
// actual size, or the rest of the available space.
if (pane && (this._autoSize === AjaxControlToolkit.AutoSize.Limit)) {
var required = this._getTotalSize(pane.content._original).height;
// Ensure we return a number greater than or equal to zero
if (required > 0) {
height = Math.min(height, required);
}
}
}
return height;
},
_getTotalSize : function(element) {
/// <summary>
/// Get the total size of an element, including its margins
/// </summary>
/// <param name="element" type="Sys.UI.DomElement" domElement="true">
/// Element
/// </param>
/// <returns type="Object">
/// Total size of the element (in the form {width, height})
/// </returns>
var size = $common.getSize(element);
var box = $common.getMarginBox(element);
size.width += box.horizontal;
size.height += box.vertical;
return size;
},
_getGutterSize : function(element) {
/// <summary>
/// Get the extra "gutter" size around an element made up of its padding,
/// borders, and margins.
/// </summary>
/// <param name="element" type="Sys.UI.DomElement" domElement="true">
/// Element
/// </param>
/// <returns type="Object">
/// Size of the extra space (in the form of {height, width})
/// </returns>
var gutter = { width: 0, height: 0 };
try {
var box = $common.getPaddingBox(element);
gutter.width += box.horizontal;
gutter.height += box.vertical;
} catch(ex) { }
try {
var box = $common.getBorderBox(element);
gutter.width += box.horizontal;
gutter.height += box.vertical;
} catch(ex) { }
var box = $common.getMarginBox(element);
gutter.width += box.horizontal;
gutter.height += box.vertical;
return gutter;
},
add_selectedIndexChanging : function(handler) {
/// <summary>
/// Add an event handler for the selectedIndexChanging event
/// </summary>
/// <param name="handler" type="Function" mayBeNull="false">
/// Event handler
/// </param>
/// <returns />
this.get_events().addHandler('selectedIndexChanging', handler);
},
remove_selectedIndexChanging : function(handler) {
/// <summary>
/// Add an event handler for the selectedIndexChanging event
/// </summary>
/// <param name="handler" type="Function" mayBeNull="false">
/// Event handler
/// </param>
/// <returns />
this.get_events().removeHandler('selectedIndexChanging', handler);
},
raiseSelectedIndexChanging : function(eventArgs) {
/// <summary>
/// Raise the selectedIndexChanging event
/// </summary>
/// <param name="eventArgs" type="AjaxControlToolkit.AccordionSelectedIndexChangeEventArgs" mayBeNull="false">
/// Event arguments for the selectedIndexChanging event
/// </param>
/// <returns />
var handler = this.get_events().getHandler('selectedIndexChanging');
if (handler) {
handler(this, eventArgs);
}
},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -