try and get ctrl-enter to add a clear all
[roojs1] / Roo / bootstrap / DocumentSlider.js
index db07806..043ae0c 100644 (file)
@@ -7,7 +7,6 @@
  * @class Roo.bootstrap.DocumentSlider
  * @extends Roo.bootstrap.Component
  * Bootstrap DocumentSlider class
- * @cfg {Number} total 
  * 
  * @constructor
  * Create a new DocumentViewer
@@ -23,9 +22,21 @@ Roo.bootstrap.DocumentSlider = function(config){
         /**
          * @event initial
          * Fire after initEvent
-         * @param {Roo.bootstrap.DocumentViewer} this
+         * @param {Roo.bootstrap.DocumentSlider} this
          */
-        "initial" : true
+        "initial" : true,
+        /**
+         * @event update
+         * Fire after update
+         * @param {Roo.bootstrap.DocumentSlider} this
+         */
+        "update" : true,
+        /**
+         * @event click
+         * Fire after click
+         * @param {Roo.bootstrap.DocumentSlider} this
+         */
+        "click" : true
     });
 };
 
@@ -116,6 +127,8 @@ Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component,  {
         this.nextIndicator = this.el.select('.roo-document-slider-next i', true).first();
         this.nextIndicator.setVisibilityMode(Roo.Element.DISPLAY);
         
+        this.thumbEl.on('click', this.onClick, this);
+        
         this.prevIndicator.on('click', this.prev, this);
         
         this.nextIndicator.on('click', this.next, this);
@@ -134,30 +147,47 @@ Roo.extend(Roo.bootstrap.DocumentSlider, Roo.bootstrap.Component,  {
     
     update : function()
     {
-        this.imageEl.attr('src', this.files[this.indicator]);
+        this.imageEl.attr('src', this.files[this.indicator - 1]);
         
         this.titleEl.dom.innerHTML = String.format('{0} / {1}', this.indicator, this.files.length);
         
-        this.thumbEl.scrollTo('top');
+        this.prevIndicator.show();
         
-        if(this.indicator <= 1){
+        if(this.indicator == 1){
             this.prevIndicator.hide();
         }
         
-        if(this.indicator == 0 || this.indicator == this.files.length){
+        this.nextIndicator.show();
+        
+        if(this.indicator == this.files.length){
             this.nextIndicator.hide();
         }
+        
+        this.thumbEl.scrollTo('top');
+        
+        this.fireEvent('update', this);
+    },
+    
+    onClick : function(e)
+    {
+        e.preventDefault();
+        
+        this.fireEvent('click', this);
     },
     
-    prev : function()
+    prev : function(e)
     {
-        this.indicator = Math.min(1, this.indicator - 1);
+        e.preventDefault();
+        
+        this.indicator = Math.max(1, this.indicator - 1);
         
         this.update();
     },
     
-    next : function()
+    next : function(e)
     {
+        e.preventDefault();
+        
         this.indicator = Math.min(this.files.length, this.indicator + 1);
         
         this.update();