devextreme
Version:
HTML5 JavaScript Component Suite for Responsive Web Development
99 lines (74 loc) • 3.93 kB
JavaScript
"use strict";
var $ = require("../../core/renderer"),
Shader = require("./ui.scheduler.current_time_shader");
var DATE_TIME_SHADER_ALL_DAY_CLASS = "dx-scheduler-date-time-shader-all-day",
DATE_TIME_SHADER_TOP_CLASS = "dx-scheduler-date-time-shader-top",
DATE_TIME_SHADER_BOTTOM_CLASS = "dx-scheduler-date-time-shader-bottom";
var VerticalCurrentTimeShader = Shader.inherit({
_renderShader: function _renderShader() {
var shaderHeight = this._getShaderHeight(),
maxHeight = this._getShaderMaxHeight(),
renderSolidShader = false;
if (shaderHeight > maxHeight) {
shaderHeight = maxHeight;
renderSolidShader = true;
}
if (shaderHeight >= 0) {
this._$shader.height(shaderHeight);
var groupCount = this._workspace._getGroupCount() || 1;
if (renderSolidShader) {
this._renderTopShader(this._$shader, shaderHeight, this._$container.get(0).getBoundingClientRect().width, 0);
this._renderAllDayShader(this._$container.get(0).getBoundingClientRect().width, 0);
} else {
for (var i = 0; i < groupCount; i++) {
var shaderWidth = this._getShaderWidth(i);
this._renderTopShader(this._$shader, shaderHeight, shaderWidth, i);
this._renderBottomShader(this._$shader, maxHeight - shaderHeight, shaderWidth, i);
this._renderAllDayShader(shaderWidth, i);
}
}
}
},
_renderTopShader: function _renderTopShader($shader, height, width, i) {
this._$topShader = $("<div>").addClass(DATE_TIME_SHADER_TOP_CLASS);
width && this._$topShader.width(width) && this._$topShader.height(height);
this._$topShader.css("marginTop", this._getShaderTopOffset(i));
this._$topShader.css("left", this._getShaderOffset(i, width));
$shader.append(this._$topShader);
},
_renderBottomShader: function _renderBottomShader($shader, height, width, i) {
this._$bottomShader = $("<div>").addClass(DATE_TIME_SHADER_BOTTOM_CLASS);
this._$bottomShader.width(width - this._workspace.getCellWidth()) && this._$bottomShader.height(height);
this._$bottomShader.css("left", this._getShaderOffset(i, width - this._workspace.getCellWidth()));
$shader.append(this._$bottomShader);
},
_renderAllDayShader: function _renderAllDayShader(shaderWidth, i) {
if (this._workspace.option("showAllDayPanel")) {
this._$allDayIndicator = $("<div>").addClass(DATE_TIME_SHADER_ALL_DAY_CLASS);
this._$allDayIndicator.height(this._workspace.getAllDayHeight());
this._$allDayIndicator.width(shaderWidth);
this._$allDayIndicator.css("left", this._getShaderOffset(i, shaderWidth));
this._workspace._$allDayPanel.prepend(this._$allDayIndicator);
}
},
_getShaderOffset: function _getShaderOffset(i, width) {
return this._workspace.getGroupedStrategy().getShaderOffset(i, width);
},
_getShaderTopOffset: function _getShaderTopOffset(i) {
return this._workspace.getGroupedStrategy().getShaderTopOffset(i);
},
_getShaderHeight: function _getShaderHeight(i, width) {
return this._workspace.getGroupedStrategy().getShaderHeight();
},
_getShaderMaxHeight: function _getShaderMaxHeight(i, width) {
return this._workspace.getGroupedStrategy().getShaderMaxHeight();
},
_getShaderWidth: function _getShaderWidth(i) {
return this._workspace.getGroupedStrategy().getShaderWidth(i);
},
clean: function clean() {
this.callBase();
this._workspace && this._workspace._$allDayPanel && this._workspace._$allDayPanel.find("." + DATE_TIME_SHADER_ALL_DAY_CLASS).remove();
}
});
module.exports = VerticalCurrentTimeShader;