caboose-cms 0.4.111 → 0.4.112
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/model/attribute.js +2 -2
- data/app/assets/javascripts/caboose/model/bound_checkbox_multiple.js +72 -61
- data/app/assets/javascripts/caboose/model/model.js +1 -1
- data/app/assets/javascripts/caboose/model/model_binder.js +35 -2
- data/lib/caboose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGFkMjljOGM1OWI1N2ZlMWQyOGJlZmYxNzI5Mzc3YTk4ZGM2MDg3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzI1ZjUwMTk4ZGY0NTZiMTZiMTM3NThjZGZkNmZhYmY2OTUwMGJlNQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
M2Q5NDlhYTI0OGY4NDA0YjNkOWNhNjc2MjJkODgxMjE3NDJhMTk0MThjYzIw
|
10
|
+
YmM1OTc5NTY2YzBhNmZiNTY1NjE0NmE4ZDkyMTU5ZGViYjI5OTU3YmU3YTgw
|
11
|
+
Mzc3MDI0NDE1YzExYzJhZTM1MzU4Y2M0ODVkYzY1OGE2N2QzMmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzRhYjRmZGFhOGU4MjViNjNjNDE0NjIwZjgzMjdmZGE3NzdiYzJjYmY5NjVh
|
14
|
+
ZDVhZjljNmNkYTQ5NmIyOGZhYWU1YmIxYWExOGZhZjU2ODRjNDRhODE4OTk5
|
15
|
+
ZjRjYjNkY2RmZDU3NTQ1NjQyNGM1NzI1MGZmZjFhNTM5Yjg0YmY=
|
@@ -33,7 +33,7 @@ Attribute.prototype = {
|
|
33
33
|
options: false,
|
34
34
|
s3: false,
|
35
35
|
|
36
|
-
save: function(after) {
|
36
|
+
save: function(after) {
|
37
37
|
if (this.before_update) this.before_update();
|
38
38
|
var this2 = this;
|
39
39
|
$.ajax({
|
@@ -59,7 +59,7 @@ Attribute.prototype = {
|
|
59
59
|
|
60
60
|
populate_options: function(after) {
|
61
61
|
if (!this.options_url)
|
62
|
-
return;
|
62
|
+
return;
|
63
63
|
if (this.options)
|
64
64
|
{
|
65
65
|
if (after) after();
|
@@ -11,87 +11,98 @@ BoundCheckboxMultiple = BoundControl.extend({
|
|
11
11
|
checkboxes: false,
|
12
12
|
|
13
13
|
init: function(params) {
|
14
|
-
|
14
|
+
var that = this;
|
15
15
|
for (var thing in params)
|
16
16
|
this[thing] = params[thing];
|
17
17
|
|
18
18
|
this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
|
19
19
|
this.message = this.el + '_message';
|
20
20
|
this.placeholder = this.el + '_placeholder';
|
21
|
-
|
22
|
-
var
|
23
|
-
$('#'+this.el).wrap($('<div/>')
|
21
|
+
|
22
|
+
var div = $('<div/>')
|
24
23
|
.attr('id', this.el + '_container')
|
25
24
|
.addClass('mb_container')
|
26
|
-
.css('position', 'relative')
|
27
|
-
)
|
28
|
-
|
29
|
-
$('#'+this.el
|
30
|
-
|
31
|
-
.addClass('mb_placeholder')
|
32
|
-
.append($('<span/>').html(this.attribute.nice_name + ': '))
|
33
|
-
);
|
34
|
-
$('#'+this.el+'_container').append($('<input/>')
|
35
|
-
.attr('id', this.el + '_background')
|
36
|
-
.attr('disabled', true)
|
37
|
-
.css('background', '#fff')
|
38
|
-
);
|
39
|
-
if (this.attribute.width)
|
40
|
-
$('#'+this.el+'_background').css('width' , this.attribute.width);
|
41
|
-
|
42
|
-
var this2 = this;
|
43
|
-
this.attribute.populate_options(function() {
|
44
|
-
|
45
|
-
var tbody = $('<tbody/>');
|
46
|
-
$.each(this2.attribute.options, function(i, option) {
|
25
|
+
.css('position', 'relative');
|
26
|
+
if (this.attribute.height)
|
27
|
+
div.css('height', '' + this.attribute.height + 'px').css('overflow-y', 'scroll');
|
28
|
+
$('#'+this.el).wrap(div);
|
29
|
+
$('#'+this.el+'_container').empty();
|
47
30
|
|
48
|
-
|
49
|
-
|
50
|
-
|
31
|
+
if (this.attribute.options_url)
|
32
|
+
{
|
33
|
+
ModelBinder.wait_for_options(this.attribute.options_url, function(options) {
|
34
|
+
that.attribute.options = options;
|
35
|
+
that.cancel();
|
36
|
+
});
|
37
|
+
}
|
38
|
+
},
|
39
|
+
|
40
|
+
view: function() {
|
41
|
+
var that = this;
|
42
|
+
var tbody = $('<tbody/>');
|
43
|
+
$.each(that.attribute.options, function(i, option) {
|
44
|
+
var checked = that.attribute.value.indexOf(option.value) > -1;
|
45
|
+
tbody.append($('<tr/>')
|
46
|
+
.append($('<td/>')
|
47
|
+
.append($('<input/>')
|
48
|
+
.attr('id', that.el + '_' + i)
|
51
49
|
.attr('type', 'checkbox')
|
52
|
-
.attr('checked',
|
53
|
-
.
|
54
|
-
|
55
|
-
|
56
|
-
// this2.save();
|
57
|
-
})
|
58
|
-
)
|
59
|
-
.append($('<label/>')
|
60
|
-
.attr('for', this2.el + '_' + i)
|
61
|
-
.html(option.text)
|
50
|
+
.attr('checked', checked)
|
51
|
+
.val(option.value)
|
52
|
+
.css('position', 'relative')
|
53
|
+
.on('change', function() { that.save($(this).val(), $(this).prop('checked')); })
|
62
54
|
)
|
63
|
-
)
|
64
|
-
|
65
|
-
$('#'+this.el+'_container').append(
|
66
|
-
$('<table/>').append(tbody)
|
55
|
+
)
|
56
|
+
.append($('<td/>').append($('<label/>').attr('for', that.el + '_' + i).html(option.text)))
|
67
57
|
);
|
68
58
|
});
|
69
|
-
|
70
|
-
|
71
|
-
view: function() {
|
72
|
-
|
59
|
+
$('#'+this.el+'_container').append($('<table/>').addClass('data').append(tbody));
|
73
60
|
},
|
74
61
|
|
75
62
|
edit: function() {
|
76
63
|
|
77
64
|
},
|
78
65
|
|
79
|
-
save: function() {
|
80
|
-
|
81
|
-
this.attribute.value = $('#'+this.el).prop('checked') ? 1 : 0;
|
66
|
+
save: function(value, checked) {
|
82
67
|
|
83
|
-
var
|
84
|
-
this.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
68
|
+
var that = this;
|
69
|
+
var i = this.attribute.value.indexOf(value);
|
70
|
+
if (checked && i == -1) this.attribute.value.push(value);
|
71
|
+
if (!checked && i > -1) this.attribute.value.splice(i, 1);
|
72
|
+
|
73
|
+
if (this.attribute.before_update)
|
74
|
+
this.attribute.before_update();
|
75
|
+
if (!this.attribute.update_url)
|
76
|
+
this.attribute.update_url = this.model.update_url;
|
77
|
+
|
78
|
+
var data = {};
|
79
|
+
data[this.attribute.name] = [value,(checked ? 1 : 0)];
|
80
|
+
|
81
|
+
$.ajax({
|
82
|
+
url: this.attribute.update_url,
|
83
|
+
type: 'put',
|
84
|
+
data: data,
|
85
|
+
success: function(resp) {
|
86
|
+
if (resp.success)
|
87
|
+
{
|
88
|
+
if (resp.attributes && resp.attributes[that.attribute.name])
|
89
|
+
for (var thing in resp.attributes[that.attribute.name])
|
90
|
+
that.attribute[thing] = resp.attributes[that.attribute.name][thing];
|
91
|
+
that.attribute.value_clean = that.attribute.value;
|
92
|
+
|
93
|
+
that.binder.active_control = that;
|
94
|
+
if (that.binder.success)
|
95
|
+
that.binder.success(that);
|
96
|
+
}
|
97
|
+
else if (resp.error)
|
98
|
+
that.error(resp.error);
|
99
|
+
if (that.attribute.after_update)
|
100
|
+
that.attribute.after_update();
|
101
|
+
},
|
102
|
+
error: function() {
|
103
|
+
if (after) after(false);
|
104
|
+
}
|
105
|
+
});
|
95
106
|
},
|
96
107
|
|
97
108
|
cancel: function() {
|
@@ -34,12 +34,45 @@ ModelBinder.tinymce_current_control = function() {
|
|
34
34
|
return ModelBinder.tinymce_control(id);
|
35
35
|
};
|
36
36
|
|
37
|
+
//==============================================================================
|
38
|
+
|
39
|
+
ModelBinder.options = {};
|
40
|
+
ModelBinder.waiting_on_options = {};
|
41
|
+
ModelBinder.wait_for_options = function(url, after) {
|
42
|
+
if (ModelBinder.options[url])
|
43
|
+
{
|
44
|
+
after(ModelBinder.options[url]);
|
45
|
+
}
|
46
|
+
else if (ModelBinder.waiting_on_options[url])
|
47
|
+
{
|
48
|
+
ModelBinder.waiting_on_options[url].push(after);
|
49
|
+
}
|
50
|
+
else
|
51
|
+
{
|
52
|
+
ModelBinder.waiting_on_options[url] = [after];
|
53
|
+
var that = this;
|
54
|
+
$.ajax({
|
55
|
+
url: url,
|
56
|
+
type: 'get',
|
57
|
+
success: function(resp) {
|
58
|
+
ModelBinder.options[url] = resp;
|
59
|
+
$.each(ModelBinder.waiting_on_options[url], function(i, after2) {
|
60
|
+
after2(ModelBinder.options[url]);
|
61
|
+
});
|
62
|
+
}
|
63
|
+
});
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
//==============================================================================
|
68
|
+
|
37
69
|
ModelBinder.prototype = {
|
38
70
|
model: false,
|
39
71
|
controls: [],
|
40
72
|
on_load: false,
|
41
73
|
success: false,
|
42
74
|
authenticity_token: false,
|
75
|
+
options: {},
|
43
76
|
|
44
77
|
init: function(params) {
|
45
78
|
this.model = new Model({
|
@@ -60,7 +93,7 @@ ModelBinder.prototype = {
|
|
60
93
|
//this.model.populate_options();
|
61
94
|
|
62
95
|
var this2 = this;
|
63
|
-
$.each(this.model.attributes, function(i, attrib) {
|
96
|
+
$.each(this.model.attributes, function(i, attrib) {
|
64
97
|
var opts = {
|
65
98
|
model: this2.model,
|
66
99
|
attribute: attrib,
|
@@ -71,7 +104,7 @@ ModelBinder.prototype = {
|
|
71
104
|
if (attrib.type == 'text') control = new BoundText(opts);
|
72
105
|
else if (attrib.type == 'select') control = new BoundSelect(opts);
|
73
106
|
else if (attrib.type == 'checkbox') control = new BoundCheckbox(opts);
|
74
|
-
else if (attrib.type == 'checkbox-multiple') control = new BoundCheckboxMultiple(opts);
|
107
|
+
else if (attrib.type == 'checkbox-multiple') control = new BoundCheckboxMultiple(opts);
|
75
108
|
else if (attrib.type == 'textarea') control = new BoundTextarea(opts);
|
76
109
|
else if (attrib.type == 'richtext') control = new BoundRichText(opts);
|
77
110
|
else if (attrib.type == 'image') control = new BoundImage(opts);
|
data/lib/caboose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.112
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|