caboose-cms 0.3.30 → 0.3.31
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.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/model/all.js +1 -0
- data/app/assets/javascripts/caboose/model/bound_file.js +119 -0
- data/app/assets/javascripts/caboose/model/model_binder.js +9 -0
- data/app/models/caboose/utilities/schema.rb +1 -1
- data/lib/caboose/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDI4ZDcyZjQ4MTY4MzNmNTg0NmQ0Yjc0NTJiNmZlMWNmMjhkZGFhYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTMyZTdhY2YwZWJhMDVjNDllMWFjMzE3YTExZWNlOWYwODY2ZDZhMA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzJhOWVmYTg3N2I0YTMyZmM2NGU3MDU3Mzk5ZGExYTE5NDUzODYyMGI3YzE1
|
10
|
+
MzViY2JlZGQ3NDI3YTc1YjE1YjRhNzlhNjhjNmU0Y2I3Y2IwYWVkY2Q2ZjRk
|
11
|
+
NDMwYTRlYzI4NDUzZmY0MzJjMzY0MWY3MzZkYzY3ODFkMjU0MDM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWVjMTY1YWFkZTM2MTZmZDYyYjc3OWUwNmRjMTUxNDJmMTM3YTkwNGUwOThh
|
14
|
+
ZDk4Y2RmY2Q3NjVlNzA1YjA0MGY4NmRmMGRmYzE3OGYyOTQ2NjIwY2ZmNTM4
|
15
|
+
Zjk1NjIxMGI4N2YxOTA0NjI3NzNjZDdkN2VhZjdmNjA1YmJmZTM=
|
@@ -6,6 +6,7 @@
|
|
6
6
|
//= require caboose/model/bound_checkbox
|
7
7
|
//= require caboose/model/bound_checkbox_multiple
|
8
8
|
//= require caboose/model/bound_image
|
9
|
+
//= require caboose/model/bound_file
|
9
10
|
//= require caboose/model/bound_select
|
10
11
|
//= require caboose/model/bound_text
|
11
12
|
//= require caboose/model/bound_textarea
|
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
BoundFile = BoundControl.extend({
|
3
|
+
|
4
|
+
width: 100,
|
5
|
+
authenticity_token: false,
|
6
|
+
placeholder: false,
|
7
|
+
|
8
|
+
init: function(params) {
|
9
|
+
for (var thing in params)
|
10
|
+
this[thing] = params[thing];
|
11
|
+
|
12
|
+
this.el = this.el ? this.el : this.model.name.toLowerCase() + '_' + this.model.id + '_' + this.attribute.name;
|
13
|
+
|
14
|
+
if (!this.attribute.update_url)
|
15
|
+
this.attribute.update_url = this.model.update_url;
|
16
|
+
this.placeholder = this.el + '_placeholder';
|
17
|
+
|
18
|
+
var this2 = this;
|
19
|
+
$('#'+this.el).wrap($('<div/>').attr('id', this.el + '_container').css('position', 'relative'));
|
20
|
+
$('#'+this.el+'_container').empty();
|
21
|
+
|
22
|
+
var tr = $('<tr/>');
|
23
|
+
|
24
|
+
if (this.attribute.fixed_placeholder == true)
|
25
|
+
{
|
26
|
+
tr.append($('<td/>')
|
27
|
+
.attr('id', this.placeholder)
|
28
|
+
.addClass('placeholder')
|
29
|
+
.css('position', 'relative')
|
30
|
+
.append($('<span/>').html(this.attribute.nice_name + ': '))
|
31
|
+
);
|
32
|
+
}
|
33
|
+
|
34
|
+
tr.append($('<td/>').append($('<a/>')
|
35
|
+
.attr('id', this.el + '_link')
|
36
|
+
.attr('href', this.attribute.value)
|
37
|
+
.html('Download current file')
|
38
|
+
.css('margin-right', 10)
|
39
|
+
));
|
40
|
+
|
41
|
+
tr.append($('<td/>').append($('<form/>')
|
42
|
+
.attr('action', this.attribute.update_url)
|
43
|
+
.attr('method', 'post')
|
44
|
+
.attr('enctype', 'multipart/form-data')
|
45
|
+
.attr('encoding', 'multipart/form-data')
|
46
|
+
.attr('target', this.el + '_iframe')
|
47
|
+
.on('submit', function() {
|
48
|
+
$('#'+this2.el+'_message').html("<p class='loading'>Uploading...</p>");
|
49
|
+
$('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
|
50
|
+
})
|
51
|
+
.append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
|
52
|
+
.append($('<input/>').attr('type', 'button').val('Update ' + this.attribute.nice_name).click(function() {
|
53
|
+
$('#'+this2.el+'_container input[type="file"]').click();
|
54
|
+
}))
|
55
|
+
.append($('<input/>')
|
56
|
+
.attr('type', 'file')
|
57
|
+
.attr('name', this.attribute.name)
|
58
|
+
.css('display', 'none')
|
59
|
+
.on('change', function() { $('#'+this2.el+'_container form').submit(); })
|
60
|
+
)
|
61
|
+
));
|
62
|
+
|
63
|
+
$('#'+this.el+'_container').append($('<table/>').append($('<thead/>').append(tr)));
|
64
|
+
|
65
|
+
$('#'+this.el+'_container').append($('<div/>')
|
66
|
+
.attr('id', this.el + '_message')
|
67
|
+
);
|
68
|
+
iframe = $('<iframe/>')
|
69
|
+
.attr('name', this.el + '_iframe')
|
70
|
+
.attr('id', this.el + '_iframe');
|
71
|
+
if (this.attribute.debug)
|
72
|
+
iframe.css('width', '100%').css('height', 600).css('background', '#fff');
|
73
|
+
else
|
74
|
+
iframe.css('width', 0).css('height', 0).css('border', 0);
|
75
|
+
$('#'+this.el+'_container').append(iframe);
|
76
|
+
$('#'+this.el+'_container').append($('<br/>').css('clear', 'both'));
|
77
|
+
},
|
78
|
+
|
79
|
+
post_upload: function() {
|
80
|
+
$('#'+this.el+'_message').empty();
|
81
|
+
|
82
|
+
var str = frames[this.el+'_iframe'].document.documentElement.innerHTML;
|
83
|
+
str = str.replace(/.*?{(.*?)/, '{$1');
|
84
|
+
str = str.substr(0, str.lastIndexOf('}')+1);
|
85
|
+
|
86
|
+
var resp = $.parseJSON(str);
|
87
|
+
if (resp.success)
|
88
|
+
{
|
89
|
+
if (resp.attributes && resp.attributes[this.attribute.name])
|
90
|
+
for (var thing in resp.attributes[this.attribute.name])
|
91
|
+
this.attribute[thing] = resp.attributes[this.attribute.name][thing];
|
92
|
+
this.attribute.value_clean = this.attribute.value;
|
93
|
+
}
|
94
|
+
|
95
|
+
if (resp.error)
|
96
|
+
this.error(resp.error);
|
97
|
+
else
|
98
|
+
{
|
99
|
+
$('#'+this.el+'_container a').attr('href', this.attribute.value);
|
100
|
+
//$('#'+this.el+'_container img').attr('src', this.attribute.value);
|
101
|
+
}
|
102
|
+
},
|
103
|
+
|
104
|
+
error: function(str) {
|
105
|
+
if (!$('#'+this.el+'_message').length)
|
106
|
+
{
|
107
|
+
$('#'+this.el+'_container').append($('<div/>')
|
108
|
+
.attr('id', this.el + '_message')
|
109
|
+
.css('width', $('#'+this.el).outerWidth())
|
110
|
+
);
|
111
|
+
}
|
112
|
+
$('#'+this.el+'_message').hide();
|
113
|
+
$('#'+this.el+'_message').html("<p class='note error'>" + str + "</p>");
|
114
|
+
$('#'+this.el+'_message').slideDown();
|
115
|
+
var this2 = this;
|
116
|
+
setTimeout(function() { $('#'+this2.el+'_message').slideUp(function() { $(this).empty(); }); }, 3000);
|
117
|
+
}
|
118
|
+
|
119
|
+
});
|
@@ -58,6 +58,7 @@ ModelBinder.prototype = {
|
|
58
58
|
binder: this2
|
59
59
|
};
|
60
60
|
var control = false;
|
61
|
+
|
61
62
|
if (attrib.type == 'text') control = new BoundText(opts);
|
62
63
|
else if (attrib.type == 'select') control = new BoundSelect(opts);
|
63
64
|
else if (attrib.type == 'checkbox') control = new BoundCheckbox(opts);
|
@@ -65,6 +66,14 @@ ModelBinder.prototype = {
|
|
65
66
|
else if (attrib.type == 'textarea') control = new BoundTextarea(opts);
|
66
67
|
else if (attrib.type == 'richtext') control = new BoundRichText(opts);
|
67
68
|
else if (attrib.type == 'image') control = new BoundImage(opts);
|
69
|
+
else if (attrib.type == 'file') control = new BoundFile(opts);
|
70
|
+
else
|
71
|
+
{
|
72
|
+
control_class = "";
|
73
|
+
$.each(attrib.type.split('-'), function(j, word) { control_class += word.charAt(0).toUpperCase() + word.toLowerCase().slice(1); });
|
74
|
+
control = eval("new Bound" + control_class + "(opts)");
|
75
|
+
}
|
76
|
+
|
68
77
|
this2.controls.push(control);
|
69
78
|
});
|
70
79
|
|
@@ -52,7 +52,7 @@ class Caboose::Utilities::Schema
|
|
52
52
|
|
53
53
|
# Special case for attachments
|
54
54
|
if col[1] == :attachment
|
55
|
-
c.add_attachment tbl, col[
|
55
|
+
c.add_attachment tbl, col[0] if !c.column_exists?(tbl, "#{col[0]}_file_size")
|
56
56
|
next
|
57
57
|
end
|
58
58
|
|
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.3.
|
4
|
+
version: 0.3.31
|
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-02-
|
11
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- app/assets/javascripts/caboose/model/bound_checkbox.js
|
138
138
|
- app/assets/javascripts/caboose/model/bound_checkbox_multiple.js
|
139
139
|
- app/assets/javascripts/caboose/model/bound_control.js
|
140
|
+
- app/assets/javascripts/caboose/model/bound_file.js
|
140
141
|
- app/assets/javascripts/caboose/model/bound_image.js
|
141
142
|
- app/assets/javascripts/caboose/model/bound_richtext.js
|
142
143
|
- app/assets/javascripts/caboose/model/bound_select.js
|