summaryrefslogtreecommitdiff
path: root/lib/gallery.common.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gallery.common.js')
-rw-r--r--lib/gallery.common.js105
1 files changed, 79 insertions, 26 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js
index c6a619c1..9aaac1ce 100644
--- a/lib/gallery.common.js
+++ b/lib/gallery.common.js
@@ -1,9 +1,21 @@
(function ($) {
- $.fn.gallery_show_message = function(message) {
+
+ // Fade in action status message background color
+ $.fn.gallery_show_message = function() {
return this.each(function(i){
- $(this).effect("highlight", {"color": "white"}, 3000);
- $(this).animate({opacity: 1.0}, 6000);
+ $(this).hide().fadeIn(3000)
+ });
+ };
+
+ // Make the height of all items the same as the tallest item within the set
+ $.fn.equal_heights = function() {
+ var tallest_height = 0;
+ $(this).each(function(){
+ if ($(this).height() > tallest_height) {
+ tallest_height = $(this).height();
+ }
});
+ return $(this).height(tallest_height);
};
// Vertically align a block element's content
@@ -12,8 +24,8 @@
if (container == null) {
container = 'div';
}
- $(this).html("<" + container + " class=\"gValign\">" + $(this).html() + "</" + container + ">");
- var el = $(this).children(container + ".gValign");
+ $(this).html("<" + container + " class=\"g-valign\">" + $(this).html() + "</" + container + ">");
+ var el = $(this).children(container + ".g-valign");
var elh = $(el).height();
var ph = $(this).height();
var nh = (ph - elh) / 2;
@@ -35,21 +47,21 @@
/**
* Toggle the processing indicator, both large and small
- * @param elementID Target ID, including #, to apply .gLoadingSize
+ * @param elementID Target ID, including #, to apply .g-loading-size
*/
$.fn.gallery_show_loading = function() {
return this.each(function(i){
var size;
switch ($(this).attr("id")) {
- case "#gDialog":
- case "#gPanel":
- size = "Large";
+ case "#g-dialog":
+ case "#g-panel":
+ size = "large";
break;
default:
- size = "Small";
+ size = "small";
break;
}
- $(this).toggleClass("gLoading" + size);
+ $(this).toggleClass("g-loading" + size);
});
};
@@ -77,7 +89,7 @@
*/
$.fn.gallery_get_photo = function() {
var photo = $(this).find("img").filter(function() {
- return this.id.match(/gPhotoId-\d+/);
+ return this.id.match(/g-photo-id-\d+/);
});
return photo;
};
@@ -111,24 +123,29 @@
$(thumb).attr({src: data.src, width: data.width, height: data.height});
};
+ // Initialize context menus
$.fn.gallery_context_menu = function() {
- var in_progress = 0;
- $(".gContextMenu *").removeAttr('title');
- $(".gContextMenu ul").hide();
- $(".gContextMenu").hover(
- function() {
- if (in_progress == 0) {
- $(this).find("ul").slideDown("fast", function() { in_progress = 1; });
- $(this).find(".gDialogLink").gallery_dialog();
- $(this).find(".gAjaxLink").gallery_ajax();
+ if ($(".g-context-menu li").length) {
+ var hover_target = ".g-context-menu";
+ var in_progress = 0;
+ $(hover_target + " *").removeAttr('title');
+ $(hover_target + " ul").hide();
+ $(hover_target).hover(
+ function() {
+ if (in_progress == 0) {
+ $(this).find("ul").slideDown("fast", function() { in_progress = 1; });
+ $(this).find(".g-dialog-link").gallery_dialog();
+ $(this).find(".g-ajax-link").gallery_ajax();
+ }
+ },
+ function() {
+ $(this).find("ul").slideUp("slow", function() { in_progress = 0; });
}
- },
- function() {
- $(this).find("ul").slideUp("slow", function() { in_progress = 0; });
- }
- );
+ );
+ }
};
+ // Size a container to fit within the browser window
$.gallery_auto_fit_window = function(imageWidth, imageHeight) {
var size = $.gallery_get_viewport_size();
var width = size.width() - 6,
@@ -154,4 +171,40 @@
};
};
+ // Initialize a short form. Short forms may contain only one text input.
+ $.fn.gallery_short_form = function() {
+ return this.each(function(i){
+ var label = $(this).find("label:first");
+ var input = $(this).find("input[type=text]:first");
+ var button = $(this).find("input[type=submit]");
+
+ $(".g-short-form").addClass("ui-helper-clearfix");
+ $(".g-short-form input[type=text]").addClass("ui-corner-left");
+ $(".g-short-form input[type=submit]").addClass("ui-state-default ui-corner-right");
+
+ // Set the input value equal to label text
+ if (input.val() == "") {
+ input.val(label.html());
+ button.enable(false);
+ }
+
+ // Attach event listeners to the input
+ input.bind("focus", function(e) {
+ // Empty input value if it equals it's label
+ if ($(this).val() == label.html()) {
+ $(this).val("");
+ }
+ button.enable(true);
+ });
+
+ input.bind("blur", function(e){
+ // Reset the input value if it's empty
+ if ($(this).val() == "") {
+ $(this).val(label.html());
+ button.enable(false);
+ }
+ });
+ });
+ };
+
})(jQuery);