|
43 | 43 | *
|
44 | 44 | * @type string
|
45 | 45 | **/
|
46 |
| - Mobilebone.VERSION = '2.5.2'; |
| 46 | + Mobilebone.VERSION = '2.5.3'; |
47 | 47 |
|
48 | 48 | /**
|
49 | 49 | * Whether catch attribute of href from element with tag 'a'
|
|
944 | 944 | var eventName = "click", $ = root.$ || root.jQuery || root.Zepto;
|
945 | 945 | if ($ && $.fn && $.fn.tap && ('ontouchstart' in window == true)) eventName = "tap";
|
946 | 946 |
|
947 |
| - if (this.captureLink == true) { |
948 |
| - if ($ && $.fn && $.fn.on) { |
949 |
| - // for some unknown 'tap' plugin |
950 |
| - $(document).on(eventName, this.handleTapEvent); |
951 |
| - } else { |
952 |
| - document.addEventListener(eventName, this.handleTapEvent); |
953 |
| - } |
954 |
| - if (eventName == "tap") { |
955 |
| - // zepto tap event.preventDefault can't prevent default click-events |
956 |
| - document.addEventListener("click", function(event) { |
957 |
| - var target = event.target; |
958 |
| - if (!target) return; |
959 |
| - if (target.tagName.toLowerCase() != "a" && !(target = target.getParentElementByTag("a"))) { |
960 |
| - return; |
961 |
| - } |
962 |
| - var ajax = target.getAttribute("data-ajax"), href = target.href; |
963 |
| - // if not ajax request |
964 |
| - if (target.getAttribute("data-rel") == "external" |
965 |
| - || ajax == "false" |
966 |
| - || (href.replace("://", "").split("/")[0] !== location.href.replace("://", "").split("/")[0] && ajax != "true") |
967 |
| - ) return; |
968 |
| - event.preventDefault(); |
969 |
| - }); |
970 |
| - } |
| 947 | + if ($ && $.fn && $.fn.on) { |
| 948 | + // for some unknown 'tap' plugin |
| 949 | + $(document).on(eventName, this.handleTapEvent); |
| 950 | + } else { |
| 951 | + document.addEventListener(eventName, this.handleTapEvent); |
| 952 | + } |
| 953 | + |
| 954 | + if (eventName == "tap") { |
| 955 | + // zepto tap event.preventDefault can't prevent default click-events |
| 956 | + document.addEventListener("click", function(event) { |
| 957 | + var target = event.target; |
| 958 | + if (!target) return; |
| 959 | + if (target.tagName.toLowerCase() != "a" && !(target = target.getParentElementByTag("a"))) { |
| 960 | + return; |
| 961 | + } |
| 962 | + var ajax = target.getAttribute("data-ajax"), href = target.href; |
| 963 | + // if not ajax request |
| 964 | + if (target.getAttribute("data-rel") == "external" |
| 965 | + || ajax == "false" |
| 966 | + || (href.replace("://", "").split("/")[0] !== location.href.replace("://", "").split("/")[0] && ajax != "true") |
| 967 | + || (this.captureLink == false && ajax != "true") |
| 968 | + ) return; |
| 969 | + event.preventDefault(); |
| 970 | + }); |
971 | 971 | }
|
972 | 972 | // Important:
|
973 | 973 | // In ios7+, swipe the edge of page will navigate Safari
|
|
1010 | 1010 | if ((!href || /a/i.test(target.tagName) == false) && (target = target.getParentElementByTag("a"))) {
|
1011 | 1011 | href = target.href;
|
1012 | 1012 | }
|
1013 |
| - |
1014 | 1013 | // the page that current touched or actived
|
1015 | 1014 | var self_page = document.querySelector(".in." + Mobilebone.classPage);
|
1016 | 1015 |
|
|
1075 | 1074 | event.preventDefault();
|
1076 | 1075 | return;
|
1077 | 1076 | }
|
1078 |
| - |
1079 | 1077 | if (/^javascript/.test(href)) {
|
1080 | 1078 | if (back == false) return;
|
1081 | 1079 | } else {
|
1082 | 1080 | external = external || (href.replace("://", "").split("/")[0] !== location.href.replace("://", "").split("/")[0]);
|
1083 | 1081 | if ((external == true || capture == false) && target.getAttribute("data-ajax") != "true") return;
|
1084 | 1082 | }
|
1085 |
| - |
| 1083 | + |
1086 | 1084 | // judge that if it's a ajax request
|
1087 | 1085 | if (/^#/.test(target.getAttribute("href")) == true) {
|
1088 | 1086 | // hash slide
|
|
0 commit comments