Explorar el Código

revive weekNumberStyleAttr in BasicView

Adam Shaw hace 7 años
padre
commit
809b794858
Se han modificado 1 ficheros con 17 adiciones y 5 borrados
  1. 17 5
      src/basic/AbstractBasicView.ts

+ 17 - 5
src/basic/AbstractBasicView.ts

@@ -32,6 +32,7 @@ export default abstract class BasicView extends View {
   dayGrid: DayGrid // the main subcomponent that does most of the heavy lifting
   dayGrid: DayGrid // the main subcomponent that does most of the heavy lifting
 
 
   colWeekNumbersVisible: boolean
   colWeekNumbersVisible: boolean
+  weekNumberWidth: number
 
 
 
 
   constructor(context: ComponentContext, viewSpec: ViewSpec, dateProfileGenerator: DateProfileGenerator, parentEl: HTMLElement) {
   constructor(context: ComponentContext, viewSpec: ViewSpec, dateProfileGenerator: DateProfileGenerator, parentEl: HTMLElement) {
@@ -111,6 +112,15 @@ export default abstract class BasicView extends View {
   }
   }
 
 
 
 
+  // Generates an HTML attribute string for setting the width of the week number column, if it is known
+  weekNumberStyleAttr() {
+    if (this.weekNumberWidth != null) {
+      return 'style="width:' + this.weekNumberWidth + 'px"'
+    }
+    return ''
+  }
+
+
   // Determines whether each row should have a constant height
   // Determines whether each row should have a constant height
   hasRigidRows() {
   hasRigidRows() {
     let eventLimit = this.opt('eventLimit')
     let eventLimit = this.opt('eventLimit')
@@ -150,7 +160,9 @@ export default abstract class BasicView extends View {
 
 
     if (this.colWeekNumbersVisible) {
     if (this.colWeekNumbersVisible) {
       // Make sure all week number cells running down the side have the same width.
       // Make sure all week number cells running down the side have the same width.
-      matchCellWidths(findElements(this.el, '.fc-week-number'))
+      this.weekNumberWidth = matchCellWidths(
+        findElements(this.el, '.fc-week-number')
+      )
     }
     }
 
 
     // reset all heights to be natural
     // reset all heights to be natural
@@ -246,7 +258,7 @@ export default abstract class BasicView extends View {
 
 
     if (this.colWeekNumbersVisible) {
     if (this.colWeekNumbersVisible) {
       return '' +
       return '' +
-        '<th class="fc-week-number ' + theme.getClass('widgetHeader') + '">' +
+        '<th class="fc-week-number ' + theme.getClass('widgetHeader') + '" ' + this.weekNumberStyleAttr() + '>' +
           '<span>' + // needed for matchCellWidths
           '<span>' + // needed for matchCellWidths
             htmlEscape(this.opt('weekLabel')) +
             htmlEscape(this.opt('weekLabel')) +
           '</span>' +
           '</span>' +
@@ -268,7 +280,7 @@ export default abstract class BasicView extends View {
 
 
     if (this.colWeekNumbersVisible) {
     if (this.colWeekNumbersVisible) {
       return '' +
       return '' +
-        '<td class="fc-week-number">' +
+        '<td class="fc-week-number" ' + this.weekNumberStyleAttr() + '>' +
           buildGotoAnchorHtml( // aside from link, important for matchCellWidths
           buildGotoAnchorHtml( // aside from link, important for matchCellWidths
             this,
             this,
             { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 },
             { date: weekStart, type: 'week', forceOff: dayGrid.colCnt === 1 },
@@ -286,7 +298,7 @@ export default abstract class BasicView extends View {
     let { theme } = this
     let { theme } = this
 
 
     if (this.colWeekNumbersVisible) {
     if (this.colWeekNumbersVisible) {
-      return '<td class="fc-week-number ' + theme.getClass('widgetContent') + '"></td>'
+      return '<td class="fc-week-number ' + theme.getClass('widgetContent') + '" ' + this.weekNumberStyleAttr() + '></td>'
     }
     }
 
 
     return ''
     return ''
@@ -298,7 +310,7 @@ export default abstract class BasicView extends View {
   renderDayGridIntroHtml = () => {
   renderDayGridIntroHtml = () => {
 
 
     if (this.colWeekNumbersVisible) {
     if (this.colWeekNumbersVisible) {
-      return '<td class="fc-week-number"></td>'
+      return '<td class="fc-week-number" ' + this.weekNumberStyleAttr() + '></td>'
     }
     }
 
 
     return ''
     return ''