Skip to content

Commit

Permalink
Update typeahead to v0.11.1
Browse files Browse the repository at this point in the history
  • Loading branch information
fredj committed Aug 11, 2015
1 parent 2ea6be5 commit 6f68d04
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 36 deletions.
19 changes: 8 additions & 11 deletions examples/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
height: 400px;
}
/* CSS stolen from https://github.com/bassjobsen/typeahead.js-bootstrap-css/ */
span.twitter-typeahead .tt-dropdown-menu {
span.twitter-typeahead .tt-menu {
position: absolute;
top: 100%;
left: 0;
Expand All @@ -35,7 +35,7 @@
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
background-clip: padding-box;
}
span.twitter-typeahead .tt-suggestion > p {
span.twitter-typeahead .tt-suggestion {
display: block;
padding: 3px 20px;
margin-bottom: 0px;
Expand All @@ -45,17 +45,14 @@
color: #333333;
white-space: nowrap;
}
span.twitter-typeahead .tt-suggestion > p:hover,
span.twitter-typeahead .tt-suggestion > p:focus {
span.twitter-typeahead .tt-suggestion.tt-cursor,
span.twitter-typeahead .tt-suggestion:hover,
span.twitter-typeahead .tt-suggestion:focus {
color: #ffffff;
text-decoration: none;
outline: 0;
background-color: #428bca;
}
span.twitter-typeahead .tt-suggestion.tt-cursor {
color: #ffffff;
background-color: #428bca;
}
span.twitter-typeahead .tt-suggestion button {
background: none;
border: 0;
Expand All @@ -67,13 +64,13 @@
.input-group span.twitter-typeahead {
display: block !important;
}
.input-group span.twitter-typeahead .tt-dropdown-menu {
.input-group span.twitter-typeahead .tt-menu {
top: 32px !important;
}
.input-group.input-group-lg span.twitter-typeahead .tt-dropdown-menu {
.input-group.input-group-lg span.twitter-typeahead .tt-menu {
top: 44px !important;
}
.input-group.input-group-sm span.twitter-typeahead .tt-dropdown-menu {
.input-group.input-group-sm span.twitter-typeahead .tt-menu {
top: 28px !important;
}
</style>
Expand Down
6 changes: 3 additions & 3 deletions examples/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ app.SearchController = function($rootScope, $compile,
* @type {TypeaheadOptions}
* @export
*/
this.options = {
this.options = /** @type {TypeaheadOptions} */ ({
highlight: true,
hint: undefined,
minLength: undefined
};
});

/**
* @type {Array.<TypeaheadDataset>}
* @export
*/
this.datasets = [{
source: bloodhoundEngine.ttAdapter(),
displayKey: function(suggestion) {
display: function(suggestion) {
var feature = /** @type {ol.Feature} */ (suggestion);
return feature.get('label');
},
Expand Down
54 changes: 37 additions & 17 deletions externs/typeahead.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @fileoverview Externs for Typeahead and Bloodhound 0.10.5
* @fileoverview Externs for Typeahead and Bloodhound 0.11.1
* @see https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md
* @see https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md
* @externs
Expand All @@ -15,23 +15,21 @@ var BloodhoundDatum;
* @typedef {{
* url: string,
* wildcard: (string|undefined),
* replace: (function(string,string):string|undefined),
* rateLimitBy: (string|undefined),
* rateLimitWait: (number|undefined),
* filter: (function(?):Array.<BloodhoundDatum>|undefined),
* ajax: (jQueryAjaxSettings|undefined)
* prepare: function(string, jQueryAjaxSettings):jQueryAjaxSettings,
* transform: (function(?):Array.<BloodhoundDatum>|undefined)
* }}
*/
var BloodhoundRemoteOptions;

/**
* @typedef {{
* url: string,
* cacheKey: (string|undefined),
* cache: (boolean|undefined),
* ttl: (number|undefined),
* thumbprint: (string|undefined),
* filter: (function(?):Array.<BloodhoundDatum>|undefined),
* ajax: (Object.<string,*>|undefined)
* cacheKey: (string|undefined),
* thumbprint: (string|undefined)
* }}
*/
var BloodhoundPrefetchOptions;
Expand All @@ -40,8 +38,9 @@ var BloodhoundPrefetchOptions;
* @typedef {{
* datumTokenizer: function(BloodhoundDatum):Array.<string>,
* queryTokenizer: function(string):Array.<string>,
* limit: (number|undefined),
* dupDetector: (function():boolean|undefined),
* initialize: (string|undefined),
* identify: (function(BloodhoundDatum):string|undefined),
* sufficient: (number|undefined),
* sorter: (function(BloodhoundDatum,BloodhoundDatum):number|undefined),
* local: (Array.<BloodhoundDatum>|function():Array.<BloodhoundDatum>|undefined),
* prefetch: (string|BloodhoundPrefetchOptions|undefined),
Expand Down Expand Up @@ -129,7 +128,8 @@ Bloodhound.tokenizers.obj.nonword = function(key) {};

/**
* @typedef {{
* empty: (function(Object):string|undefined),
* notFound: (function(Object):string|undefined),
* pending: (function(Object):string|undefined),
* footer: (function(Object):string|undefined),
* header: (function(Object):string|undefined),
* suggestion: (function(Object):string|undefined)
Expand All @@ -140,33 +140,53 @@ var TypeaheadTemplates;
/**
* @typedef {{
* source: function(string,function(Array.<BloodhoundDatum>)),
* async: (boolean|undefined),
* name: (string|undefined),
* displayKey: (string|undefined),
* limit: (number|undefined),
* display: (string|function(Object):string|undefined),
* templates: (TypeaheadTemplates|undefined)
* }}
*/
var TypeaheadDataset;

/**
* @typedef {{
* wrapper: (string|undefined),
* input: (string|undefined),
* hint: (string|undefined),
* menu: (string|undefined),
* dataset: (string|undefined),
* suggestion: (string|undefined),
* selectable: (string|undefined),
* empty: (string|undefined),
* open: (string|undefined),
* cursor: (string|undefined),
* highlight: (string|undefined)
* }}
*/
var TypeaheadClassNames;

/**
* @typedef {{
* highlight: (boolean|undefined),
* hint: (boolean|undefined),
* minLength: (number|undefined)
* minLength: (number|undefined),
* classNames: (TypeaheadClassNames|undefined)
* }}
*/
var TypeaheadOptions;

/**
* @param {string|TypeaheadOptions} options
* @param {...TypeaheadDataset} var_dataset
* @param {TypeaheadOptions|string} options
* @param {...TypeaheadDataset|string} var_dataset
* @return {!jQuery}
*/
jQuery.prototype.typeahead = function(options, var_dataset) {};


/**
* @param {string|TypeaheadOptions} options
* @param {...TypeaheadDataset} var_dataset
* @param {TypeaheadOptions|string} options
* @param {...TypeaheadDataset|string} var_dataset
* @return {!angular.JQLite}
*/
angular.JQLite.prototype.typeahead = function(options, var_dataset) {};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"openlayers": "openlayers/ol3#master",
"phantomjs": "~1.9.7-5",
"temp": "~0.7.0",
"typeahead.js": "~0.10.5",
"typeahead.js": "0.11.1",
"walk": "~2.3.3"
}
}
9 changes: 5 additions & 4 deletions src/services/creategeojsonbloodhound.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
*
* var bloodhound = ngeoCreateGeoJSONBloodhound({
* remote: {
* limit: 10,
* url: mySearchEngineUrl,
* replace: function(url, query) {
* return url +
Expand Down Expand Up @@ -53,10 +52,12 @@ ngeo.createGeoJSONBloodhound = function(options, opt_featureProjection,
var bloodhoundOptions = /** @type {BloodhoundOptions} */ ({
remote: {
url: goog.isString(options) ? options : '',
ajax: {
dataType: 'jsonp'
prepare: function(query, settings) {
settings.url = settings.url.replace('%QUERY', query);
settings.dataType = 'jsonp';
return settings;
},
filter: function(parsedResponse) {
transform: function(parsedResponse) {
var featureCollection = /** @type {GeoJSONFeatureCollection} */
(parsedResponse);
return geojsonFormat.readFeatures(featureCollection, {
Expand Down

0 comments on commit 6f68d04

Please sign in to comment.