|
- (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- 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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- var Events = function () {
- function Events() {
- _classCallCheck(this, Events);
-
- this._types = {};
- this._seq = 0;
- }
-
- _createClass(Events, [{
- key: "on",
- value: function on(eventType, listener) {
- var subs = this._types[eventType];
- if (!subs) {
- subs = this._types[eventType] = {};
- }
- var sub = "sub" + this._seq++;
- subs[sub] = listener;
- return sub;
- }
-
-
-
- }, {
- key: "off",
- value: function off(eventType, listener) {
- var subs = this._types[eventType];
- if (typeof listener === "function") {
- for (var key in subs) {
- if (subs.hasOwnProperty(key)) {
- if (subs[key] === listener) {
- delete subs[key];
- return key;
- }
- }
- }
- return false;
- } else if (typeof listener === "string") {
- if (subs && subs[listener]) {
- delete subs[listener];
- return listener;
- }
- return false;
- } else {
- throw new Error("Unexpected type for listener");
- }
- }
- }, {
- key: "trigger",
- value: function trigger(eventType, arg, thisObj) {
- var subs = this._types[eventType];
- for (var key in subs) {
- if (subs.hasOwnProperty(key)) {
- subs[key].call(thisObj, arg);
- }
- }
- }
- }]);
-
- return Events;
- }();
-
- exports.default = Events;
-
- },{}],2:[function(require,module,exports){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.FilterHandle = undefined;
-
- 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; }; }();
-
- var _events = require("./events");
-
- var _events2 = _interopRequireDefault(_events);
-
- var _filterset = require("./filterset");
-
- var _filterset2 = _interopRequireDefault(_filterset);
-
- var _group = require("./group");
-
- var _group2 = _interopRequireDefault(_group);
-
- var _util = require("./util");
-
- var util = _interopRequireWildcard(_util);
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- 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"); } }
-
- function getFilterSet(group) {
- var fsVar = group.var("filterset");
- var result = fsVar.get();
- if (!result) {
- result = new _filterset2.default();
- fsVar.set(result);
- }
- return result;
- }
-
- var id = 1;
- function nextId() {
- return id++;
- }
-
- var FilterHandle = exports.FilterHandle = function () {
-
-
- function FilterHandle(group, extraInfo) {
- _classCallCheck(this, FilterHandle);
-
- this._eventRelay = new _events2.default();
- this._emitter = new util.SubscriptionTracker(this._eventRelay);
-
-
- this._group = null;
-
- this._filterSet = null;
-
- this._filterVar = null;
-
- this._varOnChangeSub = null;
-
- this._extraInfo = util.extend({ sender: this }, extraInfo);
-
- this._id = "filter" + nextId();
-
- this.setGroup(group);
- }
-
-
-
-
-
- _createClass(FilterHandle, [{
- key: "setGroup",
- value: function setGroup(group) {
- var _this = this;
-
-
- if (this._group === group) return;
-
- if (!this._group && !group) return;
-
- if (this._filterVar) {
- this._filterVar.off("change", this._varOnChangeSub);
- this.clear();
- this._varOnChangeSub = null;
- this._filterVar = null;
- this._filterSet = null;
- }
-
- this._group = group;
-
- if (group) {
- group = (0, _group2.default)(group);
- this._filterSet = getFilterSet(group);
- this._filterVar = (0, _group2.default)(group).var("filter");
- var sub = this._filterVar.on("change", function (e) {
- _this._eventRelay.trigger("change", e, _this);
- });
- this._varOnChangeSub = sub;
- }
- }
-
-
-
-
- }, {
- key: "_mergeExtraInfo",
- value: function _mergeExtraInfo(extraInfo) {
- return util.extend({}, this._extraInfo ? this._extraInfo : null, extraInfo ? extraInfo : null);
- }
-
-
-
-
- }, {
- key: "close",
- value: function close() {
- this._emitter.removeAllListeners();
- this.clear();
- this.setGroup(null);
- }
-
-
-
-
- }, {
- key: "clear",
- value: function clear(extraInfo) {
- if (!this._filterSet) return;
- this._filterSet.clear(this._id);
- this._onChange(extraInfo);
- }
-
-
-
-
- }, {
- key: "set",
- value: function set(keys, extraInfo) {
- if (!this._filterSet) return;
- this._filterSet.update(this._id, keys);
- this._onChange(extraInfo);
- }
-
-
-
-
- }, {
- key: "on",
-
-
-
-
- value: function on(eventType, listener) {
- return this._emitter.on(eventType, listener);
- }
-
-
-
-
- }, {
- key: "off",
- value: function off(eventType, listener) {
- return this._emitter.off(eventType, listener);
- }
- }, {
- key: "_onChange",
- value: function _onChange(extraInfo) {
- if (!this._filterSet) return;
- this._filterVar.set(this._filterSet.value, this._mergeExtraInfo(extraInfo));
- }
-
-
-
-
-
-
-
- }, {
- key: "filteredKeys",
- get: function get() {
- return this._filterSet ? this._filterSet.value : null;
- }
- }]);
-
- return FilterHandle;
- }();
-
- },{"./events":1,"./filterset":3,"./group":4,"./util":11}],3:[function(require,module,exports){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- 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; }; }();
-
- var _util = require("./util");
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function naturalComparator(a, b) {
- if (a === b) {
- return 0;
- } else if (a < b) {
- return -1;
- } else if (a > b) {
- return 1;
- }
- }
-
-
-
- var FilterSet = function () {
- function FilterSet() {
- _classCallCheck(this, FilterSet);
-
- this.reset();
- }
-
- _createClass(FilterSet, [{
- key: "reset",
- value: function reset() {
-
- this._handles = {};
-
- this._keys = {};
- this._value = null;
- this._activeHandles = 0;
- }
- }, {
- key: "update",
- value: function update(handleId, keys) {
- if (keys !== null) {
- keys = keys.slice(0);
- keys.sort(naturalComparator);
- }
-
- var _diffSortedLists = (0, _util.diffSortedLists)(this._handles[handleId], keys),
- added = _diffSortedLists.added,
- removed = _diffSortedLists.removed;
-
- this._handles[handleId] = keys;
-
- for (var i = 0; i < added.length; i++) {
- this._keys[added[i]] = (this._keys[added[i]] || 0) + 1;
- }
- for (var _i = 0; _i < removed.length; _i++) {
- this._keys[removed[_i]]--;
- }
-
- this._updateValue(keys);
- }
-
-
-
-
- }, {
- key: "_updateValue",
- value: function _updateValue() {
- var keys = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this._allKeys;
-
- var handleCount = Object.keys(this._handles).length;
- if (handleCount === 0) {
- this._value = null;
- } else {
- this._value = [];
- for (var i = 0; i < keys.length; i++) {
- var count = this._keys[keys[i]];
- if (count === handleCount) {
- this._value.push(keys[i]);
- }
- }
- }
- }
- }, {
- key: "clear",
- value: function clear(handleId) {
- if (typeof this._handles[handleId] === "undefined") {
- return;
- }
-
- var keys = this._handles[handleId];
- if (!keys) {
- keys = [];
- }
-
- for (var i = 0; i < keys.length; i++) {
- this._keys[keys[i]]--;
- }
- delete this._handles[handleId];
-
- this._updateValue();
- }
- }, {
- key: "value",
- get: function get() {
- return this._value;
- }
- }, {
- key: "_allKeys",
- get: function get() {
- var allKeys = Object.keys(this._keys);
- allKeys.sort(naturalComparator);
- return allKeys;
- }
- }]);
-
- return FilterSet;
- }();
-
- exports.default = FilterSet;
-
- },{"./util":11}],4:[function(require,module,exports){
- (function (global){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- 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; }; }();
-
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-
- exports.default = group;
-
- var _var2 = require("./var");
-
- var _var3 = _interopRequireDefault(_var2);
-
- 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"); } }
-
-
-
- global.__crosstalk_groups = global.__crosstalk_groups || {};
- var groups = global.__crosstalk_groups;
-
- function group(groupName) {
- if (groupName && typeof groupName === "string") {
- if (!groups.hasOwnProperty(groupName)) {
- groups[groupName] = new Group(groupName);
- }
- return groups[groupName];
- } else if ((typeof groupName === "undefined" ? "undefined" : _typeof(groupName)) === "object" && groupName._vars && groupName.var) {
-
- return groupName;
- } else if (Array.isArray(groupName) && groupName.length == 1 && typeof groupName[0] === "string") {
- return group(groupName[0]);
- } else {
- throw new Error("Invalid groupName argument");
- }
- }
-
- var Group = function () {
- function Group(name) {
- _classCallCheck(this, Group);
-
- this.name = name;
- this._vars = {};
- }
-
- _createClass(Group, [{
- key: "var",
- value: function _var(name) {
- if (!name || typeof name !== "string") {
- throw new Error("Invalid var name");
- }
-
- if (!this._vars.hasOwnProperty(name)) this._vars[name] = new _var3.default(this, name);
- return this._vars[name];
- }
- }, {
- key: "has",
- value: function has(name) {
- if (!name || typeof name !== "string") {
- throw new Error("Invalid var name");
- }
-
- return this._vars.hasOwnProperty(name);
- }
- }]);
-
- return Group;
- }();
-
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-
- },{"./var":12}],5:[function(require,module,exports){
- (function (global){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- var _group = require("./group");
-
- var _group2 = _interopRequireDefault(_group);
-
- var _selection = require("./selection");
-
- var _filter = require("./filter");
-
- require("./input");
-
- require("./input_selectize");
-
- require("./input_checkboxgroup");
-
- require("./input_slider");
-
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
-
- var defaultGroup = (0, _group2.default)("default");
-
- function var_(name) {
- return defaultGroup.var(name);
- }
-
- function has(name) {
- return defaultGroup.has(name);
- }
-
- if (global.Shiny) {
- global.Shiny.addCustomMessageHandler("update-client-value", function (message) {
- if (typeof message.group === "string") {
- (0, _group2.default)(message.group).var(message.name).set(message.value);
- } else {
- var_(message.name).set(message.value);
- }
- });
- }
-
- var crosstalk = {
- group: _group2.default,
- var: var_,
- has: has,
- SelectionHandle: _selection.SelectionHandle,
- FilterHandle: _filter.FilterHandle
- };
-
-
- exports.default = crosstalk;
-
- global.crosstalk = crosstalk;
-
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-
- },{"./filter":2,"./group":4,"./input":6,"./input_checkboxgroup":7,"./input_selectize":8,"./input_slider":9,"./selection":10}],6:[function(require,module,exports){
- (function (global){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.register = register;
- var $ = global.jQuery;
-
- var bindings = {};
-
- function register(reg) {
- bindings[reg.className] = reg;
- if (global.document && global.document.readyState !== "complete") {
- $(function () {
- bind();
- });
- } else if (global.document) {
- setTimeout(bind, 100);
- }
- }
-
- function bind() {
- Object.keys(bindings).forEach(function (className) {
- var binding = bindings[className];
- $("." + binding.className).not(".crosstalk-input-bound").each(function (i, el) {
- bindInstance(binding, el);
- });
- });
- }
-
-
- function $escape(val) {
- return val.replace(/([!"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~])/g, "\\$1");
- }
-
- function bindEl(el) {
- var $el = $(el);
- Object.keys(bindings).forEach(function (className) {
- if ($el.hasClass(className) && !$el.hasClass("crosstalk-input-bound")) {
- var binding = bindings[className];
- bindInstance(binding, el);
- }
- });
- }
-
- function bindInstance(binding, el) {
- var jsonEl = $(el).find("script[type='application/json'][data-for='" + $escape(el.id) + "']");
- var data = JSON.parse(jsonEl[0].innerText);
-
- var instance = binding.factory(el, data);
- $(el).data("crosstalk-instance", instance);
- $(el).addClass("crosstalk-input-bound");
- }
-
- if (global.Shiny) {
- (function () {
- var inputBinding = new global.Shiny.InputBinding();
- var $ = global.jQuery;
- $.extend(inputBinding, {
- find: function find(scope) {
- return $(scope).find(".crosstalk-input");
- },
- initialize: function initialize(el) {
- if (!$(el).hasClass("crosstalk-input-bound")) {
- bindEl(el);
- }
- },
- getId: function getId(el) {
- return el.id;
- },
- getValue: function getValue(el) {},
- setValue: function setValue(el, value) {},
- receiveMessage: function receiveMessage(el, data) {},
- subscribe: function subscribe(el, callback) {
- $(el).data("crosstalk-instance").resume();
- },
- unsubscribe: function unsubscribe(el) {
- $(el).data("crosstalk-instance").suspend();
- }
- });
- global.Shiny.inputBindings.register(inputBinding, "crosstalk.inputBinding");
- })();
- }
-
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-
- },{}],7:[function(require,module,exports){
- (function (global){
- "use strict";
-
- var _input = require("./input");
-
- var input = _interopRequireWildcard(_input);
-
- var _filter = require("./filter");
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- var $ = global.jQuery;
-
- input.register({
- className: "crosstalk-input-checkboxgroup",
-
- factory: function factory(el, data) {
-
-
- var ctHandle = new _filter.FilterHandle(data.group);
-
- var lastKnownKeys = void 0;
- var $el = $(el);
- $el.on("change", "input[type='checkbox']", function () {
- var checked = $el.find("input[type='checkbox']:checked");
- if (checked.length === 0) {
- lastKnownKeys = null;
- ctHandle.clear();
- } else {
- (function () {
- var keys = {};
- checked.each(function () {
- data.map[this.value].forEach(function (key) {
- keys[key] = true;
- });
- });
- var keyArray = Object.keys(keys);
- keyArray.sort();
- lastKnownKeys = keyArray;
- ctHandle.set(keyArray);
- })();
- }
- });
-
- return {
- suspend: function suspend() {
- ctHandle.clear();
- },
- resume: function resume() {
- if (lastKnownKeys) ctHandle.set(lastKnownKeys);
- }
- };
- }
- });
-
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-
- },{"./filter":2,"./input":6}],8:[function(require,module,exports){
- (function (global){
- "use strict";
-
- var _input = require("./input");
-
- var input = _interopRequireWildcard(_input);
-
- var _util = require("./util");
-
- var util = _interopRequireWildcard(_util);
-
- var _filter = require("./filter");
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- var $ = global.jQuery;
-
- input.register({
- className: "crosstalk-input-select",
-
- factory: function factory(el, data) {
-
-
-
- var first = [{ value: "", label: "(All)" }];
- var items = util.dataframeToD3(data.items);
- var opts = {
- options: first.concat(items),
- valueField: "value",
- labelField: "label",
- searchField: "label"
- };
-
- var select = $(el).find("select")[0];
-
- var selectize = $(select).selectize(opts)[0].selectize;
-
- var ctHandle = new _filter.FilterHandle(data.group);
-
- var lastKnownKeys = void 0;
- selectize.on("change", function () {
- if (selectize.items.length === 0) {
- lastKnownKeys = null;
- ctHandle.clear();
- } else {
- (function () {
- var keys = {};
- selectize.items.forEach(function (group) {
- data.map[group].forEach(function (key) {
- keys[key] = true;
- });
- });
- var keyArray = Object.keys(keys);
- keyArray.sort();
- lastKnownKeys = keyArray;
- ctHandle.set(keyArray);
- })();
- }
- });
-
- return {
- suspend: function suspend() {
- ctHandle.clear();
- },
- resume: function resume() {
- if (lastKnownKeys) ctHandle.set(lastKnownKeys);
- }
- };
- }
- });
-
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-
- },{"./filter":2,"./input":6,"./util":11}],9:[function(require,module,exports){
- (function (global){
- "use strict";
-
- var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
-
- var _input = require("./input");
-
- var input = _interopRequireWildcard(_input);
-
- var _filter = require("./filter");
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- var $ = global.jQuery;
- var strftime = global.strftime;
-
- input.register({
- className: "crosstalk-input-slider",
-
- factory: function factory(el, data) {
-
-
- var ctHandle = new _filter.FilterHandle(data.group);
-
- var opts = {};
- var $el = $(el).find("input");
- var dataType = $el.data("data-type");
- var timeFormat = $el.data("time-format");
- var timeFormatter = void 0;
-
-
- if (dataType === "date") {
- timeFormatter = strftime.utc();
- opts.prettify = function (num) {
- return timeFormatter(timeFormat, new Date(num));
- };
- } else if (dataType === "datetime") {
- var timezone = $el.data("timezone");
- if (timezone) timeFormatter = strftime.timezone(timezone);else timeFormatter = strftime;
-
- opts.prettify = function (num) {
- return timeFormatter(timeFormat, new Date(num));
- };
- }
-
- $el.ionRangeSlider(opts);
-
- function getValue() {
- var result = $el.data("ionRangeSlider").result;
-
-
- var convert = void 0;
- var dataType = $el.data("data-type");
- if (dataType === "date") {
- convert = function convert(val) {
- return formatDateUTC(new Date(+val));
- };
- } else if (dataType === "datetime") {
- convert = function convert(val) {
-
- return +val / 1000;
- };
- } else {
- convert = function convert(val) {
- return +val;
- };
- }
-
- if ($el.data("ionRangeSlider").options.type === "double") {
- return [convert(result.from), convert(result.to)];
- } else {
- return convert(result.from);
- }
- }
-
- var lastKnownKeys = null;
-
- $el.on("change.crosstalkSliderInput", function (event) {
- if (!$el.data("updating") && !$el.data("animating")) {
- var _getValue = getValue(),
- _getValue2 = _slicedToArray(_getValue, 2),
- from = _getValue2[0],
- to = _getValue2[1];
-
- var keys = [];
- for (var i = 0; i < data.values.length; i++) {
- var val = data.values[i];
- if (val >= from && val <= to) {
- keys.push(data.keys[i]);
- }
- }
- keys.sort();
- ctHandle.set(keys);
- lastKnownKeys = keys;
- }
- });
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- return {
- suspend: function suspend() {
- ctHandle.clear();
- },
- resume: function resume() {
- if (lastKnownKeys) ctHandle.set(lastKnownKeys);
- }
- };
- }
- });
-
-
- function padZeros(n, digits) {
- var str = n.toString();
- while (str.length < digits) {
- str = "0" + str;
- }return str;
- }
-
-
-
- function formatDateUTC(date) {
- if (date instanceof Date) {
- return date.getUTCFullYear() + "-" + padZeros(date.getUTCMonth() + 1, 2) + "-" + padZeros(date.getUTCDate(), 2);
- } else {
- return null;
- }
- }
-
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-
- },{"./filter":2,"./input":6}],10:[function(require,module,exports){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.SelectionHandle = undefined;
-
- 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; }; }();
-
- var _events = require("./events");
-
- var _events2 = _interopRequireDefault(_events);
-
- var _group = require("./group");
-
- var _group2 = _interopRequireDefault(_group);
-
- var _util = require("./util");
-
- var util = _interopRequireWildcard(_util);
-
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
-
- 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 SelectionHandle = exports.SelectionHandle = function () {
-
-
-
- function SelectionHandle() {
- var group = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
- var extraInfo = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
-
- _classCallCheck(this, SelectionHandle);
-
- this._eventRelay = new _events2.default();
- this._emitter = new util.SubscriptionTracker(this._eventRelay);
-
-
- this._group = null;
-
- this._var = null;
-
- this._varOnChangeSub = null;
-
- this._extraInfo = util.extend({ sender: this }, extraInfo);
-
- this.setGroup(group);
- }
-
-
-
-
-
- _createClass(SelectionHandle, [{
- key: "setGroup",
- value: function setGroup(group) {
- var _this = this;
-
-
- if (this._group === group) return;
-
- if (!this._group && !group) return;
-
- if (this._var) {
- this._var.off("change", this._varOnChangeSub);
- this._var = null;
- this._varOnChangeSub = null;
- }
-
- this._group = group;
-
- if (group) {
- this._var = (0, _group2.default)(group).var("selection");
- var sub = this._var.on("change", function (e) {
- _this._eventRelay.trigger("change", e, _this);
- });
- this._varOnChangeSub = sub;
- }
- }
-
-
-
-
- }, {
- key: "_mergeExtraInfo",
-
-
-
-
- value: function _mergeExtraInfo(extraInfo) {
-
- return util.extend({}, this._extraInfo ? this._extraInfo : null, extraInfo ? extraInfo : null);
- }
-
-
-
-
- }, {
- key: "set",
- value: function set(selectedKeys, extraInfo) {
- if (this._var) this._var.set(selectedKeys, this._mergeExtraInfo(extraInfo));
- }
-
-
-
-
- }, {
- key: "clear",
- value: function clear(extraInfo) {
- if (this._var) this.set(void 0, this._mergeExtraInfo(extraInfo));
- }
-
-
-
-
- }, {
- key: "on",
- value: function on(eventType, listener) {
- return this._emitter.on(eventType, listener);
- }
-
-
-
-
- }, {
- key: "off",
- value: function off(eventType, listener) {
- return this._emitter.off(eventType, listener);
- }
-
-
-
-
- }, {
- key: "close",
- value: function close() {
- this._emitter.removeAllListeners();
- this.setGroup(null);
- }
-
-
-
-
-
-
-
- }, {
- key: "value",
- get: function get() {
- return this._var ? this._var.get() : null;
- }
- }]);
-
- return SelectionHandle;
- }();
-
- },{"./events":1,"./group":4,"./util":11}],11:[function(require,module,exports){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- 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; }; }();
-
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-
- exports.extend = extend;
- exports.checkSorted = checkSorted;
- exports.diffSortedLists = diffSortedLists;
- exports.dataframeToD3 = dataframeToD3;
-
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
-
- function extend(target) {
- for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
- sources[_key - 1] = arguments[_key];
- }
-
- for (var i = 0; i < sources.length; i++) {
- var src = sources[i];
- if (typeof src === "undefined" || src === null) continue;
-
- for (var key in src) {
- if (src.hasOwnProperty(key)) {
- target[key] = src[key];
- }
- }
- }
- return target;
- }
-
- function checkSorted(list) {
- for (var i = 1; i < list.length; i++) {
- if (list[i] <= list[i - 1]) {
- throw new Error("List is not sorted or contains duplicate");
- }
- }
- }
-
- function diffSortedLists(a, b) {
- var i_a = 0;
- var i_b = 0;
-
- if (!a) a = [];
- if (!b) b = [];
-
- var a_only = [];
- var b_only = [];
-
- checkSorted(a);
- checkSorted(b);
-
- while (i_a < a.length && i_b < b.length) {
- if (a[i_a] === b[i_b]) {
- i_a++;
- i_b++;
- } else if (a[i_a] < b[i_b]) {
- a_only.push(a[i_a++]);
- } else {
- b_only.push(b[i_b++]);
- }
- }
-
- if (i_a < a.length) a_only = a_only.concat(a.slice(i_a));
- if (i_b < b.length) b_only = b_only.concat(b.slice(i_b));
- return {
- removed: a_only,
- added: b_only
- };
- }
-
-
-
- function dataframeToD3(df) {
- var names = [];
- var length = void 0;
- for (var name in df) {
- if (df.hasOwnProperty(name)) names.push(name);
- if (_typeof(df[name]) !== "object" || typeof df[name].length === "undefined") {
- throw new Error("All fields must be arrays");
- } else if (typeof length !== "undefined" && length !== df[name].length) {
- throw new Error("All fields must be arrays of the same length");
- }
- length = df[name].length;
- }
- var results = [];
- var item = void 0;
- for (var row = 0; row < length; row++) {
- item = {};
- for (var col = 0; col < names.length; col++) {
- item[names[col]] = df[names[col]][row];
- }
- results.push(item);
- }
- return results;
- }
-
-
-
- var SubscriptionTracker = exports.SubscriptionTracker = function () {
- function SubscriptionTracker(emitter) {
- _classCallCheck(this, SubscriptionTracker);
-
- this._emitter = emitter;
- this._subs = {};
- }
-
- _createClass(SubscriptionTracker, [{
- key: "on",
- value: function on(eventType, listener) {
- var sub = this._emitter.on(eventType, listener);
- this._subs[sub] = eventType;
- return sub;
- }
- }, {
- key: "off",
- value: function off(eventType, listener) {
- var sub = this._emitter.off(eventType, listener);
- if (sub) {
- delete this._subs[sub];
- }
- return sub;
- }
- }, {
- key: "removeAllListeners",
- value: function removeAllListeners() {
- var _this = this;
-
- var current_subs = this._subs;
- this._subs = {};
- Object.keys(current_subs).forEach(function (sub) {
- _this._emitter.off(current_subs[sub], sub);
- });
- }
- }]);
-
- return SubscriptionTracker;
- }();
-
- },{}],12:[function(require,module,exports){
- (function (global){
- "use strict";
-
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
-
- var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
-
- 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; }; }();
-
- var _events = require("./events");
-
- var _events2 = _interopRequireDefault(_events);
-
- 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 Var = function () {
- function Var(group, name, /*optional*/value) {
- _classCallCheck(this, Var);
-
- this._group = group;
- this._name = name;
- this._value = value;
- this._events = new _events2.default();
- }
-
- _createClass(Var, [{
- key: "get",
- value: function get() {
- return this._value;
- }
- }, {
- key: "set",
- value: function set(value, /*optional*/event) {
- if (this._value === value) {
-
- return;
- }
- var oldValue = this._value;
- this._value = value;
-
- var evt = {};
- if (event && (typeof event === "undefined" ? "undefined" : _typeof(event)) === "object") {
- for (var k in event) {
- if (event.hasOwnProperty(k)) evt[k] = event[k];
- }
- }
- evt.oldValue = oldValue;
- evt.value = value;
- this._events.trigger("change", evt, this);
-
-
-
- if (global.Shiny && global.Shiny.onInputChange) {
- global.Shiny.onInputChange(".clientValue-" + (this._group.name !== null ? this._group.name + "-" : "") + this._name, typeof value === "undefined" ? null : value);
- }
- }
- }, {
- key: "on",
- value: function on(eventType, listener) {
- return this._events.on(eventType, listener);
- }
- }, {
- key: "off",
- value: function off(eventType, listener) {
- return this._events.off(eventType, listener);
- }
- }]);
-
- return Var;
- }();
-
- exports.default = Var;
-
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
-
- },{"./events":1}]},{},[5])
|