summaryrefslogtreecommitdiff
path: root/lib/gallery.in_place_edit.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gallery.in_place_edit.js')
-rw-r--r--lib/gallery.in_place_edit.js27
1 files changed, 18 insertions, 9 deletions
diff --git a/lib/gallery.in_place_edit.js b/lib/gallery.in_place_edit.js
index 4a90581b..681688e5 100644
--- a/lib/gallery.in_place_edit.js
+++ b/lib/gallery.in_place_edit.js
@@ -2,7 +2,6 @@
$.widget("ui.gallery_in_place_edit", {
_init: function() {
var self = this;
- $(self).data("parent", self.element.parent());
this.element.click(function(event) {
event.preventDefault();
self._show(event.currentTarget);
@@ -15,11 +14,9 @@
var tag_width = $(target).width();
$(self).data("tag_width", tag_width);
- var form = $("#g-inplace-edit-form");
+ var form = $("#g-in-place-edit-form");
if (form.length > 0) {
- var parent = form.parent();
- form.remove();
- parent.children().show();
+ self._cancel();
}
$.get(self.options.form_url.replace("__ID__", $(target).attr('rel')), function(data) {
@@ -31,8 +28,7 @@
.focus();
$(".g-short-form").gallery_short_form();
parent.find("form .g-cancel").click(function(event) {
- parent.find("form").remove();
- parent.children().show();
+ self._cancel();
event.preventDefault();
return false;
});
@@ -41,21 +37,34 @@
},
+ _cancel: function() {
+ var parent = $("#g-in-place-edit-form").parent();
+ $(parent).find("form").remove();
+ $(parent).children().show();
+ $("#g-in-place-edit-message").remove();
+ },
+
_ajaxify_edit: function() {
var self = this;
- var form = $($(self).data("parent")).find("form");
+ var form = $("#g-in-place-edit-form");
$(form).ajaxForm({
dataType: "json",
success: function(data) {
if (data.result == "success") {
window.location.reload();
} else {
+ var parent = $(form).parent();
$(form).replaceWith(data.form);
var width = $(self).data("tag_width");
- $($(self).data("parent")).find("form :text")
+ $(parent).find("form :text")
.width(width)
.focus();
$(".g-short-form").gallery_short_form();
+ $(parent).find("form .g-cancel").click(function(event) {
+ self._cancel();
+ event.preventDefault();
+ return false;
+ });
self._ajaxify_edit();
}
}