|
46 | 46 | *
|
47 | 47 | * @type string
|
48 | 48 | **/
|
49 |
| - Mobilebone.VERSION = '2.5.5'; |
| 49 | + Mobilebone.VERSION = '2.5.6'; |
50 | 50 |
|
51 | 51 | /**
|
52 | 52 | * Whether catch attribute of href from element with tag 'a'
|
|
625 | 625 | }
|
626 | 626 |
|
627 | 627 | var create_title = create.getElementsByTagName("title")[0];
|
| 628 | + |
628 | 629 | // get the page element
|
629 | 630 | if (!(create_page = create.querySelector("." + classPage))) {
|
| 631 | + // if there no .page, create as create_page |
630 | 632 | create.className = classPage + " out";
|
631 |
| - if (typeof page_title == "string") create.setAttribute("data-title", page_title); |
632 | 633 | create_page = create;
|
633 |
| - } else { |
634 |
| - if (create_title) { |
635 |
| - create_page.setAttribute("data-title", create_title.innerText); |
636 |
| - } else if (typeof page_title == "string") { |
637 |
| - create_page.setAttribute("data-title", page_title); |
638 |
| - } |
639 | 634 | }
|
| 635 | + // set and store title |
| 636 | + if (typeof page_title == "string") { |
| 637 | + create_page.setAttribute("data-title", page_title); |
| 638 | + } else if (create_title && create_title.innerText) { // the judge behind '&&' for issues #144 |
| 639 | + create_page.setAttribute("data-title", create_title.innerText); |
| 640 | + } |
| 641 | + |
640 | 642 | // insert create page as a last-child
|
641 | 643 | (container || document.body).appendChild(create_page);
|
642 | 644 |
|
|
881 | 883 | Mobilebone.submit = function(form) {
|
882 | 884 | if (!form || typeof form.action != "string") return;
|
883 | 885 | var ajax = form.getAttribute("data-ajax");
|
884 |
| - if (ajax == "false" || (this.captureForm == false && ajax != "true")) return; |
| 886 | + if (ajax == "false" || (Mobilebone.captureForm == false && ajax != "true")) return; |
885 | 887 |
|
886 | 888 | form.addEventListener("submit", function(event) {
|
887 | 889 | // prevent detect
|
|
970 | 972 | }
|
971 | 973 |
|
972 | 974 | // Initialization link-catch events.
|
973 |
| - var eventName = "click", $ = root.$ || root.jQuery || root.Zepto; |
974 |
| - if ($ && $.fn && $.fn.tap && ('ontouchstart' in window == true)) eventName = "tap"; |
975 |
| - |
976 |
| - if ($ && $.fn && $.fn.on) { |
| 975 | + var $ = root.$ || root.jQuery || root.Zepto; |
| 976 | + if ($ && $.fn && $.fn.tap && ('ontouchstart' in window == true)) { |
977 | 977 | // for some unknown 'tap' plugin
|
978 |
| - $(document).on(eventName, this.handleTapEvent); |
979 |
| - } else { |
980 |
| - document.addEventListener(eventName, this.handleTapEvent); |
981 |
| - } |
982 |
| - |
983 |
| - if (eventName == "tap") { |
| 978 | + $(document).tap(this.handleTapEvent); |
| 979 | + |
984 | 980 | // zepto tap event.preventDefault can't prevent default click-events
|
985 | 981 | document.addEventListener("click", function(event) {
|
986 | 982 | var target = event.target;
|
|
993 | 989 | if (target.getAttribute("data-rel") == "external"
|
994 | 990 | || ajax == "false"
|
995 | 991 | || (href.replace("://", "").split("/")[0] !== location.href.replace("://", "").split("/")[0] && ajax != "true")
|
996 |
| - || (this.captureLink == false && ajax != "true") |
| 992 | + || (Mobilebone.captureLink == false && ajax != "true") |
997 | 993 | ) return;
|
998 | 994 | event.preventDefault();
|
999 | 995 | });
|
| 996 | + } else { |
| 997 | + document.addEventListener("click", this.handleTapEvent); |
1000 | 998 | }
|
| 999 | + |
1001 | 1000 | // Important:
|
1002 | 1001 | // In ios7+, swipe the edge of page will navigate Safari
|
1003 | 1002 | // that will trigger 'popstate' events and the page will transition twice
|
|
0 commit comments