Refactor duplicated and abbreviated animationRate variable

This commit is contained in:
Eric Davis 2011-10-28 14:45:30 -07:00
parent a592f024cb
commit 923cdf3ff3
1 changed files with 12 additions and 14 deletions

View File

@ -370,19 +370,20 @@ function hideOnLoad() {
Event.observe(window, 'load', hideOnLoad); Event.observe(window, 'load', hideOnLoad);
// a few constants for animations speeds, etc.
var animationRate = 100;
/* jQuery code from #263 */ /* jQuery code from #263 */
/* TODO: integrate with existing code and/or refactor */ /* TODO: integrate with existing code and/or refactor */
jQuery(document).ready(function($) { jQuery(document).ready(function($) {
// a few constants for animations speeds, etc.
var animRate = 100;
// header menu hovers // header menu hovers
$("#account .drop-down").hover(function() { $("#account .drop-down").hover(function() {
$(this).addClass("open").find("ul").slideDown(animRate); $(this).addClass("open").find("ul").slideDown(animationRate);
$("#top-menu").toggleClass("open"); $("#top-menu").toggleClass("open");
}, function() { }, function() {
$(this).removeClass("open").find("ul").slideUp(animRate); $(this).removeClass("open").find("ul").slideUp(animationRate);
$("#top-menu").toggleClass("open"); $("#top-menu").toggleClass("open");
}); });
@ -392,7 +393,7 @@ jQuery(document).ready(function($) {
var searchWidth = $("#account-nav").width(); var searchWidth = $("#account-nav").width();
$(this).toggleClass("open"); $(this).toggleClass("open");
$("#nav-search").width(searchWidth).slideToggle(animRate, function(){ $("#nav-search").width(searchWidth).slideToggle(animationRate, function(){
$("#nav-search-box").select(); $("#nav-search-box").select();
}); });
@ -415,7 +416,7 @@ jQuery(document).ready(function($) {
// show/hide the files table // show/hide the files table
$(".attachments h4").click(function() { $(".attachments h4").click(function() {
$(this).toggleClass("closed").next().slideToggle(animRate); $(this).toggleClass("closed").next().slideToggle(animationRate);
}); });
// custom function for sliding the main-menu. IE6 & IE7 don't handle sliding very well // custom function for sliding the main-menu. IE6 & IE7 don't handle sliding very well
@ -426,7 +427,7 @@ jQuery(document).ready(function($) {
// this forces IE to redraw the menu area, un-bollocksing things // this forces IE to redraw the menu area, un-bollocksing things
$("#main-menu").css({paddingBottom:5}).animate({paddingBottom:0}, 10); $("#main-menu").css({paddingBottom:5}).animate({paddingBottom:0}, 10);
} else { } else {
this.slideToggle(animRate); this.slideToggle(animationRate);
} }
return this; return this;
@ -445,9 +446,9 @@ jQuery(document).ready(function($) {
// submenu flyouts // submenu flyouts
$("#main-menu li li:has(ul)").hover(function() { $("#main-menu li li:has(ul)").hover(function() {
$(this).find(".profile-box").show(); $(this).find(".profile-box").show();
$(this).find("ul").slideDown(animRate); $(this).find("ul").slideDown(animationRate);
}, function() { }, function() {
$(this).find("ul").slideUp(animRate); $(this).find("ul").slideUp(animationRate);
}); });
// add filter dropdown menu // add filter dropdown menu
@ -456,19 +457,16 @@ jQuery(document).ready(function($) {
// is this inside the title bar? // is this inside the title bar?
if (tgt.parents().is(".title-bar")) { if (tgt.parents().is(".title-bar")) {
$(".title-bar-extras:hidden").slideDown(animRate); $(".title-bar-extras:hidden").slideDown(animationRate);
} }
$(this).parent().find("ul").slideToggle(animRate); $(this).parent().find("ul").slideToggle(animationRate);
return false; return false;
}); });
}); });
/* Appended 2009-07-07 */
var animRate = 100;
// returns viewport height // returns viewport height
jQuery.viewportHeight = function() { jQuery.viewportHeight = function() {
return self.innerHeight || return self.innerHeight ||