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
@listenTo(@root, 'click', @click_root)\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\r
\r
+ enable: () ->\r
+ @power = true\r
+ @render()\r
+ \r
+ disable: () ->\r
+ @power = false\r
+ @render()\r
+ \r
# push history\r
- navigate: (params) ->\r
- # get caption and icon\r
+ push: (params, options) ->\r
+ if @power\r
+ @list.push(params, options)\r
\r
click_back: () ->\r
@list.back()\r
click_root: () ->\r
@trigger('http_get', 'folders/root')\r
\r
+ http_get: (url) ->\r
+ @trigger('http_get', url)\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\r
+ content: icon.render().el\r
})\r
@listenTo(@button, 'click', @click)\r
\r
render: () ->\r
- this.$el.html(@button.render().el)\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\r
+ content: icon.render().el\r
})\r
@listenTo(@button, 'click', @click)\r
- \r
- render: () ->\r
- this.$el.html(@button.render().el)\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
+ tagName: 'div'\r
+ className: 'history-list'\r
+ \r
+ initialize: (options) ->\r
+ @buttons = []\r
+ @cursor = null\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ _.each @buttons, (button) =>\r
+ this.$el.append(button.render().el)\r
+ this\r
+ \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
+ \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
+ \r
+class Pettanr.Views.History.List.Log extends Backbone.View\r
+ tagName: 'div'\r
+ className: 'history-list-log'\r
+ \r
+ initialize: (options) ->\r
+ @params = options.params\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
+ content: icon.render().el\r
+ })\r
+ @listenTo(@button, 'click', @click)\r
+ this.$el.append(@button.render().el)\r
+ this\r
+ \r
+ catch: () ->\r
+ this.$el.css('border-width', '3px')\r
+ \r
+ release: () ->\r
+ this.$el.css('border-width', '0px')\r
+ \r
+ click: () ->\r
+ @trigger('click')\r
\r
class Pettanr.Views.History.Root extends Backbone.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\r
+ content: icon.render().el\r
})\r
@listenTo(@button, 'click', @click)\r
\r
render: () ->\r
- this.$el.html(@button.render().el)\r
+ this.$el.html('')\r
+ this.$el.append(@button.render().el)\r
this\r
\r
click: () ->\r