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=cec6aa9b8287a96380222ba8971803f263d1d68b;hb=d7c8065be895b67dc453b0e11ad0f259f1ca6706;hpb=99f2d489050575e3ff46f6e67b9c1b792ef0eb31 diff --git a/app/assets/javascripts/models/picture.js.coffee b/app/assets/javascripts/models/picture.js.coffee index cec6aa9b..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,36 +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) -> - _this = this - this.fetch({cache: true}).done -> - cb(_this.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() @@ -75,12 +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() - initialize: () -> - if @id - @url = @url + @id + initialize: (attr = {}, options = {}) -> + super(attr, options)