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.js41
1 files changed, 40 insertions, 1 deletions
diff --git a/lib/gallery.common.js b/lib/gallery.common.js
index 4ac6de70..7c52fef0 100644
--- a/lib/gallery.common.js
+++ b/lib/gallery.common.js
@@ -1,4 +1,6 @@
(function ($) {
+
+ // Fade in action status message background color
$.fn.gallery_show_message = function(message) {
return this.each(function(i){
$(this).effect("highlight", {"color": "white"}, 3000);
@@ -17,7 +19,6 @@
return $(this).height(tallest_height);
};
-
// Vertically align a block element's content
$.fn.gallery_valign = function(container) {
return this.each(function(i){
@@ -123,6 +124,7 @@
$(thumb).attr({src: data.src, width: data.width, height: data.height});
};
+ // Initialize context menus
$.fn.gallery_context_menu = function() {
if ($(".g-context-menu li").length) {
var hover_target = ".g-context-menu";
@@ -144,6 +146,7 @@
}
};
+ // 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,
@@ -169,4 +172,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);