Fix Printproblem with offset 0
authorsstamer <s.stamer@metaways.de>
Tue, 6 Jan 2015 08:51:38 +0000 (09:51 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 8 Jan 2015 13:09:01 +0000 (14:09 +0100)
- 24:00

Change-Id: I72ce7bb393b9920309f62807bda9304b99ea8e54
Reviewed-on: http://gerrit.tine20.com/customers/1510
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Calendar/css/print.css
tine20/Calendar/js/DaysView.js
tine20/Calendar/js/EventUI.js
tine20/Calendar/js/Printer/DaysView.js

index 065e904..099707a 100644 (file)
@@ -48,7 +48,7 @@ div.page
 }
 
 .cal-print-daysview-day-dayOfMonth {
-    font-size: 20px;
+    font-size: 15px;
     font-weight: bold;
 }
 
index 5045341..a5e1cc7 100644 (file)
@@ -227,9 +227,9 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         
         this.dayStart = Ext.isDate(startTime) ? startTime : Date.parseDate(this.dayStart, 'H:i');
         this.dayEnd = Ext.isDate(endTime) ? endTime : Date.parseDate(this.dayEnd, 'H:i');
-        this.dayEndPx = this.getTimeOffset(this.dayEnd);
+        this.dayEndPx = this.getTimeOffset(this.dayEnd, true);
         
-        this.cropDayTime = !! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar') && !(!this.getTimeOffset(this.dayStart) && !this.getTimeOffset(this.dayEnd));
+        this.cropDayTime = !! Tine.Tinebase.configManager.get('daysviewcroptime', 'Calendar') && !(!this.getTimeOffset(this.dayStart, false) && !this.getTimeOffset(this.dayEnd, true));
         
         Tine.Calendar.DaysView.superclass.initComponent.apply(this, arguments);
     },
@@ -470,14 +470,12 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         
         // crop daytime
         if (this.cropDayTime) {
-            var cropStartPx = this.getTimeOffset(this.dayStart),
-                cropHeightPx = this.getTimeOffset(this.dayEnd) +2;
+            var cropStartPx = this.getTimeOffset(this.dayStart, false),
+                cropHeightPx = this.getTimeOffset(this.dayEnd, true) +2;
                 
             this.mainBody.setStyle('margin-top', '-' + cropStartPx + 'px');
-            if (this.getTimeOffset(this.dayEnd)) {
-                this.mainBody.setStyle('height', cropHeightPx + 'px');
-                this.mainBody.setStyle('overflow', 'hidden');
-            }
+            this.mainBody.setStyle('height', cropHeightPx + 'px');
+            this.mainBody.setStyle('overflow', 'hidden');
             this.scroller.addClass('cal-daysviewpanel-body-cropDayTime');
         }
         
@@ -495,7 +493,7 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
     
     scrollTo: function(time) {
         time = Ext.isDate(time) ? time : new Date();
-        this.scroller.dom.scrollTop = this.getTimeOffset(time);
+        this.scroller.dom.scrollTop = this.getTimeOffset(time, false);
     },
     
     onBeforeScroll: function() {
@@ -553,7 +551,7 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
     
     onShow: function() {
         this.onLayout();
-        this.scroller.dom.scrollTop = this.lastScrollPos || this.getTimeOffset(new Date());
+        this.scroller.dom.scrollTop = this.lastScrollPos || this.getTimeOffset(new Date(), false);
     },
     
     onBeforeHide: function() {
@@ -1205,10 +1203,11 @@ Ext.extend(Tine.Calendar.DaysView, Ext.Container, {
         }
     },
     
-    getTimeOffset: function(date) {
-        var d = this.granularityUnitHeights / this.timeGranularity;
+    getTimeOffset: function(date, isEnd) {
+        var d = this.granularityUnitHeights / this.timeGranularity
+            hours = isEnd && (date.getHours() == 0) ? 24 : date.getHours();
         
-        return Math.round(d * ( 60 * date.getHours() + date.getMinutes()));
+        return Math.round(d * ( 60 * hours + date.getMinutes()));
     },
     
     getTimeHeight: function(dtStart, dtEnd) {
index 1d237ca..3423650 100644 (file)
@@ -374,8 +374,8 @@ Tine.Calendar.DaysViewEventUI = Ext.extend(Tine.Calendar.EventUI, {
                 continue;
             }
             
-            var top = view.getTimeOffset(this.dtStart);
-            var height = this.startColNum == this.endColNum ? view.getTimeHeight(this.dtStart, this.dtEnd) : view.getTimeOffset(this.dtEnd);
+            var top = view.getTimeOffset(this.dtStart, false);
+            var height = this.startColNum == this.endColNum ? view.getTimeHeight(this.dtStart, this.dtEnd) : view.getTimeOffset(this.dtEnd, true);
             
             if (currColNum != this.startColNum) {
                 top = 0;
index 867e0e4..f94682f 100644 (file)
@@ -39,7 +39,7 @@ Tine.Calendar.Printer.DaysViewRenderer = Ext.extend(Tine.Calendar.Printer.BaseRe
         
         // resize header/scroller to fullsize
         header.style.height = [header.firstChild.style.height, header.style.height].sort().pop();
-        scroller.style.height = view.dayEndPx - view.getTimeOffset(view.dayStart) + 20 + 'px';
+        scroller.style.height = view.dayEndPx - view.getTimeOffset(view.dayStart, false) + 20 + 'px';
         scroller.style.width = null;
         
         return this.generateTitle(view) + node.innerHTML;