File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
packages/uikit-workshop/src/scripts/components Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 8
8
*
9
9
*/
10
10
11
- var patternFinder = {
11
+ import { urlHandler } from '@pattern-lab/utils/url-handler' ;
12
+ import $ from 'jquery' ;
13
+ import Bloodhound from 'typeahead.js/dist/bloodhound.js' ;
14
+
15
+ export const patternFinder = {
12
16
data : [ ] ,
13
17
active : false ,
14
18
15
19
init : function ( ) {
16
- for ( var patternType in patternPaths ) {
17
- if ( patternPaths . hasOwnProperty ( patternType ) ) {
18
- for ( var pattern in patternPaths [ patternType ] ) {
20
+ // don't init more than once.
21
+ if ( document . querySelectorAll ( '.pl-js-typeahead' ) . length > 1 ) {
22
+ return ;
23
+ }
24
+
25
+ for ( var patternType in window . patternPaths ) {
26
+ if ( window . patternPaths . hasOwnProperty ( patternType ) ) {
27
+ for ( var pattern in window . patternPaths [ patternType ] ) {
19
28
var obj = { } ;
20
29
obj . patternPartial = patternType + '-' + pattern ;
21
- obj . patternPath = patternPaths [ patternType ] [ pattern ] ;
30
+ obj . patternPath = window . patternPaths [ patternType ] [ pattern ] ;
22
31
this . data . push ( obj ) ;
23
32
}
24
33
}
You can’t perform that action at this time.
0 commit comments