From 72a8ce696e37a74ed8bbea31364b39f9e0776bbc Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Thu, 5 Nov 2009 12:59:37 -0800 Subject: Refactor out the in place editting and use the new gallery.in_place_edit widget to manage the tag renames. Part the fix for ticket #750. --- modules/tag/js/tag.js | 71 --------------------------------------------------- 1 file changed, 71 deletions(-) (limited to 'modules/tag/js') diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js index 8cb4e571..4760084d 100644 --- a/modules/tag/js/tag.js +++ b/modules/tag/js/tag.js @@ -1,7 +1,3 @@ -$("document").ready(function() { - ajaxify_tag_form(); -}); - function ajaxify_tag_form() { $("#g-tag form").ajaxForm({ dataType: "json", @@ -15,70 +11,3 @@ function ajaxify_tag_form() { } }); } - -function closeEditInPlaceForms() { - // closes currently open inplace edit forms - if ($("#g-rename-tag-form").length) { - $("#g-action-status").remove(); - var li = $("#g-rename-tag-form").parent(); - $("#g-rename-tag-form").parent().html($("#g-rename-tag-form").parent().data("revert")); - li.height(""); - $(".g-editable", li).bind("click", editInPlace); - $(".g-dialog-link", li).gallery_dialog(); - } -} - -function str_replace(search_term, replacement, string) { - var temp = string.split(search_term); - return temp.join(replacement); -} - -function editInPlace(element) { - closeEditInPlaceForms(); - - // create edit form - var tag_id = $(this).attr('rel'); - var tag_name = $(this).html(); - var tag_width = $(this).width(); - $(this).parent().data("revert", $(this).parent().html()); - var form = '
'; - form += ''; - form += ''; - form += '
'; - - // add edit form - $(this).parent().html(form); - $("#g-rename-tag-form #name") - .width(tag_width) - .focus(); - $(".g-short-form").gallery_short_form(); - $("#g-rename-tag-form .g-cancel").bind("click", closeEditInPlaceForms); - - ajaxify_editInPlaceForm = function() { - $("#g-rename-tag-form").ajaxForm({ - dataType: "json", - success: function(data) { - if (data.result == "success") { - closeEditInPlaceForms(); // close form - $(".g-tag[rel=" + data.tag_id + "]").text(data.new_tagname); // update tagname - window.location.reload(); - } else if (data.result == "error") { - $("#g-rename-tag-form #name") - .addClass("g-error") - .focus(); - var message = ""; - $("#g-tag-admin").before(message); - } - } - }); - }; - ajaxify_editInPlaceForm(); -} -- cgit v1.2.3