summaryrefslogtreecommitdiff
path: root/modules/tag/js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/tag/js')
-rw-r--r--modules/tag/js/tag.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js
index 3cbc30bf..b0ba2516 100644
--- a/modules/tag/js/tag.js
+++ b/modules/tag/js/tag.js
@@ -15,3 +15,54 @@ function ajaxify_tag_form() {
}
});
}
+
+function closeEditInPlaceForms() {
+ // closes currently open inplace edit forms
+ if ($("#gRenameTagForm").length) {
+ var li = $("#gRenameTagForm").parent();
+ $("#gRenameTagForm").parent().html($("#gRenameTagForm").parent().data("revert"));
+ li.height("");
+ $(".gEditable", li).bind("click", editInplace);
+ $(".gDialogLink", li).bind("click", handleDialogEvent);
+ }
+}
+
+function editInplace(element) {
+ closeEditInPlaceForms();
+
+ // creat edit form
+ var tag_id = $(this).attr('id').substr(5);
+ var tag_name = $(this).text();
+ var tag_width = $(this).width();
+ $(this).parent().data("revert", $(this).parent().html());
+ var form = '<form id="gRenameTagForm" method="post" class="ui-helper-clearfix" ';
+ form += 'action="/gallery3/index.php/admin/tags/rename/' + tag_id + '">';
+ form += '<input name="csrf" type="hidden" value="' + csrf_token + '" />';
+ form += '<input id="name" name="name" type="text" class="textbox" value="' + tag_name + '" />';
+ form += '<input type="submit" class="submit ui-state-default ui-corner-all" value="' + save_i18n + '" />';
+ form += '<span>' + or_i18n + '</span> <a href="#">' + cancel_i18n + '</a>';
+ form += '</form>';
+
+ // add edit form
+ $(this).parent().html(form);
+ $("#gRenameTagForm #name")
+ .width(tag_width+30)
+ .focus();
+ //$("#gRenameTagForm").parent().height( $("#gRenameTagForm").height() );
+ $("#gRenameTagForm a").bind("click", closeEditInPlaceForms);
+
+ ajaxify_editInplaceForm = function() {
+ $("#gRenameTagForm").ajaxForm({
+ dataType: "json",
+ success: function(data) {
+ if (data.result == "success") {
+ closeEditInPlaceForms(); // close form
+ $("#gTag-" + data.tag_id).text(data.new_tagname); // update tagname
+ console.log(data);
+ window.location.reload();
+ }
+ }
+ });
+ };
+ ajaxify_editInplaceForm();
+} \ No newline at end of file