org.apache.wicket.request.resource.JavaScriptResourceReference Java Examples

The following examples show how to use org.apache.wicket.request.resource.JavaScriptResourceReference. 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: CodeEditorPanel.java    From Orienteer with Apache License 2.0 6 votes vote down vote up
private void setCustomEditorDependencies(IHeaderResponse response) {
    response.render(JavaScriptHeaderItem.forReference(
            new JavaScriptResourceReference(CodeEditorPanel.class, "editor.js")));
    response.render(CssHeaderItem.forReference(
            new CssResourceReference(CodeEditorPanel.class, "editor.css")));
    response.render(CssHeaderItem.forReference(CodeMirrorCss.CORE.getResourceReference()));
    response.render(JavaScriptHeaderItem.forReference(CodeMirrorJs.CORE.getResourceReference()));
    response.render(JavaScriptHeaderItem.forReference(CodeMirrorJs.ACTIVELINE_ADDON.getResourceReference()));
    addShowHintAddon(response);
    addActiveLine(response);
    addScrollbar(response);
    addFullscreenMode(response);
    addMatchBrackets(response);
    addAutoCloseBrackets(response);
    addEditorTheme(response);
}
 
Example #2
Source File: Chat.java    From openmeetings with Apache License 2.0 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(Chat.class, "chat.js"))));
	response.render(new PriorityHeaderItem(getNamedFunction("chatActivity", chatActivity, explicit(PARAM_TYPE), explicit(PARAM_ROOM_ID), explicit(PARAM_MSG_ID))));

	if (showDashboardChat) {
		StringBuilder sb = new StringBuilder(getReinit());
		List<ChatMessage> list = new ArrayList<>(chatDao.getGlobal(0, 30));
		list.addAll(chatDao.getUserRecent(getUserId(), Date.from(Instant.now().minus(Duration.ofHours(1L))), 0, 30));
		if (!list.isEmpty()) {
			sb.append("Chat.addMessage(").append(getMessage(list).toString()).append(");");
		}
		response.render(OnDomReadyHeaderItem.forScript(sb.toString()));
	}
}
 
Example #3
Source File: JQueryUIResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = new ArrayList<>();
	dependencies.add(JavaScriptHeaderItem.forReference(
			Application.get().getJavaScriptLibrarySettings().getJQueryReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(
			JQueryUIResourceReference.class, "jquery-ui.min.js")));
	dependencies.add(CssHeaderItem.forReference(
			new CssResourceReference(JQueryUIResourceReference.class, "jquery-ui.min.css")));
	return dependencies;
}
 
Example #4
Source File: ChartBehavior.java    From wicket-chartjs with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
  super.renderHead(component, response);
  response.render(JavaScriptHeaderItem.forReference(
      new JavaScriptResourceReference(AbstractChartPanel.class, "chartjs/Chart.min.js")));
  response.render(JavaScriptHeaderItem
      .forReference(new JavaScriptResourceReference(AbstractChartPanel.class, "bridge.js")));
  String script =
      "WicketCharts['" + component.getMarkupId() + "'] = new Chart(document.getElementById('"
          + component.getMarkupId() + "').getContext('2d'), " + generateChartConfig() + ");";
  response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example #5
Source File: FilterPanel.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(JavaScriptHeaderItem.forReference(
            new JavaScriptResourceReference(FilterPanel.class, "filter.js")));
    response.render(CssHeaderItem.forReference(
            new CssResourceReference(FilterPanel.class, "filter.css")));
    response.render(OnDomReadyHeaderItem.forScript(initFilterJs(containerId, currentTab != null ? currentTab.getMarkupId() : null)));
}
 
Example #6
Source File: PivotPanel.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(PIVOT_CSS));
	response.render(CssHeaderItem.forReference(PIVOT_CSS_FIX));
	response.render(CssHeaderItem.forReference(C3_CSS));
	response.render(JavaScriptHeaderItem.forReference(JQueryDashboardSupport.JQUERY_UI_JS));
	response.render(JavaScriptHeaderItem.forReference(PIVOT_JS));
	response.render(JavaScriptHeaderItem.forReference(D3_JS));
	response.render(JavaScriptHeaderItem.forReference(C3_JS));
	response.render(JavaScriptHeaderItem.forReference(D3_RENDERERS_JS));
	response.render(JavaScriptHeaderItem.forReference(C3_RENDERERS_JS));
	String lang = getLocale().getLanguage();
	if(SUPPORTED_LANGS.indexOf(lang)<0) lang = "en";
	JavaScriptResourceReference langRes = getLocalizationJSResource(lang);
	if(langRes!=null) response.render(JavaScriptHeaderItem.forReference(langRes));
	TextTemplate template = new PackageTextTemplate(PivotPanel.class, "pivottable.tmpl.js");
	Map<String, Object> params = new HashMap<String, Object>();
	params.put("componentId", getMarkupId());
	params.put("dataUrl", getModelObject().replace("'", "\\'"));
	params.put("config", Strings.defaultIfEmpty(configModel.getObject(), "{}"));
	params.put("editMode", DisplayMode.EDIT.equals(modeModel.getObject()));
	params.put("callBackScript", updatePivotTableBehavior.getCallbackScript());
	params.put("language", lang);
	template.interpolate(params);
	response.render(OnDomReadyHeaderItem.forScript(template.asString()));
}
 
Example #7
Source File: BootstrapDateTimePickerBehaviour.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) 
{
	super.renderHead(component, response);
	
	if(component.isEnabledInHierarchy()) {
		
		response.render(CssReferenceHeaderItem.forReference(DATETIME_PICKER_CSS));
		response.render(JavaScriptHeaderItem.forReference(MOMENT_JAVASCRIPT));
		response.render(JavaScriptHeaderItem.forReference(DATETIME_PICKER_JAVASCRIPT));
		
		if(!component.getLocale().getLanguage().equals("en")) {
			
			response.render(JavaScriptHeaderItem.forReference(
								new JavaScriptResourceReference(BootstrapDateTimePickerBehaviour.class
															  , "locales/" + component.getLocale().getLanguage() + ".js")));
		}
		
		/** Not supporting special dates at the moment **/
		
		response.render(OnDomReadyHeaderItem.forScript("$(\"#" + component.getMarkupId() + "\").datetimepicker({ "
																									+ " format: 'DD/MM/YYYY HH:mm:ss',"
																									+ " icons: { "
																										+ " time: 'fa fa-clock-o',"
																										+ " date: 'fa fa-calendar',"
																										+ " up: 'fa fa-arrow-up',"
																										+ " down: 'fa fa-arrow-down',"
																										+ " previous: 'fa fa-arrow-left',"
																										+ " next: 'fa fa-arrow-right'"
																									+ "}"
																								+ "});"
				
		));
	}
}
 
Example #8
Source File: BootstrapDatePickerBehaviour.java    From pm-wicket-utils with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	Collection<SpecialDate> specialDates = getSpecialDates();

	if(component.isEnabledInHierarchy()){
		response.render(CssReferenceHeaderItem.forReference(DATE_PICKER_CSS));
		response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_JAVASCRIPT));
		response.render(JavaScriptHeaderItem.forReference(DATE_PICKER_EXTENSION_JAVASCRIPT));
		if(!component.getLocale().getLanguage().equals("en")){
			response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(BootstrapDatePickerBehaviour.class, "locales/bootstrap-datepicker."+component.getLocale().getLanguage()+".min.js")));
		}

		if(null != specialDates && !specialDates.isEmpty()) {
			StringBuilder sb = new StringBuilder();
			sb.append("[");
			DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
			SpecialDate[] sdArray = specialDates.toArray(new SpecialDate[20]);
			for(int i = 0; i < specialDates.size(); ++i) {
				SpecialDate sd = sdArray[i];
				sb.append("{dt:new Date('"+df.format(sd.getDt())+"'), css:'"+sd.getCssClass()+"', tooltip:'"+ sd.getTooltip() +"'}");
				if(i < specialDates.size() - 1) {
					sb.append(",");
				}
			}
			sb.append("]");

			response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker(null, "+sb.toString()+")"));
		} else {
			response.render(OnDomReadyHeaderItem.forScript("$(\"#"+component.getMarkupId()+"\").datepicker()"));
		}
	}
}
 
Example #9
Source File: RoomPanel.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(interview ? INTERVIEWWB_JS_REFERENCE : WB_JS_REFERENCE)));
	response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(RoomPanel.class, "room.js"))));
	response.render(JavaScriptHeaderItem.forReference(TouchPunchResourceReference.instance()));
	if (room.isVisible()) {
		response.render(OnDomReadyHeaderItem.forScript(roomEnter.getCallbackScript()));
	}
}
 
Example #10
Source File: PollResultsDialog.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(JqPlotJavascriptResourceReference.get()));
	response.render(CssHeaderItem.forReference(JqPlotCssResourceReference.get()));
	Chart<?> c1 = new PieChart<>(null);
	c1.getChartConfiguration().setHighlighter(new Highlighter());
	for (Chart<?> chart : new Chart<?>[]{c1, new BarChart<Integer>(null)}) {
		for (String resource : JqPlotUtils.retriveJavaScriptResources(chart)) {
			response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(JqPlotBehavior.class, removeMinified(resource))));
		}
	}
}
 
Example #11
Source File: BasePage.java    From openmeetings with Apache License 2.0 5 votes vote down vote up
protected void internalRenderHead(IHeaderResponse response) {
	response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference())));
	super.renderHead(response);
	final String suffix = DEVELOPMENT == getApplication().getConfigurationType() ? "" : ".min";
	response.render(CssHeaderItem.forUrl(String.format("css/theme_om/jquery-ui%s.css", suffix)));
	response.render(CssHeaderItem.forUrl("css/theme.css"));
	if (!Strings.isEmpty(getGaCode())) {
		response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(BasePage.class, "om-ga.js"))));
		StringBuilder script = new StringBuilder("initGA('");
		script.append(getGaCode()).append("');").append(isMainPage() ? "initHash()" : "init()").append(';');
		response.render(OnDomReadyHeaderItem.forScript(script));
	}
	response.render(CssHeaderItem.forReference(FontAwesome5CssReference.instance()));
	response.render(new FilteredHeaderItem(CssHeaderItem.forUrl("css/custom.css"), CUSTOM_CSS_FILTER));
}
 
Example #12
Source File: AtWhoResourceReference.java    From onedev with MIT License 5 votes vote down vote up
@Override
public List<HeaderItem> getDependencies() {
	List<HeaderItem> dependencies = new ArrayList<>();
	dependencies.add(JavaScriptHeaderItem.forReference(Application.get().getJavaScriptLibrarySettings().getJQueryReference()));
	dependencies.add(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(
			AtWhoResourceReference.class, "jquery.atwho-caret.js")));
	dependencies.add(CssHeaderItem.forReference(new CssResourceReference(
			AtWhoResourceReference.class, "jquery.atwho.css")));
	return dependencies;
}
 
Example #13
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 #14
Source File: ActivitiesPanel.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(ActivitiesPanel.class, "activities.js"))));
}
 
Example #15
Source File: UploadDialog.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(UploadDialog.class, "upload.js"))));
}
 
Example #16
Source File: UserMultiChoice.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(new PriorityHeaderItem(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(getClass(), "user-multi-choice.js"), "user-multi-choice")));
}
 
Example #17
Source File: FileTreePanel.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(FileTreePanel.class, "filetree.js")));
}
 
Example #18
Source File: RssWidgetView.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(RssWidgetView.class, "rss.js")));
	response.render(OnDomReadyHeaderItem.forScript(String.format("displayRss(%s);", getRss().toString()))) ;
}
 
Example #19
Source File: OArchitectEditorWidget.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
    super.renderHead(response);
    response.render(CssReferenceHeaderItem.forReference(OARCHITECT_CSS));
    response.render(CssReferenceHeaderItem.forReference(MXGRAPH_CSS));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/OArchitectApplication.js")));
    response.render(JavaScriptHeaderItem.forScript(
            String.format("initMxGraph('%s');", "en"), null));
    response.render(JavaScriptHeaderItem.forReference(MXGRAPH_JS));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectEditor.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectBar.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectOType.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectMessage.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectPopupMenu.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectModalWindow.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OArchitectValueContainer.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OClassEditModalWindow.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/OPropertyEditModalWindow.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/behavior/OArchitectAction.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/config/GraphConfig.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/config/GraphConnectionConfig.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/component/config/GraphStyleConfig.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectCommand.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectUtil.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectOClass.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectOProperty.js")));
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class, "js/util/OArchitectConstants.js")));
    String locale = getOArchitectEditorLocale();
    response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(OArchitectEditorWidget.class,
            String.format("js/util/locale/architect_%s.js", locale))));

    PackageResourceReference configXml = new PackageResourceReference(OArchitectEditorWidget.class, "js/OArchitectApplication.js");
    String configUrl = urlFor(configXml, null).toString();
    String baseUrl = configUrl.substring(0, configUrl.indexOf("js/OArchitectApplication"));
    TextTemplate configTemplate = new PackageTextTemplate(OArchitectEditorWidget.class, "config.tmpl.xml");
    Map<String, Object> params = CommonUtils.toMap("basePath", baseUrl);
    String config = configTemplate.asString(params);
    boolean canUpdate = canUserUpdateEditor();
    response.render(OnLoadHeaderItem.forScript(String.format("initOrienteerArchitect('%s', %s, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s);",
            baseUrl,
            CommonUtils.escapeAndWrapAsJavaScriptString(config),
            locale,
            this.getMarkupId(),
            container.getMarkupId(),
            editor.getMarkupId(),
            sidebar.getMarkupId(),
            toolbar.getMarkupId(),
            outline.getMarkupId(),
            Boolean.toString(canUpdate))));
}
 
Example #20
Source File: ConfigForm.java    From openmeetings with Apache License 2.0 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new JavaScriptResourceReference(ConfigForm.class, "admin-config.js")));
}