org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem Java Examples

The following examples show how to use org.apache.wicket.markup.head.JavaScriptReferenceHeaderItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InfiniteScrollBehavior.java    From onedev with MIT License 6 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	response.render(JavaScriptReferenceHeaderItem.forReference(new InfiniteScrollResourceReference()));
	
	String itemSelector;
	if (getItemSelector() != null)
		itemSelector = "'"+JavaScriptEscape.escapeJavaScript(getItemSelector())+"'";
	else
		itemSelector = "undefined";
	
	// Run onload script as the container size might be adjusted in window resize event (which 
	// happens before onload). An example is the issue board columns
	String script = String.format("onedev.server.infiniteScroll.onLoad('%s', %s, %s, %s);", 
			component.getMarkupId(true), getCallbackFunction(explicit("offset"), explicit("count")), 
			pageSize, itemSelector);
	response.render(OnLoadHeaderItem.forScript(script));
}
 
Example #2
Source File: AbstractMobilePage.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response)
{
  super.renderHead(response);
  response.render(JavaScriptReferenceHeaderItem.forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference()));
  response.render(StringHeaderItem.forString(WicketUtils.getCssForFavicon(getUrl("/favicon.ico"))));
  if (WebConfiguration.isDevelopmentMode() == true) {
    response.render(CssReferenceHeaderItem.forUrl("mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + "/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".css"));
  } else {
    response.render(CssReferenceHeaderItem.forUrl("mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + "/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".min.css"));
  }
  response.render(CssReferenceHeaderItem.forUrl("mobile/projectforge.css"));
  response.render(JavaScriptReferenceHeaderItem.forUrl("mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + "/myconfig.js"));
  if (WebConfiguration.isDevelopmentMode() == true) {
    // response.renderJavaScriptReference("mobile/jquery.mobile/myconfig.js");
    response.render(JavaScriptReferenceHeaderItem.forUrl("mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + "/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".js"));
  } else {
    // response.renderJavaScriptReference("mobile/jquery.mobile/myconfig.js");
    response.render(JavaScriptReferenceHeaderItem.forUrl("mobile/jquery.mobile-" + JQUERY_MOBILE_VERSION + "/jquery.mobile-" + JQUERY_MOBILE_VERSION + ".min.js"));
  }
}
 
Example #3
Source File: BasePage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * This block adds the required wrapper markup to style it like a Sakai tool. 
 * Add to this any additional CSS or JS references that you need.
 * 
 */
public void renderHead(IHeaderResponse response) {
	
	
	//get Sakai skin
	String skinRepo = sakaiProxy.getSkinRepoProperty();
	String toolCSS = sakaiProxy.getToolSkinCSS(skinRepo);
	String toolBaseCSS = skinRepo + "/tool_base.css";
	
	//Sakai additions				
	response.render(JavaScriptReferenceHeaderItem.forUrl("/library/js/headscripts.js"));
	response.render(CssReferenceHeaderItem.forUrl(toolBaseCSS));
	response.render(CssReferenceHeaderItem.forUrl(toolCSS));
	response.render (OnLoadHeaderItem.forScript("setMainFrameHeight( window.name )"));
	response.render(StringHeaderItem.forString("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"));					
	
}
 
Example #4
Source File: BasePage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
/**
 * This block adds the required wrapper markup to style it like a Sakai tool. 
 * Add to this any additional CSS or JS references that you need.
 * 
 */
public void renderHead(IHeaderResponse response) {
	
	
	//get Sakai skin
	String skinRepo = sakaiProxy.getSkinRepoProperty();
	String toolCSS = sakaiProxy.getToolSkinCSS(skinRepo);
	String toolBaseCSS = skinRepo + "/tool_base.css";
	
	//Sakai additions				
	response.render(JavaScriptReferenceHeaderItem.forUrl("/library/js/headscripts.js"));
	response.render(CssReferenceHeaderItem.forUrl(toolBaseCSS));
	response.render(CssReferenceHeaderItem.forUrl(toolCSS));
	response.render (OnLoadHeaderItem.forScript("setMainFrameHeight( window.name )"));
	response.render(StringHeaderItem.forString("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"));					
	
}
 
Example #5
Source File: AbstractFullCalendar.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {

	response.render(JavaScriptHeaderItem.forReference(WicketAjaxJQueryResourceReference.get()));

	response.render(CssReferenceHeaderItem.forReference(CSS));

	if (getApplication().usesDeploymentConfig()) {
		response.render(JavaScriptReferenceHeaderItem.forReference(JS_MIN));
	} else {
		response.render(JavaScriptReferenceHeaderItem.forReference(JS));
	}
	response.render(JavaScriptReferenceHeaderItem.forReference(JS_EXT));

}
 
Example #6
Source File: ChartPanel.java    From inception with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse aResponse)
{
    super.renderHead(aResponse);

    // import Js
    aResponse.render(JavaScriptHeaderItem
            .forReference(new WebjarsJavaScriptResourceReference("c3/current/c3.js")));
    aResponse.render(JavaScriptHeaderItem
            .forReference(new WebjarsJavaScriptResourceReference("d3js/current/d3.js")));

    // import Css
    aResponse.render(
            CssHeaderItem.forReference(new WebjarsCssResourceReference("c3/current/c3.css")));

    aResponse.render(JavaScriptReferenceHeaderItem.forReference(
            getApplication().getJavaScriptLibrarySettings().getJQueryReference()));

    aResponse.render(JavaScriptHeaderItem.forReference(ChartJsReference.get()));
    
    String chartTriggerJavascript = String.join("\n",
            "$(document).ready(function(){", 
            "   $.ajax({",
            "       url:'" + chartAjaxBejavior.getCallbackUrl().toString() + "',",
            "       type:'post',",
            "       contentType:'application/json',",
            "       dataType:'json',",
            "       success : function(result){",
            "           updateLearningCurveDiagram(result)",
            "       }",
            "   })",
            "})");

    aResponse.render(JavaScriptContentHeaderItem.forScript(chartTriggerJavascript, null));
}
 
Example #7
Source File: TeamCalFilterDialog.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.apache.wicket.Component#renderHead(org.apache.wicket.markup.html.IHeaderResponse)
 */
@Override
public void renderHead(final IHeaderResponse response)
{
  super.renderHead(response);
  response.render(CssHeaderItem.forUrl("scripts/spectrum/spectrum.css"));
  response.render(JavaScriptReferenceHeaderItem.forUrl("scripts/spectrum/spectrum.js"));
}
 
Example #8
Source File: WicketRenderHeadUtils.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Bootstrap, jqueryui and uquery.contextmenu.js.
 */
public static void renderAutogrowJavaScriptIncludes(final IHeaderResponse response)
{
  renderMainJavaScriptIncludes(response);
  for (final String url : AUTOGROW_JAVASCRIPT_FILES) {
    response.render(JavaScriptReferenceHeaderItem.forUrl(url));
  }
}
 
Example #9
Source File: PFAutoCompleteBehavior.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @see org.apache.wicket.ajax.AbstractDefaultAjaxBehavior#renderHead(org.apache.wicket.Component,
 *      org.apache.wicket.markup.html.IHeaderResponse)
 */
@Override
public void renderHead(final Component component, final IHeaderResponse response)
{
  super.renderHead(component, response);
  WicketRenderHeadUtils.renderMainJavaScriptIncludes(response);
  response.render(JavaScriptReferenceHeaderItem.forUrl("scripts/jquery.wicket-autocomplete.js"));
  renderAutocompleteHead(response);
}
 
Example #10
Source File: ImageCropperPage.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response)
{
  super.renderHead(response);
  response.render(CssReferenceHeaderItem.forUrl("imagecropper/history/history.css"));
  response.render(JavaScriptReferenceHeaderItem.forUrl("imagecropper/history/history.js"));
  response.render(JavaScriptReferenceHeaderItem.forUrl("imagecropper/AC_OETags.js"));
}
 
Example #11
Source File: BootstrapAwareJQueryUIJavaScriptResourceReference.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies()
{
    IBootstrapSettings settings = Bootstrap.getSettings();
    final JavaScriptReferenceHeaderItem jsReference = JavaScriptHeaderItem.forReference(
            settings.getJsResourceReference(), new PageParameters(), "bootstrap-js",
            settings.deferJavascript());
    return Dependencies.combine(super.getDependencies(), jsReference);
}
 
Example #12
Source File: ResourceBundleReferencesTest.java    From onedev with MIT License 5 votes vote down vote up
@Test
public void testc() {
	ResourceBundleReferences references = new ResourceBundleReferences(Js1ResourceReferenceC.class);

	Assert.assertEquals(2, references.getJavaScriptBundles().size());
	Assert.assertEquals(
			Lists.newArrayList(
					JavaScriptReferenceHeaderItem.forReference(new Js3ResourceReferenceC()), 
					JavaScriptReferenceHeaderItem.forReference(new Js4ResourceReferenceC())), 
			references.getJavaScriptBundles().get(0).getProvidedResources());
	Assert.assertEquals(
			Lists.newArrayList(
					JavaScriptReferenceHeaderItem.forReference(new Js1ResourceReferenceC()), 
					JavaScriptReferenceHeaderItem.forReference(new Js2ResourceReferenceC())), 
			references.getJavaScriptBundles().get(1).getProvidedResources());
	
	Assert.assertEquals(2, references.getCssBundles().size());
	Assert.assertEquals(
			Lists.newArrayList(
					CssReferenceHeaderItem.forReference(new CssResourceReference(Js3ResourceReferenceC.class, "3.css")), 
					CssReferenceHeaderItem.forReference(new CssResourceReference(Js4ResourceReferenceC.class, "4.css"))), 
			references.getCssBundles().get(0).getProvidedResources());
	Assert.assertEquals(
			Lists.newArrayList(
					CssReferenceHeaderItem.forReference(new CssResourceReference(Js1ResourceReferenceC.class, "1.css")), 
					CssReferenceHeaderItem.forReference(new CssResourceReference(Js2ResourceReferenceC.class, "2.css"))), 
			references.getCssBundles().get(1).getProvidedResources());
}
 
Example #13
Source File: ResourceBundleReferencesTest.java    From onedev with MIT License 5 votes vote down vote up
@Test
public void testb() {
	ResourceBundleReferences references = new ResourceBundleReferences(Js1ResourceReferenceB.class);
	
	Assert.assertEquals(2, references.getJavaScriptBundles().size());
	Assert.assertEquals(
			Lists.newArrayList(
					JavaScriptReferenceHeaderItem.forReference(new Js2ResourceReferenceB()), 
					JavaScriptReferenceHeaderItem.forReference(new Js3ResourceReferenceB())), 
			references.getJavaScriptBundles().get(0).getProvidedResources());
	Assert.assertEquals(
			Lists.newArrayList(JavaScriptReferenceHeaderItem.forReference(new Js1ResourceReferenceB())), 
			references.getJavaScriptBundles().get(1).getProvidedResources());
}
 
Example #14
Source File: ResourceBundleReferencesTest.java    From onedev with MIT License 5 votes vote down vote up
@Test
public void testa() {
	ResourceBundleReferences references = new ResourceBundleReferences(Js1ResourceReferenceA.class);
	Assert.assertEquals(1, references.getJavaScriptBundles().size());
	Assert.assertEquals(
			Lists.newArrayList(
					JavaScriptReferenceHeaderItem.forReference(new Js1ResourceReferenceA()), 
					JavaScriptReferenceHeaderItem.forReference(new Js2ResourceReferenceA()), 
					JavaScriptReferenceHeaderItem.forReference(new Js3ResourceReferenceA())), 
			references.getJavaScriptBundles().get(0).getProvidedResources());
}
 
Example #15
Source File: SourceFormatPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptReferenceHeaderItem.forReference(new SourceFormatResourceReference()));
	
	String script = String.format("onedev.server.sourceFormat.init('%s');", getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #16
Source File: ResourceBundleReferences.java    From onedev with MIT License 5 votes vote down vote up
private void createBundles(Class<?> scope, Set<ResourceReference> resourceReferences) {
	/*
	 * Some bundled css file may contain resources relative to parent paths of the css url, 
	 * for instance, a css may define below style:
	 * 
	 * background: url(../images/clock.png)),
	 *  
	 * if we use a resource name for instance "bundle" here, the generated resource 
	 * path will be something like "http://<server>:<port>/wicket/resource/org.apache.wicket.Application/bundle-ver-1472816165384.css", 
	 * and browser will resolve image url above as "http://<server>:<port>/wicket/resource/images/clock.png", which will cause Wicket
	 * resource loading not working at all. However if we use a long path here for resource name, for instance 
	 * "a/l/o/n/g/p/a/t/h/bundle", the resolved image url will be "http://<server>:<port>/wicket/resource/org.apache.wicket.Application/a/l/o/n/g/p/a/t/clock.png",  
	 * which will be resolved to the correct image with help of our BundleAwareResourceReferenceFactory
	 */
	String name = "a/l/o/n/g/p/a/t/h/bundle";
	
	List<ResourceReference> resourceReferenceList = new ArrayList<>(resourceReferences);
	resourceReferenceList.sort((o1, o2)->sorted.indexOf(o1)-sorted.indexOf(o2));
	
	List<JavaScriptReferenceHeaderItem> javaScriptResourceReferences = new ArrayList<>();
	List<CssReferenceHeaderItem> cssResourceReferences = new ArrayList<>();
	for (ResourceReference resourceReference: resourceReferenceList) {
		if (resourceReference instanceof JavaScriptResourceReference) {
			javaScriptResourceReferences.add(JavaScriptReferenceHeaderItem.forReference(resourceReference));
		} else if (resourceReference instanceof CssResourceReference) {
			cssResourceReferences.add(CssReferenceHeaderItem.forReference(resourceReference));
		}
	}
	
	if (!javaScriptResourceReferences.isEmpty()) {
		javaScriptBundleReferences.add(new JavaScriptConcatResourceBundleReference(
				scope, name + ".js", javaScriptResourceReferences));			
	}
	
	if (!cssResourceReferences.isEmpty()) {
		cssBundleReferences.add(new CssConcatResourceBundleReference(
				scope, name + ".css", cssResourceReferences));			
	}
}
 
Example #17
Source File: DropBehavior.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	response.render(JavaScriptReferenceHeaderItem.forReference(new DragDropResourceReference()));
	String script = String.format("onedev.server.dragdrop.setupDroppable('#%s', %s, %s);", 
			component.getMarkupId(), getAccept(), getCallbackFunction(explicit("dragData")));
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #18
Source File: ResourceBundleReferences.java    From onedev with MIT License 4 votes vote down vote up
public List<ConcatResourceBundleReference<JavaScriptReferenceHeaderItem>> getJavaScriptBundles() {
	return javaScriptBundleReferences;
}
 
Example #19
Source File: AddressListPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response)
{
  super.renderHead(response);
  response.render(JavaScriptReferenceHeaderItem.forUrl("scripts/zoom.js"));
}
 
Example #20
Source File: JavaScriptConcatResourceBundleReference.java    From onedev with MIT License 4 votes vote down vote up
public JavaScriptConcatResourceBundleReference(Class<?> scope, String name, List<JavaScriptReferenceHeaderItem> resources) {
	super(scope, name, resources);
}
 
Example #21
Source File: BundleAwareResourceReferenceFactory.java    From onedev with MIT License 4 votes vote down vote up
public BundleAwareResourceReferenceFactory(List<ConcatResourceBundleReference<JavaScriptReferenceHeaderItem>> javaScriptBundles, 
		List<ConcatResourceBundleReference<CssReferenceHeaderItem>> cssBundles) {
	bundles.addAll(javaScriptBundles);
	bundles.addAll(cssBundles);
}
 
Example #22
Source File: SearchPage.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response)
{
  super.renderHead(response);
  response.render(JavaScriptReferenceHeaderItem.forUrl("scripts/zoom.js"));
}
 
Example #23
Source File: DragBehavior.java    From onedev with MIT License 4 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	response.render(JavaScriptReferenceHeaderItem.forReference(new DragDropResourceReference()));
	response.render(OnDomReadyHeaderItem.forScript(String.format("onedev.server.dragdrop.setupDraggable('#%s', '%s', '%s');", 
			component.getMarkupId(), dragData, dragText)));
}