From: Thomas Heck Date: Tue, 16 Jul 2013 12:22:23 +0000 (+0200) Subject: CustomerVendor: MapWidget umgebaut X-Git-Tag: release-3.1.0beta1~161^2^2~7 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=b69669f3464e6567271d1a2ecd6657fb6c761854;p=kivitendo-erp.git CustomerVendor: MapWidget umgebaut --- diff --git a/js/kivi.CustomerVendor.js b/js/kivi.CustomerVendor.js index 928c6736c..aed7081b3 100644 --- a/js/kivi.CustomerVendor.js +++ b/js/kivi.CustomerVendor.js @@ -84,78 +84,80 @@ namespace('kivi.CustomerVendor', function(ns) { '#country' ]; - this.showMapWidget = function(prefix, widgetWrapper) { - var result = { - }; - - $(function(){ + this.MapWidget = function(prefix) + { + var $mapSearchElements = []; + var $widgetWrapper; - widgetWrapper = $(widgetWrapper); + var init = function() { + if( $mapSearchElements.length > 0 ) + return; - var mapSearchElements = []; for(var i in mapSearchStmts) { var stmt = mapSearchStmts[i]; if( stmt.charAt(0) == '#' ) { - var elem = $('#'+ prefix + stmt.substring(1)); - if( elem ) - mapSearchElements.push(elem); + var $elem = $('#'+ prefix + stmt.substring(1)); + if( $elem ) + $mapSearchElements.push($elem); } } + }; - var isNotEmpty = function() { - for(var i in mapSearchElements) - if( mapSearchElements[i].val() == '' ) - return false; - return true; - }; + var isNotEmpty = function() { + for(var i in $mapSearchElements) + if( $mapSearchElements[i].val() == '' ) + return false; + return true; + }; - widgetWrapper - .html(''+ kivi.t8(') - .click(function(){ - ns.showMap(prefix); - }); + var showMap = function() { + var searchString = ""; - var testInputs = function() { - if( isNotEmpty() ) - widgetWrapper.show(); + for(var i in mapSearchStmts) { + var stmt = mapSearchStmts[i]; + if( stmt.charAt(0) == '#' ) { + var val = $('#'+ prefix + stmt.substring(1)).val(); + if( val ) + searchString += val; + } else - widgetWrapper.hide(); - }; + searchString += stmt; + } - result.testInputs = testInputs; + var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString); - $(mapSearchElements) - .map(function() { - return this.toArray(); - }) - .keyup(testInputs) + window.open(url, '_blank'); + window.focus(); + }; - if( !isNotEmpty() ) - widgetWrapper.hide(); + var render = function(widgetWrapper) { + init(); - }); + $widgetWrapper = $(widgetWrapper); - return result; - }; + $widgetWrapper + .html(''+ kivi.t8(') + .click(function() { + showMap(); + }); + for(var i in $mapSearchElements) + $mapSearchElements[i].keyup(function() { + testInputs(); + }); + this.testInputs(); + }; - this.showMap = function(prefix) { - var searchString = ""; + var testInputs = function() { + init(); - for(var i in mapSearchStmts) { - var stmt = mapSearchStmts[i]; - if( stmt.charAt(0) == '#' ) { - var val = $('#'+ prefix + stmt.substring(1)).val(); - if( val ) - searchString += val; - } + if( isNotEmpty() ) + $widgetWrapper.show(); else - searchString += stmt; - } - - var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString); + $widgetWrapper.hide(); + }; - window.open(url, '_blank'); - window.focus(); + this.render = render; + this.testInputs = testInputs; }; this.showHistoryWindow = function(id) { diff --git a/templates/webpages/customer_vendor/tabs/billing.html b/templates/webpages/customer_vendor/tabs/billing.html index 7635af49d..b7dfe9ea2 100644 --- a/templates/webpages/customer_vendor/tabs/billing.html +++ b/templates/webpages/customer_vendor/tabs/billing.html @@ -88,7 +88,10 @@ [% L.input_tag('cv.street', SELF.cv.street, size = 35, maxlength = 75) %] diff --git a/templates/webpages/customer_vendor/tabs/contacts.html b/templates/webpages/customer_vendor/tabs/contacts.html index d2b87b13e..6420cbe7e 100644 --- a/templates/webpages/customer_vendor/tabs/contacts.html +++ b/templates/webpages/customer_vendor/tabs/contacts.html @@ -159,7 +159,10 @@ [% L.input_tag('contact.cp_street', SELF.contact.cp_street, size = 40, maxlength = 75) %] diff --git a/templates/webpages/customer_vendor/tabs/shipto.html b/templates/webpages/customer_vendor/tabs/shipto.html index b4fbb2832..0b238c34b 100644 --- a/templates/webpages/customer_vendor/tabs/shipto.html +++ b/templates/webpages/customer_vendor/tabs/shipto.html @@ -47,7 +47,10 @@