Class: RailsAdmin::JcropController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RailsAdmin::JcropController
- Defined in:
- app/controllers/rails_admin/jcrop_controller.rb
Instance Method Summary collapse
Instance Method Details
#edit ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/controllers/rails_admin/jcrop_controller.rb', line 11 def edit = {} [:method] = :put [:'data-title'] = "#{I18n.t("admin.actions.crop.menu").capitalize} #{abstract_model.model.human_attribute_name @field}" = {} [:class] = "jcrop-subject" [:'data-geometry'] = geometry(@object.send(@field).path).join(",") if @fit_image fit_image_geometry = fit_image_geometry(@object.send(@field).path) [:'style'] = "margin-left: #{375 - (fit_image_geometry[0]/2) - 15}px;" [:style] = "" [:style] << "width: #{fit_image_geometry[0]}px !important;" [:style] << "height: #{fit_image_geometry[1]}px !important;" [:style] << "border: 1px solid #AAA !important;" end respond_to do |format| format.html format.js { render :edit, :layout => false } end end |
#update ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/rails_admin/jcrop_controller.rb', line 37 def update @object.rails_admin_crop! params respond_to do |format| format.html { redirect_to_on_success } format.js do asset = @object.send @field urls = {:original => asset.url} thumbnail_names.each {|name| urls[name] = asset.url(name)} render :json => { :id => @object.id, :label => @model_config.with(:object => @object).object_label, :field => @field, :urls => urls } end end end |