forked from damiengarbarino/dojo-calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathColumnViewSecondarySheet.js
118 lines (97 loc) · 2.81 KB
/
ColumnViewSecondarySheet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
define([
"dcl/dcl",
"delite/register",
"dojo/dom-geometry",
"dojo/dom-style",
"./MatrixView",
"delite/handlebars!./templates/ColumnViewSecondarySheet.html"
], function (
dcl,
register,
domGeometry,
domStyle,
MatrixView,
template
) {
return register("d-calendar-column-view-secondary-sheet", [MatrixView], {
// summary:
// This class defines a matrix view designed to be embedded in a column view,
// usually to display long or all day events on one row.
template: template,
baseClass: "d-calendar-matrix-view d-calendar-column-view-secondary-sheet",
rowCount: 1,
cellPaddingTop: 4,
_defaultHeight: -1,
layoutDuringResize: true,
_defaultItemToRendererKindFunc: function (item) {
// tags:
// private
return item.allDay ? "horizontal" : null;
},
_formatGridCellLabel: function () {
return null;
},
_formatRowHeaderLabel: function () {
return null;
},
// events redispatch
__fixEvt: function (e) {
e.sheet = "secondary";
e.source = this;
return e;
},
_layoutExpandRenderers: dcl.superCall(function (sup) {
return function () {
if (!this.expandRenderer || this._expandedRowCol == -1) {
return;
}
var h = domGeometry.getMarginBox(this).h;
if (this._defaultHeight == -1 || // not set
this._defaultHeight === 0) { // initialized at 0, must be reset
this._defaultHeight = h;
}
if (this._defaultHeight != h && h >= this._getExpandedHeight() ||
this._expandedRowCol !== undefined && this._expandedRowCol !== -1) {
var col = this._expandedRowCol;
if (col >= this.columnCount) {
col = 0;
}
this._layoutExpandRendererImpl(0, col, null, true);
} else {
sup.apply(this, arguments);
}
};
}),
expandRendererClickHandler: function (e, renderer) {
// summary:
// Default action when an expand renderer is clicked.
// This method will expand the secondary sheet to show all the events.
// e: Event
// The mouse event.
// renderer: Object
// The renderer that was clicked.
// tags:
// callback
e.stopPropagation();
var h = domGeometry.getMarginBox(this).h;
var expandedH = this._getExpandedHeight();
if (this._defaultHeight == h || h < expandedH) {
this._expandedRowCol = renderer.columnIndex;
} else {
delete this._expandedRowCol;
}
},
_getExpandedHeight: function () {
// tags:
// private
return (this.naturalRowsHeight && this.naturalRowsHeight.length > 0 ? this.naturalRowsHeight[0] : 0) +
this.expandRendererHeight + this.verticalGap + this.verticalGap;
},
refreshRendering: function () {
// make sure to show the expand/collapse renderer if no item is displayed but the row was expanded.
if (!this.visibleItems || this.visibleItems.length === 0) {
this._layoutExpandRenderers(0, false, null);
}
}
});
});