From a5d9daff139d7c132ff42a34eacc32fa8bc397a1 Mon Sep 17 00:00:00 2001 From: TMMeilleur Date: Fri, 15 Nov 2013 18:40:17 +0200 Subject: [PATCH 1/8] added responsive rich menu and small fix in blockbanner --- modules/blockbanner/blockbanner.tpl | 2 +- modules/blocktopmenu/blocktopmenu.php | 4 +- .../blocktopmenu/css/superfish-modified.css | 211 ++++++++++- .../js/modules/blocktopmenu/js/hoverIntent.js | 176 +++++---- .../blocktopmenu/js/superfish-modified.js | 353 ++++++++++++------ .../modules/blocktopmenu/blocktopmenu.tpl | 57 ++- .../blocktopmenu/css/superfish-modified.scss | 180 ++++++++- 7 files changed, 761 insertions(+), 222 deletions(-) diff --git a/modules/blockbanner/blockbanner.tpl b/modules/blockbanner/blockbanner.tpl index 23e946eef..460a41a89 100644 --- a/modules/blockbanner/blockbanner.tpl +++ b/modules/blockbanner/blockbanner.tpl @@ -29,7 +29,7 @@
{if isset($banner_img)} - + {else} {$banner_desc} {/if} diff --git a/modules/blocktopmenu/blocktopmenu.php b/modules/blocktopmenu/blocktopmenu.php index e3d4fe96e..db961a7fb 100644 --- a/modules/blocktopmenu/blocktopmenu.php +++ b/modules/blocktopmenu/blocktopmenu.php @@ -490,13 +490,13 @@ class Blocktopmenu extends Module if ($category->level_depth == 2) { $files = scandir(_PS_CAT_IMG_DIR_); - $this->_menu .= '
'; + $this->_menu .= '
  • '; foreach ($files as $file) if (preg_match('/'.$category->id.'-([0-9])?_thumb.jpg/i', $file) === 1) $this->_menu .= '
    '.ImageManager::thumbnail(_PS_CAT_IMG_DIR_.$file, 'category_'.$file, 100, 'jpg', true, true).'
    '; - $this->_menu .= '
  • '; + $this->_menu .= ''; } $this->_menu .= ''; diff --git a/themes/default-bootstrap/css/modules/blocktopmenu/css/superfish-modified.css b/themes/default-bootstrap/css/modules/blocktopmenu/css/superfish-modified.css index b2f91d31a..da2ff11b8 100644 --- a/themes/default-bootstrap/css/modules/blocktopmenu/css/superfish-modified.css +++ b/themes/default-bootstrap/css/modules/blocktopmenu/css/superfish-modified.css @@ -2,6 +2,19 @@ /*** ESSENTIAL STYLES ***/ .sf-contener { clear: both; + float: left; + width: 100%; + margin: 50px 0 0; +} +@media (min-width: 480px) and (max-width: 767px) { + .sf-contener { + margin-top: 80px; + } +} +@media (max-width: 479px) { + .sf-contener { + margin-top: 70px; + } } .sf-menu, .sf-menu * { @@ -11,30 +24,28 @@ } .sf-menu { - margin: 50px 0 0; + position: relative; padding: 0; width: 100%; border-bottom: 3px solid #e9e9e9; background: #f6f6f6; } -@media (min-width: 480px) and (max-width: 767px) { +@media (max-width: 767px) { .sf-menu { - margin-top: 80px; - } -} -@media (max-width: 479px) { - .sf-menu { - margin-top: 70px; + display: none; } } .sf-menu ul { position: absolute; top: -999em; - width: 10em; - /* left offset of submenus need to match (see below) */ background: white; } +@media (max-width: 767px) { + .sf-menu ul { + position: relative; + } +} .sf-menu ul li { width: 100%; @@ -45,15 +56,32 @@ /* fixes IE7 'sticky bug' */ } -.sf-menu li { - position: relative; -} - .sf-menu > li { float: left; border-right: 1px solid #d6d4d4; margin-bottom: -3px; } +@media (max-width: 767px) { + .sf-menu > li { + float: none; + position: relative; + border-right: none; + } + .sf-menu > li span { + position: absolute; + right: 6px; + top: 20px; + display: none; + width: 30px; + height: 30px; + z-index: 2; + } + .sf-menu > li span:after { + font-family: "FontAwesome"; + content: ""; + font-size: 26px; + } +} .sf-menu > li > a { font: 600 18px/22px "Open Sans", sans-serif; text-transform: uppercase; @@ -62,14 +90,25 @@ padding: 17px 20px; border-bottom: 3px solid #e9e9e9; } +@media (max-width: 767px) { + .sf-menu > li > a.sf-with-ul:after { + position: absolute; + right: 15px; + top: 18px; + font-family: "FontAwesome"; + content: ""; + font-size: 26px; + z-index: 1; + } +} .sf-menu > li.sfHover > a, .sf-menu > li > a:hover, .sf-menu > li.sfHoverForce > a { background: #333333; border-bottom-color: #666666; color: white; } -.sf-menu li li a { - display: block; +.sf-menu li li li a { + display: inline-block; position: relative; color: #777777; font-size: 13px; @@ -77,13 +116,13 @@ font-weight: bold; padding-bottom: 10px; } -.sf-menu li li a:before { +.sf-menu li li li a:before { content: ""; display: inline-block; font-family: "FontAwesome"; padding-right: 10px; } -.sf-menu li li a:hover { +.sf-menu li li li a:hover { color: #333333; } @@ -93,12 +132,34 @@ top: 59px; /* match top ul list item height */ z-index: 99; - width: 220px; - padding: 25px 30px; + padding: 12px 0px 18px 0px; -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 13px; -moz-box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 13px; box-shadow: rgba(0, 0, 0, 0.2) 0px 5px 13px; } +@media (max-width: 767px) { + .sf-menu li ul { + top: 0; + } +} + +.sf-menu li li ul { + position: static; + display: block !important; + opacity: 1 !important; + background: none; + -webkit-box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px; + -moz-box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px; + box-shadow: rgba(0, 0, 0, 0) 0px 0px 0px; +} + +.sf-menu li li li ul { + padding: 0 0 0 20px; +} + +.sf-menu li li li ul { + width: 220px; +} ul.sf-menu li:hover li ul, ul.sf-menu li.sfHover li ul { @@ -123,3 +184,113 @@ ul.sf-menu li li li.sfHover ul { /* match ul width */ top: 0; } + +.sf-menu > li > ul { + padding: 26px 30px 31px; + width: 100%; +} +.sf-menu > li > ul > li > a { + text-transform: uppercase; + font: 600 16px/20px "Open Sans", sans-serif; + color: #333333; +} +.sf-menu > li > ul > li > a:hover { + color: #515151; +} + +.sf-menu > li > ul > li:not(#category-thumbnail) { + float: left; + width: 20%; + padding-right: 15px; +} +@media (max-width: 767px) { + .sf-menu > li > ul > li:not(#category-thumbnail) { + width: 50%; + } +} +@media (max-width: 479px) { + .sf-menu > li > ul > li:not(#category-thumbnail) { + width: 100%; + } +} +@media (min-width: 768px) { + .sf-menu > li > ul > li:not(#category-thumbnail).first-in-line-lg { + clear: left; + } +} +@media (min-width: 480px) and (max-width: 767px) { + .sf-menu > li > ul > li:not(#category-thumbnail).first-in-line-xs { + clear: left; + } +} + +.sf-menu > li > ul > li#category-thumbnail { + width: 100%; + clear: both; + overflow: hidden; +} +.sf-menu > li > ul > li#category-thumbnail > div { + float: left; + padding-left: 10px; + width: 33.333%; +} +@media (max-width: 479px) { + .sf-menu > li > ul > li#category-thumbnail > div { + width: 100%; + padding-left: 0; + padding-top: 10px; + text-align: center; + } +} +.sf-menu > li > ul > li#category-thumbnail > div:first-child { + padding-left: 0; +} +.sf-menu > li > ul > li#category-thumbnail > div img { + max-width: 100%; + width: 100%; + display: block; +} + +.cat-title { + display: none; +} +@media (max-width: 767px) { + .cat-title { + display: block; + font: 600 18px/22px "Open Sans", sans-serif; + text-transform: uppercase; + color: #484848; + display: block; + padding: 17px 20px; + border-bottom: 3px solid #e9e9e9; + background: #f6f6f6; + position: relative; + } + .cat-title:hover { + background: #333333; + border-bottom-color: #666666; + color: white; + } + .cat-title:after { + display: block; + font-family: "FontAwesome"; + content: ""; + position: absolute; + right: 15px; + top: 18px; + font-size: 26px; + } + .cat-title.active:after { + content: ""; + } +} + +@media (max-width: 767px) { + .sf-menu > li.sfHover > a.sf-with-ul:after, .sf-menu > li.sfHoverForce > a.sf-with-ul:after { + display: none; + } + + .sf-menu > li.sfHover > span, .sf-menu > li.sfHoverForce > span { + display: block; + } +} diff --git a/themes/default-bootstrap/js/modules/blocktopmenu/js/hoverIntent.js b/themes/default-bootstrap/js/modules/blocktopmenu/js/hoverIntent.js index 91da57b24..cbe3ae715 100644 --- a/themes/default-bootstrap/js/modules/blocktopmenu/js/hoverIntent.js +++ b/themes/default-bootstrap/js/modules/blocktopmenu/js/hoverIntent.js @@ -1,84 +1,114 @@ -(function($){ - /* hoverIntent by Brian Cherne */ - $.fn.hoverIntent = function(f,g) { - // default configuration options - var cfg = { - sensitivity: 7, - interval: 100, - timeout: 0 - }; - // override configuration options with user supplied object - cfg = $.extend(cfg, g ? { over: f, out: g } : f ); +/** + * hoverIntent is similar to jQuery's built-in "hover" method except that + * instead of firing the handlerIn function immediately, hoverIntent checks + * to see if the user's mouse has slowed down (beneath the sensitivity + * threshold) before firing the event. The handlerOut function is only + * called after a matching handlerIn. + * + * hoverIntent r7 // 2013.03.11 // jQuery 1.9.1+ + * http://cherne.net/brian/resources/jquery.hoverIntent.html + * + * You may use hoverIntent under the terms of the MIT license. Basically that + * means you are free to use hoverIntent as long as this header is left intact. + * Copyright 2007, 2013 Brian Cherne + * + * // basic usage ... just like .hover() + * .hoverIntent( handlerIn, handlerOut ) + * .hoverIntent( handlerInOut ) + * + * // basic usage ... with event delegation! + * .hoverIntent( handlerIn, handlerOut, selector ) + * .hoverIntent( handlerInOut, selector ) + * + * // using a basic configuration object + * .hoverIntent( config ) + * + * @param handlerIn function OR configuration object + * @param handlerOut function OR selector for delegation OR undefined + * @param selector selector OR undefined + * @author Brian Cherne + **/ +(function($) { + $.fn.hoverIntent = function(handlerIn,handlerOut,selector) { - // instantiate variables - // cX, cY = current X and Y position of mouse, updated by mousemove event - // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval - var cX, cY, pX, pY; + // default configuration values + var cfg = { + interval: 100, + sensitivity: 7, + timeout: 0 + }; - // A private function for getting mouse position - var track = function(ev) { - cX = ev.pageX; - cY = ev.pageY; - }; + if ( typeof handlerIn === "object" ) { + cfg = $.extend(cfg, handlerIn ); + } else if ($.isFunction(handlerOut)) { + cfg = $.extend(cfg, { over: handlerIn, out: handlerOut, selector: selector } ); + } else { + cfg = $.extend(cfg, { over: handlerIn, out: handlerIn, selector: handlerOut } ); + } - // A private function for comparing current and previous mouse position - var compare = function(ev,ob) { - ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); - // compare mouse positions to see if they've crossed the threshold - if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) { - $(ob).unbind("mousemove",track); - // set hoverIntent state to true (so mouseOut can be called) - ob.hoverIntent_s = 1; - return cfg.over.apply(ob,[ev]); - } else { - // set previous coordinates for next time - pX = cX; pY = cY; - // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs) - ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval ); - } - }; + // instantiate variables + // cX, cY = current X and Y position of mouse, updated by mousemove event + // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval + var cX, cY, pX, pY; - // A private function for delaying the mouseOut function - var delay = function(ev,ob) { - ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); - ob.hoverIntent_s = 0; - return cfg.out.apply(ob,[ev]); - }; + // A private function for getting mouse position + var track = function(ev) { + cX = ev.pageX; + cY = ev.pageY; + }; - // A private function for handling mouse 'hovering' - var handleHover = function(e) { - // next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut - var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; - while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } } - if ( p == this ) { return false; } + // A private function for comparing current and previous mouse position + var compare = function(ev,ob) { + ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); + // compare mouse positions to see if they've crossed the threshold + if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) { + $(ob).off("mousemove.hoverIntent",track); + // set hoverIntent state to true (so mouseOut can be called) + ob.hoverIntent_s = 1; + return cfg.over.apply(ob,[ev]); + } else { + // set previous coordinates for next time + pX = cX; pY = cY; + // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs) + ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval ); + } + }; - // copy objects to be passed into t (required for event object to be passed in IE) - var ev = jQuery.extend({},e); - var ob = this; + // A private function for delaying the mouseOut function + var delay = function(ev,ob) { + ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); + ob.hoverIntent_s = 0; + return cfg.out.apply(ob,[ev]); + }; - // cancel hoverIntent timer if it exists - if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } + // A private function for handling mouse 'hovering' + var handleHover = function(e) { + // copy objects to be passed into t (required for event object to be passed in IE) + var ev = jQuery.extend({},e); + var ob = this; - // else e.type == "onmouseover" - if (e.type == "mouseover") { - // set "previous" X and Y position based on initial entry point - pX = ev.pageX; pY = ev.pageY; - // update "current" X and Y position based on mousemove - $(ob).bind("mousemove",track); - // start polling interval (self-calling timeout) to compare mouse coordinates over time - if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} + // cancel hoverIntent timer if it exists + if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } - // else e.type == "onmouseout" - } else { - // unbind expensive mousemove event - $(ob).unbind("mousemove",track); - // if hoverIntent state is true, then call the mouseOut function after the specified delay - if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );} - } - }; + // if e.type == "mouseenter" + if (e.type == "mouseenter") { + // set "previous" X and Y position based on initial entry point + pX = ev.pageX; pY = ev.pageY; + // update "current" X and Y position based on mousemove + $(ob).on("mousemove.hoverIntent",track); + // start polling interval (self-calling timeout) to compare mouse coordinates over time + if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} - // bind the function to the two event listeners - return this.mouseover(handleHover).mouseout(handleHover); - }; - + // else e.type == "mouseleave" + } else { + // unbind expensive mousemove event + $(ob).off("mousemove.hoverIntent",track); + // if hoverIntent state is true, then call the mouseOut function after the specified delay + if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );} + } + }; + + // listen for mouseenter and mouseleave + return this.on({'mouseenter.hoverIntent':handleHover,'mouseleave.hoverIntent':handleHover}, cfg.selector); + }; })(jQuery); \ No newline at end of file diff --git a/themes/default-bootstrap/js/modules/blocktopmenu/js/superfish-modified.js b/themes/default-bootstrap/js/modules/blocktopmenu/js/superfish-modified.js index d0dfb5090..03b614702 100644 --- a/themes/default-bootstrap/js/modules/blocktopmenu/js/superfish-modified.js +++ b/themes/default-bootstrap/js/modules/blocktopmenu/js/superfish-modified.js @@ -1,124 +1,257 @@ - /* - * Superfish v1.4.8 - jQuery menu widget - * Copyright (c) 2008 Joel Birch + * 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 - * - * CHANGELOG: http://users.tpg.com.au/j_birch/plugins/superfish/changelog.txt + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html */ -;(function($){ - $.fn.superfish = function(op){ +;(function ($) { + "use strict"; - var sf = $.fn.superfish, - c = sf.c, - $arrow = $([' »'].join('')), - over = function(){ - var $$ = $(this), menu = getMenu($$); - clearTimeout(menu.sfTimer); - $$.showSuperfishUl().siblings().hideSuperfishUl(); + 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' }, - out = function(){ - var $$ = $(this), menu = getMenu($$), o = sf.op; - clearTimeout(menu.sfTimer); - menu.sfTimer=setTimeout(function(){ - o.retainPath=($.inArray($$[0],o.$path)>-1); - $$.hideSuperfishUl(); - if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);} - },o.delay); + 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); }, - getMenu = function($menu){ - var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0]; - sf.op = sf.o[menu.serial]; - return menu; + 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); }, - addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); }; - - return this.each(function() { - var s = this.serial = sf.o.length; - var o = $.extend({},sf.defaults,op); - o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){ - $(this).addClass([o.hoverClass,c.bcClass].join(' ')) - .filter('li:has(ul)').removeClass(o.pathClass); - }); - sf.o[s] = sf.op = o; - - $('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() { - if (o.autoArrows) addArrow( $('>a:first-child',this) ); - }) - .not('.'+c.bcClass) - .hideSuperfishUl(); - - var $a = $('a',this); - $a.each(function(i){ - var $li = $a.eq(i).parents('li'); - $a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);}); - }); - o.onInit.call(this); - - }).each(function() { - menuClasses = [c.menuClass]; - if (sf.op.dropShadows && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass); - $(this).addClass(menuClasses.join(' ')); - }); - }; + 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); - var sf = $.fn.superfish; - sf.o = []; - sf.op = {}; - sf.IE7fix = function(){ - var o = sf.op; - if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined) - this.toggleClass(sf.c.shadowClass+'-off'); + 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); + }); + } }; - sf.c = { - bcClass : 'sf-breadcrumb', - menuClass : 'sf-js-enabled', - anchorClass : 'sf-with-ul', - arrowClass : 'sf-sub-indicator', - shadowClass : 'sf-shadow' - }; - sf.defaults = { - hoverClass : 'sfHover', - pathClass : 'overideThisToUse', - pathLevels : 1, - delay : 800, - animation : {opacity:'show'}, - speed : 'fast', - autoArrows : false, - dropShadows : false, - disableHI : false, // true disables hoverIntent detection - onInit : function(){}, // callback functions - onBeforeShow: function(){}, - onShow : function(){}, - onHide : function(){} - }; - $.fn.extend({ - hideSuperfishUl : function(){ - var o = sf.op, - not = (o.retainPath===true) ? o.$path : ''; - o.retainPath = false; - var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass) - .find('>ul').hide().css('visibility','hidden'); - o.onHide.call($ul); - return this; - }, - showSuperfishUl : function(){ - var o = sf.op, - sh = sf.c.shadowClass+'-off', - $ul = this.addClass(o.hoverClass) - .find('>ul:hidden').css('visibility','visible'); - sf.IE7fix.call($ul); - o.onBeforeShow.call($ul); - $ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); }); - return 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: 1, + 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); -jQuery(function(){ - jQuery('ul.sf-menu').superfish(); -}); \ No newline at end of file +})(jQuery); \ No newline at end of file diff --git a/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl b/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl index a2914e0df..74a3c5966 100644 --- a/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl +++ b/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl @@ -2,7 +2,8 @@
    -
      +
      {l s="Categories" mod="blocktopmenu"}
      +
    + {literal} + + {/literal} {/if} \ No newline at end of file diff --git a/themes/default-bootstrap/sass/modules/blocktopmenu/css/superfish-modified.scss b/themes/default-bootstrap/sass/modules/blocktopmenu/css/superfish-modified.scss index a3f7c34a7..c38417b6a 100644 --- a/themes/default-bootstrap/sass/modules/blocktopmenu/css/superfish-modified.scss +++ b/themes/default-bootstrap/sass/modules/blocktopmenu/css/superfish-modified.scss @@ -2,6 +2,15 @@ /*** ESSENTIAL STYLES ***/ .sf-contener { clear:both; + float:left; + width:100%; + margin: 50px 0 0; + @media (min-width: $screen-xs) and (max-width: $screen-xs-max) { // min 480px max 767px + margin-top:80px; + } + @media (max-width: $screen-xs - 1) { // max 479px + margin-top:70px; + } } .sf-right { } @@ -11,23 +20,22 @@ list-style: none; } .sf-menu { - margin: 50px 0 0; + position: relative; padding: 0; width: 100%; border-bottom: 3px solid #e9e9e9; background: #f6f6f6; - @media (min-width: $screen-xs) and (max-width: $screen-xs-max) { // min 480px max 767px - margin-top:80px; - } - @media (max-width: $screen-xs - 1) { // max 479px - margin-top:70px; + @media (max-width: $screen-xs-max) { // max 767px + display:none; } } .sf-menu ul { position: absolute; top: -999em; - width: 10em; /* left offset of submenus need to match (see below) */ background: $light-background; + @media (max-width: $screen-xs-max) { // max 767px + position:relative; + } } .sf-menu ul li { width: 100%; @@ -35,14 +43,31 @@ .sf-menu li:hover { visibility: inherit; /* fixes IE7 'sticky bug' */ } -.sf-menu li { - position: relative; -} .sf-menu > li { float: left; border-right: 1px solid $base-border-color; margin-bottom: -3px; - + @media (max-width: $screen-xs-max) { // max 767px + float:none; + position:relative; + border-right:none; + + span { + position:absolute; + right:6px; + top:20px; + display:none; + width:30px; + height:30px; + z-index:2; + + &:after { + font-family:$font-icon; + content:""; + font-size:26px; + } + } + } > a { font: 600 18px/22px $font-custom; text-transform: uppercase; @@ -50,6 +75,19 @@ display: block; padding: 17px 20px; border-bottom: 3px solid #e9e9e9; + @media (max-width: $screen-xs-max) { // max 767px + &.sf-with-ul { + &:after { + position:absolute; + right:15px; + top:18px; + font-family:$font-icon; + content:""; + font-size:26px; + z-index:1; + } + } + } } &.sfHover > a, > a:hover, &.sfHoverForce > a { @@ -58,8 +96,8 @@ color: $light-text-color; } } -.sf-menu li li a { - display: block; +.sf-menu li li li a { + display: inline-block; position: relative; color: #777777; font-size: 13px; @@ -83,9 +121,24 @@ left: 0; top: 59px; /* match top ul list item height */ z-index: 99; - width: 220px; - padding: 25px 30px; + padding: 12px 0px 18px 0px; @include box-shadow(rgba(black, 0.20) 0px 5px 13px); + @media (max-width: $screen-xs-max) { // max 767px + top:0; + } +} +.sf-menu li li ul { + position:static; + display:block !important; + opacity:1 !important; + background:none; + @include box-shadow(rgba(black, 0) 0px 0px 0px); +} +.sf-menu li li li ul { + padding:0 0 0 20px; +} +.sf-menu li li li ul { + width: 220px; } ul.sf-menu li:hover li ul, ul.sf-menu li.sfHover li ul { @@ -105,3 +158,100 @@ ul.sf-menu li li li.sfHover ul { left: 200px; /* match ul width */ top: 0; } +.sf-menu > li > ul { + padding:26px 30px 31px; + width:100%; + + > li { + > a { + text-transform:uppercase; + font:600 16px/20px $font-custom; + color:$base-text-color; + + &:hover { + color:$link-hover-color; + } + } + } +} +.sf-menu > li > ul > li:not(#category-thumbnail) { + float:left; + width:20%; + padding-right:15px; + @media (max-width: $screen-xs-max) { // max 767px + width:50%; + } + @media (max-width: $screen-xs - 1) { // max 479px + width:100%; + } + @media (min-width: $screen-sm) { // min 768px + &.first-in-line-lg {clear:left;} + } + @media (min-width: $screen-xs) and (max-width: $screen-xs-max) { // min 480px max 767px + &.first-in-line-xs {clear:left;} + } +} +.sf-menu > li > ul > li#category-thumbnail { + width:100%; + clear:both; + overflow:hidden; + + > div { + float:left; + padding-left:10px; + width:33.333%; + @media (max-width: $screen-xs - 1) { // max 479px + width:100%; + padding-left:0; + padding-top:10px; + text-align:center; + } + + &:first-child {padding-left:0;} + img { + max-width:100%; + width:100%; + display:block; + } + } +} +.cat-title { + display:none; + @media (max-width: $screen-xs-max) { // max 767px + display: block; + font: 600 18px/22px $font-custom; + text-transform: uppercase; + color: #484848; + display: block; + padding: 17px 20px; + border-bottom: 3px solid #e9e9e9; + background: #f6f6f6; + position:relative; + + &:hover { + background: $dark-background; + border-bottom-color: #666666; + color: $light-text-color; + } + &:after { + display:block; + font-family:$font-icon; + content:""; + position:absolute; + right:15px; + top:18px; + font-size:26px; + } + &.active:after{ + content:""; + } + } +} +@media (max-width: $screen-xs-max) { // max 767px +.sf-menu > li.sfHover > a.sf-with-ul:after, .sf-menu > li.sfHoverForce > a.sf-with-ul:after { + display:none; +} +.sf-menu > li.sfHover > span, .sf-menu > li.sfHoverForce > span { + display:block; +} +} \ No newline at end of file From b62952accf8a6a1b08d5bf3b90ca56b665c5e9a4 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Fri, 15 Nov 2013 18:07:07 +0100 Subject: [PATCH 2/8] [*] BO : Added simulation mode to the dashboard --- .../dashboard/helpers/view/view.tpl | 16 +++++++ .../admin/AdminDashboardController.php | 8 +++- install-dev/data/theme.sql | 1 + js/admin-dashboard.js | 14 ++++++ modules/dashactivity/dashactivity.php | 43 ++++++++++++++++++- modules/dashtrends/dashtrends.php | 34 ++++++++++++--- 6 files changed, 107 insertions(+), 9 deletions(-) diff --git a/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl b/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl index c39de195c..ffe85bf5c 100644 --- a/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl +++ b/admin-dev/themes/default/template/controllers/dashboard/helpers/view/view.tpl @@ -128,6 +128,22 @@
    {l s="Go to prestashop.com"}
    + +
    +

    {l s="Simulation Mode"}

    + + + + + + + +
    +
    \ No newline at end of file diff --git a/controllers/admin/AdminDashboardController.php b/controllers/admin/AdminDashboardController.php index f7c6289fd..9a9dc3f0c 100644 --- a/controllers/admin/AdminDashboardController.php +++ b/controllers/admin/AdminDashboardController.php @@ -309,7 +309,13 @@ class AdminDashboardControllerCore extends AdminController die(Tools::jsonEncode(Hook::exec('dashboardData', $params, $id_module, true, true, (int)Tools::getValue('dashboard_use_push')))); } - + + public function ajaxProcessSetSimulationMode() + { + Configuration::updateValue('PS_DASHBOARD_SIMULATION', (int)Tools::getValue('PS_DASHBOARD_SIMULATION')); + die ('k'.Configuration::get('PS_DASHBOARD_SIMULATION').'k'); + } + public function ajaxProcessGetBlogRss() { $return = array('has_errors' => false, 'rss' => array()); diff --git a/install-dev/data/theme.sql b/install-dev/data/theme.sql index 82e32c790..6e746f123 100644 --- a/install-dev/data/theme.sql +++ b/install-dev/data/theme.sql @@ -67,6 +67,7 @@ UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'BLOCK_CATEG_NBR_COLU UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPDB_FILENAME'; UPDATE `PREFIX_configuration` SET value = '' WHERE name = 'UPGRADER_BACKUPFILES_FILENAME'; UPDATE `PREFIX_configuration` SET value = '40' WHERE name = 'CONF_AVERAGE_PRODUCT_MARGIN'; +UPDATE `PREFIX_configuration` SET value = '1' WHERE name = 'PS_DASHBOARD_SIMULATION'; /* No right column */ DELETE FROM `PREFIX_hook_module` WHERE id_hook = (SELECT id_hook FROM `PREFIX_hook` WHERE name = 'displayRightColumn'); diff --git a/js/admin-dashboard.js b/js/admin-dashboard.js index 4f1dd753e..4ba33e6d3 100644 --- a/js/admin-dashboard.js +++ b/js/admin-dashboard.js @@ -289,4 +289,18 @@ $(document).ready( function () { getBlogRss(); bindSubmitDashConfig(); bindCancelDashConfig(); + + $('.ps_dashboard_simulation').change(function(e) { + $.ajax({ + url : dashboard_ajax_url, + data : { + ajax:true, + action:'setSimulationMode', + PS_DASHBOARD_SIMULATION: $(this).val() + }, + success : function(result) { + refreshDashboard(false, false); + } + }); + }); }); diff --git a/modules/dashactivity/dashactivity.php b/modules/dashactivity/dashactivity.php index 63804f7e8..11043100d 100644 --- a/modules/dashactivity/dashactivity.php +++ b/modules/dashactivity/dashactivity.php @@ -97,6 +97,45 @@ class Dashactivity extends Module public function hookDashboardData($params) { + if (Configuration::get('PS_DASHBOARD_SIMULATION')) + { + $days = round((strtotime($params['date_to']) - strtotime($params['date_from'])) / 3600 / 24); + $online_visitor = round(rand(10, 50)); + $visits = round(rand(200, 2000) * $days); + + return array( + 'data_value' => array( + 'pending_orders' => round(rand(0, 5)), + 'return_exchanges' => round(rand(0, 5)), + 'abandoned_cart' => round(rand(5, 50)), + 'products_out_of_stock' => round(rand(1, 10)), + 'new_messages' => round(rand(1, 10) * $days), + 'order_inquires' => 42, + 'product_reviews' => round(rand(5, 50) * $days), + 'new_customers' => round(rand(1, 5) * $days), + 'online_visitor' => $online_visitor, + 'active_shopping_cart' => round($online_visitor / 10), + 'new_registrations' => round(rand(1, 5) * $days), + 'total_suscribers' => round(rand(200, 2000)), + 'visits' => $visits, + 'unique_visitors' => round($visits * 0.6), + ), + 'data_trends' => array( + 'orders_trends' => array('way' => 'down', 'value' => 0.42), + ), + 'data_list_small' => array( + 'dash_traffic_source' => array('prestashop.com' => round($visits / 2), 'google.com' => round($visits / 3), 'Direct Traffic' => round($visits / 4)) + ), + 'data_chart' => array( + 'dash_trends_chart1' => array('chart_type' => 'pie_chart_trends', 'data' => array( + array('key' => 'prestashop.com', 'y' => round($visits / 2)), + array('key' => 'google.com', 'y' => round($visits / 3)), + array('key' => 'Direct Traffic', 'y' => round($visits / 4)) + )) + ) + ); + } + $gapi = Module::isInstalled('gapi') ? Module::getInstanceByName('gapi') : false; if (Validate::isLoadedObject($gapi) && $gapi->isConfigured()) { @@ -353,14 +392,14 @@ class Dashactivity extends Module $fields_form['form']['input'][] = array( 'label' => $this->l('Cart abandoned (min)'), 'desc' => $this->l('Default time range (min) to consider a Shopping cart as abandoned (default 24hrs)'), - 'name' => 'DASHACTIVITY_CART_ABANDONED_MIN', + 'name' => 'DASHACTIVITY_CART_ABANDONED', 'type' => 'text', 'suffix' => $this->l('hrs'), ); $fields_form['form']['input'][] = array( 'label' => $this->l('Cart abandoned (max)'), 'desc' => $this->l('Default time range (max) to consider a Shopping cart as abandoned (default 48hrs)'), - 'name' => 'DASHACTIVITY_CART_ABANDONED_MAX', + 'name' => 'DASHACTIVITY_CART_ABANDONED', 'type' => 'text', 'suffix' => $this->l('hrs'), ); diff --git a/modules/dashtrends/dashtrends.php b/modules/dashtrends/dashtrends.php index 80c8583d9..015945ff4 100644 --- a/modules/dashtrends/dashtrends.php +++ b/modules/dashtrends/dashtrends.php @@ -75,11 +75,30 @@ class Dashtrends extends Module 'total_expenses' => array() ); - $tmp_data['visits'] = AdminStatsControllerCore::getVisits(false, $date_from, $date_to, 'day'); - $tmp_data['orders'] = AdminStatsControllerCore::getOrders($date_from, $date_to, 'day'); - $tmp_data['total_paid_tax_excl'] = AdminStatsControllerCore::getTotalSales($date_from, $date_to, 'day'); - $tmp_data['total_purchases'] = AdminStatsControllerCore::getPurchases($date_from, $date_to, 'day'); - $tmp_data['total_expenses'] = AdminStatsControllerCore::getExpenses($date_from, $date_to, 'day'); + if (Configuration::get('PS_DASHBOARD_SIMULATION')) + { + $from = strtotime($date_from.' 00:00:00'); + $to = min(time(), strtotime($date_to.' 23:59:59')); + for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date)) + { + $tmp_data['visits'][$date] = round(rand(2000, 20000)); + $tmp_data['conversion_rate'][$date] = rand(80, 250) / 100; + $tmp_data['average_cart_value'][$date] = round(rand(60, 200), 2); + $tmp_data['orders'][$date] = round($tmp_data['visits'][$date] * $tmp_data['conversion_rate'][$date] / 100); + $tmp_data['total_paid_tax_excl'][$date] = $tmp_data['orders'][$date] * $tmp_data['average_cart_value'][$date]; + $tmp_data['total_purchases'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(50, 70) / 100; + $tmp_data['total_expenses'][$date] = $tmp_data['total_paid_tax_excl'][$date] * rand(0, 10) / 100; + } + } + else + { + $tmp_data['visits'] = AdminStatsControllerCore::getVisits(false, $date_from, $date_to, 'day'); + $tmp_data['orders'] = AdminStatsControllerCore::getOrders($date_from, $date_to, 'day'); + $tmp_data['total_paid_tax_excl'] = AdminStatsControllerCore::getTotalSales($date_from, $date_to, 'day'); + $tmp_data['total_purchases'] = AdminStatsControllerCore::getPurchases($date_from, $date_to, 'day'); + $tmp_data['total_expenses'] = AdminStatsControllerCore::getExpenses($date_from, $date_to, 'day'); + } + return $tmp_data; } @@ -93,7 +112,10 @@ class Dashtrends extends Module 'conversion_rate' => array(), 'net_profits' => array() ); - $from = max(strtotime(_PS_CREATION_DATE_.' 00:00:00'), strtotime($date_from.' 00:00:00')); + + $from = strtotime($date_from.' 00:00:00'); + if (!Configuration::get('PS_DASHBOARD_SIMULATION')) + $from = max(strtotime(_PS_CREATION_DATE_.' 00:00:00'), $from); $to = min(time(), strtotime($date_to.' 23:59:59')); for ($date = $from; $date <= $to; $date = strtotime('+1 day', $date)) { From 8c3eb9b9a4a3796185d279d32321a3388b23ad01 Mon Sep 17 00:00:00 2001 From: rGaillard Date: Fri, 15 Nov 2013 21:03:17 +0100 Subject: [PATCH 3/8] // typo --- .../themes/default/template/controllers/modules/configure.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin-dev/themes/default/template/controllers/modules/configure.tpl b/admin-dev/themes/default/template/controllers/modules/configure.tpl index fdd8b9c2f..5ef55369b 100644 --- a/admin-dev/themes/default/template/controllers/modules/configure.tpl +++ b/admin-dev/themes/default/template/controllers/modules/configure.tpl @@ -24,7 +24,7 @@ *}

    - {l s='Configure'} : {$module_display_name} ({$module_name}} + {l s='Configure:'} {$module_display_name} ({$module_name})

    From 9b787c454f935ff30827b80c6f42cf68c791e3f8 Mon Sep 17 00:00:00 2001 From: PrestaEdit Date: Sat, 16 Nov 2013 01:21:56 +0100 Subject: [PATCH 4/8] //typo --- .../modules/blocktopmenu/blocktopmenu.tpl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl b/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl index 74a3c5966..2257fe616 100644 --- a/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl +++ b/themes/default-bootstrap/modules/blocktopmenu/blocktopmenu.tpl @@ -61,7 +61,7 @@ } } - function resposiveMenu(){ + function responsiveMenu(){ if ($(document).width() <= 767 && responsiveflagMenu == false){ menuChange('enable'), responsiveflagMenu = true @@ -71,8 +71,8 @@ responsiveflagMenu = false } } - $(document).ready(resposiveMenu); - $(window).resize(resposiveMenu); + $(document).ready(responsiveMenu); + $(window).resize(responsiveMenu); {/literal} -{/if} \ No newline at end of file +{/if} From de9e6d72c8cfac6bf7d654e757c0a74daa5f0c79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Nadaud?= Date: Sat, 16 Nov 2013 08:04:59 +0100 Subject: [PATCH 5/8] // Typo --- themes/default-bootstrap/js/jquery/resonsive_utilites.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/themes/default-bootstrap/js/jquery/resonsive_utilites.js b/themes/default-bootstrap/js/jquery/resonsive_utilites.js index 87b3ab5d7..46b7b1b53 100644 --- a/themes/default-bootstrap/js/jquery/resonsive_utilites.js +++ b/themes/default-bootstrap/js/jquery/resonsive_utilites.js @@ -78,7 +78,7 @@ function accordion(status){ } -function resposiveResize(){ +function responsiveResize(){ if ($(document).width() <= 767 && responsiveflag == false){ accordion('enable'), accordionFooter('enable'), @@ -91,8 +91,8 @@ function resposiveResize(){ } } -$(document).ready(resposiveResize); -$(window).resize(resposiveResize); +$(document).ready(responsiveResize); +$(window).resize(responsiveResize); //replace top banner to top of page, before #header $(document).ready(function(){ From 68c8e9da57dcb29862ce4b47d80fc52a66ff8bed Mon Sep 17 00:00:00 2001 From: rGaillard Date: Sat, 16 Nov 2013 19:24:03 +0100 Subject: [PATCH 6/8] // move to themeconfigurator --- .../images/index.php | 0 .../logo.gif | Bin .../logo.png | Bin .../themeconfigurator/themeconfigurator.php | 424 +++++++++++++++++- .../views/css/admin.css | 0 .../views/css/font/FontAwesome.otf | Bin .../views/css/font/font.css | 0 .../views/css/font/fontawesome-webfont.eot | Bin .../views/css/font/fontawesome-webfont.svg | 0 .../views/css/font/fontawesome-webfont.ttf | Bin .../views/css/font/fontawesome-webfont.woff | Bin .../views/css/font/museo_slab_300-webfont.eot | Bin .../views/css/font/museo_slab_300-webfont.ttf | Bin .../views/css/font/museo_slab_500-webfont.eot | Bin .../views/css/font/museo_slab_500-webfont.ttf | Bin .../css/font/proximanova-sbold-webfont.eot | Bin .../css/font/proximanova-sbold-webfont.ttf | Bin .../views/css/font/proximanova-webfont.eot | Bin .../views/css/font/proximanova-webfont.ttf | Bin .../views/css/hooks.css | 0 .../views/js/admin.js | 0 .../views/js}/index.php | 0 .../views/templates/admin/admin.tpl | 9 +- .../views/templates/admin}/index.php | 0 .../views/templates/admin/items.tpl | 34 +- .../views/templates/admin/messages.tpl | 0 .../views/templates/admin/new.tpl | 26 +- .../views/templates/hooks/hook.tpl} | 6 +- .../views/templates}/index.php | 0 modules/tmhtmlcontent/config.xml | 12 - .../4124625121355c962edd8c86ef14f3ee.jpg | Bin 115280 -> 0 bytes .../471dd22ba78685f12e457c16c9e3a005.jpg | Bin 138914 -> 0 bytes .../4f15eb95ccf54ffc141222224b86b2ac.jpg | Bin 139990 -> 0 bytes .../67d43d531b80880be4bf34fa50c3c2d5.jpg | Bin 80665 -> 0 bytes .../73c2f0d3133082d7d2879648d7b72e8d.jpg | Bin 142954 -> 0 bytes .../86a740c6973b2c0fdd9211583fb51dc3.jpg | Bin 87797 -> 0 bytes .../eb27ba8719f4206d861d8ce84dad7891.jpg | Bin 123560 -> 0 bytes modules/tmhtmlcontent/index.php | 8 - modules/tmhtmlcontent/tmhtmlcontent.php | 387 ---------------- .../views/templates/admin/index.php | 10 - .../views/templates/hooks/footer.tpl | 27 -- .../views/templates/hooks/left.tpl | 27 -- .../views/templates/hooks/right.tpl | 27 -- .../views/templates/hooks/top.tpl | 27 -- .../tmhtmlcontent/views/templates/index.php | 10 - 45 files changed, 438 insertions(+), 596 deletions(-) rename modules/{tmhtmlcontent => themeconfigurator}/images/index.php (100%) rename modules/{tmhtmlcontent => themeconfigurator}/logo.gif (100%) rename modules/{tmhtmlcontent => themeconfigurator}/logo.png (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/admin.css (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/FontAwesome.otf (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/font.css (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/fontawesome-webfont.eot (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/fontawesome-webfont.svg (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/fontawesome-webfont.ttf (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/fontawesome-webfont.woff (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/museo_slab_300-webfont.eot (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/museo_slab_300-webfont.ttf (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/museo_slab_500-webfont.eot (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/museo_slab_500-webfont.ttf (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/proximanova-sbold-webfont.eot (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/proximanova-sbold-webfont.ttf (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/proximanova-webfont.eot (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/font/proximanova-webfont.ttf (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/css/hooks.css (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/js/admin.js (100%) rename modules/{tmhtmlcontent/translations => themeconfigurator/views/js}/index.php (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/templates/admin/admin.tpl (84%) rename modules/{tmhtmlcontent/views => themeconfigurator/views/templates/admin}/index.php (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/templates/admin/items.tpl (88%) rename modules/{tmhtmlcontent => themeconfigurator}/views/templates/admin/messages.tpl (100%) rename modules/{tmhtmlcontent => themeconfigurator}/views/templates/admin/new.tpl (88%) rename modules/{tmhtmlcontent/views/templates/hooks/home.tpl => themeconfigurator/views/templates/hooks/hook.tpl} (86%) rename modules/{tmhtmlcontent/views/js => themeconfigurator/views/templates}/index.php (100%) delete mode 100644 modules/tmhtmlcontent/config.xml delete mode 100644 modules/tmhtmlcontent/images/4124625121355c962edd8c86ef14f3ee.jpg delete mode 100644 modules/tmhtmlcontent/images/471dd22ba78685f12e457c16c9e3a005.jpg delete mode 100644 modules/tmhtmlcontent/images/4f15eb95ccf54ffc141222224b86b2ac.jpg delete mode 100644 modules/tmhtmlcontent/images/67d43d531b80880be4bf34fa50c3c2d5.jpg delete mode 100644 modules/tmhtmlcontent/images/73c2f0d3133082d7d2879648d7b72e8d.jpg delete mode 100644 modules/tmhtmlcontent/images/86a740c6973b2c0fdd9211583fb51dc3.jpg delete mode 100644 modules/tmhtmlcontent/images/eb27ba8719f4206d861d8ce84dad7891.jpg delete mode 100644 modules/tmhtmlcontent/index.php delete mode 100644 modules/tmhtmlcontent/tmhtmlcontent.php delete mode 100644 modules/tmhtmlcontent/views/templates/admin/index.php delete mode 100644 modules/tmhtmlcontent/views/templates/hooks/footer.tpl delete mode 100644 modules/tmhtmlcontent/views/templates/hooks/left.tpl delete mode 100644 modules/tmhtmlcontent/views/templates/hooks/right.tpl delete mode 100644 modules/tmhtmlcontent/views/templates/hooks/top.tpl delete mode 100644 modules/tmhtmlcontent/views/templates/index.php diff --git a/modules/tmhtmlcontent/images/index.php b/modules/themeconfigurator/images/index.php similarity index 100% rename from modules/tmhtmlcontent/images/index.php rename to modules/themeconfigurator/images/index.php diff --git a/modules/tmhtmlcontent/logo.gif b/modules/themeconfigurator/logo.gif similarity index 100% rename from modules/tmhtmlcontent/logo.gif rename to modules/themeconfigurator/logo.gif diff --git a/modules/tmhtmlcontent/logo.png b/modules/themeconfigurator/logo.png similarity index 100% rename from modules/tmhtmlcontent/logo.png rename to modules/themeconfigurator/logo.png diff --git a/modules/themeconfigurator/themeconfigurator.php b/modules/themeconfigurator/themeconfigurator.php index 97114461e..6d2bf81bb 100644 --- a/modules/themeconfigurator/themeconfigurator.php +++ b/modules/themeconfigurator/themeconfigurator.php @@ -26,21 +26,281 @@ if (!defined('_PS_VERSION_')) exit; - + class ThemeConfigurator extends Module { + protected $max_image_size = 1048576; + protected $default_language; + protected $languages; + public function __construct() { $this->name = 'themeconfigurator'; $this->tab = 'front_office_features'; $this->version = '0.1'; + $this->bootstrap = true; + + $this->secure_key = Tools::encrypt($this->name); + $this->default_language = Language::getLanguage(Configuration::get('PS_LANG_DEFAULT')); + $this->languages = Language::getLanguages(); + parent::__construct(); $this->displayName = $this->l('Theme configurator'); $this->description = $this->l('Configure elements of your theme'); - $this->bootstrap = true; + + $this->module_path = _PS_MODULE_DIR_.$this->name.'/'; + $this->uploads_path = _PS_MODULE_DIR_.$this->name.'/images/'; + $this->admin_tpl_path = _PS_MODULE_DIR_.$this->name.'/views/templates/admin/'; + $this->hooks_tpl_path = _PS_MODULE_DIR_.$this->name.'/views/templates/hooks/'; + + } + + public function install() + { + if (!parent::install() || + !$this->installDB() || + !$this->registerHook('displayHeader') || + !$this->registerHook('displayTop') || + !$this->registerHook('displayLeftColumn') || + !$this->registerHook('displayRightColumn') || + !$this->registerHook('displayHome') || + !$this->registerHook('displayFooter') || + !$this->registerHook('displayBackOfficeHeader')) + return false; + + return true; + } + + private function installDB() + { + return ( + Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'themeconfigurator`') && + Db::getInstance()->Execute(' + CREATE TABLE `'._DB_PREFIX_.'themeconfigurator` ( + `id_item` int(10) unsigned NOT NULL AUTO_INCREMENT, + `id_shop` int(10) unsigned NOT NULL, + `id_lang` int(10) unsigned NOT NULL, + `item_order` int(10) unsigned NOT NULL, + `title` VARCHAR(100), + `title_use` tinyint(1) unsigned NOT NULL DEFAULT \'0\', + `hook` VARCHAR(100), + `url` VARCHAR(100), + `target` tinyint(1) unsigned NOT NULL DEFAULT \'0\', + `image` VARCHAR(100), + `image_w` VARCHAR(10), + `image_h` VARCHAR(10), + `html` TEXT, + `active` tinyint(1) unsigned NOT NULL DEFAULT \'1\', + PRIMARY KEY (`id_item`) + ) ENGINE = '._MYSQL_ENGINE_.' DEFAULT CHARSET=UTF8;') + ); + + return true; + } + + public function uninstall() + { + $images = Db::getInstance()->executeS('SELECT image FROM `'._DB_PREFIX_.'themeconfigurator`'); + foreach ($images as $image) + $this->deleteImage($image['image']); + + if (!Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'themeconfigurator`') || + !parent::uninstall()) + return false; + + return true; + } + + public function hookDisplayBackOfficeHeader() + { + if (Tools::getValue('configure') != $this->name) + return; + $this->context->controller->addCSS($this->_path.'views/css/admin.css'); + $this->context->controller->addJquery(); + $this->context->controller->addJS($this->_path.'views/js/admin.js'); + } + + public function hookdisplayHeader($params) + { + $this->context->controller->addCss($this->_path.'views/css/hooks.css', 'all'); + } + + public function hookDisplayTop() + { + $this->context->smarty->assign(array( + 'htmlitems'=> $this->getItemsFromHook('top'), + 'hook' => 'top' + )); + return $this->display(__FILE__, 'views/templates/hooks/hook.tpl'); + } + + public function hookDisplayHome() + { + $this->context->smarty->assign(array( + 'htmlitems'=> $this->getItemsFromHook('home'), + 'hook' => 'home' + )); + return $this->display(__FILE__, 'views/templates/hooks/hook.tpl'); + } + + public function hookDisplayLeftColumn() + { + $this->context->smarty->assign(array( + 'htmlitems'=> $this->getItemsFromHook('left'), + 'hook' => 'left' + )); + return $this->display(__FILE__, 'views/templates/hooks/hook.tpl'); } + public function hookDisplayRightColumn() + { + $this->context->smarty->assign(array( + 'htmlitems'=> $this->getItemsFromHook('right'), + 'hook' => 'right' + )); + return $this->display(__FILE__, 'views/templates/hooks/hook.tpl'); + } + public function hookDisplayFooter() + { + $this->context->smarty->assign(array( + 'htmlitems'=> $this->getItemsFromHook('footer'), + 'hook' => 'footer' + )); + return $this->display(__FILE__, 'views/templates/hooks/hook.tpl'); + } + + protected function getItemsFromHook($hook) + { + if (!$hook) + return false; + + return Db::getInstance()->ExecuteS(' + SELECT * + FROM `'._DB_PREFIX_.'themeconfigurator` + WHERE id_shop = '.(int)$this->context->shop->id.' AND id_lang = '.(int)$this->context->language->id.' AND hook = \''.pSQL($hook).'\' AND active = 1 + ORDER BY item_order ASC' + ); + } + + protected function deleteImage($image) + { + $file_name = $this->uploads_path.$image; + if (realpath(dirname($file_name)) != $this->uploads_path) + die; + + if ($image != '' && is_file($file_name)) + unlink($file_name); + } + + protected function removeItem() + { + $id_item = (int)Tools::getValue('item_id'); + + if ($image = Db::getInstance()->getValue('SELECT image FROM `'._DB_PREFIX_.'themeconfigurator` WHERE id_item = '.(int)$id_item)) + $this->deleteImage($image); + + Db::getInstance()->delete(_DB_PREFIX_.'themeconfigurator', 'id_item = '.(int)$id_item); + + if (Db::getInstance()->Affected_Rows() == 1) + { + Db::getInstance()->execute(' + UPDATE `'._DB_PREFIX_.'themeconfigurator` + SET item_order = item_order-1 + WHERE ( + item_order > '.(int)Tools::getValue('item_order').' AND + id_shop = '.(int)$this->context->shop->id.' AND + hook = \''.pSQL(Tools::getValue('item_hook')).'\') + '); + + $this->context->smarty->assign('confirmation', $this->l('Successful deletion.')); + } + else + $this->context->smarty->assign('error', $this->l('Can\'t delete the slide.')); + } + + protected function updateItem() + { + $id_item = (int)Tools::getValue('item_id'); + + $title = Tools::getValue('item_title'); + $content = Tools::getValue('item_html'); + if (!Validate::isCleanHtml($title, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')) || !Validate::isCleanHtml($content,(int)Configuration::get('PS_ALLOW_HTML_IFRAME'))) + { + $this->context->smarty->assign('error', $this->l('Invalid content')); + return false; + } + + $new_image = ''; + $image_w = (is_numeric(Tools::getValue('item_img_w'))) ? (int)Tools::getValue('item_img_w') : ''; + $image_h = (is_numeric(Tools::getValue('item_img_h'))) ? (int)Tools::getValue('item_img_h') : ''; + + if(!empty($_FILES['item_img']['name'])) + { + if ($old_image = Db::getInstance()->getValue('SELECT image FROM `'._DB_PREFIX_.'themeconfigurator` WHERE id_item = '.(int)$id_item)) + $this->_deleteImages($old_image); + + if (!$image = $this->uploadImage($_FILES['item_img'], $image_w, $image_h)) + return false; + + $new_image = 'image = \''.pSQL($image).'\','; + } + else + { + $image_w = ''; + $image_h = ''; + } + + if (!Db::getInstance()->execute(' + UPDATE `'._DB_PREFIX_.'themeconfigurator` SET + title = \''.pSQL($title).'\', + title_use = '.(int)Tools::getValue('item_title_use').', + hook = \''.pSQL(Tools::getValue('item_hook')).'\', + url = \''.pSQL(Tools::getValue('item_url')).'\', + target = '.(int)Tools::getValue('item_target').', + '.$new_image.' + image_w = '.(int)$image_w.', + image_h = '.(int)$image_h.', + active = '.(int)Tools::getValue('item_active').', + html = \''.pSQL($content).'\' + WHERE id_item = '.(int)Tools::getValue('item_id') + )) + { + if ($image = Db::getInstance()->getValue('SELECT image FROM `'._DB_PREFIX_.'themeconfigurator` WHERE id_item = '.(int)Tools::getValue('item_id'))) + $this->deleteImage($image); + + $this->context->smarty->assign('error', $this->l('An error occured while saving data.')); + return false; + } + $this->context->smarty->assign('confirmation', $this->l('Successfully updated.')); + return true; + + } + + protected function uploadImage($image, $image_w = '', $image_h = '') + { + $res = false; + if (is_array($image) && (ImageManager::validateUpload($image, $this->max_image_size) === false) && ($tmp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS')) && move_uploaded_file($image['tmp_name'], $tmp_name)) + { + $type = Tools::strtolower(Tools::substr(strrchr($image['name'], '.'), 1)); + $img_name = Tools::encrypt($image['name'].sha1(microtime())).'.'.$type; + Configuration::set('PS_IMAGE_QUALITY','png_all'); + if (ImageManager::resize($tmp_name, dirname(__FILE__).'/images/'.$img_name, $image_w, $image_h)) + $res = true; + + } + + if (isset($temp_name)) + @unlink($tmp_name); + if (!$res) + { + $this->context->smarty->assign('error', $this->l('An error occurred during the image upload.')); + return false; + } + + return $img_name; + } + public function getContent() { if (Tools::isSubmit('submitModule')) @@ -71,19 +331,107 @@ class ThemeConfigurator extends Module $module_instance->install(); } } - return $this->renderForm(); + + if (Tools::isSubmit('newItem')) + $this->addItem(); + elseif (Tools::isSubmit('updateItem')) + $this->updateItem(); + elseif (Tools::isSubmit('removeItem')) + $this->removeItem(); + + $html = $this->renderConfigurationForm(); + $html .= $this->renderThemeConfiguratorForm(); + + return $html; } - public function renderForm() + protected function addItem() { + $title = Tools::getValue('item_title'); + $content = Tools::getValue('item_html'); + if (!Validate::isCleanHtml($title, (int)Configuration::get('PS_ALLOW_HTML_IFRAME')) || !Validate::isCleanHtml($content, (int)Configuration::get('PS_ALLOW_HTML_IFRAME'))) + { + $this->context->smarty->assign('error', $this->l('Invalid content')); + return false; + } + + if (!$current_order = (int)Db::getInstance()->getValue(' + SELECT item_order + 1 + FROM `'._DB_PREFIX_.'themeconfigurator` + WHERE + id_shop = '.(int)$this->context->shop->id.' + AND id_lang = '.(int)Tools::getValue('id_lang').' + AND hook = \''.pSQL(Tools::getValue('item_hook')).'\' + ORDER BY item_order DESC' + )) + $current_order = 1; + + $image_w = is_numeric(Tools::getValue('item_img_w')) ? (int)Tools::getValue('item_img_w') : ''; + $image_h = is_numeric(Tools::getValue('item_img_h')) ? (int)Tools::getValue('item_img_h') : ''; + + if(!empty($_FILES['item_img']['name'])) + { + if (!$image = $this->uploadImage($_FILES['item_img'], $image_w, $image_h)) + return false; + } + else + { + $image = ''; + $image_w = ''; + $image_h = ''; + } + + if (!Db::getInstance()->Execute(' + INSERT INTO `'._DB_PREFIX_.'themeconfigurator` ( + `id_shop`, `id_lang`, `item_order`, `title`, `title_use`, `hook`, `url`, `target`, `image`, `image_w`, `image_h`, `html`, `active` + ) VALUES ( + \''.(int)$this->context->shop->id.'\', + \''.(int)Tools::getValue('id_lang').'\', + \''.(int)$current_order.'\', + \''.pSQL($title).'\', + \''.(int)Tools::getValue('item_title_use').'\', + \''.pSQL(Tools::getValue('item_hook')).'\', + \''.pSQL(Tools::getValue('item_url')).'\', + \''.(int)Tools::getValue('item_target').'\', + \''.pSQL($image).'\', + \''.pSQL($image_w).'\', + \''.pSQL($image_h).'\', + \''.pSQL($content).'\', + 1) + ')) + { + if (!Tools::isEmpty($image)) + $this->deleteImage($image); + + $this->context->smarty->assign('error', $this->l('An error occured while saving data.')); + return false; + } + + $this->context->smarty->assign('confirmation', $this->l('New item added successfull.')); + return true; + } + + public function renderConfigurationForm() + { $inputs = array(); foreach ($this->getConfigurableModules() as $module) + { + $desc = ''; + if (isset($module['is_module']) && $module['is_module']) + { + $module_instance = Module::getInstanceByName($module['name']); + if (Validate::isLoadedObject($module_instance) && method_exists($module_instance, 'getContent')) + $desc = ''.$this->l('Configure').''; + } + if (!$desc && isset($module['desc']) && $module['desc']) + $desc = $module['desc']; + $inputs[] = array( 'type' => 'switch', 'label' => $module['label'], 'name' => $module['name'], - 'desc' => (isset($module['desc']) ? $module['desc'] : ''), + 'desc' => $desc, 'values' => array( array( 'id' => 'active_on', @@ -97,6 +445,7 @@ class ThemeConfigurator extends Module ) ), ); + } $fields_form = array( 'form' => array( @@ -131,6 +480,52 @@ class ThemeConfigurator extends Module return $helper->generateForm(array($fields_form)); } + + protected function renderThemeConfiguratorForm() + { + $id_shop = (int)$this->context->shop->id; + $items = array(); + + $this->context->smarty->assign('htmlcontent', array( + 'admin_tpl_path' => $this->admin_tpl_path, + 'hooks_tpl_path' => $this->hooks_tpl_path, + + 'info' => array( + 'module' => $this->name, + 'name' => $this->displayName, + 'version' => $this->version, + 'psVersion' => _PS_VERSION_, + 'context' => (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 0) ? 1 : ($this->context->shop->getTotalShops() != 1) ? $this->context->shop->getContext() : 1 + ) + )); + + foreach ($this->languages as $language) { + $hooks[$language['id_lang']] = array('home', 'top', 'left', 'right', 'footer'); + + foreach ($hooks[$language['id_lang']] as $hook) + $items[$language['id_lang']][$hook] = Db::getInstance()->ExecuteS(' + SELECT * FROM `'._DB_PREFIX_.'themeconfigurator` + WHERE id_shop = '.(int)$id_shop.' + AND id_lang = '.(int)$language['id_lang'].' + AND hook = \''.pSQL($hook).'\' + ORDER BY item_order ASC' + ); + } + + $this->context->smarty->assign('htmlitems', array( + 'items' => $items, + 'lang' => array( + 'default' => $this->default_language, + 'all' => $this->languages, + 'lang_dir' => _THEME_LANG_DIR_, + 'user' => $this->context->language->id + ), + 'postAction' => 'index.php?tab=AdminModules&configure='.$this->name.'&token='.Tools::getAdminTokenLite('AdminModules').'&tab_module=other&module_name='.$this->name.'', + 'id_shop' => $id_shop + )); + + return $this->display(__FILE__, 'views/templates/admin/admin.tpl'); + } protected function getConfigurableModules() { @@ -138,52 +533,39 @@ class ThemeConfigurator extends Module array( 'label' => $this->l('Display the reinsurance block'), 'name' => 'blockreinsurance', - 'desc' => ''.$this->l('Configure the reinsurance block').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('blockreinsurance')) && $module->active), 'is_module' => true, ), array( 'label' => $this->l('Display the social following links'), 'name' => 'blocksocial', - 'desc' => ''.$this->l('Configure the social following links').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('blocksocial')) && $module->active), 'is_module' => true, ), array( 'label' => $this->l('Display contact information'), 'name' => 'blockcontactinfos', - 'desc' => ''.$this->l('Configure the contact information of your store').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('blockcontactinfos')) && $module->active), 'is_module' => true, ), array( 'label' => $this->l('Display social buttons on the products page'), 'name' => 'addsharethis', - 'desc' => ''.$this->l('Configure').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('addsharethis')) && $module->active), 'is_module' => true, ), array( 'label' => $this->l('Display facebook block on the home page'), 'name' => 'blockfacebook', - 'desc' => ''.$this->l('Configure').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('blockfacebook')) && $module->active), 'is_module' => true, ), array( 'label' => $this->l('Customer cms information block'), 'name' => 'blockcmsinfo', - 'desc' => ''.$this->l('Configure').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('blockcmsinfo')) && $module->active), 'is_module' => true, ), - array( - 'label' => $this->l('Customer banner information block'), - 'name' => 'tmhtmlcontent', - 'desc' => ''.$this->l('Configure').'', - 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('tmhtmlcontent')) && $module->active), - 'is_module' => true, - ), array( 'label' => $this->l('Enable Quick view'), 'name' => 'quick_view', @@ -192,14 +574,12 @@ class ThemeConfigurator extends Module array( 'label' => $this->l('Enable top banner'), 'name' => 'blockbanner', - 'desc' => ''.$this->l('Configure').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('blockbanner')) && $module->active), 'is_module' => true, ), array( 'label' => $this->l('Enable product payment logos'), 'name' => 'productpaymentlogos', - 'desc' => ''.$this->l('Configure').'', 'value' => (int)(Validate::isLoadedObject($module = Module::getInstanceByName('productpaymentlogos')) && $module->active), 'is_module' => true, ) @@ -213,5 +593,5 @@ class ThemeConfigurator extends Module $values[$module['name']] = $module['value']; return $values; - } -} + } +} \ No newline at end of file diff --git a/modules/tmhtmlcontent/views/css/admin.css b/modules/themeconfigurator/views/css/admin.css similarity index 100% rename from modules/tmhtmlcontent/views/css/admin.css rename to modules/themeconfigurator/views/css/admin.css diff --git a/modules/tmhtmlcontent/views/css/font/FontAwesome.otf b/modules/themeconfigurator/views/css/font/FontAwesome.otf similarity index 100% rename from modules/tmhtmlcontent/views/css/font/FontAwesome.otf rename to modules/themeconfigurator/views/css/font/FontAwesome.otf diff --git a/modules/tmhtmlcontent/views/css/font/font.css b/modules/themeconfigurator/views/css/font/font.css similarity index 100% rename from modules/tmhtmlcontent/views/css/font/font.css rename to modules/themeconfigurator/views/css/font/font.css diff --git a/modules/tmhtmlcontent/views/css/font/fontawesome-webfont.eot b/modules/themeconfigurator/views/css/font/fontawesome-webfont.eot similarity index 100% rename from modules/tmhtmlcontent/views/css/font/fontawesome-webfont.eot rename to modules/themeconfigurator/views/css/font/fontawesome-webfont.eot diff --git a/modules/tmhtmlcontent/views/css/font/fontawesome-webfont.svg b/modules/themeconfigurator/views/css/font/fontawesome-webfont.svg similarity index 100% rename from modules/tmhtmlcontent/views/css/font/fontawesome-webfont.svg rename to modules/themeconfigurator/views/css/font/fontawesome-webfont.svg diff --git a/modules/tmhtmlcontent/views/css/font/fontawesome-webfont.ttf b/modules/themeconfigurator/views/css/font/fontawesome-webfont.ttf similarity index 100% rename from modules/tmhtmlcontent/views/css/font/fontawesome-webfont.ttf rename to modules/themeconfigurator/views/css/font/fontawesome-webfont.ttf diff --git a/modules/tmhtmlcontent/views/css/font/fontawesome-webfont.woff b/modules/themeconfigurator/views/css/font/fontawesome-webfont.woff similarity index 100% rename from modules/tmhtmlcontent/views/css/font/fontawesome-webfont.woff rename to modules/themeconfigurator/views/css/font/fontawesome-webfont.woff diff --git a/modules/tmhtmlcontent/views/css/font/museo_slab_300-webfont.eot b/modules/themeconfigurator/views/css/font/museo_slab_300-webfont.eot similarity index 100% rename from modules/tmhtmlcontent/views/css/font/museo_slab_300-webfont.eot rename to modules/themeconfigurator/views/css/font/museo_slab_300-webfont.eot diff --git a/modules/tmhtmlcontent/views/css/font/museo_slab_300-webfont.ttf b/modules/themeconfigurator/views/css/font/museo_slab_300-webfont.ttf similarity index 100% rename from modules/tmhtmlcontent/views/css/font/museo_slab_300-webfont.ttf rename to modules/themeconfigurator/views/css/font/museo_slab_300-webfont.ttf diff --git a/modules/tmhtmlcontent/views/css/font/museo_slab_500-webfont.eot b/modules/themeconfigurator/views/css/font/museo_slab_500-webfont.eot similarity index 100% rename from modules/tmhtmlcontent/views/css/font/museo_slab_500-webfont.eot rename to modules/themeconfigurator/views/css/font/museo_slab_500-webfont.eot diff --git a/modules/tmhtmlcontent/views/css/font/museo_slab_500-webfont.ttf b/modules/themeconfigurator/views/css/font/museo_slab_500-webfont.ttf similarity index 100% rename from modules/tmhtmlcontent/views/css/font/museo_slab_500-webfont.ttf rename to modules/themeconfigurator/views/css/font/museo_slab_500-webfont.ttf diff --git a/modules/tmhtmlcontent/views/css/font/proximanova-sbold-webfont.eot b/modules/themeconfigurator/views/css/font/proximanova-sbold-webfont.eot similarity index 100% rename from modules/tmhtmlcontent/views/css/font/proximanova-sbold-webfont.eot rename to modules/themeconfigurator/views/css/font/proximanova-sbold-webfont.eot diff --git a/modules/tmhtmlcontent/views/css/font/proximanova-sbold-webfont.ttf b/modules/themeconfigurator/views/css/font/proximanova-sbold-webfont.ttf similarity index 100% rename from modules/tmhtmlcontent/views/css/font/proximanova-sbold-webfont.ttf rename to modules/themeconfigurator/views/css/font/proximanova-sbold-webfont.ttf diff --git a/modules/tmhtmlcontent/views/css/font/proximanova-webfont.eot b/modules/themeconfigurator/views/css/font/proximanova-webfont.eot similarity index 100% rename from modules/tmhtmlcontent/views/css/font/proximanova-webfont.eot rename to modules/themeconfigurator/views/css/font/proximanova-webfont.eot diff --git a/modules/tmhtmlcontent/views/css/font/proximanova-webfont.ttf b/modules/themeconfigurator/views/css/font/proximanova-webfont.ttf similarity index 100% rename from modules/tmhtmlcontent/views/css/font/proximanova-webfont.ttf rename to modules/themeconfigurator/views/css/font/proximanova-webfont.ttf diff --git a/modules/tmhtmlcontent/views/css/hooks.css b/modules/themeconfigurator/views/css/hooks.css similarity index 100% rename from modules/tmhtmlcontent/views/css/hooks.css rename to modules/themeconfigurator/views/css/hooks.css diff --git a/modules/tmhtmlcontent/views/js/admin.js b/modules/themeconfigurator/views/js/admin.js similarity index 100% rename from modules/tmhtmlcontent/views/js/admin.js rename to modules/themeconfigurator/views/js/admin.js diff --git a/modules/tmhtmlcontent/translations/index.php b/modules/themeconfigurator/views/js/index.php similarity index 100% rename from modules/tmhtmlcontent/translations/index.php rename to modules/themeconfigurator/views/js/index.php diff --git a/modules/tmhtmlcontent/views/templates/admin/admin.tpl b/modules/themeconfigurator/views/templates/admin/admin.tpl similarity index 84% rename from modules/tmhtmlcontent/views/templates/admin/admin.tpl rename to modules/themeconfigurator/views/templates/admin/admin.tpl index 5779a4a57..a57abe9e5 100644 --- a/modules/tmhtmlcontent/views/templates/admin/admin.tpl +++ b/modules/themeconfigurator/views/templates/admin/admin.tpl @@ -1,16 +1,13 @@

    {$htmlcontent.info.name} (v.{$htmlcontent.info.version})

    - - {if $error} + {if isset($error) && $error} {include file="{$htmlcontent.admin_tpl_path}messages.tpl" id="main" text=$error class='error'} {/if} - {if $confirmation} + {if isset($confirmation) && $confirmation} {include file="{$htmlcontent.admin_tpl_path}messages.tpl" id="main" text=$confirmation class='conf'} {/if} - {include file="{$htmlcontent.admin_tpl_path}new.tpl"} {include file="{$htmlcontent.admin_tpl_path}items.tpl"} - -
    \ No newline at end of file +
    diff --git a/modules/tmhtmlcontent/views/index.php b/modules/themeconfigurator/views/templates/admin/index.php similarity index 100% rename from modules/tmhtmlcontent/views/index.php rename to modules/themeconfigurator/views/templates/admin/index.php diff --git a/modules/tmhtmlcontent/views/templates/admin/items.tpl b/modules/themeconfigurator/views/templates/admin/items.tpl similarity index 88% rename from modules/tmhtmlcontent/views/templates/admin/items.tpl rename to modules/themeconfigurator/views/templates/admin/items.tpl index da603ab09..8cd6e246f 100644 --- a/modules/tmhtmlcontent/views/templates/admin/items.tpl +++ b/modules/themeconfigurator/views/templates/admin/items.tpl @@ -9,7 +9,7 @@
    {foreach name=hooks from=$langItems key=hook item=hookItems} -

    {l s='Hook' mod='tmhtmlcontent'} "{$hook}"

    +

    {l s='Hook' mod='themeconfigurator'} "{$hook}"

    {if $hookItems}
      {foreach name=items from=$hookItems item=hItem} @@ -17,37 +17,37 @@ {if $hItem.item_order le 9}0{/if}{$hItem.item_order} {$hItem.title} - {l s='Edit' mod='tmhtmlcontent'} - {l s='Close' mod='tmhtmlcontent'} + {l s='Edit' mod='themeconfigurator'} + {l s='Close' mod='themeconfigurator'}
      - +
      - +
      - +
      - +
      - +
      - +
      - +
      - +
      - +
      - +
      - - + +
      @@ -107,7 +107,7 @@
    {else}
    - {l s='No items available' mod='tmhtmlcontent'} + {l s='No items available' mod='themeconfigurator'}
    {/if} {/foreach} diff --git a/modules/tmhtmlcontent/views/templates/admin/messages.tpl b/modules/themeconfigurator/views/templates/admin/messages.tpl similarity index 100% rename from modules/tmhtmlcontent/views/templates/admin/messages.tpl rename to modules/themeconfigurator/views/templates/admin/messages.tpl diff --git a/modules/tmhtmlcontent/views/templates/admin/new.tpl b/modules/themeconfigurator/views/templates/admin/new.tpl similarity index 88% rename from modules/tmhtmlcontent/views/templates/admin/new.tpl rename to modules/themeconfigurator/views/templates/admin/new.tpl index 40e2a1c69..4d7c13e2d 100644 --- a/modules/tmhtmlcontent/views/templates/admin/new.tpl +++ b/modules/themeconfigurator/views/templates/admin/new.tpl @@ -1,12 +1,12 @@
    - {l s='Add item' mod='tmhtmlcontent'} + {l s='Add item' mod='themeconfigurator'}
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    - +
    diff --git a/modules/tmhtmlcontent/views/templates/hooks/home.tpl b/modules/themeconfigurator/views/templates/hooks/hook.tpl similarity index 86% rename from modules/tmhtmlcontent/views/templates/hooks/home.tpl rename to modules/themeconfigurator/views/templates/hooks/hook.tpl index 285b07aea..cf76d7e05 100644 --- a/modules/tmhtmlcontent/views/templates/hooks/home.tpl +++ b/modules/themeconfigurator/views/templates/hooks/hook.tpl @@ -1,7 +1,7 @@ -{if isset($htmlitems.items) && $htmlitems.items} -
    +{if isset($htmlitems) && $htmlitems} +
    -{/if} diff --git a/modules/tmhtmlcontent/views/templates/hooks/left.tpl b/modules/tmhtmlcontent/views/templates/hooks/left.tpl deleted file mode 100644 index afc5afbb6..000000000 --- a/modules/tmhtmlcontent/views/templates/hooks/left.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{if isset($htmlitems.items) && $htmlitems.items} - -{/if} \ No newline at end of file diff --git a/modules/tmhtmlcontent/views/templates/hooks/right.tpl b/modules/tmhtmlcontent/views/templates/hooks/right.tpl deleted file mode 100644 index 6fe8b6c57..000000000 --- a/modules/tmhtmlcontent/views/templates/hooks/right.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{if isset($htmlitems.items) && $htmlitems.items} - -{/if} \ No newline at end of file diff --git a/modules/tmhtmlcontent/views/templates/hooks/top.tpl b/modules/tmhtmlcontent/views/templates/hooks/top.tpl deleted file mode 100644 index e9f9f958c..000000000 --- a/modules/tmhtmlcontent/views/templates/hooks/top.tpl +++ /dev/null @@ -1,27 +0,0 @@ -{if isset($htmlitems.items) && $htmlitems.items} - -{/if} \ No newline at end of file diff --git a/modules/tmhtmlcontent/views/templates/index.php b/modules/tmhtmlcontent/views/templates/index.php deleted file mode 100644 index 198b35f62..000000000 --- a/modules/tmhtmlcontent/views/templates/index.php +++ /dev/null @@ -1,10 +0,0 @@ - Date: Mon, 18 Nov 2013 12:12:14 +0100 Subject: [PATCH 7/8] // Installer optimization --- install-dev/classes/controllerHttp.php | 5 +++- install-dev/theme/js/configure.js | 24 ++++++++++++++++++ install-dev/theme/js/database.js | 24 ++++++++++++++++++ install-dev/theme/js/install.js | 24 ++++++++++++++++++ install-dev/theme/js/license.js | 24 ++++++++++++++++++ install-dev/theme/js/process.js | 24 ++++++++++++++++++ install-dev/theme/js/welcome.js | 35 ++++++++++++++++++++------ 7 files changed, 151 insertions(+), 9 deletions(-) diff --git a/install-dev/classes/controllerHttp.php b/install-dev/classes/controllerHttp.php index 8a83a4526..53bc10f39 100644 --- a/install-dev/classes/controllerHttp.php +++ b/install-dev/classes/controllerHttp.php @@ -321,13 +321,16 @@ abstract class InstallControllerHttp */ public function getPhone() { + if (InstallSession::getInstance()->support_phone != null) + return InstallSession::getInstance()->support_phone; if ($this->phone === null) { $this->phone = $this->language->getInformation('phone', false); - if ($iframe = Tools::file_get_contents('http://api.prestashop.com/iframe/install.php?lang='.$this->language->getLanguageIso())) + if ($iframe = Tools::file_get_contents('http://api.prestashop.com/iframe/install.php?lang='.$this->language->getLanguageIso(), false, null, 3)) if (preg_match('//Ui', $iframe, $matches) && isset($matches[1])) $this->phone = $matches[1]; } + InstallSession::getInstance()->support_phone = $this->phone; return $this->phone; } diff --git a/install-dev/theme/js/configure.js b/install-dev/theme/js/configure.js index 98a647702..77b83ba14 100644 --- a/install-dev/theme/js/configure.js +++ b/install-dev/theme/js/configure.js @@ -1,3 +1,27 @@ +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/osl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + $(document).ready(function() { // Change logo diff --git a/install-dev/theme/js/database.js b/install-dev/theme/js/database.js index f19e8f651..25aa056c4 100644 --- a/install-dev/theme/js/database.js +++ b/install-dev/theme/js/database.js @@ -1,3 +1,27 @@ +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/osl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + $(document).ready(function() { // Check database configuration diff --git a/install-dev/theme/js/install.js b/install-dev/theme/js/install.js index e5d753eb2..1ea1114d8 100644 --- a/install-dev/theme/js/install.js +++ b/install-dev/theme/js/install.js @@ -1,3 +1,27 @@ +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/osl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + $(document).ready(function() { $('#mainForm').submit(function() diff --git a/install-dev/theme/js/license.js b/install-dev/theme/js/license.js index 74371fa93..dc0b2e81c 100644 --- a/install-dev/theme/js/license.js +++ b/install-dev/theme/js/license.js @@ -1,3 +1,27 @@ +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/osl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + $(document).ready(function() { // Desactivate next button if licence checkbox is not checked diff --git a/install-dev/theme/js/process.js b/install-dev/theme/js/process.js index 22d66d9c4..6e523dcfc 100644 --- a/install-dev/theme/js/process.js +++ b/install-dev/theme/js/process.js @@ -1,3 +1,27 @@ +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/osl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + var is_installing = false; $(document).ready(function() { diff --git a/install-dev/theme/js/welcome.js b/install-dev/theme/js/welcome.js index 48cc69dfa..90976346b 100644 --- a/install-dev/theme/js/welcome.js +++ b/install-dev/theme/js/welcome.js @@ -1,10 +1,29 @@ -$(document).ready(function() -{ - // Submit change of language - $('#langList').change(function() - { - var form = $('#mainForm'); - form.attr('action', form.attr('action')+'#licenses-agreement'); - form.submit(); +/* +* +* NOTICE OF LICENSE +* +* This source file is subject to the Open Software License (OSL 3.0) +* that is bundled with this package in the file LICENSE.txt. +* It is also available through the world-wide-web at this URL: +* http://opensource.org/licenses/osl-3.0.php +* If you did not receive a copy of the license and are unable to +* obtain it through the world-wide-web, please send an email +* to license@prestashop.com so we can send you a copy immediately. +* +* DISCLAIMER +* +* Do not edit or add to this file if you wish to upgrade PrestaShop to newer +* versions in the future. If you wish to customize PrestaShop for your +* needs please refer to http://www.prestashop.com for more information. +* +* @author PrestaShop SA +* @copyright 2007-2013 PrestaShop SA +* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) +* International Registered Trademark & Property of PrestaShop SA +*/ + +$(document).ready(function() { + $('#langList').change(function() { + $('#mainForm').submit(); }); }); \ No newline at end of file From 89c65536d72c68664bae6d509bc5f1ef5d61037f Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Mon, 18 Nov 2013 12:23:50 +0100 Subject: [PATCH 8/8] // Added missing configuration vars in the installer --- install-dev/data/xml/configuration.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/install-dev/data/xml/configuration.xml b/install-dev/data/xml/configuration.xml index 57ae25ae3..4e8fd7658 100644 --- a/install-dev/data/xml/configuration.xml +++ b/install-dev/data/xml/configuration.xml @@ -781,5 +781,11 @@ Country - + + 40 + + + 1 +