Skip to content

Commit

Permalink
#982 load Fontawesome 4 only if it's really needed
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanrauh committed Aug 11, 2018
1 parent 0c6f661 commit 8092623
Show file tree
Hide file tree
Showing 13 changed files with 211 additions and 78 deletions.
20 changes: 16 additions & 4 deletions src/main/java/net/bootsfaces/component/button/Button.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,16 @@

package net.bootsfaces.component.button;

import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.component.html.HtmlOutcomeTargetButton;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.ListenerFor;
import javax.faces.event.ListenersFor;
import javax.faces.event.PostAddToViewEvent;

import javax.el.ValueExpression;
import javax.faces.component.FacesComponent;
import javax.faces.component.html.HtmlOutcomeTargetButton;

import net.bootsfaces.C;
import net.bootsfaces.listeners.AddResourcesListener;
import net.bootsfaces.render.IHasTooltip;
Expand Down Expand Up @@ -360,6 +359,7 @@ public String getIconAwesome() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconAwesome(String _iconAwesome) {
AddResourcesListener.setNeedsFontsAwesome(this);
getStateHelper().put(PropertyKeys.iconAwesome, _iconAwesome);
}

Expand All @@ -376,6 +376,9 @@ public boolean isIconBrand() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconBrand(boolean _iconBrand) {
if (_iconBrand) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconBrand, _iconBrand);
}

Expand Down Expand Up @@ -424,6 +427,9 @@ public boolean isIconLight() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconLight(boolean _iconLight) {
if (_iconLight) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconLight, _iconLight);
}

Expand Down Expand Up @@ -456,6 +462,9 @@ public boolean isIconRegular() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconRegular(boolean _iconRegular) {
if (_iconRegular) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconRegular, _iconRegular);
}

Expand Down Expand Up @@ -504,6 +513,9 @@ public boolean isIconSolid() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconSolid(boolean _iconSolid) {
if (_iconSolid) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconSolid, _iconSolid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,38 +147,38 @@ public Map<String, String> getJQueryEventParameterListsForAjax() {
}

public void setIconAwesome(String _iconAwesome) {
AddResourcesListener.setNeedsFontsAwesome();
AddResourcesListener.setNeedsFontsAwesome(this);
super.setIconAwesome(_iconAwesome);
}

@Override
public void setIconBrand(boolean _iconBrand) {
if (_iconBrand) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconBrand(_iconBrand);
}

@Override
public void setIconRegular(boolean _iconRegular) {
if (_iconRegular) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconRegular(_iconRegular);
}

@Override
public void setIconLight(boolean _iconLight) {
if (_iconLight) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconLight(_iconLight);
}

@Override
public void setIconSolid(boolean _iconSolid) {
if (_iconSolid) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconSolid(_iconSolid);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ public String getIconAwesome() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconAwesome(String _iconAwesome) {
AddResourcesListener.setNeedsFontsAwesome(this);
getStateHelper().put(PropertyKeys.iconAwesome, _iconAwesome);
}

Expand All @@ -393,6 +394,9 @@ public boolean isIconBrand() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconBrand(boolean _iconBrand) {
if (_iconBrand) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconBrand, _iconBrand);
}

Expand Down Expand Up @@ -441,6 +445,9 @@ public boolean isIconLight() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconLight(boolean _iconLight) {
if (_iconLight) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconLight, _iconLight);
}

Expand Down Expand Up @@ -473,6 +480,9 @@ public boolean isIconRegular() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconRegular(boolean _iconRegular) {
if (_iconRegular) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconRegular, _iconRegular);
}

Expand Down Expand Up @@ -521,6 +531,9 @@ public boolean isIconSolid() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconSolid(boolean _iconSolid) {
if (_iconSolid) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconSolid, _iconSolid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,38 +208,38 @@ public boolean isDisabled() {
}

public void setIconAwesome(String _iconAwesome) {
AddResourcesListener.setNeedsFontsAwesome();
AddResourcesListener.setNeedsFontsAwesome(this);
super.setIconAwesome(_iconAwesome);
}

@Override
public void setIconBrand(boolean _iconBrand) {
if (_iconBrand) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconBrand(_iconBrand);
}

@Override
public void setIconRegular(boolean _iconRegular) {
if (_iconRegular) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconRegular(_iconRegular);
}

@Override
public void setIconLight(boolean _iconLight) {
if (_iconLight) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconLight(_iconLight);
}

@Override
public void setIconSolid(boolean _iconSolid) {
if (_iconSolid) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconSolid(_iconSolid);
}
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/net/bootsfaces/component/dropButton/DropButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public String getIconAwesome() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconAwesome(String _iconAwesome) {
AddResourcesListener.setNeedsFontsAwesome(this);
getStateHelper().put(PropertyKeys.iconAwesome, _iconAwesome);
}

Expand All @@ -313,6 +314,9 @@ public boolean isIconBrand() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconBrand(boolean _iconBrand) {
if (_iconBrand) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconBrand, _iconBrand);
}

Expand Down Expand Up @@ -361,6 +365,9 @@ public boolean isIconLight() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconLight(boolean _iconLight) {
if (_iconLight) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconLight, _iconLight);
}

Expand Down Expand Up @@ -393,6 +400,9 @@ public boolean isIconRegular() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconRegular(boolean _iconRegular) {
if (_iconRegular) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconRegular, _iconRegular);
}

Expand Down Expand Up @@ -441,6 +451,9 @@ public boolean isIconSolid() {
* Usually this method is called internally by the JSF engine.
*/
public void setIconSolid(boolean _iconSolid) {
if (_iconSolid) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.iconSolid, _iconSolid);
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/net/bootsfaces/component/dropMenu/DropMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,38 +77,38 @@ public String getFamily() {
}

public void setIconAwesome(String _iconAwesome) {
AddResourcesListener.setNeedsFontsAwesome();
AddResourcesListener.setNeedsFontsAwesome(this);
super.setIconAwesome(_iconAwesome);
}

@Override
public void setIconBrand(boolean _iconBrand) {
if (_iconBrand) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconBrand(_iconBrand);
}

@Override
public void setIconRegular(boolean _iconRegular) {
if (_iconRegular) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconRegular(_iconRegular);
}

@Override
public void setIconLight(boolean _iconLight) {
if (_iconLight) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconLight(_iconLight);
}

@Override
public void setIconSolid(boolean _iconSolid) {
if (_iconSolid) {
AddResourcesListener.setFontAwesomeVersion(5);
AddResourcesListener.setFontAwesomeVersion(5, this);
}
super.setIconSolid(_iconSolid);
}
Expand Down
32 changes: 16 additions & 16 deletions src/main/java/net/bootsfaces/component/iconAwesome/IconAwesome.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@

package net.bootsfaces.component.iconAwesome;

import javax.faces.event.AbortProcessingException;
import javax.faces.event.ComponentSystemEvent;
import javax.faces.event.ListenerFor;
import javax.faces.event.ListenersFor;
import javax.faces.event.PostAddToViewEvent;

import javax.faces.component.FacesComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.ListenerFor;
import javax.faces.event.ListenersFor;
import javax.faces.event.PostAddToViewEvent;
Expand All @@ -45,15 +38,6 @@ public class IconAwesome extends Icon {

public static final String DEFAULT_RENDERER = "net.bootsfaces.component.iconAwesome.IconAwesome";

public void processEvent(ComponentSystemEvent event) throws AbortProcessingException {
if (isAutoUpdate()) {
if (FacesContext.getCurrentInstance().isPostback()) {
FacesContext.getCurrentInstance().getPartialViewContext().getRenderIds().add(getClientId());
}
super.processEvent(event);
}
}

protected enum PropertyKeys {
ajax, autoUpdate, brand, colLg, colMd, colSm, colXs, delay, display, fixedWidth, hidden, inverse, largeScreen, light, mediumScreen, offset, offsetLg, offsetMd, offsetSm, offsetXs, onclick, oncomplete, onerror, onsuccess, process, pulse, regular, smallScreen, solid, span, style, styleClass, tinyScreen, tooltip, tooltipContainer, tooltipDelay, tooltipDelayHide, tooltipDelayShow, tooltipPosition, update, value, visible;
String toString;
Expand All @@ -69,6 +53,10 @@ public String toString() {
return ((this.toString != null) ? this.toString : super.toString());
}
}

public IconAwesome() {
AddResourcesListener.setNeedsFontsAwesome(this);
}

/**
* Whether the Button submits the form with AJAX. <P>
Expand Down Expand Up @@ -115,6 +103,9 @@ public boolean isBrand() {
* Usually this method is called internally by the JSF engine.
*/
public void setBrand(boolean _brand) {
if (_brand) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.brand, _brand);
}

Expand Down Expand Up @@ -291,6 +282,9 @@ public boolean isLight() {
* Usually this method is called internally by the JSF engine.
*/
public void setLight(boolean _light) {
if (_light) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.light, _light);
}

Expand Down Expand Up @@ -499,6 +493,9 @@ public boolean isRegular() {
* Usually this method is called internally by the JSF engine.
*/
public void setRegular(boolean _regular) {
if (_regular) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.regular, _regular);
}

Expand Down Expand Up @@ -531,6 +528,9 @@ public boolean isSolid() {
* Usually this method is called internally by the JSF engine.
*/
public void setSolid(boolean _solid) {
if (_solid) {
AddResourcesListener.setFontAwesomeVersion(5, this);
}
getStateHelper().put(PropertyKeys.solid, _solid);
}

Expand Down
Loading

0 comments on commit 8092623

Please sign in to comment.