12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <?php
- use yii\web\View;
- use \app\models\base\Tags;
- use \app\models\Tagsfilter;
- if( YII_ENV_DEV || 1 )
- {
- $tmodel = new Tags();
- $session = Yii::$app->session;
- $x =$session->get('filterx');
- $items = Yii::$app->cache->getOrSet("tagsmenu",function () use($tmodel){
- return $tmodel->find()->rightJoin(['m'=>Tagsfilter::find()], 'm.id = tags.id')->orderBy('sort')->All();
- });
- ?>
- <div class="header-bottom__button">
- <span style="fill: #ff8813;" onclick="toggletFiltersModalSel();return false;" class="button button_grey">
- <span class="button__icon"><i class="fa-solid fa-filter"></i>
- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" style="width: 17px;height: 14px;" class="icon icon-tg"><title>фильтры материалов</title><path d="M3.9 54.9C10.5 40.9 24.5 32 40 32H472c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L320 320.9V448c0 12.1-6.8 23.2-17.7 28.6s-23.8 4.3-33.5-3l-64-48c-8.1-6-12.8-15.5-12.8-25.6V320.9L9 97.3C-.7 85.4-2.8 68.8 3.9 54.9z"/></svg>
- </span>
- Ваша лента
- </span>
- </div>
- <?php $this->beginBlock('FilterModal'); ?>
- <div id="tfilters-modal" class="mymodal hidden shadow p-3 mb-5 bg-white rounded modal-sm">
- <div class="modal-header">
- <h5 class="modal-title">Показать в ленте:</h5>
- <button type="button" class="close" data-dismiss="modal" aria-label="Close" onclick="$('#tfilters-modal').addClass('hidden');">
- <span aria-hidden="true">×</span>
- </button>
- </div>
- <div class="form-group w-100 ml-4">
- <?
- foreach( $items as $item ){
- ?>
- <div class="form-check checkbox-lg">
- <input class="form-check-input exttag" type="checkbox" value="<?=$item->id?>" id="flexCheck<?=$item->id?>" name="ExtTag[<?=$item->id?>]"<?=($x && in_array($item->id,$x))?' checked':''?>>
- <label class="form-check-label" for="flexCheck<?=$item->id?>"><?=$item->title?></label><br>
- </div>
- <?}?>
- </div>
- <span class="btn btn-gray" onclick="SendTfilter();">Применить фильтр</span>
- </div>
- <?php $this->endBlock(); ?>
- <?php
- $filterurl = \yii\helpers\Url::base('https')."/setfilters";
- $this->registerJs(
- <<<JS
- function toggletFiltersModalSel(){
- $("#tfilters-modal").toggleClass("hidden");
- }
- function delete_cookie( name, path, domain ) {
- if( get_cookie( name ) ) {
- document.cookie = name + "=" +
- ((path) ? ";path="+path:"")+
- ((domain)?";domain="+domain:"") +
- ";expires=Thu, 01 Jan 1970 00:00:01 GMT";
- }
- }
- function get_cookie(name){
- return document.cookie.split(';').some(c => {
- return c.trim().startsWith(name + '=');
- });
- }
- function SendTfilter(){
- $("#tfilters-modal").toggleClass("hidden");
- var selectElement = document.querySelectorAll('.exttag');
- var a = [];
- selectElement.forEach((el) => {
- if( el.checked ) a.push(el.value);
- });
- if( a.length == 0 ) a.push(0);
- $.getJSON( "$filterurl", { 'filters': a }, function( data ) {
- if( data.status == 'ok' ){
- delete_cookie('filterq','','/');
- document.location.reload();
- }
- });
- }
- JS
- ,
- View::POS_END,
- 'fmodal'
- );
- }
|