|
612 | $.mobile.showPageLoadingMsg();
| 612 | $.mobile.showPageLoadingMsg();
|
613 | }
| 613 | }
|
614 |
| 614 |
|
615 | - $.ajaxTransport( "+*", function( s ) { | 615 | + if ( !( $.mobile.allowCrossDomainPages || path.isSameDomain( documentUrl, absUrl ) ) ) { |
616 | - if ( s.crossDomain && !$.mobile.ajaxCrossDomainEnabled ) { | 616 | + deferred.reject( absUrl, options ); |
617 | - return { | 617 | + } else { |
618 | - send: function() { | 618 | + // Load the new page. |
619 | - $.error( "Cross domain .ajax() calls are disabled." ); | 619 | + $.ajax({ |
620 | - }, | 620 | + url: fileUrl, |
621 | - abort: $.noop | 621 | + type: settings.type, |
622 | - }; | 622 | + data: settings.data, |
623 | - } | 623 | + dataType: "html", |
624 | - }); | 624 | + success: function( html ) { |
625 | - | 625 | + //pre-parse html to check for a data-url, |
626 | - // Load the new page. | 626 | + //use it as the new fileUrl, base path, etc |
627 | - $.ajax({ | 627 | + var all = $( "<div></div>" ), |
628 | - url: fileUrl, | | |
629 | - type: settings.type, | | |
630 | - data: settings.data, | | |
631 | - dataType: "html", | | |
632 | - success: function( html ) { | | |
633 | - //pre-parse html to check for a data-url, | | |
634 | - //use it as the new fileUrl, base path, etc | | |
635 | - var all = $( "<div></div>" ), | | |
636 |
| 628 |
|
637 | //page title regexp
| 629 | //page title regexp
|
638 | newPageTitle = html.match( /<title[^>]*>([^<]*)/ ) && RegExp.$1,
| 630 | newPageTitle = html.match( /<title[^>]*>([^<]*)/ ) && RegExp.$1,
|
|
642 | dataUrlRegex = new RegExp( "\\bdata-" + $.mobile.ns + "url=[\"']?([^\"'>]*)[\"']?" );
| 634 | dataUrlRegex = new RegExp( "\\bdata-" + $.mobile.ns + "url=[\"']?([^\"'>]*)[\"']?" );
|
643 |
| 635 |
|
644 |
| 636 |
|
645 | - // data-url must be provided for the base tag so resource requests can be directed to the | 637 | + // data-url must be provided for the base tag so resource requests can be directed to the |
646 | - // correct url. loading into a temprorary element makes these requests immediately | 638 | + // correct url. loading into a temprorary element makes these requests immediately |
647 | - if( pageElemRegex.test( html ) | 639 | + if( pageElemRegex.test( html ) |
648 | - && RegExp.$1 | 640 | + && RegExp.$1 |
649 | - && dataUrlRegex.test( RegExp.$1 ) | 641 | + && dataUrlRegex.test( RegExp.$1 ) |
650 | - && RegExp.$1 ) { | 642 | + && RegExp.$1 ) { |
651 | - url = fileUrl = path.getFilePath( RegExp.$1 ); | 643 | + url = fileUrl = path.getFilePath( RegExp.$1 ); |
652 | - } | 644 | + } |
653 |
| 645 |
|
654 | - if ( base ) { | 646 | + if ( base ) { |
655 | - base.set( fileUrl ); | 647 | + base.set( fileUrl ); |
656 | - } | 648 | + } |
657 |
| 649 |
|
658 | - //workaround to allow scripts to execute when included in page divs | 650 | + //workaround to allow scripts to execute when included in page divs |
659 | - all.get( 0 ).innerHTML = html; | 651 | + all.get( 0 ).innerHTML = html; |
660 | - page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first(); | 652 | + page = all.find( ":jqmData(role='page'), :jqmData(role='dialog')" ).first(); |
661 |
| 653 |
|
662 | - if ( newPageTitle && !page.jqmData( "title" ) ) { | 654 | + if ( newPageTitle && !page.jqmData( "title" ) ) { |
663 | - page.jqmData( "title", newPageTitle ); | 655 | + page.jqmData( "title", newPageTitle ); |
664 | - } | 656 | + } |
665 |
| 657 |
|
666 | - //rewrite src and href attrs to use a base url | 658 | + //rewrite src and href attrs to use a base url |
667 | - if( !$.support.dynamicBaseTag ) { | 659 | + if( !$.support.dynamicBaseTag ) { |
668 | - var newPath = path.get( fileUrl ); | 660 | + var newPath = path.get( fileUrl ); |
669 | - page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() { | 661 | + page.find( "[src], link[href], a[rel='external'], :jqmData(ajax='false'), a[target]" ).each(function() { |
670 | - var thisAttr = $( this ).is( '[href]' ) ? 'href' : | 662 | + var thisAttr = $( this ).is( '[href]' ) ? 'href' : |
671 | - $(this).is('[src]') ? 'src' : 'action', | 663 | + $(this).is('[src]') ? 'src' : 'action', |
672 | - thisUrl = $( this ).attr( thisAttr ); | 664 | + thisUrl = $( this ).attr( thisAttr ); |
673 | - | 665 | + |
674 | - // XXX_jblas: We need to fix this so that it removes the document | 666 | + // XXX_jblas: We need to fix this so that it removes the document |
675 | - // base URL, and then prepends with the new page URL. | 667 | + // base URL, and then prepends with the new page URL. |
676 | - //if full path exists and is same, chop it - helps IE out | 668 | + //if full path exists and is same, chop it - helps IE out |
677 | - thisUrl = thisUrl.replace( location.protocol + '//' + location.host + location.pathname, '' ); | 669 | + thisUrl = thisUrl.replace( location.protocol + '//' + location.host + location.pathname, '' ); |
678 | - | 670 | + |
679 | - if( !/^(\w+:|#|\/)/.test( thisUrl ) ) { | 671 | + if( !/^(\w+:|#|\/)/.test( thisUrl ) ) { |
680 | - $( this ).attr( thisAttr, newPath + thisUrl ); | 672 | + $( this ).attr( thisAttr, newPath + thisUrl ); |
681 | - } | 673 | + } |
682 | - }); | 674 | + }); |
683 | - } | 675 | + } |
684 |
| 676 |
|
685 | - //append to page and enhance | 677 | + //append to page and enhance |
686 | - page | 678 | + page |
687 | - .attr( "data-" + $.mobile.ns + "url", path.convertUrlToDataUrl( fileUrl ) ) | 679 | + .attr( "data-" + $.mobile.ns + "url", path.convertUrlToDataUrl( fileUrl ) ) |
688 | - .appendTo( settings.pageContainer ); | 680 | + .appendTo( settings.pageContainer ); |
689 |
| 681 |
|
690 | - enhancePage( page, settings.role ); | 682 | + enhancePage( page, settings.role ); |
691 |
| 683 |
|
692 | - // Enhancing the page may result in new dialogs/sub pages being inserted | 684 | + // Enhancing the page may result in new dialogs/sub pages being inserted |
693 | - // into the DOM. If the original absUrl refers to a sub-page, that is the | 685 | + // into the DOM. If the original absUrl refers to a sub-page, that is the |
694 | - // real page we are interested in. | 686 | + // real page we are interested in. |
695 | - if ( absUrl.indexOf( "&" + $.mobile.subPageUrlKey ) > -1 ) { | 687 | + if ( absUrl.indexOf( "&" + $.mobile.subPageUrlKey ) > -1 ) { |
696 | - page = settings.pageContainer.children( ":jqmData(url='" + dataUrl + "')" ); | 688 | + page = settings.pageContainer.children( ":jqmData(url='" + dataUrl + "')" ); |
697 | - } | 689 | + } |
698 |
| 690 |
|
699 | - // Remove loading message. | 691 | + // Remove loading message. |
700 | - if ( settings.showLoadMsg ) { | 692 | + if ( settings.showLoadMsg ) { |
701 | - $.mobile.hidePageLoadingMsg(); | 693 | + $.mobile.hidePageLoadingMsg(); |
702 | - } | 694 | + } |
703 |
| 695 |
|
704 | - deferred.resolve( absUrl, options, page, dupCachedPage ); | 696 | + deferred.resolve( absUrl, options, page, dupCachedPage ); |
705 | - }, | 697 | + }, |
706 | - error: function() { | 698 | + error: function() { |
707 | - //set base back to current path | 699 | + //set base back to current path |
708 | - if( base ) { | 700 | + if( base ) { |
709 | - base.set( path.get() ); | 701 | + base.set( path.get() ); |
710 | - } | 702 | + } |
711 |
| 703 |
|
712 | - // Remove loading message. | 704 | + // Remove loading message. |
713 | - if ( settings.showLoadMsg ) { | 705 | + if ( settings.showLoadMsg ) { |
714 | - $.mobile.hidePageLoadingMsg(); | 706 | + $.mobile.hidePageLoadingMsg(); |
715 | - | 707 | + |
716 | - //show error message | 708 | + //show error message |
717 | - $( "<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h1>"+ $.mobile.pageLoadErrorMessage +"</h1></div>" ) | 709 | + $( "<div class='ui-loader ui-overlay-shadow ui-body-e ui-corner-all'><h1>"+ $.mobile.pageLoadErrorMessage +"</h1></div>" ) |
718 | - .css({ "display": "block", "opacity": 0.96, "top": $window.scrollTop() + 100 }) | 710 | + .css({ "display": "block", "opacity": 0.96, "top": $window.scrollTop() + 100 }) |
719 | - .appendTo( settings.pageContainer ) | 711 | + .appendTo( settings.pageContainer ) |
720 | - .delay( 800 ) | 712 | + .delay( 800 ) |
721 | - .fadeOut( 400, function() { | 713 | + .fadeOut( 400, function() { |
722 | - $( this ).remove(); | 714 | + $( this ).remove(); |
723 | - }); | 715 | + }); |
724 | - } | 716 | + } |
725 |
| 717 |
|
726 | - deferred.reject( absUrl, options ); | 718 | + deferred.reject( absUrl, options ); |
727 | - } | 719 | + } |
728 | - }); | 720 | + }); |
| | 721 | + } |
729 |
| 722 |
|
730 | return deferred.promise();
| 723 | return deferred.promise();
|
731 | };
| 724 | };
|
|
0 commit comments