Sha256: 6b052fb1fc1cce5458c70a60cd41fd58e3ad2be989fd72ad924cc12ca71170cc

Contents?: true

Size: 1.68 KB

Versions: 28

Compression:

Stored size: 1.68 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;
      }
      
      $('#image_cropper_form').submit(Alchemy.ImageCropper.destroy);
      $('.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() {
      Alchemy.ImageCropper.api.destroy();
      Alchemy.ImageCropper.initialized = false;
    }
    
  }
  
})(jQuery);

Version data entries

28 entries across 22 versions & 1 rubygems

Version Path
alchemy_cms-2.0.7 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.6.1 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.5 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.1.beta6 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.0.4 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.1.beta5 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.0.3.1 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.1.beta1 app/assets/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.0.3 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.2 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.1 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.rc6 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.rc5 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.rc4 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.rc3 spec/dummy/public/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.0.rc3 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.rc2 assets/javascripts/alchemy.image_cropper.js
alchemy_cms-2.0.rc2 spec/dummy/public/javascripts/alchemy/alchemy.image_cropper.js
alchemy_cms-2.0.rc1 assets/javascripts/alchemy.image_cropper.js