app/models/activeadmin_selleo_cms/layout.rb in activeadmin-selleo-cms-0.0.18 vs app/models/activeadmin_selleo_cms/layout.rb in activeadmin-selleo-cms-0.0.20

- old
+ new

@@ -35,16 +35,40 @@ Dir.glob(File.join(Rails.root, 'app/views/layouts/[a-z]*html.erb')).map{|l| l.split('/').last.split('.').first } end end class Section - attr_accessor :name, :type, :toolbar, :attachments + attr_accessor :name, :type, :toolbar, :width, :height, :resize_method def initialize(node) @name = node.attributes["name"].content - @attachments = node.attributes["attachments"] ? true : false @type = node.attributes["data-type"] ? node.attributes["data-type"].content : 'ckeditor' - @toolbar = node.attributes["data-toolbar"] ? node.attributes["data-toolbar"].content : 'Easy' + @attachments = (['files'].include?(@type) or node.attributes["data-attachments"]) ? true : false + @attachment = (['file'].include?(@type) or node.attributes["data-attachment"]) ? true : false + @toolbar = node.attributes["data-toolbar"] ? node.attributes["data-toolbar"].content : 'Minimal' + @width = node.attributes["data-width"] ? node.attributes["data-width"].content : 640 + @height = node.attributes["data-height"] ? node.attributes["data-height"].content : 480 + @resize_method = node.attributes["data-resize-method"] ? node.attributes["data-resize-method"].content : "#" + end + + def text? + ['ckeditor', 'text'].include? @type + end + + def image? + ['image'].include? @type + end + + def images? + ['images'].include? @type + end + + def attachments? + @attachments == true + end + + def attachment? + @attachment == true end end end end