All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wicketstuff.jwicket.tooltip.WTooltip Maven / Gradle / Ivy

Go to download

WicketJQuery by Stefan Lindner has been renamed to jWicket, mavenized, and migrated to WicketStuff. This Wicketstuff version supercedes the original version which was available at http://subversion.visionet.de/project/WicketJQuery/wiki

There is a newer version: 1.4.21
Show newest version
package org.wicketstuff.jwicket.tooltip;


import org.apache.wicket.Component;
import org.apache.wicket.markup.html.IHeaderContributor;
import org.apache.wicket.markup.html.IHeaderResponse;
import org.wicketstuff.jwicket.JQuery;
import org.wicketstuff.jwicket.JQueryAjaxBehavior;
import org.wicketstuff.jwicket.JQueryJavascriptResourceReference;
import org.wicketstuff.jwicket.JQueryResourceReferenceType;


/**
 * This Class is a wrapper around the jQuery plugin wTooltip 
 */
public class WTooltip extends AbstractToolTip {
	private static final long serialVersionUID = 1L;

	private static final JQueryJavascriptResourceReference wTooltip = new JQueryJavascriptResourceReference(WTooltip.class, "wTooltip.js", JQueryResourceReferenceType.NOT_OVERRIDABLE);


	private String style;
	private String cssClassName;
	private int offsetX = 1;
	private int offsetY = -10;
	private int fadeinMs = 0;
	private int fadeoutMs = 0;
	private int delayMs = 0;
	private int timeoutMs = 0;


	public WTooltip(final String tooltipText) {
		super(tooltipText);
	}


	@Override
	IHeaderContributor getHeadercontributor() {
		return new JQueryAjaxBehavior(wTooltip) {
			private static final long serialVersionUID = 1L;

			@Override
			public void renderHead(IHeaderResponse response) {
				super.renderHead(response);

				response.renderJavascript(getJavaScript(), null);
			}
		};
	}
	
	
	public WTooltip setTooltipText(final String htmlCode) {
		this.tooltipText = htmlCode.replace(" 0) {
				builder.append(",style:{");
				builder.append(style);
				builder.append("}");
			}
			if (cssClassName != null && cssClassName.trim().length() > 0) {
				builder.append(",className:'");
				builder.append(cssClassName);
				builder.append("'");
			}
			if (offsetX != 1) {
				builder.append(",offsetX:");
				builder.append(offsetX);
			}
			if (offsetY != -10) {
				builder.append(",offsetY:");
				builder.append(offsetY);
			}
			if (fadeinMs != 0) {
				builder.append(",fadeIn:");
				builder.append(fadeinMs);
			}
			if (fadeoutMs != 0) {
				builder.append(",fadeOut:");
				builder.append(fadeoutMs);
			}
			if (delayMs != 0) {
				builder.append(",delay:");
				builder.append(delayMs);
			}
			if (timeoutMs != 0) {
				builder.append(",timeout:");
				builder.append(timeoutMs);
			}
			builder.append("});});");
		}
		return builder.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy