X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpicture.js.coffee;h=6dce3159d05338411e7eb1c762a13cc342e8b7cd;hp=27471271e132099274b7f74393e9b9237790c0db;hb=b49c73c78a5625e0b59de9d1a0d5b2f67e853c25;hpb=787b560f1977baa1786c35a4d6ff91369bc8dc72 diff --git a/app/assets/javascripts/models/picture.js.coffee b/app/assets/javascripts/models/picture.js.coffee index 27471271..6dce3159 100644 --- a/app/assets/javascripts/models/picture.js.coffee +++ b/app/assets/javascripts/models/picture.js.coffee @@ -1,5 +1,4 @@ class Pettanr.Picture extends Peta.Content - url: '/pictures/' @singular: () -> 'Picture' @@ -11,7 +10,12 @@ class Pettanr.Picture extends Peta.Content id: null } - is_visible: (operators) -> + @trace_routes: () -> + { + resource_picture: ['resource_picture_picture', 'resource_picture'] + } + + is_visible: (operators = Pettanr.cache.operators) -> return true filename: () -> @@ -23,35 +27,25 @@ class Pettanr.Picture extends Peta.Content mime_type: () -> 'image/' + @get('ext') - r_url: () -> - '/pictures/' + @filename() - - opt_img_tag: () -> - {src: @r_url(), width: @get('width'), height: @get('height')} - - tmb_opt_img_tag: () -> - new Pettanr.Image.SymbolPicture({ - attr: { - src: @r_url() - }, - picture: this - }) - - tail_opt_img_tag: (img) -> - {src: img, width: @get('width'), height: @get('height')} - - tail_tmb_opt_img_tag: (img) -> - wh = Pettanr.Imager.thumbnail_size(@get('width'), @get('height')) - {src: img, width: wh[0], height: wh[1]} + r_url: (subdir = null) -> + q = if subdir + '?subdir=' + subdir + else + '' + '/pictures/' + @filename() + q alt_name: () -> lgn = Pettanr.to_s(@license().license_group().get('caption')) ln = Pettanr.to_s(@license().get('caption')) lgn + '[' + ln + ']' - symbol_option: (cb) -> - @fetch({cache: true}).done => - cb(@tmb_opt_img_tag()) + symbol_option: (context, options) -> + @retrieve(this, { + success: (symbol_item) => + options.success.call(context, symbol_item.symbol_file()) + fail: (response, opt) => + options.fail.call(context, response, opt) + }) is_enable: () -> if @head().resource_picture() @@ -74,18 +68,11 @@ class Pettanr.Picture extends Peta.Content else ['', 'v', 'h', 'vh'] - is_showable: (operators = null) -> + is_showable: (operators = Pettanr.cache.operators) -> return false if not @original_picture() return true if @is_own(operators) #@is_enable() and @is_head() - credit_icon_view: () -> - new Pettanr.Views.Picture.CreditIcon({item: this}) - - credit_view: (with_icon = true) -> - new Pettanr.Views.Picture.Credit({item: this, with_icon: with_icon}) - - initialize: () -> - if @id - @url = @url + @id + initialize: (attr = {}, options = {}) -> + super(attr, options)