Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision ef6fcba9

Von Thomas Heck vor mehr als 11 Jahren hinzugefügt

  • ID ef6fcba983f1a5b50f11495f86510b959b22ea76
  • Vorgänger 95c1acfe
  • Nachfolger 3d5cfc78

CustomerVendor: MapWidget umgebaut

Unterschiede anzeigen:

js/kivi.CustomerVendor.js
84 84
    '#country'
85 85
  ];
86 86

  
87
  this.showMapWidget = function(prefix, widgetWrapper) {
88
    var result = {
89
    };
90

  
91
    $(function(){
87
  this.MapWidget = function(prefix)
88
  {
89
    var $mapSearchElements = [];
90
    var $widgetWrapper;
92 91

  
93
      widgetWrapper = $(widgetWrapper);
92
    var init = function() {
93
      if( $mapSearchElements.length > 0 )
94
        return;
94 95

  
95
      var mapSearchElements = [];
96 96
      for(var i in mapSearchStmts) {
97 97
        var stmt = mapSearchStmts[i];
98 98
        if( stmt.charAt(0) == '#' ) {
99
          var elem = $('#'+ prefix + stmt.substring(1));
100
          if( elem )
101
            mapSearchElements.push(elem);
99
          var $elem = $('#'+ prefix + stmt.substring(1));
100
          if( $elem )
101
            $mapSearchElements.push($elem);
102 102
        }
103 103
      }
104
    };
104 105

  
105
      var isNotEmpty = function() {
106
        for(var i in mapSearchElements)
107
          if( mapSearchElements[i].val() == '' )
108
            return false;
109
        return true;
110
      };
106
    var isNotEmpty = function() {
107
      for(var i in $mapSearchElements)
108
        if( $mapSearchElements[i].val() == '' )
109
          return false;
110
      return true;
111
    };
111 112

  
112
      widgetWrapper
113
        .html('<img src="image/map.png" alt="'+ kivi.t8("Map") +'" title="'+ kivi.t8("Map") +'" />')
114
        .click(function(){
115
          ns.showMap(prefix);
116
        });
113
    var showMap = function() {
114
      var searchString = "";
117 115

  
118
      var testInputs = function() {
119
        if( isNotEmpty() )
120
          widgetWrapper.show();
116
      for(var i in mapSearchStmts) {
117
        var stmt = mapSearchStmts[i];
118
        if( stmt.charAt(0) == '#' ) {
119
          var val = $('#'+ prefix + stmt.substring(1)).val();
120
          if( val )
121
            searchString += val;
122
        }
121 123
        else
122
          widgetWrapper.hide();
123
      };
124
          searchString += stmt;
125
      }
124 126

  
125
      result.testInputs = testInputs;
127
      var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
126 128

  
127
      $(mapSearchElements)
128
        .map(function() {
129
          return this.toArray();
130
        })
131
        .keyup(testInputs)
129
      window.open(url, '_blank');
130
      window.focus();
131
    };
132 132

  
133
      if( !isNotEmpty() )
134
        widgetWrapper.hide();
133
    var render = function(widgetWrapper) {
134
      init();
135 135

  
136
    });
136
      $widgetWrapper = $(widgetWrapper);
137 137

  
138
    return result;
139
  };
138
      $widgetWrapper
139
        .html('<img src="image/map.png" alt="'+ kivi.t8("Map") +'" title="'+ kivi.t8("Map") +'" />')
140
        .click(function() {
141
          showMap();
142
        });
143
      for(var i in $mapSearchElements)
144
        $mapSearchElements[i].keyup(function() {
145
          testInputs();
146
        });
147
      this.testInputs();
148
    };
140 149

  
141
  this.showMap = function(prefix) {
142
    var searchString = "";
150
    var testInputs = function() {
151
      init();
143 152

  
144
    for(var i in mapSearchStmts) {
145
      var stmt = mapSearchStmts[i];
146
      if( stmt.charAt(0) == '#' ) {
147
        var val = $('#'+ prefix + stmt.substring(1)).val();
148
        if( val )
149
          searchString += val;
150
      }
153
      if( isNotEmpty() )
154
        $widgetWrapper.show();
151 155
      else
152
        searchString += stmt;
153
    }
154

  
155
    var url = 'https://maps.google.com/maps?q='+ encodeURIComponent(searchString);
156
        $widgetWrapper.hide();
157
    };
156 158

  
157
    window.open(url, '_blank');
158
    window.focus();
159
    this.render = render;
160
    this.testInputs = testInputs;
159 161
  };
160 162

  
161 163
  this.showHistoryWindow = function(id) {
templates/webpages/customer_vendor/tabs/billing.html
88 88
        [% L.input_tag('cv.street', SELF.cv.street, size = 35, maxlength = 75) %]
89 89
        <span id="billing_map"></span>
90 90
        <script type="text/javascript">
91
          kivi.CustomerVendor.showMapWidget('cv_', $('#billing_map'));
91
          billingMapWidget = new kivi.CustomerVendor.MapWidget('cv_');
92
          $(function() {
93
            billingMapWidget.render($('#billing_map'));
94
          });
92 95
        </script>
93 96
      </td>
94 97
    </tr>
templates/webpages/customer_vendor/tabs/contacts.html
159 159
        [% L.input_tag('contact.cp_street', SELF.contact.cp_street, size = 40, maxlength = 75) %]
160 160
        <span id="contact_map"></span>
161 161
        <script type="text/javascript">
162
        var contactsMapWidget = kivi.CustomerVendor.showMapWidget('contact_cp_', $('#contact_map'));
162
          var contactsMapWidget = new kivi.CustomerVendor.MapWidget('contact_cp_');
163
          $(function() {
164
            contactsMapWidget.render($('#contact_map'));
165
          });
163 166
        </script>
164 167
      </td>
165 168
    </tr>
templates/webpages/customer_vendor/tabs/shipto.html
47 47

  
48 48
        <span id="shipto_map"></span>
49 49
        <script type="text/javascript">
50
          var shiptoMapWidget = kivi.CustomerVendor.showMapWidget('shipto_shipto', $('#shipto_map'));
50
          shiptoMapWidget = new kivi.CustomerVendor.MapWidget('shipto_shipto');
51
          $(function() {
52
            shiptoMapWidget.render($('#shipto_map'));
53
          });
51 54
        </script>
52 55
      </td>
53 56
    </tr>

Auch abrufbar als: Unified diff