dist/crocodoc.viewer.js
function (layoutMode) {
            // create a layout component with the new layout config
            var lastPage = config.page,
                lastZoom = config.zoom || 1,
                previousLayoutMode = config.layout,
                newLayout;

            // if there is already a layout, save some state
            if (layout) {
                // ignore this if we already have the specified layout
                if (layoutMode === previousLayoutMode) {
                    return layout;
                }

                lastPage = layout.state.currentPage;
                lastZoom = layout.state.zoomState;
            }

            newLayout = scope.createComponent('layout-' + layoutMode);
            if (!newLayout) {
                throw new Error('Invalid layout ' +  layoutMode);
            }

            // remove and destroy the existing layout component
            // @NOTE: this must be done after we decide if the
            // new layout exists!
            if (layout) {
                scope.destroyComponent(layout);
            }

            config.layout = layoutMode;

            layout = newLayout;
            layout.init();
            layout.setZoom(lastZoom.zoomMode || lastZoom.zoom || lastZoom);
            if (util.isFn(layout.scrollTo)) {
                layout.scrollTo(lastPage);
            }
            config.currentLayout = layout;

            scope.broadcast('layoutchange', {
                // in the context of event data, `layout` and `previousLayout`
                // are actually the name of those layouts, and not the layout
                // objects themselves
                previousLayout: previousLayoutMode,
                layout: layoutMode
            });
            return layout;
        }
function (layoutMode) {
            // create a layout component with the new layout config
            var lastPage = config.page,
                lastZoom = config.zoom || 1,
                previousLayoutMode = config.layout,
                newLayout;

            // if there is already a layout, save some state
            if (layout) {
                // ignore this if we already have the specified layout
                if (layoutMode === previousLayoutMode) {
                    return layout;
                }

                lastPage = layout.state.currentPage;
                lastZoom = layout.state.zoomState;
            }

            newLayout = scope.createComponent('layout-' + layoutMode);
            if (!newLayout) {
                throw new Error('Invalid layout ' +  layoutMode);
            }

            // remove and destroy the existing layout component
            // @NOTE: this must be done after we decide if the
            // new layout exists!
            if (layout) {
                scope.destroyComponent(layout);
            }

            config.layout = layoutMode;

            layout = newLayout;
            layout.init();
            layout.setZoom(lastZoom.zoomMode || lastZoom.zoom || lastZoom);
            if (util.isFn(layout.scrollTo)) {
                layout.scrollTo(lastPage);
            }
            config.currentLayout = layout;

            scope.broadcast('layoutchange', {
                // in the context of event data, `layout` and `previousLayout`
                // are actually the name of those layouts, and not the layout
                // objects themselves
                previousLayout: previousLayoutMode,
                layout: layoutMode
            });
            return layout;
        }
function ( layoutMode ) { // create a layout component with the new layout config var lastPage = config . page , lastZoom = config . zoom || 1 , previousLayoutMode = config . layout , newLayout ; // if there is already a layout, save some state if ( layout ) { // ignore this if we already have the specified layout if ( layoutMode === previousLayoutMode ) { return layout ; } lastPage = layout . state . currentPage ; lastZoom = layout . state . zoomState ; } newLayout = scope . createComponent ( 'layout-' + layoutMode ) ; if ( ! newLayout ) { throw new Error ( 'Invalid layout ' + layoutMode ) ; } // remove and destroy the existing layout component // @NOTE: this must be done after we decide if the // new layout exists! if ( layout ) { scope . destroyComponent ( layout ) ; } config . layout = layoutMode ; layout = newLayout ; layout . init ( ) ; layout . setZoom ( lastZoom . zoomMode || lastZoom . zoom || lastZoom ) ; if ( util . isFn ( layout . scrollTo ) ) { layout . scrollTo ( lastPage ) ; } config . currentLayout = layout ; scope . broadcast ( 'layoutchange' , { // in the context of event data, `layout` and `previousLayout` // are actually the name of those layouts, and not the layout // objects themselves previousLayout : previousLayoutMode , layout : layoutMode } ) ; return layout ; }
Set the layout to the given mode, destroying and cleaning up the current
layout if there is one
@param  {string} layoutMode The layout mode
@returns {Layout} The layout object
Set the layout to the given mode destroying and cleaning up the current layout if there is one