-class Pettanr.Views.History extends Backbone.View\r
+class Pettanr.Views.History extends Pettanr.View\r
tagName: 'div'\r
className: 'history'\r
\r
initialize: (options) ->\r
@power = true\r
- @back = new Pettanr.Views.History.Back({})\r
- @forward = new Pettanr.Views.History.Forward({})\r
- @list = new Pettanr.Views.History.List({})\r
@root = new Pettanr.Views.History.Root({})\r
- @listenTo(@back, 'click', @click_back)\r
- @listenTo(@forward, 'click', @click_forward)\r
- @listenTo(@list, 'http_get', @http_get)\r
+ @list = new Pettanr.Views.History.List({})\r
@listenTo(@root, 'click', @click_root)\r
+ @listenTo(@list, 'click:log', @click_log)\r
\r
render: () ->\r
this.$el.html('')\r
return if !@power\r
- this.$el.append(@back.render().el)\r
- this.$el.append(@forward.render().el)\r
- this.$el.append(@list.render().el)\r
this.$el.append(@root.render().el)\r
+ this.$el.append(@list.render().el)\r
this\r
\r
enable: () ->\r
@render()\r
\r
# push history\r
+ # options: str:page title\r
push: (params, options) ->\r
- if @power\r
- @list.push(params, options)\r
- \r
- click_back: () ->\r
- @list.back()\r
- \r
- click_forward: () ->\r
- @list.forward()\r
+ return if !@power\r
+ @list.push(params, options)\r
\r
click_root: () ->\r
@trigger('http_get', 'folders/root')\r
\r
- http_get: (url) ->\r
- @trigger('http_get', url)\r
+ click_log: (log) ->\r
+ @trigger('get', log.params, null)\r
\r
-class Pettanr.Views.History.Back extends Backbone.View\r
- tagName: 'div'\r
- \r
- initialize: (options) ->\r
- icon = new Pettanr.Views.Common.BackIcon()\r
- @button = new Tag.A({\r
- attr: {href: '#'}, \r
- content: icon.render().el\r
- })\r
- @listenTo(@button, 'click', @click)\r
- \r
- render: () ->\r
- this.$el.html('')\r
- this.$el.append(@button.render().el)\r
- this\r
- \r
- click: () ->\r
- @trigger('click')\r
- \r
-class Pettanr.Views.History.Forward extends Backbone.View\r
- tagName: 'div'\r
- \r
- initialize: (options) ->\r
- \r
- render: () ->\r
- this.$el.html('')\r
- icon = new Pettanr.Views.Common.ForwardIcon()\r
- @button = new Tag.A({\r
- attr: {href: '#'}, \r
- content: icon.render().el\r
- })\r
- @listenTo(@button, 'click', @click)\r
- this.$el.append(@button.render().el)\r
- this\r
- \r
- click: () ->\r
- @trigger('click')\r
- \r
-class Pettanr.Views.History.List extends Backbone.View\r
+class Pettanr.Views.History.List extends Pettanr.View\r
tagName: 'div'\r
className: 'history-list'\r
\r
initialize: (options) ->\r
+ @max_logs = options.max_logs || 10\r
@buttons = []\r
- @cursor = null\r
\r
render: () ->\r
this.$el.html('')\r
this.$el.append(button.render().el)\r
this\r
\r
+ # options: str:page title\r
push: (params, options) ->\r
- @buttons.push(\r
- new Pettanr.Views.History.List.Log({params: params, options: options})\r
- )\r
- @buttons.shift() if @buttons.length > 10\r
- @cursor = @buttons.length - 1\r
- @render()\r
- \r
- back: () ->\r
- return if !@cursor\r
- return if @cursor <= 0\r
- @buttons[@cursor].release()\r
- @cursor--\r
- @buttons[@cursor].catch()\r
- @trigger('http_get', 'folders/root')\r
+ _.last(@buttons).release() if !_.isEmpty(@buttons)\r
+ if @buttons.length > @max_logs\r
+ b = @buttons.shift()\r
+ b.remove()\r
+ button = new Pettanr.Views.History.List.Log({\r
+ params: params, \r
+ selected: true,\r
+ options: options\r
+ })\r
+ @listenTo(button, 'click', @click_log)\r
+ @buttons.push(button)\r
+ this.$el.append(button.render().el)\r
\r
- forward: () ->\r
- return if !@cursor\r
- return if @cursor >= @buttons.length - 1 - 1\r
- @buttons[@cursor].release()\r
- @cursor++\r
- @buttons[@cursor].catch()\r
+ click_log: (log) ->\r
+ @trigger('click:log', log)\r
\r
-class Pettanr.Views.History.List.Log extends Backbone.View\r
+class Pettanr.Views.History.List.Log extends Pettanr.View\r
tagName: 'div'\r
className: 'history-list-log'\r
\r
initialize: (options) ->\r
@params = options.params\r
+ @selected = options.selected\r
@options = options.options\r
# get caption and icon\r
@item_name = Manifest.manifest().singularize(@params['controller'])\r
@controller = Manifest.manifest().controllers[@params['controller']]\r
@action = @controller.actions[@params['action']]\r
@model = Manifest.manifest().models[@action.item_name].classify()\r
- \r
- render: () ->\r
- this.$el.html('')\r
icon = new Pettanr.Image.Icon({item: @model, title: @options, half: true})\r
@button = new Tag.A({\r
- attr: {href: '#'}, \r
+ attr: {href: '/' + @action.url(@params)}, \r
content: icon.render().el\r
})\r
@listenTo(@button, 'click', @click)\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
this.$el.append(@button.render().el)\r
+ @refresh()\r
this\r
\r
+ refresh: () ->\r
+ border = if @selected\r
+ '3px'\r
+ else\r
+ '0px'\r
+ this.$el.css('border-width', border)\r
+ \r
catch: () ->\r
- this.$el.css('border-width', '3px')\r
+ @selected = true\r
+ @refresh()\r
\r
release: () ->\r
- this.$el.css('border-width', '0px')\r
+ @selected = false\r
+ @refresh()\r
\r
click: () ->\r
- @trigger('click')\r
+ @trigger('click', this)\r
\r
-class Pettanr.Views.History.Root extends Backbone.View\r
+class Pettanr.Views.History.Root extends Pettanr.View\r
tagName: 'div'\r
\r
initialize: (options) ->\r
- icon = new Pettanr.Views.Common.RootIcon()\r
- @button = new Tag.A({\r
- attr: {href: '#'}, \r
- content: icon.render().el\r
+ icon = new Pettanr.View.Minicon(Pettanr.View.Image.icon_root_file())\r
+ @button = new Pettanr.View.Button('/', icon.render().el, {\r
+ context: this,\r
+ click: () =>\r
+ @trigger('click')\r
})\r
- @listenTo(@button, 'click', @click)\r
\r
render: () ->\r
this.$el.html('')\r
this.$el.append(@button.render().el)\r
this\r
\r
- click: () ->\r
- @trigger('click')\r
- \r