ui.scheduler.appointmentsPositioning.strategy.adaptive.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. /**
  2. * DevExtreme (ui/scheduler/rendering_strategies/ui.scheduler.appointmentsPositioning.strategy.adaptive.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. function _typeof(obj) {
  11. "@babel/helpers - typeof";
  12. return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj) {
  13. return typeof obj
  14. } : function(obj) {
  15. return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj
  16. }, _typeof(obj)
  17. }
  18. var _uiSchedulerAppointmentsPositioningStrategy = require("./ui.scheduler.appointmentsPositioning.strategy.base");
  19. var _uiSchedulerAppointmentsPositioningStrategy2 = _interopRequireDefault(_uiSchedulerAppointmentsPositioningStrategy);
  20. function _interopRequireDefault(obj) {
  21. return obj && obj.__esModule ? obj : {
  22. "default": obj
  23. }
  24. }
  25. function _classCallCheck(instance, Constructor) {
  26. if (!(instance instanceof Constructor)) {
  27. throw new TypeError("Cannot call a class as a function")
  28. }
  29. }
  30. function _defineProperties(target, props) {
  31. for (var i = 0; i < props.length; i++) {
  32. var descriptor = props[i];
  33. descriptor.enumerable = descriptor.enumerable || false;
  34. descriptor.configurable = true;
  35. if ("value" in descriptor) {
  36. descriptor.writable = true
  37. }
  38. Object.defineProperty(target, descriptor.key, descriptor)
  39. }
  40. }
  41. function _createClass(Constructor, protoProps, staticProps) {
  42. if (protoProps) {
  43. _defineProperties(Constructor.prototype, protoProps)
  44. }
  45. if (staticProps) {
  46. _defineProperties(Constructor, staticProps)
  47. }
  48. Object.defineProperty(Constructor, "prototype", {
  49. writable: false
  50. });
  51. return Constructor
  52. }
  53. function _get() {
  54. if ("undefined" !== typeof Reflect && Reflect.get) {
  55. _get = Reflect.get.bind()
  56. } else {
  57. _get = function(target, property, receiver) {
  58. var base = _superPropBase(target, property);
  59. if (!base) {
  60. return
  61. }
  62. var desc = Object.getOwnPropertyDescriptor(base, property);
  63. if (desc.get) {
  64. return desc.get.call(arguments.length < 3 ? target : receiver)
  65. }
  66. return desc.value
  67. }
  68. }
  69. return _get.apply(this, arguments)
  70. }
  71. function _superPropBase(object, property) {
  72. while (!Object.prototype.hasOwnProperty.call(object, property)) {
  73. object = _getPrototypeOf(object);
  74. if (null === object) {
  75. break
  76. }
  77. }
  78. return object
  79. }
  80. function _inherits(subClass, superClass) {
  81. if ("function" !== typeof superClass && null !== superClass) {
  82. throw new TypeError("Super expression must either be null or a function")
  83. }
  84. subClass.prototype = Object.create(superClass && superClass.prototype, {
  85. constructor: {
  86. value: subClass,
  87. writable: true,
  88. configurable: true
  89. }
  90. });
  91. Object.defineProperty(subClass, "prototype", {
  92. writable: false
  93. });
  94. if (superClass) {
  95. _setPrototypeOf(subClass, superClass)
  96. }
  97. }
  98. function _setPrototypeOf(o, p) {
  99. _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, p) {
  100. o.__proto__ = p;
  101. return o
  102. };
  103. return _setPrototypeOf(o, p)
  104. }
  105. function _createSuper(Derived) {
  106. var hasNativeReflectConstruct = _isNativeReflectConstruct();
  107. return function() {
  108. var result, Super = _getPrototypeOf(Derived);
  109. if (hasNativeReflectConstruct) {
  110. var NewTarget = _getPrototypeOf(this).constructor;
  111. result = Reflect.construct(Super, arguments, NewTarget)
  112. } else {
  113. result = Super.apply(this, arguments)
  114. }
  115. return _possibleConstructorReturn(this, result)
  116. }
  117. }
  118. function _possibleConstructorReturn(self, call) {
  119. if (call && ("object" === _typeof(call) || "function" === typeof call)) {
  120. return call
  121. } else {
  122. if (void 0 !== call) {
  123. throw new TypeError("Derived constructors may only return object or undefined")
  124. }
  125. }
  126. return _assertThisInitialized(self)
  127. }
  128. function _assertThisInitialized(self) {
  129. if (void 0 === self) {
  130. throw new ReferenceError("this hasn't been initialised - super() hasn't been called")
  131. }
  132. return self
  133. }
  134. function _isNativeReflectConstruct() {
  135. if ("undefined" === typeof Reflect || !Reflect.construct) {
  136. return false
  137. }
  138. if (Reflect.construct.sham) {
  139. return false
  140. }
  141. if ("function" === typeof Proxy) {
  142. return true
  143. }
  144. try {
  145. Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
  146. return true
  147. } catch (e) {
  148. return false
  149. }
  150. }
  151. function _getPrototypeOf(o) {
  152. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(o) {
  153. return o.__proto__ || Object.getPrototypeOf(o)
  154. };
  155. return _getPrototypeOf(o)
  156. }
  157. var COLLECTOR_ADAPTIVE_SIZE = 28;
  158. var COLLECTOR_ADAPTIVE_BOTTOM_OFFSET = 40;
  159. var ADAPTIVE_APPOINTMENT_DEFAULT_OFFSET = 35;
  160. var ADAPTIVE_APPOINTMENT_DEFAULT_WIDTH = 30;
  161. var AdaptivePositioningStrategy = function(_BasePositioningStrat) {
  162. _inherits(AdaptivePositioningStrategy, _BasePositioningStrat);
  163. var _super = _createSuper(AdaptivePositioningStrategy);
  164. function AdaptivePositioningStrategy() {
  165. _classCallCheck(this, AdaptivePositioningStrategy);
  166. return _super.apply(this, arguments)
  167. }
  168. _createClass(AdaptivePositioningStrategy, [{
  169. key: "getDropDownAppointmentWidth",
  170. value: function(intervalCount, isAllDay) {
  171. return this.getDropDownButtonAdaptiveSize()
  172. }
  173. }, {
  174. key: "getDropDownButtonAdaptiveSize",
  175. value: function() {
  176. return COLLECTOR_ADAPTIVE_SIZE
  177. }
  178. }, {
  179. key: "getCompactAppointmentTopOffset",
  180. value: function(allDay) {
  181. var renderingStrategy = this.getRenderingStrategy();
  182. if (renderingStrategy.hasAllDayAppointments() && allDay) {
  183. return (renderingStrategy.getDefaultAllDayCellHeight() - renderingStrategy.getDropDownButtonAdaptiveSize()) / 2
  184. } else {
  185. return this.getRenderingStrategy().getDefaultCellHeight() - COLLECTOR_ADAPTIVE_BOTTOM_OFFSET
  186. }
  187. }
  188. }, {
  189. key: "getCompactAppointmentLeftOffset",
  190. value: function() {
  191. return (this.getRenderingStrategy().getDefaultCellWidth() - COLLECTOR_ADAPTIVE_SIZE) / 2
  192. }
  193. }, {
  194. key: "getAppointmentDefaultOffset",
  195. value: function() {
  196. return ADAPTIVE_APPOINTMENT_DEFAULT_OFFSET
  197. }
  198. }, {
  199. key: "getDynamicAppointmentCountPerCell",
  200. value: function() {
  201. var renderingStrategy = this.getRenderingStrategy();
  202. if (renderingStrategy.hasAllDayAppointments()) {
  203. return {
  204. allDay: 0,
  205. simple: this._calculateDynamicAppointmentCountPerCell() || this._getAppointmentMinCount()
  206. }
  207. } else {
  208. return 0
  209. }
  210. }
  211. }, {
  212. key: "getDropDownAppointmentHeight",
  213. value: function() {
  214. return COLLECTOR_ADAPTIVE_SIZE
  215. }
  216. }, {
  217. key: "_getAppointmentMinCount",
  218. value: function() {
  219. return 0
  220. }
  221. }, {
  222. key: "_getAppointmentDefaultWidth",
  223. value: function() {
  224. var renderingStrategy = this.getRenderingStrategy();
  225. if (renderingStrategy.hasAllDayAppointments()) {
  226. return ADAPTIVE_APPOINTMENT_DEFAULT_WIDTH
  227. }
  228. return _get(_getPrototypeOf(AdaptivePositioningStrategy.prototype), "_getAppointmentDefaultWidth", this).call(this)
  229. }
  230. }, {
  231. key: "_calculateDynamicAppointmentCountPerCell",
  232. value: function() {
  233. return Math.floor(this.getRenderingStrategy()._getAppointmentMaxWidth() / this.getRenderingStrategy()._getAppointmentDefaultWidth())
  234. }
  235. }]);
  236. return AdaptivePositioningStrategy
  237. }(_uiSchedulerAppointmentsPositioningStrategy2.default);
  238. module.exports = AdaptivePositioningStrategy;