* creates the initializer script.
*
* @return initializer script
*/
protected String createScript(final ColorPickerConfig config) {
JQuery script = $(this);
if (config.isComponent()) {
script.closest(".colorpicker-component");
}
script.chain("colorpicker", config);
if (config.isAjaxUpdate()) {
List<ColorChangeAjaxBehavior> behaviors = getBehaviors(ColorChangeAjaxBehavior.class);
ColorChangeAjaxBehavior colorChangeAjaxBehavior = behaviors.get(0);
String toColor = config.getFormat().to();
CharSequence attrs = colorChangeAjaxBehavior.getAttrs();
script.on("changeColor", new JQuery.JavaScriptInlineFunction(
String.format("var color = evt.color.%s; new Wicket.Ajax.Call().ajax(%s)",
toColor, attrs)));
}
return script.get();
}