Sha256: 5f5a81753c2099c4011e3b8ad2ec01a47c96d51646e0c6df06fe880984a0d761

Contents?: true

Size: 1.46 KB

Versions: 9

Compression:

Stored size: 1.46 KB

Contents

window.Alchemy = {} if typeof (window.Alchemy) is "undefined"

Alchemy.ImageCropper =

  initialized: false

  init: (box, size_x, size_y, default_box, ratio, true_size) ->
    crop_from_field = $("#essence_picture_crop_from")
    crop_size_field = $("#essence_picture_crop_size")
    options =
      onSelect: (coords) ->
        crop_from_field.val coords.x + "x" + coords.y
        crop_size_field.val coords.w + "x" + coords.h
      setSelect: box
      aspectRatio: (if ratio then ratio else `undefined`)
      minSize: [size_x, size_y]
      boxWidth: 800
      boxHeight: 600
      trueSize: true_size
    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
    unless Alchemy.ImageCropper.initialized
      Alchemy.ImageCropper.api = $.Jcrop("#imageToCrop", options)
      Alchemy.ImageCropper.initialized = true
    dialog = Alchemy.currentDialog()
    if dialog?
      dialog.options.closed = ->
        Alchemy.ImageCropper.destroy()

  undo: ->
    Alchemy.ImageCropper.api.setSelect Alchemy.ImageCropper.box

  reset: ->
    Alchemy.ImageCropper.api.setSelect Alchemy.ImageCropper.default_box
    Alchemy.ImageCropper.crop_from_field.val ""
    Alchemy.ImageCropper.crop_size_field.val ""

  destroy: ->
    if Alchemy.ImageCropper.api
      Alchemy.ImageCropper.api.destroy()
    Alchemy.ImageCropper.initialized = false
    true

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
alchemy_cms-3.0.4 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.3 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.2 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.1 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.0 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.0.rc8 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.0.rc7 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.0.rc6 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee
alchemy_cms-3.0.0.rc5 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee