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=27503a8600682302c6205f59ace9f26d3fac9adc;hb=b49c73c78a5625e0b59de9d1a0d5b2f67e853c25;hpb=70027b80e56b5fbea8d63d520fbbf92050959f28 diff --git a/app/assets/javascripts/models/picture.js.coffee b/app/assets/javascripts/models/picture.js.coffee index 27503a86..6dce3159 100644 --- a/app/assets/javascripts/models/picture.js.coffee +++ b/app/assets/javascripts/models/picture.js.coffee @@ -1,14 +1,78 @@ class Pettanr.Picture extends Peta.Content - @single: () -> + + @singular: () -> 'Picture' @plural: () -> 'Pictures' defaults: { - id: 11 + id: null } - initialize: () -> - confirm("Welcome to Panel") - + @trace_routes: () -> + { + resource_picture: ['resource_picture_picture', 'resource_picture'] + } + + is_visible: (operators = Pettanr.cache.operators) -> + return true + + filename: () -> + @get('id') + '.' + @get('ext') + + gifname: () -> + @get('id') + '.gif' + + mime_type: () -> + 'image/' + @get('ext') + + 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: (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() + true + else + false + + @head: (opid) -> + #Picture.find( conditions => ['original_picture_id = ?', opid], :order => 'pictures.revision desc') + + head: () -> + Picture.head(@get('original_picture_id')) + + is_head: () -> + #this == @head() + + subdirs: () -> + if @license_extend().reverse < 0 + [''] + else + ['', 'v', 'h', 'vh'] + + is_showable: (operators = Pettanr.cache.operators) -> + return false if not @original_picture() + return true if @is_own(operators) + #@is_enable() and @is_head() + + initialize: (attr = {}, options = {}) -> + super(attr, options) +