View | Details | Raw Unified | Return to bug 41078
Collapse All | Expand All

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt (-130 / +1 lines)
Lines 486-491 Link Here
486
        const virtualshelves = [% ( virtualshelves ) ? 1 : 0 | html %];
486
        const virtualshelves = [% ( virtualshelves ) ? 1 : 0 | html %];
487
    </script>
487
    </script>
488
    [% Asset.js("js/results-list.js") | $raw %]
488
    [% Asset.js("js/results-list.js") | $raw %]
489
    [% Asset.js("js/cover_images.js") | $raw %]
489
    <script>
490
    <script>
490
        [% IF ( OpacHighlightedWords ) %]
491
        [% IF ( OpacHighlightedWords ) %]
491
            var q_array = new Array();  // holds search terms if available
492
            var q_array = new Array();  // holds search terms if available
Lines 510-645 Link Here
510
            }
511
            }
511
        [% END # /IF OpacHighlightedWords %]
512
        [% END # /IF OpacHighlightedWords %]
512
513
513
        function verify_cover_images() {
514
            // Loop over each container in the template which contains covers
515
            $(".cover-slider").each(function( index ){
516
                let biblionumber = $(this).data("biblionumber");
517
                let booktitle = $(this).data("title");
518
                var lightbox_descriptions = [];
519
                $(this).find(".cover-image").each( function( index ){
520
                    var div = $(this);
521
                    // Find the image in the container
522
                    var img = div.find("img")[0];
523
                    if( img && $(img).length > 0 ){
524
                        // All slides start hidden. If this is the first one, show it.
525
                        // Check if Amazon image is present
526
                        if ( div.hasClass("amazon-coverimg") ) {
527
                            let w = img.width;
528
                            let h = img.height;
529
                            if ((w == 1) || (h == 1)) {
530
                                // Amazon returned single-pixel placeholder
531
                                // Remove the container
532
                                div.remove();
533
                            } else {
534
                                lightbox_descriptions.push(_("Amazon cover image (<a href='%s'>see the original image</a>)").format($(img).data('link')));
535
                            }
536
                        } else if( div.hasClass("custom-coverimg") ){
537
538
                            if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) {
539
                                // No image was loaded via the CustomCoverImages system preference
540
                                // Remove the container
541
                                div.remove();
542
                            } else {
543
                                lightbox_descriptions.push(_("Custom cover image"));
544
                            }
545
                        } else if( div.hasClass("syndetics-coverimg") ){
546
                            lightbox_descriptions.push(_("Image from Syndetics"))
547
                        } else if( div.hasClass("googlejacket-coverimg" ) ){
548
                            if( img.naturalHeight  ){
549
                                lightbox_descriptions.push(_("Image from Google Books (<a href='%s'>see the original image</a>)").format($(img).data('link')));
550
                            }
551
                        } else if( div.hasClass("openlibrary-coverimg") ){
552
                            lightbox_descriptions.push(_("Image from OpenLibrary (<a href='%s'>see the original image</a>)").format($(img).data('link')));
553
                        } else if( div.hasClass("coce-coverimg" ) ){
554
                            // Identify which service's image is being loaded by Coce
555
                            var coce_description;
556
                            let src = $(img).attr("src");
557
                            if( src.indexOf('amazon.com') >= 0 ){
558
                                coce_description = _("Coce image from Amazon.com");
559
                            } else if( src.indexOf('google.com') >= 0 ){
560
                                coce_description = _("Coce image from Google Books");
561
                            } else if( src.indexOf('openlibrary.org') >= 0 ){
562
                                coce_description = _("Coce image from Open Library");
563
                            }
564
                            div.find(".hint").html(coce_description);
565
                            lightbox_descriptions.push(coce_description);
566
                        } else if ( div.hasClass("bakertaylor-coverimg" ) ){
567
                            lightbox_descriptions.push(_("Image from Baker &amp; Taylor"));
568
                        } else if ( div.hasClass("cover-image local-coverimg" ) ){
569
                            lightbox_descriptions.push(_("Local cover image"));
570
                        } else {
571
                            lightbox_descriptions.push(_("Cover image source unknown"));
572
                        }
573
                    } else {
574
                        div.remove();
575
                    }
576
                });
577
578
                // Lightbox for cover images
579
                Chocolat(this.querySelectorAll('.cover-image a'), {
580
                    description: function(){
581
                        return lightbox_descriptions[this.settings.currentImageIndex];
582
                    }
583
                });
584
585
            });
586
587
            $(".cover-slider").each(function(){
588
                var coverSlide = this;
589
                var coverImages = $(this).find(".cover-image");
590
                if( coverImages.length > 1 ){
591
                    coverImages.each(function( index ){
592
                        // If more that one image is present, add a navigation link
593
                        // for activating the slide
594
                        var covernav = $("<a href=\"#\" data-num=\"" + index + "\" class=\"cover-nav\"></a>");
595
                        if( index == 0 ){
596
                            // Set the first navigation link as active
597
                            $(covernav).addClass("nav-active");
598
                        }
599
                        $(covernav).html("<i class=\"fa fa-circle\"></i>");
600
                        $(coverSlide).append( covernav );
601
                    });
602
                }
603
604
                $(coverSlide).find(".cover-image").eq(0).show();
605
606
                if( $(coverSlide).find(".cover-image").length < 1 ){
607
                    $(coverSlide).remove();
608
                } else {
609
                    // This is a suboptimal workaround; we should do this via load, but
610
                    // the image code is scattered all over now. We come here now after
611
                    // window load and wait_for_images (so load completed).
612
                    var check_complete = 1;
613
                    $(coverSlide).find("img").each( function() {
614
                        if( !this.complete || this.naturalHeight == 0 ) check_complete = 0;
615
                    });
616
                    if( check_complete ) $(coverSlide).removeClass('cover-slides');
617
                }
618
            });
619
620
            $(".cover-slider").on("click",".cover-nav", function(e){
621
                e.preventDefault();
622
                var cover_slider = $(this).parent();
623
                // Adding click handler for cover image navigation links
624
                var num = $(this).data("num");
625
                $(cover_slider).find(".cover-nav").removeClass("nav-active");
626
                $(this).addClass("nav-active");
627
                $(cover_slider).find(".cover-image").hide();
628
                $(cover_slider).find(".cover-image").eq( num ).show();
629
            });
630
631
            $("#editions img").each(function(i){
632
                if ( this.src.indexOf('amazon.com') >= 0 ) {
633
                    let w = this.width;
634
                    let h = this.height;
635
                    if ((w == 1) || (h == 1)) {
636
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
637
                    } else if ( (this.complete != null) && (!this.complete) || this.naturalHeight == 0 ) {
638
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
639
                    }
640
                }
641
            });
642
        } /* /verify_images */
643
514
644
515
645
        let counter_wait = 0;
516
        let counter_wait = 0;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt (-90 / +55 lines)
Lines 18-23 Link Here
18
[% SET ArticleRequestsEnabled = ( Koha.Preference('ArticleRequests') == 1 ) && LoginEnabled %]
18
[% SET ArticleRequestsEnabled = ( Koha.Preference('ArticleRequests') == 1 ) && LoginEnabled %]
19
[% SET MultiHolds = ( Koha.Preference('DisplayMultiPlaceHold') == 1 ) && HoldsEnabled %]
19
[% SET MultiHolds = ( Koha.Preference('DisplayMultiPlaceHold') == 1 ) && HoldsEnabled %]
20
[% SET CoverImagePlugins = KohaPlugins.get_plugins_opac_cover_images %]
20
[% SET CoverImagePlugins = KohaPlugins.get_plugins_opac_cover_images %]
21
[% SET OPACLocalCoverImages = Koha.Preference('OPACLocalCoverImages') %]
22
[% SET OPACAmazonCoverImages = Koha.Preference('OPACAmazonCoverImages') %]
23
[% SET SyndeticsCoverImages = ( Koha.Preference('SyndeticsEnabled') && Koha.Preference('SyndeticsCoverImages') ) %]
24
[% SET GoogleJackets = Koha.Preference('GoogleJackets') %]
25
[% SET OpenLibraryCovers = Koha.Preference('OpenLibraryCovers') %]
26
[% SET BakerTaylorEnabled = Koha.Preference('BakerTaylorEnabled') %]
27
[% SET OPACCoce = ( Koha.Preference('OPACCoce') && Koha.Preference('CoceProviders') ) %]
28
[% IF ( CoverImagePlugins || OPACLocalCoverImages || OPACAmazonCoverImages || SyndeticsCoverImages || GoogleJackets || OpenLibraryCovers || BakerTaylorEnabled || OPACCoce || OPACCustomCoverImages ) %]
29
    [% SET CoverImages = 1 %]
30
    [% SET OPACCustomCoverImages = ( Koha.Preference('OPACCustomCoverImages') && Koha.Preference('CustomCoverImagesURL') ) %]
31
    [% SET OverDriveEnabled = Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') %]
32
[% END %]
33
[% SET OverDriveEnabled = ( Koha.Preference( "OPACOverDrive" ) && Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') ) %]
21
34
22
[% BLOCK delete_shelf %]
35
[% BLOCK delete_shelf %]
23
    <form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="deleteshelf[% shelf.shelfnumber | html %]" class="d-inline">
36
    <form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="deleteshelf[% shelf.shelfnumber | html %]" class="d-inline">
Lines 49-54 Link Here
49
[% INCLUDE 'doc-head-close.inc' %]
62
[% INCLUDE 'doc-head-close.inc' %]
50
[% BLOCK cssinclude %]
63
[% BLOCK cssinclude %]
51
[% END %]
64
[% END %]
65
[% Asset.css("lib/Chocolat/css/chocolat.css") | $raw %]
52
</head>
66
</head>
53
[% IF ( loggedinusername ) %]
67
[% IF ( loggedinusername ) %]
54
    [% INCLUDE 'bodytag.inc' bodyid='opac-userlists' bodyclass='scrollto' %]
68
    [% INCLUDE 'bodytag.inc' bodyid='opac-userlists' bodyclass='scrollto' %]
Lines 407-501 Link Here
407
                                                        </td>
421
                                                        </td>
408
                                                    [% END %]
422
                                                    [% END %]
409
                                                    <td>
423
                                                    <td>
410
                                                        <div class="coverimages">
424
                                                        <div class="coverimages"> [% INCLUDE 'cover-images.inc' SEARCH_RESULT=itemsloo %] </div>
411
                                                            [% IF ( itemsloo.title ) %]
412
                                                                [% img_title = itemsloo.title %]
413
                                                            [% ELSE %]
414
                                                                [% img_title = itemsloo.biblionumber %]
415
                                                            [% END %]
416
                                                            <a
417
                                                                class="p1"
418
                                                                href="/cgi-bin/koha/opac-detail.pl?biblionumber=[% itemsloo.biblionumber | html %]"
419
                                                                data-isbn="[% itemsloo.normalized_isbn | html %]"
420
                                                                data-title="[% img_title | html %]"
421
                                                            >
422
                                                                [% IF ( OPACLocalCoverImages ) %]
423
                                                                    <span title="[% img_title | html %]" class="[% itemsloo.biblionumber | html %]" id="local-thumbnail[% loop.count | html %]"></span>
424
                                                                [% END %]
425
426
                                                                [% IF ( OPACAmazonCoverImages ) %]
427
                                                                    [% IF ( itemsloo.normalized_isbn ) %]
428
                                                                        <span title="[% img_title | html %]" id="amazon-thumbnail[% loop.count | html %]"
429
                                                                            ><img src="https://images-na.ssl-images-amazon.com/images/P/[% itemsloo.normalized_isbn | html %].01.TZZZZZZZ.jpg" alt=""
430
                                                                        /></span>
431
                                                                    [% ELSE %]
432
                                                                        <span class="no-image">No cover image available</span>
433
                                                                    [% END %]
434
                                                                [% END %]
435
436
                                                                [% IF ( SyndeticsEnabled && SyndeticsCoverImages ) %]
437
                                                                    <span title="[% img_title | html %]" id="syndetics-thumbnail[% loop.count | html %]"
438
                                                                        ><img
439
                                                                            src="https://secure.syndetics.com/index.aspx?isbn=[% itemsloo.normalized_isbn | html %]/[% SyndeticsCoverImageSize | uri %].GIF&amp;client=[% SyndeticsClientCode | html %]&amp;type=xw10&amp;upc=[% itemsloo.normalized_upc | html %]&amp;oclc=[% itemsloo.normalized_oclc | html %]"
440
                                                                            alt=""
441
                                                                    /></span>
442
                                                                [% END %]
443
444
                                                                [% IF ( GoogleJackets ) %]
445
                                                                    [% IF ( itemsloo.normalized_isbn ) %]
446
                                                                        <div title="[% img_title | html %]" class="[% itemsloo.normalized_isbn | html %]" id="gbs-thumbnail[% loop.count | html %]"></div>
447
                                                                    [% ELSE %]
448
                                                                        <span class="no-image">No cover image available</span>
449
                                                                    [% END %]
450
                                                                [% END %]
451
452
                                                                [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
453
                                                                    [% coce_id = itemsloo.normalized_ean || itemsloo.normalized_isbn %]
454
                                                                    [% IF ( coce_id ) %]
455
                                                                        <span title="[% img_title | html %]" class="[% coce_id | html %]" id="coce-thumbnail[% loop.count | html %]"></span>
456
                                                                    [% ELSE %]
457
                                                                        <span class="no-image">No cover image available</span>
458
                                                                    [% END %]
459
                                                                [% END %]
460
461
                                                                [% IF OpenLibraryCovers %]
462
                                                                    [% IF itemsloo.normalized_isbn %]
463
                                                                        <span title="[% img_title | html %]" class="[% itemsloo.normalized_isbn | html %]" id="openlibrary-thumbnail[% loop.count | html %]"></span>
464
                                                                    [% ELSE %]
465
                                                                        <span class="no-image">No cover image available</span>
466
                                                                    [% END %]
467
                                                                [% END %]
468
                                                            </a>
469
                                                            <!-- / .p1 -->
470
                                                            [% IF ( Koha.Preference('BakerTaylorEnabled') && !Koha.Preference('BakerTaylorBookstoreURL') ) %]
471
                                                                [% bt_id = ( itemsloo.normalized_upc || itemsloo.normalized_isbn ) %]
472
                                                                [% IF ( bt_id ) %]
473
                                                                    <img alt="See Baker &amp; Taylor" src="[% BakerTaylorImageURL | html %][% bt_id | html %]" />
474
                                                                [% ELSE %]
475
                                                                    <span class="no-image">No cover image available</span>
476
                                                                [% END %]
477
                                                            [% END %]
478
479
                                                            [% IF ( Koha.Preference('BakerTaylorEnabled') && Koha.Preference('BakerTaylorBookstoreURL') ) %]
480
                                                                [% bt_id = ( itemsloo.normalized_upc || itemsloo.normalized_isbn ) %]
481
                                                                [% IF ( bt_id ) %]
482
                                                                    <a href="https://[% Koha.Preference('BakerTaylorBookstoreURL') | uri %][% bt_id | uri %]">
483
                                                                        <img alt="See Baker &amp; Taylor" src="[% BakerTaylorImageURL | html %][% bt_id | html %]" />
484
                                                                    </a>
485
                                                                [% ELSE %]
486
                                                                    <span class="no-image">No cover image available</span>
487
                                                                [% END %]
488
                                                            [% END %]
489
490
                                                            [% IF Koha.Preference('OPACCustomCoverImages') AND Koha.Preference('CustomCoverImagesURL') %]
491
                                                                [% SET custom_cover_image_url = itemsloo.biblio_object.custom_cover_image_url %]
492
                                                                [% IF custom_cover_image_url %]
493
                                                                    <a class="custom_cover_image" href="[% PROCESS biblio_a_href biblionumber => itemsloo.biblionumber %]">
494
                                                                        <img alt="Cover image" src="[% custom_cover_image_url | url %]"
495
                                                                    /></a>
496
                                                                [% END %]
497
                                                            [% END %]
498
                                                        </div>
499
425
500
                                                        [% itemsloo.XSLTBloc | $raw %]
426
                                                        [% itemsloo.XSLTBloc | $raw %]
501
427
Lines 889-894 Link Here
889
815
890
[% INCLUDE 'opac-bottom.inc' %]
816
[% INCLUDE 'opac-bottom.inc' %]
891
[% BLOCK jsinclude %]
817
[% BLOCK jsinclude %]
818
    [% Asset.js("lib/Chocolat/js/chocolat.js") | $raw %]
892
    [% CoverImagePlugins | $raw %]
819
    [% CoverImagePlugins | $raw %]
893
    [% IF OpenLibraryCovers || OpenLibrarySearch %]
820
    [% IF OpenLibraryCovers || OpenLibrarySearch %]
894
        [% Asset.js("js/openlibrary.js") | $raw %]
821
        [% Asset.js("js/openlibrary.js") | $raw %]
Lines 899-905 Link Here
899
        const virtualshelves = [% ( virtualshelves ) ? 1 : 0 | html %];
826
        const virtualshelves = [% ( virtualshelves ) ? 1 : 0 | html %];
900
    </script>
827
    </script>
901
    [% Asset.js("js/results-list.js") | $raw %]
828
    [% Asset.js("js/results-list.js") | $raw %]
829
    [% Asset.js("js/cover_images.js") | $raw %]
902
    <script>
830
    <script>
831
        let counter_wait = 0;
832
        function wait_for_images(cb){
833
834
            var loaded = 1;
835
            counter_wait++;
836
837
            [% IF GoogleJackets %]
838
                if ( loaded ) {
839
                    loaded = KOHA.Google.done;
840
                }
841
            [% END %]
842
843
            [% IF OpenLibraryCovers %]
844
                if ( loaded ) {
845
                    loaded = KOHA.OpenLibrary.done;
846
                }
847
            [% END %]
848
849
            [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
850
                if ( loaded ) {
851
                    loaded = KOHA.coce.done;
852
                }
853
            [% END %]
854
855
            if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds
856
                window.setTimeout(function(){wait_for_images(cb);}, 100);
857
            } else {
858
                if (counter_wait >= 50 ) {
859
                }
860
                cb();
861
            }
862
        }
863
864
        $(window).load(function() {
865
            wait_for_images(verify_cover_images);
866
        });
867
868
903
        [% IF ( TagsInputEnabled && loggedinusername ) %]
869
        [% IF ( TagsInputEnabled && loggedinusername ) %]
904
            function tagSelected() {
870
            function tagSelected() {
905
                var checkedBoxes = $("input:checkbox:checked");
871
                var checkedBoxes = $("input:checkbox:checked");
906
- 

Return to bug 41078