X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fgooglemaps%2Fstatic%2Fjs%2Fgooglemaps.js;h=2a4df3d689d3b1169107df20a33ccc2eb2919dfa;hb=22dba9d34674e0cc1b285e678bbb7bc6482c58ca;hp=cf3bc28f82a4862a69df60f3dd00d02686918ea5;hpb=91f54bd15e11b1e1e0f5dd18638e75312f739cf9;p=myslice.git diff --git a/plugins/googlemaps/static/js/googlemaps.js b/plugins/googlemaps/static/js/googlemaps.js index cf3bc28f..2a4df3d6 100644 --- a/plugins/googlemaps/static/js/googlemaps.js +++ b/plugins/googlemaps/static/js/googlemaps.js @@ -13,7 +13,7 @@ googlemaps_debug_detailed=false; (function($){ - var GoogleMaps = Plugin.extend({ + var GoogleMaps = Plugin.extend({ init: function(options, element) { if (googlemaps_debug) messages.debug("GoogleMaps.init"); @@ -23,7 +23,7 @@ googlemaps_debug_detailed=false; // query status this.received_all = false; this.received_set = false; - this.in_set_buffer = Array(); + this.in_set_buffer = []; // key -> { marker, checked } this.map_markers = {} @@ -72,7 +72,7 @@ googlemaps_debug_detailed=false; center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP, } - + var domid = this.options.plugin_uuid + manifold.separator + 'map'; var el = document.getElementById(domid); if (googlemaps_debug) messages.debug("gmap.initialize_map based on domid=" + domid + " el=" + el); @@ -89,16 +89,16 @@ googlemaps_debug_detailed=false; var key_value; /* The function accepts both records and their key */ switch (manifold.get_type(record)) { - case TYPE_VALUE: - key_value = record; - break; - case TYPE_RECORD: - /* XXX Test the key before ? */ - key_value = record[this.key]; - break; - default: - throw "Not implemented"; - break; + case TYPE_VALUE: + key_value = record; + break; + case TYPE_RECORD: + /* XXX Test the key before ? */ + key_value = record[this.key]; + break; + default: + throw "Not implemented"; + break; } // we cannot directly edit html, since nothing but marker is displayed @@ -113,16 +113,16 @@ googlemaps_debug_detailed=false; dict_info.in_set = checked; dict_info.marker.content = this.get_marker_content(dict_info.record, checked); -// Thierry - this code seems to cause the googlmap area to go all grayed out -// once all the quesries have come back -// BEG turning off temporarily -// // Update opened infowindow -// // XXX Factor this code -// this.infowindow.close(); -// this.infowindow.open(this.map, dict_info.marker); -// this.infowindow.setContent(dict_info.marker.content); -// this.els('map-button').unbind('click').click(this, this._button_click); -// END turning off temporarily + // Thierry - this code seems to cause the googlmap area to go all grayed out + // once all the quesries have come back + // BEG turning off temporarily + // // Update opened infowindow + // // XXX Factor this code + // this.infowindow.close(); + // this.infowindow.open(this.map, dict_info.marker); + // this.infowindow.setContent(dict_info.marker.content); + // this.elts('map-button').unbind('click').click(this, this._button_click); + // END turning off temporarily //var button = this.checkbox(record, checked); //this.el('checkbox', this.id_from_record(method, record)).html(button); }, @@ -182,23 +182,23 @@ googlemaps_debug_detailed=false; //jQuery(".map-button").click(button_click); //if(jQuery.inArray(record, rows)>-1){ - var marker = new google.maps.Marker({ - position: myLatlng, - title: get_value(record['hostname']), - // This should be done by the rendering - content: this.get_marker_content(record, false), - }); - - this.addInfoWindow(marker, this.map); - var key_value = (this.key in record) ? record[this.key] : null; - if (!key_value) - return; - this.map_markers[unfold.escape_id(key_value).replace(/\\/g, '')] = { - marker: marker, - in_set: false, - record: record, - value: key_value - } + var marker = new google.maps.Marker({ + position: myLatlng, + title: get_value(record['hostname']), + // This should be done by the rendering + content: this.get_marker_content(record, false), + }); + + this.addInfoWindow(marker, this.map); + var key_value = (this.key in record) ? record[this.key] : null; + if (!key_value) + return; + this.map_markers[unfold.escape_id(key_value).replace(/\\/g, '')] = { + marker: marker, + in_set: false, + record: record, + value: key_value + } //} }, // new_record @@ -214,8 +214,8 @@ googlemaps_debug_detailed=false; self.infowindow.open(map, marker); // onload of the infowindow on the map, bind a click on a button google.maps.event.addListener(self.infowindow, 'domready', function() { - self.els('map-button').unbind('click').click(self, self._button_click); -// jQuery(".map-button").click({instance: instance_, infoWindow: object.infowindow}, button_click); + self.elts('map-button').unbind('click').click(self, self._button_click); + // jQuery(".map-button").click({instance: instance_, infoWindow: object.infowindow}, button_click); }); }); }, // addInfoWindow @@ -255,16 +255,16 @@ googlemaps_debug_detailed=false; on_field_state_changed: function(data) { if (googlemaps_debug) messages.debug("on_field_state_changed"); switch(data.request) { - case FIELD_REQUEST_ADD: - case FIELD_REQUEST_ADD_RESET: - this.set_checkbox(data.value, true); - break; - case FIELD_REQUEST_REMOVE: - case FIELD_REQUEST_REMOVE_RESET: - this.set_checkbox(data.value, false); - break; - default: - break; + case FIELD_REQUEST_ADD: + case FIELD_REQUEST_ADD_RESET: + this.set_checkbox(data.value, true); + break; + case FIELD_REQUEST_REMOVE: + case FIELD_REQUEST_REMOVE_RESET: + this.set_checkbox(data.value, false); + break; + default: + break; } }, @@ -297,10 +297,10 @@ googlemaps_debug_detailed=false; var cluster_markers = cluster.getMarkers(); var bounds = new google.maps.LatLngBounds(); /* - * date: 24/05/2012 - * author: lbaron - * Firefox JS Error - replaced $.each by JQuery.each - */ + * date: 24/05/2012 + * author: lbaron + * Firefox JS Error - replaced $.each by JQuery.each + */ jQuery.each(cluster_markers, function(i, marker){ bounds.extend(marker.getPosition()); }); @@ -318,6 +318,8 @@ googlemaps_debug_detailed=false; $.each(this.in_set_buffer, function(i, record) { self.set_checkbox(record, true); }); + // reset + self.in_set_buffer = []; this.unspin(); }