New theme

As You can see, adjusting new theme took less then I excepted. Well, I should not saying this, since not everything works yet. In IE 7.0 blog header (title) does not render, and I have no idea why…

New theme is IMO better because uses much more screen (resolutions lower than 1024×768 are on less than 1% browsers used to view this site), and allows to put some kind of suggestions for useful content on sidebars. I hope to work on this suggestions, and as result lower bounce rate.

On the side, WordPress is really powerful tool to publish in Internet…

Save editing WordPress theme on live site

I’m preparing to make major change in layout of this blog, mostly because of poor bounce rate. When reader comes here from Google, and lands directly on some post page, there are no suggestions what he/she can read more. I do believe I have here some useful content and make bounce rate better.

So I needed to establish way how to create and edit new theme and don’t interfere with readers. Solutions could be to do it on local copy or make it short and work on live site. Since I didn’t want to do it on local copy (I’m to lazy :) ) I wanted something else.

Solution is very simple, it took less time than write this post ;-)) Install ThemeSwitcher plugin, activate it and edit for example sidebar (sidebar.php in default WP theme). Add in some place following code:

<?php if ( current_user_can('edit_themes') ) { ?>
<li>Themes:
        <?php wp_theme_switcher(); ?>
</li>
<?php }
?>

Starting from now users with privilege of editing themes (that mean administrator role) could switch to other themes. Install now new theme You want to tweak and switch to it. You can edit files on server and test results, when all other users get old (but not broken by development efforts) theme.

Code generation and events in Google Maps API

I’m moving fast with new RNS features development and I discover new GM API nuances, this time with events.

In map edition mode it will be possible to change icons for particular route points and add some notes. All markers are kept in array, and for each marker I add listener for event ‘click’ which opens info windows with openInfoWindowHtml(). Pretty straightforward. But HTML code for this window becomes a little more complicated. In this window I place bunch of links, which are basically calls to JavaScript functions (with onclick property) with parameters generated when ‘click’ handler for particular marker is run. This code is dynamic and depends on other variables state, thus results can differ for each time handler is used for some marker.

Today I have noticed that click on opened info window will trigger Google Maps ‘click’ event, and since info window is another overlay in terms of GM API, You should be aware that using code from GM API documentation to add markers can lead to errors.

var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(37.4419, -122.1419), 13);

GEvent.addListener(map, "click", function(marker, point) {
  if (marker) {
    map.removeOverlay(marker);
  } else {
    map.addOverlay(new GMarker(point));
  }

If You open somewhere info window with link on it, clicking on it will trigger again ‘click’ event on map object with marker variable pointing to overlay which represents info window. And as result with above code will close info window. If link is leading to some other page this is no problem, but in case You need to not running this event when window is open (this was my case, ‘click’ event handler was messing variables state, since it was ‘thinking‘ it was clicked on marker) You can add some logical global variable to check at event handler start:

GEvent.addListener(map, "click", function(marker, point) {
  if (!runClickEvent)
     return
  if (marker) {
    map.removeOverlay(marker);
  } else {
    map.addOverlay(new GMarker(point));
  }

And open info window this way:

marker.openInfoWindowHtml(content)
runClickEvent = false
GEvent.addListener( map.getInfoWindow(), 'closeclick', 
    function () { runClickEvent = true } )

Last line adds new handler for event fired when user clicks in close button on info window. Handler is responsible for restoring ‘click’ handler to usable state setting global variable to value resulting in not returning from first if in ‘click’ handler.

Don’t forget to initialize runClickEvent on script beginning with var runClickEvent = true

Smaller labels on Google Maps

I’m using TLabel library to support more compact and handy labels on map in RNS application. It works very well, buthen You add labels on map with many other elements (markers, polygons) You may noticed label is below markers.

This makes labels hard readable. This is caused by default level on which are they attached to map. If You want to display them over everything else (except info window), change in tlabel.js constant G_MAP_MAP_PANE to G_MAP_FLOAT_PANE in TLabel.prototype.initialize and in removeTLabel

Migrations with advanced data operations

I was quite busy last week. I’m developing major upgrade to Run-N-Share, my daily job brings me some normal Cisco (eeek it is no more fun and exciting thing for me) related work, and I was testing updated geocoding services for Poland area from Google (in polish).

Making major changes to RNS means migrations heavy usage. It turns out I had some misconceptions about them, but now with new experience I can use it more efficiently.

So few words for You, maybe it will save Your time.

Continue reading