Sha256: e30d4d79cab24ca6b7e85aaa8d7e3a66355865cc7a43c4afb386b0337ad57b6c

Contents?: true

Size: 1.25 KB

Versions: 6

Compression:

Stored size: 1.25 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(canvas, options) {
      options = options || {};
      var context = canvas.getContext('2d');

      if (options.disableImageSmoothing) {
        context.imageSmoothingEnabled = false;
      }

      context.drawImage(image,
                        0,
                        0,
                        canvas.width,
                        canvas.height);
    };
  }

  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

6 entries across 6 versions & 1 rubygems

Version Path
pageflow-linkmap-page-1.5.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-1.4.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-1.3.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-1.2.1 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-1.2.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js
pageflow-linkmap-page-1.1.0 app/assets/javascript/pageflow/linkmap_page/widgets/linkmap/remote_image.js