X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fgooglemaps%2Fstatic%2Fjs%2Fgooglemaps.js;h=8973c45d562707eca5905c7da7f835d626fd65aa;hb=f23f0ef5fc4dcf8c087341941b4176ba2b119f3a;hp=aefd2cb93f6aa78adb8739fea1389a497b986602;hpb=0f95c8fe41bff140a98c693cc1ec7be669820d94;p=myslice.git diff --git a/plugins/googlemaps/static/js/googlemaps.js b/plugins/googlemaps/static/js/googlemaps.js index aefd2cb9..8973c45d 100644 --- a/plugins/googlemaps/static/js/googlemaps.js +++ b/plugins/googlemaps/static/js/googlemaps.js @@ -4,12 +4,19 @@ * License: GPLv3 */ +/* BUGS: + * - infowindow is not properly reopened when the maps does not have the focus + */ + +googlemaps_debug=true; +googlemaps_debug_detailed=false; + (function($){ var GoogleMaps = Plugin.extend({ - init: function(options, element) - { + init: function(options, element) { + if (googlemaps_debug) messages.debug("GoogleMaps.init"); this._super(options, element); /* Member variables */ @@ -42,8 +49,8 @@ /* PLUGIN EVENTS */ - on_show: function(e) - { + on_show: function(e) { + if (googlemaps_debug) messages.debug("on_show"); var self = e.data; google.maps.event.trigger(self.map, 'resize'); }, // on_show @@ -54,8 +61,8 @@ /** */ - initialize_map: function() - { + initialize_map: function() { + if (googlemaps_debug) messages.debug("initialize_map"); this.markerCluster = null; this.coords = new Array(); @@ -63,16 +70,22 @@ var myOptions = { zoom: this.options.zoom, center: myLatlng, - mapTypeId: google.maps.MapTypeId.ROADMAP + mapTypeId: google.maps.MapTypeId.ROADMAP, } - var id = this.options.plugin_uuid + manifold.separator + 'map'; - this.map = new google.maps.Map(document.getElementById(id), myOptions); + 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); + this.map = new google.maps.Map(el, myOptions); this.infowindow = new google.maps.InfoWindow(); }, // initialize_map - set_checkbox: function(record, checked) - { + set_checkbox: function(record, checked) { + if (googlemaps_debug_detailed) messages.debug ("set_checkbox"); + /* Default: checked = true */ + if (typeof checked === 'undefined') + checked = true; + var key_value; /* The function accepts both records and their key */ switch (manifold.get_type(record)) { @@ -95,28 +108,24 @@ var dict_info = this.map_markers[unfold.escape_id(key_value).replace(/\\/g, '')]; - /* Default: swap check status */ - if (typeof checked === 'undefined') - dict_info.in_set = !dict_info.in_set; - else - dict_info.in_set = checked; // Update the marker content + dict_info.in_set = checked; dict_info.marker.content = this.get_marker_content(dict_info.record, checked); // Update opened infowindow // XXX Factor this code this.infowindow.close(); - this.infowindow.setContent(dict_info.marker.content); 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); //var button = this.checkbox(record, checked); //this.el('checkbox', this.id_from_record(method, record)).html(button); }, - checkbox: function(record, checked) - { + checkbox: function(record, checked) { + if (googlemaps_debug_detailed) messages.debug ("checkbox"); if (typeof checked === 'undefined') checked = false; @@ -135,15 +144,15 @@ return "
' + this.method + ': ' + get_value(record['resource_hrn']) + '
network: ' + get_value(record['network'])+'