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 2140-2146 li { Link Here
2140
}
2140
}
2141
2141
2142
.cover-slides {
2142
.cover-slides {
2143
    background: #FFF url("[% interface | html %]/[% theme | html %]/img/spinner-small.gif") center center no-repeat;
2143
    background: #FFF url("../img/spinner-small.gif") center center no-repeat;
2144
2144
2145
    .hint {
2145
    .hint {
2146
        font-size: 90%;
2146
        font-size: 90%;
Lines 2157-2162 li { Link Here
2157
    }
2157
    }
2158
}
2158
}
2159
2159
2160
td {
2161
    &.bookcoverimg {
2162
        background: #FFF url("../img/spinner-small.gif") center center no-repeat;
2163
        min-width: 120px;
2164
        text-align: center;
2165
    }
2166
    .cover-slides {
2167
        background: transparent none;
2168
        border: 0;
2169
        margin: 0;
2170
        min-height: unset;
2171
        padding: 0;
2172
    }
2173
}
2174
2160
.cover-image {
2175
.cover-image {
2161
    display: none;
2176
    display: none;
2162
2177
(-)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 holdfor_cardnumber holdforclub strQuery PREF_NotHighlightedWords __ */
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 holdfor_cardnumber holdforclub strQuery PREF_NotHighlightedWords __ */
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 303-323 function holdForClub() { Link Here
303
    placeHold();
414
    placeHold();
304
}
415
}
305
416
306
// http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
307
function verify_images() {
308
    $("img").each(function(){
309
        if ((this.src.indexOf('images-amazon.com') >= 0) || (this.src.indexOf('images.amazon.com') >=0)) {
310
            var w = this.width;
311
            var h = this.height;
312
            if ((w == 1) || (h == 1)) {
313
                $(this).parent().html('<span class="no-image">'+ __("No cover image available") +'</span>');
314
            } else if ((this.complete != null) && (!this.complete)) {
315
                $(this).parent().html('<span class="no-image">'+ __("No cover image available") +'</span>');
316
            }
317
        }
318
    });
319
}
320
321
function toggleBatchOp( b ){
417
function toggleBatchOp( b ){
322
    var results_batch_ops = $("#results_batch_ops");
418
    var results_batch_ops = $("#results_batch_ops");
323
    if( b ){
419
    if( b ){
Lines 332-338 function resultsBatchProcess( op ){ Link Here
332
    var params = [];
428
    var params = [];
333
    var url = "";
429
    var url = "";
334
    if( op == "edit" ){
430
    if( op == "edit" ){
335
        // batch edit selected records
431
        /* batch edit selected records */
336
        if ( selected.length < 1 ){
432
        if ( selected.length < 1 ){
337
            alert( __("You must select at least one record") );
433
            alert( __("You must select at least one record") );
338
        } else {
434
        } else {
Lines 343-349 function resultsBatchProcess( op ){ Link Here
343
            location.href = url;
439
            location.href = url;
344
        }
440
        }
345
    } else if( op == "delete" ){
441
    } else if( op == "delete" ){
346
        // batch delete selected records
442
        /* batch delete selected records */
347
        if ( selected.length < 1) {
443
        if ( selected.length < 1) {
348
            alert( __("You must select at least one record") );
444
            alert( __("You must select at least one record") );
349
        } else {
445
        } else {
Lines 354-360 function resultsBatchProcess( op ){ Link Here
354
            location.href = url;
450
            location.href = url;
355
        }
451
        }
356
    } else if( op == "merge" ){
452
    } else if( op == "merge" ){
357
        // merge selected records
453
        /* merge selected records */
358
        if ( selected.length < 2) {
454
        if ( selected.length < 2) {
359
            alert( __("At least two records must be selected for merging") );
455
            alert( __("At least two records must be selected for merging") );
360
        } else {
456
        } else {
361
- 

Return to bug 25846