forked from dotarj/jQuery-UI-Pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
385 lines (298 loc) · 9.52 KB
/
README.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
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
/*
* jQuery UI Pattern @VERSION
*
* Copyright 2011, Arjen Post (http://arjenpost.nl)
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://arjenpost.nl/license
*
* http://arjenpost.nl/#pattern
*/
--- Table of contents -----------------------------------------------
1 Overview
1.1 Dependencies
1.2 Default usage
1.3 To-do list
2 Options
2.1 arrowCorrectImage
2.2 arrowIncorrectImage
2.3 clearDelay
2.4 disabled
2.5 gridSize
2.6 lineColor
2.7 lineOpacity
2.8 lineWidth
2.9 multiSelect
3 Events
3.1 create
3.2 start
3.3 change
3.4 stop
4 Methods
4.1 clearPattern
4.2 destroy
4.3 disable
4.4 enable
4.5 option
4.6 option
4.7 pattern
4.8 widget
--- 1 Overview ------------------------------------------------------
Pattern is a Android-style unlock plugin build with jQuery and jQuery
UI, using the jQuery UI widget factory.
--- 1.1 Dependencies ------------------------------------------------
jQuery UI Pattern uses jQuery and jQuery UI:
- jquery.ui.core.js
- jquery.ui.widget.js
- jquery.ui.mouse.js
--- 1.2 Default usage -----------------------------------------------
$('.selector').pattern(
{
arrowCorrectImage: 'img/arrow-correct.png',
arrowIncorrectImage: 'img/arrow-incorrect.png',
stop: function(event, ui) {
var correct = ...;//Check pattern logic (ui.pattern)...
$('.selector').pattern('clearPattern', correct);
}
});
--- 1.3 To-do list --------------------------------------------------
- Make pattern compatible with touch devices
--- 2 Options -------------------------------------------------------
--- 2.1 arrowCorrectImage -------------------------------------------
Name: arrowCorrectImage
Type: String
Default: ''
Description:
Get or set the path to the arrow image which is used for a correct
pattern.
Code examples:
Initialize a pattern with the arrowCorrectImage option specified.
$( ".selector" ).pattern({ arrowCorrectImage:
'img/arrow-correct.png' });
Get or set the arrowCorrectImage option, after init.
//getter
var arrowCorrectImage = $( ".selector" ).pattern( "option",
"arrowCorrectImage" );
//setter
$( ".selector" ).pattern( "option", "arrowCorrectImage",
'img/arrow-correct.png' );
--- 2.2 arrowIncorrectImage -----------------------------------------
Name: arrowIncorrectImage
Type: String
Default: ''
Description:
Get or set the path to the arrow image which is used for an incorrect
pattern.
Code examples:
Initialize a pattern with the arrowIncorrectImage option specified.
$( ".selector" ).pattern({ arrowIncorrectImage:
'img/arrow-incorrect.png' });
Get or set the arrowIncorrectImage option, after init.
//getter
var arrowIncorrectImage = $( ".selector" ).pattern( "option",
"arrowIncorrectImage" );
//setter
$( ".selector" ).pattern( "option", "arrowIncorrectImage",
'img/arrow-incorrect.png' );
--- 2.3 clearDelay --------------------------------------------------
Name: clearDelay
Type: Number
Default: 2000
Description:
Get or set the delay used after clearPattern is called to unselect
the current pattern.
Code examples:
Initialize a pattern with the clearDelay option specified.
$( ".selector" ).pattern({ clearDelay: 2000 });
Get or set the clearDelay option, after init.
//getter
var clearDelay = $( ".selector" ).pattern( "option", "clearDelay" );
//setter
$( ".selector" ).pattern( "option", "clearDelay", 2000 );
--- 2.4 disabled ----------------------------------------------------
Name: disabled
Type: Boolean
Default: false
Description:
Disables (true) or enables (false) the pattern. Can be set when
initialising (first creating) the pattern.
Code examples:
Initialize a pattern with the disabled option specified.
$( ".selector" ).pattern({ disabled: true });
Get or set the disabled option, after init.
//getter
var disabled = $( ".selector" ).pattern( "option", "disabled" );
//setter
$( ".selector" ).pattern( "option", "disabled", true );
--- 2.5 gridSize ----------------------------------------------------
Name: gridSize
Type: Number
Default: 3
Description:
Get or set the size of the pattern grid, eg: 3 = 3x3 4 = 4x4...
Code examples:
Initialize a pattern with the gridSize option specified.
$( ".selector" ).pattern({ gridSize: 3 });
Get or set the gridSize option, after init.
//getter
var gridSize = $( ".selector" ).pattern( "option", "gridSize" );
//setter
$( ".selector" ).pattern( "option", "gridSize", 3 );
--- 2.6 lineColor ---------------------------------------------------
Name: lineColor
Type: String
Default: '#fff'
Description:
Get or set the color of the line which is drawn between the connected
nodes.
Code examples:
Initialize a pattern with the lineColor option specified.
$( ".selector" ).pattern({ lineColor: '#fff' });
Get or set the lineColor option, after init.
//getter
var lineColor = $( ".selector" ).pattern( "option", "lineColor" );
//setter
$( ".selector" ).pattern( "option", "lineColor", '#fff' );
--- 2.7 lineOpacity -------------------------------------------------
Name: lineOpacity
Type: Number
Default: 0.3
Description:
Get or set the opacity of the line which is drawn between the
connected nodes.
Code examples:
Initialize a pattern with the lineOpacity option specified.
$( ".selector" ).pattern({ lineOpacity: 0.3 });
Get or set the lineOpacity option, after init.
//getter
var lineOpacity = $( ".selector" ).pattern( "option",
"lineOpacity" );
//setter
$( ".selector" ).pattern( "option", "lineOpacity", 0.3 );
--- 2.8 lineWidth ---------------------------------------------------
Name: lineWidth
Type: Number
Default: 45
Description:
Get or set the width of the line which is drawn between the connected
nodes.
Code examples:
Initialize a pattern with the lineWidth option specified.
$( ".selector" ).pattern({ lineWidth: 45 });
Get or set the lineWidth option, after init.
//getter
var lineWidth = $( ".selector" ).pattern( "option", "lineWidth" );
//setter
$( ".selector" ).pattern( "option", "lineWidth", 45 );
--- 2.9 multiSelect -------------------------------------------------
Name: multiSelect
Type: Boolean
Default: false
Description:
If true, allows nodes to be selected multiple times.
Code examples:
Initialize a pattern with the multiSelect option specified.
$( ".selector" ).pattern({ multiSelect: true });
Get or set the multiSelect option, after init.
//getter
var multiSelect = $( ".selector" ).pattern( "option", "multiSelect" );
//setter
$( ".selector" ).pattern( "option", "multiSelect", true );
--- 3 Events --------------------------------------------------------
--- 3.1 create ------------------------------------------------------
Name: create
Type: patterncreate
Description:
This event is triggered when pattern is created.
Code examples:
Supply a callback function to handle the create event as an init
option.
$( ".selector" ).pattern({
create: function(event, ui) { ... }
});
Bind to the create event by type: patterncreate.
$( ".selector" ).bind( "patterncreate", function(event, ui) {
...
});
--- 3.2 start -------------------------------------------------------
Name: start
Type: patternstart
Description:
This event is triggered when the user starts selecting a pattern.
Code examples
Supply a callback function to handle the start event as an init
option.
$( ".selector" ).pattern({
start: function(event, ui) { ... }
});
Bind to the start event by type: patternstart.
$( ".selector" ).bind( "patternstart", function(event, ui) {
...
});
--- 3.4 change ------------------------------------------------------
Name: change
Type: patternchange
Description:
This event is triggered on when a node is selected. Use ui.pattern
to obtain the current pattern.
Code examples:
Supply a callback function to handle the change event as an init
option.
$( ".selector" ).pattern({
change: function(event, ui) { ... }
});
Bind to the change event by type: patternchange.
$( ".selector" ).bind( "patternchange", function(event, ui) {
...
});
--- 3.4 stop --------------------------------------------------------
Name: stop
Type: patternstop
Description:
This event is triggered when the user stops pattern selection. Use
ui.pattern to obtain the current pattern.
Code examples:
Supply a callback function to handle the stop event as an init
option.
$( ".selector" ).pattern({
stop: function(event, ui) { ... }
});
Bind to the stop event by type: patternstop.
$( ".selector" ).bind( "patternstop", function(event, ui) {
...
});
--- 4 Methods -------------------------------------------------------
--- 4.1 clearPattern ------------------------------------------------
clearPattern
.pattern( "clearPattern" )
Clears the current pattern after the specified delay (see
clearDelay).
--- 4.2 destroy -----------------------------------------------------
destroy
.pattern( "destroy" )
Remove the pattern functionality completely. This will return the
element back to its pre-init state.
--- 4.3 disable -----------------------------------------------------
disable
.pattern( "disable" )
Disable the pattern.
--- 4.4 enable ------------------------------------------------------
enable
.pattern( "enable" )
Enable the pattern.
--- 4.5 option ------------------------------------------------------
option
.pattern( "option" , optionName , [value] )
Get or set any pattern option. If no value is specified, will act as
a getter.
--- 4.6 option ------------------------------------------------------
option
.pattern( "option" , options )
Set multiple pattern options at once by providing an options object.
--- 4.7 pattern -----------------------------------------------------
pattern
.pattern( "pattern" )
Get the currently selected pattern.
--- 4.8 widget ------------------------------------------------------
widget
.pattern( "widget" )
Returns the .ui-pattern element.