modeljs 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -81,15 +81,16 @@ Model.Form = Class.extend({
81
81
 
82
82
  var div = $('<div/>')
83
83
  .append($('<table/>').append(tbody))
84
- .append($('<div/>').attr('id', this.message))
85
- .append($('<p/>')
86
- .append($('<input/>').attr('type', 'button').val('Back').click(function() {
87
- var obj = Model.parse_url(m.listing_url);
88
- window.location = obj.url;
89
- }))
90
- .append(' ')
91
- .append($('<input/>').attr('type', 'button').val('Delete ' + m.name).click(function() { m.ajax_delete(); }))
92
- );
84
+ .append($('<div/>').attr('id', this.message));
85
+ var p = $('<p/>')
86
+ var back = $('<input/>')
87
+ .attr('type', 'button')
88
+ .val('Back')
89
+ .click(m.back_button_click ? m.back_button_click : function() { window.location = Model.parse_url(m.listing_url).url; });
90
+ p.append(back).append(' ');
91
+ if (m.show_delete_button)
92
+ p.append($('<input/>').attr('type', 'button').val('Delete ' + m.name).click(function() { m.ajax_delete(); }));
93
+ div.append(p);
93
94
  return div;
94
95
  },
95
96
 
@@ -68,6 +68,8 @@ Model.prototype = {
68
68
  ca: false, // current attribute being edited
69
69
  container: false,
70
70
  form: 'Model.Form', // Name of the class that generates add/edit forms for the model
71
+ back_button_click: false, // Click handler for the back button
72
+ show_delete_button: true, // Whether or not we should show the delete button on the main model
71
73
 
72
74
  // Urls of CRUD events
73
75
  create_url: false,
@@ -1,3 +1,3 @@
1
1
  module Modeljs
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modeljs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-06-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -68,7 +68,6 @@ extra_rdoc_files: []
68
68
  files:
69
69
  - app/assets/images/loading.gif
70
70
  - app/assets/images/loading_small.gif
71
- - app/assets/javascripts/#Untitled-1#
72
71
  - app/assets/javascripts/attribute/checkbox-multiple.js
73
72
  - app/assets/javascripts/attribute/checkbox.js
74
73
  - app/assets/javascripts/attribute/date-time.js
@@ -1,57 +0,0 @@
1
- /*
2
- Class: Model.Form
3
- Author: William Barry (william@nine.is)
4
- Description: Abstract form class to encapsulate add and edit forms for models.
5
- */
6
-
7
- Model.Form = Class.extend({
8
-
9
- class_name: 'Model.Form',
10
- model: false,
11
- message: false,
12
- adding_message: null,
13
- deleting_message: null,
14
- delete_message: null,
15
- listing_models: false,
16
-
17
- init: function(model, params)
18
-
19
- // Returns the form for adding the model or false for an embedded form.
20
- add: function()
21
- post_add_display: function() {},
22
-
23
- // Returns the form for editing a model or false for an embedded form.
24
- edit: function()
25
- post_edit_display: function() {},
26
-
27
- listing_view: function()
28
- post_listing_view_display: function() {},
29
-
30
- // Returns a listing table of models or false for an embedded listing
31
- listing_form: function()
32
- post_listing_form_display: function() {},
33
-
34
- listing_view: function()
35
- post_listing_view_display: function() {},
36
-
37
- // Gets the latest rows for the listing
38
- refresh_listing_models: function(done)
39
- refresh_listing_models_helper: function(models)
40
-
41
- // Returns the values of the add form that will be sent to model.ajax_add
42
- add_values: function()
43
-
44
- // Show a confirmation screen
45
- confirm: function(params)
46
-
47
- ajax_success: function(resp)
48
-
49
- ajax_error: function(str) { this.error(str); },
50
-
51
- // Notes
52
- loading: function(str) { this.show_message('loading' , str); },
53
- note: function(str) { this.show_message('note' , str); },
54
- success: function(str) { this.show_message('note success' , str); },
55
- error: function(str) { this.show_message('note error' , str); },
56
- show_message: function(class_names, str) { $('#' + this.message).empty().append($('<p/>').addClass(class_names).html(str)); }
57
- });