]> www.average.org Git - mkgallery.git/blobdiff - include/controls.js
remove creation of the rss/atom feeds - it does not work anyway
[mkgallery.git] / include / controls.js
index 4aa3002535870253f2d29a0484e12c1eeac0e1e8..ba0d89aae9d441d52add4cb9f1aeee09bcb0bcea 100644 (file)
@@ -26,9 +26,8 @@ var Controls = new Class({
        getOptions: function(){
                return {
                        onClick: $empty,
-                       zIndex: 3,
-                       buttonClass: 'controlButton',
-                       buttons: ['prev','stop','play','next','exit','comm'],
+                       zIndex: 9,
+                       buttonClass: 'controlButton'
                }
        },
 
@@ -38,18 +37,19 @@ var Controls = new Class({
                this.container = new Element('div').addClass(name).
                setProperties({
                        id: name,
-                       name: name,
+                       name: name
                }).setStyles({
-                       zIndex: this.options.zIndex,
+                       zIndex: this.options.zIndex
                }).addEvent('click', function(){
                        this.options.onClick()
                }.bind(this)).injectInside(this.parent);
-               this.options.buttons.each(function(el){
+               var buttons = ['prev','stop','play','next','exit','comm'];
+               buttons.each(function(el){
                        var sub = new Element('div');
                        sub.addClass(this.options.buttonClass).setProperties({
                                id: el,
                                name: el,
-                               title: el,
+                               title: el
                        }).addEvent('click', function(){
                                this[el]();
                        }.bind(this)).injectInside(this.container);
@@ -57,13 +57,13 @@ var Controls = new Class({
                },this);
                this.posbox = new Element('span').
                addClass('controlPosition').setProperties({
-                       id: 'controlPosition',
+                       id: 'controlPosition'
                }).injectInside(this.commbox);
                this.refbox = new Element('a', {
                        href: 'javascript: void(1);',
-                       html: 'title',
+                       html: 'title'
                }).addClass('controlRef').setProperties({
-                       id: 'controlRef',
+                       id: 'controlRef'
                }).injectInside(this.commbox);
        },
 
@@ -72,6 +72,7 @@ var Controls = new Class({
        },
 
        prev: function(){
+               if (this.prevdisabled) { return; }
                if (this.show.prev) { this.show.prev() }
                else { alert('no method for "prev", file complaint with UN') }
        },
@@ -87,6 +88,7 @@ var Controls = new Class({
        },
 
        next: function(){
+               if (this.nextdisabled) { return; }
                if (this.show.next) { this.show.next() }
                else { alert('no method for "next", file complaint with UN') }
        },
@@ -102,10 +104,24 @@ var Controls = new Class({
        },
 
        info: function(pos, max, ref, txt){
-               var msg = 'pos='+pos+', max='+max+', ref='+ref+', txt='+txt;
+               var p1 = pos + 1;
                this.refbox.set('html',txt);
                this.refbox.set('href',ref);
-               this.posbox.set('text',pos+' of '+max);
+               this.posbox.set('text',p1+' of '+max);
+               if (p1 < 2) {
+                       this.prevbox.set('id', 'prevDisabled');
+                       this.prevdisabled = true;
+               } else {
+                       this.prevbox.set('id', 'prev');
+                       this.prevdisabled = false;
+               }
+               if (p1 >= max) {
+                       this.nextbox.set('id', 'nextDisabled');
+                       this.nextdisabled = true;
+               } else {
+                       this.nextbox.set('id', 'next');
+                       this.nextdisabled = false;
+               }
        },
 
        running: function(isrunning){
@@ -116,7 +132,8 @@ var Controls = new Class({
                        this.stopbox.setStyle('display', 'none');
                        this.playbox.setStyle('display', 'block');
                }
-       },
+       }
 });
+
 Controls.implement(new Options);