Skip to content

Instantly share code, notes, and snippets.

@mscottford
Forked from jsqu99/gist:5015728
Last active December 14, 2015 02:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mscottford/5015777 to your computer and use it in GitHub Desktop.
Save mscottford/5015777 to your computer and use it in GitHub Desktop.
<% preview_width, preview_height = proof_file.large.get_version_dimensions %>
<% original_width, original_height = proof_file.original.get_version_dimensions %>
<%= javascript_tag %Q[
function activate_#{proof_file.object_id}() {
// set the 'master' and 'preview' images to be cropped
$('#cropbox').attr('src', '#{proof_file.large.url}');
$('#preview').attr('src', '#{proof_file.large.url}');
// update the width of the preview pane per the selected size
$("#preview_div").css('width', 300 * current_aspect_ratio('#{size_dom_id}'));
// destroy the old cropper
if(typeof jcrop_api != 'undefined') {
jcrop_api.destroy();
}
// create a new cropper
var dims = new Array();
dims[0] = #{original_width};
dims[1] = #{original_height};
var aspect_ratio = current_aspect_ratio('#{size_dom_id}');
// need to set the appropriate horizontal/vertical crop option
if (aspect_ratio == 1) {
$('#vertical').attr('checked', 'checked');
} else {
$('#horizontal').attr('checked', 'checked');
}
current_proof_cropper = new ProofCropper(aspect_ratio, dims);
}
] %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment