diff options
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 |
