ui.scheduler.current_time_shader.vertical.js 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * DevExtreme (ui/scheduler/shaders/ui.scheduler.current_time_shader.vertical.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var $ = require("../../../core/renderer");
  11. var Shader = require("./ui.scheduler.current_time_shader");
  12. var DATE_TIME_SHADER_ALL_DAY_CLASS = "dx-scheduler-date-time-shader-all-day";
  13. var DATE_TIME_SHADER_TOP_CLASS = "dx-scheduler-date-time-shader-top";
  14. var DATE_TIME_SHADER_BOTTOM_CLASS = "dx-scheduler-date-time-shader-bottom";
  15. var VerticalCurrentTimeShader = Shader.inherit({
  16. _renderShader: function() {
  17. var shaderHeight = this._getShaderHeight();
  18. var maxHeight = this._getShaderMaxHeight();
  19. var renderSolidShader = false;
  20. if (shaderHeight > maxHeight) {
  21. shaderHeight = maxHeight;
  22. renderSolidShader = true
  23. }
  24. if (shaderHeight >= 0) {
  25. this._$shader.height(shaderHeight);
  26. var groupCount = this._workspace._getGroupCount() || 1;
  27. if (renderSolidShader) {
  28. this._renderTopShader(this._$shader, shaderHeight, this._$container.get(0).getBoundingClientRect().width, 0);
  29. this._renderAllDayShader(this._$container.get(0).getBoundingClientRect().width, 0)
  30. } else {
  31. for (var i = 0; i < groupCount; i++) {
  32. var shaderWidth = this._getShaderWidth(i);
  33. this._renderTopShader(this._$shader, shaderHeight, shaderWidth, i);
  34. this._renderBottomShader(this._$shader, maxHeight - shaderHeight, shaderWidth, i);
  35. this._renderAllDayShader(shaderWidth, i)
  36. }
  37. }
  38. }
  39. },
  40. _renderTopShader: function($shader, height, width, i) {
  41. this._$topShader = $("<div>").addClass(DATE_TIME_SHADER_TOP_CLASS);
  42. width && this._$topShader.width(width) && this._$topShader.height(height);
  43. this._$topShader.css("marginTop", this._getShaderTopOffset(i));
  44. this._$topShader.css("left", this._getShaderOffset(i, width));
  45. $shader.append(this._$topShader)
  46. },
  47. _renderBottomShader: function($shader, height, width, i) {
  48. this._$bottomShader = $("<div>").addClass(DATE_TIME_SHADER_BOTTOM_CLASS);
  49. this._$bottomShader.width(width - this._workspace.getCellWidth()) && this._$bottomShader.height(height);
  50. this._$bottomShader.css("left", this._getShaderOffset(i, width - this._workspace.getCellWidth()));
  51. $shader.append(this._$bottomShader)
  52. },
  53. _renderAllDayShader: function(shaderWidth, i) {
  54. if (this._workspace.option("showAllDayPanel")) {
  55. this._$allDayIndicator = $("<div>").addClass(DATE_TIME_SHADER_ALL_DAY_CLASS);
  56. this._$allDayIndicator.height(this._workspace.getAllDayHeight());
  57. this._$allDayIndicator.width(shaderWidth);
  58. this._$allDayIndicator.css("left", this._getShaderOffset(i, shaderWidth));
  59. this._workspace._$allDayPanel.prepend(this._$allDayIndicator)
  60. }
  61. },
  62. _getShaderOffset: function(i, width) {
  63. return this._workspace.getGroupedStrategy().getShaderOffset(i, width)
  64. },
  65. _getShaderTopOffset: function(i) {
  66. return this._workspace.getGroupedStrategy().getShaderTopOffset(i)
  67. },
  68. _getShaderHeight: function(i, width) {
  69. return this._workspace.getGroupedStrategy().getShaderHeight()
  70. },
  71. _getShaderMaxHeight: function(i, width) {
  72. return this._workspace.getGroupedStrategy().getShaderMaxHeight()
  73. },
  74. _getShaderWidth: function(i) {
  75. return this._workspace.getGroupedStrategy().getShaderWidth(i)
  76. },
  77. clean: function() {
  78. this.callBase();
  79. this._workspace && this._workspace._$allDayPanel && this._workspace._$allDayPanel.find("." + DATE_TIME_SHADER_ALL_DAY_CLASS).remove()
  80. }
  81. });
  82. module.exports = VerticalCurrentTimeShader;