Java Code Examples for org.apache.wicket.markup.head.IHeaderResponse

The following are top voted examples for showing how to use org.apache.wicket.markup.head.IHeaderResponse. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: gitplex-mit   File: MarkdownEditor.java   Source Code and License 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new MarkdownResourceReference()));
	
	String encodedAttachmentSupport;
	if (getAttachmentSupport() != null) {
		encodedAttachmentSupport = Base64.encodeBase64String(SerializationUtils.serialize(getAttachmentSupport()));
		encodedAttachmentSupport = StringUtils.deleteWhitespace(encodedAttachmentSupport);
		encodedAttachmentSupport = StringEscapeUtils.escapeEcmaScript(encodedAttachmentSupport);
		encodedAttachmentSupport = "'" + encodedAttachmentSupport + "'";
	} else {
		encodedAttachmentSupport = "undefined";
	}
	String callback = ajaxBehavior.getCallbackFunction(explicit("action"), explicit("param1"), explicit("param2"), 
			explicit("param3")).toString();
	
	String autosaveKey = getAutosaveKey();
	if (autosaveKey != null)
		autosaveKey = "'" + JavaScriptEscape.escapeJavaScript(autosaveKey) + "'";
	else
		autosaveKey = "undefined";
	
	String script = String.format("gitplex.server.markdown.onDomReady('%s', %s, %d, %s, %d, %b, %b, %s);", 
			container.getMarkupId(), 
			callback, 
			ATWHO_LIMIT, 
			encodedAttachmentSupport, 
			getAttachmentSupport()!=null?getAttachmentSupport().getAttachmentMaxSize():0,
			getUserMentionSupport() != null,
			getPullRequestReferenceSupport() != null, 
			autosaveKey);
	response.render(OnDomReadyHeaderItem.forScript(script));
	
	script = String.format("gitplex.server.markdown.onWindowLoad('%s');", container.getMarkupId());
	response.render(OnLoadHeaderItem.forScript(script));
}
 
Example 2
Project: gitplex-mit   File: Select2Choice.java   Source Code and License 6 votes vote down vote up
@Override
protected void renderInitializationScript(IHeaderResponse response) {

	T value;
	if (getWebRequest().getRequestParameters().getParameterNames().contains(getInputName())) {
		convertInput();
		value = getConvertedInput();
	} else {
		value = getModelObject();
	}

	if (value != null) {

		JsonBuilder selection = new JsonBuilder();

		try {
			selection.object();
			getProvider().toJson(value, selection);
			selection.endObject();
		} catch (JSONException e) {
			throw new RuntimeException("Error converting model object to Json", e);
		}
		response.render(OnDomReadyHeaderItem.forScript(
				JQuery.execute("$('#%s').select2('data', %s);", getJquerySafeMarkupId(), selection.toJson())));
	}
}
 
Example 3
Project: gitplex-mit   File: SourceEditPanel.java   Source Code and License 6 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new SourceEditResourceReference()));

	String autosaveKey = JavaScriptEscape.escapeJavaScript(context.getAutosaveKey());
	String jsonOfMark = context.getMark()!=null?getJson(context.getMark()):"undefined"; 
	String script = String.format("gitplex.server.sourceEdit.onDomReady('%s', '%s', %s, '%s', %s, '%s', %b, '%s');", 
			sourceFormComponent.getMarkupId(), 
			JavaScriptEscape.escapeJavaScript(context.getNewPath()), 
			jsonOfMark,
			sourceFormat.getIndentType(), 
			sourceFormat.getTabSize(), 
			sourceFormat.getLineWrapMode(), 
			context.getMode() == Mode.EDIT, 
			autosaveKey);
	response.render(OnDomReadyHeaderItem.forScript(script));
	
	script = String.format("gitplex.server.sourceEdit.onWindowLoad('%s', %s, '%s');", 
			sourceFormComponent.getMarkupId(), jsonOfMark, autosaveKey);
	response.render(OnLoadHeaderItem.forScript(script));
}
 
Example 4
Project: karate   File: FeaturePage.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
    super.renderHead(response);
    String script = "Wicket.Event.subscribe(\"/websocket/message\", function(jqEvent, message) {\n"
            + "  message = JSON.parse(message);\n"
            + "  if (message.type == 'step') updateStep(message); else { Karate.Ajax.DebugWindow.logInfo(message.text); }\n"
            + "});\n" 
            + "function updateStep(message){ var btn = jQuery('#' + message.buttonId); btn.addClass('btn-success'); }";
    response.render(JavaScriptHeaderItem.forScript(script, "karate-ws-js"));
    response.render(JavaScriptHeaderItem.forReference(KarateJsResourceReference.INSTANCE));
}
 
Example 5
Project: gitplex-mit   File: CollapseBehavior.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);

	String script = String.format("gitplex.server.setupCollapse('%s', '%s')", component.getMarkupId(), target.getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 6
Project: gitplex-mit   File: SessionFeedbackPanel.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	// we delay show feedback with a timer as some other script may scroll the window 
	response.render(OnDomReadyHeaderItem.forScript("setTimeout('gitplex.server.showSessionFeedback();', 1);"));
}
 
Example 7
Project: gitplex-mit   File: InfiniteScrollBehavior.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	response.render(JavaScriptReferenceHeaderItem.forReference(new InfiniteScrollResourceReference()));
	
	CharSequence url = RequestCycle.get().urlFor(new PackageResourceReference(
			InfiniteScrollBehavior.class, "ajax-indicator.gif"), new PageParameters());
	String script = String.format("gitplex.infiniteScroll.init('%s', %s, '%s', %s);", 
			component.getMarkupId(true), getCallbackFunction(explicit("page")), url, pageSize);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 8
Project: gitplex-mit   File: InputAssistBehavior.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);

	response.render(JavaScriptHeaderItem.forReference(new InputAssistResourceReference()));
	
	String script = String.format("gitplex.server.inputassist.init('%s', %s);", 
			getComponent().getMarkupId(true), 
			getCallbackFunction(explicit("type"), explicit("input"), explicit("caret")));
	
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 9
Project: gitplex-mit   File: DropBehavior.java   Source Code and 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("gitplex.server.dragdrop.setupDroppable('#%s', %s, %s);", 
			component.getMarkupId(), getAccept(), getCallbackFunction(explicit("dragData")));
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 10
Project: gitplex-mit   File: AutoHeightBehavior.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);

	String script = String.format("gitplex.server.autoHeight('#%s', %d);", 
				component.getMarkupId(), bottomOffset);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 11
Project: gitplex-mit   File: CopyClipboardBehavior.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	response.render(JavaScriptHeaderItem.forReference(new CopyClipboardResourceReference()));
	String script = String.format("gitplex.server.copyclipboard.init('%s', '%s');", 
			component.getMarkupId(true), JavaScriptEscape.escapeJavaScript(textModel.getObject()));
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 12
Project: gitplex-mit   File: CompositeAjaxCallListener.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	for (IAjaxCallListener listener: listeners) {
		if (listener instanceof IComponentAwareHeaderContributor) {
			IComponentAwareHeaderContributor headerContributor = (IComponentAwareHeaderContributor) listener;
			headerContributor.renderHead(component, response);
		}
	}
}
 
Example 13
Project: gitplex-mit   File: MarkdownViewer.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new MarkdownResourceReference()));
	
	CharSequence callback = behavior.getCallbackFunction(
			explicit(SourcePositionTrackExtension.DATA_START_ATTRIBUTE), 
			explicit(TASK_CHECKED));
	
	String script = String.format("gitplex.server.markdown.onViewerDomReady('%s', %s, '%s');", 
			getMarkupId(), 
			contentVersionSupport!=null?callback:"undefined", 
			SourcePositionTrackExtension.DATA_START_ATTRIBUTE);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 14
Project: gitplex-mit   File: SourceFormatPanel.java   Source Code and 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("gitplex.server.sourceFormat.init('%s');", getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 15
Project: gitplex-mit   File: DropdownLink.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	String script = String.format(""
			+ "$('#%s').on('click', function(e){"
			+ "  $(this).data('mouseX', e.pageX).data('mouseY', e.pageY);"
			+ "});", getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 16
Project: gitplex-mit   File: FloatingPanel.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	add(newContent(CONTENT_ID).setOutputMarkupId(true));
	
	add(new AbstractPostAjaxBehavior() {
		
		@Override
		protected void respond(AjaxRequestTarget target) {
			FloatingPanel.this.remove();
			onClosed();
		}
		
		@Override
		public void renderHead(Component component, IHeaderResponse response) {
			super.renderHead(component, response);

			response.render(JavaScriptHeaderItem.forReference(new FloatingResourceReference()));
			
			String script = String.format("gitplex.server.floating.init('%s', {target:%s, placement:%s}, %s);", 
					getMarkupId(true), alignTarget, placement, getCallbackFunction());
			response.render(OnDomReadyHeaderItem.forScript(script));
		}

	});
	
	add(AttributeAppender.append("class", "floating"));
	setOutputMarkupId(true);
}
 
Example 17
Project: gitplex-mit   File: CommitListPanel.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new CommitGraphResourceReference()));
	response.render(CssHeaderItem.forReference(new CommitListResourceReference()));
	
	String jsonOfCommits = CommitGraphUtils.asJSON(commitsModel.getObject());
	String script = String.format("gitplex.server.commitgraph.render('%s', %s);", container.getMarkupId(), jsonOfCommits);
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 18
Project: gitplex-mit   File: ModalPanel.java   Source Code and License 5 votes vote down vote up
@Override
protected void onInitialize() {
	super.onInitialize();
	
	WebMarkupContainer dialog = new WebMarkupContainer("dialog");
	add(dialog);
	
	dialog.add(newContent(CONTENT_ID));
	
	if (size == Size.LARGE)
		dialog.add(AttributeAppender.append("class", "modal-lg"));
	else if (size == Size.SMALL)
		dialog.add(AttributeAppender.append("class", "modal-sm"));
	
	add(new AbstractPostAjaxBehavior() {
		
		@Override
		protected void respond(AjaxRequestTarget target) {
			ModalPanel.this.remove();
			onClosed();
		}
		
		@Override
		public void renderHead(Component component, IHeaderResponse response) {
			super.renderHead(component, response);

			response.render(JavaScriptHeaderItem.forReference(new ModalResourceReference()));
			
			String script = String.format("gitplex.server.modal.onDomReady('%s', %s);", 
					getMarkupId(true), getCallbackFunction());
			response.render(OnDomReadyHeaderItem.forScript(script));
		}

	});
	
	setOutputMarkupId(true);
}
 
Example 19
Project: gitplex-mit   File: AccordionPanel.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	String script = String.format("gitplex.server.setupAccordion('%s')", getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 20
Project: gitplex-mit   File: DragAndDropBehavior.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {

	response.render(JavaScriptHeaderItem.forReference(new JQueryUIResourceReference()));

	// Render script to enable sortable/drag-and-drop behavior
	String script = "$('#%1$s').select2('container').find('ul.select2-choices').sortable({"
			+ "containment: 'parent'," + "start: function() { $('#%1$s').select2('onSortStart'); },"
			+ "update: function() { $('#%1$s').select2('onSortEnd'); }" + "});";
	response.render(OnDomReadyHeaderItem.forScript(JQuery.execute(script, component.getMarkupId())));
}
 
Example 21
Project: gitplex-mit   File: AbstractSelect2Choice.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

	// initialize select2
	response.render(JavaScriptHeaderItem.forReference(new Select2ResourceReference()));

	response.render(OnDomReadyHeaderItem
			.forScript(JQuery.execute("$('#%s').select2(%s);", getJquerySafeMarkupId(), settings.toJson())));

	// select current value

	renderInitializationScript(response);
}
 
Example 22
Project: gitplex-mit   File: Select2MultiChoice.java   Source Code and License 5 votes vote down vote up
@Override
protected void renderInitializationScript(IHeaderResponse response) {
	Collection<? extends T> choices;
	if (getWebRequest().getRequestParameters().getParameterNames().contains(getInputName())) {
		convertInput();
		choices = getConvertedInput();
	} else {
		choices = getModelObject();
	}

	if (choices != null && !choices.isEmpty()) {

		JsonBuilder selection = new JsonBuilder();

		try {
			selection.array();
			for (T choice : choices) {
				selection.object();
				getProvider().toJson(choice, selection);
				selection.endObject();
			}
			selection.endArray();
		} catch (JSONException e) {
			throw new RuntimeException("Error converting model object to Json", e);
		}

		response.render(OnDomReadyHeaderItem.forScript(
				JQuery.execute("$('#%s').select2('data', %s);", getJquerySafeMarkupId(), selection.toJson())));
	}
}
 
Example 23
Project: gitplex-mit   File: ConfirmDeletePanel.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(JavaScriptHeaderItem.forReference(new ConfirmDeleteResourceReference()));
	
	String script = String.format("gitplex.server.confirmDelete('%s', '%s');", getMarkupId(), getConfirmInput());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 24
Project: gitplex-mit   File: DatetimePicker.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	String script = String.format(""
			+ "$('#%s').keyup(function() {"
			+ "  if (e.keyCode == 13) {"
			+ "    $(this).closest('form').find(\"input[type='submit'],button[type='submit']\").trigger('click');"
			+ "  }"
			+ "});", getMarkupId());
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 25
Project: gitplex-mit   File: ProjectCommitsPage.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new CommitGraphResourceReference()));
	response.render(CssHeaderItem.forReference(new ProjectCommitsResourceReference()));
	response.render(OnDomReadyHeaderItem.forScript(renderCommitGraph()));
}
 
Example 26
Project: gitplex-mit   File: ServerInitPage.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(CssHeaderItem.forReference(new ServerInitResourceReference()));
	
	if (initStage.getManualConfigs().isEmpty())
		response.render(OnDomReadyHeaderItem.forScript("$('#server-init').addClass('inited');"));
}
 
Example 27
Project: gitplex-mit   File: BlobEditPanel.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

	response.render(JavaScriptHeaderItem.forReference(new BlobEditResourceReference()));
	
	String script = String.format("gitplex.server.blobEdit.onDomReady('%s');", getMarkupId()); 
	response.render(OnDomReadyHeaderItem.forScript(script));
}
 
Example 28
Project: gitplex-mit   File: BlobViewPanel.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new BlobViewResourceReference()));
	
	response.render(OnDomReadyHeaderItem.forScript(String.format("gitplex.server.blobView.onDomReady('%s');", getMarkupId())));
}
 
Example 29
Project: gitplex-mit   File: MarkdownBlobEditor.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	if (autoFocus) {
		String script = String.format("$('#%s textarea').focus();", input.getMarkupId());
		response.render(OnDomReadyHeaderItem.forScript(script));
	}
}
 
Example 30
Project: gitplex-mit   File: FolderViewPanel.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new FolderViewResourceReference()));

	PageParameters params = LastCommitsResource.paramsOf(context.getProject(), 
			context.getBlobIdent().revision, context.getBlobIdent().path); 
	String lastCommitsUrl = urlFor(new LastCommitsResourceReference(), params).toString();
	response.render(OnDomReadyHeaderItem.forScript(
			String.format("gitplex.server.folderView('%s', '%s')", getMarkupId(), lastCommitsUrl)));
}
 
Example 31
Project: gitplex-mit   File: ProjectPage.java   Source Code and License 5 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

	response.render(JavaScriptHeaderItem.forReference(new ProjectResourceReference()));
	response.render(OnDomReadyHeaderItem.forScript("gitplex.server.project();"));
}
 
Example 32
Project: karate   File: BasePage.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
    response.render(CssContentHeaderItem.forReference(KarateCssResourceReference.INSTANCE));
}
 
Example 33
Project: gitplex-mit   File: DashboardPage.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	response.render(CssHeaderItem.forReference(new DashboardResourceReference()));
}
 
Example 34
Project: gitplex-mit   File: BlameMessageBehavior.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(Component component, IHeaderResponse response) {
	super.renderHead(component, response);
	response.render(JavaScriptHeaderItem.forReference(new BlameMessageResourceReference()));
}
 
Example 35
Project: gitplex-mit   File: DragBehavior.java   Source Code and 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("gitplex.server.dragdrop.setupDraggable('#%s', '%s', '%s');", 
			component.getMarkupId(), dragData, dragText)));
}
 
Example 36
Project: gitplex-mit   File: LayoutPage.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(CssHeaderItem.forReference(new LayoutResourceReference()));
}
 
Example 37
Project: gitplex-mit   File: ReflectionBeanEditor.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(OnDomReadyHeaderItem.forScript(String.format("gitplex.server.editable.adjustReflectionEditor('%s')", getMarkupId())));
}
 
Example 38
Project: gitplex-mit   File: UserSingleChoice.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new UserChoiceResourceReference()));
}
 
Example 39
Project: gitplex-mit   File: UserMultiChoice.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);
	
	response.render(JavaScriptHeaderItem.forReference(new UserChoiceResourceReference()));
}
 
Example 40
Project: gitplex-mit   File: RevisionSelector.java   Source Code and License 4 votes vote down vote up
@Override
public void renderHead(IHeaderResponse response) {
	super.renderHead(response);

	response.render(JavaScriptHeaderItem.forReference(new RevisionSelectorResourceReference()));
}