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 # options: str:page title
\r
29 push: (params, options) ->
\r
31 @list.push(params, options)
\r
34 @trigger('http_get', 'folders/root')
\r
37 @trigger('get', log.params, null)
\r
39 class Pettanr.Views.History.List extends Backbone.View
\r
41 className: 'history-list'
\r
43 initialize: (options) ->
\r
44 @max_logs = options.max_logs || 10
\r
49 _.each @buttons, (button) =>
\r
50 this.$el.append(button.render().el)
\r
53 # options: str:page title
\r
54 push: (params, options) ->
\r
55 _.last(@buttons).release() if !_.isEmpty(@buttons)
\r
56 if @buttons.length > @max_logs
\r
57 b = @buttons.shift()
\r
59 button = new Pettanr.Views.History.List.Log({
\r
64 @listenTo(button, 'click', @click_log)
\r
65 @buttons.push(button)
\r
66 this.$el.append(button.render().el)
\r
69 @trigger('click:log', log)
\r
71 class Pettanr.Views.History.List.Log extends Backbone.View
\r
73 className: 'history-list-log'
\r
75 initialize: (options) ->
\r
76 @params = options.params
\r
77 @selected = options.selected
\r
78 @options = options.options
\r
79 # get caption and icon
\r
80 @item_name = Manifest.manifest().singularize(@params['controller'])
\r
81 @controller = Manifest.manifest().controllers[@params['controller']]
\r
82 @action = @controller.actions[@params['action']]
\r
83 @model = Manifest.manifest().models[@action.item_name].classify()
\r
84 icon = new Pettanr.Image.Icon({item: @model, title: @options, half: true})
\r
85 @button = new Tag.A({
\r
86 attr: {href: '/' + @action.url(@params)},
\r
87 content: icon.render().el
\r
89 @listenTo(@button, 'click', @click)
\r
93 this.$el.append(@button.render().el)
\r
98 border = if @selected
\r
102 this.$el.css('border-width', border)
\r
113 @trigger('click', this)
\r
115 class Pettanr.Views.History.Root extends Backbone.View
\r
118 initialize: (options) ->
\r
119 icon = new Pettanr.Views.Common.RootIcon()
\r
120 @button = new Tag.A({
\r
121 attr: {href: '/'},
\r
122 content: icon.render().el
\r
124 @listenTo(@button, 'click', @click)
\r
128 this.$el.append(@button.render().el)
\r