Bug 13385: Add field 508 to XSLT (OPAC and staff)
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / js / global.js
1 // http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery/5341855#5341855
2 String.prototype.format = function() { return formatstr(this, arguments) }
3 function formatstr(str, col) {
4     col = typeof col === 'object' ? col : Array.prototype.slice.call(arguments, 1);
5     var idx = 0;
6     return str.replace(/%%|%s|%(\d+)\$s/g, function (m, n) {
7         if (m == "%%") { return "%"; }
8         if (m == "%s") { return col[idx++]; }
9         return col[n];
10     });
11 };
12
13 function confirmDelete(message) {
14     return (confirm(message) ? true : false);
15 }
16
17 function Dopop(link) {
18     newin=window.open(link,'popup','width=500,height=400,toolbar=false,scrollbars=yes,resizeable=yes');
19 }
20
21 jQuery.fn.preventDoubleFormSubmit = function() {
22     jQuery(this).submit(function() {
23         if (this.beenSubmitted)
24             return false;
25         else
26             this.beenSubmitted = true;
27     });
28 };
29
30 function prefixOf (s, tok) {
31     var index = s.indexOf(tok);
32     return s.substring(0, index);
33 }
34 function suffixOf (s, tok) {
35     var index = s.indexOf(tok);
36     return s.substring(index + 1);
37 }