caboose-cms 0.3.65 → 0.3.66

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NzhlYmEyZGJjYWRmM2I4OTgyMGY4NGFlODA5MDdhNjMyMTdhZGViOA==
4
+ NGI5NDdhNDA4NGYxMzQyMmI1NTUyNTA4NGI1ZDBhMjc2ZGViNGFjNg==
5
5
  data.tar.gz: !binary |-
6
- M2VkZWYzYjE3NzI2MmQxNmY1OWZjMzg1OGRhZjdiOTdmODM4YjA5Zg==
6
+ N2VjZDQ2YjBjOTdkMjIwMzY4ZjZiZGIzMzk1OGVhYjI4NjFlODNkYg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDNkZjIwYTNjNzNlMTEzN2NhM2I5ODRiNjZiZGQxMDJkODY3NzE0YjFkZTAw
10
- Y2ZjNjJhOGVhNmQ2ZWQ4NTJkYzYwZmI3ZGFmZGU1MmIzYjk5N2JhNTY0ZWVk
11
- YzI1ZWU5ZTUyYjk4YTBlNGNlNzg2NjA4YTgyYzEwNTkxODA2ODE=
9
+ NmI1MTY5N2Q1NjVjZTdmZGQ0MjZjNzNjNjIyZDU4N2Q5OGRlOTRjMTIxNGQz
10
+ YjMxZmYyODEzYjg3NTQ5ZGNmY2Y5N2YyOTIzZWVkYzMxZDZjMTlmYjZjZWMy
11
+ MjRhZmY4MzYyOWM5Yjk5NGQ2ODAyMzI1NDBjYTdhNTBmYzVhZDA=
12
12
  data.tar.gz: !binary |-
13
- Nzc5ZmQ3YmZiOWFkYzE0NjVhZjAxNDJmOWVkZGY5NDAxOWEwNmI3NjhiNzVh
14
- MDRiOGI0MmJlZWU3N2U5NTA1NzkxMDc3ZGRkYTBlYjQwY2FkOTM1MTI3M2Ew
15
- Yjk4NjcyNjcxN2Y5MTM2YjdlZDg3YjFiYzgwODRhYTNmZmI1ZjE=
13
+ ZGE3N2E4ZDE0NzFmZTI5ZTlhNGM2ODMxYTQ4YWVmOTVmOTUwNjFmZWRiODlh
14
+ YmUzOTYyOTk2NGI3N2ViZmJkYWM1ZmVkYzNiOTJkMTc2NWYxZjdmYjAyMWRm
15
+ NGJlOTU0NWI2ZmU3MjA5ODMxNjcyNTBmMDNmZjRiYTI5YmUyYjk=
@@ -19,79 +19,87 @@ BoundFile = BoundControl.extend({
19
19
  $('#'+this.el).wrap($('<div/>')
20
20
  .attr('id', this.el + '_container')
21
21
  .addClass('mb_container')
22
- .css('position', 'relative')
22
+ .addClass('mb_file_container')
23
23
  );
24
24
  $('#'+this.el+'_container').empty();
25
-
26
- var tr = $('<tr/>');
27
-
25
+
26
+ $('#'+this.el+'_container')
27
+ .append($('<form target="' + this.el + '_iframe"></form>')
28
+ .addClass('mb_file_form')
29
+ .attr('id', this.el + '_form')
30
+ .attr('action', this.attribute.update_url)
31
+ .attr('method', 'post')
32
+ .attr('enctype', 'multipart/form-data')
33
+ .attr('encoding', 'multipart/form-data')
34
+ .on('submit', function() {
35
+ $('#'+this2.el+'_message').html("<p class='loading'>Uploading...</p>");
36
+ $('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
37
+ return true;
38
+ })
39
+ );
40
+
28
41
  if (this.attribute.fixed_placeholder == true)
29
42
  {
30
- tr.append($('<td/>')
43
+ $('#'+this.el+'_form').append($('<div/>')
31
44
  .attr('id', this.placeholder)
32
- .addClass('mb_placeholder')
33
- .css('position', 'relative')
45
+ .addClass('mb_placeholder')
34
46
  .append($('<span/>').html(this.attribute.nice_name + ': '))
35
47
  );
36
48
  }
37
-
38
- var td = $('<td/>').append($('<a/>')
39
- .attr('id', this.el + '_link')
40
- .attr('href', this.attribute.value)
41
- .attr('target', '_blank')
42
- .html(this.attribute.download_text ? this.attribute.download_text : 'Download current file')
43
- .css('margin-right', 10)
44
- );
45
- if (this.attribute.value == false)
46
- td.css('display', 'none');
47
- tr.append(td);
48
-
49
- tr.append($('<td/>').append($('<form/>')
50
- .attr('action', this.attribute.update_url)
51
- .attr('method', 'post')
52
- .attr('enctype', 'multipart/form-data')
53
- .attr('encoding', 'multipart/form-data')
54
- .attr('target', this.el + '_iframe')
55
- .on('submit', function() {
56
- $('#'+this2.el+'_message').html("<p class='loading'>Uploading...</p>");
57
- $('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
58
- })
59
- .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
60
- .append($('<a/>').attr('href', '#').html(this.attribute.upload_text ? this.attribute.upload_text : 'Update ' + this.attribute.nice_name).click(function() {
61
- $('#'+this2.el+'_container input[type="file"]').click();
62
- }))
63
- //.append($('<input/>').attr('type', 'button').val('Update ' + this.attribute.nice_name).click(function() {
64
- // $('#'+this2.el+'_container input[type="file"]').click();
65
- //}))
66
- .append($('<input/>')
67
- .attr('type', 'file')
68
- .attr('name', this.attribute.name)
69
- .css('display', 'none')
70
- .on('change', function() { $('#'+this2.el+'_container form').submit(); })
71
- )
72
- ));
73
-
74
- $('#'+this.el+'_container').append($('<table/>').append($('<thead/>').append(tr)));
75
49
 
50
+ $('#'+this.el+'_form')
51
+ .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
52
+ .append($('<div/>')
53
+ .attr('id', this.el + '_fake_file_input')
54
+ .addClass('mb_fake_file_input')
55
+ .append($('<input/>')
56
+ .attr('type', 'button')
57
+ .attr('id', this.el + '_update_button')
58
+ .val(this.attribute.upload_text ? this.attribute.upload_text : 'Update ' + this.attribute.nice_name)
59
+ .click(function() { $('#'+this2.el+'_file').click(); })
60
+ )
61
+ .append($('<input/>')
62
+ .attr('type', 'file')
63
+ .attr('id', this.el + '_file')
64
+ .attr('name', this.attribute.name)
65
+ .change(function() { $('#'+this2.el+'_form').trigger('submit'); })
66
+ )
67
+ .append($('<input/>')
68
+ .attr('type', 'submit')
69
+ .val('Submit')
70
+ )
71
+ );
72
+
73
+ if (this.attribute.value && this.attribute.value != '/files/original/missing.png')
74
+ {
75
+ $('#'+this.el+'_form').append($('<input/>')
76
+ .attr('type', 'button')
77
+ .attr('id', this.el + '_download_button')
78
+ .val(this.attribute.download_text ? this.attribute.download_text : 'Download current file')
79
+ .click(function() { window.open(this2.timestamped_link(), '_blank'); })
80
+ );
81
+ }
82
+
76
83
  $('#'+this.el+'_container').append($('<div/>')
77
84
  .attr('id', this.el + '_message')
78
85
  );
79
- iframe = $("<iframe name=\"" + this.el + "_iframe\"></iframe>")
80
- .attr('name', this.el + '_iframe')
81
- .attr('id', this.el + '_iframe');
86
+ iframe = $("<iframe name=\"" + this.el + "_iframe\" id=\"" + this.el + "_iframe\" src=''></iframe>");
82
87
  if (this.attribute.debug)
83
88
  iframe.css('width', '100%').css('height', 600).css('background', '#fff');
84
89
  else
85
90
  iframe.css('width', 0).css('height', 0).css('border', 0);
86
91
  $('#'+this.el+'_container').append(iframe);
87
92
  $('#'+this.el+'_container').append($('<br/>').css('clear', 'both'));
93
+
94
+ var w = $('#' + this.el + '_update_button').outerWidth(true);
95
+ $('#' + this.el + '_fake_file_input').css('width', '' + w + 'px');
88
96
  },
89
97
 
90
98
  post_upload: function() {
91
99
  $('#'+this.el+'_message').empty();
92
100
 
93
101
  var str = frames[this.el+'_iframe'].document.documentElement.innerHTML;
94
- str = str.replace(/.*?{(.*?)/, '{$1');
102
+ str = str.replace(/[\s\S]*?{([\s\S]*?)/, '{$1');
95
103
  str = str.substr(0, str.lastIndexOf('}')+1);
96
104
 
97
105
  var resp = $.parseJSON(str);
@@ -100,19 +108,21 @@ BoundFile = BoundControl.extend({
100
108
  if (resp.attributes && resp.attributes[this.attribute.name])
101
109
  for (var thing in resp.attributes[this.attribute.name])
102
110
  this.attribute[thing] = resp.attributes[this.attribute.name][thing];
103
- this.attribute.value_clean = this.attribute.value;
111
+ this.attribute.value_clean = this.attribute.value;
104
112
  }
105
113
 
106
114
  if (resp.error)
107
- this.error(resp.error);
108
- else
109
- {
110
- $('#'+this.el+'_link').parent().css('display', 'block');
111
- $('#'+this.el+'_link').attr('href', this.attribute.value);
112
- //$('#'+this.el+'_container img').attr('src', this.attribute.value);
113
- }
115
+ this.error(resp.error);
114
116
  },
115
117
 
118
+ timestamped_link: function() {
119
+ var href = this.attribute.value;
120
+ if (href.indexOf('?') > 0)
121
+ href = href.split('?')[0];
122
+ href = href + '?' + Math.random();
123
+ return href;
124
+ },
125
+
116
126
  error: function(str) {
117
127
  if (!$('#'+this.el+'_message').length)
118
128
  {
@@ -33,48 +33,62 @@ BoundImage = BoundControl.extend({
33
33
  .css('float', 'left')
34
34
  .css('margin-right', 10)
35
35
  );
36
- $('#'+this.el+'_container').append($('<form/>')
37
- .attr('action', this.attribute.update_url)
38
- .attr('method', 'post')
39
- .attr('enctype', 'multipart/form-data')
40
- .attr('encoding', 'multipart/form-data')
41
- .attr('target', this.el + '_iframe')
42
- .on('submit', function() {
43
- $('#'+this2.el+'_message').html("<p class='loading'>Uploading...</p>");
44
- $('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
45
- })
46
- .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
47
- .append($('<input/>').attr('type', 'button').val('Update ' + this.attribute.nice_name).click(function() {
48
- $('#'+this2.el+'_container input[type="file"]').click();
49
- }))
50
- .append($('<input/>')
51
- .attr('type', 'file')
52
- .attr('name', this.attribute.name)
53
- .css('display', 'none')
54
- .on('change', function() { $('#'+this2.el+'_container form').submit(); })
55
- )
56
- );
36
+ $('#'+this.el+'_container')
37
+ .append($('<form target="' + this.el + '_iframe"></form>')
38
+ .attr('id', this.el + '_form')
39
+ .attr('action', this.attribute.update_url)
40
+ .attr('method', 'post')
41
+ .attr('enctype', 'multipart/form-data')
42
+ .attr('encoding', 'multipart/form-data')
43
+ //.attr('target', this.el + '_iframe')
44
+ .on('submit', function() {
45
+ $('#'+this2.el+'_message').html("<p class='loading'>Uploading...</p>");
46
+ $('#'+this2.el+'_iframe').on('load', function() { this2.post_upload(); });
47
+ return true;
48
+ })
49
+ .append($('<input/>').attr('type', 'hidden').attr('name', 'authenticity_token').val(this.binder.authenticity_token))
50
+ .append($('<div/>')
51
+ .attr('id', this.el + '_fake_file_input')
52
+ .addClass('mb_fake_file_input')
53
+ .append($('<input/>')
54
+ .attr('type', 'button')
55
+ .attr('id', this.el + '_update_button')
56
+ .val('Update ' + this.attribute.nice_name)
57
+ .click(function() { $('#'+this2.el+'_file').click(); })
58
+ )
59
+ .append($('<input/>')
60
+ .attr('type', 'file')
61
+ .attr('id', this.el + '_file')
62
+ .attr('name', this.attribute.name)
63
+ .change(function() { $('#'+this2.el+'_form').trigger('submit'); })
64
+ )
65
+ .append($('<input/>')
66
+ .attr('type', 'submit')
67
+ .val('Submit')
68
+ )
69
+ )
70
+ );
57
71
  $('#'+this.el+'_container').append($('<div/>')
58
72
  .attr('id', this.el + '_message')
59
73
  );
60
- iframe = $('<iframe/>')
61
- .attr('name', this.el + '_iframe')
62
- .attr('id', this.el + '_iframe');
74
+ iframe = $("<iframe name=\"" + this.el + "_iframe\" id=\"" + this.el + "_iframe\" src=''></iframe>");
63
75
  if (this.attribute.debug)
64
76
  iframe.css('width', '100%').css('height', 600).css('background', '#fff');
65
77
  else
66
78
  iframe.css('width', 0).css('height', 0).css('border', 0);
67
79
  $('#'+this.el+'_container').append(iframe);
68
80
  $('#'+this.el+'_container').append($('<br/>').css('clear', 'both'));
81
+
82
+ var w = $('#' + this.el + '_update_button').outerWidth(true);
83
+ $('#' + this.el + '_fake_file_input').css('width', '' + w + 'px');
69
84
  },
70
85
 
71
86
  post_upload: function() {
72
87
  $('#'+this.el+'_message').empty();
73
88
 
74
89
  var str = frames[this.el+'_iframe'].document.documentElement.innerHTML;
75
- str = str.replace(/.*?{(.*?)/, '{$1');
90
+ str = str.replace(/[\s\S]*?{([\s\S]*?)/, '{$1');
76
91
  str = str.substr(0, str.lastIndexOf('}')+1);
77
-
78
92
  var resp = $.parseJSON(str);
79
93
  if (resp.success)
80
94
  {
@@ -84,12 +84,22 @@ div.mb_container div.mb_placeholder {
84
84
  z-index: 19;
85
85
  }
86
86
 
87
+ div.mb_container form.mb_file_form div.mb_placeholder {
88
+ position: relative;
89
+ float: left;
90
+ margin-right: 14px;
91
+ }
92
+
87
93
  .mb_container .mb_placeholder span {
88
94
  display: block;
89
95
  font-size: 20px;
90
96
  color: #757575;
91
97
  }
92
98
 
99
+ div.mb_container form.mb_file_form div.mb_placeholder span {
100
+ display: inline;
101
+ }
102
+
93
103
  .mb_container input[type='checkbox'] {
94
104
  /*position: absolute;*/
95
105
  top: 4px;
@@ -116,3 +126,33 @@ div.mb_container div.mb_placeholder {
116
126
  clear: both;
117
127
  line-height: 0;
118
128
  }
129
+
130
+ .mb_fake_file_input {
131
+ position: relative;
132
+ overflow: hidden;
133
+ float: left;
134
+ margin-right: 14px;
135
+ }
136
+
137
+ .mb_fake_file_input input[type='file'] {
138
+ position: absolute;
139
+ top: 0;
140
+ right: 0;
141
+ z-index: 2;
142
+ width: 1000px;
143
+ height: 100px;
144
+ text-align: right;
145
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
146
+ filter: alpha(opacity=0);
147
+ -khtml-opacity: 0;
148
+ -moz-opacity: 0;
149
+ opacity: 0;
150
+ }
151
+
152
+ .mb_fake_file_input input[type='button'] {
153
+ z-index: 1;
154
+ }
155
+
156
+ .mb_fake_file_input input[type='submit'] {
157
+ display: none;
158
+ }
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.3.65'
2
+ VERSION = '0.3.66'
3
3
  end
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.65
4
+ version: 0.3.66
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-03-14 00:00:00.000000000 Z
11
+ date: 2014-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails