govuk_publishing_components 24.3.0 → 24.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/details.js +1 -1
  3. data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +108 -0
  4. data/app/assets/javascripts/govuk_publishing_components/components/show-password.js +7 -2
  5. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +6 -2
  6. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  7. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -1
  8. data/app/assets/stylesheets/govuk_publishing_components/components/_breadcrumbs.scss +11 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/components/_cookie-banner.scss +8 -1
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +117 -0
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +17 -13
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +12 -0
  13. data/app/models/govuk_publishing_components/audit_applications.rb +1 -1
  14. data/app/models/govuk_publishing_components/audit_comparer.rb +2 -2
  15. data/app/models/govuk_publishing_components/component_example.rb +4 -3
  16. data/app/views/govuk_publishing_components/components/_breadcrumbs.html.erb +8 -5
  17. data/app/views/govuk_publishing_components/components/_contents_list.html.erb +1 -1
  18. data/app/views/govuk_publishing_components/components/_cookie_banner.html.erb +6 -6
  19. data/app/views/govuk_publishing_components/components/_highlight_boxes.html.erb +1 -1
  20. data/app/views/govuk_publishing_components/components/_image_card.html.erb +1 -1
  21. data/app/views/govuk_publishing_components/components/_list.html.erb +5 -5
  22. data/app/views/govuk_publishing_components/components/_metadata.html.erb +1 -1
  23. data/app/views/govuk_publishing_components/components/_organisation_logo.html.erb +1 -1
  24. data/app/views/govuk_publishing_components/components/_previous_and_next_navigation.html.erb +1 -1
  25. data/app/views/govuk_publishing_components/components/_radio.html.erb +2 -1
  26. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +45 -0
  27. data/app/views/govuk_publishing_components/components/_search.html.erb +27 -16
  28. data/app/views/govuk_publishing_components/components/_share_links.html.erb +1 -1
  29. data/app/views/govuk_publishing_components/components/_show_password.html.erb +6 -4
  30. data/app/views/govuk_publishing_components/components/_step_by_step_nav_header.html.erb +1 -1
  31. data/app/views/govuk_publishing_components/components/_step_by_step_nav_related.html.erb +1 -1
  32. data/app/views/govuk_publishing_components/components/_subscription_links.html.erb +1 -1
  33. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +73 -31
  34. data/app/views/govuk_publishing_components/components/_taxonomy_list.html.erb +1 -1
  35. data/app/views/govuk_publishing_components/components/_translation_nav.html.erb +1 -1
  36. data/app/views/govuk_publishing_components/components/contextual_sidebar/_brexit_cta.html.erb +1 -1
  37. data/app/views/govuk_publishing_components/components/docs/breadcrumbs.yml +22 -0
  38. data/app/views/govuk_publishing_components/components/docs/inverse_header.yml +1 -1
  39. data/app/views/govuk_publishing_components/components/docs/radio.yml +14 -1
  40. data/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +85 -0
  41. data/app/views/govuk_publishing_components/components/docs/search.yml +10 -0
  42. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +33 -19
  43. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +2 -0
  44. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +17 -3
  45. data/app/views/govuk_publishing_components/components/related_navigation/_section.html.erb +2 -2
  46. data/config/locales/en.yml +25 -15
  47. data/lib/govuk_publishing_components/app_helpers/table_helper.rb +2 -1
  48. data/lib/govuk_publishing_components/presenters/machine_readable/faq_page_schema.rb +1 -1
  49. data/lib/govuk_publishing_components/presenters/machine_readable/html_publication_schema.rb +1 -7
  50. data/lib/govuk_publishing_components/presenters/meta_tags.rb +1 -2
  51. data/lib/govuk_publishing_components/presenters/related_navigation_helper.rb +2 -2
  52. data/lib/govuk_publishing_components/version.rb +1 -1
  53. data/lib/tasks/govuk_publishing_components_tasks.rake +1 -1
  54. data/node_modules/sortablejs/LICENSE +21 -0
  55. data/node_modules/sortablejs/README.md +815 -0
  56. data/node_modules/sortablejs/Sortable.js +3721 -0
  57. data/node_modules/sortablejs/Sortable.min.js +2 -0
  58. data/node_modules/sortablejs/modular/sortable.complete.esm.js +3713 -0
  59. data/node_modules/sortablejs/modular/sortable.core.esm.js +3710 -0
  60. data/node_modules/sortablejs/modular/sortable.esm.js +3711 -0
  61. data/node_modules/sortablejs/package.json +56 -0
  62. metadata +19 -7
@@ -1,12 +1,6 @@
1
1
  module GovukPublishingComponents
2
2
  module Presenters
3
3
  class HtmlPublicationSchema < FaqPageSchema
4
- attr_reader :page
5
-
6
- def initialize(page)
7
- @page = page
8
- end
9
-
10
4
  def structured_data
11
5
  return ArticleSchema.new(page).structured_data if less_than_two_headings_of_any_one_type?
12
6
 
@@ -55,7 +49,7 @@ module GovukPublishingComponents
55
49
  # {:a => :b, :b => :c}
56
50
  def pairs_hash(array)
57
51
  all_but_last = array[0..-2]
58
- all_but_first = array[1..-1]
52
+ all_but_first = array[1..]
59
53
  pairs = [all_but_last, all_but_first].transpose
60
54
  Hash[pairs]
61
55
  end
@@ -20,8 +20,7 @@ module GovukPublishingComponents
20
20
  meta_tags = add_organisation_tags(meta_tags)
21
21
  meta_tags = add_political_tags(meta_tags)
22
22
  meta_tags = add_taxonomy_tags(meta_tags)
23
- meta_tags = add_step_by_step_tags(meta_tags)
24
- meta_tags
23
+ add_step_by_step_tags(meta_tags)
25
24
  end
26
25
 
27
26
  private
@@ -58,14 +58,14 @@ module GovukPublishingComponents
58
58
  I18n.t(
59
59
  "components.related_#{@context}_navigation." + section_title,
60
60
  default: [
61
- I18n.t("components.related_navigation." + section_title),
61
+ I18n.t("components.related_navigation.#{section_title}"),
62
62
  section_title.tr("_", " "),
63
63
  ],
64
64
  )
65
65
  end
66
66
  end
67
67
 
68
- def section_css_class(css_class, section_title, link = {}, link_is_inline = false)
68
+ def section_css_class(css_class, section_title, link: {}, link_is_inline: false)
69
69
  css_classes = [css_class]
70
70
  css_classes << "#{css_class}--#{@context}" unless @context.nil?
71
71
  css_classes << "#{css_class}--inline" if link_is_inline
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "24.3.0".freeze
2
+ VERSION = "24.6.0".freeze
3
3
  end
@@ -14,7 +14,7 @@ namespace :component do
14
14
 
15
15
  if components_missing_docs.any?
16
16
  error = "You have components which are missing documentation. These components will not be displayed in the component guide:\n"
17
- components_missing_docs.each { |component| error += "\t" + component + "\n" }
17
+ components_missing_docs.each { |component| error += "\t#{component}\n" }
18
18
  error += "\n"
19
19
  raise NotImplementedError, error
20
20
  end
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 All contributors to Sortable
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,815 @@
1
+ # Sortable &nbsp; [![Financial Contributors on Open Collective](https://opencollective.com/Sortable/all/badge.svg?label=financial+contributors)](https://opencollective.com/Sortable) [![CircleCI](https://circleci.com/gh/SortableJS/Sortable.svg?style=svg)](https://circleci.com/gh/SortableJS/Sortable) [![DeepScan grade](https://deepscan.io/api/teams/3901/projects/5666/branches/43977/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=3901&pid=5666&bid=43977) [![](https://data.jsdelivr.com/v1/package/npm/sortablejs/badge)](https://www.jsdelivr.com/package/npm/sortablejs) [![npm](https://img.shields.io/npm/v/sortablejs.svg)](https://www.npmjs.com/package/sortablejs)
2
+
3
+ Sortable is a JavaScript library for reorderable drag-and-drop lists.
4
+
5
+ Demo: http://sortablejs.github.io/Sortable/
6
+
7
+ [<img width="250px" src="https://raw.githubusercontent.com/SortableJS/Sortable/HEAD/st/saucelabs.svg?sanitize=true">](https://saucelabs.com/)
8
+
9
+ ## Features
10
+
11
+ * Supports touch devices and [modern](http://caniuse.com/#search=drag) browsers (including IE9)
12
+ * Can drag from one list to another or within the same list
13
+ * CSS animation when moving items
14
+ * Supports drag handles *and selectable text* (better than voidberg's html5sortable)
15
+ * Smart auto-scrolling
16
+ * Advanced swap detection
17
+ * Smooth animations
18
+ * [Multi-drag](https://github.com/SortableJS/Sortable/tree/master/plugins/MultiDrag) support
19
+ * Support for CSS transforms
20
+ * Built using native HTML5 drag and drop API
21
+ * Supports
22
+ * [Meteor](https://github.com/SortableJS/meteor-sortablejs)
23
+ * Angular
24
+ * [2.0+](https://github.com/SortableJS/angular-sortablejs)
25
+ * [1.&ast;](https://github.com/SortableJS/angular-legacy-sortablejs)
26
+ * React
27
+ * [ES2015+](https://github.com/SortableJS/react-sortablejs)
28
+ * [Mixin](https://github.com/SortableJS/react-mixin-sortablejs)
29
+ * [Knockout](https://github.com/SortableJS/knockout-sortablejs)
30
+ * [Polymer](https://github.com/SortableJS/polymer-sortablejs)
31
+ * [Vue](https://github.com/SortableJS/Vue.Draggable)
32
+ * [Ember](https://github.com/SortableJS/ember-sortablejs)
33
+ * Supports any CSS library, e.g. [Bootstrap](#bs)
34
+ * Simple API
35
+ * Support for [plugins](#plugins)
36
+ * [CDN](#cdn)
37
+ * No jQuery required (but there is [support](https://github.com/SortableJS/jquery-sortablejs))
38
+ * Typescript definitions at `@types/sortablejs`
39
+
40
+
41
+ <br/>
42
+
43
+
44
+ ### Articles
45
+
46
+ * [Dragging Multiple Items in Sortable](https://github.com/SortableJS/Sortable/wiki/Dragging-Multiple-Items-in-Sortable) (April 26, 2019)
47
+ * [Swap Thresholds and Direction](https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction) (December 2, 2018)
48
+ * [Sortable v1.0 — New capabilities](https://github.com/SortableJS/Sortable/wiki/Sortable-v1.0-—-New-capabilities/) (December 22, 2014)
49
+ * [Sorting with the help of HTML5 Drag'n'Drop API](https://github.com/SortableJS/Sortable/wiki/Sorting-with-the-help-of-HTML5-Drag'n'Drop-API/) (December 23, 2013)
50
+
51
+ <br/>
52
+
53
+ ### Getting Started
54
+
55
+ Install with NPM:
56
+ ```bash
57
+ $ npm install sortablejs --save
58
+ ```
59
+
60
+ Install with Bower:
61
+ ```bash
62
+ $ bower install --save sortablejs
63
+ ```
64
+
65
+ Import into your project:
66
+ ```js
67
+ // Default SortableJS
68
+ import Sortable from 'sortablejs';
69
+
70
+ // Core SortableJS (without default plugins)
71
+ import Sortable from 'sortablejs/modular/sortable.core.esm.js';
72
+
73
+ // Complete SortableJS (with all plugins)
74
+ import Sortable from 'sortablejs/modular/sortable.complete.esm.js';
75
+ ```
76
+
77
+ Cherrypick plugins:
78
+ ```js
79
+ // Cherrypick extra plugins
80
+ import Sortable, { MultiDrag, Swap } from 'sortablejs';
81
+
82
+ Sortable.mount(new MultiDrag(), new Swap());
83
+
84
+
85
+ // Cherrypick default plugins
86
+ import Sortable, { AutoScroll } from 'sortablejs/modular/sortable.core.esm.js';
87
+
88
+ Sortable.mount(new AutoScroll());
89
+ ```
90
+
91
+
92
+ ---
93
+
94
+
95
+ ### Usage
96
+ ```html
97
+ <ul id="items">
98
+ <li>item 1</li>
99
+ <li>item 2</li>
100
+ <li>item 3</li>
101
+ </ul>
102
+ ```
103
+
104
+ ```js
105
+ var el = document.getElementById('items');
106
+ var sortable = Sortable.create(el);
107
+ ```
108
+
109
+ You can use any element for the list and its elements, not just `ul`/`li`. Here is an [example with `div`s](https://jsbin.com/visimub/edit?html,js,output).
110
+
111
+
112
+ ---
113
+
114
+
115
+ ### Options
116
+ ```js
117
+ var sortable = new Sortable(el, {
118
+ group: "name", // or { name: "...", pull: [true, false, 'clone', array], put: [true, false, array] }
119
+ sort: true, // sorting inside list
120
+ delay: 0, // time in milliseconds to define when the sorting should start
121
+ delayOnTouchOnly: false, // only delay if user is using touch
122
+ touchStartThreshold: 0, // px, how many pixels the point should move before cancelling a delayed drag event
123
+ disabled: false, // Disables the sortable if set to true.
124
+ store: null, // @see Store
125
+ animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
126
+ easing: "cubic-bezier(1, 0, 0, 1)", // Easing for animation. Defaults to null. See https://easings.net/ for examples.
127
+ handle: ".my-handle", // Drag handle selector within list items
128
+ filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function)
129
+ preventOnFilter: true, // Call `event.preventDefault()` when triggered `filter`
130
+ draggable: ".item", // Specifies which items inside the element should be draggable
131
+
132
+ dataIdAttr: 'data-id',
133
+
134
+ ghostClass: "sortable-ghost", // Class name for the drop placeholder
135
+ chosenClass: "sortable-chosen", // Class name for the chosen item
136
+ dragClass: "sortable-drag", // Class name for the dragging item
137
+
138
+ swapThreshold: 1, // Threshold of the swap zone
139
+ invertSwap: false, // Will always use inverted swap zone if set to true
140
+ invertedSwapThreshold: 1, // Threshold of the inverted swap zone (will be set to swapThreshold value by default)
141
+ direction: 'horizontal', // Direction of Sortable (will be detected automatically if not given)
142
+
143
+ forceFallback: false, // ignore the HTML5 DnD behaviour and force the fallback to kick in
144
+
145
+ fallbackClass: "sortable-fallback", // Class name for the cloned DOM Element when using forceFallback
146
+ fallbackOnBody: false, // Appends the cloned DOM Element into the Document's Body
147
+ fallbackTolerance: 0, // Specify in pixels how far the mouse should move before it's considered as a drag.
148
+
149
+ dragoverBubble: false,
150
+ removeCloneOnHide: true, // Remove the clone element when it is not showing, rather than just hiding it
151
+ emptyInsertThreshold: 5, // px, distance mouse must be from empty sortable to insert drag element into it
152
+
153
+
154
+ setData: function (/** DataTransfer */dataTransfer, /** HTMLElement*/dragEl) {
155
+ dataTransfer.setData('Text', dragEl.textContent); // `dataTransfer` object of HTML5 DragEvent
156
+ },
157
+
158
+ // Element is chosen
159
+ onChoose: function (/**Event*/evt) {
160
+ evt.oldIndex; // element index within parent
161
+ },
162
+
163
+ // Element is unchosen
164
+ onUnchoose: function(/**Event*/evt) {
165
+ // same properties as onEnd
166
+ },
167
+
168
+ // Element dragging started
169
+ onStart: function (/**Event*/evt) {
170
+ evt.oldIndex; // element index within parent
171
+ },
172
+
173
+ // Element dragging ended
174
+ onEnd: function (/**Event*/evt) {
175
+ var itemEl = evt.item; // dragged HTMLElement
176
+ evt.to; // target list
177
+ evt.from; // previous list
178
+ evt.oldIndex; // element's old index within old parent
179
+ evt.newIndex; // element's new index within new parent
180
+ evt.oldDraggableIndex; // element's old index within old parent, only counting draggable elements
181
+ evt.newDraggableIndex; // element's new index within new parent, only counting draggable elements
182
+ evt.clone // the clone element
183
+ evt.pullMode; // when item is in another sortable: `"clone"` if cloning, `true` if moving
184
+ },
185
+
186
+ // Element is dropped into the list from another list
187
+ onAdd: function (/**Event*/evt) {
188
+ // same properties as onEnd
189
+ },
190
+
191
+ // Changed sorting within list
192
+ onUpdate: function (/**Event*/evt) {
193
+ // same properties as onEnd
194
+ },
195
+
196
+ // Called by any change to the list (add / update / remove)
197
+ onSort: function (/**Event*/evt) {
198
+ // same properties as onEnd
199
+ },
200
+
201
+ // Element is removed from the list into another list
202
+ onRemove: function (/**Event*/evt) {
203
+ // same properties as onEnd
204
+ },
205
+
206
+ // Attempt to drag a filtered element
207
+ onFilter: function (/**Event*/evt) {
208
+ var itemEl = evt.item; // HTMLElement receiving the `mousedown|tapstart` event.
209
+ },
210
+
211
+ // Event when you move an item in the list or between lists
212
+ onMove: function (/**Event*/evt, /**Event*/originalEvent) {
213
+ // Example: https://jsbin.com/nawahef/edit?js,output
214
+ evt.dragged; // dragged HTMLElement
215
+ evt.draggedRect; // DOMRect {left, top, right, bottom}
216
+ evt.related; // HTMLElement on which have guided
217
+ evt.relatedRect; // DOMRect
218
+ evt.willInsertAfter; // Boolean that is true if Sortable will insert drag element after target by default
219
+ originalEvent.clientY; // mouse position
220
+ // return false; — for cancel
221
+ // return -1; — insert before target
222
+ // return 1; — insert after target
223
+ // return true; — keep default insertion point based on the direction
224
+ // return void; — keep default insertion point based on the direction
225
+ },
226
+
227
+ // Called when creating a clone of element
228
+ onClone: function (/**Event*/evt) {
229
+ var origEl = evt.item;
230
+ var cloneEl = evt.clone;
231
+ },
232
+
233
+ // Called when dragging element changes position
234
+ onChange: function(/**Event*/evt) {
235
+ evt.newIndex // most likely why this event is used is to get the dragging element's current index
236
+ // same properties as onEnd
237
+ }
238
+ });
239
+ ```
240
+
241
+
242
+ ---
243
+
244
+
245
+ #### `group` option
246
+ To drag elements from one list into another, both lists must have the same `group` value.
247
+ You can also define whether lists can give away, give and keep a copy (`clone`), and receive elements.
248
+
249
+ * name: `String` — group name
250
+ * pull: `true|false|["foo", "bar"]|'clone'|function` — ability to move from the list. `clone` — copy the item, rather than move. Or an array of group names which the elements may be put in. Defaults to `true`.
251
+ * put: `true|false|["baz", "qux"]|function` — whether elements can be added from other lists, or an array of group names from which elements can be added.
252
+ * revertClone: `boolean` — revert cloned element to initial position after moving to a another list.
253
+
254
+
255
+ Demo:
256
+ - https://jsbin.com/hijetos/edit?js,output
257
+ - https://jsbin.com/nacoyah/edit?js,output — use of complex logic in the `pull` and` put`
258
+ - https://jsbin.com/bifuyab/edit?js,output — use `revertClone: true`
259
+
260
+
261
+ ---
262
+
263
+
264
+ #### `sort` option
265
+ Allow sorting inside list.
266
+
267
+ Demo: https://jsbin.com/jayedig/edit?js,output
268
+
269
+
270
+ ---
271
+
272
+
273
+ #### `delay` option
274
+ Time in milliseconds to define when the sorting should start.
275
+ Unfortunately, due to browser restrictions, delaying is not possible on IE or Edge with native drag & drop.
276
+
277
+ Demo: https://jsbin.com/zosiwah/edit?js,output
278
+
279
+
280
+ ---
281
+
282
+
283
+ #### `delayOnTouchOnly` option
284
+ Whether or not the delay should be applied only if the user is using touch (eg. on a mobile device). No delay will be applied in any other case. Defaults to `false`.
285
+
286
+
287
+ ---
288
+
289
+
290
+ #### `swapThreshold` option
291
+ Percentage of the target that the swap zone will take up, as a float between `0` and `1`.
292
+
293
+ [Read more](https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#swap-threshold)
294
+
295
+ Demo: http://sortablejs.github.io/Sortable#thresholds
296
+
297
+
298
+ ---
299
+
300
+
301
+ #### `invertSwap` option
302
+ Set to `true` to set the swap zone to the sides of the target, for the effect of sorting "in between" items.
303
+
304
+ [Read more](https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#forcing-inverted-swap-zone)
305
+
306
+ Demo: http://sortablejs.github.io/Sortable#thresholds
307
+
308
+
309
+ ---
310
+
311
+
312
+ #### `invertedSwapThreshold` option
313
+ Percentage of the target that the inverted swap zone will take up, as a float between `0` and `1`. If not given, will default to `swapThreshold`.
314
+
315
+ [Read more](https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#dealing-with-swap-glitching)
316
+
317
+
318
+ ---
319
+
320
+
321
+ #### `direction` option
322
+ Direction that the Sortable should sort in. Can be set to `'vertical'`, `'horizontal'`, or a function, which will be called whenever a target is dragged over. Must return `'vertical'` or `'horizontal'`.
323
+
324
+ [Read more](https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#direction)
325
+
326
+
327
+ Example of direction detection for vertical list that includes full column and half column elements:
328
+
329
+ ```js
330
+ Sortable.create(el, {
331
+ direction: function(evt, target, dragEl) {
332
+ if (target !== null && target.className.includes('half-column') && dragEl.className.includes('half-column')) {
333
+ return 'horizontal';
334
+ }
335
+ return 'vertical';
336
+ }
337
+ });
338
+ ```
339
+
340
+
341
+ ---
342
+
343
+
344
+ #### `touchStartThreshold` option
345
+ This option is similar to `fallbackTolerance` option.
346
+
347
+ When the `delay` option is set, some phones with very sensitive touch displays like the Samsung Galaxy S8 will fire
348
+ unwanted touchmove events even when your finger is not moving, resulting in the sort not triggering.
349
+
350
+ This option sets the minimum pointer movement that must occur before the delayed sorting is cancelled.
351
+
352
+ Values between 3 to 5 are good.
353
+
354
+
355
+ ---
356
+
357
+
358
+ #### `disabled` options
359
+ Disables the sortable if set to `true`.
360
+
361
+ Demo: https://jsbin.com/sewokud/edit?js,output
362
+
363
+ ```js
364
+ var sortable = Sortable.create(list);
365
+
366
+ document.getElementById("switcher").onclick = function () {
367
+ var state = sortable.option("disabled"); // get
368
+
369
+ sortable.option("disabled", !state); // set
370
+ };
371
+ ```
372
+
373
+
374
+ ---
375
+
376
+
377
+ #### `handle` option
378
+ To make list items draggable, Sortable disables text selection by the user.
379
+ That's not always desirable. To allow text selection, define a drag handler,
380
+ which is an area of every list element that allows it to be dragged around.
381
+
382
+ Demo: https://jsbin.com/numakuh/edit?html,js,output
383
+
384
+ ```js
385
+ Sortable.create(el, {
386
+ handle: ".my-handle"
387
+ });
388
+ ```
389
+
390
+ ```html
391
+ <ul>
392
+ <li><span class="my-handle">::</span> list item text one
393
+ <li><span class="my-handle">::</span> list item text two
394
+ </ul>
395
+ ```
396
+
397
+ ```css
398
+ .my-handle {
399
+ cursor: move;
400
+ cursor: -webkit-grabbing;
401
+ }
402
+ ```
403
+
404
+
405
+ ---
406
+
407
+
408
+ #### `filter` option
409
+
410
+
411
+ ```js
412
+ Sortable.create(list, {
413
+ filter: ".js-remove, .js-edit",
414
+ onFilter: function (evt) {
415
+ var item = evt.item,
416
+ ctrl = evt.target;
417
+
418
+ if (Sortable.utils.is(ctrl, ".js-remove")) { // Click on remove button
419
+ item.parentNode.removeChild(item); // remove sortable item
420
+ }
421
+ else if (Sortable.utils.is(ctrl, ".js-edit")) { // Click on edit link
422
+ // ...
423
+ }
424
+ }
425
+ })
426
+ ```
427
+
428
+
429
+ ---
430
+
431
+
432
+ #### `ghostClass` option
433
+ Class name for the drop placeholder (default `sortable-ghost`).
434
+
435
+ Demo: https://jsbin.com/henuyiw/edit?css,js,output
436
+
437
+ ```css
438
+ .ghost {
439
+ opacity: 0.4;
440
+ }
441
+ ```
442
+
443
+ ```js
444
+ Sortable.create(list, {
445
+ ghostClass: "ghost"
446
+ });
447
+ ```
448
+
449
+
450
+ ---
451
+
452
+
453
+ #### `chosenClass` option
454
+ Class name for the chosen item (default `sortable-chosen`).
455
+
456
+ Demo: https://jsbin.com/hoqufox/edit?css,js,output
457
+
458
+ ```css
459
+ .chosen {
460
+ color: #fff;
461
+ background-color: #c00;
462
+ }
463
+ ```
464
+
465
+ ```js
466
+ Sortable.create(list, {
467
+ delay: 500,
468
+ chosenClass: "chosen"
469
+ });
470
+ ```
471
+
472
+
473
+ ---
474
+
475
+
476
+ #### `forceFallback` option
477
+ If set to `true`, the Fallback for non HTML5 Browser will be used, even if we are using an HTML5 Browser.
478
+ This gives us the possibility to test the behaviour for older Browsers even in newer Browser, or make the Drag 'n Drop feel more consistent between Desktop , Mobile and old Browsers.
479
+
480
+ On top of that, the Fallback always generates a copy of that DOM Element and appends the class `fallbackClass` defined in the options. This behaviour controls the look of this 'dragged' Element.
481
+
482
+ Demo: https://jsbin.com/sibiput/edit?html,css,js,output
483
+
484
+
485
+ ---
486
+
487
+
488
+ #### `fallbackTolerance` option
489
+ Emulates the native drag threshold. Specify in pixels how far the mouse should move before it's considered as a drag.
490
+ Useful if the items are also clickable like in a list of links.
491
+
492
+ When the user clicks inside a sortable element, it's not uncommon for your hand to move a little between the time you press and the time you release.
493
+ Dragging only starts if you move the pointer past a certain tolerance, so that you don't accidentally start dragging every time you click.
494
+
495
+ 3 to 5 are probably good values.
496
+
497
+
498
+ ---
499
+
500
+
501
+ #### `dragoverBubble` option
502
+ If set to `true`, the dragover event will bubble to parent sortables. Works on both fallback and native dragover event.
503
+ By default, it is false, but Sortable will only stop bubbling the event once the element has been inserted into a parent Sortable, or *can* be inserted into a parent Sortable, but isn't at that specific time (due to animation, etc).
504
+
505
+ Since 1.8.0, you will probably want to leave this option as false. Before 1.8.0, it may need to be `true` for nested sortables to work.
506
+
507
+
508
+ ---
509
+
510
+
511
+ #### `removeCloneOnHide` option
512
+ If set to `false`, the clone is hidden by having it's CSS `display` property set to `none`.
513
+ By default, this option is `true`, meaning Sortable will remove the cloned element from the DOM when it is supposed to be hidden.
514
+
515
+
516
+ ---
517
+
518
+
519
+ #### `emptyInsertThreshold` option
520
+ The distance (in pixels) the mouse must be from an empty sortable while dragging for the drag element to be inserted into that sortable. Defaults to `5`. Set to `0` to disable this feature.
521
+
522
+ Demo: https://jsbin.com/becavoj/edit?js,output
523
+
524
+
525
+ ---
526
+ ### Event object ([demo](https://jsbin.com/fogujiv/edit?js,output))
527
+
528
+ - to:`HTMLElement` — list, in which moved element
529
+ - from:`HTMLElement` — previous list
530
+ - item:`HTMLElement` — dragged element
531
+ - clone:`HTMLElement`
532
+ - oldIndex:`Number|undefined` — old index within parent
533
+ - newIndex:`Number|undefined` — new index within parent
534
+ - oldDraggableIndex: `Number|undefined` — old index within parent, only counting draggable elements
535
+ - newDraggableIndex: `Number|undefined` — new index within parent, only counting draggable elements
536
+ - pullMode:`String|Boolean|undefined` — Pull mode if dragging into another sortable (`"clone"`, `true`, or `false`), otherwise undefined
537
+
538
+
539
+ #### `move` event object
540
+ - to:`HTMLElement`
541
+ - from:`HTMLElement`
542
+ - dragged:`HTMLElement`
543
+ - draggedRect:`DOMRect`
544
+ - related:`HTMLElement` — element on which have guided
545
+ - relatedRect:`DOMRect`
546
+ - willInsertAfter:`Boolean` — `true` if will element be inserted after target (or `false` if before)
547
+
548
+
549
+ ---
550
+
551
+
552
+ ### Method
553
+
554
+
555
+ ##### option(name:`String`[, value:`*`]):`*`
556
+ Get or set the option.
557
+
558
+
559
+
560
+ ##### closest(el:`HTMLElement`[, selector:`String`]):`HTMLElement|null`
561
+ For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
562
+
563
+
564
+ ##### toArray():`String[]`
565
+ Serializes the sortable's item `data-id`'s (`dataIdAttr` option) into an array of string.
566
+
567
+
568
+ ##### sort(order:`String[]`, useAnimation:`Boolean`)
569
+ Sorts the elements according to the array.
570
+
571
+ ```js
572
+ var order = sortable.toArray();
573
+ sortable.sort(order.reverse(), true); // apply
574
+ ```
575
+
576
+
577
+ ##### save()
578
+ Save the current sorting (see [store](#store))
579
+
580
+
581
+ ##### destroy()
582
+ Removes the sortable functionality completely.
583
+
584
+
585
+ ---
586
+
587
+
588
+ <a name="store"></a>
589
+ ### Store
590
+ Saving and restoring of the sort.
591
+
592
+ ```html
593
+ <ul>
594
+ <li data-id="1">order</li>
595
+ <li data-id="2">save</li>
596
+ <li data-id="3">restore</li>
597
+ </ul>
598
+ ```
599
+
600
+ ```js
601
+ Sortable.create(el, {
602
+ group: "localStorage-example",
603
+ store: {
604
+ /**
605
+ * Get the order of elements. Called once during initialization.
606
+ * @param {Sortable} sortable
607
+ * @returns {Array}
608
+ */
609
+ get: function (sortable) {
610
+ var order = localStorage.getItem(sortable.options.group.name);
611
+ return order ? order.split('|') : [];
612
+ },
613
+
614
+ /**
615
+ * Save the order of elements. Called onEnd (when the item is dropped).
616
+ * @param {Sortable} sortable
617
+ */
618
+ set: function (sortable) {
619
+ var order = sortable.toArray();
620
+ localStorage.setItem(sortable.options.group.name, order.join('|'));
621
+ }
622
+ }
623
+ })
624
+ ```
625
+
626
+
627
+ ---
628
+
629
+
630
+ <a name="bs"></a>
631
+ ### Bootstrap
632
+ Demo: https://jsbin.com/visimub/edit?html,js,output
633
+
634
+ ```html
635
+ <!-- Latest compiled and minified CSS -->
636
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
637
+
638
+
639
+ <!-- Latest Sortable -->
640
+ <script src="http://SortableJS.github.io/Sortable/Sortable.js"></script>
641
+
642
+
643
+ <!-- Simple List -->
644
+ <ul id="simpleList" class="list-group">
645
+ <li class="list-group-item">This is <a href="http://SortableJS.github.io/Sortable/">Sortable</a></li>
646
+ <li class="list-group-item">It works with Bootstrap...</li>
647
+ <li class="list-group-item">...out of the box.</li>
648
+ <li class="list-group-item">It has support for touch devices.</li>
649
+ <li class="list-group-item">Just drag some elements around.</li>
650
+ </ul>
651
+
652
+ <script>
653
+ // Simple list
654
+ Sortable.create(simpleList, { /* options */ });
655
+ </script>
656
+ ```
657
+
658
+
659
+ ---
660
+
661
+
662
+ ### Static methods & properties
663
+
664
+
665
+
666
+ ##### Sortable.create(el:`HTMLElement`[, options:`Object`]):`Sortable`
667
+ Create new instance.
668
+
669
+
670
+ ---
671
+
672
+
673
+ ##### Sortable.active:`Sortable`
674
+ The active Sortable instance.
675
+
676
+
677
+ ---
678
+
679
+
680
+ ##### Sortable.dragged:`HTMLElement`
681
+ The element being dragged.
682
+
683
+
684
+ ---
685
+
686
+
687
+ ##### Sortable.ghost:`HTMLElement`
688
+ The ghost element.
689
+
690
+
691
+ ---
692
+
693
+
694
+ ##### Sortable.clone:`HTMLElement`
695
+ The clone element.
696
+
697
+
698
+ ---
699
+
700
+
701
+ ##### Sortable.get(element:`HTMLElement`):`Sortable`
702
+ Get the Sortable instance on an element.
703
+
704
+
705
+ ---
706
+
707
+
708
+ ##### Sortable.mount(plugin:`...SortablePlugin|SortablePlugin[]`)
709
+ Mounts a plugin to Sortable.
710
+
711
+
712
+ ---
713
+
714
+
715
+ ##### Sortable.utils
716
+ * on(el`:HTMLElement`, event`:String`, fn`:Function`) — attach an event handler function
717
+ * off(el`:HTMLElement`, event`:String`, fn`:Function`) — remove an event handler
718
+ * css(el`:HTMLElement`)`:Object` — get the values of all the CSS properties
719
+ * css(el`:HTMLElement`, prop`:String`)`:Mixed` — get the value of style properties
720
+ * css(el`:HTMLElement`, prop`:String`, value`:String`) — set one CSS properties
721
+ * css(el`:HTMLElement`, props`:Object`) — set more CSS properties
722
+ * find(ctx`:HTMLElement`, tagName`:String`[, iterator`:Function`])`:Array` — get elements by tag name
723
+ * bind(ctx`:Mixed`, fn`:Function`)`:Function` — Takes a function and returns a new one that will always have a particular context
724
+ * is(el`:HTMLElement`, selector`:String`)`:Boolean` — check the current matched set of elements against a selector
725
+ * closest(el`:HTMLElement`, selector`:String`[, ctx`:HTMLElement`])`:HTMLElement|Null` — for each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree
726
+ * clone(el`:HTMLElement`)`:HTMLElement` — create a deep copy of the set of matched elements
727
+ * toggleClass(el`:HTMLElement`, name`:String`, state`:Boolean`) — add or remove one classes from each element
728
+ * detectDirection(el`:HTMLElement`)`:String` — automatically detect the [direction](https://github.com/SortableJS/Sortable/wiki/Swap-Thresholds-and-Direction#direction) of the element as either `'vertical'` or `'horizontal'`
729
+
730
+
731
+ ---
732
+
733
+
734
+ ### Plugins
735
+ #### Extra Plugins (included in complete versions)
736
+ - [MultiDrag](https://github.com/SortableJS/Sortable/tree/master/plugins/MultiDrag)
737
+ - [Swap](https://github.com/SortableJS/Sortable/tree/master/plugins/Swap)
738
+
739
+ #### Default Plugins (included in default versions)
740
+ - [AutoScroll](https://github.com/SortableJS/Sortable/tree/master/plugins/AutoScroll)
741
+ - [OnSpill](https://github.com/SortableJS/Sortable/tree/master/plugins/OnSpill)
742
+
743
+
744
+ ---
745
+
746
+
747
+ <a name="cdn"></a>
748
+ ### CDN
749
+
750
+ ```html
751
+ <!-- jsDelivr :: Sortable :: Latest (https://www.jsdelivr.com/package/npm/sortablejs) -->
752
+ <script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
753
+ ```
754
+
755
+
756
+ ---
757
+
758
+
759
+ ### Contributing (Issue/PR)
760
+
761
+ Please, [read this](CONTRIBUTING.md).
762
+
763
+
764
+ ---
765
+
766
+
767
+ ## Contributors
768
+
769
+ ### Code Contributors
770
+
771
+ This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
772
+ <a href="https://github.com/SortableJS/Sortable/graphs/contributors"><img src="https://opencollective.com/Sortable/contributors.svg?width=890&button=false" /></a>
773
+
774
+ ### Financial Contributors
775
+
776
+ Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/Sortable/contribute)]
777
+
778
+ #### Individuals
779
+
780
+ <a href="https://opencollective.com/Sortable"><img src="https://opencollective.com/Sortable/individuals.svg?width=890"></a>
781
+
782
+ #### Organizations
783
+
784
+ Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/Sortable/contribute)]
785
+
786
+ <a href="https://opencollective.com/Sortable/organization/0/website"><img src="https://opencollective.com/Sortable/organization/0/avatar.svg"></a>
787
+ <a href="https://opencollective.com/Sortable/organization/1/website"><img src="https://opencollective.com/Sortable/organization/1/avatar.svg"></a>
788
+ <a href="https://opencollective.com/Sortable/organization/2/website"><img src="https://opencollective.com/Sortable/organization/2/avatar.svg"></a>
789
+ <a href="https://opencollective.com/Sortable/organization/3/website"><img src="https://opencollective.com/Sortable/organization/3/avatar.svg"></a>
790
+ <a href="https://opencollective.com/Sortable/organization/4/website"><img src="https://opencollective.com/Sortable/organization/4/avatar.svg"></a>
791
+ <a href="https://opencollective.com/Sortable/organization/5/website"><img src="https://opencollective.com/Sortable/organization/5/avatar.svg"></a>
792
+ <a href="https://opencollective.com/Sortable/organization/6/website"><img src="https://opencollective.com/Sortable/organization/6/avatar.svg"></a>
793
+ <a href="https://opencollective.com/Sortable/organization/7/website"><img src="https://opencollective.com/Sortable/organization/7/avatar.svg"></a>
794
+ <a href="https://opencollective.com/Sortable/organization/8/website"><img src="https://opencollective.com/Sortable/organization/8/avatar.svg"></a>
795
+ <a href="https://opencollective.com/Sortable/organization/9/website"><img src="https://opencollective.com/Sortable/organization/9/avatar.svg"></a>
796
+
797
+ ## MIT LICENSE
798
+ Permission is hereby granted, free of charge, to any person obtaining
799
+ a copy of this software and associated documentation files (the
800
+ "Software"), to deal in the Software without restriction, including
801
+ without limitation the rights to use, copy, modify, merge, publish,
802
+ distribute, sublicense, and/or sell copies of the Software, and to
803
+ permit persons to whom the Software is furnished to do so, subject to
804
+ the following conditions:
805
+
806
+ The above copyright notice and this permission notice shall be
807
+ included in all copies or substantial portions of the Software.
808
+
809
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
810
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
811
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
812
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
813
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
814
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
815
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.