-class Locmare.FilerModule.Pager extends Backbone.View\r
- tagName: 'ul'\r
- className: 'pagination'\r
- \r
- initialize: (options) ->\r
- @filer = options.filer\r
- \r
- total_result: () ->\r
- _this = this\r
- t = @filer.list_result.total\r
- t.fetch().done ->\r
- a = t.count\r
- _this.render()\r
- \r
- list_result: () ->\r
- @filer.list_result\r
- \r
- api_path: () ->\r
- list_result().path\r
- \r
-class Locmare.FilerModule.DefaultPager extends Locmare.FilerModule.Pager\r
+class Locmare.FilerModule.DefaultPager extends Backbone.View\r
tagName: 'ul'\r
className: 'pagination'\r
\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
_this = this\r
@counter.fetch().done ->\r
_this.total = _this.counter.get('count')\r
_this.total_page = Math.floor(_this.total / _this.per_page) + 1\r
- _this.render()\r
+ if _this.total_page > 1\r
+ _this.render()\r
\r
render: () ->\r
@parts = []\r
this\r
\r
build: () ->\r
- @parts.push(new Locmare.FilerModule.DefaultPager.FirstPage({})) if @hasPreviousPage()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.PrevPage({})) if @hasPreviousPage()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.PageGap({})) if @hasPreviousPageGap()\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
else\r
@total_page\r
for page in [f..t]\r
- @parts.push(new Locmare.FilerModule.DefaultPager.Page({page: page}))\r
- @parts.push(new Locmare.FilerModule.DefaultPager.PageGap({})) if @hasNextPageGap()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.NextPage({})) if @hasNextPage()\r
- @parts.push(new Locmare.FilerModule.DefaultPager.LastPage({})) if @hasNextPage()\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
tagName: 'li'\r
className: 'first'\r
\r
+ initialize: (options) ->\r
+ @page_status = options.page_status\r
+ @params = @page_status.params\r
+ \r
render: () ->\r
- this.$el.html('<<')\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 Pettanr.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
- this.$el.html('<')\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 Pettanr.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
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
- this.$el.html(@page)\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 Pettanr.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
- this.$el.html('>')\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 Pettanr.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
- this.$el.html('>>')\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 Pettanr.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 Locmare.FilerModule.Pager\r
+class Locmare.FilerModule.MorePager extends Backbone.View\r
\r