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. Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
953a53d9d6
commit
814a7ecf47
|
|
@ -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 ) %]
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
@ -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
|
||||
|
|
@ -126,6 +127,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
|
||||
|
|
@ -239,3 +255,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() );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue