| Total Complexity | 10 |
| Complexity/F | 1.25 |
| Lines of Code | 42 |
| Function Count | 8 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | Mivhak.component('top-bar-button', { |
||
| 2 | template: '<div class="mivhak-top-bar-button"></div>', |
||
| 3 | props: { |
||
| 4 | text: null, |
||
| 5 | icon: null, |
||
| 6 | dropdown: null, |
||
| 7 | mivhakInstance: null, |
||
| 8 | onClick: function(){} |
||
| 9 | }, |
||
| 10 | events: { |
||
| 11 | click: function() { |
||
| 12 | this.onClick(); |
||
| 13 | } |
||
| 14 | }, |
||
| 15 | created: function() { |
||
| 16 | var $this = this; |
||
| 17 | this.$el.text(this.text); |
||
| 18 | if(this.icon) this.$el.addClass('mivhak-icon mivhak-icon-'+this.icon).append($(Mivhak.icons[this.icon])); |
||
| 19 | if(this.dropdown) |
||
| 20 | { |
||
| 21 | $this.$el.append(this.dropdown.$el); |
||
| 22 | this.onClick = function() { |
||
| 23 | $this.toggleActivation(); |
||
| 24 | $this.dropdown.toggle(); |
||
| 25 | }; |
||
| 26 | } |
||
| 27 | }, |
||
| 28 | methods: { |
||
| 29 | activate: function() { |
||
| 30 | this.$el.addClass('mivhak-button-active'); |
||
| 31 | }, |
||
| 32 | deactivate: function() { |
||
| 33 | this.$el.removeClass('mivhak-button-active'); |
||
| 34 | }, |
||
| 35 | toggleActivation: function() { |
||
| 36 | this.$el.toggleClass('mivhak-button-active'); |
||
| 37 | }, |
||
| 38 | isActive: function() { |
||
| 39 | return this.$el.hasClass('mivhak-button-active'); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | }); |