The basics
-- Select2 can take a regular select box like this... -
++ Select2 can take a regular select box like this... +
-- -
++ +
-- and turn it into this... -
++ and turn it into this... +
-- -
-diff --git a/docs/_includes/nav/examples.html b/docs/_includes/nav/examples.html new file mode 100644 index 00000000..c2e2b301 --- /dev/null +++ b/docs/_includes/nav/examples.html @@ -0,0 +1,67 @@ + diff --git a/docs/_sass/_prettify.scss b/docs/_sass/_prettify.scss index bb85b289..830860d4 100644 --- a/docs/_sass/_prettify.scss +++ b/docs/_sass/_prettify.scss @@ -28,11 +28,11 @@ padding: 9px 14px; margin-bottom: 20px; margin-top: 20px; - border: 1px solid #e8e8e8; + border: 1px solid #eee; &.linenums { - -webkit-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; - -moz-box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; - box-shadow: inset 40px 0 0 #fbfbfc, inset 41px 0 0 #ececf0; + -webkit-box-shadow: inset 40px 0 0 #fbfbfb, inset 41px 0 0 #f6f6f6; + -moz-box-shadow: inset 40px 0 0 #fbfbfb, inset 41px 0 0 #f6f6f6; + box-shadow: inset 40px 0 0 #fbfbfb, inset 41px 0 0 #f6f6f6; } } @@ -42,6 +42,6 @@ ol.linenums { } ol.linenums li { padding-left: 12px; - color: #bebec5; + color: #bebebe; line-height: 18px; } diff --git a/docs/_sass/_s2-docs-examples.scss b/docs/_sass/_s2-docs-examples.scss new file mode 100644 index 00000000..ce1440b4 --- /dev/null +++ b/docs/_sass/_s2-docs-examples.scss @@ -0,0 +1,83 @@ +.s2-example + pre, +.s2-event-log + pre { + margin: -15px -15px 15px; + border-radius: 0; + border-width: 0 0 1px; +} + +@media (min-width: 768px) { + .s2-example + pre, + .s2-event-log + pre { + margin-top: -16px; + margin-left: 0; + margin-right: 0; + border-width: 1px; + border-bottom-left-radius: 4px; + border-bottom-right-radius: 4px; + } +} + +.s2-event-log { + background: #002451; + font-family: Menlo, 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', Monaco, Consolas, monospace; + color: white; + position: relative; + padding: 45px 15px 15px; + margin: 0 -15px 15px; +} + +.s2-event-log:after { + content: "Event Log"; + position: absolute; + top: 15px; + left: 15px; + font-size: 12px; + font-weight: bold; + color: #BBB; + text-transform: uppercase; + letter-spacing: 1px; +} + +.s2-example { + position: relative; + padding: 45px 15px 15px; + margin: 0 -15px 15px; + background-color: #FAFAFA; + box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.05); + border-color: #E5E5E5 #EEE #EEE; + border-style: solid; + border-width: 1px 0; +} + +@media (min-width: 768px) { + .s2-example { + margin-left: 0; + margin-right: 0; + background-color: #FFF; + border-width: 1px; + border-color: #eee; + border-radius: 4px 4px 0 0; + box-shadow: none; + } + + .s2-event-log { + margin-left: 0; + margin-right: 0; + margin-top: -15px; + border-width: 1px; + border-color: #eee; + box-shadow: none; + } +} + +.s2-example:after { + content: "Example"; + position: absolute; + top: 15px; + left: 15px; + font-size: 12px; + font-weight: bold; + color: #BBB; + text-transform: uppercase; + letter-spacing: 1px; +} diff --git a/docs/css/s2-docs.scss b/docs/css/s2-docs.scss index 47cbbe9b..a11e67c3 100644 --- a/docs/css/s2-docs.scss +++ b/docs/css/s2-docs.scss @@ -8,6 +8,7 @@ @import "s2-docs-footer"; @import "s2-docs-alert"; @import "s2-docs-home"; +@import "s2-docs-examples"; @import "anchorjs"; @import "jumbotron"; @import "prettify"; @@ -62,11 +63,3 @@ pre { background-color: #f7f7f9; border: 1px solid #e1e1e8; } - -.s2-docs-headline-example { - font-size: 12px; - font-weight: 700; - color: #959595; - text-transform: uppercase; - letter-spacing: 1px; -} diff --git a/docs/examples.html b/docs/examples.html index 6737109f..46b5f5fc 100644 --- a/docs/examples.html +++ b/docs/examples.html @@ -26,30 +26,30 @@ slug: examples
- Select2 can take a regular select box like this... -
++ Select2 can take a regular select box like this... +
-- -
++ +
-- and turn it into this... -
++ and turn it into this... +
-- -
-+ +
+
- Select2 also supports multi-value select boxes. The select below is declared with the multiple
attribute.
-
+ Select2 also supports multi-value select boxes. The select below is declared with the multiple
attribute.
+
- -
-+ +
+- A placeholder value can be defined and will be displayed until a selection is made. -
+
+ A placeholder value can be defined and will be displayed until a
+ selection is made. Select2 uses the placeholder
attribute
+ on multiple select boxes, which requires IE 10+. You can support it in
+ older versions with
+ the Placeholders.js polyfill.
+
- -
++ +
-
- Select2 uses the placeholder
attribute on multiple select
- boxes, which requires IE 10+. You can support it in older versions with
- the Placeholders.js polyfill.
-
+ +
+- -
-- Various display options of the Select2 component can be changed -
+
+ Various display options of the Select2 component can be changed:
+ You can access the <option>
element
+ (or <optgroup>
) and any attributes on those elements
+ using .element
.
+
- -
+
+ Templating is primarily controlled by the
+ templateResult
+ and templateSelection
+ options.
+
- You can access the <option>
element
- (or <optgroup>
) and any attributes on those elements
- using .element
.
-
+ +
+
- Templating is primarily controlled by the
- templateResult
- and templateSelection
- options.
-
- Select2 provides a way to load the data from a local array. -
++ Select2 provides a way to load the data from a local array. + You can provide initial selections with array data by providing the + option tag for the selected values, similar to how it would be done for + a standard select. +
-- -
++ +
-- You can provide initial selections with array data by providing the - option tag for the selected values, similar to how it would be done for - a standard select. -
++ +
+- -
-- Select2 comes with AJAX support built in, using jQuery's AJAX methods. - In this example, we can search for repositories using GitHub's API. -
++ Select2 comes with AJAX support built in, using jQuery's AJAX methods. + In this example, we can search for repositories using GitHub's API. +
-- -
++ +
-
- When using Select2 with remote data, the HTML required for the
- select
is the same as any other Select2. If you need to
- provide default selections, you just need to include an
- option
for each selection that contains the value and text
- that should be displayed.
-
+ When using Select2 with remote data, the HTML required for the
+ select
is the same as any other Select2. If you need to
+ provide default selections, you just need to include an
+ option
for each selection that contains the value and text
+ that should be displayed.
+
- You can configure how Select2 searches for remote data using the
- ajax
option. More information on the individual options
- that Select2 handles can be found in the
- options documentation for ajax
.
-
+ You can configure how Select2 searches for remote data using the
+ ajax
option. More information on the individual options
+ that Select2 handles can be found in the
+ options documentation for ajax
.
+
- Select2 will pass any options in the ajax
object to
- jQuery's $.ajax
function, or the transport
- function you specify.
-
+ Select2 will pass any options in the ajax
object to
+ jQuery's $.ajax
function, or the transport
+ function you specify.
+
- Select2's width can be set to a percentage of its parent to support - responsive design. The two Select2 boxes below are styled to 50% and 75% - width respectively. -
++ Select2's width can be set to a percentage of its parent to support + responsive design. The two Select2 boxes below are styled to 50% and 75% + width respectively. +
-- -
++ +
-- -
-+ +
+style
declaration into the tag.
- style
declaration into the tag.
+
- Select2 will response the disabled
attribute on
- <select>
elements. You can also initialize Select2
- with disabled: true
to get the same effect.
-
+ Select2 will response the disabled
attribute on
+ <select>
elements. You can also initialize Select2
+ with disabled: true
to get the same effect.
+
- -
+- -
++ +
-+ +
-
- Select2 will correctly handled disabled results, both with data coming
- from a standard select (when the disabled
attribute is set)
- and from remote sources, where the object has
- disabled: true
set.
-
+ Select2 will correctly handled disabled results, both with data coming
+ from a standard select (when the disabled
attribute is set)
+ and from remote sources, where the object has
+ disabled: true
set.
+
- -
-+ +
+- Select2 supports methods that allow programmatic control of the - component. -
++ Select2 supports methods that allow programmatic control of the + component. +
-- -
++ +
+ + + ++ +
+ +- -
- -Select2 multi-value select boxes can set restrictions regarding the maximum number of options selected.
- The select below is declared with the multiple
attribute with maxSelectionLength
in the select2 options
- -
-
+ Select2 multi-value select boxes can set restrictions regarding the
+ maximum number of options selected. The select below is declared with
+ the multiple
attribute with maxSelectionLength
+ in the select2 options.
+
+ +
+
- Select2 allows you to hide the search box depending on the number of
- options which are displayed. In this example, we use the value
- Infinity
to tell Select2 to never display the search box.
-
- -
-
+ Select2 allows you to hide the search box depending on the number of
+ options which are displayed. In this example, we use the value
+ Infinity
to tell Select2 to never display the search box.
+
+ +
+- Select2 will trigger some events on the original select element, - allowing you to integrate it with other components. You can find more - information on events - on the options page. -
+- -
++ Select2 will trigger some events on the original select element, + allowing you to integrate it with other components. You can find more + information on events + on the options page. +
-- -
+
+ change
is fired whenever an option is selected or removed.
+
- change
is fired whenever an option is selected or removed.
-
+ select2:open
is fired whenever the dropdown is opened.
+ select2:opening
is fired before this and can be prevented.
+
- select2:open
is fired whenever the dropdown is opened.
- select2:opening
is fired before this and can be prevented.
-
+ select2:close
is fired whenever the dropdown is closed.
+ select2:closing
is fired before this and can be prevented.
+
- select2:close
is fired whenever the dropdown is closed.
- select2:closing
is fired before this and can be prevented.
-
+ select2:select
is fired whenever a result is selected.
+ select2:selecting
is fired before this and can be prevented.
+
- select2:select
is fired whenever a result is selected.
- select2:selecting
is fired before this and can be prevented.
-
+ select2:unselect
is fired whenever a result is unselected.
+ select2:unselecting
is fired before this and can be prevented.
+
- select2:unselect
is fired whenever a result is unselected.
- select2:unselecting
is fired before this and can be prevented.
-
+ +
-+ +
+- Select2 supports ability to add choices automatically as the user is - typing into the search field. Try typing in the search field below and - entering a space or a comma. -
+- -
++ Select2 supports ability to add choices automatically as the user is + typing into the search field. Try typing in the search field below and + entering a space or a comma. +
-- The separators that should be used when tokenizing can be specified - using the tokenSeparators - options. -
++ The separators that should be used when tokenizing can be specified + using the tokenSeparators + options. +
-+ +
+- Unlike other dropdowns on this page, this one matches options only if - the term appears in the beginning of the string as opposed to anywhere: -
+- -
++ Unlike other dropdowns on this page, this one matches options only if + the term appears in the beginning of the string as opposed to anywhere: +
-- This custom matcher uses a - compatibility module that is - only bundled in the - full version of Select2. You also - have the option of using a - more complex matcher. -
-+ This custom matcher uses a + compatibility module that is + only bundled in the + full version of Select2. You also + have the option of using a + more complex matcher. +
- ++ +
+- Select2's default matcher will ignore diacritics, making it easier for - users to filter results in international selects. Type "aero" into the - select below. -
+- -
-+ Select2's default matcher will ignore diacritics, making it easier for + users to filter results in international selects. Type "aero" into the + select below. +
- ++ +
+- Select2 supports displaying the messages in different languages, as well - as providing your own - custom messages - that can be displayed. -
+- -
++ Select2 supports displaying the messages in different languages, as well + as providing your own + custom messages + that can be displayed. +
-
- The language does not have to be defined when Select2 is being
- initialized, but instead can be defined in the [lang]
- attribute of any parent elements as [lang="es"]
.
-
+ The language does not have to be defined when Select2 is being
+ initialized, but instead can be defined in the [lang]
+ attribute of any parent elements as [lang="es"]
.
+
+ +
+- Select2 supports custom themes using the - theme option - so you can style Select2 to match the rest of your application. -
+- -
++ Select2 supports custom themes using the + theme option + so you can style Select2 to match the rest of your application. +
-
- These are using the classic
theme, which matches the old
- look of Select2.
-
+ These are using the classic
theme, which matches the old
+ look of Select2.
+
- -
-+ +
- ++ +
+
- Select2 will work on RTL websites if the dir
attribute is
- set on the <select>
or any parents of it.
-
- -
+
+ Select2 will work on RTL websites if the dir
attribute is
+ set on the <select>
or any parents of it. You can also
+ initialize Select2 with dir: "rtl"
set.
+
- You can also use initialize Select2 with dir: "rtl"
set.
-
+ +
+