govuk_publishing_components 24.4.0 → 24.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/govuk_publishing_components/components/accordion.js +7 -5
  3. data/app/assets/javascripts/govuk_publishing_components/components/details.js +3 -2
  4. data/app/assets/javascripts/govuk_publishing_components/components/reorderable-list.js +108 -0
  5. data/app/assets/javascripts/govuk_publishing_components/lib/header-navigation.js +6 -2
  6. data/app/assets/javascripts/govuk_publishing_components/modules.js +3 -1
  7. data/app/assets/stylesheets/component_guide/application.scss +1 -1
  8. data/app/assets/stylesheets/govuk_publishing_components/_all_components.scss +1 -0
  9. data/app/assets/stylesheets/govuk_publishing_components/_all_components_print.scss +1 -1
  10. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-for-public.scss +10 -1
  11. data/app/assets/stylesheets/govuk_publishing_components/components/_layout-header.scss +8 -7
  12. data/app/assets/stylesheets/govuk_publishing_components/components/_reorderable-list.scss +117 -0
  13. data/app/assets/stylesheets/govuk_publishing_components/components/_search.scss +15 -1
  14. data/app/assets/stylesheets/govuk_publishing_components/components/_summary-list.scss +12 -0
  15. data/app/views/govuk_publishing_components/components/_layout_for_public.html.erb +48 -7
  16. data/app/views/govuk_publishing_components/components/_layout_header.html.erb +15 -12
  17. data/app/views/govuk_publishing_components/components/_list.html.erb +5 -5
  18. data/app/views/govuk_publishing_components/components/_reorderable_list.html.erb +45 -0
  19. data/app/views/govuk_publishing_components/components/_search.html.erb +27 -16
  20. data/app/views/govuk_publishing_components/components/_summary_list.html.erb +73 -31
  21. data/app/views/govuk_publishing_components/components/docs/contextual_sidebar.yml +3 -0
  22. data/app/views/govuk_publishing_components/components/docs/layout_for_public.yml +26 -0
  23. data/app/views/govuk_publishing_components/components/docs/reorderable_list.yml +85 -0
  24. data/app/views/govuk_publishing_components/components/docs/search.yml +10 -0
  25. data/app/views/govuk_publishing_components/components/docs/summary_list.yml +50 -19
  26. data/app/views/govuk_publishing_components/components/layout_header/_navigation_items.html.erb +8 -1
  27. data/app/views/govuk_publishing_components/components/layout_header/_search.html.erb +17 -3
  28. data/config/locales/en.yml +24 -16
  29. data/lib/govuk_publishing_components/presenters/contextual_navigation.rb +5 -0
  30. data/lib/govuk_publishing_components/version.rb +1 -1
  31. data/node_modules/sortablejs/LICENSE +21 -0
  32. data/node_modules/sortablejs/README.md +815 -0
  33. data/node_modules/sortablejs/Sortable.js +3721 -0
  34. data/node_modules/sortablejs/Sortable.min.js +2 -0
  35. data/node_modules/sortablejs/modular/sortable.complete.esm.js +3713 -0
  36. data/node_modules/sortablejs/modular/sortable.core.esm.js +3710 -0
  37. data/node_modules/sortablejs/modular/sortable.esm.js +3711 -0
  38. data/node_modules/sortablejs/package.json +56 -0
  39. metadata +18 -6
@@ -27,3 +27,29 @@ examples:
27
27
  description: This allows the header to be omitted which is currently used when rendering CSV previews from Whitehall
28
28
  data:
29
29
  omit_header: true
30
+ navigation:
31
+ description: Passes the navigation through to the [header component](/component-guide/layout_header/).
32
+ data:
33
+ show_search: false
34
+ navigation_items:
35
+ - text: Navigation item 1
36
+ href: "item-1"
37
+ active: true
38
+ - text: Navigation item 2
39
+ href: "item-2"
40
+ - text: Hidden on desktop
41
+ href: "item-3"
42
+ show_only_in_collapsed_menu: true
43
+ with_global_banner:
44
+ description: This allows the HTML for the global banner to be added to the page. This is only the slot for the global banner - the markup for the banner needs to be passed in.
45
+ data:
46
+ global_bar: <div class="govuk-!-padding-top-5 govuk-!-padding-bottom-3">This is the global bar slot</div>
47
+ with_emergency_banner:
48
+ description: This allows the HTML for the emergency banner to be added to the page in the correct place. This is only the slot for the emergency banner - the markup for the banner needs to be passed in.
49
+ data:
50
+ emergency_banner: <div class="govuk-!-padding-top-3 govuk-!-padding-bottom-3">This is the emergency banner slot</div>
51
+ with_global_and_emergency_banner:
52
+ description: Both global banner and emergency banner should be usable together.
53
+ data:
54
+ emergency_banner: <div class="govuk-!-padding-top-3 govuk-!-padding-bottom-3">This is the emergency banner slot</div>
55
+ global_bar: <div class="govuk-!-padding-top-5 govuk-!-padding-bottom-3">This is the global bar slot</div>
@@ -0,0 +1,85 @@
1
+ name: Reorderable list
2
+ description: A list of items that can be reordered
3
+ body: |
4
+ List items can be reordered by drag and drop or by using the up/down buttons.
5
+ On small viewports the drag and drop feature is disabled to prevent being triggered
6
+ when scrolling on touch devices.
7
+
8
+ This component uses SortableJS - a JavaScript library for drag and drop interactions.
9
+ When JavaScript is disabled a set of inputs will be shown allowing users to provide
10
+ an order index for each item.
11
+
12
+ When this component is embedded into a form and that form is submit you will receive a
13
+ parameter of `ordering` (which can be customised with the `input_name` option).
14
+ This will contain item ids and ordering positions in a hash.
15
+
16
+ For example, for two items with id "a" and "b" that are ordered accordingly,
17
+ you'd receive a submission of `ordering[a]=1&ordering[b]=2`, which Rails can
18
+ translate to `"ordering" => { "a" => "1", "b" => "2" }`.
19
+
20
+ accessibility_criteria: |
21
+ Buttons in this component must:
22
+
23
+ * be keyboard focusable
24
+ * inform the user about which item they operate on
25
+ * preserve focus after interacting with them
26
+ examples:
27
+ default:
28
+ data:
29
+ items:
30
+ - id: "ce99dd60-67dc-11eb-ae93-0242ac130002"
31
+ title: "Budget 2018"
32
+ - id: "d321cb86-67dc-11eb-ae93-0242ac130002"
33
+ title: "Budget 2018 (web)"
34
+ - id: "63a6d29e-6b6d-4157-9067-84c1a390e352"
35
+ title: "Impact on households: distributional analysis to accompany Budget 2018"
36
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
37
+ title: "Table 2.1: Budget 2018 policy decisions"
38
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
39
+ title: "Table 2.2: Measures announced at Autumn Budget 2017 or earlier that will take effect from November 2018 or later (£ million)"
40
+ with_description:
41
+ data:
42
+ items:
43
+ - id: "ce99dd60-67dc-11eb-ae93-0242ac130002"
44
+ title: "Budget 2018"
45
+ description: "PDF, 2.56MB, 48 pages"
46
+ - id: "d321cb86-67dc-11eb-ae93-0242ac130002"
47
+ title: "Budget 2018 (web)"
48
+ description: "HTML attachment"
49
+ - id: "63a6d29e-6b6d-4157-9067-84c1a390e352"
50
+ title: "Impact on households: distributional analysis to accompany Budget 2018"
51
+ description: "PDF, 592KB, 48 pages"
52
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
53
+ title: "Table 2.1: Budget 2018 policy decisions"
54
+ description: "MS Excel Spreadsheet, 248KB"
55
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
56
+ title: "Table 2.2: Measures announced at Autumn Budget 2017 or earlier that will take effect from November 2018 or later (£ million)"
57
+ description: "MS Excel Spreadsheet, 248KB"
58
+ within_form:
59
+ embed: |
60
+ <form>
61
+ <%= component %>
62
+ <button class="govuk-button" type="submit">Save order</button>
63
+ </form>
64
+ data:
65
+ items:
66
+ - id: "ce99dd60-67dc-11eb-ae93-0242ac130002"
67
+ title: "Budget 2018"
68
+ - id: "d321cb86-67dc-11eb-ae93-0242ac130002"
69
+ title: "Budget 2018 (web)"
70
+ - id: "63a6d29e-6b6d-4157-9067-84c1a390e352"
71
+ title: "Impact on households: distributional analysis to accompany Budget 2018"
72
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
73
+ title: "Table 2.1: Budget 2018 policy decisions"
74
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
75
+ title: "Table 2.2: Measures announced at Autumn Budget 2017 or earlier that will take effect from November 2018 or later (£ million)"
76
+ with_custom_input_name:
77
+ data:
78
+ input_name: "attachments[ordering]"
79
+ items:
80
+ - id: "5ebd75d7-6c37-4b93-b444-1b7c49757fb9"
81
+ title: "Budget 2018"
82
+ description: "PDF, 2.56MB, 48 pages"
83
+ - id: "0a4d377d-68f4-472f-b2e3-ef71dc750f85"
84
+ title: "Budget 2020"
85
+ description: "PDF, 2.56MB, 48 pages"
@@ -51,6 +51,16 @@ examples:
51
51
  with_aria_controls_attribute:
52
52
  description: |
53
53
  The aria-controls attribute is a 'relationship attribute' which denotes which elements in a page an interactive element or set of elements has control over and affects.
54
+
54
55
  For places like the finders where the page is updated dynamically after value changes to the input.
55
56
  data:
56
57
  aria_controls: "wrapper"
58
+ with_custom_button_text:
59
+ description: |
60
+ The search box component may be used multiple times on a page -- for example, on a [guidance and regulation finder results page](https://www.gov.uk/search/guidance-and-regulation?keywords=bananas&order=relevance) there is both the sitewide search in the header and also for the specific finder.
61
+
62
+ To avoid confusion, the text inside the button should be different for each form. This can be done by setting the `button_text` parameter.
63
+
64
+ This is visually hidden text -- to check for changes use a screen reader or inspect the button element.
65
+ data:
66
+ button_text: "Search absolutely everywhere"
@@ -35,6 +35,7 @@ examples:
35
35
  borderless: true
36
36
 
37
37
  with_edit_on_section:
38
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
38
39
  data:
39
40
  <<: *default-example-data
40
41
  edit:
@@ -43,6 +44,7 @@ examples:
43
44
  gtm: "edit-title-summary-body"
44
45
 
45
46
  with_delete_on_section:
47
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
46
48
  data:
47
49
  <<: *default-example-data
48
50
  delete:
@@ -51,6 +53,7 @@ examples:
51
53
  gtm: "delete-title-summary-body"
52
54
 
53
55
  with_edit_and_delete_on_section:
56
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
54
57
  data:
55
58
  <<: *default-example-data
56
59
  edit:
@@ -62,32 +65,45 @@ examples:
62
65
  data_attributes:
63
66
  gtm: "delete-title-summary-body"
64
67
 
68
+ with_customised_links:
69
+ description: |
70
+ For all links shown in the component, visually hidden text containing the name of the thing it refers to is automatically appended. This offers a better experience for screen reader users by making the link text unique and more explicit. In the example below, the link text would be `Change Title, summary and body`.
71
+
72
+ The text of the link can be customised using the `link_text` option. Take care that the provided `link_text` still makes sense to screen readers when combined with the title. For instance, `Reorder` link text and `Items` title becomes `Reorder Items`, which reads fine, but link text of `Summary` would read as `Summary Items`, which does not make sense.
73
+
74
+ To override this behaviour, use `link_text_no_enhance` on the link in question, as shown. This will remove the visually hidden text, allowing you to add your own. The component will render a `span` element with a class of `govuk-visually-hidden` included in a passed [capture block](https://apidock.com/rails/ActionView/Helpers/CaptureHelper/capture) as the `link_text` parameter.
75
+ data:
76
+ title: "Title, summary and body"
77
+ items:
78
+ - field: "Title"
79
+ value: "Rural conservation techniques"
80
+ edit:
81
+ href: "edit-title"
82
+ text: "Edit"
83
+ data_attributes:
84
+ gtm: "edit-title"
85
+ - field: "Body"
86
+ value: "Following the land use committee change to overreaching rural byelaws in 2009, further policies were adopted."
87
+ edit:
88
+ href: "edit-body"
89
+ link_text: "Edit"
90
+ delete:
91
+ href: "delete-body"
92
+ link_text: "Remove"
93
+ link_text_no_enhance: true
94
+ edit:
95
+ href: "edit-title-summary-body"
96
+ link_text: Edit this document <span class="govuk-visually-hidden">my hidden text for screenreaders</span>
97
+ link_text_no_enhance: true
98
+
65
99
  with_custom_section_heading:
66
100
  data:
67
101
  <<: *default-example-data
68
102
  heading_level: 2
69
103
  heading_size: l
70
104
 
71
- with_custom_link_on_section:
72
- description: |
73
- Take care that the provided `link_text` still makes sense to screen readers when combined with the title.
74
- For instance, `Reorder` link text and `Items` title becomes `Reorder Items`, which reads fine, but link text
75
- of `Summary` would read as `Summary Items`, which does not make sense.
76
- data:
77
- edit:
78
- href: "custom-link"
79
- link_text: "Reorder"
80
- title: "Items"
81
- items:
82
- - field: "Item 1"
83
- value: "Value 2"
84
- - field: "Item 2"
85
- value: "Value 2"
86
- - field: "Item 3"
87
- value: "Value 3"
88
-
89
105
  with_edit_on_individual_items:
90
- description: The link text can be optionally modified using the 'link_text' parameter, as for the edit link in previous examples.
106
+ description: For all links shown in the component, see the <a href="/component-guide/summary_list/with_customised_links">with customised links example</a> for guidance.
91
107
  data:
92
108
  title: "Title, summary and body"
93
109
  items:
@@ -113,6 +129,21 @@ examples:
113
129
  href: "delete-body"
114
130
  link_text: "Remove"
115
131
 
132
+ wide_title_layout:
133
+ description: Allows a slightly adjusted layout for longer text in the field name.
134
+ data:
135
+ title: Privacy settings
136
+ wide_title: true
137
+ items:
138
+ - field: "GOV.UK can use cookies while you’re signed in"
139
+ value: "No"
140
+ edit:
141
+ href: "edit-cookies"
142
+ - field: "GOV.UK can send you feedback emails"
143
+ value: "Yes"
144
+ edit:
145
+ href: "edit-feedback"
146
+
116
147
  with_block:
117
148
  description: Use the summary list with a block when you need to show an empty state message or load another component.
118
149
  data:
@@ -1,7 +1,14 @@
1
1
  <% navigation_aria_label ||= "Top level" %>
2
2
 
3
3
  <% if navigation_items.any? %>
4
- <button role="button" class="govuk-header__menu-button gem-c-header__menu-button govuk-js-header-toggle" aria-controls="navigation" aria-label="Show or hide Top Level Navigation">Menu</button>
4
+ <button
5
+ aria-controls="navigation"
6
+ aria-label="Show or hide Top Level Navigation"
7
+ class="govuk-header__menu-button govuk-js-header-toggle gem-c-header__menu-button"
8
+ type="button"
9
+ >
10
+ Menu
11
+ </button>
5
12
  <%= tag.nav class: "gem-c-header__nav", aria: { label: navigation_aria_label } do %>
6
13
  <ul id="navigation" class="govuk-header__navigation govuk-header__navigation--end">
7
14
  <% navigation_items.each_with_index do |item, index| %>
@@ -1,8 +1,22 @@
1
- <button class="search-toggle js-header-toggle" data-search-toggle-for="search">Show search</button>
2
- <form id="search" class="gem-c-layout-header__search-form govuk-clearfix" action="/search" method="get" role="search">
1
+ <button
2
+ class="search-toggle js-header-toggle"
3
+ data-search-toggle-for="search"
4
+ data-show-text="<%= t("components.layout_header.show_button") %>"
5
+ data-hide-text="<%= t("components.layout_header.hide_button") %>"
6
+ >
7
+ <%= t("components.layout_header.show_button") %>
8
+ </button>
9
+ <form
10
+ action="/search"
11
+ class="gem-c-layout-header__search-form govuk-clearfix"
12
+ id="search"
13
+ method="get"
14
+ role="search"
15
+ >
3
16
  <%= render "govuk_publishing_components/components/search", {
17
+ button_text: t("components.layout_header.search_button"),
4
18
  id: "site-search-text",
19
+ margin_bottom: 0,
5
20
  no_border: true,
6
- margin_bottom: 0
7
21
  } %>
8
22
  </form>
@@ -4,11 +4,11 @@
4
4
  #
5
5
  # To use the locales, use `I18n.t`:
6
6
  #
7
- # I18n.t 'hello'
7
+ # I18n.t "hello"
8
8
  #
9
9
  # In views, this is aliased to just `t`:
10
10
  #
11
- # <%= t('hello') %>
11
+ # <%= t("hello") %>
12
12
  #
13
13
  # To use a different locale, set it with `I18n.locale`:
14
14
  #
@@ -31,11 +31,11 @@ en:
31
31
  article_schema:
32
32
  scoped_search_description: "Search within %{title}"
33
33
  back_link:
34
- back: 'Back'
34
+ back: "Back"
35
35
  checkboxes:
36
- or: 'or'
36
+ or: "or"
37
37
  contents_list:
38
- contents: Contents
38
+ contents: "Contents"
39
39
  feedback:
40
40
  is_this_page_useful: "Is this page useful?"
41
41
  yes: "Yes"
@@ -54,10 +54,14 @@ en:
54
54
  what_wrong: "What went wrong?"
55
55
  send_me_survey: "Send me the survey"
56
56
  send: "Send"
57
+ layout_header:
58
+ search_button: "Search GOV.UK"
59
+ show_button: "Show search"
60
+ hide_button: "Hide search"
57
61
  organisation_schema:
58
62
  all_content_search_description: "Find all content from %{organisation}"
59
63
  radio:
60
- or: 'or'
64
+ or: "or"
61
65
  related_navigation:
62
66
  collections: "Collection"
63
67
  external_links: "Elsewhere on the web"
@@ -76,22 +80,26 @@ en:
76
80
  link_path: "/transition"
77
81
  link_text: "Check what you need to do"
78
82
  take_action_list:
79
- red: Check
80
- amber: Change
81
- green: Go
82
- aria_label: Brexit campaign slogan, Check, Change, Go.
83
+ red: "Check"
84
+ amber: "Change"
85
+ green: "Go"
86
+ aria_label: "Brexit campaign slogan, Check, Change, Go."
83
87
  related_footer_navigation:
84
88
  collections: "Collections"
85
89
  policies: "Policies"
86
90
  statistical_data_sets: "Statistical data sets"
87
91
  topical_events: "Topical events"
92
+ search_box:
93
+ search_button: "Search"
94
+ label: "Search on GOV.UK"
95
+ input_title: "Search"
88
96
  show_password:
89
- show: Show
90
- hide: Hide
91
- show_password: Show password
92
- hide_password: Hide password
93
- announce_show: Your password is shown
94
- announce_hide: Your password is hidden
97
+ show: "Show"
98
+ hide: "Hide"
99
+ show_password: "Show password"
100
+ hide_password: "Hide password"
101
+ announce_show: "Your password is shown"
102
+ announce_hide: "Your password is hidden"
95
103
  print_link:
96
104
  text: "Print this page"
97
105
  skip_link:
@@ -249,6 +249,10 @@ module GovukPublishingComponents
249
249
  false
250
250
  end
251
251
 
252
+ def brexit_cta_lang_allow_list?
253
+ %w[en cy].include?(content_item["locale"])
254
+ end
255
+
252
256
  def parent_taxon_include?(taxon, taxon_list)
253
257
  if taxon.present?
254
258
  if taxon.dig("links", "parent_taxons").to_a.any? { |taxon_item| taxon_list.include?(taxon_item["content_id"]) }
@@ -294,6 +298,7 @@ module GovukPublishingComponents
294
298
 
295
299
  def show_brexit_cta?
296
300
  brexit_cta_taxon_allow_list? &&
301
+ brexit_cta_lang_allow_list? &&
297
302
  step_by_step_count.zero? &&
298
303
  !brexit_cta_exception?
299
304
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "24.4.0".freeze
2
+ VERSION = "24.7.0".freeze
3
3
  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.