Custom Build of 1.3.2 JS Out of Order

Đang mở
#72 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
build-system, frontend

Hướng nghiên cứu

Issue không nêu tên tệp nguồn, điểm vào của bản build hoặc bài kiểm thử nào. Hãy lần theo quy trình custom-build và kiểm tra thứ tự của JavaScript được tạo ra, sử dụng khối khởi tạo được hiển thị làm phần cuối dự kiến. Được xem là hoàn tất khi trang jQuery Mobile đầu tiên khởi tạo đúng trong một bản build tùy chỉnh 1.3.2.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

When building a custom version of 1.3.2, the built JS is not in the correct order, which causes the first JQM page to not initialize properly. The following code needs to be the last item in the JS file and it is not.

(function( $, window, undefined ) {
    var $html = $( "html" ),
    $head = $( "head" ),
    $window = $.mobile.window;

//remove initial build class (only present on first pageshow)
function hideRenderingClass() {
    $html.removeClass( "ui-mobile-rendering" );
}

// trigger mobileinit event - useful hook for configuring $.mobile settings before they're used
$( window.document ).trigger( "mobileinit" );

// support conditions
// if device support condition(s) aren't met, leave things as they are -> a basic, usable experience,
// otherwise, proceed with the enhancements
if ( !$.mobile.gradeA() ) {
    return;
}

// override ajaxEnabled on platforms that have known conflicts with hash history updates
// or generally work better browsing in regular http for full page refreshes (BB5, Opera Mini)
if ( $.mobile.ajaxBlacklist ) {
    $.mobile.ajaxEnabled = false;
}

// Add mobile, initial load "rendering" classes to docEl
$html.addClass( "ui-mobile ui-mobile-rendering" );

// This is a fallback. If anything goes wrong (JS errors, etc), or events don't fire,
// this ensures the rendering class is removed after 5 seconds, so content is visible and accessible
setTimeout( hideRenderingClass, 5000 );

$.extend( $.mobile, {
    // find and enhance the pages in the dom and transition to the first page.
    initializePage: function() {
        // find present pages
        var path = $.mobile.path,
            $pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" ),
            hash = path.stripHash( path.stripQueryParams(path.parseLocation().hash) ),
            hashPage = document.getElementById( hash );

        // if no pages are found, create one with body's inner html
        if ( !$pages.length ) {
            $pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
        }

        // add dialogs, set data-url attrs
        $pages.each(function() {
            var $this = $( this );

            // unless the data url is already set set it to the pathname
            if ( !$this.jqmData( "url" ) ) {
                $this.attr( "data-" + $.mobile.ns + "url", $this.attr( "id" ) || location.pathname + location.search );
            }
        });

        // define first page in dom case one backs out to the directory root (not always the first page visited, but defined as fallback)
        $.mobile.firstPage = $pages.first();

        // define page container
        $.mobile.pageContainer = $.mobile.firstPage.parent().addClass( "ui-mobile-viewport" );

        // initialize navigation events now, after mobileinit has occurred and the page container
        // has been created but before the rest of the library is alerted to that fact
        $.mobile.navreadyDeferred.resolve();

        // alert listeners that the pagecontainer has been determined for binding
        // to events triggered on it
        $window.trigger( "pagecontainercreate" );

        // cue page loading message
        $.mobile.showPageLoadingMsg();

        //remove initial build class (only present on first pageshow)
        hideRenderingClass();

        // if hashchange listening is disabled, there's no hash deeplink,
        // the hash is not valid (contains more than one # or does not start with #)
        // or there is no page with that hash, change to the first page in the DOM
        // Remember, however, that the hash can also be a path!
        if ( ! ( $.mobile.hashListeningEnabled &&
            $.mobile.path.isHashValid( location.hash ) &&
            ( $( hashPage ).is( ':jqmData(role="page")' ) ||
                $.mobile.path.isPath( hash ) ||
                hash === $.mobile.dialogHashKey ) ) ) {

            // Store the initial destination
            if ( $.mobile.path.isHashValid( location.hash ) ) {
                $.mobile.urlHistory.initialDst = hash.replace( "#", "" );
            }

            // make sure to set initial popstate state if it exists
            // so that navigation back to the initial page works properly
            if( $.event.special.navigate.isPushStateEnabled() ) {
                $.mobile.navigate.navigator.squash( path.parseLocation().href );
            }

            $.mobile.changePage( $.mobile.firstPage, {
                transition: "none",
                reverse: true,
                changeHash: false,
                fromHashChange: true
            });
        } else {
            // trigger hashchange or navigate to squash and record the correct
            // history entry for an initial hash path
            if( !$.event.special.navigate.isPushStateEnabled() ) {
                $window.trigger( "hashchange", [true] );
            } else {
                // TODO figure out how to simplify this interaction with the initial history entry
                // at the bottom js/navigate/navigate.js
                $.mobile.navigate.history.stack = [];
                $.mobile.navigate( $.mobile.path.isPath( location.hash ) ? location.hash : location.href );
            }
        }
    }
});

// check which scrollTop value should be used by scrolling to 1 immediately at domready
// then check what the scroll top is. Android will report 0... others 1
// note that this initial scroll won't hide the address bar. It's just for the check.
$(function() {
    window.scrollTo( 0, 1 );

    // if defaultHomeScroll hasn't been set yet, see if scrollTop is 1
    // it should be 1 in most browsers, but android treats 1 as 0 (for hiding addr bar)
    // so if it's 1, use 0 from now on
    $.mobile.defaultHomeScroll = ( !$.support.scrollTop || $.mobile.window.scrollTop() === 1 ) ? 0 : 1;

    //dom-ready inits
    if ( $.mobile.autoInitializePage ) {
        $.mobile.initializePage();
    }

    // window load event
    // hide iOS browser chrome on load
    $window.load( $.mobile.silentScroll );

    if ( !$.support.cssPointerEvents ) {
        // IE and Opera don't support CSS pointer-events: none that we use to disable link-based buttons
        // by adding the 'ui-disabled' class to them. Using a JavaScript workaround for those browser.
        // https://github.com/jquery/jquery-mobile/issues/3558

        $.mobile.document.delegate( ".ui-disabled", "vclick",
            function( e ) {
                e.preventDefault();
                e.stopImmediatePropagation();
            }
        );
    }
});
}( jQuery, this ));
Ngôn ngữ chính
HTML
Star
57
Fork
69
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của jquery/jquerymobile.com

Tất cả issue của jquery/jquerymobile.com

Issue tương tự

Thêm issue về Build System

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.