Skip to content

Commit df1aee8

Browse files
committedNov 27, 2021
add prettier
1 parent c1d6d22 commit df1aee8

33 files changed

+976
-940
lines changed
 

‎.eslintrc.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@ module.exports = {
1111
},
1212
},
1313
plugins: ['ember'],
14-
extends: [
15-
'eslint:recommended',
16-
'plugin:ember/recommended',
17-
'plugin:prettier/recommended',
18-
],
14+
extends: ['eslint:recommended', 'plugin:ember/recommended', 'plugin:prettier/recommended'],
1915
env: {
2016
browser: true,
2117
},

‎.github/ISSUE_TEMPLATE/bug_report.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
---
22
name: Bug report
33
about: Create a report to help us improve
4-
labels:
5-
4+
labels:
65
---
76

87
**Describe the bug**
98
A clear and concise description of what the bug is.
109

1110
**To Reproduce**
1211
Steps to reproduce the behavior:
12+
1313
1. Go to '...'
1414
2. Click on '....'
1515
3. Scroll down to '....'

‎.github/workflows/github_ci.yml

+3-7
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ name: build
66
on:
77
workflow_dispatch:
88
push:
9-
branches: [ master ]
9+
branches: [master]
1010
pull_request:
11-
branches: [ master ]
11+
branches: [master]
1212

1313
jobs:
1414
main-test:
@@ -34,11 +34,7 @@ jobs:
3434
strategy:
3535
fail-fast: false
3636
matrix:
37-
scenario: [
38-
ember-lts-3.20,
39-
ember-lts-3.24,
40-
ember-lts-3.28,
41-
]
37+
scenario: [ember-lts-3.20, ember-lts-3.24, ember-lts-3.28]
4238
steps:
4339
- uses: actions/checkout@v2
4440
- name: Use Node.js 12

‎.prettierrc.js

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
module.exports = {
44
singleQuote: true,
5+
printWidth: 120,
56
};

‎CHANGELOG.md

+183-108
Large diffs are not rendered by default.

‎CONTRIBUTING.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22

33
## Installation
44

5-
* `git clone <repository-url>`
6-
* `cd ember-sortable`
7-
* `yarn install`
5+
- `git clone <repository-url>`
6+
- `cd ember-sortable`
7+
- `yarn install`
88

99
## Linting
1010

11-
* `yarn lint:hbs`
12-
* `yarn lint:js`
13-
* `yarn lint:js --fix`
11+
- `yarn lint:hbs`
12+
- `yarn lint:js`
13+
- `yarn lint:js --fix`
1414

1515
## Running tests
1616

17-
* `ember test` – Runs the test suite on the current Ember version
18-
* `ember test --server` – Runs the test suite in "watch mode"
19-
* `ember try:each` – Runs the test suite against multiple Ember versions
17+
- `ember test` – Runs the test suite on the current Ember version
18+
- `ember test --server` – Runs the test suite in "watch mode"
19+
- `ember try:each` – Runs the test suite against multiple Ember versions
2020

2121
## Running the dummy application
2222

23-
* `ember serve`
24-
* Visit the dummy application at [http://localhost:4200](http://localhost:4200).
23+
- `ember serve`
24+
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).
2525

26-
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).
26+
For more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).

‎MIGRATION_GUIDE_MODIFIERS.md

+20-13
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
To use modifiers, you must use angle-bracket syntax
66

77
### New Root component
8-
1. Instead of using `sortable-group` as a component, use `sortable-group` as a modifier
9-
any element. You no longer need to tell `sortable-group` about the models, so the `each`
10-
uses the models directly.
8+
9+
1. Instead of using `sortable-group` as a component, use `sortable-group` as a modifier
10+
any element. You no longer need to tell `sortable-group` about the models, so the `each`
11+
uses the models directly.
1112

1213
**Old Component**
14+
1315
```hbs
1416
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
1517
{{#each group.model as |item|}}
1618
```
19+
1720
**New Component**
21+
1822
```hbs
1923
<ol {{sortable-group onChange=(action "reorderItems")}}>
2024
{{#each model.items as |item|}}
@@ -23,19 +27,21 @@ uses the models directly.
2327
2. Each `item` can be represented by any dom element or component using angle-bracket syntax
2428

2529
**Old Component**
30+
2631
```hbs
27-
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
32+
{{#sortable-group model=model.items onChange=(action 'reorderItems') as |group|}}
2833
{{#each group.model as |item|}}
2934
{{#group.item model=item}}
30-
{{tem.name}}
35+
{{tem.name}}
3136
{{/group.item}}
3237
{{/each}}
3338
{{/sortable-group}}
3439
```
3540

3641
**New Component with modifier**
42+
3743
```hbs
38-
<ol {{sortable-group onChange=(action "reorderItems")}}>
44+
<ol {{sortable-group onChange=(action 'reorderItems')}}>
3945
{{#each model.items as |item|}}
4046
<li {{sortable-item model=item}}>
4147
{{tem.name}}
@@ -47,6 +53,7 @@ uses the models directly.
4753
3. The Handle is also any element with a `sortable-handle` applied to it.
4854

4955
**Old Component**
56+
5057
```hbs
5158
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
5259
{{#each group.model as |modelItem|}}
@@ -61,28 +68,28 @@ uses the models directly.
6168
```
6269

6370
**New Component with modifier**
71+
6472
```hbs
65-
<ol {{sortable-group onChange=(action "reorderItems")}}>
73+
<ol {{sortable-group onChange=(action 'reorderItems')}}>
6674
{{#each model.items as |item|}}
6775
<li {{sortable-item model=item}}>
6876
{{tem.name}}
69-
<span class="handle" {{sortable-handle}}>&varr;</span>
77+
<span class='handle' {{sortable-handle}}>&varr;</span>
7078
</li>
7179
{{/each}}
7280
</ol>
7381
```
7482

75-
4. The modifier `groupModel` property is no longer supported. The equivalent can
76-
be accomplished by the `action` helper or the new `fn` helper.
83+
4. The modifier `groupModel` property is no longer supported. The equivalent can
84+
be accomplished by the `action` helper or the new `fn` helper.
7785

7886
```hbs
79-
<ol {{sortable-group onChange=(action "reorderItems" model)}}>
87+
<ol {{sortable-group onChange=(action 'reorderItems' model)}}>
8088
{{#each model.items as |item|}}
8189
<li {{sortable-item model=item}}>
8290
{{tem.name}}
83-
<span class="handle" {{sortable-handle}}>&varr;</span>
91+
<span class='handle' {{sortable-handle}}>&varr;</span>
8492
</li>
8593
{{/each}}
8694
</ol>
8795
```
88-

‎MIGRATION_GUIDE_V2.md

+20-8
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
[High Order Components](#Higher Order Components) or [Modifiers](/MIGRATION_GUIDE_MODIFIERS.md)
66

77
### Higher Order Components
8+
89
`Ember-sortable` can now be built using [higher order components](https://v4.chriskrycho.com/2018/higher-order-components-in-emberjs.html)
910

1011
1. The array of models are now yielded out by `sortable-group`
1112

1213
**V1**
14+
1315
```hbs
1416
{{#sortable-group onChange=(action "reorderItems") as |group|}}
1517
{{#each model.items as |item|}}
1618
```
19+
1720
**V2**
21+
1822
```hbs
1923
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
2024
{{#each group.model as |item|}}
@@ -23,23 +27,25 @@
2327
2. Each `item` can be represented by the yielded `sortable-item` instead of directly using `sortable-item` and passing the `group` manually.
2428

2529
**V1**
30+
2631
```hbs
27-
{{#sortable-group onChange=(action "reorderItems") as |group|}}
32+
{{#sortable-group onChange=(action 'reorderItems') as |group|}}
2833
{{#each model.items as |item|}}
29-
{{#sortable-item model=item group=group handle=".handle"}}
34+
{{#sortable-item model=item group=group handle='.handle'}}
3035
{{item.name}}
31-
<span class="handle">&varr;</span>
36+
<span class='handle'>&varr;</span>
3237
{{/sortable-item}}
3338
{{/each}}
3439
{{/sortable-group}}
3540
```
3641

3742
**V2**
43+
3844
```hbs
39-
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
45+
{{#sortable-group model=model.items onChange=(action 'reorderItems') as |group|}}
4046
{{#each group.model as |item|}}
4147
{{#group.item model=item}}
42-
...
48+
...
4349
{{/group.item}}
4450
{{/each}}
4551
{{/sortable-group}}
@@ -48,18 +54,20 @@
4854
3. It is recommended to use the yielded `sortable-handle` instead of referencing `handle` by `class`, as it guarantees accessibility support.
4955

5056
**V1**
57+
5158
```hbs
52-
{{#sortable-group onChange=(action "reorderItems") as |group|}}
59+
{{#sortable-group onChange=(action 'reorderItems') as |group|}}
5360
{{#each model.items as |item|}}
54-
{{#sortable-item model=item group=group handle=".handle"}}
61+
{{#sortable-item model=item group=group handle='.handle'}}
5562
{{item.name}}
56-
<span class="handle">&varr;</span>
63+
<span class='handle'>&varr;</span>
5764
{{/sortable-item}}
5865
{{/each}}
5966
{{/sortable-group}}
6067
```
6168

6269
**V2**
70+
6371
```hbs
6472
{{#sortable-group model=model.items onChange=(action "reorderItems") as |group|}}
6573
{{#each group.model as |modelItem|}}
@@ -76,6 +84,7 @@
7684
4. `groupModel` is still supported via `groupModel` instead of `model`
7785

7886
**V1**
87+
7988
```hbs
8089
{{#sortable-group model=model onChange=(action "reorderItems") as |group|}}
8190
{{#each model.items as |item|}}
@@ -84,6 +93,7 @@
8493
```
8594

8695
**V2**
96+
8797
```hbs
8898
{{#sortable-group groupModel=model model=model.items onChange=(action "reorderItems") as |group|}}
8999
{{#each group.model as |item|}}
@@ -94,6 +104,7 @@
94104
### Modifiers
95105

96106
### Accessibility support
107+
97108
1. Keyboard navigation is built into `ember-sortable`.
98109
2. `a11yItemName`, `a11yAnnouncementConfig`, `itemVisualClass`, `handleVisualClass` can be supplied to enhance the accessibility experience.
99110
3. Refer to [Accessibility Section](/README.md#Accessibility) for more details.
@@ -103,6 +114,7 @@
103114
```
104115

105116
### Testing
117+
106118
1. The `drag` and `reorder` test helpers are no longer global `async` helpers. They are now importable.
107119

108120
Refer to [Testing Section](/README.md#Testing) for more details.

‎README.md

+44-31
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ Sortable UI primitives for Ember.
1313
[Check out the demo](https://adopted-ember-addons.github.io/ember-sortable/demo/)
1414

1515
## v2 -> v3 Migration
16+
1617
The component versions have been removed and you must use the modifier.
1718
The modifier version does not support `groupModel`, use the currying of the `fn` helper.
1819

1920
## v1 -> v2 Migration
21+
2022
If you are migrating from `1.x.x` to `2.x.x`,
2123
For components, please read this [migration guide](/MIGRATION_GUIDE_V2.md).
2224
For modifiers, please read this [migration guide](/MIGRATION_GUIDE_MODIFIERS.md).
@@ -46,7 +48,7 @@ $ ember install ember-sortable
4648
{{#each @model.items as |modelItem|}}
4749
<li {{sortable-item model=modelItem}}>
4850
{{modelItem.name}}
49-
<span class="handle" {{sortable-handle}}>&varr;</span>
51+
<span class='handle' {{sortable-handle}}>&varr;</span>
5052
</li>
5153
{{/each}}
5254
</ol>
@@ -78,13 +80,12 @@ The modifier version does not support `groupModel`, use the currying of `action`
7880
{{#each @model.items as |modelItem|}}
7981
<li {{sortable-item model=modelItem}}>
8082
{{modelItem.name}}
81-
<span class="handle" {{sortable-handle}}>&varr;</span>
83+
<span class='handle' {{sortable-handle}}>&varr;</span>
8284
</li>
8385
{{/each}}
8486
</ol>
8587
```
8688

87-
8889
### Changing sort direction
8990

9091
To change sort direction, define `direction` on `sortable-group` (default is `y`):
@@ -145,7 +146,7 @@ transition of `.125s` in the default case:
145146

146147
```css
147148
.sortable-item {
148-
transition: all .125s;
149+
transition: all 0.125s;
149150
}
150151
```
151152

@@ -219,11 +220,11 @@ There is a service behind the scenes for communication between the group and the
219220
Both the `{{sortable-group}}` and `{{sortable-item}}` take an additional argument `groupName`. Should you encounter this conflict, assign a `groupName` to the group and items. You only need to do this for one of the sortables in conflict, but you can on both if you wish.
220221

221222
```hbs
222-
<ol {{sortable-group groupName="products" onChange=this.reorderItems}}>
223+
<ol {{sortable-group groupName='products' onChange=this.reorderItems}}>
223224
{{#each @model.items as |modelItem|}}
224-
<li {{sortable-item groupName="products" model=modelItem}}>
225+
<li {{sortable-item groupName='products' model=modelItem}}>
225226
{{modelItem.name}}
226-
<span class="handle" {{sortable-handle}}>&varr;</span>
227+
<span class='handle' {{sortable-handle}}>&varr;</span>
227228
</li>
228229
{{/each}}
229230
</ol>
@@ -232,20 +233,20 @@ Both the `{{sortable-group}}` and `{{sortable-item}}` take an additional argumen
232233
Ensure that the same name is passed to both the group and the items, this would be best accomplished by creating property on the component and referring to that property. If you are able to use the `{{#let}}` helper (useful in template only components), using `{{#let}}` makes the usage clearer.
233234

234235
```hbs
235-
{{#let "products" as | myGroupName |}}
236+
{{#let 'products' as |myGroupName|}}
236237
<ol {{sortable-group groupName=myGroupName onChange=this.reorderItems}}>
237238
{{#each @model.items as |modelItem|}}
238239
<li {{sortable-item groupName=myGroupName model=modelItem}}>
239240
{{modelItem.name}}
240-
<span class="handle" {{sortable-handle}}>&varr;</span>
241+
<span class='handle' {{sortable-handle}}>&varr;</span>
241242
</li>
242243
{{/each}}
243244
</ol>
244245
{{/let}}
245246
```
246247

247-
248248
### Disabling Drag (Experimental)
249+
249250
`sortable-item` exposes an optional `disabled` (previously `isDraggingDisabled`) flag that you can use to disable reordering for that particular item. Disabling and item won't prevent it from changing position in the array. The user can still move other non-disabled items to over it.
250251

251252
This flag is intended as an utility to make your life easier with 3 main benefits:
@@ -261,30 +262,35 @@ No data is mutated by `sortable-group` or `sortable-item`. In the spirit of “d
261262
Each item takes a `model` property. This should be fairly self-explanatory but it’s important to note that it doesn’t do anything with this object besides keeping a reference for later use in `onChange`.
262263

263264
### Accessibility
265+
264266
The `sortable-group` has support for the following accessibility functionality:
265267

266268
#### Built-in Functionalities
267269

268270
##### Keyboard Navigation
271+
269272
There are 4 modes during keyboard navigation:
273+
270274
- **ACTIVATE**
271275
enables the keyboard navigation.
272-
Activate via `ENTER/SPACE`
276+
Activate via `ENTER/SPACE`
273277
- **MOVE**
274278
enables item(s) to be moved up, down, left, or right based on `direction`.
275-
Activate via `ARROW UP/DOWN/LEFT/RIGHT`
279+
Activate via `ARROW UP/DOWN/LEFT/RIGHT`
276280
- **CONFIRM**
277281
submits the new sort order, invokes the `onChange` action.
278-
Activate via `ENTER/SPACE`.
282+
Activate via `ENTER/SPACE`.
279283
- **CANCEL**
280284
cancels the new sort order, reverts back to the old sort order.
281-
Activate via `ESCAPE` or when `focus` is lost.
285+
Activate via `ESCAPE` or when `focus` is lost.
282286

283287
##### Focus Management
288+
284289
- When `focus` is on a `item` or `handle`, user can effectively select the `item` via `ENTER/SPACE`. This is the `ACTIVATE` mode.
285290
- While `ACTIVATE`, the `focus` is locked on `sortable-group` container and will not be lost until `CONFIRM`, `CANCEL`, or `focus` is lost.
286291

287292
#### User configurable
293+
288294
##### Screen Reader
289295

290296
The default language for `ember-sortable` is English. Any language can be supported by passing in the configuration below in the appropriate language.
@@ -293,18 +299,21 @@ The default language for `ember-sortable` is English. Any language can be suppor
293299
a name for the item. Defaults to `item`.
294300
- **a11yAnnouncementConfig**
295301
a map of `action enums` to `functions` that takes the following `config`, which is exposed by `sortable-group`.
302+
296303
```javascript
297304
a11yAnnounceConfig = {
298305
a11yItemName, // name associated with the name
299306
index, // 0-based
300307
maxLength, // length of the items
301308
direction, // x or y
302309
delta, // +1 means down or right, -1 means up or left
303-
}
310+
};
304311
```
312+
305313
and returns a `string` constructed from the `config`.
306314

307315
**Default value**
316+
308317
```javascript
309318
{
310319
ACTIVATE: function({ a11yItemName, index, maxLength, direction }) {
@@ -332,6 +341,7 @@ and returns a `string` constructed from the `config`.
332341
```
333342

334343
##### Visual Indicator
344+
335345
- **handleVisualClass**
336346
This class will be added to the `sortable-handle` during `ACTIVATE` and `MOVE` operations. This allows you to add custom styles such as `visual arrows` via `pseudo` classes.
337347

@@ -342,9 +352,9 @@ and returns a `string` constructed from the `config`.
342352

343353
`ember-sortable` exposes some acceptance test helpers:
344354

345-
* [`drag`][drag]: Drags elements by an offset specified in pixels.
346-
* [`reorder`][reorder]: Reorders elements to the specified state.
347-
* [`keyboard`][keyboard]: Keycode constants for quick.
355+
- [`drag`][drag]: Drags elements by an offset specified in pixels.
356+
- [`reorder`][reorder]: Reorders elements to the specified state.
357+
- [`keyboard`][keyboard]: Keycode constants for quick.
348358

349359
[drag]: addon-test-support/helpers/drag.js
350360
[reorder]: addon-test-support/helpers/reorder.js
@@ -353,32 +363,35 @@ and returns a `string` constructed from the `config`.
353363
To include them in your application, you can import them:
354364

355365
```js
356-
import { drag, reorder } from 'ember-sortable/test-support/helpers';
357-
import { ENTER_KEY_CODE, SPACE_KEY_CODE, ESCAPE_KEY_CODE, ARROW_KEY_CODES } from "ember-sortable/test-support/utils/keyboard";
366+
import { drag, reorder } from 'ember-sortable/test-support/helpers';
367+
import {
368+
ENTER_KEY_CODE,
369+
SPACE_KEY_CODE,
370+
ESCAPE_KEY_CODE,
371+
ARROW_KEY_CODES,
372+
} from 'ember-sortable/test-support/utils/keyboard';
358373
```
359374

360375
### Examples
376+
361377
`Reorder`
378+
362379
```js
363-
await reorder(
364-
'mouse',
365-
'[data-test-vertical-demo-handle]',
366-
...order
367-
);
380+
await reorder('mouse', '[data-test-vertical-demo-handle]', ...order);
368381
```
369382

370383
`Drag`
384+
371385
```js
372-
await drag('mouse', '[data-test-scrollable-demo-handle] .handle', () => { return {dy: itemHeight() * 2 + 1, dx: undefined}});
386+
await drag('mouse', '[data-test-scrollable-demo-handle] .handle', () => {
387+
return { dy: itemHeight() * 2 + 1, dx: undefined };
388+
});
373389
```
374390

375391
`Keyboard`
392+
376393
```js
377-
await triggerKeyEvent(
378-
'[data-test-vertical-demo-handle]',
379-
'keydown',
380-
ENTER_KEY_CODE
381-
);
394+
await triggerKeyEvent('[data-test-vertical-demo-handle]', 'keydown', ENTER_KEY_CODE);
382395
```
383396

384397
## Developing

‎V2_MIGRATION_RFC.md

+188-222
Large diffs are not rendered by default.

‎addon-test-support/helpers/drag.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ export async function drag(mode, itemSelector, offsetFn, callbacks = {}) {
5757
// https://stackoverflow.com/a/5042051
5858
const dx = offset.dx || 0;
5959
const dy = offset.dy || 0;
60-
const clientHeight =
61-
itemElement.clientHeight ||
62-
itemElement.offsetHeight ||
63-
itemElement.parentNode.offsetHeight;
60+
const clientHeight = itemElement.clientHeight || itemElement.offsetHeight || itemElement.parentNode.offsetHeight;
6461
const scale = clientHeight / (rect.bottom - rect.top);
6562
const halfwayX = itemOffset.left + (dx * scale) / 2;
6663
const halfwayY = itemOffset.top + (dy * scale) / 2;

‎addon-test-support/helpers/reorder.js

+3-9
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@ const OVERSHOOT = 2;
2727
@return {Promise}
2828
*/
2929
export async function reorder(mode, itemSelector, ...resultSelectors) {
30-
for (
31-
let targetIndex = 0;
32-
targetIndex < resultSelectors.length;
33-
targetIndex++
34-
) {
30+
for (let targetIndex = 0; targetIndex < resultSelectors.length; targetIndex++) {
3531
const items = findAll(itemSelector);
3632
const sourceElement = find(resultSelectors[targetIndex]);
3733
const targetElement = items[targetIndex];
38-
const dx =
39-
getOffset(targetElement).left - OVERSHOOT - getOffset(sourceElement).left;
40-
const dy =
41-
getOffset(targetElement).top - OVERSHOOT - getOffset(sourceElement).top;
34+
const dx = getOffset(targetElement).left - OVERSHOOT - getOffset(sourceElement).left;
35+
const dy = getOffset(targetElement).top - OVERSHOOT - getOffset(sourceElement).top;
4236

4337
await drag(mode, sourceElement, () => {
4438
return { dx: dx, dy: dy };

‎addon-test-support/utils/keyboard.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,7 @@ function createKeyTest(key, keyCode) {
2626
export const isEnterKey = createKeyTest(ENTER_KEY, ENTER_KEY_CODE);
2727
export const isEscapeKey = createKeyTest(ESCAPE_KEY, ESCAPE_KEY_CODE);
2828
export const isSpaceKey = createKeyTest(SPACE_KEY, SPACE_KEY_CODE);
29-
export const isLeftArrowKey = createKeyTest(
30-
ARROW_KEYS.LEFT,
31-
ARROW_KEY_CODES.LEFT
32-
);
29+
export const isLeftArrowKey = createKeyTest(ARROW_KEYS.LEFT, ARROW_KEY_CODES.LEFT);
3330
export const isUpArrowKey = createKeyTest(ARROW_KEYS.UP, ARROW_KEY_CODES.UP);
34-
export const isRightArrowKey = createKeyTest(
35-
ARROW_KEYS.RIGHT,
36-
ARROW_KEY_CODES.RIGHT
37-
);
38-
export const isDownArrowKey = createKeyTest(
39-
ARROW_KEYS.DOWN,
40-
ARROW_KEY_CODES.DOWN
41-
);
31+
export const isRightArrowKey = createKeyTest(ARROW_KEYS.RIGHT, ARROW_KEY_CODES.RIGHT);
32+
export const isDownArrowKey = createKeyTest(ARROW_KEYS.DOWN, ARROW_KEY_CODES.DOWN);

‎addon/modifiers/sortable-group.js

+5-21
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ export default class SortableGroupModifier extends Modifier {
8686
* }
8787
*/
8888
get a11yAnnouncementConfig() {
89-
return (
90-
this.args.named.a11yAnnouncementConfig || defaultA11yAnnouncementConfig
91-
);
89+
return this.args.named.a11yAnnouncementConfig || defaultA11yAnnouncementConfig;
9290
}
9391

9492
get itemVisualClass() {
@@ -109,10 +107,7 @@ export default class SortableGroupModifier extends Modifier {
109107
*/
110108
@action
111109
focusOut() {
112-
if (
113-
!this.isRetainingFocus &&
114-
!this._isElementWithinHandle(document.activeElement)
115-
) {
110+
if (!this.isRetainingFocus && !this._isElementWithinHandle(document.activeElement)) {
116111
this.cancelKeyboardSelection();
117112
}
118113
}
@@ -136,10 +131,7 @@ export default class SortableGroupModifier extends Modifier {
136131
const isKeyboardReorderModeEnabled = this.isKeyboardReorderModeEnabled;
137132
const _selectedItem = this._selectedItem;
138133

139-
if (
140-
!isKeyboardReorderModeEnabled &&
141-
(isEnterKey(event) || isSpaceKey(event))
142-
) {
134+
if (!isKeyboardReorderModeEnabled && (isEnterKey(event) || isSpaceKey(event))) {
143135
this._prepareKeyboardReorderMode();
144136
this._announceAction(ANNOUNCEMENT_ACTION_TYPES.ACTIVATE);
145137
this._updateItemVisualIndicators(_selectedItem, true);
@@ -190,20 +182,12 @@ export default class SortableGroupModifier extends Modifier {
190182
// DOWN or RIGHT
191183
if (toIndex > fromIndex) {
192184
value = item[direction];
193-
set(
194-
item,
195-
direction,
196-
nextItem[direction] + (nextItem[dimension] - item[dimension])
197-
);
185+
set(item, direction, nextItem[direction] + (nextItem[dimension] - item[dimension]));
198186
set(nextItem, direction, value);
199187
// UP or LEFT
200188
} else {
201189
value = nextItem[direction];
202-
set(
203-
nextItem,
204-
direction,
205-
item[direction] + (item[dimension] - nextItem[dimension])
206-
);
190+
set(nextItem, direction, item[direction] + (item[dimension] - nextItem[dimension]));
207191
set(item, direction, value);
208192
}
209193
}

‎addon/modifiers/sortable-item.js

+13-46
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { Promise, defer } from 'rsvp';
33
import { action, set } from '@ember/object';
44
import { reads } from '@ember/object/computed';
55
import { or } from '@ember/object/computed';
6-
import {
7-
DRAG_ACTIONS,
8-
ELEMENT_CLICK_ACTION,
9-
END_ACTIONS,
10-
} from '../utils/constant';
6+
import { DRAG_ACTIONS, ELEMENT_CLICK_ACTION, END_ACTIONS } from '../utils/constant';
117
import { run, throttle, bind, scheduleOnce, later } from '@ember/runloop';
128
import { DEBUG } from '@glimmer/env';
139
import { getX, getY } from '../utils/coordinate';
@@ -129,12 +125,7 @@ export default class SortableItemModifier extends Modifier {
129125
}
130126
);
131127

132-
return (
133-
this.groupDisabled ||
134-
this.args.named.disabled ||
135-
this.args.named.isDraggingDisabled ||
136-
false
137-
);
128+
return this.groupDisabled || this.args.named.disabled || this.args.named.isDraggingDisabled || false;
138129
}
139130

140131
/**
@@ -249,9 +240,7 @@ export default class SortableItemModifier extends Modifier {
249240
@property disableCheckScrollBounds
250241
*/
251242
get disableCheckScrollBounds() {
252-
return this.args.named.disableCheckScrollBounds != undefined
253-
? this.args.named.disableCheckScrollBounds
254-
: isTesting;
243+
return this.args.named.disableCheckScrollBounds != undefined ? this.args.named.disableCheckScrollBounds : isTesting;
255244
}
256245

257246
/**
@@ -351,26 +340,18 @@ export default class SortableItemModifier extends Modifier {
351340

352341
this._prepareDragListener = bind(this, this._prepareDrag, startEvent);
353342

354-
DRAG_ACTIONS.forEach((event) =>
355-
window.addEventListener(event, this._prepareDragListener)
356-
);
343+
DRAG_ACTIONS.forEach((event) => window.addEventListener(event, this._prepareDragListener));
357344

358345
this._cancelStartDragListener = () => {
359-
DRAG_ACTIONS.forEach((event) =>
360-
window.removeEventListener(event, this._prepareDragListener)
361-
);
346+
DRAG_ACTIONS.forEach((event) => window.removeEventListener(event, this._prepareDragListener));
362347
};
363348

364349
const selfCancellingCallback = () => {
365-
END_ACTIONS.forEach((event) =>
366-
window.removeEventListener(event, selfCancellingCallback)
367-
);
350+
END_ACTIONS.forEach((event) => window.removeEventListener(event, selfCancellingCallback));
368351
this._cancelStartDragListener();
369352
};
370353

371-
END_ACTIONS.forEach((event) =>
372-
window.addEventListener(event, selfCancellingCallback)
373-
);
354+
END_ACTIONS.forEach((event) => window.addEventListener(event, selfCancellingCallback));
374355
}
375356

376357
/**
@@ -387,9 +368,7 @@ export default class SortableItemModifier extends Modifier {
387368
let dy = Math.abs(getY(startEvent) - getY(event));
388369

389370
if (distance <= dx || distance <= dy) {
390-
DRAG_ACTIONS.forEach((event) =>
391-
window.removeEventListener(event, this._prepareDragListener)
392-
);
371+
DRAG_ACTIONS.forEach((event) => window.removeEventListener(event, this._prepareDragListener));
393372
this._startDrag(startEvent);
394373
}
395374
}
@@ -410,19 +389,15 @@ export default class SortableItemModifier extends Modifier {
410389
let dragThrottled = (ev) => throttle(this, drag, ev, 16, false);
411390

412391
let drop = () => {
413-
DRAG_ACTIONS.forEach((event) =>
414-
window.removeEventListener(event, dragThrottled)
415-
);
392+
DRAG_ACTIONS.forEach((event) => window.removeEventListener(event, dragThrottled));
416393
END_ACTIONS.forEach((event) => window.removeEventListener(event, drop));
417394

418395
run(() => {
419396
this._drop();
420397
});
421398
};
422399

423-
DRAG_ACTIONS.forEach((event) =>
424-
window.addEventListener(event, dragThrottled)
425-
);
400+
DRAG_ACTIONS.forEach((event) => window.addEventListener(event, dragThrottled));
426401
END_ACTIONS.forEach((event) => window.addEventListener(event, drop));
427402

428403
this.sortableGroup.prepare();
@@ -590,10 +565,7 @@ export default class SortableItemModifier extends Modifier {
590565

591566
if (groupDirection === 'x') {
592567
let x = this.x;
593-
let dx =
594-
x -
595-
this.element.offsetLeft +
596-
parseFloat(getComputedStyle(this.element).marginLeft);
568+
let dx = x - this.element.offsetLeft + parseFloat(getComputedStyle(this.element).marginLeft);
597569

598570
this.element.style.transform = `translateX(${dx}px)`;
599571
}
@@ -652,10 +624,7 @@ export default class SortableItemModifier extends Modifier {
652624
*/
653625
_preventClick() {
654626
const selfCancellingCallback = (event) => {
655-
this.element.removeEventListener(
656-
ELEMENT_CLICK_ACTION,
657-
selfCancellingCallback
658-
);
627+
this.element.removeEventListener(ELEMENT_CLICK_ACTION, selfCancellingCallback);
659628
this._preventClickHandler(event);
660629
};
661630

@@ -725,9 +694,7 @@ export default class SortableItemModifier extends Modifier {
725694
let el = this.element;
726695
let transitionProperty = getComputedStyle(el).transitionProperty;
727696

728-
return (
729-
/all|transform/.test(transitionProperty) && this.transitionDuration > 0
730-
);
697+
return /all|transform/.test(transitionProperty) && this.transitionDuration > 0;
731698
}
732699

733700
/**

‎addon/utils/defaults.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
export const defaultA11yAnnouncementConfig = {
22
ACTIVATE({ a11yItemName, index, maxLength, direction }) {
3-
let message = `${a11yItemName} at position, ${
4-
index + 1
5-
} of ${maxLength}, is activated to be repositioned.`;
3+
let message = `${a11yItemName} at position, ${index + 1} of ${maxLength}, is activated to be repositioned.`;
64

75
if (direction === 'y') {
86
message += 'Press up and down keys to change position,';

‎addon/utils/keyboard.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,7 @@ function createKeyTest(key, keyCode) {
2626
export const isEnterKey = createKeyTest(ENTER_KEY, ENTER_KEY_CODE);
2727
export const isEscapeKey = createKeyTest(ESCAPE_KEY, ESCAPE_KEY_CODE);
2828
export const isSpaceKey = createKeyTest(SPACE_KEY, SPACE_KEY_CODE);
29-
export const isLeftArrowKey = createKeyTest(
30-
ARROW_KEYS.LEFT,
31-
ARROW_KEY_CODES.LEFT
32-
);
29+
export const isLeftArrowKey = createKeyTest(ARROW_KEYS.LEFT, ARROW_KEY_CODES.LEFT);
3330
export const isUpArrowKey = createKeyTest(ARROW_KEYS.UP, ARROW_KEY_CODES.UP);
34-
export const isRightArrowKey = createKeyTest(
35-
ARROW_KEYS.RIGHT,
36-
ARROW_KEY_CODES.RIGHT
37-
);
38-
export const isDownArrowKey = createKeyTest(
39-
ARROW_KEYS.DOWN,
40-
ARROW_KEY_CODES.DOWN
41-
);
31+
export const isRightArrowKey = createKeyTest(ARROW_KEYS.RIGHT, ARROW_KEY_CODES.RIGHT);
32+
export const isDownArrowKey = createKeyTest(ARROW_KEYS.DOWN, ARROW_KEY_CODES.DOWN);

‎config/ember-try.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
const getChannelURL = require('ember-source-channel-url');
44

55
module.exports = function () {
6-
return Promise.all([
7-
getChannelURL('release'),
8-
getChannelURL('beta'),
9-
getChannelURL('canary'),
10-
]).then((urls) => {
6+
return Promise.all([getChannelURL('release'), getChannelURL('beta'), getChannelURL('canary')]).then((urls) => {
117
return {
128
useYarn: true,
139
scenarios: [

‎tests/acceptance/auto-scroll-test.js

+9-26
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,11 @@ function fakeDocumentContainer() {
2525
document.getElementById('ember-testing').style.height = 'auto';
2626

2727
return () => {
28-
document.getElementById('ember-testing-container').style.height =
29-
originalStyle.containerHeight;
30-
document.getElementById('ember-testing-container').style.width =
31-
originalStyle.containerWidth;
32-
document.getElementById('ember-testing-container').style.overflow =
33-
originalStyle.containerOverflow;
34-
document.getElementById('ember-testing').style.height =
35-
originalStyle.appHeight;
36-
document.getElementById('ember-testing').style.height =
37-
originalStyle.appWidth;
28+
document.getElementById('ember-testing-container').style.height = originalStyle.containerHeight;
29+
document.getElementById('ember-testing-container').style.width = originalStyle.containerWidth;
30+
document.getElementById('ember-testing-container').style.overflow = originalStyle.containerOverflow;
31+
document.getElementById('ember-testing').style.height = originalStyle.appHeight;
32+
document.getElementById('ember-testing').style.height = originalStyle.appWidth;
3833
};
3934
}
4035

@@ -58,10 +53,7 @@ module('Acceptance | container auto scroll', function (hooks) {
5853
await drag('mouse', '[data-test-doc-auto-scroll-demo-item]', () => {
5954
return { dy: itemHeight() * 30 + 1, dx: undefined };
6055
});
61-
assert.ok(
62-
document.getElementById('ember-testing-container').scrollTop,
63-
'The container has scroll (top)'
64-
);
56+
assert.ok(document.getElementById('ember-testing-container').scrollTop, 'The container has scroll (top)');
6557
});
6658

6759
test('horizontaly reordering can scroll his parent container (not document)', async function (assert) {
@@ -76,10 +68,7 @@ module('Acceptance | container auto scroll', function (hooks) {
7668
await drag('mouse', '[data-test-doc-auto-scroll-demo-item]', () => {
7769
return { dy: undefined, dx: itemWidth() * 30 + 1 };
7870
});
79-
assert.ok(
80-
document.getElementById('ember-testing-container').scrollLeft,
81-
'The container has scroll (left)'
82-
);
71+
assert.ok(document.getElementById('ember-testing-container').scrollLeft, 'The container has scroll (left)');
8372
});
8473

8574
test('verticaly reordering can scroll his parent container (document)', async function (assert) {
@@ -96,10 +85,7 @@ module('Acceptance | container auto scroll', function (hooks) {
9685
await drag('mouse', '[data-test-doc-auto-scroll-demo-item]', () => {
9786
return { dy: itemHeight() * 30 + 1, dx: undefined };
9887
});
99-
assert.ok(
100-
document.documentElement.scrollTop,
101-
'The document has scroll (top)'
102-
);
88+
assert.ok(document.documentElement.scrollTop, 'The document has scroll (top)');
10389
restoreTestingContainer();
10490
});
10591

@@ -117,10 +103,7 @@ module('Acceptance | container auto scroll', function (hooks) {
117103
await drag('mouse', '[data-test-doc-auto-scroll-demo-item]', () => {
118104
return { dy: undefined, dx: itemWidth() * 30 + 1 };
119105
});
120-
assert.ok(
121-
document.documentElement.scrollLeft,
122-
'The document has scroll (left)'
123-
);
106+
assert.ok(document.documentElement.scrollLeft, 'The document has scroll (left)');
124107
restoreTestingContainer();
125108
});
126109
});

‎tests/acceptance/smoke-modifier-test.js

+49-236
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{@item}}
1+
{{@item}}
+12-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import Controller from '@ember/controller';
22
import { equal } from '@ember/object/computed';
3-
import { set } from '@ember/object';
3+
import { action, set } from '@ember/object';
44

5-
export default Controller.extend({
6-
queryParams: ['direction'],
7-
direction: 'y',
8-
isVertical: equal('direction', 'y'),
9-
actions: {
10-
updateItems(newOrder) {
11-
set(this, 'model.items', newOrder);
12-
},
13-
},
14-
});
5+
export default class DocAutoScroll extends Controller {
6+
queryParams = ['direction'];
7+
direction = 'y';
8+
9+
@equal('direction', 'y') isVertical;
10+
11+
@action
12+
updateItems(newOrder) {
13+
set(this, 'model.items', newOrder);
14+
}
15+
}

‎tests/dummy/app/controllers/index.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ export default class ModifierController extends Controller {
1515

1616
a11yAnnouncementConfig = {
1717
ACTIVATE: function ({ a11yItemName, index, maxLength, direction }) {
18-
let message = `${a11yItemName} at position, ${
19-
index + 1
20-
} of ${maxLength}, is activated to be repositioned.`;
18+
let message = `${a11yItemName} at position, ${index + 1} of ${maxLength}, is activated to be repositioned.`;
2119
if (direction === 'y') {
2220
message += 'Press up and down keys to change position,';
2321
} else {

‎tests/dummy/app/index.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="utf-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<title>Ember Sortable Demo</title>
7-
<meta name="description" content="">
8-
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<meta name="description" content="" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
99

1010
{{content-for "head"}}
1111

12-
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css">
13-
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css">
12+
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/vendor.css" />
13+
<link integrity="" rel="stylesheet" href="{{rootURL}}assets/dummy.css" />
1414

1515
{{content-for "head-footer"}}
1616
</head>

‎tests/dummy/app/styles/app.css

+20-14
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121

2222
.demo footer {
2323
margin-top: 2em;
24-
font-size: .5em;
24+
font-size: 0.5em;
2525
}
2626

2727
.demo .sortable-item {
2828
padding: 4px;
29-
transition: all .125s;
29+
transition: all 0.125s;
3030
}
3131

3232
.demo .sortable-item.is-dragging {
@@ -35,14 +35,13 @@
3535
}
3636

3737
.demo .sortable-item .handle {
38-
padding: 0 .5em;
38+
padding: 0 0.5em;
3939
cursor: move;
4040
display: flex;
4141
flex-direction: column;
4242
justify-content: center;
4343
}
4444

45-
4645
.vertical-demo .sortable-item {
4746
display: block;
4847
position: relative;
@@ -62,23 +61,28 @@
6261
.vertical-demo .sortable-item .handle {
6362
display: block;
6463
position: absolute;
65-
top: 0; right: 0; bottom: 0;
64+
top: 0;
65+
right: 0;
66+
bottom: 0;
6667
background: rgba(71, 1, 1, 0.5);
6768
color: pink;
6869
}
6970

70-
.vertical-spacing-demo .sortable-item, .vertical-distance-demo .sortable-item, .vertical-doc-auto-scroll-demo .sortable-item {
71+
.vertical-spacing-demo .sortable-item,
72+
.vertical-distance-demo .sortable-item,
73+
.vertical-doc-auto-scroll-demo .sortable-item {
7174
display: block;
7275
position: relative;
73-
background: #58D3F7;
76+
background: #58d3f7;
7477
width: 50%;
7578
line-height: 50px;
7679
margin: 5px auto;
7780
text-align: center;
7881
}
7982

80-
.vertical-spacing-demo .sortable-item.is-dragging, .vertical-distance-demo .sortable-item.is-dragging {
81-
background: #A9E2F3;
83+
.vertical-spacing-demo .sortable-item.is-dragging,
84+
.vertical-distance-demo .sortable-item.is-dragging {
85+
background: #a9e2f3;
8286
}
8387

8488
.horizontal-demo {
@@ -89,14 +93,15 @@
8993
.horizontal-doc-auto-scroll-demo {
9094
white-space: nowrap;
9195
}
92-
.horizontal-doc-auto-scroll-demo ol{
96+
.horizontal-doc-auto-scroll-demo ol {
9397
padding-left: 0px;
9498
}
95-
.horizontal-doc-auto-scroll-demo .sortable-item{
99+
.horizontal-doc-auto-scroll-demo .sortable-item {
96100
width: 70px;
97101
}
98102

99-
.horizontal-demo .sortable-item, .horizontal-doc-auto-scroll-demo .sortable-item{
103+
.horizontal-demo .sortable-item,
104+
.horizontal-doc-auto-scroll-demo .sortable-item {
100105
display: inline-block;
101106
position: relative;
102107
cursor: move;
@@ -136,7 +141,6 @@
136141
color: black;
137142
}
138143

139-
140144
.scrollable-demo .sortable-container {
141145
height: 300px;
142146
overflow-y: auto;
@@ -165,7 +169,9 @@
165169
.scrollable-demo .sortable-item .handle {
166170
display: block;
167171
position: absolute;
168-
top: 0; right: 0; bottom: 0;
172+
top: 0;
173+
right: 0;
174+
bottom: 0;
169175
background: rgba(71, 1, 1, 0.5);
170176
color: pink;
171177
}
+4-8
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
<section class={{if isVertical "vertical-doc-auto-scroll-demo" "horizontal-doc-auto-scroll-demo" }}>
2-
<ol data-test-doc-auto-scroll-demo-group
3-
{{sortable-group
4-
onChange=(action "updateItems")
5-
direction=direction}}
6-
>
7-
{{#each model.items as |item|}}
1+
<section class={{if @isVertical 'vertical-doc-auto-scroll-demo' 'horizontal-doc-auto-scroll-demo'}}>
2+
<ol data-test-doc-auto-scroll-demo-group {{sortable-group onChange=this.updateItems direction=@direction}}>
3+
{{#each @model.items as |item|}}
84
<li data-test-doc-auto-scroll-demo-item {{sortable-item disableCheckScrollBounds=false model=item}}>
95
{{item}}
106
</li>
117
{{/each}}
128
</ol>
13-
</section>
9+
</section>

‎tests/dummy/app/templates/index.hbs

+49-48
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,74 @@
1-
<article class="demo">
1+
<article class='demo'>
22
<header>
33
<h2>Ember Sortable</h2>
44
</header>
55

66
<main>
7-
<section class="vertical-demo">
7+
<section class='vertical-demo'>
88
<h3>Vertical</h3>
99

10-
<ol data-test-vertical-demo-group
10+
<ol
11+
data-test-vertical-demo-group
1112
{{sortable-group
1213
onChange=this.update
1314
a11yAnnouncementConfig=this.a11yAnnouncementConfig
14-
a11yItemName="spanish number"
15+
a11yItemName='spanish number'
1516
itemVisualClass=this.itemVisualClass
1617
handleVisualClass=this.handleVisualClass
1718
}}
1819
>
1920
{{#each model.items as |item|}}
2021
<li data-test-vertical-demo-item {{sortable-item model=item}}>
2122
{{item}}
22-
<span class="handle" data-test-vertical-demo-handle {{sortable-handle}} data-item={{item}}>
23+
<span class='handle' data-test-vertical-demo-handle {{sortable-handle}} data-item={{item}}>
2324
<span>&vArr;</span>
2425
</span>
2526
</li>
2627
{{/each}}
2728
</ol>
2829
</section>
2930

30-
<section class="vertical-demo">
31+
<section class='vertical-demo'>
3132
<h3>Vertical with different sized models and inputs</h3>
3233

33-
<ol data-test-vertical-demo-group
34-
{{sortable-group
35-
onChange=this.updateDifferentSizedModels
36-
groupName="verticle-size"
37-
}}
34+
<ol
35+
data-test-vertical-demo-group
36+
{{sortable-group onChange=this.updateDifferentSizedModels groupName='verticle-size'}}
3837
>
3938
{{#each this.differentSizedModels as |item|}}
40-
<li data-test-vertical-demo-item class="word-break" {{sortable-item model=item groupName="verticle-size"}}>
41-
<label for="demo-input">{{item}}</label>
42-
<input id="demo-input" type="text">
43-
<span data-item={{item}} data-test-vertical-demo-handle class="handle" {{sortable-handle}}>
39+
<li data-test-vertical-demo-item class='word-break' {{sortable-item model=item groupName='verticle-size'}}>
40+
<label for='demo-input'>{{item}}</label>
41+
<input id='demo-input' type='text' />
42+
<span data-item={{item}} data-test-vertical-demo-handle class='handle' {{sortable-handle}}>
4443
<span>&vArr;</span>
4544
</span>
4645
</li>
4746
{{/each}}
4847
</ol>
4948
</section>
5049

51-
<section class="horizontal-demo">
50+
<section class='horizontal-demo'>
5251
<h3>Horizontal</h3>
5352

54-
<ol data-test-horizontal-demo-group
53+
<ol
54+
data-test-horizontal-demo-group
5555
{{sortable-group
56-
direction="x"
56+
direction='x'
5757
onChange=this.update
5858
itemVisualClass=this.itemVisualClass
5959
handleVisualClass=this.handleVisualClass
60-
groupName="horizontal"
60+
groupName='horizontal'
6161
}}
6262
>
63-
{{#each this.model.items as |item|}}
64-
<li data-test-horizontal-demo-handle tabindex={{"0"}} {{sortable-item model=item groupName="horizontal"}}>
63+
{{#each @model.items as |item|}}
64+
<li data-test-horizontal-demo-handle tabindex={{'0'}} {{sortable-item model=item groupName='horizontal'}}>
6565
<ItemPresenter @item={{item}} />
6666
</li>
6767
{{/each}}
6868
</ol>
6969
</section>
7070

71-
<section class="table-demo">
71+
<section class='table-demo'>
7272
<h3>Table</h3>
7373

7474
{{! template-lint-disable table-groups}}
@@ -79,23 +79,23 @@
7979
<th>Item</th>
8080
</tr>
8181
</thead>
82-
<tbody {{sortable-group onChange=this.update groupName="table"}}>
82+
<tbody {{sortable-group onChange=this.update groupName='table'}}>
8383
{{#each this.model.items as |item|}}
84-
<tr data-test-table-demo-item class="handle" {{sortable-item model=item groupName="table"}}>
85-
<td><span data-test-table-demo-handle data-item={{item}} class="handle">&vArr;</span></td>
84+
<tr data-test-table-demo-item class='handle' {{sortable-item model=item groupName='table'}}>
85+
<td><span data-test-table-demo-handle data-item={{item}} class='handle'>&vArr;</span></td>
8686
<td>{{item}}</td>
8787
</tr>
8888
{{/each}}
8989
</tbody>
9090
</table>
9191
</section>
9292

93-
<section class="vertical-spacing-demo">
93+
<section class='vertical-spacing-demo'>
9494
<h3>Vertical with 15px spacing</h3>
9595

96-
<ol {{sortable-group onChange=this.update groupName="verticle-15"}}>
96+
<ol {{sortable-group onChange=this.update groupName='verticle-15'}}>
9797
{{#each this.model.items as |item|}}
98-
<li {{sortable-item model=item spacing=15 groupName="verticle-15"}} tabindex="0">
98+
<li {{sortable-item model=item spacing=15 groupName='verticle-15'}} tabindex='0'>
9999
{{item}}
100100
<span data-test-vertical-spacing-demo-handle data-item={{item}}>
101101
</span>
@@ -104,12 +104,16 @@
104104
</ol>
105105
</section>
106106

107-
<section class="vertical-distance-demo">
107+
<section class='vertical-distance-demo'>
108108
<h3>Vertical with distance set to 15</h3>
109109

110-
<ol {{sortable-group onChange=this.update groupName="verticle-15d"}}>
110+
<ol {{sortable-group onChange=this.update groupName='verticle-15d'}}>
111111
{{#each this.model.items as |item|}}
112-
<li data-test-vertical-distance-demo-handle {{sortable-item model=item distance=15 groupName="verticle-15d"}} tabindex="0">
112+
<li
113+
data-test-vertical-distance-demo-handle
114+
{{sortable-item model=item distance=15 groupName='verticle-15d'}}
115+
tabindex='0'
116+
>
113117
{{item}}
114118
<span data-item={{item}}>
115119
</span>
@@ -118,15 +122,15 @@
118122
</ol>
119123
</section>
120124

121-
<section class="scrollable-demo">
125+
<section class='scrollable-demo'>
122126
<h3>Scrollable</h3>
123127

124-
<div class="sortable-container">
125-
<ol {{sortable-group onChange=this.update groupName="scrollable"}}>
128+
<div class='sortable-container'>
129+
<ol {{sortable-group onChange=this.update groupName='scrollable'}}>
126130
{{#each this.model.items as |item|}}
127-
<li data-test-scrollable-demo-handle {{sortable-item model=item groupName="scrollable"}}>
131+
<li data-test-scrollable-demo-handle {{sortable-item model=item groupName='scrollable'}}>
128132
{{item}}
129-
<span class="handle" data-item={{item}} {{sortable-handle}}>
133+
<span class='handle' data-item={{item}} {{sortable-handle}}>
130134
<span>&vArr;</span>
131135
</span>
132136
</li>
@@ -142,32 +146,29 @@
142146

143147
<footer>
144148
<p>
145-
<a href="https://github.com/adopted-ember-addons/ember-sortable">
149+
<a href='https://github.com/adopted-ember-addons/ember-sortable'>
146150
View on GitHub
147151
</a>
148152
</p>
149153
</footer>
150154
</article>
151-
<article class="demo-no-css">
152-
<section class="vertical-demo">
155+
<article class='demo-no-css'>
156+
<section class='vertical-demo'>
153157
<h3>Vertical</h3>
154158

155-
<ol
159+
<ol
156160
data-test-vertical-demo-group-no-css
157-
{{sortable-group
158-
onChange=this.update
159-
handleVisualClass=handleVisualClass
160-
groupName="verticle-no-css"}}>
161+
{{sortable-group onChange=this.update handleVisualClass=handleVisualClass groupName='verticle-no-css'}}
162+
>
161163
{{#each this.model.items as |item|}}
162-
<li data-test-scrollable-demo-handle-item-no-css {{sortable-item model=item groupName="verticle-no-css"}}>
164+
<li data-test-scrollable-demo-handle-item-no-css {{sortable-item model=item groupName='verticle-no-css'}}>
163165
{{item}}
164-
<span class="handle" data-test-vertical-demo-handle-no-css data-item={{item}} {{sortable-handle}}>
166+
<span class='handle' data-test-vertical-demo-handle-no-css data-item={{item}} {{sortable-handle}}>
165167
<span>&vArr;</span>
166168
</span>
167169
</li>
168170
{{/each}}
169171
</ol>
170172

171173
</section>
172-
</article>
173-
174+
</article>

‎tests/dummy/config/ember-cli-update.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
"outputRepo": "https://github.com/ember-cli/ember-addon-output",
1111
"codemodsSource": "ember-addon-codemods-manifest@1",
1212
"isBaseBlueprint": true,
13-
"options": [
14-
"--welcome",
15-
"--yarn"
16-
]
13+
"options": ["--welcome", "--yarn"]
1714
}
1815
]
1916
}

‎tests/dummy/config/targets.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
'use strict';
22

3-
const browsers = [
4-
'last 1 Chrome versions',
5-
'last 1 Firefox versions',
6-
'last 1 Safari versions',
7-
];
3+
const browsers = ['last 1 Chrome versions', 'last 1 Firefox versions', 'last 1 Safari versions'];
84

95
// Ember's browser support policy is changing, and IE11 support will end in
106
// v4.0 onwards.

‎tests/index.html

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<meta charset="utf-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
4+
<meta charset="utf-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
66
<title>Dummy Tests</title>
7-
<meta name="description" content="">
8-
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<meta name="description" content="" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1" />
99

10-
{{content-for "head"}}
11-
{{content-for "test-head"}}
10+
{{content-for "head"}} {{content-for "test-head"}}
1211

13-
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css">
14-
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css">
15-
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css">
12+
<link rel="stylesheet" href="{{rootURL}}assets/vendor.css" />
13+
<link rel="stylesheet" href="{{rootURL}}assets/dummy.css" />
14+
<link rel="stylesheet" href="{{rootURL}}assets/test-support.css" />
1615

17-
{{content-for "head-footer"}}
18-
{{content-for "test-head-footer"}}
16+
{{content-for "head-footer"}} {{content-for "test-head-footer"}}
1917
</head>
2018
<body>
21-
{{content-for "body"}}
22-
{{content-for "test-body"}}
19+
{{content-for "body"}} {{content-for "test-body"}}
2320

2421
<div id="qunit"></div>
2522
<div id="qunit-fixture">
@@ -34,7 +31,6 @@
3431
<script src="{{rootURL}}assets/dummy.js"></script>
3532
<script src="{{rootURL}}assets/tests.js"></script>
3633

37-
{{content-for "body-footer"}}
38-
{{content-for "test-body-footer"}}
34+
{{content-for "body-footer"}} {{content-for "test-body-footer"}}
3935
</body>
4036
</html>

‎tests/integration/modifiers/sortable-group-test.js

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
import { module, test } from 'qunit';
22
import { setupRenderingTest } from 'ember-qunit';
3-
import {
4-
settled,
5-
find,
6-
findAll,
7-
render,
8-
triggerKeyEvent,
9-
waitUntil,
10-
} from '@ember/test-helpers';
3+
import { settled, find, findAll, render, triggerKeyEvent, waitUntil } from '@ember/test-helpers';
114
import { set } from '@ember/object';
125
import { reorder } from 'ember-sortable/test-support/helpers';
136
import hbs from 'htmlbars-inline-precompile';
@@ -109,9 +102,7 @@ module('Integration | Modifier | sortable-group', function (hooks) {
109102
await announcerHasText();
110103
assert
111104
.dom(announcerSelector)
112-
.hasText(
113-
'item is moved to position, 2 of 3. Press Space to confirm new position, Escape to cancel.'
114-
);
105+
.hasText('item is moved to position, 2 of 3. Press Space to confirm new position, Escape to cancel.');
115106

116107
triggerKeyEvent('[data-test-handle=Uno]', 'keydown', 32) /* SPACE */;
117108

@@ -126,11 +117,7 @@ module('Integration | Modifier | sortable-group', function (hooks) {
126117
});
127118

128119
function contents(selector) {
129-
return find(selector)
130-
.textContent.replace(//g, '')
131-
.replace(/\s+/g, ' ')
132-
.replace(/^\s+/, '')
133-
.replace(/\s+$/, '');
120+
return find(selector).textContent.replace(//g, '').replace(/\s+/g, ' ').replace(/^\s+/, '').replace(/\s+$/, '');
134121
}
135122

136123
let announcerSelector = '#test-list + .visually-hidden';

‎tests/unit/services/ember-sortable-test.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ module('Unit | Service | ember-sortable', function (hooks) {
66
setupTest(hooks);
77

88
hooks.beforeEach(function () {
9-
this.sortableService = this.owner.lookup(
10-
'service:ember-sortable@ember-sortable'
11-
);
9+
this.sortableService = this.owner.lookup('service:ember-sortable@ember-sortable');
1210

1311
// While not truly a group modifier, the service just registers whatever object is passed
1412
this.groupModifier = {
@@ -48,10 +46,7 @@ module('Unit | Service | ember-sortable', function (hooks) {
4846
assert.ok(isArray(groupDef.items));
4947
assert.ok(groupDef.items.includes(this.sortableItem));
5048

51-
this.sortableService.deregisterItem(
52-
this.unregisteredGroupName,
53-
this.sortableItem
54-
);
49+
this.sortableService.deregisterItem(this.unregisteredGroupName, this.sortableItem);
5550
groupDef = this.sortableService.fetchGroup(this.groupName);
5651
assert.ok(groupDef.items.includes(this.sortableItem));
5752

@@ -67,10 +62,6 @@ module('Unit | Service | ember-sortable', function (hooks) {
6762
assert.ok(isArray(groupDef.items));
6863

6964
let groupDef2 = this.sortableService.fetchGroup(this.groupName);
70-
assert.strictEqual(
71-
groupDef,
72-
groupDef2,
73-
'Fetches the correct group is one exists'
74-
);
65+
assert.strictEqual(groupDef, groupDef2, 'Fetches the correct group is one exists');
7566
});
7667
});

‎yarn.lock

+302-15
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.