|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471 |
- (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;
- }
-
- // Returns false if no match, or string for sub name if matched
-
- }, {
- 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 () {
- /**
- * @classdesc
- * Use this class to contribute to, and listen for changes to, the filter set
- * for the given group of widgets. Filter input controls should create one
- * `FilterHandle` and only call {@link FilterHandle#set}. Output widgets that
- * wish to displayed filtered data should create one `FilterHandle` and use
- * the {@link FilterHandle#filteredKeys} property and listen for change
- * events.
- *
- * If two (or more) `FilterHandle` instances in the same webpage share the
- * same group name, they will contribute to a single "filter set". Each
- * `FilterHandle` starts out with a `null` value, which means they take
- * nothing away from the set of data that should be shown. To make a
- * `FilterHandle` actually remove data from the filter set, set its value to
- * an array of keys which should be displayed. Crosstalk will aggregate the
- * various key arrays by finding their intersection; only keys that are
- * present in all non-null filter handles are considered part of the filter
- * set.
- *
- * @param {string} [group] - The name of the Crosstalk group, or if none,
- * null or undefined (or any other falsy value). This can be changed later
- * via the @{link FilterHandle#setGroup} method.
- * @param {Object} [extraInfo] - An object whose properties will be copied to
- * the event object whenever an event is emitted.
- */
- function FilterHandle(group, extraInfo) {
- _classCallCheck(this, FilterHandle);
-
- this._eventRelay = new _events2.default();
- this._emitter = new util.SubscriptionTracker(this._eventRelay);
-
- // Name of the group we're currently tracking, if any. Can change over time.
- this._group = null;
- // The filterSet that we're tracking, if any. Can change over time.
- this._filterSet = null;
- // The Var we're currently tracking, if any. Can change over time.
- this._filterVar = null;
- // The event handler subscription we currently have on var.on("change").
- this._varOnChangeSub = null;
-
- this._extraInfo = util.extend({ sender: this }, extraInfo);
-
- this._id = "filter" + nextId();
-
- this.setGroup(group);
- }
-
- /**
- * Changes the Crosstalk group membership of this FilterHandle. If `set()` was
- * previously called on this handle, switching groups will clear those keys
- * from the old group's filter set. These keys will not be applied to the new
- * group's filter set either. In other words, `setGroup()` effectively calls
- * `clear()` before switching groups.
- *
- * @param {string} group - The name of the Crosstalk group, or null (or
- * undefined) to clear the group.
- */
-
-
- _createClass(FilterHandle, [{
- key: "setGroup",
- value: function setGroup(group) {
- var _this = this;
-
- // If group is unchanged, do nothing
- if (this._group === group) return;
- // Treat null, undefined, and other falsy values the same
- 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;
- }
- }
-
- /**
- * Combine the given `extraInfo` (if any) with the handle's default
- * `_extraInfo` (if any).
- * @private
- */
-
- }, {
- key: "_mergeExtraInfo",
- value: function _mergeExtraInfo(extraInfo) {
- return util.extend({}, this._extraInfo ? this._extraInfo : null, extraInfo ? extraInfo : null);
- }
-
- /**
- * Close the handle. This clears this handle's contribution to the filter set,
- * and unsubscribes all event listeners.
- */
-
- }, {
- key: "close",
- value: function close() {
- this._emitter.removeAllListeners();
- this.clear();
- this.setGroup(null);
- }
-
- /**
- * Clear this handle's contribution to the filter set.
- *
- * @param {Object} [extraInfo] - Extra properties to be included on the event
- * object that's passed to listeners (in addition to any options that were
- * passed into the `FilterHandle` constructor).
- */
-
- }, {
- key: "clear",
- value: function clear(extraInfo) {
- if (!this._filterSet) return;
- this._filterSet.clear(this._id);
- this._onChange(extraInfo);
- }
-
- /**
- * Set this handle's contribution to the filter set. This array should consist
- * of the keys of the rows that _should_ be displayed; any keys that are not
- * present in the array will be considered _filtered out_. Note that multiple
- * `FilterHandle` instances in the group may each contribute an array of keys,
- * and only those keys that appear in _all_ of the arrays make it through the
- * filter.
- *
- * @param {string[]} keys - Empty array, or array of keys. To clear the
- * filter, don't pass an empty array; instead, use the
- * {@link FilterHandle#clear} method.
- * @param {Object} [extraInfo] - Extra properties to be included on the event
- * object that's passed to listeners (in addition to any options that were
- * passed into the `FilterHandle` constructor).
- */
-
- }, {
- key: "set",
- value: function set(keys, extraInfo) {
- if (!this._filterSet) return;
- this._filterSet.update(this._id, keys);
- this._onChange(extraInfo);
- }
-
- /**
- * @return {string[]|null} - Either: 1) an array of keys that made it through
- * all of the `FilterHandle` instances, or, 2) `null`, which means no filter
- * is being applied (all data should be displayed).
- */
-
- }, {
- key: "on",
-
-
- /**
- * Subscribe to events on this `FilterHandle`.
- *
- * @param {string} eventType - Indicates the type of events to listen to.
- * Currently, only `"change"` is supported.
- * @param {FilterHandle~listener} listener - The callback function that
- * will be invoked when the event occurs.
- * @return {string} - A token to pass to {@link FilterHandle#off} to cancel
- * this subscription.
- */
- value: function on(eventType, listener) {
- return this._emitter.on(eventType, listener);
- }
-
- /**
- * Cancel event subscriptions created by {@link FilterHandle#on}.
- *
- * @param {string} eventType - The type of event to unsubscribe.
- * @param {string|FilterHandle~listener} listener - Either the callback
- * function previously passed into {@link FilterHandle#on}, or the
- * string that was returned from {@link FilterHandle#on}.
- */
-
- }, {
- 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));
- }
-
- /**
- * @callback FilterHandle~listener
- * @param {Object} event - An object containing details of the event. For
- * `"change"` events, this includes the properties `value` (the new
- * value of the filter set, or `null` if no filter set is active),
- * `oldValue` (the previous value of the filter set), and `sender` (the
- * `FilterHandle` instance that made the change).
- */
-
- /**
- * @event FilterHandle#change
- * @type {object}
- * @property {object} value - The new value of the filter set, or `null`
- * if no filter set is active.
- * @property {object} oldValue - The previous value of the filter set.
- * @property {FilterHandle} sender - The `FilterHandle` instance that
- * changed the value.
- */
-
- }, {
- 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;
- }
- }
-
- /**
- * @private
- */
-
- var FilterSet = function () {
- function FilterSet() {
- _classCallCheck(this, FilterSet);
-
- this.reset();
- }
-
- _createClass(FilterSet, [{
- key: "reset",
- value: function reset() {
- // Key: handle ID, Value: array of selected keys, or null
- this._handles = {};
- // Key: key string, Value: count of handles that include it
- this._keys = {};
- this._value = null;
- this._activeHandles = 0;
- }
- }, {
- key: "update",
- value: function update(handleId, keys) {
- if (keys !== null) {
- keys = keys.slice(0); // clone before sorting
- 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);
- }
-
- /**
- * @param {string[]} keys Sorted array of strings that indicate
- * a superset of possible keys.
- * @private
- */
-
- }, {
- 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"); } }
-
- // Use a global so that multiple copies of crosstalk.js can be loaded and still
- // have groups behave as singletons across all copies.
- 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) {
- // Appears to already be a group object
- 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
- };
-
- /**
- * @namespace crosstalk
- */
- 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);
- });
- });
- }
-
- // Escape jQuery identifier
- 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) {
- /*
- * map: {"groupA": ["keyA", "keyB", ...], ...}
- * group: "ct-groupname"
- */
- 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) {
- /*
- * items: {value: [...], label: [...]}
- * map: {"groupA": ["keyA", "keyB", ...], ...}
- * group: "ct-groupname"
- */
-
- 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) {
- /*
- * map: {"groupA": ["keyA", "keyB", ...], ...}
- * group: "ct-groupname"
- */
- 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;
-
- // Set up formatting functions
- 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;
-
- // Function for converting numeric value from slider to appropriate type.
- 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) {
- // Convert ms to s
- 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;
- }
- });
-
- // let $el = $(el);
- // $el.on("change", "input[type="checkbox"]", function() {
- // let checked = $el.find("input[type="checkbox"]:checked");
- // if (checked.length === 0) {
- // ctHandle.clear();
- // } else {
- // let keys = {};
- // checked.each(function() {
- // data.map[this.value].forEach(function(key) {
- // keys[key] = true;
- // });
- // });
- // let keyArray = Object.keys(keys);
- // keyArray.sort();
- // ctHandle.set(keyArray);
- // }
- // });
-
- return {
- suspend: function suspend() {
- ctHandle.clear();
- },
- resume: function resume() {
- if (lastKnownKeys) ctHandle.set(lastKnownKeys);
- }
- };
- }
- });
-
- // Convert a number to a string with leading zeros
- function padZeros(n, digits) {
- var str = n.toString();
- while (str.length < digits) {
- str = "0" + str;
- }return str;
- }
-
- // Given a Date object, return a string in yyyy-mm-dd format, using the
- // UTC date. This may be a day off from the date in the local time zone.
- 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 () {
-
- /**
- * @classdesc
- * Use this class to read and write (and listen for changes to) the selection
- * for a Crosstalk group. This is intended to be used for linked brushing.
- *
- * If two (or more) `SelectionHandle` instances in the same webpage share the
- * same group name, they will share the same state. Setting the selection using
- * one `SelectionHandle` instance will result in the `value` property instantly
- * changing across the others, and `"change"` event listeners on all instances
- * (including the one that initiated the sending) will fire.
- *
- * @param {string} [group] - The name of the Crosstalk group, or if none,
- * null or undefined (or any other falsy value). This can be changed later
- * via the [SelectionHandle#setGroup](#setGroup) method.
- * @param {Object} [extraInfo] - An object whose properties will be copied to
- * the event object whenever an event is emitted.
- */
- 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);
-
- // Name of the group we're currently tracking, if any. Can change over time.
- this._group = null;
- // The Var we're currently tracking, if any. Can change over time.
- this._var = null;
- // The event handler subscription we currently have on var.on("change").
- this._varOnChangeSub = null;
-
- this._extraInfo = util.extend({ sender: this }, extraInfo);
-
- this.setGroup(group);
- }
-
- /**
- * Changes the Crosstalk group membership of this SelectionHandle. The group
- * being switched away from (if any) will not have its selection value
- * modified as a result of calling `setGroup`, even if this handle was the
- * most recent handle to set the selection of the group.
- *
- * The group being switched to (if any) will also not have its selection value
- * modified as a result of calling `setGroup`. If you want to set the
- * selection value of the new group, call `set` explicitly.
- *
- * @param {string} group - The name of the Crosstalk group, or null (or
- * undefined) to clear the group.
- */
-
-
- _createClass(SelectionHandle, [{
- key: "setGroup",
- value: function setGroup(group) {
- var _this = this;
-
- // If group is unchanged, do nothing
- if (this._group === group) return;
- // Treat null, undefined, and other falsy values the same
- 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;
- }
- }
-
- /**
- * Retrieves the current selection for the group represented by this
- * `SelectionHandle`.
- *
- * - If no selection is active, then this value will be falsy.
- * - If a selection is active, but no data points are selected, then this
- * value will be an empty array.
- * - If a selection is active, and data points are selected, then the keys
- * of the selected data points will be present in the array.
- */
-
- }, {
- key: "_mergeExtraInfo",
-
-
- /**
- * Combines the given `extraInfo` (if any) with the handle's default
- * `_extraInfo` (if any).
- * @private
- */
- value: function _mergeExtraInfo(extraInfo) {
- // Important incidental effect: shallow clone is returned
- return util.extend({}, this._extraInfo ? this._extraInfo : null, extraInfo ? extraInfo : null);
- }
-
- /**
- * Overwrites the current selection for the group, and raises the `"change"`
- * event among all of the group's '`SelectionHandle` instances (including
- * this one).
- *
- * @fires SelectionHandle#change
- * @param {string[]} selectedKeys - Falsy, empty array, or array of keys (see
- * {@link SelectionHandle#value}).
- * @param {Object} [extraInfo] - Extra properties to be included on the event
- * object that's passed to listeners (in addition to any options that were
- * passed into the `SelectionHandle` constructor).
- */
-
- }, {
- key: "set",
- value: function set(selectedKeys, extraInfo) {
- if (this._var) this._var.set(selectedKeys, this._mergeExtraInfo(extraInfo));
- }
-
- /**
- * Overwrites the current selection for the group, and raises the `"change"`
- * event among all of the group's '`SelectionHandle` instances (including
- * this one).
- *
- * @fires SelectionHandle#change
- * @param {Object} [extraInfo] - Extra properties to be included on the event
- * object that's passed to listeners (in addition to any that were passed
- * into the `SelectionHandle` constructor).
- */
-
- }, {
- key: "clear",
- value: function clear(extraInfo) {
- if (this._var) this.set(void 0, this._mergeExtraInfo(extraInfo));
- }
-
- /**
- * Subscribes to events on this `SelectionHandle`.
- *
- * @param {string} eventType - Indicates the type of events to listen to.
- * Currently, only `"change"` is supported.
- * @param {SelectionHandle~listener} listener - The callback function that
- * will be invoked when the event occurs.
- * @return {string} - A token to pass to {@link SelectionHandle#off} to cancel
- * this subscription.
- */
-
- }, {
- key: "on",
- value: function on(eventType, listener) {
- return this._emitter.on(eventType, listener);
- }
-
- /**
- * Cancels event subscriptions created by {@link SelectionHandle#on}.
- *
- * @param {string} eventType - The type of event to unsubscribe.
- * @param {string|SelectionHandle~listener} listener - Either the callback
- * function previously passed into {@link SelectionHandle#on}, or the
- * string that was returned from {@link SelectionHandle#on}.
- */
-
- }, {
- key: "off",
- value: function off(eventType, listener) {
- return this._emitter.off(eventType, listener);
- }
-
- /**
- * Shuts down the `SelectionHandle` object.
- *
- * Removes all event listeners that were added through this handle.
- */
-
- }, {
- key: "close",
- value: function close() {
- this._emitter.removeAllListeners();
- this.setGroup(null);
- }
-
- /**
- * @callback SelectionHandle~listener
- * @param {Object} event - An object containing details of the event. For
- * `"change"` events, this includes the properties `value` (the new
- * value of the selection, or `undefined` if no selection is active),
- * `oldValue` (the previous value of the selection), and `sender` (the
- * `SelectionHandle` instance that made the change).
- */
-
- /**
- * @event SelectionHandle#change
- * @type {object}
- * @property {object} value - The new value of the selection, or `undefined`
- * if no selection is active.
- * @property {object} oldValue - The previous value of the selection.
- * @property {SelectionHandle} sender - The `SelectionHandle` instance that
- * changed the value.
- */
-
- }, {
- 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
- };
- }
-
- // Convert from wide: { colA: [1,2,3], colB: [4,5,6], ... }
- // to long: [ {colA: 1, colB: 4}, {colA: 2, colB: 5}, ... ]
- 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;
- }
-
- /**
- * Keeps track of all event listener additions/removals and lets all active
- * listeners be removed with a single operation.
- *
- * @private
- */
-
- 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) {
- // Do nothing; the value hasn't changed
- return;
- }
- var oldValue = this._value;
- this._value = value;
- // Alert JavaScript listeners that the value has changed
- 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);
-
- // TODO: Make this extensible, to let arbitrary back-ends know that
- // something has changed
- 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])
- //# sourceMappingURL=crosstalk.js.map
|