|  | 
| 1 |  | -/* eslint-disable ember/no-classic-components, ember/no-mixins, ember/require-tagless-components */ | 
| 2 | 1 | /** | 
| 3 | 2 |  * @module ember-paper | 
| 4 | 3 |  */ | 
| 5 |  | -import { reads } from '@ember/object/computed'; | 
| 6 |  | - | 
| 7 |  | -import Component from '@ember/component'; | 
| 8 |  | -import FocusableMixin from 'ember-paper/mixins/focusable-mixin'; | 
| 9 |  | -import ProxiableMixin from 'ember-paper/mixins/proxiable-mixin'; | 
| 10 |  | -import { invokeAction } from 'ember-paper/utils/invoke-action'; | 
|  | 4 | +import Focusable from './-focusable'; | 
|  | 5 | +import { action } from '@ember/object'; | 
| 11 | 6 | 
 | 
| 12 | 7 | /** | 
| 13 | 8 |  * @class PaperButton | 
| 14 |  | - * @extends Ember.Component | 
| 15 |  | - * @uses FocusableMixin | 
| 16 |  | - * @uses ProxiableMixin | 
|  | 9 | + * @extends Focusable | 
| 17 | 10 |  */ | 
| 18 |  | -export default Component.extend(FocusableMixin, ProxiableMixin, { | 
| 19 |  | -  tagName: 'button', | 
| 20 |  | -  classNames: ['md-default-theme', 'md-button'], | 
| 21 |  | -  raised: false, | 
| 22 |  | -  iconButton: false, | 
| 23 |  | - | 
| 24 |  | -  // circular button | 
| 25 |  | -  fab: reads('mini'), | 
| 26 |  | - | 
| 27 |  | -  mini: false, | 
| 28 |  | -  type: 'button', | 
| 29 |  | -  href: null, | 
| 30 |  | -  target: null, | 
| 31 |  | - | 
| 32 |  | -  attributeBindings: ['type', 'href', 'target', 'title', 'download', 'rel'], | 
| 33 |  | - | 
| 34 |  | -  classNameBindings: [ | 
| 35 |  | -    'raised:md-raised', | 
| 36 |  | -    'iconButton:md-icon-button', | 
| 37 |  | -    'fab:md-fab', | 
| 38 |  | -    'mini:md-mini', | 
| 39 |  | -    'warn:md-warn', | 
| 40 |  | -    'accent:md-accent', | 
| 41 |  | -    'primary:md-primary', | 
| 42 |  | -  ], | 
| 43 |  | - | 
| 44 |  | -  init() { | 
| 45 |  | -    this._super(...arguments); | 
| 46 |  | -    if (this.href) { | 
| 47 |  | -      this.setProperties({ | 
| 48 |  | -        tagName: 'a', | 
| 49 |  | -        type: null, | 
| 50 |  | -      }); | 
|  | 11 | +export default class PaperButton extends Focusable { | 
|  | 12 | +  get tag() { | 
|  | 13 | +    if (this.args.href) { | 
|  | 14 | +      return 'a'; | 
|  | 15 | +    } | 
|  | 16 | + | 
|  | 17 | +    return 'button'; | 
|  | 18 | +  } | 
|  | 19 | + | 
|  | 20 | +  get type() { | 
|  | 21 | +    if (this.args.type) { | 
|  | 22 | +      return this.args.type; | 
|  | 23 | +    } | 
|  | 24 | + | 
|  | 25 | +    return 'button'; | 
|  | 26 | +  } | 
|  | 27 | + | 
|  | 28 | +  get fab() { | 
|  | 29 | +    return this.args.fab || this.args.mini; | 
|  | 30 | +  } | 
|  | 31 | + | 
|  | 32 | +  @action handleClick(e) { | 
|  | 33 | +    if (this.args.onClick) { | 
|  | 34 | +      this.args.onClick(e); | 
| 51 | 35 |     } | 
| 52 |  | -  }, | 
| 53 | 36 | 
 | 
| 54 |  | -  click(e) { | 
| 55 |  | -    invokeAction(this, 'onClick', e); | 
| 56 | 37 |     // Prevent bubbling, if specified. If undefined, the event will bubble. | 
| 57 |  | -    return this.bubbles; | 
| 58 |  | -  }, | 
| 59 |  | -}); | 
|  | 38 | +    if (this.args.bubbles === undefined) { | 
|  | 39 | +      return true; | 
|  | 40 | +    } | 
|  | 41 | + | 
|  | 42 | +    return this.args.bubbles; | 
|  | 43 | +  } | 
|  | 44 | +} | 
0 commit comments