-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created a WebivaExporter, now exports can follow you around the site.
Changed Webform to use WebivaExporter.
- Loading branch information
Doug Youch
committed
Oct 13, 2010
1 parent
f5212ca
commit dc279dc
Showing
8 changed files
with
119 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% if session[:download_worker_key] && Workling.return.get(session[:download_worker_key]) -%> | ||
<div id="download_notice" class='flash_notice'> | ||
<span id="download_status"><%= 'Still Exporting...' %></span> | ||
</div> | ||
<script> | ||
new WebivaExporter({status: "#download_status", onComplete: function() {$j('#download_notice').hide();}}); | ||
</script> | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
|
||
WebivaExporter = function(opts) { | ||
var $ = jQuery; | ||
var buttonId = opts.button; | ||
var statusId = opts.status ? opts.status : buttonId + '_status'; | ||
var generateUrl = opts.url; | ||
var statusUrl = opts.statusUrl ? opts.statusUrl : '/website/file/export_status'; | ||
var downloadUrl = opts.downloadUrl ? opts.downloadUrl : '/website/file/export_file'; | ||
var onComplete = opts.onComplete; | ||
|
||
function showButton() { | ||
if(buttonId) { | ||
$(buttonId).show(); | ||
} | ||
|
||
$(statusId).hide(); | ||
|
||
if(onComplete) { | ||
onComplete(); | ||
} | ||
} | ||
|
||
function download() { | ||
$(statusId).html("Starting Download"); | ||
document.location = downloadUrl; | ||
setTimeout(function(){showButton();}, 3000); | ||
} | ||
|
||
function failure() { | ||
$(statusId).html("Download Failed"); | ||
setTimeout(function(){showButton();}, 3000); | ||
} | ||
|
||
function status() { | ||
$.get(statusUrl, function(data) { | ||
if(data.completed) { | ||
download(); | ||
} else if(data.failed) { | ||
failure(); | ||
} else { | ||
$(statusId).html('Still Exporting...'); | ||
setTimeout(function() {status();}, 1000); | ||
} | ||
}); | ||
} | ||
|
||
if(buttonId && generateUrl) { | ||
$(buttonId).click(function() { | ||
$(buttonId).hide(); | ||
$(statusId).show(); | ||
$(statusId).html('Exporting File'); | ||
|
||
$.get(generateUrl, function(data) { | ||
$(statusId).html('Generating File'); | ||
status(); | ||
}); | ||
}); | ||
} else if(statusId) { | ||
setTimeout(function() {status();}, 500); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 11 additions & 34 deletions
45
vendor/modules/webform/app/views/webform/manage/results.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,21 @@ | ||
<script> | ||
<%= active_table_javascript %> | ||
<% action_panel do |p| -%> | ||
<% p.custom do %> | ||
<a href="javascript:void(0);" id="export_button"><%= theme_image_tag('icons/title_actions/configure.gif') %> <%= 'Export Results to CSV'.t %></a> | ||
<span id="export_button_status"></span> | ||
<% end %> | ||
<% end -%> | ||
|
||
Exporter = { | ||
generate: function() { | ||
$('export_download').innerHTML = '<%= jh "Exporting File".t %>'; | ||
Element.show('export_download'); | ||
$('export_submit_button').hide(); | ||
new Ajax.Request("<%= url_for :controller => '/webform/export', :action => 'generate_file', :path => [@webform.id] %>", | ||
{ onComplete: function(req) { | ||
setTimeout(Exporter.status,1000); | ||
} | ||
} | ||
); | ||
}, | ||
|
||
status: function() { | ||
$('export_download').innerHTML = '<%= jh "Still Exporting...".t %>'; | ||
new Ajax.Request("<%= url_for :controller => '/webform/export', :action => 'status', :path => [@webform.id] %>") | ||
}, | ||
|
||
download: function() { | ||
$('export_download').innerHTML = '<%= jh "Starting Download".t %>'; | ||
document.location = "<%= url_for :controller => '/webform/export', :action => 'download_file', :path => [@webform.id] %>"; | ||
setTimeout(Exporter.backToContent,3000); | ||
|
||
}, | ||
|
||
backToContent: function() { | ||
document.location = "<%= url_for %>"; | ||
} | ||
} | ||
<script> | ||
new WebivaExporter({button: "#export_button", | ||
url: "<%= url_for :controller => '/webform/export', :action => 'generate_file', :path => [@webform.id] %>" | ||
}); | ||
</script> | ||
|
||
<div class="admin_content"><ul class="action_panel"> <li><a onclick="Exporter.generate();" href="javascript:void(0);" id="export_submit_button"><img alt="Add" src="/themes/standard/images/icons/actions/add.gif?1259075050" align="absmiddle">Export Results to CSV</a> <span id="export_download"></span></li> | ||
</ul></div> | ||
|
||
<hr/> | ||
|
||
<div class='admin_content'> | ||
<div id='webform_result_table'> | ||
<%= render :partial => 'webform_result_table' %> | ||
</div> | ||
</div> | ||
|