flowpaper.js 92 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640
  1. /**
  2. █▒▓▒░ The FlowPaper Project
  3. This file is part of FlowPaper.
  4. For more information on FlowPaper please see the FlowPaper project
  5. home page: https://flowpaper.com
  6. */
  7. /**
  8. *
  9. * FlowPaper helper function for retrieving a active FlowPaper instance
  10. *
  11. */
  12. window.$FlowPaper = window.getDocViewer = window["$FlowPaper"] = function(id){
  13. var instance = (id==="undefined")?"":id;
  14. return window["FlowPaperViewer_Instance"+instance];
  15. };
  16. /**
  17. *
  18. * FlowPaper embedding (name of placeholder, config)
  19. *
  20. */
  21. window.FlowPaperViewerEmbedding = window.$f = function(id, args) {
  22. this.id = id;
  23. var userAgent = navigator.userAgent.toLowerCase();
  24. var browser = window["eb.browser"] = {
  25. version: (userAgent.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/) || [])[1],
  26. safari: (/webkit/.test(userAgent) || /applewebkit/.test(userAgent)) && !(/chrome/.test(userAgent)),
  27. opera: /opera/.test(userAgent),
  28. msie: /msie/.test(userAgent) && !/opera/.test(userAgent),
  29. mozilla: /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent),
  30. seamonkey: /seamonkey/.test(userAgent),
  31. chrome: /chrome/.test(userAgent)
  32. };
  33. browser.detected = browser.safari || browser.opera || browser.msie || browser.mozilla || browser.seamonkey || browser.chrome;
  34. // assume Chrome version 500 if we couldnt detect it
  35. if(!browser.detected || !browser.version){
  36. browser.chrome = true; browser.version = "500.00";
  37. }
  38. var platform = window["eb.platform"] = {
  39. win:/win/.test(userAgent),
  40. mac:/mac/.test(userAgent),
  41. touchdevice : (function(){try {return 'ontouchstart' in document.documentElement;} catch (e) {return false;} })(),
  42. android : (userAgent.indexOf("android") > -1),
  43. ios : ((userAgent.match(/iphone/i)) || (userAgent.match(/ipod/i)) || (userAgent.match(/ipad/i))),
  44. iphone : (userAgent.match(/iphone/i)) || (userAgent.match(/ipod/i)),
  45. ipad : (userAgent.match(/ipad/i)),
  46. winphone : userAgent.match(/Windows Phone/i),
  47. blackberry : userAgent.match(/BlackBerry/i) || userAgent.match(/BB10/i),
  48. webos : userAgent.match(/webOS/i)
  49. };
  50. platform.touchonlydevice = platform.touchdevice && (platform.android || platform.ios || platform.winphone || platform.blackberry || platform.webos);
  51. var config = args.config;
  52. var _SWFFile,_PDFFile,_IMGFiles,_SVGFiles,_IMGFiles_thumbs="",_IMGFiles_highres="",_JSONFile = "",_jsDirectory="",_cssDirectory="",_localeDirectory="";_WMode = (config.WMode!=null||config.wmode!=null?config.wmode||config.WMode:"direct");
  53. var _uDoc = ((config.DOC !=null)?unescape(config.DOC):null);
  54. var instance = "FlowPaperViewer_Instance"+((id==="undefined")?"":id);
  55. var _JSONDataType = (config.JSONDataType!=null)?config.JSONDataType:"json";
  56. if (_uDoc != null) {
  57. _SWFFile = FLOWPAPER.translateUrlByFormat(_uDoc,"swf");
  58. _PDFFile = FLOWPAPER.translateUrlByFormat(_uDoc,"pdf");
  59. _JSONFile = FLOWPAPER.translateUrlByFormat(_uDoc,_JSONDataType);
  60. _IMGFiles = FLOWPAPER.translateUrlByFormat(_uDoc,"jpg");
  61. _SVGFiles = FLOWPAPER.translateUrlByFormat(_uDoc,"svg");
  62. _IMGFiles_thumbs = FLOWPAPER.translateUrlByFormat(_uDoc,"jpg");
  63. _IMGFiles_highres = FLOWPAPER.translateUrlByFormat(_uDoc,"jpgpageslice");
  64. }
  65. _SWFFile = (config.SwfFile!=null?config.SwfFile:_SWFFile);
  66. _SWFFile = (config.SWFFile!=null?config.SWFFile:_SWFFile);
  67. _PDFFile = (config.PDFFile!=null?config.PDFFile:_PDFFile);
  68. _IMGFiles = (config.IMGFiles!=null?config.IMGFiles:_IMGFiles);
  69. _IMGFiles = (config.PageImagePattern!=null?config.PageImagePattern:_IMGFiles);
  70. _SVGFiles = (config.SVGFiles!=null?config.SVGFiles:_SVGFiles);
  71. _IMGFiles_thumbs = (config.ThumbIMGFiles!=null?config.ThumbIMGFiles:_IMGFiles_thumbs);
  72. _IMGFiles_highres = (config.HighResIMGFiles!=null?config.HighResIMGFiles:_IMGFiles_highres);
  73. _JSONFile = (config.JSONFile!=null?config.JSONFile:_JSONFile);
  74. _jsDirectory = (config.jsDirectory!=null?config.jsDirectory:FLOWPAPER.detectjsdir());
  75. _cssDirectory = (config.cssDirectory!=null?config.cssDirectory:FLOWPAPER.detectcssdir());
  76. _localeDirectory = (config.localeDirectory!=null?config.localeDirectory:"locale/");
  77. if(_SWFFile!=null && _SWFFile.indexOf("{" )==0 && _SWFFile.indexOf("[*," ) > 0 && _SWFFile.indexOf("]" ) > 0){_SWFFile = escape(_SWFFile);} // split file fix
  78. // routine for *.flowpaper.com hosted domains
  79. var hostname = FLOWPAPER.getHostName();
  80. if(hostname.indexOf(".flowpaper.")>-1 && hostname.length > 16){
  81. var subDomain = hostname.substr(0,hostname.indexOf("flowpaper.")-1);
  82. var folderName = window.location.pathname.split('/')[1];
  83. if(config.URLAlias){
  84. subDomain = config.URLAlias.substr(8,config.URLAlias.indexOf("flowpaper.")-9);
  85. }
  86. if(subDomain != "test-online" && subDomain != "online"){
  87. var trialHosted = subDomain.indexOf('-trial')>-1;
  88. var cloudUrl = trialHosted?"https://test-cdn-online.flowpaper.com/":"https://cdn-online.flowpaper.com/";
  89. _IMGFiles = _IMGFiles && _IMGFiles.indexOf('docs') == 0?cloudUrl + subDomain + '/' + folderName + '/' + _IMGFiles:_IMGFiles;
  90. // _PDFFile = _PDFFile && _PDFFile.indexOf('docs') == 0 && _PDFFile.indexOf('[')>-1?cloudUrl + subDomain + '/' + folderName + '/' + _PDFFile:_PDFFile;
  91. _IMGFiles_thumbs = _IMGFiles_thumbs && _IMGFiles_thumbs.indexOf('docs') == 0?cloudUrl + subDomain + '/' + folderName + '/' + _IMGFiles_thumbs:_IMGFiles_thumbs;
  92. _IMGFiles_highres = _IMGFiles_highres && _IMGFiles_highres.indexOf('docs') == 0?cloudUrl + subDomain + '/' + folderName + '/' + _IMGFiles_highres:_IMGFiles_highres;
  93. if(config.URLAlias){
  94. _JSONFile = _JSONFile && _JSONFile.indexOf('docs') == 0?config.URLAlias + _JSONFile:_JSONFile;
  95. _PDFFile = _PDFFile && _PDFFile.indexOf('docs') == 0?config.URLAlias + _PDFFile:_PDFFile;
  96. }
  97. }
  98. }
  99. // overwrite StartAtPage with anything off the hash
  100. if(FLOWPAPER.getLocationHashParameter){
  101. var pageFromHash = FLOWPAPER.getLocationHashParameter('page');
  102. if(pageFromHash!=null){
  103. config.StartAtPage = pageFromHash;
  104. }
  105. }
  106. if(FLOWPAPER.getLocationHashParameter){
  107. var previewModeFromHash = FLOWPAPER.getLocationHashParameter('PreviewMode');
  108. if(previewModeFromHash!=null){
  109. config.PreviewMode = previewModeFromHash;
  110. }
  111. }
  112. // remove the ?reload parameter from being shown if any
  113. if(FLOWPAPER.getParameterByName && FLOWPAPER.getParameterByName('reload') && window.location.href && window.location.href.indexOf('.flowpaper.com')>-1){
  114. var currURL = window.location.href;
  115. window.history.pushState({}, document.title, currURL.replace('?reload='+FLOWPAPER.getParameterByName('reload'),''));
  116. }
  117. if(config.PreviewMode == "FrontPage" && ((_IMGFiles!=null && _IMGFiles.length>0) || (_IMGFiles_thumbs!=null && _IMGFiles_thumbs.length>0))){
  118. FLOWPAPER.initFrontPagePreview(id,args,(_IMGFiles_thumbs!=null && _IMGFiles_thumbs.length>0)?_IMGFiles_thumbs:_IMGFiles);
  119. return;
  120. }
  121. // append signature & policy to the urls if we're authenticated
  122. if(FLOWPAPER.authenticated){
  123. _SWFFile = FLOWPAPER.appendUrlParameter(_SWFFile,FLOWPAPER.authenticated.getParams());
  124. _PDFFile = FLOWPAPER.appendUrlParameter(_PDFFile,FLOWPAPER.authenticated.getParams());
  125. _IMGFiles = FLOWPAPER.appendUrlParameter(_IMGFiles,FLOWPAPER.authenticated.getParams());
  126. _SVGFiles = FLOWPAPER.appendUrlParameter(_SVGFiles,FLOWPAPER.authenticated.getParams());
  127. _JSONFile = FLOWPAPER.appendUrlParameter(_JSONFile,FLOWPAPER.authenticated.getParams());
  128. _IMGFiles_thumbs = FLOWPAPER.appendUrlParameter(_IMGFiles_thumbs,FLOWPAPER.authenticated.getParams());
  129. _IMGFiles_highres = FLOWPAPER.appendUrlParameter(_IMGFiles_highres,FLOWPAPER.authenticated.getParams());
  130. config.BrandingLogo = FLOWPAPER.appendUrlParameter(config.BrandingLogo,FLOWPAPER.authenticated.getParams());
  131. }
  132. window[instance] = fpembed(id, {
  133. src : _jsDirectory+"../FlowPaperViewer.swf",
  134. version : [11, 0],
  135. expressInstall : "js/expressinstall.swf",
  136. wmode : _WMode
  137. },{
  138. ElementId : id,
  139. SwfFile : _SWFFile,
  140. PdfFile : _PDFFile,
  141. IMGFiles : _IMGFiles,
  142. SVGFiles : _SVGFiles,
  143. JSONFile : _JSONFile,
  144. ThumbIMGFiles : _IMGFiles_thumbs,
  145. HighResIMGFiles : _IMGFiles_highres,
  146. useCustomJSONFormat : config.useCustomJSONFormat,
  147. JSONPageDataFormat : config.JSONPageDataFormat,
  148. JSONDataType : _JSONDataType,
  149. Scale : (config.Scale!=null)?config.Scale:0.8,
  150. ZoomTransition : (config.ZoomTransition!=null)?config.ZoomTransition:'easeOut',
  151. ZoomTime : (config.ZoomTime!=null)?config.ZoomTime:0.5,
  152. ZoomInterval : (config.ZoomInterval)?config.ZoomInterval:0.1,
  153. TouchZoomInterval : (config.TouchZoomInterval)?config.TouchZoomInterval:1.5,
  154. FitPageOnLoad : (config.FitPageOnLoad!=null)?config.FitPageOnLoad:false,
  155. FitWidthOnLoad : (config.FitWidthOnLoad!=null)?config.FitWidthOnLoad:false,
  156. FullScreenAsMaxWindow : (config.FullScreenAsMaxWindow!=null)?config.FullScreenAsMaxWindow:false,
  157. ProgressiveLoading : (config.ProgressiveLoading!=null)?config.ProgressiveLoading:false,
  158. MinZoomSize : (config.MinZoomSize!=null)?config.MinZoomSize:0.2,
  159. MaxZoomSize : (config.MaxZoomSize!=null)?config.MaxZoomSize:5,
  160. SearchMatchAll : (config.SearchMatchAll!=null)?config.SearchMatchAll:false,
  161. SearchServiceUrl : config.SearchServiceUrl,
  162. InitViewMode : config.InitViewMode,
  163. DisableOverflow : config.DisableOverflow,
  164. RTLMode : config.RTLMode,
  165. DisplayRange : config.DisplayRange,
  166. TouchInitViewMode : config.TouchInitViewMode,
  167. PreviewMode : config.PreviewMode,
  168. PublicationTitle : config.PublicationTitle,
  169. LinkTarget : config.LinkTarget,
  170. LoaderImage : config.LoaderImage,
  171. MixedMode : config.MixedMode,
  172. URLAlias : config.URLAlias,
  173. EnableWebGL : config.EnableWebGL,
  174. AutoDetectLinks : config.AutoDetectLinks,
  175. ImprovedAccessibility : config.ImprovedAccessibility,
  176. BitmapBasedRendering : (config.BitmapBasedRendering!=null)?config.BitmapBasedRendering:false,
  177. StartAtPage : (config.StartAtPage!=null&&config.StartAtPage.toString().length>0&&!isNaN(config.StartAtPage))?config.StartAtPage:1,
  178. FontsToLoad : config.FontsToLoad,
  179. PrintPaperAsBitmap : (config.PrintPaperAsBitmap!=null)?config.PrintPaperAsBitmap:((browser.safari||browser.mozilla)?true:false),
  180. PrintFn : config.PrintFn,
  181. AutoAdjustPrintSize : (config.AutoAdjustPrintSize!=null)?config.AutoAdjustPrintSize:true,
  182. EnableSearchAbstracts : ((config.EnableSearchAbstracts!=null)?config.EnableSearchAbstracts:true),
  183. EnableCornerDragging : ((config.EnableCornerDragging!=null)?config.EnableCornerDragging:true), // FlowPaper Zine parameter
  184. BackgroundColor : config.BackgroundColor, // FlowPaper Zine parameter
  185. PanelColor : config.PanelColor, // FlowPaper Zine parameter
  186. BackgroundAlpha : config.BackgroundAlpha, // FlowPaper Zine parameter
  187. UIConfig : config.UIConfig, // FlowPaper Zine parameter
  188. PageIndexAdjustment : config.PageIndexAdjustment,
  189. SharingUrl : config.SharingUrl,
  190. BrandingLogo : config.BrandingLogo,
  191. BrandingUrl : config.BrandingUrl,
  192. ViewModeToolsVisible : ((config.ViewModeToolsVisible!=null)?config.ViewModeToolsVisible:true),
  193. ZoomToolsVisible : ((config.ZoomToolsVisible!=null)?config.ZoomToolsVisible:true),
  194. NavToolsVisible : ((config.NavToolsVisible!=null)?config.NavToolsVisible:true),
  195. CursorToolsVisible : ((config.CursorToolsVisible!=null)?config.CursorToolsVisible:true),
  196. SearchToolsVisible : ((config.SearchToolsVisible!=null)?config.SearchToolsVisible:true),
  197. AnnotationToolsVisible : ((config.AnnotationToolsVisible!=null)?config.AnnotationToolsVisible:true), // Annotations viewer parameter
  198. StickyTools : config.StickyTools,
  199. UserCollaboration : config.UserCollaboration,
  200. CurrentUser : config.CurrentUser,
  201. Toolbar : config.Toolbar,
  202. BottomToolbar : config.BottomToolbar,
  203. DocSizeQueryService : config.DocSizeQueryService,
  204. RenderingOrder : config.RenderingOrder,
  205. TrackingNumber : config.TrackingNumber,
  206. localeChain : (config.localeChain!=null)?config.localeChain:"en_US",
  207. jsDirectory : _jsDirectory,
  208. cssDirectory : _cssDirectory,
  209. localeDirectory : _localeDirectory,
  210. signature : config.signature,
  211. key : config.key
  212. });
  213. if(config.LinkTarget){
  214. FLOWPAPER.LinkTarget = config.LinkTarget;
  215. }
  216. // add TrackingNumber to the data collection for easier use in events later
  217. if(config.TrackingNumber && config.TrackingNumber.length>0){
  218. var _trackSWFFile = _SWFFile; if(_trackSWFFile){_trackSWFFile = (_trackSWFFile.indexOf("/")>0?_trackSWFFile.substr(_trackSWFFile.lastIndexOf("/")+1):_trackSWFFile); _trackSWFFile = _trackSWFFile.replace("_[*,0]",""); _trackSWFFile = _trackSWFFile.replace(".swf",".pdf"); _trackSWFFile = (_trackSWFFile.indexOf("}")>0?_trackSWFFile.substr(0,_trackSWFFile.lastIndexOf(",")):_trackSWFFile);}
  219. var _trackPDFFile = _PDFFile; if(_trackPDFFile){_trackPDFFile = (_trackPDFFile.indexOf("/")>0?_trackPDFFile.substr(_trackPDFFile.lastIndexOf("/")+1):_trackPDFFile); _trackPDFFile = _trackPDFFile.replace("_[*,0]","").replace("_[*,2]","");}
  220. var _trackJSONFile = _JSONFile; if(_JSONFile){_trackJSONFile = (_trackJSONFile.indexOf("/")>0?_trackJSONFile.substr(_trackJSONFile.lastIndexOf("/")+1):_trackJSONFile); _trackJSONFile = _trackJSONFile.replace("{page}",""); _trackJSONFile = _trackJSONFile.replace(".js",".pdf");}
  221. jQuery('#'+id).data('TrackingDocument',(_trackPDFFile || _trackSWFFile || _trackJSONFile));
  222. jQuery('#'+id).data('TrackingNumber',config.TrackingNumber);
  223. }
  224. };
  225. window.TrackFlowPaperEvent = function(trackingNumber,trackingDocument,eventType,eventLabel,pagenum){
  226. if(trackingNumber && document.location.href.indexOf('http://localhost') == -1 && document.location.href.indexOf('http://127.0.0.1') == -1){
  227. var trackingDoc = trackingDocument;
  228. var pagelocation = (document.location.pathname.indexOf('.html')>-1?document.location.pathname.substr(0,document.location.pathname.lastIndexOf('.html'))+'/':document.location.pathname)+(pagenum?'#page='+pagenum:'');
  229. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  230. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  231. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  232. })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  233. ga('create', trackingNumber, 'auto', 'FlowPaperEventTracker');
  234. ga('FlowPaperEventTracker.send', {
  235. hitType: 'event',
  236. eventCategory: 'PDF Documents',
  237. eventAction: eventType,
  238. eventLabel: eventLabel
  239. });
  240. }
  241. };
  242. (function() {
  243. if(!window.FLOWPAPER){window.FLOWPAPER = {};}
  244. FLOWPAPER.detectjsdir = function(){
  245. if(jQuery('script[src$="flowpaper.js"]').length>0){
  246. return jQuery('script[src$="flowpaper.js"]').attr('src').replace('flowpaper.js','');
  247. }else{
  248. return "js/"
  249. }
  250. };
  251. FLOWPAPER.detectcssdir= function(){
  252. if(jQuery('link[href$="flowpaper.css"]').length>0){
  253. return jQuery('link[href$="flowpaper.css"]').attr('href').replace('flowpaper.css','');
  254. }else{
  255. return "css/"
  256. }
  257. };
  258. // placeholder for signature/policies when using signed urls
  259. FLOWPAPER.authenticated=null;
  260. FLOWPAPER.getLocationHashParameter = function(param){
  261. var hash = location.hash.substr(1);
  262. if(hash.indexOf(param+'=')>=0){
  263. var value = hash.substr(hash.indexOf(param+'='))
  264. .split('&')[0]
  265. .split('=')[1];
  266. return value;
  267. }
  268. return null;
  269. };
  270. FLOWPAPER.translateUrlByFormat = function(url,format){
  271. if(url.indexOf("{") == 0 && format != "swf"){ // loading in split file mode
  272. url = url.substring(1,url.lastIndexOf(","));
  273. if(format!="pdf"){
  274. url = url.replace("[*,0]","{page}")
  275. url = url.replace("[*,2]","{page}")
  276. }
  277. }else if(format == "swf" && url.indexOf("{") != 0){
  278. url = url.replace("{page}", "");
  279. url = url.replace(/&/g, '%26');
  280. url = url.replace(/ /g, '%20');
  281. }
  282. if(format =="jpgpageslice"){
  283. url = url + "&sector={sector}";
  284. }
  285. url = (url!=null && url.indexOf('{format}') > 0 ? url.replace("{format}", format):null);
  286. return url;
  287. };
  288. FLOWPAPER.translateUrlByDocument = function(url,document){
  289. return (url!=null && url.indexOf('{doc}') > 0 ? url.replace("{doc}", document):null);
  290. };
  291. FLOWPAPER.animateDenyEffect = function(obj,margin,time,cycles,dir) {
  292. window.setTimeout(function(){
  293. var speed = time / ((2*cycles)+1);
  294. var margRat = 1 + (60/(cycles*cycles)); jQuery(obj).stop(true,true);
  295. for (var i=0; i<=cycles; i++) {
  296. for (var j=-1; j<=1; j+=2)
  297. jQuery(obj).animate({marginLeft: (i!=cycles)*j*margin},{duration:speed, queue:true});
  298. margin/=margRat;
  299. }
  300. },500);
  301. };
  302. FLOWPAPER.initFrontPagePreview = function initFrontPagePreview(viewerid,args,IMGFiles){
  303. var animate = true;
  304. jQuery(document.body).css('background-color',jQuery('#'+viewerid).css('background-color'));
  305. var img = new Image();
  306. jQuery(img).bind('load',function(){
  307. jQuery(document.body).append(
  308. "<div id='flowpaper_frontpagePreview_"+viewerid+"'>"+
  309. "<form class='flowpaper_htmldialog' method='POST' style='display:none;top:100px;margin:"+((jQuery(window).height()>350)?"50px auto":"0px auto")+";padding-bottom:0px;'>"+
  310. "<div class='flowpaper_preview_container flowpaper_publications flowpaper_publication_csstransforms3d' style='overflow-y:hidden;overflow-x:hidden;text-align:center;margin: -25px -25px 0px;padding: 15px 25px 20px 25px;'>"+
  311. "<div class='flowpaper_publication flowpaper_publication_csstransforms3d' style='cursor:pointer;margin-bottom:20px;'>"+
  312. "<img src='"+(IMGFiles.replace("{page}",1))+"' />"+
  313. "</div>"+
  314. ((args.config.PublicationTitle!=null && args.config.PublicationTitle.length>0)?"<h1 class='flowpaper_htmldialog-title' style='margin-bottom:0px;'>"+unescape(args.config.PublicationTitle)+"</h1>":"")+
  315. "</div>"+
  316. "</form>"+
  317. "</div>"
  318. );
  319. var anim_duration = animate?1000:0;
  320. var anim_height_dur = animate?anim_duration/3:0;
  321. var theight = 260;
  322. jQuery('.flowpaper_htmldialog').css({height : '0px', display : 'block'});
  323. jQuery('.flowpaper_htmldialog').animate({'height': theight+'px','top':'0px'},{duration: anim_height_dur, complete: function(){
  324. var preview_container = jQuery('#flowpaper_frontpagePreview_'+viewerid);
  325. var container_width = preview_container.find('.flowpaper_preview_container').width();
  326. var container_height = preview_container.find('.flowpaper_preview_container').height();
  327. preview_container.find('.flowpaper_htmldialog').css({'height' : ''}); // remove height attribute to fit publication
  328. preview_container.find('.flowpaper_preview_container').append("<div class='flowpaper_frontpagePreview_play' style='position:absolute;left:"+(container_width/2)+"px;top:"+(container_height/2-((args.config.PublicationTitle!=null)?50:25))+"px;width:0px;height:0px;border-bottom:50px solid transparent;border-top:50px solid transparent;border-left:50px solid #AAAAAA;'></div>");
  329. var playbutton = preview_container.find('.flowpaper_frontpagePreview_play');
  330. playbutton.css({opacity : 0.85, 'cursor' : 'pointer'});
  331. preview_container.find('.flowpaper_publication, .flowpaper_frontpagePreview_play').on("mouseover",function(e){
  332. jQuery(playbutton).css({
  333. 'border-left' : '50px solid #FFFFFF',
  334. opacity : 0.85
  335. });
  336. });
  337. preview_container.find('.flowpaper_publication, .flowpaper_frontpagePreview_play').on("mouseout",function(e){
  338. jQuery(playbutton).css({
  339. 'border-left' : '50px solid #AAAAAA'
  340. });
  341. });
  342. preview_container.find('.flowpaper_publication, .flowpaper_frontpagePreview_play').on("mousedown",function(e){
  343. jQuery('#flowpaper_frontpagePreview_'+viewerid).remove();
  344. args.config.PreviewMode=null;
  345. jQuery('#'+viewerid).FlowPaperViewer(args);
  346. });
  347. jQuery('.flowpaper_publication').animate({opacity:1},{
  348. step : function(now,fx){
  349. var target = -7;var opacityfrom = -40;var diff = opacityfrom - target;var rotate = (diff * now);
  350. jQuery('.flowpaper_publication').css({
  351. '-webkit-transform' : 'perspective(300) rotateY('+(opacityfrom - rotate)+'deg)',
  352. '-moz-transform' : 'rotateY('+(opacityfrom - rotate)+'deg)',
  353. 'box-shadow' : '5px 5px 20px rgba(51, 51, 51, '+now+')'
  354. });
  355. },
  356. duration:anim_duration
  357. });
  358. }});
  359. });
  360. img.src = (IMGFiles.replace("{page}",1));
  361. };
  362. FLOWPAPER.requireSignature = function(signService,loginFormImage,sharingPath,user){
  363. if($.cookie("FLOWPAPER_AUTH")){
  364. var cookieObj = JSON.parse($.cookie("FLOWPAPER_AUTH"));
  365. FLOWPAPER.authenticated = {
  366. Policy : cookieObj.Policy,
  367. Signature : cookieObj.Signature,
  368. KeyPairId : cookieObj.Keypairid,
  369. getParams : function(){
  370. return 'Policy='+cookieObj.Policy+'&Signature='+cookieObj.Signature+'&Key-Pair-Id='+cookieObj.KeyPairId;
  371. }
  372. }
  373. $('#loginForm').remove();
  374. $('#documentViewer').show();
  375. initViewer();
  376. }else{
  377. $('#documentViewer').hide();
  378. FLOWPAPER.initLoginForm(loginFormImage,true,function(){
  379. $('#loginForm').find('form').submit(function( event ) {
  380. event.preventDefault();
  381. $.post(signService,
  382. {
  383. publicationId : sharingPath+user, // added up upload service last part being the user
  384. password : $('#loginForm').find('#txt_flowpaper_password').val(),
  385. }, function(data){
  386. if(data && data.result == 'ACCEPT'){
  387. var policy = FLOWPAPER.getParameterByName('Policy',data.url);
  388. var signature = FLOWPAPER.getParameterByName('Signature',data.url);
  389. var keypairid = FLOWPAPER.getParameterByName('Key-Pair-Id',data.url);
  390. $.cookie("FLOWPAPER_AUTH", JSON.stringify({
  391. Policy : policy,
  392. Signature : signature,
  393. KeyPairId : keypairid
  394. }), { expires: 1 });
  395. FLOWPAPER.authenticated = {
  396. Policy : policy,
  397. Signature : signature,
  398. KeyPairId : keypairid,
  399. getParams : function(){
  400. return 'Policy='+this.Policy+'&Signature='+this.Signature+'&Key-Pair-Id='+keypairid;
  401. }
  402. }
  403. $('#loginForm').remove();
  404. $('#documentViewer').show();
  405. initViewer();
  406. }else{
  407. FLOWPAPER.animateDenyEffect ('#loginForm',25,500,7,'hor');
  408. }
  409. });
  410. return false;
  411. });
  412. });
  413. }
  414. };
  415. FLOWPAPER.initLoginForm = function initLoginForm(IMGFiles,animate,callback){
  416. jQuery(document.body).css('background-color','#dedede');
  417. var img = new Image();
  418. jQuery(img).bind('load',function(){
  419. jQuery(document.body).append(
  420. "<div id='loginForm'>"+
  421. "<form class='flowpaper_htmldialog' method='POST' style='display:none;top:100px;margin:"+((jQuery(window).height()>500)?"50px auto":"0px auto")+"'>"+
  422. "<div class='flowpaper_publications flowpaper_publication_csstransforms3d' style='overflow-y:hidden;overflow-x:hidden;text-align:center;background: #f7f7f7;margin: -25px -25px 0px;padding: 15px 25px 0px 25px;'>"+
  423. "<div class='flowpaper_publication flowpaper_publication_csstransforms3d' id='flowpaper_publication1'>"+
  424. "<img src='"+(IMGFiles.replace("{page}",1))+"' />"+
  425. "</div>"+
  426. "<h1 class='flowpaper_htmldialog-title'>password protected publication</h1>"+
  427. "<input type='password' id='txt_flowpaper_password' name='txt_flowpaper_password' class='flowpaper_htmldialog-input' placeholder='Enter password'>"+
  428. "<input type='submit' value='Submit' class='flowpaper_htmldialog-button'>"+
  429. "</div>"+
  430. "</form>"+
  431. "</div>"
  432. );
  433. var anim_duration = animate?1000:0;
  434. var anim_height_dur = animate?anim_duration/3:0;
  435. var theight = 400;
  436. jQuery('.flowpaper_htmldialog').css({height : '0px', display : 'block'});
  437. jQuery('.flowpaper_htmldialog').animate({'height': theight+'px','top':'0px'},{duration: anim_height_dur, complete: function(){
  438. jQuery('.flowpaper_htmldialog').css({'height' : ''}); // remove height attribute to fit publication
  439. jQuery('.flowpaper_publication').animate({opacity:1},{
  440. step : function(now,fx){
  441. var target = -7;var opacityfrom = -40;var diff = opacityfrom - target;var rotate = (diff * now);
  442. jQuery('.flowpaper_publication').css({
  443. '-webkit-transform' : 'perspective(300) rotateY('+(opacityfrom - rotate)+'deg)',
  444. '-moz-transform' : 'rotateY('+(opacityfrom - rotate)+'deg)',
  445. 'box-shadow' : '5px 5px 20px rgba(51, 51, 51, '+now+')'
  446. });
  447. },
  448. duration:anim_duration
  449. });
  450. }});
  451. if(callback){callback();}
  452. });
  453. img.src = (IMGFiles.replace("{page}",1));
  454. };
  455. FLOWPAPER.getParameterByName = function(name, url) {
  456. if (!url) url = window.location.href;
  457. name = name.replace(/[\[\]]/g, "\\$&");
  458. var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
  459. results = regex.exec(url);
  460. if (!results) return null;
  461. if (!results[2]) return '';
  462. return decodeURIComponent(results[2].replace(/\+/g, " "));
  463. };
  464. FLOWPAPER.appendUrlParameter = function(url,param){
  465. if(url){
  466. if(url.indexOf('?')>-1){
  467. url = url + '&' + param;
  468. }else{
  469. url = url + '?' + param;
  470. }
  471. }
  472. return url;
  473. };
  474. FLOWPAPER.blockedNewWindow = function(poppedWindow){
  475. var result = false;
  476. try {
  477. if (typeof poppedWindow == 'undefined') {
  478. // Safari with popup blocker... leaves the popup window handle undefined
  479. result = true;
  480. }
  481. else if (poppedWindow && poppedWindow.closed) {
  482. // This happens if the user opens and closes the client window...
  483. // Confusing because the handle is still available, but it's in a "closed" state.
  484. // We're not saying that the window is not being blocked, we're just saying
  485. // that the window has been closed before the test could be run.
  486. result = false;
  487. }
  488. else if (poppedWindow && poppedWindow.document) {
  489. // This is the actual test. The client window should be fine.
  490. result = false;
  491. }
  492. else {
  493. // Else we'll assume the window is not OK
  494. result = true;
  495. }
  496. } catch (err) {
  497. //if (console) {
  498. // console.warn("Could not access popup window", err);
  499. //}
  500. }
  501. return result;
  502. };
  503. FLOWPAPER.getHostName = function(){
  504. try{
  505. var url = window.location.href;
  506. if(!url){return '';}
  507. var a = document.createElement('a');
  508. if(url.indexOf('http')==-1){url='http://'+url;}
  509. a.href = url;
  510. return a.hostname;
  511. }catch(e){
  512. return '';
  513. }
  514. };
  515. })();
  516. /**
  517. *
  518. * FlowPaper embedding functionality.
  519. *
  520. */
  521. (function() {
  522. var ua = navigator.userAgent.toLowerCase();
  523. var IE = document.all,
  524. JQUERY = typeof jQuery == 'function',
  525. RE = /(\d+)[^\d]+(\d+)[^\d]*(\d*)/,
  526. INMETRO = /msie/.test(ua) && (function(){try {return !!new ActiveXObject("htmlfile");} catch (e) {return false;} })() && navigator.platform == "Win64" && (document.documentElement.clientWidth == screen.width),
  527. MOBILE = (function(){try {return 'ontouchstart' in document.documentElement;} catch (e) {return false;} })() || ua.match(/touch/i),
  528. MOBILEOS = ((ua.indexOf("android") > -1) || ((ua.match(/iphone/i)) || (ua.match(/ipod/i)) || (ua.match(/ipad/i))) || ua.match(/Windows Phone/i) || ua.match(/BlackBerry/i) || ua.match(/webOS/i)),
  529. GLOBAL_OPTS = {
  530. // very common opts
  531. width: '100%',
  532. height: '100%',
  533. id: "_" + ("" + Math.random()).slice(9),
  534. // fpembed defaults
  535. allowfullscreen: true,
  536. allowscriptaccess: 'always',
  537. quality: 'high',
  538. allowFullScreenInteractive : true,
  539. // fpembed specific options
  540. version: [10, 0],
  541. onFail: null,
  542. expressInstall: null,
  543. w3c: false,
  544. cachebusting: false
  545. };
  546. window.isTouchScreen = MOBILE && (MOBILEOS || INMETRO);
  547. // simple extend
  548. function extend(to, from) {
  549. if (from) {
  550. for (var key in from) {
  551. if (from.hasOwnProperty(key)) {
  552. to[key] = from[key];
  553. }
  554. }
  555. }
  556. return to;
  557. }
  558. // used by asString method
  559. function map(arr, func) {
  560. var newArr = [];
  561. for (var i in arr) {
  562. if (arr.hasOwnProperty(i)) {
  563. newArr[i] = func(arr[i]);
  564. }
  565. }
  566. return newArr;
  567. }
  568. window.fpembed = function(root, opts, conf) {
  569. // root must be found / loaded
  570. if (typeof root == 'string') {
  571. root = document.getElementById(root.replace("#", ""));
  572. }
  573. // not found
  574. if (!root) { return; }
  575. root.onclick = function(){return false;}
  576. if (typeof opts == 'string') {
  577. opts = {src: opts};
  578. }
  579. return new viewerEmbed(root, extend(extend({}, GLOBAL_OPTS), opts), conf);
  580. };
  581. // fpembed "static" API
  582. var f = extend(window.fpembed, {
  583. conf: GLOBAL_OPTS
  584. });
  585. function viewerEmbed(root, opts, conf) {
  586. var browser = window["eb.browser"];
  587. browser.version = browser.version?browser.version:"";
  588. var platform = window["eb.platform"];
  589. var supportsHTML4 = (browser.mozilla && browser.version.split(".")[0] >= 3) ||
  590. (browser.chrome) ||
  591. (browser.msie && browser.version.split(".")[0] >= 8) ||
  592. (browser.safari) ||
  593. (browser.opera);
  594. var supportsCanvasDrawing = (browser.mozilla && browser.version.split(".")[0] >= 4 && !browser.seamonkey) ||
  595. (browser.chrome) ||
  596. (browser.msie && browser.version.split(".")[0] >= 9) ||
  597. (browser.safari && browser.version.split(".")[0] >= 535 /*&& !platform.ios*/);
  598. // Default to a rendering mode if its not set
  599. if(!conf.RenderingOrder && conf.JSONFile != null && conf.JSONFile){conf.RenderingOrder = "html";}
  600. if(!conf.RenderingOrder && conf.PdfFile != null){conf.RenderingOrder = "html5";}
  601. if(platform.ios){
  602. var v = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
  603. if(v!=null && v.length>1){
  604. platform.iosversion = [parseInt(v[1], 10), parseInt(v[2], 10), parseInt(v[3] || 0, 10)][0];
  605. }
  606. }
  607. var viewerId = jQuery(root).attr('id');
  608. var instance = "FlowPaperViewer_Instance"+((viewerId==="undefined")?"":viewerId);
  609. window['ViewerMode'] = 'html';
  610. //jQuery.noConflict();
  611. jQuery(document).ready(function() {
  612. if(conf.Toolbar){jQuery.fn.showFullScreen = function(){$FlowPaper(jQuery(this).attr('id')).openFullScreen();}}
  613. // Enable cache of scripts. You can disable this if you want to force FlowPaper to use a non-cached version every time.
  614. jQuery.ajaxSetup({
  615. cache: true
  616. });
  617. var scriptPromise = new jQuery.Deferred();
  618. if(!window["FlowPaperViewer_HTML"]){
  619. jQuery.getScript(conf.jsDirectory+'FlowPaperViewer.js').then(function(){scriptPromise.resolve();}).fail(function(){
  620. if(arguments[0].readyState==0){
  621. console.log("failed to load FlowPaperViewer.js. Check your resources");
  622. }else{
  623. //script loaded but failed to parse
  624. console.log(arguments[2].toString());
  625. }
  626. });
  627. }else{
  628. scriptPromise.resolve();
  629. }
  630. if(scriptPromise.then(function(){
  631. // If rendering order isnt set but the formats are supplied then assume the rendering order.
  632. if(!conf.RenderingOrder){
  633. conf.RenderingOrder = "";
  634. if(conf.PdfFile!=null){conf.RenderingOrder = "html5";}
  635. }
  636. // add fallback for html if not specified
  637. if(conf.JSONFile!=null && conf.JSONFile.length>0 && conf.IMGFiles!=null && conf.IMGFiles.length>0){
  638. if((browser.safari /*&& (platform.iosversion<8 && platform.ipad)*/) || platform.android || (browser.msie && browser.version <=9) || platform.mobilepreview){ // ios should use html as preferred rendering mode if available.
  639. conf.RenderingOrder = "html" + (conf.RenderingOrder.length>0?",":"") + conf.RenderingOrder;
  640. }else{
  641. conf.RenderingOrder += (conf.RenderingOrder.length>0?",":"")+"html";
  642. }
  643. }
  644. var oRenderingList = conf.RenderingOrder.split(",");
  645. var pageRenderer = null;
  646. var usingFlattenedPDF = conf.FontsToLoad && conf.FontsToLoad.length>0;
  647. // if PDFJS isn't supported and the html formats are supplied, then use these as primary format
  648. if(oRenderingList && oRenderingList.length==1 && conf.JSONFile!=null && conf.JSONFile.length>0 && conf.IMGFiles!=null && conf.IMGFiles.length>0 && !supportsCanvasDrawing){
  649. oRenderingList[1] = conf.RenderingOrder[0];
  650. oRenderingList[0] = 'html';
  651. }
  652. if(!usingFlattenedPDF && conf.PdfFile!=null && conf.PdfFile.length>0 && conf.RenderingOrder.split(",").length>=1 && supportsCanvasDrawing && (oRenderingList[0] == 'html5')){
  653. pageRenderer = new CanvasPageRenderer(viewerId,conf.PdfFile,conf.jsDirectory,
  654. {
  655. jsonfile : conf.JSONFile,
  656. pageImagePattern : conf.IMGFiles,
  657. pageThumbImagePattern : conf.ThumbIMGFiles,
  658. compressedJSONFormat : !conf.useCustomJSONFormat,
  659. JSONPageDataFormat : conf.JSONPageDataFormat,
  660. JSONDataType : conf.JSONDataType,
  661. MixedMode : conf.MixedMode,
  662. URLAlias : conf.URLAlias,
  663. signature : conf.signature,
  664. PageIndexAdjustment : conf.PageIndexAdjustment,
  665. DisableShadows : conf.DisableOverflow,
  666. DisplayRange : conf.DisplayRange,
  667. RTLMode : conf.RTLMode
  668. });
  669. }else{
  670. pageRenderer = new ImagePageRenderer(
  671. viewerId,
  672. {
  673. jsonfile : conf.JSONFile,
  674. pageImagePattern : conf.IMGFiles,
  675. pageThumbImagePattern : conf.ThumbIMGFiles,
  676. pageHighResImagePattern : conf.HighResIMGFiles,
  677. pageSVGImagePattern : conf.SVGFiles,
  678. compressedJSONFormat : !conf.useCustomJSONFormat,
  679. JSONPageDataFormat : conf.JSONPageDataFormat,
  680. JSONDataType : conf.JSONDataType,
  681. SVGMode : conf.RenderingOrder.toLowerCase().indexOf('svg')>=0,
  682. MixedMode : conf.MixedMode,
  683. URLAlias : conf.URLAlias,
  684. signature : conf.signature,
  685. PageIndexAdjustment : conf.PageIndexAdjustment,
  686. DisableShadows : conf.DisableOverflow,
  687. DisableOverflow : conf.DisableOverflow,
  688. DisplayRange : conf.DisplayRange,
  689. RTLMode : conf.RTLMode,
  690. FontsToLoad : conf.FontsToLoad
  691. },
  692. conf.jsDirectory);
  693. }
  694. var flowpaper_html = window[instance] = new FlowPaperViewer_HTML({
  695. rootid : viewerId,
  696. Toolbar : ((conf.Toolbar!=null)?conf.Toolbar:null),
  697. BottomToolbar : ((conf.BottomToolbar!=null)?conf.BottomToolbar:null),
  698. instanceid : instance,
  699. document: {
  700. SWFFile : conf.SwfFile,
  701. IMGFiles : conf.IMGFiles,
  702. ThumbIMGFiles : conf.ThumbIMGFiles,
  703. JSONFile : conf.JSONFile,
  704. PDFFile : conf.PdfFile,
  705. Scale : conf.Scale,
  706. FitPageOnLoad : conf.FitPageOnLoad,
  707. FitWidthOnLoad : conf.FitWidthOnLoad,
  708. FullScreenAsMaxWindow : conf.FullScreenAsMaxWindow,
  709. MinZoomSize : conf.MinZoomSize,
  710. MaxZoomSize : conf.MaxZoomSize,
  711. SearchMatchAll : conf.SearchMatchAll,
  712. InitViewMode : conf.InitViewMode,
  713. DisableOverflow : conf.DisableOverflow,
  714. DisplayRange : conf.DisplayRange,
  715. RTLMode : conf.RTLMode,
  716. TouchInitViewMode : conf.TouchInitViewMode,
  717. PreviewMode : conf.PreviewMode,
  718. MixedMode : conf.MixedMode,
  719. URLAlias : conf.URLAlias,
  720. LoaderImage : conf.LoaderImage,
  721. SharingUrl : conf.SharingUrl,
  722. BrandingLogo : conf.BrandingLogo,
  723. BrandingUrl : conf.BrandingUrl,
  724. EnableWebGL : conf.EnableWebGL,
  725. StartAtPage : conf.StartAtPage,
  726. RenderingOrder : conf.RenderingOrder,
  727. useCustomJSONFormat : conf.useCustomJSONFormat,
  728. JSONPageDataFormat : conf.JSONPageDataFormat,
  729. JSONDataType : conf.JSONDataType,
  730. ZoomTime : conf.ZoomTime,
  731. ZoomTransition : conf.ZoomTransition,
  732. ZoomInterval : conf.ZoomInterval,
  733. TouchZoomInterval : conf.TouchZoomInterval,
  734. ViewModeToolsVisible : conf.ViewModeToolsVisible,
  735. ZoomToolsVisible : conf.ZoomToolsVisible,
  736. NavToolsVisible : conf.NavToolsVisible,
  737. CursorToolsVisible : conf.CursorToolsVisible,
  738. SearchToolsVisible : conf.SearchToolsVisible,
  739. AnnotationToolsVisible : conf.AnnotationToolsVisible,
  740. StickyTools : conf.StickyTools,
  741. AutoDetectLinks : conf.AutoDetectLinks,
  742. ImprovedAccessibility : conf.ImprovedAccessibility,
  743. PrintPaperAsBitmap : conf.PrintPaperAsBitmap,
  744. PrintFn : conf.PrintFn,
  745. AutoAdjustPrintSize : conf.AutoAdjustPrintSize,
  746. EnableSearchAbstracts : conf.EnableSearchAbstracts,
  747. EnableCornerDragging : conf.EnableCornerDragging,
  748. UIConfig : conf.UIConfig,
  749. BackgroundColor : conf.BackgroundColor, // FlowPaper Zine parameter
  750. PanelColor : conf.PanelColor, // FlowPaper Zine parameter
  751. localeChain : conf.localeChain
  752. },
  753. renderer : pageRenderer,
  754. key : conf.key,
  755. jsDirectory : conf.jsDirectory,
  756. localeDirectory : conf.localeDirectory,
  757. cssDirectory : conf.cssDirectory,
  758. docSizeQueryService : conf.DocSizeQueryService,
  759. UserCollaboration : conf.UserCollaboration,
  760. CurrentUser : conf.CurrentUser
  761. });
  762. flowpaper_html.initialize();
  763. flowpaper_html.bindEvents();
  764. flowpaper_html['load'] = flowpaper_html.loadFromUrl;
  765. flowpaper_html['loadDoc'] = flowpaper_html.loadDoc;
  766. flowpaper_html['fitWidth'] = flowpaper_html.fitwidth;
  767. flowpaper_html['fitHeight'] = flowpaper_html.fitheight;
  768. flowpaper_html['gotoPage'] = flowpaper_html.gotoPage;
  769. flowpaper_html['getCurrPage'] = flowpaper_html.getCurrPage;
  770. flowpaper_html['getTotalPages'] = flowpaper_html.getTotalPages;
  771. flowpaper_html['nextPage'] = flowpaper_html.next;
  772. flowpaper_html['prevPage'] = flowpaper_html.previous;
  773. flowpaper_html['setZoom'] = flowpaper_html.Zoom;
  774. flowpaper_html['Zoom'] = flowpaper_html.Zoom;
  775. flowpaper_html['ZoomIn'] = flowpaper_html.ZoomIn;
  776. flowpaper_html['ZoomOut'] = flowpaper_html.ZoomOut;
  777. flowpaper_html['openFullScreen'] = flowpaper_html.openFullScreen;
  778. flowpaper_html['sliderChange'] = flowpaper_html.sliderChange;
  779. flowpaper_html['searchText'] = flowpaper_html.searchText;
  780. flowpaper_html['expandOutline'] = flowpaper_html.expandOutline;
  781. flowpaper_html['resize'] = flowpaper_html.resize;
  782. flowpaper_html['rotate'] = flowpaper_html.rotate;
  783. flowpaper_html['addLink'] = flowpaper_html.addLink;
  784. flowpaper_html['addImage'] = flowpaper_html.addImage;
  785. flowpaper_html['addVideo'] = flowpaper_html.addVideo;
  786. //flowpaper_html['nextSearchMatch'] = flowpaper_html.nextSearchMatch; //TBD
  787. //flowpaper_html['prevSearchMatch'] = flowpaper_html.nextSearchMatch; //TBD
  788. flowpaper_html['switchMode'] = flowpaper_html.switchMode;
  789. flowpaper_html['printPaper'] = flowpaper_html.printPaper;
  790. flowpaper_html['highlight'] = flowpaper_html.highlight;
  791. flowpaper_html['getCurrentRenderingMode'] = flowpaper_html.getCurrentRenderingMode;
  792. //flowpaper_html['postSnapshot'] = flowpaper_html.postSnapshot; //TBD
  793. flowpaper_html['setCurrentCursor'] = flowpaper_html.setCurrentCursor;
  794. flowpaper_html['showFullScreen'] = flowpaper_html.openFullScreen;
  795. pageRenderer.initialize(function(){
  796. flowpaper_html.document.numPages = pageRenderer.getNumPages();
  797. flowpaper_html.document.dimensions = pageRenderer.getDimensions();
  798. flowpaper_html.show();
  799. window[instance] = flowpaper_html;
  800. },{
  801. StartAtPage : conf.StartAtPage,
  802. MixedMode : conf.MixedMode
  803. });
  804. }));
  805. });
  806. // bind a listener to the hash change event and change page if the user changes the page hash parameter
  807. jQuery(window).bind('hashchange',(function() {
  808. var page = FLOWPAPER.getLocationHashParameter('page');
  809. if(page){
  810. $FlowPaper(viewerId).gotoPage(page);
  811. }
  812. }));
  813. // http://flowplayer.org/forum/8/18186#post-18593
  814. if (IE) {
  815. window[opts.id] = document.getElementById(opts.id);
  816. }
  817. // API methods for callback
  818. extend(this, {
  819. getRoot: function() {
  820. return root;
  821. },
  822. getOptions: function() {
  823. return opts;
  824. },
  825. getConf: function() {
  826. return conf;
  827. },
  828. getApi: function() {
  829. return root.firstChild;
  830. }
  831. });
  832. }
  833. // setup jquery support
  834. if (JQUERY) {
  835. jQuery.fn.fpembed = function(opts, conf) {
  836. return this.each(function() {
  837. jQuery(this).data("fpembed", fpembed(this, opts, conf));
  838. });
  839. };
  840. jQuery.fn.FlowPaperViewer = function(args){
  841. jQuery('#'+this.attr('id')).empty();
  842. var embed = new FlowPaperViewerEmbedding(this.attr('id'),args);
  843. this.element = jQuery('#'+embed.id);
  844. return this.element;
  845. };
  846. }else{
  847. throw new Error("jQuery missing!");
  848. }
  849. })();
  850. if (!String.prototype.endsWith) {
  851. String.prototype.endsWith = function (suffix) {
  852. return (this.substr(this.length - suffix.length) === suffix);
  853. }
  854. }
  855. function getIEversion()
  856. // Returns the version of Internet Explorer or a -1.
  857. // (indicating the use of another browser).
  858. {
  859. var rv = -1; // Return value assumes failure.
  860. if (navigator.appName == 'Microsoft Internet Explorer')
  861. {
  862. var ua = navigator.userAgent;
  863. var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
  864. if (re.exec(ua) != null)
  865. rv = parseFloat( RegExp.$1 );
  866. }
  867. return rv;
  868. }
  869. // Initializing PDFJS global object here, it case if we need to change/disable
  870. // some PDF.js features, e.g. range requests
  871. if (typeof PDFJS === 'undefined') {
  872. (typeof window !== 'undefined' ? window : this).PDFJS = {};
  873. }
  874. window.unsupportedPDFJSieversion = getIEversion()>0 && getIEversion()<9;
  875. // Checking if the typed arrays are supported
  876. // Support: iOS<6.0 (subarray), IE<10, Android<4.0
  877. (function checkTypedArrayCompatibility() {
  878. if (typeof Uint8Array !== 'undefined') {
  879. // Support: iOS<6.0
  880. if (typeof Uint8Array.prototype.subarray === 'undefined') {
  881. Uint8Array.prototype.subarray = function subarray(start, end) {
  882. return new Uint8Array(this.slice(start, end));
  883. };
  884. Float32Array.prototype.subarray = function subarray(start, end) {
  885. return new Float32Array(this.slice(start, end));
  886. };
  887. }
  888. // Support: Android<4.1
  889. if (typeof Float64Array === 'undefined') {
  890. window.Float64Array = Float32Array;
  891. }
  892. return;
  893. }
  894. function subarray(start, end) {
  895. return new TypedArray(this.slice(start, end));
  896. }
  897. function setArrayOffset(array, offset) {
  898. if (arguments.length < 2) {
  899. offset = 0;
  900. }
  901. for (var i = 0, n = array.length; i < n; ++i, ++offset) {
  902. this[offset] = array[i] & 0xFF;
  903. }
  904. }
  905. function TypedArray(arg1) {
  906. var result, i, n;
  907. if (typeof arg1 === 'number') {
  908. result = [];
  909. for (i = 0; i < arg1; ++i) {
  910. result[i] = 0;
  911. }
  912. } else if ('slice' in arg1) {
  913. result = arg1.slice(0);
  914. } else {
  915. result = [];
  916. for (i = 0, n = arg1.length; i < n; ++i) {
  917. result[i] = arg1[i];
  918. }
  919. }
  920. result.subarray = subarray;
  921. result.buffer = result;
  922. result.byteLength = result.length;
  923. result.set = setArrayOffset;
  924. if (typeof arg1 === 'object' && arg1.buffer) {
  925. result.buffer = arg1.buffer;
  926. }
  927. return result;
  928. }
  929. window.Uint8Array = TypedArray;
  930. window.Int8Array = TypedArray;
  931. // we don't need support for set, byteLength for 32-bit array
  932. // so we can use the TypedArray as well
  933. window.Uint32Array = TypedArray;
  934. window.Int32Array = TypedArray;
  935. window.Uint16Array = TypedArray;
  936. window.Float32Array = TypedArray;
  937. window.Float64Array = TypedArray;
  938. })();
  939. // URL = URL || webkitURL
  940. // Support: Safari<7, Android 4.2+
  941. (function normalizeURLObject() {
  942. if (!window.URL) {
  943. window.URL = window.webkitURL;
  944. }
  945. })();
  946. // Object.defineProperty()?
  947. // Support: Android<4.0, Safari<5.1
  948. (function checkObjectDefinePropertyCompatibility() {
  949. if(window.unsupportedPDFJSieversion){return;}
  950. if (typeof Object.defineProperty !== 'undefined') {
  951. var definePropertyPossible = true;
  952. try {
  953. // some browsers (e.g. safari) cannot use defineProperty() on DOM objects
  954. // and thus the native version is not sufficient
  955. Object.defineProperty(new Image(), 'id', { value: 'test' });
  956. // ... another test for android gb browser for non-DOM objects
  957. // var Test = function Test() {};
  958. // Test.prototype = { get id() { } };
  959. // Object.defineProperty(new Test(), 'id',
  960. // { value: '', configurable: true, enumerable: true, writable: false });
  961. eval("var Test = function Test() {};Test.prototype = { get id() { } };Object.defineProperty(new Test(), 'id',{ value: '', configurable: true, enumerable: true, writable: false });");
  962. } catch (e) {
  963. definePropertyPossible = false;
  964. }
  965. if (definePropertyPossible) {
  966. return;
  967. }
  968. }
  969. Object.defineProperty = function objectDefineProperty(obj, name, def) {
  970. delete obj[name];
  971. if ('get' in def) {
  972. obj.__defineGetter__(name, def['get']);
  973. }
  974. if ('set' in def) {
  975. obj.__defineSetter__(name, def['set']);
  976. }
  977. if ('value' in def) {
  978. obj.__defineSetter__(name, function objectDefinePropertySetter(value) {
  979. this.__defineGetter__(name, function objectDefinePropertyGetter() {
  980. return value;
  981. });
  982. return value;
  983. });
  984. obj[name] = def.value;
  985. }
  986. };
  987. })();
  988. // No XMLHttpRequest#response?
  989. // Support: IE<11, Android <4.0
  990. (function checkXMLHttpRequestResponseCompatibility() {
  991. if(window.unsupportedPDFJSieversion){return;}
  992. var xhrPrototype = XMLHttpRequest.prototype;
  993. var xhr = new XMLHttpRequest();
  994. if (!('overrideMimeType' in xhr)) {
  995. // IE10 might have response, but not overrideMimeType
  996. // Support: IE10
  997. Object.defineProperty(xhrPrototype, 'overrideMimeType', {
  998. value: function xmlHttpRequestOverrideMimeType(mimeType) {}
  999. });
  1000. }
  1001. if ('responseType' in xhr) {
  1002. return;
  1003. }
  1004. // The worker will be using XHR, so we can save time and disable worker.
  1005. PDFJS.disableWorker = true;
  1006. Object.defineProperty(xhrPrototype, 'responseType', {
  1007. get: function xmlHttpRequestGetResponseType() {
  1008. return this._responseType || 'text';
  1009. },
  1010. set: function xmlHttpRequestSetResponseType(value) {
  1011. if (value === 'text' || value === 'arraybuffer') {
  1012. this._responseType = value;
  1013. if (value === 'arraybuffer' &&
  1014. typeof this.overrideMimeType === 'function') {
  1015. this.overrideMimeType('text/plain; charset=x-user-defined');
  1016. }
  1017. }
  1018. }
  1019. });
  1020. // Support: IE9
  1021. if (typeof VBArray !== 'undefined') {
  1022. Object.defineProperty(xhrPrototype, 'response', {
  1023. get: function xmlHttpRequestResponseGet() {
  1024. if (this.responseType === 'arraybuffer') {
  1025. return new Uint8Array(new VBArray(this.responseBody).toArray());
  1026. } else {
  1027. return this.responseText;
  1028. }
  1029. }
  1030. });
  1031. return;
  1032. }
  1033. Object.defineProperty(xhrPrototype, 'response', {
  1034. get: function xmlHttpRequestResponseGet() {
  1035. if (this.responseType !== 'arraybuffer') {
  1036. return this.responseText;
  1037. }
  1038. var text = this.responseText;
  1039. var i, n = text.length;
  1040. var result = new Uint8Array(n);
  1041. for (i = 0; i < n; ++i) {
  1042. result[i] = text.charCodeAt(i) & 0xFF;
  1043. }
  1044. return result.buffer;
  1045. }
  1046. });
  1047. })();
  1048. // window.btoa (base64 encode function) ?
  1049. // Support: IE<10
  1050. (function checkWindowBtoaCompatibility() {
  1051. if ('btoa' in window) {
  1052. return;
  1053. }
  1054. var digits =
  1055. 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1056. window.btoa = function windowBtoa(chars) {
  1057. var buffer = '';
  1058. var i, n;
  1059. for (i = 0, n = chars.length; i < n; i += 3) {
  1060. var b1 = chars.charCodeAt(i) & 0xFF;
  1061. var b2 = chars.charCodeAt(i + 1) & 0xFF;
  1062. var b3 = chars.charCodeAt(i + 2) & 0xFF;
  1063. var d1 = b1 >> 2, d2 = ((b1 & 3) << 4) | (b2 >> 4);
  1064. var d3 = i + 1 < n ? ((b2 & 0xF) << 2) | (b3 >> 6) : 64;
  1065. var d4 = i + 2 < n ? (b3 & 0x3F) : 64;
  1066. buffer += (digits.charAt(d1) + digits.charAt(d2) +
  1067. digits.charAt(d3) + digits.charAt(d4));
  1068. }
  1069. return buffer;
  1070. };
  1071. })();
  1072. // window.atob (base64 encode function)?
  1073. // Support: IE<10
  1074. (function checkWindowAtobCompatibility() {
  1075. if ('atob' in window) {
  1076. return;
  1077. }
  1078. // https://github.com/davidchambers/Base64.js
  1079. var digits =
  1080. 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  1081. window.atob = function (input) {
  1082. input = input.replace(/=+$/, '');
  1083. if (input.length % 4 === 1) {
  1084. throw new Error('bad atob input');
  1085. }
  1086. for (
  1087. // initialize result and counters
  1088. var bc = 0, bs, buffer, idx = 0, output = '';
  1089. // get next character
  1090. buffer = input.charAt(idx++);
  1091. // character found in table?
  1092. // initialize bit storage and add its ascii value
  1093. ~buffer && (bs = bc % 4 ? bs * 64 + buffer : buffer,
  1094. // and if not first of each 4 characters,
  1095. // convert the first 8 bits to one ascii character
  1096. bc++ % 4) ? output += String.fromCharCode(255 & bs >> (-2 * bc & 6)) : 0
  1097. ) {
  1098. // try to find character in table (0-63, not found => -1)
  1099. buffer = digits.indexOf(buffer);
  1100. }
  1101. return output;
  1102. };
  1103. })();
  1104. // Function.prototype.bind?
  1105. // Support: Android<4.0, iOS<6.0
  1106. (function checkFunctionPrototypeBindCompatibility() {
  1107. if (typeof Function.prototype.bind !== 'undefined') {
  1108. return;
  1109. }
  1110. Function.prototype.bind = function functionPrototypeBind(obj) {
  1111. var fn = this, headArgs = Array.prototype.slice.call(arguments, 1);
  1112. var bound = function functionPrototypeBindBound() {
  1113. var args = headArgs.concat(Array.prototype.slice.call(arguments));
  1114. return fn.apply(obj, args);
  1115. };
  1116. return bound;
  1117. };
  1118. })();
  1119. // HTMLElement dataset property
  1120. // Support: IE<11, Safari<5.1, Android<4.0
  1121. (function checkDatasetProperty() {
  1122. if(window.unsupportedPDFJSieversion){return;}
  1123. var div = document.createElement('div');
  1124. if ('dataset' in div) {
  1125. return; // dataset property exists
  1126. }
  1127. Object.defineProperty(HTMLElement.prototype, 'dataset', {
  1128. get: function() {
  1129. if (this._dataset) {
  1130. return this._dataset;
  1131. }
  1132. var dataset = {};
  1133. for (var j = 0, jj = this.attributes.length; j < jj; j++) {
  1134. var attribute = this.attributes[j];
  1135. if (attribute.name.substring(0, 5) !== 'data-') {
  1136. continue;
  1137. }
  1138. var key = attribute.name.substring(5).replace(/\-([a-z])/g,
  1139. function(all, ch) {
  1140. return ch.toUpperCase();
  1141. });
  1142. dataset[key] = attribute.value;
  1143. }
  1144. Object.defineProperty(this, '_dataset', {
  1145. value: dataset,
  1146. writable: false,
  1147. enumerable: false
  1148. });
  1149. return dataset;
  1150. },
  1151. enumerable: true
  1152. });
  1153. })();
  1154. // HTMLElement classList property
  1155. // Support: IE<10, Android<4.0, iOS<5.0
  1156. (function checkClassListProperty() {
  1157. if(window.unsupportedPDFJSieversion){return;}
  1158. var div = document.createElement('div');
  1159. if ('classList' in div) {
  1160. return; // classList property exists
  1161. }
  1162. function changeList(element, itemName, add, remove) {
  1163. var s = element.className || '';
  1164. var list = s.split(/\s+/g);
  1165. if (list[0] === '') {
  1166. list.shift();
  1167. }
  1168. var index = list.indexOf(itemName);
  1169. if (index < 0 && add) {
  1170. list.push(itemName);
  1171. }
  1172. if (index >= 0 && remove) {
  1173. list.splice(index, 1);
  1174. }
  1175. element.className = list.join(' ');
  1176. return (index >= 0);
  1177. }
  1178. var classListPrototype = {
  1179. add: function(name) {
  1180. changeList(this.element, name, true, false);
  1181. },
  1182. contains: function(name) {
  1183. return changeList(this.element, name, false, false);
  1184. },
  1185. remove: function(name) {
  1186. changeList(this.element, name, false, true);
  1187. },
  1188. toggle: function(name) {
  1189. changeList(this.element, name, true, true);
  1190. }
  1191. };
  1192. Object.defineProperty(HTMLElement.prototype, 'classList', {
  1193. get: function() {
  1194. if (this._classList) {
  1195. return this._classList;
  1196. }
  1197. var classList = Object.create(classListPrototype, {
  1198. element: {
  1199. value: this,
  1200. writable: false,
  1201. enumerable: true
  1202. }
  1203. });
  1204. Object.defineProperty(this, '_classList', {
  1205. value: classList,
  1206. writable: false,
  1207. enumerable: false
  1208. });
  1209. return classList;
  1210. },
  1211. enumerable: true
  1212. });
  1213. })();
  1214. // Check console compatibility
  1215. // In older IE versions the console object is not available
  1216. // unless console is open.
  1217. // Support: IE<10
  1218. (function checkConsoleCompatibility() {
  1219. if(window.unsupportedPDFJSieversion){return;}
  1220. if (!('console' in window)) {
  1221. window.console = {
  1222. log: function() {},
  1223. error: function() {},
  1224. warn: function() {}
  1225. };
  1226. } else if (!('bind' in console.log)) {
  1227. // native functions in IE9 might not have bind
  1228. console.log = (function(fn) {
  1229. return function(msg) { return fn(msg); };
  1230. })(console.log);
  1231. console.error = (function(fn) {
  1232. return function(msg) { return fn(msg); };
  1233. })(console.error);
  1234. console.warn = (function(fn) {
  1235. return function(msg) { return fn(msg); };
  1236. })(console.warn);
  1237. }
  1238. })();
  1239. // Check onclick compatibility in Opera
  1240. // Support: Opera<15
  1241. (function checkOnClickCompatibility() {
  1242. // workaround for reported Opera bug DSK-354448:
  1243. // onclick fires on disabled buttons with opaque content
  1244. function ignoreIfTargetDisabled(event) {
  1245. if (isDisabled(event.target)) {
  1246. event.stopPropagation();
  1247. }
  1248. }
  1249. function isDisabled(node) {
  1250. return node.disabled || (node.parentNode && isDisabled(node.parentNode));
  1251. }
  1252. if (navigator.userAgent.indexOf('Opera') !== -1) {
  1253. // use browser detection since we cannot feature-check this bug
  1254. document.addEventListener('click', ignoreIfTargetDisabled, true);
  1255. }
  1256. })();
  1257. // Checks if possible to use URL.createObjectURL()
  1258. // Support: IE
  1259. (function checkOnBlobSupport() {
  1260. // sometimes IE loosing the data created with createObjectURL(), see #3977
  1261. if (navigator.userAgent.indexOf('Trident') >= 0) {
  1262. PDFJS.disableCreateObjectURL = true;
  1263. }
  1264. })();
  1265. // Checks if navigator.language is supported
  1266. (function checkNavigatorLanguage() {
  1267. if ('language' in navigator &&
  1268. /^[a-z]+(-[A-Z]+)?$/.test(navigator.language)) {
  1269. return;
  1270. }
  1271. function formatLocale(locale) {
  1272. var split = locale.split(/[-_]/);
  1273. split[0] = split[0].toLowerCase();
  1274. if (split.length > 1) {
  1275. split[1] = split[1].toUpperCase();
  1276. }
  1277. return split.join('-');
  1278. }
  1279. var language = navigator.language || navigator.userLanguage || 'en-US';
  1280. PDFJS.locale = formatLocale(language);
  1281. })();
  1282. (function checkRangeRequests() {
  1283. // Safari has issues with cached range requests see:
  1284. // https://github.com/mozilla/pdf.js/issues/3260
  1285. // Last tested with version 6.0.4.
  1286. // Support: Safari 6.0+
  1287. var isSafari = Object.prototype.toString.call(
  1288. window.HTMLElement).indexOf('Constructor') > 0;
  1289. // Older versions of Android (pre 3.0) has issues with range requests, see:
  1290. // https://github.com/mozilla/pdf.js/issues/3381.
  1291. // Make sure that we only match webkit-based Android browsers,
  1292. // since Firefox/Fennec works as expected.
  1293. // Support: Android<3.0
  1294. var regex = /Android\s[0-2][^\d]/;
  1295. var isOldAndroid = regex.test(navigator.userAgent);
  1296. if (isSafari || isOldAndroid) {
  1297. PDFJS.disableRange = true;
  1298. PDFJS.disableStream = true;
  1299. }
  1300. })();
  1301. // Check if the browser supports manipulation of the history.
  1302. // Support: IE<10, Android<4.2
  1303. (function checkHistoryManipulation() {
  1304. // Android 2.x has so buggy pushState support that it was removed in
  1305. // Android 3.0 and restored as late as in Android 4.2.
  1306. // Support: Android 2.x
  1307. if (!history.pushState || navigator.userAgent.indexOf('Android 2.') >= 0) {
  1308. PDFJS.disableHistory = true;
  1309. }
  1310. })();
  1311. // Support: IE<11, Chrome<21, Android<4.4, Safari<6
  1312. (function checkSetPresenceInImageData() {
  1313. // IE < 11 will use window.CanvasPixelArray which lacks set function.
  1314. if (window.CanvasPixelArray) {
  1315. if (typeof window.CanvasPixelArray.prototype.set !== 'function') {
  1316. window.CanvasPixelArray.prototype.set = function(arr) {
  1317. for (var i = 0, ii = this.length; i < ii; i++) {
  1318. this[i] = arr[i];
  1319. }
  1320. };
  1321. }
  1322. } else {
  1323. // Old Chrome and Android use an inaccessible CanvasPixelArray prototype.
  1324. // Because we cannot feature detect it, we rely on user agent parsing.
  1325. var polyfill = false, versionMatch;
  1326. if (navigator.userAgent.indexOf('Chrom') >= 0) {
  1327. versionMatch = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
  1328. // Chrome < 21 lacks the set function.
  1329. polyfill = versionMatch && parseInt(versionMatch[2]) < 21;
  1330. } else if (navigator.userAgent.indexOf('Android') >= 0) {
  1331. // Android < 4.4 lacks the set function.
  1332. // Android >= 4.4 will contain Chrome in the user agent,
  1333. // thus pass the Chrome check above and not reach this block.
  1334. polyfill = /Android\s[0-4][^\d]/g.test(navigator.userAgent);
  1335. } else if (navigator.userAgent.indexOf('Safari') >= 0) {
  1336. versionMatch = navigator.userAgent.
  1337. match(/Version\/([0-9]+)\.([0-9]+)\.([0-9]+) Safari\//);
  1338. // Safari < 6 lacks the set function.
  1339. polyfill = versionMatch && parseInt(versionMatch[1]) < 6;
  1340. }
  1341. if (polyfill) {
  1342. var contextPrototype = window.CanvasRenderingContext2D.prototype;
  1343. contextPrototype._createImageData = contextPrototype.createImageData;
  1344. contextPrototype.createImageData = function(w, h) {
  1345. var imageData = this._createImageData(w, h);
  1346. imageData.data.set = function(arr) {
  1347. for (var i = 0, ii = this.length; i < ii; i++) {
  1348. this[i] = arr[i];
  1349. }
  1350. };
  1351. return imageData;
  1352. };
  1353. }
  1354. }
  1355. })();
  1356. // Support: IE<10, Android<4.0, iOS
  1357. (function checkRequestAnimationFrame() {
  1358. function fakeRequestAnimationFrame(callback) {
  1359. window.setTimeout(callback, 20);
  1360. }
  1361. var isIOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
  1362. if ('requestAnimationFrame' in window) {
  1363. return;
  1364. }
  1365. window.requestAnimationFrame =
  1366. window.mozRequestAnimationFrame ||
  1367. window.webkitRequestAnimationFrame ||
  1368. fakeRequestAnimationFrame;
  1369. })();
  1370. (function checkCanvasSizeLimitation() {
  1371. var isIOS = /(iPad|iPhone|iPod)/g.test(navigator.userAgent);
  1372. var isAndroid = /Android/g.test(navigator.userAgent);
  1373. if (isIOS || isAndroid) {
  1374. // 5MP
  1375. PDFJS.maxCanvasPixels = 5242880;
  1376. }
  1377. })();
  1378. // Disable fullscreen support for certain problematic configurations.
  1379. // Support: IE11+ (when embedded).
  1380. (function checkFullscreenSupport() {
  1381. var isEmbeddedIE = (navigator.userAgent.indexOf('Trident') >= 0 &&
  1382. window.parent !== window);
  1383. if (isEmbeddedIE) {
  1384. PDFJS.disableFullscreen = true;
  1385. }
  1386. })();
  1387. (function(){var root=this;var previousUnderscore=root._;var breaker={};var ArrayProto=Array.prototype,ObjProto=Object.prototype,FuncProto=Function.prototype;var push=ArrayProto.push,slice=ArrayProto.slice,concat=ArrayProto.concat,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty;var nativeForEach=ArrayProto.forEach,nativeMap=ArrayProto.map,nativeReduce=ArrayProto.reduce,nativeReduceRight=ArrayProto.reduceRight,nativeFilter=ArrayProto.filter,nativeEvery=ArrayProto.every,nativeSome=
  1388. ArrayProto.some,nativeIndexOf=ArrayProto.indexOf,nativeLastIndexOf=ArrayProto.lastIndexOf,nativeIsArray=Array.isArray,nativeKeys=Object.keys,nativeBind=FuncProto.bind;var _=function(obj){if(obj instanceof _)return obj;if(!(this instanceof _))return new _(obj);this._wrapped=obj};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=_;exports._=_}else root._=_;_.VERSION="1.5.2";var each=_.each=_.forEach=function(obj,iterator,context){if(obj==null)return;
  1389. if(nativeForEach&&obj.forEach===nativeForEach)obj.forEach(iterator,context);else if(obj.length===+obj.length)for(var i=0,length=obj.length;i<length;i++){if(iterator.call(context,obj[i],i,obj)===breaker)return}else{var keys=_.keys(obj);for(var i=0,length=keys.length;i<length;i++)if(iterator.call(context,obj[keys[i]],keys[i],obj)===breaker)return}};_.map=_.collect=function(obj,iterator,context){var results=[];if(obj==null)return results;if(nativeMap&&obj.map===nativeMap)return obj.map(iterator,context);
  1390. each(obj,function(value,index,list){results.push(iterator.call(context,value,index,list))});return results};var reduceError="Reduce of empty array with no initial value";_.reduce=_.foldl=_.inject=function(obj,iterator,memo,context){var initial=arguments.length>2;if(obj==null)obj=[];if(nativeReduce&&obj.reduce===nativeReduce){if(context)iterator=_.bind(iterator,context);return initial?obj.reduce(iterator,memo):obj.reduce(iterator)}each(obj,function(value,index,list){if(!initial){memo=value;initial=
  1391. true}else memo=iterator.call(context,memo,value,index,list)});if(!initial)throw new TypeError(reduceError);return memo};_.reduceRight=_.foldr=function(obj,iterator,memo,context){var initial=arguments.length>2;if(obj==null)obj=[];if(nativeReduceRight&&obj.reduceRight===nativeReduceRight){if(context)iterator=_.bind(iterator,context);return initial?obj.reduceRight(iterator,memo):obj.reduceRight(iterator)}var length=obj.length;if(length!==+length){var keys=_.keys(obj);length=keys.length}each(obj,function(value,
  1392. index,list){index=keys?keys[--length]:--length;if(!initial){memo=obj[index];initial=true}else memo=iterator.call(context,memo,obj[index],index,list)});if(!initial)throw new TypeError(reduceError);return memo};_.find=_.detect=function(obj,iterator,context){var result;any(obj,function(value,index,list){if(iterator.call(context,value,index,list)){result=value;return true}});return result};_.filter=_.select=function(obj,iterator,context){var results=[];if(obj==null)return results;if(nativeFilter&&obj.filter===
  1393. nativeFilter)return obj.filter(iterator,context);each(obj,function(value,index,list){if(iterator.call(context,value,index,list))results.push(value)});return results};_.reject=function(obj,iterator,context){return _.filter(obj,function(value,index,list){return!iterator.call(context,value,index,list)},context)};_.every=_.all=function(obj,iterator,context){iterator||(iterator=_.identity);var result=true;if(obj==null)return result;if(nativeEvery&&obj.every===nativeEvery)return obj.every(iterator,context);
  1394. each(obj,function(value,index,list){if(!(result=result&&iterator.call(context,value,index,list)))return breaker});return!!result};var any=_.some=_.any=function(obj,iterator,context){iterator||(iterator=_.identity);var result=false;if(obj==null)return result;if(nativeSome&&obj.some===nativeSome)return obj.some(iterator,context);each(obj,function(value,index,list){if(result||(result=iterator.call(context,value,index,list)))return breaker});return!!result};_.contains=_.include=function(obj,target){if(obj==
  1395. null)return false;if(nativeIndexOf&&obj.indexOf===nativeIndexOf)return obj.indexOf(target)!=-1;return any(obj,function(value){return value===target})};_.invoke=function(obj,method){var args=slice.call(arguments,2);var isFunc=_.isFunction(method);return _.map(obj,function(value){return(isFunc?method:value[method]).apply(value,args)})};_.pluck=function(obj,key){return _.map(obj,function(value){return value[key]})};_.where=function(obj,attrs,first){if(_.isEmpty(attrs))return first?void 0:[];return _[first?
  1396. "find":"filter"](obj,function(value){for(var key in attrs)if(attrs[key]!==value[key])return false;return true})};_.findWhere=function(obj,attrs){return _.where(obj,attrs,true)};_.max=function(obj,iterator,context){if(!iterator&&_.isArray(obj)&&obj[0]===+obj[0]&&obj.length<65535)return Math.max.apply(Math,obj);if(!iterator&&_.isEmpty(obj))return-Infinity;var result={computed:-Infinity,value:-Infinity};each(obj,function(value,index,list){var computed=iterator?iterator.call(context,value,index,list):
  1397. value;computed>result.computed&&(result={value:value,computed:computed})});return result.value};_.min=function(obj,iterator,context){if(!iterator&&_.isArray(obj)&&obj[0]===+obj[0]&&obj.length<65535)return Math.min.apply(Math,obj);if(!iterator&&_.isEmpty(obj))return Infinity;var result={computed:Infinity,value:Infinity};each(obj,function(value,index,list){var computed=iterator?iterator.call(context,value,index,list):value;computed<result.computed&&(result={value:value,computed:computed})});return result.value};
  1398. _.shuffle=function(obj){var rand;var index=0;var shuffled=[];each(obj,function(value){rand=_.random(index++);shuffled[index-1]=shuffled[rand];shuffled[rand]=value});return shuffled};_.sample=function(obj,n,guard){if(arguments.length<2||guard)return obj[_.random(obj.length-1)];return _.shuffle(obj).slice(0,Math.max(0,n))};var lookupIterator=function(value){return _.isFunction(value)?value:function(obj){return obj[value]}};_.sortBy=function(obj,value,context){var iterator=lookupIterator(value);return _.pluck(_.map(obj,
  1399. function(value,index,list){return{value:value,index:index,criteria:iterator.call(context,value,index,list)}}).sort(function(left,right){var a=left.criteria;var b=right.criteria;if(a!==b){if(a>b||a===void 0)return 1;if(a<b||b===void 0)return-1}return left.index-right.index}),"value")};var group=function(behavior){return function(obj,value,context){var result={};var iterator=value==null?_.identity:lookupIterator(value);each(obj,function(value,index){var key=iterator.call(context,value,index,obj);behavior(result,
  1400. key,value)});return result}};_.groupBy=group(function(result,key,value){(_.has(result,key)?result[key]:result[key]=[]).push(value)});_.indexBy=group(function(result,key,value){result[key]=value});_.countBy=group(function(result,key){_.has(result,key)?result[key]++:result[key]=1});_.sortedIndex=function(array,obj,iterator,context){iterator=iterator==null?_.identity:lookupIterator(iterator);var value=iterator.call(context,obj);var low=0,high=array.length;while(low<high){var mid=low+high>>>1;iterator.call(context,
  1401. array[mid])<value?low=mid+1:high=mid}return low};_.toArray=function(obj){if(!obj)return[];if(_.isArray(obj))return slice.call(obj);if(obj.length===+obj.length)return _.map(obj,_.identity);return _.values(obj)};_.size=function(obj){if(obj==null)return 0;return obj.length===+obj.length?obj.length:_.keys(obj).length};_.first=_.head=_.take=function(array,n,guard){if(array==null)return void 0;return n==null||guard?array[0]:slice.call(array,0,n)};_.initial=function(array,n,guard){return slice.call(array,
  1402. 0,array.length-(n==null||guard?1:n))};_.last=function(array,n,guard){if(array==null)return void 0;if(n==null||guard)return array[array.length-1];else return slice.call(array,Math.max(array.length-n,0))};_.rest=_.tail=_.drop=function(array,n,guard){return slice.call(array,n==null||guard?1:n)};_.compact=function(array){return _.filter(array,_.identity)};var flatten=function(input,shallow,output){if(shallow&&_.every(input,_.isArray))return concat.apply(output,input);each(input,function(value){if(_.isArray(value)||
  1403. _.isArguments(value))shallow?push.apply(output,value):flatten(value,shallow,output);else output.push(value)});return output};_.flatten=function(array,shallow){return flatten(array,shallow,[])};_.without=function(array){return _.difference(array,slice.call(arguments,1))};_.uniq=_.unique=function(array,isSorted,iterator,context){if(_.isFunction(isSorted)){context=iterator;iterator=isSorted;isSorted=false}var initial=iterator?_.map(array,iterator,context):array;var results=[];var seen=[];each(initial,
  1404. function(value,index){if(isSorted?!index||seen[seen.length-1]!==value:!_.contains(seen,value)){seen.push(value);results.push(array[index])}});return results};_.union=function(){return _.uniq(_.flatten(arguments,true))};_.intersection=function(array){var rest=slice.call(arguments,1);return _.filter(_.uniq(array),function(item){return _.every(rest,function(other){return _.indexOf(other,item)>=0})})};_.difference=function(array){var rest=concat.apply(ArrayProto,slice.call(arguments,1));return _.filter(array,
  1405. function(value){return!_.contains(rest,value)})};_.zip=function(){var length=_.max(_.pluck(arguments,"length").concat(0));var results=new Array(length);for(var i=0;i<length;i++)results[i]=_.pluck(arguments,""+i);return results};_.object=function(list,values){if(list==null)return{};var result={};for(var i=0,length=list.length;i<length;i++)if(values)result[list[i]]=values[i];else result[list[i][0]]=list[i][1];return result};_.indexOf=function(array,item,isSorted){if(array==null)return-1;var i=0,length=
  1406. array.length;if(isSorted)if(typeof isSorted=="number")i=isSorted<0?Math.max(0,length+isSorted):isSorted;else{i=_.sortedIndex(array,item);return array[i]===item?i:-1}if(nativeIndexOf&&array.indexOf===nativeIndexOf)return array.indexOf(item,isSorted);for(;i<length;i++)if(array[i]===item)return i;return-1};_.lastIndexOf=function(array,item,from){if(array==null)return-1;var hasIndex=from!=null;if(nativeLastIndexOf&&array.lastIndexOf===nativeLastIndexOf)return hasIndex?array.lastIndexOf(item,from):array.lastIndexOf(item);
  1407. var i=hasIndex?from:array.length;while(i--)if(array[i]===item)return i;return-1};_.range=function(start,stop,step){if(arguments.length<=1){stop=start||0;start=0}step=arguments[2]||1;var length=Math.max(Math.ceil((stop-start)/step),0);var idx=0;var range=new Array(length);while(idx<length){range[idx++]=start;start+=step}return range};var ctor=function(){};_.bind=function(func,context){var args,bound;if(nativeBind&&func.bind===nativeBind)return nativeBind.apply(func,slice.call(arguments,1));if(!_.isFunction(func))throw new TypeError;
  1408. args=slice.call(arguments,2);return bound=function(){if(!(this instanceof bound))return func.apply(context,args.concat(slice.call(arguments)));ctor.prototype=func.prototype;var self=new ctor;ctor.prototype=null;var result=func.apply(self,args.concat(slice.call(arguments)));if(Object(result)===result)return result;return self}};_.partial=function(func){var args=slice.call(arguments,1);return function(){return func.apply(this,args.concat(slice.call(arguments)))}};_.bindAll=function(obj){var funcs=slice.call(arguments,
  1409. 1);if(funcs.length===0)throw new Error("bindAll must be passed function names");each(funcs,function(f){obj[f]=_.bind(obj[f],obj)});return obj};_.memoize=function(func,hasher){var memo={};hasher||(hasher=_.identity);return function(){var key=hasher.apply(this,arguments);return _.has(memo,key)?memo[key]:memo[key]=func.apply(this,arguments)}};_.delay=function(func,wait){var args=slice.call(arguments,2);return setTimeout(function(){return func.apply(null,args)},wait)};_.defer=function(func){return _.delay.apply(_,
  1410. [func,1].concat(slice.call(arguments,1)))};_.throttle=function(func,wait,options){var context,args,result;var timeout=null;var previous=0;options||(options={});var later=function(){previous=options.leading===false?0:new Date;timeout=null;result=func.apply(context,args)};return function(){var now=new Date;if(!previous&&options.leading===false)previous=now;var remaining=wait-(now-previous);context=this;args=arguments;if(remaining<=0){clearTimeout(timeout);timeout=null;previous=now;result=func.apply(context,
  1411. args)}else if(!timeout&&options.trailing!==false)timeout=setTimeout(later,remaining);return result}};_.debounce=function(func,wait,immediate){var timeout,args,context,timestamp,result;return function(){context=this;args=arguments;timestamp=new Date;var later=function(){var last=new Date-timestamp;if(last<wait)timeout=setTimeout(later,wait-last);else{timeout=null;if(!immediate)result=func.apply(context,args)}};var callNow=immediate&&!timeout;if(!timeout)timeout=setTimeout(later,wait);if(callNow)result=
  1412. func.apply(context,args);return result}};_.once=function(func){var ran=false,memo;return function(){if(ran)return memo;ran=true;memo=func.apply(this,arguments);func=null;return memo}};_.wrap=function(func,wrapper){return function(){var args=[func];push.apply(args,arguments);return wrapper.apply(this,args)}};_.compose=function(){var funcs=arguments;return function(){var args=arguments;for(var i=funcs.length-1;i>=0;i--)args=[funcs[i].apply(this,args)];return args[0]}};_.after=function(times,func){return function(){if(--times<
  1413. 1)return func.apply(this,arguments)}};_.keys=nativeKeys||function(obj){if(obj!==Object(obj))throw new TypeError("Invalid object");var keys=[];for(var key in obj)if(_.has(obj,key))keys.push(key);return keys};_.values=function(obj){var keys=_.keys(obj);var length=keys.length;var values=new Array(length);for(var i=0;i<length;i++)values[i]=obj[keys[i]];return values};_.pairs=function(obj){var keys=_.keys(obj);var length=keys.length;var pairs=new Array(length);for(var i=0;i<length;i++)pairs[i]=[keys[i],
  1414. obj[keys[i]]];return pairs};_.invert=function(obj){var result={};var keys=_.keys(obj);for(var i=0,length=keys.length;i<length;i++)result[obj[keys[i]]]=keys[i];return result};_.functions=_.methods=function(obj){var names=[];for(var key in obj)if(_.isFunction(obj[key]))names.push(key);return names.sort()};_.extend=function(obj){each(slice.call(arguments,1),function(source){if(source)for(var prop in source)obj[prop]=source[prop]});return obj};_.pick=function(obj){var copy={};var keys=concat.apply(ArrayProto,
  1415. slice.call(arguments,1));each(keys,function(key){if(key in obj)copy[key]=obj[key]});return copy};_.omit=function(obj){var copy={};var keys=concat.apply(ArrayProto,slice.call(arguments,1));for(var key in obj)if(!_.contains(keys,key))copy[key]=obj[key];return copy};_.defaults=function(obj){each(slice.call(arguments,1),function(source){if(source)for(var prop in source)if(obj[prop]===void 0)obj[prop]=source[prop]});return obj};_.clone=function(obj){if(!_.isObject(obj))return obj;return _.isArray(obj)?
  1416. obj.slice():_.extend({},obj)};_.tap=function(obj,interceptor){interceptor(obj);return obj};var eq=function(a,b,aStack,bStack){if(a===b)return a!==0||1/a==1/b;if(a==null||b==null)return a===b;if(a instanceof _)a=a._wrapped;if(b instanceof _)b=b._wrapped;var className=toString.call(a);if(className!=toString.call(b))return false;switch(className){case "[object String]":return a==String(b);case "[object Number]":return a!=+a?b!=+b:a==0?1/a==1/b:a==+b;case "[object Date]":case "[object Boolean]":return+a==
  1417. +b;case "[object RegExp]":return a.source==b.source&&a.global==b.global&&a.multiline==b.multiline&&a.ignoreCase==b.ignoreCase}if(typeof a!="object"||typeof b!="object")return false;var length=aStack.length;while(length--)if(aStack[length]==a)return bStack[length]==b;var aCtor=a.constructor,bCtor=b.constructor;if(aCtor!==bCtor&&!(_.isFunction(aCtor)&&aCtor instanceof aCtor&&_.isFunction(bCtor)&&bCtor instanceof bCtor))return false;aStack.push(a);bStack.push(b);var size=0,result=true;if(className==
  1418. "[object Array]"){size=a.length;result=size==b.length;if(result)while(size--)if(!(result=eq(a[size],b[size],aStack,bStack)))break}else{for(var key in a)if(_.has(a,key)){size++;if(!(result=_.has(b,key)&&eq(a[key],b[key],aStack,bStack)))break}if(result){for(key in b)if(_.has(b,key)&&!size--)break;result=!size}}aStack.pop();bStack.pop();return result};_.isEqual=function(a,b){return eq(a,b,[],[])};_.isEmpty=function(obj){if(obj==null)return true;if(_.isArray(obj)||_.isString(obj))return obj.length===
  1419. 0;for(var key in obj)if(_.has(obj,key))return false;return true};_.isElement=function(obj){return!!(obj&&obj.nodeType===1)};_.isArray=nativeIsArray||function(obj){return toString.call(obj)=="[object Array]"};_.isObject=function(obj){return obj===Object(obj)};each(["Arguments","Function","String","Number","Date","RegExp"],function(name){_["is"+name]=function(obj){return toString.call(obj)=="[object "+name+"]"}});if(!_.isArguments(arguments))_.isArguments=function(obj){return!!(obj&&_.has(obj,"callee"))};
  1420. if(typeof/./!=="function")_.isFunction=function(obj){return typeof obj==="function"};_.isFinite=function(obj){return isFinite(obj)&&!isNaN(parseFloat(obj))};_.isNaN=function(obj){return _.isNumber(obj)&&obj!=+obj};_.isBoolean=function(obj){return obj===true||obj===false||toString.call(obj)=="[object Boolean]"};_.isNull=function(obj){return obj===null};_.isUndefined=function(obj){return obj===void 0};_.has=function(obj,key){return hasOwnProperty.call(obj,key)};_.noConflict=function(){root._=previousUnderscore;
  1421. return this};_.identity=function(value){return value};_.times=function(n,iterator,context){var accum=Array(Math.max(0,n));for(var i=0;i<n;i++)accum[i]=iterator.call(context,i);return accum};_.random=function(min,max){if(max==null){max=min;min=0}return min+Math.floor(Math.random()*(max-min+1))};var entityMap={escape:{"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;"}};entityMap.unescape=_.invert(entityMap.escape);var entityRegexes={escape:new RegExp("["+_.keys(entityMap.escape).join("")+
  1422. "]","g"),unescape:new RegExp("("+_.keys(entityMap.unescape).join("|")+")","g")};_.each(["escape","unescape"],function(method){_[method]=function(string){if(string==null)return"";return(""+string).replace(entityRegexes[method],function(match){return entityMap[method][match]})}});_.result=function(object,property){if(object==null)return void 0;var value=object[property];return _.isFunction(value)?value.call(object):value};_.mixin=function(obj){each(_.functions(obj),function(name){var func=_[name]=obj[name];
  1423. _.prototype[name]=function(){var args=[this._wrapped];push.apply(args,arguments);return result.call(this,func.apply(_,args))}})};var idCounter=0;_.uniqueId=function(prefix){var id=++idCounter+"";return prefix?prefix+id:id};_.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var noMatch=/(.)^/;var escapes={"'":"'","\\":"\\","\r":"r","\n":"n","\t":"t","\u2028":"u2028","\u2029":"u2029"};var escaper=/\\|'|\r|\n|\t|\u2028|\u2029/g;_.template=function(text,
  1424. data,settings){var render;settings=_.defaults({},settings,_.templateSettings);var matcher=new RegExp([(settings.escape||noMatch).source,(settings.interpolate||noMatch).source,(settings.evaluate||noMatch).source].join("|")+"|$","g");var index=0;var source="__p+='";text.replace(matcher,function(match,escape,interpolate,evaluate,offset){source+=text.slice(index,offset).replace(escaper,function(match){return"\\"+escapes[match]});if(escape)source+="'+\n((__t=("+escape+"))==null?'':_.escape(__t))+\n'";
  1425. if(interpolate)source+="'+\n((__t=("+interpolate+"))==null?'':__t)+\n'";if(evaluate)source+="';\n"+evaluate+"\n__p+='";index=offset+match.length;return match});source+="';\n";if(!settings.variable)source="with(obj||{}){\n"+source+"}\n";source="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+source+"return __p;\n";try{render=new Function(settings.variable||"obj","_",source)}catch(e){e.source=source;throw e;}if(data)return render(data,_);var template=function(data){return render.call(this,
  1426. data,_)};template.source="function("+(settings.variable||"obj")+"){\n"+source+"}";return template};_.chain=function(obj){return _(obj).chain()};var result=function(obj){return this._chain?_(obj).chain():obj};_.mixin(_);each(["pop","push","reverse","shift","sort","splice","unshift"],function(name){var method=ArrayProto[name];_.prototype[name]=function(){var obj=this._wrapped;method.apply(obj,arguments);if((name=="shift"||name=="splice")&&obj.length===0)delete obj[0];return result.call(this,obj)}});
  1427. each(["concat","join","slice"],function(name){var method=ArrayProto[name];_.prototype[name]=function(){return result.call(this,method.apply(this._wrapped,arguments))}});_.extend(_.prototype,{chain:function(){this._chain=true;return this},value:function(){return this._wrapped}})}).call(this);
  1428. (function(){if(typeof exports!=="undefined"){var underscore=require("underscore");underscore.extend(exports,declare(underscore))}else if(typeof define!=="undefined")define(["underscore"],declare);else window.ring=declare(_);function declare(_){var ring={};function RingObject(){}ring.Object=RingObject;_.extend(ring.Object,{__mro__:[ring.Object],__properties__:{__ringConstructor__:function(){}},__classId__:1,__parents__:[],__classIndex__:{1:ring.Object}});_.extend(ring.Object.prototype,{__ringConstructor__:ring.Object.__properties__.__ringConstructor__});
  1429. var objectCreate=function(o){function CreatedObject(){}CreatedObject.prototype=o;var tmp=new CreatedObject;tmp.__proto__=o;return tmp};ring.__objectCreate=objectCreate;var classCounter=3;var fnTest=/xyz/.test(function(){xyz()})?/\$super\b/:/.*/;ring.create=function(){var args=_.toArray(arguments);args.reverse();var props=args[0];var parents=args.length>=2?args[1]:[];if(!(parents instanceof Array))parents=[parents];_.each(parents,function(el){toRingClass(el)});if(parents.length===0)parents=[ring.Object];
  1430. var cons=props.constructor!==Object?props.constructor:undefined;props=_.clone(props);delete props.constructor;if(cons)props.__ringConstructor__=cons;else{cons=props.init;delete props.init;if(cons)props.__ringConstructor__=cons}var claz=function Instance(){this.$super=null;this.__ringConstructor__.apply(this,arguments)};claz.__properties__=props;var toMerge=_.pluck(parents,"__mro__");toMerge=toMerge.concat([parents]);var __mro__=[claz].concat(mergeMro(toMerge));var prototype=Object.prototype;_.each(_.clone(__mro__).reverse(),
  1431. function(claz){var current=objectCreate(prototype);_.extend(current,claz.__properties__);_.each(_.keys(current),function(key){var p=current[key];if(typeof p!=="function"||!fnTest.test(p)||key!=="__ringConstructor__"&&claz.__ringConvertedObject__)return;current[key]=function(name,fct,supProto){return function(){var tmp=this.$super;this.$super=supProto[name];try{return fct.apply(this,arguments)}finally{this.$super=tmp}}}(key,p,prototype)});current.constructor=claz;prototype=current});var id=classCounter++;
  1432. claz.__mro__=__mro__;claz.__parents__=parents;claz.prototype=prototype;claz.__classId__=id;claz.__classIndex__={};_.each(claz.__mro__,function(c){claz.__classIndex__[c.__classId__]=c});if(claz.prototype.classInit){claz.__classInit__=claz.prototype.classInit;delete claz.prototype.classInit}_.each(_.chain(claz.__mro__).clone().reverse().value(),function(c){if(c.__classInit__){var ret=c.__classInit__(claz.prototype);if(ret!==undefined)claz.prototype=ret}});return claz};var mergeMro=function(toMerge){var __mro__=
  1433. [];var current=_.clone(toMerge);while(true){var found=false;for(var i=0;i<current.length;i++){if(current[i].length===0)continue;var currentClass=current[i][0];var isInTail=_.find(current,function(lst){return _.contains(_.rest(lst),currentClass)});if(!isInTail){found=true;__mro__.push(currentClass);current=_.map(current,function(lst){if(_.head(lst)===currentClass)return _.rest(lst);else return lst});break}}if(found)continue;if(_.all(current,function(i){return i.length===0}))return __mro__;throw new ring.ValueError("Cannot create a consistent method resolution order (MRO)");
  1434. }};var toRingClass=function(claz){if(claz.__classId__)return;var proto=!Object.getOwnPropertyNames?claz.prototype:function(){var keys={};(function crawl(p){if(p===Object.prototype)return;_.extend(keys,_.chain(Object.getOwnPropertyNames(p)).map(function(el){return[el,true]}).object().value());crawl(Object.getPrototypeOf(p))})(claz.prototype);return _.object(_.map(_.keys(keys),function(k){return[k,claz.prototype[k]]}))}();proto=_.chain(proto).map(function(v,k){return[k,v]}).filter(function(el){return el[0]!==
  1435. "constructor"&&el[0]!=="__proto__"}).object().value();var id=classCounter++;_.extend(claz,{__mro__:[claz,ring.Object],__properties__:_.extend({},proto,{__ringConstructor__:function(){this.$super.apply(this,arguments);var tmp=this.$super;this.$super=null;try{claz.apply(this,arguments)}finally{this.$super=tmp}}}),__classId__:id,__parents__:[ring.Object],__classIndex__:{1:ring.Object},__ringConvertedObject__:true});claz.__classIndex__[id]=claz};ring.instance=function(obj,type){if(typeof obj==="object"&&
  1436. obj.constructor&&obj.constructor.__classIndex__&&typeof type==="function"&&typeof type.__classId__==="number")return obj.constructor.__classIndex__[type.__classId__]!==undefined;if(typeof type==="string")return typeof obj===type;return obj instanceof type};ring.Error=ring.create({name:"ring.Error",defaultMessage:"",constructor:function(message){this.message=message||this.defaultMessage},classInit:function(prototype){var protos=[];var gather=function(proto){if(!proto)return;protos.push(proto);gather(proto.__proto__)};
  1437. gather(prototype);var current=new Error;_.each(_.clone(protos).reverse(),function(proto){var tmp=objectCreate(current);_.each(proto,function(v,k){if(k!=="__proto__")tmp[k]=v});current=tmp});return current}});ring.ValueError=ring.create([ring.Error],{name:"ring.ValueError"});ring.getSuper=function(currentClass,obj,attributeName){var pos;var __mro__=obj.constructor.__mro__;for(var i=0;i<__mro__.length;i++)if(__mro__[i]===currentClass){pos=i;break}if(pos===undefined)throw new ring.ValueError("Class not found in instance's method resolution order.");
  1438. var find=function(proto,counter){if(counter===0)return proto;return find(proto.__proto__,counter-1)};var proto=find(obj.constructor.prototype,pos+1);var att;if(attributeName!=="constructor"&&attributeName!=="init")att=proto[attributeName];else att=proto.__ringConstructor__;if(ring.instance(att,"function"))return _.bind(att,obj);else return att};return ring}})();