[Ovirt-devel] [PATCH] added tallen's confirmation dialog styling changes. I've replaced all of the confirm("foo") javascript confirmation popups with the facebox-based design.

Scott Seago sseago at redhat.com
Fri Jul 18 16:59:49 UTC 2008


Signed-off-by: Scott Seago <sseago at redhat.com>
---
 wui/src/app/helpers/application_helper.rb       |   24 ++++++++++
 wui/src/app/views/hardware/quick_summary.rhtml  |   26 ++++++------
 wui/src/app/views/layouts/_side_toolbar.rhtml   |    6 ++-
 wui/src/app/views/layouts/redux.rhtml           |   40 ++++++++---------
 wui/src/app/views/resources/quick_summary.rhtml |   30 +++++++-------
 wui/src/app/views/storage/show.rhtml            |   24 +++++-----
 wui/src/app/views/vm/show.rhtml                 |   52 +++++++++++-----------
 wui/src/public/images/bg_warningMessage.png     |  Bin 0 -> 625 bytes
 wui/src/public/images/icon_warning.png          |  Bin 0 -> 1954 bytes
 wui/src/public/stylesheets/layout.css           |   18 ++++++++
 10 files changed, 131 insertions(+), 89 deletions(-)
 create mode 100644 wui/src/public/images/bg_warningMessage.png
 create mode 100644 wui/src/public/images/icon_warning.png

diff --git a/wui/src/app/helpers/application_helper.rb b/wui/src/app/helpers/application_helper.rb
index 58a6358..63a33d3 100644
--- a/wui/src/app/helpers/application_helper.rb
+++ b/wui/src/app/helpers/application_helper.rb
@@ -113,6 +113,30 @@ module ApplicationHelper
      }
   end
 
+  def confirmation_dialog(div_id, text, action)
+    %{
+      <div id="#{div_id}" style="display:none;">
+        <div class="confirm_dialog_title">
+          <div class="confirm_dialog_header">#{text}</div>
+          <div style="clear:both;"></div>
+        </div>
+
+        <div class="confirm_dialog_footer">
+          <div class="button">
+            <div class="button_left_grey"></div>
+            <div class="button_middle_grey"><a href="#" onclick="jQuery(document).trigger('close.facebox')">Cancel</a></div>
+            <div class="button_right_grey"></div>
+          </div>
+          <div class="button">
+            <div class="button_left_blue"></div>
+            <div class="button_middle_blue"><a href="#" onclick="#{action}">OK</a></div>
+            <div class="button_right_blue"></div>
+          </div>
+        </div>
+      </div>
+     }
+  end
+
   def timeout_flash(name)
     %{
     <script type="text/javascript">
diff --git a/wui/src/app/views/hardware/quick_summary.rhtml b/wui/src/app/views/hardware/quick_summary.rhtml
index 897cecb..eb2e6af 100644
--- a/wui/src/app/views/hardware/quick_summary.rhtml
+++ b/wui/src/app/views/hardware/quick_summary.rhtml
@@ -10,7 +10,7 @@
       <%= link_to image_tag("icon_edit.png") + " Edit Default Quota",
                             {:controller => 'quota', :action => 'edit', :id => @pool.quota},
                             :rel=>"facebox[.bolder]", :class=>"selection_facebox" %>
-      <a href="#" onClick="delete_default_quota()">
+      <a href="#confirm_delete_default_quota"  rel="facebox[.bolder]">
         <%= image_tag "icon_x.png" %> Remove Default Quota
       </a> 
     <% else -%>
@@ -20,21 +20,21 @@
     <% end -%>
   <% end -%>
 <% end -%>
+<%= confirmation_dialog("confirm_delete_default_quota", "Are you sure?", "delete_default_quota()") %>
 <script type="text/javascript">
   function delete_default_quota()
   {
-    if(confirm("Are you sure?")){
-      $.post('<%= url_for :controller => "quota", :action => "destroy", :id => @pool.quota %>',
-              function(data,status){
-                refresh_summary('hwpool_selection', 
-                            '<%= url_for :controller => "hardware", 
-                                         :action => "quick_summary" %>',
-                            <%= @pool.id %>)
-		if (data.alert) {
-		  $.jGrowl(data.alert);
-                }
-               }, 'json');
-    }
+    jQuery(document).trigger('close.facebox');
+    $.post('<%= url_for :controller => "quota", :action => "destroy", :id => @pool.quota %>',
+            function(data,status){
+              refresh_summary('hwpool_selection',
+                          '<%= url_for :controller => "hardware",
+                                       :action => "quick_summary" %>',
+                          <%= @pool.id %>);
+              if (data.alert) {
+                $.jGrowl(data.alert);
+              }
+             }, 'json');
   }
 </script>
 
diff --git a/wui/src/app/views/layouts/_side_toolbar.rhtml b/wui/src/app/views/layouts/_side_toolbar.rhtml
index 2cdd4f3..42cbae6 100644
--- a/wui/src/app/views/layouts/_side_toolbar.rhtml
+++ b/wui/src/app/views/layouts/_side_toolbar.rhtml
@@ -13,10 +13,12 @@
 </div>
 <% end -%>
 <div class="toolbar" style="float:left;">
-    <a href="#" onClick="delete_<%=pool[:type]=='HardwarePool' ? 'hw' : 'vm' %>_pool(<%=pool.id%>)">
+    <a href="#conf_nav_delete_pool" rel="facebox[.bolder]">
       <%= image_tag "icon_delete.gif", :title=>"Delete Selected Pool" %>
     </a> 
 </div>
 <% end -%>
-
+<div class="toolbar" style="display:none;">
+  <%= confirmation_dialog("conf_nav_delete_pool", "Are you sure?", "delete_#{pool[:type]=='HardwarePool' ? 'hw' : 'vm'}_pool(#{pool.id})") %>
+</div>
 <div class="toolbar"></div>
diff --git a/wui/src/app/views/layouts/redux.rhtml b/wui/src/app/views/layouts/redux.rhtml
index 46ff9da..23983fa 100644
--- a/wui/src/app/views/layouts/redux.rhtml
+++ b/wui/src/app/views/layouts/redux.rhtml
@@ -109,30 +109,28 @@
 
   function delete_vm_pool(id, parent)
   {
-    if(confirm("Are you sure?")){
-      $.post('<%= url_for :controller => "resources", :action => "destroy" %>',
-             {id: id},
-              function(data,status){
-                // need to redirect to the parent using the new ajax reload stuff
-                $("#vmpools_grid").flexReload()
-		if (data.alert) {
-		  $.jGrowl(data.alert);
-                }
-               }, 'json');
-    }
+    jQuery(document).trigger('close.facebox');
+    $.post('<%= url_for :controller => "resources", :action => "destroy" %>',
+           {id: id},
+            function(data,status){
+              // need to redirect to the parent using the new ajax reload stuff
+              $("#vmpools_grid").flexReload();
+              if (data.alert) {
+                $.jGrowl(data.alert);
+              }
+             }, 'json');
   }
   function delete_hw_pool(id, parent)
   {
-    if(confirm("Are you sure?")){
-      $.post('<%= url_for :controller => "hardware", :action => "destroy" %>',
-             {id: id},
-              function(data,status){
-                // need to redirect to the parent using the new ajax reload stuff
-		if (data.alert) {
-		  $.jGrowl(data.alert);
-                }
-               }, 'json');
-    }
+    jQuery(document).trigger('close.facebox');
+    $.post('<%= url_for :controller => "hardware", :action => "destroy" %>',
+           {id: id},
+            function(data,status){
+              // need to redirect to the parent using the new ajax reload stuff
+              if (data.alert) {
+                $.jGrowl(data.alert);
+              }
+             }, 'json');
   }
       </script>
    <%= yield :scripts -%>
diff --git a/wui/src/app/views/resources/quick_summary.rhtml b/wui/src/app/views/resources/quick_summary.rhtml
index 77b1708..b17d332 100644
--- a/wui/src/app/views/resources/quick_summary.rhtml
+++ b/wui/src/app/views/resources/quick_summary.rhtml
@@ -10,7 +10,7 @@
       <%= link_to image_tag("icon_edit.png") + " Edit Quota",
                             {:controller => 'quota', :action => 'edit', :id => @vm_resource_pool.quota},
                             :rel=>"facebox[.bolder]", :class=>"selection_facebox" %>
-      <a href="#" onClick="delete_vm_quota()">
+      <a href="#confirm_delete_quota"  rel="facebox[.bolder]">
         <%= image_tag "icon_x.png" %> Revert to Default Quota
       </a> 
     <% else -%>
@@ -20,22 +20,22 @@
     <% end -%>
   <% end -%>
 <% end -%>
+<%= confirmation_dialog("confirm_delete_quota", "Are you sure?", "delete_vm_quota()") %>
 <script type="text/javascript">
-  function delete_vm_quota(id)
+  function delete_vm_quota()
   {
-    if(confirm("Are you sure?")){
-      $.post('<%= url_for :controller => "quota", :action => "destroy", :id => @vm_resource_pool.quota %>',
-             {x: 1},
-              function(data,status){
-                refresh_summary('vmpool_selection', 
-                            '<%= url_for :controller => "resources", 
-                                         :action => "quick_summary" %>',
-                            <%= @vm_resource_pool.id %>)
-		if (data.alert) {
-		  $.jGrowl(data.alert);
-                }
-               }, 'json');
-    }
+    jQuery(document).trigger('close.facebox');
+    $.post('<%= url_for :controller => "quota", :action => "destroy", :id => @vm_resource_pool.quota %>',
+           {x: 1},
+            function(data,status){
+              refresh_summary('vmpool_selection',
+                          '<%= url_for :controller => "resources",
+                                       :action => "quick_summary" %>',
+                          <%= @vm_resource_pool.id %>);
+              if (data.alert) {
+                $.jGrowl(data.alert);
+              }
+             }, 'json');
   }
 </script>
 
diff --git a/wui/src/app/views/storage/show.rhtml b/wui/src/app/views/storage/show.rhtml
index 6263021..19ab30e 100644
--- a/wui/src/app/views/storage/show.rhtml
+++ b/wui/src/app/views/storage/show.rhtml
@@ -10,7 +10,7 @@
       <a href="#" onClick="refresh_storage_pool()">
         <%= image_tag "icon_refresh.png" %> Refresh
       </a> 
-      <a href="#" onClick="delete_storage_pool()">
+      <a href="#confirm_delete_storage" rel="facebox[.bolder]">
         <%= image_tag "icon_x.png" %> Delete
       </a> 
   <%- end -%>
@@ -52,6 +52,7 @@
 
 <%- end -%>
 
+<%= confirmation_dialog("confirm_delete_storage", "Are you sure?", "delete_storage_pool()") %>
 <script type="text/javascript">
 	$("#storage_volumes_grid").flexigrid
 	(
@@ -82,7 +83,7 @@
                             '<%= url_for :controller => "storage", 
                                          :action => "show" %>',
                             <%= @storage_pool.id %>)
-                $("#storage_grid").flexReload()
+                $("#storage_grid").flexReload();
 		if (data.alert) {
 		  $.jGrowl(data.alert);
                 }
@@ -90,16 +91,15 @@
   }
   function delete_storage_pool()
   {
-    if(confirm("Are you sure?")){
-      $.post('<%= url_for :controller => "storage", :action => "destroy", :id => @storage_pool %>',
-              function(data,status){
-                $("#storage_grid").flexReload()
-		if (data.alert) {
-		  $.jGrowl(data.alert);
-                }
-	        empty_summary('storage_selection', 'Storage Pool')
-               }, 'json');
-    }
+    jQuery(document).trigger('close.facebox');
+    $.post('<%= url_for :controller => "storage", :action => "destroy", :id => @storage_pool %>',
+            function(data,status){
+              $("#storage_grid").flexReload();
+              if (data.alert) {
+                $.jGrowl(data.alert);
+              }
+	      empty_summary('storage_selection', 'Storage Pool');
+             }, 'json');
   }
 </script>
 
diff --git a/wui/src/app/views/vm/show.rhtml b/wui/src/app/views/vm/show.rhtml
index 293b632..defd40e 100644
--- a/wui/src/app/views/vm/show.rhtml
+++ b/wui/src/app/views/vm/show.rhtml
@@ -29,44 +29,44 @@
         </a>
       <% end -%>
     <% end %>
-    <a href="#" onClick="cancel_queued_tasks()">
+    <a href="#confirm_cancel"  rel="facebox[.bolder]">
       <%= image_tag "icon_x.png" %> Cancel queued tasks
     </a> 
-    <a href="#" onClick="delete_vm()">
+    <a href="#confirm_delete"  rel="facebox[.bolder]">
       <%= image_tag "icon_x.png" %> Delete
     </a> 
   <% end -%>
 <% end -%>
+<%= confirmation_dialog("confirm_cancel", "Are you sure?", "cancel_queued_tasks()") %>
+<%= confirmation_dialog("confirm_delete", "Are you sure?", "delete_vm()") %>
 <script type="text/javascript">
   function cancel_queued_tasks()
   {
-    if(confirm("Are you sure?")){
-      $.post('<%= url_for :controller => "vm", :action => "cancel_queued_tasks", :id => @vm %>',
-              function(data,status){
-                refresh_summary('vms_selection', 
-                            '<%= url_for :controller => "vm", 
-                                         :action => "show" %>',
-                            <%= @vm.id %>)
-                $("#vms_grid").flexReload()
-		if (data.alert) {
-		  $.jGrowl(data.alert);
-                }
-               }, 'json');
-    }
+    jQuery(document).trigger('close.facebox');
+    $.post('<%= url_for :controller => "vm", :action => "cancel_queued_tasks", :id => @vm %>',
+          function(data,status){
+            refresh_summary('vms_selection',
+                        '<%= url_for :controller => "vm",
+                                     :action => "show" %>',
+                        <%= @vm.id %>);
+            $("#vms_grid").flexReload();
+            if (data.alert) {
+              $.jGrowl(data.alert);
+            }
+          }, 'json');
   }
   function delete_vm()
   {
-    if(confirm("Are you sure?")){
-      $.post('<%= url_for :controller => "vm", :action => "destroy", :id => @vm %>',
-             {x: 1},
-              function(data,status){
-                $("#vms_grid").flexReload()
-		if (data.alert) {
-		  $.jGrowl(data.alert);
-                }
-	        empty_summary('vms_selection', 'Virtual Machine')
-               }, 'json');
-    }
+    jQuery(document).trigger('close.facebox');
+    $.post('<%= url_for :controller => "vm", :action => "destroy", :id => @vm %>',
+           {x: 1},
+            function(data,status){
+              $("#vms_grid").flexReload();
+              if (data.alert) {
+                $.jGrowl(data.alert);
+              }
+	      empty_summary('vms_selection', 'Virtual Machine');
+            }, 'json');
   }
   function single_vm_action(action)
   {
diff --git a/wui/src/public/images/bg_warningMessage.png b/wui/src/public/images/bg_warningMessage.png
new file mode 100644
index 0000000000000000000000000000000000000000..063a1f067fda745edfd6e0508263a259320d29ec
GIT binary patch
literal 625
zcmV-%0*?KOP)<h;3K|Lk000e1NJLTq000F50027(1^@s6vmZb>00004b3#c}2nYxW
zd<bNS00009a7bBm000W`000W`0Ya=am;e9(9CSrkbW?9;ba!ELWdK2BZ(?O2Mrm?o
zcW-iQb09-gGnm#!0{{R36?8>dbVG7wVRUJ4ZXi@?ZDjyAFEKDLFgWjXy+!~40m?~4
zK~y-6UDN+dQ(+Xx@%M9go%6cs+!~PtMS+nJMMM!41xbNe5JmrEP$(vbQB)K~QBfpD
zMUfOr`*Pjfy!*cE58lo5ocrU$bIyx%KF>8_{(gx3a`$k-5eIjn at BkM~bZ`d>4*?V1
z%-x2<JpC#YhG9r?!D{PLT*T^o;1({%>>p%rLg|r!vU5;ciXh`aW)}QqFcR_~E6885
zq09}@6CiUP{3lUQfQcE{dJ4vgZcbc-t!MPB_Mq}}1(jc5^-W(@Q2Gj#UkYgaGE`m(
zX#5gXUMr~bMnT(eu{Je!QDroC0k+?XeWuPs^*xw=MyYd9{eYcO^`nAnpKK_3Rzb-#
zQ2Q*#OrD0?7xpt6Jq0^oRYp6j3JTT+HvsUa)#|*H5PTE5cLIX%K!0`K6a+ui>gqog
zRR4uFz{qj+>JrDG at moNNqtN&xpu`bqtShMbS3%8xSOW|nR;wGHgyx3O<A<QNDKd&5
zgw}uTjM{kxwF@>hlvB`97TP5Nxf$sA0&>&PDJ!T`QBb#PXB11RjABXX)`TAOpc_Q1
zGX|Uy=+y^rY7go)6x3^B4dBGZF9Tp)2s=VIF$lXvug*l}y#cffQ@)|W$mauN00000
LNkvXXu0mjfq;&#r

literal 0
HcmV?d00001

diff --git a/wui/src/public/images/icon_warning.png b/wui/src/public/images/icon_warning.png
new file mode 100644
index 0000000000000000000000000000000000000000..741d0994c3abfc3dcb8beae7bf87b589519bde0a
GIT binary patch
literal 1954
zcmV;T2VMAyP)<h;3K|Lk000e1NJLTq001Na001Ni1^@s6;Q*MJ00004XF*Lt007q5
z)K6G40000PbVXQnQ*UN;cVTj606}DLV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XENwy3cyz*2xw$Tz~SS$ZZ8E9pj_90 at zJVZvX7;kHHhP>Re8%0a_=I~Me}X!
z(ZD at My^O+q<Gtu`<`6auby_Ge7#^^p=ePk~{pLr6!vi$>ac|)u?;2it*SW%tbqygF
z!CPJsH7>lW?FmvQJ at -!J6R8B_PqCJlf0!&kPD@}pFl>!+yx|TCIC-=nJ~*1|`nbn9
zNI1Zk+>>Z66)Mjxt5Di?g(WZ&oE*i3FMUFhCB~=t55+GU-_1n$@~|Y5fsH{n^wWU#
z<zQaCj~zdfew_3<Q9@#9RcLe3%KyVZBQyCBU+2)ypwZ9m5%*omorJkA47nF5b{PQ?
oe+Gp){R*G$UpH6e^N#=n0H=d1t<sL41poj507*qoM6N<$f{l-!F#rGn

literal 0
HcmV?d00001

diff --git a/wui/src/public/stylesheets/layout.css b/wui/src/public/stylesheets/layout.css
index 52151eb..4df8c66 100644
--- a/wui/src/public/stylesheets/layout.css
+++ b/wui/src/public/stylesheets/layout.css
@@ -386,6 +386,24 @@ a { color:#000000; text-decoration: none;}
   height: 350px;
 }
 
+.confirm_dialog_title {
+  width:400px;
+  padding: 15px;
+  font-size: 110%;
+  background:url(../images/bg_warningMessage.png) top repeat-x;
+}
+.confirm_dialog_header {
+  background:url(../images/icon_warning.png) top left no-repeat;
+  padding: 0 0 0 45px;
+  min-height:36px;
+
+}
+.confirm_dialog_footer {
+  height: 37px;
+  text-align:right;
+  padding: 5px 9px 0 0;
+}
+
 .dialog_form {
   margin: 15px;
   background: #FFFFFF
-- 
1.5.5.1




More information about the ovirt-devel mailing list