-
Notifications
You must be signed in to change notification settings - Fork 16
/
select2.jquery.txt
136 lines (123 loc) · 8.91 KB
/
select2.jquery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
SELECT2
ALTERNATIVES ==> # - chosen
# - select2 (prefer)
VERSION ==> #4.0.0-rc.2
#Combo box
JQ.select2([OBJ]) #On a <select>, including with usual HTML: multiple, disabled, <optgroup>.
#Do not forget to use an least one <option>, which will be default selected.
#Flatten diacritics.
#Options OBJ can also be specified through:
# - data-VAR[--VAR2]="VAL" as HTML attribute
# - $.fn.select2.defaults.set(VAR_STR, VAL)
#OBJ:
# - data DOBJ_ARR, where DOBJ: id NUM, text STR. Use instead of <option>
# - ajax OBJ: instead of <option>, calls $.ajax(OBJ). Except results as { results DOBJ_ARR }
# OBJ has extra members:
# - delay NUM (def: 250): waits NUM ms after user stops tipping to do AJAX call
# - url(OBJ)->URL
# - processResults(OBJ)->OBJ
# - multiple BOOL
# - disabled BOOL
# - placeholder STR|OBJ: OBJ is id STR, placeholder STR
# - allowClear BOOL: let user clear selection with a cross icon on right
# - templateResult|Selection(DOBJ)->AJQ|ELEM|STR (def: returns DOBJ.text): filter for each
# element after|before being selected (allows HTML templates).
# AJQ|ELEM are not HTML escaped, STR is.
# - width CSS_STR|STR: STR can be "element", "style" (inline HTML style="...") or "resolve"
# ("style" first, fallbacks to "element")
# - minimumInputLength NUM: starts searching after this number of chars typed
# - maximumInputLength NUM: can't typed more than this
# - maximumSelectionLength NUM: max items when multiple
# - minimumResultsForSearch NUM: show search box after this number of options.
# use Infinity for no search box
# - tags BOOL (def: false): if true, users can add their own option
# - tokenSeparators STR_ARR: add what typed so far as item when user type any of the separator
# STR
# - matcher(STR, STR2)->BOOL: custom matching for which term to highlight/pick.
# Do not work with ajax option.
# - language STR (def: any parent element HTML attribute lang). Must include source file
# "dist/js/i18n/LANG.js"
# - dropDownParent JQ|ELEM (def: document.body): DOM parent of the dropdown menu
# - closeOnSelect BOOL: if true (def), close dropdown when selecting an option
# - dir "rtl"
JQ.select2("open|close") #
JQ.select2("destroy") #
JQ.val(STR[_ARR]) #Must then call JQ.trigger("change")
JQ.trigger("change") #To call after programatically change data.
JQ.on("select2:open|close",
FUNC(AEVENT)) #
JQ.on("select2:change",
FUNC(AEVENT)) #
JQ.on("select2:[un]select",
FUNC(AEVENT)) #
SELECT2-BOOTSTRAP-CSS ==> #CSS files that integrates select2 with Bootstrap. Version 1.4.6
UI-SELECT ==> #For Angular.
#MODULE "ui.select"
#DIRECTIVE below.
EXAMPLE ==> #Actual values:
# - selected: EXPR and $select.selected
# - all: ARR
#Display values:
# - selected: <ui-select-match> children
# - all: <ui-select-choices> children
<ui-select ng-model="EXPR">
<ui-select-match>{{$select.selected.VAR2}}</ui-select-match>
<ui-select-choices repeat="VAR in ARR | filter: $select.search">
<div ng-bind-html="VAR.VAR2 | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>'
ui-select #Combo box (0.8.3)
#Container.
#Can set some default options with uiSelectConfig PROVIDER, e.g.
#uiSelectConfig.resetSearchInput = true
#Creates a scope with variables:
# $select OBJ:
# - search STR: current text search. Search through display values, not actual values.
# - selected STR: selected actual value
# - items STR_ARR: options
# - activeIndex NUM: 0 if no match
# - placeholder STR
# - disabled BOOL
# - focus BOOL
# - isGrouped BOOL
# - multiple BOOL
# - open BOOL
# $model NG-MODEL
ng-model="EXPR" #EXPR can be STR[_ARR] or NUM[_ARR] (actual value)
#EXPR needs to be "OBJ.VAR", not "OBJ"
theme="STR" #Can be "bootstrap|select2|selectize"
#Need to load Bootstrap|select2|selectize CSS. Def: "bootstrap"
multiple #Need then to use $item instead of $select.selected
on-select|remove="EXPR" #
reset-search-input=
"BOOL_EXPR" #If true (def: false), reset input if not valid (not in options)
close-on-select="BOOL_EXPR" #
ng-disabled="BOOL_EXPR" #
search-enabled="BOOL_EXPR" #
tagging[="FUNC_STR_EXPR"] #Enables tagging (see Select2 above).
#Will call FUNC(STR)->VAL to transpose display value to actual value.
tagging-tokens="STR_EXPR" #Like tokenSeparators above. STR is "...|...|...". Use "SPACE" or "ENTER" for those ones.
#Def: "ENTER|,"
tagging-label="EXPR" #Shows STR or nothing if false, before display value of added items.
append-to-body="BOOL" #Def: false
autofocus #Get focus when loaded
sortable="BOOL" #
ui-select-match #Child of <ui-select>. Contains selected display values (e.g. $select.selected)
placeholder="STR" #Def: ""
allow-clear="BOOL" #
ui-lock-choice="BOOL_EXPR" #Make selected items impossible to unselect, e.g. "$item.VAR == STR"
ui-select-choices #Child of <ui-select>. Contains possible display values.
repeat="[EXPR2 as ]VAR in #Fires a ng-repeat.
EXPR_ARR[ track by EXPR3]" #Often use "filter : $select.search"
#Child are display values which can use VAR. Can use filter " | highlight $select.search" but:
# - produces HTML so should use ng-bind-html, e.g.:
# ng-bind-html="$sce.trustAsHtml((EXPR | highlight $select.search))"
# - if EXPR is NUM, and use highlight, should do EXPR.toString()
#EXPR3 exclude duplicates
ui-disable-choice="BOOLEXPR"#Disable items that evaluates to true, e.g. "VAR.VAR2 == STR"
group-by="'STR'|FUNC" #Group shown values by VAR.STR, or FUNC(VAR)->STR
refresh="EXPR" #Fires periodically
refresh-delay="NUM" #Def: 1000
on-highlight="EXPR" #