var catalogSlider = null;
var mediaQuerySize = 1024;
function catalogSliderInit () {
if (!catalogSlider) {
catalogSlider = new Swiper('.catalogSlider', {
// ... ваши опции
});
}
}
function catalogSliderDestroy () {
if (catalogSlider) {
catalogSlider.destroy();
catalogSlider = null;
}
}
$(window).on('load resize', function () {
// Берём текущую ширину экрана
var windowWidth = $(this).innerWidth();
// Если ширина экрана меньше или равна mediaQuerySize(1024)
if (windowWidth <= mediaQuerySize) {
// Инициализировать слайдер если он ещё не был инициализирован
catalogSliderInit()
} else {
// Уничтожить слайдер если он был инициализирован
catalogSliderDestroy()
}
});
class ConditionalRouting implements BootstrapInterface
{
/**
* @var array
*/
public $guestRules = [
'' => 'guest/index',
];
/**
* @var array
*/
public $userRules = [
'' => 'user/index'
];
/**
* @inheritDoc
*/
public function bootstrap($app)
{
$manager = \Yii::$app->urlManager;
$manager->addRules(\Yii::$app->user->isGuest ? $this->guestRules : $this->userRules, false);
}
}
...
'bootstrap' => [
\app\components\ConditionalRouting::class
],
...
<select size="4">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<div class="phone"
<?
$Now = date(H);
$WorkDayStart = 9;
$WorkDayEnd = 18;
If ($WorkDayStart < $Now and $Now < $WorkDayEnd): ?>
<?$APPLICATION->IncludeComponent(
"bitrix:main.include",
"",
Array(
"COMPONENT_TEMPLATE" => ".default",
"AREA_FILE_SHOW" => "file",
"AREA_FILE_SUFFIX" => "inc",
"EDIT_TEMPLATE" => "",
"PATH" => "/include/telefon.php"
)
);?>
<?else:?>
<?$APPLICATION->IncludeComponent(
"bitrix:main.include",
"",
Array(
"COMPONENT_TEMPLATE" => ".default",
"AREA_FILE_SHOW" => "file",
"AREA_FILE_SUFFIX" => "inc",
"EDIT_TEMPLATE" => "",
"PATH" => "/include/email.php"
)
);?>
<?endif?>
</div>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="light.css" class="style">
</head>
<body>
<button id="color">Сменить цвет</button>
<script type="text/javascript">
if (localStorage.getItem('style') == 'dark') {
document.querySelector('.style').href="dark.css";
}
document.querySelector('#color').onclick = function (){
if (document.querySelector('.style').getAttribute('href') === 'light.css') {
document.querySelector('.style').href="dark.css";
localStorage.setItem('style', 'dark');
} else {
document.querySelector('.style').href="light.css";
localStorage.setItem('style', 'light');
}
}
</script>
</body>
</html>
<style type="text/css">
body {
background: #fff;
color: #000;
}
#color {
color: #fff;
background: #000;
}
.dark {
background: #000;
color: #fff;
}
.dark #color {
color: #000;
background: #fff;
}
</style>
<button id="color">Сменить цвет</button>
<script type="text/javascript">
if (localStorage.getItem('style') == 'dark') {
document.body.classList.toggle('dark');
}
document.querySelector('#color').onclick = function (){
document.body.classList.toggle('dark');
if (document.body.getAttribute('class') == 'dark') {
localStorage.setItem('style', 'dark');
} else {
localStorage.setItem('style', '');
}
}
</script>