par
lecer » 24 déc. 2010, 14:27
Bonjour,
je voudrai adapter la taille et les polices de mon site selon la résolution de l'écran.
J'ai un template dans lequel il y a un fichier de config qui permet de faire cela mais c'est uniquement sur action du visiteur (après un clic sur des icones).
Avec un javascript, genre if(screen.width > 1024) { etc ... il semble possible de récupérer la résolution du navigateur mais comment et ou le placer pour qu'il modifie automatiquement le tableau php au niveau de "fontDefault" => "font-medium" et "widthDefault" => "width-wide", ?
par avance merci pour votre aide.
voici le fichier de config :
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
* YtSettings
*
* Class to store yootheme template settings
*
* @version 1.0.1 (29.04.2007)
* @author yootheme.com
* @copyright Copyright (C) 2007 YOOtheme Ltd. & Co. KG. All rights reserved.
*/
class YtSettings {
/* yootheme global default template settings */
var $defaults;
/* javascript settings */
var $javascript;
/* template settings */
var $settings;
function YtSettings($settings = array()) {
$this->defaults = array(
/* color */
"color" => "green",
/* item color variation */
"item1" => "green",
"item2" => "blue",
"item3" => "orange",
"item4" => "violet",
"item5" => "black",
"item6" => "lilac",
"item7" => "black",
"item8" => "beige",
"item9" => "turquoise",
"item10" => "violet",
/* layout */
"dogear" => true,
"date" => true,
"styleswitcherFont" => true,
"styleswitcherWidth" => true,
"layout" => "left",
/* features */
"lightbox" => true,
"reflection" => true,
"snap" => false,
/* style switcher */
"fontDefault" => "font-medium",
"widthDefault" => "width-wide",
"widthThinPx" => 780,
"widthWidePx" => 900,
"widthFluidPx" => 0.9,
/* top panel */
"toppanel" => true,
"heightToppanel" => 320,
"textToppanel" => "Top Panel",
/* javascript */
"loadJavascript" => true
);
$this->javascript = array(
/* color */
"color" => "'<VAL>'",
/* layout */
"layout" => "'<VAL>'",
/* features */
"lightbox" => "<VAL>",
/* style switcher */
"fontDefault" => "'<VAL>'",
"widthDefault" => "'<VAL>'",
"widthThinPx" => "<VAL>",
"widthWidePx" => "<VAL>",
"widthFluidPx" => "<VAL>",
/* top panel */
"heightToppanel" => "<VAL>",
);
$this->settings = $settings + $this->defaults;
}
function get($key) {
return $this->settings[$key];
}
function getJavaScript() {
$js = "var YtSettings = { ";
$seperator = false;
foreach($this->javascript as $key => $val) {
$setting = $this->get($key);
if(is_bool($setting)) {
$setting ? $setting = "true" : $setting = "false";
}
if(is_float($setting)) {
$setting = number_format($setting, 2, ".", "");
}
$seperator ? $js .= ", " : $seperator = true;
$js .= $key . ": " . str_replace("<VAL>", $setting, $val);
}
$js .= " };";
return $js;
}
function showJavaScript() {
echo $this->getJavaScript();
}
}
?>
Bonjour,
je voudrai adapter la taille et les polices de mon site selon la résolution de l'écran.
J'ai un template dans lequel il y a un fichier de config qui permet de faire cela mais c'est uniquement sur action du visiteur (après un clic sur des icones).
Avec un javascript, genre if(screen.width > 1024) { etc ... il semble possible de récupérer la résolution du navigateur mais comment et ou le placer pour qu'il modifie automatiquement le tableau php au niveau de "fontDefault" => "font-medium" et "widthDefault" => "width-wide", ?
par avance merci pour votre aide.
voici le fichier de config :
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
* YtSettings
*
* Class to store yootheme template settings
*
* @version 1.0.1 (29.04.2007)
* @author yootheme.com
* @copyright Copyright (C) 2007 YOOtheme Ltd. & Co. KG. All rights reserved.
*/
class YtSettings {
/* yootheme global default template settings */
var $defaults;
/* javascript settings */
var $javascript;
/* template settings */
var $settings;
function YtSettings($settings = array()) {
$this->defaults = array(
/* color */
"color" => "green",
/* item color variation */
"item1" => "green",
"item2" => "blue",
"item3" => "orange",
"item4" => "violet",
"item5" => "black",
"item6" => "lilac",
"item7" => "black",
"item8" => "beige",
"item9" => "turquoise",
"item10" => "violet",
/* layout */
"dogear" => true,
"date" => true,
"styleswitcherFont" => true,
"styleswitcherWidth" => true,
"layout" => "left",
/* features */
"lightbox" => true,
"reflection" => true,
"snap" => false,
/* style switcher */
"fontDefault" => "font-medium",
"widthDefault" => "width-wide",
"widthThinPx" => 780,
"widthWidePx" => 900,
"widthFluidPx" => 0.9,
/* top panel */
"toppanel" => true,
"heightToppanel" => 320,
"textToppanel" => "Top Panel",
/* javascript */
"loadJavascript" => true
);
$this->javascript = array(
/* color */
"color" => "'<VAL>'",
/* layout */
"layout" => "'<VAL>'",
/* features */
"lightbox" => "<VAL>",
/* style switcher */
"fontDefault" => "'<VAL>'",
"widthDefault" => "'<VAL>'",
"widthThinPx" => "<VAL>",
"widthWidePx" => "<VAL>",
"widthFluidPx" => "<VAL>",
/* top panel */
"heightToppanel" => "<VAL>",
);
$this->settings = $settings + $this->defaults;
}
function get($key) {
return $this->settings[$key];
}
function getJavaScript() {
$js = "var YtSettings = { ";
$seperator = false;
foreach($this->javascript as $key => $val) {
$setting = $this->get($key);
if(is_bool($setting)) {
$setting ? $setting = "true" : $setting = "false";
}
if(is_float($setting)) {
$setting = number_format($setting, 2, ".", "");
}
$seperator ? $js .= ", " : $seperator = true;
$js .= $key . ": " . str_replace("<VAL>", $setting, $val);
}
$js .= " };";
return $js;
}
function showJavaScript() {
echo $this->getJavaScript();
}
}
?>