+# page header for signed in user\r
class Pettanr.Views.User.Account extends Backbone.View\r
tagName: 'div'\r
\r
initialize: (options) ->\r
- @operators = options.operators\r
- @author = @operators.author\r
- @artist = @operators.artist\r
+ @author = Pettanr.cache.operators.author\r
+ @artist = Pettanr.cache.operators.artist\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ @logo = new Pettanr.Views.Common.Logo({})\r
+ @listenTo(@logo, 'click', @logo_click)\r
+ this.$el.append(@logo.render().el)\r
if @author\r
@author_view = @author.icon_with_caption_view()\r
@listenTo(@author_view, 'click', @author_click)\r
+ this.$el.append(@author_view.render().el)\r
if @artist\r
@artist_view = @artist.icon_with_caption_view()\r
@listenTo(@artist_view, 'click', @artist_click)\r
- \r
- render: () ->\r
- this.$el.html('')\r
- if @author_view\r
- this.$el.append(@author_view.render().el)\r
- if @artist_view\r
this.$el.append(@artist_view.render().el)\r
+ if @author\r
+ @quick = new Pettanr.Views.User.Account.Quick()\r
+ @listenTo(@quick, 'click:mydoc', @click_mydoc)\r
+ @listenTo(@quick, 'click:mynew', @click_mynew)\r
+ this.$el.append(@quick.render().el)\r
sign_out = new Tag.A({\r
attr: {href: '/users/sign_out'}, \r
class_name: 'sign_out', \r
content: 'sign out'\r
})\r
+ @listenTo(sign_out, 'click', @sign_out_click)\r
this.$el.append(sign_out.render().el)\r
- @delegateEvents({'click .sign_out': 'sign_out'})\r
this\r
\r
+ logo_click: () ->\r
+ @trigger('http_get', '')\r
+ \r
author_click: () ->\r
- @trigger('navigate', @author_view.url())\r
+ @trigger('http_get', @author_view.url())\r
\r
artist_click: () ->\r
- @trigger('navigate', @artist_view.url())\r
- \r
- sign_out: () ->\r
- user = new Backbone.Model({id: 0})\r
- user.url = '/users/sign_out'\r
- user.destroy({success: () ->\r
- r = new Pettanr.Views.Top.Index({})\r
- $("#header").html(r.render().el)\r
- $("#pettanr").html('')\r
- })\r
+ @trigger('http_get', @artist_view.url())\r
+ \r
+ sign_out_click: () ->\r
+ @trigger('http_post', 'users/sign_out')\r
+ return false\r
+ \r
+ click_mydoc: (url) ->\r
+ @trigger('http_get', url)\r
+ return false\r
+ \r
+ click_mynew: (url) ->\r
+ @trigger('http_get', url)\r
return false\r
\r
+class Pettanr.Views.User.Account.Quick extends Backbone.View\r
+ tagName: 'span'\r
+ \r
+ initialize: (options) ->\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ @home()\r
+ @create()\r
+ this\r
+ \r
+ home: () ->\r
+ params = {\r
+ controller: 'folders',\r
+ action: 'index',\r
+ path: '/my documents/create/'\r
+ }\r
+ list = Locmare.ListGroup.list(\r
+ 'folders', 'index', params\r
+ )\r
+ list.open(() =>\r
+ if !_.isEmpty(list.items())\r
+ @mydoc = list.items()[0]\r
+ @add_mydoc()\r
+ )\r
+ \r
+ create: () ->\r
+ params = {\r
+ controller: 'folders',\r
+ action: 'index',\r
+ path: '/my documents/'\r
+ }\r
+ list = Locmare.ListGroup.list(\r
+ 'folders', 'index', params\r
+ )\r
+ list.open(() =>\r
+ if !_.isEmpty(list.items())\r
+ @mynew = list.items()[0]\r
+ @add_mynew()\r
+ )\r
+ \r
+ add_mydoc: () ->\r
+ mydoc_icon = new Pettanr.Views.User.Account.LinkedMydocIcon({item: @mydoc, half: true})\r
+ @listenTo(mydoc_icon, 'click', @click_mydoc_icon)\r
+ this.$el.append(mydoc_icon.render().el)\r
+ \r
+ add_mynew: () ->\r
+ mynew_icon = new Pettanr.Views.User.Account.LinkedCreateIcon({item: @mynew, half: true})\r
+ @listenTo(mynew_icon, 'click', @click_mynew_icon)\r
+ this.$el.append(mynew_icon.render().el)\r
+ \r
+ click_mydoc_icon: () ->\r
+ @trigger('click:mydoc', @mydoc.show_url())\r
+ \r
+ click_mynew_icon: () ->\r
+ @trigger('click:mynew', @mynew.show_url())\r
+ \r
+class Pettanr.Views.User.Account.LinkedMydocIcon extends Tag.A\r
+ \r
+ initialize: (options) ->\r
+ item = options.item\r
+ half = options.half\r
+ img = new Pettanr.Image.SymbolImg({\r
+ attr: {src: '/images/home.gif'}, half: half\r
+ })\r
+ super({\r
+ attr: {href: '/' + item.show_url()}, \r
+ content: img.render().el\r
+ })\r
+ \r
+class Pettanr.Views.User.Account.LinkedCreateIcon extends Tag.A\r
+ \r
+ initialize: (options) ->\r
+ item = options.item\r
+ half = options.half\r
+ img = new Pettanr.Image.SymbolImg({\r
+ attr: {src: '/images/inspire.gif'}, half: half\r
+ })\r
+ super({\r
+ attr: {href: '/' + item.show_url()}, \r
+ content: img.render().el\r
+ })\r
+ \r