UNPKG

@quartic/bokehjs

Version:

Interactive, novel data visualization

53 lines (52 loc) 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var bind = function (fn, me) { return function () { return fn.apply(me, arguments); }; }, extend = function (child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; var $ = require("jquery"); require("jquery-ui/datepicker"); var p = require("core/properties"); var input_widget_1 = require("./input_widget"); exports.DatePickerView = (function (superClass) { extend(DatePickerView, superClass); function DatePickerView() { this.onSelect = bind(this.onSelect, this); return DatePickerView.__super__.constructor.apply(this, arguments); } DatePickerView.prototype.render = function () { DatePickerView.__super__.render.call(this); this.label = $('<label>').text(this.model.title); this.input = $('<input type="text">'); this.datepicker = this.input.datepicker({ defaultDate: new Date(this.model.value), minDate: this.model.min_date != null ? new Date(this.model.min_date) : null, maxDate: this.model.max_date != null ? new Date(this.model.max_date) : null, onSelect: this.onSelect }); this.$el.append([this.label, this.input]); this._prefix_ui(); return this; }; DatePickerView.prototype.onSelect = function (dateText, ui) { var d, ref; d = new Date(dateText); this.model.value = d.toString(); return (ref = this.model.callback) != null ? ref.execute(this.model) : void 0; }; return DatePickerView; })(input_widget_1.InputWidgetView); exports.DatePicker = (function (superClass) { extend(DatePicker, superClass); function DatePicker() { return DatePicker.__super__.constructor.apply(this, arguments); } DatePicker.prototype.type = "DatePicker"; DatePicker.prototype.default_view = exports.DatePickerView; DatePicker.define({ value: [p.Any, Date.now()], min_date: [p.Any], max_date: [p.Any] }); return DatePicker; })(input_widget_1.InputWidget);