Skip to content

Commit

Permalink
Merge pull request #638 from dchiller/issue-635-go-to-first-chant-fea…
Browse files Browse the repository at this point in the history
…ture

Add go to first chant nav button
  • Loading branch information
dchiller committed Oct 10, 2022
2 parents 206dbd1 + 6ce9f18 commit ff6f2e2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Marionette from 'marionette';
import Backbone from 'backbone';
import $ from 'jquery';

import template from './diva-folio-advancer.template.html';

var manuscriptChannel = Backbone.Radio.channel('manuscript');
/**
* A widget with buttons that controls
*/
Expand All @@ -12,13 +14,15 @@ export default Marionette.ItemView.extend({
ui:
{
nextButton: ".next-folio",
previousButton: ".previous-folio"
previousButton: ".previous-folio",
firstChantFolioButton: ".first-chant-folio"
},

events:
{
"click @ui.nextButton": "nextButtonCallbackHandler",
"click @ui.previousButton": "previousButtonCallbackHandler"
"click @ui.previousButton": "previousButtonCallbackHandler",
"click @ui.firstChantFolioButton": "firstChantFolioCallbackHandler",
},

/**
Expand Down Expand Up @@ -65,6 +69,18 @@ export default Marionette.ItemView.extend({
);
},

firstChantFolioCallbackHandler: function(event){
// Query which folio in the manuscript has the first chant
var manuscript = manuscriptChannel.request('manuscript');
var queryUrl = '/folio-set/manuscript/' + manuscript + '/';
var divaData = this.getDivaData();
$.get(queryUrl,
function(data){
var firstFolioURI = data[0].image_uri;
divaData.gotoPageByName(firstFolioURI);
})
},

/**
* Change the Diva page index. numberChangeFunction is a function that
* takes the current page index and returns the desired new page index.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<div class="diva-folio-advancer-region">
<nav>
<ul class="pager text-right">
<li><a href="#" class="first-chant-folio"><span class="glyphicon glyphicon-log-in" aria-hidden="true"></span> Go to first chant</a></li>
<li><a href="#" class="previous-folio"><span class="glyphicon glyphicon-chevron-up" aria-hidden="true"></span> Previous Folio</a></li>
<li>
<a href="#" class="next-folio">Next Folio <span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span></a>
Expand Down

0 comments on commit ff6f2e2

Please sign in to comment.