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 (-1 / +38 lines)
Lines 4-10 Link Here
4
::selection {
4
::selection {
5
    background: #538200;
5
    background: #538200;
6
    color: #FFFFFF;
6
    color: #FFFFFF;
7
}
7
} 
8
8
9
a {
9
a {
10
    &:link,
10
    &:link,
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 136-171 Link Here
136
        [% END %]
136
        [% END %]
137
137
138
        [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
138
        [% IF ( AmazonCoverImages  || LocalCoverImages || AdlibrisEnabled || IntranetCoce || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
139
        </div><div class="col-xs-3" id="bookcoverimg">
139
            </div>
140
        [% IF ( LocalCoverImages ) %]
140
            <div class="col-xs-3" id="bookcoverimg">
141
            <div title="[% biblionumber |url %]" class="[% biblionumber | html %]" id="local-thumbnail-preview"></div>
141
                <div id="cover-slides">
142
        [% END %]
142
                    [% IF ( LocalCoverImages ) %]
143
        [% IF ( AdlibrisEnabled && normalized_isbn ) %]
143
                        [% IF ( localimages.0 ) %]
144
            <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>
144
                            [% FOREACH image IN localimages %]
145
        [% END %]
145
                                [% IF image %]
146
        [% IF ( AmazonCoverImages && normalized_isbn) %]
146
                                    <div class="cover-image local-coverimg">
147
            <div id="amazon-bookcoverimg">
147
                                        <a href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | uri %]&amp;imagenumber=[% image | uri %]">
148
            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
148
                                            <img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=[% image | uri %]" alt="Local cover image" />
149
                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="" />
149
                                        </a>
150
        </a></div>
150
                                        <div class="hint">Local cover image</div>
151
        [% END %]
151
                                    </div>
152
        [% IF ( IntranetCoce && CoceProviders ) %]
152
                                [% END %]
153
          [% coce_id = normalized_ean || normalized_isbn %]
153
                            [% END %]
154
            <a class="p1" href="/cgi-bin/koha/catalogue/[% DetailPage | html %]?biblionumber=[% biblionumber | url %]">
154
                        [% END %]
155
          [% IF ( coce_id ) %]
155
                    [% END %]
156
            <span style="block" title="[% biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail-preview"></span>
157
          [% ELSE %]
158
            <span class="no-image">No cover image available</span>
159
          [% END %]
160
            </a>
161
        [% END %]
162
156
163
        [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
157
                    [% IF ( AdlibrisEnabled && normalized_isbn ) %]
164
            <a class="custom_cover_image" href="[% biblio.custom_cover_image_url | url %]"><img alt="Cover image" src="[% biblio.custom_cover_image_url | url %]" /></a>
158
                        <div class="cover-image" id="adlibris-coverimg">
165
        [% END %]
159
                            <a href="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]">
166
        [% END %]
160
                                <img src="[% AdlibrisURL | url %]?isbn=[% normalized_isbn | uri %]" class="adlibris-cover-big" alt="Adlibris cover image" />
161
                            </a>
162
                            <div class="hint">Image from Adlibris</div>
163
                        </div>
164
                    [% END %]
165
                    [% IF ( AmazonCoverImages && normalized_isbn) %]
166
                        <div class="cover-image" id="amazon-bookcoverimg">
167
                            <a href="http://www.amazon[% AmazonTld | uri %]/gp/reader/[% normalized_isbn | uri %][% AmazonAssocTag | uri %]#reader-link">
168
                                <img src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn | html %].01.MZZZZZZZ.jpg" alt="Amazon cover image" />
169
                            </a>
170
                            <div class="hint">Image from Amazon.com</div>
171
                        </div>
172
                    [% END %]
173
                    [% IF ( IntranetCoce && CoceProviders && normalized_isbn ) %]
174
                        [% coce_id = normalized_ean || normalized_isbn %]
175
                        <div class="cover-image" id="coce-coverimg">
176
                            [% IF ( coce_id ) %]
177
                                <span title="[% biblionumber | url %]" class="[% coce_id | html %]" id="coce-thumbnail-preview"></span>
178
                            [% ELSE %]
179
                                <span class="no-image">No cover image available</span>
180
                            [% END %]
181
                            <div class="hint">Image from Coce</div>
182
                        </div>
183
                    [% END %]
167
184
168
</div>
185
                    [% IF Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
186
                        <div class="cover-image" id="custom-coverimg">
187
                            <a class="custom_cover_image" href="[% biblio.custom_cover_image_url | url %]">
188
                                <img id="custom-img" alt="Custom cover image" src="[% biblio.custom_cover_image_url | url %]" />
189
                            </a>
190
                            <div class="hint">Custom cover image</div>
191
                        </div>
192
                    [% END %]
193
                </div>
194
            </div> <!-- /#bookcoverimg -->
195
        [% END %]
169
</div>
196
</div>
170
<div id="bibliodetails" class="toptabs">
197
<div id="bibliodetails" class="toptabs">
171
198
Lines 825-854 Note that permanent location is a code, and location may be an authval. Link Here
825
        var theme = "[% theme | html %]";
852
        var theme = "[% theme | html %]";
826
        // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
853
        // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
827
        function verify_images() {
854
        function verify_images() {
828
            $("#bookcoverimg").each(function(i){
855
            // Loop over each container in the template which contains covers
829
                $(this).find('img').each(function(i){
856
            var coverSlides = $(".cover-image");
830
                   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'))) {
857
            coverSlides.each( function( index ){
831
                        w = this.width;
858
                var div = $(this);
832
                        h = this.height;
859
                // Find the image in the container
833
                        if ((w == 1) || (h == 1)) {
860
                var img = div.find("img")[0];
834
                            $("#amazon-bookcoverimg").remove();
861
                if( $(img).length > 0 ){
835
                        } else if ((this.complete != null) && (!this.complete)) {
862
                    if( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ){
836
                            $("#amazon-bookcoverimg").remove();
863
                        // No image loaded in the container. Remove the slide
864
                        div.remove();
865
                    } else {
866
                        // All slides start hidden. If this is the first one, show it.
867
                        if( index == 0 ){
868
                            div.show();
869
                        }
870
                        // Check if Amazon image is present
871
                        if ( div.attr("id") == "amazon-bookcoverimg"  ) {
872
                            w = img.width;
873
                            h = img.height;
874
                            if ((w == 1) || (h == 1)) {
875
                                // Amazon returned single-pixel placeholder
876
                                // Remove the container
877
                                div.remove();
878
                            }
879
                        }
880
                        if( div.attr("id") == "custom-img" ){
881
                            if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) {
882
                                // No image was loaded via the CustomCoverImages system preference
883
                                // Remove the container
884
                                div.remove();
885
                            }
886
                        }
887
                        if( div.attr("id") == "coce-coverimg" ){
888
                            // Identify which service's image is being loaded by Coce
889
                            if( $(img).attr("src").indexOf('amazon.com') >= 0 ){
890
                                div.find(".hint").html(_("Coce image from Amazon.com"));
891
                            } else if( $(img).attr("src").indexOf('google.com') >= 0 ){
892
                                div.find(".hint").html(_("Coce image from Google Books"));
893
                            } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){
894
                                div.find(".hint").html(_("Coce image from Open Library"));
895
                            }
896
                        }
897
                        // If more that one slide is present, add a navigation link
898
                        // for activating the slide
899
                        if( coverSlides.length > 1 ){
900
                            var covernav = $("<a href=\"#\" data-num=\"" + index + "\" class=\"cover-nav\"></a>");
901
                            if( index == 0 ){
902
                                // Set the first navigation link as active
903
                                $(covernav).addClass("nav-active");
904
                            }
905
                            $(covernav).html("<i class=\"fa fa-circle\"></i>");
906
                            $("#cover-slides").append( covernav );
837
                        }
907
                        }
838
                    }
908
                    }
839
                });
840
                if( $(this).find('img').length < 1 ){
841
                    $(this).remove();
842
                    $("#catalogue_detail_biblio").attr("class","col-xs-12");
843
                }
909
                }
844
            });
910
            });
911
            if( $(".cover-image:visible").length < 1 ){
912
                $("#cover-slides").remove();
913
            }
914
845
            $("#editions img").each(function(i){
915
            $("#editions img").each(function(i){
846
                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'))) {
916
                if ( this.src.indexOf('amazon.com') >= 0 ) {
847
                    w = this.width;
917
                    w = this.width;
848
                    h = this.height;
918
                    h = this.height;
849
                    if ((w == 1) || (h == 1)) {
919
                    if ((w == 1) || (h == 1)) {
850
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
920
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
851
                    } else if ((this.complete != null) && (!this.complete)) {
921
                    } else if ( (this.complete != null) && (!this.complete) || this.naturalHeight == 0 ) {
852
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
922
                        this.src = 'https://images-na.ssl-images-amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
853
                    }
923
                    }
854
                }
924
                }
Lines 981-990 Note that permanent location is a code, and location may be an authval. Link Here
981
1051
982
                return false;
1052
                return false;
983
            });
1053
            });
984
            [%# inject no images message %]
985
            [% IF LocalCoverImages %]
986
                KOHA.LocalCover.GetCoverFromBibnumber(true);
987
            [% END %]
988
            [% IF ( IntranetCoce && CoceProviders ) %]
1054
            [% IF ( IntranetCoce && CoceProviders ) %]
989
                KOHA.coce.getURL('[% CoceHost | html %]', '[% CoceProviders | html %]');
1055
                KOHA.coce.getURL('[% CoceHost | html %]', '[% CoceProviders | html %]');
990
            [% END %]
1056
            [% END %]
Lines 1017-1027 Note that permanent location is a code, and location may be an authval. Link Here
1017
                link = $(this).attr("href");
1083
                link = $(this).attr("href");
1018
                openWindow(link,"Print spine label",400,400);
1084
                openWindow(link,"Print spine label",400,400);
1019
             });
1085
             });
1086
             $("#cover-slides").on("click",".cover-nav", function(){
1087
                // Adding click handler for cover image navigation links
1088
                var num = $(this).data("num");
1089
                $(".cover-nav").removeClass("nav-active");
1090
                $(this).addClass("nav-active");
1091
                $(".cover-image").hide();
1092
                $(".cover-image").eq( num ).show();
1093
             });
1020
        });
1094
        });
1021
1095
1022
        [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() {
1096
        $(window).load(function() {
1023
            verify_images();
1097
            verify_images();
1024
        });[% END %]
1098
        });
1025
    </script>
1099
    </script>
1026
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1100
    [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %]
1027
        <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script>
1101
        <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