X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpicture.js.coffee;h=4cbe1a377688a8a20d1e6398b453716578704180;hp=9bc47c28c2388c507dc832ec37cd6e6bb2459b4f;hb=d7c8065be895b67dc453b0e11ad0f259f1ca6706;hpb=3f0b76f7b7fddc70ba3badd2a97b2babe9549b79 diff --git a/app/assets/javascripts/models/picture.js.coffee b/app/assets/javascripts/models/picture.js.coffee index 9bc47c28..4cbe1a37 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,34 +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: () -> - @tmb_opt_img_tag() + symbol_option: (context, options) -> + @retrieve(this, { + success: (symbol_item) => + options.success.call(context, symbol_item.to_symbol()) + fail: (response, opt) => + options.fail.call(context, response, opt) + }) is_enable: () -> if @head().resource_picture() @@ -73,29 +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}) - - fetch: (options) -> - if @id - @credit_icon = @credit_icon_view() - @credit = null - f = (data, status) => - @credit = data - @trigger('ready') - $.get(@url + '/credit', null, f, 'html') - super(options) - initialize: (attr = {}, options = {}) -> super(attr, options) - if @id - @url = @url + @id