From 390bc7c1f6b79924e42b326718ee244ee989243a Mon Sep 17 00:00:00 2001 From: Chad Kieffer Date: Sun, 14 Jun 2009 10:42:14 -0600 Subject: Switch quick delete from JS confirm to jQuery UI dialog, closes ticket #355. --- modules/gallery/controllers/quick.php | 15 +++++++++++++++ modules/gallery/helpers/item.php | 18 ++++++++++++++++++ modules/gallery/js/quick.js | 4 ---- modules/gallery/views/quick_pane.html.php | 5 +---- 4 files changed, 34 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index d6f5213f..30383307 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -95,6 +95,21 @@ class Quick_Controller extends Controller { print json_encode(array("result" => "success", "reload" => 1)); } + public function form_delete($id) { + $item = model_cache::get("item", $id); + access::required("view", $item); + access::required("edit", $item); + + if ($item->is_album()) { + print t("Delete the album %title? All items within the album will also be deleted.", array("title" => $item->title)); + } else { + print t("Are you sure you want to delete %title?", array("title" => $item->title)); + } + + $form = item::get_delete_form($item); + print $form; + } + public function delete($id) { access::verify_csrf(); $item = model_cache::get("item", $id); diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 09870b45..f40b5c97 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -119,4 +119,22 @@ class item_Core { $title = preg_replace("/ +/", " ", $title); return $title; } + + /** + * Display delete confirmation message and form + * @param object $item + * @return string form + */ + static function get_delete_form($item) { + if (Input::instance()->get("page_type") == "album") { + $page_type = "album"; + } else { + $page_type = "item"; + } + $form = new Forge("quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "gConfirmDelete")); + $form->hidden("_method")->value("put"); + $group = $form->group("confirm_delete")->label(t("Confirm Deletion")); + $group->submit("")->value(t("Delete")); + return $form; + } } \ No newline at end of file diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 8a87ed07..4ebdac47 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -39,10 +39,6 @@ var show_quick = function() { ); $("#gQuickPane a:not(.options)").click(function(e) { e.preventDefault(); - if ($(this).attr("id") == "gQuickDelete" && - !confirm($(this).attr("ref"))) { - return; - } quick_do(cont, $(this), img); }); $("#gQuickPane a.options").click(function(e) { diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php index 95de972b..f50e1abe 100644 --- a/modules/gallery/views/quick_pane.html.php +++ b/modules/gallery/views/quick_pane.html.php @@ -67,15 +67,12 @@ type == "photo"): ?> - type == "movie"): ?> - type == "album"): ?> - -id?csrf=$csrf&page_type=$page_type") ?>" ref="" id="gQuickDelete" title=""> +id?page_type=$page_type") ?>" id="gQuickDelete" title=""> -- cgit v1.2.3