Skip to content
This repository has been archived by the owner on May 20, 2021. It is now read-only.

Added Dropdown/Positioning Options #64

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'));

});