Category Archives: web development

OpenLayers disable mouse wheel on zoom

What is OpenLayers?

OpenLayers is a open source JavaScript library, which helps for the usage and development of web based map applications. Usually when you use something like http://openstreetmap.org you’ve a tile server, which contains, or dynamically, renders tiles on a specific coordinates and zoom level. Such application in basic are most of the map servers you may know, as Google, Yahoo and Live (now Bing). Than you need a layer above that, that must generate the correct HTTP queries to the server and after receiving the tiles to position them correctly. Of course a open library like OpenLayers do much more. In fact this is complex JavaScript application that gives enough flexability to manipulate rich map applications.

How to disable the zoom with the mouse wheel

Very common problem (if we can say so) in map sites is the scroll, cause sometimes the user wants to scroll the page, and sometimes to scroll the map, which action results in zooming the map. Yes, there are so many solutions as many are the combinations of those scenarios. But the case here was how to disable the mouse wheel on OpenLayers. Continue reading OpenLayers disable mouse wheel on zoom →

Zend Framework – quick tutorial (part 3) – front controller plugins

Why writing a front controller plugin?

Almost every application uses a database connection and acl module. Why doing this in the bootstrap and to mantain many lines of code there, instead of making it clear and mantainable. Of course you can have all these lines of code in your bootstrap, but you know for serious applications that recently will become an obstacle. That’s why Zend Framework allows you to use Front_Controller plugin.

First in you bootstrap add those lines of code

/*
 * add a simple plugin to the controller
 */
 
$front->registerPlugin(new Zend_Controller_Plugin_Init())
      ->registerPlugin(new Zend_Controller_Plugin_Acl());

These two classes (Zend_Controller_Plugin_Init and Zend_Controller_Plugin_Acl) should be placed in two different files with the same names in Controller/Plugins directory under Zend folder, and garantee you that both classes will be instanciated before starting the front controller. Continue reading Zend Framework – quick tutorial (part 3) – front controller plugins →

Semi Transparent PNG8 with no Fireworks

PNG8 vs other image formats

PNG8 is a rising winner in all the battles between the web formats. It has smaller size than GIF and PNG24, it has alpha channel, and the really big advantage is the semi transparency, which unfortunately degrade in IE6 to a GIF-like full transparency. So there are few very important advantages at all:

1. smaller size than PNG24 and GIF

2. same semi-transparent pixels as PNG24 but with smaller size and no need of alpha filter for IE6, where there’s a GIF like full transparency.

Fireworks and semi transparent pixels in PNG8

The problem is that only Adobe (former Macromedia) Fireworks can export such semi transparent PNG8s, and it’s not free. You may guess PNG (Portable Network Graphics) is a Macromedia format which unfortunately turns into closed capability of rendering PNG8 with transparency and with no need of Fireworks. Very sad!

Recent discovery

Finally these days I found a workaround with PNG8 and it’s called pngquant. You can find the tutorial on http://www.ethanandjamie.com/blog/37-user-interface/81-png8-transparency-without-fireworks and everything here’s about the above pngquant.

Now make your website sprites

a PNG8

Google Adsense, iframes and IE

What a lovely combination

Recently I wrote an article about the Google Adsense problem with page load blocking and than the solution was simple and elegant. You must put your ad in a separate .html file and to include it into your page with an iframe. That gives the page the ability to “breath” and to load faster.

You can see the entire article here.

When everything’s OK, wait for the IE

Yes as usual every browser loaded the iframe correclty, except … Continue reading Google Adsense, iframes and IE →

JavaScript encode cyrillic symbols with encodeURIComponent

JavaScript and Cyrillic

Let’s assume we’ve a JavaScript file which rewrites the location.href, resulting in changes in the URI of the browser. Everything is OK till you work with Latin alphabet. The problem arises when you decide to put some Cyrillic symbols into the string.

The encode() function

With that function you can encode the URL if you have some entity symbols. It is not like but it should be something like encodeURI in PHP. The problem is that this function does not work correctly with Cyrillic symbols.

Use encodeURIComponent

There is another usefull function which does this. It’s called encodeURIComponent, and I strongly recomment its use.