X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=js%2Fkivi.CustomerVendor.js;fp=js%2Fkivi.CustomerVendor.js;h=aed7081b3e073be64d94212e19f81d1d3d91ee97;hb=ef6fcba983f1a5b50f11495f86510b959b22ea76;hp=928c6736c1896ec3277bf25439ec149835f8441c;hpb=95c1acfeb2631a78df6c0cec37649d68657fba04;p=kivitendo-erp.git 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) {