diff options
| author | Jakob Hilden <jhild@umich.edu> | 2009-03-25 04:47:25 +0000 | 
|---|---|---|
| committer | Jakob Hilden <jhild@umich.edu> | 2009-03-25 04:47:25 +0000 | 
| commit | b909132f54d6dd3a1a9455a3255767ef26bce658 (patch) | |
| tree | dd896ba004dd8dd4e06c90f550b315eaa5a3ed49 /modules/tag | |
| parent | 0a4bce3f674dcb719ef16d52a6034d85b250083c (diff) | |
tag changes in the tag admin should now work as expected
Diffstat (limited to 'modules/tag')
| -rw-r--r-- | modules/tag/controllers/admin_tags.php | 4 | ||||
| -rw-r--r-- | modules/tag/js/tag.js | 51 | ||||
| -rw-r--r-- | modules/tag/views/admin_tags.html.php | 12 | 
3 files changed, 65 insertions, 2 deletions
| diff --git a/modules/tag/controllers/admin_tags.php b/modules/tag/controllers/admin_tags.php index d6ae310b..90b051aa 100644 --- a/modules/tag/controllers/admin_tags.php +++ b/modules/tag/controllers/admin_tags.php @@ -103,7 +103,9 @@ class Admin_Tags_Controller extends Admin_Controller {        print json_encode(          array("result" => "success", -              "location" => url::site("admin/tags"))); +              "location" => url::site("admin/tags"), +              "tag_id" => $tag->id, +              "new_tagname" => $tag->name));      } else {        print json_encode(          array("result" => "error", 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 diff --git a/modules/tag/views/admin_tags.html.php b/modules/tag/views/admin_tags.html.php index 484cb759..db51555a 100644 --- a/modules/tag/views/admin_tags.html.php +++ b/modules/tag/views/admin_tags.html.php @@ -1,9 +1,19 @@  <?php defined("SYSPATH") or die("No direct script access.") ?> +<script src="<?= url::file("modules/tag/js/tag.js") ?>" type="text/javascript"></script>  <script>    $("document").ready(function() { -    // $("#gTagAdmin .tag-name").attr("title", "<?= t("Click to edit this tag") ?>"); +    // using JS for adding link titles to avoid running t() for each tag +    $("#gTagAdmin .tag-name").attr("title", "<?= t("Click to edit this tag") ?>");      $("#gTagAdmin .delete-link").attr("title", $(".delete-link:first span").html()); +     +    // In-place editing for tag admin +    $(".gEditable").bind("click", editInplace);    }); +  // make some values available within tag.js +  var csrf_token = "<?= access::csrf_token() ?>"; +  var save_i18n = '<?= t("save") ?>'; +  var or_i18n = '<?= t("or") ?>'; +  var cancel_i18n = '<?= t("cancel") ?>';  </script>  <div class="gBlock">    <h2> | 
