File tree 1 file changed +20
-2
lines changed
1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change 686
686
if ( $ && $ . fn && $ . fn . tap ) eventName = "tap" ;
687
687
688
688
if ( this . captureLink == true ) {
689
- document . addEventListener ( eventName , this . handleTapEvent ) ;
689
+ document . addEventListener ( eventName , this . handleTapEvent , true ) ;
690
+ if ( eventName == "tap" ) {
691
+ // zepto tap event.preventDefault can't prevent default click-events
692
+ document . addEventListener ( "click" , function ( event ) {
693
+ var target = event . target ;
694
+ if ( ! target ) return ;
695
+ if ( target . tagName . toLowerCase ( ) != "a" && ! ( target = target . getParentElementByTag ( "a" ) ) ) {
696
+ return ;
697
+ }
698
+ var ajax = target . getAttribute ( "data-ajax" ) , href = target . href ;
699
+ // if not ajax request
700
+ if ( target . getAttribute ( "data-rel" ) == "external"
701
+ || ajax == "false"
702
+ || ( href . split ( "/" ) [ 0 ] !== location . href . split ( "/" ) [ 0 ] && ajax != "true" )
703
+ || ( Mobilebone . captureLink == false && ajax != "true" )
704
+ ) return ;
705
+
706
+ event . preventDefault ( ) ;
707
+ } ) ;
708
+ }
690
709
}
691
710
// change flag-var for avoiding repeat init
692
711
hasInited = true ;
698
717
Mobilebone . handleTapEvent = function ( event ) {
699
718
// get target and href
700
719
var target = event . target || event . touches [ 0 ] , href = target . href ;
701
-
702
720
if ( ( ! href || / a / i. test ( target . tagName ) == false ) && ( target = target . getParentElementByTag ( "a" ) ) ) {
703
721
href = target . href ;
704
722
}
You can’t perform that action at this time.
0 commit comments