//= require ./manifest/controller/action/base
//= require ./manifest/controller/action/list
//= require ./manifest/controller/action/show
-//= require ./manifest/controller/action/count
//= require ./manifest/controller/action/new
//= require ./manifest/controller/action/edit
//= require ./manifest/controller/action/create
//= require ./locmare/filer/body/file_body/file_item/edit/none
//= require ./locmare/filer/body/file_body/file_item/edit/account
//= require ./locmare/filer/body/file_body/file_item/edit/template
-//= require ./locmare/filer/pager
//= require ./locmare/profiler
//= require ./locmare/profiler/header
//= require ./locmare/profiler/column
//= require ./locmare/form/field/helper/popup
//= require ./locmare/bucket
//= require ./locmare/list_group
+//= require ./locmare/list_group/lib
+//= require ./locmare/list_group/lib/pager
//= require ./locmare/list_group/list/base
//= require ./locmare/list_group/list/public
//= require ./locmare/list_group/list/private
\r
play: () ->\r
@set_play()\r
- @play_list()\r
+ _list = @list\r
+ _this = this\r
+ @item.fetch({cache: true}).done ->\r
+ _list.open(() ->\r
+ _this.redraw_title(_this.params, _this.item.get('title'))\r
+ view = new Pettanr.Views.Scroll.Play({\r
+ el: "#pettanr",\r
+ item: _this.item,\r
+ list: _this.list,\r
+ operators: _this.operators\r
+ })\r
+ view.render()\r
+ )\r
\r
count: () ->\r
\r
\r
init: () ->\r
super()\r
- @model_manifest = Manifest.manifest().models[@item_name()]\r
- @model_list_manifest = @model_manifest.list\r
- @model = Manifest.item_name_to_model @item_name()\r
+ \r
+ model_manifest: () ->\r
+ Manifest.manifest().models[@item_name()]\r
+ \r
+ model: () ->\r
+ Manifest.item_name_to_model(@item_name())\r
\r
item_name: () ->\r
@action_manifest().item_name\r
this.$el.html('')\r
this.$el.append(@header.render().el)\r
this.$el.append(@body.render().el)\r
- this.$el.append(@pager.el) if @pager\r
+ this.$el.append(@pager.render().el) if @pager\r
this\r
\r
model: () ->\r
url: () ->\r
controller = Manifest.manifest().controllers[@item.table_name()]\r
action = controller.actions[@my_manifest.action_name]\r
+ mani = action.original || action\r
params = {\r
controller: controller,\r
action: action,\r
id: @item.get('id'),\r
format: 'html'\r
}\r
- '/' + action.url(params)\r
+ '/' + mani.url(params)\r
\r
this\r
\r
time_ago: () ->\r
- if Pettanr.is_blank(@item.get('updated_at'))\r
- ''\r
- else\r
- $.timeago(@item.get('updated_at'))\r
+ Pettanr.AppHelper.distance_of_time_in_words_to_now(@item.get('updated_at'))\r
\r
is_visible: () ->\r
true\r
+++ /dev/null
-class Locmare.FilerModule.DefaultPager extends Backbone.View\r
- tagName: 'ul'\r
- className: 'pagination'\r
- \r
- initialize: (options) ->\r
- @page_status = options.page_status\r
- @count = @page_status.count\r
- @current_page = @page_status.current_page\r
- @per_page = @page_status.per_page\r
- @window_size = @page_status.window_size\r
- @params = @page_status.params\r
- @parts = []\r
- @total = @count\r
- @total_page = Math.floor(@total / @per_page) + 1\r
- if @total_page > 1\r
- @render()\r
- \r
- render: () ->\r
- @parts = []\r
- @build()\r
- _this = this\r
- this.$el.html('')\r
- _.each @parts, (part) ->\r
- _this.$el.append(part.render().el)\r
- rb = new Tag.RowBreak()\r
- this.$el.append(rb.render().el)\r
- this\r
- \r
- build: () ->\r
- opt = {pager: this, page_status: @page_status}\r
- @parts.push(new Locmare.FilerModule.DefaultPager.FirstPage(opt)) if @hasPreviousPage()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.PrevPage(opt)) if @hasPreviousPage()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.PageGap(opt)) if @hasPreviousPageGap()\r
- f = if @hasPreviousPageGap()\r
- @current_page - @window_size\r
- else\r
- 1\r
- t = if @hasNextPageGap()\r
- @current_page + @window_size\r
- else\r
- @total_page\r
- for page in [f..t]\r
- @parts.push(new Locmare.FilerModule.DefaultPager.Page({pager: this, page: page, page_status: @page_status}))\r
- @parts.push(new Locmare.FilerModule.DefaultPager.PageGap(opt)) if @hasNextPageGap()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.NextPage(opt)) if @hasNextPage()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.LastPage(opt)) if @hasNextPage()\r
- \r
- hasPreviousPage: () ->\r
- @current_page > 1\r
- \r
- hasNextPage: () ->\r
- @current_page < @total_page\r
- \r
- hasPreviousPageGap: () ->\r
- @current_page > @window_size + 1\r
- \r
- hasNextPageGap: () ->\r
- @total_page - @current_page > @window_size\r
- \r
-class Locmare.FilerModule.DefaultPager.FirstPage extends Backbone.View\r
- tagName: 'li'\r
- className: 'first'\r
- \r
- initialize: (options) ->\r
- @page_status = options.page_status\r
- @params = @page_status.params\r
- \r
- render: () ->\r
- my_params = {}\r
- _.extend(my_params, @params)\r
- my_params['page'] = 1\r
- url = Pettanr.url(my_params['controller'], my_params['action'], my_params)\r
- linked_caption = new Tag.A({\r
- attr: {href: '/' + url}, \r
- handler_name: url,\r
- content: '<<'\r
- })\r
- this.$el.html(linked_caption.render().el)\r
- this\r
- \r
-class Locmare.FilerModule.DefaultPager.PrevPage extends Backbone.View\r
- tagName: 'li'\r
- className: 'prev'\r
- \r
- initialize: (options) ->\r
- @page_status = options.page_status\r
- @current_page = @page_status.current_page\r
- @params = @page_status.params\r
- \r
- render: () ->\r
- my_params = {}\r
- _.extend(my_params, @params)\r
- my_params['page'] = @current_page - 1\r
- url = Pettanr.url(my_params['controller'], my_params['action'], my_params)\r
- linked_caption = new Tag.A({\r
- attr: {href: '/' + url}, \r
- handler_name: url,\r
- content: '<'\r
- })\r
- this.$el.html(linked_caption.render().el)\r
- this\r
- \r
- \r
-class Locmare.FilerModule.DefaultPager.PageGap extends Backbone.View\r
- tagName: 'li'\r
- className: 'page-gap'\r
- \r
- render: () ->\r
- this.$el.html('...')\r
- this\r
- \r
-class Locmare.FilerModule.DefaultPager.Page extends Backbone.View\r
- tagName: 'li'\r
- className: 'page'\r
- \r
- initialize: (options) ->\r
- @page_status = options.page_status\r
- @page = options.page\r
- @params = @page_status.params\r
- \r
- render: () ->\r
- my_params = {}\r
- _.extend(my_params, @params)\r
- my_params['page'] = @page\r
- url = Pettanr.url(my_params['controller'], my_params['action'], my_params)\r
- linked_caption = new Tag.A({\r
- attr: {href: '/' + url}, \r
- handler_name: url,\r
- content: @page\r
- })\r
- this.$el.html(linked_caption.render().el)\r
- this\r
- \r
-class Locmare.FilerModule.DefaultPager.NextPage extends Backbone.View\r
- tagName: 'li'\r
- className: 'next'\r
- \r
- initialize: (options) ->\r
- @page_status = options.page_status\r
- @current_page = @page_status.current_page\r
- @params = @page_status.params\r
- \r
- render: () ->\r
- my_params = {}\r
- _.extend(my_params, @params)\r
- my_params['page'] = @current_page + 1\r
- url = Pettanr.url(my_params['controller'], my_params['action'], my_params)\r
- linked_caption = new Tag.A({\r
- attr: {href: '/' + url}, \r
- handler_name: url,\r
- content: '>'\r
- })\r
- this.$el.html(linked_caption.render().el)\r
- this\r
- \r
-class Locmare.FilerModule.DefaultPager.LastPage extends Backbone.View\r
- tagName: 'li'\r
- className: 'last'\r
- \r
- initialize: (options) ->\r
- @page_status = options.page_status\r
- @pager = options.pager\r
- @params = @page_status.params\r
- \r
- render: () ->\r
- my_params = {}\r
- _.extend(my_params, @params)\r
- my_params['page'] = @pager.total_page\r
- url = Pettanr.url(my_params['controller'], my_params['action'], my_params)\r
- linked_caption = new Tag.A({\r
- attr: {href: '/' + url}, \r
- handler_name: url,\r
- content: '>>'\r
- })\r
- this.$el.html(linked_caption.render().el)\r
- this\r
- \r
-class Locmare.FilerModule.MorePager extends Backbone.View\r
- \r
--- /dev/null
+class Locmare.ListGroupModule.LibModule\r
--- /dev/null
+class Locmare.ListGroupModule.LibModule.Pager\r
+ @factory: (page_status, params) ->\r
+ pagers = {\r
+ default: Locmare.ListGroupModule.LibModule.PagerModule.Default,\r
+ offset: Locmare.ListGroupModule.LibModule.PagerModule.Offset,\r
+ unlimited: Locmare.ListGroupModule.LibModule.PagerModule.Unlimited\r
+ }\r
+ c = pagers[page_status.type]\r
+ return null if not page_status.total_page\r
+ new c({page_status: page_status, params: params})\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule\r
+class Locmare.ListGroupModule.LibModule.PagerModule.Default extends Backbone.View\r
+ tagName: 'ul'\r
+ className: 'pagination'\r
+ \r
+ initialize: (options) ->\r
+ @page_status = options.page_status\r
+ @params = options.params\r
+ @total = @page_status.total\r
+ \r
+ @window_size = 3\r
+ @controller = Manifest.manifest().controllers[@params['controller']]\r
+ @action = @controller.actions[@params['action']]\r
+ @action = @action.original if @action.original\r
+ \r
+ @current_page = @page_status.page\r
+ @per_page = @page_status.limit\r
+ @total_page = @page_status.total_page\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ if @hasPreviousPage()\r
+ this.$el.append(\r
+ (new Locmare.ListGroupModule.LibModule.PagerModule.FirstPage({\r
+ parent: this, page: 1, class_name: 'first'\r
+ })).render().el\r
+ )\r
+ if @hasPreviousPage()\r
+ this.$el.append(\r
+ (new Locmare.ListGroupModule.LibModule.PagerModule.PrevPage({\r
+ parent: this, page: @current_page - 1, class_name: 'prev'\r
+ })).render().el\r
+ )\r
+ if @hasPreviousPageGap()\r
+ this.$el.append(\r
+ (new Locmare.ListGroupModule.LibModule.PagerModule.PageGap()).render().el\r
+ )\r
+ _this = this\r
+ _.each @range(), (page) ->\r
+ _this.$el.append(\r
+ (new Locmare.ListGroupModule.LibModule.PagerModule.Page({\r
+ parent: _this, page: page, class_name: 'page'\r
+ })).render().el\r
+ )\r
+ if @hasNextPageGap()\r
+ this.$el.append(\r
+ (new Locmare.ListGroupModule.LibModule.PagerModule.PageGap()).render().el\r
+ )\r
+ if @hasNextPage()\r
+ this.$el.append(\r
+ (new Locmare.ListGroupModule.LibModule.PagerModule.NextPage({\r
+ parent: this, page: @current_page + 1, class_name: 'next'\r
+ })).render().el\r
+ )\r
+ if @hasNextPage()\r
+ this.$el.append(\r
+ (new Locmare.ListGroupModule.LibModule.PagerModule.LastPage({\r
+ parent: this, page: @total_page, class_name: 'last'\r
+ })).render().el\r
+ )\r
+ rb = new Tag.RowBreak()\r
+ this.$el.append(rb.render().el)\r
+ this\r
+ \r
+ range: () ->\r
+ f = if @hasPreviousPageGap()\r
+ @current_page - @window_size\r
+ else\r
+ 1\r
+ t = if @hasNextPageGap()\r
+ @current_page + @window_size\r
+ else\r
+ @total_page\r
+ _.range(f, t)\r
+ \r
+ hasPreviousPage: () ->\r
+ @current_page > 1\r
+ \r
+ hasNextPage: () ->\r
+ @current_page < @total_page\r
+ \r
+ hasPreviousPageGap: () ->\r
+ @current_page > @window_size + 1\r
+ \r
+ hasNextPageGap: () ->\r
+ @total_page - @current_page > @window_size\r
+ \r
+ url: (page) ->\r
+ params = {}\r
+ _.each @params, (v, k) -> # deep copy\r
+ params[k] = v\r
+ params['page'] = page\r
+ params['page_size'] = @per_page\r
+ @action.url params\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule.Part extends Backbone.View\r
+ tagName: 'li'\r
+ \r
+ initialize: (options) ->\r
+ @parent = options.parent\r
+ @page = options.page\r
+ @el.className = options.class_name\r
+ \r
+ render: () ->\r
+ url = @parent.url(@page)\r
+ if @page == @parent.current_page\r
+ this.$el.html(@content())\r
+ else\r
+ linked_caption = new Tag.A({\r
+ attr: {href: '/' + url}, \r
+ handler_name: url,\r
+ content: @content()\r
+ })\r
+ this.$el.html(linked_caption.render().el)\r
+ this\r
+ \r
+ content: () ->\r
+ ''\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule.FirstPage extends Locmare.ListGroupModule.LibModule.PagerModule.Part\r
+ \r
+ content: () ->\r
+ '<<'\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule.PrevPage extends Locmare.ListGroupModule.LibModule.PagerModule.Part\r
+ \r
+ content: () ->\r
+ '<'\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule.PageGap extends Backbone.View\r
+ tagName: 'li'\r
+ className: 'page-gap'\r
+ \r
+ render: () ->\r
+ this.$el.html('...')\r
+ this\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule.Page extends Locmare.ListGroupModule.LibModule.PagerModule.Part\r
+ \r
+ content: () ->\r
+ Pettanr.to_s(@page)\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule.NextPage extends Locmare.ListGroupModule.LibModule.PagerModule.Part\r
+ \r
+ content: () ->\r
+ '>'\r
+ \r
+class Locmare.ListGroupModule.LibModule.PagerModule.LastPage extends Locmare.ListGroupModule.LibModule.PagerModule.Part\r
+ \r
+ content: () ->\r
+ '>>'\r
+ \r
@controller_manifest = Manifest.manifest().controllers[@controller_name]\r
@action_manifest = @controller_manifest.actions[@action_name]\r
@item_name = @action_manifest.item_name\r
- @model_manifest = Manifest.manifest().models[@item_name]\r
@model_class = Manifest.item_name_to_model @item_name\r
@table_name = @model_class.table_name()\r
- \r
+ \r
parse: (res) ->\r
- @s = res.page_status\r
+ @page_status = res.page_status\r
res.list\r
\r
- page_number: (prm = null) ->\r
- page = Pettanr.to_i(parseInt(prm))\r
- page = 1 if page < 1\r
- page\r
- \r
- page_size: (prm) ->\r
- page_size = Pettanr.to_i(parseInt(prm))\r
- page_size = @max_page_size() if page_size > @max_page_size()\r
- page_size = @default_page_size() if page_size < 1\r
- page_size\r
- \r
- default_page_size: () ->\r
- @model_list_manifest.default_page_size\r
- \r
- max_page_size: () ->\r
- @model_list_manifest.max_page_size\r
- \r
items: () ->\r
_this = this\r
_.map @models, (model) ->\r
new Pettanr.CounterModel({}, {url: '/' + @action_manifest.counter_url(@params)})\r
\r
open: (cb) ->\r
- page = @params['page'] \r
- page_size = @params['page_size'] \r
@url = '/' + @action_manifest.url(@params)\r
_this = this\r
- counter = new Locmare.ListGroupModule.Counter({}, {url: '/' + @action_manifest.counter_url(@params)})\r
- counter.fetch({cache: true}).done ->\r
- page_status = new Locmare.ListGroupModule.PageStatus(page, page_size, counter.count(), _this.params)\r
- _this.fetch({cache: true}).done ->\r
- #_this.boost(items)\r
- cb(page_status)\r
- \r
-class Locmare.ListGroupModule.Counter extends Backbone.Model\r
- initialize: (attr, options) ->\r
- @url = options['url']\r
- \r
- count: () ->\r
- @get('count')\r
- \r
-class Locmare.ListGroupModule.PageStatus\r
- \r
- constructor: (@current_page, @per_page, @count, @params) ->\r
- @window_size = 3\r
+ @fetch({cache: true}).done ->\r
+ #_this.boost(items)\r
+ cb()\r
\r
\r
init: () ->\r
super()\r
+ @action_name = @name\r
+ @alias = @args.alias\r
@item_name = @args.item_name\r
@param_id = @args.param_id\r
+ # source manifest of alias manifest\r
+ @original = @args.original\r
+ \r
+ a_arg_names: () ->\r
+ []\r
+ \r
+ b_arg_names: () ->\r
+ ['item_name', 'param_id']\r
+ \r
+ controller: () ->\r
+ @parent\r
+ \r
+ alias_action: () ->\r
+ s = @alias.split('.')\r
+ c = Manifest.manifest().controllers[s[0]]\r
+ c.actions[s[1]]\r
\r
path_name: () ->\r
@parent.name\r
+++ /dev/null
-class Manifest.ControllerModule.ActionModule.ActionCount extends Manifest.ControllerModule.ActionModule.Base\r
- \r
- set_default: () ->\r
- super()\r
- @args.action_name ||= @name.replace(/^count_/, '')\r
- \r
- init: () ->\r
- super()\r
- @action_name = @args.action_name\r
- \r
\r
init: () ->\r
super()\r
- @alias = @args.alias\r
@order = @args.order || 'updated_at'\r
@direction = @args.direction\r
@default_page_size = @args.default_page_size\r
@max_page_size = @args.max_page_size\r
- @counter_name = if @args.counter_name\r
- @args.counter_name\r
- else\r
- if @name == 'index'\r
- 'count'\r
- else\r
- 'count_' + @name\r
\r
- alias_action: () ->\r
- s = @alias.split('.')\r
- c = Manifest.manifest().controllers[s[0]]\r
- c.actions[s[1]]\r
- \r
- counter_url: (params) ->\r
- @encode_url(@counter_name, params)\r
- \r
+ a_arg_names: () ->\r
+ _.union(super(), ['order', 'direction', 'default_page_size', 'max_page_size'])\r
\r
@items = ManifestBase.load_type_name_args(this, @global_json, 'items', Manifest.ItemFactory)\r
@controllers = Manifest.Controller.load(this, @global_json, 'controllers', Manifest.Controller)\r
@models = Manifest.Model.load(this, @global_json, 'models', Manifest.Model)\r
+ @replace_action_alias()\r
true\r
\r
+ replace_action_alias: () ->\r
+ replaces = {}\r
+ _.each @controllers, (controller_manifest, controller_name) ->\r
+ _.each controller_manifest.actions, (action_manifest, action_name) ->\r
+ return if not action_manifest.alias\r
+ alias_action = action_manifest.alias_action()\r
+ return if alias_action.type != action_manifest.type\r
+ args = {}\r
+ _.each action_manifest.a_arg_names(), (name) ->\r
+ args[name] = action_manifest[name] || alias_action[name]\r
+ _.each action_manifest.b_arg_names(), (name) ->\r
+ args[name] = alias_action[name] || action_manifest[name]\r
+ args.original = action_manifest\r
+ json = {type: alias_action.type, args: args}\r
+ new_action_manifest = Manifest.ControllerModule.ActionFactory.factory(\r
+ controller_manifest, action_manifest.name, json, \r
+ action_manifest.module_name, Manifest.ControllerModule.ActionFactory\r
+ )\r
+ replaces[controller_name] ||= {}\r
+ replaces[controller_name][action_name] = new_action_manifest\r
+ _.each replaces, (controller, controller_name) ->\r
+ _.each controller, (action_manifest, action_name) ->\r
+ Manifest.manifest().controllers[controller_name].actions[action_name] = action_manifest\r
+ \r
pluralize: (item_name) ->\r
@item_names[item_name]\r
\r
t: null\r
} \r
\r
+ @licensed_pictures: (scroll_panels) ->\r
+ panels = _.filter(scroll_panels, (sp) ->\r
+ sp.has_panel()\r
+ )\r
+ Pettanr.Panel.licensed_pictures(panels)\r
+ \r
scroll: () ->\r
new Pettanr.Scroll({id: @get('scroll_id')})\r
\r
panel: () ->\r
- new Pettanr.Panel({id: @get('panel_id')})\r
+ new Pettanr.Panel({id: @get('panel_id')}, {with_elements: true})\r
+ \r
+ has_panel: () ->\r
+ if @get('panel_id')\r
+ true\r
+ else\r
+ false\r
\r
initialize: () ->\r
if @id\r
I18n.t(Manifest.manifest().system_resources.select_items[name][index][0])\r
\r
@distance_of_time_in_words_to_now: (datetime) ->\r
- datetime\r
+ if Pettanr.is_blank(datetime)\r
+ ''\r
+ else\r
+ $.timeago(datetime)\r
\r
@cache = {}\r
@credits = {}\r
filer_list: () ->\r
@set_list()\r
_this = this\r
- @list.open((page_status) ->\r
- pager = new Locmare.FilerModule.DefaultPager({page_status: page_status})\r
+ _list = @list\r
+ @list.open(() ->\r
+ pager = Locmare.ListGroupModule.LibModule.Pager.factory(_list.page_status, _this.params)\r
f = new Locmare.Filer({\r
el: "#pettanr",\r
item_name: _this.my_list_model_class.item_name(), \r
\r
set_play: () ->\r
@set_list()\r
- @binder_controller = Manifest.manifest().controllers[@params['controller']]\r
- @binder_action = @my_controller.actions[params['action']]\r
+ @binder_action = @my_action.original\r
+ @binder_controller = @binder_action.controller()\r
@binder_model = Manifest.manifest().models[@binder_action.item_name]\r
@binder_model_class = @binder_model.classify()\r
@item = new @binder_model_class({id: @params['id']})\r
\r
play_list: () ->\r
_this = this\r
- @options = @params\r
- @options['my_play'] = @item.is_own?(@operators)\r
- @item.fetch({cache: true}).done ->\r
- _this.list.open((page_status) ->\r
- console.log _this.list.models\r
- )\r
- false\r
+ _list = @list\r
+ @list.open(() ->\r
+ console.log _this.list.items()\r
+ )\r
+ false\r
\r
show_prof: () ->\r
_this = this\r
this.$el.html(@content)\r
this\r
\r
+class Tag.H2 extends Tag.H3\r
+ tagName: 'h2'\r
+ \r
@Tag = Tag\r
'border-color': 'black', \r
'background-color': 'white'\r
}\r
+ \r
+class Pettanr.Views.Panel.Footer extends Backbone.View\r
+ tagName: 'table'\r
+ className: 'no-border'\r
+ \r
+ initialize: (options) ->\r
+ @panel = options.panel\r
+ @operators = options.operators\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ this.$el.append(\r
+ (new Pettanr.Views.Panel.Icon({item: @panel, half: true})).render().el\r
+ )\r
+ this.$el.append(\r
+ (new Pettanr.Views.Author.Icon({item: @panel.author(), half: true})).render().el\r
+ )\r
+ this.$el.append(Pettanr.AppHelper.distance_of_time_in_words_to_now(@panel.get('updated_at')))\r
+ if @panel.is_own(@operators)\r
+ this.$el.append(\r
+ (new Pettanr.Views.Show.LinkedEditButton({item: @panel})).render().el\r
+ )\r
+ this\r
+ \r
@panel = options.panel\r
@operators = options.operators\r
@spot = options.spot\r
+ \r
+ icon_url = Pettanr.url(@panel.table_name(), 'show', {id: @panel.get('id')})\r
+ caption_url = Pettanr.url(@panel.table_name(), 'show', {id: @panel.get('id')})\r
+ prof_url = Pettanr.url(@panel.table_name(), 'show', {id: @panel.get('id'), format: 'prof'})\r
+ @header = new Pettanr.Views.Scroll.ShowModule.Header({\r
+ item: @panel, \r
+ operators: @operators,\r
+ caption: @panel.get('caption'), \r
+ icon_url: icon_url,\r
+ caption_url: caption_url,\r
+ prof_url: prof_url\r
+ })\r
@body = new Pettanr.Views.Panel.Body({\r
panel: @panel,\r
operators: @operators,\r
spot: @spot\r
})\r
- @credits = new Pettanr.Views.Panel.Show.Credits({panel: @panel})\r
+ @footer = new Pettanr.Views.Panel.Footer({\r
+ panel: @panel,\r
+ operators: @operators\r
+ })\r
+ @credits = new Pettanr.Views.Panel.Show.Credits({pictures: @panel.licensed_pictures()})\r
\r
render: () ->\r
this.$el.html('')\r
+ this.$el.append(@header.render().el)\r
this.$el.append(@body.render().el)\r
+ this.$el.append(@footer.render().el)\r
this.$el.append(@credits.render().el)\r
rb = new Tag.RowBreak()\r
this.$el.append(rb.render().el)\r
className: 'credits'\r
\r
initialize: (options) ->\r
- @panel = options.panel\r
- @pictures = @panel.licensed_pictures()\r
+ @pictures = options.pictures\r
\r
render: () ->\r
_this = this\r
--- /dev/null
+class Pettanr.Views.Scroll.PlayModule\r
+class Pettanr.Views.Scroll.PlayModule.Header extends Pettanr.Views.Show.Header\r
+ \r
+ initialize: (options) ->\r
+ super(options)\r
+ \r
+class Pettanr.Views.Scroll.PlayModule.Owner extends Pettanr.Views.Show.Owner\r
+ \r
+ initialize: (options) ->\r
+ super(options)\r
+ \r
+class Pettanr.Views.Scroll.PlayModule.Footer extends Backbone.View\r
+ tagName: 'table'\r
+ className: 'no-border'\r
+ \r
+ initialize: (options) ->\r
+ @panel = options.panel\r
+ @scroll_panel = options.scroll_panel\r
+ @operators = options.operators\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ this.$el.append(\r
+ (new Pettanr.Views.Panel.Icon({item: @panel, half: true})).render().el\r
+ )\r
+ this.$el.append(\r
+ (new Pettanr.Views.Author.Icon({item: @panel.author(), half: true})).render().el\r
+ )\r
+ this.$el.append(Pettanr.AppHelper.distance_of_time_in_words_to_now(@panel.get('updated_at')))\r
+ #\r
+ this.$el.append(\r
+ (new Pettanr.Views.Panel.Icon({item: @scroll_panel, half: true})).render().el\r
+ )\r
+ this.$el.append(\r
+ (new Pettanr.Views.Author.Icon({item: @panel.author(), half: true})).render().el\r
+ )\r
+ this.$el.append(Pettanr.AppHelper.distance_of_time_in_words_to_now(@scroll_panel.get('updated_at')))\r
+ #\r
+ if @panel.is_own(@operators)\r
+ this.$el.append('')\r
+ this\r
+ \r
+class Pettanr.Views.Scroll.PlayModule.Credits extends Backbone.View\r
+ tagName: 'div'\r
+ className: 'credits'\r
+ \r
+ initialize: (options) ->\r
+ @parent = options.parent\r
+ @licensed_pictures = {}\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ this\r
+ \r
+ push: (append_pictures) ->\r
+ _this = this\r
+ _.each append_pictures, (picture, pid) ->\r
+ return if _this.licensed_pictures[pid]\r
+ _this.licensed_pictures[pid] = picture\r
+ picture.fetch({cache: true}).done ->\r
+ credit = picture.credit_view()\r
+ _this.$el.append(credit.render().el)\r
+ \r
+class Pettanr.Views.Scroll.PlayModule.Panels extends Backbone.View\r
+ tagName: 'div'\r
+ \r
+ initialize: (options) ->\r
+ @parent = options.parent\r
+ @items = options.items\r
+ @credits = options.credits\r
+ @operators = options.operators\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ _this = this\r
+ _.each @items, (scroll_panel) ->\r
+ return if not scroll_panel.has_panel()\r
+ panel = scroll_panel.panel()\r
+ panel.fetch({cache: true}).done ->\r
+ body = new Pettanr.Views.Panel.Body({\r
+ panel: panel,\r
+ operators: _this.operators,\r
+ spot: null\r
+ })\r
+ _this.$el.append(body.render().el)\r
+ footer = new Pettanr.Views.Panel.Footer({\r
+ scroll_panel: scroll_panel,\r
+ panel: panel,\r
+ operators: _this.operators\r
+ })\r
+ _this.$el.append(footer.render().el)\r
+ _this.credits.push(panel.licensed_pictures())\r
+ this\r
+ \r
+class Pettanr.Views.Scroll.PlayModule.Body extends Backbone.View\r
+ tagName: 'div'\r
+ \r
+ initialize: (options) ->\r
+ @parent = options.parent\r
+ @list = options.list\r
+ @operators = options.operators\r
+ @items = @list.items()\r
+ if @items.length < 1\r
+ @render_empty()\r
+ else\r
+ @render()\r
+ \r
+ render_empty: () ->\r
+ this.$el.html('')\r
+ this.$el.append((new Tag.H2({content: I18n.t('scrolls.play.empty')})).render().el)\r
+ this\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ # paginate(@pager)\r
+ credits = new Pettanr.Views.Scroll.PlayModule.Credits({parent: this})\r
+ panels = new Pettanr.Views.Scroll.PlayModule.Panels({\r
+ parent: this,\r
+ items: @items,\r
+ credits: credits,\r
+ operators: @operators\r
+ })\r
+ this.$el.append(panels.render().el)\r
+ this.$el.append(credits.render().el)\r
+ rb = new Tag.RowBreak()\r
+ this.$el.append(rb.render().el)\r
+ # paginate(@pager)\r
+ this\r
+ \r
+class Pettanr.Views.Scroll.Play extends Backbone.View\r
+ tagName: 'div'\r
+ className: 'show'\r
+ \r
+ initialize: (options) ->\r
+ @item = options.item\r
+ @list = options.list\r
+ @operators = options.operators\r
+ icon_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id')})\r
+ caption_url = Pettanr.url(@item.table_name(), 'play', {id: @item.get('id')})\r
+ prof_url = Pettanr.url(@item.table_name(), 'show', {id: @item.get('id'), format: 'prof'})\r
+ @header = new Pettanr.Views.Scroll.PlayModule.Header({\r
+ item: @item, \r
+ operators: @operators,\r
+ caption: @item.get('title'), \r
+ icon_url: icon_url,\r
+ caption_url: caption_url,\r
+ prof_url: prof_url\r
+ })\r
+ @author = new Pettanr.Views.Show.HeaderAuthor({item: @item})\r
+ @body = new Pettanr.Views.Scroll.PlayModule.Body({\r
+ parent: this,\r
+ list: @list, \r
+ operators: @operators\r
+ })\r
+ @owner = new Pettanr.Views.Scroll.PlayModule.Owner({item: @item, operators: @operators})\r
+ \r
+ render: () ->\r
+ this.$el.html('')\r
+ this.$el.append(@header.render().el)\r
+ this.$el.append(@author.render().el)\r
+ this.$el.append(@body.render().el)\r
+ this.$el.append(@owner.render().el) if @item.is_own(@operators)\r
+ this\r
+ \r
this.$el.append(@linked_author.render().el) if @linked_author\r
this\r
\r
+class Pettanr.Views.Show.LinkedEditButton extends Tag.A\r
+ \r
+ initialize: (options) ->\r
+ item = options.item\r
+ edit_url = Pettanr.url(item.table_name(), 'edit', {id: item.get('id')})\r
+ super({\r
+ attr: {href: '/' + edit_url}, \r
+ handler_name: edit_url,\r
+ content: I18n.t('link.edit')\r
+ })\r
+ \r
+class Pettanr.Views.Show.LinkedDestroyButton extends Tag.A\r
+ \r
+ initialize: (options) ->\r
+ item = options.item\r
+ edit_url = Pettanr.url(item.table_name(), 'destroy', {id: item.get('id')})\r
+ super({\r
+ attr: {href: '/' + edit_url}, \r
+ handler_name: edit_url,\r
+ content: I18n.t('link.destroy')\r
+ })\r
+ \r
class Pettanr.Views.Show.OwnerFooter extends Backbone.View\r
tagName: 'div'\r
className: 'show-owner-footer'\r
super(options)\r
@item = options.item\r
@operators = options.operators\r
- @edit_url = Pettanr.url(@item.table_name(), 'edit', {id: @item.get('id')})\r
- @edit = new Tag.A({\r
- attr: {href: '/' + @edit_url}, \r
- handler_name: @edit_url,\r
- content: I18n.t('link.edit')\r
- })\r
- @destroy_url = Pettanr.url(@item.table_name(), 'destroy', {id: @item.get('id')})\r
- @destroy = new Tag.A({\r
- attr: {href: '/' + @destroy_url}, \r
- handler_name: @destroy_url,\r
- content: I18n.t('link.destroy')\r
- })\r
+ @edit = new Pettanr.Views.Show.LinkedEditButton({item: @item})\r
+ @destroy = new Pettanr.Views.Show.LinkedDestroyButton({item: @item})\r
\r
render: () ->\r
this.$el.html('')\r
:filer => @filer
}
}
- format.json {
- res = {
- :page_status => @list.page_status.to_hash,
- # rails3.2 has problem
- # y method defined as private
- # attribute y conflict at PanelPicture, balloon ..etc
- # use i.attributes[name]
- :list => @items.map{|i| i.attributes}
- # :list => @items.to_json
- }
- render json: res.to_json
- }
+ list_json_format @list, format
format.atom
format.rss
end
end
+ def list_json_format list, format
+ format.json {
+ res = {
+ :page_status => list.page_status.to_hash,
+ # rails3.2 has problem
+ # y method defined as private
+ # attribute y conflict at PanelPicture, balloon ..etc
+ # use i.attributes[name]
+ :list => list.items.map{|i| i.attributes}
+ # :list => @items.to_json
+ }
+ render json: res.to_json
+ }
+ end
+
def set_play
set_list
@binder_action = @my_action.original
end
def play_list
- @options = params
- if @item.own?(@operators)
- @list.item_wheres = []
- @list.list_wheres = ['private', 'play']
- end
@items = @list.items #.map {|sp| sp.root }
@count = @list.total
@pager = @list.page_status.pager
def play
set_play
- @list = Locmare::ListGroup.list(
- @my_controller.name,
- @my_action.name, @operators,
- {:id => @item.id, :offset => 0, :limit => -1}# no limit
- )
- @items = @list.items(@operators)
- @count = @list.count @operators
+ play_list
+ # no limit
# no pager
respond_to do |format|
format.html {
@new_story_items = assist_items('home', 'stories')
end
}
- format.json { render json: @items.to_json }
+ list_json_format @list, format
end
end
@pager = @list.page_status.pager
respond_to do |format|
format.html
- format.json { render json: @items.map{|i| i.attributes}.to_json }
+ list_json_format @list, format
format.atom
format.rss
end
end
def create
- @my_model_class = self.class.model
+ set_model
@item = @my_model_class.new
@item.supply_default
@item.attributes = params[@item.item_name]
end
def update
- @my_model_class = self.class.model
+ set_model
@item = @my_model_class.edit(params[:id], @operators)
ot = @item.t
@item.attributes = params[@item.item_name]
@new_panel_items = assist_items('home', 'panels')
end
}
- format.json { render json: @items.to_json }
+ list_json_format @list, format
end
end
end
def play
- params[:offset] = nil
- params[:count] = nil
- params[:page] ||= 1
- params[:page_size] = 1
- set_play
- @list = Locmare::ListGroup.list(
- @my_controller.name,
- @my_action.name, @operators,
- {:id => @item.id, :offset => 0, :limit => -1}# no limit
- )
- @items = @list.items(@operators)
- @count = @list.count @operators
+ play_list
+ # no limit
+ # no pager
respond_to do |format|
format.html {
if @item.own? @operators
@new_sheet_items = assist_items('home', 'sheets')
end
}
- format.json { render json: @items.to_json }
+ list_json_format @list, format
end
end
end
def overwrite operators
- return false unless operators.author
- self.author_id = operators.author.id
end
def self.public_list_where list
def to_hash
{
- :type => :default, :total => @total,
+ :type => :default, :total => @total, :total_page => self.total_page,
:page => self.page, :page_size => self.limit
}
end
def to_hash
{
- :type => :offset, :total => @total,
+ :type => :offset, :total => @total, :total_page => self.total_page,
:offset => self.offset, :count => self.limit
}
end