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

The following examples show how to use org.apache.wicket.markup.head.JavaScriptHeaderItem. 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: ReportsEditPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forUrl(JQUERYSCRIPT));
	response.render(JavaScriptHeaderItem.forUrl(JQUERYUISCRIPT));
	response.render(JavaScriptHeaderItem.forUrl(DATEPICKERSCRIPT));
	response.render(JavaScriptHeaderItem.forUrl(StatsManager.SITESTATS_WEBAPP + "/script/reports.js"));
	StringBuilder onDomReady = new StringBuilder();
	onDomReady.append("checkWhatSelection();");
	onDomReady.append("checkWhenSelection();");
       onDomReady.append("checkWhoSelection();");
       onDomReady.append("checkHowSelection();");
       onDomReady.append("checkReportDetails();");
       onDomReady.append("checkHowChartSelection();");
	response.render(OnDomReadyHeaderItem.forScript(onDomReady.toString()));
}
 
Example #2
Source File: WidgetPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response) {
    super.renderHead(response);

    final String version = this.serverConfigurationService.getString("portal.cdn.version", "");

    // get the Sakai skin header fragment from the request attribute
    final HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();

    response.render(StringHeaderItem.forString((String) request.getAttribute("sakai.html.head")));
    response.render(OnLoadHeaderItem.forScript("setMainFrameHeight( window.name )"));

    // Tool additions (at end so we can override if required)
    response.render(StringHeaderItem.forString("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"));

    // render jQuery and the Wicket event library
    // Both must be priority so they are emitted into the head
    response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery/1.12.4/jquery.min.js?version=%s", version))));
    response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forUrl(String.format("/mycalendar/scripts/wicket/wicket-event-jquery.min.js?version=%s", version))));

    // additional styles (datepicker, this widget etc)
    response.render(CssHeaderItem.forUrl(String.format("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.css?version=%s", version)));

    // NOTE: All libraries apart from jQuery and Wicket Event must be rendered inline with the application. See WidgetPage.html.

}
 
Example #3
Source File: AbstractHtmlJsPaneWidget.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	ODocument doc = getWidgetDocument();
	Collection<String> resources = doc.field("resources");
	if(resources!=null) {
		for(String resource : resources) {
			String lowercase = resource.toLowerCase();
			if(lowercase.endsWith(".css")) {
				response.render(CssHeaderItem.forUrl(resource));
			}
			else if(lowercase.endsWith(".js")) {
				response.render(JavaScriptHeaderItem.forUrl(resource));
			}
		}
	}
	String script = doc.field("script");
	if(!Strings.isEmpty(script)) {
		response.render(OnDomReadyHeaderItem.forScript(interpolateScript(script)));
	}
}
 
Example #4
Source File: KendoResourceBehavior.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Override
public void renderHead(Component aComponent, IHeaderResponse aResponse)
{
    // We use Kendo TextFields, but they do not automatically load the Kendo
    // JS/CSS, so
    // we do it manually here and for all the pages.
    KendoUILibrarySettings kendoCfg = KendoUILibrarySettings.get();

    if (kendoCfg.getCommonStyleSheetReference() != null) {
        aResponse.render(CssHeaderItem
                .forReference(kendoCfg.getCommonStyleSheetReference()));
    }

    if (kendoCfg.getThemeStyleSheetReference() != null) {
        aResponse.render(CssHeaderItem
                .forReference(kendoCfg.getThemeStyleSheetReference()));
    }

    if (kendoCfg.getJavaScriptReference() != null) {
        aResponse.render(JavaScriptHeaderItem
                .forReference(kendoCfg.getJavaScriptReference()));
    }
}
 
Example #5
Source File: AbstractBasePage.java    From the-app with Apache License 2.0 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
    super.renderHead(response);

    String contextPath = RequestCycle.get().getRequest().getContextPath();

    Map<String, String> replacements = Collections.singletonMap("contextPath", getContextPath());
    MapVariableInterpolator variableInterpolator = new MapVariableInterpolator(FAVICON_HEADER, replacements);
    response.render(StringHeaderItem.forString(variableInterpolator.toString()));

    String designUrl = String.format("/assets/css/bootstrap-%s.min.css", designSelector.getDesignType());
    response.render(CssHeaderItem.forUrl(contextPath + designUrl));
    response.render(CssHeaderItem.forUrl(contextPath + "/assets/css/bootstrap-theme-shop.css"));

    response.render(JavaScriptHeaderItem.forUrl(contextPath + "/assets/js/bootstrap.min.js"));
    response.render(CssHeaderItem.forUrl(contextPath + "/assets/css/bootstrap-addon.css"));
}
 
Example #6
Source File: WidgetPage.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
@Override
public void renderHead(final IHeaderResponse response) {

    super.renderHead(response);

    final String version = this.serverConfigurationService.getString("portal.cdn.version", "");

    // get the Sakai skin header fragment from the request attribute
    final HttpServletRequest request = (HttpServletRequest) getRequest().getContainerRequest();

    response.render(StringHeaderItem.forString((String) request.getAttribute("sakai.html.head")));
    response.render(OnLoadHeaderItem.forScript("setMainFrameHeight( window.name )"));

    // Tool additions (at end so we can override if required)
    response.render(StringHeaderItem.forString("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"));

    // render jQuery and the Wicket event library
    // Both must be priority so they are emitted into the head
    response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forUrl(String.format("/library/webjars/jquery/1.12.4/jquery.min.js?version=%s", version))));
    response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forUrl(String.format("/site-description/scripts/wicket/wicket-event-jquery.min.js?version=%s", version))));

    // NOTE: All libraries apart from jQuery and Wicket Event must be rendered inline with the application. See WidgetPage.html.
}
 
Example #7
Source File: WarningsFooterPanel.java    From webanno with Apache License 2.0 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse aResponse)
{
    super.renderHead(aResponse);
    
    aResponse.render(JavaScriptHeaderItem.forReference(
            getApplication().getJavaScriptLibrarySettings().getJQueryReference()));
    String script = String.join("\n",
            "$(function () {",
            "  $('[data-toggle=\"popover\"]').popover({",
            "    html : true,",
            "    content: function() {",
            "      var content = $(this).attr('data-popover-content');",
            "      return $(content).children('.popover-body').html();",
            "    }",
            "  });",
            "});");
    aResponse.render(JavaScriptHeaderItem.forScript(script, "popover"));
}
 
Example #8
Source File: DropzoneField.java    From onedev with MIT License 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new DropzoneFieldResourceReference()));
	
	String script = String.format(
			"onedev.server.dropzone.onDomReady('%s', '%s', %s, %s, %s, %d);", 
			getMarkupId(), 
			uploadBehavior.getCallbackUrl(), 
			deleteBehavior.getCallbackFunction(CallbackParameter.explicit("name")),
			acceptedFiles!=null?"'" + acceptedFiles + "'":"null",				
			maxFiles!=0?maxFiles:"null",
			maxFilesize);
	
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #9
Source File: SourceViewResourceReference.java    From onedev with MIT License 6 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	dependencies.add(JavaScriptHeaderItem.forReference(new JQueryUIResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new SelectionPopoverResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new HoverResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new ScrollIntoViewResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new DoneEventsResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new HotkeysResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new CookiesResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new CodeMirrorResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new ClipboardResourceReference()));
	dependencies.add(CssHeaderItem.forReference(
			new BaseDependentCssResourceReference(SourceViewResourceReference.class, "source-view.css")));
	return dependencies;
}
 
Example #10
Source File: ImageDiffPanel.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new ImageDiffResourceReference()));
	String script = String.format("onedev.server.imageDiff.onDomReady('%s');", getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #11
Source File: DisplayHTML5Panel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
  public void renderHead(IHeaderResponse response) {
response.render(OnLoadHeaderItem.forScript(getResizeEndDefinition()));
response.render(OnLoadHeaderItem.forScript(getResizeJavaScript()));
	
// must call display onLoad instead of onDomReady to appear it in iframe
// $(document).ready in the iframe seems to be fired too soon and the iframe content isn't even loaded yet
response.render(OnLoadHeaderItem.forScript(getDisplayCall()));

//include js file
      response.render(JavaScriptHeaderItem.forReference(NEXT_JS));
      
      //<script> tag
      //response.renderJavaScript(getJavaScript(), null); 
  }
 
Example #12
Source File: Select2ResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	dependencies.add(JavaScriptHeaderItem.forReference(new MouseWheelResourceReference()));
	dependencies.add(CssHeaderItem.forReference(new Select2CssResourceReference()));
	return dependencies;
}
 
Example #13
Source File: BasePage.java    From wicket-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(getApplication().getJavaScriptLibrarySettings().getJQueryReference()));
	response.render(JavaScriptHeaderItem.forReference(getApplication().getJavaScriptLibrarySettings().getWicketEventReference()));
	response.render(JavaScriptHeaderItem.forReference(getApplication().getJavaScriptLibrarySettings().getWicketAjaxReference()));
	
	String bootstrapPrefixPath = "bootstrap/current";
	response.render(JavaScriptHeaderItem.forReference(new WebjarsJavaScriptResourceReference(bootstrapPrefixPath + "/js/bootstrap.js")));
	response.render(CssHeaderItem.forReference(new WebjarsJavaScriptResourceReference(bootstrapPrefixPath + "/css/bootstrap.css")));
}
 
Example #14
Source File: ColorPicker.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new ColorPickerResourceReference()));
	
	String script = String.format("onedev.server.colorPicker.onDomReady('%s', %b);", 
			getMarkupId(true), allowEmpty);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #15
Source File: FolderViewResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	dependencies.add(CssHeaderItem.forReference(
			new CssResourceReference(FolderViewResourceReference.class, "folder-view.css")));
	
	// add this dependency as the lazy loaded last commits information includes avatar displaying
	dependencies.add(CssHeaderItem.forReference(new UserAvatarResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new HoverResourceReference()));
	return dependencies;
}
 
Example #16
Source File: DynamicTextAreaFeatureEditor.java    From webanno with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse aResponse) {
    aResponse.render(
            JavaScriptHeaderItem.forReference(DynamicTextAreaScriptReference.get()));
    aResponse.render(OnDomReadyHeaderItem.forScript(
            "window.addEventListener('load', function(){resizeDynamicTextArea(document.getElementById('" + textarea.getMarkupId() + "'));});"));
}
 
Example #17
Source File: BuildLogResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	dependencies.add(JavaScriptHeaderItem.forReference(new PerfectScrollbarResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new MomentResourceReference()));
	dependencies.add(CssHeaderItem.forReference(new BaseDependentCssResourceReference(
			BuildLogResourceReference.class, "build-log.css")));
	return dependencies;
}
 
Example #18
Source File: TabbedPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(CssHeaderItem.forReference(TabsPanel.TABDROP_CSS));
	response.render(JavaScriptHeaderItem.forReference(TabsPanel.TABDROP_JS));
	response.render(OnDomReadyHeaderItem.forScript("$('#"+getMarkupId()+" > ul').tabdrop({text: '<i class=\"glyphicon glyphicon-align-justify\"></i>'});"));
}
 
Example #19
Source File: PivotPage.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
       IJavaScriptLibrarySettings settings = NextServerApplication.get().getJavaScriptLibrarySettings();
       response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(settings.getJQueryReference())));
}
 
Example #20
Source File: IndicatorHTML5Panel.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
  public void renderHead(IHeaderResponse response) {
response.render(OnLoadHeaderItem.forScript(getResizeEndDefinition()));
response.render(OnLoadHeaderItem.forScript(getResizeJavaScript()));
	
// must call indicator onLoad instead of onDomReady to appear it in iframe
// $(document).ready in the iframe seems to be fired too soon and the iframe content isn't even loaded yet
response.render(OnLoadHeaderItem.forScript(getIndicatorCall()));

//include js file
      response.render(JavaScriptHeaderItem.forReference(INDICATOR_JS));
      
      //<script> tag
      //response.renderJavaScript(getJavaScript(), null); 
  }
 
Example #21
Source File: ProjectBlobPage.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

	response.render(JavaScriptHeaderItem.forReference(new ProjectBlobResourceReference()));
	
	String callback = ajaxBehavior.getCallbackFunction(explicit("action")).toString();
	String script = String.format("onedev.server.projectBlob.onDomReady(%s);", callback);
	
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #22
Source File: BasePage.java    From nextreports-server with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

       // add nextserver.js
	new NextServerJavaScriptContributor().renderHead(response);

       // add busy-indicator.js
	response.render(JavaScriptHeaderItem.forReference(new PackageResourceReference(BasePage.class, "busy-indicator.js")));

       if (isInternetExplorer()) {        	
           response.render(JavaScriptHeaderItem.forUrl("js/jquery.pngFix.js"));
           response.render(JavaScriptHeaderItem.forUrl("js/pngFix.js"));
       }
}
 
Example #23
Source File: ConfirmationBehavior.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);

	References.renderWithFilter(response, JavaScriptHeaderItem
			.forReference(new JQueryPluginResourceReference(ConfirmationBehavior.class, "bootstrap-confirmation.js")));

	if (selector == null) {
		config.withRootSelector(component.getMarkupId());
		response.render($(component).chain("confirmation", config).asDomReadyScript());
	} else {
		config.withRootSelector(selector);
		response.render($(selector).chain("confirmation", config).asDomReadyScript());
	}
}
 
Example #24
Source File: SideBar.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new SidebarResourceReference()));
	String script = String.format("onedev.server.sidebar.onDomReady('%s', %s);", 
			getMarkupId(true), miniCookieKey!=null?"'"+miniCookieKey+"'":"undefined");
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #25
Source File: SidebarResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	dependencies.add(JavaScriptHeaderItem.forReference(new CookiesResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new PerfectScrollbarResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new JQueryUIResourceReference()));
	dependencies.add(CssHeaderItem.forReference(new BaseDependentCssResourceReference(SidebarResourceReference.class, "sidebar.css")));
	return dependencies;
}
 
Example #26
Source File: SideInfoResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	dependencies.add(JavaScriptHeaderItem.forReference(new PerfectScrollbarResourceReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new JQueryUIResourceReference()));
	dependencies.add(CssHeaderItem.forReference(new BaseDependentCssResourceReference(
			SideInfoPanel.class, "side-info.css")));
	return dependencies;
}
 
Example #27
Source File: QRCodeDivAppenderBehavior.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response)
{
  super.renderHead(component, response);
  response.render(JavaScriptHeaderItem.forUrl("scripts/qrcode.js"));
  response.render(OnDomReadyHeaderItem.forScript("$(function() {\n" +
      "var urlComponent = $('#" + component.getMarkupId() + "');\n" +
        "if (urlComponent.val() != undefined && urlComponent.val().length > 0) {\n" +
          "var qrCode = new QRCode(urlComponent.siblings('.pf_qrcode')[0], {width: 250, height: 250});\n" +
          "qrCode.makeCode(urlComponent.val());\n" +
        "}\n" +
      "});"));
}
 
Example #28
Source File: DropzoneFieldResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = super.getDependencies();
	dependencies.add(JavaScriptHeaderItem.forReference(new DropzoneResourceReference()));
	dependencies.add(CssHeaderItem.forReference(
			new BaseDependentCssResourceReference(DropzoneField.class, "dropzone-field.css")));
	return dependencies;
}
 
Example #29
Source File: CopyToClipboardLink.java    From onedev with MIT License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new CopyToClipboardResourceReference()));
	String script = String.format("onedev.server.copyToClipboard.onDomReady('%s', '%s');", 
			getMarkupId(true), JavaScriptEscape.escapeJavaScript(textModel.getObject()));
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #30
Source File: BasePage.java    From sakai with Educational Community License v2.0 5 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(JavaScriptHeaderItem.forUrl("/library/js/headscripts.js"));
	response.render(CssHeaderItem.forUrl(toolBaseCSS));
	response.render(CssHeaderItem.forUrl(toolCSS));
	response.render(OnDomReadyHeaderItem.forScript("setMainFrameHeight( window.name )"));

	StringBuilder headJs = new StringBuilder();
	headJs.append("var sakai = sakai || {}; sakai.editor = sakai.editor || {}; " +
	"sakai.editor.editors = sakai.editor.editors || {}; " +
	"sakai.editor.editors.ckeditor = sakai.editor.editors.ckeditor || {}; " +
	"sakai.locale = sakai.locale || {};\n");
	headJs.append("sakai.locale.userCountry = '" + rloader.getLocale().getCountry() + "';\n");
	headJs.append("sakai.locale.userLanguage = '" + rloader.getLocale().getLanguage() + "';\n");
	headJs.append("sakai.locale.userLocale = '" + rloader.getLocale().toString() + "';\n");
	response.render(JavaScriptHeaderItem.forScript(headJs, null));

	//Tool additions (at end so we can override if required)
	response.render(StringHeaderItem.forString("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />"));
	//response.renderCSSReference("css/my_tool_styles.css");
	//response.renderJavascriptReference("js/my_tool_javascript.js");

	//for jQuery
	response.render(JavaScriptHeaderItem.forUrl("/library/webjars/jquery/1.12.4/jquery.min.js"));
	response.render(JavaScriptHeaderItem.forUrl("/library/webjars/jquery-ui/1.12.1/jquery-ui.min.js"));

	//for datepicker
	response.render(CssHeaderItem.forUrl("/library/webjars/jquery-ui/1.12.1/jquery-ui.css"));
	response.render(JavaScriptHeaderItem.forUrl("javascript/jquery.asmselect.js"));
	response.render(CssHeaderItem.forUrl("css/jquery.asmselect.css"));
	response.render(JavaScriptHeaderItem.forUrl("/library/js/lang-datepicker/lang-datepicker.js"));
}