switch to "new" slideshow (which is not working yet)
[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.options.tohide.setStyle('display', 'none');
72                 }
73                 this.container.setStyle('display', 'block');
74         },
75
76         hide: function(){
77                 if (this.options.tohide) {
78                         this.options.tohide.setStyle('display', 'block');
79                 }
80                 this.container.setStyle('display', 'none');
81         }
82 })
83 showWindow.implement(new Options);
84