@trigger('click')\r
\r
\r
-class Pettanr.Views.Common.LoadIcon extends Tag.Img\r
+class Pettanr.Views.Common.EmptyIcon extends Tag.Img\r
\r
- initialize: () ->\r
+ initialize: (options) ->\r
@attr = {}\r
@width = Manifest.manifest().magic_numbers['thumbnail_width']\r
@height = Manifest.manifest().magic_numbers['thumbnail_height']\r
@width = Pettanr.to_i(@width/2)\r
@height = Pettanr.to_i(@height/2)\r
- @attr['src'] = '/images/loading.gif'\r
+ @attr['src'] = @file_name()\r
@attr['width'] = @width\r
@attr['height'] = @height\r
@attr['alt'] = 'Loading'\r
attr: @attr,\r
}\r
super(opt)\r
+ \r
+ file_name: () ->\r
+ '/images/empty.gif'\r
\r
+class Pettanr.Views.Common.LoadIcon extends Pettanr.Views.Common.EmptyIcon\r
+ \r
+ file_name: () ->\r
+ '/images/loading.gif'\r
+ \r
+class Pettanr.Views.Common.BackIcon extends Pettanr.Views.Common.EmptyIcon\r
+ \r
+ file_name: () ->\r
+ '/images/back.png'\r
+ \r
+class Pettanr.Views.Common.ForwardIcon extends Pettanr.Views.Common.EmptyIcon\r
+ \r
+ file_name: () ->\r
+ '/images/forward.png'\r
+ \r
+class Pettanr.Views.Common.RootIcon extends Pettanr.Views.Common.EmptyIcon\r
+ \r
+ file_name: () ->\r
+ '/images/root.png'\r
+ \r
class Pettanr.Views.Common.EmptyCaption extends Backbone.View\r
tagName: 'div'\r
className: 'empty'\r
--- /dev/null
+class Pettanr.Views.History extends Backbone.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
+ @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
+ 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
+ \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.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
+ 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
+ @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
+ @model = Manifest.item_name_to_model(@item_name)\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.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
@global_router = new Pettanr.GlobalRouter({operators: @operators})\r
@listenTo(@global_router, 'go', @body_get)\r
@header = new Pettanr.Views.Layout.Sns.Header({parent: this})\r
+ @history = new Pettanr.Views.History({parent: this})\r
+ @listenTo(@history, 'http_get', @body_http_get)\r
@body = new Pettanr.Views.Layout.Sns.Body({parent: this})\r
@footer = new Pettanr.Views.Layout.Sns.Footer({parent: this})\r
\r
render: () ->\r
this.$el.html('')\r
this.$el.append(@header.render().el)\r
+ this.$el.append(@history.render().el)\r
+ rb = new Tag.RowBreak()\r
+ this.$el.append(rb.render().el)\r
this.$el.append(@body.render().el)\r
this.$el.append(@footer.render().el)\r
this\r
test_redirect: (url) ->\r
proxy = @getter_proxy()\r
@stopListening(proxy, 'done') # ignore global routing\r
+ @stopListening(proxy, 'title', @push_history) # ignore push_history\r
proxy.http_get(url, null)\r
\r
sign_in: (user) ->\r
@init_operators(user)\r
@head_http_get('users/account')\r
+ @history.enable()\r
\r
sign_out: () ->\r
@reset_operators()\r
@head_http_get('users/guest')\r
+ @history.disable()\r
\r
head_http_get: (url) ->\r
proxy = new Pettanr.Proxy({operators: @operators})\r
proxy = new Pettanr.Proxy({operators: @operators})\r
@listenTo(proxy, 'ready', @body_ready)\r
@listenTo(proxy, 'title', @body_title)\r
+ @listenTo(proxy, 'title', @push_history)\r
@listenTo(proxy, 'done', @body_done)\r
proxy\r
\r
url = Pettanr.params_to_url(params)\r
@global_router.navigate(url, {trigger: false})\r
\r
+ push_history: (params, str = null) ->\r
+ @history.push(params, str)\r
+ \r
body_title: (params, str = null) ->\r
t = str || I18n.t(params['controller'] + '.' + params['action'] + '.title')\r
site_caption = _.escape(Manifest.manifest().magic_numbers.profile.users.caption)\r