public String getResizeEndDefinition() {
		StringBuilder sb = new StringBuilder();
		sb.append("$(window).resize(function() {").
		   append("if(this.resizeTO) clearTimeout(this.resizeTO);").
		   append("this.resizeTO = setTimeout(function() {").
		   append("$(this).trigger('resizeEnd');").
		   append("}, 500);").
		   append("});");
		return sb.toString();
	}
public String getResizeEndDefinition ( ) { StringBuilder sb = new StringBuilder ( ) ; sb . append ( "$(window).resize(function() {" ) . append ( "if(this.resizeTO) clearTimeout(this.resizeTO);" ) . append ( "this.resizeTO = setTimeout(function() {" ) . append ( "$(this).trigger('resizeEnd');" ) . append ( "}, 500);" ) . append ( "});" ) ; return sb . toString ( ) ; }
http://stackoverflow.com/questions/2996431/detect-when-a-window-is-resized-using-javascript