bug 2509: fix file permissions
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / lib / greybox / GreyBox_v5_5 / greybox_source / set / set.js
1 GB_showFullScreenSet = function(set, start_index, callback_fn) {
2     var options = {
3         type: 'page',
4         fullscreen: true,
5         center_win: false
6     }
7     var gb_sets = new GB_Sets(options, set);
8     gb_sets.addCallback(callback_fn);
9     gb_sets.showSet(start_index-1);
10     return false;
11 }
12
13 GB_showImageSet = function(set, start_index, callback_fn) {
14     var options = {
15         type: 'image',
16         fullscreen: false,
17         center_win: true,
18         width: 300,
19         height: 300
20     }
21     var gb_sets = new GB_Sets(options, set);
22     gb_sets.addCallback(callback_fn);
23     gb_sets.showSet(start_index-1);
24     return false;
25 }
26
27 GB_Sets = GB_Gallery.extend({
28     init: function(options, set) {
29         this.parent(options);
30         if(!this.img_next) this.img_next = this.root_dir + 'next.gif';
31         if(!this.img_prev) this.img_prev = this.root_dir + 'prev.gif';
32         this.current_set = set; 
33     },
34
35     showSet: function(start_index) {
36         this.current_index = start_index;
37
38         var item = this.current_set[this.current_index];
39         this.show(item.url);
40         this._setCaption(item.caption);
41
42         this.btn_prev = AJS.IMG({'class': 'left', src: this.img_prev});
43         this.btn_next = AJS.IMG({'class': 'right', src: this.img_next});
44
45         AJS.AEV(this.btn_prev, 'click', AJS.$b(this.switchPrev, this));
46         AJS.AEV(this.btn_next, 'click', AJS.$b(this.switchNext, this));
47
48         GB_STATUS = AJS.SPAN({'class': 'GB_navStatus'});
49         AJS.ACN(AJS.$('GB_middle'), this.btn_prev, GB_STATUS, this.btn_next);
50         
51         this.updateStatus();
52     },
53
54     updateStatus: function() {
55         AJS.setHTML(GB_STATUS, (this.current_index + 1) + ' / ' + this.current_set.length);
56         if(this.current_index == 0) {
57             AJS.addClass(this.btn_prev, 'disabled');
58         }
59         else {
60             AJS.removeClass(this.btn_prev, 'disabled');
61         }
62
63         if(this.current_index == this.current_set.length-1) {
64             AJS.addClass(this.btn_next, 'disabled');
65         }
66         else {
67             AJS.removeClass(this.btn_next, 'disabled');
68         }
69     },
70
71     _setCaption: function(caption) {
72         AJS.setHTML(AJS.$('GB_caption'), caption);
73     },
74
75     updateFrame: function() {
76         var item = this.current_set[this.current_index];
77         this._setCaption(item.caption);
78         this.url = item.url;
79         this.startLoading();
80     },
81
82     switchPrev: function() {
83         if(this.current_index != 0) {
84             this.current_index--;
85             this.updateFrame();
86             this.updateStatus();
87         }
88     },
89
90     switchNext: function() {
91         if(this.current_index != this.current_set.length-1) {
92             this.current_index++
93             this.updateFrame();
94             this.updateStatus();
95         }
96     }
97 });
98
99 AJS.AEV(window, 'load', function() {
100     AJS.preloadImages(GB_ROOT_DIR+'next.gif', GB_ROOT_DIR+'prev.gif');
101 });