-
Notifications
You must be signed in to change notification settings - Fork 1
/
civcoms-bookmarklet.js
41 lines (38 loc) · 1003 Bytes
/
civcoms-bookmarklet.js
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
$(function() {
function log( message ) {
$( "<div/>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}
$( "#title" ).autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://marketplace.civiccommons.org/api/v1/views/application_api.jsonp",
dataType: "jsonp",
data: {
display_id: 'field_view',
'filters[keywords]': request.term
},
success: function( data ) {
response( $.map( data, function( item ) {
return {
label: item.node_title,
value: item.node_title
}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.label :
"Nothing selected, input was " + this.value);
},
open: function() {
$( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
},
close: function() {
$( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
}
});
});