package de.alpharogroup.wicket.components.examples.tooltips;

import org.apache.wicket.Application;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import de.alpharogroup.wicket.behaviors.JavascriptAppenderBehavior;
import de.alpharogroup.wicket.behaviors.tooltipster.TooltipsterJsGenerator;
import de.alpharogroup.wicket.behaviors.tooltipster.TooltipsterSettings;
import de.alpharogroup.wicket.components.factory.ComponentFactory;

/**
 * The Panel for the example page with the several tooltips like tooltipster or bootstrap tooltip.
 */
public class TooltipsExamplePanel extends Panel
{

	/**
	 * The serialVersionUID
	 */
	private static final long serialVersionUID = 1L;

	public TooltipsExamplePanel(final String id, final IModel<?> model)
	{
		super(id, model);
		Label label = ComponentFactory.newLabel("tooltipTestLabel",
			Model.of("Im example for tooltipster."));
		TooltipsterSettings tooltipsterSettings = new TooltipsterSettings();
		// tooltipsterSettings.getAnimation().setValue("grow");
		// tooltipsterSettings.getArrow().setValue(false);
		tooltipsterSettings.getContent().setValue("Loading...");
		TooltipsterJsGenerator tooltipsterJsGenerator = new TooltipsterJsGenerator(
			tooltipsterSettings, label);
		String js = tooltipsterJsGenerator.generateJs();
		label.add(new JavascriptAppenderBehavior(js, "tooltip_" + label.getMarkupId()));
		add(label);
	}


	/**
	 * {@inheritDoc}
	 */
	@Override
	public void renderHead(IHeaderResponse response)
	{
		super.renderHead(response);
		response.render(JavaScriptHeaderItem.forReference(Application.get()
			.getJavaScriptLibrarySettings().getJQueryReference()));
		response.render(JavaScriptHeaderItem
			.forReference(TooltipsterJsGenerator.TOOLTIPSTER_PLUGIN_REFERENCE));
	}
}

@@ -536,24 +536,107 @@
 Generator;%0D%0A
+import de.alpharogroup.wicket.behaviors.tooltipster.TooltipsterResourceReference;%0D%0A
 import de.al
@@ -697,16 +697,16 @@
 tings;%0D%0A
-
 import d
@@ -1296,27 +1296,24 @@
 tings();%0D%0A%09%09
-// 
 tooltipsterS
@@ -1360,11 +1360,8 @@
 %0D%0A%09%09
-// 
 tool
@@ -1457,16 +1457,20 @@
 %22Loading
+ foo
 ...%22);%0D%0A
@@ -1573,24 +1573,38 @@
 tings, label
+.getMarkupId()
 );%0D%0A%09%09String
@@ -2086,45 +2086,31 @@
 ster
-JsGenerator.TOOLTIPSTER_PLUGIN_REFERE
+ResourceReference.INSTA
 NCE)

update to new settings.