Sha256: e95f6c35ea8617454141c2ab63e7edc7dc7b2fff06c1491dfdc216b2b42ba94e

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

if (typeof(Alchemy) === 'undefined') {
  var Alchemy = {};
}

(function ($) {

  var ImageCropper = {};
  ImageCropper.initialized = false;
  $.extend(Alchemy, ImageCropper);

  Alchemy.ImageCropper = {

    init:function (box, size_x, size_y, default_box, ratio) {
      var crop_from_field = $('#essence_picture_crop_from');
      var crop_size_field = $('#essence_picture_crop_size');
      var options = {
        onSelect:function (coords) {
          crop_from_field.val(coords.x + "x" + coords.y);
          crop_size_field.val(coords.w + "x" + coords.h);
        },
        setSelect:box,
        aspectRatio:ratio ? ratio : undefined,
        minSize:[size_x, size_y]
      };
      Alchemy.ImageCropper.box = box;
      Alchemy.ImageCropper.default_box = default_box;
      Alchemy.ImageCropper.crop_from_field = crop_from_field;
      Alchemy.ImageCropper.crop_size_field = crop_size_field;

      if (!Alchemy.ImageCropper.initialized) {
        Alchemy.ImageCropper.api = $.Jcrop('#imageToCrop', options);
        Alchemy.ImageCropper.initialized = true;
      }
      $('.ui-dialog-titlebar-close').click(Alchemy.ImageCropper.destroy);
    },

    undo:function () {
      Alchemy.ImageCropper.api.setSelect(Alchemy.ImageCropper.box);
    },

    reset:function () {
      Alchemy.ImageCropper.api.setSelect(Alchemy.ImageCropper.default_box);
      Alchemy.ImageCropper.crop_from_field.val('');
      Alchemy.ImageCropper.crop_size_field.val('');
    },

    destroy:function () {
      try {
        Alchemy.ImageCropper.api.destroy();
      } catch (e) {
      } finally {
        Alchemy.ImageCropper.initialized = false;
      }
    }

  }

})(jQuery);

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
alchemy_cms-2.2.rc13 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.2.rc11 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.2.rc8 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.2.rc7 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.2.rc6 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.2.rc3 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.2.rc2 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.2.rc1 app/assets/javascripts/alchemy/alchemy.image_cropper.js