diff --git a/classes/Controller.php b/classes/Controller.php index ed66cd8ea..8579d8e89 100644 --- a/classes/Controller.php +++ b/classes/Controller.php @@ -143,6 +143,9 @@ abstract class ControllerCore if ($this->checkAccess()) { + if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) + $this->setMedia(); + // postProcess handles ajaxProcess $this->postProcess(); @@ -150,10 +153,7 @@ abstract class ControllerCore $this->redirect(); if (!$this->content_only && ($this->display_header || (isset($this->className) && $this->className))) - { - $this->setMedia(); $this->initHeader(); - } $this->initContent(); diff --git a/classes/Media.php b/classes/Media.php index 5f7dfe164..1ff804680 100755 --- a/classes/Media.php +++ b/classes/Media.php @@ -36,7 +36,7 @@ class MediaCore 'ui.droppable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('uicore', 'ui.widget', 'ui.mouse', 'ui.draggable'), 'theme' => false), 'ui.resizable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), 'ui.selectable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), - 'ui.sortable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => false), + 'ui.sortable' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.mouse'), 'theme' => true), 'ui.accordion' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), 'ui.autocomplete' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget', 'ui.position'), 'theme' => true), 'ui.button' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('ui.core', 'ui.widget'), 'theme' => true), @@ -58,7 +58,7 @@ class MediaCore 'effects.scale' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.shake' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false), 'effects.slide' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false), - 'effects.transfer' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core')) + 'effects.transfer' => array('fileName' => 'jquery.ui.mouse.min.js', 'dependencies' => array('effects.core'), 'theme' => false) ); public static function minifyHTML($html_content) diff --git a/modules/blocklayered/blocklayered.css b/modules/blocklayered/blocklayered.css index 5ee9d203e..8ac36f2d5 100644 --- a/modules/blocklayered/blocklayered.css +++ b/modules/blocklayered/blocklayered.css @@ -4,6 +4,26 @@ #layered_block_left ul { padding-left: 0; + max-height: 100px; + overflow-y: auto; + overflow-x: hidden; + padding-left: 1px; + padding-right: 1px; +} + +#layered_form > div > div { + border-bottom: 1px dotted #CCCCCC; + padding-bottom: 5px; + margin-bottom: 5px; +} + +#layered_block_left .hide-action { + display: block; + text-align: right; + padding-right: 5px; +} +#layered_block_left .hide-action:hover { + text-decoration: underline; } #layered_block_left ul li { @@ -12,11 +32,9 @@ list-style-type: none; } -#layered_block_left #enabled_filters , #layered_url_filter_block{ +#layered_block_left #enabled_filters , #layered_url_filter_block { font-size: 10px; - padding-bottom: 10px; - margin-bottom: 5px; - border-bottom: 1px dotted #CCC; + padding-bottom: 5px; } #layered_block_left #enabled_filters ul li { @@ -75,4 +93,18 @@ } #product_list .warning { margin-top: 13px; +} + +#layered_form .select { + width: 165px; +} +#layered_form .color-option { + margin-left: 0; + width: 16px; + height: 16px; + padding:0; + border: 1px solid #666; +} +#layered_form .color-option.on { + border: 1px solid red; } \ No newline at end of file diff --git a/modules/blocklayered/blocklayered.js b/modules/blocklayered/blocklayered.js index 77cfcc26a..fc66b147b 100644 --- a/modules/blocklayered/blocklayered.js +++ b/modules/blocklayered/blocklayered.js @@ -45,10 +45,20 @@ $(document).ready(function() }); // Click on checkbox - $('#layered_form input[type=checkbox]').live('click', function() + $('#layered_form input, #layered_form select').live('change', function() { reloadContent(); }); + + $('.radio').live('click', function() { + var name = $(this).attr('name'); + $.each($(this).parent().parent().find('input[type=button]'), function (it, item) { + if ($(item).hasClass('on') && $(item).attr('name') != name) { + $(item).click(); + } + }); + return true; + }); // Click on label $('label a').live({ @@ -58,13 +68,45 @@ $(document).ready(function() $(this).parent().parent().find('input').click(); reloadContent(); } - return false; } }); + + layered_hidden_list = {}; + $('.hide-action').live('click', function() { + if (typeof(layered_hidden_list[$(this).parent().find('ul').attr('id')]) == 'undefined' || layered_hidden_list[$(this).parent().find('ul').attr('id')] == false) + { + layered_hidden_list[$(this).parent().find('ul').attr('id')] = true; + } + else + { + layered_hidden_list[$(this).parent().find('ul').attr('id')] = false; + } + hideFilterValueAction(this); + }); + $('.hide-action').each(function() { + hideFilterValueAction(this); + }); + paginationButton(); initLayered(); }); + +function hideFilterValueAction(it) +{ + if (typeof(layered_hidden_list[$(it).parent().find('ul').attr('id')]) == 'undefined' || layered_hidden_list[$(it).parent().find('ul').attr('id')] == false) + { + $(it).parent().find('.hiddable').hide(); + $(it).parent().find('.hide-action.less').hide(); + $(it).parent().find('.hide-action.more').show(); + } + else + { + $(it).parent().find('.hiddable').show(); + $(it).parent().find('.hide-action.less').show(); + $(it).parent().find('.hide-action.more').hide(); + } +} function addSlider(type, data, unit) { @@ -198,6 +240,10 @@ function reloadContent(params_plus) data += '&'+$(this).attr('id')+'='+sliderStart+'_'+sliderStop; }); + $('#layered_form .select option:checked').each( function () { + data += '&'+$(this).attr('id') + '=' + $(this).val(); + }); + if ($('#selectPrductSort').length) { var splitData = $('#selectPrductSort').val().split(':'); @@ -281,6 +327,10 @@ function reloadContent(params_plus) if(slideUp) $.scrollTo('#product_list', 400); updateProductUrl(); + + $('.hide-action').each(function() { + hideFilterValueAction(this); + }); } }); ajaxQueries.push(ajaxQuery); diff --git a/modules/blocklayered/blocklayered.php b/modules/blocklayered/blocklayered.php index e8f9796c1..f0eacb40f 100644 --- a/modules/blocklayered/blocklayered.php +++ b/modules/blocklayered/blocklayered.php @@ -1158,31 +1158,44 @@ class BlockLayered extends Module foreach ($_POST['categoryBox'] as $idc) $filterValues['categories'][] = (int)$idc; - $sqlToInsert = 'INSERT INTO '._DB_PREFIX_.'layered_category (id_category, id_value, type, position) VALUES '; + $sqlToInsert = 'INSERT INTO '._DB_PREFIX_.'layered_category (id_category, id_value, type, position, filter_show_limit, filter_type) VALUES '; foreach ($_POST['categoryBox'] as $id_category_layered) { $n = 0; foreach ($_POST as $key => $value) if (substr($key, 0, 17) == 'layered_selection' && $value == 'on') { - $filterValues[$key] = $value; + $type = 0; + $limit = 0; + if (Tools::getValue($key.'_filter_type')) + $type = Tools::getValue($key.'_filter_type'); + if (Tools::getValue($key.'_filter_show_limit')) + $limit = Tools::getValue($key.'_filter_show_limit'); + + $filterValues[$key] = array( + 'filter_type' => (int)$type, + 'filter_show_limit' => (int)$limit + ); $n++; + if ($key == 'layered_selection_stock') - $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'quantity\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'quantity\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; else if ($key == 'layered_selection_subcategories') - $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'category\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'category\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; else if ($key == 'layered_selection_condition') - $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'condition\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'condition\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; else if ($key == 'layered_selection_weight_slider') - $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'weight\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'weight\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; else if ($key == 'layered_selection_price_slider') - $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'price\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'price\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; else if ($key == 'layered_selection_manufacturer') - $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'manufacturer\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.',NULL,\'manufacturer\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; else if (substr($key, 0, 21) == 'layered_selection_ag_') - $sqlToInsert .= '('.(int)$id_category_layered.','.(int)str_replace('layered_selection_ag_', '', $key).',\'id_attribute_group\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.','.(int)str_replace('layered_selection_ag_', '', $key).', + \'id_attribute_group\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; else if (substr($key, 0, 23) == 'layered_selection_feat_') - $sqlToInsert .= '('.(int)$id_category_layered.','.(int)str_replace('layered_selection_feat_', '', $key).',\'id_feature\','.(int)$n.'),'; + $sqlToInsert .= '('.(int)$id_category_layered.','.(int)str_replace('layered_selection_feat_', '', $key).', + \'id_feature\','.(int)$n.', '.(int)$limit.', '.(int)$type.'),'; } } @@ -1198,8 +1211,8 @@ class BlockLayered extends Module Db::getInstance()->AutoExecute(_DB_PREFIX_.'layered_filter', $valuesToInsert, 'INSERT'); - echo '
- '.$this->l('Your filter').' "'.Tools::safeOutput(Tools::getValue('layered_tpl_name')).'" '.
+ echo '
').
+ $this->l('Your filter').' "'.Tools::safeOutput(Tools::getValue('layered_tpl_name')).'" '.
((isset($_POST['id_layered_filter']) && $_POST['id_layered_filter']) ? $this->l('was updated successfully.') : $this->l('was added successfully.')).'
'.$this->l('Settings saved successfully').'
+
').$this->l('Settings saved successfully').'
'.$this->l('Filters template deleted, categories updated (reverted to default Filters template).').'
+
').'
+ '.$this->l('Filters template deleted, categories updated (reverted to default Filters template).').'