class Pettanr\r
+ # Foo.class -> Pettanr[@constructor.name]\r
+\r
@is_blank: (str) ->\r
!str?.trim()\r
\r
else\r
false\r
\r
+ @is_number: (str) ->\r
+ if typeof(str) != 'number' && typeof(str) != 'string'\r
+ return false\r
+ else\r
+ n = if typeof(str) == 'string'\r
+ parseInt(str)\r
+ else\r
+ str\r
+ isFinite(n)\r
+ \r
@to_s: (str) ->\r
if @is_a_string(str)\r
str\r
if l.length == 1\r
I18n.t('activerecord.models.' + Pettanr[label].item_name())\r
else\r
- I18n.t('activerecord.models.attribtes.' + Pettanr[l.first].item_name() + '.' + l.last)\r
+ Pettanr.AppHelper.t_a(Pettanr[l.first].item_name(), l.last)\r
\r
+ @t_a: (item_name, attr_name) ->\r
+ I18n.t('activerecord.attributes.' + item_name + '.' + attr_name)\r
+ \r
@t_select_items: (items) ->\r
_.map items, (i) ->\r
[t(i[0]), i[1]]\r
@distance_of_time_in_words_to_now: (datetime) ->\r
datetime\r
\r
+ class Pettanr.CounterModel extends Backbone.Model\r
+ initialize: (attr, options) ->\r
+ @url = options['url']\r
+ \r
+ count: () ->\r
+ @get('count')\r
+ \r
+ class Pettanr.Pager extends Backbone.View\r
+ \r
+ initialize: (options) ->\r
+ @action = options['action']\r
+ @params = options['params']\r
+ @current_page = @params['page']\r
+ @per_page = @params['page_size']\r
+ @window_size = 3\r
+ @counter = new Pettanr.CounterModel({}, {url: '/' + @action.counter_url(@params)})\r
+ _this = this\r
+ @counter.fetch().done ->\r
+ _this.total_page = (@total / _this.per_page) + 1\r
+ \r
+ class Pettanr.FilerCollection extends Backbone.Collection\r
+ \r
+ initialize: (models, options) ->\r
+ @model = options['model']\r
+ @action = options['action']\r
+ @params = options['params']\r
+ \r
+ @url = '/' + @action.url(@params)\r
+ \r
class Pettanr.AppController\r
+ constructor: () ->\r
+ @params = {}\r
+ \r
+ set_model: () ->\r
+ @my_controller = Manifest.manifest().controllers[@params['controller']]\r
+ @my_action = @my_controller.actions[@params['action']]\r
+ @my_model = Manifest.manifest().models[@my_controller.item_name]\r
+ @my_model_class = @my_model.classify()\r
+ \r
+ set_list: () ->\r
+ @set_model()\r
+ @my_list_model = Manifest.manifest().models[@my_action.item_name]\r
+ @my_list_model_class = @my_list_model.classify()\r
+ @pager = new Pettanr.Pager({action: @my_action, params: @params})\r
+ @list = new Pettanr.FilerCollection({}, {model: @my_list_model_class, action: @my_action, params: @params})\r
+ \r
+ filer_list: () ->\r
+ @set_list()\r
+ f = new Locmare.Filer({\r
+ el: "#pettanr",\r
+ item_name: @my_list_model_class.item_name(), \r
+ collection: @list, \r
+ pager: @pager, \r
+ operators: window.operators\r
+ })\r
\r
class Pettanr.FilerRender\r
constructor: (item_name, list_result, pager_type, operators) ->\r