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

(-)a/C4/External/OverDrive.pm (-1 / +1 lines)
Lines 122-128 sub GetOverDriveToken { Link Here
122
    $token = $contents->{'token_type'} . ' ' . $contents->{'access_token'};
122
    $token = $contents->{'token_type'} . ' ' . $contents->{'access_token'};
123
123
124
    # Fudge factor to prevent spurious failures
124
    # Fudge factor to prevent spurious failures
125
    $cache->set_in_cache( 'overdrive_token', $token, $contents->{'expires_in'} - 5 );
125
    $cache and $cache->set_in_cache( 'overdrive_token', $token, $contents->{'expires_in'} - 5 );
126
126
127
    return $token;
127
    return $token;
128
}
128
}
(-)a/koha-tmpl/opac-tmpl/ccsr/en/css/opac.css (-1 / +15 lines)
Lines 2841-2844 a.reviewlink,a.reviewlink:visited { Link Here
2841
2841
2842
.branch-info-tooltip {
2842
.branch-info-tooltip {
2843
    display: none;
2843
    display: none;
2844
}
2844
}
2845
2846
#overdrive-results {
2847
    font-weight: bold;
2848
    padding-left: 1em;
2849
}
2850
2851
.throbber {
2852
    vertical-align: middle;
2853
}
2854
2855
#overdrive-results-list .star-rating-control {
2856
    display: block;
2857
    overflow: auto;
2858
}
(-)a/koha-tmpl/opac-tmpl/prog/en/css/opac.css (+5 lines)
Lines 2976-2978 padding: 0.1em 0; Link Here
2976
.throbber {
2976
.throbber {
2977
    vertical-align: middle;
2977
    vertical-align: middle;
2978
}
2978
}
2979
2980
#overdrive-results-list .star-rating-control {
2981
    display: block;
2982
    overflow: auto;
2983
}
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-overdrive-search.tt (-17 / +27 lines)
Lines 2-7 Link Here
2
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]'
2
[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › OverDrive search for '[% q | html %]'
3
[% INCLUDE 'doc-head-close.inc' %]
3
[% INCLUDE 'doc-head-close.inc' %]
4
<script type="text/javascript" src="[% themelang %]/js/overdrive.js"></script>
4
<script type="text/javascript" src="[% themelang %]/js/overdrive.js"></script>
5
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.rating.js"></script>
6
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/jquery.rating.css" />
5
<script type="text/javascript">
7
<script type="text/javascript">
6
var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
8
var querystring = "[% q |replace( "'", "\'" ) |replace( '\n', '\\n' ) |replace( '\r', '\\r' ) |html %]";
7
var results_per_page = [% OPACnumSearchResults %];
9
var results_per_page = [% OPACnumSearchResults %];
Lines 9-15 var results_per_page = [% OPACnumSearchResults %]; Link Here
9
function fetch_availability( prod, $tr ) {
11
function fetch_availability( prod, $tr ) {
10
    var $availability_summary = $( '<span class="results_summary"></span>' );
12
    var $availability_summary = $( '<span class="results_summary"></span>' );
11
    $tr.find( '.info' ).append( $availability_summary );
13
    $tr.find( '.info' ).append( $availability_summary );
12
    $availability_summary.html( '<span class="label">Availability: </span> Loading...' );
14
    $availability_summary.html( '<span class="label">' + _("Availability:") + ' </span> ' + _("Loading...") );
13
15
14
    KOHA.OverDrive.Get(
16
    KOHA.OverDrive.Get(
15
        prod.links.availability.href,
17
        prod.links.availability.href,
Lines 17-50 function fetch_availability( prod, $tr ) { Link Here
17
        function ( data ) {
19
        function ( data ) {
18
            if ( data.error ) return;
20
            if ( data.error ) return;
19
21
20
            $availability_summary.html( '<span class="label">Copies available: </span><span class="available"><strong>' +  data.copiesAvailable + '</strong> out of ' + data.copiesOwned + '</span>' );
22
            $availability_summary.html( '<span class="label">' + _("Copies available:") + ' </span><span class="available"><strong>' +  data.copiesAvailable + '</strong> ' + _("out of") + ' ' + data.copiesOwned + '</span>' );
21
23
22
            if ( data.numberOfHolds ) {
24
            if ( data.numberOfHolds ) {
23
                $availability_summary.find( '.available' ).append( ', waiting holds: <strong>' + data.numberOfHolds + '</strong>' );
25
                $availability_summary.find( '.available' ).append( ', ' + _("waiting holds:") + ' <strong>' + data.numberOfHolds + '</strong>' );
24
            }
26
            }
25
27
26
            $tr.find( '.info' ).append( '<span class="results_summary actions"><span class="label">Actions: </span><a href="http://' + prod.contentDetails[0].href + '" ' + ( data.copiesAvailable ? ' class="addtocart">Check out' : ' class="hold">Place hold' ) + '</a></span>' );
28
            $tr.find( '.info' ).append( '<span class="results_summary actions"><span class="label">' + _("Actions:") + ' </span><a href="http://' + prod.contentDetails[0].href + '" ' + ( data.copiesAvailable ? ( ' class="addtocart">' + _("Check out") ) : ( ' class="hold">' + _("Place hold") ) ) + '</a></span>' );
27
        }
29
        }
28
    );
30
    );
29
}
31
}
30
32
31
function search( offset ) {
33
function search( offset ) {
32
    $( '#overdrive-status' ).html( 'Searching OverDrive... <img class="throbber" src="/opac-tmpl/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
34
    $( '#overdrive-status' ).html( _("Searching OverDrive...") + ' <img class="throbber" src="/opac-tmpl/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
33
35
34
    KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) {
36
    KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, results_per_page, offset, function( data ) {
35
        if ( data.error ) {
37
        if ( data.error ) {
36
            $( '#overdrive-status' ).html( '<strong class="unavailable">Error searching OverDrive collection.</strong>' );
38
            $( '#overdrive-status' ).html( '<strong class="unavailable">' + _("Error searching OverDrive collection.") + '</strong>' );
37
            return;
39
            return;
38
        }
40
        }
39
41
40
        if ( !data.totalItems ) {
42
        if ( !data.totalItems ) {
41
            $( '#overdrive-status' ).html( '<strong>No results found in the library\'s OverDrive collection.</strong>' );
43
            $( '#overdrive-status' ).html( '<strong>' + _("No results found in the library's OverDrive collection.") + '</strong>' );
42
            return;
44
            return;
43
        }
45
        }
44
46
45
        $( '#results tbody' ).empty();
47
        $( '#overdrive-results-list tbody' ).empty();
46
48
47
        $( '#overdrive-status' ).html( '<strong>Found ' + data.totalItems + ' results in the library\'s OverDrive collection.</strong>' );
49
        $( '#overdrive-status' ).html( '<strong>' + _("Found") + ' ' + data.totalItems + ' ' + _("results in the library's OverDrive collection.") + '</strong>' );
48
50
49
        for ( var i = 0; data.products[i]; i++ ) {
51
        for ( var i = 0; data.products[i]; i++ ) {
50
            var prod = data.products[i];
52
            var prod = data.products[i];
Lines 56-64 function search( offset ) { Link Here
56
            results.push( prod.title );
58
            results.push( prod.title );
57
            if ( prod.subtitle ) results.push( ', ', prod.subtitle );
59
            if ( prod.subtitle ) results.push( ', ', prod.subtitle );
58
            results.push( '</a>' );
60
            results.push( '</a>' );
59
            results.push( '<p>by ', prod.primaryCreator.name, '</p>' );
61
            results.push( '<p>' + _("by") + ' ', prod.primaryCreator.name, '</p>' );
60
            results.push( '<span class="results_summary"><span class="label">Type: </span>', prod.mediaType, '</span>' );
62
            if ( prod.starRating ) {
61
            if ( prod.starRating ) results.push( '<span class="results_summary"><span class="label">Average rating: <img src="[% themelang %]/../images/Star', Math.round( parseInt( prod.starRating )), '.gif" title="" style="max-height: 15px; vertical-align: bottom"/></span>' );
63
                results.push( '<span class="results_summary ratings">' );
64
                for ( var rating = 1; rating <= 5; rating++ ) {
65
                    results.push( '<input class="star" type="radio" name="rating-' + i + '" value="' + rating + '"' + ( rating == Math.round( prod.starRating ) ? ' checked="checked"' : '' ) + ' disabled="disabled" />' );
66
                }
67
                results.push( '</span>' );
68
            }
69
            results.push( '<span class="results_summary"><span class="label">' + _("Type:") + ' </span>', prod.mediaType, '</span>' );
62
            results.push( '</td>' );
70
            results.push( '</td>' );
63
71
64
            results.push( '<td>' );
72
            results.push( '<td>' );
Lines 71-89 function search( offset ) { Link Here
71
79
72
            results.push( '</tr>' );
80
            results.push( '</tr>' );
73
            var $tr = $( results.join( '' ));
81
            var $tr = $( results.join( '' ));
74
            $( '#results tbody' ).append( $tr );
82
            $( '#overdrive-results-list tbody' ).append( $tr );
75
83
76
            fetch_availability( prod, $tr );
84
            fetch_availability( prod, $tr );
77
        }
85
        }
78
86
79
        $( '#results tr:odd' ).addClass( 'highlight' );
87
        $( '#overdrive-results-list tr:odd' ).addClass( 'highlight' );
80
88
81
        var pages = [];
89
        var pages = [];
82
        var cur_page = offset / results_per_page;
90
        var cur_page = offset / results_per_page;
83
        var max_page = Math.floor( data.totalItems / results_per_page );
91
        var max_page = Math.floor( data.totalItems / results_per_page );
84
92
85
        if ( cur_page != 0 ) {
93
        if ( cur_page != 0 ) {
86
            pages.push( '<a class="nav" href="#" data-offset="' + (offset - results_per_page) + '">&lt;&lt; Previous</a>' );
94
            pages.push( '<a class="nav" href="#" data-offset="' + (offset - results_per_page) + '">&lt;&lt; ' + _("Previous") + '</a>' );
87
        }
95
        }
88
96
89
        for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
97
        for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) {
Lines 95-104 function search( offset ) { Link Here
95
        }
103
        }
96
104
97
        if ( cur_page < max_page ) {
105
        if ( cur_page < max_page ) {
98
            pages.push( ' <a class="nav" href="#" data-offset="' + (offset + results_per_page) + '">Next >></a>' );
106
            pages.push( ' <a class="nav" href="#" data-offset="' + (offset + results_per_page) + '">' + _("Next") + ' >></a>' );
99
        }
107
        }
100
108
101
        if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pages' ).html( pages.join( '' ) );
109
        if ( pages.length > 1 ) $( '#top-pages, #bottom-pages' ).find( '.pages' ).html( pages.join( '' ) );
110
111
        $( '#overdrive-results-list input.star' ).rating();
102
    } );
112
    } );
103
}
113
}
104
114
Lines 140-146 $( document ).ready( function() { Link Here
140
            <div class="pages">
150
            <div class="pages">
141
            </div>
151
            </div>
142
        </div>
152
        </div>
143
        <table id="results">
153
        <table id="overdrive-results-list">
144
            <tbody>
154
            <tbody>
145
            </tbody>
155
            </tbody>
146
        </table>
156
        </table>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tt (-3 / +3 lines)
Lines 266-283 $(document).ready(function(){ Link Here
266
        $("#highlight_toggle_off").show().click(function() {highlightOff();});
266
        $("#highlight_toggle_off").show().click(function() {highlightOff();});
267
    [% END %]
267
    [% END %]
268
    [% IF ( OverDriveEnabled ) %]
268
    [% IF ( OverDriveEnabled ) %]
269
        var $overdrive_results = $( '<span id="overdrive-results">Searching OverDrive... <img class="throbber" src="/opac-tmpl/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
269
        var $overdrive_results = $( '<span id="overdrive-results">' + _( 'Searching OverDrive...' ) + ' <img class="throbber" src="/opac-tmpl/lib/jquery/plugins/themes/classic/throbber.gif" /></span>' );
270
        $( '#breadcrumbs p' ).eq(0)
270
        $( '#breadcrumbs p' ).eq(0)
271
            .append( ' ' )
271
            .append( ' ' )
272
            .append( $overdrive_results );
272
            .append( $overdrive_results );
273
        KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, 1, 0, function( data ) {
273
        KOHA.OverDrive.Search( "[% OverDriveLibraryID %]", querystring, 1, 0, function( data ) {
274
            if ( data.error ) {
274
            if ( data.error ) {
275
                $overdrive_results.html( 'Error searching OverDrive collection' );
275
                $overdrive_results.html( _( 'Error searching OverDrive collection' ) );
276
                return;
276
                return;
277
            }
277
            }
278
278
279
            if ( data.totalItems ) {
279
            if ( data.totalItems ) {
280
                $overdrive_results.html( 'Found <a href="/cgi-bin/koha/opac-overdrive-search.pl?q=' + escape( querystring ) + '">' + data.totalItems + ' results</a> in OverDrive collection' );
280
                $overdrive_results.html( _( 'Found' ) + ' <a href="/cgi-bin/koha/opac-overdrive-search.pl?q=' + escape( querystring ) + '">' + data.totalItems + ' ' + _( 'results' ) + '</a> ' + _( 'in OverDrive collection' ) );
281
            } else {
281
            } else {
282
                $overdrive_results.remove();
282
                $overdrive_results.remove();
283
            }
283
            }
(-)a/t/External_Overdrive.t (-1 / +13 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# This Koha test module is a stub!
4
# Add more tests here!!!
5
6
use strict;
7
use warnings;
8
9
use Test::More tests => 1;
10
11
BEGIN {
12
        use_ok('C4::External::OverDrive');
13
}

Return to bug 10320