Bugzilla – Attachment 76049 Details for
Bug 10659
Upgrade jQuery star ratings plugin
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10659: Upgrade jQuery star ratings plugin
Bug-10659-Upgrade-jQuery-star-ratings-plugin.patch (text/plain), 43.34 KB, created by
Owen Leonard
on 2018-06-14 13:09:17 UTC
(
hide
)
Description:
Bug 10659: Upgrade jQuery star ratings plugin
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2018-06-14 13:09:17 UTC
Size:
43.34 KB
patch
obsolete
>From 43f76c84e5e9955e7e5fe91323611e571af3f10a Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 13 Jun 2018 16:45:48 +0000 >Subject: [PATCH] Bug 10659: Upgrade jQuery star ratings plugin > >This patch replaces our current jQuery star ratings plugin with a newer >plugin which will be compatible with newer versions of jQuery: > >http://antenna.io/demo/jquery-bar-rating/examples/ > >To test you should have one or more records in your catalog with star >ratings. > >- Apply the patch and set the OpacStarRatings system preference > to "results and details" >- Perform a search in the catalog which will return one or more titles > which have ratings. > - Confirm that the ratings appear correctly and the ratings are > read-only. >- Open the "normal" detail page for that record. > - Confirm that the star rating appears correctly. > - Test setting and re-setting your star rating. Confirm that it is > saved. > - Confirm that the "cancel rating" link appears when you have a rating > set, and that it disappears after you click it. >- Test that the "only details" and disabled options of the > OpacStarRatings preference work as they should. >--- > .../opac-tmpl/bootstrap/css/jquery.rating.css | 14 - > .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 90 +++-- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 34 +- > .../bootstrap/images/star-ratings-sprite.png | Bin 2000 -> 0 bytes > koha-tmpl/opac-tmpl/bootstrap/less/opac.less | 71 ++++ > .../bootstrap/lib/jquery/plugins/jquery.rating.js | 392 --------------------- > .../lib/jquery/plugins/jquery.barrating.min.js | 2 + > 7 files changed, 134 insertions(+), 469 deletions(-) > delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/css/jquery.rating.css > delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/images/star-ratings-sprite.png > delete mode 100644 koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.rating.js > create mode 100644 koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.barrating.min.js > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/css/jquery.rating.css b/koha-tmpl/opac-tmpl/bootstrap/css/jquery.rating.css >deleted file mode 100644 >index 461f015..0000000 >--- a/koha-tmpl/opac-tmpl/bootstrap/css/jquery.rating.css >+++ /dev/null >@@ -1,14 +0,0 @@ >-/* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */ >-div.rating-cancel,div.star-rating{float:left;width:15px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden} >-div.rating-cancel,div.rating-cancel a{background:url(../images/star-ratings-sprite.png) no-repeat 0 -49px} >-div.star-rating,div.star-rating a{background:url(../images/star-ratings-sprite.png) no-repeat 0 0px} >-div.rating-cancel a{display:block;width:16px;height:100%;background-position:0 -49px;border:0} >-div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0} >-div.star-rating-on a{background-position:0 -32px!important} >-div.rating-cancel.star-rating-hover a{background-position:0 -65px} >-div.star-rating-hover a{background-position:0 -16px} >-/* Read Only CSS */ >-div.star-rating-readonly a{cursor:default !important} >-/* Partial Star CSS */ >-div.star-rating{background:transparent!important;overflow:hidden!important} >-/* END jQuery.Rating Plugin CSS */ >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >index 7567a7c..58b2d56 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt >@@ -37,9 +37,6 @@ > [% IF ( bidi ) %] > [% BLOCK cssinclude %][% Asset.css("css/right-to-left.css") %][% END %] > [% END %] >-[% IF ( OpacStarRatings != 'disable' ) %] >- [% BLOCK cssinclude %][% Asset.css("css/jquery.rating.css") %][% END %] >-[% END %] > [% INCLUDE greybox.inc %] > [% Asset.css("lib/emoji-picker/css/emoji.css") %] > </head> >@@ -495,18 +492,19 @@ > > [% SET rating_avg = ratings.get_avg_rating() %] > [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] >- [% FOREACH i IN [ 1 2 3 4 5 ] %] >- [% IF rating_avg_int == i && borrowernumber %] >- <input class="auto-submit-star" type="radio" name="rating" value="[% i %]" checked="checked" /> >- [% ELSIF rating_avg_int == i %] >- <input class="auto-submit-star" type="radio" name="rating" value="[% i %]" checked="checked" disabled="disabled" /> >- [% ELSIF borrowernumber %] >- <input class="auto-submit-star" type="radio" name="rating" value="[% i %]" /> >- [% ELSE %] >- <input class="auto-submit-star" type="radio" name="rating" value="[% i %]" disabled="disabled" /> >- [% END %] >+ [% IF ( borrowernumber ) %] >+ <select id="star_rating" name="rating" data-rating-enabled="1" autocomplete="off"> >+ [% ELSE %] >+ <select id="star_rating" name="rating" data-rating-enabled="0" disabled="disabled" autocomplete="off"> > [% END %] >- >+ [% FOREACH i IN [ 1 2 3 4 5 ] %] >+ [% IF rating_avg_int == i %] >+ <option value="[% i %]" selected="selected">[% i %]</option> >+ [% ELSE %] >+ <option value"[% i %]">[% i %]</option> >+ [% END %] >+ [% END %] >+ </select> > <!-- define some hidden vars for ratings --> > > <input type="hidden" name='biblionumber' value="[% biblio.biblionumber %]" /> >@@ -515,12 +513,14 @@ > [% UNLESS ( rating_readonly ) %] <input name="rate_button" type="submit" value="Rate me" />[% END %] > > [% IF my_rating %] >- <span id="rating_value_text">your rating: [% my_rating.rating_value %], </span> >+ <span id="rating_value_text">Your rating: [% my_rating.rating_value %].</span> >+ <span id="cancel_rating_text"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span> > [% ELSE %] > <span id="rating_value_text"></span> >+ <span id="cancel_rating_text" style="display:none;"><a href="#"><i class="fa fa-remove"></i> Cancel rating</a>.</span> > [% END %] > >- <span id="rating_text">average rating: [% rating_avg %] ([% ratings.count %] votes)</span> >+ <span id="rating_text">Average rating: [% rating_avg %] ([% ratings.count %] votes)</span> > </div> > </form> > [% END # / IF OpacStarRatings != 'disable' %] >@@ -1389,7 +1389,7 @@ > </script> > <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> > [% END %] >-[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") %][% END %] >+[% IF ( OpacStarRatings != 'disable' ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") %][% END %] > > [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %][% END %] > >@@ -1649,50 +1649,46 @@ > // ----------------------------------------------------- > // star-ratings code > // ----------------------------------------------------- >- // hide 'rate' button if javascript enabled > >+ // hide 'rate' button if javascript enabled > $('input[name="rate_button"]').remove(); > >- $(function () { >- $(".auto-submit-star").rating({ >- cancel: _("Cancel rating"), >- callback: function (value, link) { >- >- // if the new value equals the old value, dont execute callback... >- // just do nothing! >- if ($("#rating_value").attr("value") != value) { >- >- $(function () { >- >- $.post("/cgi-bin/koha/opac-ratings-ajax.pl", { >+ var rating_enabled = ( $("#star_rating").data("rating-enabled") == "1" ) ? false : true; >+ $('#star_rating').barrating({ >+ theme: 'fontawesome-stars', >+ showSelectedRating: false, >+ allowEmpty: true, >+ readonly: rating_enabled, >+ onSelect: function(value, text) { >+ $.post("/cgi-bin/koha/opac-ratings-ajax.pl", { > rating_old_value: $("#rating_value").attr("value"), > borrowernumber: "[% borrowernumber %]", > biblionumber: "[% biblio.biblionumber %]", > rating_value: value, > auth_error: value >- }, function (data) { >+ }, function (data) { > > if (data.auth_status != 'ok') { >- window.alert(_("Your CGI session cookie is not current. Please refresh the page and try again.")); >+ window.alert(_("Your session has expired. Please refresh the page and try again.")); > } else { >- $("#rating_value").val(data.rating_value); >- >- if (data.rating_value) { >- $("#rating_value_text").text(_("your rating: %s, ").format(data.rating_value)); >- } else { >- $("#rating_value_text").text(''); >- } >- >- $("#rating_text").text(_("average rating: %s (%s votes)").format(data.rating_avg, data.rating_total)); >- >+ $("#rating_value").val(data.rating_value); >+ if (data.rating_value) { >+ $("#rating_value_text").text(_("Your rating: %s.").format(data.rating_value)); >+ $("#cancel_rating_text").show(); >+ } else { >+ $("#rating_value_text").text(''); >+ $("#cancel_rating_text").hide(); >+ } >+ $("#rating_text").text(_("Average rating: %s (%s votes)").format(data.rating_avg, data.rating_total)); > } >- }, "json"); >- }); >- }; >+ }, "json"); > } >- }); > }); >- // ----------------------------------------------------- >+ >+ $("#cancel_rating_text a").on("click", function(){ >+ $("#star_rating").barrating("set", ""); >+ }); >+ > [% END # / IF ( OpacStarRatings != 'disable' )%] > > [% IF ( IDreamBooksReviews || IDreamBooksReadometer ) %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index c30f330..52694b7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -11,12 +11,7 @@ > You did not specify any search criteria. > [% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] >-[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %] >- [% BLOCK cssinclude %] >- [% Asset.css("css/jquery.rating.css") %] >- [% END %] >-[% END %] >- >+[% BLOCK cssinclude %][% END %] > <link rel="alternate" type="application/rss+xml" title="[% LibraryName |html %] Search RSS feed" href="[% OPACBaseURL %]/cgi-bin/koha/opac-search.pl?[% query_cgi | url %][% limit_cgi |uri %]&count=[% countrss |uri %]&sort_by=acqdate_dsc&format=rss2" /> > </head> > >@@ -425,6 +420,7 @@ > <div class="star-rating rater-[% i %] star star-rating-applied star-rating-readonly"><a title="[% i %]">[% i %]</a></div> > [% END %] > [% END %] >+ > <span id="babeltheque-rating_total_[% SEARCH_RESULT.biblionumber %]"> [% SEARCH_RESULT.score_avg %] / 5 (on [% SEARCH_RESULT.num_scores %] rates)</span> > > [% IF ( SEARCH_RESULT.num_critics ) %] >@@ -482,15 +478,21 @@ > > [% IF ( OpacStarRatings == 'all' ) %] > <div class="results_summary ratings"> >- [% SET rating_avg = SEARCH_RESULT.ratings.get_avg_rating() %] >- [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] >- [% FOREACH i IN [ 1 2 3 4 5 ] %] >- [% IF rating_avg_int == i %] >- <input class="star" type="radio" name="rating-[% SEARCH_RESULT.biblionumber %]" value="[% i %]" checked="checked" disabled="disabled" /> >- [% ELSE %] >- <input class="star" type="radio" name="rating-[% SEARCH_RESULT.biblionumber %]" value="[% i %]" disabled="disabled" /> >- [% END %] >- [% END %] >+ [% SET rating_avg = SEARCH_RESULT.ratings.get_avg_rating() %] >+ [% rating_avg_int = BLOCK %][% rating_avg | format("%.0f") %][% END %] >+ <div class="br-wrapper br-theme-fontawesome-stars"> >+ <div class="br-widget br-readonly"> >+ [% FOREACH i IN [ 1 2 3 4 5 ] %] >+ [% IF rating_avg_int == i %] >+ <a href="#" class="br-selected br-current"></a> >+ [% ELSIF rating_avg_int > i %] >+ <a href="#" class="br-selected"></a> >+ [% ELSE %] >+ <a href="#"></a> >+ [% END %] >+ [% END %] >+ </div> >+ </div> > > [% IF SEARCH_RESULT.ratings.count > 0 %] > <span id="rating_total_[% SEARCH_RESULT.biblionumber %]"> ([% SEARCH_RESULT.ratings.count %] votes)</span> >@@ -591,7 +593,7 @@ > [% IF ( LibraryThingForLibrariesID ) %] > <script src="https://ltfl.librarything.com/forlibraries/widget.js?id=[% LibraryThingForLibrariesID %]&systype=koha"></script> > [% END %] >-[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.rating.js") %][% END %] >+[% IF ( OpacStarRatings == 'all' || Koha.Preference('Babeltheque') ) %][% Asset.js("lib/jquery/plugins/jquery.barrating.min.js") %][% END %] > [% IF ( OverDriveEnabled ) %][% Asset.js("js/overdrive.js") %][% END %] > [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") %] > [% IF ( OpacHighlightedWords ) %][% Asset.js("lib/jquery/plugins/jquery.highlight-3.js") %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/images/star-ratings-sprite.png b/koha-tmpl/opac-tmpl/bootstrap/images/star-ratings-sprite.png >deleted file mode 100644 >index 1dadc550abfcc6824f5950c0caf717d5a26d8540..0000000000000000000000000000000000000000 >GIT binary patch >literal 0 >HcmV?d00001 > >literal 2000 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 >I-h-C)H_bQ)TL1t6 > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >index 88b350a..73482c7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >+++ b/koha-tmpl/opac-tmpl/bootstrap/less/opac.less >@@ -2643,6 +2643,77 @@ a.reviewlink:visited { > } > } > >+/* jQuery Bar Rating plugin for star ratings */ >+ >+@star-default: #d2d2d2; >+@star-active: #C24A4A; >+@star-selected: #EDB867; >+ >+.br-wrapper { >+ display: inline-block; >+} >+ >+.br-theme-fontawesome-stars { >+ >+ .br-widget { >+ height: 28px; >+ white-space: nowrap; >+ a { >+ font: normal normal normal 20px/1 FontAwesome; >+ text-rendering: auto; >+ -webkit-font-smoothing: antialiased; >+ text-decoration: none; >+ margin-right: 2px; >+ } >+ >+ a:after { >+ content: '\f005'; >+ color: @star-default; >+ } >+ >+ a.br-active:after { >+ color: @star-active; >+ } >+ >+ a.br-selected:after { >+ color: @star-selected; >+ } >+ >+ .br-current-rating { >+ display: none; >+ } >+ } >+ >+ .br-readonly { >+ a { >+ cursor: default; >+ } >+ } >+ >+} >+ >+#cancel_rating_text a { >+ color: #C24A4A; >+} >+ >+@media print { >+ .br-theme-fontawesome-stars { >+ >+ .br-widget { >+ a:after { >+ content: '\f006'; >+ color: black; >+ } >+ >+ a.br-active:after, >+ a.br-selected:after { >+ content: '\f005'; >+ color: black; >+ } >+ } >+ >+ } >+} > > > @import "responsive.less"; >diff --git a/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.rating.js b/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.rating.js >deleted file mode 100644 >index f4a22d5..0000000 >--- a/koha-tmpl/opac-tmpl/bootstrap/lib/jquery/plugins/jquery.rating.js >+++ /dev/null >@@ -1,392 +0,0 @@ >-/* >- ### jQuery Star Rating Plugin v3.14 - 2012-01-26 ### >- * Home: http://www.fyneworks.com/jquery/star-rating/ >- * Code: http://code.google.com/p/jquery-star-rating-plugin/ >- * >- * Dual licensed under the MIT and GPL licenses: >- * http://www.opensource.org/licenses/mit-license.php >- * http://www.gnu.org/licenses/gpl.html >- ### >-*/ >- >-/*# AVOID COLLISIONS #*/ >-;if(window.jQuery) (function($){ >-/*# AVOID COLLISIONS #*/ >- >- // IE6 Background Image Fix >- if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { }; >- // Thanks to http://www.visualjquery.com/rating/rating_redux.html >- >- // plugin initialization >- $.fn.rating = function(options){ >- if(this.length==0) return this; // quick fail >- >- // Handle API methods >- if(typeof arguments[0]=='string'){ >- // Perform API methods on individual elements >- if(this.length>1){ >- var args = arguments; >- return this.each(function(){ >- $.fn.rating.apply($(this), args); >- }); >- }; >- // Invoke API method handler >- $.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []); >- // Quick exit... >- return this; >- }; >- >- // Initialize options for this call >- var options = $.extend( >- {}/* new object */, >- $.fn.rating.options/* default options */, >- options || {} /* just-in-time options */ >- ); >- >- // Allow multiple controls with the same name by making each call unique >- $.fn.rating.calls++; >- >- // loop through each matched element >- this >- .not('.star-rating-applied') >- .addClass('star-rating-applied') >- .each(function(){ >- >- // Load control parameters / find context / etc >- var control, input = $(this); >- var eid = (this.name || 'unnamed-rating').replace(/\[|\]/g, '_').replace(/^\_+|\_+$/g,''); >- var context = $(this.form || document.body); >- >- // FIX: http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=23 >- var raters = context.data('rating'); >- if(!raters || raters.call!=$.fn.rating.calls) raters = { count:0, call:$.fn.rating.calls }; >- var rater = raters[eid]; >- >- // if rater is available, verify that the control still exists >- if(rater) control = rater.data('rating'); >- >- if(rater && control)//{// save a byte! >- // add star to control if rater is available and the same control still exists >- control.count++; >- >- //}// save a byte! >- else{ >- // create new control if first star or control element was removed/replaced >- >- // Initialize options for this rater >- control = $.extend( >- {}/* new object */, >- options || {} /* current call options */, >- ($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */ >- { count:0, stars: [], inputs: [] } >- ); >- >- // increment number of rating controls >- control.serial = raters.count++; >- >- // create rating element >- rater = $('<span class="star-rating-control"/>'); >- input.before(rater); >- >- // Mark element for initialization (once all stars are ready) >- rater.addClass('rating-to-be-drawn'); >- >- // Accept readOnly setting from 'disabled' property >- if(input.attr('disabled') || input.hasClass('disabled')) control.readOnly = true; >- >- // Accept required setting from class property (class='required') >- if(input.hasClass('required')) control.required = true; >- >- // Create 'cancel' button >- rater.append( >- control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>') >- .mouseover(function(){ >- $(this).rating('drain'); >- $(this).addClass('star-rating-hover'); >- //$(this).rating('focus'); >- }) >- .mouseout(function(){ >- $(this).rating('draw'); >- $(this).removeClass('star-rating-hover'); >- //$(this).rating('blur'); >- }) >- .click(function(){ >- $(this).rating('select'); >- }) >- .data('rating', control) >- ); >- >- }; // first element of group >- >- // insert rating star >- var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="' + (this.title || this.value) + '">' + this.value + '</a></div>'); >- rater.append(star); >- >- // inherit attributes from input element >- if(this.id) star.attr('id', this.id); >- if(this.className) star.addClass(this.className); >- >- // Half-stars? >- if(control.half) control.split = 2; >- >- // Prepare division control >- if(typeof control.split=='number' && control.split>0){ >- var stw = ($.fn.width ? star.width() : 0) || control.starWidth; >- var spi = (control.count % control.split), spw = Math.floor(stw/control.split); >- star >- // restrict star's width and hide overflow (already in CSS) >- .width(spw) >- // move the star left by using a negative margin >- // this is work-around to IE's stupid box model (position:relative doesn't work) >- .find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' }) >- }; >- >- // readOnly? >- if(control.readOnly)//{ //save a byte! >- // Mark star as readOnly so user can customize display >- star.addClass('star-rating-readonly'); >- //} //save a byte! >- else//{ //save a byte! >- // Enable hover css effects >- star.addClass('star-rating-live') >- // Attach mouse events >- .mouseover(function(){ >- $(this).rating('fill'); >- $(this).rating('focus'); >- }) >- .mouseout(function(){ >- $(this).rating('draw'); >- $(this).rating('blur'); >- }) >- .click(function(){ >- $(this).rating('select'); >- }) >- ; >- //}; //save a byte! >- >- // set current selection >- if(this.checked) control.current = star; >- >- // set current select for links >- if(this.nodeName=="A"){ >- if($(this).hasClass('selected')) >- control.current = star; >- }; >- >- // hide input element >- input.hide(); >- >- // backward compatibility, form element to plugin >- input.change(function(){ >- $(this).rating('select'); >- }); >- >- // attach reference to star to input element and vice-versa >- star.data('rating.input', input.data('rating.star', star)); >- >- // store control information in form (or body when form not available) >- control.stars[control.stars.length] = star[0]; >- control.inputs[control.inputs.length] = input[0]; >- control.rater = raters[eid] = rater; >- control.context = context; >- >- input.data('rating', control); >- rater.data('rating', control); >- star.data('rating', control); >- context.data('rating', raters); >- }); // each element >- >- // Initialize ratings (first draw) >- $('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn'); >- >- return this; // don't break the chain... >- }; >- >- /*--------------------------------------------------------*/ >- >- /* >- ### Core functionality and API ### >- */ >- $.extend($.fn.rating, { >- // Used to append a unique serial number to internal control ID >- // each time the plugin is invoked so same name controls can co-exist >- calls: 0, >- >- focus: function(){ >- var control = this.data('rating'); if(!control) return this; >- if(!control.focus) return this; // quick fail if not required >- // find data for event >- var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null ); >- // focus handler, as requested by focusdigital.co.uk >- if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]); >- }, // $.fn.rating.focus >- >- blur: function(){ >- var control = this.data('rating'); if(!control) return this; >- if(!control.blur) return this; // quick fail if not required >- // find data for event >- var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null ); >- // blur handler, as requested by focusdigital.co.uk >- if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]); >- }, // $.fn.rating.blur >- >- fill: function(){ // fill to the current mouse position. >- var control = this.data('rating'); if(!control) return this; >- // do not execute when control is in read-only mode >- if(control.readOnly) return; >- // Reset all stars and highlight them up to this element >- this.rating('drain'); >- this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover'); >- },// $.fn.rating.fill >- >- drain: function() { // drain all the stars. >- var control = this.data('rating'); if(!control) return this; >- // do not execute when control is in read-only mode >- if(control.readOnly) return; >- // Reset all stars >- control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover'); >- },// $.fn.rating.drain >- >- draw: function(){ // set value and stars to reflect current selection >- var control = this.data('rating'); if(!control) return this; >- // Clear all stars >- this.rating('drain'); >- // Set control value >- if(control.current){ >- control.current.data('rating.input').attr('checked','checked'); >- control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on'); >- } >- else >- $(control.inputs).removeAttr('checked'); >- // Show/hide 'cancel' button >- control.cancel[control.readOnly || control.required?'hide':'show'](); >- // Add/remove read-only classes to remove hand pointer >- this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly'); >- },// $.fn.rating.draw >- >- >- >- >- >- select: function(value,wantCallBack){ // select a value >- >- // ***** MODIFICATION ***** >- // Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27 >- // >- // ***** LIST OF MODIFICATION ***** >- // ***** added Parameter wantCallBack : false if you don't want a callback. true or undefined if you want postback to be performed at the end of this method' >- // ***** recursive calls to this method were like : ... .rating('select') it's now like .rating('select',undefined,wantCallBack); (parameters are set.) >- // ***** line which is calling callback >- // ***** /LIST OF MODIFICATION ***** >- >- var control = this.data('rating'); if(!control) return this; >- // do not execute when control is in read-only mode >- if(control.readOnly) return; >- // clear selection >- control.current = null; >- // programmatically (based on user input) >- if(typeof value!='undefined'){ >- // select by index (0 based) >- if(typeof value=='number') >- return $(control.stars[value]).rating('select',undefined,wantCallBack); >- // select by literal value (must be passed as a string >- if(typeof value=='string') >- //return >- $.each(control.stars, function(){ >- if($(this).data('rating.input').val()==value) $(this).rating('select',undefined,wantCallBack); >- }); >- } >- else >- control.current = this[0].tagName=='INPUT' ? >- this.data('rating.star') : >- (this.is('.rater-'+ control.serial) ? this : null); >- >- // Update rating control state >- this.data('rating', control); >- // Update display >- this.rating('draw'); >- // find data for event >- var input = $( control.current ? control.current.data('rating.input') : null ); >- // click callback, as requested here: http://plugins.jquery.com/node/1655 >- >- // **** MODIFICATION ***** >- // Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27 >- // >- //old line doing the callback : >- //if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event >- // >- //new line doing the callback (if i want :) >- if((wantCallBack ||wantCallBack == undefined) && control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event >- //to ensure retro-compatibility, wantCallBack must be considered as true by default >- // **** /MODIFICATION ***** >- >- },// $.fn.rating.select >- >- >- >- >- >- readOnly: function(toggle, disable){ // make the control read-only (still submits value) >- var control = this.data('rating'); if(!control) return this; >- // setread-only status >- control.readOnly = toggle || toggle==undefined ? true : false; >- // enable/disable control value submission >- if(disable) $(control.inputs).attr("disabled", "disabled"); >- else $(control.inputs).removeAttr("disabled"); >- // Update rating control state >- this.data('rating', control); >- // Update display >- this.rating('draw'); >- },// $.fn.rating.readOnly >- >- disable: function(){ // make read-only and never submit value >- this.rating('readOnly', true, true); >- },// $.fn.rating.disable >- >- enable: function(){ // make read/write and submit value >- this.rating('readOnly', false, false); >- }// $.fn.rating.select >- >- }); >- >- /*--------------------------------------------------------*/ >- >- /* >- ### Default Settings ### >- eg.: You can override default control like this: >- $.fn.rating.options.cancel = 'Clear'; >- */ >- $.fn.rating.options = { //$.extend($.fn.rating, { options: { >- cancel: 'Cancel Rating', // advisory title for the 'cancel' link >- cancelValue: '', // value to submit when user click the 'cancel' link >- split: 0, // split the star into how many parts? >- >- // Width of star image in case the plugin can't work it out. This can happen if >- // the jQuery.dimensions plugin is not available OR the image is hidden at installation >- starWidth: 16//, >- >- //NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code! >- //half: false, // just a shortcut to control.split = 2 >- //required: false, // disables the 'cancel' button so user can only select one of the specified values >- //readOnly: false, // disable rating plugin interaction/ values cannot be changed >- //focus: function(){}, // executed when stars are focused >- //blur: function(){}, // executed when stars are focused >- //callback: function(){}, // executed when a star is clicked >- }; //} }); >- >- /*--------------------------------------------------------*/ >- >- /* >- ### Default implementation ### >- The plugin will attach itself to file inputs >- with the class 'multi' when the page loads >- */ >- $(function(){ >- $('input[type=radio].star').rating(); >- }); >- >- >- >-/*# AVOID COLLISIONS #*/ >-})(jQuery); >-/*# AVOID COLLISIONS #*/ >diff --git a/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.barrating.min.js b/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.barrating.min.js >new file mode 100644 >index 0000000..c65b39f >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/lib/jquery/plugins/jquery.barrating.min.js >@@ -0,0 +1,2 @@ >+!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}(function(t){var e=function(){function e(){var e=this,n=function(){var n=["br-wrapper"];""!==e.options.theme&&n.push("br-theme-"+e.options.theme),e.$elem.wrap(t("<div />",{"class":n.join(" ")}))},i=function(){e.$elem.unwrap()},a=function(n){return t.isNumeric(n)&&(n=Math.floor(n)),t('option[value="'+n+'"]',e.$elem)},r=function(){var n=e.options.initialRating;return n?a(n):t("option:selected",e.$elem)},o=function(){var n=e.$elem.find('option[value="'+e.options.emptyValue+'"]');return!n.length&&e.options.allowEmpty?(n=t("<option />",{value:e.options.emptyValue}),n.prependTo(e.$elem)):n},l=function(t){var n=e.$elem.data("barrating");return"undefined"!=typeof t?n[t]:n},s=function(t,n){null!==n&&"object"==typeof n?e.$elem.data("barrating",n):e.$elem.data("barrating")[t]=n},u=function(){var t=r(),n=o(),i=t.val(),a=t.data("html")?t.data("html"):t.text(),l=null!==e.options.allowEmpty?e.options.allowEmpty:!!n.length,u=n.length?n.val():null,d=n.length?n.text():null;s(null,{userOptions:e.options,ratingValue:i,ratingText:a,originalRatingValue:i,originalRatingText:a,allowEmpty:l,emptyRatingValue:u,emptyRatingText:d,readOnly:e.options.readonly,ratingMade:!1})},d=function(){e.$elem.removeData("barrating")},c=function(){return l("ratingText")},f=function(){return l("ratingValue")},g=function(){var n=t("<div />",{"class":"br-widget"});return e.$elem.find("option").each(function(){var i,a,r,o;i=t(this).val(),i!==l("emptyRatingValue")&&(a=t(this).text(),r=t(this).data("html"),r&&(a=r),o=t("<a />",{href:"#","data-rating-value":i,"data-rating-text":a,html:e.options.showValues?a:""}),n.append(o))}),e.options.showSelectedRating&&n.append(t("<div />",{text:"","class":"br-current-rating"})),e.options.reverse&&n.addClass("br-reverse"),e.options.readonly&&n.addClass("br-readonly"),n},p=function(){return l("userOptions").reverse?"nextAll":"prevAll"},h=function(t){a(t).prop("selected",!0),e.$elem.change()},m=function(){t("option",e.$elem).prop("selected",function(){return this.defaultSelected}),e.$elem.change()},v=function(t){t=t?t:c(),t==l("emptyRatingText")&&(t=""),e.options.showSelectedRating&&e.$elem.parent().find(".br-current-rating").text(t)},y=function(t){return Math.round(Math.floor(10*t)/10%1*100)},b=function(){e.$widget.find("a").removeClass(function(t,e){return(e.match(/(^|\s)br-\S+/g)||[]).join(" ")})},w=function(){var n,i,a=e.$widget.find('a[data-rating-value="'+f()+'"]'),r=l("userOptions").initialRating,o=t.isNumeric(f())?f():0,s=y(r);if(b(),a.addClass("br-selected br-current")[p()]().addClass("br-selected"),!l("ratingMade")&&t.isNumeric(r)){if(o>=r||!s)return;n=e.$widget.find("a"),i=a.length?a[l("userOptions").reverse?"prev":"next"]():n[l("userOptions").reverse?"last":"first"](),i.addClass("br-fractional"),i.addClass("br-fractional-"+s)}},$=function(t){return l("allowEmpty")&&l("userOptions").deselectable?f()==t.attr("data-rating-value"):!1},x=function(n){n.on("click.barrating",function(n){var i,a,r=t(this),o=l("userOptions");return n.preventDefault(),i=r.attr("data-rating-value"),a=r.attr("data-rating-text"),$(r)&&(i=l("emptyRatingValue"),a=l("emptyRatingText")),s("ratingValue",i),s("ratingText",a),s("ratingMade",!0),h(i),v(a),w(),o.onSelect.call(e,f(),c(),n),!1})},R=function(e){e.on("mouseenter.barrating",function(){var e=t(this);b(),e.addClass("br-active")[p()]().addClass("br-active"),v(e.attr("data-rating-text"))})},V=function(t){e.$widget.on("mouseleave.barrating blur.barrating",function(){v(),w()})},O=function(e){e.on("touchstart.barrating",function(e){e.preventDefault(),e.stopPropagation(),t(this).click()})},C=function(t){t.on("click.barrating",function(t){t.preventDefault()})},S=function(t){x(t),e.options.hoverState&&(R(t),V(t))},T=function(t){t.off(".barrating")},j=function(t){var n=e.$widget.find("a");O&&O(n),t?(T(n),C(n)):S(n)};this.show=function(){l()||(n(),u(),e.$widget=g(),e.$widget.insertAfter(e.$elem),w(),v(),j(e.options.readonly),e.$elem.hide())},this.readonly=function(t){"boolean"==typeof t&&l("readOnly")!=t&&(j(t),s("readOnly",t),e.$widget.toggleClass("br-readonly"))},this.set=function(t){var n=l("userOptions");0!==e.$elem.find('option[value="'+t+'"]').length&&(s("ratingValue",t),s("ratingText",e.$elem.find('option[value="'+t+'"]').text()),s("ratingMade",!0),h(f()),v(c()),w(),n.silent||n.onSelect.call(this,f(),c()))},this.clear=function(){var t=l("userOptions");s("ratingValue",l("originalRatingValue")),s("ratingText",l("originalRatingText")),s("ratingMade",!1),m(),v(c()),w(),t.onClear.call(this,f(),c())},this.destroy=function(){var t=f(),n=c(),a=l("userOptions");T(e.$widget.find("a")),e.$widget.remove(),d(),i(),e.$elem.show(),a.onDestroy.call(this,t,n)}}return e.prototype.init=function(e,n){return this.$elem=t(n),this.options=t.extend({},t.fn.barrating.defaults,e),this.options},e}();t.fn.barrating=function(n,i){return this.each(function(){var a=new e;if(t(this).is("select")||t.error("Sorry, this plugin only works with select fields."),a.hasOwnProperty(n)){if(a.init(i,this),"show"===n)return a.show(i);if(a.$elem.data("barrating"))return a.$widget=t(this).next(".br-widget"),a[n](i)}else{if("object"==typeof n||!n)return i=n,a.init(i,this),a.show();t.error("Method "+n+" does not exist on jQuery.barrating")}})},t.fn.barrating.defaults={theme:"",initialRating:null,allowEmpty:null,emptyValue:"",showValues:!1,showSelectedRating:!0,deselectable:!0,reverse:!1,readonly:!1,fastClicks:!0,hoverState:!0,silent:!1,onSelect:function(t,e,n){},onClear:function(t,e){},onDestroy:function(t,e){}},t.fn.barrating.BarRating=e}); >+//# sourceMappingURL=jquery.barrating.min.js.map >\ No newline at end of file >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 10659
:
76049
|
76050
|
76051
|
76487
|
76488
|
76489
|
77740
|
77741
|
82760
|
82826
|
84706
|
84903
|
84970
|
85010
|
85011