hide scroll bars when going to show mode; some rearrangement
[mkgallery.git] / include / showwin.js
1 /*
2         $Id$
3
4         This is a part of mkgallery.pl suite
5         http://www.average.org/mkgallery/
6
7         Uses mootools (1.2) http://www.mootools.net/
8         Uses slideshow http://www.phatfusion.net/slideshow/
9 */
10
11 /*
12         Hidable "fullscreen" Window for Slideshow
13 */
14
15 var showWindow = new Class({
16
17         getOptions: function(){
18                 return {
19                         zIndex: 2,
20                         container: document.body,
21                         tohide: '',
22                         onClick: $empty,
23                 }
24         },
25
26         initialize: function(name,options){
27                 this.setOptions(this.getOptions(), options);
28
29                 this.options.container = $(this.options.container);
30                 this.options.tohide = $(this.options.tohide);
31
32                 this.container = new Element('div').addClass(name).
33                 setProperties({
34                         id: name,
35                         name: name,
36                 }).setStyles({
37                         position: 'absolute',
38                         left: '0px',
39                         top: '0px',
40                         width: '100%',
41                         zIndex: this.options.zIndex,
42                         overflow: 'hidden',
43                         display: 'none'
44                 }).addEvent('click', function(){
45                         this.options.onClick()
46                 }.bind(this)).injectInside(this.options.container);
47
48                 this.position();
49
50                 window.addEvent('resize', this.position.bind(this));
51                 window.addEvent('scroll', this.position.bind(this));
52         },
53
54         position: function(){
55                 if(this.options.container == document.body){
56                         this.h = window.getHeight();
57                         this.s = window.getScrollTop();
58                 }else{
59                         var myCoords = this.options.container.getCoordinates();
60                         this.h = myCoords.height;
61                         this.s = myCoords.top;
62                 }
63                 this.container.setStyles({
64                         top: this.s+'px',
65                         height: this.h+'px'
66                 })
67         },
68
69         show: function(){
70                 if (this.options.tohide) {
71                         this.hiddenstyles = this.options.tohide.getStyles(
72                                 'display'
73                         );
74                         this.options.tohide.setStyles({
75                                 display: 'none',
76                         });
77                 }
78                 this.bodystyles = document.body.getStyles(
79                         'overflow', 'overflow-x', 'overflow-y'
80                 );
81                 document.body.setStyles({
82                         overflow: 'hidden',
83                         'overflow-x': 'hidden',
84                         'overflow-y': 'hidden',
85                 });
86                 this.container.setStyle('display', 'block');
87         },
88
89         hide: function(){
90                 if (this.options.tohide) {
91                         this.options.tohide.setStyles(this.hiddenstyles);
92                 }
93                 document.body.setStyles(this.bodystyles);
94                 this.container.setStyle('display', 'none');
95         }
96 })
97 showWindow.implement(new Options);
98