Skip to content

Commit

Permalink
Item13272: upgraded superfish and hoverintent
Browse files Browse the repository at this point in the history
also: deprecated supersubs
  • Loading branch information
MichaelDaum committed Feb 23, 2015
1 parent add5167 commit 4e2a91e
Show file tree
Hide file tree
Showing 13 changed files with 274 additions and 215 deletions.
2 changes: 2 additions & 0 deletions JQueryPlugin/.gitignore
Expand Up @@ -109,10 +109,12 @@ pub/System/JQueryPlugin/plugins/slimbox/slimbox2.init.js
pub/System/JQueryPlugin/plugins/slimbox/slimbox2.js
pub/System/JQueryPlugin/plugins/sprintf/git/
pub/System/JQueryPlugin/plugins/sprintf/sprintf.js
pub/System/JQueryPlugin/plugins/superfish/git/
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-navbar.css
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-vertical.css
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish.css
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish.js
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-megafish.css
pub/System/JQueryPlugin/plugins/supersubs/jquery.supersubs.js
pub/System/JQueryPlugin/plugins/tabpane/jquery.tabpane.css
pub/System/JQueryPlugin/plugins/tabpane/jquery.tabpane.js
Expand Down
118 changes: 3 additions & 115 deletions JQueryPlugin/data/System/JQuerySuperfish.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1393328760" format="1.1" reprev="2" version="2"}%
%META:TOPICINFO{author="ProjectContributor" comment="reprev" date="1424695107" format="1.1" reprev="2" version="1"}%
%META:TOPICPARENT{name="JQueryPlugin"}%
---+ %TOPIC%
%JQPLUGINS{"superfish"
Expand All @@ -22,12 +22,9 @@ Features:
* drop shadows for capable browsers ? degrades gracefully for Internet Explorer 6. Can disable shadows completely via options object.
* Can show the path to your current page while the menu is idle. The easiest way to understand this is to view the nav-bar example.
* Optional callback functions. The 'this' keyword within the handlers you attach will refer to the animated ul sub-menu. From version 1.4 there are now three other optional callbacks allowing for further enhancements and functionality to be added without needing to alter the core Superfish code.
* See supersubs companion Javascript to automatically resize menus to fit their contents.
%ENDSECTION{"summary"}%

---++ Examples
%JQREQUIRE{"supersubs"}%

%ADDTOZONE{"head"
id="SUPERFISH::DEMO"
text="<link rel='stylesheet' href='%PUBURLPATH%/%SYSTEMWEB%/JQueryPlugin/plugins/superfish/jquery.superfish.css' type='text/css'/>
Expand All @@ -37,7 +34,7 @@ Features:
%ADDTOZONE{"script"
id="SUPERFISH::DEMO"
text="<script type='text/javascript' src='%ATTACHURLPATH%/example.js'></script>"
requires="JQUERYPLUGIN::SUPERFISH,JQUERYPLUGIN::SUPERSUBS"
requires="JQUERYPLUGIN::SUPERFISH"
}%

---+++ Using <nop>TreePlugin
Expand Down Expand Up @@ -338,118 +335,9 @@ Requires Foswiki:Extensions.TreePlugin
</ul>
%CLEAR%

---++++ Supersubs

<blockquote>
This menu uses the optional Supersubs plugin (currently beta) to make the sub-menu widths variable. The fixed width set in the CSS is overridden and all menu items within a sub-menu are altered to match the width of their widest sibling. This is most commonly used to make all menu items fit on one line so that they are all of equal height.

Note that Supersubs needs to be called before Superfish in the initialisation chain...</blockquote>

<ul id="sample-menu-5" class="sf-menu">
<li class="current">
<a href="#a">menu item</a>
<ul>
<li>
<a href="#aa">menu item that is quite long</a>
</li>
<li class="current">
<a href="#ab">menu item</a>
<ul>
<li class="current"><a href="#">menu item that is even longer still!</a></li>
<li><a href="#aba">menu item</a></li>
<li><a href="#abb">menu item</a></li>
<li><a href="#abc">menu item</a></li>
<li><a href="#abd">menu item</a></li>
</ul>
</li>
<li>
<a href="#">menu item</a>
<ul>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
</ul>
</li>
<li>
<a href="#">menu item</a>
<ul>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#">menu item</a>
</li>
<li>
<a href="#">menu item</a>
<ul>
<li>
<a href="#">menu item</a>
<ul>
<li><a href="#">short</a></li>
<li><a href="#">short</a></li>
<li><a href="#">short</a></li>
<li><a href="#">short</a></li>
<li><a href="#">short</a></li>
</ul>
</li>
<li>
<a href="#">menu item</a>
<ul>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
</ul>
</li>
<li>
<a href="#">menu item</a>
<ul>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
</ul>
</li>
<li>
<a href="#">menu item</a>
<ul>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
</ul>
</li>
<li>
<a href="#">menu item</a>
<ul>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
<li><a href="#">menu item</a></li>
</ul>
</li>
</ul>
</li>
<li>
<a href="#">menu item</a>
</li>
</ul>
%CLEAR%

<!--
* Set NOWYSIWYG = 1
-->

%META:FILEATTACHMENT{name="example.js" attachment="example.js" attr="" comment="" date="1257681912" path="example.js" size="250" user="ProjectContributor" version="1"}%
%META:FILEATTACHMENT{name="example.js" attachment="example.js" attr="" comment="" date="1424695107" path="example.js" size="250" user="ProjectContributor" version="1"}%
@@ -0,0 +1,41 @@
# See bottom of file for license and copyright information
package Foswiki::Configure::Checkers::JQueryPlugin::Plugins::Supersub::Enabled;

use warnings;
use strict;

use Foswiki::Configure::Checker ();
our @ISA = qw( Foswiki::Configure::Checker );

sub check {
my $this = shift;
my $warnings;

if ( $Foswiki::cfg{JQueryPlugin}{Plugins}{Supersub}{Enabled} ) {
$warnings .= $this->WARN(<<'HERE');
Supersub has been deprecated. The latest Superfish supersedes it.
HERE
}

return $warnings;
}

1;
__END__
Foswiki - The Free and Open Source Wiki, http://foswiki.org/
Copyright (C) 2008-2015 Foswiki Contributors. Foswiki Contributors
are listed in the AUTHORS file in the root of this distribution.
NOTE: Please extend that file, not this notice.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version. For
more details read LICENSE in the root of this distribution.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
As per the GPL, removal of this notice is prohibited.
7 changes: 4 additions & 3 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/Config.spec
Expand Up @@ -175,9 +175,6 @@ $Foswiki::cfg{JQueryPlugin}{Plugins}{Stars}{Enabled} = 1;
# **BOOLEAN LABEL="Superfish"**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Superfish}{Enabled} = 1;

# **BOOLEAN LABEL="Supersubs"**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Supersubs}{Enabled} = 1;

# **BOOLEAN LABEL="Tabpane"**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Tabpane}{Enabled} = 1;

Expand Down Expand Up @@ -261,6 +258,10 @@ $Foswiki::cfg{JQueryPlugin}{Plugins}{Shake}{Enabled} = 0;
# Warning: This plugin is deprecated. Please use ui::dialog, the jquery-ui dialog widget.
$Foswiki::cfg{JQueryPlugin}{Plugins}{SimpleModal}{Enabled} = 0;

# **BOOLEAN LABEL="Supersubs"**
# Warning: This plugin is deprecated. The latest superfish module supersedes it.
$Foswiki::cfg{JQueryPlugin}{Plugins}{Supersubs}{Enabled} = 0;

# **BOOLEAN LABEL="Tmpl" EXPERT**
# Warning: This plugin is deprecated. Please use jsrender.
$Foswiki::cfg{JQueryPlugin}{Plugins}{Tmpl}{Enabled} = 0;
Expand Down
4 changes: 2 additions & 2 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/HOVERINTENT.pm
Expand Up @@ -28,10 +28,10 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'hoverIntent',
version => 'r7',
version => '1.8.0',
author => 'Brian Cherne',
homepage =>
'http://cherne.net/brian/resources/jquery.hoverIntent.htm',
'http://cherne.net/brian/resources/jquery.hoverIntent.html',
javascript => ['jquery.hoverIntent.js'],
),
$class
Expand Down
4 changes: 4 additions & 0 deletions JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/MANIFEST
Expand Up @@ -75,6 +75,7 @@ lib/Foswiki/Configure/Checkers/JQueryPlugin/Plugins/Nifty/Enabled.pm 0644
lib/Foswiki/Configure/Checkers/JQueryPlugin/Plugins/Rating/Enabled.pm 0644
lib/Foswiki/Configure/Checkers/JQueryPlugin/Plugins/Shake/Enabled.pm 0644
lib/Foswiki/Configure/Checkers/JQueryPlugin/Plugins/SimpleModal/Enabled.pm 0644
lib/Foswiki/Configure/Checkers/JQueryPlugin/Plugins/Supersub/Enabled.pm 0644
lib/Foswiki/Configure/Checkers/JQueryPlugin/Plugins/Tmpl/Enabled.pm 0644
lib/Foswiki/Configure/Checkers/JQueryPlugin/Plugins/Tooltip/Enabled.pm 0644
lib/Foswiki/Form/Color.pm 0644
Expand Down Expand Up @@ -640,6 +641,9 @@ pub/System/JQueryPlugin/plugins/superfish/jquery.superfish.uncompressed.js 0644
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-vertical.css 0644
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-vertical.css.gz 0644
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-vertical.uncompressed.css 0644
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-megafish.css 0644
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-megafish.css.gz 0644
pub/System/JQueryPlugin/plugins/superfish/jquery.superfish-megafish.uncompressed.css 0644
pub/System/JQueryPlugin/plugins/superfish/Makefile 0644
pub/System/JQueryPlugin/plugins/supersubs/jquery.supersubs.js 0644
pub/System/JQueryPlugin/plugins/supersubs/jquery.supersubs.js.gz 0644
Expand Down
3 changes: 2 additions & 1 deletion JQueryPlugin/lib/Foswiki/Plugins/JQueryPlugin/SUPERFISH.pm
Expand Up @@ -27,10 +27,11 @@ sub new {
my $this = bless(
$class->SUPER::new(
name => 'Superfish',
version => '1.7.2',
version => '1.7.5',
author => 'Joel Birch',
homepage => 'http://users.tpg.com.au/j_birch/plugins/superfish/',
javascript => ['jquery.superfish.js'],
css => ['jquery.superfish.css'],
dependencies => ['hoverintent'],
),
$class
Expand Down
@@ -1,16 +1,17 @@
/**
* 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+
/*!
* hoverIntent v1.8.0 // 2014.06.29 // jQuery v1.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
* Copyright 2007, 2014 Brian Cherne
*/

/* 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.
*
* // basic usage ... just like .hover()
* .hoverIntent( handlerIn, handlerOut )
Expand All @@ -27,14 +28,14 @@
* @param handlerOut function OR selector for delegation OR undefined
* @param selector selector OR undefined
* @author Brian Cherne <brian(at)cherne(dot)net>
**/
*/
(function($) {
$.fn.hoverIntent = function(handlerIn,handlerOut,selector) {

// default configuration values
var cfg = {
interval: 100,
sensitivity: 7,
sensitivity: 6,
timeout: 0
};

Expand All @@ -61,10 +62,10 @@
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 ) {
if ( Math.sqrt( (pX-cX)*(pX-cX) + (pY-cY)*(pY-cY) ) < cfg.sensitivity ) {
$(ob).off("mousemove.hoverIntent",track);
// set hoverIntent state to true (so mouseOut can be called)
ob.hoverIntent_s = 1;
ob.hoverIntent_s = true;
return cfg.over.apply(ob,[ev]);
} else {
// set previous coordinates for next time
Expand All @@ -77,38 +78,38 @@
// A private function for delaying the mouseOut function
var delay = function(ev,ob) {
ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
ob.hoverIntent_s = 0;
ob.hoverIntent_s = false;
return cfg.out.apply(ob,[ev]);
};

// 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 ev = $.extend({},e);
var ob = this;

// cancel hoverIntent timer if it exists
if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

// if e.type == "mouseenter"
if (e.type == "mouseenter") {
// 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 );}
if (!ob.hoverIntent_s) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

// 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 );}
if (ob.hoverIntent_s) { 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);
})(jQuery);

0 comments on commit 4e2a91e

Please sign in to comment.