This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlist-formatting.js
More file actions
85 lines (85 loc) · 4.81 KB
/
list-formatting.js
File metadata and controls
85 lines (85 loc) · 4.81 KB
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
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ej2_react_calendars_1 = require("@syncfusion/ej2-react-calendars");
var sample_base_1 = require("../common/sample-base");
require("./timepicker-component.css");
var Formatting = (function (_super) {
__extends(Formatting, _super);
function Formatting() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.value = new Date();
return _this;
}
// scrollTo value will be assigned only if the timepicker value is not null or undefined and is a valid value.
Formatting.prototype.onOpen = function (args) {
if (this.timeObj.value && !isNaN(+this.timeObj.value))
//assign the current value as the scrollTo value
this.timeObj.scrollTo = this.timeObj.value;
};
//item render event handler
Formatting.prototype.itemRenderHandler = function (args) {
// inner element declaration for text
var span = document.createElement('span');
if (args.value.getHours() === 0 && args.value.getMinutes() === 0 && args.value.getSeconds() === 0) {
//assign the initial value to the variable
this.startTime = args.value;
}
//get the minutes details
var minutes = (+args.value - +this.startTime) / 60000;
//get the hours details
var hours = parseInt('' + (minutes / 60), 10);
var mins = (minutes % 60) / 6;
//displayed text formation for each LI element.
var minText;
if (minutes === 0 || minutes === 30) {
minText = minutes + ' mins';
}
else {
minText = (mins > 0) ? ('.' + mins) : '';
}
span.innerHTML = ' (' + ((hours > 0) ? (hours + minText + ' hrs') : ('' + ' mins')) + ')';
//disable the specific time from the selection
if ((minutes / 60) % 3 === 0) {
span.classList.add('e-icons');
//disable the time values by addeding the e-disabled class.
args.element.classList.add('e-disabled');
}
//append the custom SPAN element into LI element
args.element.appendChild(span);
};
Formatting.prototype.render = function () {
var _this = this;
return (React.createElement("div", { className: 'control-pane default' },
React.createElement("div", { className: 'control-section' },
React.createElement("div", { className: 'timepicker-control-section' },
React.createElement(ej2_react_calendars_1.TimePickerComponent, { cssClass: 'e-custom-style', value: this.value, ref: function (Timepicker) { return _this.timeObj = Timepicker; }, open: this.onOpen.bind(this), itemRender: this.itemRenderHandler.bind(this) }))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null, "The following sample demonstrates the popup list element in specific time duration. click the time icon to select the desired value. ")),
React.createElement("div", { id: 'description' },
React.createElement("p", null,
"The Time Duration sample illustrates, how to customize or disable the time values in time list popup by using",
React.createElement("code", null, "itemRender"),
" event. Here, all the time values has addition information on duration between them in sequence and some of the values are disabled through itemRender event by adding the ",
React.createElement("code", null, "e-disabled"),
" class.By using the",
React.createElement("code", null, "scrollTo"),
" can set the scroll position to the given value when no value is selected or the selected value is not availble in the timepicker popup list."),
React.createElement("p", null,
" \tMore information about TimePicker and it's configuration can be found in the ",
React.createElement("a", { target: '_blank', href: 'https://ej2.syncfusion.com/react/documentation/timepicker/getting-started.html#adding-timepicker-component-to-the-application' }, "documentation"),
" section."))));
};
return Formatting;
}(sample_base_1.SampleBase));
exports.Formatting = Formatting;