Sha256: 7a5e4d70dbe48435602878511745dfaeccac4c77c38516de8c873baa8d7c6d01

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 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
        return
      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
    $(".alchemy_overlay").on 'dialogclose', Alchemy.ImageCropper.destroy
    return

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

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

  destroy: ->
    try
      Alchemy.ImageCropper.api.destroy()
    finally
      Alchemy.ImageCropper.initialized = false
    return

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alchemy_cms-2.6.0.rc5 app/assets/javascripts/alchemy/alchemy.image_cropper.js.coffee