class Pettanr.Image class Pettanr.Image.Icon extends Tag.Img # attr: {any_attr: 'hoge', ...} # class_name: 'El-Class' # item: item # half: true // half size if you want initialize: (options) -> @item = options.item @half = options.half @class_name = options.class_name @attr = options.attr || {} @width = Manifest.manifest().magic_numbers['thumbnail_width'] @height = Manifest.manifest().magic_numbers['thumbnail_height'] @name = @item.model_name() @title = if @item['get'] # is instance? @name + ' ID:' + Pettanr.to_s(@item.get('id')) else @name if @half @width = Pettanr.to_i(@width/2) @height = Pettanr.to_i(@height/2) @attr['src'] = '/images/' + Pettanr.underscore(@name) + '.gif' @attr['width'] = @width @attr['height'] = @height @attr['alt'] = @name @attr['title'] = options.title || @title opt = { attr: @attr, class_name: @class_name } super(opt) class Pettanr.Image.SymbolPicture extends Tag.Img # show picture as symbol size # attr: {src: '/2.png', alt: 'title', ...} # class_name: 'El-Class' # picture: instance of AnyPicture # half: true // half size if you want initialize: (options) -> @picture = options.picture @class_name = options.class_name @attr = options.attr @half = options.half wh = Pettanr.Imager.thumbnail_size(@picture.get('width'), @picture.get('height')) @width = Math.abs(wh[0]) @height = Math.abs(wh[1]) if @half @width = Pettanr.to_i(@width/2) @height = Pettanr.to_i(@height/2) @attr['width'] = @width @attr['height'] = @height opt = { attr: @attr, class_name: @class_name } super(opt) class Pettanr.Image.SymbolImg extends Tag.Img # show image file as symbol size # attr: {src: '/2.png', alt: 'title', ...} # class_name: 'El-Class' # half: true // half size if you want initialize: (options) -> @class_name = options.class_name @attr = options.attr @half = options.half @width = Manifest.manifest().magic_numbers['thumbnail_width'] @height = Manifest.manifest().magic_numbers['thumbnail_height'] if @half @width = Pettanr.to_i(@width/2) @height = Pettanr.to_i(@height/2) @attr['width'] = @width @attr['height'] = @height opt = { attr: @attr, class_name: @class_name } super(opt) class Pettanr.Image.SymbolImg.Error extends Pettanr.Image.SymbolImg initialize: (options) -> super(options) options ||= {} options.attr ||= {} options.attr.src ||= '/images/error.png'