Sha256: 97d2ff1b5325e9efc2a2d1eb05cfbf959a0e9b90d6223348a6dac27f598d0e63
Contents?: true
Size: 879 Bytes
Versions: 7
Compression:
Stored size: 879 Bytes
Contents
import Component from "@ember/component"; import { observer } from "@ember/object"; export default Component.extend({ showMenu: false, tagName: "span", init() { this._super(...arguments); this.bindingFunction = this.bindingFunction.bind(this); }, bindingFunction(event) { const context = this.$()[0]; if (!Em.$.contains(context, event.target) && context !== event.target) { this.set("showMenu", false); } }, bindDocument: observer("showMenu", function() { const $document = Em.$(document); if (this.get("showMenu")) { $document.on("click", this.get("bindingFunction")); } else { $document.unbind("click", this.get("bindingFunction")); } }), actions: { expandMenu() { this.toggleProperty("showMenu"); }, share() { this.share(); } } });
Version data entries
7 entries across 7 versions & 1 rubygems