caboose-cms 0.8.42 → 0.8.43
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/class.js +60 -0
- data/app/assets/javascripts/caboose/modal_controllers/modal_block_controller.js +403 -0
- data/app/assets/javascripts/caboose/modal_controllers/modal_button_controller.js +60 -0
- data/app/assets/javascripts/caboose/modal_controllers/modal_controller.js +69 -0
- data/app/assets/stylesheets/caboose/modal_inline.css +17 -0
- data/app/models/caboose/tax_calculator.rb +3 -2
- data/lib/caboose/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18b283a8b96050980b4e8122571e7a867d425ffa
|
4
|
+
data.tar.gz: 1c331a70fc7ade2a2b6bb3f6157e9869460bda49
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04470cf22851378fcf5824f8e4e52bcc058c6c2e0e6d40054d615821d6ff509dea3a2fb68d77c07c298f5b9d5b95268b891253744b1b7479b111ec257ff8956c
|
7
|
+
data.tar.gz: 6b5960db73cbfa6957a70c24922e80666ba1c12456ec4e3e476279aa93f7c1df399db86b83c00ffa908791d597cca95d137fb5211d58c7e435c2c82147e0fb3f
|
@@ -0,0 +1,60 @@
|
|
1
|
+
// Inspired by base2 and Prototype
|
2
|
+
(function(){
|
3
|
+
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
|
4
|
+
|
5
|
+
// The base Class implementation (does nothing)
|
6
|
+
this.Class = function(){};
|
7
|
+
|
8
|
+
// Create a new Class that inherits from this class
|
9
|
+
Class.extend = function(prop) {
|
10
|
+
var _super = this.prototype;
|
11
|
+
|
12
|
+
// Instantiate a base class (but only create the instance,
|
13
|
+
// don't run the init constructor)
|
14
|
+
initializing = true;
|
15
|
+
var prototype = new this();
|
16
|
+
initializing = false;
|
17
|
+
|
18
|
+
// Copy the properties over onto the new prototype
|
19
|
+
for (var name in prop) {
|
20
|
+
// Check if we're overwriting an existing function
|
21
|
+
prototype[name] = typeof prop[name] == "function" &&
|
22
|
+
typeof _super[name] == "function" && fnTest.test(prop[name]) ?
|
23
|
+
(function(name, fn){
|
24
|
+
return function() {
|
25
|
+
var tmp = this._super;
|
26
|
+
|
27
|
+
// Add a new ._super() method that is the same method
|
28
|
+
// but on the super-class
|
29
|
+
this._super = _super[name];
|
30
|
+
|
31
|
+
// The method only need to be bound temporarily, so we
|
32
|
+
// remove it when we're done executing
|
33
|
+
var ret = fn.apply(this, arguments);
|
34
|
+
this._super = tmp;
|
35
|
+
|
36
|
+
return ret;
|
37
|
+
};
|
38
|
+
})(name, prop[name]) :
|
39
|
+
prop[name];
|
40
|
+
}
|
41
|
+
|
42
|
+
// The dummy class constructor
|
43
|
+
function Class() {
|
44
|
+
// All construction is actually done in the init method
|
45
|
+
if ( !initializing && this.init )
|
46
|
+
this.init.apply(this, arguments);
|
47
|
+
}
|
48
|
+
|
49
|
+
// Populate our constructed prototype object
|
50
|
+
Class.prototype = prototype;
|
51
|
+
|
52
|
+
// Enforce the constructor to be what we expect
|
53
|
+
Class.constructor = Class;
|
54
|
+
|
55
|
+
// And make this class extendable
|
56
|
+
Class.extend = arguments.callee;
|
57
|
+
|
58
|
+
return Class;
|
59
|
+
};
|
60
|
+
})();
|
@@ -0,0 +1,403 @@
|
|
1
|
+
|
2
|
+
var ModalBlockController = ModalController.extend({
|
3
|
+
|
4
|
+
block_types: false,
|
5
|
+
|
6
|
+
init: function(options)
|
7
|
+
{
|
8
|
+
for (var thing in options)
|
9
|
+
this[thing] = options[thing];
|
10
|
+
|
11
|
+
//this.set_block_type_editable();
|
12
|
+
this.set_block_value_editable(this.block);
|
13
|
+
this.set_child_blocks_editable();
|
14
|
+
this.set_clickable();
|
15
|
+
|
16
|
+
that.update_on_close = false;
|
17
|
+
$.each(that.block.children, function(i, b) {
|
18
|
+
if (b.block_type.field_type == 'image' || b.block_type.field_type == 'file')
|
19
|
+
that.update_on_close = true
|
20
|
+
});
|
21
|
+
|
22
|
+
},
|
23
|
+
|
24
|
+
base_url: function(b)
|
25
|
+
{
|
26
|
+
return '/admin/' + (b.page_id ? 'pages/' + b.page_id : 'posts/' + b.post_id) + '/blocks';
|
27
|
+
},
|
28
|
+
|
29
|
+
block_url: function(b)
|
30
|
+
{
|
31
|
+
return this.base_url(b) + '/' + b.id;
|
32
|
+
},
|
33
|
+
|
34
|
+
edit_block: function(block_id)
|
35
|
+
{
|
36
|
+
window.location = this.base_url(this.block) + '/' + block_id + '/edit';
|
37
|
+
},
|
38
|
+
|
39
|
+
/*****************************************************************************
|
40
|
+
Printing
|
41
|
+
*****************************************************************************/
|
42
|
+
|
43
|
+
crumbtrail: function()
|
44
|
+
{
|
45
|
+
var crumbs = $('<h2/>').css('margin-top', '0').css('padding-top', '0');
|
46
|
+
var b = that.block;
|
47
|
+
while (b)
|
48
|
+
{
|
49
|
+
var href = b.id == that.block_id ? "#" : that.base_url + '/' + b.id;
|
50
|
+
var text = b.block_type.description + (b.name ? ' (' + b.name + ')' : '');
|
51
|
+
crumbs.prepend($('<a/>').attr('href', href).html(text));
|
52
|
+
b = b.parent
|
53
|
+
if (b) crumbs.prepend(' > ');
|
54
|
+
}
|
55
|
+
return crumbs;
|
56
|
+
},
|
57
|
+
|
58
|
+
print: function()
|
59
|
+
{
|
60
|
+
var that = this;
|
61
|
+
|
62
|
+
if (!that.block)
|
63
|
+
{
|
64
|
+
var div = $('<div/>')
|
65
|
+
.append($('<div/>').attr('id', 'crumbtrail'))
|
66
|
+
.append($('<div/>').attr('id', 'modal_content'));
|
67
|
+
.append($('<div/>').attr('id', 'modal_message'));
|
68
|
+
.append($('<p/>')
|
69
|
+
.append($('<input/>').attr('type', 'button').val('Close').click(function() {
|
70
|
+
if (that.update_on_close)
|
71
|
+
parent_controller.render_blocks();
|
72
|
+
that.close();
|
73
|
+
}))
|
74
|
+
<% if @block.name.nil? %>
|
75
|
+
<input type='button' value='Delete Block' onclick="controller.delete_block();" />
|
76
|
+
<% end %>
|
77
|
+
<input type='button' value='Move Up' onclick="controller.move_up();" />
|
78
|
+
<input type='button' value='Move Down' onclick="controller.move_down();" />
|
79
|
+
<input type='button' value='Advanced' onclick="window.location='<%= raw base_url %>/<%= @block.id %>/advanced';" />
|
80
|
+
</p>
|
81
|
+
|
82
|
+
that.modal(div, 800);
|
83
|
+
that.refresh(function() { that.print(); });
|
84
|
+
return;
|
85
|
+
}
|
86
|
+
|
87
|
+
var div = $('<div/>');
|
88
|
+
|
89
|
+
if (that.block.block_type.field_type != 'block')
|
90
|
+
div.append($('<p/>').append($('<div/>').attr('id', 'block_' + that.block.id + '_value')));
|
91
|
+
else
|
92
|
+
{
|
93
|
+
if (that.block.children.length > 0)
|
94
|
+
{
|
95
|
+
$.each(that.block.children, function(i, b) {
|
96
|
+
if (b.block_type.field_type != 'block' && b.block_type.field_type != 'richtext' && b.block_type.field_type != 'image' && b.block_type.field_type != 'file')
|
97
|
+
div.append($('<div/>').css('margin-bottom', '10px').append($('<div/>').attr('id', 'block_' + b.id + '_value')));
|
98
|
+
else
|
99
|
+
div.append(b.rendered_value);
|
100
|
+
});
|
101
|
+
}
|
102
|
+
else
|
103
|
+
{
|
104
|
+
div.append($('<p/>').append("This block doesn't have any content yet."));
|
105
|
+
}
|
106
|
+
if (that.block.block_type.allow_child_blocks)
|
107
|
+
{
|
108
|
+
div.append($('<p/>').append($('<a/>').attr('href', '#').html("Add a child block!").click(function(e) {
|
109
|
+
e.preventDefault();
|
110
|
+
that.add_child_block();
|
111
|
+
})));
|
112
|
+
}
|
113
|
+
}
|
114
|
+
div.append($('<div/>').
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<% content_for :caboose_css do %>
|
120
|
+
<style type='text/css'>
|
121
|
+
.block { border: #ccc 1px dotted; }
|
122
|
+
#block_<%= @block.id %>_block_type_id_container { }
|
123
|
+
#modal_content .checkbox_multiple input[type=checkbox] { position: relative !important; }
|
124
|
+
</style>
|
125
|
+
<% end %>
|
126
|
+
<% content_for :caboose_js do %>
|
127
|
+
<%= javascript_include_tag "caboose/model/all" %>
|
128
|
+
<%= javascript_include_tag "caboose/admin_block_edit" %>
|
129
|
+
<script type='text/javascript'>
|
130
|
+
|
131
|
+
var modal = false;
|
132
|
+
$(window).load(function() {
|
133
|
+
keep_modal_autosized();
|
134
|
+
});
|
135
|
+
|
136
|
+
var autosize_count = 0;
|
137
|
+
function keep_modal_autosized()
|
138
|
+
{
|
139
|
+
if (autosize_count > 3) return;
|
140
|
+
if (modal) modal.autosize();
|
141
|
+
else modal = new CabooseModal(800);
|
142
|
+
autosize_count = autosize_count + 1;
|
143
|
+
setTimeout(function() { keep_modal_autosized(); }, 1000);
|
144
|
+
}
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
},
|
149
|
+
|
150
|
+
/*****************************************************************************
|
151
|
+
Block Rendering
|
152
|
+
*****************************************************************************/
|
153
|
+
|
154
|
+
set_clickable: function()
|
155
|
+
{
|
156
|
+
var that = this;
|
157
|
+
$.ajax({
|
158
|
+
url: that.base_url(that.block) + '/tree',
|
159
|
+
success: function(blocks) {
|
160
|
+
$(blocks).each(function(i,b) {
|
161
|
+
that.set_clickable_helper(b);
|
162
|
+
});
|
163
|
+
}
|
164
|
+
});
|
165
|
+
},
|
166
|
+
|
167
|
+
set_clickable_helper: function(b)
|
168
|
+
{
|
169
|
+
var that = this;
|
170
|
+
$('#block_' + b.id).attr('onclick','').unbind('click');
|
171
|
+
$('#block_' + b.id).click(function(e) {
|
172
|
+
e.stopPropagation();
|
173
|
+
that.edit_block(b.id);
|
174
|
+
});
|
175
|
+
if (b.allow_child_blocks == true)
|
176
|
+
{
|
177
|
+
$('#new_block_' + b.id).replaceWith($('<input/>')
|
178
|
+
.attr('type', 'button')
|
179
|
+
.val('New Block')
|
180
|
+
.click(function(e) { e.stopPropagation(); that.new_block(b.id);
|
181
|
+
})
|
182
|
+
);
|
183
|
+
}
|
184
|
+
var show_mouseover = true;
|
185
|
+
if (b.children && b.children.length > 0)
|
186
|
+
{
|
187
|
+
$.each(b.children, function(i, b2) {
|
188
|
+
if (b2.block_type_id = 34)
|
189
|
+
show_mouseover = false;
|
190
|
+
that.set_clickable_helper(b2);
|
191
|
+
});
|
192
|
+
}
|
193
|
+
if (show_mouseover)
|
194
|
+
{
|
195
|
+
$('#block_' + b.id).mouseover(function(el) { $('#block_' + b.id).addClass( 'block_over'); });
|
196
|
+
$('#block_' + b.id).mouseout(function(el) { $('#block_' + b.id).removeClass('block_over'); });
|
197
|
+
}
|
198
|
+
},
|
199
|
+
|
200
|
+
/****************************************************************************/
|
201
|
+
|
202
|
+
//set_block_type_editable: function()
|
203
|
+
//{
|
204
|
+
// var that = this;
|
205
|
+
// var b = this.block;
|
206
|
+
// m = new ModelBinder({
|
207
|
+
// name: 'Block',
|
208
|
+
// id: b.id,
|
209
|
+
// update_url: '/admin/pages/' + b.page_id + '/blocks/' + b.id,
|
210
|
+
// authenticity_token: that.authenticity_token,
|
211
|
+
// attributes: [{
|
212
|
+
// name: 'block_type_id',
|
213
|
+
// nice_name: 'Block type',
|
214
|
+
// type: 'select',
|
215
|
+
// value: b.block_type_id,
|
216
|
+
// text: b.block_type.name,
|
217
|
+
// width: 400,
|
218
|
+
// fixed_placeholder: true,
|
219
|
+
// options_url: '/admin/block-types/options',
|
220
|
+
// after_update: function() { parent.controller.render_blocks(); window.location.reload(true); },
|
221
|
+
// after_cancel: function() { parent.controller.render_blocks(); window.location.reload(true); },
|
222
|
+
// on_load: function() { that.modal.autosize(); }
|
223
|
+
// },{
|
224
|
+
// name: 'parent_id',
|
225
|
+
// nice_name: 'Parent ID',
|
226
|
+
// type: 'select',
|
227
|
+
// value: b.parent_id,
|
228
|
+
// text: b.parent_title,
|
229
|
+
// width: 400,
|
230
|
+
// fixed_placeholder: true,
|
231
|
+
// options_url: '/admin/pages/' + b.page_id + '/block-options',
|
232
|
+
// after_update: function() { parent.controller.render_blocks(); },
|
233
|
+
// after_cancel: function() { parent.controller.render_blocks(); },
|
234
|
+
// on_load: function() { that.modal.autosize(); }
|
235
|
+
// }]
|
236
|
+
// });
|
237
|
+
// $('#advanced').hide();
|
238
|
+
//},
|
239
|
+
|
240
|
+
set_block_value_editable: function(b)
|
241
|
+
{
|
242
|
+
var that = this;
|
243
|
+
var bt = b.block_type;
|
244
|
+
if (b.block_type.field_type == 'block')
|
245
|
+
return;
|
246
|
+
|
247
|
+
var h = {
|
248
|
+
name: 'value',
|
249
|
+
type: bt.field_type,
|
250
|
+
nice_name: bt.description ? bt.description : bt.name,
|
251
|
+
width: bt.width ? bt.width : 780,
|
252
|
+
after_update: function() { parent.controller.render_blocks(); },
|
253
|
+
after_cancel: function() { parent.controller.render_blocks(); }
|
254
|
+
};
|
255
|
+
h['value'] = b.value
|
256
|
+
if (bt.field_type == 'checkbox') h['value'] = b.value ? 'true' : 'false';
|
257
|
+
if (bt.field_type == 'image') h['value'] = b.image.tiny_url;
|
258
|
+
if (bt.field_type == 'file') h['value'] = b.image.url;
|
259
|
+
if (bt.field_type == 'select') h['text'] = b.value;
|
260
|
+
if (bt.height) h['height'] = bt.height;
|
261
|
+
if (bt.fixed_placeholder) h['fixed_placeholder'] = bt.fixed_placeholder;
|
262
|
+
if (bt.options || bt.options_function) h['options_url'] = '/admin/block-types/' + bt.id + '/options';
|
263
|
+
else if (bt.options_url) h['options_url'] = bt.options_url;
|
264
|
+
if (bt.field_type == 'file') h['update_url'] = that.block_url(b) + '/file';
|
265
|
+
if (bt.field_type == 'image')
|
266
|
+
{
|
267
|
+
h['update_url'] = that.block_url(b) + '/image'
|
268
|
+
h['image_refresh_delay'] = 100;
|
269
|
+
}
|
270
|
+
|
271
|
+
m = new ModelBinder({
|
272
|
+
name: 'Block',
|
273
|
+
id: b.id,
|
274
|
+
update_url: that.block_url(b),
|
275
|
+
authenticity_token: that.authenticity_token,
|
276
|
+
attributes: [h]
|
277
|
+
});
|
278
|
+
},
|
279
|
+
|
280
|
+
set_child_blocks_editable: function()
|
281
|
+
{
|
282
|
+
var that = this;
|
283
|
+
$.each(this.block.children, function(i, b) {
|
284
|
+
var bt = b.block_type;
|
285
|
+
if (bt.field_type == 'block' || bt.field_type == 'richtext')
|
286
|
+
{
|
287
|
+
//$('#block_' + b.id).attr('onclick','').unbind('click');
|
288
|
+
//$('#block_' + b.id).click(function(e) {
|
289
|
+
// window.location = '/admin/pages/' + b.page_id + '/blocks/' + b.id + '/edit';
|
290
|
+
//});
|
291
|
+
}
|
292
|
+
else
|
293
|
+
that.set_block_value_editable(b);
|
294
|
+
});
|
295
|
+
},
|
296
|
+
|
297
|
+
add_child_block: function(block_type_id)
|
298
|
+
{
|
299
|
+
var that = this;
|
300
|
+
if (!this.block_types)
|
301
|
+
{
|
302
|
+
modal.autosize("<p class='loading'>Getting block types...</p>");
|
303
|
+
$.ajax({
|
304
|
+
url: '/admin/block-types/options',
|
305
|
+
type: 'get',
|
306
|
+
success: function(resp) {
|
307
|
+
that.block_types = resp;
|
308
|
+
that.add_child_block();
|
309
|
+
}
|
310
|
+
});
|
311
|
+
return;
|
312
|
+
}
|
313
|
+
if (!block_type_id)
|
314
|
+
{
|
315
|
+
var select = $('<select/>').attr('id', 'new_block_type_id');
|
316
|
+
$.each(this.block_types, function(i, bt) {
|
317
|
+
var opt = $('<option/>').val(bt.value).html(bt.text);
|
318
|
+
select.append(opt);
|
319
|
+
});
|
320
|
+
var p = $('<p/>').addClass('note warning')
|
321
|
+
.append("Select a type of page block: ")
|
322
|
+
.append(select)
|
323
|
+
.append("<br/>")
|
324
|
+
.append($('<input/>').attr('type','button').val('Confirm Add Block').click(function() { that.add_child_block($('#new_block_type_id').val()) })).append(' ')
|
325
|
+
.append($('<input/>').attr('type','button').val('Cancel').click(function() { $('#message').empty(); modal.autosize(); }));
|
326
|
+
modal.autosize(p);
|
327
|
+
return;
|
328
|
+
}
|
329
|
+
modal.autosize("<p class='loading'>Adding block...</p>");
|
330
|
+
$.ajax({
|
331
|
+
url: that.block_url(block),
|
332
|
+
type: 'post',
|
333
|
+
data: { block_type_id: block_type_id },
|
334
|
+
success: function(resp) {
|
335
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
336
|
+
if (resp.block) window.location.reload(true);
|
337
|
+
}
|
338
|
+
});
|
339
|
+
},
|
340
|
+
|
341
|
+
delete_block: function(confirm)
|
342
|
+
{
|
343
|
+
var that = this;
|
344
|
+
if (!confirm)
|
345
|
+
{
|
346
|
+
var p = $('<p/>').addClass('note warning')
|
347
|
+
.append("Are you sure you want to delete the block? This can't be undone.<br />")
|
348
|
+
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.delete_block(true); })).append(' ')
|
349
|
+
.append($('<input/>').attr('type','button').val('No').click(function() { $('#message').empty(); modal.autosize(); }));
|
350
|
+
modal.autosize(p);
|
351
|
+
return;
|
352
|
+
}
|
353
|
+
modal.autosize("<p class='loading'>Deleting block...</p>");
|
354
|
+
$.ajax({
|
355
|
+
url: that.block_url(that.block),
|
356
|
+
type: 'delete',
|
357
|
+
success: function(resp) {
|
358
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
359
|
+
if (resp.redirect)
|
360
|
+
{
|
361
|
+
parent.controller.render_blocks();
|
362
|
+
modal.close();
|
363
|
+
}
|
364
|
+
}
|
365
|
+
});
|
366
|
+
},
|
367
|
+
|
368
|
+
move_up: function()
|
369
|
+
{
|
370
|
+
var that = this;
|
371
|
+
modal.autosize("<p class='loading'>Moving up...</p>");
|
372
|
+
$.ajax({
|
373
|
+
url: that.block_url(that.block) + '/move-up',
|
374
|
+
type: 'put',
|
375
|
+
success: function(resp) {
|
376
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
377
|
+
if (resp.success)
|
378
|
+
{
|
379
|
+
modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
380
|
+
parent.controller.render_blocks();
|
381
|
+
}
|
382
|
+
}
|
383
|
+
});
|
384
|
+
},
|
385
|
+
|
386
|
+
move_down: function()
|
387
|
+
{
|
388
|
+
var that = this;
|
389
|
+
modal.autosize("<p class='loading'>Moving down...</p>");
|
390
|
+
$.ajax({
|
391
|
+
url: that.block_url(that.block) + '/move-down',
|
392
|
+
type: 'put',
|
393
|
+
success: function(resp) {
|
394
|
+
if (resp.error) modal.autosize("<p class='note error'>" + resp.error + "</p>");
|
395
|
+
if (resp.success)
|
396
|
+
{
|
397
|
+
modal.autosize("<p class='note success'>" + resp.success + "</p>");
|
398
|
+
parent.controller.render_blocks();
|
399
|
+
}
|
400
|
+
}
|
401
|
+
});
|
402
|
+
}
|
403
|
+
};
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
var ModalButtonController = ModalController.extend({
|
3
|
+
|
4
|
+
print: function()
|
5
|
+
{
|
6
|
+
var that = this;
|
7
|
+
|
8
|
+
if (!that.block)
|
9
|
+
{
|
10
|
+
var div = $('<div/>')
|
11
|
+
.append($('<div/>').attr('id', 'modal_content'))
|
12
|
+
.append($('<div/>').attr('id', 'modal_message').html("<p class='loading'>Getting block...</p>"))
|
13
|
+
.append($('<p/>').append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function(e) { $.colorbox.close(); })));
|
14
|
+
that.modal(div, 500, 200);
|
15
|
+
that.refresh(function() { that.print(); });
|
16
|
+
return;
|
17
|
+
}
|
18
|
+
|
19
|
+
var block_ids = {};
|
20
|
+
$.each(that.block.children, function(i, b) {
|
21
|
+
block_ids[b.name] = b.id;
|
22
|
+
});
|
23
|
+
|
24
|
+
$('#modal_content').empty()
|
25
|
+
.append($('<h2/>').append('Edit Button'))
|
26
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + block_ids['text' ] + '_text' )))
|
27
|
+
.append($('<p/>').append("Where do you want your button to go?"))
|
28
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + block_ids['url' ] + '_url' )))
|
29
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + block_ids['file' ] + '_file' )))
|
30
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + block_ids['target' ] + '_target' )))
|
31
|
+
.append($('<p/>').append("Options"))
|
32
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + block_ids['align' ] + '_align' )))
|
33
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + block_ids['color' ] + '_color' )))
|
34
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + block_ids['margin' ] + '_margin' )));
|
35
|
+
$('#modal_message').empty();
|
36
|
+
that.autosize();
|
37
|
+
|
38
|
+
$.each(that.block.children, function(i, b) {
|
39
|
+
var attribs = [];
|
40
|
+
if (b.name == 'text' ) attribs.push({ name: 'text' , nice_name: 'Button Text' , type: 'text' , value: that.block.text , width: 500 });
|
41
|
+
if (b.name == 'url' ) attribs.push({ name: 'url' , nice_name: 'URL' , type: 'text' , value: that.block.url , width: 500 });
|
42
|
+
if (b.name == 'file' ) attribs.push({ name: 'file' , nice_name: 'File' , type: 'text' , value: that.block.file , width: 500 });
|
43
|
+
if (b.name == 'align' ) attribs.push({ name: 'align' , nice_name: 'Align' , type: 'select' , value: that.block.align , width: 500 , options_url: '/admin/block-types/' + b.block_type_id + '/options' });
|
44
|
+
if (b.name == 'color' ) attribs.push({ name: 'color' , nice_name: 'Color' , type: 'select' , value: that.block.color , width: 500 , options_url: '/admin/block-types/' + b.block_type_id + '/options' });
|
45
|
+
if (b.name == 'margin' ) attribs.push({ name: 'margin' , nice_name: 'Margin' , type: 'select' , value: that.block.margin , width: 500 , options_url: '/admin/block-types/' + b.block_type_id + '/options' });
|
46
|
+
if (b.name == 'target' ) attribs.push({ name: 'target' , nice_name: 'Open in New Window?', type: 'checkbox' , value: that.block.target == 'New Window' ? 1 : 0 , width: 500 });
|
47
|
+
|
48
|
+
new ModelBinder({
|
49
|
+
name: 'Block',
|
50
|
+
id: b.id,
|
51
|
+
update_url: '/admin/pages/' + that.page_id + '/blocks/' + b.id,
|
52
|
+
authenticity_token: that.authenticity_token,
|
53
|
+
attributes: attribs,
|
54
|
+
on_load: function() { that.autosize(); }
|
55
|
+
});
|
56
|
+
setTimeout(function() { that.autosize(); }, 2000);
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
});
|
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
var ModalController = Class.extend({
|
3
|
+
|
4
|
+
page_id: false,
|
5
|
+
block_id: false,
|
6
|
+
block: false,
|
7
|
+
modal_element: false,
|
8
|
+
authenticity_token: false,
|
9
|
+
|
10
|
+
init: function(params) {
|
11
|
+
var that = this;
|
12
|
+
for (var i in params)
|
13
|
+
that[i] = params[i];
|
14
|
+
that.print();
|
15
|
+
},
|
16
|
+
|
17
|
+
refresh: function(callback)
|
18
|
+
{
|
19
|
+
var that = this
|
20
|
+
$.ajax({
|
21
|
+
url: '/admin/pages/' + that.page_id + '/blocks/' + that.block_id + '/tree',
|
22
|
+
type: 'get',
|
23
|
+
success: function(arr) {
|
24
|
+
that.block = arr[0];
|
25
|
+
if (callback) callback();
|
26
|
+
}
|
27
|
+
});
|
28
|
+
},
|
29
|
+
|
30
|
+
modal: function(el, width, height, callback)
|
31
|
+
{
|
32
|
+
var that = this;
|
33
|
+
if (!width) width = 400;
|
34
|
+
if (!height) height = $(el).outerHeight(true);
|
35
|
+
that.modal_element = el;
|
36
|
+
el.attr('id', 'the_modal').addClass('modal').css('width', '' + width + 'px');
|
37
|
+
$.colorbox({
|
38
|
+
html: el,
|
39
|
+
initialWidth: width,
|
40
|
+
initialHeight: height,
|
41
|
+
innerWidth: width,
|
42
|
+
innerHeight: height,
|
43
|
+
scrolling: false,
|
44
|
+
closeButton: false,
|
45
|
+
opacity: 0.50,
|
46
|
+
onComplete: function() {
|
47
|
+
var arr = ['TopLeft','TopCenter','TopRight','BottomLeft','BottomCenter','BottomRight','MiddleLeft','MiddleRight'];
|
48
|
+
for (var i in arr) $('#cbox' + arr[i]).css('background-color', '#fff !important');
|
49
|
+
$("#cboxClose").hide();
|
50
|
+
if (callback) callback();
|
51
|
+
}
|
52
|
+
});
|
53
|
+
},
|
54
|
+
|
55
|
+
autosize: function(msg, msg_container)
|
56
|
+
{
|
57
|
+
var that = this;
|
58
|
+
if (!that.modal_element) return;
|
59
|
+
if (msg) $('#' + (msg_container ? msg_container : 'modal_message')).html(msg);
|
60
|
+
var h = $(that.modal_element).outerHeight(true) + 20;
|
61
|
+
$.colorbox.resize({ innerHeight: '' + h + 'px' });
|
62
|
+
},
|
63
|
+
|
64
|
+
close: function()
|
65
|
+
{
|
66
|
+
$.colorbox.close();
|
67
|
+
}
|
68
|
+
|
69
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
#the_modal {
|
3
|
+
box-sizing: content-box; /* border-box */
|
4
|
+
}
|
5
|
+
|
6
|
+
#modal_content p { margin-bottom: 10px; }
|
7
|
+
|
8
|
+
#modal_content .mb_container input { border: #ccc 1px solid; }
|
9
|
+
|
10
|
+
#modal_content div.mb_container div.mb_placeholder { top: 9px; }
|
11
|
+
#modal_content div.mb_container div.mb_placeholder span { font-size: 16px; }
|
12
|
+
|
13
|
+
#modal_content div.mb_container select { border: #ccc 1px solid; height: 36px; }
|
14
|
+
#modal_content div.mb_container select option { font-size: 16px; }
|
15
|
+
|
16
|
+
#modal_content div.mb_container input[type=checkbox] { top: 12px; }
|
17
|
+
|
@@ -8,12 +8,13 @@ module Caboose
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def self.tax(invoice)
|
11
|
+
sc = invoice.site.store_config
|
12
|
+
return self.custom_tax(sc, invoice) if !sc.auto_calculate_tax
|
13
|
+
|
11
14
|
return 0.00 if !invoice.shipping_address
|
12
15
|
return 0.00 if !invoice.has_taxable_items?
|
13
16
|
return 0.00 if !invoice.has_shippable_items?
|
14
17
|
|
15
|
-
sc = invoice.site.store_config
|
16
|
-
return self.custom_tax(sc, invoice) if !sc.auto_calculate_tax
|
17
18
|
return invoice.subtotal * invoice.tax_rate if invoice.tax_rate # See if the tax rate has already been calculated
|
18
19
|
|
19
20
|
t = self.transaction(invoice)
|
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.8.
|
4
|
+
version: 0.8.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -544,6 +544,7 @@ files:
|
|
544
544
|
- app/assets/javascripts/caboose/checkout_payment_authnet.js
|
545
545
|
- app/assets/javascripts/caboose/checkout_payment_stripe.js
|
546
546
|
- app/assets/javascripts/caboose/checkout_shipping.js
|
547
|
+
- app/assets/javascripts/caboose/class.js
|
547
548
|
- app/assets/javascripts/caboose/date_format.js
|
548
549
|
- app/assets/javascripts/caboose/google_spreadsheets.js
|
549
550
|
- app/assets/javascripts/caboose/imageZoom.js
|
@@ -560,6 +561,9 @@ files:
|
|
560
561
|
- app/assets/javascripts/caboose/main.js
|
561
562
|
- app/assets/javascripts/caboose/media_browser.js
|
562
563
|
- app/assets/javascripts/caboose/modal.js
|
564
|
+
- app/assets/javascripts/caboose/modal_controllers/modal_block_controller.js
|
565
|
+
- app/assets/javascripts/caboose/modal_controllers/modal_button_controller.js
|
566
|
+
- app/assets/javascripts/caboose/modal_controllers/modal_controller.js
|
563
567
|
- app/assets/javascripts/caboose/modal_integration.js
|
564
568
|
- app/assets/javascripts/caboose/model.form.page.js
|
565
569
|
- app/assets/javascripts/caboose/model.form.user.js
|
@@ -700,6 +704,7 @@ files:
|
|
700
704
|
- app/assets/stylesheets/caboose/login.css
|
701
705
|
- app/assets/stylesheets/caboose/message_boxes.css.scss
|
702
706
|
- app/assets/stylesheets/caboose/modal.css
|
707
|
+
- app/assets/stylesheets/caboose/modal_inline.css
|
703
708
|
- app/assets/stylesheets/caboose/modal_main.css
|
704
709
|
- app/assets/stylesheets/caboose/model_binder.css
|
705
710
|
- app/assets/stylesheets/caboose/my_account.css
|