B2G/gaia/apps/homescreen/js/grid.js
/*
     * Initializes the grid manager
     *
     * @param {String} selector
     *                 Specifies the HTML container element for the pages.
     *
     */
Initializes the grid manager
@param {String} selector
Specifies the HTML container element for the pages.
Initializes the grid manager @param { String } selector Specifies the HTML container element for the pages .
function gm_init(gridSelector, dockSelector, pTapThreshold, callback)
    {
      calculateDefaultIcons();
      pages = [];
      bookmarkIcons = Object.create(null);
      appIcons = Object.create(null);
      appsByOrigin = Object.create(null);
      bookmarksByOrigin = Object.create(null);
      initUI(gridSelector);
      tapThreshold = pTapThreshold;
      IconRetriever.init();
      HomeState.init(function eachPage(pageState) {
        if (pageState.index == 0) {
          var dockContainer = document.querySelector(dockSelector);
          var dock = new Dock(dockContainer,
            convertDescriptorsToIcons(pageState));
          DockManager.init(dockContainer, dock, tapThreshold);
          return;
        }
        pageHelper.addPage(convertDescriptorsToIcons(pageState));
      }, function onState() {
        initApps();
        callback();
      }, function onError(error) {
        var dockContainer = document.querySelector(dockSelector);
        var dock = new Dock(dockContainer, []);
        DockManager.init(dockContainer, dock, tapThreshold);
        initApps();
        callback();
      });
    }
function gm_init ( gridSelector , dockSelector , pTapThreshold , callback ) { calculateDefaultIcons ( ) ; pages = [ ] ; bookmarkIcons = Object . create ( null ) ; appIcons = Object . create ( null ) ; appsByOrigin = Object . create ( null ) ; bookmarksByOrigin = Object . create ( null ) ; initUI ( gridSelector ) ; tapThreshold = pTapThreshold ; IconRetriever . init ( ) ; HomeState . init ( function eachPage ( pageState ) { if ( pageState . index == 0 ) { var dockContainer = document . querySelector ( dockSelector ) ; var dock = new Dock ( dockContainer , convertDescriptorsToIcons ( pageState ) ) ; DockManager . init ( dockContainer , dock , tapThreshold ) ; return ; } pageHelper . addPage ( convertDescriptorsToIcons ( pageState ) ) ; } , function onState ( ) { initApps ( ) ; callback ( ) ; } , function onError ( error ) { var dockContainer = document . querySelector ( dockSelector ) ; var dock = new Dock ( dockContainer , [ ] ) ; DockManager . init ( dockContainer , dock , tapThreshold ) ; initApps ( ) ; callback ( ) ; } ) ; }
Initializes the grid manager
 @param {String} selector
                 Specifies the HTML container element for the pages.
Initializes the grid manager @param { String } selector Specifies the HTML container element for the pages .
// Initialize the grid from the state saved in IndexedDB. // First 'page' is the dock.