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 2095-2100 li { Link Here
2095
    }
2095
    }
2096
}
2096
}
2097
2097
2098
#cover-slides {
2099
    background: #FFF url("[% interface | html %]/[% theme | html %]/img/spinner-small.gif") center center no-repeat;
2100
    border: 1px solid #b9d8d9;
2101
    border-radius: 3px;
2102
    margin: 5px;
2103
    padding: 10px 5px 5px 5px;
2104
    min-height: 175px;
2105
2106
    .hint {
2107
        font-size: 90%;
2108
        padding: .5em 0;
2109
    }
2110
2111
    a {
2112
        &.nav-active {
2113
            &:link,
2114
            &:visited {
2115
                color: #85ca11;
2116
            }
2117
        }
2118
    }
2119
}
2120
2121
.cover-image {
2122
    display: none;
2123
2124
    img {
2125
        height: auto;
2126
        max-width: 100%;
2127
    }
2128
}
2129
2130
.cover-nav {
2131
    display: inline-block;
2132
    padding: 3px 4px;
2133
}
2134
2098
.searchhighlightblob {
2135
.searchhighlightblob {
2099
    font-size: 75%;
2136
    font-size: 75%;
2100
    font-style: italic;
2137
    font-style: italic;
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc (-4 lines)
Lines 60-69 Link Here
60
60
61
[% IF LocalCoverImages %]
61
[% IF LocalCoverImages %]
62
    [% Asset.js("js/localcovers.js") | $raw %]
62
    [% Asset.js("js/localcovers.js") | $raw %]
63
    <script>
64
        // LocalCoverImages
65
        var NO_LOCAL_JACKET = _("No cover image available");
66
    </script>
67
[% END %]
63
[% END %]
68
64
69
[% IF Koha.Preference('AudioAlerts') || AudioAlertsPage %]
65
[% IF Koha.Preference('AudioAlerts') || AudioAlertsPage %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt (-49 / +123 lines)
Lines 138-173 Link Here
138
        [% END %]
138
        [% END %]
139
139
140
        [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
140
        [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
141
        </div><div class="col-xs-3" id="bookcoverimg">
141
            </div>
142
        [% IF ( LocalCoverImages ) %]
142
            <div class="col-xs-3" id="bookcoverimg">
143
            <div title="[% biblionumber |url %]" class="[% biblionumber | html %]" id="local-thumbnail-preview"></div>
143
                <div id="cover-slides">
144
        [% END %]
144
                    [% IF ( LocalCoverImages ) %]
145
        [% IF ( AdlibrisEnabled && normalized_isbn ) %]
145
                        [% IF ( localimages.0 ) %]
146
            <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>
146
                            [% FOREACH image IN localimages %]
147
        [% END %]
147
                                [% IF image %]
148
        [% IF ( AmazonCoverImages && normalized_isbn) %]
148
                                    <div class="cover-image local-coverimg">
149
            <div id="amazon-bookcoverimg">
149
                                        <a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | uri %]&amp;imagenumber=[% image | uri %]">
150
            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
150
                                            <img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image | uri %]" alt="Local cover image" />
151
                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="" />
151
                                        </a>
152
        </a></div>
152
                                        <div class="hint">Local cover image</div>
153
        [% END %]
153
                                    </div>
154
        [% IF ( IntranetCoce && CoceProviders ) %]
154
                                [% END %]
155
          [% coce_id = normalized_ean || normalized_isbn %]
155
                            [% END %]
156
            <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% biblionumber | url %]">
156
                        [% END %]
157
          [% IF ( coce_id ) %]
157
                    [% END %]
158
            <span style="block" title="[% biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail-preview"></span>
159
          [% ELSE %]
160
            <span class="no-image">No cover image available</span>
161
          [% END %]
162
            </a>
163
        [% END %]
164
158
165
        [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
159
                    [% IF ( AdlibrisEnabled && normalized_isbn ) %]
166
            <a class="custom_cover_image" href="[% biblio.custom_cover_image_url | url %]"><img alt="Cover image" src="[% biblio.custom_cover_image_url | url %]" /></a>
160
                        <div class="cover-image" id="adlibris-coverimg">
167
        [% END %]
161
                            <a href="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]">
168
        [% END %]
162
                                <img src="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]" class="adlibris-cover-big" alt="Adlibris cover image" />
163
                            </a>
164
                            <div class="hint">Image from Adlibris</div>
165
                        </div>
166
                    [% END %]
167
                    [% IF ( AmazonCoverImages && normalized_isbn) %]
168
                        <div class="cover-image" id="amazon-bookcoverimg">
169
                            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
170
                                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="Amazon cover image" />
171
                            </a>
172
                            <div class="hint">Image from Amazon.com</div>
173
                        </div>
174
                    [% END %]
175
                    [% IF ( IntranetCoce && CoceProviders && normalized_isbn ) %]
176
                        [% coce_id = normalized_ean || normalized_isbn %]
177
                        <div class="cover-image" id="coce-coverimg">
178
                            [% IF ( coce_id ) %]
179
                                <span title="[% biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail-preview"></span>
180
                            [% ELSE %]
181
                                <span class="no-image">No cover image available</span>
182
                            [% END %]
183
                            <div class="hint">Image from Coce</div>
184
                        </div>
185
                    [% END %]
169
186
170
</div>
187
                    [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
188
                        <div class="cover-image" id="custom-coverimg">
189
                            <a class="custom_cover_image" href="[% biblio.custom_cover_image_url | url %]">
190
                                <img id="custom-img" alt="Custom cover image" src="[% biblio.custom_cover_image_url | url %]" />
191
                            </a>
192
                            <div class="hint">Custom cover image</div>
193
                        </div>
194
                    [% END %]
195
                </div>
196
            </div> <!-- /#bookcoverimg -->
197
        [% END %]
171
</div>
198
</div>
172
<div id="bibliodetails" class="toptabs">
199
<div id="bibliodetails" class="toptabs">
173
200
Lines 908-937 Note that permanent location is a code, and location may be an authval. Link Here
908
        var theme = "[% theme | html %]";
935
        var theme = "[% theme | html %]";
909
        // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
936
        // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
910
        function verify_images() {
937
        function verify_images() {
911
            $("#bookcoverimg").each(function(i){
938
            // Loop over each container in the template which contains covers
912
                $(this).find('img').each(function(i){
939
            var coverSlides = $(".cover-image");
913
                   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'))) {
940
            coverSlides.each( function( index ){
914
                        w = this.width;
941
                var div = $(this);
915
                        h = this.height;
942
                // Find the image in the container
916
                        if ((w == 1) || (h == 1)) {
943
                var img = div.find("img")[0];
917
                            $("#amazon-bookcoverimg").remove();
944
                if( $(img).length > 0 ){
918
                        } else if ((this.complete != null) && (!this.complete)) {
945
                    if( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ){
919
                            $("#amazon-bookcoverimg").remove();
946
                        // No image loaded in the container. Remove the slide
947
                        div.remove();
948
                    } else {
949
                        // All slides start hidden. If this is the first one, show it.
950
                        if( index == 0 ){
951
                            div.show();
952
                        }
953
                        // Check if Amazon image is present
954
                        if ( div.attr("id") == "amazon-bookcoverimg"  ) {
955
                            w = img.width;
956
                            h = img.height;
957
                            if ((w == 1) || (h == 1)) {
958
                                // Amazon returned single-pixel placeholder
959
                                // Remove the container
960
                                div.remove();
961
                            }
962
                        }
963
                        if( div.attr("id") == "custom-img" ){
964
                            if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) {
965
                                // No image was loaded via the CustomCoverImages system preference
966
                                // Remove the container
967
                                div.remove();
968
                            }
969
                        }
970
                        if( div.attr("id") == "coce-coverimg" ){
971
                            // Identify which service's image is being loaded by Coce
972
                            if( $(img).attr("src").indexOf('amazon.com') >= 0 ){
973
                                div.find(".hint").html(_("Coce image from Amazon.com"));
974
                            } else if( $(img).attr("src").indexOf('google.com') >= 0 ){
975
                                div.find(".hint").html(_("Coce image from Google Books"));
976
                            } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){
977
                                div.find(".hint").html(_("Coce image from Open Library"));
978
                            }
979
                        }
980
                        // If more that one slide is present, add a navigation link
981
                        // for activating the slide
982
                        if( coverSlides.length > 1 ){
983
                            var covernav = $("<a href=\"#\" data-num=\"" + index + "\" class=\"cover-nav\"></a>");
984
                            if( index == 0 ){
985
                                // Set the first navigation link as active
986
                                $(covernav).addClass("nav-active");
987
                            }
988
                            $(covernav).html("<i class=\"fa fa-circle\"></i>");
989
                            $("#cover-slides").append( covernav );
920
                        }
990
                        }
921
                    }
991
                    }
922
                });
923
                if( $(this).find('img').length < 1 ){
924
                    $(this).remove();
925
                    $("#catalogue_detail_biblio").attr("class","col-xs-12");
926
                }
992
                }
927
            });
993
            });
994
            if( $(".cover-image:visible").length < 1 ){
995
                $("#cover-slides").remove();
996
            }
997
928
            $("#editions img").each(function(i){
998
            $("#editions img").each(function(i){
929
                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'))) {
999
                if ( this.src.indexOf('amazon.com') >= 0 ) {
930
                    w = this.width;
1000
                    w = this.width;
931
                    h = this.height;
1001
                    h = this.height;
932
                    if ((w == 1) || (h == 1)) {
1002
                    if ((w == 1) || (h == 1)) {
933
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
1003
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
934
                    } else if ((this.complete != null) && (!this.complete)) {
1004
                    } else if ( (this.complete != null) && (!this.complete) || this.naturalHeight == 0 ) {
935
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
1005
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
936
                    }
1006
                    }
937
                }
1007
                }
Lines 1064-1073 Note that permanent location is a code, and location may be an authval. Link Here
1064
1134
1065
                return false;
1135
                return false;
1066
            });
1136
            });
1067
            [%# inject no images message %]
1068
            [% IF LocalCoverImages %]
1069
                KOHA.LocalCover.GetCoverFromBibnumber(true);
1070
            [% END %]
1071
            [% IF ( IntranetCoce && CoceProviders ) %]
1137
            [% IF ( IntranetCoce && CoceProviders ) %]
1072
                KOHA.coce.getURL('[% CoceHost | html %]', '[% CoceProviders | html %]');
1138
                KOHA.coce.getURL('[% CoceHost | html %]', '[% CoceProviders | html %]');
1073
            [% END %]
1139
            [% END %]
Lines 1100-1110 Note that permanent location is a code, and location may be an authval. Link Here
1100
                link = $(this).attr("href");
1166
                link = $(this).attr("href");
1101
                openWindow(link,"Print spine label",400,400);
1167
                openWindow(link,"Print spine label",400,400);
1102
             });
1168
             });
1169
             $("#cover-slides").on("click",".cover-nav", function(){
1170
                // Adding click handler for cover image navigation links
1171
                var num = $(this).data("num");
1172
                $(".cover-nav").removeClass("nav-active");
1173
                $(this).addClass("nav-active");
1174
                $(".cover-image").hide();
1175
                $(".cover-image").eq( num ).show();
1176
             });
1103
        });
1177
        });
1104
1178
1105
        [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() {
1179
        $(window).load(function() {
1106
            verify_images();
1180
            verify_images();
1107
        });[% END %]
1181
        });
1108
    </script>
1182
    </script>
1109
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1183
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1110
        <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
1184
        <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