caboose-cms 0.8.43 → 0.8.44
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/admin_page_edit_content.js +83 -70
- data/app/assets/javascripts/caboose/card.js +2432 -0
- data/app/assets/javascripts/caboose/clipboard.js +7 -0
- data/app/assets/javascripts/caboose/modal_controllers/modal_block_controller.js +174 -252
- data/app/assets/javascripts/caboose/modal_controllers/modal_controller.js +160 -12
- data/app/assets/javascripts/caboose/modal_controllers/modal_media_controller.js +419 -0
- data/app/assets/javascripts/caboose/modal_integration.js +21 -1
- data/app/assets/javascripts/caboose/model/bound_checkbox.js +13 -6
- data/app/assets/javascripts/caboose/model/bound_select.js +16 -7
- data/app/assets/javascripts/caboose/model/bound_text.js +15 -2
- data/app/assets/stylesheets/caboose/admin_block_edit_image.css.scss +16 -1
- data/app/assets/stylesheets/caboose/admin_new_block.css +9 -0
- data/app/assets/stylesheets/caboose/application.css +2 -1
- data/app/assets/stylesheets/caboose/modal_inline.css +8 -15
- data/app/assets/stylesheets/caboose/my_account.scss +178 -0
- data/app/controllers/caboose/block_types_controller.rb +20 -0
- data/app/controllers/caboose/blocks_controller.rb +70 -8
- data/app/controllers/caboose/media_controller.rb +39 -3
- data/app/models/caboose/block.rb +17 -1
- data/app/models/caboose/media.rb +9 -8
- data/app/models/caboose/schema.rb +1 -0
- data/app/views/caboose/block_types/admin_edit.html.erb +5 -2
- data/app/views/caboose/block_types/admin_index.html.erb +2 -1
- data/app/views/caboose/my_account/index.html.erb +124 -63
- data/app/views/caboose/my_account/index_old.html.erb +191 -0
- data/app/views/caboose/pages/admin_edit_content.html.erb +16 -1
- data/lib/caboose/version.rb +1 -1
- metadata +8 -3
- data/app/assets/stylesheets/caboose/my_account.css +0 -2
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* clipboard.js v1.5.12
|
3
|
+
* https://zenorocha.github.io/clipboard.js
|
4
|
+
*
|
5
|
+
* Licensed MIT © Zeno Rocha
|
6
|
+
*/
|
7
|
+
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(r)return r(a,!0);var l=new Error("Cannot find module '"+a+"'");throw l.code="MODULE_NOT_FOUND",l}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n?n:t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(t,e,n){var o=t("matches-selector");e.exports=function(t,e,n){for(var i=n?t:t.parentNode;i&&i!==document;){if(o(i,e))return i;i=i.parentNode}}},{"matches-selector":5}],2:[function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e,!0),n.delegateTarget&&o.call(t,n)}}var r=t("closest");e.exports=o},{closest:1}],3:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){var e=Object.prototype.toString.call(t);return"[object Function]"===e}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return i(t,e,n);if(c.nodeList(t))return r(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return s(document.body,t,e,n)}var c=t("./is"),s=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function o(t,e){if(r)return r.call(t,e);for(var n=t.parentNode.querySelectorAll(e),o=0;o<n.length;++o)if(n[o]==t)return!0;return!1}var i=Element.prototype,r=i.matchesSelector||i.webkitMatchesSelector||i.mozMatchesSelector||i.msMatchesSelector||i.oMatchesSelector;e.exports=o},{}],6:[function(t,e,n){function o(t){var e;if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName)t.focus(),t.setSelectionRange(0,t.value.length),e=t.value;else{t.hasAttribute("contenteditable")&&t.focus();var n=window.getSelection(),o=document.createRange();o.selectNodeContents(t),n.removeAllRanges(),n.addRange(o),e=n.toString()}return e}e.exports=o},{}],7:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;i>o;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,a=o.length;a>r;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if("undefined"!=typeof o)r(n,e("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return t.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action=e.action,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""},t.prototype.initSelection=function t(){this.text?this.selectFake():this.target&&this.selectTarget()},t.prototype.selectFake=function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0,this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[n?"right":"left"]="-9999px",this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,document.body.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()},t.prototype.removeFake=function t(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)},t.prototype.selectTarget=function t(){this.selectedText=(0,i.default)(this.target),this.copyText()},t.prototype.copyText=function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(n){e=!1}this.handleResult(e)},t.prototype.handleResult=function t(e){e?this.emitter.emit("success",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})},t.prototype.clearSelection=function t(){this.target&&this.target.blur(),window.getSelection().removeAllRanges()},t.prototype.destroy=function t(){this.removeFake()},a(t,[{key:"action",set:function t(){var e=arguments.length<=0||void 0===arguments[0]?"copy":arguments[0];if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!==("undefined"==typeof e?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=c})},{select:6}],9:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if("undefined"!=typeof o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(t,e,n,o){"use strict";function i(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function s(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var l=i(e),u=i(n),f=i(o),d=function(t){function e(n,o){r(this,e);var i=a(this,t.call(this));return i.resolveOptions(o),i.listenClick(n),i}return c(e,t),e.prototype.resolveOptions=function t(){var e=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText},e.prototype.listenClick=function t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})},e.prototype.onClick=function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new l.default({action:this.action(n),target:this.target(n),text:this.text(n),trigger:n,emitter:this})},e.prototype.defaultAction=function t(e){return s("action",e)},e.prototype.defaultTarget=function t(e){var n=s("target",e);return n?document.querySelector(n):void 0},e.prototype.defaultText=function t(e){return s("text",e)},e.prototype.destroy=function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)},e}(u.default);t.exports=d})},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)});
|
@@ -3,100 +3,50 @@ var ModalBlockController = ModalController.extend({
|
|
3
3
|
|
4
4
|
block_types: false,
|
5
5
|
|
6
|
-
|
6
|
+
after_refresh: function()
|
7
7
|
{
|
8
|
-
|
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
|
-
|
8
|
+
var that = this;
|
16
9
|
that.update_on_close = false;
|
17
10
|
$.each(that.block.children, function(i, b) {
|
18
11
|
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';
|
12
|
+
that.update_on_close = true;
|
13
|
+
});
|
14
|
+
that.print();
|
37
15
|
},
|
38
16
|
|
39
17
|
/*****************************************************************************
|
40
18
|
Printing
|
41
19
|
*****************************************************************************/
|
42
20
|
|
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
21
|
print: function()
|
59
22
|
{
|
60
|
-
var that = this;
|
61
|
-
|
23
|
+
var that = this;
|
62
24
|
if (!that.block)
|
63
|
-
{
|
25
|
+
{
|
64
26
|
var div = $('<div/>')
|
65
|
-
.append($('<div/>').attr('id', '
|
66
|
-
.append($('<div/>').attr('id', 'modal_content'))
|
67
|
-
.append($('<div/>').attr('id', 'modal_message'))
|
68
|
-
.append($('<
|
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
|
-
|
27
|
+
.append($('<div/>').attr('id', 'modal_crumbtrail' ))
|
28
|
+
.append($('<div/>').attr('id', 'modal_content' ))
|
29
|
+
.append($('<div/>').attr('id', 'modal_message' ))
|
30
|
+
.append($('<div/>').attr('id', 'modal_controls' ));
|
82
31
|
that.modal(div, 800);
|
83
|
-
that.refresh(function() { that.
|
32
|
+
that.refresh(function() { that.after_refresh() });
|
84
33
|
return;
|
85
34
|
}
|
86
35
|
|
87
|
-
var div = $('<div/>');
|
88
|
-
|
36
|
+
var div = $('<div/>').attr('id', 'modal_content');
|
89
37
|
if (that.block.block_type.field_type != 'block')
|
90
38
|
div.append($('<p/>').append($('<div/>').attr('id', 'block_' + that.block.id + '_value')));
|
91
39
|
else
|
92
40
|
{
|
93
41
|
if (that.block.children.length > 0)
|
94
|
-
{
|
95
|
-
$.each(that.block.children, function(i, b) {
|
42
|
+
{
|
43
|
+
$.each(that.block.children, function(i, b) {
|
96
44
|
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
45
|
div.append($('<div/>').css('margin-bottom', '10px').append($('<div/>').attr('id', 'block_' + b.id + '_value')));
|
98
|
-
else
|
99
|
-
|
46
|
+
else
|
47
|
+
{
|
48
|
+
div.append($('<div/>').css('margin-bottom', '10px').append($('<div/>').attr('id', 'block_' + b.id)));
|
49
|
+
}
|
100
50
|
});
|
101
51
|
}
|
102
52
|
else
|
@@ -105,157 +55,187 @@ var ModalBlockController = ModalController.extend({
|
|
105
55
|
}
|
106
56
|
if (that.block.block_type.allow_child_blocks)
|
107
57
|
{
|
108
|
-
div.append($('<p/>').append($('<a/>').attr('href', '#').html("Add a child block!").click(function(e) {
|
58
|
+
div.append($('<p/>').css('clear', 'both').append($('<a/>').attr('href', '#').html("Add a child block!").click(function(e) {
|
109
59
|
e.preventDefault();
|
110
|
-
that.
|
60
|
+
that.add_block();
|
111
61
|
})));
|
112
62
|
}
|
113
63
|
}
|
114
|
-
|
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
|
-
|
64
|
+
$('#modal_content').replaceWith(div);
|
65
|
+
$('#modal_crumbtrail').empty().append(that.crumbtrail());
|
66
|
+
$('#modal_controls').empty().append(that.controls());
|
146
67
|
|
68
|
+
that.render_blocks();
|
69
|
+
that.set_editable();
|
70
|
+
that.autosize();
|
71
|
+
},
|
72
|
+
|
73
|
+
controls: function()
|
74
|
+
{
|
75
|
+
var that = this;
|
76
|
+
var p = $('<p/>').css('clear', 'both')
|
77
|
+
.append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function() { that.close(); if (that.update_on_close) { that.parent_controller.render_blocks(); } })).append(' ');
|
78
|
+
if (!that.block.name)
|
79
|
+
p.append($('<input/>').attr('type', 'button').addClass('btn').val('Delete Block').click(function() { that.delete_block(); })).append(' ');
|
80
|
+
p.append($('<input/>').attr('type', 'button').addClass('btn').val('Move Up' ).click(function() { that.move_up(); })).append(' ');
|
81
|
+
p.append($('<input/>').attr('type', 'button').addClass('btn').val('Move Down' ).click(function() { that.move_down(); })).append(' ');
|
82
|
+
p.append($('<input/>').attr('type', 'button').addClass('btn').val('Advanced' ).attr('id', 'btn_advanced').click(function() { that.print_advanced(); }));
|
83
|
+
return p;
|
84
|
+
},
|
85
|
+
|
86
|
+
print_advanced: function()
|
87
|
+
{
|
88
|
+
var that = this;
|
89
|
+
var b = that.block;
|
147
90
|
|
91
|
+
$('#modal_content').empty()
|
92
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_block_type_id' )))
|
93
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_parent_id' )))
|
94
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_constrain' )))
|
95
|
+
.append($('<p/>').append($('<div/>').attr('id', 'block_' + b.id + '_full_width' )))
|
96
|
+
$('#modal_controls').empty()
|
97
|
+
.append($('<p/>')
|
98
|
+
.append($('<input/>').attr('type', 'button').addClass('btn').val('Close').click(function() { that.close(); if (that.update_on_close) { that.parent_controller.render_blocks(); } })).append(' ')
|
99
|
+
.append($('<input/>').attr('type', 'button').addClass('btn').val('Back' ).click(function() { that.print(); }))
|
100
|
+
);
|
101
|
+
|
102
|
+
var m = new ModelBinder({
|
103
|
+
name: 'Block',
|
104
|
+
id: b.id,
|
105
|
+
update_url: that.block_url(b),
|
106
|
+
authenticity_token: that.authenticity_token,
|
107
|
+
attributes: [
|
108
|
+
{ name: 'block_type_id' , nice_name: 'Block type' , type: 'select' , value: b.block_type_id , text: b.block_type.name , width: 400, fixed_placeholder: true, options_url: '/admin/block-types/options' , after_update: function() { that.parent_controller.render_blocks(); that.block.block_type_id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
|
109
|
+
{ name: 'parent_id' , nice_name: 'Parent ID' , type: 'select' , value: b.parent_id , text: b.parent ? b.parent.title : '' , width: 400, fixed_placeholder: true, options_url: '/admin/pages/' + that.page_id + '/block-options' , after_update: function() { that.parent_controller.render_blocks(); that.block.parent_id = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
|
110
|
+
{ name: 'constrain' , nice_name: 'Constrain' , type: 'checkbox' , value: b.constrain ? 1 : 0 , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.constrain = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }},
|
111
|
+
{ name: 'full_width' , nice_name: 'Full Width' , type: 'checkbox' , value: b.full_width ? 1 : 0 , width: 400, fixed_placeholder: true, after_update: function() { that.parent_controller.render_blocks(); that.block.full_width = this.value; }, after_cancel: function() { that.parent_controller.render_blocks(); }, on_load: function() { that.modal.autosize(); }}
|
112
|
+
]
|
113
|
+
});
|
114
|
+
that.autosize();
|
115
|
+
},
|
116
|
+
|
117
|
+
crumbtrail: function()
|
118
|
+
{
|
119
|
+
var that = this;
|
120
|
+
var crumbs = $('<h2/>').css('margin-top', '0').css('padding-top', '0');
|
121
|
+
$.each(that.block.crumbtrail, function(i, h) {
|
122
|
+
if (i > 0) crumbs.append(' > ');
|
123
|
+
crumbs.append($('<a/>').attr('href', '#').html(h['text']).data('block_id', h['block_id']).click(function(e) {
|
124
|
+
e.preventDefault();
|
125
|
+
that.parent_controller.edit_block(parseInt($(this).data('block_id')));
|
126
|
+
}));
|
127
|
+
});
|
128
|
+
return crumbs;
|
148
129
|
},
|
149
130
|
|
150
131
|
/*****************************************************************************
|
151
132
|
Block Rendering
|
152
133
|
*****************************************************************************/
|
153
134
|
|
154
|
-
|
155
|
-
{
|
156
|
-
var that = this;
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
135
|
+
render_blocks: function()
|
136
|
+
{
|
137
|
+
var that = this;
|
138
|
+
if (that.block.block_type.field_type != 'block' && that.block.children.length == 0)
|
139
|
+
return;
|
140
|
+
|
141
|
+
$.each(that.block.children, function(i, b) {
|
142
|
+
var ft = b.block_type.field_type;
|
143
|
+
if (ft == 'block' || ft == 'richtext' || ft == 'image' || ft == 'file')
|
144
|
+
{
|
145
|
+
if (!b.rendered_value)
|
146
|
+
{
|
147
|
+
$.ajax({
|
148
|
+
block_id: b.id, // Used in the success function
|
149
|
+
url: that.block_url(b) + '/render',
|
150
|
+
type: 'get',
|
151
|
+
success: function(html) {
|
152
|
+
$('#the_modal #block_' + this.block_id).replaceWith(html);
|
153
|
+
|
154
|
+
var b2 = that.block_with_id(this.block_id);
|
155
|
+
b2.rendered_value = html;
|
156
|
+
that.set_clickable(b2);
|
157
|
+
that.autosize();
|
158
|
+
},
|
159
|
+
});
|
160
|
+
}
|
161
|
+
else
|
162
|
+
$('#the_modal #block_' + b.id).replaceWith(b.rendered_value);
|
163
163
|
}
|
164
|
-
});
|
164
|
+
});
|
165
165
|
},
|
166
|
+
|
167
|
+
/****************************************************************************/
|
168
|
+
|
169
|
+
set_clickable: function(b)
|
170
|
+
{
|
171
|
+
var that = this;
|
166
172
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
173
|
+
if (!b)
|
174
|
+
{
|
175
|
+
$.each(that.block.children, function(i,b) {
|
176
|
+
that.set_clickable(b);
|
177
|
+
});
|
178
|
+
}
|
179
|
+
|
180
|
+
$('#the_modal #block_' + b.id).attr('onclick','').unbind('click');
|
181
|
+
$('#the_modal #block_' + b.id).click(function(e) {
|
172
182
|
e.stopPropagation();
|
173
|
-
that.edit_block(b.id);
|
183
|
+
that.parent_controller.edit_block(b.id);
|
174
184
|
});
|
175
|
-
if (b.allow_child_blocks == true)
|
176
|
-
{
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
}
|
185
|
+
//if (b.allow_child_blocks == true)
|
186
|
+
//{
|
187
|
+
// $('#new_block_' + b.id).replaceWith($('<input/>')
|
188
|
+
// .attr('type', 'button')
|
189
|
+
// .val('New Block')
|
190
|
+
// .click(function(e) { e.stopPropagation(); that.new_block(b.id);
|
191
|
+
// })
|
192
|
+
// );
|
193
|
+
//}
|
184
194
|
var show_mouseover = true;
|
185
195
|
if (b.children && b.children.length > 0)
|
186
196
|
{
|
187
197
|
$.each(b.children, function(i, b2) {
|
188
198
|
if (b2.block_type_id = 34)
|
189
199
|
show_mouseover = false;
|
190
|
-
that.
|
200
|
+
that.set_clickable(b2);
|
191
201
|
});
|
192
202
|
}
|
193
203
|
if (show_mouseover)
|
194
204
|
{
|
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'); });
|
205
|
+
$('#the_modal #block_' + b.id).mouseover(function(el) { $('#the_modal #block_' + b.id).addClass( 'block_over'); });
|
206
|
+
$('#the_modal #block_' + b.id).mouseout(function(el) { $('#the_modal #block_' + b.id).removeClass('block_over'); });
|
197
207
|
}
|
198
208
|
},
|
199
209
|
|
200
210
|
/****************************************************************************/
|
201
211
|
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
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
|
-
//},
|
212
|
+
set_editable: function()
|
213
|
+
{
|
214
|
+
var that = this;
|
215
|
+
that.set_block_value_editable(that.block);
|
216
|
+
$.each(that.block.children, function(i, b) {
|
217
|
+
that.set_block_value_editable(b);
|
218
|
+
});
|
219
|
+
},
|
239
220
|
|
240
221
|
set_block_value_editable: function(b)
|
241
|
-
{
|
222
|
+
{
|
242
223
|
var that = this;
|
243
|
-
var bt = b.block_type;
|
244
|
-
if (
|
245
|
-
return;
|
246
|
-
|
224
|
+
var bt = b.block_type;
|
225
|
+
if (bt.field_type == 'block' || bt.field_type == 'richtext')
|
226
|
+
return;
|
247
227
|
var h = {
|
248
228
|
name: 'value',
|
249
229
|
type: bt.field_type,
|
250
230
|
nice_name: bt.description ? bt.description : bt.name,
|
251
231
|
width: bt.width ? bt.width : 780,
|
252
|
-
after_update: function() {
|
253
|
-
after_cancel: function() {
|
232
|
+
after_update: function() { that.parent_controller.render_blocks(); },
|
233
|
+
after_cancel: function() { that.parent_controller.render_blocks(); }
|
254
234
|
};
|
255
235
|
h['value'] = b.value
|
256
236
|
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.
|
237
|
+
//if (bt.field_type == 'image') h['value'] = b.image.tiny_url;
|
238
|
+
//if (bt.field_type == 'file') h['value'] = b.file.url;
|
259
239
|
if (bt.field_type == 'select') h['text'] = b.value;
|
260
240
|
if (bt.height) h['height'] = bt.height;
|
261
241
|
if (bt.fixed_placeholder) h['fixed_placeholder'] = bt.fixed_placeholder;
|
@@ -276,67 +256,8 @@ function keep_modal_autosized()
|
|
276
256
|
attributes: [h]
|
277
257
|
});
|
278
258
|
},
|
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
259
|
|
297
|
-
|
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
|
-
},
|
260
|
+
/****************************************************************************/
|
340
261
|
|
341
262
|
delete_block: function(confirm)
|
342
263
|
{
|
@@ -346,20 +267,20 @@ function keep_modal_autosized()
|
|
346
267
|
var p = $('<p/>').addClass('note warning')
|
347
268
|
.append("Are you sure you want to delete the block? This can't be undone.<br />")
|
348
269
|
.append($('<input/>').attr('type','button').val('Yes').click(function() { that.delete_block(true); })).append(' ')
|
349
|
-
.append($('<input/>').attr('type','button').val('No').click(function() { $('#
|
350
|
-
|
270
|
+
.append($('<input/>').attr('type','button').val('No').click(function() { $('#modal_message').empty(); that.autosize(); }));
|
271
|
+
that.autosize(p);
|
351
272
|
return;
|
352
273
|
}
|
353
|
-
|
274
|
+
that.autosize("<p class='loading'>Deleting block...</p>");
|
354
275
|
$.ajax({
|
355
276
|
url: that.block_url(that.block),
|
356
277
|
type: 'delete',
|
357
278
|
success: function(resp) {
|
358
|
-
if (resp.error)
|
279
|
+
if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
|
359
280
|
if (resp.redirect)
|
360
281
|
{
|
361
|
-
|
362
|
-
|
282
|
+
that.close();
|
283
|
+
that.parent_controller.render_blocks();
|
363
284
|
}
|
364
285
|
}
|
365
286
|
});
|
@@ -368,16 +289,16 @@ function keep_modal_autosized()
|
|
368
289
|
move_up: function()
|
369
290
|
{
|
370
291
|
var that = this;
|
371
|
-
|
292
|
+
that.autosize("<p class='loading'>Moving up...</p>");
|
372
293
|
$.ajax({
|
373
294
|
url: that.block_url(that.block) + '/move-up',
|
374
295
|
type: 'put',
|
375
296
|
success: function(resp) {
|
376
|
-
if (resp.error)
|
297
|
+
if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
|
377
298
|
if (resp.success)
|
378
299
|
{
|
379
|
-
|
380
|
-
|
300
|
+
that.autosize("<p class='note success'>" + resp.success + "</p>");
|
301
|
+
that.parent_controller.render_blocks();
|
381
302
|
}
|
382
303
|
}
|
383
304
|
});
|
@@ -386,18 +307,19 @@ function keep_modal_autosized()
|
|
386
307
|
move_down: function()
|
387
308
|
{
|
388
309
|
var that = this;
|
389
|
-
|
310
|
+
that.autosize("<p class='loading'>Moving down...</p>");
|
390
311
|
$.ajax({
|
391
312
|
url: that.block_url(that.block) + '/move-down',
|
392
313
|
type: 'put',
|
393
314
|
success: function(resp) {
|
394
|
-
if (resp.error)
|
315
|
+
if (resp.error) that.autosize("<p class='note error'>" + resp.error + "</p>");
|
395
316
|
if (resp.success)
|
396
317
|
{
|
397
|
-
|
398
|
-
|
318
|
+
that.autosize("<p class='note success'>" + resp.success + "</p>");
|
319
|
+
that.parent_controller.render_blocks();
|
399
320
|
}
|
400
321
|
}
|
401
322
|
});
|
402
323
|
}
|
403
|
-
|
324
|
+
|
325
|
+
});
|