Wednesday, January 20, 2010

Page decomposition with JQuery UI

Today I've tried something funny with JQuery UI. I was thinking about marketing teams hardly trying to make understand their vision through ugly drawings made in Photoshop or even MS Paint :-)
With JQuery it is very easy to decompose page elements and make them draggable.
Just go to a website running JQuery UI, open you firebug console and paste & run the following code:

jQuery('body *:visible').draggable({opacity: 0.4}).hover(function(event) {
event.stopPropagation();
event.stopImmediatePropagation();
event.currentTarget.oldStyles = {
border: event.currentTarget.style.border,
cursor: event.currentTarget.style.cursor
};
event.currentTarget.style.border='1px solid blue';
event.currentTarget.style.cursor='pointer';
}, function(event) {
if(event.currentTarget.oldStyles) {
event.currentTarget.style.border=event.currentTarget.oldStyles.border;
event.currentTarget.style.cursor=event.currentTarget.oldStyles.cursor;
}
});

Click here to try it on my blog !

2 comments: