-
Notifications
You must be signed in to change notification settings - Fork 0
/
eirt.min.js
11 lines (11 loc) · 8.33 KB
/
eirt.min.js
1
2
3
4
5
6
7
8
9
10
11
/**!
* Exame Informática Reader Tools
* https://github.com/pedrofsantoscom/exame-informatica-reader-tools
*
* Copyright 2015 Pedro F. Santos, http://pedrofsantos.com, [email protected]
* Released under the MIT license
* http://en.wikipedia.org/wiki/MIT_License
*
* Version: 2015.09.22
*/
var EIReaderTools={version:"2015.09.22",options:{fullscreen:{icon:{on:"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgBAMAAACBVGfHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABVQTFRFAAAAAAAAAAAAAAAAAAAAAAAAAAAAEgEApAAAAAZ0Uk5TAA+fz9/vpTOW9gAAAJNJREFUKM/NkkEKwyAUBSeeQOoFDAX3duERcoQcQJN3/yN08RVLUui2fyE4Ph/IyPLiY56eoDj3TpmiOkFSI2lEPE6qtgSA3A+TtBaA9pAq4KRTANr77SQZUO93E1j9sg9wegDCTGQAygTN80fz+3FsAxx8T1w7nHQY2CySpJgAqpMq3QVANA3mwo/6eld5k339Dm89PDdxiEGVaQAAAABJRU5ErkJggg==",off:"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAI1JREFUeNrsV0EOwCAI6w/8/6lP8gk8ZTuPLUoirltCEy8mpY0iIAAcg0WsgxONreIRE4+bhnzYr05AkgO2wQQHV3wxwAmBieJe6xY8w0Q0BlcDZHOngXqA1zPziE68BTjNmWDGM4qKexNEoVAoJPVzWSGSlmJpM3q1HcsHEvlI9omhtL5m9TWT5cApwAD/IigEZttSgAAAAABJRU5ErkJggg=="}},savedFunctions:{ResizeViewer:{orig:ResizeViewer,mod:function(){var e=Math.max(400,document.documentElement.clientHeight),i=Math.round(pw*e/ph);ResizeMenu(),zoom&&(i=Math.max(1e3,Math.min(1502,document.documentElement.clientWidth)),$("#bvdPage div.pages").width(i).height(e).children(".panviewport").width(i).height(e)),zoom||null!=crop||RszImgs(i,e)}},CancelZoom:{orig:CancelZoom,mod:function(){var e=$(this).find("img");$("#bvdMenu").show(),e.css("transform",""),EIReaderTools.options.savedFunctions.CancelZoom.orig()}},PageChange:{orig:PageChange,mod:function(){CancelCut(),Tag(),TagAd(),smode||$(window).trigger("resize"),player&&$("#jqp").jPlayer("play"),$(document).trigger("endPageChanged.eirt"),$("#ctl00_cph_viewer1_bvdPages").append($("<div>").addClass("eirt-loading"))}}}},highlightSidePage:function(){var e=GetPage().p,i=$("#bvdMenuInner"),t=$("#bvdMenuImg img").removeClass("eirt-highlight"),o=t.eq(e);o.addClass("eirt-highlight"),t.eq(e+(e%2==0?1:-1)).addClass("eirt-highlight"),i.stop().animate({scrollTop:98*parseInt(e/2)},1e3)},requestPageLoading:function(e){e=e||{type:"click",target:$(".crn.topright")[0]};var i=$("#bvNav td.bvNavLinkSec, #bvdMenuImg img, .crn.topleft, .crn.topright"),t=$(".eirt-loading");("click"===e.type&&i.find(e.target).length||i.is(e.target))&&"none"===t.css("display")&&(t.css("display","block"),$(document).one("endPageChanged.eirt",function(){$(".eirt-loading").remove()}))},initPagination:function(){var e=$("<div>",{id:"eirt-pag-cont"}).css({display:"inline-block",color:"#000",position:"relative",padding:"0 2px","border-left":"1px solid hsl(0, 0%, 70%)","border-right":"1px solid hsl(0, 0%, 70%)"}).insertAfter($("#eirt-state")),i=function(e){if(e.stopPropagation(),e.preventDefault(),"click"!==e.type){var i=e.keyCode?e.keyCode:e.which;if(13!==i||"keyup"!==e.type)return!1}var t=$(this),o=t;t.siblings("#eirt-pag-input").length>0&&(o=t.siblings("#eirt-pag-input"));var n=o.val(),a=$("#bvdMenuImg img[onclick]");o.val("");var r={i:2,inicio:0,fim:a.length-1},s={i:2,begin:0,end:a.length-1};if(null!=r[n]||null!=s[n])return $(a[r[n]||s[n]]).click(),void 0;var d=parseInt(n);if(null!=d&&0/0!==d){var l=Math.max(Math.min(d,a.length),0);$(a[l]).click(),EIReaderTools.requestPageLoading()}},t=function(e){80==e.which&&e.altKey&&$("#eirt-pag-input").focus()},o=function(){$(this).on("keyup.esc.eirt",function(e){var i=$(this);return 27===e.which&&i.is(":focus")?(document.getElementByTagName().blur(),!1):void 0}).one("blur.esc.eirt",function(){$(this).off("keyup.esc.eirt")})};$("<input>",{id:"eirt-pag-input",type:"text",placeholder:"Página"}).css({width:"40px",height:"14px",margin:"0px 3px 0 5px"}).appendTo(e),$(document).on("keyup.eirt",t).on("keyup.eirt","#eirt-pag-input",i).on("focus.eirt","#eirt-pag-input",o).on("click.eirt","#eirt-pag-acc",i)},initNavigation:function(){$(document).on("keyup.eirt",function(e){var i=$("#bvdMenuImg img[onclick]"),t=$(".page.fleft"),o=$(".page.fright");if(39===e.which){0===o.length&&(o=$(".page:visible"));var n=o.attr("src"),a=+n.split("/")[3].replace("f","");a<i.length-1&&$(".crn.topright").click()}else{if(37!==e.which)return;0===t.length&&(t=$(".page:visible"));var n=t.attr("src"),a=+n.split("/")[3].replace("f","");a>1&&$(".crn.topleft").click()}EIReaderTools.requestPageLoading()})},initZoom:function(){var e=function(e,i,t){return Math.max(Math.min(e,t),i)};$(document).on("mousewheel.eirt",".panviewport",function(i){var t=$(this).find("img:visible"),o=-i.originalEvent.deltaY,n=t.data("scale")||1,a=e(o/1e3+n,.1,1),r="scale("+a+")".replace("@par",a);t.data("scale",a).css({transform:r}),i.preventDefault()})},initFullscreen:function(){{var e=EIReaderTools.options.fullscreen.icon,i=function(i){var t=$(this);if("keyup"===i.type&&(t=$("#eirt-fs")),!(27!==i.which&&"keyup"===i.type||27===i.which&&!t.data("mode"))){i.data=i.data||{},i.data.modeOverride=i.data?i.data.modeOverride:null;var o=null!=i.data.modeOverride?i.data.modeOverride:!t.data("mode"),n='url("data:image/png;base64,'+e.off+'")',a="50%",r="-219%",s="6px",d="orig",l=$("#zahirad192");$("#bvdPage_css").remove(),o&&($("<style>",{id:"bvdPage_css"}).html("#bvdPage { position: absolute; top: 0; right: 0; left: 0; bottom: 0; margin: 0; z-index: 1000; background-color: #F5F5F5; }").appendTo($("head")),d="mod",n='url("data:image/png;base64,'+e.on+'")',l=$("body"),fsPosition="absolute",s="0",a="0",r="0%");var g=$("#eirt-container").css({left:a,top:s}).attr("style");$("#eirt-container").attr("style",g+";transform: translateX("+r+");"),t.css("background-image",n),t.data("mode",o),ResizeViewer=EIReaderTools.options.savedFunctions.ResizeViewer[d],$(window).trigger("resize")}};$("<div>",{id:"eirt-fs"}).css({display:"inline-block",width:"15px",height:"15px","background-image":'url("data:image/png;base64,'+e.off+'")',"margin-left":"5px",position:"relative",top:"3px","background-size":"100%"}).data("mode",!1).click(i).insertAfter($("#eirt-pag-cont"))}$(document).on("keyup.fullscreen.eirt",{modeOverride:!1},i)},init:function(){EIReaderTools.reset(),$(document).on("click.eirt.requestStarted",EIReaderTools.requestPageLoading),$("<div>",{id:"eirt-container"}).css({position:"absolute",left:"50%",transform:"translateX(-219%)",top:"5px","z-index":"1010",background:"#fff",padding:"4px","border-right":"1px solid hsl(0, 0%, 70%)","border-bottom":"1px solid hsl(0, 0%, 70%)"}).appendTo($("body")),$("<span>",{id:"eirt-state"}).text("EIReaderTools").css({color:"#f00","margin-right":"5px",position:"relative",top:"-4px"}).appendTo($("#eirt-container")),$("head").append($("<style>",{id:"eirt-style"}).text('#eirt-state:after{content: "v'+EIReaderTools.version+'";color: black;font-size: 8px;position: absolute;left: 0;bottom: -8px;margin-left: 32px;}#bvdMenuImg img.eirt-highlight{border: 4px solid rgb(0, 173, 239);margin: 0;}@keyframes loading{to {transform: rotate(360deg);}}@-webkit-keyframes loading{to {-webkit-transform: rotate(360deg);}}.eirt-loading{display: none;min-width: 100%;min-height: 100%;position: absolute;background-color: hsla(100, 0%, 0%, 0.5);}.eirt-loading:before{content: "A carregar...";position: absolute;top: 50%;left: 50%;width: 150px;height: 150px;margin-top: -75px;margin-left: -75px;}.eirt-loading:not(:required):before{content: "";border-radius: 50%;border-top: 10px solid #03ade0;border-right: 0px solid transparent;animation: loading 1s linear infinite;-webkit-animation: loading 1s linear infinite;}')),$("#ctl00_cph_viewer1_bvdPages").append($("<div>").addClass("eirt-loading")),$(document).on("endPageChanged.eirt",EIReaderTools.highlightSidePage),CancelZoom=EIReaderTools.options.savedFunctions.CancelZoom.mod,PageChange=EIReaderTools.options.savedFunctions.PageChange.mod,EIReaderTools.initPagination(),EIReaderTools.initNavigation(),EIReaderTools.initFullscreen(),EIReaderTools.initZoom(),EIReaderTools.highlightSidePage(),$("#eirt-state").css("color","#32CD32")},reset:function(){$("#eirt-container,#eirt-style").remove(),$("#bvdMenuImg img").removeClass("eirt-highlight"),ResizeViewer=EIReaderTools.options.savedFunctions.ResizeViewer.orig,CancelZoom=EIReaderTools.options.savedFunctions.CancelZoom.orig,PageChange=EIReaderTools.options.savedFunctions.PageChange.orig,$(document).off("click.eirt.requestStarted").off("click.eirt").off("dblclick.eirt").off("mousewheel.eirt").off("keyup.eirt").off("keyup.fullscreen.eirt").off("endPageChanged.eirt")}};$(document).ready(EIReaderTools.init);