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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
|
<div class="row">
<div class="col-sm-12">
<h3 class="pageHeading">Configuration & Options</h3>
<!--
<div class="row">
<div class="col-sm-12">
<h5>Full spec</h5>
<pre><code><div
multi-select
input-model="$scope.arrOfObjects"
output-model="$scope.arrOfObjects2"
button-label="property1 property2 ..."
item-label="property1 property2 ..."
tick-property="property3"
disable-property="property4"
orientation="horizontal | vertical"
selection-mode="multiple | single"
max-labels="999"
directive-id="..."
is-disabled="true | false"
helper-elements="all none reset filter"
default-label="..."
on-open="$scope.function()"
on-close="$scope.function()"
on-item-click="$scope.function( data )"
on-select-all="$scope.function()"
on-select-none="$scope.function()"
on-reset="$scope.function()"
on-clear="$scope.function()"
on-filter-change="$scope.function()"
i18n="$scope.object"
>
</div>
</code></pre>
</div>
</div>
-->
<p>Below are the available attributes to configure the multi-select directive. The first 5 are required.</p>
<span class="configData">
<h5>input-model</h5> <span class="label label-primary">required</span>
<p>
This is the data you pass into the directive. You can programatically do changes
and the directive will refresh accordingly. For example; to reset programmatically, you can iterate over
this input-model and set <code>selected = false</code>. If, for any reason, you want to reset it, set it into an empty array.
Don't set it to null or other types.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope variable. Array of objects. <br />
<span class="inlineTitle">Default value</span>: N/A <br />
<span class="inlineTitle">Example</span>: <br />
In your view: <code><div isteven-multi-select ... input-model="inputList"></div></code>.
<br />
In your controller:
</p>
<pre><code>$scope.inputList = [
{ firstName: "Peter", lastName: "Parker", pic: "<img src='[...]/peter.png />", selected: false },
{ firstName: "Mary", lastName: "Jane", pic: "<img src='[...]/mary.png />", selected: false },
{ firstName: "Bruce", lastName: "Wayne", pic: "<img src='[...]/bruce.png />", selected: true },
{ firstName: "David", lastName: "Banner", pic: "<img src='[...]/david.png />", selected: false },
{ firstName: "Natalia", lastName: "Romanova", pic: "<img src='[...]/nat.png />", selected: false },
{ firstName: "Clark", lastName: "Kent", pic: "<img src='[...]/clark.png />", selected: true }
];</code></pre>
<p>
<span class="inlineTitle">Note</span>:
There might be some limitations on what HTML tags you can use (Use common sense. For example, flash animation
most likely won't work on the button label). It's highly suggested that you don't use
BUTTON and INPUT tags to prevent conflicts.
</p>
<h5>output-model</h5> <span class="label label-primary">required</span>
<p>
Will list all the selected items. If you enable grouping, this WILL NOT include the group headers.
Also, this model is OUTPUT ONLY. If you want to programmatically change things, do it in the INPUT-MODEL.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope variable. Array of objects. <br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... output-model="outputData"></div></code>.
</p>
<h5>button-label</h5> <span class="label label-primary">required</span>
<p>
input-model properties that you want to display on the button.
</p>
<p>
<span class="inlineTitle">Type</span>: String. Separate multiple values by space.<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... button-label="pic firstName"></div></code>
</p>
<h5>item-label</h5> <span class="label label-primary">required</span>
<p>
input-model properties that you use as item label.
</p>
<p>
<span class="inlineTitle">Type</span>: String. Separate multiple values by space.<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code>><div isteven-multi-select ... item-label="firstName lastName"></div></code>
<p>
<h5>tick-property</h5> <span class="label label-primary">required</span>
<p>
input-model property with a boolean value that represents whether a checkbox is ticked or not.
</p>
<p>
<span class="inlineTitle">Type</span>: String<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>:
</p>
<ul>
<li>
If <code><div isteven-multi-select ... tick-property="selected"></div></code>, then:
<ul>
<li>selected === true, item is selected. </li>
<li>selected === false, item is not selected.</li>
</ul>
</li>
<li>
If <code>><div isteven-multi-select ... tick-property="isOn"></div></code>, then:
<ul>
<li>isOn === true, item is selected. </li>
<li>isOn === false, item is not selected.</li>
</ul>
</li>
</ul>
<h5>disable-property</h5>
<p>
Input-model property with a boolean value that represent whether an item is disabled or enabled.
This gives you granular control over each checkbox, and it has higher priority over the "is-disabled" attribute explained later.
</p>
<p>
<span class="inlineTitle">Type</span>: String<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>:
</p>
<ul>
<li>
If <code><div isteven-multi-select ... disable-property="thisItemIsDisabled"></div></code>, then:
<ul>
<li>thisItemIsDisabled === true, item is disabled. </li>
<li>thisItemIsDisabled === false, item is enabled.</li>
</ul>
</li>
</ul>
<h5>orientation</h5>
<p>Orientation of the item list.</p>
<p>
<span class="inlineTitle">Type</span>: String<br />
<span class="inlineTitle">Available values</span>: "vertical" | "horizontal"<br />
<span class="inlineTitle">Default value</span>: "vertical"<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... orientation="vertical"></div></code>.
</p>
<h5>selection-mode</h5>
<p>Single or multiple selection. If not specified, the default will be "multiple".</p>
<p>
<span class="inlineTitle">Type</span>: String<br />
<span class="inlineTitle">Available values</span>: "single" | "multiple"<br />
<span class="inlineTitle">Default value</span>: "multiple"<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... selection-mode="single"></div></code>.
</p>
<h5>max-labels</h5>
<p>
Maximum number of items that will be displayed in the dropdown button. If not specified, will display all selected items.
</p>
<p>
<span class="inlineTitle">Type</span>: Integer-parseable string ( Such as "2", or "3" )<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>:
With the input-model above,
</p>
<ul>
<li><code>max-labels="1"</code> will display: "Bruce Wayne, ... (2)" on the button.</li>
<li><code>max-labels="0"</code> will display: "(2)" on the button.</li>
</ul>
<h5>is-disabled</h5>
<p>
Will disable or enable all checkboxes except stated otherwise in "disable-property" above.
It's similar with ng-disabled, visit <a href="http://docs.angularjs.org/api/ng/directive/ngDisabled">http://docs.angularjs.org/api/ng/directive/ngDisabled</a>
to learn more.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope boolean expression, or string ( "true" or "false" )<br />
<span class="inlineTitle">Default value</span>: false or "false"<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... is-disabled="true"></div></code>.
</p>
<h5>directive-id</h5>
<p>
Name or id for your directive, to be attached to a <code>span</code> element (parent of the button elemnet).
Useful if you want to debug from within the directive code and you use more than one directive in one page.
Example (from within the multi-select.js): <code>console.log( 'Currently active multi-select: ' + $scope.directiveId );</code>
</p>
<p>
<span class="inlineTitle">Type</span>: String<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... directive-id="hello1"></div></code>.
</p>
<h5>helper-elements</h5>
<p>
Define which helper buttons (Select all, none, reset, filter box) to be displayed.
</p>
<p>
<span class="inlineTitle">Type</span>: String. Separate multiple values with space. Order of values does not matter.<br />
<span class="inlineTitle">Available values</span>: Combinations of "all", "none", "reset", "filter", or empty string<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>:
<ul>
<li>
Display "Select All" button and the filter box: <code><div isteven-multi-select ... helper-elements="all filter"></div></code>
</li>
<li>
Display none: empty string. <code><div isteven-multi-select ... helper-elements=""></div></code>.
</li>
<li>If not specified, by default will display all.</li>
</ul>
</p>
<h5>max-height</h5>
<p>
Set the maximum height of the selection item list area.
</p>
<p>
<span class="inlineTitle">Type</span>: Integer-parseable string or string which comply with CSS' height unit (such as "100", "100px") <br />
<span class="inlineTitle">Default value</span>: auto<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... max-height="250px"></div></code>.
</p>
<h5>min-search-length</h5> <span class="label label-warning">New! v3.0.0</span>
<p>
Set the minimum characters required to trigger search action.
</p>
<p>
<span class="inlineTitle">Type</span>: Integer-parseable string ( Such as "3", or "5" ).<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... min-search-length="3"></div></code>.
</p>
<h5>search-property</h5> <span class="label label-warning">New! v3.0.0</span>
<p>
Set which input-model properties to be searched. Previously, the directive will search from all
available object properties. Now, if this is specified, you can define which property to search.
</p>
<p>
<span class="inlineTitle">Type</span>: String<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... search-property="firstName"></div></code>.
</p>
<h5>translation</h5> <span class="label label-warning">New! v3.0.0</span>
<p>
Use custom text on the helper elements. You can use different text or other languages. If you use it,
you need to define ALL five of the labels here, or they will show "undefined".
</p>
<p>
<span class="inlineTitle">Type</span>: $scope object<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... translation="localLang"></div></code>.
</p>
<p>
In your controller:
<pre ><code>$scope.localLang = {
selectAll : "Tick all",
selectNone : "Tick none",
reset : "Undo all",
search : "Type here to search...",
nothingSelected : "Nothing is selected" //default-label is deprecated and replaced with this.
}</code></pre>
</p>
<h5>on-open</h5>
<p>
A $scope function to call on multi-select open. You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-open="funcOpen()"></div></code>.
</p>
<h5>on-close</h5>
<p>
A $scope function to call on multi-select close (be it by clicking the button or clicking outside the multi-select element).
You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-close="funcClose()"></div></code>.
</p>
<h5>on-item-click</h5>
<p>
A $scope function to call when user click on an item. Triggered AFTER the item is clicked.
You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: Will pass a singular object of the clicked item<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-item-click="funcClick( data )"></div></code>.
</p>
<h5>on-select-all</h5>
<p>
A $scope function to call when "select all" button is clicked.
You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-select-all="funcSelectAll()"></div></code>.
</p>
<h5>on-select-none</h5>
<p>
A $scope function to call when "select none" button is clicked.
You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-select-none="funcSelectNone()"></div></code>.
</p>
<h5>on-reset</h5>
<p>
A $scope function to call when "reset" button is clicked.
You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-reset="funcReset()"></div></code>.
</p>
<h5>on-clear</h5>
<p>
A $scope function to call when the "x" button in filter field is clicked.
You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-clear="funcClear()"></div></code>.
</p>
<h5>on-search-change</h5>
<p>
A $scope function to call when you type in the search field.
You need to define this function in your controller.
</p>
<p>
<span class="inlineTitle">Type</span>: $scope function<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Parameter</span>: Will pass the string that you type and the result<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... on-filter-change="funcFilterChange( data )"></div></code>.
</p>
<h5>output-properties</h5> <span class="label label-warning">New! v4.0.0</span>
<p>
Set what model properties you want to have in your output-model
</p>
<p>
<span class="inlineTitle">Type</span>: String. Separate multiple values by space.<br />
<span class="inlineTitle">Default value</span>: N/A<br />
<span class="inlineTitle">Example</span>: <code><div isteven-multi-select ... output-properties="firstName pic selected"></div></code>
</p>
</span>
</div>
</div>
<script>
$(document).ready(function() {
$('pre code').each(function(i, block) {
hljs.highlightBlock(block);
});
});
</script>
|