Skip to content

Instantly share code, notes, and snippets.

@jsqu99
Created February 22, 2013 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jsqu99/5015728 to your computer and use it in GitHub Desktop.
Save jsqu99/5015728 to your computer and use it in GitHub Desktop.
<%= javascript_tag do %>
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 %>');
<% preview_width, preview_height = proof_file.large.get_version_dimensions %>
<% original_width, original_height = proof_file.original.get_version_dimensions %>
// 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);
}
<% end %>
compiles to:
<script type="text/javascript">
//<![CDATA[
....
var aspect_ratio = current_aspect_ratio('ad_hoc_option_values_5062_60');
// 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);
}
//]]>
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment