define daysView mouseWheelIncrement per config
authorCornelius Weiß <mail@corneliusweiss.de>
Thu, 19 Feb 2015 09:38:11 +0000 (10:38 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 25 Feb 2015 13:04:34 +0000 (14:04 +0100)
Change-Id: I54c160cae49e777910f1851150c9894bcb50da9d
Reviewed-on: http://gerrit.tine20.com/customers/1675
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/Config.php
tine20/Calendar/js/DaysView.js
tine20/Tinebase/js/ux/Function.createBuffered.js

index b9388d8..daebc35 100644 (file)
@@ -42,6 +42,13 @@ class Calendar_Config extends Tinebase_Config_Abstract
      * @var string
      */
     const CROP_DAYS_VIEW = 'daysviewcroptime';
+
+    /**
+     * Days view mouse wheel increment
+     *
+     * @var integer
+     */
+    const DAYS_VIEW_MOUSE_WHEEL_INCREMENT = 'daysviewwheelincrement';
     
     /**
      * Allow events outside the definition created by the edit dialog
@@ -119,6 +126,8 @@ class Calendar_Config extends Tinebase_Config_Abstract
             'description'           => 'Crop calendar view configured start and endtime.',
             'type'                  => Tinebase_Config_Abstract::TYPE_BOOL,
             'clientRegistryInclude' => true,
+            'setByAdminModule'      => false,
+            'setBySetupModule'      => false,
             'default'               => false
         
         ),
@@ -129,9 +138,24 @@ class Calendar_Config extends Tinebase_Config_Abstract
             'description'           => 'Allow events outside start and endtime.',
             'type'                  => Tinebase_Config_Abstract::TYPE_BOOL,
             'clientRegistryInclude' => true,
+            'setByAdminModule'      => false,
+            'setBySetupModule'      => false,
             'default'               => false
         
         ),
+        self::DAYS_VIEW_MOUSE_WHEEL_INCREMENT => array(
+                                    //_('Week View Mouse Wheel Increment')
+            'label'                 => 'Week View Mouse Wheel Increment',
+            //_('Crop calendar view configured start and endtime.')
+            'description'           => 'Number of pixels to scroll per mouse wheel',
+            'type'                  => Tinebase_Config_Abstract::TYPE_INT,
+            'clientRegistryInclude' => true,
+            'setByAdminModule'      => false,
+            'setBySetupModule'      => false,
+            'default'               => 50
+
+        ),
+
         self::ATTENDEE_STATUS => array(
                                    //_('Attendee Status Available')
             'label'                 => 'Attendee Status Available',
index e57d68d..c393b21 100644 (file)
@@ -106,6 +106,11 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
      */
     cropDayTime: false,
     /**
+     *  @cfg {Integer} wheelIncrement
+     *  the number of pixels to increment on mouse wheel scrolling (defaults to 50)
+     */
+    wheelIncrement: 50,
+    /**
      * @cfg {String} newEventSummary
      * _('New Event')
      */
@@ -241,12 +246,14 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         this.dayEndPx = this.getTimeOffset(this.dayEnd);
         
         this.cropDayTime = !! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar') && !(!this.getTimeOffset(this.dayStart) && !this.getTimeOffset(this.dayEnd));
-        
+
         if (this.cropDayTime) {
             this.defaultStart = Ext.isDate(defaultStartTime) ? defaultStartTime : Date.parseDate(this.defaultStart, 'H:i');
         } else {
             this.defaultStart = this.dayStart;
         }
+
+        this.wheelIncrement = Tine.Tinebase.configManager.get('daysviewwheelincrement', 'Calendar') || this.wheelIncrement;
         
         Tine.Calendar.DaysView.superclass.initComponent.apply(this, arguments);
     },
@@ -520,7 +527,21 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
 
         this.scroller.dom.scrollTop = scrollTop;
     },
-    
+
+    onMouseWheel: function(e) {
+        var d = e.getWheelDelta()*this.wheelIncrement*-1;
+        e.stopEvent();
+
+        var scrollTop = this.scroller.dom.scrollTop,
+            newTop = scrollTop + d,
+            sh = this.scroller.dom.scrollHeight-this.scroller.dom.clientHeight;
+
+        var s = Math.max(0, Math.min(sh, newTop));
+        if(s != scrollTop){
+            this.scroller.scrollTo('top', s);
+        }
+    },
+
     onBeforeScroll: function() {
         if (! this.isScrolling) {
             this.isScrolling = true;
@@ -1263,6 +1284,9 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         
         this.scroller = new E(this.mainWrap.dom.childNodes[1]);
         this.scroller.setStyle('overflow-x', 'hidden');
+
+
+        this.mon(this.scroller, 'mousewheel', this.onMouseWheel, this);
         this.mon(this.scroller, 'scroll', this.onBeforeScroll, this);
         this.mon(this.scroller, 'scroll', this.onScroll, this, {buffer: 200});
 
index bdc8665..1bd9107 100644 (file)
@@ -20,13 +20,14 @@ Ext.applyIf(Function.prototype, {
         return function(){
             var timerId;
             return function() {
-                var me = this;
+                var me = this,
+                    argsPassed = arguments;
                 if (timerId) {
                     clearInterval(timerId);
                     timerId = null;
                 }
                 timerId = setTimeout(function(){
-                    fn.apply(scope || me, args || arguments);
+                    fn.apply(scope || me, args || argsPassed);
                 }, buffer);
             };
         }();