Skip to content

Commit

Permalink
Merge remote-tracking branch 'miguelcobain/master' into update-grid-list
Browse files Browse the repository at this point in the history
  • Loading branch information
Subtletree committed Jul 7, 2017
2 parents 8621746 + f3ceafa commit beb1fa5
Show file tree
Hide file tree
Showing 24 changed files with 452 additions and 342 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Contributions and pull requests are always welcome. Contributors may often be fo
- Flex and layout attributes are replaced by classes (see [the documentation](http://miguelcobain.github.io/ember-paper/release-1/#/layout/introduction)). `flex=true` on Ember Paper components has also been removed and replaced by classes.

### master
- [#730](https://github.com/miguelcobain/ember-paper/pull/730) ready for fastboot 1.0

### 1.0.0-alpha.20 (June 26, 2017)
- [#679](https://github.com/miguelcobain/ember-paper/issues/679) fix outline on paper-menu
- [#699](https://github.com/miguelcobain/ember-paper/issues/699) Removed paper-wormhole initializer in favor of the `contentFor` hook. This makes ember-paper more acceptance test friendly.
- updated Angular Material to 1.1.4 version
Expand All @@ -25,6 +28,7 @@ Contributions and pull requests are always welcome. Contributors may often be fo
- [#707](https://github.com/miguelcobain/ember-paper/pull/707) paper-dialog-inner's image load events are now properly cleaned up
- [51a6250](https://github.com/miguelcobain/ember-paper/commit/51a6250bebf1200e2b38d21c5655333540543bb8) icons are now absolutely sized (line-height, min-height, font-size, etc), from the `size` property
- [#720](https://github.com/miguelcobain/ember-paper/issues/720) add `opaque` option to `paper-dialog` component (defaults to `true`).
- [#726](https://github.com/miguelcobain/ember-paper/pull/726) update eps to 1.8.5 version. An internal change, but clears some deprecation messages and bugs.

### 1.0.0-alpha.19 (March 20, 2017)
- [56b84cf](https://github.com/miguelcobain/ember-paper/commit/56b84cf6b30e01dcf64961c4f75e101d0899593c) fix sliders on android browsers
Expand Down
93 changes: 0 additions & 93 deletions addon/components/paper-autocomplete-dropdown.js

This file was deleted.

1 change: 0 additions & 1 deletion addon/components/paper-autocomplete-highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const { Component, computed, String: { htmlSafe } } = Ember;
export default Component.extend({
layout,
tagName: 'span',

flags: '',

highlight: computed('searchText', 'label', 'flags', function() {
Expand Down
44 changes: 1 addition & 43 deletions addon/components/paper-autocomplete-trigger-container.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,5 @@
import Ember from 'ember';
import BasicTrigger from 'ember-basic-dropdown/components/basic-dropdown/trigger';
const { computed } = Ember;

export default BasicTrigger.extend({
tagName: 'md-autocomplete',
attributeBindings: ['label:md-floating-label', 'disabled:disabled'],
disabled: computed('disabledProxy', function() {
return this.get('disabledProxy') ? this.get('disabledProxy') : undefined;
}),

// Chrome 51: setting tabindex=0 explicitly stops tab propogation to
// other elements. We need to verify that other browsers behave as expected.
tabIndex: computed('dropdown.disabled', 'tabindex', function() {
let tabindex = this.get('tabindex');

// tabindex = falsy - don't set tabindex attr
if (!tabindex || this.get('dropdown.disabled')) {
return null;
}
return tabindex;
}),

addMandatoryHandlers() {
if (this.get('isTouchDevice')) {
this.element.addEventListener('touchstart', () => {
document.body.addEventListener('touchmove', this._touchMoveHandler);
});
this.element.addEventListener('touchend', (e) => {
this.send('handleTouchEnd', e);
});
}
this.element.addEventListener('mousedown', (e) => this.send('handleMousedown', e));
this.element.addEventListener('keydown', (e) => this.send('handleKeyDown', e));
},

actions: {

handleMousedown() {
let dropdown = this.get('dropdown');
if (dropdown.disabled) {
return;
}
this.stopTextSelectionUntilMouseup();
}
}
attributeBindings: ['label:md-floating-label', 'disabled:disabled']
});
42 changes: 32 additions & 10 deletions addon/components/paper-autocomplete-trigger.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
/**
* @module ember-paper
*/
import Ember from 'ember';
import layout from '../templates/components/paper-autocomplete-trigger';

const { Component, isPresent, isBlank, run, get, computed } = Ember;

/**
* @class PaperAutocompleteTrigger
* @extends Ember.Component
*/
export default Component.extend({
layout,
tagName: 'md-autocomplete-wrap',
Expand Down Expand Up @@ -39,28 +46,43 @@ export default Component.extend({
}),

// Lifecycle hooks
didUpdateAttrs({ oldAttrs, newAttrs }) {
didUpdateAttrs() {
this._super(...arguments);
/*
* We need to update the input field with value of the selected option whenever we're closing
* the select box. But we also close the select box when we're loading search results and when
* we remove input text -- so protect against this
*/
if (oldAttrs.select.isOpen && !newAttrs.select.isOpen && !newAttrs.loading && newAttrs.searchText) {
let oldSelect = this.get('_oldSelect');
let oldLastSearchedText = this.get('_lastSearchedText');
let oldLoading = this.get('_loading');

let select = this.get('select');
let loading = this.get('loading');
let searchText = this.get('searchText');
let lastSearchedText = this.get('lastSearchedText');

if (oldSelect && oldSelect.isOpen && !select.isOpen && !loading && searchText) {
this.set('text', this.getSelectedAsText());
}

if (newAttrs.lastSearchedText !== oldAttrs.lastSearchedText) {
if (isBlank(newAttrs.lastSearchedText)) {
run.schedule('actions', null, newAttrs.select.actions.close, null, true);
if (lastSearchedText !== oldLastSearchedText) {
if (isBlank(lastSearchedText)) {
run.schedule('actions', null, select.actions.close, null, true);
} else {
run.schedule('actions', null, newAttrs.select.actions.open);
run.schedule('actions', null, select.actions.open);
}
} else if (!isBlank(newAttrs.lastSearchedText) && get(this, 'options.length') === 0 && this.get('loading')) {
run.schedule('actions', null, newAttrs.select.actions.close, null, true);
} else if (oldAttrs.loading && !newAttrs.loading && newAttrs.options.length > 0) {
run.schedule('actions', null, newAttrs.select.actions.open);
} else if (!isBlank(lastSearchedText) && get(this, 'options.length') === 0 && this.get('loading')) {
run.schedule('actions', null, select.actions.close, null, true);
} else if (oldLoading && !loading && this.get('options.length') > 0) {
run.schedule('actions', null, select.actions.open);
}

this.setProperties({
_oldSelect: select,
_lastSearchedText: lastSearchedText,
_loading: loading
});
},

// Actions
Expand Down
10 changes: 10 additions & 0 deletions addon/components/paper-autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import layout from '../templates/components/paper-autocomplete';
import ValidationMixin from 'ember-paper/mixins/validation-mixin';
import ChildMixin from 'ember-paper/mixins/child-mixin';
import { indexOfOption } from 'ember-power-select/utils/group-utils';
import calculatePosition from '../utils/calculate-ac-position';

const { assert, computed, inject, isNone, defineProperty } = Ember;

Expand All @@ -16,11 +17,15 @@ const { assert, computed, inject, isNone, defineProperty } = Ember;
*/
export default PowerSelect.extend(ValidationMixin, ChildMixin, {
layout,
calculatePosition,

util: inject.service(),
constants: inject.service(),
triggerComponent: 'paper-autocomplete-trigger',
contentComponent: 'paper-autocomplete-content',
optionsComponent: 'paper-autocomplete-options',
triggerWrapperComponent: 'paper-autocomplete-trigger-container',

concatenatedDropdownClasses: ['md-autocomplete-suggestions-container md-virtual-repeat-container'],

extra: computed('labelPath', 'label', function() {
Expand Down Expand Up @@ -77,6 +82,10 @@ export default PowerSelect.extend(ValidationMixin, ChildMixin, {

actions: {

onTriggerMouseDown() {
return false;
},

onFocus(event) {
this.send('activate');
let publicAPI = this.get('publicAPI');
Expand All @@ -98,6 +107,7 @@ export default PowerSelect.extend(ValidationMixin, ChildMixin, {
if (action) {
action(this.get('publicAPI'), event);
}

this.notifyValidityChange();
},

Expand Down
8 changes: 3 additions & 5 deletions addon/components/paper-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,9 @@ export default BasicDropdownComponent.extend({
return { left, top };
}),

// EBD passes `dropdown` as options
// that var is `this` component itself
calculatePosition(trigger, dropdownEl, { dropdown }) {
let containerNode = dropdownEl;
let openMenuNode = dropdownEl.firstElementChild;
calculatePosition(trigger, content, destination, { dropdown }) {
let containerNode = content;
let openMenuNode = content.firstElementChild;
let openMenuNodeRect = openMenuNode.getBoundingClientRect();
let boundryNode = document.body;
let boundryNodeRect = boundryNode.getBoundingClientRect();
Expand Down
6 changes: 2 additions & 4 deletions addon/components/paper-select-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,8 @@ export default PaperMenu.extend({

triggerComponent: 'paper-select-menu-trigger',

// EBD passes `dropdown` as options
// that var is `this` component itself
calculatePosition(trigger, dropdownEl, { dropdown }) {
let $dropdown = $(dropdownEl);
calculatePosition(trigger, content, destination, { dropdown }) {
let $dropdown = $(content);
let opts = {
target: $(trigger),
parent: $('body'),
Expand Down
20 changes: 9 additions & 11 deletions addon/components/paper-virtual-repeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ const VirtualRepeatComponent = VirtualEachComponent.extend({
});
},

didReceiveAttrs(changes) {
didReceiveAttrs() {
this._super(...arguments);
let { newAttrs, oldAttrs = {} } = changes;

let oldScrollIndex = this.get('_oldScrollIndex');
let newScrollIndex = this.get('scrollIndex');
let scrollTop = this.get('scrollTop');

RSVP.cast(this.getAttr('items')).then((attrItems) => {
let items = emberArray(attrItems);
Expand All @@ -140,17 +143,12 @@ const VirtualRepeatComponent = VirtualEachComponent.extend({
_totalHeight: Math.max(itemsCount * this.get('itemHeight'), 0)
});

// Set size explicitly
if (newAttrs.height) {
this.set('size', newAttrs.height);
} else if (newAttrs.width) {
this.set('size', newAttrs.width);
}

// Scroll index has changed, load more data & scroll
if (oldAttrs.scrollIndex !== newAttrs.scrollIndex) {
this.scrollToVirtualItem(newAttrs.scrollIndex, newAttrs.scrollTop);
if (oldScrollIndex !== newScrollIndex) {
this.scrollToVirtualItem(newScrollIndex, scrollTop);
}

this.set('_oldScrollIndex', newScrollIndex);
});
},

Expand Down
13 changes: 10 additions & 3 deletions addon/templates/components/paper-autocomplete-content.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
{{#if dropdown.isOpen}}
{{#ember-wormhole to=to renderInPlace=renderInPlace}}
{{paper-backdrop class="md-click-catcher"}}
{{#ember-wormhole to=destination renderInPlace=renderInPlace}}
{{!--
Not really needed anymore - EPS does a good job of managing dropdown position
including destination scroll offset.
This remove double click issue when trying to focus another element while
autocomplete is open.
{{paper-backdrop class="md-click-catcher"}}
--}}
{{#paper-virtual-repeat (readonly select.results)
id=(readonly dropdownId)
class=(concat dropdownId " md-autocomplete-suggestions-container" " ember-basic-dropdown-content " (if renderInPlace 'ember-basic-dropdown-content--in-place ') (if hPosition (concat 'ember-basic-dropdown-content--' hPosition ' ')) (if vPosition (concat 'ember-basic-dropdown-content--' vPosition ' ') "md-whiteframe-z1 ") animationClass)
containerSelector='.md-autocomplete-suggestions'
scrollIndex=(readonly select.scrollIndex)
positionCoordinates=(readonly positionCoordinates) as |rawItems virtualItems|}}
positionCoordinates=(hash top=top left=left right=right width=width)
as |rawItems virtualItems|}}
{{yield virtualItems}}
{{/paper-virtual-repeat}}
{{/ember-wormhole}}
Expand Down
26 changes: 0 additions & 26 deletions addon/templates/components/paper-autocomplete-dropdown.hbs

This file was deleted.

Loading

0 comments on commit beb1fa5

Please sign in to comment.