upgrade typeahead to 1.10 and new syntax
This commit is contained in:
parent
4bc03e3d2a
commit
bd9c275ada
3 changed files with 2481 additions and 1187 deletions
2451
app/assets/javascripts/lib/typeahead.bundle.js
Normal file
2451
app/assets/javascripts/lib/typeahead.bundle.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -672,11 +672,15 @@ Metamaps.Create = {
|
||||||
[{
|
[{
|
||||||
name: 'topic_autocomplete',
|
name: 'topic_autocomplete',
|
||||||
limit: 8,
|
limit: 8,
|
||||||
template: $('#topicAutocompleteTemplate').html(),
|
template: Hogan.compile($('#topicAutocompleteTemplate').html()),
|
||||||
remote: {
|
source: function(query, syncResults, asyncResults) {
|
||||||
url: '/topics/autocomplete_topic?term=%QUERY'
|
syncResults([]); //we don't got none
|
||||||
|
var url = '/topics/autocomplete_topic?term=' + query;
|
||||||
|
$.ajax(url, {
|
||||||
|
success: function(data) { asyncResults(data); },
|
||||||
|
error: function() { asyncResults([]); },
|
||||||
|
});
|
||||||
},
|
},
|
||||||
engine: Hogan
|
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -733,23 +737,34 @@ Metamaps.Create = {
|
||||||
},
|
},
|
||||||
[{
|
[{
|
||||||
name: 'synapse_autocomplete',
|
name: 'synapse_autocomplete',
|
||||||
template: "<div class='genericSynapseDesc'>{{label}}</div>",
|
template: Hogan.compile("<div class='genericSynapseDesc'>{{label}}</div>"),
|
||||||
remote: {
|
source: function(query, syncResults, asyncResults) {
|
||||||
url: '/search/synapses?term=%QUERY'
|
syncResults([]); //we don't got none
|
||||||
|
var url = '/search/synapses?term=' + query;
|
||||||
|
$.ajax(url, {
|
||||||
|
success: function(data) { asyncResults(data); },
|
||||||
|
error: function() { asyncResults([]); },
|
||||||
|
});
|
||||||
},
|
},
|
||||||
engine: Hogan
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'existing_synapses',
|
name: 'existing_synapses',
|
||||||
limit: 50,
|
limit: 50,
|
||||||
template: $('#synapseAutocompleteTemplate').html(),
|
template: Hogan.compile($('#synapseAutocompleteTemplate').html()),
|
||||||
remote: {
|
source: function(query, syncResults, asyncResults) {
|
||||||
url: '/search/synapses',
|
syncResults([]); //we don't got none
|
||||||
replace: function () {
|
var self = Metamaps.Create.newSynapse;
|
||||||
return self.getSearchQuery();
|
|
||||||
|
if (Metamaps.Selected.Nodes.length < 2) {
|
||||||
|
var url = '/search/synapses?topic1id=' + self.topic1id + '&topic2id=' + self.topic2id;
|
||||||
|
$.ajax(url, {
|
||||||
|
success: function(data) { asyncResults(data); },
|
||||||
|
error: function() { asyncResults([]); },
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
asyncResults([]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
engine: Hogan,
|
|
||||||
header: "<h3>Existing synapses</h3>"
|
header: "<h3>Existing synapses</h3>"
|
||||||
}]
|
}]
|
||||||
);
|
);
|
||||||
|
@ -785,13 +800,6 @@ Metamaps.Create = {
|
||||||
Metamaps.Mouse.synapseStartCoordinates = [];
|
Metamaps.Mouse.synapseStartCoordinates = [];
|
||||||
Metamaps.Visualize.mGraph.plot();
|
Metamaps.Visualize.mGraph.plot();
|
||||||
},
|
},
|
||||||
getSearchQuery: function () {
|
|
||||||
var self = Metamaps.Create.newSynapse;
|
|
||||||
|
|
||||||
if (Metamaps.Selected.Nodes.length < 2) {
|
|
||||||
return '/search/synapses?topic1id=' + self.topic1id + '&topic2id=' + self.topic2id;
|
|
||||||
} else return '';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}; // end Metamaps.Create
|
}; // end Metamaps.Create
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue