Using a watermark plugin for jQuery, I'm attempting to jslint and minimize the functions but I've come across syntax I have never seen before wherein there are expressions where there really ought to be an assignment or function call:
(function($) {
$.fn.watermark = function(css, text) {
return this.each(function() {
var i = $(this), w;
i.focus(function() {
w && !(w=0) && i.removeClass(css).data('w',0).val('');
})
.blur(function() {
!i.val() && (w=1) && i.addClass(css).data('w',1).val(text);
})
.closest('form').submit(function() {
w && i.val('');
});
i.blur();
});
};
$.fn.removeWatermark = function() {
return this.each(function() {
$(this).data('w') && $(this).val('');
});
};
})(jQuery);
I'm specifically interested in the following lines:
w && !(w=0) && i.removeClass(css).data('w',0).val('');
and
!i.val() && (w=1) && i.addClass(css).data('w',1).val(text);
Can someone explain this shorthand and rewrite these functions in such a way that I could compare them to better to understand the shorthand myself?
Thank you.