summaryrefslogtreecommitdiff
path: root/themes/default/js/ui.init.js
diff options
context:
space:
mode:
authorChad Kieffer <chad@2tbsp.com>2008-12-31 04:10:03 +0000
committerChad Kieffer <chad@2tbsp.com>2008-12-31 04:10:03 +0000
commit959fa91f49dd0de72c52d58a9ffb65bcf471dcb2 (patch)
tree7f9bb07d31158fc4e7160af4b9abf9e3d986ce58 /themes/default/js/ui.init.js
parent1579494ec4acb80e103a40106aea1630628c00d2 (diff)
Minor refactor. Move some stuff out of $("document").ready to functions. Comment updates.
Diffstat (limited to 'themes/default/js/ui.init.js')
-rw-r--r--themes/default/js/ui.init.js48
1 files changed, 26 insertions, 22 deletions
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("<div></div>")
$('.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);
});
@@ -72,6 +61,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
*
* @see openDialog()