dist/crocodoc.viewer.js
function () {
            var $loadStylesheetPromise,
                $loadMetadataPromise,
                $pageOneContentPromise,
                $pageOneTextPromise;

            if ($assetsPromise) {
                return;
            }

            $loadMetadataPromise = scope.get('metadata');
            $loadMetadataPromise.then(function handleMetadataResponse(metadata) {
                config.metadata = metadata;
            });

            // don't load the stylesheet for IE < 9
            if (browser.ielt9) {
                stylesheetEl = util.insertCSS('');
                config.stylesheet = stylesheetEl.styleSheet;
                $loadStylesheetPromise = $.when('').promise({
                    abort: function () {}
                });
            } else {
                $loadStylesheetPromise = scope.get('stylesheet');
                $loadStylesheetPromise.then(function handleStylesheetResponse(cssText) {
                    stylesheetEl = util.insertCSS(cssText);
                    config.stylesheet = stylesheetEl.sheet;
                });
            }


            // load page 1 assets immediately if necessary
            if (config.autoloadFirstPage &&
                (!config.pageStart || config.pageStart === 1)) {
                if (support.svg && config.useSVG) {
                    $pageOneContentPromise = scope.get('page-svg', 1);
                } else if (config.conversionIsComplete) {
                    // unfortunately, page-1.png is not necessarily available
                    // on View API's document.viewable event, so we can only
                    // prefetch page-1.png if conversion is complete
                    $pageOneContentPromise = scope.get('page-img', 1);
                }
                if (config.enableTextSelection) {
                    $pageOneTextPromise = scope.get('page-text', 1);
                }
            }

            // when both metatadata and stylesheet are done or if either fails...
            $assetsPromise = $.when($loadMetadataPromise, $loadStylesheetPromise)
                .fail(function (error) {
                    if ($assetsPromise) {
                        $assetsPromise.abort();
                    }
                    scope.ready();
                    scope.broadcast('asseterror', error);
                    scope.broadcast('fail', error);
                })
                .then(completeInit)
                .promise({
                    abort: function () {
                        $assetsPromise = null;
                        $loadMetadataPromise.abort();
                        $loadStylesheetPromise.abort();
                        if ($pageOneContentPromise) {
                            $pageOneContentPromise.abort();
                        }
                        if ($pageOneTextPromise) {
                            $pageOneTextPromise.abort();
                        }
                    }
                });
        }
function () {
            var $loadStylesheetPromise,
                $loadMetadataPromise,
                $pageOneContentPromise,
                $pageOneTextPromise;

            if ($assetsPromise) {
                return;
            }

            $loadMetadataPromise = scope.get('metadata');
            $loadMetadataPromise.then(function handleMetadataResponse(metadata) {
                config.metadata = metadata;
            });

            // don't load the stylesheet for IE < 9
            if (browser.ielt9) {
                stylesheetEl = util.insertCSS('');
                config.stylesheet = stylesheetEl.styleSheet;
                $loadStylesheetPromise = $.when('').promise({
                    abort: function () {}
                });
            } else {
                $loadStylesheetPromise = scope.get('stylesheet');
                $loadStylesheetPromise.then(function handleStylesheetResponse(cssText) {
                    stylesheetEl = util.insertCSS(cssText);
                    config.stylesheet = stylesheetEl.sheet;
                });
            }


            // load page 1 assets immediately if necessary
            if (config.autoloadFirstPage &&
                (!config.pageStart || config.pageStart === 1)) {
                if (support.svg && config.useSVG) {
                    $pageOneContentPromise = scope.get('page-svg', 1);
                } else if (config.conversionIsComplete) {
                    // unfortunately, page-1.png is not necessarily available
                    // on View API's document.viewable event, so we can only
                    // prefetch page-1.png if conversion is complete
                    $pageOneContentPromise = scope.get('page-img', 1);
                }
                if (config.enableTextSelection) {
                    $pageOneTextPromise = scope.get('page-text', 1);
                }
            }

            // when both metatadata and stylesheet are done or if either fails...
            $assetsPromise = $.when($loadMetadataPromise, $loadStylesheetPromise)
                .fail(function (error) {
                    if ($assetsPromise) {
                        $assetsPromise.abort();
                    }
                    scope.ready();
                    scope.broadcast('asseterror', error);
                    scope.broadcast('fail', error);
                })
                .then(completeInit)
                .promise({
                    abort: function () {
                        $assetsPromise = null;
                        $loadMetadataPromise.abort();
                        $loadStylesheetPromise.abort();
                        if ($pageOneContentPromise) {
                            $pageOneContentPromise.abort();
                        }
                        if ($pageOneTextPromise) {
                            $pageOneTextPromise.abort();
                        }
                    }
                });
        }
function ( ) { var $loadStylesheetPromise , $loadMetadataPromise , $pageOneContentPromise , $pageOneTextPromise ; if ( $assetsPromise ) { return ; } $loadMetadataPromise = scope . get ( 'metadata' ) ; $loadMetadataPromise . then ( function handleMetadataResponse ( metadata ) { config . metadata = metadata ; } ) ; // don't load the stylesheet for IE < 9 if ( browser . ielt9 ) { stylesheetEl = util . insertCSS ( '' ) ; config . stylesheet = stylesheetEl . styleSheet ; $loadStylesheetPromise = $ . when ( '' ) . promise ( { abort : function ( ) { } } ) ; } else { $loadStylesheetPromise = scope . get ( 'stylesheet' ) ; $loadStylesheetPromise . then ( function handleStylesheetResponse ( cssText ) { stylesheetEl = util . insertCSS ( cssText ) ; config . stylesheet = stylesheetEl . sheet ; } ) ; } // load page 1 assets immediately if necessary if ( config . autoloadFirstPage && ( ! config . pageStart || config . pageStart === 1 ) ) { if ( support . svg && config . useSVG ) { $pageOneContentPromise = scope . get ( 'page-svg' , 1 ) ; } else if ( config . conversionIsComplete ) { // unfortunately, page-1.png is not necessarily available // on View API's document.viewable event, so we can only // prefetch page-1.png if conversion is complete $pageOneContentPromise = scope . get ( 'page-img' , 1 ) ; } if ( config . enableTextSelection ) { $pageOneTextPromise = scope . get ( 'page-text' , 1 ) ; } } // when both metatadata and stylesheet are done or if either fails... $assetsPromise = $ . when ( $loadMetadataPromise , $loadStylesheetPromise ) . fail ( function ( error ) { if ( $assetsPromise ) { $assetsPromise . abort ( ) ; } scope . ready ( ) ; scope . broadcast ( 'asseterror' , error ) ; scope . broadcast ( 'fail' , error ) ; } ) . then ( completeInit ) . promise ( { abort : function ( ) { $assetsPromise = null ; $loadMetadataPromise . abort ( ) ; $loadStylesheetPromise . abort ( ) ; if ( $pageOneContentPromise ) { $pageOneContentPromise . abort ( ) ; } if ( $pageOneTextPromise ) { $pageOneTextPromise . abort ( ) ; } } } ) ; }
Load the metadata and css for this document
@returns {void}
Load the metadata and css for this document