diff options
| author | Bharat Mediratta <bharat@menalto.com> | 2008-11-08 09:28:11 +0000 |
|---|---|---|
| committer | Bharat Mediratta <bharat@menalto.com> | 2008-11-08 09:28:11 +0000 |
| commit | 950c58e6d37f68f69815d4d73df5577b9789679a (patch) | |
| tree | f8f176513d9b364b4b0a7b2a6e87ade8af11baeb /core/views | |
| parent | ac8199a09a810277624c93fd82e49d2250ae0461 (diff) | |
Add support for in-place editing of data fields.
Diffstat (limited to 'core/views')
| -rw-r--r-- | core/views/in_place_edit.html.php | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/core/views/in_place_edit.html.php b/core/views/in_place_edit.html.php new file mode 100644 index 00000000..adcad6c6 --- /dev/null +++ b/core/views/in_place_edit.html.php @@ -0,0 +1,38 @@ +<? defined("SYSPATH") or die("No direct script access."); ?> +<script type="text/javascript"> +$(document).ready(function() { + ajax_update = function(className, id) { + return function(value, settings) { + $.post("<?= url::site("item/__ID__") ?>".replace("__ID__", id), + {"key": settings.name, "value": value}, + function(data, textStatus) { + if (textStatus == "success") { + $(className).html(data); + } + }, + "html"); + } + } + + var seen_before = {}; + var editable = $(".gInPlaceEdit"); + for (i = 0; i < editable.length; i++) { + var matches = editable[i].className.match(/gEditField-(\d+)-(\S+)/); + if (matches && matches.length == 3) { + var className = "." + matches[0]; + if (!seen_before[className]) { + $(className).editable( + ajax_update(className, matches[1]), + {indicator : "<?= _("Saving...") ?>", + tooltip : "<?= _("Double-click to edit...") ?>", + event : "dblclick", + style : "inherit", + name : matches[2], + select : true} + ); + seen_before[className] = 1; + } + } + } +}); +</script>
\ No newline at end of file |
