Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
96 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ engines: | |
config: | ||
extensions: | ||
- .es6 | ||
ignore_warnings: true | ||
fixme: | ||
enabled: false | ||
rubocop: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,68 @@ | ||
import Location from 'sufia/autocomplete/location' | ||
import Subject from 'sufia/autocomplete/subject' | ||
import Language from 'sufia/autocomplete/language' | ||
import Work from 'sufia/autocomplete/work' | ||
|
||
|
||
export class Autocomplete { | ||
constructor() { | ||
} | ||
constructor() { | ||
} | ||
|
||
// This is the initial setup for the form. | ||
setup() { | ||
$('[data-autocomplete]').each((index, value) => { | ||
let selector = $(value) | ||
switch (selector.data('autocomplete')) { | ||
case "subject": | ||
this.autocompleteSubject(selector); | ||
break; | ||
case "language": | ||
this.autocompleteLanguage(selector); | ||
break; | ||
case "based_near": | ||
this.autocompleteLocation(selector); | ||
break; | ||
case "work": | ||
var user = selector.data('user'); | ||
var id = selector.data('id'); | ||
this.autocompleteWork(selector, user, id); | ||
break; | ||
} | ||
}); | ||
} | ||
// This is the initial setup for the form. | ||
setup() { | ||
$('[data-autocomplete]').each((index, value) => { | ||
let selector = $(value) | ||
switch (selector.data('autocomplete')) { | ||
case "subject": | ||
this.autocompleteSubject(selector); | ||
break; | ||
case "language": | ||
this.autocompleteLanguage(selector); | ||
break; | ||
case "based_near": | ||
this.autocompleteLocation(selector); | ||
break; | ||
case "work": | ||
var user = selector.data('user'); | ||
var id = selector.data('id'); | ||
this.autocompleteWork(selector, user, id); | ||
break; | ||
} | ||
}); | ||
} | ||
|
||
// attach an auto complete based on the field | ||
fieldAdded(cloneElem) { | ||
var $cloneElem = $(cloneElem); | ||
// FIXME this code (comparing the id) depends on a bug. Each input has an id and | ||
// the id is duplicated when you press the plus button. This is not valid html. | ||
if (/_based_near$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLocation($cloneElem); | ||
} else if (/_language$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLanguage($cloneElem); | ||
} else if (/_subject$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteSubject($cloneElem); | ||
// attach an auto complete based on the field | ||
fieldAdded(cloneElem) { | ||
var $cloneElem = $(cloneElem); | ||
// FIXME this code (comparing the id) depends on a bug. Each input has an id and | ||
// the id is duplicated when you press the plus button. This is not valid html. | ||
if (/_based_near$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLocation($cloneElem); | ||
} else if (/_language$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteLanguage($cloneElem); | ||
} else if (/_subject$/.test($cloneElem.attr("id"))) { | ||
this.autocompleteSubject($cloneElem); | ||
} | ||
} | ||
} | ||
|
||
autocompleteLocation(field) { | ||
var loc = require('sufia/autocomplete/location'); | ||
new loc.Location(field, field.data('autocomplete-url')) | ||
} | ||
autocompleteLocation(field) { | ||
new Location(field, field.data('autocomplete-url')) | ||
} | ||
|
||
autocompleteSubject(field) { | ||
var subj = require('sufia/autocomplete/subject'); | ||
new subj.Subject(field, field.data('autocomplete-url')) | ||
} | ||
autocompleteSubject(field) { | ||
new Subject(field, field.data('autocomplete-url')) | ||
} | ||
|
||
autocompleteLanguage(field) { | ||
var lang = require('sufia/autocomplete/language'); | ||
new lang.Language(field, field.data('autocomplete-url')) | ||
} | ||
autocompleteLanguage(field) { | ||
new Language(field, field.data('autocomplete-url')) | ||
} | ||
|
||
autocompleteWork(field, user, id) { | ||
var work = require('sufia/autocomplete/work') | ||
new work.Work( | ||
field, | ||
field.data('autocomplete-url'), | ||
user, | ||
id | ||
) | ||
} | ||
autocompleteWork(field, user, id) { | ||
new Work( | ||
field, | ||
field.data('autocomplete-url'), | ||
user, | ||
id | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters