dist/crocodoc.viewer.js
function(objectType, pageNum) {
            var img = this.getImage(),
                retries = Crocodoc.ASSET_REQUEST_RETRIES,
                loaded = false,
                url = this.getURL(pageNum),
                $deferred = $.Deferred();

            function loadImage() {
                img.setAttribute('src', url);
            }

            function abortImage() {
                if (img) {
                    img.removeAttribute('src');
                }
            }

            // add load and error handlers
            img.onload = function () {
                loaded = true;
                $deferred.resolve(img);
            };

            img.onerror = function () {
                if (retries > 0) {
                    retries--;
                    abortImage();
                    loadImage();
                } else {
                    img = null;
                    loaded = false;
                    $deferred.reject({
                        error: 'image failed to load',
                        resource: url
                    });
                }
            };

            // load the image
            loadImage();

            return $deferred.promise({
                abort: function () {
                    if (!loaded) {
                        abortImage();
                        $deferred.reject();
                    }
                }
            });
        }
function(objectType, pageNum) {
            var img = this.getImage(),
                retries = Crocodoc.ASSET_REQUEST_RETRIES,
                loaded = false,
                url = this.getURL(pageNum),
                $deferred = $.Deferred();

            function loadImage() {
                img.setAttribute('src', url);
            }

            function abortImage() {
                if (img) {
                    img.removeAttribute('src');
                }
            }

            // add load and error handlers
            img.onload = function () {
                loaded = true;
                $deferred.resolve(img);
            };

            img.onerror = function () {
                if (retries > 0) {
                    retries--;
                    abortImage();
                    loadImage();
                } else {
                    img = null;
                    loaded = false;
                    $deferred.reject({
                        error: 'image failed to load',
                        resource: url
                    });
                }
            };

            // load the image
            loadImage();

            return $deferred.promise({
                abort: function () {
                    if (!loaded) {
                        abortImage();
                        $deferred.reject();
                    }
                }
            });
        }
function ( objectType , pageNum ) { var img = this . getImage ( ) , retries = Crocodoc . ASSET_REQUEST_RETRIES , loaded = false , url = this . getURL ( pageNum ) , $deferred = $ . Deferred ( ) ; function loadImage ( ) { img . setAttribute ( 'src' , url ) ; } function abortImage ( ) { if ( img ) { img . removeAttribute ( 'src' ) ; } } // add load and error handlers img . onload = function ( ) { loaded = true ; $deferred . resolve ( img ) ; } ; img . onerror = function ( ) { if ( retries > 0 ) { retries -- ; abortImage ( ) ; loadImage ( ) ; } else { img = null ; loaded = false ; $deferred . reject ( { error : 'image failed to load' , resource : url } ) ; } } ; // load the image loadImage ( ) ; return $deferred . promise ( { abort : function ( ) { if ( ! loaded ) { abortImage ( ) ; $deferred . reject ( ) ; } } } ) ; }
Retrieve the page image asset from the server
@param {string} objectType The type of data being requested
@param {number} pageNum The page number for which to request the page image
@returns {$.Promise}    A promise with an additional abort() method that will abort the img request.
Retrieve the page image asset from the server