root / htmltest / sites / all / libraries / superfish-version / sftouchscreen.js @ 4543c6c7
1 |
/*
|
---|---|
2 |
* sf-Touchscreen v1.0b - Provides touchscreen compatibility for the jQuery Superfish plugin. - LAST UPDATE: MARCH 23rd, 2011
|
3 |
*
|
4 |
* Developer's notes:
|
5 |
* Built as a part of the Superfish project for Drupal (http://drupal.org/project/superfish)
|
6 |
* Found any bug? have any cool ideas? contact me right away! http://drupal.org/user/619294/contact
|
7 |
*
|
8 |
* jQuery version: 1.3.x or higher.
|
9 |
*
|
10 |
* Dual licensed under the MIT and GPL licenses:
|
11 |
* http://www.opensource.org/licenses/mit-license.php
|
12 |
* http://www.gnu.org/licenses/gpl.html
|
13 |
*/
|
14 |
|
15 |
(function($){ |
16 |
$.fn.sftouchscreen = function() { |
17 |
// Return original object to support chaining.
|
18 |
return this.each( function() { |
19 |
// Select hyperlinks from parent menu items.
|
20 |
$(this).find('li > ul').closest('li').children('a').each( function() { |
21 |
var $item = $(this); |
22 |
// No .toggle() here as it's not possible to reset it.
|
23 |
$item.click( function(event){ |
24 |
// Already clicked? proceed to the URI.
|
25 |
if ($item.hasClass('sf-clicked')) { |
26 |
var $uri = $item.attr('href'); |
27 |
window.location = $uri;
|
28 |
} |
29 |
else {
|
30 |
event.preventDefault(); |
31 |
$item.addClass('sf-clicked'); |
32 |
} |
33 |
}).closest('li').mouseleave( function(){ |
34 |
// So, we reset everything.
|
35 |
$item.removeClass('sf-clicked'); |
36 |
}); |
37 |
}); |
38 |
}); |
39 |
}; |
40 |
})(jQuery); |