summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2014-06-17 16:40:03 +0100
committerGreg Roach <fisharebest@gmail.com>2014-06-17 16:40:03 +0100
commit278af5d1ace7346bd49339ef4461d324f2339967 (patch)
tree6e0f8e45d58bc502bb6363e57ebec7bf5b2ec1ee /js
parent41529aefb463adb31b0fc88fcd97b9badb04013c (diff)
downloadwebtrees-278af5d1ace7346bd49339ef4461d324f2339967.tar.gz
webtrees-278af5d1ace7346bd49339ef4461d324f2339967.tar.bz2
webtrees-278af5d1ace7346bd49339ef4461d324f2339967.zip
Autocomplete doesn't work on pages with data from multiple trees
Diffstat (limited to 'js')
-rw-r--r--js/autocomplete.js107
-rw-r--r--js/webtrees-1.5.4.js36
2 files changed, 36 insertions, 107 deletions
diff --git a/js/autocomplete.js b/js/autocomplete.js
index 9b9e37b945..aa9e3765fe 100644
--- a/js/autocomplete.js
+++ b/js/autocomplete.js
@@ -37,109 +37,4 @@ return $( "<li></li>" )
}
});
-})( jQuery );
-
-/*
-webtrees: Web based Family History software
-Copyright (C) 2014 webtrees development team.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-*/
-
-// INDI
-jQuery("#spouseid, input[id*=pid], input[id*=PID], input[id^=gedcomid], input[id^=rootid], input[id$=ROOT_ID], input[name^=FATHER], input[name^=MOTHER], input[name^=CHIL]").autocomplete({
- source: "autocomplete.php?field=INDI",
- html: true
-});
-
-// ASSO
-jQuery(".ASSO, ._ASSO").autocomplete({
- source: function(request, response) {jQuery.getJSON("autocomplete.php?field=ASSO", {term:request.term, pid:jQuery("input[name=pid]").val(), event_date:jQuery("input[id*=_DATE]").val()}, response);},
- html: true
-});
-
-// FAM
-jQuery(".FAM, input[id*=famid], input[id*=FAMC], #famid").autocomplete({
- source: "autocomplete.php?field=FAM",
- html: true
-});
-
-// NOTE
-jQuery(".NOTE, .SHARED_NOTE").autocomplete({
- source: "autocomplete.php?field=NOTE",
- html: true
-});
-
-// SOUR
-jQuery(".SOUR, input[id*=sid]").autocomplete({
- source: "autocomplete.php?field=SOUR"
-});
-
-// SOUR:PAGE
-jQuery(".PAGE").autocomplete({
- source: function(request, response) {jQuery.getJSON("autocomplete.php?field=SOUR_PAGE", {term:request.term, sid:jQuery("input[class^=SOUR]").val()}, response);}
-});
-
-// SOUR:TITL
-jQuery("#TITL").autocomplete({
- source: "autocomplete.php?field=SOUR_TITL"
-});
-
-// REPO
-jQuery(".REPO, #REPO").autocomplete({
- source: "autocomplete.php?field=REPO"
-});
-
-// REPO:NAME
-jQuery("#REPO_NAME").autocomplete({
- source: "autocomplete.php?field=REPO_NAME"
-});
-
-// OBJE
-jQuery(".OBJE, #OBJE, #mediaid, #filter").autocomplete({
- source: "autocomplete.php?field=OBJE",
- html: true
-});
-
-// INDI or FAM or SOUR or REPO or NOTE or OBJE
-jQuery("input[id$=xref], input[name^=gid], #cart_item_id").autocomplete({
- source: "autocomplete.php?field=IFSRO",
- html: true
-});
-
-// PLAC : with hierarchy
-jQuery(".PLAC, #place, input[name=place], input[id=place], input[name*=PLACS], input[name*=PLAC3], input[name^=PLAC], input[name$=PLAC]").autocomplete({
- source: "autocomplete.php?field=PLAC"
-});
-
-// PLAC : without hierarchy
-jQuery("input[name=place2], input[id=birthplace], input[id=marrplace], input[id=deathplace], input[id=bdmplace]").autocomplete({
- source: "autocomplete.php?field=PLAC2"
-});
-
-// INDI:BURI:CEME
-jQuery("input[id*=_CEME]").autocomplete({
- source: "autocomplete.php?field=CEME"
-});
-
-// GIVN
-jQuery("#GIVN, input[name*=GIVN], input[name*=firstname]").autocomplete({
- source: "autocomplete.php?field=GIVN"
-});
-
-// SURN
-jQuery("#SURN, input[name*=SURN], input[name*=lastname], #NAME, input[id=name]").autocomplete({
- source: "autocomplete.php?field=SURN"
-});
+})( jQuery ); \ No newline at end of file
diff --git a/js/webtrees-1.5.4.js b/js/webtrees-1.5.4.js
index 64c2f17a3a..157952f239 100644
--- a/js/webtrees-1.5.4.js
+++ b/js/webtrees-1.5.4.js
@@ -1531,7 +1531,6 @@ function valid_lati_long(field, pos, neg) {
field.value = txt;
}
-
// This is the default way for webtrees to show image galleries.
// Custom themes may use a different viewer.
function activate_colorbox(config) {
@@ -1588,6 +1587,41 @@ function activate_colorbox(config) {
});
}
+
+// Initialize autocomplete elements.
+function autocomplete(selector) {
+ if (typeof(selector) === "undefined") {
+ selector = "input[data-autocomplete-type]";
+ }
+
+ jQuery(selector).each(function() {
+ var type = $(this).data("autocomplete-type"); // What type of field
+ var ged = $(this).data("autocomplete-ged"); // Which family tree
+
+ if (typeof(type) === "undefined") {
+ alert("Missing data-autocomplete-type attribute");
+ }
+
+ // Default to the current tree
+ if (typeof(ged) === "undefined") {
+ jQuery(this).data("autocomplete-ged", WT_GEDCOM);
+ }
+
+ var self=jQuery(this);
+ self.autocomplete({
+ // Cannot use a simple URL, as the data-autocomplete-xxxx parameters may change.
+ source: function(request, response) {
+ jQuery.getJSON("autocomplete.php", {
+ field: self.data("autocomplete-type"),
+ ged: self.data("autocomplete-ged"),
+ term: request.term
+ }, response);
+ },
+ html: true
+ });
+ });
+}
+
// Add LTR/RTL support for jQueryUI Accordions
jQuery.extend($.ui.accordion.prototype.options, {
icons: {