Bugzilla – Attachment 104280 Details for
Bug 25363
Merge common.js with staff-global.js
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25363: Merge common.js with staff-global.js
Bug-25363-Merge-commonjs-with-staff-globaljs.patch (text/plain), 6.64 KB, created by
Owen Leonard
on 2020-05-04 13:41:51 UTC
(
hide
)
Description:
Bug 25363: Merge common.js with staff-global.js
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2020-05-04 13:41:51 UTC
Size:
6.64 KB
patch
obsolete
>From bf42b2897a621af9dd934fb12cf2d42b8f4c7dab Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Mon, 4 May 2020 12:36:57 +0000 >Subject: [PATCH] Bug 25363: Merge common.js with staff-global.js > >This patch merges the contents of common.js with staff-global.js. Both >are included globally in the staff interface, and there doesn't seem to >be any reason to require that the user downloads two different >JavaScript files. > >To test, apply the patch and perform a catalog search in the staff >client. > >View the detail page for a title in the search results. On the detail >page you should see navigation controls in the sidebar for browsing >through search results. Confirm they work correctly. >--- > .../intranet-tmpl/prog/en/includes/js_includes.inc | 1 - > koha-tmpl/intranet-tmpl/prog/js/commons.js | 73 --------------------- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 75 ++++++++++++++++++++++ > 3 files changed, 75 insertions(+), 74 deletions(-) > delete mode 100644 koha-tmpl/intranet-tmpl/prog/js/commons.js > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index bd833a4e76..7e7604b71c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -25,7 +25,6 @@ > [% Asset.js("lib/jquery/plugins/jquery.validate.min.js") | $raw %] > <!-- koha core js --> > [% Asset.js("js/staff-global.js") | $raw %] >-[% Asset.js("js/commons.js") | $raw %] > > [% INCLUDE 'validator-strings.inc' %] > [% IF ( IntranetUserJS ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/commons.js b/koha-tmpl/intranet-tmpl/prog/js/commons.js >deleted file mode 100644 >index 4981c07946..0000000000 >--- a/koha-tmpl/intranet-tmpl/prog/js/commons.js >+++ /dev/null >@@ -1,73 +0,0 @@ >-// Extends jQuery API >-jQuery.extend({uniqueArray:function(array){ >- return $.grep(array, function(el, index) { >- return index === $.inArray(el, array); >- }); >-}}); >- >-function removeByValue(arr, val) { >- for(var i=0; i<arr.length; i++) { >- if(arr[i] == val) { >- arr.splice(i, 1); >- break; >- } >- } >-} >- >-function paramOfUrl( url, param ) { >- param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); >- var regexS = "[\\?&]"+param+"=([^&#]*)"; >- var regex = new RegExp( regexS ); >- var results = regex.exec( url ); >- if( results == null ) { >- return ""; >- } else { >- return results[1]; >- } >-} >- >-function addBibToContext( bibnum ) { >- bibnum = parseInt(bibnum, 10); >- var bibnums = getContextBiblioNumbers(); >- bibnums.push(bibnum); >- setContextBiblioNumbers( bibnums ); >- setContextBiblioNumbers( $.uniqueArray( bibnums ) ); >-} >- >-function delBibToContext( bibnum ) { >- var bibnums = getContextBiblioNumbers(); >- removeByValue( bibnums, bibnum ); >- setContextBiblioNumbers( $.uniqueArray( bibnums ) ); >-} >- >-function setContextBiblioNumbers( bibnums ) { >- $.cookie('bibs_selected', JSON.stringify( bibnums )); >-} >- >-function getContextBiblioNumbers() { >- var r = $.cookie('bibs_selected'); >- if ( r ) { >- return JSON.parse(r); >- } >- r = new Array(); >- return r; >-} >- >-function resetSearchContext() { >- setContextBiblioNumbers( new Array() ); >-} >- >-$(document).ready(function(){ >- // forms with action leading to search >- $("form[action*='search.pl']").submit(function(){ >- resetSearchContext(); >- }); >- // any link to launch a search except navigation links >- $("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ >- resetSearchContext(); >- }); >- // any link to a detail page from the results page. >- $("#bookbag_form a[href*='detail.pl?']").click(function(){ >- resetSearchContext(); >- }); >-}); >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 4c6f96c92b..8fa419a8c1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -1,4 +1,5 @@ > /* global shortcut delCookie delBasket Sticky */ >+/* exported paramOfUrl addBibToContext delBibToContext */ > if ( KOHA === undefined ) var KOHA = {}; > > function _(s) { return s; } // dummy function for gettext >@@ -119,6 +120,21 @@ $.fn.selectTabByID = function (tabID) { > $.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" }); > } > $.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" }); >+ >+ /* Search results browsing */ >+ /* forms with action leading to search */ >+ $("form[action*='search.pl']").submit(function(){ >+ resetSearchContext(); >+ }); >+ /* any link to launch a search except navigation links */ >+ $("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ >+ resetSearchContext(); >+ }); >+ /* any link to a detail page from the results page. */ >+ $("#bookbag_form a[href*='detail.pl?']").click(function(){ >+ resetSearchContext(); >+ }); >+ > }); > > // http://jennifermadden.com/javascript/stringEnterKeyDetector.html >@@ -232,3 +248,62 @@ function keep_text(clicked_index) { > searchboxes[i].value = persist; > } > } >+ >+// Extends jQuery API >+jQuery.extend({uniqueArray:function(array){ >+ return $.grep(array, function(el, index) { >+ return index === $.inArray(el, array); >+ }); >+}}); >+ >+function removeByValue(arr, val) { >+ for(var i=0; i<arr.length; i++) { >+ if(arr[i] == val) { >+ arr.splice(i, 1); >+ break; >+ } >+ } >+} >+ >+function paramOfUrl( url, param ) { >+ param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); >+ var regexS = "[\\?&]"+param+"=([^&#]*)"; >+ var regex = new RegExp( regexS ); >+ var results = regex.exec( url ); >+ if( results == null ) { >+ return ""; >+ } else { >+ return results[1]; >+ } >+} >+ >+function addBibToContext( bibnum ) { >+ bibnum = parseInt(bibnum, 10); >+ var bibnums = getContextBiblioNumbers(); >+ bibnums.push(bibnum); >+ setContextBiblioNumbers( bibnums ); >+ setContextBiblioNumbers( $.uniqueArray( bibnums ) ); >+} >+ >+function delBibToContext( bibnum ) { >+ var bibnums = getContextBiblioNumbers(); >+ removeByValue( bibnums, bibnum ); >+ setContextBiblioNumbers( $.uniqueArray( bibnums ) ); >+} >+ >+function setContextBiblioNumbers( bibnums ) { >+ $.cookie('bibs_selected', JSON.stringify( bibnums )); >+} >+ >+function getContextBiblioNumbers() { >+ var r = $.cookie('bibs_selected'); >+ if ( r ) { >+ return JSON.parse(r); >+ } >+ r = new Array(); >+ return r; >+} >+ >+function resetSearchContext() { >+ setContextBiblioNumbers( new Array() ); >+} >-- >2.11.0
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 25363
:
104280
|
104388
|
105751