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

(-)a/koha-tmpl/intranet-tmpl/js/coce.js (-39 / +39 lines)
Lines 6-50 if (KOHA === undefined || !KOHA) { var KOHA = {}; } Link Here
6
 */
6
 */
7
KOHA.coce = {
7
KOHA.coce = {
8
8
9
  /**
9
    /**
10
   * Search all:
10
     * Search all:
11
   *    <div title="biblionumber" id="isbn" class="coce-thumbnail"></div>
11
     *    <div title="biblionumber" id="isbn" class="coce-thumbnail"></div>
12
   * or
12
     * or
13
   *    <div title="biblionumber" id="isbn" class="coce-thumbnail-preview"></div>
13
     *    <div title="biblionumber" id="isbn" class="coce-thumbnail-preview"></div>
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, newWindow) {
18
    var ids = [];
18
        var ids = [];
19
    $("[id^=coce-thumbnail]").each(function(i) {
19
        $("[id^=coce-thumbnail]").each(function(i) {
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
        });
23
    if (ids.length == 0) return;
23
        if (ids.length == 0) return;
24
    ids = ids.join(',');
24
        ids = ids.join(',');
25
    var coceURL = host + '/cover?id=' + ids + '&provider=' + provider;
25
        var coceURL = host + '/cover?id=' + ids + '&provider=' + provider;
26
    $.ajax({
26
        $.ajax({
27
      url: coceURL,
27
            url: coceURL,
28
      dataType: 'jsonp',
28
            dataType: 'jsonp',
29
      success: function(urlPerID){
29
            success: function(urlPerID) {
30
        for (var id in urlPerID) {
30
                for (var id in urlPerID) {
31
          var url = urlPerID[id];
31
                    var url = urlPerID[id];
32
          $("[id^=coce-thumbnail]."+id).each(function() {
32
                    $("[id^=coce-thumbnail]." + id).each(function() {
33
            var img = document.createElement("img");
33
                        var img = document.createElement("img");
34
            img.src = url;
34
                        img.src = url;
35
            img.classList.add("thumbnail");
35
                        img.alt = "Cover image";
36
            img.alt = "Cover image";
36
                        img.onload = function() {
37
            img.onload = function(){
37
                            // image dimensions can't be known until image has loaded
38
                // image dimensions can't be known until image has loaded
38
                            if (img.height == 1 && img.width == 1) {
39
                if( img.height == 1 && img.width == 1 ){
39
                                $(this).remove();
40
                    $(this).remove();
40
                            }
41
                        };
42
                        $(this).html(img);
43
                    });
41
                }
44
                }
42
            }
45
            },
43
            $(this).html(img);
46
44
         });
47
        });
45
        }
48
    }
46
      }
47
    });
48
  }
49
49
50
};
50
};
(-)a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss (+37 lines)
Lines 2091-2096 li { Link Here
2091
    }
2091
    }
2092
}
2092
}
2093
2093
2094
#cover-slides {
2095
    background: #FFF url("[% interface | html %]/[% theme | html %]/img/spinner-small.gif") center center no-repeat;
2096
    border: 1px solid #b9d8d9;
2097
    border-radius: 3px;
2098
    margin: 5px;
2099
    padding: 10px 5px 5px 5px;
2100
    min-height: 175px;
2101
2102
    .hint {
2103
        font-size: 90%;
2104
        padding: .5em 0;
2105
    }
2106
2107
    a {
2108
        &.nav-active {
2109
            &:link,
2110
            &:visited {
2111
                color: #85ca11;
2112
            }
2113
        }
2114
    }
2115
}
2116
2117
.cover-image {
2118
    display: none;
2119
2120
    img {
2121
        height: auto;
2122
        max-width: 100%;
2123
    }
2124
}
2125
2126
.cover-nav {
2127
    display: inline-block;
2128
    padding: 3px 4px;
2129
}
2130
2094
.searchhighlightblob {
2131
.searchhighlightblob {
2095
    font-size: 75%;
2132
    font-size: 75%;
2096
    font-style: italic;
2133
    font-style: italic;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (-3 lines)
Lines 57-65 Link Here
57
57
58
[% IF LocalCoverImages %]
58
[% IF LocalCoverImages %]
59
    [% Asset.js("js/localcovers.js") | $raw %]
59
    [% Asset.js("js/localcovers.js") | $raw %]
60
    <script>
61
        var NO_LOCAL_JACKET = _("No cover image available");
62
    </script>
63
[% END %]
60
[% END %]
64
61
65
[% IF Koha.Preference('AudioAlerts') || AudioAlertsPage %]
62
[% IF Koha.Preference('AudioAlerts') || AudioAlertsPage %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-49 / +123 lines)
Lines 137-172 Link Here
137
        [% END %]
137
        [% END %]
138
138
139
        [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
139
        [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
140
        </div><div class="col-xs-3" id="bookcoverimg">
140
            </div>
141
        [% IF ( LocalCoverImages ) %]
141
            <div class="col-xs-3" id="bookcoverimg">
142
            <div title="[% biblionumber |url %]" class="[% biblionumber | html %]" id="local-thumbnail-preview"></div>
142
                <div id="cover-slides">
143
        [% END %]
143
                    [% IF ( LocalCoverImages ) %]
144
        [% IF ( AdlibrisEnabled && normalized_isbn ) %]
144
                        [% IF ( localimages.0 ) %]
145
            <a href="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]"><img src="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]" class="adlibris-cover-big" alt="Adlibris cover image" /></a>
145
                            [% FOREACH image IN localimages %]
146
        [% END %]
146
                                [% IF image %]
147
        [% IF ( AmazonCoverImages && normalized_isbn) %]
147
                                    <div class="cover-image local-coverimg">
148
            <div id="amazon-bookcoverimg">
148
                                        <a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | uri %]&amp;imagenumber=[% image | uri %]">
149
            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
149
                                            <img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image | uri %]" alt="Local cover image" />
150
                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="" />
150
                                        </a>
151
        </a></div>
151
                                        <div class="hint">Local cover image</div>
152
        [% END %]
152
                                    </div>
153
        [% IF ( IntranetCoce && CoceProviders ) %]
153
                                [% END %]
154
          [% coce_id = normalized_ean || normalized_isbn %]
154
                            [% END %]
155
            <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% biblionumber | url %]">
155
                        [% END %]
156
          [% IF ( coce_id ) %]
156
                    [% END %]
157
            <span style="block" title="[% biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail-preview"></span>
158
          [% ELSE %]
159
            <span class="no-image">No cover image available</span>
160
          [% END %]
161
            </a>
162
        [% END %]
163
157
164
        [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
158
                    [% IF ( AdlibrisEnabled && normalized_isbn ) %]
165
            <a class="custom_cover_image" href="[% biblio.custom_cover_image_url | url %]"><img alt="Cover image" src="[% biblio.custom_cover_image_url | url %]" /></a>
159
                        <div class="cover-image" id="adlibris-coverimg">
166
        [% END %]
160
                            <a href="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]">
167
        [% END %]
161
                                <img src="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]" class="adlibris-cover-big" alt="Adlibris cover image" />
162
                            </a>
163
                            <div class="hint">Image from Adlibris</div>
164
                        </div>
165
                    [% END %]
166
                    [% IF ( AmazonCoverImages && normalized_isbn) %]
167
                        <div class="cover-image" id="amazon-bookcoverimg">
168
                            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
169
                                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="Amazon cover image" />
170
                            </a>
171
                            <div class="hint">Image from Amazon.com</div>
172
                        </div>
173
                    [% END %]
174
                    [% IF ( IntranetCoce && CoceProviders && normalized_isbn ) %]
175
                        [% coce_id = normalized_ean || normalized_isbn %]
176
                        <div class="cover-image" id="coce-coverimg">
177
                            [% IF ( coce_id ) %]
178
                                <span title="[% biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail-preview"></span>
179
                            [% ELSE %]
180
                                <span class="no-image">No cover image available</span>
181
                            [% END %]
182
                            <div class="hint">Image from Coce</div>
183
                        </div>
184
                    [% END %]
168
185
169
</div>
186
                    [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
187
                        <div class="cover-image" id="custom-coverimg">
188
                            <a class="custom_cover_image" href="[% biblio.custom_cover_image_url | url %]">
189
                                <img id="custom-img" alt="Custom cover image" src="[% biblio.custom_cover_image_url | url %]" />
190
                            </a>
191
                            <div class="hint">Custom cover image</div>
192
                        </div>
193
                    [% END %]
194
                </div>
195
            </div> <!-- /#bookcoverimg -->
196
        [% END %]
170
</div>
197
</div>
171
<div id="bibliodetails" class="toptabs">
198
<div id="bibliodetails" class="toptabs">
172
199
Lines 901-930 Note that permanent location is a code, and location may be an authval. Link Here
901
        var theme = "[% theme | html %]";
928
        var theme = "[% theme | html %]";
902
        // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
929
        // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
903
        function verify_images() {
930
        function verify_images() {
904
            $("#bookcoverimg").each(function(i){
931
            // Loop over each container in the template which contains covers
905
                $(this).find('img').each(function(i){
932
            var coverSlides = $(".cover-image");
906
                   if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('images-na.ssl-images-amazon.com'))) {
933
            coverSlides.each( function( index ){
907
                        w = this.width;
934
                var div = $(this);
908
                        h = this.height;
935
                // Find the image in the container
909
                        if ((w == 1) || (h == 1)) {
936
                var img = div.find("img")[0];
910
                            $("#amazon-bookcoverimg").remove();
937
                if( $(img).length > 0 ){
911
                        } else if ((this.complete != null) && (!this.complete)) {
938
                    if( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ){
912
                            $("#amazon-bookcoverimg").remove();
939
                        // No image loaded in the container. Remove the slide
940
                        div.remove();
941
                    } else {
942
                        // All slides start hidden. If this is the first one, show it.
943
                        if( index == 0 ){
944
                            div.show();
945
                        }
946
                        // Check if Amazon image is present
947
                        if ( div.attr("id") == "amazon-bookcoverimg"  ) {
948
                            w = img.width;
949
                            h = img.height;
950
                            if ((w == 1) || (h == 1)) {
951
                                // Amazon returned single-pixel placeholder
952
                                // Remove the container
953
                                div.remove();
954
                            }
955
                        }
956
                        if( div.attr("id") == "custom-img" ){
957
                            if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) {
958
                                // No image was loaded via the CustomCoverImages system preference
959
                                // Remove the container
960
                                div.remove();
961
                            }
962
                        }
963
                        if( div.attr("id") == "coce-coverimg" ){
964
                            // Identify which service's image is being loaded by Coce
965
                            if( $(img).attr("src").indexOf('amazon.com') >= 0 ){
966
                                div.find(".hint").html(_("Coce image from Amazon.com"));
967
                            } else if( $(img).attr("src").indexOf('google.com') >= 0 ){
968
                                div.find(".hint").html(_("Coce image from Google Books"));
969
                            } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){
970
                                div.find(".hint").html(_("Coce image from Open Library"));
971
                            }
972
                        }
973
                        // If more that one slide is present, add a navigation link
974
                        // for activating the slide
975
                        if( coverSlides.length > 1 ){
976
                            var covernav = $("<a href=\"#\" data-num=\"" + index + "\" class=\"cover-nav\"></a>");
977
                            if( index == 0 ){
978
                                // Set the first navigation link as active
979
                                $(covernav).addClass("nav-active");
980
                            }
981
                            $(covernav).html("<i class=\"fa fa-circle\"></i>");
982
                            $("#cover-slides").append( covernav );
913
                        }
983
                        }
914
                    }
984
                    }
915
                });
916
                if( $(this).find('img').length < 1 ){
917
                    $(this).remove();
918
                    $("#catalogue_detail_biblio").attr("class","col-xs-12");
919
                }
985
                }
920
            });
986
            });
987
            if( $(".cover-image:visible").length < 1 ){
988
                $("#cover-slides").remove();
989
            }
990
921
            $("#editions img").each(function(i){
991
            $("#editions img").each(function(i){
922
                if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('images-na.ssl-images-amazon.com'))) {
992
                if ( this.src.indexOf('amazon.com') >= 0 ) {
923
                    w = this.width;
993
                    w = this.width;
924
                    h = this.height;
994
                    h = this.height;
925
                    if ((w == 1) || (h == 1)) {
995
                    if ((w == 1) || (h == 1)) {
926
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
996
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
927
                    } else if ((this.complete != null) && (!this.complete)) {
997
                    } else if ( (this.complete != null) && (!this.complete) || this.naturalHeight == 0 ) {
928
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
998
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
929
                    }
999
                    }
930
                }
1000
                }
Lines 1057-1066 Note that permanent location is a code, and location may be an authval. Link Here
1057
1127
1058
                return false;
1128
                return false;
1059
            });
1129
            });
1060
            [%# inject no images message %]
1061
            [% IF LocalCoverImages %]
1062
                KOHA.LocalCover.GetCoverFromBibnumber(true);
1063
            [% END %]
1064
            [% IF ( IntranetCoce && CoceProviders ) %]
1130
            [% IF ( IntranetCoce && CoceProviders ) %]
1065
                KOHA.coce.getURL('[% CoceHost | html %]', '[% CoceProviders | html %]');
1131
                KOHA.coce.getURL('[% CoceHost | html %]', '[% CoceProviders | html %]');
1066
            [% END %]
1132
            [% END %]
Lines 1093-1103 Note that permanent location is a code, and location may be an authval. Link Here
1093
                link = $(this).attr("href");
1159
                link = $(this).attr("href");
1094
                openWindow(link,"Print spine label",400,400);
1160
                openWindow(link,"Print spine label",400,400);
1095
             });
1161
             });
1162
             $("#cover-slides").on("click",".cover-nav", function(){
1163
                // Adding click handler for cover image navigation links
1164
                var num = $(this).data("num");
1165
                $(".cover-nav").removeClass("nav-active");
1166
                $(this).addClass("nav-active");
1167
                $(".cover-image").hide();
1168
                $(".cover-image").eq( num ).show();
1169
             });
1096
        });
1170
        });
1097
1171
1098
        [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() {
1172
        $(window).load(function() {
1099
            verify_images();
1173
            verify_images();
1100
        });[% END %]
1174
        });
1101
    </script>
1175
    </script>
1102
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1176
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1103
        <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
1177
        <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/localcovers.js (-31 / +20 lines)
Lines 1-3 Link Here
1
/* global _ */
2
1
if (typeof KOHA == "undefined" || !KOHA) {
3
if (typeof KOHA == "undefined" || !KOHA) {
2
    var KOHA = {};
4
    var KOHA = {};
3
}
5
}
Lines 18-59 KOHA.LocalCover = { Link Here
18
     * olCallBack().
20
     * olCallBack().
19
     */
21
     */
20
    GetCoverFromBibnumber: function(uselink) {
22
    GetCoverFromBibnumber: function(uselink) {
21
        $("div [id^=local-thumbnail]").each(function(i) {
23
        var mydiv = $("#local-thumbnail-preview");
22
            var mydiv = this;
24
        var biblionumber = mydiv.data("biblionumber");
23
            var message = document.createElement("span");
25
        var img = document.createElement("img");
24
            $(message).attr("class","no-image");
26
        img.src = "/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=" + biblionumber;
25
            $(message).html(NO_LOCAL_JACKET);
27
        img.onload = function() {
26
            $(mydiv).parent().find('.no-image').remove();
28
            // image dimensions can't be known until image has loaded
27
            $(mydiv).append(message);
29
            if ( (img.complete != null) && (!img.complete) ) {
28
            var img = $("<img />").attr('src',
30
                mydiv.remove();
29
                '/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
31
            }
30
                .load(function () {
32
        };
31
                    if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth <= 1) {
33
        if (uselink) {
32
                        //IE HACK
34
            var a = $("<a />").attr('href', '/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=' + $(mydiv).attr("class"));
33
                        try {
35
            $(a).append(img);
34
                            $(mydiv).remove();
36
            mydiv.append(a);
35
                        }
37
        } else {
36
                        catch(err){
38
            mydiv.append(img);
37
                        }
39
        }
38
                    } else {
39
                        if (uselink) {
40
                            var a = $("<a />").attr('href', '/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=' + $(mydiv).attr("class"));
41
                            $(a).append(img);
42
                            $(mydiv).append(a);
43
                        } else {
44
                            $(mydiv).append(img);
45
                        }
46
                        $(mydiv).children('.no-image').remove();
47
                    }
48
                });
49
        });
50
    },
40
    },
51
    LoadResultsCovers: function(){
41
    LoadResultsCovers: function(){
52
        $("div [id^=local-thumbnail]").each(function(i) {
42
        $("div [id^=local-thumbnail]").each(function(i) {
53
            var mydiv = this;
43
            var mydiv = this;
54
            var message = document.createElement("span");
44
            var message = document.createElement("span");
55
            $(message).attr("class","no-image thumbnail");
45
            $(message).attr("class","no-image thumbnail");
56
            $(message).html(NO_LOCAL_JACKET);
46
            $(message).html( _("No cover image available") );
57
            $(mydiv).append(message);
47
            $(mydiv).append(message);
58
            var img = $("<img />");
48
            var img = $("<img />");
59
            img.attr('src','/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
49
            img.attr('src','/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
60
- 

Return to bug 25031