Archive for category Development
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.
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.

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 »



































