37 lines
1.1 KiB
Ruby
37 lines
1.1 KiB
Ruby
|
class DesktopWidget
|
||
|
include Mongoid::Document
|
||
|
include Mongoid::Timestamps
|
||
|
include ParserLayoutWidget
|
||
|
|
||
|
field :name
|
||
|
field :author
|
||
|
field :shape, default: "w1 h1"
|
||
|
field :fullsize, :type => Boolean, default: false
|
||
|
field :version, :type => String
|
||
|
field :text_color, :type => String, default: ""
|
||
|
field :bg_color, :type => String, default: ""
|
||
|
field :icon, default: "icon.png"
|
||
|
|
||
|
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
|
||
|
has_one :widget_layout, :autosave => true, :dependent => :destroy
|
||
|
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
|
||
|
has_many :javascripts, as: :js, :autosave => true, :dependent => :destroy
|
||
|
has_and_belongs_to_many :desktops, :autosave => true
|
||
|
has_many :tiles, :autosave => true
|
||
|
|
||
|
accepts_nested_attributes_for :images, :allow_destroy => true
|
||
|
accepts_nested_attributes_for :javascripts, :allow_destroy => true
|
||
|
|
||
|
after_save :parse_css_for_images
|
||
|
|
||
|
# belongs_to :desktop
|
||
|
|
||
|
|
||
|
protected
|
||
|
|
||
|
def parse_css_for_images
|
||
|
self.css_default.parse_urls
|
||
|
parse_widget_for_images(self)
|
||
|
end
|
||
|
|
||
|
end
|