]> source.dussan.org Git - nextcloud-server.git/commitdiff
Contacts: Added autocomplete using geonames.org.
authorThomas Tanghus <thomas@tanghus.net>
Tue, 3 Apr 2012 05:29:47 +0000 (07:29 +0200)
committerThomas Tanghus <thomas@tanghus.net>
Tue, 3 Apr 2012 05:29:47 +0000 (07:29 +0200)
apps/contacts/css/contacts.css
apps/contacts/js/contacts.js
apps/contacts/templates/settings.php

index 9d238c36f3369fd1078f4714e261698df345a2f8..4e7d8c285a3f29e2ee37e213a5506a4030b5db48 100644 (file)
@@ -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; }
index e838d713d4549c4fb46d9ece294414db5116604c..b72f3c9a6785d8bdfb5932561b548103f9c1693c 100644 (file)
@@ -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);
index f56de0ec8b0198d5d16f7334322cf71c8169c8c8..d77c4d380278bfad2d021c982e30424a172b4475 100644 (file)
@@ -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>