Fixes rendering of Google Maps in mobile sidebars
authorMatthias Schmidt <gravatronics@live.com>
Thu, 20 Mar 2014 16:26:23 +0000 (17:26 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 20 Mar 2014 16:26:23 +0000 (17:26 +0100)
wcfsetup/install/files/js/WCF.Location.js

index 379669f8c090313454ad0beb459bf53b6a4f80a2..19c4713050ba2fc5a556c7d0c23b9c5d87eabe8d 100644 (file)
@@ -117,9 +117,25 @@ WCF.Location.GoogleMaps.Map = Class.extend({
                this._map = new google.maps.Map(this._mapContainer[0], this._mapOptions);
                this._markers = [ ];
                
+               // fix maps in mobile sidebars by refreshing the map when displaying
+               // the map
+               if (this._mapContainer.parents('.sidebar').length) {
+                       enquire.register('screen and (max-width: 800px)', {
+                               setup: $.proxy(this._addSidebarMapListener, this),
+                               deferSetup: true
+                       });
+               }
+               
                this.refresh();
        },
        
+       /**
+        * Adds click listener to mobile sidebar toggle button to refresh map.
+        */
+       _addSidebarMapListener: function() {
+               $('.content > .mobileSidebarToggleButton').click($.proxy(this.refresh, this));
+       },
+       
        /**
         * Returns the default map options.
         *