From 8dc96d22f2fcd6d6072d5bb891ae9d27c1890287 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Mon, 2 Jul 2007 13:56:01 +0000 Subject: [PATCH] (javascript) Caching some elements in closures at load time to minimize the time between clicking and the start of the animations. --- templates/history.tmpl | 6 ++++-- templates/tool_menu.tmpl | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/templates/history.tmpl b/templates/history.tmpl index 25d70cf93fc..160680b0b79 100644 --- a/templates/history.tmpl +++ b/templates/history.tmpl @@ -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( "" ).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(); } diff --git a/templates/tool_menu.tmpl b/templates/tool_menu.tmpl index 801c59a5750..628a85ece5d 100644 --- a/templates/tool_menu.tmpl +++ b/templates/tool_menu.tmpl @@ -15,19 +15,19 @@ q( "div.toolSectionBody" ).hide(); q( "div.toolSectionTitle > span" ).wrap( "" ) 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; + } + }); }); });