Skip to content

Commit

Permalink
Compute total cover dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
melmothx committed Jan 30, 2024
1 parent 49ca2b9 commit fca82eb
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions root/src/bookcovers/edit.tt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</div>
<form action="[% c.uri_for_action('/bookcovers/edit', bookcover.bookcover_id) %]"
method="POST"
id="bookcover-form"
enctype="multipart/form-data">

<div class="row">
Expand Down Expand Up @@ -87,6 +88,15 @@
id="marklength">
</div>
</div>
<div class="form-group">
<label for="total-lengths" class="col-sm-6 text-right">[% loc('Total size (mm)') %]
</label>
<div class="col-sm-6" id="total-lengths">
<strong>
<span id="paper-width"></span> x <span id="paper-height"></span>
</strong>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-6 col-sm-6">
<div class="checkbox">
Expand Down Expand Up @@ -230,3 +240,25 @@
</div>
</div>
</form>

<script>
$(document).ready(function() {
function compute_total() {
console.log("Computing totals");
var total_height = parseInt($('#coverheight').val() || 0)
+ parseInt($('#bleedwidth').val() || 0) * 2
+ parseInt($('#marklength').val() || 0) * 2;
var total_width = parseInt($('#coverwidth').val() || 0) * 2
+ parseInt($('#spinewidth').val() || 0)
+ parseInt($('#wrapwidth').val() || 0) * 2
+ parseInt($('#flapwidth').val() || 0) * 2
+ parseInt($('#bleedwidth').val() || 0) * 2
+ parseInt($('#marklength').val() || 0) * 2;
$('#paper-height').text(total_height);
$('#paper-width').text(total_width);
}
compute_total();
$('#bookcover-form').on('keyup', compute_total);
$('#bookcover-form').on('change', compute_total);
});
</script>

0 comments on commit fca82eb

Please sign in to comment.