Skip to content

Commit

Permalink
Web 'Activities' window refreshes on runScript() callback. See #6964
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Moore committed Oct 12, 2011
1 parent ca2162f commit 91ca374
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Expand Up @@ -47,7 +47,7 @@ function popupActivites(url) {
var top = parseInt((screen.availHeight - h)/3);
activitiesWindow = window.open(url, 'Activities', config='height='+h+',width='+w+',left='+left+',top='+top+',toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,directories=no,status=no');
if(!activitiesWindow.closed) activitiesWindow.focus();
return false;
return activitiesWindow;
}
function refreshActivitiesWindow(url) {
if (activitiesWindow != undefined) {
Expand Down
Expand Up @@ -39,7 +39,7 @@
<link rel="stylesheet" href="{% url webstatic "css/tooltip.css" %}" type="text/css" media="screen"/>

<script type="text/javascript">
jQuery.fn.runScript = function() {
jQuery.fn.runScript = function(actWindow) {
var $form = $(this);
var postData = $form.serialize();
var actionUrl = $form.attr('action');
Expand All @@ -50,16 +50,19 @@
contentType:'json',
success: function(data){
if(data.status == 'in progress') {
// we don't try to open 'Activities' window here, since it triggers popup blockers
// we don't try to open 'Activities' window here, since it triggers popup blockers...
window.opener.refreshProgressBar();
actWindow.location.href = '{% url status %}'; //...but we can refresh
self.close();
}
else {
// error is stored in http session - displayed in 'Activities' window.
actWindow.location.href = '{% url status %}';
self.close();
}
},
error: function(data) {
actWindow.location.href = '{% url status %}';
self.close();
}
});
Expand All @@ -69,11 +72,13 @@
$(document).ready(function() {
$('form').submit(function() {
$("#submit").attr("disabled", true); // make sure we don't submit twice.
$(this).runScript();

// if an "existing" window is opened by the window behind this one, we can't focus it...
window.open("", 'Activities').close(); // make sure there is no existing 'Activities' window
window.opener.popupActivites('{% url status %}');
var actWindow = window.opener.popupActivites('{% url status %}');

// pass the window to runScript() so we can refresh the window on AJAX callback.
$(this).runScript(actWindow);
return false;
});

Expand Down

0 comments on commit 91ca374

Please sign in to comment.