OSDN Git Service

fix profiler
[pettanr/pettanr.git] / app / assets / javascripts / pettanr.js.coffee
index 1de7dd2..034f26c 100644 (file)
@@ -24,7 +24,10 @@ class Pettanr
     if @is_a_string(str)\r
       str\r
     else\r
-      ''\r
+      if @is_number(str)\r
+        str.toString()\r
+      else\r
+        ''\r
   \r
   class Pettanr.AppHelper\r
     @manifest: () ->\r
@@ -53,17 +56,32 @@ class Pettanr
     @t_selected_item: (name, index) ->\r
       I18n.t(Manifest.manifest().system_resources.select_items[name][index][0])\r
     \r
+    class Pettanr.AppHelperA extends Backbone.View\r
+      tagName: 'a'\r
+      \r
+      initialize: (options) ->\r
+        @href = options.href\r
+        @content = options.content\r
+      \r
+      render: () ->\r
+        this.$el.attr('href', @href)\r
+        this.$el.html(@content)\r
+        this\r
+        \r
+    \r
     class Pettanr.AppHelperImg extends Backbone.View\r
       tagName: 'img'\r
       \r
       initialize: (options) ->\r
         @src = options.src\r
         @size = options.size\r
+        @class_name = options.class_name\r
       \r
       render: () ->\r
         this.$el.attr('src', @src)\r
         this.$el.attr('width', @size)\r
         this.$el.attr('height', @size)\r
+        @el.className = @class_name\r
         this\r
     \r
     @image_tag: (src, opt = {}) ->\r
@@ -141,6 +159,7 @@ class Pettanr
   class Pettanr.AppController\r
     constructor: () ->\r
       @params = {}\r
+      @operators = window.operators\r
       \r
     set_model: () ->\r
       @my_controller = Manifest.manifest().controllers[@params['controller']]\r
@@ -155,6 +174,10 @@ class Pettanr
       @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
+    set_show: () ->\r
+      @set_model()\r
+      @item = new @my_model_class({id: @params['id']})\r
+    \r
     filer_list: () ->\r
       @set_list()\r
       f = new Locmare.Filer({\r
@@ -162,7 +185,15 @@ class Pettanr
         item_name: @my_list_model_class.item_name(), \r
         collection: @list, \r
         pager: @pager, \r
-        operators: window.operators\r
+        operators: @operators\r
+      })\r
+    \r
+    show_prof: () ->\r
+      profiler = new Locmare.Profiler({\r
+        el: "#pettanr",\r
+        item_name: @item.item_name(), \r
+        item: @item, \r
+        operators: @operators\r
       })\r
   \r
   class Pettanr.FilerRender\r