Bug 8597: fix hardcoded references to prog in ccsr
[koha.git] / koha-tmpl / opac-tmpl / ccsr / en / js / script.js
1 function _(s) { return s } // dummy function for gettext
2 function confirmDelete(message) {
3     return (confirm(message) ? true : false);
4 }
5
6 function Dopop(link) {
7     newin=window.open(link,'popup','width=500,height=400,toolbar=false,scrollbars=yes,resizeable=yes');
8 }
9
10 $.datepicker.setDefaults({
11         showOn: "both",
12         changeMonth: true,
13         changeYear: true,
14         buttonImage: '/opac-tmpl/prog/famfamfam/silk/calendar.png',
15         buttonImageOnly: true,
16         showButtonPanel: true
17     });
18
19 $(document).ready(function(){
20     $(".close").click(function(){
21         window.close();
22     });
23     $(".focus").focus();
24     $( ".datepicker" ).datepicker();
25     // http://jqueryui.com/demos/datepicker/#date-range
26     var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({
27         changeMonth: true,
28         numberOfMonths: 1,
29         onSelect: function( selectedDate ) {
30             var option = this.id == "from" ? "minDate" : "maxDate",
31                 instance = $( this ).data( "datepicker" );
32                 date = $.datepicker.parseDate(
33                     instance.settings.dateFormat ||
34                     $.datepicker._defaults.dateFormat,
35                     selectedDate, instance.settings );
36             dates.not( this ).datepicker( "option", option, date );
37         }
38     });
39     // clear the basket when user logs out
40     $("#logout").click(function(){
41         var nameCookie = "bib_list";
42         var valCookie = readCookie(nameCookie);
43         if (valCookie) { // basket has contents
44             updateBasket(0,null);
45             delCookie(nameCookie);
46             return true;
47         } else {
48             return true;
49         }
50     });
51
52
53      // Add the mobile menu button if we are in some sections of the opac
54    if($('body#opac-user, body#opac-passwd, body#opac-search-history, body#opac-readingrecord, body#opac-userupdate, body#opac-usersuggestions, body#opac-account, body#opac-privacy, body#opac-usertags').length != 0) {
55           $('body').addClass('mobile_menu');
56
57             var button = $('<input type="button" id="mobile_menu_button" value="">').addClass('mobile_only');
58               $('#searchform').append(button);
59
60               button.click(function() {
61                       if($('body').hasClass('mobile_menu_opened')){
62                           $('body').removeClass('mobile_menu_opened');
63                    }
64                       else {
65                          $('body').addClass('mobile_menu_opened');
66                       }
67               });
68     }
69 });
70
71 // build Change Language menus
72 YAHOO.util.Event.onContentReady("changelanguage", function () {
73     $(".sublangs").each(function(){
74         var menuid = $(this).attr("id");
75         var menuid = menuid.replace("show","");
76
77         var oMenu = new YAHOO.widget.Menu("sub"+menuid, { zindex: 2 });
78         function positionoMenu() {
79             oMenu.align("bl", "tl");
80         }
81         oMenu.subscribe("beforeShow", function () {
82         if (this.getRoot() == this) {
83             positionoMenu();
84         }
85         });
86         oMenu.render();
87         oMenu.cfg.setProperty("context", ["show"+menuid, "bl", "tl"]);
88         function onYahooClick(p_oEvent) {
89             // Position and display the menu
90             positionoMenu();
91             oMenu.show();
92             // Stop propagation and prevent the default "click" behavior
93             YAHOO.util.Event.stopEvent(p_oEvent);
94         }
95         YAHOO.util.Event.addListener("show"+menuid, "click", onYahooClick);
96         YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionoMenu);
97
98     });
99 });
100
101 /*
102 // Build lists menu
103 YAHOO.util.Event.onContentReady("listsmenu", function () {
104     YAHOO.widget.Menu.prototype.onRender = function () { };
105     $("#listsmenu").css("display","block").css("visibility","hidden");
106     $("#listsmenulink").attr("href","#");
107     var listMenu = new YAHOO.widget.Menu("listsmenu");
108         listMenu.render();
109         listMenu.cfg.setProperty("context", ["listsmenulink", "tr", "br"]);
110         listMenu.cfg.setProperty("effect",{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.05});
111         listMenu.subscribe("beforeShow",positionlistMenu);
112         listMenu.subscribe("show", listMenu.focus);
113         function positionlistMenu() {
114                     listMenu.align("tr", "br");
115         }
116         YAHOO.util.Event.addListener("listsmenulink", "click", listMenu.show, null, listMenu);
117         YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionlistMenu);
118  });
119 */
120
121 jQuery.fn.preventDoubleFormSubmit = function() {
122     jQuery(this).submit(function() {
123         if (this.beenSubmitted)
124             return false;
125         else
126             this.beenSubmitted = true;
127     });
128 };