[OpenLayers-Commits] r12164 - trunk/openlayers/examples

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Tue Jul 12 11:21:16 EDT 2011


Author: ahocevar
Date: 2011-07-12 08:21:14 -0700 (Tue, 12 Jul 2011)
New Revision: 12164

Modified:
   trunk/openlayers/examples/mobile-jq.js
Log:
fixing the example so it also works with later versions of jquery mobile

Modified: trunk/openlayers/examples/mobile-jq.js
===================================================================
--- trunk/openlayers/examples/mobile-jq.js	2011-07-11 17:07:15 UTC (rev 12163)
+++ trunk/openlayers/examples/mobile-jq.js	2011-07-12 15:21:14 UTC (rev 12164)
@@ -1,3 +1,6 @@
+// Start with the map page
+window.location.replace(window.location.href.split("#")[0] + "#mappage");
+
 var selectedFeature = null;
 
 $(document).ready(function() {
@@ -2,18 +5,14 @@
 
-    // Start with the map page
-    if (window.location.hash && window.location.hash!='#mappage') {
-        $.mobile.changePage('mappage');
-    }
-
     // fix height of content
     function fixContentHeight() {
         var footer = $("div[data-role='footer']:visible"),
-        content = $("div[data-role='content']:visible:visible"),
-        viewHeight = $(window).height(),
-        contentHeight = viewHeight - footer.outerHeight();
+            content = $("div[data-role='content']:visible:visible"),
+            viewHeight = $(window).height(),
+            contentHeight = viewHeight - footer.outerHeight();
 
         if ((content.outerHeight() + footer.outerHeight()) !== viewHeight) {
-            contentHeight -= (content.outerHeight() - content.height());
+            contentHeight -= (content.outerHeight() - content.height() + 1);
             content.height(contentHeight);
         }
+
         if (window.map) {
@@ -24,13 +23,12 @@
             // initialize map
             init(function(feature) { 
                 selectedFeature = feature; 
-                $.mobile.changePage($("#popup"), "pop"); 
+                $.mobile.changePage("#popup", "pop"); 
             });
+            initLayerList();
         }
     }
     $(window).bind("orientationchange resize pageshow", fixContentHeight);
-    fixContentHeight(); 
-    //init();
 
     // Map zoom  
     $("#plus").click(function(){
@@ -48,7 +46,7 @@
         }
     });
     
-    $('div#popup').live('pageshow',function(event, ui){
+    $('#popup').live('pageshow',function(event, ui){
         var li = "";
         for(var attr in selectedFeature.attributes){
             li += "<li><div style='width:25%;float:left'>" + attr + "</div><div style='width:75%;float:right'>" 
@@ -83,7 +81,7 @@
                         }))
                         .appendTo('#search_results')
                         .click(function() {
-                            $.mobile.changePage('mappage');
+                            $.mobile.changePage('#mappage');
                             var lonlat = new OpenLayers.LonLat(place.lng, place.lat);
                             map.setCenter(lonlat.transform(gg, sm), 10);
                         })
@@ -97,7 +95,10 @@
         $('#searchpage').die('pageshow', arguments.callee);
     });
 
-    $('#layerslist').listview();
+});
+
+function initLayerList() {
+    $('#layerspage').page();
     $('<li>', {
             "data-role": "list-divider",
             text: "Base Layers"
@@ -122,7 +123,7 @@
     map.events.register("addlayer", this, function(e) {
         addLayerToList(e.layer);
     });
-});
+}
 
 function addLayerToList(layer) {
     var item = $('<li>', {
@@ -133,7 +134,7 @@
             text: layer.name
         })
             .click(function() {
-                $.mobile.changePage('mappage');
+                $.mobile.changePage('#mappage');
                 if (layer.isBaseLayer) {
                     layer.map.setBaseLayer(layer);
                 } else {



More information about the Commits mailing list