", { 'class': 'pagetoolbox', 'id': 'ptb' + index }).on(pageToolBoxEvent, function (event, shiftKey) {
/*
var origBG = '#404040'
var origActiveBG = '#455667';
var activeBG = '#ffa200';
*/
var pdfPageCount;
var startIndex;
var endIndex;
if ((event.shiftKey || shiftKey) && lastPdfIndex !== -1) {
// Select multiple pages
if (index < lastPdfIndex)
{ startIndex = index; endIndex = lastPdfIndex - 1; }
else
{ startIndex = lastPdfIndex + 1; endIndex = index; }
for (x = startIndex; x <= endIndex; x++)
{
pdfPageIndex = $.inArray(x, pdfPages);
// Select/Deselect a single page
if(pdfPageIndex < 0) {
pdfPageCount = pdfPages.push(x);
$('#ptb' + x).addClass('selected').css('display', 'block');;
if(!pdfBar.hasClass('active')) {
pdfBar.removeClass('disabled').addClass('active').fadeTo(200, 1);
}
}
}
lastPdfIndex = index;
}
else {
pdfPageIndex = $.inArray(index, pdfPages);
// Select/Deselect a single page
if(pdfPageIndex < 0) {
pdfPageCount = pdfPages.push(index);
pageToolbox.addClass('selected').css('display', 'block');
if(!pdfBar.hasClass('active')) {
pdfBar.removeClass('disabled').addClass('active').fadeTo(200, 1);
}
lastPdfIndex = index;
} else {
pdfPageCount = pdfPages.remove(pdfPageIndex);
pageToolbox.removeClass('selected');
lastPdfIndex = -1;
}
}
// Re-sort pdfs
pdfPages.sort(function (a, b){ return (a-b); });
updatePdfPageCounter(pdfPageCount);
// Prevent event propagating to dragscrollable
event.stopPropagation();
});
var isAnimating = false;
var pdfPageIndex = $.inArray(index, pdfPages);
// Page has already been added to pdfPages
if(pdfPageIndex >= 0) {
pageToolbox.addClass('selected').css('display', 'block');
}
// Hard coded dimensions due to inability to ensure correct dimensions
pageToolbox.data('info', {
index: index,
origWidth: 230,
origHeight: 70
});
return pageToolbox;
}
function updatePdfPageCounter(pdfPageCount) {
var origBG = '#404040'
var origActiveBG = '#455667';
var activeBG = '#ffa200';
pdfCounter.stop(true, true).animate({ backgroundColor : activeBG }, 100, 'easeOutQuad', function() {
if(pdfPageCount <= 0) {
pdfCounter.text('No Pages Added');
pdfBar.removeClass('active').addClass('disabled');
} else if(pdfPageCount == 1) {
pdfCounter.text(pdfPageCount + ' Page Added');
pdfReviewCounter.text(pdfPageCount + ' Page');
} else {
pdfCounter.text(pdfPageCount + ' Pages Added');
pdfReviewCounter.text(pdfPageCount + ' Pages');
}
}).animate({ backgroundColor : (pdfPageCount <= 0) ? origBG : origActiveBG }, 400, 'easeOutQuad');
}
// Create BeautyTips if canvas exists & not IE (results in singlepage view scrolling to top)
if(Modernizr.canvas) { // && !$.browser.msie) {
$('.dicon, .jqmClose').bt({
padding: 10,
spikeLength: 10,
spikeGirth: 13,
fill: '#266099',
strokeWidth: 0,
shrinkToFit: true,
positions: ['most'],
overlap: -1,
cssStyles: { color: '#fff' },
hoverIntentOpts: {
interval: 500,
timeout: 0
}
});
}
br.numLeafs = 244;
br.bookTitle = '';
br.imagesBaseURL = '/images/';
br.titleLeaf = 5;
BookReader.prototype.addPageToolBox = function (index, page) {
var pageToolbox = this.getPageToolbox(index);
pageToolbox.appendTo(page);
}
BookReader.prototype.add2upPageToolBox = function (index, page) {
return;
}
BookReader.prototype.scrollDown = function() {
br.next();
}
BookReader.prototype.scrollUp = function() {
br.prev();
}
// Bookviewer crashes ie6, dont even attempt to load it
if (!$('html').is('.ie6')) {
br.init();
var BRtoolbar = $("#BRtoolbar").detach();
BRtoolbar.appendTo("#BRtoolbarwrapper");
$('.BRtoolbar-container').append("");
var PDFtoolbar = $("#toolbar-top").detach();
PDFtoolbar.prependTo("#BRtoolbar");
$('#BRtoolbar').prepend("
");
var AnnotationBox = $("#AnnotationBox").detach();
AnnotationBox.appendTo("#right-panel-content");
if (!true) $("#showSearchButton").hide();
// Print page
var printPageButton = $('.page_print');
printPageButton.on("click", function () {
var printImg = $('
![]()
', { src: br.getPageURI(br.currentIndex()) });
printImg.css({ 'width': '100%', 'height': '100%', 'object-fit': 'contain' });
printImg.on("load", function () {
printWindow.print();
printWindow.close();
});
var printWindow = window.open('', "PrintWindow", "width=750,height=650,top=50,left=50,toolbars=no,scrollbars=yes,status=no,resizable=yes");
$(printWindow.document.body).append(printImg);
printWindow.document.close();
printWindow.focus();
});
// Toggle left hand container for Pages
var showPagesButton = $('#showPagesButton');
showPagesButton.on("click", function () {
$("#left-panel2").toggle("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
if (showPagesButton.attr("title") == "Show Pages") {
showPagesButton.attr("title", "Hide Pages");
showPagesButton.text("Hide Pages");
showPagesButton.toggleClass("book_leftmost", true).toggleClass("book_rightmost", false);
} else {
showPagesButton.attr("title", "Show Pages");
showPagesButton.text("Show Pages");
showPagesButton.toggleClass("book_leftmost", false).toggleClass("book_rightmost", true);
}
});
// Toggle right hand container for text
var showOCRButton = $('#showOCRButton');
showOCRButton.on("click", function () {
newpageOCR.text("");
if (showOCRButton.attr("title") == "Show Text") {
updateOCR(br.currentIndex());
$("#right-panel2").show("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
$("#pageOCR-panel").show();
showOCRButton.attr("title", "Hide Text");
showOCRButton.html("Hide
Text");
showOCRButton.addClass("displayed");
} else {
$("#right-panel2").hide("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
showOCRButton.attr("title", "Show Text");
showOCRButton.html("Show
Text");
showOCRButton.removeClass("displayed");
}
resetInfoBox();
resetAnnotationsBox();
resetSearchBox();
});
// Toggle right hand container for info
var showInfoButton = $('#showInfoButton');
showInfoButton.on("click", function () {
if (showInfoButton.attr("title") == "Show Info") {
$("#right-panel2").show("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
$("#pageInfo-panel").show();
showInfoButton.attr("title", "Hide Info");
showInfoButton.html("Hide
Info");
showInfoButton.addClass("displayed");
} else {
$("#right-panel2").hide("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
showInfoButton.attr("title", "Show Info");
showInfoButton.html("Show
Info");
showInfoButton.removeClass("displayed");
}
resetPageOCRBox();
resetAnnotationsBox();
resetSearchBox();
});
// Toggle right hand container for Search
var showSearchButton = $('#showSearchButton');
showSearchButton.on("click", function () {
if (showSearchButton.attr("title") == "Search Inside") {
$("#right-panel2").show("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
$("#pageSearch-panel").show();
$("#sibSearchText").focus();
showSearchButton.attr("title", "Hide Search");
showSearchButton.html("Hide Search");
showSearchButton.addClass("displayed");
} else {
$("#right-panel2").hide("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
showSearchButton.attr("title", "Search Inside");
showSearchButton.html("Search Inside");
showSearchButton.removeClass("displayed");
}
resetPageOCRBox();
resetInfoBox();
resetAnnotationsBox();
});
// Toggle right hand container for Annotations
var showAnnotationsButton = $("#showAnnotationsButton");
showAnnotationsButton.on("click", function () {
if (showAnnotationsButton.attr("title") == "Show Annotations") {
$("#right-panel2").show("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
$("#AnnotationBox").show();
showAnnotationsButton.attr("title", "Hide Annotations");
showAnnotationsButton.html("Hide
Annotations");
showAnnotationsButton.addClass("displayed");
} else {
$("#right-panel2").hide("fast", function () { if (br.mode == 3) { br.resizePageView(); } br.centerPageView(); });
showAnnotationsButton.attr("title", "Show Annotations");
showAnnotationsButton.html("Show
Annotations");
showAnnotationsButton.removeClass("displayed");
}
resetPageOCRBox();
resetInfoBox();
resetSearchBox();
});
if ("false" === "false") {
showAnnotationsButton.hide();
} else {
showAnnotationsButton.trigger('click');
window.setTimeout("br.centerPageView()", 500);
}
updateUIHeights();
}
$("#BRcontainer").on('scroll', this, function (e) {
if (self.mode != self.constMode2up) {
e.data.loadLeafs();
}
$('.pagetoolbox').each(function () {
if (actionMode == actionModeType.Select) {
$(this).show();
}
})
});
});
$(window).on('resize', this, function (e) {
updateUIHeights();
});
function updateUIHeights() {
var leftPanelHeight = $("#left-panel2").height();
var pagesPanel = $("#lstPages").outerHeight();
var namesPanel = $("#names-panel").outerHeight();
var topTotalHeight = 0;
$("#left-panel2 .left-panel-boxes:first-child").children().each(function(){
topTotalHeight = topTotalHeight + $(this).outerHeight();
});
topTotalHeight = topTotalHeight-pagesPanel;
var bottomTotalHeight = 0;
$("#left-panel2 .left-panel-boxes:last-child").children().each(function(){
bottomTotalHeight = bottomTotalHeight + $(this).outerHeight();
});
bottomTotalHeight = bottomTotalHeight-namesPanel;
var lphh = (leftPanelHeight)/4;
if (leftPanelHeight < 720) {
topTotalHeight = 0;
bottomTotalHeight = 0;
}
if (topTotalHeight >= bottomTotalHeight) {
finalHeight = topTotalHeight;
} else {
finalHeight = bottomTotalHeight;
}
finalHeight += lphh;
$("#names-panel").height(leftPanelHeight/3);
var isiPad = navigator.userAgent.match(/(iPad)|(iPhone)|(iPod)/i) != null;
if (!isiPad) {
var newHeight = leftPanelHeight/4;
var showMore = ($(".showmore a").html() === "Show Less"); // current state of list boxes
if (showMore)
{
var newHeight = leftPanelHeight * 0.75;
}
$("#lstPages").height(newHeight);
$("#lstPages").css("min-height", newHeight);
$("#lstSegments").height(newHeight);
$("#lstSegments ul").height(newHeight);
}
$("div.text span").height(leftPanelHeight-($("#BRtoolbarwrapper").height()+$("div.header").height()));
}
function resetAnnotationsBox() {
$("#AnnotationBox").hide();
$("#showAnnotationsButton").attr("title", "Show Annotations");
$("#showAnnotationsButton").html("Show
Annotations");
$("#showAnnotationsButton").removeClass("displayed");
}
function resetSearchBox() {
$("#pageSearch-panel").hide();
$("#showSearchButton").attr("title", "Search Inside");
$("#showSearchButton").html("Search
Inside");
$("#showSearchButton").removeClass("displayed");
}
function resetInfoBox() {
$("#pageInfo-panel").hide();
$("#showInfoButton").attr("title", "Show Info");
$("#showInfoButton").html("Show
Info");
$("#showInfoButton").removeClass("displayed");
}
function resetPageOCRBox() {
$("#pageOCR-panel").hide();
$("#showOCRButton").attr("title", "Show Text");
$("#showOCRButton").html("Show
Text");
$("#showOCRButton").removeClass("displayed");
}
function resetPDFDialog() {
$("#tbEmail").val("");
$("#tbTitle").val("");
$("#tbAuthors").val("");
$("#tbSubjects").val("");
}
function showTitleSelector() {
titleSelector.style.display = 'inline';
document.addEventListener("mouseup", hideTitleSelector, false);
}
function hideTitleSelector(e) {
var titleSelectorPopup = $(".titleSelector");
if (!titleSelectorPopup.is(e.target) // if the target of the click isn't the container...
&& (titleSelectorPopup.has(e.target).length === 0) // ... nor a descendant of the container
&& (e.target != titleSelectorPopup.get(0))) // nor the scrollbar
{
closeTitleSelector();
}
}
function closeTitleSelector() {
var titleSelectorPopup = document.getElementsByClassName('brTitleSelectPopup')[0];
titleSelectorPopup.style.display = 'none';
document.removeEventListener("mouseup", hideTitleSelector, false);
}
$(document).ready(function(){
// Called when we click on the tab itself
$('#pagestab').on("click", function() {
if ($('#pagestab').hasClass('active')) return false;
$('#pagestabcontent').show();
$('#segmentstabcontent').hide();
$('#pagestab').toggleClass("active");
$('#segmentstab').toggleClass("active");
// Do nothing when tab is clicked
return false;
});
// Called when we click on the tab itself
$('#segmentstab').on("click", function() {
if ($('#segmentstab').hasClass('active')) return false;
$('#pagestabcontent').hide();
$('#segmentstabcontent').show();
$('#pagestab').toggleClass("active");
$('#segmentstab').toggleClass("active");
// Do nothing when tab is clicked
return false;
});
var segmentCount = 1;
if (segmentCount == 0) {
$('#segmentstab').hide();
}
});
//]]>