From 6078baec53c8039560c3e1806df73542b9ddeaf1 Mon Sep 17 00:00:00 2001 From: jrb6 Date: Mon, 4 Jun 2012 11:20:04 -0500 Subject: [PATCH 1/3] Added extra line to allow clicking outside of modal dialog --- app/views/dev/toolbox.js.erb | 3 +++ app/views/help/topic.js.erb | 5 ++++- app/views/project_questions/attribution.js.erb | 3 +++ app/views/questions/preview.js.erb | 3 +++ app/views/questions/quickview.js.erb | 3 +++ app/views/users/action_new.js.erb | 5 ++++- 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/views/dev/toolbox.js.erb b/app/views/dev/toolbox.js.erb index 1d45066..e12cdd8 100644 --- a/app/views/dev/toolbox.js.erb +++ b/app/views/dev/toolbox.js.erb @@ -7,3 +7,6 @@ refresh_buttons(); refresh_datetime_pickers(); $("#dev_toolbox_dialog").dialog('open'); +$('.ui-widget-overlay').live("click",function(){ + $("#dev_toolbox_dialog").dialog("close"); + }); diff --git a/app/views/help/topic.js.erb b/app/views/help/topic.js.erb index a4aee2b..4ecbbd6 100644 --- a/app/views/help/topic.js.erb +++ b/app/views/help/topic.js.erb @@ -18,4 +18,7 @@ $("#help_dialog").dialog({ <%= reload_mathjax("help_dialog") if @options[:include_mathjax] %> $("#help_dialog").dialog('open'); -$("#help_dialog").scrollTop(0); \ No newline at end of file +$('.ui-widget-overlay').live("click",function(){ + $("#help_dialog").dialog("close"); + }); +$("#help_dialog").scrollTop(0); diff --git a/app/views/project_questions/attribution.js.erb b/app/views/project_questions/attribution.js.erb index 4649ebc..ebf8633 100644 --- a/app/views/project_questions/attribution.js.erb +++ b/app/views/project_questions/attribution.js.erb @@ -6,3 +6,6 @@ $("#attribution_dialog").html("<%= escape_javascript( :locals => {:question_ids => @question_ids}) %>"); $("#attribution_dialog").dialog('open'); +$('.ui-widget-overlay').live("click",function(){ + $("#attribution_dialog").dialog("close"); + }); diff --git a/app/views/questions/preview.js.erb b/app/views/questions/preview.js.erb index 3dd3f26..4b6dbc9 100644 --- a/app/views/questions/preview.js.erb +++ b/app/views/questions/preview.js.erb @@ -7,6 +7,9 @@ <%= reload_mathjax("preview_dialog") %> $("#preview_dialog").dialog('open'); + $('.ui-widget-overlay').live("click",function(){ + $("#preview_dialog").dialog("close"); + }); <% else %> // Submit the form so that the error messages display nicely with formatting // around the offending entries (use the trigger approach so we don't get diff --git a/app/views/questions/quickview.js.erb b/app/views/questions/quickview.js.erb index a6978c3..de5f847 100644 --- a/app/views/questions/quickview.js.erb +++ b/app/views/questions/quickview.js.erb @@ -6,3 +6,6 @@ $("#quickview_dialog").html("<%= escape_javascript(render :partial => "show", <%= reload_mathjax("quickview_dialog") %> $("#quickview_dialog").dialog('open'); +$('.ui-widget-overlay').live("click",function(){ + $("#quickview_dialog").dialog("close"); + }); diff --git a/app/views/users/action_new.js.erb b/app/views/users/action_new.js.erb index ab22a75..55a4ba2 100644 --- a/app/views/users/action_new.js.erb +++ b/app/views/users/action_new.js.erb @@ -11,4 +11,7 @@ $("#user_action_dialog").dialog({ width:600, buttons: { "Close": function() { $(this).dialog("close"); }}, open: function(event, ui) { $("#text_query").val(''); $("#selected_type").val(''); } -}); \ No newline at end of file +}); +$('.ui-widget-overlay').live("click",function(){ + $("#user_action_dialog").dialog('close'); + }); From a883b3d8ce15c402a678017012dd1ea70f4936f5 Mon Sep 17 00:00:00 2001 From: jrb6 Date: Wed, 11 Jul 2012 13:00:31 -0500 Subject: [PATCH 2/3] Added closeOnClickOutside function and appended that to dialog open statements --- app/assets/javascripts/jquery_extensions.js | 7 +++++++ app/views/dev/toolbox.js.erb | 5 +---- app/views/help/topic.js.erb | 5 +---- app/views/project_questions/attribution.js.erb | 5 +---- app/views/questions/preview.js.erb | 5 +---- app/views/questions/quickview.js.erb | 5 +---- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/jquery_extensions.js b/app/assets/javascripts/jquery_extensions.js index b303914..fbfe7eb 100644 --- a/app/assets/javascripts/jquery_extensions.js +++ b/app/assets/javascripts/jquery_extensions.js @@ -2,3 +2,10 @@ // License version 3 or later. See the COPYRIGHT file for details. jQuery.fn.exists = function(){return jQuery(this).length>0;} + +jQuery.fn.closeOnClickOutside = function(){ + var dialogx = this; + $('.ui-widget-overlay').live("click",function(){ + dialogx.dialog("close"); + }); +} diff --git a/app/views/dev/toolbox.js.erb b/app/views/dev/toolbox.js.erb index e12cdd8..3a78a98 100644 --- a/app/views/dev/toolbox.js.erb +++ b/app/views/dev/toolbox.js.erb @@ -6,7 +6,4 @@ $("#dev_toolbox_dialog").html("<%= ej(render :partial => 'toolbox' )%>"); refresh_buttons(); refresh_datetime_pickers(); -$("#dev_toolbox_dialog").dialog('open'); -$('.ui-widget-overlay').live("click",function(){ - $("#dev_toolbox_dialog").dialog("close"); - }); +$("#dev_toolbox_dialog").dialog('open').closeOnClickOutside(); diff --git a/app/views/help/topic.js.erb b/app/views/help/topic.js.erb index 4ecbbd6..89bdef1 100644 --- a/app/views/help/topic.js.erb +++ b/app/views/help/topic.js.erb @@ -17,8 +17,5 @@ $("#help_dialog").dialog({ <%= reload_mathjax("help_dialog") if @options[:include_mathjax] %> -$("#help_dialog").dialog('open'); -$('.ui-widget-overlay').live("click",function(){ - $("#help_dialog").dialog("close"); - }); +$("#help_dialog").dialog('open').closeOnClickOutside(); $("#help_dialog").scrollTop(0); diff --git a/app/views/project_questions/attribution.js.erb b/app/views/project_questions/attribution.js.erb index ebf8633..294aed6 100644 --- a/app/views/project_questions/attribution.js.erb +++ b/app/views/project_questions/attribution.js.erb @@ -5,7 +5,4 @@ $("#attribution_dialog").html("<%= escape_javascript( render :partial => 'project_questions/attribution', :locals => {:question_ids => @question_ids}) %>"); -$("#attribution_dialog").dialog('open'); -$('.ui-widget-overlay').live("click",function(){ - $("#attribution_dialog").dialog("close"); - }); +$("#attribution_dialog").dialog('open').closeOnClickOutside(); diff --git a/app/views/questions/preview.js.erb b/app/views/questions/preview.js.erb index 4b6dbc9..b6c7fe1 100644 --- a/app/views/questions/preview.js.erb +++ b/app/views/questions/preview.js.erb @@ -6,10 +6,7 @@ :locals => {:question => @question}) %>"); <%= reload_mathjax("preview_dialog") %> - $("#preview_dialog").dialog('open'); - $('.ui-widget-overlay').live("click",function(){ - $("#preview_dialog").dialog("close"); - }); + $("#preview_dialog").dialog('open').closeOnClickOutside(); <% else %> // Submit the form so that the error messages display nicely with formatting // around the offending entries (use the trigger approach so we don't get diff --git a/app/views/questions/quickview.js.erb b/app/views/questions/quickview.js.erb index fe284db..4694206 100644 --- a/app/views/questions/quickview.js.erb +++ b/app/views/questions/quickview.js.erb @@ -5,7 +5,4 @@ $("#quickview_dialog").html("<%= escape_javascript(render :partial => 'show', :locals => {:question => @question}) %>"); <%= reload_mathjax("quickview_dialog") %> -$("#quickview_dialog").dialog('open'); -$('.ui-widget-overlay').live("click",function(){ - $("#quickview_dialog").dialog("close"); - }); +$("#quickview_dialog").dialog('open').closeOnClickOutside(); From 23778de7404d8901e8718d5a972e9cdc8e73671b Mon Sep 17 00:00:00 2001 From: jrb6 Date: Wed, 11 Jul 2012 13:02:18 -0500 Subject: [PATCH 3/3] and finished, missed action_new --- app/views/users/action_new.js.erb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/users/action_new.js.erb b/app/views/users/action_new.js.erb index 55a4ba2..8ab4106 100644 --- a/app/views/users/action_new.js.erb +++ b/app/views/users/action_new.js.erb @@ -11,7 +11,4 @@ $("#user_action_dialog").dialog({ width:600, buttons: { "Close": function() { $(this).dialog("close"); }}, open: function(event, ui) { $("#text_query").val(''); $("#selected_type").val(''); } -}); -$('.ui-widget-overlay').live("click",function(){ - $("#user_action_dialog").dialog('close'); - }); +}).closeOnClickOutside();