]> www.average.org Git - mkgallery.git/blobdiff - include/showwin.js
fix image centering issue
[mkgallery.git] / include / showwin.js
index c900ab4decbd10e92094e6e57f4f7aee04561e3f..00f91ce3727cb48e9efc3c1c1e332ed35c47555b 100644 (file)
@@ -9,7 +9,7 @@
 */
 
 /*
-       Hidable "fullscreen" Window for Slideshow
+       Hideable "fullscreen" Window for Slideshow
 */
 
 var showWindow = new Class({
@@ -20,6 +20,7 @@ var showWindow = new Class({
                        container: document.body,
                        tohide: '',
                        onClick: $empty,
+                       onKeypress: $empty,
                }
        },
 
@@ -43,20 +44,22 @@ var showWindow = new Class({
                        display: 'none'
                }).addEvent('click', function(){
                        this.options.onClick()
+               }.bind(this)).addEvent('keypress', function(){
+                       this.options.onKeypress()
                }.bind(this)).injectInside(this.options.container);
 
-               this.position();
-
                window.addEvent('resize', this.position.bind(this));
                window.addEvent('scroll', this.position.bind(this));
        },
 
        position: function(){
                if(this.options.container == document.body){
+                       this.w = window.getWidth();
                        this.h = window.getHeight();
                        this.s = window.getScrollTop();
                }else{
                        var myCoords = this.options.container.getCoordinates();
+                       this.w = myCoords.width;
                        this.h = myCoords.height;
                        this.s = myCoords.top;
                }
@@ -66,6 +69,14 @@ var showWindow = new Class({
                })
        },
 
+       getCoordinates: function(){
+               return {
+                       width: this.w,
+                       height: this.h,
+                       top: this.s,
+               };
+       },
+
        show: function(){
                if (this.options.tohide) {
                        this.hiddenstyles = this.options.tohide.getStyles(
@@ -83,6 +94,7 @@ var showWindow = new Class({
                        'overflow-x': 'hidden',
                        'overflow-y': 'hidden',
                });
+               this.position();
                this.container.setStyle('display', 'block');
        },