Closes #193 - inline components work

This commit is contained in:
James Brooks
2015-01-01 14:09:14 +00:00
parent fa6bbd52fd
commit 47a3702c98
4 changed files with 87 additions and 67 deletions
+24 -22
View File
@@ -71,29 +71,31 @@ $(function() {
// Sortable components. // Sortable components.
var componentList = document.getElementById("component-list"); var componentList = document.getElementById("component-list");
new Sortable(componentList, { if (componentList) {
group: "omega", new Sortable(componentList, {
handle: ".drag-handle", group: "omega",
onUpdate: function() { handle: ".drag-handle",
// Loop each component, setting the order input to the new order. onUpdate: function() {
var $components = $('#component-list .striped-list-item'); // Loop each component, setting the order input to the new order.
$.each($components, function(id) { var $components = $('#component-list .striped-list-item');
// Order should start from 1 now. $.each($components, function(id) {
$(this).find('input[rel=order]').val(id + 1); // Order should start from 1 now.
}); $(this).find('input[rel=order]').val(id + 1);
});
// Now POST the form to the internal API. // Now POST the form to the internal API.
$.ajax({ $.ajax({
async: true, async: true,
url: '/dashboard/api/components/order', url: '/dashboard/api/components/order',
type: 'POST', type: 'POST',
data: $('form[name=componentList]').serializeObject(), data: $('form[name=componentList]').serializeObject(),
success: function() { success: function() {
(new CachetHQ.Notifier).notify('Components updated.', 'success'); (new CachetHQ.Notifier).notify('Components updated.', 'success');
} }
}); });
} }
}); });
}
// Toggle inline component statuses. // Toggle inline component statuses.
$('form.component-inline').on('click', 'input[type=radio]', function() { $('form.component-inline').on('click', 'input[type=radio]', function() {
@@ -12433,29 +12433,31 @@ $(function() {
// Sortable components. // Sortable components.
var componentList = document.getElementById("component-list"); var componentList = document.getElementById("component-list");
new Sortable(componentList, { if (componentList) {
group: "omega", new Sortable(componentList, {
handle: ".drag-handle", group: "omega",
onUpdate: function() { handle: ".drag-handle",
// Loop each component, setting the order input to the new order. onUpdate: function() {
var $components = $('#component-list .striped-list-item'); // Loop each component, setting the order input to the new order.
$.each($components, function(id) { var $components = $('#component-list .striped-list-item');
// Order should start from 1 now. $.each($components, function(id) {
$(this).find('input[rel=order]').val(id + 1); // Order should start from 1 now.
}); $(this).find('input[rel=order]').val(id + 1);
});
// Now POST the form to the internal API. // Now POST the form to the internal API.
$.ajax({ $.ajax({
async: true, async: true,
url: '/dashboard/api/components/order', url: '/dashboard/api/components/order',
type: 'POST', type: 'POST',
data: $('form[name=componentList]').serializeObject(), data: $('form[name=componentList]').serializeObject(),
success: function() { success: function() {
(new CachetHQ.Notifier).notify('Components updated.', 'success'); (new CachetHQ.Notifier).notify('Components updated.', 'success');
} }
}); });
} }
}); });
}
// Toggle inline component statuses. // Toggle inline component statuses.
$('form.component-inline').on('click', 'input[type=radio]', function() { $('form.component-inline').on('click', 'input[type=radio]', function() {
@@ -12475,4 +12477,11 @@ $(function() {
} }
}); });
}); });
// Banner removal JS
$('#remove-banner').click(function(){
$('#banner-view').remove();
$('input[name=remove_banner]').val('1');
$('#settings-form').submit();
});
}); });
+31 -22
View File
@@ -12433,29 +12433,31 @@ $(function() {
// Sortable components. // Sortable components.
var componentList = document.getElementById("component-list"); var componentList = document.getElementById("component-list");
new Sortable(componentList, { if (componentList) {
group: "omega", new Sortable(componentList, {
handle: ".drag-handle", group: "omega",
onUpdate: function() { handle: ".drag-handle",
// Loop each component, setting the order input to the new order. onUpdate: function() {
var $components = $('#component-list .striped-list-item'); // Loop each component, setting the order input to the new order.
$.each($components, function(id) { var $components = $('#component-list .striped-list-item');
// Order should start from 1 now. $.each($components, function(id) {
$(this).find('input[rel=order]').val(id + 1); // Order should start from 1 now.
}); $(this).find('input[rel=order]').val(id + 1);
});
// Now POST the form to the internal API. // Now POST the form to the internal API.
$.ajax({ $.ajax({
async: true, async: true,
url: '/dashboard/api/components/order', url: '/dashboard/api/components/order',
type: 'POST', type: 'POST',
data: $('form[name=componentList]').serializeObject(), data: $('form[name=componentList]').serializeObject(),
success: function() { success: function() {
(new CachetHQ.Notifier).notify('Components updated.', 'success'); (new CachetHQ.Notifier).notify('Components updated.', 'success');
} }
}); });
} }
}); });
}
// Toggle inline component statuses. // Toggle inline component statuses.
$('form.component-inline').on('click', 'input[type=radio]', function() { $('form.component-inline').on('click', 'input[type=radio]', function() {
@@ -12475,4 +12477,11 @@ $(function() {
} }
}); });
}); });
// Banner removal JS
$('#remove-banner').click(function(){
$('#banner-view').remove();
$('input[name=remove_banner]').val('1');
$('#settings-form').submit();
});
}); });
+1 -1
View File
@@ -1,4 +1,4 @@
{ {
"css/all.css": "css/all-c5b65085.css", "css/all.css": "css/all-c5b65085.css",
"js/all.js": "js/all-337c2216.js" "js/all.js": "js/all-215df44c.js"
} }