Автор Тема: Скрыть выпадающее меню  (Прочитано 2417 раз)

09 Апрель 2015, 13:37:56
  • Фрилансер
  • *
  • Сообщений: 107
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
проблема такая. Мне необходимо скрыть выпадающий список категорий в главном горизонтальном меню. Раньше скрывался он так, в файле modules/blocktopmenu/js/superfish-modified.js  менялось
getMenu = function($menu){
var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
sf.op = sf.o[menu.serial];
return menu;
},
addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
на
getMenu = function($menu){
return menu;
},
addArrow = function($a){ };
И было счастье. НО! После обновления модуля этот способ перестал работать( В чем проблема и как это  можно решить?
09 Апрель 2015, 13:59:41
Ответ #1
  • Ветеран
  • *****
  • Сообщений: 1808
  • Репутация: +49/-1
  • Сообщество PrestaShop
    • Просмотр профиля
pathLevels: 1, // the number of levels of submenus that remain open or are restored using pathClass.в самом низу настройки $.fn.superfish.defaults
09 Апрель 2015, 14:11:04
Ответ #2
  • Фрилансер
  • *
  • Сообщений: 107
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Спасибо всё работает. Пока что. При обновлении эту махинацию снова придется проделывать?
09 Апрель 2015, 14:35:59
Ответ #3
  • Ветеран
  • *****
  • Сообщений: 1808
  • Репутация: +49/-1
  • Сообщество PrestaShop
    • Просмотр профиля
Не всегда, если только js будут обновлять.
04 Июнь 2015, 17:34:54
Ответ #4
  • Новичок
  • *
  • Сообщений: 23
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
pathLevels: 1, // the number of levels of submenus that remain open or are restored using pathClass.в самом низу настройки $.fn.superfish.defaults

Здравствуйте.

Извиняюсь но я что-то не понимаю как это сделать в pathLevels: 1 изменил 1 на 0 и всё равно вы подает окно в меню
04 Июнь 2015, 19:14:10
Ответ #5
  • Партнер
  • Ветеран
  • ****
  • Сообщений: 22816
  • Репутация: +17143/-1
  • Разработка веб-сайтов и веб-программирование
    • Просмотр профиля
Кеш отключите во время изменений и очистите папку /cache/smarty/compile/...
Интернет-магазин под ключ.
Какой выбрать движок для интернет магазина ?
Какой движок лучше ?
Magento или Prestashop ?
Решение всех Ваших вопросов в создании Интернет-магазина.
04 Июнь 2015, 19:28:19
Ответ #6
  • Новичок
  • *
  • Сообщений: 23
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Выключил кэш,удалил всё с той папки, изменил файл и всё равно не работает
04 Июнь 2015, 19:40:06
Ответ #7
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 105673
  • Репутация: +39553/-0
    • Просмотр профиля
    • Webstudio UwK
В каком файле меняли?

Менять настройки меню нужно в
/themes/default-bootstrap/js/modules/blocktopmenu/js/superfish-modified.js
Cоздание интернет сайтов Webstudio UwK
04 Июнь 2015, 20:02:54
Ответ #8
  • Новичок
  • *
  • Сообщений: 23
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Не работает, вот этот код. Вроде всё верно

$.fn.superfish.defaults = {
popUpSelector: 'ul,.sf-mega', // within menu context
hoverClass: 'sfHover',
pathClass: 'overrideThisToUse',
pathLevels: 0,
delay: 800,
animation: {opacity: 'show'},
animationOut: {opacity: 'hide'},
speed: 'normal',
speedOut: 'fast',
cssArrows: true,
disableHI: false,
onInit: $.noop,
onBeforeShow: $.noop,
onShow: $.noop,
onBeforeHide: $.noop,
onHide: $.noop,
onIdle: $.noop,
onDestroy: $.noop
04 Июнь 2015, 20:29:15
Ответ #9
  • Модератор
  • Ветеран
  • *****
  • Сообщений: 105673
  • Репутация: +39553/-0
    • Просмотр профиля
    • Webstudio UwK
Если не получается изменить параметры конф., то можно закомментировать код в этом-же файле
/*
over = function () {
var $this = $(this),
o = getOptions($this);
clearTimeout(o.sfTimer);
$this.siblings().superfish('hide').end().superfish('show');
},
out = function () {
var $this = $(this),
o = getOptions($this);
if (ios) {
$.proxy(close, $this, o)();
}
else {
clearTimeout(o.sfTimer);
        o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay);
        }
},
*/
Cоздание интернет сайтов Webstudio UwK
04 Июнь 2015, 20:42:07
Ответ #10
  • Новичок
  • *
  • Сообщений: 23
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Не поверишь, всё равно не работает. Версия PrestaShop 1.6.0.14
04 Июнь 2015, 21:37:29
Ответ #11
  • Ветеран
  • *****
  • Сообщений: 16670
  • Репутация: +14630/-5
  • Сообщество PrestaShop
    • Просмотр профиля
Тема стандарная?
04 Июнь 2015, 22:30:56
Ответ #12
  • Новичок
  • *
  • Сообщений: 23
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Да. Вот уже весь код выкладываю, всё как сказали делал, не понимаю в чём дело. :|

/*
 * jQuery Superfish Menu Plugin - v1.7.4
 * Copyright (c) 2013 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */

(function ($) {
"use strict";

var methods = (function () {
// private properties and methods go here
var c = {
bcClass: 'sf-breadcrumb',
menuClass: 'sf-js-enabled',
anchorClass: 'sf-with-ul',
menuArrowClass: 'sf-arrows'
},
ios = (function () {
var ios = /iPhone|iPad|iPod/i.test(navigator.userAgent);
if (ios) {
// iOS clicks only bubble as far as body children
$(window).load(function () {
$('body').children().on('click', $.noop);
});
}
return ios;
})(),
wp7 = (function () {
var style = document.documentElement.style;
return ('behavior' in style && 'fill' in style && /iemobile/i.test(navigator.userAgent));
})(),
toggleMenuClasses = function ($menu, o) {
var classes = c.menuClass;
if (o.cssArrows) {
classes += ' ' + c.menuArrowClass;
}
$menu.toggleClass(classes);
},
setPathToCurrent = function ($menu, o) {
return $menu.find('li.' + o.pathClass).slice(0, o.pathLevels)
.addClass(o.hoverClass + ' ' + c.bcClass)
.filter(function () {
return ($(this).children(o.popUpSelector).hide().show().length);
}).removeClass(o.pathClass);
},
toggleAnchorClass = function ($li) {
$li.children('a').toggleClass(c.anchorClass);
},
toggleTouchAction = function ($menu) {
var touchAction = $menu.css('ms-touch-action');
touchAction = (touchAction === 'pan-y') ? 'auto' : 'pan-y';
$menu.css('ms-touch-action', touchAction);
},
applyHandlers = function ($menu, o) {
var targets = 'li:has(' + o.popUpSelector + ')';
if ($.fn.hoverIntent && !o.disableHI) {
$menu.hoverIntent(over, out, targets);
}
else {
$menu
.on('mouseenter.superfish', targets, over)
.on('mouseleave.superfish', targets, out);
}
var touchevent = 'MSPointerDown.superfish';
if (!ios) {
touchevent += ' touchend.superfish';
}
if (wp7) {
touchevent += ' mousedown.superfish';
}
$menu
.on('focusin.superfish', 'li', over)
.on('focusout.superfish', 'li', out)
.on(touchevent, 'a', o, touchHandler);
},
touchHandler = function (e) {
var $this = $(this),
$ul = $this.siblings(e.data.popUpSelector);

if ($ul.length > 0 && $ul.is(':hidden')) {
$this.one('click.superfish', false);
if (e.type === 'MSPointerDown') {
$this.trigger('focus');
} else {
$.proxy(over, $this.parent('li'))();
}
}
},
                        /*
over = function () {
var $this = $(this),
o = getOptions($this);
clearTimeout(o.sfTimer);
$this.siblings().superfish('hide').end().superfish('show');
},
out = function () {
var $this = $(this),
o = getOptions($this);
if (ios) {
$.proxy(close, $this, o)();
}
else {
clearTimeout(o.sfTimer);
o.sfTimer = setTimeout($.proxy(close, $this, o), o.delay);
}
},

                        */
close = function (o) {
o.retainPath = ($.inArray(this[0], o.$path) > -1);
this.superfish('hide');

if (!this.parents('.' + o.hoverClass).length) {
o.onIdle.call(getMenu(this));
if (o.$path.length) {
$.proxy(over, o.$path)();
}
}
},
getMenu = function ($el) {
return $el.closest('.' + c.menuClass);
},
getOptions = function ($el) {
return getMenu($el).data('sf-options');
};

return {
// public methods
hide: function (instant) {
if (this.length) {
var $this = this,
o = getOptions($this);
if (!o) {
return this;
}
var not = (o.retainPath === true) ? o.$path : '',
$ul = $this.find('li.' + o.hoverClass).add(this).not(not).removeClass(o.hoverClass).children(o.popUpSelector),
speed = o.speedOut;

if (instant) {
$ul.show();
speed = 0;
}
o.retainPath = false;
o.onBeforeHide.call($ul);
$ul.stop(true, true).animate(o.animationOut, speed, function () {
var $this = $(this);
o.onHide.call($this);
});
}
return this;
},
show: function () {
var o = getOptions(this);
if (!o) {
return this;
}
var $this = this.addClass(o.hoverClass),
$ul = $this.children(o.popUpSelector);

o.onBeforeShow.call($ul);
$ul.stop(true, true).animate(o.animation, o.speed, function () {
o.onShow.call($ul);
});
return this;
},
destroy: function () {
return this.each(function () {
var $this = $(this),
o = $this.data('sf-options'),
$hasPopUp;
if (!o) {
return false;
}
$hasPopUp = $this.find(o.popUpSelector).parent('li');
clearTimeout(o.sfTimer);
toggleMenuClasses($this, o);
toggleAnchorClass($hasPopUp);
toggleTouchAction($this);
// remove event handlers
$this.off('.superfish').off('.hoverIntent');
// clear animation's inline display style
$hasPopUp.children(o.popUpSelector).attr('style', function (i, style) {
return style.replace(/display[^;]+;?/g, '');
});
// reset 'current' path classes
o.$path.removeClass(o.hoverClass + ' ' + c.bcClass).addClass(o.pathClass);
$this.find('.' + o.hoverClass).removeClass(o.hoverClass);
o.onDestroy.call($this);
$this.removeData('sf-options');
});
},
init: function (op) {
return this.each(function () {
var $this = $(this);
if ($this.data('sf-options')) {
return false;
}
var o = $.extend({}, $.fn.superfish.defaults, op),
$hasPopUp = $this.find(o.popUpSelector).parent('li');
o.$path = setPathToCurrent($this, o);

$this.data('sf-options', o);

toggleMenuClasses($this, o);
toggleAnchorClass($hasPopUp);
toggleTouchAction($this);
applyHandlers($this, o);

$hasPopUp.not('.' + c.bcClass).superfish('hide', true);

o.onInit.call(this);
});
}
};
})();

$.fn.superfish = function (method, args) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
}
else if (typeof method === 'object' || ! method) {
return methods.init.apply(this, arguments);
}
else {
return $.error('Method ' +  method + ' does not exist on jQuery.fn.superfish');
}
};

$.fn.superfish.defaults = {
popUpSelector: 'ul,.sf-mega', // within menu context
hoverClass: 'sfHover',
pathClass: 'overrideThisToUse',
pathLevels: 0,
delay: 800,
animation: {opacity: 'show'},
animationOut: {opacity: 'hide'},
speed: 'normal',
speedOut: 'fast',
cssArrows: true,
disableHI: false,
onInit: $.noop,
onBeforeShow: $.noop,
onShow: $.noop,
onBeforeHide: $.noop,
onHide: $.noop,
onIdle: $.noop,
onDestroy: $.noop
};

// soon to be deprecated
$.fn.extend({
hideSuperfishUl: methods.hide,
showSuperfishUl: methods.show
});

})(jQuery);
05 Июнь 2015, 08:17:39
Ответ #13
  • Партнер
  • Ветеран
  • ****
  • Сообщений: 22816
  • Репутация: +17143/-1
  • Разработка веб-сайтов и веб-программирование
    • Просмотр профиля
1. Измените 2 файла
/modules/blocktopmenu/js/superfish-modified.js
/themes/default-bootstrap/js/modules/blocktopmenu/js/superfish-modified.js
Закоментируйте код как написал Виталий.
Переменные over/out как раз отвечают за события наведения курсора на пункт меню. Если вы их убрали, то меню выпадать не может. 

2. Очистите кеш браузера и папку /cache/smarty/compile/ на хостинге.

Проверьте с помощью firebug загрузку файла superfish-modified.js.
Интернет-магазин под ключ.
Какой выбрать движок для интернет магазина ?
Какой движок лучше ?
Magento или Prestashop ?
Решение всех Ваших вопросов в создании Интернет-магазина.
05 Июнь 2015, 12:31:01
Ответ #14
  • Новичок
  • *
  • Сообщений: 23
  • Репутация: +0/-0
  • Сообщество PrestaShop
    • Просмотр профиля
Всем спасибо всё получилось.
Тока теперь другая проблема возникла, раньше он сразу выводил на главной странице новые поступления а теперь надо нажимать на эту кнопку что-бы вывелся товар.