OSDN Git Service

fix: fetch fail
[pettanr/pettanr.git] / app / assets / javascripts / pettanr / file.js.coffee
1 class Pettanr.File
2   
3   constructor: (@filename) ->
4   
5 class Pettanr.ImageFile extends Pettanr.File
6   
7   src: () ->
8     @filename
9   
10   width: () ->
11     null
12   
13   height: () ->
14     null
15   
16   real_size: () ->
17     [@width(), @height()]
18   
19   has_size: () ->
20     @width() and @height()
21   
22   tag_options: () ->
23     {}
24   
25   thumbnail_size: () ->
26     if @has_size()
27       Pettanr.View.Image.to_thumbnail_size(@width(), @height())
28     else
29       Pettanr.View.Image.thumbnail_size()
30   
31   minicon_size: () ->
32     if @has_size()
33       Pettanr.View.Image.to_minicon_size(@width(), @height())
34     else
35       Pettanr.View.Image.minicon_size()
36   
37 class Pettanr.PictureFile extends Pettanr.ImageFile
38   
39   constructor: (@item, subdir = null) ->
40     @filename = @item.r_url(subdir)
41   
42   width: () ->
43     Math.abs(@item.get('width'))
44   
45   height: () ->
46     Math.abs(@item.get('height'))
47   
48   tag_options: () ->
49     {}
50