2009-11-01 18:15:59 +00:00
|
|
|
var Storyline = {};
|
2009-11-13 12:51:40 +00:00
|
|
|
var ComicImageTypes = {};
|
2010-01-31 21:40:27 +00:00
|
|
|
var CategoryGroupings = {};
|
2009-11-01 18:15:59 +00:00
|
|
|
|
2009-11-13 12:51:40 +00:00
|
|
|
(function() {
|
|
|
|
Storyline.get_order = function() {
|
2009-11-13 19:45:28 +00:00
|
|
|
var order = [];
|
2009-11-13 12:51:40 +00:00
|
|
|
$$('#storyline-sorter .cp-category-info').each(function(info) {
|
2009-11-13 19:45:28 +00:00
|
|
|
var matches = info.id.match(/category_([0-9\-]+)/);
|
|
|
|
if (matches) { order.push(matches[1].replace(/\-/g,'/')); }
|
2009-11-13 12:51:40 +00:00
|
|
|
});
|
|
|
|
$$('input[name*=storyline_order]').pop().value = order.join(',');
|
|
|
|
};
|
2009-11-01 18:15:59 +00:00
|
|
|
|
2009-11-13 12:51:40 +00:00
|
|
|
Storyline.setup = function() {
|
|
|
|
var i = 0;
|
|
|
|
var depths = {};
|
|
|
|
$$('.cp-children').each(function(ch) {
|
|
|
|
ch.id = 'children-' + i;
|
|
|
|
var depth = ch.ancestors().length;
|
|
|
|
if (!depths[depth]) { depths[depth] = []; }
|
|
|
|
depths[depth].push(ch);
|
|
|
|
++i;
|
|
|
|
});
|
2009-11-01 18:15:59 +00:00
|
|
|
|
2009-11-13 12:51:40 +00:00
|
|
|
depths = $H(depths);
|
2009-11-03 03:21:53 +00:00
|
|
|
|
2009-11-13 12:51:40 +00:00
|
|
|
depths.keys().sort(function(a,b) { return b - a; }).each(function(depth) {
|
|
|
|
depths.get(depth).each(function(ch) {
|
|
|
|
Sortable.create(ch.id, {
|
|
|
|
tag: 'div',
|
|
|
|
handle: 'span',
|
|
|
|
onUpdate: Storyline.get_order
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2009-11-13 19:45:28 +00:00
|
|
|
|
|
|
|
Storyline.get_order();
|
|
|
|
};
|
|
|
|
|
|
|
|
ComicImageTypes.setup_checkboxes = function() {
|
|
|
|
var checkboxes = $$('input[name*=default][name*=image_types]');
|
|
|
|
checkboxes.each(function(c) {
|
|
|
|
c.stopObserving('change');
|
|
|
|
c.observe('change', function(e) {
|
|
|
|
checkboxes.each(function(ch) {
|
|
|
|
if (e.target != ch) { ch.checked = false; }
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2009-11-13 12:51:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ComicImageTypes.setup = function() {
|
|
|
|
$$('.image-type-holder').each(function(ith) {
|
|
|
|
var closer = ith.select('.delete-image-type').pop();
|
|
|
|
if (closer) {
|
|
|
|
closer.observe('click', function(e) {
|
|
|
|
Event.stop(e);
|
2009-11-13 19:45:28 +00:00
|
|
|
if (confirm('Are you sure? Your templates may break after deleting this image type.')) {
|
2009-11-13 12:51:40 +00:00
|
|
|
new Effect.Fade(ith, {
|
|
|
|
from: 1,
|
|
|
|
to: 0,
|
|
|
|
afterFinish: function() {
|
|
|
|
ith.parentNode.removeChild(ith);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2009-11-13 19:45:28 +00:00
|
|
|
ComicImageTypes.setup_checkboxes();
|
2009-11-13 12:51:40 +00:00
|
|
|
|
|
|
|
$('add-new-image-type').observe('click', function(e) {
|
|
|
|
Event.stop(e);
|
|
|
|
new Ajax.Updater('image-type-container', ComicPressAdmin.ajax_uri, {
|
|
|
|
method: 'get',
|
|
|
|
parameters: {
|
|
|
|
'cp[_nonce]': ComicPressAdmin.nonce,
|
2010-01-31 21:40:27 +00:00
|
|
|
'cp[action]': 'get-new-image-type-editor',
|
|
|
|
'cp[_action_nonce]': ComicPressAdmin.image_type_editor_nonce
|
2009-11-13 12:51:40 +00:00
|
|
|
},
|
2009-11-13 19:45:28 +00:00
|
|
|
insertion: 'bottom',
|
|
|
|
onComplete: function() {
|
|
|
|
ComicImageTypes.setup_checkboxes();
|
|
|
|
}
|
2009-11-13 12:51:40 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
2010-01-31 21:40:27 +00:00
|
|
|
|
|
|
|
CategoryGroupings.highlight_child_levels = function(e) {
|
2010-02-06 00:49:09 +00:00
|
|
|
(function($) {
|
|
|
|
$('.category-group-holder input[type=checkbox]').attr('disabled', false);
|
2010-01-31 21:40:27 +00:00
|
|
|
|
2010-02-06 00:49:09 +00:00
|
|
|
$('.category-group-holder li')
|
|
|
|
.removeClass('selected')
|
|
|
|
.each(function() {
|
|
|
|
if ($(this).find('input[type=checkbox]:first').is('*:checked')) {
|
|
|
|
$(this).addClass('selected').find('input[type=checkbox]').not("*:first").attr('disabled', true);
|
|
|
|
}
|
|
|
|
});
|
2010-01-31 21:40:27 +00:00
|
|
|
|
2010-02-06 00:49:09 +00:00
|
|
|
$('.category-group-holder').each(function() {
|
|
|
|
$(this).find('.empty-group-warning')[($(this).find('input:checked').length == 0) ? 'show' : 'hide'](250);
|
2010-01-31 21:40:27 +00:00
|
|
|
});
|
2010-02-06 00:49:09 +00:00
|
|
|
}(jQuery))
|
2010-01-31 21:40:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CategoryGroupings.setup_editors = function() {
|
2010-02-06 00:49:09 +00:00
|
|
|
(function($) {
|
|
|
|
$('.category-group-holder input[type=checkbox], .category-group-holder label')
|
|
|
|
.unbind('click')
|
|
|
|
.click(CategoryGroupings.highlight_child_levels);
|
|
|
|
}(jQuery))
|
2010-01-31 21:40:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CategoryGroupings.setup = function() {
|
|
|
|
CategoryGroupings.setup_editors();
|
|
|
|
CategoryGroupings.highlight_child_levels();
|
|
|
|
|
2010-02-06 00:49:09 +00:00
|
|
|
(function($) {
|
|
|
|
$('#add-new-category-group').click(function() {
|
|
|
|
$.post(
|
|
|
|
ComicPressAdmin.ajax_uri,
|
|
|
|
{
|
|
|
|
'cp[_nonce]': ComicPressAdmin.nonce,
|
|
|
|
'cp[action]': 'get-new-category-group-editor',
|
|
|
|
'cp[_action_nonce]': ComicPressAdmin.category_group_editor_nonce
|
|
|
|
},
|
|
|
|
function(data) {
|
|
|
|
$('#category-groups-holder').append(data);
|
|
|
|
CategoryGroupings.setup_editors();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
return false;
|
2010-01-31 21:40:27 +00:00
|
|
|
});
|
2010-02-06 00:49:09 +00:00
|
|
|
}(jQuery));
|
2010-01-31 21:40:27 +00:00
|
|
|
}
|
2009-11-13 12:51:40 +00:00
|
|
|
}())
|