OSDN Git Service

Merge branch 'v06' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v06
[pettanr/pettanr.git] / app / assets / javascripts / models / panel.js.coffee
index 834bf3f..453343b 100644 (file)
@@ -9,12 +9,14 @@ class Pettanr.Panel extends Peta.Root
   \r
   defaults: {\r
     id: null,\r
+    width: 500,\r
+    height: 300,\r
     border: 2,\r
     publish: 0\r
   } \r
   \r
   author: () ->\r
-    new Pettanr.Author({id: @get('author_id')})\r
+    Pettanr.cache.store(new Pettanr.Author({id: @get('author_id')}, {expire_time: (new Date)}))\r
   \r
   pp: () ->\r
     new Pettanr.PanelPicture({id: @get('pp_id')})\r
@@ -77,14 +79,20 @@ class Pettanr.Panel.WithElements extends Pettanr.Panel
     @url = @my_url() + '?with_elements=true'\r
     super(options)\r
   \r
-  save: (attrs, options = {}) ->\r
+  save: (attrs) ->\r
     @url = @my_url()\r
-    options.attrs = {panel: attrs}\r
     method = if @isNew()\r
       'create'\r
     else\r
       'update'\r
-    xhr = @sync(method, this, options)\r
+    _this = this\r
+    xhr = @sync(method, this, {\r
+      attrs: {panel: attrs},\r
+      success: (model, response, options) =>\r
+        _this.trigger('save:success', _this, response)\r
+      error: (model, response, options) =>\r
+        _this.trigger('save:fail', _this, response)\r
+    })\r
     xhr\r
   \r
   destroy: (options) ->\r