20 February 2011

NodeJS 0.4 + npm 0.3.1 on Windows the easy way

Getting node JS on Windows is nothing very hard but you have to compile it using MingW or in Cygwin environment. The guys from node-js.prcn.co.cc were making it much easier creating the bundle that is easy to use: just download, unpack & run.

Because I use node JS everyday and wanted to have 0.4 on board I've created own bundle. The bundle is based on their great work but except the run scripts it is build from scratch (newer npm, newer cygwin libs, added bash etc.). You can grab it from my Node JS on Windows page. Please read instructions about using npm.

16 January 2011

IE9 and fancy border image buttons

Current Webkit, Firefox and Opera support border-image CSS which allows creating fancy buttons with advanced border. The problem is that IE9 will likely not support this CSS3 element. By fancy buttons I means ones with cannot be easily done with combination of box-shadow, border-radius and gradients (or if it is not available using box-shadow inset). More of creating such buttons you will find on Opera's Beutiful UI Styling with CSS3 article. It is the simpler route if you do not need extra fanciness as there is no images involved.
Of course there are old tricks to get fancy buttons work in all browsers by creating <a> with <span> tag. But suppose we only want to have an <a> tag. In addition we want to have the button universally stretchable. Border-image allows stretching horizontally and vertically but for most buttons only X axis is important so lets go that route.

In standard solution working for current Chrome & Safari, Firefox 3.6+ and Opera 11 you just have to have 9 slice image and add below CSS:


a.button.bi {
border-width: 0 12px;
-webkit-border-image: url(button.png) 0 12 0 12;
-moz-border-image: url(button.png) 0 12 0 12;
-o-border-image: url(button.png) 0 12 0 12;
border-image: url(button.png) 0 12 0 12;
}

If we do the above on IE9 beta and have both white background and white button text, we see nothing (top example on demo page). Making it to work on IE9 (and with some additional work also on IE8) requires much more work:


a.button.mb {
margin: 0 22px;
position: relative;
background: url(button.png) center repeat-x;
-moz-background-size: 300% 100%;
-o-background-size: 300% 100%;
-webkit-background-size: 300% 100%;
background-size: 300% 100%;
}

a.button.mb:after, a.button.mb:before {
content: " "; /* this is &nbsp; char, not a normal space char*/
top: 0;
display: block;
position: absolute;
width: 12px;
height: 46px;
background: url(button.png) no-repeat;
}

a.button.mb:before {
left: -12px;
background-position: top left;
}

a.button.mb:after {
right: -12px;
background-position: top right;
}

Please see that we are still using exactly the same slice image (it should be a little wider for reasons mentioned below). The approach has some limitations:
  • stretching with background size is not the same as border-image stretch
  • Opera 11 does not play nicely with background-size above 300%, a bug maybe?
  • pattern in the button must allow stretching & repeating, but most of the time it is the case also for border-image (but you an choose stretching OR repeating ;)
If we remove background-size and use very wide button background, we also get support on IE8 if we need to.
Demo page has the second version shown as the bottom image. In addition you can see the used button image.

7 January 2011

Updated look & info

In new year new blog look and also some small updates. It should also be better with new posts, will see.

18 April 2010

Chrome + Adobe Flash on Ubuntu 10.04 64-bit

In the recent post from Google Chrome you can read that they will provide Adobe Flash plugin with the browser itself. Of course it is still in development branch but as for now they will not provide 64-bit version on Linux :( But installing Flash Player 10 64-bit for Linux (labs release) is nothing hard (tested on Chrome 5.0.342.9 beta, 64-bit):
  1. Download plugin from http://labs.adobe.com/downloads/flashplayer10_64bit.html
  2. Unpack it.
  3. Use command sudo cp libflashplayer.so /usr/lib/mozilla/plugins/
  4. Restart Chrome.
  5. You can check if everything worked fine by using about:plugins page.

6 April 2010

Close PhoneGap/Android application from JavaScript

Normally you do not care much about creating "Close" button for Web pages. The same happens when you create Android application using PhoneGap (a wrapper for HTML/CSS/JS development) because user closes the app using hardware button or other system provided method. The problem was that today I had to close PhoneGap application using JavaScript call. PhoneGap by default does not have such an option, but adding it was really easy.

I assume you have the latest edge source code of PhoneGap for Android. Find the file framework/src/com/phonegap/PhoneGap.java and then add to it at the end (before last closing bracket) below code:

public void closeApp(){
Activity act = (Activity) mCtx;
act.setResult(0);
act.finish();
}


In addition add the below import at the beginning of the file:

import android.app.Activity;

Next you compile phonegap.jar as always. To close application you just call DroidGap.closeApp().