Skip to content

Commit

Permalink
Added hover options for acoustep#21
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldwasserman committed Apr 17, 2017
1 parent 3c24be2 commit e8c7aa7
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
24 changes: 22 additions & 2 deletions addon/components/zf-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
import Ember from 'ember';
import zfWidget from 'ember-cli-foundation-6-sass/mixins/zf-widget';

const { computed, assert } = Ember;

export default Ember.Component.extend(zfWidget, {
/** @member Class names */
classNames: ['dropdown-pane'],
classNames: ['dropdown-pane', '_position'],

/** @member Attribute bindings */
attributeBindings: ['data-dropdown', 'data-auto-focus'],
attributeBindings: ['data-dropdown', 'data-auto-focus', 'data-hover', 'data-hover-pane'],

/** @member Makes the data attribute binding appear */
'data-dropdown': ' ',

'data-auto-focus': true,

/** @member enables hover options **/
'zfHover': false,
'data-hover': computed('zfHover', function() {
return this.get('zfHover');
}),
'data-hover-pane': computed('zfHover', function() {
return this.get('zfHover');
}),

/** @member Foundation type */
'zfType': 'Dropdown',

/** @private Hanlde attribute bindings for position **/
_position: computed('positionClass', function() {
let allowedPositions = ['top', 'right', 'left', 'bottom'];
let position = this.get('positionClass');
assert('Must provide a valid foundation position for dropdown', allowedPositions.indexOf(position));

return position;
}),

/** @member Foundation specific options */
'zfOptions': ['hoverDelay', 'hover', 'hoverPane', 'vOffset', 'hOffset', 'positionClass',
'trapFocus', 'autoFocus', 'closeOnClick']
Expand Down
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
"loader.js": "ember-cli/loader.js#3.4.0",
"qunit": "~1.20.0"
}

}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"babel-register": "^6.18.0",
"broccoli-funnel": "^1.1.0",
"broccoli-merge-trees": "^1.2.1",
"ember-cli-babel": "^5.1.5",
"ember-cli-babel": "^5.1.5",
"ember-cli-htmlbars": "^1.0.2",
"ember-cli-sass": "^6.0.0",
"ember-cli-version-checker": "^1.2.0"
Expand Down
28 changes: 28 additions & 0 deletions tests/integration/components/zf-dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,31 @@ test('it renders', function(assert) {
assert.ok(this.$().text().indexOf('Example form in a dropdown.') > -1);

});


test('Handles hover and positioning properties', function(assert) {

this.render(hbs`
<button class="button" data-toggle="example-dropdown">Toggle Dropdown</button>
{{#zf-dropdown id="example-dropdown" positionClass="top"}}
Example form in a dropdown.
<form>
<div class="row">
<div class="medium-6 columns">
<label>Name
<input type="text" placeholder="Kirk, James T.">
</label>
</div>
<div class="medium-6 columns">
<label>Rank
<input type="text" placeholder="Captain">
</label>
</div>
</div>
</form>
{{/zf-dropdown}}
`);

assert.ok(this.$('#example-dropdown').hasClass('top'));

});

0 comments on commit e8c7aa7

Please sign in to comment.