class wsHTML5Compiler {
+ public static function factory($book_id, $version = 'stable') {
+ if ($version == 'stable') {
+ return new wsHTML5Compiler($book_id, $version);
+ } else {
+ return new wsHTML5CompilerDev($book_id, $version);
+ }
+ }
+
protected static $resolutions = array(150, 36);
protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', '');
protected static $jsFiles = array(
protected function writeIndex($numCSS) {
global $core;
-
+
$html = file_get_contents($this->assets . '/_index.html');
$uhtml = $html;
$this->config->height = $this->cssHeight;
$this->config->optimalWidth = $this->optimalWidth;
$this->config->optimalHeight = $this->optimalHeight;
- $this->config->chapters=$this->book->chapters;
+ $this->config->chapters = $this->book->chapters;
foreach ($this->additionalConfig as $k => $v) {
$this->config->$k = $v;
}
}
+class wsHTML5CompilerDev extends wsHTML5Compiler {
+
+ protected function writeCSS($file, $links) {
+ $res = array();
+
+ // General theme
+ $cssWidth = $this->cssWidth;
+ $cssHeight = $this->cssHeight;
+ $cssScale = $this->cssScale;
+ $w2 = ($cssWidth * 2) . 'px';
+
+
+ $h = $cssHeight . 'px';
+
+ $wm = ($this->width * $this->multiply) . 'px';
+ $hm = ($this->height * $this->multiply) . 'px';
+ $w = $cssWidth . 'px';
+ $offsetLeft = round(($this->optimalWidth - $cssWidth) / 2, 3);
+ $offsetLeft2 = $offsetLeft * 2;
+ $offsetTop = round(($this->optimalHeight - $cssHeight) / 2, 3);
+ $navTop = ($cssHeight - 40 - 100) / 2;
+
+
+ $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.portrait #shadow,#shadow.single,.page .links,.doublePage._3d{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}';
+ $res[] = '.doublePage,#pages,.landscape #shadow.double{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}';
+ $res[] = '.landscape .doublePage._2d.next{' . $this->writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}';
+ $res[] = '.landscape .doublePage._2d.prev{' . $this->writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}';
+ $res[] = '.portrait .doublePage._2d.next{' . $this->writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}';
+ $res[] = '.portrait .doublePage._2d.prev{' . $this->writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}';
+ $res[] = '.doublePage._3d{left:' . $w . ';}';
+ $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}';
+ $res[] = '.landscape #shadow.single.right{left: ' . $w . ';}';
+ $res[] = '.landscape .page.right{left:' . $w . '}';
+ if ($this->theme->parametres->displayPageNumber) {
+ $res[] = '#pagesnumbers{top:' . $h . ';color:' . self::colorToCSS($this->theme->parametres->colorPageNumber) . '}';
+ $res[] = '#pagesnumbers div{width:' . $w . '}';
+ } else {
+ $res[] = '#pagesnumbers{display:none;}';
+ }
+
+
+ $res[] = '.background{' . $this->writeCSSUA('transform-origin', 'top left') . ';}';
+ foreach (self::$resolutions as $r) {
+ $ratio = round(72 / $r, 3) * $cssScale;
+
+ $wr = $cssWidth / $ratio;
+ $hr = $cssHeight / $ratio;
+
+ $br = '.background.r' . $r . '{';
+ if ($ratio != 1) {
+ $br.=$this->writeCSSUA('transform', 'scale(' . $ratio . ')') . ';';
+ }
+ $br.='width:' . $wr . 'px;height:' . $hr . 'px;}';
+ $res[] = $br;
+ }
+ $texts = '.texts{' . $this->writeCSSUA('transform-origin', 'top left') . ';';
+ $texts.=$this->writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';';
+ $texts.='width:' . ($wm / $this->cssSVGScale) . '; max-width:' . ($wm / $this->cssSVGScale) . ';';
+ $texts.='height:' . ($hm / $this->cssSVGScale) . '; max-height:' . ($hm / $this->cssSVGScale) . ';';
+ $texts.='}';
+ $res[] = $texts;
+
+ // Theme
+ // Background
+ $body = '#main{';
+ $body.='background-color:#' . $this->theme->parametres->backgroundColor . ';';
+ switch ($this->theme->parametres->repeat) {
+ case wsTheme::REPEAT:
+ $body.='background-repeat:repeat;';
+ break;
+ case wsTheme::NONE:
+ $body.='background-repeat:no-repeat;';
+ break;
+ case wsTheme::RATIO:
+ $body.='background-repeat:no-repeat;';
+ $body.='background-size:cover;';
+ break;
+ case wsTheme::STRETCH:
+ $body.='background-repeat:no-repeat;';
+ $body.='background-size:100% 100%;';
+ break;
+ }
+ if ($this->theme->parametres->backgroundImage != '') {
+ copy($this->themeRoot . '/' . $this->theme->parametres->backgroundImage, $this->vdir . '/data/images/' . $this->theme->parametres->backgroundImage);
+ $body.='background-image:url(../images/' . $this->theme->parametres->backgroundImage . ');';
+ $body.='background-position:';
+
+ switch ($this->theme->parametres->backgroundVAlign) {
+ case wsTheme::TOP:
+ $body.='top';
+ break;
+ case wsTheme::MIDDLE:
+ $body.='center';
+ break;
+ case wsTheme::BOTTOM:
+ $body.='bottom';
+ break;
+ }
+ $body.=' ';
+ switch ($this->theme->parametres->backgroundHAlign) {
+ case wsTheme::LEFT:
+ $body.='left';
+ break;
+ case wsTheme::CENTER:
+ $body.='center';
+ break;
+ case wsTheme::RIGHT:
+ $body.='right';
+ break;
+ }
+ $body.=';';
+ }
+
+ $body.='}';
+ $res[] = $body;
+
+ // Header
+ $header = '#header{';
+ $header.='height:' . $this->theme->parametres->menuHeight . 'px;';
+ $header.='background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';';
+ if ($this->theme->parametres->menuImage != '') {
+ copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage);
+ $header.='background-image:url(../images/' . $this->theme->parametres->menuImage . ');';
+ $header.='background-repeat:no-repeat;';
+ $header.='background-size:100% ' . $this->theme->parametres->menuHeight . 'px;';
+ }
+ $header.='}';
+ $res[] = $header;
+
+ //Icons
+ $res = array_merge($res, $this->writeIcons());
+
+ // Logo
+ $logo = '#logo{';
+ if ($this->theme->parametres->logo) {
+ copy($this->themeRoot . '/' . $this->theme->parametres->logo, $this->vdir . '/data/images/' . $this->theme->parametres->logo);
+ $dim = getimagesize($this->vdir . '/data/images/' . $this->theme->parametres->logo);
+ $logo.='background-image:url(../images/' . $this->theme->parametres->logo . ');width:' . $dim[0] . 'px;height:' . $dim[1] . 'px;';
+ }
+ $logo.='}';
+ $res[] = $logo;
+
+ // Credits
+ $res[] = '#credits,#credits a{color:' . self::colorToCSS($this->theme->parametres->creditsColor) . ';}';
+
+ // Arrows
+ $res[] = '#next,#previous{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}';
+ // Book shadow
+ $shadowColor = self::colorToCSS($this->theme->parametres->bookShadeColor);
+ if ($shadowColor != 'transparent') {
+ $res[] = '#shadow{' . $this->writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}';
+ }
+
+ // Links Styles
+ $res = array_merge($res, $links);
+ $res[] = '.link a.displayArea:hover,.link a.displayArea.animating{background-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';}';
+ $res[] = '.link a.displayArea{-webkit-tap-highlight-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';background-color:' . self::colorToCSS($this->theme->parametres->linksColor, 0.0001) . ';}';
+
+ // Menus
+ # View
+ $res[] = '.portrait #view{width:' . $w . ';min-height:' . $h . '}';
+ $res[] = '.landscape #view{width:' . $w2 . ';min-height:' . $h . '}';
+ $res[] = '#view{background-color:' . self::colorToCSS($this->theme->parametres->couleurB) . ';color:' . self::colorToCSS($this->theme->parametres->subTextColor) . ';}';
+ # Index
+ $ratio = $this->width / $this->height;
+ $thumbh = round(100 / $ratio);
+ $res[] = '#index .thumb img{width:100px;height:' . $thumbh . 'px;}';
+ $res[] = '#index .doubleThumb{height:' . $thumbh . 'px;' . $this->writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}';
+ $res[] = '#index .doubleThumb .overlay{height:' . $thumbh . 'px;}';
+ $res[] = '#index .doubleThumb .hits.yes{background-color:' . self::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextSelectColor) . '}';
+
+ $res = array_chunk($res, 3500);
+ foreach ($res as $k => $css) {
+ file_put_contents(sprintf($file, $k), implode("\n", $css));
+ }
+ return count($res);
+ }
+
+}
+
?>
\ No newline at end of file