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

(-)a/koha-tmpl/intranet-tmpl/js/coce.js (-3 / +3 lines)
Lines 14-22 KOHA.coce = { Link Here
14
     * and run a search with all collected isbns to coce cover service.
14
     * and run a search with all collected isbns to coce cover service.
15
     * The result is asynchronously returned, and used to append <img>.
15
     * The result is asynchronously returned, and used to append <img>.
16
     */
16
     */
17
    getURL: function(host, provider, newWindow) {
17
    getURL: function(host, provider) {
18
        var ids = [];
18
        var ids = [];
19
        $("[id^=coce-thumbnail]").each(function(i) {
19
        $("[id^=coce-thumbnail]").each(function() {
20
            var id = $(this).attr("class"); // id=isbn
20
            var id = $(this).attr("class"); // id=isbn
21
            if (id !== '') { ids.push(id); }
21
            if (id !== '') { ids.push(id); }
22
        });
22
        });
Lines 36-42 KOHA.coce = { Link Here
36
                        img.onload = function() {
36
                        img.onload = function() {
37
                            // image dimensions can't be known until image has loaded
37
                            // image dimensions can't be known until image has loaded
38
                            if (img.height == 1 && img.width == 1) {
38
                            if (img.height == 1 && img.width == 1) {
39
                                $(this).remove();
39
                                $(this).closest(".coce-coverimg").remove();
40
                            }
40
                            }
41
                        };
41
                        };
42
                        $(this).html(img);
42
                        $(this).html(img);
(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (-1 / +16 lines)
Lines 2096-2102 li { Link Here
2096
}
2096
}
2097
2097
2098
.cover-slides {
2098
.cover-slides {
2099
    background: #FFF url("[% interface | html %]/[% theme | html %]/img/spinner-small.gif") center center no-repeat;
2099
    background: #FFF url("../img/spinner-small.gif") center center no-repeat;
2100
    border: 1px solid #b9d8d9;
2100
    border: 1px solid #b9d8d9;
2101
    border-radius: 3px;
2101
    border-radius: 3px;
2102
    margin: 5px;
2102
    margin: 5px;
Lines 2118-2123 li { Link Here
2118
    }
2118
    }
2119
}
2119
}
2120
2120
2121
td {
2122
    &.bookcoverimg {
2123
        background: #FFF url("../img/spinner-small.gif") center center no-repeat;
2124
        min-width: 120px;
2125
        text-align: center;
2126
    }
2127
    .cover-slides {
2128
        background: transparent none;
2129
        border: 0;
2130
        margin: 0;
2131
        min-height: unset;
2132
        padding: 0;
2133
    }
2134
}
2135
2121
.cover-image {
2136
.cover-image {
2122
    display: none;
2137
    display: none;
2123
2138
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-35 / +49 lines)
Lines 420-462 Link Here
420
                                    <!-- Actual Search Results -->
420
                                    <!-- Actual Search Results -->
421
                                    [% SET MaxSearchResultsItemsPerRecordStatusCheck = Koha.Preference('MaxSearchResultsItemsPerRecordStatusCheck') %]
421
                                    [% SET MaxSearchResultsItemsPerRecordStatusCheck = Koha.Preference('MaxSearchResultsItemsPerRecordStatusCheck') %]
422
                                    [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
422
                                    [% FOREACH SEARCH_RESULT IN SEARCH_RESULTS %]
423
                                        <tr>
423
                                        <tr id="row[% SEARCH_RESULT.biblionumber | html %]">
424
                                            [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
424
                                            [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
425
                                                <td>
425
    <td class="bookcoverimg">
426
                                                    [% IF ( LocalCoverImages) %]
426
        <div id="cover-slides-[% SEARCH_RESULT.biblionumber | html %]" class="cover-slides" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]">
427
                                                        <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]">
427
            [% IF ( LocalCoverImages ) %][% SEARCH_RESULT.localimage | html %]
428
                                                            <span title="[% SEARCH_RESULT.biblionumber |url %]" class="[% SEARCH_RESULT.biblionumber | html %]" id="local-thumbnail[% loop.count | html %]"></span>
428
                <div id="local-coverimg-[% SEARCH_RESULT.biblionumber | html %]" class="cover-image local-coverimg">
429
                                                        </a>
429
                    <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]">
430
                                                    [% END %]
430
                        <img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;biblionumber=[% SEARCH_RESULT.biblionumber | uri %]" alt="Local cover image" />
431
                                                    [% IF ( AdlibrisEnabled && SEARCH_RESULT.normalized_isbn ) %]
431
                    </a>
432
                                                        <a href="[% AdlibrisURL | url %]?isbn=[% SEARCH_RESULT.normalized_isbn | uri %]"><img src="[% AdlibrisURL | url %]?isbn=[% SEARCH_RESULT.normalized_isbn | uri %]" class="adlibris-cover" alt="Adlibris cover image" /></a>
432
                    <div class="hint">Local cover image</div>
433
                                                    [% END %]
433
                </div>
434
                                                    [% IF ( AmazonCoverImages ) %]
434
            [% END %]
435
                                                        [% IF ( SEARCH_RESULT.normalized_isbn ) %]
436
                                                            <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]">
437
                                                            <img src="https://images-na.ssl-images-amazon.com/images/P/[% SEARCH_RESULT.normalized_isbn | html %].01.TZZZZZZZ.jpg" alt="" class="thumbnail" />
438
                                                        [% ELSIF ( !LocalCoverImages ) %]
439
                                                            <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]">
440
                                                            <span class="no-image">No cover image available</span>
441
                                                        [% END %]
442
                                                        </a>
443
                                                    [% END # /IF AmazonCoverImages %]
444
                                                    [% IF ( IntranetCoce && CoceProviders ) %]
445
                                                        [% coce_id = SEARCH_RESULT.normalized_ean || SEARCH_RESULT.normalized_isbn %]
446
                                                            <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% SEARCH_RESULT.biblionumber | url %]">
447
                                                        [% IF ( coce_id ) %]
448
                                                            <span style="block" title="[% SEARCH_RESULT.biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail[% loop.count | html %]"></span>
449
                                                        [% ELSE %]
450
                                                            <span class="no-image">No cover image available</span>
451
                                                        [% END %]
452
                                                            </a>
453
                                                    [% END %]
454
435
455
                                                    [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
436
            [% IF ( AdlibrisEnabled && SEARCH_RESULT.normalized_isbn ) %]
456
                                                        <a class="custom_cover_image" href="[% SEARCH_RESULT.biblio_object.custom_cover_image_url | url %]"><img alt="Cover image" src="[% SEARCH_RESULT.biblio_object.custom_cover_image_url | url %]" />
437
                <div id="adlibris-coverimg-[% SEARCH_RESULT.biblionumber | html %]" class="cover-image adlibris-coverimg">
457
                                                    [% END %]
438
                    <a href="[% AdlibrisURL | url %]?isbn=[% SEARCH_RESULT.normalized_isbn | uri %]"><img src="[% AdlibrisURL | url %]?isbn=[% SEARCH_RESULT.normalized_isbn | uri %]" class="adlibris-cover" alt="Adlibris cover image" /></a>
458
                                                </td>
439
                </div>
459
                                            [% END # /IF( AmazonCoverImages || LocalCoverImages || AdlibrisEnabled || IntranetCoce )%]
440
            [% END %]
441
442
            [% IF ( AmazonCoverImages && SEARCH_RESULT.normalized_isbn ) %]
443
                <div id="amazon-bookcoverimg-[% SEARCH_RESULT.biblionumber | html %]" class="cover-image amazon-bookcoverimg">
444
                    <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% SEARCH_RESULT.biblionumber |url %]">
445
                        <img src="https://images-na.ssl-images-amazon.com/images/P/[% SEARCH_RESULT.normalized_isbn | html %].01.TZZZZZZZ.jpg" alt="Cover image from Amazon.com" />
446
                    </a>
447
                    <div class="hint">Amazon cover image</div>
448
                </div>
449
            [% END # /IF AmazonCoverImages %]
450
451
            [% IF ( IntranetCoce && CoceProviders && SEARCH_RESULT.normalized_isbn ) %]
452
                [% coce_id = SEARCH_RESULT.normalized_ean || SEARCH_RESULT.normalized_isbn %]
453
                [% IF ( coce_id ) %]
454
                    <div id="coce-coverimg-[% SEARCH_RESULT.biblionumber | html %]" class="cover-image coce-coverimg">
455
                        <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% SEARCH_RESULT.biblionumber | url %]">
456
                            <span style="block" title="[% SEARCH_RESULT.biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail[% SEARCH_RESULT.biblionumber | html %]"></span>
457
                        </a>
458
                        <div class="hint">Coce cover image</div>
459
                    </div>
460
                [% END %]
461
            [% END %]
462
463
            [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
464
                <div id="custom-coverimg-[% SEARCH_RESULT.biblionumber | html %]" class="cover-image custom-coverimg">
465
                    <a class="custom_cover_image" href="[% SEARCH_RESULT.biblio_object.custom_cover_image_url | url %]">
466
                        <img alt="Custom cover image" src="[% SEARCH_RESULT.biblio_object.custom_cover_image_url | url %]" />
467
                    </a>
468
                    <div class="hint">Custom cover image</div>
469
                </div>
470
            [% END %]
471
        </div>
472
    </td>
473
[% END # /IF( AmazonCoverImages || LocalCoverImages || AdlibrisEnabled || IntranetCoce )%]
460
474
461
                                            <td>
475
                                            <td>
462
                                                <input type="checkbox" class="selection" id="bib[% SEARCH_RESULT.biblionumber | html %]" name="biblionumber" value="[% SEARCH_RESULT.biblionumber | html %]" style="display:none" />
476
                                                <input type="checkbox" class="selection" id="bib[% SEARCH_RESULT.biblionumber | html %]" name="biblionumber" value="[% SEARCH_RESULT.biblionumber | html %]" style="display:none" />
(-)a/koha-tmpl/intranet-tmpl/prog/js/pages/results.js (-25 / +120 lines)
Lines 1-17 Link Here
1
/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_AmazonCoverImages PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers MSG_NO_ITEM_SELECTED MSG_NO_ITEM_SELECTED holdfor_cardnumber holdforclub strQuery MSG_NON_RESERVES_SELECTED PREF_NotHighlightedWords PLACE_HOLD __ */
1
/* global KOHA biblionumber new_results_browser addMultiple vShelfAdd openWindow search_result SEARCH_RESULTS PREF_LocalCoverImages PREF_IntranetCoce PREF_CoceProviders CoceHost CoceProviders addRecord delSingleRecord PREF_BrowseResultSelection resetSearchContext addBibToContext delBibToContext getContextBiblioNumbers MSG_NO_ITEM_SELECTED MSG_NO_ITEM_SELECTED holdfor_cardnumber holdforclub strQuery MSG_NON_RESERVES_SELECTED PREF_NotHighlightedWords PLACE_HOLD __ */
2
2
3
if( PREF_AmazonCoverImages ){
3
function verify_images() {
4
    $(window).load(function() {
4
    /* Loop over each container in the template which contains covers */
5
        verify_images();
5
    var coverSlides = $(".cover-slides"); /* One coverSlides for each search result */
6
    coverSlides.each( function( index ){
7
        var slide = $(this);
8
        var biblionumber = $(this).data("biblionumber");
9
        var coverImages = $(".cover-image", slide ); /* Multiple coverImages for each coverSlides */
10
        var blanks = [];
11
        coverImages.each( function( index ){
12
            var div = $(this);
13
            var coverId = div.attr("id");
14
            /* Find the image in the container */
15
            var img = div.find("img")[0];
16
            if( $(img).length > 0 ){
17
                if( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ){
18
                    /* No image loaded in the container. Remove the slide */
19
                    blanks.push( coverId );
20
                    div.remove();
21
                } else {
22
                    /* Check if Amazon image is present */
23
                    if ( div.hasClass("amazon-bookcoverimg") ) {
24
                        w = img.width;
25
                        h = img.height;
26
                        if ((w == 1) || (h == 1)) {
27
                            /* Amazon returned single-pixel placeholder */
28
                            /* Remove the container */
29
                            blanks.push( coverId );
30
                            div.remove();
31
                        }
32
                    }
33
                    /* Check if Local image is present */
34
                    if ( div.hasClass("local-coverimg" ) ) {
35
                        w = img.width;
36
                        h = img.height;
37
                        if ((w == 1) || (h == 1)) {
38
                            /* Local cover image returned single-pixel placeholder */
39
                            /* Remove the container */
40
                            blanks.push( coverId );
41
                            div.remove();
42
                        }
43
                    }
44
                    if( div.hasClass("custom-img") ){
45
                        /* Check for image from CustomCoverImages system preference */
46
                        if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) {
47
                            /* No image was loaded via the CustomCoverImages system preference */
48
                            /* Remove the container */
49
                            blanks.push( coverId );
50
                            div.remove();
51
                        }
52
                    }
53
54
                    if( div.hasClass("coce-coverimg") ){
55
                        /* Identify which service's image is being loaded by IntranetCoce system pref */
56
                        if( $(img).attr("src").indexOf('amazon.com') >= 0 ){
57
                            div.find(".hint").html(_("Coce image from Amazon.com"));
58
                        } else if( $(img).attr("src").indexOf('google.com') >= 0 ){
59
                            div.find(".hint").html(_("Coce image from Google Books"));
60
                        } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){
61
                            div.find(".hint").html(_("Coce image from Open Library"));
62
                        } else {
63
                            blanks.push( coverId );
64
                            div.remove();
65
                        }
66
                    }
67
                    if( coverImages.length > 1 ){
68
                        if( blanks.includes( coverId ) ){
69
                            /* Don't add covernav link */
70
                        } else {
71
                            var covernav = $("<a href=\"#\" data-coverid=\"" + coverId + "\" data-biblionumber=\"" + biblionumber + "\" class=\"cover-nav\"></a>");
72
                            $(covernav).html("<i class=\"fa fa-circle\"></i>");
73
                            slide.addClass("cover-slides").append( covernav );
74
                        }
75
                    }
76
                } /* /IF image loaded */
77
            } else {
78
                blanks.push( coverId );
79
                div.remove();
80
            } /* /IF there is an image tag */
81
            /* console.log( coverImages ); */
82
        });
83
84
        /* Show the first cover image slide after empty ones have been removed */
85
        $(".cover-image", slide).eq(0).show();
86
        /* Remove "loading" background gif */
87
        $(".bookcoverimg").css("background","unset");
88
89
        if( $(".cover-image", slide).length < 2 ){
90
            /* Don't show controls for switching between covers if there is only 1 */
91
            $(".cover-nav", slide).remove();
92
        }
93
        /* Set the first navigation link as active */
94
        $(".cover-nav", slide).eq(0).addClass("nav-active");
95
96
        /* If no slides contain any cover images, remove the container */
97
        if( $(".cover-image:visible", slide).length < 1 ){
98
            slide.remove();
99
        }
6
    });
100
    });
7
}
101
}
8
102
103
$(window).load(function() {
104
    verify_images();
105
});
106
9
var Sticky;
107
var Sticky;
10
var toHighlight = {};
108
var toHighlight = {};
11
var q_array;
109
var q_array;
12
110
13
$(document).ready(function() {
111
$(document).ready(function() {
14
112
113
    $("#searchresults").on("click",".cover-nav", function(e){
114
        e.preventDefault();
115
        /* Adding click handler for cover image navigation links */
116
        var coverid = $(this).data("coverid");
117
        var biblionumber = $(this).data("biblionumber");
118
        var slides = $("#cover-slides-" + biblionumber );
119
120
        $(".cover-nav", slides).removeClass("nav-active");
121
        $(this).addClass("nav-active");
122
        $(".cover-image", slides).hide();
123
        $( "#" + coverid ).show();
124
    });
125
15
    $(".moretoggle").click(function(e) {
126
    $(".moretoggle").click(function(e) {
16
        e.preventDefault();
127
        e.preventDefault();
17
        $(this).siblings(".collapsible-facet").toggle();
128
        $(this).siblings(".collapsible-facet").toggle();
Lines 86-93 $(document).ready(function() { Link Here
86
    if( search_result.query_desc ){
197
    if( search_result.query_desc ){
87
        toHighlight = $("p,span.results_summary,a.title");
198
        toHighlight = $("p,span.results_summary,a.title");
88
        q_array = search_result.query_desc.split(" ");
199
        q_array = search_result.query_desc.split(" ");
89
        // ensure that we don't have "" at the end of the array, which can
200
        /* ensure that we don't have "" at the end of the array, which can */
90
        // break the highlighter
201
        /* break the highlighter */
91
        while ( q_array.length > 0 && q_array[q_array.length-1] == "") {
202
        while ( q_array.length > 0 && q_array[q_array.length-1] == "") {
92
            q_array = q_array.splice(0,-1);
203
            q_array = q_array.splice(0,-1);
93
        }
204
        }
Lines 307-327 function holdForClub() { Link Here
307
    placeHold();
418
    placeHold();
308
}
419
}
309
420
310
// http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
311
function verify_images() {
312
    $("img").each(function(){
313
        if ((this.src.indexOf('images-amazon.com') >= 0) || (this.src.indexOf('images.amazon.com') >=0)) {
314
            var w = this.width;
315
            var h = this.height;
316
            if ((w == 1) || (h == 1)) {
317
                $(this).parent().html('<span class="no-image">'+__("No cover image available")+'</span>');
318
            } else if ((this.complete != null) && (!this.complete)) {
319
                $(this).parent().html('<span class="no-image">'+__("No cover image available")+'</span>');
320
            }
321
        }
322
    });
323
}
324
325
function toggleBatchOp( b ){
421
function toggleBatchOp( b ){
326
    var results_batch_ops = $("#results_batch_ops");
422
    var results_batch_ops = $("#results_batch_ops");
327
    if( b ){
423
    if( b ){
Lines 336-342 function resultsBatchProcess( op ){ Link Here
336
    var params = [];
432
    var params = [];
337
    var url = "";
433
    var url = "";
338
    if( op == "edit" ){
434
    if( op == "edit" ){
339
        // batch edit selected records
435
        /* batch edit selected records */
340
        if ( selected.length < 1 ){
436
        if ( selected.length < 1 ){
341
            alert( __("You must select at least one record") );
437
            alert( __("You must select at least one record") );
342
        } else {
438
        } else {
Lines 347-353 function resultsBatchProcess( op ){ Link Here
347
            location.href = url;
443
            location.href = url;
348
        }
444
        }
349
    } else if( op == "delete" ){
445
    } else if( op == "delete" ){
350
        // batch delete selected records
446
        /* batch delete selected records */
351
        if ( selected.length < 1) {
447
        if ( selected.length < 1) {
352
            alert( __("You must select at least one record") );
448
            alert( __("You must select at least one record") );
353
        } else {
449
        } else {
Lines 358-364 function resultsBatchProcess( op ){ Link Here
358
            location.href = url;
454
            location.href = url;
359
        }
455
        }
360
    } else if( op == "merge" ){
456
    } else if( op == "merge" ){
361
        // merge selected records
457
        /* merge selected records */
362
        if ( selected.length < 2) {
458
        if ( selected.length < 2) {
363
            alert( __("At least two records must be selected for merging") );
459
            alert( __("At least two records must be selected for merging") );
364
        } else {
460
        } else {
365
- 

Return to bug 25846