1 class Pettanr.Views.History extends Backbone.View
\r
5 initialize: (options) ->
\r
7 @root = new Pettanr.Views.History.Root({})
\r
8 @list = new Pettanr.Views.History.List({})
\r
9 @listenTo(@root, 'click', @click_root)
\r
10 @listenTo(@list, 'click:log', @click_log)
\r
15 this.$el.append(@root.render().el)
\r
16 this.$el.append(@list.render().el)
\r
28 push: (params, options) ->
\r
30 @list.push(params, options)
\r
33 @trigger('http_get', 'folders/root')
\r
36 @trigger('get', log.params, null)
\r
38 class Pettanr.Views.History.List extends Backbone.View
\r
40 className: 'history-list'
\r
42 initialize: (options) ->
\r
43 @max_logs = options.max_logs || 10
\r
48 _.each @buttons, (button) =>
\r
49 this.$el.append(button.render().el)
\r
52 push: (params, options) ->
\r
53 _.last(@buttons).release() if !_.isEmpty(@buttons)
\r
54 if @buttons.length > @max_logs
\r
55 b = @buttons.shift()
\r
57 button = new Pettanr.Views.History.List.Log({
\r
62 @listenTo(button, 'click', @click_log)
\r
63 @buttons.push(button)
\r
64 this.$el.append(button.render().el)
\r
67 @trigger('click:log', log)
\r
69 class Pettanr.Views.History.List.Log extends Backbone.View
\r
71 className: 'history-list-log'
\r
73 initialize: (options) ->
\r
74 @params = options.params
\r
75 @selected = options.selected
\r
76 @options = options.options
\r
77 # get caption and icon
\r
78 @item_name = Manifest.manifest().singularize(@params['controller'])
\r
79 @controller = Manifest.manifest().controllers[@params['controller']]
\r
80 @action = @controller.actions[@params['action']]
\r
81 @model = Manifest.manifest().models[@action.item_name].classify()
\r
82 icon = new Pettanr.Image.Icon({item: @model, title: @options, half: true})
\r
83 @button = new Tag.A({
\r
85 content: icon.render().el
\r
87 @listenTo(@button, 'click', @click)
\r
91 this.$el.append(@button.render().el)
\r
96 border = if @selected
\r
100 this.$el.css('border-width', border)
\r
111 @trigger('click', this)
\r
113 class Pettanr.Views.History.Root extends Backbone.View
\r
116 initialize: (options) ->
\r
117 icon = new Pettanr.Views.Common.RootIcon()
\r
118 @button = new Tag.A({
\r
119 attr: {href: '#'},
\r
120 content: icon.render().el
\r
122 @listenTo(@button, 'click', @click)
\r
126 this.$el.append(@button.render().el)
\r