Sha256: 51b2439566c294bfe8418575985f40ba764d053c9aaf74568d8df03c02eef208

Contents?: true

Size: 1.39 KB

Versions: 13

Compression:

Stored size: 1.39 KB

Contents

<% content_for(:head) do %>
<%= stylesheet_link_tag "ext/jquery.Jcrop" %>
<%= javascript_include_tag "ext/jquery.Jcrop.min" %>
<script type="text/javascript" charset="utf-8">
$(function() {
  $('#cropbox').Jcrop({
    onChange: update_crop,
    onSelect: update_crop,
    setSelect: [0, 0, 500, 500],
    aspectRatio: <%= @element.opt_image_width %> / <%= @element.opt_image_height %>
  });
});

function update_crop(coords) {
  var rx = 100/coords.w;
  var ry = 100/coords.h;
  $('#preview').css({
    width: Math.round(rx * <%= @element.opt_image_width %>) + 'px',
    height: Math.round(ry * <%= @element.opt_image_height %>) + 'px',
    marginLeft: '-' + Math.round(rx * coords.x) + 'px',
    marginTop: '-' + Math.round(ry * coords.y) + 'px'
  });
  var ratio = <%= @element.opt_image_width %> / <%= @element.opt_image_height %>;
  $("#crop_x").val(Math.round(coords.x));
  $("#crop_y").val(Math.round(coords.y));
  $("#crop_w").val(Math.round(coords.w));
  $("#crop_h").val(Math.round(coords.h));
}
</script>
<% end %>

<%= scribbler_layout do %>
<h3>Bild bearbeiten</h3>

  <%= image_tag @element.image.url, :id => "cropbox" %>

  <%= form_for @element, :url => {:action => "crop_image", :id => @element.id} do |f| %>
    <% for attribute in [:crop_x, :crop_y, :crop_w, :crop_h] %>
      <%= f.hidden_field attribute, :id => attribute %>
    <% end %>
    <p><%= f.submit "Zuschneiden" %></p>
  <% end %>
<% end %>

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
scribble_cms-0.91 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.90 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.89 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.88 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.82 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.8 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.71 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.7 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.6 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.5 app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.0.14a app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.0.13a app/views/scribbler_admin/image_cropper.html.erb
scribble_cms-0.0.1a app/views/scribbler_admin/image_cropper.html.erb