2012-11-01 12:42:40 +00:00
|
|
|
class DesktopWidget
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include ParserLayoutWidget
|
|
|
|
|
|
|
|
field :name
|
|
|
|
field :author
|
2013-05-14 09:18:05 +00:00
|
|
|
field :shape, default: "w1 h1"
|
2013-05-02 08:45:33 +00:00
|
|
|
field :fullsize, :type => Boolean, default: false
|
2012-11-01 12:42:40 +00:00
|
|
|
field :version, :type => String
|
2013-05-13 09:13:44 +00:00
|
|
|
field :text_color, :type => String, default: ""
|
|
|
|
field :bg_color, :type => String, default: ""
|
2013-05-02 08:45:33 +00:00
|
|
|
field :icon, default: "icon.png"
|
2012-11-01 12:42:40 +00:00
|
|
|
|
2012-11-05 15:04:54 +00:00
|
|
|
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
|
2012-11-01 12:42:40 +00:00
|
|
|
has_one :widget_layout, :autosave => true, :dependent => :destroy
|
2012-11-05 15:04:54 +00:00
|
|
|
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
|
2013-03-25 10:44:06 +00:00
|
|
|
has_many :tiles, :autosave => true
|
2012-11-01 12:42:40 +00:00
|
|
|
|
|
|
|
accepts_nested_attributes_for :images, :allow_destroy => true
|
2012-11-05 15:04:54 +00:00
|
|
|
accepts_nested_attributes_for :javascripts, :allow_destroy => true
|
2012-11-01 12:42:40 +00:00
|
|
|
|
|
|
|
after_save :parse_css_for_images
|
|
|
|
|
|
|
|
# belongs_to :desktop
|
|
|
|
|
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def parse_css_for_images
|
2012-11-05 15:04:54 +00:00
|
|
|
self.css_default.parse_urls
|
2012-11-01 12:42:40 +00:00
|
|
|
parse_widget_for_images(self)
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|