Skip to content

Instantly share code, notes, and snippets.

@basz
Created July 2, 2015 20:48
Show Gist options
  • Select an option

  • Save basz/0afab2cd47d085c82099 to your computer and use it in GitHub Desktop.

Select an option

Save basz/0afab2cd47d085c82099 to your computer and use it in GitHub Desktop.
import Ember from 'ember';
/**
* MaterializeCSS Dropdown Component
*
* @see http://materializecss.com/dropdown.html
*/
export default Ember.Component.extend({
tagName: 'a',
classNames: ['dropdown-button'],
attributeBindings: [
'data-activates', 'data-induration', 'data-outduration', 'data-constrainwidth', 'data-hover', 'data-gutter',
'data-beloworigin'
],
didInsertElement: function () {
this._super();
Ember.run.scheduleOnce('afterRender', this, this.afterRenderEvent);
},
afterRenderEvent: function () {
Ember.assert("Required attribute 'data-activates' not specified on 'materialize/dropdown-button' component", !Ember.isNone(this.get('attrs.data-activates')));
this.$().dropdown({
hover: this.getWithDefault('attrs.data-hover', false),
constrainWidth: this.getWithDefault('attrs.data-constrainwidth', true),
inDuration: this.getWithDefault('attrs.data-induration', 300),
outDuration: this.getWithDefault('attrs.data-outduration', 300),
gutter: this.getWithDefault('attrs.data-gutter', 0),
belowOrigin: this.getWithDefault('attrs.data-beloworigin', true)
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment