activeadmin-selleo-cms 0.0.43 → 0.0.44

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.
@@ -1,4 +1,5 @@
1
1
  @import 'jquery-ui.css.scss';
2
+ @import 'active_admin/jquery.Jcrop.css';
2
3
 
3
4
  div.translation > input {
4
5
  -webkit-appearance: none;
@@ -0,0 +1,165 @@
1
+ /* jquery.Jcrop.css v0.9.12 - MIT License */
2
+ /*
3
+ The outer-most container in a typical Jcrop instance
4
+ If you are having difficulty with formatting related to styles
5
+ on a parent element, place any fixes here or in a like selector
6
+
7
+ You can also style this element if you want to add a border, etc
8
+ A better method for styling can be seen below with .jcrop-light
9
+ (Add a class to the holder and style elements for that extended class)
10
+ */
11
+ .jcrop-holder {
12
+ direction: ltr;
13
+ text-align: left;
14
+ }
15
+ /* Selection Border */
16
+ .jcrop-vline,
17
+ .jcrop-hline {
18
+ background: #ffffff url("Jcrop.gif");
19
+ font-size: 0;
20
+ position: absolute;
21
+ }
22
+ .jcrop-vline {
23
+ height: 100%;
24
+ width: 1px !important;
25
+ }
26
+ .jcrop-vline.right {
27
+ right: 0;
28
+ }
29
+ .jcrop-hline {
30
+ height: 1px !important;
31
+ width: 100%;
32
+ }
33
+ .jcrop-hline.bottom {
34
+ bottom: 0;
35
+ }
36
+ /* Invisible click targets */
37
+ .jcrop-tracker {
38
+ height: 100%;
39
+ width: 100%;
40
+ /* "turn off" link highlight */
41
+ -webkit-tap-highlight-color: transparent;
42
+ /* disable callout, image save panel */
43
+ -webkit-touch-callout: none;
44
+ /* disable cut copy paste */
45
+ -webkit-user-select: none;
46
+ }
47
+ /* Selection Handles */
48
+ .jcrop-handle {
49
+ background-color: #333333;
50
+ border: 1px #eeeeee solid;
51
+ width: 7px;
52
+ height: 7px;
53
+ font-size: 1px;
54
+ }
55
+ .jcrop-handle.ord-n {
56
+ left: 50%;
57
+ margin-left: -4px;
58
+ margin-top: -4px;
59
+ top: 0;
60
+ }
61
+ .jcrop-handle.ord-s {
62
+ bottom: 0;
63
+ left: 50%;
64
+ margin-bottom: -4px;
65
+ margin-left: -4px;
66
+ }
67
+ .jcrop-handle.ord-e {
68
+ margin-right: -4px;
69
+ margin-top: -4px;
70
+ right: 0;
71
+ top: 50%;
72
+ }
73
+ .jcrop-handle.ord-w {
74
+ left: 0;
75
+ margin-left: -4px;
76
+ margin-top: -4px;
77
+ top: 50%;
78
+ }
79
+ .jcrop-handle.ord-nw {
80
+ left: 0;
81
+ margin-left: -4px;
82
+ margin-top: -4px;
83
+ top: 0;
84
+ }
85
+ .jcrop-handle.ord-ne {
86
+ margin-right: -4px;
87
+ margin-top: -4px;
88
+ right: 0;
89
+ top: 0;
90
+ }
91
+ .jcrop-handle.ord-se {
92
+ bottom: 0;
93
+ margin-bottom: -4px;
94
+ margin-right: -4px;
95
+ right: 0;
96
+ }
97
+ .jcrop-handle.ord-sw {
98
+ bottom: 0;
99
+ left: 0;
100
+ margin-bottom: -4px;
101
+ margin-left: -4px;
102
+ }
103
+ /* Dragbars */
104
+ .jcrop-dragbar.ord-n,
105
+ .jcrop-dragbar.ord-s {
106
+ height: 7px;
107
+ width: 100%;
108
+ }
109
+ .jcrop-dragbar.ord-e,
110
+ .jcrop-dragbar.ord-w {
111
+ height: 100%;
112
+ width: 7px;
113
+ }
114
+ .jcrop-dragbar.ord-n {
115
+ margin-top: -4px;
116
+ }
117
+ .jcrop-dragbar.ord-s {
118
+ bottom: 0;
119
+ margin-bottom: -4px;
120
+ }
121
+ .jcrop-dragbar.ord-e {
122
+ margin-right: -4px;
123
+ right: 0;
124
+ }
125
+ .jcrop-dragbar.ord-w {
126
+ margin-left: -4px;
127
+ }
128
+ /* The "jcrop-light" class/extension */
129
+ .jcrop-light .jcrop-vline,
130
+ .jcrop-light .jcrop-hline {
131
+ background: #ffffff;
132
+ filter: alpha(opacity=70) !important;
133
+ opacity: .70!important;
134
+ }
135
+ .jcrop-light .jcrop-handle {
136
+ -moz-border-radius: 3px;
137
+ -webkit-border-radius: 3px;
138
+ background-color: #000000;
139
+ border-color: #ffffff;
140
+ border-radius: 3px;
141
+ }
142
+ /* The "jcrop-dark" class/extension */
143
+ .jcrop-dark .jcrop-vline,
144
+ .jcrop-dark .jcrop-hline {
145
+ background: #000000;
146
+ filter: alpha(opacity=70) !important;
147
+ opacity: 0.7 !important;
148
+ }
149
+ .jcrop-dark .jcrop-handle {
150
+ -moz-border-radius: 3px;
151
+ -webkit-border-radius: 3px;
152
+ background-color: #ffffff;
153
+ border-color: #000000;
154
+ border-radius: 3px;
155
+ }
156
+ /* Simple macro to turn off the antlines */
157
+ .solid-line .jcrop-vline,
158
+ .solid-line .jcrop-hline {
159
+ background: #ffffff;
160
+ }
161
+ /* Fix for twitter bootstrap et al. */
162
+ .jcrop-holder img,
163
+ img.jcrop-preview {
164
+ max-width: none;
165
+ }
@@ -1,7 +1,7 @@
1
1
  module ActiveadminSelleoCms
2
2
  class Asset < ActiveRecord::Base
3
3
  attr_protected :id
4
- attr_accessor :cover_width, :cover_height, :cover_resize_method
4
+ attr_accessor :cover_width, :cover_height, :cover_resize_method, :crop_x, :crop_y, :crop_w, :crop_h
5
5
 
6
6
  acts_as_list :scope => [:assetable_type, :assetable_id]
7
7
 
@@ -6,15 +6,29 @@ module ActiveadminSelleoCms
6
6
  :url => "/system/cms/images/:id/:style_:basename.:extension",
7
7
  :path => ":rails_root/public/system/cms/images/:id/:style_:basename.:extension",
8
8
  :styles => Proc.new{ |attachment| attachment.instance.image_sizes },
9
- :default_style => :normal
9
+ :default_style => :normal,
10
+ :processors => [:cropper]
10
11
 
11
12
  validates_attachment_size :data, :less_than => 1.megabytes
12
13
  validates_attachment_presence :data
13
14
 
14
15
  attr_protected :id
15
16
 
17
+ after_update :reprocess_image, :if => :cropping?
18
+
19
+ def cropping?
20
+ !crop_x.blank? && !crop_y.blank? && !crop_w.blank? && !crop_h.blank?
21
+ end
22
+
16
23
  def image_sizes
17
- { :normal => "#{image_width || 640}x#{image_height || 480}#{resize_method || "#"}" }
24
+ { :normal => "#{image_width || 640}x#{image_height || 480}#{resize_method || ">"}" }
25
+ end
26
+
27
+ private
28
+
29
+ def reprocess_image
30
+ data.assign(data)
31
+ data.save
18
32
  end
19
33
 
20
34
  end
@@ -48,7 +48,7 @@ module ActiveadminSelleoCms
48
48
  @toolbar = node.attributes["data-toolbar"] ? node.attributes["data-toolbar"].content : 'Minimal'
49
49
  @width = node.attributes["data-width"] ? node.attributes["data-width"].content : 640
50
50
  @height = node.attributes["data-height"] ? node.attributes["data-height"].content : 480
51
- @resize_method = node.attributes["data-resize-method"] ? node.attributes["data-resize-method"].content : "#"
51
+ @resize_method = node.attributes["data-resize-method"] ? node.attributes["data-resize-method"].content : ">"
52
52
  @cover_width = node.attributes["data-cover-width"] ? node.attributes["data-cover-width"].content : 140
53
53
  @cover_height = node.attributes["data-cover-height"] ? node.attributes["data-cover-height"].content : 199
54
54
  @cover_resize_method = node.attributes["data-cover-resize-method"] ? node.attributes["data-cover-resize-method"].content : ">"
File without changes
@@ -0,0 +1,16 @@
1
+ = semantic_form_for [:admin, resource], remote: true, html: { multipart: true } do |form|
2
+
3
+ = form.inputs id: 'image_fields' do
4
+ = form.input :assetable_type, as: :hidden, input_html: { value: resource.assetable_type }
5
+ = form.input :assetable_id, as: :hidden, input_html: { value: resource.assetable_id }
6
+ = form.input :image_width, as: :hidden, input_html: { value: resource.assetable.activeadmin_selleo_cms_section.width }
7
+ = form.input :image_height, as: :hidden, input_html: { value: resource.assetable.activeadmin_selleo_cms_section.height }
8
+ = form.input :resize_method, as: :hidden, input_html: { value: resource.assetable.activeadmin_selleo_cms_section.resize_method }
9
+ = form.input :crop_x, as: :hidden
10
+ = form.input :crop_y, as: :hidden
11
+ = form.input :crop_w, as: :hidden
12
+ = form.input :crop_h, as: :hidden
13
+ %div.jcrop
14
+ = image_tag resource.data.url(:original)
15
+ = form.actions :submit
16
+
@@ -11,3 +11,4 @@
11
11
  = form.input :data, label: "Image", hint: (resource.data.exists? ? image_tag(resource.data.url, style: "max-width:520px") : "No image")
12
12
  = form.input :caption
13
13
  = form.actions :submit
14
+ = link_to_function "Crop image", "cropImage(#{resource.id}, #{resource.assetable.activeadmin_selleo_cms_section.width}, #{resource.assetable.activeadmin_selleo_cms_section.height})" unless resource.data.blank?
@@ -0,0 +1 @@
1
+ <%= render partial: 'crop_form' %>
@@ -1,4 +1,5 @@
1
- = semantic_form_for [:admin, @page], url: (@page.new_record? ? admin_pages_path : admin_page_path(@page.id)), html: { multipart: true } do |form|
1
+ - @inline = defined?(inline)
2
+ = semantic_form_for [:admin, @page], url: (@page.new_record? ? admin_pages_path : admin_page_path(@page.id)), remote: @inline, html: { multipart: true } do |form|
2
3
 
3
4
  %input{name: "_change_layout", type: "hidden"}
4
5
  - @page.new_record? ? @page.initialize_missing_translations : @page.create_missing_translations
@@ -8,8 +9,9 @@
8
9
  -#= @page.errors.full_messages
9
10
 
10
11
  = form.inputs general_options(@page), id: 'id-general-options' do
11
- = form.input :layout_name, collection: ActiveadminSelleoCms::Layout.all.sort, include_blank: false, hint: "The form will reload on change"
12
- = form.input :parent_id, as: :select, collection: nested_set_options(ActiveadminSelleoCms::Page, @page) {|i| "#{'-' * i.level} #{i.title}" }
12
+ - unless @inline
13
+ = form.input :layout_name, collection: ActiveadminSelleoCms::Layout.all.sort, include_blank: false, hint: "The form will reload on change"
14
+ = form.input :parent_id, as: :select, collection: nested_set_options(ActiveadminSelleoCms::Page, @page) {|i| "#{'-' * i.level} #{i.title}" }
13
15
  = form.input :show_in_menu, as: :boolean
14
16
  = form.input :is_published, as: :boolean
15
17
  = form.input :published_at, as: :datetimepicker
@@ -88,11 +90,14 @@
88
90
  });
89
91
 
90
92
  $('#file-manager').dialog({
91
- width: 1200,
93
+ width: 'auto',
92
94
  height: 'auto',
93
95
  title: 'File manager',
94
96
  modal: true,
95
- autoOpen: false
97
+ autoOpen: false,
98
+ resize: function( event, ui ) {
99
+ $(this).dialog("option", "position", ['center', 'center'] );
100
+ }
96
101
  });
97
102
  });
98
103
 
@@ -8,51 +8,51 @@
8
8
  = form.input :meta_keywords, input_html: { class: 'link-url-hide' }
9
9
  = form.input :meta_description, input_html: { rows: 3, class: 'link-url-hide' }
10
10
  = form.input :locale, :as => :hidden, :label => false
11
- -#- unless @page.new_record?
12
- - @section_forms.sort_by{|sf| sf.object.name}.each do |section_form|
13
- %section{:name => section_form.object.name, :id => "id-#{section_form.object.name}"}
14
- = section_form.semantic_fields_for :translations do |section_form_translated|
15
- - if section_form_translated.object.locale.to_sym == locale.code
16
- - section = @page.layout.find_section(section_form.object.name)
17
-
18
- %fieldset.inputs
19
- %legend
20
- %span= "#{section.name.titleize} section"
21
-
22
- %ol
23
- - if section.text?
24
- = section_form_translated.input :body, as: section.type, label: "Content", label: false, input_html: { ckeditor: { toolbar: section.toolbar } }
25
-
26
- = section_form_translated.input :locale, :as => :hidden, :label => false
27
-
28
- - unless @page.new_record?
29
- - if section.attachments?
30
- %li.input
31
- %ol{ :style => "padding-left: 275px;" }
32
- %li= button_to_function t("active_admin.cms.manage_attachments"), "fileManager('#{edit_admin_section_translation_path(section_form_translated.object.id)}')", style: "padding: 5px;"
33
-
34
- - if section.image?
35
- %li.input
36
- %label Image
37
- %ol{ :style => "padding-left: 275px;" }
38
- %li= button_to_function t("active_admin.cms.file_manager.edit_image"), "fileManager('#{section_form_translated.object.image ? edit_admin_image_path(section_form_translated.object.image.id) : new_admin_image_path(image: { assetable_type: section_form_translated.object.class.name, assetable_id: section_form_translated.object.id })}')", style: "padding: 5px;"
39
-
40
- - if section.images?
41
- %li.input
42
- %label Attachments
43
- %ol{ :style => "padding-left: 275px;" }
44
- %li= button_to_function t("active_admin.cms.manage_images"), "fileManager('#{edit_admin_section_translation_path(section_form_translated.object.id)}')", style: "padding: 5px;"
45
-
46
- - if section.attachment?
47
- %li.input
48
- %label Attachment
49
- %ol{ :style => "padding-left: 275px;" }
50
- %li= button_to_function t("active_admin.cms.file_manager.edit_attachment"), "fileManager('#{section_form_translated.object.attachment ? edit_admin_attachment_path(section_form_translated.object.attachment.id): new_admin_attachment_path(image: { assetable_type: section_form_translated.object.class.name, assetable_id: section_form_translated.object.id }) }')", style: "padding: 5px;"
51
-
52
- - if section.related?
53
- %li.input
54
- %ol{ :style => "padding-left: 275px;" }
55
- %li= button_to_function t("active_admin.cms.manage_related"), "fileManager('#{edit_admin_section_translation_path(section_form_translated.object.id)}')", style: "padding: 5px;"
56
-
57
- - else
58
- = ""
11
+ - unless @inline
12
+ - @section_forms.sort_by{|sf| sf.object.name}.each do |section_form|
13
+ %section{:name => section_form.object.name, :id => "id-#{section_form.object.name}"}
14
+ = section_form.semantic_fields_for :translations do |section_form_translated|
15
+ - if section_form_translated.object.locale.to_sym == locale.code
16
+ - section = @page.layout.find_section(section_form.object.name)
17
+
18
+ %fieldset.inputs
19
+ %legend
20
+ %span= "#{section.name.titleize} section"
21
+
22
+ %ol
23
+ - if section.text?
24
+ = section_form_translated.input :body, as: section.type, label: "Content", label: false, input_html: { ckeditor: { toolbar: section.toolbar } }
25
+
26
+ = section_form_translated.input :locale, :as => :hidden, :label => false
27
+
28
+ - unless @page.new_record?
29
+ - if section.attachments?
30
+ %li.input
31
+ %ol{ :style => "padding-left: 275px;" }
32
+ %li= button_to_function t("active_admin.cms.manage_attachments"), "fileManager('#{edit_admin_section_translation_path(section_form_translated.object.id)}')", style: "padding: 5px;"
33
+
34
+ - if section.image?
35
+ %li.input
36
+ %label Image
37
+ %ol{ :style => "padding-left: 275px;" }
38
+ %li= button_to_function t("active_admin.cms.file_manager.edit_image"), "fileManager('#{section_form_translated.object.image ? edit_admin_image_path(section_form_translated.object.image.id) : new_admin_image_path(image: { assetable_type: section_form_translated.object.class.name, assetable_id: section_form_translated.object.id })}')", style: "padding: 5px;"
39
+
40
+ - if section.images?
41
+ %li.input
42
+ %label Attachments
43
+ %ol{ :style => "padding-left: 275px;" }
44
+ %li= button_to_function t("active_admin.cms.manage_images"), "fileManager('#{edit_admin_section_translation_path(section_form_translated.object.id)}')", style: "padding: 5px;"
45
+
46
+ - if section.attachment?
47
+ %li.input
48
+ %label Attachment
49
+ %ol{ :style => "padding-left: 275px;" }
50
+ %li= button_to_function t("active_admin.cms.file_manager.edit_attachment"), "fileManager('#{section_form_translated.object.attachment ? edit_admin_attachment_path(section_form_translated.object.attachment.id): new_admin_attachment_path(image: { assetable_type: section_form_translated.object.class.name, assetable_id: section_form_translated.object.id }) }')", style: "padding: 5px;"
51
+
52
+ - if section.related?
53
+ %li.input
54
+ %ol{ :style => "padding-left: 275px;" }
55
+ %li= button_to_function t("active_admin.cms.manage_related"), "fileManager('#{edit_admin_section_translation_path(section_form_translated.object.id)}')", style: "padding: 5px;"
56
+
57
+ - else
58
+ = ""
@@ -0,0 +1 @@
1
+ <%= render partial: 'form', locals: { inline: true } %>
@@ -0,0 +1,29 @@
1
+ module Paperclip
2
+ class Cropper < Thumbnail
3
+ def initialize(file, options = {}, attachment = nil)
4
+ super
5
+ @current_geometry.width = target.crop_w
6
+ @current_geometry.height = target.crop_h
7
+ end
8
+
9
+ def target
10
+ @attachment.instance
11
+ end
12
+
13
+ def transformation_command
14
+ if @attachment.instance.cropping?
15
+ crop_command = [
16
+ "-crop",
17
+ "#{target.crop_w}x" \
18
+ "#{target.crop_h}+" \
19
+ "#{target.crop_x}+" \
20
+ "#{target.crop_y}",
21
+ "+repage"
22
+ ]
23
+ crop_command + super
24
+ else
25
+ super
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveadminSelleoCms
2
- VERSION = "0.0.43"
2
+ VERSION = "0.0.44"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-selleo-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.43
4
+ version: 0.0.44
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -403,17 +403,22 @@ files:
403
403
  - app/helpers/pages_helper.rb
404
404
  - app/assets/stylesheets/active_admin/jquery-ui.css.scss
405
405
  - app/assets/stylesheets/active_admin/cms.css.scss
406
+ - app/assets/stylesheets/active_admin/jquery.Jcrop.css
407
+ - app/assets/images/activeadmin-selleo-cms/Jcrop.gif
406
408
  - app/assets/javascripts/active_admin.js
407
409
  - app/assets/javascripts/ckeditor/config.js
408
410
  - app/assets/javascripts/ckeditor/plugins/inlinesave/icons/save.png
409
411
  - app/assets/javascripts/ckeditor/plugins/inlinesave/plugin.js
412
+ - app/assets/javascripts/activeadmin-selleo-cms/jquery.Jcrop.js
410
413
  - app/assets/javascripts/activeadmin-selleo-cms/jquery-ui-timepicker-addon.js
411
414
  - app/assets/javascripts/activeadmin-selleo-cms/application.js
412
415
  - app/assets/javascripts/activeadmin-selleo-cms/jquery.mjs.nestedSortable.js
413
416
  - app/assets/javascripts/activeadmin-selleo-cms/custom.js
417
+ - app/assets/javascripts/activeadmin-selleo-cms/inline-editing.js
414
418
  - app/views/admin/sections/_form.html.haml
415
419
  - app/views/admin/sections/update.js.erb
416
420
  - app/views/admin/pages/_js.html.haml
421
+ - app/views/admin/pages/edit.js.erb
417
422
  - app/views/admin/pages/reorder.html.haml
418
423
  - app/views/admin/pages/_form.html.haml
419
424
  - app/views/admin/pages/update_positions.js.erb
@@ -422,10 +427,13 @@ files:
422
427
  - app/views/admin/images/_form.html.haml
423
428
  - app/views/admin/images/new.html.erb
424
429
  - app/views/admin/images/_image.html.haml
430
+ - app/views/admin/images/_crop_form.html.haml
425
431
  - app/views/admin/images/create.js.erb
426
432
  - app/views/admin/images/edit.html.erb
433
+ - app/views/admin/images/crop.js.erb
427
434
  - app/views/admin/images/update.js.erb
428
435
  - app/views/admin/assets/destroy.js.erb
436
+ - app/views/admin/assets/edit.js.erb
429
437
  - app/views/admin/translations/update.js.haml
430
438
  - app/views/admin/related_items/destroy.js.erb
431
439
  - app/views/admin/related_items/_form.html.haml
@@ -467,6 +475,7 @@ files:
467
475
  - config/locales/cms.en.yml
468
476
  - config/initializers/ckeditor.rb
469
477
  - config/initializers/active_admin.rb
478
+ - config/initializers/cropper.rb
470
479
  - config/initializers/formtastic.rb
471
480
  - config/initializers/i18n.rb
472
481
  - config/initializers/acts_as_list.rb