Skip to content

Commit

Permalink
Move inline script to menu.js
Browse files Browse the repository at this point in the history
  • Loading branch information
joomlart committed Feb 2, 2013
1 parent eef13b3 commit 3603e2c
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
32 changes: 32 additions & 0 deletions source/plg_system_t3/base/js/menu.js
Original file line number Diff line number Diff line change
@@ -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);
6 changes: 6 additions & 0 deletions source/plg_system_t3/includes/core/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
17 changes: 0 additions & 17 deletions source/tpl_t3_blank/tpls/blocks/mainnav.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,4 @@
</div>
</div>
</nav>

<?php if ($this->getParam ('navigation_trigger') == 'hover') :?>
<script type="text/javascript">
jQuery(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));
});
});
</script>
<?php endif ?>
<!-- //MAIN NAVIGATION -->

0 comments on commit 3603e2c

Please sign in to comment.