Skip to content

Commit

Permalink
Update javascript to use document metadata JSON.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Terrell committed May 16, 2014
1 parent 92514c5 commit 38c5443
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,26 @@ class BookReaderManager
constructor: ->
return unless $("#BookReader").length > 0
@element = $("#BookReader")
@br = this.initialize_bookreader()
$('#BRtoolbar').find('.read').hide();
$('#textSrch').hide();
$('#btnSrch').hide();
this.get_metadata($.proxy(this.initialize_bookreader, this))
$('#BRtoolbar').find('.read').hide()
$('#textSrch').hide()
$('#btnSrch').hide()
get_metadata: (callback) ->
pid = @element.data("pid")
$.getJSON("/document/#{pid}.json", (data) =>
@page_info = data["pages"]
callback()
)
initialize_bookreader: ->
@br = new BookReader()
@br.imagesBaseURL = "/assets/bookreader/images/"
@br.getPageWidth = (index) -> 1000
@br.getPageHeight = (index) -> 1000
@br.getPageWidth = (index) => @page_info[index]["size"]["width"]
@br.getPageHeight = (index) => @page_info[index]["size"]["height"]
@br.getPageURI = this.getPageURI
@br.getPageSide = this.getPageSide
@br.getSpreadIndices = this.getSpreadIndices
@br.getPageNum = (index) -> index+1
@br.numLeafs = @element.data("pages")
@br.numLeafs = @page_info.length
@br.bookTitle = @element.data("title")
@br.bookUrl = ''
@br.getEmbedCode = -> return "Embedding is disabled."
Expand All @@ -31,7 +37,7 @@ class BookReaderManager
else
return'L'
getSpreadIndices: (pindex) =>
spreadIndices = [null, null];
spreadIndices = [null, null]
if 'rl' == @br.pageProgression
if this.getPageSide(pindex) == 'R'
spreadIndices[1] = pindex
Expand All @@ -42,8 +48,8 @@ class BookReaderManager
else
if this.getPageSide(pindex) == 'L'
spreadIndices[0] = pindex
spreadIndices[1] = pindex + 1;
spreadIndices[1] = pindex + 1
else
spreadIndices[1] = pindex
spreadIndices[0] = pindex-1
return spreadIndices
return spreadIndices
3 changes: 2 additions & 1 deletion app/decorators/document_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def data_hash
{
:pages => pages,
:title => title,
:root => root
:root => root,
:pid => pid
}
end

Expand Down

0 comments on commit 38c5443

Please sign in to comment.