/** * Resize the canvases' resolutions, and fires out the onResize callback * * @param {HTMLDivElement} container * @param {Object} canvases * @param {Number} debounceRate */ function handleResizes(canvases, debounceRate) { let { container, main, zoom } = canvases; let window = container.ownerDocument.defaultView; function resize() { let width = container.offsetWidth * window.devicePixelRatio; let height = container.offsetHeight * window.devicePixelRatio; main.canvas.width = width; main.canvas.height = height; zoom.canvas.width = width; zoom.canvas.height = height; canvases.emit('resize'); } // Tests may not need debouncing let debouncedResize = debounceRate > 0 ? debounce(resize, debounceRate) : resize; window.addEventListener("resize", debouncedResize, false); resize(); return function removeResizeHandlers() { window.removeEventListener("resize", debouncedResize, false); }; }
initialize: function() { this._onGraphNodeClick = this._onGraphNodeClick.bind(this); this._onThemeChange = this._onThemeChange.bind(this); this._onNodeSelect = this._onNodeSelect.bind(this); this._onStartContext = this._onStartContext.bind(this); this.draw = debounce(this.draw.bind(this), GRAPH_DEBOUNCE_TIMER); $('#graph-target').addEventListener('click', this._onGraphNodeClick, false); window.on(EVENTS.THEME_CHANGE, this._onThemeChange); window.on(EVENTS.UI_INSPECTOR_NODE_SET, this._onNodeSelect); window.on(EVENTS.START_CONTEXT, this._onStartContext); },
initialize: function() { this._onGraphClick = this._onGraphClick.bind(this); this._onThemeChange = this._onThemeChange.bind(this); this._onStartContext = this._onStartContext.bind(this); this._onEvent = this._onEvent.bind(this); this.draw = debounce(this.draw.bind(this), GRAPH_DEBOUNCE_TIMER); $("#graph-target").addEventListener("click", this._onGraphClick, false); window.on(EVENTS.THEME_CHANGE, this._onThemeChange); window.on(EVENTS.START_CONTEXT, this._onStartContext); gAudioNodes.on("*", this._onEvent); },
/** * Set the various event listeners and return a function to remove them * * @param {Object} dragZoom * @param {HTMLElement} container * @param {Function} update * @return {Function} The function to remove the handlers */ function setHandlers(dragZoom, container, update, debounceRate) { let emitChanged = debounce(() => dragZoom.emit("change"), debounceRate); let removeDragHandlers = setDragHandlers(container, dragZoom, emitChanged, update); let removeScrollHandlers = setScrollHandlers(container, dragZoom, emitChanged, update); return function removeHandlers() { removeDragHandlers(); removeScrollHandlers(); }; }
setup: function setup(options) { //console.log("BxTagButton ("+options.tags+"): initialize",options); this.id=options.id=cleanSelfId + '-TagButton-' + options.id; //evade doing x rebuilds in 15 seconds this.rebuildWait = debounce(this.rebuild, 15000); //set tagOptions this.tags = options.tags; this.order = options.order; this.itemMap = new Map(); this.isupdated = true; // Make button element let gOptions = merge (options, { //if using image instead of icon, something breaks and no id type: 'menu', // menu-button for button ánd dropdown icon: waitIcon }); // console.log("BxTagButton ("+this.tags+"): Options before for view create:" + gOptions); view.create(gOptions); this.node = view.nodeFor(gOptions.id); this.node.setAttribute('class', 'bookmark-item'); this.node.setAttribute('constrain-size', "false"); this.node.bxTbutton = this; this.node.setAttribute('context', ButCtId); // Make and attach menupopup this.pp = doc.createElementNS(XUL_NS,'menupopup'); this.pp.setAttribute("placespopup", "true"); this.pp.setAttribute('id', this.node.id + '-MenuPopup'); //If this below could work once, it would be fantastic! However: this._view is null... //this.pp.setAttribute("context", "placesContext"); this.pp.setAttribute("context", MICtId); this.node.appendChild(this.pp); this.node.addEventListener('popupshown', (e) => { //console.log("BxTagButton ("+this.tags+"): "+e); if (this.isUpdated) this.statusNormal(); }); this.getBms(); },