// Add data related to the current quiz in the "to compile" files
$this->writeStyles();
+ $this->writeAnimations();
$this->writeL10n();
$this->writeData();
// Run the compiler
// Main background
$this->sassVariables['background-color'] = Color::colorToCSS($this->theme->backgroundColor);
$this->sassVariables['background-custom'] = $this->theme->backgroundCustom ? 'true' : 'false';
+
+ $this->data->set('mainBackground', '');
+ $this->data->set('mainBackgroundMobile', '');
+
if ($this->theme->backgroundCustom) {
- $this->_addBackgroundVariables('background-desktop', 'background');
+ $this->_addBackgroundVariables('background-desktop', 'background', 'mainBackground');
if ($this->theme->backgroundCustomMobile) {
- $this->_addBackgroundVariables('background-mobile', 'background', 'Mobile');
+ $this->_addBackgroundVariables('background-mobile', 'background', 'mainBackgroundMobile', 'Mobile');
} else {
- $this->_addBackgroundVariables('background-mobile', 'background');
+ $this->_addBackgroundVariables('background-mobile', 'background', 'mainBackgroundMobile');
}
}
+
$this->writeSass();
}
- protected function _addBackgroundVariables($sassPrefix, $themePrefix, $themeSuffix = '')
+ protected function _addBackgroundVariables($sassPrefix, $themePrefix, $dataKey, $themeSuffix = '')
{
- $this->sassVariables[$sassPrefix . '-image'] = '../' . $this->data['theme']->{$themePrefix . 'Image' . $themeSuffix};
- switch ($this->data['theme']->{$themePrefix . 'Size' . $themeSuffix}) {
+ $i=$this->data['theme']->{$themePrefix . 'Image' . $themeSuffix};
+ $this->data->set($dataKey, $i);
+ if(stristr($i,'.json')){
+ $this->animations[$i]=file_get_contents($this->theme->getPageData()->getImageFile($themePrefix . 'Image' . $themeSuffix));
+ }
- case ThemeBackgroundSize::REPEAT:
- $size = 'auto auto';
- $repeat = 'repeat';
- break;
+ switch ($this->data['theme']->{$themePrefix . 'Size' . $themeSuffix}) {
case ThemeBackgroundSize::RATIO:
$size = 'cover';
- $repeat = 'no-repeat';
break;
case ThemeBackgroundSize::NONE:
- $size = 'auto auto';
- $repeat = 'no-repeat';
+ $size = 'none';
break;
default:
case ThemeBackgroundSize::STRETCH:
- $size = '100% 100%';
- $repeat = 'no-repeat';
+ $size = 'fill';
break;
}
default => '50%',
};
- $this->sassVariables[$sassPrefix . '-repeat'] = $repeat;
$this->sassVariables[$sassPrefix . '-size'] = $size;
$this->sassVariables[$sassPrefix . '-position-x'] = $positionx;
$this->sassVariables[$sassPrefix . '-position-y'] = $positiony;
}
-
protected function _font($f)
{
if (!$f) {
$resourcePath = $this->_resourcesPath();
$vdir->copyDirectory($resourcePath . '/js', 'js');
$vdir->copyDirectory($resourcePath . '/style', 'style');
- $this->writeAnimations();
}
protected function _resourcesPath()
const NOK_COLOR = '#D0167C';
const CONFETTI_COLOR = '#E4FF19';
+ protected $animations=[];
+
/**
* @param $vdir VirtualDirectory
* @return void
$font = FluidbookFont::getAvailableFonts()[$this->theme->font ?: 'SourceSans'];
$animationReplace['Source Sans Pro'] = trim($font['font_family'], '"');
$animationReplace['"fPath":"images/font_0",'] = '';
- $animations = [];
foreach (Files::getDirectoryIterator($this->_resourcesPath() . '/animations/') as $file) {
if (!$file->isFile() || $file->getExtension() !== 'json') {
foreach ($animationPregReplace as $regex => $replace) {
$c = preg_replace($regex, $replace, $c);
}
- $animations[$file->getBasename('.' . $file->getExtension())] = $c;
+ $this->animations[$file->getBasename('.' . $file->getExtension())] = $c;
}
- $this->data['animations'] = new Data($animations);
+ $this->data['animations'] = new Data($this->animations);
}
}