OSDN Git Service

add: license publisher
[pettanr/pettanr.git] / app / assets / javascripts / views / resource_pictures / form.js.coffee
diff --git a/app/assets/javascripts/views/resource_pictures/form.js.coffee b/app/assets/javascripts/views/resource_pictures/form.js.coffee
new file mode 100644 (file)
index 0000000..d8b996d
--- /dev/null
@@ -0,0 +1,29 @@
+#\r
+#   Confirm page\r
+#\r
+class Pettanr.Views.ResourcePicture.Form extends Backbone.View\r
+  \r
+  initialize: (options) ->\r
+    super(options)\r
+    @resource_picture = options.resource_picture\r
+    @credits = options.credits\r
+  \r
+  render: () ->\r
+    this.$el.html('')\r
+    this.$el.append(@credits)\r
+    submit = new Tag.Submit({value: I18n.t('resource_pictures.new.publish')})\r
+    @listenTo(submit, 'click', @submit)\r
+    this.$el.append(submit.render().el)\r
+    this\r
+  \r
+  submit: () ->\r
+    @listenTo(@resource_picture, 'save:success', @success)\r
+    @listenTo(@resource_picture, 'save:fail', @fail)\r
+    @resource_picture.save()\r
+  \r
+  success: (model, response) ->\r
+    @trigger('success', @resource_picture)\r
+  \r
+  fail: (model, response) ->\r
+    @trigger('fail', model, response)\r
+  \r