OSDN Git Service

add profiler
[pettanr/pettanr.git] / app / assets / javascripts / locmare / profiler / column.js.coffee
1 class Locmare.ProfilerModule.Column extends Backbone.View\r
2   tagName: 'div'\r
3   className: 'columns'\r
4   \r
5   initialize: (options) ->\r
6     @profiler = options.profiler\r
7     @profiler_manifest = @profiler.profiler_manifest\r
8     @columns = {}\r
9     _this = this\r
10     _.each @profiler_manifest.columns, (column, name) ->\r
11       _this.columns[name] = _this.factory(_this.profiler, column)\r
12   \r
13   render: () ->\r
14     _this = this\r
15     this.$el.html('')\r
16     _.each @sorted_columns(), (column) ->\r
17       _this.$el.append(column.render().el)\r
18     this\r
19   \r
20   types: () ->\r
21     {\r
22       default: Locmare.ProfilerModule.ColumnModule.Default, \r
23       date: Locmare.ProfilerModule.ColumnModule.Date, \r
24       source: Locmare.ProfilerModule.ColumnModule.Source, \r
25       extend: Locmare.ProfilerModule.ColumnModule.Extend, \r
26       json: Locmare.ProfilerModule.ColumnModule.Json\r
27     }\r
28   \r
29   factory: (profiler, my_manifest) ->\r
30     type = my_manifest.type\r
31     console.log("undefined type for local view filers > #{profiler.item_name} > edit\n") if not type\r
32     my_class = @types()[type]\r
33     console.log("undefined class for local view filers > #{profiler.item_name} > edit > #{type}\n") if not my_class\r
34     new my_class({profiler: profiler,  column_manifest: my_manifest})\r
35   \r
36   sorted_columns: () ->\r
37     _.map @profiler_manifest.column_names, (column_name) =>\r
38       _this.columns[column_name]\r
39   \r
40 class Locmare.ProfilerModule.ColumnModule\r
41 \r