(scheduler2)
| 4879 | }; |
| 4880 | } |
| 4881 | function extend$c(scheduler2) { |
| 4882 | scheduler2._events = {}; |
| 4883 | scheduler2.clearAll = function() { |
| 4884 | this._events = {}; |
| 4885 | this._loaded = {}; |
| 4886 | this._edit_id = null; |
| 4887 | this._select_id = null; |
| 4888 | this._drag_id = null; |
| 4889 | this._drag_mode = null; |
| 4890 | this._drag_pos = null; |
| 4891 | this._new_event = null; |
| 4892 | this.clear_view(); |
| 4893 | this.callEvent("onClearAll", []); |
| 4894 | }; |
| 4895 | scheduler2.addEvent = function(start_date, end_date, text, id, extra_data) { |
| 4896 | if (!arguments.length) |
| 4897 | return this.addEventNow(); |
| 4898 | var ev = start_date; |
| 4899 | if (arguments.length != 1) { |
| 4900 | ev = extra_data || {}; |
| 4901 | ev.start_date = start_date; |
| 4902 | ev.end_date = end_date; |
| 4903 | ev.text = text; |
| 4904 | ev.id = id; |
| 4905 | } |
| 4906 | ev.id = ev.id || scheduler2.uid(); |
| 4907 | ev.text = ev.text || ""; |
| 4908 | if (typeof ev.start_date == "string") |
| 4909 | ev.start_date = this.templates.api_date(ev.start_date); |
| 4910 | if (typeof ev.end_date == "string") |
| 4911 | ev.end_date = this.templates.api_date(ev.end_date); |
| 4912 | var d = (this.config.event_duration || this.config.time_step) * 6e4; |
| 4913 | if (new Date(ev.end_date).valueOf() - new Date(ev.start_date).valueOf() <= d) |
| 4914 | ev.end_date.setTime(ev.start_date.valueOf() + d); |
| 4915 | ev.start_date.setMilliseconds(0); |
| 4916 | ev.end_date.setMilliseconds(0); |
| 4917 | ev._timed = this.isOneDayEvent(ev); |
| 4918 | var is_new = !this._events[ev.id]; |
| 4919 | this._events[ev.id] = ev; |
| 4920 | this.event_updated(ev); |
| 4921 | if (!this._loading) |
| 4922 | this.callEvent(is_new ? "onEventAdded" : "onEventChanged", [ev.id, ev]); |
| 4923 | return ev.id; |
| 4924 | }; |
| 4925 | scheduler2.deleteEvent = function(id, silent) { |
| 4926 | var ev = this._events[id]; |
| 4927 | if (!silent && (!this.callEvent("onBeforeEventDelete", [id, ev]) || !this.callEvent("onConfirmedBeforeEventDelete", [id, ev]))) |
| 4928 | return; |
| 4929 | if (ev) { |
| 4930 | if (scheduler2.getState().select_id == id) { |
| 4931 | scheduler2.unselect(); |
| 4932 | } |
| 4933 | delete this._events[id]; |
| 4934 | this.event_updated(ev); |
| 4935 | if (this._drag_id == ev.id) { |
| 4936 | this._drag_id = null; |
| 4937 | this._drag_mode = null; |
| 4938 | this._drag_pos = null; |
no test coverage detected