fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-01-31 07:28 am

[dw-free] Deleting Layers: use pop-up confirmation instead of loading a new page

[commit: http://hg.dwscoalition.org/dw-free/rev/662783e34f29]

http://bugs.dwscoalition.org/show_bug.cgi?id=4188

Switch to popup.

Patch by [personal profile] ninetydegrees.

Files modified:
  • htdocs/customize/advanced/layers.bml
--------------------------------------------------------------------------------
diff -r 547cfe82ac04 -r 662783e34f29 htdocs/customize/advanced/layers.bml
--- a/htdocs/customize/advanced/layers.bml	Tue Jan 31 15:04:23 2012 +0800
+++ b/htdocs/customize/advanced/layers.bml	Tue Jan 31 15:30:25 2012 +0800
@@ -160,28 +160,6 @@
         return $err->($ML{'.error.notyourlayer'})
             unless $lay->{userid} == $u->userid;
 
-        unless ($POST{'confirm'}) {
-            my $layerinfo = {};
-            LJ::S2::load_layer_info($layerinfo, [ $id ]);
-            my $name = $layerinfo->{$id}->{'name'} ? BML::ml('.delete.layername', {'name' => $layerinfo->{$id}->{'name'}}) : BML::ml('.delete.layerid', {'id' => $id});
-            $name = LJ::ehtml($name);
-
-            $title = BML::ml('.delete.title', {'name' => $name});
-            $body .= "<br /> ";
-            $body .= BML::ml("Backlink", {
-                'link' => "$LJ::SITEROOT/customize/advanced/layers?authas=$authas",
-                'text' => $ML{'.back2layers'},
-            }) . "\n";
-            $body .= "<form method='post' action='layers?authas=$authas'>";
-            $body .= $formauth;
-            $body .= LJ::html_hidden('action:del', '1', 'id', $id);
-              
-            $body .= BML::ml('.delete.text', {'type' => $lay->{'type'}, 'name' => $name});
-            $body .= "<p>" . LJ::html_submit('confirm', $ML{'.btn.delete'}) . "</p>\n";;
-            $body .= "</form>\n";
-            return;
-        }
-
         LJ::S2::delete_layer($u, $id);
         return BML::redirect("layers?authas=$authas");
     }
@@ -262,7 +240,12 @@
             $body .= "<form method='post' style='display:inline' action='layers?authas=$authas'>";
             $body .= $formauth;
             $body .= LJ::html_hidden('id', $lid);
-            $body .= LJ::html_submit('action:del', $ML{'.btn.delete2'}, { disabled => $noactions });
+
+            my $confirm_msg = LJ::ejs(BML::ml('.delete.text', {'type' => $laytype, 'name' => $name}));
+
+            $body .= LJ::html_submit('action:del', $ML{'.btn.delete2'},
+                                    { 'onclick' => "return confirm('$confirm_msg')", disabled => $noactions }) . " ";
+
             $body .= "</form>";
             $body .= "</td></tr>\n"
         }
--------------------------------------------------------------------------------