diff --git a/src/assets/index.html b/src/assets/index.html index ca4c3c7..f69d437 100644 --- a/src/assets/index.html +++ b/src/assets/index.html @@ -35,7 +35,7 @@ {% inline "assorted.svg" %}
- + @@ -210,20 +210,11 @@ {% inline "circle-full.svg" %} {% inline "circle.svg" %} - - {% inline "sliders.svg" %} - - - - {% inline "external-link.svg" %} - - -
+ + +
- +
+ + + {% inline "external-link.svg" %} +
- + @@ -348,7 +348,7 @@ {% inline "alert-circle.svg" %}
- + diff --git a/src/assets/javascripts/app.js b/src/assets/javascripts/app.js index 519e58a..b2e2b72 100644 --- a/src/assets/javascripts/app.js +++ b/src/assets/javascripts/app.js @@ -84,22 +84,21 @@ Vue.component('drag', { }) Vue.component('dropdown', { - props: ['class', 'toggle-class', 'ref'], + props: ['class', 'toggle-class', 'ref', 'drop'], data: function() { - return {open: false, openClass: ''} + return {open: false} }, template: ` `, computed: { btnToggleClass: function() { var c = this.$props.toggleClass || '' c += ' dropdown-toggle dropdown-toggle-no-caret' - c += this.open ? ' open' : '' + c += this.open ? ' show' : '' return c.trim() } }, @@ -114,15 +113,24 @@ Vue.component('dropdown', { }, show: function(e) { this.open = true - this.openClass = ' show' - this.$refs.menu.style.right = '0' - this.$refs.menu.style.left = 'auto' - this.$refs.menu.style.top = (this.$refs.btn.offsetHeight) + 'px' + this.$refs.menu.style.top = this.$refs.btn.offsetHeight + 'px' + var drop = this.$props.drop + + if (drop === 'right') { + this.$refs.menu.style.left = 'auto' + this.$refs.menu.style.right = '0' + } else if (drop === 'center') { + this.$nextTick(function() { + var btnWidth = this.$refs.btn.getBoundingClientRect().width + var menuWidth = this.$refs.menu.getBoundingClientRect().width + this.$refs.menu.style.left = '-' + ((menuWidth - btnWidth) / 2) + 'px' + }.bind(this)) + } + document.addEventListener('click', this.clickHandler) }, hide: function() { this.open = false - this.openClass = '' document.removeEventListener('click', this.clickHandler) }, clickHandler: function(e) {