class Pettanr.GroundColor extends Peta.Element url: '/ground_colors/' @singular: () -> 'GroundColor' @plural: () -> 'GroundColors' defaults: { id: null, code: 0, } @has_picture: () -> false div_offset: () -> if @get('xy') @get('xy') else 0 div_size: () -> if @get('wh') @get('wh') else 100 - @div_offset() div_x: () -> if @get('orientation') == 0 0 else @div_offset() div_y: () -> if @get('orientation') == 0 @div_offset() else 0 div_width: () -> if @get('orientation') == 0 100 else @div_size() div_height: () -> if @get('orientation') == 0 @div_size() else 100 style: (spot = null, opacity = 20) -> r = { position: 'absolute', 'z-index': @get('z'), top: Pettanr.to_s(@div_y()) + '%', left: Pettanr.to_s(@div_x()) + '%', width: Pettanr.to_s(@div_width()) + '%', height: Pettanr.to_s(@div_height()) + '%', 'background-color': '#' + ('000000' + Pettanr.to_s(@get('code'))).slice(-6) } @merge_opacity(r, opacity) if spot and spot != this r initialize: () -> if @id @url = @url + @id class Pettanr.GroundColor.Collection extends Backbone.Collection model: Pettanr.GroundColor url: '/ground_colors'