Skip to content
Snippets Groups Projects
Commit a52935ec authored by Florian Gnaegi - frentix GmbH's avatar Florian Gnaegi - frentix GmbH
Browse files

OO-1068 refactor button rendering

parent d8fecd76
No related branches found
No related tags found
No related merge requests found
......@@ -68,9 +68,14 @@ class FormButtonRenderer implements ComponentRenderer {
sb.append(" disabled=\"disabled\" ");
}
sb.append(FormJSHelper.getRawJSFor(fs.getRootForm(), id, fs.getAction()));
sb.append(" class=\"b_button ");
sb.append(" class=\"btn");
if (fsC.getIsSubmitAndValidate()) {
sb.append(" btn-primary");
} else {
sb.append(" btn-default");
}
if(!source.isEnabled()){
sb.append(" b_disabled ");
sb.append(" o_disabled ");
}
sb.append("\"><span>");
sb.append(fs.getTranslated());
......
......@@ -57,13 +57,15 @@ public class Link extends AbstractComponent {
public static final int BUTTON_XSMALL = 1;
public static final int BUTTON_SMALL = 2;
public static final int BUTTON = 3;
public static final int LINK_BACK = 4;
public static final int LINK = 5;
public static final int BUTTON_LARGE = 4;
public static final int LINK_BACK = 5;
public static final int LINK = 6;
/**
* to be refactored later into own components
*/
public static final int TOOLENTRY_DEFAULT = 6;
public static final int TOOLENTRY_CLOSE = 7;
public static final int TOOLENTRY_DEFAULT = 7;
public static final int TOOLENTRY_CLOSE = 8;
/**
* can be added to one of the following:
......@@ -75,6 +77,7 @@ public class Link extends AbstractComponent {
private String command;
private int presentation;
private int presentationBeforeCustomCSS;
private boolean primary;
private String i18n;
private String title;
private String elementId;
......@@ -206,6 +209,14 @@ public class Link extends AbstractComponent {
return i18n;
}
public boolean isPrimary() {
return primary;
}
public void setPrimary(boolean isPrimary) {
primary = isPrimary;
}
public int getPresentation() {
return presentation;
}
......
......@@ -162,6 +162,24 @@ public class LinkFactory {
return new Link(name, cmd, i18nKey, presentation, vc, listener);
}
/**
* add a button to the <code>vc</code> Velocity Container and make the <code>listeningController</code> listen to this button.<p>
* Follow these instructions to show the button and catch its events:
* <ol>
* <li><code>$r.render("myButton")</code> in your velocity page, that the button shows up.</li>
* <li>save the returned link as a instance variable <code>myButton</code></li>
* <li>in the <code>listeningController.event(UserRequest ureq, Component source, Event event)</code> you catch the button by<br><code>if(source == myButton){..your stuff here..}</code></li>
* </ol>
*
* @param one string for name of component, command and i18n key
* @param vc the VelocityContainer within you put this link
* @param listener
* @return the link component
*/
public static Link createButtonLarge(String name, VelocityContainer vc, ComponentEventListener listener){
return new Link(name, name, name, Link.BUTTON_LARGE, vc, listener);
}
/**
* add a button to the <code>vc</code> Velocity Container and make the <code>listeningController</code> listen to this button.<p>
* Follow these instructions to show the button and catch its events:
......
......@@ -81,11 +81,17 @@ public class LinkRenderer extends DefaultComponentRenderer {
cssSb.append(" b_disabled ");
}
if (presentation == Link.BUTTON_XSMALL) {
cssSb.append("b_button b_xsmall");
cssSb.append("btn btn-xs ");
cssSb.append(link.isPrimary() ? "btn-primary" : "btn-default");
} else if (presentation == Link.BUTTON_SMALL) {
cssSb.append("b_button b_small");
cssSb.append("btn btn-sm ");
cssSb.append(link.isPrimary() ? "btn-primary" : "btn-default");
} else if (presentation == Link.BUTTON) {
cssSb.append("b_button");
cssSb.append("btn ");
cssSb.append(link.isPrimary() ? "btn-primary" : "btn-default");
} else if (presentation == Link.BUTTON_LARGE) {
cssSb.append("btn btn-lg ");
cssSb.append(link.isPrimary() ? "btn-primary" : "btn-default");
} else if (presentation == Link.LINK_BACK) {
cssSb.append("b_link_back");
} else if (presentation == Link.TOOLENTRY_DEFAULT) {
......
......@@ -22,6 +22,7 @@
@import "modules/main";
@import "modules/footer";
@import "modules/form";
@import "modules/im";
@import "modules/flags";
@import "modules/devel";
......
.o_form{
legend {}
.o_chelp {}
.o_desc {}
.o_warning {}
.o_info {}
.o_icon_mandatory {
margin-left: 0.3em;
}
.o_disabled {}
}
\ No newline at end of file
/* HELP, context sensitive */
a.o_chelp {
@extend .o_undecorated;
@extend .btn;
@extend .btn-primary;
padding: 1px 3px;
font-size: 10px;
line-height: 1.5;
border-radius: 2px;
}
div.o_chelp_wrapper {
......@@ -12,12 +17,13 @@ div.o_chelp_wrapper {
right: 0.5em;
}
}
/*
fieldset a.o_chelp,
fieldset div.o_chelp_wrapper a.o_chelp {
position: absolute;
top: -1.5em; right: -0.8em;
}
*/
.o_undecorated {
&:hover,&:focus {
......
......@@ -11,11 +11,13 @@ $fa-css-prefix: "o_icon" !default;
/* OpenOLAT Icons */
.o_icon_close { @extend .o_icon-times;}
.o_icon_dev { @extend .o_icon-wrench;}
.o_icon_error {@extend .o_icon-times;}
.o_icon_help { @extend .o_icon-question-circle; @extend .o_icon-lg; cursor: help;}
.o_icon_impress { @extend .o_icon-info-circle; }
.o_icon_message { @extend .o_icon-envelope;}
.o_icon_login {@extend .o_icon-sign-in;}
.o_icon_logout {@extend .o_icon-sign-out;}
.o_icon_mandatory {@extend .o_icon-asterisk; color: #f0ad4e;}
.o_icon_refresh { @extend .o_icon-refresh; }
.o_icon_search {@extend .o_icon-search;}
.o_icon_status_available { @extend .o_icon-circle; color: #006633; }
......
source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment