Bugzilla – Attachment 46103 Details for
Bug 15434
Make search results breadcrumbs human readable
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15434: Search criteria definition table
Bug-15434-Search-criteria-definition-table.patch (text/plain), 10.42 KB, created by
Srdjan Jankovic
on 2015-12-31 02:20:51 UTC
(
hide
)
Description:
Bug 15434: Search criteria definition table
Filename:
MIME Type:
Creator:
Srdjan Jankovic
Created:
2015-12-31 02:20:51 UTC
Size:
10.42 KB
patch
obsolete
>From 1ff8ed7ca0b9f8fb5c488292bebab3e1bcfc856b Mon Sep 17 00:00:00 2001 >From: Srdjan <srdjan@catalyst.net.nz> >Date: Tue, 29 Dec 2015 14:09:45 +1300 >Subject: [PATCH] Bug 15434: Search criteria definition table > >Collected search criteria and limit labels in opac-bottom.inc, so it >can be used for both making search criteria selects and displaying back >selections on the result screen. > >*-opac-bootstrap.po translation files need to be changed: >* references to opac-advanced-search.tt need to be updated to > opac-bottom.inc >* messages and translations need -s removed >--- > .../bootstrap/en/includes/opac-bottom.inc | 52 ++++++++++++++++++++ > .../bootstrap/en/modules/opac-results-grouped.tt | 12 ++++- > .../opac-tmpl/bootstrap/en/modules/opac-results.tt | 14 +++++- > koha-tmpl/opac-tmpl/bootstrap/js/search.js | 57 ++++++++++++++++++++++ > 4 files changed, 132 insertions(+), 3 deletions(-) > create mode 100644 koha-tmpl/opac-tmpl/bootstrap/js/search.js > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index 1d350ea..7a77ece 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -85,6 +85,7 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > </script> > <script type="text/javascript" src="[% interface %]/[% theme %]/lib/bootstrap/js/bootstrap.min.js"></script> > <script type="text/javascript" src="[% interface %]/[% theme %]/js/global.js"></script> >+<script type="text/javascript" src="[% interface %]/[% theme %]/js/search.js"></script> > <script type="text/javascript"> > Modernizr.load([ > // Test need for polyfill >@@ -96,6 +97,57 @@ $.widget.bridge('uitooltip', $.ui.tooltip); > "[% interface %]/[% theme %]/lib/enquire.min.js", > "[% interface %]/[% theme %]/js/script.js" > ]); >+ $(document).ready(function() { >+ var query_xlate = { >+ "kw": _("Keyword"), >+ "su": _("Subject"), >+ "su,phr": _("Subject phrase"), >+ "su-br": _("Subject and broader terms"), >+ "su-na": _("Subject and narrower terms"), >+ "su-rl": _("Subject and related terms"), >+ "ti": _("Title"), >+ "ti,phr": _("Title phrase"), >+ "se": _("Series"), >+ "se,wrdl": _("Series title"), >+ "callnum": _("Call Number"), >+ "location": _("Shelving location"), >+ "au": _("Author"), >+ "au,phr": _("Author phrase"), >+ "cpn": _("Corporate name"), >+ "cfn": _("Conference name"), >+ "cfn,phr": _("Conference name phrase"), >+ "pn": _("Personal name"), >+ "pn,phr": _("Personal name phrase"), >+ "nt": _("Notes/Comments"), >+ "curriculum": _("Curriculum"), >+ "pb": _("Publisher"), >+ "pl": _("Publisher location"), >+ "sn": _("Standard number"), >+ "nb": _("ISBN"), >+ "ns": _("ISSN"), >+ "bc": _("Barcode") >+ }; >+ var limit_xlate = { >+ "mc-itype": _("Type"), >+ "ln": _("Language"), >+ "branch": _("Branch"), >+ "aud": _("Audience"), >+ "l-format": _("Format"), >+ "ctype": _("Content Type"), >+ "yr": _("Year") >+ }; >+ var limit_qualifier_xlate = { >+ "wrdl": "", >+ "phr": "", >+ "rtrn": "", >+ "st-numeric": "", >+ "ge=": ">=", >+ "le=": "<=" >+ }; >+ KOHA.Search.init(query_xlate, limit_xlate, limit_qualifier_xlate); >+ >+ KOHA.Search.search_set_select('select[name="idx"]'); >+ }); > </script> > [% IF ( OPACAmazonCoverImages || SyndeticsCoverImages ) %] > <script type="text/javascript">//<![CDATA[ >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt >index 68c543c..04971a0 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt >@@ -20,7 +20,7 @@ href="/cgi-bin/koha/opac-rss.pl?[% query_cgi %][% limit_cgi |html %]" /> > <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li> > <li> > [% IF ( searchdesc ) %] >- <a href="#">Results of search [% IF ( query_desc ) %]for '[% query_desc | html %]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc | html %]'[% END %]</a> >+ <a href="#">Results of search [% IF ( query_desc ) %]for '<span class="query_desc_xlate">[% query_desc | html %]</span>'[% END %][% IF ( limit_desc ) %] with limit(s): '<span class="limit_desc_xlate">[% limit_desc | html %]</span>'[% END %]</a> > [% ELSE %] > <a href="#">You did not specify any search criteria.</a> > [% END %] >@@ -323,6 +323,10 @@ $(document).ready(function(){ > return false; > }); > [% IF ( query_desc ) %] >+ [% IF ( searchdesc ) %] >+ var query_desc_xlate = KOHA.Search.query_xlate("[% query_desc %]"); >+ $(".query_desc_xlate").text(query_desc_xlate); >+ [% END %] > var query_desc = "[% query_desc |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') |html %]"; > q_array = query_desc.split(" "); > // ensure that we don't have "" at the end of the array, which can >@@ -334,6 +338,12 @@ $(document).ready(function(){ > $("#highlight_toggle_on" ).hide().click(function() {highlightOn() ;}); > $("#highlight_toggle_off").show().click(function() {highlightOff();}); > [% END %] >+ [% IF ( limit_desc ) %] >+ [% IF ( searchdesc ) %] >+ var limit_desc_xlate = KOHA.Search.limit_xlate("[% limit_desc %]"); >+ $(".limit_desc_xlate").text(limit_desc_xlate); >+ [% END %] >+ [% END %] > }); > > function highlightOff() { >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 8a0ec89..c670d5c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -27,7 +27,7 @@ > <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li> > <li> > [% IF ( searchdesc ) %] >- <a href="#">Results of search [% IF ( query_desc ) %]for '[% query_desc | html%]'[% END %][% IF ( limit_desc ) %] with limit(s): '[% limit_desc | html %]'[% END %]</a> >+ <a href="#">Results of search [% IF ( query_desc ) %]for '<span class="query_desc_xlate">[% query_desc | html%]</span>'[% END %][% IF ( limit_desc ) %] with limit(s): '<span class="limit_desc_xlate">[% limit_desc | html %]</span>'[% END %]</a> > [% ELSE %] > <a href="#">You did not specify any search criteria</a> > [% END %] >@@ -865,9 +865,13 @@ $(document).ready(function(){ > [% END %] > > [% IF ( query_desc ) %] >- var query_desc = "[% query_desc |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') |html %]"; >+ [% IF ( searchdesc ) %] >+ var query_desc_xlate = KOHA.Search.query_xlate("[% query_desc %]"); >+ $(".query_desc_xlate").text(query_desc_xlate); >+ [% END %] > var querystring = "[% querystring |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') |html %]"; > [% IF ( OpacHighlightedWords ) %] >+ var query_desc = "[% query_desc |replace("'", "\'") |replace('\n', '\\n') |replace('\r', '\\r') |html %]"; > q_array = query_desc.split(" "); > // ensure that we don't have "" at the end of the array, which can > // break the highlighter >@@ -896,6 +900,12 @@ $(document).ready(function(){ > } ); > [% END %] > [% END %] >+[% IF ( limit_desc ) %] >+ [% IF ( searchdesc ) %] >+ var limit_desc_xlate = KOHA.Search.limit_xlate("[% limit_desc %]"); >+ $(".limit_desc_xlate").text(limit_desc_xlate); >+ [% END %] >+[% END %] > > [% IF ( TagsInputEnabled && loggedinusername ) %] > $("#tagsel_tag").click(function(){ >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/search.js b/koha-tmpl/opac-tmpl/bootstrap/js/search.js >new file mode 100644 >index 0000000..2c8aa2e >--- /dev/null >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/search.js >@@ -0,0 +1,57 @@ >+if ( typeof KOHA == "undefined" || !KOHA ) { >+ var KOHA = {}; >+} >+ >+KOHA.Search = new function() { >+ this.query_xlate_table = {}; >+ this.limit_xlate_table = {}; >+ this.limit_qualifier_xlate_table = {}; >+ >+ this.init = function(query_xlate_table, limit_xlate_table, limit_qualifier_xlate_table) { >+ this.query_xlate_table = query_xlate_table; >+ this.limit_xlate_table = limit_xlate_table; >+ this.limit_qualifier_xlate_table = limit_qualifier_xlate_table; >+ } >+ >+ this.search_set_select = function(select_el) { >+ var query_xlate_table = this.query_xlate_table; >+ $(select_el).children("option").each(function(index, el) { >+ var val = $(el).attr("value"); >+ var label = query_xlate_table[val]; >+ if (label) { >+ var html = $(el).html().replace(/[\w\s]*$/,label); >+ $(el).html(html); >+ } >+ }); >+ }; >+ >+ this.query_xlate = function(query_desc) { >+ $.each(this.query_xlate_table, function (key, val) { >+ var key_re = new RegExp('\\b' + key + ':', "g"); >+ query_desc = query_desc.replace(key_re, val + ':'); >+ if (!key.match(/,/)) { >+ key_re = new RegExp('\\b' + key + ',wrdl:', "g"); >+ query_desc = query_desc.replace(key_re, val + ':'); >+ } >+ }); >+ return query_desc; >+ }; >+ >+ this.limit_xlate = function(limit_desc) { >+ $.each(this.limit_xlate_table, function (key, val) { >+ var key_re = new RegExp('\\b' + key + ':', 'g'); >+ limit_desc = limit_desc.replace(key_re, val + ':'); >+ key_re = new RegExp('\\b' + key + ',', 'g'); >+ limit_desc = limit_desc.replace(key_re, val + ','); >+ }); >+ $.each(this.limit_qualifier_xlate_table, function (key, val) { >+ var repl = ""; >+ if (val) { >+ repl = " " + val; >+ } >+ var key_re = new RegExp('\\b,' + key, 'g'); >+ limit_desc = limit_desc.replace(key_re, repl); >+ }); >+ return limit_desc; >+ }; >+} >-- >1.9.1
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 15434
:
46017
|
46103
|
46674
|
46887
|
49074
|
49075
|
49077
|
50963
|
50964