src/common/js/winjs/js/ui.js
function updateGroups() {
                        function createGroup(groupInfo, itemsContainer) {
                            var GroupType = (groupInfo.enableCellSpanning ?
                                Groups.CellSpanningGroup :
                                Groups.UniformGroup);
                            return new GroupType(that, itemsContainer);
                        }

                        var oldRealizedItemRange = (that._groups.length > 0 ?
                                that._getRealizationRange() :
                                null),
                            newGroups = [],
                            prepared = [],
                            cleanUpDom = {},
                            newGroupMap = {},
                            currentIndex = 0,
                            len = tree.length,
                            i;

                        for (i = 0; i < len; i++) {
                            var oldChangedRealizedRangeInGroup = null,
                                groupInfo = that._getGroupInfo(i),
                                groupKey = that._site.groupFromIndex(i).key,
                                oldGroup = that._groupMap[groupKey],
                                wasCellSpanning = oldGroup instanceof Groups.CellSpanningGroup,
                                isCellSpanning = groupInfo.enableCellSpanning;

                            if (oldGroup) {
                                if (wasCellSpanning !== isCellSpanning) {
                                    // The group has changed types so DOM needs to be cleaned up
                                    cleanUpDom[groupKey] = true;
                                } else {
                                    // Compute the range of changed items that is within the group's realized range
                                    var firstChangedIndexInGroup = Math.max(0, changedRange.firstIndex - oldGroup.startIndex),
                                        oldRealizedItemRangeInGroup = that._rangeForGroup(oldGroup, oldRealizedItemRange);
                                    if (oldRealizedItemRangeInGroup && firstChangedIndexInGroup <= oldRealizedItemRangeInGroup.lastIndex) {
                                        // The old changed realized range is non-empty
                                        oldChangedRealizedRangeInGroup = {
                                            firstIndex: Math.max(firstChangedIndexInGroup, oldRealizedItemRangeInGroup.firstIndex),
                                            lastIndex: oldRealizedItemRangeInGroup.lastIndex
                                        };
                                    }
                                }
                            }
                            var group = createGroup(groupInfo, tree[i].itemsContainer.element);
                            var prepareLayoutPromise;
                            if (group.prepareLayoutWithCopyOfTree) {
                                prepareLayoutPromise = group.prepareLayoutWithCopyOfTree(copyItemsContainerTree(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, {
                                    groupInfo: groupInfo,
                                    startIndex: currentIndex,
                                });
                            } else {
                                prepareLayoutPromise = group.prepareLayout(getItemsContainerLength(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, {
                                    groupInfo: groupInfo,
                                    startIndex: currentIndex,
                                });
                            }
                            prepared.push(prepareLayoutPromise);

                            currentIndex += group.count;

                            newGroups.push(group);
                            newGroupMap[groupKey] = group;
                        }

                        return Promise.join(prepared).then(function () {
                            var currentOffset = 0;
                            for (var i = 0, len = newGroups.length; i < len; i++) {
                                var group = newGroups[i];
                                group.offset = currentOffset;
                                currentOffset += that._getGroupSize(group);
                            }

                            // Clean up deleted groups
                            Object.keys(that._groupMap).forEach(function (deletedKey) {
                                var skipDomCleanUp = !cleanUpDom[deletedKey];
                                that._groupMap[deletedKey].cleanUp(skipDomCleanUp);
                            });

                            that._groups = newGroups;
                            that._groupMap = newGroupMap;
                        });
                    }
function updateGroups() {
                        function createGroup(groupInfo, itemsContainer) {
                            var GroupType = (groupInfo.enableCellSpanning ?
                                Groups.CellSpanningGroup :
                                Groups.UniformGroup);
                            return new GroupType(that, itemsContainer);
                        }

                        var oldRealizedItemRange = (that._groups.length > 0 ?
                                that._getRealizationRange() :
                                null),
                            newGroups = [],
                            prepared = [],
                            cleanUpDom = {},
                            newGroupMap = {},
                            currentIndex = 0,
                            len = tree.length,
                            i;

                        for (i = 0; i < len; i++) {
                            var oldChangedRealizedRangeInGroup = null,
                                groupInfo = that._getGroupInfo(i),
                                groupKey = that._site.groupFromIndex(i).key,
                                oldGroup = that._groupMap[groupKey],
                                wasCellSpanning = oldGroup instanceof Groups.CellSpanningGroup,
                                isCellSpanning = groupInfo.enableCellSpanning;

                            if (oldGroup) {
                                if (wasCellSpanning !== isCellSpanning) {
                                    // The group has changed types so DOM needs to be cleaned up
                                    cleanUpDom[groupKey] = true;
                                } else {
                                    // Compute the range of changed items that is within the group's realized range
                                    var firstChangedIndexInGroup = Math.max(0, changedRange.firstIndex - oldGroup.startIndex),
                                        oldRealizedItemRangeInGroup = that._rangeForGroup(oldGroup, oldRealizedItemRange);
                                    if (oldRealizedItemRangeInGroup && firstChangedIndexInGroup <= oldRealizedItemRangeInGroup.lastIndex) {
                                        // The old changed realized range is non-empty
                                        oldChangedRealizedRangeInGroup = {
                                            firstIndex: Math.max(firstChangedIndexInGroup, oldRealizedItemRangeInGroup.firstIndex),
                                            lastIndex: oldRealizedItemRangeInGroup.lastIndex
                                        };
                                    }
                                }
                            }
                            var group = createGroup(groupInfo, tree[i].itemsContainer.element);
                            var prepareLayoutPromise;
                            if (group.prepareLayoutWithCopyOfTree) {
                                prepareLayoutPromise = group.prepareLayoutWithCopyOfTree(copyItemsContainerTree(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, {
                                    groupInfo: groupInfo,
                                    startIndex: currentIndex,
                                });
                            } else {
                                prepareLayoutPromise = group.prepareLayout(getItemsContainerLength(tree[i].itemsContainer), oldChangedRealizedRangeInGroup, oldGroup, {
                                    groupInfo: groupInfo,
                                    startIndex: currentIndex,
                                });
                            }
                            prepared.push(prepareLayoutPromise);

                            currentIndex += group.count;

                            newGroups.push(group);
                            newGroupMap[groupKey] = group;
                        }

                        return Promise.join(prepared).then(function () {
                            var currentOffset = 0;
                            for (var i = 0, len = newGroups.length; i < len; i++) {
                                var group = newGroups[i];
                                group.offset = currentOffset;
                                currentOffset += that._getGroupSize(group);
                            }

                            // Clean up deleted groups
                            Object.keys(that._groupMap).forEach(function (deletedKey) {
                                var skipDomCleanUp = !cleanUpDom[deletedKey];
                                that._groupMap[deletedKey].cleanUp(skipDomCleanUp);
                            });

                            that._groups = newGroups;
                            that._groupMap = newGroupMap;
                        });
                    }
function updateGroups ( ) { function createGroup ( groupInfo , itemsContainer ) { var GroupType = ( groupInfo . enableCellSpanning ? Groups . CellSpanningGroup : Groups . UniformGroup ) ; return new GroupType ( that , itemsContainer ) ; } var oldRealizedItemRange = ( that . _groups . length > 0 ? that . _getRealizationRange ( ) : null ) , newGroups = [ ] , prepared = [ ] , cleanUpDom = { } , newGroupMap = { } , currentIndex = 0 , len = tree . length , i ; for ( i = 0 ; i < len ; i ++ ) { var oldChangedRealizedRangeInGroup = null , groupInfo = that . _getGroupInfo ( i ) , groupKey = that . _site . groupFromIndex ( i ) . key , oldGroup = that . _groupMap [ groupKey ] , wasCellSpanning = oldGroup instanceof Groups . CellSpanningGroup , isCellSpanning = groupInfo . enableCellSpanning ; if ( oldGroup ) { if ( wasCellSpanning !== isCellSpanning ) { // The group has changed types so DOM needs to be cleaned up cleanUpDom [ groupKey ] = true ; } else { // Compute the range of changed items that is within the group's realized range var firstChangedIndexInGroup = Math . max ( 0 , changedRange . firstIndex - oldGroup . startIndex ) , oldRealizedItemRangeInGroup = that . _rangeForGroup ( oldGroup , oldRealizedItemRange ) ; if ( oldRealizedItemRangeInGroup && firstChangedIndexInGroup <= oldRealizedItemRangeInGroup . lastIndex ) { // The old changed realized range is non-empty oldChangedRealizedRangeInGroup = { firstIndex : Math . max ( firstChangedIndexInGroup , oldRealizedItemRangeInGroup . firstIndex ) , lastIndex : oldRealizedItemRangeInGroup . lastIndex } ; } } } var group = createGroup ( groupInfo , tree [ i ] . itemsContainer . element ) ; var prepareLayoutPromise ; if ( group . prepareLayoutWithCopyOfTree ) { prepareLayoutPromise = group . prepareLayoutWithCopyOfTree ( copyItemsContainerTree ( tree [ i ] . itemsContainer ) , oldChangedRealizedRangeInGroup , oldGroup , { groupInfo : groupInfo , startIndex : currentIndex , } ) ; } else { prepareLayoutPromise = group . prepareLayout ( getItemsContainerLength ( tree [ i ] . itemsContainer ) , oldChangedRealizedRangeInGroup , oldGroup , { groupInfo : groupInfo , startIndex : currentIndex , } ) ; } prepared . push ( prepareLayoutPromise ) ; currentIndex += group . count ; newGroups . push ( group ) ; newGroupMap [ groupKey ] = group ; } return Promise . join ( prepared ) . then ( function ( ) { var currentOffset = 0 ; for ( var i = 0 , len = newGroups . length ; i < len ; i ++ ) { var group = newGroups [ i ] ; group . offset = currentOffset ; currentOffset += that . _getGroupSize ( group ) ; } // Clean up deleted groups Object . keys ( that . _groupMap ) . forEach ( function ( deletedKey ) { var skipDomCleanUp = ! cleanUpDom [ deletedKey ] ; that . _groupMap [ deletedKey ] . cleanUp ( skipDomCleanUp ) ; } ) ; that . _groups = newGroups ; that . _groupMap = newGroupMap ; } ) ; }
Updates the GridLayout's internal state to reflect the current tree. Similarly tells each group to update its internal state via prepareLayout. After this function runs, the ILayout functions will return results that are appropriate for the current tree.
Updates the GridLayout s internal state to reflect the current tree . Similarly tells each group to update its internal state via prepareLayout . After this function runs the ILayout functions will return results that are appropriate for the current tree .