Sha256: 4dd797d61cff3a00b7ecb363ab2d4150e903da8eefbc11ec093f087a331e988b

Contents?: true

Size: 1.21 KB

Versions: 13

Compression:

Stored size: 1.21 KB

Contents

pageflow.linkmapPage.RemoteImage = (function() {
  function RemoteImage(url, image) {
    this.width = function() {
      return image.width;
    };

    this.height = function() {
      return image.height;
    };

    this.draw = function(context, options) {
      if (options.disableImageSmoothing) {
        context.imageSmoothingEnabled = false;
      }

      context.drawImage(image,
                        0,
                        0,
                        options.width,
                        image.height * (options.width / image.width));
    };
  }

  RemoteImage.load = function(url) {
    return new $.Deferred(function(deferred) {
      var image = new Image();

      image.onload = onLoad;
      image.onerror = onError;
      image.crossOrigin = 'Anonymous';
      image.src = url;

      function onLoad() {
        deferred.resolve(new pageflow.linkmapPage.RemoteImage(url, image));
      }

      function onError() {
        deferred.reject(loadError(url));
      }
    }).promise();
  };

  return RemoteImage;

  function loadError(url) {
    var error = new Error('Error while loading ' + url + '.');
    error.i18nKey = 'pageflow.linkmap_page.errors.loading_remote_image_failed';

    return error;
  }
}());

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
pageflow-linkmap-page-2.10.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.9.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.8.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.7.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.7.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.6.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.6.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.5.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.4.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.3.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-2.0.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js