Files
gallery3/core/views/in_place_edit.html.php
Bharat Mediratta 1b490c5fe6 Make Gallery3 more RESTful.
Create Item_Controller as a common superclass for Album_Controller and
Photo_Controller.  Change routes to route requests to Item_Controller
for dispatching, which in turn will generate get/post/put/delete
requests to the controlller so that each controller has a RESTful
surface.

Change in_place editing to take advantage of this.
2008-11-09 19:20:23 +00:00

41 lines
1.3 KiB
PHP

<? defined("SYSPATH") or die("No direct script access."); ?>
<script type="text/javascript">
$(document).ready(function() {
ajax_update = function(className, id) {
return function(value, settings) {
var post_data = {'__return': settings.name};
post_data[settings.name] = value;
$.post("<?= url::site("item/__ID__") ?>".replace("__ID__", id),
post_data,
function(data, textStatus) {
if (textStatus == "success") {
$(className).html(data);
}
},
"html");
}
}
var seen_before = {};
var editable = $("span.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>