active_admin_jcrop 0.0.2.alpha → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/active_admin_jcrop/crop_modal.js.coffee +29 -20
- data/app/views/active_admin_jcrop/_jcrop_modal.html.erb +5 -2
- data/config/locales/en.yml +6 -0
- data/config/locales/pt-BR.yml +6 -0
- data/lib/{asset_engine → active_admin_jcrop/asset_engine}/carrier_wave.rb +0 -0
- data/lib/{asset_engine → active_admin_jcrop/asset_engine}/paperclip.rb +0 -0
- data/lib/{asset_engine.rb → active_admin_jcrop/asset_engine.rb} +2 -2
- data/lib/{dsl.rb → active_admin_jcrop/dsl.rb} +0 -0
- data/lib/{engine.rb → active_admin_jcrop/engine.rb} +0 -0
- data/lib/{image_helper.rb → active_admin_jcrop/image_helper.rb} +0 -0
- data/lib/{orm.rb → active_admin_jcrop/orm.rb} +1 -6
- data/lib/{railtie.rb → active_admin_jcrop/railtie.rb} +0 -0
- data/lib/active_admin_jcrop/version.rb +1 -1
- data/lib/active_admin_jcrop.rb +6 -6
- data/lib/formtastic/inputs/jcrop_input.rb +10 -4
- data/test/dummy/app/admin/post.rb +1 -1
- data/test/dummy/log/development.log +4326 -0
- data/test/dummy/public/uploads/post/image/1/thumb_caminhao.jpeg +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2894eb75de440448b3c40d69d7c3daf1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6e600d6b6e57393c380d4f34b7e462c1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e88a13629d2c3498c801d061a01f6bf1 +0 -0
- metadata +13 -11
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4c3e39b5e60f43769fbff60750d0b856f7af024e
         | 
| 4 | 
            +
              data.tar.gz: 7d3377bb521eb54528316a9dfd3d2bb7a6972b86
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 8c094344e92da72037c6887a8a6bd79a6e695ea10bdcf3e8bb7239fa97b59b1e9375c0bbe84245d1b15dee53e4144748938cd455e80a609f44a3b48e9e8b9d32
         | 
| 7 | 
            +
              data.tar.gz: 7205d7d0e048a19552a64805edf4fe5740a70ddfef19f56aa2639e412a448949c5a42dbb66262dfd389012a4087c623598ae23d2519aab71a72e586181bda751
         | 
| @@ -4,6 +4,9 @@ window.active_admin_jcrop = | |
| 4 4 | 
             
                  $('.crop_modal_open').click ->
         | 
| 5 5 | 
             
                    content = $(this).parent().find('.crop_modal_content').clone()
         | 
| 6 6 | 
             
                    image = content.find('img.cropping_image')
         | 
| 7 | 
            +
                    active_admin_jcrop.buttons_text = 
         | 
| 8 | 
            +
                      save_cropped_image: image.data('translateSaveCroppedImage')
         | 
| 9 | 
            +
                      cancel: image.data('translateCancel')
         | 
| 7 10 | 
             
                    active_admin_jcrop.cropper =
         | 
| 8 11 | 
             
                      object_class: image.data('objectClass')
         | 
| 9 12 | 
             
                      object_id: image.data('objectId')
         | 
| @@ -19,26 +22,32 @@ window.active_admin_jcrop = | |
| 19 22 | 
             
                         at: "center",
         | 
| 20 23 | 
             
                         of: window
         | 
| 21 24 | 
             
                      }
         | 
| 22 | 
            -
                      buttons:
         | 
| 23 | 
            -
                         | 
| 24 | 
            -
                          
         | 
| 25 | 
            -
                           | 
| 26 | 
            -
             | 
| 27 | 
            -
                             | 
| 28 | 
            -
                             | 
| 29 | 
            -
             | 
| 30 | 
            -
                               | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 25 | 
            +
                      buttons: [
         | 
| 26 | 
            +
                        {
         | 
| 27 | 
            +
                          text: active_admin_jcrop.buttons_text.save_cropped_image
         | 
| 28 | 
            +
                          click: ->
         | 
| 29 | 
            +
                            text: 'aews'
         | 
| 30 | 
            +
                            cropper = active_admin_jcrop.cropper
         | 
| 31 | 
            +
                            $.ajax
         | 
| 32 | 
            +
                              type: 'PUT'
         | 
| 33 | 
            +
                              url: cropper.jcropper_url
         | 
| 34 | 
            +
                              data:
         | 
| 35 | 
            +
                                image_data: cropper
         | 
| 36 | 
            +
                              success: ->
         | 
| 37 | 
            +
                                console.log('nois')
         | 
| 38 | 
            +
                              error: ->
         | 
| 39 | 
            +
                                alert('There was an error while cropping the image')
         | 
| 40 | 
            +
                              $(@).dialog('close')                
         | 
| 41 | 
            +
                        }
         | 
| 42 | 
            +
                        {
         | 
| 43 | 
            +
                          text: active_admin_jcrop.buttons_text.cancel
         | 
| 44 | 
            +
                          click: ->
         | 
| 45 | 
            +
                            $(@).dialog('close').remove()
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                        }
         | 
| 48 | 
            +
                      ]
         | 
| 49 | 
            +
                      options = $.extend {onSelect: update_cropper, onChange: update_cropper }, image.data('jcropOptions')
         | 
| 50 | 
            +
                      image.Jcrop(options)
         | 
| 42 51 |  | 
| 43 52 | 
             
                  update_cropper = (coords) ->
         | 
| 44 53 | 
             
                    active_admin_jcrop.cropper.crop_x = coords.x
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            <%= link_to " | 
| 1 | 
            +
            <%= link_to I18n.t("active_admin.crop.open_crop_modal").titleize, "#" , class: "button crop_modal_open" %>
         | 
| 2 2 |  | 
| 3 3 | 
             
            <%= content_tag :div, class: "crop_modal_content" do %>
         | 
| 4 4 | 
             
              <center>
         | 
| @@ -6,7 +6,10 @@ | |
| 6 6 | 
             
                  object_class: object.class.to_s.downcase, 
         | 
| 7 7 | 
             
                  object_id: object.id, 
         | 
| 8 8 | 
             
                  crop_field: field,
         | 
| 9 | 
            -
                  jcropper_url: send("jcropper_admin_#{object.class.to_s.downcase}_path")
         | 
| 9 | 
            +
                  jcropper_url: send("jcropper_admin_#{object.class.to_s.downcase}_path"),
         | 
| 10 | 
            +
                  translate_save_cropped_image: I18n.t("active_admin.crop.save_cropped_image").titleize,
         | 
| 11 | 
            +
                  translate_cancel: I18n.t("active_admin.crop.cancel").titleize,
         | 
| 12 | 
            +
                  jcrop_options: jcrop_options.to_json
         | 
| 10 13 | 
             
                  }
         | 
| 11 14 | 
             
                %>
         | 
| 12 15 | 
             
              </center>
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            if Gem::Specification::find_all_by_name('carrierwave').any?
         | 
| 2 | 
            -
              require 'asset_engine/carrier_wave'
         | 
| 2 | 
            +
              require 'active_admin_jcrop/asset_engine/carrier_wave'
         | 
| 3 3 | 
             
            elsif Gem::Specification::find_all_by_name('paperclip').any?
         | 
| 4 | 
            -
              require 'asset_engine/paperclip'
         | 
| 4 | 
            +
              require 'active_admin_jcrop/asset_engine/paperclip'
         | 
| 5 5 | 
             
            end
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| 
            File without changes
         | 
| @@ -13,12 +13,7 @@ module ActiveAdminJcrop | |
| 13 13 | 
             
                  end
         | 
| 14 14 |  | 
| 15 15 | 
             
                  def active_admin_crop!(params)
         | 
| 16 | 
            -
                     | 
| 17 | 
            -
                      require 'asset_engine/carrier_wave'
         | 
| 18 | 
            -
                    elsif defined?(::Paperclip)
         | 
| 19 | 
            -
                      require 'asset_engine/paperclip'
         | 
| 20 | 
            -
                    end
         | 
| 21 | 
            -
             | 
| 16 | 
            +
                    
         | 
| 22 17 | 
             
                    CropFields.each {|f| self.send "#{f}=", params[f] }
         | 
| 23 18 |  | 
| 24 19 | 
             
                    ::ActiveAdminJcrop::AssetEngine.crop!(self, self.crop_field) if self.active_admin_cropping?
         | 
| 
            File without changes
         | 
    
        data/lib/active_admin_jcrop.rb
    CHANGED
    
    | @@ -1,8 +1,8 @@ | |
| 1 1 | 
             
            require "activeadmin"
         | 
| 2 | 
            -
            require "dsl"
         | 
| 3 | 
            -
            require 'asset_engine'
         | 
| 4 | 
            -
            require 'orm'
         | 
| 2 | 
            +
            require "active_admin_jcrop/dsl"
         | 
| 3 | 
            +
            require 'active_admin_jcrop/asset_engine'
         | 
| 4 | 
            +
            require 'active_admin_jcrop/orm'
         | 
| 5 5 | 
             
            require "formtastic/inputs/jcrop_input"
         | 
| 6 | 
            -
            require "engine"
         | 
| 7 | 
            -
            require "railtie"
         | 
| 8 | 
            -
            require 'image_helper'
         | 
| 6 | 
            +
            require "active_admin_jcrop/engine"
         | 
| 7 | 
            +
            require "active_admin_jcrop/railtie"
         | 
| 8 | 
            +
            require 'active_admin_jcrop/image_helper'
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            module Formtastic
         | 
| 2 2 | 
             
              module Inputs
         | 
| 3 | 
            -
                class  | 
| 3 | 
            +
                class JcropableInput < ::Formtastic::Inputs::FileInput
         | 
| 4 4 | 
             
                  include Base
         | 
| 5 5 |  | 
| 6 6 | 
             
                  def to_html
         | 
| @@ -9,18 +9,24 @@ module Formtastic | |
| 9 9 | 
             
                      builder.file_field(method, input_html_options) <<
         | 
| 10 10 | 
             
                      jcrop_feature
         | 
| 11 11 | 
             
                    end
         | 
| 12 | 
            -
                  end
         | 
| 12 | 
            +
                  end      
         | 
| 13 13 |  | 
| 14 14 | 
             
                  private
         | 
| 15 15 |  | 
| 16 16 | 
             
                  def jcrop_feature
         | 
| 17 | 
            -
                    if @object.send(method).present? | 
| 18 | 
            -
                      template.render(partial: "active_admin_jcrop/jcrop_modal", locals: {field: method, object: @object}) 
         | 
| 17 | 
            +
                    if @object.send(method).present?
         | 
| 18 | 
            +
                      template.render(partial: "active_admin_jcrop/jcrop_modal", locals: {field: method, object: @object, jcrop_options: jcrop_options}) 
         | 
| 19 19 | 
             
                    else 
         | 
| 20 20 | 
             
                      ''
         | 
| 21 21 | 
             
                    end
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| 24 | 
            +
                  def jcrop_options
         | 
| 25 | 
            +
                    options[:jcrop_options] ||= {}
         | 
| 26 | 
            +
                    options[:jcrop_options].assert_valid_keys(:aspectRatio, :minSize, :maxSize, :setSelect, :bgColor, :bgOpacity)
         | 
| 27 | 
            +
                    options[:jcrop_options].reverse_merge!(setSelect: [0,0,100,100])
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
             | 
| 24 30 | 
             
                end
         | 
| 25 31 | 
             
              end
         | 
| 26 32 | 
             
            end
         |