summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-04-03 07:29:47 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-04-03 07:29:47 +0200
commitfc555b48ec0f5600a7f9ae25354ffaca2e0533de (patch)
treecf131d1cba346a131ae60a9c72077f7f11492d9c
parentb3f107dddaf4f3b5b65d8dd67d66bf1bd36d9ae1 (diff)
downloadnextcloud-server-fc555b48ec0f5600a7f9ae25354ffaca2e0533de.tar.gz
nextcloud-server-fc555b48ec0f5600a7f9ae25354ffaca2e0533de.zip
Contacts: Added autocomplete using geonames.org.
-rw-r--r--apps/contacts/css/contacts.css1
-rw-r--r--apps/contacts/js/contacts.js88
-rw-r--r--apps/contacts/templates/settings.php1
3 files changed, 87 insertions, 3 deletions
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 9d238c36f33..4e7d8c285a3 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -28,6 +28,7 @@ dl.form { width: 100%; float: left; clear: right; margin: 0; padding: 0; }
.form dd { display: table-cell; clear: right; float: left; margin: 0; padding: 0px; white-space: nowrap; vertical-align: text-bottom; }
.loading { background: url('../../../core/img/loading.gif') no-repeat center !important; /*cursor: progress; */ cursor: wait; }
+.ui-autocomplete-loading { background: url('../../../core/img/loading.gif') right center no-repeat; }
.float { float: left; }
.listactions { height: 1em; width:60px; float: left; clear: right; }
.add,.edit,.delete,.mail, .globe { cursor: pointer; width: 20px; height: 20px; margin: 0; float: left; position:relative; display: none; }
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index e838d713d45..b72f3c9a678 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -908,10 +908,92 @@ Contacts={
container.remove();
}
//Contacts.UI.showHideContactInfo();
- }/*,
+ },
open : function(event, ui) {
- // load 'ADR' property - maybe :-P
- }*/
+ $( "#adr_city" ).autocomplete({
+ source: function( request, response ) {
+ $.ajax({
+ url: "http://ws.geonames.org/searchJSON",
+ dataType: "jsonp",
+ data: {
+ featureClass: "P",
+ style: "full",
+ maxRows: 12,
+ name_startsWith: request.term
+ },
+ success: function( data ) {
+ response( $.map( data.geonames, function( item ) {
+ /*for(var key in item) {
+ console.log(key + ': ' + item[key]);
+ }*/
+ return {
+ label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryName,
+ value: item.name,
+ country: item.countryName
+ }
+ }));
+ }
+ });
+ },
+ minLength: 2,
+ select: function( event, ui ) {
+ if(ui.item) {
+ $('#adr_country').val(ui.item.country);
+ }
+ /*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" );
+ }
+ });
+ $( "#adr_country" ).autocomplete({
+ source: function( request, response ) {
+ $.ajax({
+ url: "http://ws.geonames.org/searchJSON",
+ dataType: "jsonp",
+ data: {
+ /*featureClass: "A",*/
+ featureCode: "PCLI",
+ /*countryBias: "true",*/
+ /*style: "full",*/
+ maxRows: 12,
+ name_startsWith: request.term
+ },
+ success: function( data ) {
+ response( $.map( data.geonames, function( item ) {
+ for(var key in item) {
+ console.log(key + ': ' + item[key]);
+ }
+ return {
+ label: item.name,
+ value: item.name
+ }
+ }));
+ }
+ });
+ },
+ minLength: 2,
+ select: function( event, ui ) {
+ /*if(ui.item) {
+ $('#adr_country').val(ui.item.country);
+ }
+ 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" );
+ }
+ });
+ }
});
} else {
alert(jsondata.data.message);
diff --git a/apps/contacts/templates/settings.php b/apps/contacts/templates/settings.php
index f56de0ec8b0..d77c4d38027 100644
--- a/apps/contacts/templates/settings.php
+++ b/apps/contacts/templates/settings.php
@@ -9,4 +9,5 @@
<dd><code><?php echo OC_Helper::linkToAbsolute('contacts', 'carddav.php'); ?>/principals/<?php echo OC_User::getUser(); ?></code>/</dd>
</dl>
</fieldset>
+ Powered by <a href="http://geonames.org/" target="_blank">geonames.org webservice</a>
</form>