From 3603e2cf655aa27d10c6f3e8866f30400bdfeedf Mon Sep 17 00:00:00 2001 From: joomlart Date: Sat, 2 Feb 2013 15:24:04 +0700 Subject: [PATCH] Move inline script to menu.js --- source/plg_system_t3/base/js/menu.js | 32 +++++++++++++++++++ .../plg_system_t3/includes/core/template.php | 6 ++++ source/tpl_t3_blank/tpls/blocks/mainnav.php | 17 ---------- 3 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 source/plg_system_t3/base/js/menu.js diff --git a/source/plg_system_t3/base/js/menu.js b/source/plg_system_t3/base/js/menu.js new file mode 100644 index 0000000000..43b5b5f378 --- /dev/null +++ b/source/plg_system_t3/base/js/menu.js @@ -0,0 +1,32 @@ +/** + *------------------------------------------------------------------------------ + * @package T3 Framework for Joomla! + *------------------------------------------------------------------------------ + * @copyright Copyright (C) 2004-2013 JoomlArt.com. All Rights Reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + * @authors JoomlArt, JoomlaBamboo, (contribute to this project at github + * & Google group to become co-author) + * @Google group: https://groups.google.com/forum/#!forum/t3fw + * @Link: https://github.com/t3framework/ + *------------------------------------------------------------------------------ + */ + +!function($){ + var isTouch = 'ontouchstart' in window && !(/hp-tablet/gi).test(navigator.appVersion); + + if(!isTouch{ + $(document).ready(function($){ + $('.nav > li').hover(function(event) { + var $this = $(this); + clearTimeout ($this.data('hoverTimeout')); + $this.addClass ('open'); + }, + function(event) { + var $this = $(this); + $this.data('hoverTimeout', + setTimeout(function(){$this.removeClass ('open')}, 100)); + }); + }); + } + +}(jQuery); \ No newline at end of file diff --git a/source/plg_system_t3/includes/core/template.php b/source/plg_system_t3/includes/core/template.php index 2d32704ddb..c675f96600 100644 --- a/source/plg_system_t3/includes/core/template.php +++ b/source/plg_system_t3/includes/core/template.php @@ -470,6 +470,12 @@ function addHead () { $this->addScript (T3_URL.'/js/touch.js'); $this->addScript (T3_URL.'/js/script.js'); + //menu control script + if ($this->getParam ('navigation_trigger') == 'hover'){ + $this->addScript (T3_URL.'/js/menu.js'); + } + + //reponsive script if ($responsive) { $this->addScript (T3_URL.'/js/responsive.js'); } diff --git a/source/tpl_t3_blank/tpls/blocks/mainnav.php b/source/tpl_t3_blank/tpls/blocks/mainnav.php index 6d12a8c23a..347c1ce938 100644 --- a/source/tpl_t3_blank/tpls/blocks/mainnav.php +++ b/source/tpl_t3_blank/tpls/blocks/mainnav.php @@ -29,21 +29,4 @@ - -getParam ('navigation_trigger') == 'hover') :?> - - \ No newline at end of file