From 959fa91f49dd0de72c52d58a9ffb65bcf471dcb2 Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Wed, 31 Dec 2008 04:10:03 +0000 Subject: Minor refactor. Move some stuff out of $("document").ready to functions. Comment updates. --- themes/default/js/ui.init.js | 48 ++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 22 deletions(-) (limited to 'themes/default/js/ui.init.js') diff --git a/themes/default/js/ui.init.js b/themes/default/js/ui.init.js index c282ce74..3a2914ee 100644 --- a/themes/default/js/ui.init.js +++ b/themes/default/js/ui.init.js @@ -11,17 +11,19 @@ var shortForms = new Array( $("document").ready(function() { - // Vertical align thumbnails/metadata in album grid + // Album view only if ($(".gItem").length) { + // Vertical align thumbnails/metadata in album grid $(".gItem").wrapInner("
") $('.gItem div').vAlign(); } - // Apply modal dialog class - $(".gMenuLink").addClass("gDialogLink"); - $("#gLoginLink").addClass("gDialogLink"); + // Photo/Item item view only + if ($("#gItem").length) { + sizedImage(); + } - // Add Superfish menu class + // Apply Superfish menus $("ul.gMenu").addClass("sf-menu"); $("ul#gViewMenu").addClass("sf-menu"); @@ -35,28 +37,15 @@ $("document").ready(function() { speed: 'fast' }); - // Reduce width of sized photo if it is wider than its parent container - if ($("#gItem").length) { - var containerWidth = $("#gItem").width(); - var oPhoto = $("#gItem img").filter(function() { - return this.id.match(/gPhotoID-/); - }); - if (containerWidth < oPhoto.width()) { - var proportion = containerWidth / oPhoto.width(); - oPhoto.width(containerWidth); - oPhoto.height(proportion * oPhoto.height()); - } - } - - /** - * Attach event listeners to open modal dialogs - */ + // Apply modal dialogs + $(".gMenuLink").addClass("gDialogLink"); + $("#gLoginLink").addClass("gDialogLink"); var dialogLinks = $(".gDialogLink"); for (var i=0; i < dialogLinks.length; i++) { $(dialogLinks[i]).bind("click", {element: dialogLinks[i]}, handleDialogEvent); }; - // Declare which forms are short forms + // Short forms handleShortFormEvent(shortForms); }); @@ -71,6 +60,21 @@ $.fn.vAlign = function() { }); }; +/** + * Reduce width of sized photo if it's wider than its parent container + */ +function sizedImage() { + var containerWidth = $("#gItem").width(); + var oPhoto = $("#gItem img").filter(function() { + return this.id.match(/gPhotoID-/); + }); + if (containerWidth < oPhoto.width()) { + var proportion = containerWidth / oPhoto.width(); + oPhoto.width(containerWidth); + oPhoto.height(proportion * oPhoto.height()); + } +} + /** * Fire openDialog() and prevent links from opening * -- cgit v1.2.3