Skip to content

Commit

Permalink
do new loading modal style in all queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy B. Merrill committed May 15, 2014
1 parent 13bb501 commit bc92ce2
Showing 1 changed file with 18 additions and 23 deletions.
41 changes: 18 additions & 23 deletions webapp/static/js/pdf_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Tabula.PDFView = Backbone.View.extend({
'click a#help-start': function(){ Tabula.tour.ended ? Tabula.tour.restart(true) : Tabula.tour.start(true); },

//events for buttons on the follow-you-around bar.
'click #should-preview-data-checkbox' : 'setShouldPreviewData',
'click #should-preview-data-checkbox' : 'updateShouldPreviewDataAutomaticallyButton',
'click #clear-all-selections': 'clear_all_selection',
'click #restore-detected-tables': 'restore_detected_tables',
'click #repeat-lassos': 'repeat_lassos',
Expand All @@ -93,26 +93,12 @@ Tabula.PDFView = Backbone.View.extend({
},

queryWithToggledExtractionMethod: function(e){
$('#switch-method').prop('disabled', true);
$('#data-modal .modal-body').prepend(this.$loading.show());// $('#loading').show();

$('#data-modal .modal-body table').css('visibility', 'hidden');
$('#data-modal .modal-body').css('overflow', 'hidden');

console.log("before", this.extractionMethod);
// console.log("before", this.extractionMethod);
this.extractionMethod = this.getOppositeExtractionMethod();
console.log("after", this.extractionMethod);
// console.log("after", this.extractionMethod);
this.updateExtractionMethodButton();

this.redoQuery({
success: _.bind(function() {
//$('#loading').remove();
this.$loading = this.$loading.detach();
$('#switch-method').prop('disabled', false);
$('#data-modal .modal-body table').css('visibility', 'visible');
$('#data-modal .modal-body').css('overflow', 'auto');
}, this)
});
this.redoQuery();
},

updateExtractionMethodButton: function(){
Expand Down Expand Up @@ -167,7 +153,7 @@ Tabula.PDFView = Backbone.View.extend({

initialize: function(){
_.bindAll(this, 'render', 'createImgareaselects', 'getTablesJson', 'total_selections',
'toggleClearAllAndRestorePredetectedTablesButtons', 'setShouldPreviewData', 'query_all_data', 'redoQuery');
'toggleClearAllAndRestorePredetectedTablesButtons', 'updateShouldPreviewDataAutomaticallyButton', 'query_all_data', 'redoQuery');
this.pageCount = $('img.page-image').length;
this.render();
this.updateExtractionMethodButton();
Expand All @@ -179,7 +165,7 @@ Tabula.PDFView = Backbone.View.extend({
return this;
},

setShouldPreviewData: function(){
updateShouldPreviewDataAutomaticallyButton: function(){
this.noModalAfterSelect = !$('#should-preview-data-checkbox').is(':checked');
},

Expand Down Expand Up @@ -383,7 +369,7 @@ Tabula.PDFView = Backbone.View.extend({
$(e.currentTarget).fadeOut(500, function() { $(this).remove(); });

$('#should-preview-data-checkbox').prop('checked', false);
this.setShouldPreviewData();
this.updateShouldPreviewDataAutomaticallyButton();

imgAreaSelects.slice(page_idx).forEach(function(imgAreaSelectAPIObj) {
if (imgAreaSelectAPIObj === false) return;
Expand Down Expand Up @@ -434,6 +420,11 @@ Tabula.PDFView = Backbone.View.extend({

$('#data-modal').modal();

$('#switch-method').prop('disabled', true);
$('#data-modal .modal-body').prepend(this.$loading.show());
$('#data-modal .modal-body table').css('visibility', 'hidden');
$('#data-modal .modal-body').css('overflow', 'hidden');

$.ajax({
type: 'POST',
url: '/pdf/' + pdf_id + '/data',
Expand All @@ -447,6 +438,11 @@ Tabula.PDFView = Backbone.View.extend({
console.log("resp", resp);
console.log("Extraction method: ", this.extractionMethod);

this.$loading = this.$loading.detach();
$('#switch-method').prop('disabled', false);
$('#data-modal .modal-body table').css('visibility', 'visible');
$('#data-modal .modal-body').css('overflow', 'auto');


var tableHTML = '<table class="table table-condensed table-bordered">';
$.each(_.pluck(resp, 'data'), function(i, rows) {
Expand All @@ -455,8 +451,7 @@ Tabula.PDFView = Backbone.View.extend({
});
});
tableHTML += '</table>';

$('.modal-body').html(tableHTML);
$('#data-modal .modal-body').html(tableHTML);

$('#download-form').attr("action", '/pdf/' + pdf_id + '/data?format=csv');

Expand Down

0 comments on commit bc92ce2

Please sign in to comment.