@quartic/bokehjs
Version:
Interactive, novel data visualization
1,254 lines (1,241 loc) • 804 kB
JavaScript
(function() { var define = undefined; return (function outer(modules, cache, entry) {
if (Bokeh != null) {
for (var name in modules) {
Bokeh.require.modules[name] = modules[name];
}
for (var i = 0; i < entry.length; i++) {
var plugin = Bokeh.require(entry[0]);
Bokeh.Models.register_models(plugin.models);
for (var name in plugin) {
if (name !== "models") {
Bokeh[name] = plugin[name];
}
}
}
} else {
throw new Error("Cannot find Bokeh. You have to load it prior to loading plugins.");
}
})
({"models/widgets/abstract_button":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var 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 p = require("core/properties");
var build_views_1 = require("core/build_views");
var widget_1 = require("./widget");
var button_template_1 = require("./button_template");
exports.AbstractButtonView = (function (superClass) {
extend(AbstractButtonView, superClass);
function AbstractButtonView() {
return AbstractButtonView.__super__.constructor.apply(this, arguments);
}
AbstractButtonView.prototype.events = {
"click": "change_input"
};
AbstractButtonView.prototype.template = button_template_1.default;
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, ref1, val;
AbstractButtonView.__super__.render.call(this);
icon = this.model.icon;
if (icon != null) {
build_views_1.build_views(this.icon_views, [icon]);
ref = this.icon_views;
for (key in ref) {
if (!hasProp.call(ref, key))
continue;
val = ref[key];
if ((ref1 = val.el.parentNode) != null) {
ref1.removeChild(val.el);
}
}
}
this.$el.empty();
html = this.template(this.model.attributes);
this.el.appendChild(html);
$button = this.$el.find('button');
if (icon != null) {
$button.prepend(" ");
$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_1.WidgetView);
exports.AbstractButton = (function (superClass) {
extend(AbstractButton, superClass);
function AbstractButton() {
return AbstractButton.__super__.constructor.apply(this, arguments);
}
AbstractButton.prototype.type = "AbstractButton";
AbstractButton.prototype.default_view = exports.AbstractButtonView;
AbstractButton.define({
callback: [p.Instance],
label: [p.String, "Button"],
icon: [p.Instance],
button_type: [p.String, "default"]
});
return AbstractButton;
})(widget_1.Widget);
},{"./button_template":"models/widgets/button_template","./widget":"models/widgets/widget","core/build_views":undefined,"core/properties":undefined}],"models/widgets/abstract_icon":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var 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 widget_1 = require("./widget");
exports.AbstractIcon = (function (superClass) {
extend(AbstractIcon, superClass);
function AbstractIcon() {
return AbstractIcon.__super__.constructor.apply(this, arguments);
}
AbstractIcon.prototype.type = "AbstractIcon";
return AbstractIcon;
})(widget_1.Widget);
},{"./widget":"models/widgets/widget"}],"models/widgets/autocomplete_input":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var 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("jquery-ui/autocomplete");
var text_input_1 = require("./text_input");
var p = require("core/properties");
exports.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.model.completions
});
$input.autocomplete("widget").addClass("bk-autocomplete-input");
this._prefix_ui();
return this;
};
return AutocompleteInputView;
})(text_input_1.TextInputView);
exports.AutocompleteInput = (function (superClass) {
extend(AutocompleteInput, superClass);
function AutocompleteInput() {
return AutocompleteInput.__super__.constructor.apply(this, arguments);
}
AutocompleteInput.prototype.type = "AutocompleteInput";
AutocompleteInput.prototype.default_view = exports.AutocompleteInputView;
AutocompleteInput.define({
completions: [p.Array, []]
});
return AutocompleteInput;
})(text_input_1.TextInput);
},{"./text_input":"models/widgets/text_input","core/properties":undefined,"jquery-ui/autocomplete":"jquery-ui/autocomplete"}],"models/widgets/button":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var 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 p = require("core/properties");
var bokeh_events_1 = require("core/bokeh_events");
var abstract_button_1 = require("./abstract_button");
exports.ButtonView = (function (superClass) {
extend(ButtonView, superClass);
function ButtonView() {
return ButtonView.__super__.constructor.apply(this, arguments);
}
ButtonView.prototype.change_input = function () {
this.model.trigger_event(new bokeh_events_1.ButtonClick({}));
this.model.clicks = this.model.clicks + 1;
return ButtonView.__super__.change_input.call(this);
};
return ButtonView;
})(abstract_button_1.AbstractButtonView);
exports.Button = (function (superClass) {
extend(Button, superClass);
function Button() {
return Button.__super__.constructor.apply(this, arguments);
}
Button.prototype.type = "Button";
Button.prototype.default_view = exports.ButtonView;
Button.define({
clicks: [p.Number, 0]
});
return Button;
})(abstract_button_1.AbstractButton);
bokeh_events_1.register_with_event(bokeh_events_1.ButtonClick, exports.Button);
},{"./abstract_button":"models/widgets/abstract_button","core/bokeh_events":undefined,"core/properties":undefined}],"models/widgets/button_group_template":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var DOM = require("core/dom");
exports.default = function () {
return DOM.createElement("div", { class: "bk-bs-btn-group", "data-bk-bs-toggle": "buttons" });
};
},{"core/dom":undefined}],"models/widgets/button_template":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var DOM = require("core/dom");
exports.default = function (props) {
return (DOM.createElement("button", { type: "button", class: "bk-bs-btn bk-bs-btn-" + props.button_type }, props.label));
};
},{"core/dom":undefined}],"models/widgets/cell_editors":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var 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/autocomplete");
require("jquery-ui/spinner");
var p = require("core/properties");
var bokeh_view_1 = require("core/bokeh_view");
var model_1 = require("../../model");
var jqueryable_1 = require("./jqueryable");
exports.CellEditorView = (function (superClass) {
extend(CellEditorView, superClass);
function CellEditorView() {
return CellEditorView.__super__.constructor.apply(this, arguments);
}
extend(CellEditorView.prototype, jqueryable_1.JQueryable);
CellEditorView.prototype.className = "bk-cell-editor";
CellEditorView.prototype.input = null;
CellEditorView.prototype.emptyValue = null;
CellEditorView.prototype.defaultValue = null;
CellEditorView.prototype.initialize = function (options) {
this.args = options;
this.model = this.args.column.editor;
CellEditorView.__super__.initialize.call(this, options);
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();
this._prefix_ui();
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;
})(bokeh_view_1.BokehView);
exports.CellEditor = (function (superClass) {
extend(CellEditor, superClass);
function CellEditor() {
return CellEditor.__super__.constructor.apply(this, arguments);
}
CellEditor.prototype.type = "CellEditor";
CellEditor.prototype.default_view = exports.CellEditorView;
return CellEditor;
})(model_1.Model);
exports.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.completions;
if (completions.length !== 0) {
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;
})(exports.CellEditorView);
exports.StringEditor = (function (superClass) {
extend(StringEditor, superClass);
function StringEditor() {
return StringEditor.__super__.constructor.apply(this, arguments);
}
StringEditor.prototype.type = 'StringEditor';
StringEditor.prototype.default_view = exports.StringEditorView;
StringEditor.define({
completions: [p.Array, []]
});
return StringEditor;
})(exports.CellEditor);
exports.TextEditorView = (function (superClass) {
extend(TextEditorView, superClass);
function TextEditorView() {
return TextEditorView.__super__.constructor.apply(this, arguments);
}
return TextEditorView;
})(exports.CellEditorView);
exports.TextEditor = (function (superClass) {
extend(TextEditor, superClass);
function TextEditor() {
return TextEditor.__super__.constructor.apply(this, arguments);
}
TextEditor.prototype.type = 'TextEditor';
TextEditor.prototype.default_view = exports.TextEditorView;
return TextEditor;
})(exports.CellEditor);
exports.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.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;
})(exports.CellEditorView);
exports.SelectEditor = (function (superClass) {
extend(SelectEditor, superClass);
function SelectEditor() {
return SelectEditor.__super__.constructor.apply(this, arguments);
}
SelectEditor.prototype.type = 'SelectEditor';
SelectEditor.prototype.default_view = exports.SelectEditorView;
SelectEditor.define({
options: [p.Array, []]
});
return SelectEditor;
})(exports.CellEditor);
exports.PercentEditorView = (function (superClass) {
extend(PercentEditorView, superClass);
function PercentEditorView() {
return PercentEditorView.__super__.constructor.apply(this, arguments);
}
return PercentEditorView;
})(exports.CellEditorView);
exports.PercentEditor = (function (superClass) {
extend(PercentEditor, superClass);
function PercentEditor() {
return PercentEditor.__super__.constructor.apply(this, arguments);
}
PercentEditor.prototype.type = 'PercentEditor';
PercentEditor.prototype.default_view = exports.PercentEditorView;
return PercentEditor;
})(exports.CellEditor);
exports.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;
})(exports.CellEditorView);
exports.CheckboxEditor = (function (superClass) {
extend(CheckboxEditor, superClass);
function CheckboxEditor() {
return CheckboxEditor.__super__.constructor.apply(this, arguments);
}
CheckboxEditor.prototype.type = 'CheckboxEditor';
CheckboxEditor.prototype.default_view = exports.CheckboxEditorView;
return CheckboxEditor;
})(exports.CellEditor);
exports.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.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;
})(exports.CellEditorView);
exports.IntEditor = (function (superClass) {
extend(IntEditor, superClass);
function IntEditor() {
return IntEditor.__super__.constructor.apply(this, arguments);
}
IntEditor.prototype.type = 'IntEditor';
IntEditor.prototype.default_view = exports.IntEditorView;
IntEditor.define({
step: [p.Number, 1]
});
return IntEditor;
})(exports.CellEditor);
exports.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.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;
})(exports.CellEditorView);
exports.NumberEditor = (function (superClass) {
extend(NumberEditor, superClass);
function NumberEditor() {
return NumberEditor.__super__.constructor.apply(this, arguments);
}
NumberEditor.prototype.type = 'NumberEditor';
NumberEditor.prototype.default_view = exports.NumberEditorView;
NumberEditor.define({
step: [p.Number, 0.01]
});
return NumberEditor;
})(exports.CellEditor);
exports.TimeEditorView = (function (superClass) {
extend(TimeEditorView, superClass);
function TimeEditorView() {
return TimeEditorView.__super__.constructor.apply(this, arguments);
}
return TimeEditorView;
})(exports.CellEditorView);
exports.TimeEditor = (function (superClass) {
extend(TimeEditor, superClass);
function TimeEditor() {
return TimeEditor.__super__.constructor.apply(this, arguments);
}
TimeEditor.prototype.type = 'TimeEditor';
TimeEditor.prototype.default_view = exports.TimeEditorView;
return TimeEditor;
})(exports.CellEditor);
exports.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;
})(exports.CellEditorView);
exports.DateEditor = (function (superClass) {
extend(DateEditor, superClass);
function DateEditor() {
return DateEditor.__super__.constructor.apply(this, arguments);
}
DateEditor.prototype.type = 'DateEditor';
DateEditor.prototype.default_view = exports.DateEditorView;
return DateEditor;
})(exports.CellEditor);
},{"../../model":"model","./jqueryable":"models/widgets/jqueryable","core/bokeh_view":undefined,"core/properties":undefined,"jquery":"jquery","jquery-ui/autocomplete":"jquery-ui/autocomplete","jquery-ui/spinner":"jquery-ui/spinner"}],"models/widgets/cell_formatters":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var extend1 = 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");
var Numbro = require("numbro");
var p = require("core/properties");
var object_1 = require("core/util/object");
var types_1 = require("core/util/types");
var model_1 = require("../../model");
exports.CellFormatter = (function (superClass) {
extend1(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, "&").replace(/</g, "<").replace(/>/g, ">");
}
};
return CellFormatter;
})(model_1.Model);
exports.StringFormatter = (function (superClass) {
extend1(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.font_style;
text_align = this.text_align;
text_color = this.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;
})(exports.CellFormatter);
exports.NumberFormatter = (function (superClass) {
extend1(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.format;
language = this.language;
rounding = (function () {
switch (this.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;
})(exports.StringFormatter);
exports.BooleanFormatter = (function (superClass) {
extend1(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.icon).html();
}
else {
return "";
}
};
return BooleanFormatter;
})(exports.CellFormatter);
exports.DateFormatter = (function (superClass) {
extend1(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.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 = types_1.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;
})(exports.CellFormatter);
exports.HTMLTemplateFormatter = (function (superClass) {
extend1(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.template;
if (value === null) {
return "";
}
else {
dataContext = object_1.extend({}, dataContext, {
value: value
});
compiled_template = _.template(template);
return compiled_template(dataContext);
}
};
return HTMLTemplateFormatter;
})(exports.CellFormatter);
},{"../../model":"model","core/properties":undefined,"core/util/object":undefined,"core/util/types":undefined,"jquery":"jquery","numbro":"numbro"}],"models/widgets/checkbox_button_group":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var 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; };
var $ = require("jquery");
require("bootstrap/button");
var widget_1 = require("./widget");
var p = require("core/properties");
var button_group_template_1 = require("./button_group_template");
exports.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 = button_group_template_1.default;
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.appendChild(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.model.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.$el.find("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.model.callback) != null ? ref.execute(this.model) : void 0;
};
return CheckboxButtonGroupView;
})(widget_1.WidgetView);
exports.CheckboxButtonGroup = (function (superClass) {
extend(CheckboxButtonGroup, superClass);
function CheckboxButtonGroup() {
return CheckboxButtonGroup.__super__.constructor.apply(this, arguments);
}
CheckboxButtonGroup.prototype.type = "CheckboxButtonGroup";
CheckboxButtonGroup.prototype.default_view = exports.CheckboxButtonGroupView;
CheckboxButtonGroup.define({
active: [p.Array, []],
labels: [p.Array, []],
button_type: [p.String, "default"],
callback: [p.Instance]
});
return CheckboxButtonGroup;
})(widget_1.Widget);
},{"./button_group_template":"models/widgets/button_group_template","./widget":"models/widgets/widget","bootstrap/button":"bootstrap/button","core/properties":undefined,"jquery":"jquery"}],"models/widgets/checkbox_group":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var 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; };
var $ = require("jquery");
var widget_1 = require("./widget");
var p = require("core/properties");
exports.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.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 (this.model.disabled) {
$input.prop("disabled", true);
}
if (indexOf.call(active, i) >= 0) {
$input.prop("checked", true);
}
$label = $('<label></label>').text(label).prepend($input);
if (this.model.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.$el.find("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.model.callback) != null ? ref.execute(this.model) : void 0;
};
return CheckboxGroupView;
})(widget_1.WidgetView);
exports.CheckboxGroup = (function (superClass) {
extend(CheckboxGroup, superClass);
function CheckboxGroup() {
return CheckboxGroup.__super__.constructor.apply(this, arguments);
}
CheckboxGroup.prototype.type = "CheckboxGroup";
CheckboxGroup.prototype.default_view = exports.CheckboxGroupView;
CheckboxGroup.define({
active: [p.Array, []],
labels: [p.Array, []],
inline: [p.Bool, false],
callback: [p.Instance]
});
return CheckboxGroup;
})(widget_1.Widget);
},{"./widget":"models/widgets/widget","core/properties":undefined,"jquery":"jquery"}],"models/widgets/data_table":[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var wait_for_element, 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; }, 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/sortable");
var SlickGrid = require("slick_grid/slick.grid");
var RowSelectionModel = require("slick_grid/plugins/slick.rowselectionmodel");
var CheckboxSelectColumn = require("slick_grid/plugins/slick.checkboxselectcolumn");
var hittest = require("core/hittest");
var p = require("core/properties");
var string_1 = require("core/util/string");
var array_1 = require("core/util/array");
var table_widget_1 = require("./table_widget");
var widget_1 = require("./widget");
wait_for_element = function (el, fn) {
var handler, interval;
handler = (function (_this) {
return function () {
if ($.contains(document.documentElement, el)) {
clearInterval(interval);
return fn();
}
};
})(this);
return interval = setInterval(handler, 50);
};
exports.DataProvider = (function () {
function DataProvider(source) {
var j, ref, results;
this.source = source;
this.data = this.source.data;
this.fields = Object.keys(this.data);
if (indexOf.call(this.fields, "index") < 0) {
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 (cols.length === 0) {
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;
})();
exports.DataTableView = (function (superClass) {
extend(DataTableView, superClass);
function DataTableView() {
return DataTableView.__super__.constructor.apply(this, arguments);
}
DataTableView.prototype.className = "bk-data-table";
DataTableView.prototype.initialize = function (options) {
DataTableView.__super__.initialize.call(this, options);
wait_for_element(this.el, (function (_this) {
return function () {
return _this.render();
};
})(this));
this.listenTo(this.model, 'change', (function (_this) {
return function () {
return _this.render();
};
})(this));
this.listenTo(this.model.source, 'change:data', (function (_this) {
return function () {
return _this.updateGrid();
};
})(this));
this.listenTo(this.model.source, 'stream', (function (_this) {
return function () {
return _this.updateGrid();
};
})(this));
this.listenTo(this.model.source, 'patch', (function (_this) {
return function () {
return _this.updateGrid();
};
})(this));
return this.listenTo(this.model.source, 'change:selected', (function (_this) {
return function () {
return _this.updateSelection();
};
})(this));
};
DataTableView.prototype.updateGrid = function () {
this.data.constructor(this.model.source);
this.grid.invalidate();
this.grid.render();
this.model.source.data = this.model.source.data;
return this.model.source.trigger('change');
};
DataTableView.prototype.updateSelection = function () {
var cur_grid_range, indices, min_index, selected;
selected = this.model.source.selected;
indices = selected['1d'].indices;
this.grid.setSelectedRows(indices);
cur_grid_range = this.grid.getViewport();
if (this.model.scroll_to_selection && !array_1.any(indices, function (i) {
return (cur_grid_range.top <= i && i <= 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: string_1.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.model.columns;
results = [];
for (j = 0, len = ref.length; j < len; j++) {
column = ref[j];
results.push(column.toColumn());
}
return results;
}).call(this);
if (this.model.selectable === "checkbox") {
checkboxSelector = new CheckboxSelectColumn({