|
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 119-124
$.fn.selectTabByID = function (tabID) {
Link Here
|
| 119 |
$.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" }); |
120 |
$.cookie("lastborrowercard", $("#hiddenborrowercard").val(), { path: "/" }); |
| 120 |
} |
121 |
} |
| 121 |
$.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" }); |
122 |
$.cookie("currentborrowernumber", $("#hiddenborrowernumber").val(), { path: "/" }); |
|
|
123 |
|
| 124 |
/* Search results browsing */ |
| 125 |
/* forms with action leading to search */ |
| 126 |
$("form[action*='search.pl']").submit(function(){ |
| 127 |
resetSearchContext(); |
| 128 |
}); |
| 129 |
/* any link to launch a search except navigation links */ |
| 130 |
$("[href*='search.pl?']").not(".nav").not('.searchwithcontext').click(function(){ |
| 131 |
resetSearchContext(); |
| 132 |
}); |
| 133 |
/* any link to a detail page from the results page. */ |
| 134 |
$("#bookbag_form a[href*='detail.pl?']").click(function(){ |
| 135 |
resetSearchContext(); |
| 136 |
}); |
| 137 |
|
| 122 |
}); |
138 |
}); |
| 123 |
|
139 |
|
| 124 |
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html |
140 |
// http://jennifermadden.com/javascript/stringEnterKeyDetector.html |
|
Lines 232-234
function keep_text(clicked_index) {
Link Here
|
| 232 |
searchboxes[i].value = persist; |
248 |
searchboxes[i].value = persist; |
| 233 |
} |
249 |
} |
| 234 |
} |
250 |
} |
| 235 |
- |
251 |
|
|
|
252 |
// Extends jQuery API |
| 253 |
jQuery.extend({uniqueArray:function(array){ |
| 254 |
return $.grep(array, function(el, index) { |
| 255 |
return index === $.inArray(el, array); |
| 256 |
}); |
| 257 |
}}); |
| 258 |
|
| 259 |
function removeByValue(arr, val) { |
| 260 |
for(var i=0; i<arr.length; i++) { |
| 261 |
if(arr[i] == val) { |
| 262 |
arr.splice(i, 1); |
| 263 |
break; |
| 264 |
} |
| 265 |
} |
| 266 |
} |
| 267 |
|
| 268 |
function paramOfUrl( url, param ) { |
| 269 |
param = param.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); |
| 270 |
var regexS = "[\\?&]"+param+"=([^&#]*)"; |
| 271 |
var regex = new RegExp( regexS ); |
| 272 |
var results = regex.exec( url ); |
| 273 |
if( results == null ) { |
| 274 |
return ""; |
| 275 |
} else { |
| 276 |
return results[1]; |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 280 |
function addBibToContext( bibnum ) { |
| 281 |
bibnum = parseInt(bibnum, 10); |
| 282 |
var bibnums = getContextBiblioNumbers(); |
| 283 |
bibnums.push(bibnum); |
| 284 |
setContextBiblioNumbers( bibnums ); |
| 285 |
setContextBiblioNumbers( $.uniqueArray( bibnums ) ); |
| 286 |
} |
| 287 |
|
| 288 |
function delBibToContext( bibnum ) { |
| 289 |
var bibnums = getContextBiblioNumbers(); |
| 290 |
removeByValue( bibnums, bibnum ); |
| 291 |
setContextBiblioNumbers( $.uniqueArray( bibnums ) ); |
| 292 |
} |
| 293 |
|
| 294 |
function setContextBiblioNumbers( bibnums ) { |
| 295 |
$.cookie('bibs_selected', JSON.stringify( bibnums )); |
| 296 |
} |
| 297 |
|
| 298 |
function getContextBiblioNumbers() { |
| 299 |
var r = $.cookie('bibs_selected'); |
| 300 |
if ( r ) { |
| 301 |
return JSON.parse(r); |
| 302 |
} |
| 303 |
r = new Array(); |
| 304 |
return r; |
| 305 |
} |
| 306 |
|
| 307 |
function resetSearchContext() { |
| 308 |
setContextBiblioNumbers( new Array() ); |
| 309 |
} |