From eb5ff191c6bb69de087d1c68384c8a44a46f9df4 Mon Sep 17 00:00:00 2001 From: "green-ponies (jgen)" Date: Tue, 16 Aug 2011 23:14:30 -0400 Subject: [PATCH] Confirm image delete with jQuery UI modal dialog. Added config option for jQuery delete as well. --- ext/image/main.php | 2 ++ ext/image/theme.php | 23 ++++++++++---- .../jquery-ui-1.8.15.custom.css | 0 lib/shimmie.js | 30 +++++++++++++++++++ 4 files changed, 49 insertions(+), 6 deletions(-) rename lib/{css/smoothness => }/jquery-ui-1.8.15.custom.css (100%) diff --git a/ext/image/main.php b/ext/image/main.php index 4c2544ef..86a2c71a 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -98,6 +98,7 @@ class ImageIO extends SimpleExtension { $config->set_default_string('thumb_convert_path', 'convert.exe'); $config->set_default_bool('image_show_meta', false); + $config->set_default_bool('jquery_confirm', true); $config->set_default_string('image_ilink', ''); $config->set_default_string('image_tlink', ''); $config->set_default_string('image_tip', '$tags // $size // $filesize'); @@ -170,6 +171,7 @@ class ImageIO extends SimpleExtension { if(!in_array("OS", $_SERVER) || $_SERVER["OS"] != 'Windows_NT') { $sb->add_bool_option("image_show_meta", "
Show metadata: "); } + $sb->add_bool_option("jquery_confirm", "
Confirm Delete with jQuery: "); $event->panel->add_block($sb); $thumbers = array(); diff --git a/ext/image/theme.php b/ext/image/theme.php index 2682314e..10bfcfe4 100644 --- a/ext/image/theme.php +++ b/ext/image/theme.php @@ -8,14 +8,25 @@ class ImageIOTheme { */ public function get_deleter_html($image_id) { global $user; + global $config; $i_image_id = int_escape($image_id); - $html = " - ".make_form(make_link("image_admin/delete"),'POST',false,'delete_image')." - - - - "; + + if($config->get_bool("jquery_confirm")) { + $html = " + ".make_form(make_link("image_admin/delete"),'POST',false,'delete_image')." + + + + "; + } else { + $html = " + ".make_form(make_link("image_admin/delete"))." + + + + "; + } return $html; } } diff --git a/lib/css/smoothness/jquery-ui-1.8.15.custom.css b/lib/jquery-ui-1.8.15.custom.css similarity index 100% rename from lib/css/smoothness/jquery-ui-1.8.15.custom.css rename to lib/jquery-ui-1.8.15.custom.css diff --git a/lib/shimmie.js b/lib/shimmie.js index 14af3ce7..6e72770c 100644 --- a/lib/shimmie.js +++ b/lib/shimmie.js @@ -1,3 +1,33 @@ + +// Adding jQuery ui stuff +$(document).ready(function() { + + var $confirm = $('
') + .html('

This image will be permanently deleted and cannot be recovered. Are you sure?

') + .dialog({ + resizable: false, + height:220, + modal: true, + autoOpen: false, + title: 'Delete Image?', + buttons: { + "Delete Image": function() { + $( this ).dialog( "close" ); + $('form#delete_image').submit(); + }, + Cancel: function() { + $( this ).dialog( "close" ); + } + } + }); + + $('form#delete_image #delete_image_submit').click(function(e){ + e.preventDefault(); + $confirm.dialog('open'); + }); + +}); + var defaultTexts = new Array(); window.onload = function(e) {