package org.orienteer.core.widget.command;

import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.orienteer.core.component.command.AjaxCommand;
import org.orienteer.core.widget.AbstractWidget;

/**
 * Command to make widget fullscreen and back 
 * @param <T> the type of an entity to which this command can be applied
 */
public class FullScreenCommand<T> extends AjaxCommand<T> {
	
	private boolean expanded = false;
	public FullScreenCommand(String commandId) {
		super(commandId, Model.of());
		setAutoNotify(false);
	}
	
	@Override
	protected void onConfigure() {
		super.onConfigure();
		getLink().get("label").setDefaultModelObject(getLocalizer().getString(expanded?"command.fullscreen.min":"command.fullscreen.max", null));
	}

	@Override
	public void onClick(AjaxRequestTarget target) {
		expanded=!expanded;
		configure();
		target.add(this);
		AbstractWidget<?> widget = findParent(AbstractWidget.class);
		target.appendJavaScript("$('body').toggleClass('noscroll'); $('#"+widget.getMarkupId()+"').toggleClass('fullscreen');");
	}

}

@@ -90,47 +90,8 @@
 et;%0A
-import org.apache.wicket.model.IModel;%0A
 impo
@@ -124,16 +124,16 @@
 .Model;%0A
+
 import o
@@ -427,13 +427,15 @@
 %0A%09pr
-ivate
+otected
  boo
@@ -897,68 +897,344 @@
 ;%0A%09%09
-AbstractWidget%3C?%3E widget = findParent(AbstractWidget.class);
+appendJavaScript(findParent(AbstractWidget.class), target);%0A%09%7D%0A%0A%09/**%0A%09 * Append JavaScript code which enable widget fullscreen mode%0A%09 * @param widget %7B@link AbstractWidget%7D which need to be fullscreen%0A%09 * @param target %7B@link AjaxRequestTarget%7D%0A%09 */%0A%09protected void appendJavaScript(AbstractWidget%3C?%3E widget, AjaxRequestTarget target) %7B
 %0A%09%09t
@@ -1353,14 +1353,13 @@
 n');%22);%0A
+
 %09%7D%0A
-%0A
 %7D%0A

Add protected method and protected field to FullScreenCommand