1VNP.Areas.Reader = new function () { 2 3 var self = this; 4 var totalPages; 5 self.swiperUi; 6 self.isDoublePage = VNP.getDevice().isDoublePage; 7 self.verticalSummary = ""; 8 var activePage; 9 var title = VNP.getTitle(); //directory 10 var edition; //YYYYMMDDdirectory 11 var $pages = $("#vc_pages"); 12 var $summaryContainer = $("#vc_summary_container"); 13 var $pullouts = $("#vc_pullouts"); 14 var $availableEdition = $("#vc_editions"); 15 var $countDown = $(".vc_count_down"); 16 var $loading = $(".vc_loading"); 17 var $navbar = $(".vc_navbar"); 18 var booksPath; 19 var reader = "swipe"; 20 var consultationTime; 21 var time; 22 var timer; 23 var pageflip = "pageflip"; 24 var zoomedPages = 0; 25 var timerDiscountWall; 26 let awsS3Activated; 27 let s3URL = new Map(); 28 29 /* 30 * get reader 31 * @param pageflip {String} : possible values are swiper, flash, flip 32 * the parameter comes from ${getEditorValue("pageflip")} 33 * */ 34 self.getReader = function () { 35 return reader; 36 }; 37 38 /* 39 * set reader 40 * @param pageflip {String} : possible values are swiper, flash, flip 41 * the parameter comes from ${getEditorValue("pageflip")} 42 * */ 43 var setReader = function (pageflip) { 44 reader = pageflip; 45 }; 46 47 self.getBooksPath = function () { 48 return booksPath; 49 }; 50 51 /* 52 * Set path to books 53 * @param path {String} : is setted using ${issue.getPathToBooks("")} 54 * it is a relative path ( eg. /books/quattrozampe/2016/20160701quattrozampe/ ) 55 * */ 56 self.setBooksPath = function (path) { 57 booksPath = path; 58 }; 59 60 /* get active page */ 61 self.getActivePage = function () { 62 return activePage; 63 }; 64 65 /* 66 * set the active page from the hash 67 * set page to 1 if the hash there isn't 68 */ 69 self.setActivePage = function () { 70 var page = parseInt(location.href.substring(location.href.indexOf('#')).replace(/\W/g, '')); 71 //check if hash is present and it is a number 72 if (isNaN(page) || location.hash == "" || page === 0) page = 1; 73 if( page > self.getTotalPages() ) page = self.getTotalPages(); 74 activePage = page; 75 }; 76 77 78 /* 79 * set the page number which the user can zoom in the free access time, before the count down is over 80 * @pageNumber {integer} last page to zoom 81 * */ 82 self.setMaxPageToZoom = function (pageNumber){ 83 zoomedPages = pageNumber; 84 }; 85 86 /* 87 * get the last page to zoom 88 * @return {integer} last page to zoom 89 * */ 90 self.getMaxPageToZoom = function (){ 91 return zoomedPages; 92 }; 93 94 95 /* 96 * get if the summary is vertical or not 97 * search for the key in editore and testate_parameter tables 98 * the key is verticalSummary 99 * @return {Boolean} true or false 100 * */ 101 self.isVerticalSummary = function(){ 102 return ( self.verticalSummary === "true") ? true : false; 103 }; 104 105 106 /* open zoom wall */ 107 self.openZoomWall = function(){ 108 109 $navbar.css({"z-index": "10000"}); 110 111 /* avoid to close the modal */ 112 var options = { 113 message: "<p class='vc_alert'>" + VNP.getLanguagesKey["wall_zoom_denied_text"] +"</p>", 114 title: VNP.getLanguagesKey["wall_zoom_denied_title"], 115 size: 'md', 116 classname:'vc_wall_zoom', 117 useBin: true, 118 buttons: [ 119 {text: VNP.getLanguagesKey["wall_zoom_denied_btn"], style: 'primary', close: true, click: VNP.Areas.Reader.module.Zoom.out } 120 ] 121 }; 122 123 eModal.alert(options).then(VNP.Areas.Reader.module.Zoom.out); 124 125 }; 126 127 // open the edition calendar rendered into reader 128 self.openEditionCalendar = function (selector, e, title) { 129 130 if (selector == null || typeof selector === "undefined" || selector == "undefined" || $.trim(selector) == "" || $(selector).length == 0 ) { 131 return; 132 } 133 134 // stop the click from bubbling 135 e.stopPropagation(); 136 // prevent the default click action 137 e.preventDefault(); 138 // open the date picker 139 VNP.Areas.Newsstand.initializeEditionCalendar("#vc_edition_calendar_reader",title); 140 141 return false 142 }; 143 144 145 /* toggle editions for virtualmagazine, virtualbooks */ 146 self.openEditions = function () { 147 self.renderEditions(); 148 self.toggleSlider($availableEdition, "horizontal"); 149 }; 150 151 /* toggle pages */ 152 self.openPages = function () { 153 self.renderPages(); 154 self.toggleSlider($pages, "horizontal"); 155 }; 156 157 /* open the modal containing the list of articles */ 158 self.openArticles = function () { 159 160 self.module.Articles.renderArticles(self.getActivePage()); 161 if (!$(".vc_open_articles").hasClass("disabled")) { 162 var options = { 163 message: $("#vc_articles").show(), 164 size: "lg", 165 title: VNP.getLanguagesKey["articles"], 166 buttons: [], 167 useBin: true 168 }; 169 170 eModal.alert(options); 171 } 172 173 }; 174 175 self.goToFluidVersion = function(url) { 176 url = url.replace("{year}", VNP.getEdition().substr(0,4)); 177 url = url.replace("{month}", VNP.getEdition().substr(4,2)); 178 url = url.replace("{date}", VNP.getEdition().substr(6,2)); 179 url = url.replace("{title}", VNP.getEdition().substr(8,VNP.getEdition().length)); 180 url = url.replace("{page_number}", self.getActivePage()); 181 location.href=url; 182 } 183 184 /* open the modal containing the rendered multimedia */ 185 self.openMedia = function () { 186 // render the multimedia and fill in the modal 187 self.module.Multimedia.renderMultimedia(self.getActivePage()); 188 189 if (!$(".vc_open_multimedia").hasClass("disabled")) { 190 var options = { 191 message: $("#vc_multimedia").show(), 192 size: "lg", 193 title: "Multimedia", 194 buttons: [], 195 useBin: true 196 }; 197 198 eModal.alert(options); 199 } 200 201 }; 202 203 self.openExternalLinks = function () { 204 // render the multimedia and fill in the modal 205 self.module.Multimedia.renderExternalLinks(self.getActivePage()); 206 207 if (!$(".vc_open_external_links").hasClass("disabled")) { 208 var options = { 209 message: $("#vc_external_links").show(), 210 size: "lg", 211 title: VNP.getLanguagesKey["reader_external_links"], 212 buttons: [], 213 useBin: true 214 }; 215 216 eModal.alert(options); 217 } 218 219 }; 220 221 /* open summary */ 222 self.openSummary = function () { 223 224 var summary = "summary"; 225 var $summaryContainer = $("#vc_summary_container"); 226 227 // get the summary type to open: vertical or horizontal 228 if ( VNP.getTitleType() == "virtualbook" || self.isVerticalSummary()) { 229 summary = "summary_book_vertical"; 230 // Summary vertical 231 $summaryContainer.addClass("vertical"); 232 self.toggleSlider($summaryContainer, "vertical"); 233 234 } else { 235 236 // Summary horizontal 237 $summaryContainer.addClass("horizontal"); 238 self.toggleSlider($summaryContainer, "horizontal"); 239 } 240 241 // load the iframe if is not already loaded 242 var src = VNP.baseUrl + "/includes/" + summary + ".jsp?edizione=" + VNP.editionDate + "&testata=" + VNP.getTitle() + "&book=false&nocache=" + Date.now(); 243 if (!$($summaryContainer).find("#vc_summary_iframe").hasClass("loaded")) { 244 // show loading 245 $($summaryContainer).find($loading).show(); 246 $($summaryContainer).find("#vc_summary_iframe").attr("src", src).on("load", function () { 247 $($summaryContainer).find($loading).hide(); 248 $(this).addClass("loaded"); 249 // add css inside iframe, because is shared with flash version 250 var cssLink = document.createElement("link"); 251 cssLink.href = VNP.baseUrl + "/assets/css/_summary.css"; 252 cssLink.rel = "stylesheet"; 253 cssLink.type = "text/css"; 254 var documentIframe = $(this).contents()[0]; 255 documentIframe.body.appendChild(cssLink); 256 }); 257 } 258 259 return false;
260 261 }; 262 263 /* 264 * open single page pdf 265 * @param page {Integer} : page's number to get pdf 266 * 267 */ 268 self.openSinglePagePdf = function (page) { 269 window.open(VNP.baseUrl + "/reader/xsearch.jsp?edition=" + VNP.getEdition() + "&pag=" + page, '', 'scrollbars=no,width=' + ( screen.width - 5 ) + ',height=' + ( screen.height - 30 )); 270 }; 271 272 273 /* open pullouts */ 274 self.openPullouts = function () { 275 self.renderPullouts(); 276 self.toggleSlider($pullouts, "horizontal"); 277 }; 278 279 /* open shop */ 280 self.openShop = function () { 281 282 eModal.alert({ 283 message: $("#vc_choose_product_shop").show(), 284 title: VNP.getLanguagesKey["cflacquista"], 285 size: "sm", 286 buttons: [], 287 useBin: true 288 }); 289 290 }; 291 292 /* open wall */ 293 self.openPaywall = function () { 294 295 $navbar.css({"z-index": "10000"}); 296 var $wall = $('.vc_wall'); 297 /* avoid to close the modal */ 298 $wall.modal({ 299 backdrop: 'static', 300 keyboard: false 301 }); 302 303 /* avoid to close the modal */ 304 $wall.on('hide.bs.modal', function () { 305 return false; 306 }); 307 308 }; 309 310 self.confirmDownloadPdf = function(){ 311 var options = { 312 title: VNP.getLanguagesKey["msg_pdfDownloadTitle"], 313 message: VNP.getLanguagesKey["msg_pdfDownload"], 314 classname: "modal-confirm-pdf", 315 buttons: [ 316 { text: VNP.getLanguagesKey["msg_pdfDownload_reject"], close:true, style:"danger"}, 317 { text: VNP.getLanguagesKey["msg_pdfDownload_confirm"], close:true, 318 click: function(){ 319 location.href = VNP.baseUrl + self.getBooksPath() + "pdf/issue.pdf"} 320 } 321 ]}; 322 323 eModal.alert(options); 324 }; 325 326 self.getTotalPages = function(){ 327 return totalPages; 328 }; 329 330 self.setTotalPages = function(pages){ 331 totalPages = parseInt(pages); 332 }; 333 334 /* 335 * Breakpoints for the thumbnail sliders (pages, pullouts). Swiper 4 uses 336 * max-width breakpoints; Swiper 5+ (v12) uses min-width. Same effective ranges. 337 */ 338 var thumbSliderBreakpoints = function () { 339 if (window.SWIPER12) { 340 return { 341 0: { slidesPerView: 2, spaceBetween: 5 }, 342 321: { slidesPerView: 3, spaceBetween: 5 }, 343 641: { slidesPerView: 6, spaceBetween: 5 }, 344 769: { slidesPerView: 8, spaceBetween: 5 }, 345 1025: { slidesPerView: 10, spaceBetween: 5 } 346 }; 347 } 348 return { 349 1024: { slidesPerView: 8, spaceBetween: 5 }, 350 768: { slidesPerView: 6, spaceBetween: 5 }, 351 640: { slidesPerView: 3, spaceBetween: 5 }, 352 320: { slidesPerView: 2, spaceBetween: 5 } 353 }; 354 }; 355 356 /* Render the Pages */ 357 self.swiperPages = undefined; 358 self.renderPages = function () { 359 360 // don't re init if already initialized 361 if (self.swiperPages == undefined) { 362 363 var isSwiper12 = !!window.SWIPER12; 364 365 var pagesOptions = { 366 slidesPerView: 10, 367 centeredSlides: false, 368 spaceBetween: 5, 369 virtual: { 370 slides: (function () { 371 var slides = []; 372 for (var i = 1; i <= self.getTotalPages(); i++) { 373 374 let page = i; 375 let thumb = awsS3Activated ? 376 self.getS3URLByKey(page) : 377 VNP.baseUrl + self.getBooksPath() + "images/pages/Page-" + [i] + ".jpg"; 378 379 // v12 uses native lazy images, v4 the swiper-lazy module (data-src) 380 let img = isSwiper12 ? 381 "<img onclick='VNP.Areas.Reader.goToSlide(" + page + ")' src='" + thumb + "' loading='lazy' class='vc_img_thumb'>" : 382 "<img onclick='VNP.Areas.Reader.goToSlide(" + page + ")' data-src='" + thumb + "' class='vc_img_thumb swiper-lazy'>"; 383 384 //add the cloned element to the container 385 slides.push( 386 img 387 + "<div class='vc_number_page'>" + page + "</div>" 388 + "<div class='swiper-lazy-preloader'></div>" 389 ); 390 } 391 return slides; 392 }()) 393 }, 394 grabCursor: true, 395 navigation: { 396 nextEl: '.swiper-pages .swiper-button-next', 397 prevEl: '.swiper-pages .swiper-button-prev' 398 },
399 breakpoints: thumbSliderBreakpoints() 400 }; 401 if (isSwiper12) { pagesOptions.lazyPreloadPrevNext = 4; } else { pagesOptions.lazy = true; } 402 403 self.swiperPages = new Swiper('.swiper-pages', pagesOptions); 404 405 } else { 406 VNP.Areas.Reader.setActivePage(); 407 self.swiperPages.slideTo(self.getActivePage() - 1); 408 } 409 // set active page for slider of pages 410 self.setActivePageSwiperPages(self.getActivePage()); 411 412 }; 413 414 self.getS3URL = function(param){ 415 let xhrObj = { 416 method: "GET", 417 cache: false, 418 url: VNP.baseUrl + "/webservice/aws/fetchS3PreSignURL.jsp", 419 data: $.param(param), 420 dataType: "json" 421 }; 422 423 return $.ajax(xhrObj); 424 }; 425 426 self.setUpS3URL = async function(awsS3){ 427 awsS3Activated = awsS3; 428 if(awsS3){ 429 try{ 430 let param = { 431 "key": VNP.getEdition() 432 }; 433 const data = await self.getS3URL(param); 434 Object.entries(data).forEach(([key, value]) => { 435 s3URL.set(parseInt(key), value); 436 }); 437 }catch(error){ 438 console.error("Error fetching URL for page " + i, error); 439 } 440 } 441 } 442 443 self.getS3URLByKey = function(page){ 444 return s3URL.get(page); 445 } 446 447 self.getS3URLSize = function(){ 448 return s3URL.size; 449 } 450 451 /* 452 * Render the Editions 453 * it creates and load the html slides 454 */ 455 self.renderEditions = function () { 456 457 var $slider = $availableEdition.find(".swiper-container"); 458 var title = $slider.data("name-title"); 459 var limit = $slider.data("limit"); 460 461 //don't render if already rendered 462 if (VNP.Areas.Newsstand.swiperMagazine[title] == "undefined" || VNP.Areas.Newsstand.swiperMagazine[title] == undefined ){ 463 464 VNP.Areas.Newsstand.renderSliderMagazine($slider, null, limit); 465 VNP.Areas.Newsstand.renderSelectYears("[name=" + title + "]", title); 466 } 467 468 }; 469 470 /* 471 * Render the Pullouts 472 * it creates and load the html slides 473 */ 474 self.swiperPullouts = undefined; 475 self.renderPullouts = function () { 476// don't re init if already initialized 477 if (self.swiperPullouts == undefined) { 478 479 var pulloutsOptions = { 480 slidesPerView: 10, 481 centeredSlides: false, 482 spaceBetween: 5, 483 grabCursor: true, 484 navigation: { 485 nextEl: '.swiper-pullouts .swiper-button-next', 486 prevEl: '.swiper-pullouts .swiper-button-prev' 487 }, 488 breakpoints: thumbSliderBreakpoints() 489 }; 490 if (window.SWIPER12) { pulloutsOptions.lazyPreloadPrevNext = 4; } else { pulloutsOptions.lazy = true; } 491 492 self.swiperPullouts = new Swiper('.swiper-pullouts', pulloutsOptions); 493 } 494 495 }; 496 497 /* set active page for pages */ 498 self.setActivePageSwiperPages = function (page) { 499 500 var $pages = $(".swiper-pages"); 501 var activeSlide = $pages.find('[data-swiper-slide-index=' + (page - 1) + ']'); 502 var nextActiveSlide = $pages.find('[data-swiper-slide-index=' + page + ']'); 503 504 //remove all class active for other slides 505 $pages.find(".swiper-slide").removeClass("active"); 506 507 self.swiperPages.slideTo(page - 1); 508 509 if (self.isDoublePage && page > 1) { 510 // set active slide only with css 511 $(activeSlide).addClass("active"); 512 $(nextActiveSlide).addClass("active"); 513 514 } else { 515 516 $(activeSlide).addClass("active"); 517 518 } 519 }; 520 521 /* go to n page */ 522 self.goToSlide = function (slide) { 523 // close summary or pages 524 if ($pages.hasClass("show-pages-horizontal")) { 525 $pages.removeClass("show-pages-horizontal"); 526 } 527 self.swiperUi.goToSlide(parseInt(slide)); 528 }; 529 530 /* slide to next page */ 531 self.nextSlide = function () { 532 self.swiperUi.nextSlide(); 533 }; 534 535 /* slide to prev page */ 536 self.prevSlide = function () { 537 self.swiperUi.prevSlide(); 538 }; 539 540 /* slide to first page */ 541 self.firstSlide = function () { 542 self.swiperUi.goToSlide(parseInt(0)); 543 }; 544 545 /* slide to last page */ 546 self.lastSlide = function () { 547 self.swiperUi.goToSlide(self.getTotalPages()); 548 }; 549 550 /* toggle zoom in - zoom out */ 551 self.toggleZoom = function(event){ 552 self.swiperUi.toggleZoom(event); 553 }; 554 555 556 /* set the total amount of articles, multimedia etc... */ 557 self.setTotalAmount = function () { 558 559 var page = self.getActivePage(); 560 var badgeMenu = $(".menu-open-button").find(".badge"); 561 562 var totMultimedia = self.module.Multimedia.getMultimediaByPage(page).length; 563 var totArticles = self.module.Articles.getArticlesByPage(page).length; 564 565 if(self.isDoublePage && page > 1 && page < self.getTotalPages() ) { 566 567 totMultimedia += self.module.Multimedia.getMultimediaByPage( page + 1 ).length; 568 totArticles += self.module.Articles.getArticlesByPage( page + 1 ).length; 569 570 } 571 572 var totalAmount = (totMultimedia + totArticles); 573 574 if (totalAmount > 0) { 575 576 $(badgeMenu).text(44); 577 578 } else { 579 580 $(badgeMenu).empty(); 581 582 } 583 584 }; 585 586 587 /* 588 * Open / close the box selected 589 * @param element {HTML element} : html element eg. $(".selector") 590 * @param modeClass {String} : selector css used for toggling the slider vertical or horizontal. Possible values are .vertical / .horizontal 591 */ 592 self.toggleSlider = function (element, modeClass) { 593 594 var heightElement = $(element).outerHeight(); 595 var navbar = (VNP.getDevice.isMobile)? ".vc_extra" : ".vc_navbar"; 596 var heightExtraMediaElement = $(navbar).outerHeight(); 597 var showSlide = "vc_show_slide_" + modeClass; 598 var style = {}; 599 600 $("." + modeClass).not(element).removeClass(showSlide); 601 $("." + modeClass).not(element).removeAttr("style"); 602 603 if (element.hasClass(showSlide)) { 604 // close sidebar 605 element.removeClass(showSlide); 606 element.removeAttr("style"); 607 608 } else { 609 // open sidebar 610 element.addClass(showSlide); 611 612 if(modeClass == "vertical"){ 613 var widthElement = $(element).outerWidth(); 614 style = { 615 "left": 0, 616 "-webkit-transform": "translateX(0)", 617 "transform": "translateX(0)", 618 "-webkit-transform": "translate3d(0)", 619 "transform": "translate3d(0)"
620 }; 621 622 } else { 623 624 style = { 625 "bottom": "-" + heightElement + "px", 626 "-webkit-transform": "translateY(-"+ (heightElement + heightExtraMediaElement) + "px)", 627 "transform": "translateY(-"+ (heightElement + heightExtraMediaElement) + "px)", 628 "-webkit-transform": "translate3d(0, -"+ (heightElement + heightExtraMediaElement) + "px, 0)", 629 "transform": "translate3d(0, -"+ (heightElement + heightExtraMediaElement) + "px, 0)" 630 }; 631 } 632 633 element.css(style); 634 } 635 636 637 }; 638 639 640 /* 641 * set consultation time 642 * @param seconds {Integer} : milliseconds eg. 5000 643 * */ 644 self.setConsultationTime = function (milliseconds) { 645 //convert in seconds 646 consultationTime = Math.round(milliseconds / 1000); 647 648 }; 649 650 651 /* 652 * get consultation time set with ${freeReadingTime} ftl 653 * @return consultationTime {Integer} 654 * */ 655 self.getConsultationTime = function () { 656 return consultationTime; 657 }; 658 659 660 /* count down free Reading Time */ 661 self.countDown = function () { 662 663 var timeDisplaied; 664 var labelDisplaied; 665 666 if (isNaN(time)) { 667 return; 668 } 669 time--; 670 671 if (time === 0) { 672 self.stopConsultationTime(); 673 } 674 675 timeDisplaied = time; 676 labelDisplaied = VNP.getLanguagesKey["count_down_time_plural"]; 677 678 if(time === 1){ 679 labelDisplaied = VNP.getLanguagesKey["count_down_time_singular"]; 680 } 681 682 $($countDown).find(".progress-label").text(labelDisplaied); 683 $($countDown).find(".progress-value").text(timeDisplaied); 684 685 }; 686 687 /* start count down and start the animation of timer */ 688 self.startConsultationTime = function () { 689 time = self.getConsultationTime(); 690 691 if (time === 0) { 692 self.stopConsultationTime(); 693 return; 694 } 695 696 if (typeof time === "undefined" || time === "" || time === null) { 697 return; 698 } 699 700 if( VNP.getDevice().isMobile ){ 701 702 $($countDown).find(".progress-right .progress-bar").css({ 703 "animation": "progress " + time + "s linear" 704 }); 705 706 } else { 707 708 $($countDown).find(".progress-right .progress-bar").css({ 709 "animation": "loading-1 " + time / 2 + "s linear forwards" 710 }); 711 712 $($countDown).find(".progress-left .progress-bar").css({ 713 "animation": "loading-2 " + time / 2 + "s linear forwards " + time / 2 + "s" 714 }); 715 716 } 717 718 $($countDown).find(".progress-value").text(time); 719 $($countDown).show(); 720 721 timer = window.setInterval(self.countDown, 1000); 722 723 }; 724 725 /* stop count down and show paywall */ 726 self.stopConsultationTime = function () { 727 $($countDown).find(".progress-bar").css({ 728 "animation-play-state": "paused" 729 }); 730 $($countDown).find(".progress-value").empty(); 731 $($countDown).hide(); 732 window.clearInterval(timer); 733 734 //self.swiperUi.destroy(); 735 //self.swiperUi.lockSwipes(); 736 self.openPaywall(); 737 }; 738 739 740 /* 741 * scale credit if the wall is spend credit 742 * @param editionName {String} : edition name, in FTL ${issue.getName()} eg. YYYYMMDDquattrozampe 743 * */ 744 self.scaleCredits = function (editionName) { 745 746 $.ajax({ 747 url: VNP.baseUrl + "/order/order/scale-credit/", 748 data: {issue: editionName}, 749 method: "post", 750 success: function (data) { 751 752 //if (data.success == true) { 753 location.reload(); 754 //} 755 756 } 757 }); 758 759 return false; 760 761 }; 762 763 /* show alert to spend a credit without waiting for free reading time ends */ 764 self.notifyAvailableCredits = function(issue){ 765 766 var options = { 767 classname:'alert-info vc_alert_spend_credit', 768 message: VNP.getLanguagesKey['alert_credit_message'] + "" + 769 "<button type='button' class='btn btn-default btn-spend-credit' onclick='VNP.Areas.Reader.scaleCredits(\" " + issue + " \" )' >" + VNP.getLanguagesKey["alert_credit_usecredit"] + "</button>", 770 close:{ 771 auto:false 772 } 773 }; 774 VNP.setNotifications(options); 775 776 }; 777 778 /* 779 * change workstation 780 * @param customerId {Integer} : id customer 22584 781 * @param issue {String} : YYYYMMDDissue i.e. 20181220quattrozampe 782 * */ 783 self.changeWorkstation = function (customerId, issue) { 784 push_stats(stats.category.title, stats.event.station_change, ''); 785 786 if (customerId !== null && customerId !== "undefined" && typeof customerId === 'number' ) { 787 788 $.ajax({ 789 url : VNP.baseUrl + "/customer/" + customerId + "/" + issue + "/changeWorkstation", 790 method : "post", 791 success : function(data){ 792 // reload the page 793 location.reload(); 794 }, 795 error:function(){} 796 }); 797 798 } 799 800 return false;
801 }; 802 803 self.openPopupDiscount = function(){ 804 805 $navbar.css({"z-index": "10000"}); 806 var $wall = $('.vc_wall_discount'); 807 if( !$wall.hasClass("active") ) { 808 $wall.addClass("active"); 809 } 810 /* avoid to close the modal */ 811 timerDiscountWall = window.setTimeout(function(){ 812 $wall.removeClass("active"); 813 },25000); 814 815 $wall.on("click",function(e){ 816 e.stopPropagation(); 817 e.preventDefault(); 818 819 // close the popup 820 // only if the user click out of the image 821 if(e.target === this){ 822 self.closePopupDiscount(); 823 } 824 825 }); 826 }; 827 828 self.closePopupDiscount = function(){ 829 830 var $wall = $('.vc_wall_discount'); 831 if( $wall.hasClass("active") ){ 832 $wall.removeClass("active"); 833 window.clearTimeout(timerDiscountWall); 834 } 835 836 }; 837 838 839 // extend reader 840 self.module = (function () { 841 842 }); 843 844 var initReader = function(){ 845 846 var eventAwesome = new CustomEvent("open_edition", { 847 edition_id: VNP.getEditionId(), 848 title_id: VNP.getTitleId(), 849 label: VNP.getEdition(), 850 initial_page: 1 851 }); 852 console.log("Initiated") 853 document.dispatchEvent(eventAwesome); 854 855 //set active page 856 self.setActivePage(); 857 858 /* get banner */ 859 VNP.Areas.Banners.load("#vc_swipe_adv"); 860 /* set timeout to hide the banner on reader */ 861 window.setTimeout( function(){VNP.Areas.Banners.close("#vc_swipe_adv")}, 20000); 862 863 // load articles 864 self.module.Articles.loadArticles(VNP.getEdition()); 865 866 // load multimedia 867 self.module.Multimedia.loadMultimediaElements(VNP.getEdition(), function () {},true); 868 869 // init swipe 870 self.swiperUi = new SwiperUi(); 871 872 873 874 // close pages and summary on mobile if the menu is closing 875 $("#menu-open").on("click",function(){ 876 877 if( $pages.hasClass('vc_show_slide_horizontal') ){ 878 self.toggleSlider($pages, "horizontal"); 879 } 880 881 if( $summaryContainer.hasClass("vc_show_slide_vertical") ) { 882 self.toggleSlider($summaryContainer, "vertical"); 883 } 884 885 }); 886 887 // user can't read, start timer 888 if (!VNP.Areas.Customer.getCanRead()) { 889 self.startConsultationTime(); 890 } 891 892 $(window).on("hashchange", function (e) { 893 894 $(document).ready(function(){ 895 // set stats 896 push_stats(stats.category.title, stats.event.flip + '-' + EDITION_LABEL, self.getActivePage() + '-' + hasAccess_label); 897 }); 898 /* hide the banner when turn the page 899 * and when the page active is > then 1 because the banner disappear immediatly 900 * there is a redirect index.html > index.html#/1/ by getActivePage(); 901 */ 902 if ($("#vc_swipe_adv").length > 0 && self.getActivePage() > 1) { 903 VNP.Areas.Banners.close("#vc_swipe_adv:visible"); 904 } 905 }); 906 907 908 $(document).on('keydown', function (e) { 909 if(e.ctrlKey && e.shiftKey && e.keyCode == 69){ 910 //console.log("shortcut ctrl + shift + e"); 911 VNP.Areas.Reader.stopConsultationTime(); 912 } 913 }); 914 }; 915 916 self.init = function () { 917 918 919 //if user returns back using arrows of the browser force reloading page, 920 //because the browser doesn't work properly and the timer starts again 921 922 try{ 923 924 var nav = performance.getEntriesByType("navigation"); 925 926 //alert("navigazione di tipo " + nav[0].type); 927 if( nav.length > 0 && nav[0].type === "back_forward" && self.getConsultationTime() > 0 ) { 928 location.reload(); 929 } else { 930 initReader(); 931 } 932 933 } catch(err) { 934 console.log("browser doesn't support performance.getEntriesByType('navigation')",err); 935 initReader(); 936 } 937 938 939 }; 940 941};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.