From 99ad7c0c954a7f10056ac4751b9a2270bd73dbfa Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Wed, 3 May 2017 14:48:15 +0000 Subject: [PATCH] wip #1381 @0:05 --- .../html5video/class.ws.html5.compiler.php | 139 +++++------------- .../html5/html5video/class.ws.html5.links.php | 14 +- 2 files changed, 44 insertions(+), 109 deletions(-) diff --git a/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php b/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php index 529cf71a4..d5e2bdf5f 100644 --- a/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php +++ b/inc/ws/Util/html5/html5video/class.ws.html5.compiler.php @@ -1,26 +1,9 @@ con); - $book = $dao->selectById($book_id); - $version = $book->parametres->mobileLVersion; - } - - if ($version == 'stable') { - $class = 'wsHTML5Compiler'; - } else { - $class = 'wsHTML5CompilerDev'; - } - return new $class($book_id, $version, $phonegap, $phonegapVersion, $dir, $standalone, $appcache, $home); - } - protected static $resolutions = array(150, 300); protected $maxRes = 300; - protected static $uaPrefixes = array('-moz-', '-webkit-', '-o-', '-ms-', ''); + public $jsFiles = array( 'js/libs/modernizr/modernizr.js', 'js/libs/modernizr/tests.js', @@ -171,7 +154,7 @@ class wsHTML5Compiler { function __construct($book_id, $version = 'stable', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false) { global $core; - $this->phonegapVersion = self::getPhonegapVersion($phonegapVersion); + $this->phonegapVersion = wsHTML5::getPhonegapVersion($phonegapVersion); $this->appcache = $appcache; $this->multiApp = $this->home = $home; $this->version = $version; @@ -268,29 +251,6 @@ class wsHTML5Compiler { return $res; } - public static function getPhonegapVersion($v = 'latest') { - if ($v != 'latest') { - return $v; - } - - $versions = self::getPhonegapVersions(); - return array_pop($versions); - } - - public static function getPhonegapVersions() { - $versions = array(); - - $dr = opendir(WS_COMPILE_ASSETS . '/_html5/js/libs/phonegap'); - while ($file = readdir($dr)) { - if ($file == '.' || $file == '..' || $file == 'plugins') { - continue; - } - $versions[] = $file; - } - usort($versions, 'version_compare'); - return $versions; - } - public function getCssScale() { return $this->cssScale; } @@ -949,8 +909,8 @@ class wsHTML5Compiler { $this->config->optimalWidth = $this->optimalWidth; $this->config->optimalHeight = $this->optimalHeight; $this->config->chapters = $this->book->chapters; - $this->config->coquilletteBack = $this->colorToCSS($this->theme->parametres->couleurA); - $this->config->coquilletteFront = $this->colorToCSS($this->theme->parametres->arrowsColor); + $this->config->coquilletteBack = wsHTML5::colorToCSS($this->theme->parametres->couleurA); + $this->config->coquilletteFront = wsHTML5::colorToCSS($this->theme->parametres->arrowsColor); $this->config->videoFormats = $this->getVideosFormats(false); $this->config->htmlmultimedia = $this->htmlmultimedia; $this->config->phonegap = $this->phonegap; @@ -1156,26 +1116,26 @@ class wsHTML5Compiler { $res[] = '.portrait #pages,.portrait .doublePage.page,.page,.doublePage._3d,#shadow>div{width:' . $w . ';max-width:' . $w . ';height:' . $h . ';max-height:' . $h . '}'; $res[] = '.doublePage,#pages,#links{width:' . $w2 . ';max-width:' . $w2 . ';height:' . $h . ';max-height:' . $h . '}'; - $res[] = '.landscape .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}'; - $res[] = '.landscape .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}'; - $res[] = '.portrait .doublePage._2d.axis_x.next{' . self::writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}'; - $res[] = '.portrait .doublePage._2d.axis_x.prev{' . self::writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}'; - $res[] = '.doublePage._2d.axis_y.next{' . self::writeCSSUA('transform', 'translate3d(0,' . $h . ',0)') . '}'; - $res[] = '.doublePage._2d.axis_y.prev{' . self::writeCSSUA('transform', 'translate3d(0,-' . $h . ',0)') . '}'; + $res[] = '.landscape .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w2 . ',0,0)') . '}'; + $res[] = '.landscape .doublePage._2d.axis_x.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(-' . $w2 . ',0,0)') . '}'; + $res[] = '.portrait .doublePage._2d.axis_x.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(' . $w . ',0,0)') . '}'; + $res[] = '.portrait .doublePage._2d.axis_x.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(-' . $w . ',0,0)') . '}'; + $res[] = '.doublePage._2d.axis_y.next{' . wsHTML5::writeCSSUA('transform', 'translate3d(0,' . $h . ',0)') . '}'; + $res[] = '.doublePage._2d.axis_y.prev{' . wsHTML5::writeCSSUA('transform', 'translate3d(0,-' . $h . ',0)') . '}'; $res[] = '.doublePage._3d{left:' . $w . ';}'; $res[] = '#links.right{left:-' . $w . ';}'; $res[] = '.landscape #shadow>div.right{left: ' . $w . ';}'; $res[] = '.landscape .page.right{left:' . $w . '}'; if ($this->theme->parametres->displayPageNumber) { - $res[] = '#pagesnumbers{font-size: ' . (12 * $this->z) . 'px;margin: ' . (5 * $this->z) . 'px 0 0 0;top:' . $h . ';color:' . self::colorToCSS($this->theme->parametres->colorPageNumber) . '}'; + $res[] = '#pagesnumbers{font-size: ' . (12 * $this->z) . 'px;margin: ' . (5 * $this->z) . 'px 0 0 0;top:' . $h . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->colorPageNumber) . '}'; $res[] = '#pagesnumbers div{width:' . $w . '}'; } else { $res[] = '#pagesnumbers{display:none;}'; } - $res[] = '.doublePage._2d,.doublePage._3d{' . self::writeCSSUA('transition', 'all ' . $this->book->parametres->mobileTransitionDuration . 's ease-in-out') . '}'; + $res[] = '.doublePage._2d,.doublePage._3d{' . wsHTML5::writeCSSUA('transition', 'all ' . $this->book->parametres->mobileTransitionDuration . 's ease-in-out') . '}'; - $res[] = '.background{' . self::writeCSSUA('transform-origin', 'top left') . ';}'; + $res[] = '.background{' . wsHTML5::writeCSSUA('transform-origin', 'top left') . ';}'; foreach ($this->getResolutions() as $r) { $ratio = round(72 / $r, 3) * $cssScale; @@ -1184,13 +1144,13 @@ class wsHTML5Compiler { $br = '.background.r' . $r . '{'; if ($ratio != 1) { - $br .= self::writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; + $br .= wsHTML5::writeCSSUA('transform', 'scale(' . $ratio . ')') . ';'; } $br .= 'width:' . $wr . 'px;height:' . $hr . 'px;}'; $res[] = $br; } - $texts = '.texts{' . self::writeCSSUA('transform-origin', 'top left') . ';'; - $texts .= self::writeCSSUA('transform', 'scale(' . round((1 / $this->multiply) * $cssScale * $this->cssSVGScale, 3) . ')') . ';'; + $texts = '.texts{' . wsHTML5::writeCSSUA('transform-origin', 'top left') . ';'; + $texts .= wsHTML5::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 .= '}'; @@ -1204,17 +1164,17 @@ class wsHTML5Compiler { // SVG - $res[] = 'svg .fill-c-menu-back{fill:' . self::colorToCSS($this->theme->parametres->couleurB) . ';}'; - $res[] = 'svg .fill-c-menu-text{fill:' . self::colorToCSS($this->theme->parametres->subTextColor) . ';}'; + $res[] = 'svg .fill-c-menu-back{fill:' . wsHTML5::colorToCSS($this->theme->parametres->couleurB) . ';}'; + $res[] = 'svg .fill-c-menu-text{fill:' . wsHTML5::colorToCSS($this->theme->parametres->subTextColor) . ';}'; // Search field - $searchColor = self::colorToCSS($this->theme->parametres->couleurS); - $searchBackColor = self::colorToCSS($this->theme->parametres->searchFieldColor); + $searchColor = wsHTML5::colorToCSS($this->theme->parametres->couleurS); + $searchBackColor = wsHTML5::colorToCSS($this->theme->parametres->searchFieldColor); $search = '#q{'; $search .= 'color:' . $searchColor . ';'; $search .= 'background-color:' . $searchBackColor . ';'; if ($this->theme->parametres->searchShadeAlpha > 0) { - $search .= self::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;'; + $search .= wsHTML5::writeCSSUA('box-shadow', '1px 1px 4px rgba(0,0,0,' . ($this->theme->parametres->searchShadeAlpha / 100) . ')') . ' inset;'; } $search .= '}'; $search .= '#searchHints,.hint{color:' . $searchColor . ';background-color:' . $searchBackColor . ';}'; @@ -1229,7 +1189,7 @@ class wsHTML5Compiler { // Header $header = 'header{'; $header .= 'height:' . $this->theme->parametres->menuHeight . 'px;'; - $header .= 'background-color:' . self::colorToCSS($this->theme->parametres->menuColor) . ';'; + $header .= 'background-color:' . wsHTML5::colorToCSS($this->theme->parametres->menuColor) . ';'; if ($this->theme->parametres->menuImage != '') { $this->copy($this->themeRoot . '/' . $this->theme->parametres->menuImage, $this->vdir . '/data/images/' . $this->theme->parametres->menuImage); $header .= 'background-image:url(../images/' . $this->theme->parametres->menuImage . ');'; @@ -1241,7 +1201,7 @@ class wsHTML5Compiler { //Icons $res = array_merge($res, $this->writeIcons()); - $res[] = '#nav #locales{background-color:' . self::colorToCSS($this->theme->parametres->couleurI) . ';}'; + $res[] = '#nav #locales{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurI) . ';}'; // Logo $logo = '#logo{'; @@ -1254,25 +1214,25 @@ class wsHTML5Compiler { $res[] = $logo; // Credits - $res[] = 'footer,footer a{color:' . self::colorToCSS($this->theme->parametres->creditsColor) . ';}'; + $res[] = 'footer,footer a{color:' . wsHTML5::colorToCSS($this->theme->parametres->creditsColor) . ';}'; // Arrows - $res[] = '#next,#previous{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}'; + $res[] = '#next,#previous{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurA) . ';}'; // Audio description buttons - $res[] = '.audio-description-button{background-color:' . self::colorToCSS($this->theme->parametres->couleurA) . ';}'; + $res[] = '.audio-description-button{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurA) . ';}'; // Book shadow - $shadowColor = self::colorToCSS($this->theme->parametres->bookShadeColor); + $shadowColor = wsHTML5::colorToCSS($this->theme->parametres->bookShadeColor); if ($shadowColor != 'transparent') { - $res[] = '#shadow>div{' . self::writeCSSUA('box-shadow', '0 0 20px ' . $shadowColor) . '}'; + $res[] = '#shadow>div{' . wsHTML5::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:hover,.link a.displayArea.animating{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';}'; $res[] = '.link a.displayArea:hover{opacity:1 !important;}'; - $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) . ';}'; + $res[] = '.link a.displayArea{-webkit-tap-highlight-color:' . wsHTML5::colorToCSS($this->theme->parametres->linksColor, 0.4) . ';background-color:' . wsHTML5::colorToCSS($this->theme->parametres->linksColor, 0.0001) . ';}'; // Bookmarks if (!isset($this->book->parametres->bookmarkCornerSize)) { @@ -1285,7 +1245,7 @@ class wsHTML5Compiler { // Menus $menuColor = new CubeIT_Graphics_Color($this->theme->parametres->couleurB); $menuColor->setAlpha(1); - $menuTextColor = self::colorToCSS($this->theme->parametres->subTextColor); + $menuTextColor = wsHTML5::colorToCSS($this->theme->parametres->subTextColor); $menuMultiply = $menuColor->multiply($menuColor); $menuMultiply2 = $menuMultiply->multiply($menuColor); @@ -1297,7 +1257,7 @@ class wsHTML5Compiler { # Inner View $res[] .= '#innerView>div{background-color:' . $menuColor->toCSS() . ';color:' . $menuTextColor . ';}'; - $res[] .= 'form input[type="text"],form input[type="email"]{background-color:' . self::colorToCSS($this->theme->parametres->subFieldColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextFieldColor) . ';}'; + $res[] .= 'form input[type="text"],form input[type="email"]{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->subFieldColor) . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->subTextFieldColor) . ';}'; // Archives if ($this->book->parametres->externalArchivesBack) { @@ -1341,15 +1301,15 @@ class wsHTML5Compiler { $ratio = $this->width / $this->height; $thumbh = round(100 / $ratio); $res[] = '#indexView .thumb img{width:100px;height:' . $thumbh . 'px;}'; - $res[] = '#indexView .doubleThumb{height:' . $thumbh . 'px;' . self::writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}'; + $res[] = '#indexView .doubleThumb{height:' . $thumbh . 'px;' . wsHTML5::writeCSSUA('box-shadow', '0 0 3px ' . $shadowColor) . '}'; $res[] = '#indexView .doubleThumb .overlay{height:' . $thumbh . 'px;}'; - $res[] = '#indexView .doubleThumb .hits.yes{background-color:' . self::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . self::colorToCSS($this->theme->parametres->subTextSelectColor) . '}'; + $res[] = '#indexView .doubleThumb .hits.yes{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->subSelectColor) . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->subTextSelectColor) . '}'; # Tooltip - $res[] = '#tooltip{background-color:' . self::colorToCSS($this->theme->parametres->tooltipBackColor) . ';color:' . self::colorToCSS($this->theme->parametres->tooltipTextColor) . ';}'; + $res[] = '#tooltip{background-color:' . wsHTML5::colorToCSS($this->theme->parametres->tooltipBackColor) . ';color:' . wsHTML5::colorToCSS($this->theme->parametres->tooltipTextColor) . ';}'; # ZoomPopup close button background - $res[] = '.zoomPopupClose {background-color:'. self::colorToCSS($this->theme->parametres->couleurB) .';}'; + $res[] = '.zoomPopupClose {background-color:' . wsHTML5::colorToCSS($this->theme->parametres->couleurB) . ';}'; $res = array_chunk($res, 3500); foreach ($res as $k => $css) { @@ -1492,29 +1452,4 @@ class wsHTML5Compiler { } - public static function colorToArray($color, $forceAlpha = null) { - $color = ltrim($color, '#'); - if (strlen($color) == 6) { - $hex = $color; - $alpha = 1; - } else { - $alpha = hexdec(substr($color, 0, 2)) / 255; - $hex = substr($color, 2, 6); - } - - if (!is_null($forceAlpha)) { - $alpha = $forceAlpha; - } - - return array('hex' => strtoupper($hex), 'opacity' => number_format($alpha, 3, '.', '')); - } - - public static function colorToCSS($color, $forceAlpha = null) { - return CubeIT_Graphics_Color::colorToCSS($color, $forceAlpha); - } - -} - -class wsHTML5CompilerDev extends wsHTML5Compiler { - -} +} \ No newline at end of file diff --git a/inc/ws/Util/html5/html5video/class.ws.html5.links.php b/inc/ws/Util/html5/html5video/class.ws.html5.links.php index 19f45bc51..24e4b6a09 100644 --- a/inc/ws/Util/html5/html5video/class.ws.html5.links.php +++ b/inc/ws/Util/html5/html5video/class.ws.html5.links.php @@ -273,11 +273,11 @@ class wsHTML5Link { $css .= 'width:' . $this->width * $this->getCssScale() . 'px;height:' . $this->height * $this->getCssScale() . 'px;'; $origin = false; if ($this->rot) { - $css .= wsHTML5Compiler::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); + $css .= wsHTML5::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); $origin = true; } if (isset($this->extra->skewX)) { - $css .= wsHTML5Compiler::writeCSSUA('transform', 'skewX(' . $this->extra->skewX . 'deg)'); + $css .= wsHTML5::writeCSSUA('transform', 'skewX(' . $this->extra->skewX . 'deg)'); $origin = true; } $css .= $this->getCSS(); @@ -701,7 +701,7 @@ class basketLink extends contentLink { class colorLink extends contentLink { public function getCSS() { - return 'background-color:' . wsHTML5Compiler::colorToCSS($this->to) . ';'; + return 'background-color:' . wsHTML5::colorToCSS($this->to) . ';'; } } @@ -848,8 +848,8 @@ class htmlMultimediaLink extends wsHTML5Link { $sx = ($this->width / ($this->_config['width'])) * $this->getCssScale(); $sy = ($this->height / ($this->_config['height'])) * $this->getCssScale(); - $res = wsHTML5Compiler::writeCSSUA('transform', 'scale(' . $sx . ',' . $sy . ')'); - $res .= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); + $res = wsHTML5::writeCSSUA('transform', 'scale(' . $sx . ',' . $sy . ')'); + $res .= wsHTML5::writeCSSUA('transform-origin', '0% 0%'); if (!$this->_config['html']) { return ''; @@ -1049,8 +1049,8 @@ class inpesPopinLink extends htmlMultimediaLink { $css .= 'left:' . $this->left * $this->getCssScale() . 'px;top:' . $this->top * $this->getCssScale() . 'px;'; $css .= 'width:' . $this->width * $this->getCssScale() . 'px;height:' . $this->height * $this->getCssScale() . 'px;'; if ($this->rot) { - $css .= wsHTML5Compiler::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); - $css .= wsHTML5Compiler::writeCSSUA('transform-origin', '0% 0%'); + $css .= wsHTML5::writeCSSUA('transform', 'rotate(' . $this->rot . 'deg)'); + $css .= wsHTML5::writeCSSUA('transform-origin', '0% 0%'); } $css .= $this->getCSS(); $css .= '}'; -- 2.39.5