caboose-cms 0.2.7 → 0.2.8

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.
@@ -15,6 +15,9 @@ BoundImage = BoundControl.extend({
15
15
  this[thing] = params[thing];
16
16
 
17
17
  this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
18
+
19
+ if (!this.attribute.update_url)
20
+ this.attribute.update_url = this.model.update_url;
18
21
 
19
22
  var this2 = this;
20
23
  $('#'+this.el).wrap($('<div/>').attr('id', this.el + '_container').css('position', 'relative'));
@@ -37,7 +40,9 @@ BoundImage = BoundControl.extend({
37
40
  $('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
38
41
  })
39
42
  .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
40
- .append($('<input/>').attr('type', 'button').val('Update').click(function() { $('#'+this2.el+'_container input[type="file"]').click(); }))
43
+ .append($('<input/>').attr('type', 'button').val('Update ' + this.attribute.nice_name).click(function() {
44
+ $('#'+this2.el+'_container input[type="file"]').click();
45
+ }))
41
46
  .append($('<input/>')
42
47
  .attr('type', 'file')
43
48
  .attr('name', this.attribute.name)
@@ -54,6 +59,9 @@ BoundImage = BoundControl.extend({
54
59
  .css('width', 0)
55
60
  .css('height', 0)
56
61
  .css('border', 0)
62
+ //.css('width', '100%')
63
+ //.css('height', 600)
64
+ //.css('background', '#fff')
57
65
  );
58
66
  $('#'+this.el+'_container').append($('<br/>')
59
67
  .css('clear', 'both')
@@ -64,15 +72,22 @@ BoundImage = BoundControl.extend({
64
72
  $('#'+this.el+'_message').empty();
65
73
 
66
74
  var str = frames[this.el+'_iframe'].document.documentElement.innerHTML;
67
- str = str.replace(/<body>(.*?)<\/body>/, '$1');
68
- str = str.replace(/<html>(.*?)<\/html>/, '$1');
69
- str = str.replace(/<head>.*?<\/head>(.*?)/, '$1');
75
+ str = str.replace(/.*?{(.*?)/, '{$1');
76
+ str = str.substr(0, str.lastIndexOf('}')+1);
70
77
 
71
- var resp = $.parseJSON(str);
78
+ var resp = $.parseJSON(str);
79
+ if (resp.success)
80
+ {
81
+ if (resp.attributes && resp.attributes[this.attribute.name])
82
+ for (var thing in resp.attributes[this.attribute.name])
83
+ this.attribute[thing] = resp.attributes[this.attribute.name][thing];
84
+ this.attribute.value_clean = this.attribute.value;
85
+ }
86
+
72
87
  if (resp.error)
73
88
  this.error(resp.error);
74
- else if (resp.url)
75
- $('#'+this.el+'_container img').attr('src', resp.url);
89
+ else
90
+ $('#'+this.el+'_container img').attr('src', this.attribute.value);
76
91
  },
77
92
 
78
93
  error: function(str) {
@@ -73,8 +73,7 @@ BoundSelect = BoundControl.extend({
73
73
  },
74
74
 
75
75
  edit: function() {
76
- this.binder.cancel_active();
77
- this.binder.active_control = this;
76
+
78
77
  },
79
78
 
80
79
  save: function() {
@@ -85,7 +84,6 @@ BoundSelect = BoundControl.extend({
85
84
  if (resp.error) this2.error(resp.error);
86
85
  else
87
86
  {
88
- this2.binder.active_control = this2;
89
87
  if (this2.binder.success)
90
88
  this2.binder.success(this2);
91
89
  this2.view();
@@ -4,7 +4,7 @@ var ModelBinder = function(params) { this.init(params); };
4
4
  ModelBinder.prototype = {
5
5
  model: false,
6
6
  controls: [],
7
- //active_control: false,
7
+ on_load: false,
8
8
  success: false,
9
9
  authenticity_token: false,
10
10
 
@@ -42,23 +42,7 @@ ModelBinder.prototype = {
42
42
  this2.controls.push();
43
43
  });
44
44
 
45
- //$(document).keyup(function(e) {
46
- // if (e.keyCode == 27) this2.cancel_active(); // Escape
47
- // //if (e.keyCode == 13) this2.save_active(); // Enter
48
- //});
45
+ if (this.on_load)
46
+ this.on_load();
49
47
  },
50
-
51
- //cancel_active: function() {
52
- // if (!this.active_control)
53
- // return;
54
- // this.active_control.cancel();
55
- // this.active_control = false;
56
- //},
57
-
58
- //save_active: function() {
59
- // if (!this.active_control)
60
- // return;
61
- // this.active_control.save();
62
- // this.active_control = false;
63
- //},
64
48
  };
@@ -25,12 +25,12 @@ function login()
25
25
  type: 'post',
26
26
  data: $('#login_form').serialize(),
27
27
  success: function(resp) {
28
- if (resp.error)
29
- modal.autosize("<p class='note error'>" + resp.error + "</p>");
30
- else if (resp.redirect != false)
31
- <%= @modal ? "" : "parent." %>window.location = resp.redirect;
32
- else
33
- parent.location.reload(true);
28
+ //if (resp.error)
29
+ // modal.autosize("<p class='note error'>" + resp.error + "</p>");
30
+ //else if (resp.redirect != false)
31
+ // <%= @modal ? "" : "parent." %>window.location = resp.redirect;
32
+ //else
33
+ // parent.location.reload(true);
34
34
  },
35
35
  error: function() {
36
36
  modal.autosize("<p class='note error'>Error</p>");
@@ -4,10 +4,10 @@ pic = "http://gravatar.com/avatar/#{gravatar_id}.png?s=150" #&d=/assets/caboose/
4
4
  %>
5
5
  <h1>Edit User</h1>
6
6
  <p id='gravatar'><img src='<%= pic %>' /><a href='http://gravatar.com'>Update on gravatar</a></p>
7
- <p><input type='text' id='user_<%= @edituser.id %>_first_name' value="<%= @edituser.first_name %>" placeholder='First name' /></p>
8
- <p><input type='text' id='user_<%= @edituser.id %>_last_name' value="<%= @edituser.last_name %>" placeholder='Last name' /></p>
9
- <p><input type='text' id='user_<%= @edituser.id %>_username' value="<%= @edituser.username %>" placeholder='Username' /></p>
10
- <p><input type='text' id='user_<%= @edituser.id %>_email' value="<%= @edituser.email %>" placeholder='Email' /></p>
7
+ <p><div id='user_<%= @edituser.id %>_first_name' ></div></p>
8
+ <p><div id='user_<%= @edituser.id %>_last_name' ></div></p>
9
+ <p><div id='user_<%= @edituser.id %>_username' ></div></p>
10
+ <p><div id='user_<%= @edituser.id %>_email' ></div></p>
11
11
  <div id='message'></div>
12
12
  <div id='controls'>
13
13
  <input type='button' value='Back' onclick="window.location='/admin/users';" />
@@ -15,6 +15,32 @@ pic = "http://gravatar.com/avatar/#{gravatar_id}.png?s=150" #&d=/assets/caboose/
15
15
  <input type='button' value='Delete User' onclick="deleteUser();" />
16
16
  </div>
17
17
 
18
+ <% content_for :caboose_js do %>
19
+ <%= javascript_include_tag "caboose/model/all" %>
20
+ <script type="text/javascript">
21
+ var modal = false;
22
+ $(window).load(function() {
23
+ modal = new CabooseModal(500);
24
+ });
25
+
26
+ $(document).ready(function() {
27
+ new ModelBinder({
28
+ name: 'User',
29
+ id: <%= @edituser.id %>,
30
+ update_url: '/admin/users/<%= @edituser.id %>',
31
+ authenticity_token: '<%= form_authenticity_token %>',
32
+ attributes: [
33
+ { name: 'first_name' , nice_name: 'First name', type: 'text', value: <%= raw Caboose.json(@edituser.first_name) %>, width: 280 },
34
+ { name: 'last_name' , nice_name: 'Last name' , type: 'text', value: <%= raw Caboose.json(@edituser.last_name) %>, width: 280 },
35
+ { name: 'username' , nice_name: 'Username' , type: 'text', value: <%= raw Caboose.json(@edituser.username) %>, width: 280 },
36
+ { name: 'email' , nice_name: 'Email' , type: 'text', value: <%= raw Caboose.json(@edituser.email) %>, width: 280 }
37
+ ],
38
+ on_load: function() { modal.autosize(); }
39
+ });
40
+ });
41
+ </script>
42
+ <% end %>
43
+
18
44
  <% content_for :caboose_css do %>
19
45
  <style type='text/css'>
20
46
  #gravatar {
@@ -28,59 +54,4 @@ pic = "http://gravatar.com/avatar/#{gravatar_id}.png?s=150" #&d=/assets/caboose/
28
54
  border: #fff 2px solid;
29
55
  }
30
56
  </style>
31
- <% end %>
32
-
33
- <% content_for :caboose_js do %>
34
- <%= javascript_include_tag "caboose/model_binder.js" %>
35
- <script type="text/javascript">
36
-
37
- var model = false;
38
- $(document).ready(function() {
39
-
40
- m = new ModelBinder({
41
- name: 'User',
42
- id: <%= @edituser.id %>,
43
- update_url: '/admin/users/<%= @edituser.id %>',
44
- attributes: ['first_name', 'last_name', 'username', 'email']
45
- });
46
-
47
- modal = new CabooseModal(500);
48
- });
49
-
50
- // var user = new Model({
51
- // form: 'Model.Form.User',
52
- // finished_loading: function() {
53
- // modal = new CabooseModal(500);
54
- // },
55
- // name: 'User',
56
- // id: <%= @edituser.id %>,
57
- // listing_url: 'get /admin/users',
58
- // update_url: 'put /admin/users/<%= @edituser.id %>',
59
- // delete_url: 'delete /admin/users/<%= @edituser.id %>',
60
- // attributes: [
61
- // { name: 'first_name' , type: 'text', value: "<%= @edituser.first_name %>", show_reminder: false },
62
- // { name: 'last_name' , type: 'text', value: "<%= @edituser.last_name %>", show_reminder: false },
63
- // { name: 'username' , type: 'text', value: "<%= @edituser.username %>", show_reminder: false },
64
- // { name: 'email' , type: 'text', value: "<%= @edituser.email %>", show_reminder: false },
65
- // { name: 'password' , type: 'password' },
66
- // {
67
- // name: 'roles',
68
- // type: 'checkbox-multiple',
69
- // value: <%= @roles.collect{|r| r.id}.to_json %>,
70
- // text: "<%= @roles.collect{|r| r.name}.join(', ') %>",
71
- // empty_text: '[No roles]',
72
- // multiple: true,
73
- // loading_message: 'Getting roles...',
74
- // options_url: '/admin/roles/options'
75
- // },
76
- // {
77
- // name: 'pic',
78
- // type: 'image',
79
- // value: '',
80
- // update_url: '/admin/users/<%= @edituser.id %>/update-pic'
81
- // }
82
- // ]
83
- // });
84
-
85
- </script>
86
- <% end %>
57
+ <% end %>
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.2.7'
2
+ VERSION = '0.2.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: