Skip to content

Commit

Permalink
4 types of datepicker is prepared. Further tests are required
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Kasaaian committed Aug 16, 2017
1 parent 00a8766 commit 1622ca1
Show file tree
Hide file tree
Showing 17 changed files with 402 additions and 72 deletions.
37 changes: 31 additions & 6 deletions dist/DateRangePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,31 +86,56 @@
var _this = _possibleConstructorReturn(this, (DateRangePicker.__proto__ || Object.getPrototypeOf(DateRangePicker)).call(this, props));

_this.change = _this.change.bind(_this);
_this.state = { disableFromYear: "", disableFromMonth: "", disableFromDay: "", disableFromUnix: "" };
_this.secondchange = _this.secondchange.bind(_this);
_this.state = { disableFromUnix: "" };
return _this;
}

_createClass(DateRangePicker, [{
key: "change",
value: function change(unix, formatted) {
var onChangeStart = this.props.onChangeStart;

this.setState({ disableFromUnix: unix });
if (!!onChangeStart) onChangeStart(unix, formatted);
}
}, {
key: "secondchange",
value: function secondchange(unix, formatted) {
this.setState({ disableFromUnix: unix });
debugger;
var onChangeEnd = this.props.onChangeEnd;

if (!!onChangeEnd) onChangeEnd(unix, formatted);
}
}, {
key: "render",
value: function render() {
var _props = this.props,
placeholderEnd = _props.placeholderEnd,
placeholderStart = _props.placeholderStart,
idStart = _props.idStart,
idEnd = _props.idEnd,
format = _props.format;
var disableFromUnix = this.state.disableFromUnix;

if (!placeholderStart) placeholderStart = "";
if (!placeholderEnd) placeholderEnd = "";
if (!idStart) idStart = "";
if (!idEnd) idEnd = "";
return _react2.default.createElement(
"div",
{ className: "rangePicker" },
_react2.default.createElement(_index2.default, { placeholder: "\u0627\u0646\u062A\u062E\u0627\u0628 \u062A\u0627\u0631\u06CC\u062E", format: "jYYYY/jMM/jDD", onChange: this.change, id: "datePicker" }),
!!disableFromUnix && _react2.default.createElement(_index2.default, { placeholder: "\u0627\u0646\u062A\u062E\u0627\u0628 \u062A\u0627\u0631\u06CC\u062E", disableFromUnix: disableFromUnix, format: "jYYYY/jMM/jDD", onChange: this.secondchange, id: "datePicker" })
{ className: "jdtrp", style: { textAlign: "initial" } },
_react2.default.createElement(_index2.default, { placeholder: placeholderStart, format: format, onChange: this.change, id: idStart }),
_react2.default.createElement(
"div",
null,
"->"
),
!disableFromUnix && _react2.default.createElement(
"div",
null,
placeholderEnd
),
!!disableFromUnix && _react2.default.createElement(_index2.default, { placeholder: placeholderEnd, disableFromUnix: disableFromUnix, format: format, onChange: this.secondchange, id: "datePicker" })
);
}
}]);
Expand Down
11 changes: 6 additions & 5 deletions dist/DateTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,12 @@
selectedTime = _state2.selectedTime;
var _props3 = this.props,
id = _props3.id,
placeholder = _props3.placeholder;
placeholder = _props3.placeholder,
disableFromUnix = _props3.disableFromUnix;

return _react2.default.createElement(
"div",
null,
{ style: { textAlign: "initial" } },
_react2.default.createElement("input", { type: "text", id: id, placeholder: placeholder, dir: "ltr", style: { textAlign: "right" }, readOnly: true, value: inputValue, onClick: function onClick() {
_this2.setState({ openPicker: !openPicker });
} }),
Expand All @@ -251,7 +252,7 @@
_react2.default.createElement(
"div",
{ className: "left" },
_react2.default.createElement(_TimePicker2.default, { changeEvent: function changeEvent(returnedTime) {
_react2.default.createElement(_TimePicker2.default, { disableFromUnix: disableFromUnix, selectedYear: selectedYear, selectedDay: selectedDay, currentMonth: currentMonth, changeEvent: function changeEvent(returnedTime) {
return _this2.timeSelected(returnedTime);
}, selectedTime: selectedTime })
)
Expand Down Expand Up @@ -298,7 +299,7 @@
"\u062C"
)
),
_react2.default.createElement(_Days2.default, { selectedYear: selectedYear, selectedDay: selectedDay, currentMonth: currentMonth, daysCount: daysCount, firstDay: selectedMonthFirstDay, clickEvent: function clickEvent(day, momentDay) {
_react2.default.createElement(_Days2.default, { disableFromUnix: disableFromUnix, selectedYear: selectedYear, selectedDay: selectedDay, currentMonth: currentMonth, daysCount: daysCount, firstDay: selectedMonthFirstDay, clickEvent: function clickEvent(day, momentDay) {
return _this2.daysClicked(day, momentDay);
} }),
_react2.default.createElement(
Expand All @@ -312,7 +313,7 @@
_react2.default.createElement(
"button",
{ className: "JDcancel", onClick: this.canclePicker },
"\u0644\u063A\u0648"
"\u0628\u0633\u062A\u0646"
)
)
)
Expand Down
147 changes: 147 additions & 0 deletions dist/DateTimeRangePicker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(["exports", "react", "moment-jalaali", "./DateTimePicker.js"], factory);
} else if (typeof exports !== "undefined") {
factory(exports, require("react"), require("moment-jalaali"), require("./DateTimePicker.js"));
} else {
var mod = {
exports: {}
};
factory(mod.exports, global.react, global.momentJalaali, global.DateTimePicker);
global.DateTimeRangePicker = mod.exports;
}
})(this, function (exports, _react, _momentJalaali, _DateTimePicker) {
"use strict";

Object.defineProperty(exports, "__esModule", {
value: true
});

var _react2 = _interopRequireDefault(_react);

var _momentJalaali2 = _interopRequireDefault(_momentJalaali);

var _DateTimePicker2 = _interopRequireDefault(_DateTimePicker);

function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}

function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}

var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}

return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();

function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}

return call && (typeof call === "object" || typeof call === "function") ? call : self;
}

function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}

subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
}

var DateTimeRangePicker = function (_React$Component) {
_inherits(DateTimeRangePicker, _React$Component);

function DateTimeRangePicker(props) {
_classCallCheck(this, DateTimeRangePicker);

var _this = _possibleConstructorReturn(this, (DateTimeRangePicker.__proto__ || Object.getPrototypeOf(DateTimeRangePicker)).call(this, props));

_this.change = _this.change.bind(_this);
_this.secondchange = _this.secondchange.bind(_this);
_this.state = { disableFromUnix: "" };
return _this;
}

_createClass(DateTimeRangePicker, [{
key: "change",
value: function change(unix, formatted) {
var onChangeStart = this.props.onChangeStart;

this.setState({ disableFromUnix: unix });
if (!!onChangeStart) onChangeStart(unix, formatted);
}
}, {
key: "secondchange",
value: function secondchange(unix, formatted) {
var onChangeEnd = this.props.onChangeEnd;

if (!!onChangeEnd) onChangeEnd(unix, formatted);
}
}, {
key: "render",
value: function render() {
var _props = this.props,
placeholderEnd = _props.placeholderEnd,
placeholderStart = _props.placeholderStart,
idStart = _props.idStart,
idEnd = _props.idEnd,
format = _props.format;
var disableFromUnix = this.state.disableFromUnix;

if (!placeholderStart) placeholderStart = "";
if (!placeholderEnd) placeholderEnd = "";
if (!idStart) idStart = "";
if (!idEnd) idEnd = "";
return _react2.default.createElement(
"div",
{ className: "jdtrp", style: { textAlign: "initial" } },
_react2.default.createElement(_DateTimePicker2.default, { placeholder: placeholderStart, format: format, onChange: this.change, id: idStart }),
_react2.default.createElement(
"div",
null,
"->"
),
!disableFromUnix && _react2.default.createElement(
"div",
null,
placeholderEnd
),
!!disableFromUnix && _react2.default.createElement(_DateTimePicker2.default, { placeholder: placeholderEnd, disableFromUnix: disableFromUnix, format: format, onChange: this.secondchange, id: "datePicker" })
);
}
}]);

return DateTimeRangePicker;
}(_react2.default.Component);

exports.default = DateTimeRangePicker;
});
27 changes: 17 additions & 10 deletions dist/Partials/Months.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,40 @@

_this.state = {
months: ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"],
monthPickerView: false
monthPickerView: false,
selectedMonth: _this.props.month
};
return _this;
}

_createClass(Months, [{
key: "monthClicked",
value: function monthClicked(i) {
value: function monthClicked(i, e) {
var clickEvent = this.props.clickEvent;

if (clickEvent) clickEvent(i);
this.setState({ monthPickerView: false });
this.setState({ monthPickerView: false, selectedMonth: i });
}
}, {
key: "renderMonths",
value: function renderMonths() {
var _this2 = this;

var months = this.state.months;
var _state = this.state,
months = _state.months,
selectedMonth = _state.selectedMonth;

var result = [];

var _loop = function _loop(i) {
result.push(_react2.default.createElement(
if (selectedMonth == i) result.push(_react2.default.createElement(
"div",
{ key: i, className: "month-items selected" },
months[i - 1]
));else result.push(_react2.default.createElement(
"div",
{ key: i, className: "month-items", onClick: function onClick() {
return _this2.monthClicked(i);
{ key: i, className: "month-items", onClick: function onClick(e) {
return _this2.monthClicked(i, e);
} },
months[i - 1]
));
Expand All @@ -126,9 +133,9 @@
var _this3 = this;

var month = this.props.month;
var _state = this.state,
months = _state.months,
monthPickerView = _state.monthPickerView;
var _state2 = this.state,
months = _state2.months,
monthPickerView = _state2.monthPickerView;

return _react2.default.createElement(
"div",
Expand Down
Loading

0 comments on commit 1622ca1

Please sign in to comment.