X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Ffolder.js.coffee;h=f6caeccabcae95e4622b16027b2e8ad39b41455e;hp=a1fe0f94919e73c5e11d0410406d9576ff6554bd;hb=aa9eca25671c772ffec8f2f65aecc8a978a2f375;hpb=c34d9fccbf3ae4574e81fea35371ed9c5dd1bd15 diff --git a/app/assets/javascripts/models/folder.js.coffee b/app/assets/javascripts/models/folder.js.coffee index a1fe0f94..f6caecca 100644 --- a/app/assets/javascripts/models/folder.js.coffee +++ b/app/assets/javascripts/models/folder.js.coffee @@ -1,5 +1,4 @@ class Pettanr.Folder extends Peta.Owner - url: '' @singular: () -> 'Folder' @@ -15,6 +14,10 @@ class Pettanr.Folder extends Peta.Owner caption: () -> @get('name').replace(/\/$/, '').split('/').pop() + filer_caption: () -> + caption = _.escape(@caption()) + @trigger('ready:caption', caption) + is_remote: () -> if @get('category_id') == 10 true @@ -24,22 +27,40 @@ class Pettanr.Folder extends Peta.Owner remote_name: () -> Pettanr.to_s(@get('controller_name')) + '/' + Pettanr.to_s(@get('action_name')) - initialize: () -> - if @id - @url = @url + @id + remote_url: () -> + c = @get('controller_name') + a = if Pettanr.is_blank(@get('action_name')) + 'index' + else + @get('action_name') + c + '/' + a + + event_name: () -> + a = if Pettanr.is_blank(@get('action_name')) + 'index' + else + @get('action_name') + Pettanr.to_s(@get('controller_name')) + '_' + a + + initialize: (attr = {}, options = {}) -> + super(attr, options) class Pettanr.FolderWatch extends Pettanr.Folder - url: 'watch/' - initialize: () -> - if @id - @url = @url + @id -class Pettanr.Folder.Collection extends Backbone.Collection - model: Pettanr.Folder - url: 'folders' -class Pettanr.Folder.Root extends Backbone.Collection + + initialize: (attr = {}, options = {}) -> + super(attr, options) + @url = @default_url() + '?ref=1' + +class Pettanr.Folder.Root extends Pettanr.Folder model: Pettanr.Folder - url: '/folders/root' + + initialize: (attr = {}, options = {}) -> + super(attr, options) + @url = @default_url() + 'root?ref=1' + class Pettanr.Folder.Children extends Backbone.Collection model: Pettanr.Folder + initialize: (options) -> @url = '/folders/' + options.id.toString() +