|
40 | 40 | *
|
41 | 41 | * @type string
|
42 | 42 | **/
|
43 |
| - Mobilebone.VERSION = '2.0.2'; |
| 43 | + Mobilebone.VERSION = '2.1.0'; |
44 | 44 |
|
45 | 45 | /**
|
46 | 46 | * Whether catch attribute of href from element with tag 'a'
|
|
248 | 248 | var onpagefirstinto = params_in.onpagefirstinto;
|
249 | 249 | if (!store[pageid]) {
|
250 | 250 | if (typeof onpagefirstinto == "string" && params_in.root[onpagefirstinto]) {
|
251 |
| - params_in.root[onpagefirstinto](pageInto, pageOut, options.response); |
| 251 | + params_in.root[onpagefirstinto](pageInto, pageOut, options); |
252 | 252 | } else if (typeof onpagefirstinto == "function") {
|
253 |
| - onpagefirstinto(pageInto, pageOut, options.response); |
| 253 | + onpagefirstinto(pageInto, pageOut, options); |
254 | 254 | }
|
255 | 255 | // capture form submit
|
256 | 256 | slice.call(pageInto.querySelectorAll("form")).forEach(function(form) {
|
|
275 | 275 | // bind animation events
|
276 | 276 | if (typeof animition == "string" && params_in.root[animition]) {
|
277 | 277 | pageInto.addEventListener(animateEventName, function() {
|
278 |
| - params_in.root[animition](this, this.classList.contains("in")? "into": "out"); |
| 278 | + params_in.root[animition](this, this.classList.contains("in")? "into": "out", options); |
279 | 279 | });
|
280 | 280 | } else if (typeof animition == "function") {
|
281 | 281 | pageInto.addEventListener(animateEventName, function() {
|
282 |
| - animition(this, this.classList.contains("in")? "into": "out"); |
| 282 | + animition(this, this.classList.contains("in")? "into": "out", options); |
283 | 283 | });
|
284 | 284 | }
|
285 | 285 | }
|
|
304 | 304 | var callback = params_in.callback;
|
305 | 305 |
|
306 | 306 | if (typeof callback == "string") callback = params_in.root[callback];
|
307 |
| - if (typeof callback == "function") callback.call(params_in.root, pageInto, pageOut, options.response); |
| 307 | + if (typeof callback == "function") callback.call(params_in.root, pageInto, pageOut, options); |
308 | 308 | }
|
309 | 309 | };
|
310 | 310 |
|
|
455 | 455 | if (typeof options.remove != "undefined") {
|
456 | 456 | optionsTransition.remove = options.remove;
|
457 | 457 | }
|
| 458 | + if (typeof options.target != "undefined") { |
| 459 | + optionsTransition.target = options.target; |
| 460 | + } |
458 | 461 | }
|
459 | 462 | this.transition(create_page, current_page, optionsTransition);
|
460 | 463 | };
|
|
534 | 537 | }
|
535 | 538 |
|
536 | 539 | params.url = this.getCleanUrl(trigger_or_options, params.url);
|
| 540 | + params.target = trigger_or_options; |
537 | 541 |
|
538 | 542 | var tagName = trigger_or_options.tagName.toLowerCase();
|
539 | 543 | if (tagName == "form") {
|
|
727 | 731 | if (hasInited == true) return 'Don\'t repeat initialization!';
|
728 | 732 | var hash = location.hash.replace("#&", "#"), ele_in = null;
|
729 | 733 | if (hash == "" || hash == "#") {
|
730 |
| - store._initPage = document.querySelector("." + this.classPage); |
731 |
| - this.transition(store._initPage); |
| 734 | + this.transition(document.querySelector("." + this.classPage)); |
732 | 735 | } else if (isSimple.test(hash) == true && (ele_in = document.querySelector(hash)) && ele_in.classList.contains(this.classPage)) { // 'ele_in' must be a page element
|
733 | 736 | this.transition(ele_in);
|
734 | 737 | } else {
|
|
832 | 835 | if (back == false && rel == "auto") {
|
833 | 836 | back = Mobilebone.isBack(eleTargetPage, self_page);
|
834 | 837 | }
|
835 |
| - if (eleTargetPage) Mobilebone.transition(eleTargetPage, self_page, back); |
| 838 | + if (eleTargetPage) Mobilebone.transition(eleTargetPage, self_page, back, { |
| 839 | + target: target |
| 840 | + }); |
836 | 841 | event.preventDefault();
|
837 | 842 | } else if (/^javascript/.test(href)) {
|
838 | 843 | // back
|
|
849 | 854 | back = Mobilebone.isBack(store[clean_url], self_page);
|
850 | 855 | }
|
851 | 856 | Mobilebone.transition(store[clean_url], self_page, back, {
|
| 857 | + target: target, |
852 | 858 | id: clean_url
|
853 | 859 | });
|
854 | 860 | } else {
|
|
912 | 918 | window.addEventListener("popstate", function() {
|
913 | 919 | var hash = location.hash.replace("#&", "").replace("#", ""), page_in = null;
|
914 | 920 | if (hash == "") {
|
915 |
| - // if no hash, get init page as 'page_in' |
916 |
| - page_in = store._initPage; |
917 |
| - if (!page_in) return; |
| 921 | + // if no hash, get first page as 'page_in' |
| 922 | + page_in = document.querySelector("." + Mobilebone.classPage); |
| 923 | + if (page_in.id) return; |
918 | 924 | } else {
|
919 | 925 | page_in = store[hash];
|
920 | 926 | }
|
|
0 commit comments