]> www.average.org Git - mkgallery.git/blob - include/showwin.js
wip
[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                         onClick: $empty,
22                 }
23         },
24
25         initialize: function(name,options){
26                 this.setOptions(this.getOptions(), options);
27
28                 this.options.container = $(this.options.container);
29
30                 this.container = new Element('div').addClass(name).
31                 setProperties({
32                         id: name,
33                         name: name,
34                 }).setStyles({
35                         position: 'absolute',
36                         left: '0px',
37                         top: '0px',
38                         width: '100%',
39                         zIndex: this.options.zIndex,
40                         overflow: 'hidden',
41                         display: 'none'
42                 }).addEvent('click', function(){
43                         this.options.onClick()
44                 }.bind(this)).injectInside(this.options.container);
45
46                 this.position();
47
48                 window.addEvent('resize', this.position.bind(this));
49                 window.addEvent('scroll', this.position.bind(this));
50         },
51
52         position: function(){
53                 if(this.options.container == document.body){
54                         this.h = window.getHeight();
55                         this.s = window.getScrollTop();
56                 }else{
57                         var myCoords = this.options.container.getCoordinates();
58                         this.h = myCoords.height;
59                         this.s = myCoords.top;
60                 }
61                 this.container.setStyles({
62                         top: this.s+'px',
63                         height: this.h+'px'
64                 })
65         },
66
67         show: function(){
68                 this.container.setStyle('display', 'block');
69         },
70
71         hide: function(){
72                 this.container.setStyle('display', 'none');
73         }
74 })
75 showWindow.implement(new Options);
76