Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Deprecate $.mobile.loading and move loader creation/showing/hiding into an extension of pagecontainer #6479

Open
@gabrielschulhof

Description

@gabrielschulhof
  1. Deprecate $.mobile.loading, and re-implement it like this:

    $.mobile.loading = function() {
      var loader, returnValue;
    
      // Make sure the pagecontainer widget is present and also
      // that its loader extension is present
      if ( $.mobile.pagecontainer &&
        $.mobile.pagecontainer.prototype.loader ) {
    
        loader = $.mobile.pageContainer.pagecontainer( "loader" );
    
        returnValue = loader.loader.apply( loader, arguments );
      }
    
      return returnValue;
    };
  2. Remove _getLoader() from pagecontainer, and redefine _showLoading, _showError, and _hideLoading as $.noop.

  3. Create a pagecontainer extension that basically moves _showLoading, _showError, and _hideLoading from the main widget and implements the loader public API:

    $.widget( "mobile.pagecontainer", $.mobile.pagecontainer, {
      options: {
        showErrorDelay: 1500,
      },
    
      _loader: null,
    
      loader: function() {
        if ( this._loader == null ) {
          this._loader = $( $.mobile.loader.prototype.defaultHtml ).loader();
        }
        return this._loader;
      },
    
      _showLoading: function( delay, theme, msg, textonly ) {
        // This configurable timeout allows cached pages a brief
        // delay to load without showing a message
        this._loadMsg = setTimeout($.proxy(function() {
          this.loader().loader( "show", theme, msg, textonly );
        }, this), delay );
      },
    
      _hideLoading: function() {
        // Stop message show timer
        clearTimeout( this._loadMsg );
    
        // Hide loading message
        this.loader().loader( "hide" );
      },
    
      _showError: function() {
        // make sure to remove the current loading message
        this._hideLoading();
    
        // show the error message - TODO: Move these two globals into loader options
        this._showLoading( 0, $.mobile.pageLoadErrorMessageTheme, $.mobile.pageLoadErrorMessage, true );
    
        // hide the error message after a delay
        setTimeout( $.proxy(this, "_hideLoading"), this.options.showErrorDelay );
      }
    });
  4. Deprecate $.mobile.pageLoadErrorMessageTheme and $.mobile.pageLoadErrorMessage and move them into loader options and introduce loader public API that shows error. Call it showError() or error(). This latter part is optional and we can wait one more version.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions