OSDN Git Service

clean
[pettanr/pettanr.git] / app / assets / javascripts / pettanr.js.coffee
index 0ea32bd..a917530 100644 (file)
@@ -127,16 +127,14 @@ class Pettanr
     \r
     filer_list: () ->\r
       @set_list()\r
-      _this = this\r
-      _list = @list\r
-      @list.open(() ->\r
-        pager = Locmare.ListGroupModule.LibModule.Pager.factory(_list.page_status, _this.params)\r
+      @list.open(() =>\r
+        pager = Locmare.ListGroupModule.LibModule.Pager.factory(@list.page_status, @params)\r
         f = new Locmare.Filer({\r
           el: "#pettanr",\r
-          item_name: _this.my_list_model_class.item_name(), \r
-          items: _this.list.items(), \r
+          item_name: @my_list_model_class.item_name(), \r
+          items: @list.items(), \r
           pager: pager, \r
-          operators: _this.operators\r
+          operators: @operators\r
         })\r
       )\r
       false\r
@@ -150,24 +148,21 @@ class Pettanr
       @item = new @binder_model_class({id: @params['id']})\r
     \r
     play_list: () ->\r
-      _this = this\r
-      _list = @list\r
-      @list.open(() ->\r
-        console.log _this.list.items()\r
+      @list.open(() =>\r
+        console.log @list.items()\r
       )\r
       false\r
     \r
     show_prof: () ->\r
-      _this = this\r
-      @item.fetch({cache: true}).done ->\r
-        _this.item.boosts 'post'\r
+      @item.fetch({cache: true}).done =>\r
+        @item.boosts 'post'\r
         profiler = new Locmare.Profiler({\r
-          item_name: _this.item.item_name(), \r
-          item: _this.item, \r
-          operators: _this.operators\r
+          item_name: @item.item_name(), \r
+          item: @item, \r
+          operators: @operators\r
         })\r
         $("#pettanr").html(profiler.render().el)\r
-        _this.redraw_title(_this.params)\r
+        @redraw_title(@params)\r
     \r
     set_new: () ->\r
       @set_model()\r
@@ -179,10 +174,9 @@ class Pettanr
     set_edit: () ->\r
       @set_model()\r
       @item = new @my_model_class({id: @params['id']})\r
-      _this = this\r
-      @item.fetch({cache: true}).done ->\r
-        _this.item.boosts 'post'\r
-        _this.render_form()\r
+      @item.fetch({cache: true}).done =>\r
+        @item.boosts 'post'\r
+        @render_form()\r
     \r
     render_form: () ->\r
       @form = new Locmare.Form({\r
@@ -207,27 +201,6 @@ class Pettanr
       site_caption = Manifest.manifest().magic_numbers.profile.users.caption\r
       $(document).attr('title', t + ' - ' + site_caption)\r
     \r
-  class Pettanr.FilerRender\r
-    constructor: (item_name, list_result, pager_type, operators) ->\r
-      @item_name = item_name\r
-      @list_result = list_result\r
-      @pager_type = pager_type\r
-      @operators = operators\r
-      _this = this\r
-      @list_result.fetch({cache: true}).done () ->\r
-        _this.render()\r
-    \r
-    render: () ->\r
-      items = @list_result.models\r
-      f = new Locmare.Filer({\r
-        item_name: @item_name, \r
-        items: items, \r
-        list_result: @list_result, \r
-        pager_type: @pager_type, \r
-        operators: @operators\r
-      })\r
-      $("#pettanr").html(f.render().el)\r
-\r
   #>> https://gist.github.com/davidjbeveridge/3813724\r
   @xeach: (arr, func, index=0) ->\r
     if index < arr.length then [ func(arr[index], index), @xeach(arr, func, index + 1)... ] else []\r