Skip to content

Commit

Permalink
refix ZK-2931
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-szu committed Nov 10, 2015
1 parent 77278fb commit 5086b6d
Show file tree
Hide file tree
Showing 6 changed files with 734 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.zkoss.zk.ui.Execution;
import org.zkoss.zul.theme.StandardThemeProvider;

public class AtlanticThemeProvider extends StandardThemeProvider {
public class AtlanticCEThemeProvider extends StandardThemeProvider {

/** Library property key. */
private static final String DONT_USE_GOOGLE_FONT = "org.zkoss.theme.atlantic.useGoogleFont.disabled";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.zkoss.theme.atlantic;

import java.util.Collection;
import java.util.List;

import org.zkoss.html.StyleSheet;
import org.zkoss.lang.Library;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zkmax.theme.StandardThemeProvider;

public class AtlanticEEThemeProvider extends StandardThemeProvider {

/** Library property key. */
private static final String DONT_USE_GOOGLE_FONT = "org.zkoss.theme.atlantic.useGoogleFont.disabled";

@Override
public Collection<Object> getThemeURIs(Execution exec, List<Object> uris) {
if (!Boolean.parseBoolean(Library.getProperty(DONT_USE_GOOGLE_FONT))) { //false by default
//ZK-2931 can't start the url with "//", encodeURL will prepend
//current context path if no scheme were given
uris.add(new StyleSheet(exec.getScheme() + "://fonts.googleapis.com/css?family=Open+Sans", "text/css"));
}
return super.getThemeURIs(exec, uris);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.zkoss.theme.atlantic;

import java.util.Collection;
import java.util.List;

import org.zkoss.html.StyleSheet;
import org.zkoss.lang.Library;
import org.zkoss.zk.ui.Execution;
import org.zkoss.zkex.theme.StandardThemeProvider;

public class AtlanticPEThemeProvider extends StandardThemeProvider {

/** Library property key. */
private static final String DONT_USE_GOOGLE_FONT = "org.zkoss.theme.atlantic.useGoogleFont.disabled";

@Override
public Collection<Object> getThemeURIs(Execution exec, List<Object> uris) {
if (!Boolean.parseBoolean(Library.getProperty(DONT_USE_GOOGLE_FONT))) { //false by default
//ZK-2931 can't start the url with "//", encodeURL will prepend
//current context path if no scheme were given
uris.add(new StyleSheet(exec.getScheme() + "://fonts.googleapis.com/css?family=Open+Sans", "text/css"));
}
return super.getThemeURIs(exec, uris);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ public class AtlanticThemeWebAppInit implements WebAppInit {

public void init(WebApp wapp) throws Exception {
//ZK-2931 custom theme provider and library property for turning on/off the usage of google font
wapp.getConfiguration().setThemeProvider(new AtlanticThemeProvider());
wapp.getConfiguration().setThemeProvider(new AtlanticCEThemeProvider());
Themes.register(ATLANTIC_NAME, ATLANTIC_DISPLAY, ATLANTIC_PRIORITY);
String edition = WebApps.getEdition();
if ("PE".equals(edition)) {
wapp.getConfiguration().setThemeProvider(new AtlanticPEThemeProvider());
}
if ("EE".equals(edition)) {
wapp.getConfiguration().setThemeProvider(new AtlanticEEThemeProvider());
Themes.register(ResponsiveThemeRegistry.TABLET_PREFIX + ATLANTIC_NAME, ATLANTIC_DISPLAY, ATLANTIC_PRIORITY);
}
}
Expand Down
Loading

0 comments on commit 5086b6d

Please sign in to comment.