OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
authoryasushiito <yas@pen-chan.jp>
Fri, 6 Mar 2015 06:59:05 +0000 (15:59 +0900)
committeryasushiito <yas@pen-chan.jp>
Fri, 6 Mar 2015 06:59:05 +0000 (15:59 +0900)
14 files changed:
app/assets/images/back.png [new file with mode: 0644]
app/assets/images/forward.png [new file with mode: 0644]
app/assets/images/root.png [new file with mode: 0644]
app/assets/javascripts/controllers/folders.js.coffee
app/assets/javascripts/editor/panel_editor/dock.js.coffee
app/assets/javascripts/pettanr/picture.js.coffee
app/assets/javascripts/routes.js.coffee
app/assets/javascripts/views/common.js.coffee
app/assets/javascripts/views/history.js.coffee [new file with mode: 0644]
app/assets/javascripts/views/layout.js.coffee
app/assets/stylesheets/test.css.scss
public/images/back.png [new file with mode: 0644]
public/images/forward.png [new file with mode: 0644]
public/images/root.png [new file with mode: 0644]

diff --git a/app/assets/images/back.png b/app/assets/images/back.png
new file mode 100644 (file)
index 0000000..0dc7815
Binary files /dev/null and b/app/assets/images/back.png differ
diff --git a/app/assets/images/forward.png b/app/assets/images/forward.png
new file mode 100644 (file)
index 0000000..3e5930e
Binary files /dev/null and b/app/assets/images/forward.png differ
diff --git a/app/assets/images/root.png b/app/assets/images/root.png
new file mode 100644 (file)
index 0000000..f5c289f
Binary files /dev/null and b/app/assets/images/root.png differ
index de37cba..e0c6132 100644 (file)
@@ -5,7 +5,6 @@ class Pettanr.FoldersController extends Pettanr.AppController
     @filer_list()\r
   \r
   root: () ->\r
-    @trigger('title', @params)\r
     @set_model()\r
     @item = new Pettanr.Folder.Root()\r
     @item.fetch({cache: true}).done =>\r
@@ -56,8 +55,8 @@ class Pettanr.FoldersController extends Pettanr.AppController
   refresh: (view) ->\r
     @trigger('ready', view)\r
   \r
-  title: (params, str = null) ->\r
-    @trigger('title', @params, str = null)\r
+  title: (params, str) ->\r
+    @trigger('title', params, str)\r
   \r
   done: (url) ->\r
     @trigger('done', url)\r
index fafb917..5a70256 100644 (file)
@@ -189,7 +189,6 @@ class Editor.EditorModule.DockModule.ElementBay extends Editor.EditorModule.Dock
   activate: () ->\r
     _.each @tabs, (tab) ->\r
       return if not tab.element  # without new element tab\r
-      console.log(tab.body.$el.css('display'))\r
       if tab.body.$el.css('display') != 'none'\r
         tab.body.refresh()\r
   \r
index 6f85281..9a519d0 100644 (file)
@@ -25,7 +25,7 @@ class Pettanr.Image.Icon extends Tag.Img
     @attr['width'] = @width\r
     @attr['height'] = @height\r
     @attr['alt'] = @name\r
-    @attr['title'] = @title\r
+    @attr['title'] = options.title || @title\r
     opt = {\r
       attr: @attr,\r
       class_name: @class_name\r
index 22f251a..8a0a3cf 100644 (file)
@@ -1,5 +1,6 @@
 class Pettanr.History extends Backbone.History\r
   @lock_url = null\r
+  \r
   checkUrl: (e) ->\r
     if Pettanr.History.lock_url\r
       if confirm('leave? edit data unsaved')\r
index ca22d5e..67f160a 100644 (file)
@@ -26,15 +26,15 @@ class Pettanr.Views.Common.Logo extends Tag.Span
     @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
@@ -43,7 +43,30 @@ class Pettanr.Views.Common.LoadIcon extends Tag.Img
       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
diff --git a/app/assets/javascripts/views/history.js.coffee b/app/assets/javascripts/views/history.js.coffee
new file mode 100644 (file)
index 0000000..6225c48
--- /dev/null
@@ -0,0 +1,173 @@
+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
index 8de257c..77710fe 100644 (file)
@@ -9,12 +9,17 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     @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
@@ -56,15 +61,18 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
   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
@@ -80,6 +88,7 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     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
@@ -98,6 +107,9 @@ class Pettanr.Views.Layout.Sns extends Pettanr.Views.Layout.Base
     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
index 994e0c0..eb627c2 100644 (file)
@@ -652,6 +652,20 @@ ul.scenarios_elements {
 .logo{
   float: left;
 }
+.history div {
+  float: left;
+}
+
+.history-list {
+  width: 400px; 
+  background-color:#f8f8f8;
+}
+
+.history-list-log {
+  border-width: 0px;
+  border-style:  solid;
+  border-color:   #ef29ef;
+}
 
 ul.pagination {
   list-style-type: none;
diff --git a/public/images/back.png b/public/images/back.png
new file mode 100644 (file)
index 0000000..0dc7815
Binary files /dev/null and b/public/images/back.png differ
diff --git a/public/images/forward.png b/public/images/forward.png
new file mode 100644 (file)
index 0000000..3e5930e
Binary files /dev/null and b/public/images/forward.png differ
diff --git a/public/images/root.png b/public/images/root.png
new file mode 100644 (file)
index 0000000..f5c289f
Binary files /dev/null and b/public/images/root.png differ