(javascript) Caching some elements in closures at load time to minimize the

time between clicking and the start of the animations.
This commit is contained in:
James Taylor
2007-07-02 13:56:01 +00:00
parent 75642cd3d4
commit 8dc96d22f2
2 changed files with 16 additions and 14 deletions
+4 -2
View File
@@ -33,6 +33,7 @@
// Load saved state and show as neccesary
var state = new CookieSet( "galaxy.history.expand_state" );
for ( id in state.store ) { q( "#" + id ).find( "div.historyItemBody" ).show(); }
// If Mozilla, hide scrollbars in hidden items since they cause animation bugs
if ( q.browser.mozilla ) {
q( "div.historyItemBody" ).each( function() {
if ( ! q(this).is( ":visible" ) ) q(this).find( "pre.peek" ).css( "overflow", "hidden" );
@@ -42,15 +43,16 @@
q( "div.historyItemWrapper" ).each( function() {
var id = this.id;
var body = q(this).children( "div.historyItemBody" );
var peek = body.find( "pre.peek" )
q(this).children( "table" ).find( "span.historyItemTitle" ).wrap( "<a href='#'></a>" ).click( function() {
if ( body.is(":visible") ) {
if ( q.browser.mozilla ) { body.find( "pre.peek" ).css( "overflow", "hidden" ) }
if ( q.browser.mozilla ) { peek.css( "overflow", "hidden" ) }
body.slideUp( "fast" );
state.remove( id); state.save();
}
else {
body.slideDown( "fast", function() {
if ( q.browser.mozilla ) { body.find( "pre.peek" ).css( "overflow", "auto" ); }
if ( q.browser.mozilla ) { peek.css( "overflow", "auto" ); }
});
state.add( id ); state.save();
}
+12 -12
View File
@@ -15,19 +15,19 @@
q( "div.toolSectionBody" ).hide();
q( "div.toolSectionTitle > span" ).wrap( "<a href='#'></a>" )
var last_expanded = null;
q( "div.toolSectionTitle" ).click( function() {
q( "div.toolSectionTitle" ).each( function() {
var body = q(this).next( "div.toolSectionBody" );
if ( body.is( ":hidden" ) )
{
if ( last_expanded ) last_expanded.slideUp( "fast" );
last_expanded = body;
body.slideDown( "fast" );
}
else
{
body.slideUp( "fast" );
last_expanded = null;
}
q(this).click( function() {
if ( body.is( ":hidden" ) ) {
if ( last_expanded ) last_expanded.slideUp( "fast" );
last_expanded = body;
body.slideDown();
}
else {
body.slideUp();
last_expanded = null;
}
});
});
});
</script>