UNPKG

vue-bokeh

Version:

A wrapper around bokehjs embedded

1,781 lines (1,403 loc) 542 kB
(function() { var define = undefined; return (function outer(modules, cache, entry) { if (typeof Bokeh !== "undefined") { var _ = Bokeh._; for (var name in modules) { Bokeh.require.modules[name] = modules[name]; } for (var i = 0; i < entry.length; i++) { var exports = Bokeh.require(entry[i]); if (_.isObject(exports.models)) { Bokeh.Models.register_locations(exports.models); } _.extend(Bokeh, _.omit(exports, "models")); } } else { throw new Error("Cannot find Bokeh. You have to load it prior to loading plugins."); } }) ({"models/widgets/abstract_button":[function(require,module,exports){ var AbstractButton, AbstractButtonView, Widget, build_views, p, template, 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; p = require("../../core/properties"); build_views = require("../../common/build_views"); Widget = require("./widget"); template = require("./button_template"); AbstractButtonView = (function(superClass) { extend(AbstractButtonView, superClass); function AbstractButtonView() { return AbstractButtonView.__super__.constructor.apply(this, arguments); } AbstractButtonView.prototype.events = { "click": "change_input" }; AbstractButtonView.prototype.template = template; AbstractButtonView.prototype.initialize = function(options) { AbstractButtonView.__super__.initialize.call(this, options); this.icon_views = {}; this.listenTo(this.model, 'change', this.render); return this.render(); }; AbstractButtonView.prototype.render = function() { var $button, html, icon, key, ref, val; AbstractButtonView.__super__.render.call(this); icon = this.model.icon; if (icon != null) { build_views(this.icon_views, [icon]); ref = this.icon_views; for (key in ref) { if (!hasProp.call(ref, key)) continue; val = ref[key]; val.$el.detach(); } } this.$el.empty(); html = this.template(this.model.attributes); this.$el.append(html); $button = this.$el.find('button'); if (icon != null) { $button.prepend(this.icon_views[icon.id].$el); } $button.prop("disabled", this.model.disabled); return this; }; AbstractButtonView.prototype.change_input = function() { var ref; return (ref = this.model.callback) != null ? ref.execute(this.model) : void 0; }; return AbstractButtonView; })(Widget.View); AbstractButton = (function(superClass) { extend(AbstractButton, superClass); function AbstractButton() { return AbstractButton.__super__.constructor.apply(this, arguments); } AbstractButton.prototype.type = "AbstractButton"; AbstractButton.prototype.default_view = AbstractButtonView; AbstractButton.define({ callback: [p.Instance], label: [p.String, "Button"], icon: [p.Instance], button_type: [p.String, "default"] }); return AbstractButton; })(Widget.Model); module.exports = { Model: AbstractButton, View: AbstractButtonView }; },{"../../common/build_views":"common/build_views","../../core/properties":"core/properties","./button_template":"models/widgets/button_template","./widget":"models/widgets/widget"}],"models/widgets/abstract_icon":[function(require,module,exports){ var AbstractIcon, Widget, _, 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; _ = require("underscore"); Widget = require("./widget"); AbstractIcon = (function(superClass) { extend(AbstractIcon, superClass); function AbstractIcon() { return AbstractIcon.__super__.constructor.apply(this, arguments); } AbstractIcon.prototype.type = "AbstractIcon"; return AbstractIcon; })(Widget.Model); module.exports = { Model: AbstractIcon }; },{"./widget":"models/widgets/widget","underscore":"underscore"}],"models/widgets/autocomplete_input":[function(require,module,exports){ var $1, AutocompleteInput, AutocompleteInputView, TextInput, _, p, 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; _ = require("underscore"); $1 = require("jquery-ui/autocomplete"); TextInput = require("./text_input"); p = require("../../core/properties"); AutocompleteInputView = (function(superClass) { extend(AutocompleteInputView, superClass); function AutocompleteInputView() { return AutocompleteInputView.__super__.constructor.apply(this, arguments); } AutocompleteInputView.prototype.render = function() { var $input; AutocompleteInputView.__super__.render.call(this); $input = this.$el.find("input"); $input.autocomplete({ source: this.mget("completions") }); $input.autocomplete("widget").addClass("bk-autocomplete-input"); return this; }; return AutocompleteInputView; })(TextInput.View); AutocompleteInput = (function(superClass) { extend(AutocompleteInput, superClass); function AutocompleteInput() { return AutocompleteInput.__super__.constructor.apply(this, arguments); } AutocompleteInput.prototype.type = "AutocompleteInput"; AutocompleteInput.prototype.default_view = AutocompleteInputView; AutocompleteInput.define({ completions: [p.Array, []] }); return AutocompleteInput; })(TextInput.Model); module.exports = { View: AutocompleteInputView, Model: AutocompleteInput }; },{"../../core/properties":"core/properties","./text_input":"models/widgets/text_input","jquery-ui/autocomplete":"jquery-ui/autocomplete","underscore":"underscore"}],"models/widgets/button":[function(require,module,exports){ var AbstractButton, Button, ButtonView, _, p, 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; _ = require("underscore"); p = require("../../core/properties"); AbstractButton = require("./abstract_button"); ButtonView = (function(superClass) { extend(ButtonView, superClass); function ButtonView() { return ButtonView.__super__.constructor.apply(this, arguments); } ButtonView.prototype.change_input = function() { this.model.clicks = this.model.clicks + 1; return ButtonView.__super__.change_input.call(this); }; return ButtonView; })(AbstractButton.View); Button = (function(superClass) { extend(Button, superClass); function Button() { return Button.__super__.constructor.apply(this, arguments); } Button.prototype.type = "Button"; Button.prototype.default_view = ButtonView; Button.define({ clicks: [p.Number, 0] }); return Button; })(AbstractButton.Model); module.exports = { Model: Button, View: ButtonView }; },{"../../core/properties":"core/properties","./abstract_button":"models/widgets/abstract_button","underscore":"underscore"}],"models/widgets/button_group_template":[function(require,module,exports){ module.exports = function(__obj) { if (!__obj) __obj = {}; var __out = []; var __capture = function(callback) { var out = __out, result; __out = []; callback.call(this); result = __out.join(''); __out = out; return __safe(result); }; var __sanitize = function(value) { if (value && value.ecoSafe) { return value; } else if (typeof value !== 'undefined' && value != null) { return __escape(value); } else { return ''; } }; var __safe = function(value) { if (value && value.ecoSafe) { return value; } else { if (!(typeof value !== 'undefined' && value != null)) value = ''; var result = new String(value); result.ecoSafe = true; return result; } }; var __escape = function(value) { return ('' + value) .replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/"/g, '&quot;'); }; (function() { (function() { __out.push('<div class="bk-bs-btn-group" data-bk-bs-toggle="buttons">\n</div>\n'); }).call(this); }).call(__obj); return __out.join(''); }; },{}],"models/widgets/button_template":[function(require,module,exports){ module.exports = function(__obj) { if (!__obj) __obj = {}; var __out = []; var __capture = function(callback) { var out = __out, result; __out = []; callback.call(this); result = __out.join(''); __out = out; return __safe(result); }; var __sanitize = function(value) { if (value && value.ecoSafe) { return value; } else if (typeof value !== 'undefined' && value != null) { return __escape(value); } else { return ''; } }; var __safe = function(value) { if (value && value.ecoSafe) { return value; } else { if (!(typeof value !== 'undefined' && value != null)) value = ''; var result = new String(value); result.ecoSafe = true; return result; } }; var __escape = function(value) { return ('' + value) .replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/"/g, '&quot;'); }; (function() { (function() { __out.push('<button type="button" class="bk-bs-btn bk-bs-btn-'); __out.push(__sanitize(this.button_type)); __out.push('">\n '); __out.push(__sanitize(this.label)); __out.push('\n</button>\n'); }).call(this); }).call(__obj); return __out.join(''); }; },{}],"models/widgets/cell_editors":[function(require,module,exports){ var $, $1, $2, CellEditor, CellEditorView, CheckboxEditor, CheckboxEditorView, DateEditor, DateEditorView, IntEditor, IntEditorView, Model, NumberEditor, NumberEditorView, PercentEditor, PercentEditorView, SelectEditor, SelectEditorView, StringEditor, StringEditorView, TextEditor, TextEditorView, TimeEditor, TimeEditorView, Widget, _, p, 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; _ = require("underscore"); $ = require("jquery"); $1 = require("jquery-ui/autocomplete"); $2 = require("jquery-ui/spinner"); p = require("../../core/properties"); Model = require("../../model"); Widget = require("./widget"); CellEditor = (function(superClass) { extend(CellEditor, superClass); function CellEditor() { return CellEditor.__super__.constructor.apply(this, arguments); } return CellEditor; })(Model); CellEditorView = (function(superClass) { extend(CellEditorView, superClass); function CellEditorView() { return CellEditorView.__super__.constructor.apply(this, arguments); } CellEditorView.prototype.tagName = "div"; CellEditorView.prototype.className = "bk-cell-editor"; CellEditorView.prototype.input = null; CellEditorView.prototype.emptyValue = null; CellEditorView.prototype.defaultValue = null; CellEditorView.prototype.initialize = function(args) { CellEditorView.__super__.initialize.call(this, {}); this.args = args; this.model = this.args.column.editor; return this.render(); }; CellEditorView.prototype.render = function() { CellEditorView.__super__.render.call(this); this.$el.appendTo(this.args.container); this.$input = $(this.input); this.$el.append(this.$input); this.renderEditor(); this.disableNavigation(); return this; }; CellEditorView.prototype.renderEditor = function() {}; CellEditorView.prototype.disableNavigation = function() { return this.$input.keydown((function(_this) { return function(event) { var stop; stop = function() { return event.stopImmediatePropagation(); }; switch (event.keyCode) { case $.ui.keyCode.LEFT: return stop(); case $.ui.keyCode.RIGHT: return stop(); case $.ui.keyCode.UP: return stop(); case $.ui.keyCode.DOWN: return stop(); case $.ui.keyCode.PAGE_UP: return stop(); case $.ui.keyCode.PAGE_DOWN: return stop(); } }; })(this)); }; CellEditorView.prototype.destroy = function() { return this.remove(); }; CellEditorView.prototype.focus = function() { return this.$input.focus(); }; CellEditorView.prototype.show = function() {}; CellEditorView.prototype.hide = function() {}; CellEditorView.prototype.position = function() {}; CellEditorView.prototype.getValue = function() { return this.$input.val(); }; CellEditorView.prototype.setValue = function(val) { return this.$input.val(val); }; CellEditorView.prototype.serializeValue = function() { return this.getValue(); }; CellEditorView.prototype.isValueChanged = function() { return !(this.getValue() === "" && (this.defaultValue == null)) && (this.getValue() !== this.defaultValue); }; CellEditorView.prototype.applyValue = function(item, state) { return this.args.grid.getData().setField(item.index, this.args.column.field, state); }; CellEditorView.prototype.loadValue = function(item) { var value; value = item[this.args.column.field]; this.defaultValue = value != null ? value : this.emptyValue; return this.setValue(this.defaultValue); }; CellEditorView.prototype.validateValue = function(value) { var result; if (this.args.column.validator) { result = this.args.column.validator(value); if (!result.valid) { return result; } } return { valid: true, msg: null }; }; CellEditorView.prototype.validate = function() { return this.validateValue(this.getValue()); }; return CellEditorView; })(Widget.View); StringEditorView = (function(superClass) { extend(StringEditorView, superClass); function StringEditorView() { return StringEditorView.__super__.constructor.apply(this, arguments); } StringEditorView.prototype.emptyValue = ""; StringEditorView.prototype.input = '<input type="text" />'; StringEditorView.prototype.renderEditor = function() { var completions; completions = this.model.get("completions"); if (!_.isEmpty(completions)) { this.$input.autocomplete({ source: completions }); this.$input.autocomplete("widget").addClass("bk-cell-editor-completion"); } return this.$input.focus().select(); }; StringEditorView.prototype.loadValue = function(item) { StringEditorView.__super__.loadValue.call(this, item); this.$input[0].defaultValue = this.defaultValue; return this.$input.select(); }; return StringEditorView; })(CellEditorView); StringEditor = (function(superClass) { extend(StringEditor, superClass); function StringEditor() { return StringEditor.__super__.constructor.apply(this, arguments); } StringEditor.prototype.type = 'StringEditor'; StringEditor.prototype.default_view = StringEditorView; StringEditor.define({ completions: [p.Array, []] }); return StringEditor; })(CellEditor); TextEditorView = (function(superClass) { extend(TextEditorView, superClass); function TextEditorView() { return TextEditorView.__super__.constructor.apply(this, arguments); } return TextEditorView; })(CellEditorView); TextEditor = (function(superClass) { extend(TextEditor, superClass); function TextEditor() { return TextEditor.__super__.constructor.apply(this, arguments); } TextEditor.prototype.type = 'TextEditor'; TextEditor.prototype.default_view = TextEditorView; return TextEditor; })(CellEditor); SelectEditorView = (function(superClass) { extend(SelectEditorView, superClass); function SelectEditorView() { return SelectEditorView.__super__.constructor.apply(this, arguments); } SelectEditorView.prototype.input = '<select />'; SelectEditorView.prototype.renderEditor = function() { var i, len, option, ref; ref = this.model.get("options"); for (i = 0, len = ref.length; i < len; i++) { option = ref[i]; this.$input.append($('<option>').attr({ value: option }).text(option)); } return this.focus(); }; SelectEditorView.prototype.loadValue = function(item) { SelectEditorView.__super__.loadValue.call(this, item); return this.$input.select(); }; return SelectEditorView; })(CellEditorView); SelectEditor = (function(superClass) { extend(SelectEditor, superClass); function SelectEditor() { return SelectEditor.__super__.constructor.apply(this, arguments); } SelectEditor.prototype.type = 'SelectEditor'; SelectEditor.prototype.default_view = SelectEditorView; SelectEditor.define({ options: [p.Array, []] }); return SelectEditor; })(CellEditor); PercentEditorView = (function(superClass) { extend(PercentEditorView, superClass); function PercentEditorView() { return PercentEditorView.__super__.constructor.apply(this, arguments); } return PercentEditorView; })(CellEditorView); PercentEditor = (function(superClass) { extend(PercentEditor, superClass); function PercentEditor() { return PercentEditor.__super__.constructor.apply(this, arguments); } PercentEditor.prototype.type = 'PercentEditor'; PercentEditor.prototype.default_view = PercentEditorView; return PercentEditor; })(CellEditor); CheckboxEditorView = (function(superClass) { extend(CheckboxEditorView, superClass); function CheckboxEditorView() { return CheckboxEditorView.__super__.constructor.apply(this, arguments); } CheckboxEditorView.prototype.input = '<input type="checkbox" value="true" />'; CheckboxEditorView.prototype.renderEditor = function() { return this.focus(); }; CheckboxEditorView.prototype.loadValue = function(item) { this.defaultValue = !!item[this.args.column.field]; return this.$input.prop('checked', this.defaultValue); }; CheckboxEditorView.prototype.serializeValue = function() { return this.$input.prop('checked'); }; return CheckboxEditorView; })(CellEditorView); CheckboxEditor = (function(superClass) { extend(CheckboxEditor, superClass); function CheckboxEditor() { return CheckboxEditor.__super__.constructor.apply(this, arguments); } CheckboxEditor.prototype.type = 'CheckboxEditor'; CheckboxEditor.prototype.default_view = CheckboxEditorView; return CheckboxEditor; })(CellEditor); IntEditorView = (function(superClass) { extend(IntEditorView, superClass); function IntEditorView() { return IntEditorView.__super__.constructor.apply(this, arguments); } IntEditorView.prototype.input = '<input type="text" />'; IntEditorView.prototype.renderEditor = function() { this.$input.spinner({ step: this.model.get("step") }); return this.$input.focus().select(); }; IntEditorView.prototype.remove = function() { this.$input.spinner("destroy"); return IntEditorView.__super__.remove.call(this); }; IntEditorView.prototype.serializeValue = function() { return parseInt(this.getValue(), 10) || 0; }; IntEditorView.prototype.loadValue = function(item) { IntEditorView.__super__.loadValue.call(this, item); this.$input[0].defaultValue = this.defaultValue; return this.$input.select(); }; IntEditorView.prototype.validateValue = function(value) { if (isNaN(value)) { return { valid: false, msg: "Please enter a valid integer" }; } else { return IntEditorView.__super__.validateValue.call(this, value); } }; return IntEditorView; })(CellEditorView); IntEditor = (function(superClass) { extend(IntEditor, superClass); function IntEditor() { return IntEditor.__super__.constructor.apply(this, arguments); } IntEditor.prototype.type = 'IntEditor'; IntEditor.prototype.default_view = IntEditorView; IntEditor.define({ step: [p.Number, 1] }); return IntEditor; })(CellEditor); NumberEditorView = (function(superClass) { extend(NumberEditorView, superClass); function NumberEditorView() { return NumberEditorView.__super__.constructor.apply(this, arguments); } NumberEditorView.prototype.input = '<input type="text" />'; NumberEditorView.prototype.renderEditor = function() { this.$input.spinner({ step: this.model.get("step") }); return this.$input.focus().select(); }; NumberEditorView.prototype.remove = function() { this.$input.spinner("destroy"); return NumberEditorView.__super__.remove.call(this); }; NumberEditorView.prototype.serializeValue = function() { return parseFloat(this.getValue()) || 0.0; }; NumberEditorView.prototype.loadValue = function(item) { NumberEditorView.__super__.loadValue.call(this, item); this.$input[0].defaultValue = this.defaultValue; return this.$input.select(); }; NumberEditorView.prototype.validateValue = function(value) { if (isNaN(value)) { return { valid: false, msg: "Please enter a valid number" }; } else { return NumberEditorView.__super__.validateValue.call(this, value); } }; return NumberEditorView; })(CellEditorView); NumberEditor = (function(superClass) { extend(NumberEditor, superClass); function NumberEditor() { return NumberEditor.__super__.constructor.apply(this, arguments); } NumberEditor.prototype.type = 'NumberEditor'; NumberEditor.prototype.default_view = NumberEditorView; NumberEditor.define({ step: [p.Number, 0.01] }); return NumberEditor; })(CellEditor); TimeEditorView = (function(superClass) { extend(TimeEditorView, superClass); function TimeEditorView() { return TimeEditorView.__super__.constructor.apply(this, arguments); } return TimeEditorView; })(CellEditorView); TimeEditor = (function(superClass) { extend(TimeEditor, superClass); function TimeEditor() { return TimeEditor.__super__.constructor.apply(this, arguments); } TimeEditor.prototype.type = 'TimeEditor'; TimeEditor.prototype.default_view = TimeEditorView; return TimeEditor; })(CellEditor); DateEditorView = (function(superClass) { extend(DateEditorView, superClass); function DateEditorView() { return DateEditorView.__super__.constructor.apply(this, arguments); } DateEditorView.prototype.emptyValue = new Date(); DateEditorView.prototype.input = '<input type="text" />'; DateEditorView.prototype.renderEditor = function() { this.calendarOpen = false; this.$input.datepicker({ showOn: "button", buttonImageOnly: true, beforeShow: (function(_this) { return function() { return _this.calendarOpen = true; }; })(this), onClose: (function(_this) { return function() { return _this.calendarOpen = false; }; })(this) }); this.$input.siblings(".bk-ui-datepicker-trigger").css({ "vertical-align": "middle" }); this.$input.width(this.$input.width() - (14 + 2 * 4 + 4)); return this.$input.focus().select(); }; DateEditorView.prototype.destroy = function() { $.datepicker.dpDiv.stop(true, true); this.$input.datepicker("hide"); this.$input.datepicker("destroy"); return DateEditorView.__super__.destroy.call(this); }; DateEditorView.prototype.show = function() { if (this.calendarOpen) { $.datepicker.dpDiv.stop(true, true).show(); } return DateEditorView.__super__.show.call(this); }; DateEditorView.prototype.hide = function() { if (this.calendarOpen) { $.datepicker.dpDiv.stop(true, true).hide(); } return DateEditorView.__super__.hide.call(this); }; DateEditorView.prototype.position = function(position) { if (this.calendarOpen) { $.datepicker.dpDiv.css({ top: position.top + 30, left: position.left }); } return DateEditorView.__super__.position.call(this); }; DateEditorView.prototype.getValue = function() { return this.$input.datepicker("getDate").getTime(); }; DateEditorView.prototype.setValue = function(val) { return this.$input.datepicker("setDate", new Date(val)); }; return DateEditorView; })(CellEditorView); DateEditor = (function(superClass) { extend(DateEditor, superClass); function DateEditor() { return DateEditor.__super__.constructor.apply(this, arguments); } DateEditor.prototype.type = 'DateEditor'; DateEditor.prototype.default_view = DateEditorView; return DateEditor; })(CellEditor); module.exports = { String: { Model: StringEditor, View: StringEditorView }, Text: { Model: TextEditor, View: TextEditorView }, Select: { Model: SelectEditor, View: SelectEditorView }, Percent: { Model: PercentEditor, View: PercentEditorView }, Checkbox: { Model: CheckboxEditor, View: CheckboxEditorView }, Int: { Model: IntEditor, View: IntEditorView }, Number: { Model: NumberEditor, View: NumberEditorView }, Time: { Model: TimeEditor, View: TimeEditorView }, Date: { Model: DateEditor, View: DateEditorView } }; },{"../../core/properties":"core/properties","../../model":"model","./widget":"models/widgets/widget","jquery":"jquery","jquery-ui/autocomplete":"jquery-ui/autocomplete","jquery-ui/spinner":"jquery-ui/spinner","underscore":"underscore"}],"models/widgets/cell_formatters":[function(require,module,exports){ var $, BooleanFormatter, CellFormatter, DateFormatter, HTMLTemplateFormatter, Model, NumberFormatter, Numbro, StringFormatter, _, p, 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; _ = require("underscore"); $ = require("jquery"); Numbro = require("numbro"); p = require("../../core/properties"); Model = require("../../model"); CellFormatter = (function(superClass) { extend(CellFormatter, superClass); function CellFormatter() { return CellFormatter.__super__.constructor.apply(this, arguments); } CellFormatter.prototype.doFormat = function(row, cell, value, columnDef, dataContext) { if (value === null) { return ""; } else { return (value + "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"); } }; return CellFormatter; })(Model); StringFormatter = (function(superClass) { extend(StringFormatter, superClass); function StringFormatter() { return StringFormatter.__super__.constructor.apply(this, arguments); } StringFormatter.prototype.type = 'StringFormatter'; StringFormatter.define({ font_style: [p.FontStyle, "normal"], text_align: [p.TextAlign, "left"], text_color: [p.Color] }); StringFormatter.prototype.doFormat = function(row, cell, value, columnDef, dataContext) { var font_style, text, text_align, text_color; text = StringFormatter.__super__.doFormat.call(this, row, cell, value, columnDef, dataContext); font_style = this.get("font_style"); text_align = this.get("text_align"); text_color = this.get("text_color"); if ((font_style != null) || (text_align != null) || (text_color != null)) { text = $("<span>" + text + "</span>"); switch (font_style) { case "bold": text = text.css("font-weight", "bold"); break; case "italic": text = text.css("font-style", "italic"); } if (text_align != null) { text = text.css("text-align", text_align); } if (text_color != null) { text = text.css("color", text_color); } text = text.prop('outerHTML'); } return text; }; return StringFormatter; })(CellFormatter); NumberFormatter = (function(superClass) { extend(NumberFormatter, superClass); function NumberFormatter() { return NumberFormatter.__super__.constructor.apply(this, arguments); } NumberFormatter.prototype.type = 'NumberFormatter'; NumberFormatter.define({ format: [p.String, '0,0'], language: [p.String, 'en'], rounding: [p.String, 'round'] }); NumberFormatter.prototype.doFormat = function(row, cell, value, columnDef, dataContext) { var format, language, rounding; format = this.get("format"); language = this.get("language"); rounding = (function() { switch (this.get("rounding")) { case "round": case "nearest": return Math.round; case "floor": case "rounddown": return Math.floor; case "ceil": case "roundup": return Math.ceil; } }).call(this); value = Numbro.format(value, format, language, rounding); return NumberFormatter.__super__.doFormat.call(this, row, cell, value, columnDef, dataContext); }; return NumberFormatter; })(StringFormatter); BooleanFormatter = (function(superClass) { extend(BooleanFormatter, superClass); function BooleanFormatter() { return BooleanFormatter.__super__.constructor.apply(this, arguments); } BooleanFormatter.prototype.type = 'BooleanFormatter'; BooleanFormatter.define({ icon: [p.String, 'check'] }); BooleanFormatter.prototype.doFormat = function(row, cell, value, columnDef, dataContext) { if (!!value) { return $('<i>').addClass(this.get("icon")).html(); } else { return ""; } }; return BooleanFormatter; })(CellFormatter); DateFormatter = (function(superClass) { extend(DateFormatter, superClass); function DateFormatter() { return DateFormatter.__super__.constructor.apply(this, arguments); } DateFormatter.prototype.type = 'DateFormatter'; DateFormatter.define({ format: [p.String, 'yy M d'] }); DateFormatter.prototype.getFormat = function() { var format, name; format = this.get("format"); name = (function() { switch (format) { case "ATOM": case "W3C": case "RFC-3339": case "ISO-8601": return "ISO-8601"; case "COOKIE": return "COOKIE"; case "RFC-850": return "RFC-850"; case "RFC-1036": return "RFC-1036"; case "RFC-1123": return "RFC-1123"; case "RFC-2822": return "RFC-2822"; case "RSS": case "RFC-822": return "RFC-822"; case "TICKS": return "TICKS"; case "TIMESTAMP": return "TIMESTAMP"; default: return null; } })(); if (name != null) { return $.datepicker[name]; } else { return format; } }; DateFormatter.prototype.doFormat = function(row, cell, value, columnDef, dataContext) { var date; value = _.isString(value) ? parseInt(value, 10) : value; date = $.datepicker.formatDate(this.getFormat(), new Date(value)); return DateFormatter.__super__.doFormat.call(this, row, cell, date, columnDef, dataContext); }; return DateFormatter; })(CellFormatter); HTMLTemplateFormatter = (function(superClass) { extend(HTMLTemplateFormatter, superClass); function HTMLTemplateFormatter() { return HTMLTemplateFormatter.__super__.constructor.apply(this, arguments); } HTMLTemplateFormatter.prototype.type = 'HTMLTemplateFormatter'; HTMLTemplateFormatter.define({ template: [p.String, '<%= value %>'] }); HTMLTemplateFormatter.prototype.doFormat = function(row, cell, value, columnDef, dataContext) { var compiled_template, template; template = this.get("template"); if (value === null) { return ""; } else { dataContext = _.extend({}, dataContext, { value: value }); compiled_template = _.template(template); return compiled_template(dataContext); } }; return HTMLTemplateFormatter; })(CellFormatter); module.exports = { String: { Model: StringFormatter }, Number: { Model: NumberFormatter }, Boolean: { Model: BooleanFormatter }, Date: { Model: DateFormatter }, HTMLTemplate: { Model: HTMLTemplateFormatter } }; },{"../../core/properties":"core/properties","../../model":"model","jquery":"jquery","numbro":"numbro/numbro","underscore":"underscore"}],"models/widgets/checkbox_button_group":[function(require,module,exports){ var $, $1, BokehView, CheckboxButtonGroup, CheckboxButtonGroupView, Widget, _, p, template, 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, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; _ = require("underscore"); $ = require("jquery"); $1 = require("bootstrap/button"); Widget = require("./widget"); BokehView = require("../../core/bokeh_view"); p = require("../../core/properties"); template = require("./button_group_template"); CheckboxButtonGroupView = (function(superClass) { extend(CheckboxButtonGroupView, superClass); function CheckboxButtonGroupView() { return CheckboxButtonGroupView.__super__.constructor.apply(this, arguments); } CheckboxButtonGroupView.prototype.events = { "change input": "change_input" }; CheckboxButtonGroupView.prototype.template = template; CheckboxButtonGroupView.prototype.initialize = function(options) { CheckboxButtonGroupView.__super__.initialize.call(this, options); this.render(); return this.listenTo(this.model, 'change', this.render); }; CheckboxButtonGroupView.prototype.render = function() { var $input, $label, active, html, i, j, label, len, ref; CheckboxButtonGroupView.__super__.render.call(this); this.$el.empty(); html = this.template(); this.$el.append(html); active = this.model.active; ref = this.model.labels; for (i = j = 0, len = ref.length; j < len; i = ++j) { label = ref[i]; $input = $('<input type="checkbox">').attr({ value: "" + i }); if (indexOf.call(active, i) >= 0) { $input.prop("checked", true); } $label = $('<label class="bk-bs-btn"></label>'); $label.text(label).prepend($input); $label.addClass("bk-bs-btn-" + this.mget("button_type")); if (indexOf.call(active, i) >= 0) { $label.addClass("bk-bs-active"); } this.$el.find('.bk-bs-btn-group').append($label); } return this; }; CheckboxButtonGroupView.prototype.change_input = function() { var active, checkbox, i, ref; active = (function() { var j, len, ref, results; ref = this.$("input"); results = []; for (i = j = 0, len = ref.length; j < len; i = ++j) { checkbox = ref[i]; if (checkbox.checked) { results.push(i); } } return results; }).call(this); this.model.active = active; return (ref = this.mget('callback')) != null ? ref.execute(this.model) : void 0; }; return CheckboxButtonGroupView; })(Widget.View); CheckboxButtonGroup = (function(superClass) { extend(CheckboxButtonGroup, superClass); function CheckboxButtonGroup() { return CheckboxButtonGroup.__super__.constructor.apply(this, arguments); } CheckboxButtonGroup.prototype.type = "CheckboxButtonGroup"; CheckboxButtonGroup.prototype.default_view = CheckboxButtonGroupView; CheckboxButtonGroup.define({ active: [p.Array, []], labels: [p.Array, []], button_type: [p.String, "default"], callback: [p.Instance] }); return CheckboxButtonGroup; })(Widget.Model); module.exports = { Model: CheckboxButtonGroup, View: CheckboxButtonGroupView }; },{"../../core/bokeh_view":"core/bokeh_view","../../core/properties":"core/properties","./button_group_template":"models/widgets/button_group_template","./widget":"models/widgets/widget","bootstrap/button":"bootstrap/button","jquery":"jquery","underscore":"underscore"}],"models/widgets/checkbox_group":[function(require,module,exports){ var $, BokehView, CheckboxGroup, CheckboxGroupView, Widget, _, p, 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, indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; _ = require("underscore"); $ = require("jquery"); Widget = require("./widget"); BokehView = require("../../core/bokeh_view"); p = require("../../core/properties"); CheckboxGroupView = (function(superClass) { extend(CheckboxGroupView, superClass); function CheckboxGroupView() { return CheckboxGroupView.__super__.constructor.apply(this, arguments); } CheckboxGroupView.prototype.events = { "change input": "change_input" }; CheckboxGroupView.prototype.initialize = function(options) { CheckboxGroupView.__super__.initialize.call(this, options); this.render(); return this.listenTo(this.model, 'change', this.render); }; CheckboxGroupView.prototype.render = function() { var $div, $input, $label, active, i, j, label, len, ref; CheckboxGroupView.__super__.render.call(this); this.$el.empty(); active = this.mget("active"); ref = this.mget("labels"); for (i = j = 0, len = ref.length; j < len; i = ++j) { label = ref[i]; $input = $('<input type="checkbox">').attr({ value: "" + i }); if (this.mget("disabled")) { $input.prop("disabled", true); } if (indexOf.call(active, i) >= 0) { $input.prop("checked", true); } $label = $('<label></label>').text(label).prepend($input); if (this.mget("inline")) { $label.addClass("bk-bs-checkbox-inline"); this.$el.append($label); } else { $div = $('<div class="bk-bs-checkbox"></div>').append($label); this.$el.append($div); } } return this; }; CheckboxGroupView.prototype.change_input = function() { var active, checkbox, i, ref; active = (function() { var j, len, ref, results; ref = this.$("input"); results = []; for (i = j = 0, len = ref.length; j < len; i = ++j) { checkbox = ref[i]; if (checkbox.checked) { results.push(i); } } return results; }).call(this); this.model.active = active; return (ref = this.mget('callback')) != null ? ref.execute(this.model) : void 0; }; return CheckboxGroupView; })(Widget.View); CheckboxGroup = (function(superClass) { extend(CheckboxGroup, superClass); function CheckboxGroup() { return CheckboxGroup.__super__.constructor.apply(this, arguments); } CheckboxGroup.prototype.type = "CheckboxGroup"; CheckboxGroup.prototype.default_view = CheckboxGroupView; CheckboxGroup.define({ active: [p.Array, []], labels: [p.Array, []], inline: [p.Bool, false], callback: [p.Instance] }); return CheckboxGroup; })(Widget.Model); module.exports = { Model: CheckboxGroup, View: CheckboxGroupView }; },{"../../core/bokeh_view":"core/bokeh_view","../../core/properties":"core/properties","./widget":"models/widgets/widget","jquery":"jquery","underscore":"underscore"}],"models/widgets/data_table":[function(require,module,exports){ var $, $1, CheckboxSelectColumn, DOMUtil, DataProvider, DataTable, DataTableView, RowSelectionModel, SlickGrid, TableWidget, Widget, _, hittest, p, 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; _ = require("underscore"); $ = require("jquery"); $1 = require("jquery-ui/sortable"); SlickGrid = require("slick_grid/slick.grid"); RowSelectionModel = require("slick_grid/plugins/slick.rowselectionmodel"); CheckboxSelectColumn = require("slick_grid/plugins/slick.checkboxselectcolumn"); hittest = require("../../common/hittest"); p = require("../../core/properties"); DOMUtil = require("../../util/dom_util"); TableWidget = require("./table_widget"); Widget = require("./widget"); DataProvider = (function() { function DataProvider(source1) { var j, ref, results; this.source = source1; this.data = this.source.get('data'); this.fields = _.keys(this.data); if (!_.contains(this.fields, "index")) { this.data["index"] = (function() { results = []; for (var j = 0, ref = this.getLength(); 0 <= ref ? j < ref : j > ref; 0 <= ref ? j++ : j--){ results.push(j); } return results; }).apply(this); this.fields.push("index"); } } DataProvider.prototype.getLength = function() { return this.source.get_length(); }; DataProvider.prototype.getItem = function(offset) { var field, item, j, len, ref; item = {}; ref = this.fields; for (j = 0, len = ref.length; j < len; j++) { field = ref[j]; item[field] = this.data[field][offset]; } return item; }; DataProvider.prototype._setItem = function(offset, item) { var field, value; for (field in item) { value = item[field]; this.data[field][offset] = value; } }; DataProvider.prototype.setItem = function(offset, item) { this._setItem(offset, item); return this.updateSource(); }; DataProvider.prototype.getField = function(index, field) { var offset; offset = this.data["index"].indexOf(index); return this.data[field][offset]; }; DataProvider.prototype._setField = function(index, field, value) { var offset; offset = this.data["index"].indexOf(index); this.data[field][offset] = value; }; DataProvider.prototype.setField = function(index, field, value) { this._setField(index, field, value); return this.updateSource(); }; DataProvider.prototype.updateSource = function() { return this.source.trigger("change:data", this, this.source.attributes['data']); }; DataProvider.prototype.getItemMetadata = function(index) { return null; }; DataProvider.prototype.getRecords = function() { var i; return (function() { var j, ref, results; results = []; for (i = j = 0, ref = this.getLength(); 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) { results.push(this.getItem(i)); } return results; }).call(this); }; DataProvider.prototype.sort = function(columns) { var cols, column, i, j, len, record, records; cols = (function() { var j, len, results; results = []; for (j = 0, len = columns.length; j < len; j++) { column = columns[j]; results.push([column.sortCol.field, column.sortAsc ? 1 : -1]); } return results; })(); if (_.isEmpty(cols)) { cols = [["index", 1]]; } records = this.getRecords(); records.sort(function(record1, record2) { var field, j, len, ref, result, sign, value1, value2; for (j = 0, len = cols.length; j < len; j++) { ref = cols[j], field = ref[0], sign = ref[1]; value1 = record1[field]; value2 = record2[field]; result = value1 === value2 ? 0 : value1 > value2 ? sign : -sign; if (result !== 0) { return result; } } return 0; }); for (i = j = 0, len = records.length; j < len; i = ++j) { record = records[i]; this._setItem(i, record); } return this.updateSource(); }; return DataProvider; })(); DataTableView = (function(superClass) { extend(DataTableView, superClass); function DataTableView() { return DataTableView.__super__.constructor.apply(this, arguments); } DataTableView.prototype.attributes = { "class": "bk-data-table" }; DataTableView.prototype.initialize = function(options) { var source; DataTableView.__super__.initialize.call(this, options); DOMUtil.waitForElement(this.el, (function(_this) { return function() { return _this.render(); }; })(this)); this.listenTo(this.model, 'change', (function(_this) { return function() { return _this.render(); }; })(this)); source = this.mget("source"); this.listenTo(source, 'change:data', (function(_this) { return function() { return _this.updateGrid(); }; })(this)); return this.listenTo(source, 'change:selected', (function(_this) { return function() { return _this.updateSelection(); }; })(this)); }; DataTableView.prototype.updateGrid = function() { this.data = new DataProvider(this.mget("source")); this.grid.setData(this.data); return this.grid.render(); }; DataTableView.prototype.updateSelection = function() { var cur_grid_range, indices, min_index, selected; selected = this.mget("source").get("selected"); indices = selected['1d'].indices; this.grid.setSelectedRows(indices); cur_grid_range = this.grid.getViewport(); if (this.mget("scroll_to_selection") && !_.any(_.map(indices, function(index) { return cur_grid_range["top"] <= index && index <= cur_grid_range["bottom"]; }))) { min_index = Math.max(0, Math.min.apply(null, indices) - 1); return this.grid.scrollRowToTop(min_index); } }; DataTableView.prototype.newIndexColumn = function() { return { id: _.uniqueId(), name: "#", field: "index", width: 40, behavior: "select", cannotTriggerInsert: true, resizable: false, selectable: false, sortable: true, cssClass: "bk-cell-index" }; }; DataTableView.prototype.render = function() { var checkboxSelector, column, columns, height, options, width; columns = (function() { var j, len, ref, results; ref = this.mget("columns"); results = []; for (j = 0, len = ref.length; j < len; j++) { column = ref[j]; results.push(column.toColumn()); } return results; }).call(this); if (this.mget("selectable") === "checkbox") { checkboxSelector = new CheckboxSelectColumn({ cssClass: "bk-cell-select" }); columns.unshift(checkboxSelector.getColumnDefinition()); } if (this.mget("row_headers") && (this.mget("source").get_column("index") != null)) { columns.unshift(this.newIndexColumn()); } width = this.mget("width"); height = this.mget("height"); options = { enableCellNavigation: this.mget("selectable") !== false, enableColumnReorder: true, forceFitColumns: this.mget("fit_columns"), autoHeight: height === "auto", multiColumnSort: this.mget("sortable"), editable: this.mget("editable"), autoEdit: false }; if (width != null) { this.$el.css({ width: (this.mget("width")) + "px" }); } else { this.$el.css({ width: (this.mget("default_width")) + "px" }); } if ((height != null) && height !== "auto") { this.$el.css({ height: (this.mget("height")) + "px" }); } this.data = new DataProvider(this.mget("source")); this.grid = new SlickGrid(this.el, this.data, columns, options); this.grid.onSort.subscribe((function(_this) { return function(event, args) { columns = args.sortCols; _this.data.sort(columns); _this.grid.invalidate(); return _this.grid.render(); }; })(this)); if (this.mget("selectable") !== false) { this.grid.setSelectionModel(new RowSelectionModel({ selectActiveRow: checkboxSelector == null })); if (checkboxSelector != null) { this.grid.registerPlugin(checkboxSelector); } this.grid.onSelectedRowsChanged.subscribe((function(_this) { return function(event, args) { var selected; selected = hittest.create_hit_test_result(); selected['1d'].indices = args.rows; return _this.mget("source").set("selected", selected); }; })(this)); } return this; }; return DataTableView; })(Widget.View); DataTable = (function(superClass) { extend(DataTable, superClass); function DataTable() { return DataTable.__super__.constructor.apply(this, arguments); } DataTable.prototype.type = 'DataTable'; DataTable.prototype.default_view = DataTableView; DataTable.define({ columns: [p.Array, []], fit_columns: [p.Bool, true], so