Image delimiter repeat and transition param support.

This commit is contained in:
David Russell 2018-05-14 16:15:55 +07:00
parent 62de5d1a07
commit 17329d688b
3 changed files with 40 additions and 3 deletions

View File

@ -181,6 +181,10 @@ public class MarkdownModel implements Markdown {
yOpts.fetchImageBgColor(pp) : YAMLOptions.DEFAULT_BG_COLOR;
String defaultBgPosition = (yOpts != null) ?
yOpts.fetchImageBgPosition(pp) : YAMLOptions.DEFAULT_BG_POSITION;
String defaultBgRepeat = (yOpts != null) ?
yOpts.fetchImageBgRepeat(pp) : YAMLOptions.DEFAULT_BG_REPEAT;
String defaultBgTransition = (yOpts != null) ?
yOpts.fetchTransition(pp) : YAMLOptions.DEFAULT_TRANSITION;
return new StringBuffer(delimiter(md))
.append(imageService.buildBackground(md,
@ -189,6 +193,8 @@ public class MarkdownModel implements Markdown {
defaultBgSize,
defaultBgColor,
defaultBgPosition,
defaultBgRepeat,
defaultBgTransition,
this)).toString();
} else if (gistDelimFound(dp)) {
@ -654,6 +660,8 @@ public class MarkdownModel implements Markdown {
public static final String DELIM_QUERY_SIZE = "size";
public static final String DELIM_QUERY_COLOR = "color";
public static final String DELIM_QUERY_POSITION = "position";
public static final String DELIM_QUERY_REPEAT = "repeat";
public static final String DELIM_QUERY_TRANSITION = "transition";
public static final String DELIM_QUERY_FILE = "file";
public static final String DELIM_QUERY_TITLE = "title";
@ -671,6 +679,10 @@ public class MarkdownModel implements Markdown {
"\" data-background-color=\"";
public static final String MD_IMAGE_POSITION =
"\" data-background-position=\"";
public static final String MD_IMAGE_REPEAT =
"\" data-background-repeat=\"";
public static final String MD_IMAGE_TRANSITION =
"\" data-background-transition=\"";
public static final String MD_BG_COLOR =
"<!-- .slide: data-background=\"";
public static final String MD_CLOSER = "\" -->";

View File

@ -47,7 +47,9 @@ public class ImageService {
return buildBackground(yOpts.fetchImageBg(pp),
yOpts.fetchImageBgSize(pp),
yOpts.fetchImageBgColor(pp),
yOpts.fetchImageBgPosition(pp));
yOpts.fetchImageBgPosition(pp),
yOpts.fetchImageBgRepeat(pp),
yOpts.fetchTransition(pp));
}
public String buildBackground(String md,
@ -56,6 +58,8 @@ public class ImageService {
String defaultSize,
String defaultColor,
String defaultPos,
String defaultRepeat,
String defaultTransition,
MarkdownModel mdm) {
String bgUrl = dp.get(MarkdownModel.DELIM_QUERY_IMAGE);
@ -63,13 +67,19 @@ public class ImageService {
String bgSize = dp.get(MarkdownModel.DELIM_QUERY_SIZE, defaultSize);
String bgColor = dp.get(MarkdownModel.DELIM_QUERY_COLOR, defaultColor);
String bgPos = dp.get(MarkdownModel.DELIM_QUERY_POSITION, defaultPos);
return buildBackground(bgUrl, bgSize, bgColor, bgPos);
String bgRepeat =
dp.get(MarkdownModel.DELIM_QUERY_REPEAT, defaultRepeat);
String bgTransition =
dp.get(MarkdownModel.DELIM_QUERY_TRANSITION, defaultTransition);
return buildBackground(bgUrl, bgSize, bgColor, bgPos, bgRepeat, bgTransition);
}
private String buildBackground(String bgUrl,
String bgSize,
String bgColor,
String bgPosition) {
String bgPosition,
String bgRepeat,
String bgTransition) {
return new StringBuffer(MarkdownModel.MD_SPACER)
.append(MarkdownModel.MD_IMAGE_OPEN)
@ -80,6 +90,10 @@ public class ImageService {
.append(bgColor)
.append(MarkdownModel.MD_IMAGE_POSITION)
.append(bgPosition)
.append(MarkdownModel.MD_IMAGE_REPEAT)
.append(bgRepeat)
.append(MarkdownModel.MD_IMAGE_TRANSITION)
.append(bgTransition)
.append(MarkdownModel.MD_CLOSER)
.append(MarkdownModel.MD_SPACER)
.toString();

View File

@ -222,6 +222,15 @@ public final class YAMLOptions {
}
}
public String fetchImageBgRepeat(PitchParams pp) {
String bgRepeat = _yProps.get(IMAGE_BG_REPEAT_OPTION);
if (bgRepeat == null) {
return DEFAULT_BG_REPEAT;
} else {
return bgRepeat;
}
}
public String fetchTransition(PitchParams pp) {
String transition = _yProps.get(TRANSITION_OPTION);
@ -400,6 +409,7 @@ public final class YAMLOptions {
public static final String DEFAULT_BG_SIZE = "100% 100%";
public static final String DEFAULT_BG_COLOR = " ";
public static final String DEFAULT_BG_POSITION = "center";
public static final String DEFAULT_BG_REPEAT = " ";
public static final String DEFAULT_TRANSITION = "slide";
public static final String MATHJAX_DEFAULT = "TeX-MML-AM_CHTML";
public static final String HIGHLIGHT_DARK_DEFAULT = "github-gist.css";
@ -416,6 +426,7 @@ public final class YAMLOptions {
private static final String IMAGE_BG_SIZE_OPTION = "background-size";
private static final String IMAGE_BG_COLOR_OPTION = "background-color";
private static final String IMAGE_BG_POSITION_OPTION = "background-position";
private static final String IMAGE_BG_REPEAT_OPTION = "background-repeat";
private static final String TRANSITION_OPTION = "transition";
private static final String AUTOSLIDE_OPTION = "autoslide";
private static final String LOOP_OPTION = "loop";