|
Lines 1-4
Link Here
|
| 1 |
/* global shortcut delCookie delBasket Sticky */ |
1 |
/* global shortcut delCookie delBasket Sticky */ |
|
|
2 |
/* exported paramOfUrl addBibToContext delBibToContext */ |
| 2 |
if ( KOHA === undefined ) var KOHA = {}; |
3 |
if ( KOHA === undefined ) var KOHA = {}; |
| 3 |
|
4 |
|
| 4 |
function _(s) { return s; } // dummy function for gettext |
5 |
function _(s) { return s; } // dummy function for gettext |
|
Lines 126-131
$.fn.selectTabByID = function (tabID) {
Link Here
|
| 126 |
$.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" }); |
127 |
$.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" }); |
| 127 |
} |
128 |
} |
| 128 |
$.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" }); |
129 |
$.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" }); |
|
|
130 |
|
| 131 |
/* Search results browsing */ |
| 132 |
/* forms with action leading to search */ |
| 133 |
$("form[action*='search.pl']").submit(function(){ |
| 134 |
resetSearchContext(); |
| 135 |
}); |
| 136 |
/* any link to launch a search except navigation links */ |
| 137 |
$("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ |
| 138 |
resetSearchContext(); |
| 139 |
}); |
| 140 |
/* any link to a detail page from the results page. */ |
| 141 |
$("#bookbag_form a[href*='detail.pl?']").click(function(){ |
| 142 |
resetSearchContext(); |
| 143 |
}); |
| 144 |
|
| 129 |
}); |
145 |
}); |
| 130 |
|
146 |
|
| 131 |
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html |
147 |
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html |
|
Lines 239-241
function keep_text(clicked_index) {
Link Here
|
| 239 |
searchboxes[i].value = persist; |
255 |
searchboxes[i].value = persist; |
| 240 |
} |
256 |
} |
| 241 |
} |
257 |
} |
| 242 |
- |
258 |
|
|
|
259 |
// Extends jQuery API |
| 260 |
jQuery.extend({uniqueArray:function(array){ |
| 261 |
return $.grep(array, function(el, index) { |
| 262 |
return index === $.inArray(el, array); |
| 263 |
}); |
| 264 |
}}); |
| 265 |
|
| 266 |
function removeByValue(arr, val) { |
| 267 |
for(var i=0; i<arr.length; i++) { |
| 268 |
if(arr[i] == val) { |
| 269 |
arr.splice(i, 1); |
| 270 |
break; |
| 271 |
} |
| 272 |
} |
| 273 |
} |
| 274 |
|
| 275 |
function paramOfUrl( url, param ) { |
| 276 |
param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); |
| 277 |
var regexS = "[\\?&]"+param+"=([^&#]*)"; |
| 278 |
var regex = new RegExp( regexS ); |
| 279 |
var results = regex.exec( url ); |
| 280 |
if( results == null ) { |
| 281 |
return ""; |
| 282 |
} else { |
| 283 |
return results[1]; |
| 284 |
} |
| 285 |
} |
| 286 |
|
| 287 |
function addBibToContext( bibnum ) { |
| 288 |
bibnum = parseInt(bibnum, 10); |
| 289 |
var bibnums = getContextBiblioNumbers(); |
| 290 |
bibnums.push(bibnum); |
| 291 |
setContextBiblioNumbers( bibnums ); |
| 292 |
setContextBiblioNumbers( $.uniqueArray( bibnums ) ); |
| 293 |
} |
| 294 |
|
| 295 |
function delBibToContext( bibnum ) { |
| 296 |
var bibnums = getContextBiblioNumbers(); |
| 297 |
removeByValue( bibnums, bibnum ); |
| 298 |
setContextBiblioNumbers( $.uniqueArray( bibnums ) ); |
| 299 |
} |
| 300 |
|
| 301 |
function setContextBiblioNumbers( bibnums ) { |
| 302 |
$.cookie('bibs_selected', JSON.stringify( bibnums )); |
| 303 |
} |
| 304 |
|
| 305 |
function getContextBiblioNumbers() { |
| 306 |
var r = $.cookie('bibs_selected'); |
| 307 |
if ( r ) { |
| 308 |
return JSON.parse(r); |
| 309 |
} |
| 310 |
r = new Array(); |
| 311 |
return r; |
| 312 |
} |
| 313 |
|
| 314 |
function resetSearchContext() { |
| 315 |
setContextBiblioNumbers( new Array() ); |
| 316 |
} |