window.close() alert message
Posted by Nicolas Clavier in Development, Me, jQuery on August 26th, 2010
Hey, it’s a long time I haven’t posted anything here again. So today I’m going to share a very simple trick in javascript.
In the course of writing a webApp, I wanted the user to be alerted * whenever * closing the window containing the app.
window.onBeforeUnload is the event to use but this event is being triggered every time the window unloads, that means even if clicking on links or submitting a form in your page.
So here is how I delt with this little issue: we dont want to alert the user as long as the navigation is internal to the app. But we want to alert if closing the window.
in the head section of your page, early after including the jquery library, insert the following script:
/* Declare a global bool */
navAwayFromClick = false;
/* onBeforeUnload event happens every time the page changes location */
window.onbeforeunload = function(e)
{
/*
- Check if we are navigating away from the page since we clicked
either a button or a link
- Returns a message to present to the user.
*/
if (false == navAwayFromClick) return closingAlert(e);
}
function closingAlert(e)
{
var message = 'Are you sure you want to leave this page ?';
/* for consistency across browsers */
if (typeof e == 'undefined') {
e = window.event;
}
if (e) {
e.returnValue = message;
}
return message;
}
/*
Use jQuery to select all clickable elements, and bind a function to
them that will change the state of our gloobal boolean. This way we
know we are exiting the page after a click action.
The $("...").click(...) does not prevent default behavior of the click.
Up to you to trigger the same on other clickable elements.
*/
jQuery(document).ready(function()
{
jQuery("a").click(function(e)
{
navAwayFromClick = true;
});
jQuery("form").submit(function()
{
navAwayFromClick = true;
});
});
And that should work as expected, at least I tested it in Safari 5 and FireFox 3.6. If anyone cares about IE, let me know if it works.
The road to making curd (part 1)
Posted by Nicolas Clavier in Cheese Making, Food on January 18th, 2010
Yulia, my wife, who’s russian, has been teasing me since we know each other with the exceptionally fresh and tasty russian curd. Being a french man and therefore being seen abroad as wearing a label on my forehead saying “hey ! I’am an expert in smelly cheeses ! Come and ask me questions …” I got sort of challenged. And I must admit that I was seduced with what I tried.
Now, this may be obvious to some people, but thick curd is not something we’re used to here in France, or at least to my knowledge. Aspect wise it is a smooth creamy cheese that sticks to the spoon. It’s got a more or less yellowish color according to the percentage of fat that you choose. It hasn’t got a strong taste though according to how old it is, you may be getting a more pronounced acidic smell.
Read the rest of this entry »
Early skater..
Posted by Nicolas Clavier in Me, Photos, iphone on November 19th, 2009
Back .. at last !
Posted by Nicolas Clavier in Development, Me, cappuccino on November 16th, 2009
I know it’s been a long time since I have published on this blog … what or who can I blame ?
Life’s been hectic, getting married, settling down, learning Cappuccino etc .. I’ll publish pictures of all events in the relevant catégories soon.
For now I’d like to share this morning’s excitement, it’s all in the picture below. The guys at 280 North have unleashed the beast opened their beta program of Atlas.
Basically this software allows you to design the interface part a web app developed in Cappuccino / Objective J and is (amongst other benefits) going to save us an incredible amount of time !
As I’m writing those lines, the software is freshly downloaded, ready to open for the first time, and I can already confess that there is a slight Christmas atmosphere around this event … ))
All the best to the guys at 280 North, and a big thanks for bringing to us such a technology.

Theuville War Camp
Posted by Nicolas Clavier in Photos on May 26th, 2009
An incredible scene. Yulia and I were cycling when we ended up on a dead end right in the middle of a war camp ! Cameras out we were shooting away when
I suddenly stopped and wondered…”what is a war camp doing in this peaceful part of france anyway !?”
Recursive object merge with $.extend()
Posted by Nicolas Clavier in jQuery on April 1st, 2009
This post comes as an addition to this article:
Coding with a purpose: jquery $.extend() and $.fn.extend() confusion
As recommended in a jQuery plugin structure, I have a separate “default” object ($.fn.myplugin.defaults) which holds my default values for the plugin.
I then merge this object in the main function with a “configuration” object passed in Read the rest of this entry »
Starting with Cappuccino & Objective-J
Posted by Nicolas Clavier in Development on April 1st, 2009
Quoting the guys at 280north.com:
“Cappuccino is an open source framework that makes it easy to build desktop-caliber applications that run in a web browser.”
This web framework offers a different approach to web apps development by offering a desktop application architecture very close if not identical to Mac OS X apps. The language syntaxe is brand new to someone like me who Read the rest of this entry »
Winter Rain
Posted by Nicolas Clavier in Photos on March 31st, 2009
First post
Posted by Nicolas Clavier in Me on March 24th, 2009
Well this is it! I finally have a blog setup at this address. Originally Meninmac was the name of my little computer maintenance activity. I gave up the activity but I thought this name was cool and kept the domain name. Read the rest of this entry »



































